Secure SOAP APIs to support third party patient portals. Contributed
[openemr.git] / interface / patient_file / summary / demographics.php
blobf2912f29af2e3925eba01e1230e7571e70a7aa7c
1 <?php
2 // This program is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU General Public License
4 // as published by the Free Software Foundation; either version 2
5 // of the License, or (at your option) any later version.
7 //SANITIZE ALL ESCAPES
8 $sanitize_all_escapes=true;
9 //
11 //STOP FAKE REGISTER GLOBALS
12 $fake_register_globals=false;
15 require_once("../../globals.php");
16 require_once("$srcdir/patient.inc");
17 require_once("$srcdir/acl.inc");
18 require_once("$srcdir/classes/Address.class.php");
19 require_once("$srcdir/classes/InsuranceCompany.class.php");
20 require_once("$srcdir/classes/Document.class.php");
21 require_once("$srcdir/options.inc.php");
22 require_once("../history/history.inc.php");
23 require_once("$srcdir/formatting.inc.php");
24 require_once("$srcdir/edi.inc");
25 require_once("$srcdir/clinical_rules.php");
27 if ($GLOBALS['concurrent_layout'] && $_GET['set_pid']) {
28 include_once("$srcdir/pid.inc");
29 setpid($_GET['set_pid']);
32 $active_reminders = false;
33 if (($_SESSION['alert_notify_pid'] != $pid) && $_GET['set_pid'] && acl_check('patients', 'med') && $GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crp']) {
34 // showing a new patient, so check for active reminders
35 $active_reminders = active_alert_summary($pid,"reminders-due");
38 function print_as_money($money) {
39 preg_match("/(\d*)\.?(\d*)/",$money,$moneymatches);
40 $tmp = wordwrap(strrev($moneymatches[1]),3,",",1);
41 $ccheck = strrev($tmp);
42 if ($ccheck[0] == ",") {
43 $tmp = substr($ccheck,1,strlen($ccheck)-1);
45 if ($moneymatches[2] != "") {
46 return "$ " . strrev($tmp) . "." . $moneymatches[2];
47 } else {
48 return "$ " . strrev($tmp);
52 // get an array from Photos category
53 function pic_array($pid,$picture_directory) {
54 $pics = array();
55 $sql_query = "select documents.id from documents join categories_to_documents " .
56 "on documents.id = categories_to_documents.document_id " .
57 "join categories on categories.id = categories_to_documents.category_id " .
58 "where categories.name like ? and documents.foreign_id = ?";
59 if ($query = sqlStatement($sql_query, array($picture_directory,$pid))) {
60 while( $results = sqlFetchArray($query) ) {
61 array_push($pics,$results['id']);
64 return ($pics);
66 // Get the document ID of the first document in a specific catg.
67 function get_document_by_catg($pid,$doc_catg) {
69 $result = array();
71 if ($pid and $doc_catg) {
72 $result = sqlQuery("SELECT d.id, d.date, d.url FROM " .
73 "documents AS d, categories_to_documents AS cd, categories AS c " .
74 "WHERE d.foreign_id = ? " .
75 "AND cd.document_id = d.id " .
76 "AND c.id = cd.category_id " .
77 "AND c.name LIKE ? " .
78 "ORDER BY d.date DESC LIMIT 1", array($pid, $doc_catg) );
81 return($result['id']);
84 // Display image in 'widget style'
85 function image_widget($doc_id,$doc_catg)
87 global $pid, $web_root;
88 $docobj = new Document($doc_id);
89 $image_file = $docobj->get_url_file();
90 $extension = substr($image_file, strrpos($image_file,"."));
91 $viewable_types = array('.png','.jpg','.jpeg','.png','.bmp'); // image ext supported by fancybox viewer
92 if ( in_array($extension,$viewable_types) ) { // extention matches list
93 $to_url = "<td> <a href = $web_root" .
94 "/controller.php?document&retrieve&patient_id=$pid&document_id=$doc_id" .
95 "/tmp$extension" . // Force image type URL for fancybox
96 " onclick=top.restoreSession(); class='image_modal'>" .
97 " <img src = $web_root" .
98 "/controller.php?document&retrieve&patient_id=$pid&document_id=$doc_id" .
99 " width=100 alt='$doc_catg:$image_file'> </a> </td> <td valign='center'>".
100 htmlspecialchars($doc_catg) . '<br />&nbsp;' . htmlspecialchars($image_file) .
101 "</td>";
103 else {
104 $to_url = "<td> <a href='" . $web_root . "/controller.php?document&retrieve" .
105 "&patient_id=$pid&document_id=$doc_id'" .
106 " onclick='top.restoreSession()' class='css_button_small'>" .
107 "<span>" .
108 htmlspecialchars( xl("View"), ENT_QUOTES )."</a> &nbsp;" .
109 htmlspecialchars( "$doc_catg - $image_file", ENT_QUOTES ) .
110 "</span> </td>";
112 echo "<table><tr>";
113 echo $to_url;
114 echo "</tr></table>";
117 // Determine if the Vitals form is in use for this site.
118 $tmp = sqlQuery("SELECT count(*) AS count FROM registry WHERE " .
119 "directory = 'vitals' AND state = 1");
120 $vitals_is_registered = $tmp['count'];
122 <html>
124 <head>
125 <?php html_header_show();?>
126 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
127 <link rel="stylesheet" type="text/css" href="../../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
128 <style type="text/css">@import url(../../../library/dynarch_calendar.css);</style>
129 <script type="text/javascript" src="../../../library/textformat.js"></script>
130 <script type="text/javascript" src="../../../library/dynarch_calendar.js"></script>
131 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
132 <script type="text/javascript" src="../../../library/dynarch_calendar_setup.js"></script>
133 <script type="text/javascript" src="../../../library/dialog.js"></script>
134 <script type="text/javascript" src="../../../library/js/jquery.1.3.2.js"></script>
135 <script type="text/javascript" src="../../../library/js/common.js"></script>
136 <script type="text/javascript" src="../../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
137 <script type="text/javascript" language="JavaScript">
138 //Visolve - sync the radio buttons - Start
139 if((top.window.parent) && (parent.window)){
140 var wname = top.window.parent.left_nav;
141 wname.syncRadios();
142 wname.setRadio(parent.window.name, "dem");
144 //Visolve - sync the radio buttons - End
146 var mypcc = '<?php echo htmlspecialchars($GLOBALS['phone_country_code'],ENT_QUOTES); ?>';
148 function oldEvt(eventid) {
149 dlgopen('../../main/calendar/add_edit_event.php?eid=' + eventid, '_blank', 550, 270);
152 function advdirconfigure() {
153 dlgopen('advancedirectives.php', '_blank', 500, 450);
156 function refreshme() {
157 top.restoreSession();
158 location.reload();
161 // Process click on Delete link.
162 function deleteme() {
163 dlgopen('../deleter.php?patient=<?php echo htmlspecialchars($pid,ENT_QUOTES); ?>', '_blank', 500, 450);
164 return false;
167 // Called by the deleteme.php window on a successful delete.
168 function imdeleted() {
169 <?php if ($GLOBALS['concurrent_layout']) { ?>
170 parent.left_nav.clearPatient();
171 <?php } else { ?>
172 top.restoreSession();
173 top.location.href = '../main/main_screen.php';
174 <?php } ?>
177 function validate() {
178 var f = document.forms[0];
179 <?php
180 if ($GLOBALS['athletic_team']) {
181 echo " if (f.form_userdate1.value != f.form_original_userdate1.value) {\n";
182 $irow = sqlQuery("SELECT id, title FROM lists WHERE " .
183 "pid = ? AND enddate IS NULL ORDER BY begdate DESC LIMIT 1", array($pid));
184 if (!empty($irow)) {
186 if (confirm('Do you wish to also set this new return date in the issue titled "<?php echo htmlspecialchars($irow['title'],ENT_QUOTES); ?>"?')) {
187 f.form_issue_id.value = '<?php echo htmlspecialchars($irow['id'],ENT_QUOTES); ?>';
188 } else {
189 alert('OK, you will need to manually update the return date in any affected issue(s).');
191 <?php } else { ?>
192 alert('You have changed the return date but there are no open issues. You probably need to create or modify one.');
193 <?php
194 } // end empty $irow
195 echo " }\n";
196 } // end athletic team
198 return true;
201 function newEvt() {
202 dlgopen('../../main/calendar/add_edit_event.php?patientid=<?php echo htmlspecialchars($pid,ENT_QUOTES); ?>', '_blank', 550, 270);
203 return false;
206 function sendimage(pid, what) {
207 // alert('Not yet implemented.'); return false;
208 dlgopen('../upload_dialog.php?patientid=' + pid + '&file=' + what,
209 '_blank', 500, 400);
210 return false;
213 </script>
215 <script type="text/javascript">
217 function toggleIndicator(target,div) {
219 $mode = $(target).find(".indicator").text();
220 if ( $mode == "<?php echo htmlspecialchars(xl('collapse'),ENT_QUOTES); ?>" ) {
221 $(target).find(".indicator").text( "<?php echo htmlspecialchars(xl('expand'),ENT_QUOTES); ?>" );
222 $("#"+div).hide();
223 $.post( "../../../library/ajax/user_settings.php", { target: div, mode: 0 });
224 } else {
225 $(target).find(".indicator").text( "<?php echo htmlspecialchars(xl('collapse'),ENT_QUOTES); ?>" );
226 $("#"+div).show();
227 $.post( "../../../library/ajax/user_settings.php", { target: div, mode: 1 });
231 $(document).ready(function(){
232 <?php
233 if($GLOBALS['erx_enable']){
234 //$soap_status=sqlQuery("select soap_import_status from patient_data where pid=?",array($pid));
235 $soap_status=sqlStatement("select soap_import_status,pid from patient_data where soap_import_status in ('1','3')");
236 while($row_soapstatus=sqlFetchArray($soap_status)){
237 //if($soap_status['soap_import_status']=='1' || $soap_status['soap_import_status']=='3'){ ?>
238 top.restoreSession();
239 $.ajax({
240 type: "POST",
241 url: "../../soap_functions/soap_patientfullmedication.php",
242 dataType: "html",
243 data: {
244 patient:<?php echo $row_soapstatus['pid']; ?>,
246 async: false,
247 success: function(thedata){
248 alert(thedata);
250 error:function(){
251 alert('ajax error');
254 <?php
255 //}
256 //elseif($soap_status['soap_import_status']=='3'){ ?>
257 top.restoreSession();
258 $.ajax({
259 type: "POST",
260 url: "../../soap_functions/soap_allergy.php",
261 dataType: "html",
262 data: {
263 patient:<?php echo $row_soapstatus['pid']; ?>,
265 async: false,
266 success: function(thedata){
267 alert(thedata);
269 error:function(){
270 alert('ajax error');
273 <?php
274 //}
278 // load divs
279 $("#stats_div").load("stats.php", { 'embeddedScreen' : true }, function() {
280 // (note need to place javascript code here also to get the dynamic link to work)
281 $(".rx_modal").fancybox( {
282 'overlayOpacity' : 0.0,
283 'showCloseButton' : true,
284 'frameHeight' : 500,
285 'frameWidth' : 800,
286 'centerOnScroll' : false,
287 'callbackOnClose' : function() {
288 refreshme();
292 $("#pnotes_ps_expand").load("pnotes_fragment.php");
293 $("#disclosures_ps_expand").load("disc_fragment.php");
295 <?php if ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crw']) { ?>
296 top.restoreSession();
297 $("#clinical_reminders_ps_expand").load("clinical_reminders_fragment.php", { 'embeddedScreen' : true }, function() {
298 // (note need to place javascript code here also to get the dynamic link to work)
299 $(".medium_modal").fancybox( {
300 'overlayOpacity' : 0.0,
301 'showCloseButton' : true,
302 'frameHeight' : 500,
303 'frameWidth' : 800,
304 'centerOnScroll' : false,
305 'callbackOnClose' : function() {
306 refreshme();
310 <?php } // end crw?>
312 <?php if ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_prw']) { ?>
313 top.restoreSession();
314 $("#patient_reminders_ps_expand").load("patient_reminders_fragment.php");
315 <?php } // end prw?>
317 <?php if ($vitals_is_registered) { ?>
318 // Initialize the Vitals form if it is registered.
319 $("#vitals_ps_expand").load("vitals_fragment.php");
320 <?php } ?>
322 <?php
323 // Initialize for each applicable LBF form.
324 $gfres = sqlStatement("SELECT option_id FROM list_options WHERE " .
325 "list_id = 'lbfnames' AND option_value > 0 ORDER BY seq, title");
326 while($gfrow = sqlFetchArray($gfres)) {
328 $("#<?php echo $gfrow['option_id']; ?>_ps_expand").load("lbf_fragment.php?formname=<?php echo $gfrow['option_id']; ?>");
329 <?php
333 // fancy box
334 enable_modals();
336 tabbify();
338 // modal for dialog boxes
339 $(".large_modal").fancybox( {
340 'overlayOpacity' : 0.0,
341 'showCloseButton' : true,
342 'frameHeight' : 600,
343 'frameWidth' : 1000,
344 'centerOnScroll' : false
347 // modal for image viewer
348 $(".image_modal").fancybox( {
349 'overlayOpacity' : 0.0,
350 'showCloseButton' : true,
351 'centerOnScroll' : false,
352 'autoscale' : true
355 $(".iframe1").fancybox( {
356 'left':10,
357 'overlayOpacity' : 0.0,
358 'showCloseButton' : true,
359 'frameHeight' : 300,
360 'frameWidth' : 350
362 // special size for patient portal
363 $(".small_modal").fancybox( {
364 'overlayOpacity' : 0.0,
365 'showCloseButton' : true,
366 'frameHeight' : 180,
367 'frameWidth' : 380,
368 'centerOnScroll' : false
371 <?php if ($active_reminders) { ?>
372 // show the active reminder modal
373 $("#reminder_popup_link").fancybox({
374 'overlayOpacity' : 0.0,
375 'showCloseButton' : true,
376 'frameHeight' : 500,
377 'frameWidth' : 500,
378 'centerOnScroll' : false
379 }).trigger('click');
380 <?php } ?>
384 </script>
386 <style type="css/text">
387 #pnotes_ps_expand {
388 height:auto;
389 width:100%;
391 </style>
393 </head>
395 <body class="body_top">
397 <a href='../reminder/active_reminder_popup.php' id='reminder_popup_link' style='visibility: false;' class='iframe' onclick='top.restoreSession()'></a>
399 <?php
400 $result = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
401 $result2 = getEmployerData($pid);
402 $result3 = getInsuranceData($pid, "primary", "copay, provider, DATE_FORMAT(`date`,'%Y-%m-%d') as effdate");
403 $insco_name = "";
405 if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
406 $insco_name = getInsuranceProvider($result3['provider']);
409 $thisauth = acl_check('patients', 'demo');
410 if ($thisauth) {
411 if ($result['squad'] && ! acl_check('squads', $result['squad']))
412 $thisauth = 0;
415 if (!$thisauth) {
416 echo "<p>(" . htmlspecialchars(xl('Demographics not authorized'),ENT_NOQUOTES) . ")</p>\n";
417 echo "</body>\n</html>\n";
418 exit();
421 if ($thisauth == 'write') {
422 echo "<table><tr><td><span class='title'>" .
423 htmlspecialchars(getPatientName($pid),ENT_NOQUOTES) .
424 "</span></td>";
426 if (acl_check('admin', 'super')) {
427 echo "<td style='padding-left:1em;'><a class='css_button iframe' href='../deleter.php?patient=" .
428 htmlspecialchars($pid,ENT_QUOTES) . "'>" .
429 "<span>".htmlspecialchars(xl('Delete'),ENT_NOQUOTES).
430 "</span></a></td>";
432 if($GLOBALS['erx_enable']){
433 echo '<td style="padding-left:1em;"><a class="css_button" href="../../eRx.php?page=medentry" onclick="top.restoreSession()">';
434 echo "<span>".htmlspecialchars(xl('NewCrop MedEntry'),ENT_NOQUOTES)."</span></a></td>";
435 echo '<td style="padding-left:1em;"><a class="css_button iframe1" href="../../soap_functions/soap_accountStatusDetails.php" onclick="top.restoreSession()">';
436 echo "<span>".htmlspecialchars(xl('NewCrop Account Status'),ENT_NOQUOTES)."</span></a></td><td id='accountstatus'></td>";
438 //Patient Portal
439 $portalUserSetting = true; //flag to see if patient has authorized access to portal
440 if($GLOBALS['portal_onsite_enable'] && $GLOBALS['portal_onsite_address']){
441 $portalStatus = sqlQuery("SELECT allow_patient_portal FROM patient_data WHERE pid=?",array($pid));
442 if ($portalStatus['allow_patient_portal']=='YES') {
443 $portalLogin = sqlQuery("SELECT pid FROM `patient_access_onsite` WHERE `pid`=?", array($pid));
444 echo "<td style='padding-left:1em;'><a class='css_button iframe small_modal' href='create_portallogin.php?portalsite=on&patient=" . htmlspecialchars($pid,ENT_QUOTES) . "' onclick='top.restoreSession()'>";
445 if (empty($portalLogin)) {
446 echo "<span>".htmlspecialchars(xl('Create Onsite Portal Credentials'),ENT_NOQUOTES)."</span></a></td>";
448 else {
449 echo "<span>".htmlspecialchars(xl('Reset Onsite Portal Credentials'),ENT_NOQUOTES)."</span></a></td>";
452 else {
453 $portalUserSetting = false;
456 if($GLOBALS['portal_offsite_enable'] && $GLOBALS['portal_offsite_address']){
457 $portalStatus = sqlQuery("SELECT allow_patient_portal FROM patient_data WHERE pid=?",array($pid));
458 if ($portalStatus['allow_patient_portal']=='YES') {
459 $portalLogin = sqlQuery("SELECT pid FROM `patient_access_offsite` WHERE `pid`=?", array($pid));
460 echo "<td style='padding-left:1em;'><a class='css_button iframe small_modal' href='create_portallogin.php?portalsite=off&patient=" . htmlspecialchars($pid,ENT_QUOTES) . "' onclick='top.restoreSession()'>";
461 if (empty($portalLogin)) {
462 echo "<span>".htmlspecialchars(xl('Create Offsite Portal Credentials'),ENT_NOQUOTES)."</span></a></td>";
464 else {
465 echo "<span>".htmlspecialchars(xl('Reset Offsite Portal Credentials'),ENT_NOQUOTES)."</span></a></td>";
468 else {
469 $portalUserSetting = false;
472 if (!($portalUserSetting)) {
473 // Show that the patient has not authorized portal access
474 echo "<td style='padding-left:1em;'>" . htmlspecialchars( xl('Patient has not authorized the Patient Portal.'), ENT_NOQUOTES) . "</td>";
476 //Patient Portal
478 // If patient is deceased, then show this (along with the number of days patient has been deceased for)
479 $days_deceased = is_patient_deceased($pid);
480 if ($days_deceased) {
481 echo "<td style='padding-left:1em;font-weight:bold;color:red'>" . htmlspecialchars( xl('DECEASED') ,ENT_NOQUOTES) . " (" . htmlspecialchars($days_deceased,ENT_NOQUOTES) . " " . htmlspecialchars( xl('days ago') ,ENT_NOQUOTES) . ")</td>";
484 echo "</tr></table>";
487 // Get the document ID of the patient ID card if access to it is wanted here.
488 $idcard_doc_id = false;
489 if ($GLOBALS['patient_id_category_name']) {
490 $idcard_doc_id = get_document_by_catg($pid, $GLOBALS['patient_id_category_name']);
494 <table cellspacing='0' cellpadding='0' border='0'>
495 <tr>
496 <td class="small" colspan='4'>
497 <a href="../history/history.php" onclick='top.restoreSession()'>
498 <?php echo htmlspecialchars(xl('History'),ENT_NOQUOTES); ?></a>
500 <?php //note that we have temporarily removed report screen from the modal view ?>
501 <a href="../report/patient_report.php" onclick='top.restoreSession()'>
502 <?php echo htmlspecialchars(xl('Report'),ENT_NOQUOTES); ?></a>
504 <?php //note that we have temporarily removed document screen from the modal view ?>
505 <a href="../../../controller.php?document&list&patient_id=<?php echo $pid;?>" onclick='top.restoreSession()'>
506 <?php echo htmlspecialchars(xl('Documents'),ENT_NOQUOTES); ?></a>
508 <a href="../transaction/transactions.php" class='iframe large_modal' onclick='top.restoreSession()'>
509 <?php echo htmlspecialchars(xl('Transactions'),ENT_NOQUOTES); ?></a>
511 <a href="stats_full.php?active=all" onclick='top.restoreSession()'>
512 <?php echo htmlspecialchars(xl('Issues'),ENT_NOQUOTES); ?></a>
513 </td>
514 </tr>
515 </table> <!-- end header -->
517 <div style='margin-top:10px'> <!-- start main content div -->
518 <table border="0" cellspacing="0" cellpadding="0" width="100%">
519 <tr>
520 <td align="left" valign="top">
521 <!-- start left column div -->
522 <div style='float:left; margin-right:20px'>
523 <table cellspacing=0 cellpadding=0>
524 <tr<?php if ($GLOBALS['athletic_team']) echo " style='display:none;'"; ?>>
525 <td>
526 <?php
527 // Billing expand collapse widget
528 $widgetTitle = xl("Billing");
529 $widgetLabel = "billing";
530 $widgetButtonLabel = xl("Edit");
531 $widgetButtonLink = "return newEvt();";
532 $widgetButtonClass = "";
533 $linkMethod = "javascript";
534 $bodyClass = "notab";
535 $widgetAuth = false;
536 $fixedWidth = true;
537 if ($GLOBALS['force_billing_widget_open']) {
538 $forceExpandAlways = true;
540 else {
541 $forceExpandAlways = false;
543 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
544 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
545 $widgetAuth, $fixedWidth, $forceExpandAlways);
547 <br>
548 <?php
549 if ($GLOBALS['oer_config']['ws_accounting']['enabled']) {
550 // Show current balance and billing note, if any.
551 echo " <div style='margin-left: 10px; margin-right: 10px'>" .
552 "<span class='bold'><font color='#ee6600'>" .
553 htmlspecialchars(xl('Balance Due'),ENT_NOQUOTES) .
554 ": " . htmlspecialchars(oeFormatMoney(get_patient_balance($pid)),ENT_NOQUOTES) .
555 "</font></span><br>";
556 if ($result['genericname2'] == 'Billing') {
557 echo "<span class='bold'><font color='red'>" .
558 htmlspecialchars(xl('Billing Note'),ENT_NOQUOTES) . ":" .
559 htmlspecialchars($result['genericval2'],ENT_NOQUOTES) .
560 "</font></span><br>";
562 if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
563 echo "<span class='bold'>" .
564 htmlspecialchars(xl('Primary Insurance'),ENT_NOQUOTES) . ': ' . htmlspecialchars($insco_name,ENT_NOQUOTES) .
565 "</span>&nbsp;&nbsp;&nbsp;";
566 if ($result3['copay'] > 0) {
567 echo "<span class='bold'>" .
568 htmlspecialchars(xl('Copay'),ENT_NOQUOTES) . ': ' . htmlspecialchars($result3['copay'],ENT_NOQUOTES) .
569 "</span>&nbsp;&nbsp;&nbsp;";
571 echo "<span class='bold'>" .
572 htmlspecialchars(xl('Effective Date'),ENT_NOQUOTES) . ': ' . htmlspecialchars(oeFormatShortDate($result3['effdate'],ENT_NOQUOTES)) .
573 "</span>";
575 echo "</div><br>";
578 </div> <!-- required for expand_collapse_widget -->
579 </td>
580 </tr>
581 <tr>
582 <td>
583 <?php
584 // Demographics expand collapse widget
585 $widgetTitle = xl("Demographics");
586 $widgetLabel = "demographics";
587 $widgetButtonLabel = xl("Edit");
588 $widgetButtonLink = "demographics_full.php";
589 $widgetButtonClass = "";
590 $linkMethod = "html";
591 $bodyClass = "";
592 $widgetAuth = ($thisauth == "write");
593 $fixedWidth = true;
594 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
595 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
596 $widgetAuth, $fixedWidth);
598 <div id="DEM" >
599 <ul class="tabNav">
600 <?php display_layout_tabs('DEM', $result, $result2); ?>
601 </ul>
602 <div class="tabContainer">
603 <?php display_layout_tabs_data('DEM', $result, $result2); ?>
604 </div>
605 </div>
606 </div> <!-- required for expand_collapse_widget -->
607 </td>
608 </tr>
610 <tr>
611 <td>
612 <?php
613 $insurance_count = 0;
614 foreach (array('primary','secondary','tertiary') as $instype) {
615 $enddate = 'Present';
616 $query = "SELECT * FROM insurance_data WHERE " .
617 "pid = ? AND type = ? " .
618 "ORDER BY date DESC";
619 $res = sqlStatement($query, array($pid, $instype) );
620 while( $row = sqlFetchArray($res) ) {
621 if ($row['provider'] ) $insurance_count++;
625 if ( $insurance_count > 0 ) {
626 // Insurance expand collapse widget
627 $widgetTitle = xl("Insurance");
628 $widgetLabel = "insurance";
629 $widgetButtonLabel = xl("Edit");
630 $widgetButtonLink = "demographics_full.php";
631 $widgetButtonClass = "";
632 $linkMethod = "html";
633 $bodyClass = "";
634 $widgetAuth = ($thisauth == "write");
635 $fixedWidth = true;
636 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
637 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
638 $widgetAuth, $fixedWidth);
640 if ( $insurance_count > 0 ) {
643 <ul class="tabNav"><?php
644 ///////////////////////////////// INSURANCE SECTION
645 $first = true;
646 foreach (array('primary','secondary','tertiary') as $instype) {
648 $query = "SELECT * FROM insurance_data WHERE " .
649 "pid = ? AND type = ? " .
650 "ORDER BY date DESC";
651 $res = sqlStatement($query, array($pid, $instype) );
653 $enddate = 'Present';
655 while( $row = sqlFetchArray($res) ) {
656 if ($row['provider'] ) {
658 $ins_description = ucfirst($instype);
659 $ins_description = xl($ins_description);
660 $ins_description .= strcmp($enddate, 'Present') != 0 ? " (".xl('Old').")" : "";
662 <li <?php echo $first ? 'class="current"' : '' ?>><a href="/play/javascript-tabbed-navigation/">
663 <?php echo htmlspecialchars($ins_description,ENT_NOQUOTES); ?></a></li>
664 <?php
665 $first = false;
667 $enddate = $row['date'];
670 // Display the eligibility tab
671 echo "<li><a href='/play/javascript-tabbed-navigation/'>" .
672 htmlspecialchars( xl('Eligibility'), ENT_NOQUOTES) . "</a></li>";
674 ?></ul><?php
676 } ?>
678 <div class="tabContainer">
679 <?php
680 $first = true;
681 foreach (array('primary','secondary','tertiary') as $instype) {
682 $enddate = 'Present';
684 $query = "SELECT * FROM insurance_data WHERE " .
685 "pid = ? AND type = ? " .
686 "ORDER BY date DESC";
687 $res = sqlStatement($query, array($pid, $instype) );
688 while( $row = sqlFetchArray($res) ) {
689 if ($row['provider'] ) {
691 <div class="tab <?php echo $first ? 'current' : '' ?>">
692 <table border='0' cellpadding='0' width='100%'>
693 <?php
694 $icobj = new InsuranceCompany($row['provider']);
695 $adobj = $icobj->get_address();
696 $insco_name = trim($icobj->get_name());
698 <tr>
699 <td valign='top' colspan='3'>
700 <span class='text'>
701 <?php if (strcmp($enddate, 'Present') != 0) echo htmlspecialchars(xl("Old"),ENT_NOQUOTES)." "; ?>
702 <?php $tempinstype=ucfirst($instype); echo htmlspecialchars(xl($tempinstype.' Insurance'),ENT_NOQUOTES); ?>
703 <?php if (strcmp($row['date'], '0000-00-00') != 0) { ?>
704 <?php echo htmlspecialchars(xl('from','',' ',' ').$row['date'],ENT_NOQUOTES); ?>
705 <?php } ?>
706 <?php echo htmlspecialchars(xl('until','',' ',' '),ENT_NOQUOTES);
707 echo (strcmp($enddate, 'Present') != 0) ? $enddate : htmlspecialchars(xl('Present'),ENT_NOQUOTES); ?>:</span>
708 </td>
709 </tr>
710 <tr>
711 <td valign='top'>
712 <span class='text'>
713 <?php
714 if ($insco_name) {
715 echo htmlspecialchars($insco_name,ENT_NOQUOTES) . '<br>';
716 if (trim($adobj->get_line1())) {
717 echo htmlspecialchars($adobj->get_line1(),ENT_NOQUOTES) . '<br>';
718 echo htmlspecialchars($adobj->get_city() . ', ' . $adobj->get_state() . ' ' . $adobj->get_zip(),ENT_NOQUOTES);
720 } else {
721 echo "<font color='red'><b>".htmlspecialchars(xl('Unassigned'),ENT_NOQUOTES)."</b></font>";
724 <br>
725 <?php echo htmlspecialchars(xl('Policy Number'),ENT_NOQUOTES); ?>:
726 <?php echo htmlspecialchars($row['policy_number'],ENT_NOQUOTES) ?><br>
727 <?php echo htmlspecialchars(xl('Plan Name'),ENT_NOQUOTES); ?>:
728 <?php echo htmlspecialchars($row['plan_name'],ENT_NOQUOTES); ?><br>
729 <?php echo htmlspecialchars(xl('Group Number'),ENT_NOQUOTES); ?>:
730 <?php echo htmlspecialchars($row['group_number'],ENT_NOQUOTES); ?></span>
731 </td>
732 <td valign='top'>
733 <span class='bold'><?php echo htmlspecialchars(xl('Subscriber'),ENT_NOQUOTES); ?>: </span><br>
734 <span class='text'><?php echo htmlspecialchars($row['subscriber_fname'] . ' ' . $row['subscriber_mname'] . ' ' . $row['subscriber_lname'],ENT_NOQUOTES); ?>
735 <?php
736 if ($row['subscriber_relationship'] != "") {
737 echo "(" . htmlspecialchars($row['subscriber_relationship'],ENT_NOQUOTES) . ")";
740 <br>
741 <?php echo htmlspecialchars(xl('S.S.'),ENT_NOQUOTES); ?>:
742 <?php echo htmlspecialchars($row['subscriber_ss'],ENT_NOQUOTES); ?><br>
743 <?php echo htmlspecialchars(xl('D.O.B.'),ENT_NOQUOTES); ?>:
744 <?php if ($row['subscriber_DOB'] != "0000-00-00 00:00:00") echo htmlspecialchars($row['subscriber_DOB'],ENT_NOQUOTES); ?><br>
745 <?php echo htmlspecialchars(xl('Phone'),ENT_NOQUOTES); ?>:
746 <?php echo htmlspecialchars($row['subscriber_phone'],ENT_NOQUOTES); ?>
747 </span>
748 </td>
749 <td valign='top'>
750 <span class='bold'><?php echo htmlspecialchars(xl('Subscriber Address'),ENT_NOQUOTES); ?>: </span><br>
751 <span class='text'><?php echo htmlspecialchars($row['subscriber_street'],ENT_NOQUOTES); ?><br>
752 <?php echo htmlspecialchars($row['subscriber_city'],ENT_NOQUOTES); ?>
753 <?php if($row['subscriber_state'] != "") echo ", "; echo htmlspecialchars($row['subscriber_state'],ENT_NOQUOTES); ?>
754 <?php if($row['subscriber_country'] != "") echo ", "; echo htmlspecialchars($row['subscriber_country'],ENT_NOQUOTES); ?>
755 <?php echo " " . htmlspecialchars($row['subscriber_postal_code'],ENT_NOQUOTES); ?></span>
757 <?php if (trim($row['subscriber_employer'])) { ?>
758 <br><span class='bold'><?php echo htmlspecialchars(xl('Subscriber Employer'),ENT_NOQUOTES); ?>: </span><br>
759 <span class='text'><?php echo htmlspecialchars($row['subscriber_employer'],ENT_NOQUOTES); ?><br>
760 <?php echo htmlspecialchars($row['subscriber_employer_street'],ENT_NOQUOTES); ?><br>
761 <?php echo htmlspecialchars($row['subscriber_employer_city'],ENT_NOQUOTES); ?>
762 <?php if($row['subscriber_employer_city'] != "") echo ", "; echo htmlspecialchars($row['subscriber_employer_state'],ENT_NOQUOTES); ?>
763 <?php if($row['subscriber_employer_country'] != "") echo ", "; echo htmlspecialchars($row['subscriber_employer_country'],ENT_NOQUOTES); ?>
764 <?php echo " " . htmlspecialchars($row['subscriber_employer_postal_code'],ENT_NOQUOTES); ?>
765 </span>
766 <?php } ?>
768 </td>
769 </tr>
770 <tr>
771 <td>
772 <?php if ($row['copay'] != "") { ?>
773 <span class='bold'><?php echo htmlspecialchars(xl('CoPay'),ENT_NOQUOTES); ?>: </span>
774 <span class='text'><?php echo htmlspecialchars($row['copay'],ENT_NOQUOTES); ?></span>
775 <?php } ?>
776 <br>
777 <span class='bold'><?php echo htmlspecialchars(xl('Accept Assignment'),ENT_NOQUOTES); ?>:</span>
778 <span class='text'><?php if($row['accept_assignment'] == "TRUE") echo xl("YES"); ?>
779 <?php if($row['accept_assignment'] == "FALSE") echo xl("NO"); ?></span>
780 </td>
781 <td valign='top'></td>
782 <td valign='top'></td>
783 </tr>
785 </table>
786 </div>
787 <?php
789 } // end if ($row['provider'])
790 $enddate = $row['date'];
791 $first = false;
792 } // end while
793 } // end foreach
795 // Display the eligibility information
796 echo "<div class='tab'>";
797 show_eligibility_information($pid,true);
798 echo "</div>";
800 ///////////////////////////////// END INSURANCE SECTION
802 </div>
804 <?php } // ?>
806 </td>
807 </tr>
809 <tr>
810 <td width='650px'>
812 <?php
813 // Notes expand collapse widget
814 $widgetTitle = xl("Notes");
815 $widgetLabel = "pnotes";
816 $widgetButtonLabel = xl("Edit");
817 $widgetButtonLink = "pnotes_full.php";
818 $widgetButtonClass = "";
819 $linkMethod = "html";
820 $bodyClass = "notab";
821 $widgetAuth = true;
822 $fixedWidth = true;
823 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
824 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
825 $widgetAuth, $fixedWidth);
828 <br/>
829 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
830 </div>
831 </td>
832 </tr>
833 <?php if ( (acl_check('patients', 'med')) && ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_prw']) ) {
834 echo "<tr><td width='650px'>";
835 // patient reminders collapse widget
836 $widgetTitle = xl("Patient Reminders");
837 $widgetLabel = "patient_reminders";
838 $widgetButtonLabel = xl("Edit");
839 $widgetButtonLink = "../reminder/patient_reminders.php?mode=simple&patient_id=".$pid;
840 $widgetButtonClass = "";
841 $linkMethod = "html";
842 $bodyClass = "notab";
843 $widgetAuth = true;
844 $fixedWidth = true;
845 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth); ?>
846 <br/>
847 <div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>
848 </div>
849 </td>
850 </tr>
851 <?php } //end if prw is activated ?>
853 <tr>
854 <td width='650px'>
855 <?php
856 // disclosures expand collapse widget
857 $widgetTitle = xl("Disclosures");
858 $widgetLabel = "disclosures";
859 $widgetButtonLabel = xl("Edit");
860 $widgetButtonLink = "disclosure_full.php";
861 $widgetButtonClass = "";
862 $linkMethod = "html";
863 $bodyClass = "notab";
864 $widgetAuth = true;
865 $fixedWidth = true;
866 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
867 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
868 $widgetAuth, $fixedWidth);
870 <br/>
871 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
872 </div>
873 </td>
874 </tr>
876 <?php if ($vitals_is_registered) { ?>
877 <tr>
878 <td width='650px'>
879 <?php // vitals expand collapse widget
880 $widgetTitle = xl("Vitals");
881 $widgetLabel = "vitals";
882 $widgetButtonLabel = xl("Trend");
883 $widgetButtonLink = "../encounter/trend_form.php?formname=vitals";
884 $widgetButtonClass = "";
885 $linkMethod = "html";
886 $bodyClass = "notab";
887 // check to see if any vitals exist
888 $existVitals = sqlQuery("SELECT * FROM form_vitals WHERE pid=?", array($pid) );
889 if ($existVitals) {
890 $widgetAuth = true;
892 else {
893 $widgetAuth = false;
895 $fixedWidth = true;
896 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
897 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
898 $widgetAuth, $fixedWidth);
900 <br/>
901 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
902 </div>
903 </td>
904 </tr>
905 <?php } // end if ($vitals_is_registered) ?>
907 <?php
908 // This generates a section similar to Vitals for each LBF form that
909 // supports charting. The form ID is used as the "widget label".
911 $gfres = sqlStatement("SELECT option_id, title FROM list_options WHERE " .
912 "list_id = 'lbfnames' AND option_value > 0 ORDER BY seq, title");
913 while($gfrow = sqlFetchArray($gfres)) {
915 <tr>
916 <td width='650px'>
917 <?php // vitals expand collapse widget
918 $vitals_form_id = $gfrow['option_id'];
919 $widgetTitle = $gfrow['title'];
920 $widgetLabel = $vitals_form_id;
921 $widgetButtonLabel = xl("Trend");
922 $widgetButtonLink = "../encounter/trend_form.php?formname=$vitals_form_id";
923 $widgetButtonClass = "";
924 $linkMethod = "html";
925 $bodyClass = "notab";
926 // check to see if any instances exist for this patient
927 $existVitals = sqlQuery(
928 "SELECT * FROM forms WHERE pid = ? AND formdir = ? AND deleted = 0",
929 array($pid, $vitals_form_id));
930 $widgetAuth = $existVitals ? true : false;
931 $fixedWidth = true;
932 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
933 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
934 $widgetAuth, $fixedWidth);
936 <br/>
937 <div style='margin-left:10px' class='text'>
938 <image src='../../pic/ajax-loader.gif'/>
939 </div>
940 <br/>
941 </div> <!-- This is required by expand_collapse_widget(). -->
942 </td>
943 </tr>
944 <?php
945 } // end while
948 </table>
950 </div>
951 <!-- end left column div -->
953 <!-- start right column div -->
954 <div>
955 <table>
956 <tr>
957 <td>
959 <div>
960 <?php
962 // If there is an ID Card or any Photos show the widget
963 $photos = pic_array($pid, $GLOBALS['patient_photo_category_name']);
964 if ($photos or $idcard_doc_id )
966 $widgetTitle = xl("ID Card") . '/' . xl("Photos");
967 $widgetLabel = "photos";
968 $linkMethod = "javascript";
969 $bodyClass = "notab-right";
970 $widgetAuth = false;
971 $fixedWidth = false;
972 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel ,
973 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
974 $widgetAuth, $fixedWidth);
976 <br />
977 <?php
978 if ($idcard_doc_id) {
979 image_widget($idcard_doc_id, $GLOBALS['patient_id_category_name']);
982 foreach ($photos as $photo_doc_id) {
983 image_widget($photo_doc_id, $GLOBALS['patient_photo_category_name']);
988 <br />
989 </div>
990 <div>
991 <?php
992 // Advance Directives
993 if ($GLOBALS['advance_directives_warning']) {
994 // advance directives expand collapse widget
995 $widgetTitle = xl("Advance Directives");
996 $widgetLabel = "directives";
997 $widgetButtonLabel = xl("Edit");
998 $widgetButtonLink = "return advdirconfigure();";
999 $widgetButtonClass = "";
1000 $linkMethod = "javascript";
1001 $bodyClass = "summary_item small";
1002 $widgetAuth = true;
1003 $fixedWidth = false;
1004 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1005 $counterFlag = false; //flag to record whether any categories contain ad records
1006 $query = "SELECT id FROM categories WHERE name='Advance Directive'";
1007 $myrow2 = sqlQuery($query);
1008 if ($myrow2) {
1009 $parentId = $myrow2['id'];
1010 $query = "SELECT id, name FROM categories WHERE parent=?";
1011 $resNew1 = sqlStatement($query, array($parentId) );
1012 while ($myrows3 = sqlFetchArray($resNew1)) {
1013 $categoryId = $myrows3['id'];
1014 $nameDoc = $myrows3['name'];
1015 $query = "SELECT documents.date, documents.id " .
1016 "FROM documents " .
1017 "INNER JOIN categories_to_documents " .
1018 "ON categories_to_documents.document_id=documents.id " .
1019 "WHERE categories_to_documents.category_id=? " .
1020 "AND documents.foreign_id=? " .
1021 "ORDER BY documents.date DESC";
1022 $resNew2 = sqlStatement($query, array($categoryId, $pid) );
1023 $limitCounter = 0; // limit to one entry per category
1024 while (($myrows4 = sqlFetchArray($resNew2)) && ($limitCounter == 0)) {
1025 $dateTimeDoc = $myrows4['date'];
1026 // remove time from datetime stamp
1027 $tempParse = explode(" ",$dateTimeDoc);
1028 $dateDoc = $tempParse[0];
1029 $idDoc = $myrows4['id'];
1030 echo "<a href='$web_root/controller.php?document&retrieve&patient_id=" .
1031 htmlspecialchars($pid,ENT_QUOTES) . "&document_id=" .
1032 htmlspecialchars($idDoc,ENT_QUOTES) . "&as_file=true'>" .
1033 htmlspecialchars(xl_document_category($nameDoc),ENT_NOQUOTES) . "</a> " .
1034 htmlspecialchars($dateDoc,ENT_NOQUOTES);
1035 echo "<br>";
1036 $limitCounter = $limitCounter + 1;
1037 $counterFlag = true;
1041 if (!$counterFlag) {
1042 echo "&nbsp;&nbsp;" . htmlspecialchars(xl('None'),ENT_NOQUOTES);
1043 } ?>
1044 </div>
1045 <?php } // close advanced dir block
1047 // This is a feature for a specific client. -- Rod
1048 if ($GLOBALS['cene_specific']) {
1049 echo " <br />\n";
1051 $imagedir = $GLOBALS['OE_SITE_DIR'] . "/documents/$pid/demographics";
1052 $imagepath = "$web_root/sites/" . $_SESSION['site_id'] . "/documents/$pid/demographics";
1054 echo " <a href='' onclick=\"return sendimage($pid, 'photo');\" " .
1055 "title='Click to attach patient image'>\n";
1056 if (is_file("$imagedir/photo.jpg")) {
1057 echo " <img src='$imagepath/photo.jpg' /></a>\n";
1058 } else {
1059 echo " Attach Patient Image</a><br />\n";
1061 echo " <br />&nbsp;<br />\n";
1063 echo " <a href='' onclick=\"return sendimage($pid, 'fingerprint');\" " .
1064 "title='Click to attach fingerprint'>\n";
1065 if (is_file("$imagedir/fingerprint.jpg")) {
1066 echo " <img src='$imagepath/fingerprint.jpg' /></a>\n";
1067 } else {
1068 echo " Attach Biometric Fingerprint</a><br />\n";
1070 echo " <br />&nbsp;<br />\n";
1073 // This stuff only applies to athletic team use of OpenEMR. The client
1074 // insisted on being able to quickly change fitness and return date here:
1076 if (false && $GLOBALS['athletic_team']) {
1077 // blue green yellow red orange
1078 $fitcolors = array('#6677ff','#00cc00','#ffff00','#ff3333','#ff8800','#ffeecc','#ffccaa');
1079 if (!empty($GLOBALS['fitness_colors'])) $fitcolors = $GLOBALS['fitness_colors'];
1080 $fitcolor = $fitcolors[0];
1081 $form_fitness = $_POST['form_fitness'];
1082 $form_userdate1 = fixDate($_POST['form_userdate1'], '');
1083 $form_issue_id = $_POST['form_issue_id'];
1084 if ($form_submit) {
1085 $returndate = $form_userdate1 ? "'$form_userdate1'" : "NULL";
1086 sqlStatement("UPDATE patient_data SET fitness = ?, " .
1087 "userdate1 = ? WHERE pid = ?", array($form_fitness, $returndate, $pid) );
1088 // Update return date in the designated issue, if requested.
1089 if ($form_issue_id) {
1090 sqlStatement("UPDATE lists SET returndate = ? WHERE " .
1091 "id = ?", array($returndate, $form_issue_id) );
1093 } else {
1094 $form_fitness = $result['fitness'];
1095 if (! $form_fitness) $form_fitness = 1;
1096 $form_userdate1 = $result['userdate1'];
1098 $fitcolor = $fitcolors[$form_fitness - 1];
1099 echo " <form method='post' action='demographics.php' onsubmit='return validate()'>\n";
1100 echo " <span class='bold'>Fitness to Play:</span><br />\n";
1101 echo " <select name='form_fitness' style='background-color:$fitcolor'>\n";
1102 $res = sqlStatement("SELECT * FROM list_options WHERE " .
1103 "list_id = 'fitness' ORDER BY seq");
1104 while ($row = sqlFetchArray($res)) {
1105 $key = $row['option_id'];
1106 echo " <option value='" . htmlspecialchars($key,ENT_QUOTES) . "'";
1107 if ($key == $form_fitness) echo " selected";
1108 echo ">" . htmlspecialchars($row['title'],ENT_NOQUOTES) . "</option>\n";
1110 echo " </select>\n";
1111 echo " <br /><span class='bold'>Return to Play:</span><br>\n";
1112 echo " <input type='text' size='10' name='form_userdate1' id='form_userdate1' " .
1113 "value='$form_userdate1' " .
1114 "title='" . htmlspecialchars(xl('yyyy-mm-dd Date of return to play'),ENT_QUOTES) . "' " .
1115 "onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />\n" .
1116 " <img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22' " .
1117 "id='img_userdate1' border='0' alt='[?]' style='cursor:pointer' " .
1118 "title='" . htmlspecialchars(xl('Click here to choose a date'),ENT_QUOTES) . "'>\n";
1119 echo " <input type='hidden' name='form_original_userdate1' value='" . htmlspecialchars($form_userdate1,ENT_QUOTES) . "' />\n";
1120 echo " <input type='hidden' name='form_issue_id' value='' />\n";
1121 echo "<p><input type='submit' name='form_submit' value='Change' /></p>\n";
1122 echo " </form>\n";
1125 // Show current and upcoming appointments.
1126 if (isset($pid) && !$GLOBALS['disable_calendar']) {
1127 $query = "SELECT e.pc_eid, e.pc_aid, e.pc_title, e.pc_eventDate, " .
1128 "e.pc_startTime, e.pc_hometext, u.fname, u.lname, u.mname, " .
1129 "c.pc_catname " .
1130 "FROM openemr_postcalendar_events AS e, users AS u, " .
1131 "openemr_postcalendar_categories AS c WHERE " .
1132 "e.pc_pid = ? AND e.pc_eventDate >= CURRENT_DATE AND " .
1133 "u.id = e.pc_aid AND e.pc_catid = c.pc_catid " .
1134 "ORDER BY e.pc_eventDate, e.pc_startTime";
1135 $res = sqlStatement($query, array($pid) );
1137 if ( (acl_check('patients', 'med')) && ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crw']) ) {
1138 // clinical summary expand collapse widget
1139 $widgetTitle = xl("Clinical Reminders");
1140 $widgetLabel = "clinical_reminders";
1141 $widgetButtonLabel = xl("Edit");
1142 $widgetButtonLink = "../reminder/clinical_reminders.php?patient_id=".$pid;;
1143 $widgetButtonClass = "";
1144 $linkMethod = "html";
1145 $bodyClass = "summary_item small";
1146 $widgetAuth = true;
1147 $fixedWidth = false;
1148 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1149 echo "<br/>";
1150 echo "<div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>";
1151 echo "</div>";
1152 } // end if crw
1154 // appointments expand collapse widget
1155 $widgetTitle = xl("Appointments");
1156 $widgetLabel = "appointments";
1157 $widgetButtonLabel = xl("Add");
1158 $widgetButtonLink = "return newEvt();";
1159 $widgetButtonClass = "";
1160 $linkMethod = "javascript";
1161 $bodyClass = "summary_item small";
1162 $widgetAuth = (isset($res) && $res != null);
1163 $fixedWidth = false;
1164 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1166 $count = 0;
1167 while($row = sqlFetchArray($res)) {
1168 $count++;
1169 $dayname = date("l", strtotime($row['pc_eventDate']));
1170 $dispampm = "am";
1171 $disphour = substr($row['pc_startTime'], 0, 2) + 0;
1172 $dispmin = substr($row['pc_startTime'], 3, 2);
1173 if ($disphour >= 12) {
1174 $dispampm = "pm";
1175 if ($disphour > 12) $disphour -= 12;
1177 $etitle = xl('(Click to edit)');
1178 if ($row['pc_hometext'] != "") {
1179 $etitle = xl('Comments').": ".($row['pc_hometext'])."\r\n".$etitle;
1181 echo "<a href='javascript:oldEvt(" . htmlspecialchars($row['pc_eid'],ENT_QUOTES) .
1182 ")' title='" . htmlspecialchars($etitle,ENT_QUOTES) . "'>";
1183 echo "<b>" . htmlspecialchars(xl($dayname) . ", " . $row['pc_eventDate'],ENT_NOQUOTES) . "</b><br>";
1184 echo htmlspecialchars("$disphour:$dispmin " . xl($dispampm) . " " . xl_appt_category($row['pc_catname']),ENT_NOQUOTES) . "<br>\n";
1185 echo htmlspecialchars($row['fname'] . " " . $row['lname'],ENT_NOQUOTES) . "</a><br>\n";
1187 if (isset($res) && $res != null) {
1188 if ( $count < 1 ) { echo "&nbsp;&nbsp;" . htmlspecialchars(xl('None'),ENT_NOQUOTES); }
1189 echo "</div>";
1193 </div>
1195 <div id='stats_div'>
1196 <br/>
1197 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
1198 </div>
1199 </td>
1200 </tr>
1201 </table>
1203 </div> <!-- end right column div -->
1205 </td>
1207 </tr>
1208 </table>
1210 </div> <!-- end main content div -->
1212 <?php if ($GLOBALS['concurrent_layout'] && $_GET['set_pid']) { ?>
1213 <script language='JavaScript'>
1214 top.window.parent.left_nav.setPatient(<?php echo "'" . htmlspecialchars(($result['fname']) . " " . ($result['lname']),ENT_QUOTES) .
1215 "'," . htmlspecialchars($pid,ENT_QUOTES) . ",'" . htmlspecialchars(($result['pubpid']),ENT_QUOTES) .
1216 "','', ' " . htmlspecialchars(xl('DOB') . ": " . oeFormatShortDate($result['DOB_YMD']) . " " . xl('Age') . ": " . getPatientAge($result['DOB_YMD']), ENT_QUOTES) . "'"; ?>);
1217 EncounterDateArray=new Array;
1218 CalendarCategoryArray=new Array;
1219 EncounterIdArray=new Array;
1220 Count=0;
1221 <?php
1222 //Encounter details are stored to javacript as array.
1223 $result4 = sqlStatement("SELECT fe.encounter,fe.date,openemr_postcalendar_categories.pc_catname FROM form_encounter AS fe ".
1224 " left join openemr_postcalendar_categories on fe.pc_catid=openemr_postcalendar_categories.pc_catid WHERE fe.pid = ? order by fe.date desc", array($pid));
1225 if(sqlNumRows($result4)>0)
1226 while($rowresult4 = sqlFetchArray($result4))
1229 EncounterIdArray[Count]='<?php echo htmlspecialchars($rowresult4['encounter'], ENT_QUOTES); ?>';
1230 EncounterDateArray[Count]='<?php echo htmlspecialchars(oeFormatShortDate(date("Y-m-d", strtotime($rowresult4['date']))), ENT_QUOTES); ?>';
1231 CalendarCategoryArray[Count]='<?php echo htmlspecialchars( xl_appt_category($rowresult4['pc_catname']), ENT_QUOTES); ?>';
1232 Count++;
1233 <?php
1236 top.window.parent.left_nav.setPatientEncounter(EncounterIdArray,EncounterDateArray,CalendarCategoryArray);
1237 parent.left_nav.setRadio(window.name, 'dem');
1238 </script>
1239 <?php } ?>
1241 <?php if (false && $GLOBALS['athletic_team']) { ?>
1242 <script language='JavaScript'>
1243 Calendar.setup({inputField:"form_userdate1", ifFormat:"%Y-%m-%d", button:"img_userdate1"});
1244 </script>
1245 <?php } ?>
1247 </body>
1248 </html>