Patient balance computation improvements on patient summary page.
[openemr.git] / interface / patient_file / summary / demographics.php
blobd89fc9d2eec4a18d9e42a870e13f811f1aab517f
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/invoice_summary.inc.php");
26 require_once("$srcdir/clinical_rules.php");
28 if ($GLOBALS['concurrent_layout'] && isset($_GET['set_pid'])) {
29 include_once("$srcdir/pid.inc");
30 setpid($_GET['set_pid']);
33 $active_reminders = false;
34 if ((!isset($_SESSION['alert_notify_pid']) || ($_SESSION['alert_notify_pid'] != $pid)) && isset($_GET['set_pid']) && acl_check('patients', 'med') && $GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crp']) {
35 // showing a new patient, so check for active reminders
36 $active_reminders = active_alert_summary($pid,"reminders-due");
39 function print_as_money($money) {
40 preg_match("/(\d*)\.?(\d*)/",$money,$moneymatches);
41 $tmp = wordwrap(strrev($moneymatches[1]),3,",",1);
42 $ccheck = strrev($tmp);
43 if ($ccheck[0] == ",") {
44 $tmp = substr($ccheck,1,strlen($ccheck)-1);
46 if ($moneymatches[2] != "") {
47 return "$ " . strrev($tmp) . "." . $moneymatches[2];
48 } else {
49 return "$ " . strrev($tmp);
53 // get an array from Photos category
54 function pic_array($pid,$picture_directory) {
55 $pics = array();
56 $sql_query = "select documents.id from documents join categories_to_documents " .
57 "on documents.id = categories_to_documents.document_id " .
58 "join categories on categories.id = categories_to_documents.category_id " .
59 "where categories.name like ? and documents.foreign_id = ?";
60 if ($query = sqlStatement($sql_query, array($picture_directory,$pid))) {
61 while( $results = sqlFetchArray($query) ) {
62 array_push($pics,$results['id']);
65 return ($pics);
67 // Get the document ID of the first document in a specific catg.
68 function get_document_by_catg($pid,$doc_catg) {
70 $result = array();
72 if ($pid and $doc_catg) {
73 $result = sqlQuery("SELECT d.id, d.date, d.url FROM " .
74 "documents AS d, categories_to_documents AS cd, categories AS c " .
75 "WHERE d.foreign_id = ? " .
76 "AND cd.document_id = d.id " .
77 "AND c.id = cd.category_id " .
78 "AND c.name LIKE ? " .
79 "ORDER BY d.date DESC LIMIT 1", array($pid, $doc_catg) );
82 return($result['id']);
85 // Display image in 'widget style'
86 function image_widget($doc_id,$doc_catg)
88 global $pid, $web_root;
89 $docobj = new Document($doc_id);
90 $image_file = $docobj->get_url_file();
91 $extension = substr($image_file, strrpos($image_file,"."));
92 $viewable_types = array('.png','.jpg','.jpeg','.png','.bmp','.PNG','.JPG','.JPEG','.PNG','.BMP'); // image ext supported by fancybox viewer
93 if ( in_array($extension,$viewable_types) ) { // extention matches list
94 $to_url = "<td> <a href = $web_root" .
95 "/controller.php?document&retrieve&patient_id=$pid&document_id=$doc_id" .
96 "/tmp$extension" . // Force image type URL for fancybox
97 " onclick=top.restoreSession(); class='image_modal'>" .
98 " <img src = $web_root" .
99 "/controller.php?document&retrieve&patient_id=$pid&document_id=$doc_id" .
100 " width=100 alt='$doc_catg:$image_file'> </a> </td> <td valign='center'>".
101 htmlspecialchars($doc_catg) . '<br />&nbsp;' . htmlspecialchars($image_file) .
102 "</td>";
104 else {
105 $to_url = "<td> <a href='" . $web_root . "/controller.php?document&retrieve" .
106 "&patient_id=$pid&document_id=$doc_id'" .
107 " onclick='top.restoreSession()' class='css_button_small'>" .
108 "<span>" .
109 htmlspecialchars( xl("View"), ENT_QUOTES )."</a> &nbsp;" .
110 htmlspecialchars( "$doc_catg - $image_file", ENT_QUOTES ) .
111 "</span> </td>";
113 echo "<table><tr>";
114 echo $to_url;
115 echo "</tr></table>";
118 // Determine if the Vitals form is in use for this site.
119 $tmp = sqlQuery("SELECT count(*) AS count FROM registry WHERE " .
120 "directory = 'vitals' AND state = 1");
121 $vitals_is_registered = $tmp['count'];
123 // Get patient/employer/insurance information.
125 $result = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
126 $result2 = getEmployerData($pid);
127 $result3 = getInsuranceData($pid, "primary", "copay, provider, DATE_FORMAT(`date`,'%Y-%m-%d') as effdate");
128 $insco_name = "";
129 if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
130 $insco_name = getInsuranceProvider($result3['provider']);
133 <html>
135 <head>
136 <?php html_header_show();?>
137 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
138 <link rel="stylesheet" type="text/css" href="../../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
139 <style type="text/css">@import url(../../../library/dynarch_calendar.css);</style>
140 <script type="text/javascript" src="../../../library/textformat.js"></script>
141 <script type="text/javascript" src="../../../library/dynarch_calendar.js"></script>
142 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
143 <script type="text/javascript" src="../../../library/dynarch_calendar_setup.js"></script>
144 <script type="text/javascript" src="../../../library/dialog.js"></script>
145 <script type="text/javascript" src="../../../library/js/jquery-1.6.4.min.js"></script>
146 <script type="text/javascript" src="../../../library/js/common.js"></script>
147 <script type="text/javascript" src="../../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
148 <script type="text/javascript" language="JavaScript">
150 var mypcc = '<?php echo htmlspecialchars($GLOBALS['phone_country_code'],ENT_QUOTES); ?>';
152 function oldEvt(eventid) {
153 dlgopen('../../main/calendar/add_edit_event.php?eid=' + eventid, '_blank', 550, 350);
156 function advdirconfigure() {
157 dlgopen('advancedirectives.php', '_blank', 500, 450);
160 function refreshme() {
161 top.restoreSession();
162 location.reload();
165 // Process click on Delete link.
166 function deleteme() {
167 dlgopen('../deleter.php?patient=<?php echo htmlspecialchars($pid,ENT_QUOTES); ?>', '_blank', 500, 450);
168 return false;
171 // Called by the deleteme.php window on a successful delete.
172 function imdeleted() {
173 <?php if ($GLOBALS['concurrent_layout']) { ?>
174 parent.left_nav.clearPatient();
175 <?php } else { ?>
176 top.restoreSession();
177 top.location.href = '../main/main_screen.php';
178 <?php } ?>
181 function validate() {
182 var f = document.forms[0];
183 <?php
184 if ($GLOBALS['athletic_team']) {
185 echo " if (f.form_userdate1.value != f.form_original_userdate1.value) {\n";
186 $irow = sqlQuery("SELECT id, title FROM lists WHERE " .
187 "pid = ? AND enddate IS NULL ORDER BY begdate DESC LIMIT 1", array($pid));
188 if (!empty($irow)) {
190 if (confirm('Do you wish to also set this new return date in the issue titled "<?php echo htmlspecialchars($irow['title'],ENT_QUOTES); ?>"?')) {
191 f.form_issue_id.value = '<?php echo htmlspecialchars($irow['id'],ENT_QUOTES); ?>';
192 } else {
193 alert('OK, you will need to manually update the return date in any affected issue(s).');
195 <?php } else { ?>
196 alert('You have changed the return date but there are no open issues. You probably need to create or modify one.');
197 <?php
198 } // end empty $irow
199 echo " }\n";
200 } // end athletic team
202 return true;
205 function newEvt() {
206 dlgopen('../../main/calendar/add_edit_event.php?patientid=<?php echo htmlspecialchars($pid,ENT_QUOTES); ?>', '_blank', 550, 350);
207 return false;
210 function sendimage(pid, what) {
211 // alert('Not yet implemented.'); return false;
212 dlgopen('../upload_dialog.php?patientid=' + pid + '&file=' + what,
213 '_blank', 500, 400);
214 return false;
217 </script>
219 <script type="text/javascript">
221 function toggleIndicator(target,div) {
223 $mode = $(target).find(".indicator").text();
224 if ( $mode == "<?php echo htmlspecialchars(xl('collapse'),ENT_QUOTES); ?>" ) {
225 $(target).find(".indicator").text( "<?php echo htmlspecialchars(xl('expand'),ENT_QUOTES); ?>" );
226 $("#"+div).hide();
227 $.post( "../../../library/ajax/user_settings.php", { target: div, mode: 0 });
228 } else {
229 $(target).find(".indicator").text( "<?php echo htmlspecialchars(xl('collapse'),ENT_QUOTES); ?>" );
230 $("#"+div).show();
231 $.post( "../../../library/ajax/user_settings.php", { target: div, mode: 1 });
235 $(document).ready(function(){
236 var msg_updation='';
237 <?php
238 if($GLOBALS['erx_enable']){
239 //$soap_status=sqlQuery("select soap_import_status from patient_data where pid=?",array($pid));
240 $soap_status=sqlStatement("select soap_import_status,pid from patient_data where pid=? and soap_import_status in ('1','3')",array($pid));
241 while($row_soapstatus=sqlFetchArray($soap_status)){
242 //if($soap_status['soap_import_status']=='1' || $soap_status['soap_import_status']=='3'){ ?>
243 top.restoreSession();
244 $.ajax({
245 type: "POST",
246 url: "../../soap_functions/soap_patientfullmedication.php",
247 dataType: "html",
248 data: {
249 patient:<?php echo $row_soapstatus['pid']; ?>,
251 async: false,
252 success: function(thedata){
253 //alert(thedata);
254 msg_updation+=thedata;
256 error:function(){
257 alert('ajax error');
260 <?php
261 //}
262 //elseif($soap_status['soap_import_status']=='3'){ ?>
263 top.restoreSession();
264 $.ajax({
265 type: "POST",
266 url: "../../soap_functions/soap_allergy.php",
267 dataType: "html",
268 data: {
269 patient:<?php echo $row_soapstatus['pid']; ?>,
271 async: false,
272 success: function(thedata){
273 //alert(thedata);
274 msg_updation+=thedata;
276 error:function(){
277 alert('ajax error');
280 <?php
281 if($GLOBALS['erx_import_status_message']){ ?>
282 if(msg_updation)
283 alert(msg_updation);
284 <?php
286 //}
290 // load divs
291 $("#stats_div").load("stats.php", { 'embeddedScreen' : true }, function() {
292 // (note need to place javascript code here also to get the dynamic link to work)
293 $(".rx_modal").fancybox( {
294 'overlayOpacity' : 0.0,
295 'showCloseButton' : true,
296 'frameHeight' : 500,
297 'frameWidth' : 800,
298 'centerOnScroll' : false,
299 'callbackOnClose' : function() {
300 refreshme();
304 $("#pnotes_ps_expand").load("pnotes_fragment.php");
305 $("#disclosures_ps_expand").load("disc_fragment.php");
307 <?php if ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crw']) { ?>
308 top.restoreSession();
309 $("#clinical_reminders_ps_expand").load("clinical_reminders_fragment.php", { 'embeddedScreen' : true }, function() {
310 // (note need to place javascript code here also to get the dynamic link to work)
311 $(".medium_modal").fancybox( {
312 'overlayOpacity' : 0.0,
313 'showCloseButton' : true,
314 'frameHeight' : 500,
315 'frameWidth' : 800,
316 'centerOnScroll' : false,
317 'callbackOnClose' : function() {
318 refreshme();
322 <?php } // end crw?>
324 <?php if ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_prw']) { ?>
325 top.restoreSession();
326 $("#patient_reminders_ps_expand").load("patient_reminders_fragment.php");
327 <?php } // end prw?>
329 <?php if ($vitals_is_registered && acl_check('patients', 'med')) { ?>
330 // Initialize the Vitals form if it is registered and user is authorized.
331 $("#vitals_ps_expand").load("vitals_fragment.php");
332 <?php } ?>
334 <?php
335 // Initialize for each applicable LBF form.
336 $gfres = sqlStatement("SELECT option_id FROM list_options WHERE " .
337 "list_id = 'lbfnames' AND option_value > 0 ORDER BY seq, title");
338 while($gfrow = sqlFetchArray($gfres)) {
340 $("#<?php echo $gfrow['option_id']; ?>_ps_expand").load("lbf_fragment.php?formname=<?php echo $gfrow['option_id']; ?>");
341 <?php
345 // fancy box
346 enable_modals();
348 tabbify();
350 // modal for dialog boxes
351 $(".large_modal").fancybox( {
352 'overlayOpacity' : 0.0,
353 'showCloseButton' : true,
354 'frameHeight' : 600,
355 'frameWidth' : 1000,
356 'centerOnScroll' : false
359 // modal for image viewer
360 $(".image_modal").fancybox( {
361 'overlayOpacity' : 0.0,
362 'showCloseButton' : true,
363 'centerOnScroll' : false,
364 'autoscale' : true
367 $(".iframe1").fancybox( {
368 'left':10,
369 'overlayOpacity' : 0.0,
370 'showCloseButton' : true,
371 'frameHeight' : 300,
372 'frameWidth' : 350
374 // special size for patient portal
375 $(".small_modal").fancybox( {
376 'overlayOpacity' : 0.0,
377 'showCloseButton' : true,
378 'frameHeight' : 200,
379 'frameWidth' : 380,
380 'centerOnScroll' : false
383 <?php if ($active_reminders) { ?>
384 // show the active reminder modal
385 $("#reminder_popup_link").fancybox({
386 'overlayOpacity' : 0.0,
387 'showCloseButton' : true,
388 'frameHeight' : 500,
389 'frameWidth' : 500,
390 'centerOnScroll' : false
391 }).trigger('click');
392 <?php } ?>
396 // JavaScript stuff to do when a new patient is set.
398 function setMyPatient() {
399 <?php if ($GLOBALS['concurrent_layout']) { ?>
400 // Avoid race conditions with loading of the left_nav or Title frame.
401 if (!parent.allFramesLoaded()) {
402 setTimeout("setMyPatient()", 500);
403 return;
405 <?php if (isset($_GET['set_pid'])) { ?>
406 parent.left_nav.setPatient(<?php echo "'" . htmlspecialchars(($result['fname']) . " " . ($result['lname']),ENT_QUOTES) .
407 "'," . htmlspecialchars($pid,ENT_QUOTES) . ",'" . htmlspecialchars(($result['pubpid']),ENT_QUOTES) .
408 "','', ' " . htmlspecialchars(xl('DOB') . ": " . oeFormatShortDate($result['DOB_YMD']) . " " . xl('Age') . ": " . getPatientAgeDisplay($result['DOB_YMD']), ENT_QUOTES) . "'"; ?>);
409 var EncounterDateArray = new Array;
410 var CalendarCategoryArray = new Array;
411 var EncounterIdArray = new Array;
412 var Count = 0;
413 <?php
414 //Encounter details are stored to javacript as array.
415 $result4 = sqlStatement("SELECT fe.encounter,fe.date,openemr_postcalendar_categories.pc_catname FROM form_encounter AS fe ".
416 " left join openemr_postcalendar_categories on fe.pc_catid=openemr_postcalendar_categories.pc_catid WHERE fe.pid = ? order by fe.date desc", array($pid));
417 if(sqlNumRows($result4)>0) {
418 while($rowresult4 = sqlFetchArray($result4)) {
420 EncounterIdArray[Count] = '<?php echo htmlspecialchars($rowresult4['encounter'], ENT_QUOTES); ?>';
421 EncounterDateArray[Count] = '<?php echo htmlspecialchars(oeFormatShortDate(date("Y-m-d", strtotime($rowresult4['date']))), ENT_QUOTES); ?>';
422 CalendarCategoryArray[Count] = '<?php echo htmlspecialchars(xl_appt_category($rowresult4['pc_catname']), ENT_QUOTES); ?>';
423 Count++;
424 <?php
428 parent.left_nav.setPatientEncounter(EncounterIdArray,EncounterDateArray,CalendarCategoryArray);
429 <?php } // end setting new pid ?>
430 parent.left_nav.setRadio(window.name, 'dem');
431 parent.left_nav.syncRadios();
432 <?php } // end concurrent layout ?>
435 $(window).load(function() {
436 setMyPatient();
439 </script>
441 <style type="css/text">
442 #pnotes_ps_expand {
443 height:auto;
444 width:100%;
446 </style>
448 </head>
450 <body class="body_top">
452 <a href='../reminder/active_reminder_popup.php' id='reminder_popup_link' style='visibility: false;' class='iframe' onclick='top.restoreSession()'></a>
454 <?php
455 $thisauth = acl_check('patients', 'demo');
456 if ($thisauth) {
457 if ($result['squad'] && ! acl_check('squads', $result['squad']))
458 $thisauth = 0;
460 if (!$thisauth) {
461 echo "<p>(" . htmlspecialchars(xl('Demographics not authorized'),ENT_NOQUOTES) . ")</p>\n";
462 echo "</body>\n</html>\n";
463 exit();
465 if ($thisauth) {
466 echo "<table><tr><td><span class='title'>" .
467 htmlspecialchars(getPatientName($pid),ENT_NOQUOTES) .
468 "</span></td>";
470 if (acl_check('admin', 'super')) {
471 echo "<td style='padding-left:1em;'><a class='css_button iframe' href='../deleter.php?patient=" .
472 htmlspecialchars($pid,ENT_QUOTES) . "'>" .
473 "<span>".htmlspecialchars(xl('Delete'),ENT_NOQUOTES).
474 "</span></a></td>";
476 if($GLOBALS['erx_enable']){
477 echo '<td style="padding-left:1em;"><a class="css_button" href="../../eRx.php?page=medentry" onclick="top.restoreSession()">';
478 echo "<span>".htmlspecialchars(xl('NewCrop MedEntry'),ENT_NOQUOTES)."</span></a></td>";
479 echo '<td style="padding-left:1em;"><a class="css_button iframe1" href="../../soap_functions/soap_accountStatusDetails.php" onclick="top.restoreSession()">';
480 echo "<span>".htmlspecialchars(xl('NewCrop Account Status'),ENT_NOQUOTES)."</span></a></td><td id='accountstatus'></td>";
482 //Patient Portal
483 $portalUserSetting = true; //flag to see if patient has authorized access to portal
484 if($GLOBALS['portal_onsite_enable'] && $GLOBALS['portal_onsite_address']){
485 $portalStatus = sqlQuery("SELECT allow_patient_portal FROM patient_data WHERE pid=?",array($pid));
486 if ($portalStatus['allow_patient_portal']=='YES') {
487 $portalLogin = sqlQuery("SELECT pid FROM `patient_access_onsite` WHERE `pid`=?", array($pid));
488 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()'>";
489 if (empty($portalLogin)) {
490 echo "<span>".htmlspecialchars(xl('Create Onsite Portal Credentials'),ENT_NOQUOTES)."</span></a></td>";
492 else {
493 echo "<span>".htmlspecialchars(xl('Reset Onsite Portal Credentials'),ENT_NOQUOTES)."</span></a></td>";
496 else {
497 $portalUserSetting = false;
500 if($GLOBALS['portal_offsite_enable'] && $GLOBALS['portal_offsite_address']){
501 $portalStatus = sqlQuery("SELECT allow_patient_portal FROM patient_data WHERE pid=?",array($pid));
502 if ($portalStatus['allow_patient_portal']=='YES') {
503 $portalLogin = sqlQuery("SELECT pid FROM `patient_access_offsite` WHERE `pid`=?", array($pid));
504 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()'>";
505 if (empty($portalLogin)) {
506 echo "<span>".htmlspecialchars(xl('Create Offsite Portal Credentials'),ENT_NOQUOTES)."</span></a></td>";
508 else {
509 echo "<span>".htmlspecialchars(xl('Reset Offsite Portal Credentials'),ENT_NOQUOTES)."</span></a></td>";
512 else {
513 $portalUserSetting = false;
516 if (!($portalUserSetting)) {
517 // Show that the patient has not authorized portal access
518 echo "<td style='padding-left:1em;'>" . htmlspecialchars( xl('Patient has not authorized the Patient Portal.'), ENT_NOQUOTES) . "</td>";
520 //Patient Portal
522 // If patient is deceased, then show this (along with the number of days patient has been deceased for)
523 $days_deceased = is_patient_deceased($pid);
524 if ($days_deceased) {
525 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>";
528 echo "</tr></table>";
531 // Get the document ID of the patient ID card if access to it is wanted here.
532 $idcard_doc_id = false;
533 if ($GLOBALS['patient_id_category_name']) {
534 $idcard_doc_id = get_document_by_catg($pid, $GLOBALS['patient_id_category_name']);
538 <table cellspacing='0' cellpadding='0' border='0'>
539 <tr>
540 <td class="small" colspan='4'>
541 <a href="../history/history.php" onclick='top.restoreSession()'>
542 <?php echo htmlspecialchars(xl('History'),ENT_NOQUOTES); ?></a>
544 <?php //note that we have temporarily removed report screen from the modal view ?>
545 <a href="../report/patient_report.php" onclick='top.restoreSession()'>
546 <?php echo htmlspecialchars(xl('Report'),ENT_NOQUOTES); ?></a>
548 <?php //note that we have temporarily removed document screen from the modal view ?>
549 <a href="../../../controller.php?document&list&patient_id=<?php echo $pid;?>" onclick='top.restoreSession()'>
550 <?php echo htmlspecialchars(xl('Documents'),ENT_NOQUOTES); ?></a>
552 <a href="../transaction/transactions.php" class='iframe large_modal' onclick='top.restoreSession()'>
553 <?php echo htmlspecialchars(xl('Transactions'),ENT_NOQUOTES); ?></a>
555 <a href="stats_full.php?active=all" onclick='top.restoreSession()'>
556 <?php echo htmlspecialchars(xl('Issues'),ENT_NOQUOTES); ?></a>
557 </td>
558 </tr>
559 </table> <!-- end header -->
561 <div style='margin-top:10px'> <!-- start main content div -->
562 <table border="0" cellspacing="0" cellpadding="0" width="100%">
563 <tr>
564 <td align="left" valign="top">
565 <!-- start left column div -->
566 <div style='float:left; margin-right:20px'>
567 <table cellspacing=0 cellpadding=0>
568 <tr<?php if ($GLOBALS['athletic_team']) echo " style='display:none;'"; ?>>
569 <td>
570 <?php
571 // Billing expand collapse widget
572 $widgetTitle = xl("Billing");
573 $widgetLabel = "billing";
574 $widgetButtonLabel = xl("Edit");
575 $widgetButtonLink = "return newEvt();";
576 $widgetButtonClass = "";
577 $linkMethod = "javascript";
578 $bodyClass = "notab";
579 $widgetAuth = false;
580 $fixedWidth = true;
581 if ($GLOBALS['force_billing_widget_open']) {
582 $forceExpandAlways = true;
584 else {
585 $forceExpandAlways = false;
587 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
588 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
589 $widgetAuth, $fixedWidth, $forceExpandAlways);
591 <br>
592 <?php
593 //PATIENT BALANCE,INS BALANCE naina@capminds.com
594 $patientbalance = get_patient_balance($pid, false);
595 //Debit the patient balance from insurance balance
596 $insurancebalance = get_patient_balance($pid, true) - $patientbalance;
597 $totalbalance=$patientbalance + $insurancebalance;
598 if ($GLOBALS['oer_config']['ws_accounting']['enabled']) {
599 // Show current balance and billing note, if any.
600 echo "<table border='0'><tr><td>" .
601 "<table ><tr><td><span class='bold'><font color='red' size='3pt'>" .
602 xlt('Patient Balance Due') .
603 " : " . text(oeFormatMoney($patientbalance)) .
604 "</font></span></td></tr>".
605 "<tr><td><span class='bold'><font color='red' size='3pt'>" .
606 xlt('Insurance Balance Due') .
607 " : " . text(oeFormatMoney($insurancebalance)) .
608 "</font></span></td></tr>".
609 "<tr><td><span class='bold'><font color='red' size='3pt'>" .
610 xlt('Total Balance Due').
611 " : " . text(oeFormatMoney($totalbalance)) .
612 "</font></span></td></td></tr>";
613 if ($result['genericname2'] == 'Billing') {
614 echo "<tr><td><span class='bold'><font color='red'>" .
615 xlt('Billing Note') . ":" .
616 text($result['genericval2']) .
617 "</font></span></td></tr>";
619 if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
620 echo "<tr><td><span class='bold'>" .
621 xlt('Primary Insurance') . ': ' . text($insco_name) .
622 "</span>&nbsp;&nbsp;&nbsp;";
623 if ($result3['copay'] > 0) {
624 echo "<span class='bold'>" .
625 xlt('Copay') . ': ' . text($result3['copay']) .
626 "</span>&nbsp;&nbsp;&nbsp;";
628 echo "<span class='bold'>" .
629 xlt('Effective Date') . ': ' . text(oeFormatShortDate($result3['effdate'])) .
630 "</span></td></tr>";
632 echo "</table></td></tr></td></tr></table><br>";
635 </div> <!-- required for expand_collapse_widget -->
636 </td>
637 </tr>
638 <tr>
639 <td>
640 <?php
641 // Demographics expand collapse widget
642 $widgetTitle = xl("Demographics");
643 $widgetLabel = "demographics";
644 $widgetButtonLabel = xl("Edit");
645 $widgetButtonLink = "demographics_full.php";
646 $widgetButtonClass = "";
647 $linkMethod = "html";
648 $bodyClass = "";
649 $widgetAuth = acl_check('patients', 'demo', '', 'write');
650 $fixedWidth = true;
651 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
652 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
653 $widgetAuth, $fixedWidth);
655 <div id="DEM" >
656 <ul class="tabNav">
657 <?php display_layout_tabs('DEM', $result, $result2); ?>
658 </ul>
659 <div class="tabContainer">
660 <?php display_layout_tabs_data('DEM', $result, $result2); ?>
661 </div>
662 </div>
663 </div> <!-- required for expand_collapse_widget -->
664 </td>
665 </tr>
667 <tr>
668 <td>
669 <?php
670 $insurance_count = 0;
671 foreach (array('primary','secondary','tertiary') as $instype) {
672 $enddate = 'Present';
673 $query = "SELECT * FROM insurance_data WHERE " .
674 "pid = ? AND type = ? " .
675 "ORDER BY date DESC";
676 $res = sqlStatement($query, array($pid, $instype) );
677 while( $row = sqlFetchArray($res) ) {
678 if ($row['provider'] ) $insurance_count++;
682 if ( $insurance_count > 0 ) {
683 // Insurance expand collapse widget
684 $widgetTitle = xl("Insurance");
685 $widgetLabel = "insurance";
686 $widgetButtonLabel = xl("Edit");
687 $widgetButtonLink = "demographics_full.php";
688 $widgetButtonClass = "";
689 $linkMethod = "html";
690 $bodyClass = "";
691 $widgetAuth = acl_check('patients', 'demo', '', 'write');
692 $fixedWidth = true;
693 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
694 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
695 $widgetAuth, $fixedWidth);
697 if ( $insurance_count > 0 ) {
700 <ul class="tabNav"><?php
701 ///////////////////////////////// INSURANCE SECTION
702 $first = true;
703 foreach (array('primary','secondary','tertiary') as $instype) {
705 $query = "SELECT * FROM insurance_data WHERE " .
706 "pid = ? AND type = ? " .
707 "ORDER BY date DESC";
708 $res = sqlStatement($query, array($pid, $instype) );
710 $enddate = 'Present';
712 while( $row = sqlFetchArray($res) ) {
713 if ($row['provider'] ) {
715 $ins_description = ucfirst($instype);
716 $ins_description = xl($ins_description);
717 $ins_description .= strcmp($enddate, 'Present') != 0 ? " (".xl('Old').")" : "";
719 <li <?php echo $first ? 'class="current"' : '' ?>><a href="/play/javascript-tabbed-navigation/">
720 <?php echo htmlspecialchars($ins_description,ENT_NOQUOTES); ?></a></li>
721 <?php
722 $first = false;
724 $enddate = $row['date'];
727 // Display the eligibility tab
728 echo "<li><a href='/play/javascript-tabbed-navigation/'>" .
729 htmlspecialchars( xl('Eligibility'), ENT_NOQUOTES) . "</a></li>";
731 ?></ul><?php
733 } ?>
735 <div class="tabContainer">
736 <?php
737 $first = true;
738 foreach (array('primary','secondary','tertiary') as $instype) {
739 $enddate = 'Present';
741 $query = "SELECT * FROM insurance_data WHERE " .
742 "pid = ? AND type = ? " .
743 "ORDER BY date DESC";
744 $res = sqlStatement($query, array($pid, $instype) );
745 while( $row = sqlFetchArray($res) ) {
746 if ($row['provider'] ) {
748 <div class="tab <?php echo $first ? 'current' : '' ?>">
749 <table border='0' cellpadding='0' width='100%'>
750 <?php
751 $icobj = new InsuranceCompany($row['provider']);
752 $adobj = $icobj->get_address();
753 $insco_name = trim($icobj->get_name());
755 <tr>
756 <td valign='top' colspan='3'>
757 <span class='text'>
758 <?php if (strcmp($enddate, 'Present') != 0) echo htmlspecialchars(xl("Old"),ENT_NOQUOTES)." "; ?>
759 <?php $tempinstype=ucfirst($instype); echo htmlspecialchars(xl($tempinstype.' Insurance'),ENT_NOQUOTES); ?>
760 <?php if (strcmp($row['date'], '0000-00-00') != 0) { ?>
761 <?php echo htmlspecialchars(xl('from','',' ',' ').$row['date'],ENT_NOQUOTES); ?>
762 <?php } ?>
763 <?php echo htmlspecialchars(xl('until','',' ',' '),ENT_NOQUOTES);
764 echo (strcmp($enddate, 'Present') != 0) ? $enddate : htmlspecialchars(xl('Present'),ENT_NOQUOTES); ?>:</span>
765 </td>
766 </tr>
767 <tr>
768 <td valign='top'>
769 <span class='text'>
770 <?php
771 if ($insco_name) {
772 echo htmlspecialchars($insco_name,ENT_NOQUOTES) . '<br>';
773 if (trim($adobj->get_line1())) {
774 echo htmlspecialchars($adobj->get_line1(),ENT_NOQUOTES) . '<br>';
775 echo htmlspecialchars($adobj->get_city() . ', ' . $adobj->get_state() . ' ' . $adobj->get_zip(),ENT_NOQUOTES);
777 } else {
778 echo "<font color='red'><b>".htmlspecialchars(xl('Unassigned'),ENT_NOQUOTES)."</b></font>";
781 <br>
782 <?php echo htmlspecialchars(xl('Policy Number'),ENT_NOQUOTES); ?>:
783 <?php echo htmlspecialchars($row['policy_number'],ENT_NOQUOTES) ?><br>
784 <?php echo htmlspecialchars(xl('Plan Name'),ENT_NOQUOTES); ?>:
785 <?php echo htmlspecialchars($row['plan_name'],ENT_NOQUOTES); ?><br>
786 <?php echo htmlspecialchars(xl('Group Number'),ENT_NOQUOTES); ?>:
787 <?php echo htmlspecialchars($row['group_number'],ENT_NOQUOTES); ?></span>
788 </td>
789 <td valign='top'>
790 <span class='bold'><?php echo htmlspecialchars(xl('Subscriber'),ENT_NOQUOTES); ?>: </span><br>
791 <span class='text'><?php echo htmlspecialchars($row['subscriber_fname'] . ' ' . $row['subscriber_mname'] . ' ' . $row['subscriber_lname'],ENT_NOQUOTES); ?>
792 <?php
793 if ($row['subscriber_relationship'] != "") {
794 echo "(" . htmlspecialchars($row['subscriber_relationship'],ENT_NOQUOTES) . ")";
797 <br>
798 <?php echo htmlspecialchars(xl('S.S.'),ENT_NOQUOTES); ?>:
799 <?php echo htmlspecialchars($row['subscriber_ss'],ENT_NOQUOTES); ?><br>
800 <?php echo htmlspecialchars(xl('D.O.B.'),ENT_NOQUOTES); ?>:
801 <?php if ($row['subscriber_DOB'] != "0000-00-00 00:00:00") echo htmlspecialchars($row['subscriber_DOB'],ENT_NOQUOTES); ?><br>
802 <?php echo htmlspecialchars(xl('Phone'),ENT_NOQUOTES); ?>:
803 <?php echo htmlspecialchars($row['subscriber_phone'],ENT_NOQUOTES); ?>
804 </span>
805 </td>
806 <td valign='top'>
807 <span class='bold'><?php echo htmlspecialchars(xl('Subscriber Address'),ENT_NOQUOTES); ?>: </span><br>
808 <span class='text'><?php echo htmlspecialchars($row['subscriber_street'],ENT_NOQUOTES); ?><br>
809 <?php echo htmlspecialchars($row['subscriber_city'],ENT_NOQUOTES); ?>
810 <?php if($row['subscriber_state'] != "") echo ", "; echo htmlspecialchars($row['subscriber_state'],ENT_NOQUOTES); ?>
811 <?php if($row['subscriber_country'] != "") echo ", "; echo htmlspecialchars($row['subscriber_country'],ENT_NOQUOTES); ?>
812 <?php echo " " . htmlspecialchars($row['subscriber_postal_code'],ENT_NOQUOTES); ?></span>
814 <?php if (trim($row['subscriber_employer'])) { ?>
815 <br><span class='bold'><?php echo htmlspecialchars(xl('Subscriber Employer'),ENT_NOQUOTES); ?>: </span><br>
816 <span class='text'><?php echo htmlspecialchars($row['subscriber_employer'],ENT_NOQUOTES); ?><br>
817 <?php echo htmlspecialchars($row['subscriber_employer_street'],ENT_NOQUOTES); ?><br>
818 <?php echo htmlspecialchars($row['subscriber_employer_city'],ENT_NOQUOTES); ?>
819 <?php if($row['subscriber_employer_city'] != "") echo ", "; echo htmlspecialchars($row['subscriber_employer_state'],ENT_NOQUOTES); ?>
820 <?php if($row['subscriber_employer_country'] != "") echo ", "; echo htmlspecialchars($row['subscriber_employer_country'],ENT_NOQUOTES); ?>
821 <?php echo " " . htmlspecialchars($row['subscriber_employer_postal_code'],ENT_NOQUOTES); ?>
822 </span>
823 <?php } ?>
825 </td>
826 </tr>
827 <tr>
828 <td>
829 <?php if ($row['copay'] != "") { ?>
830 <span class='bold'><?php echo htmlspecialchars(xl('CoPay'),ENT_NOQUOTES); ?>: </span>
831 <span class='text'><?php echo htmlspecialchars($row['copay'],ENT_NOQUOTES); ?></span>
832 <br />
833 <?php } ?>
834 <span class='bold'><?php echo htmlspecialchars(xl('Accept Assignment'),ENT_NOQUOTES); ?>:</span>
835 <span class='text'><?php if($row['accept_assignment'] == "TRUE") echo xl("YES"); ?>
836 <?php if($row['accept_assignment'] == "FALSE") echo xl("NO"); ?></span>
837 <?php if (!empty($row['policy_type'])) { ?>
838 <br />
839 <span class='bold'><?php echo htmlspecialchars(xl('Secondary Medicare Type'),ENT_NOQUOTES); ?>: </span>
840 <span class='text'><?php echo htmlspecialchars($policy_types[$row['policy_type']],ENT_NOQUOTES); ?></span>
841 <?php } ?>
842 </td>
843 <td valign='top'></td>
844 <td valign='top'></td>
845 </tr>
847 </table>
848 </div>
849 <?php
851 } // end if ($row['provider'])
852 $enddate = $row['date'];
853 $first = false;
854 } // end while
855 } // end foreach
857 // Display the eligibility information
858 echo "<div class='tab'>";
859 show_eligibility_information($pid,true);
860 echo "</div>";
862 ///////////////////////////////// END INSURANCE SECTION
864 </div>
866 <?php } // ?>
868 </td>
869 </tr>
871 <tr>
872 <td width='650px'>
874 <?php
875 // Notes expand collapse widget
876 $widgetTitle = xl("Notes");
877 $widgetLabel = "pnotes";
878 $widgetButtonLabel = xl("Edit");
879 $widgetButtonLink = "pnotes_full.php?form_active=1";
880 $widgetButtonClass = "";
881 $linkMethod = "html";
882 $bodyClass = "notab";
883 $widgetAuth = true;
884 $fixedWidth = true;
885 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
886 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
887 $widgetAuth, $fixedWidth);
890 <br/>
891 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
892 </div>
893 </td>
894 </tr>
895 <?php if ( (acl_check('patients', 'med')) && ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_prw']) ) {
896 echo "<tr><td width='650px'>";
897 // patient reminders collapse widget
898 $widgetTitle = xl("Patient Reminders");
899 $widgetLabel = "patient_reminders";
900 $widgetButtonLabel = xl("Edit");
901 $widgetButtonLink = "../reminder/patient_reminders.php?mode=simple&patient_id=".$pid;
902 $widgetButtonClass = "";
903 $linkMethod = "html";
904 $bodyClass = "notab";
905 $widgetAuth = true;
906 $fixedWidth = true;
907 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth); ?>
908 <br/>
909 <div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>
910 </div>
911 </td>
912 </tr>
913 <?php } //end if prw is activated ?>
915 <tr>
916 <td width='650px'>
917 <?php
918 // disclosures expand collapse widget
919 $widgetTitle = xl("Disclosures");
920 $widgetLabel = "disclosures";
921 $widgetButtonLabel = xl("Edit");
922 $widgetButtonLink = "disclosure_full.php";
923 $widgetButtonClass = "";
924 $linkMethod = "html";
925 $bodyClass = "notab";
926 $widgetAuth = true;
927 $fixedWidth = true;
928 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
929 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
930 $widgetAuth, $fixedWidth);
932 <br/>
933 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
934 </div>
935 </td>
936 </tr>
938 <?php if ($vitals_is_registered && acl_check('patients', 'med')) { ?>
939 <tr>
940 <td width='650px'>
941 <?php // vitals expand collapse widget
942 $widgetTitle = xl("Vitals");
943 $widgetLabel = "vitals";
944 $widgetButtonLabel = xl("Trend");
945 $widgetButtonLink = "../encounter/trend_form.php?formname=vitals";
946 $widgetButtonClass = "";
947 $linkMethod = "html";
948 $bodyClass = "notab";
949 // check to see if any vitals exist
950 $existVitals = sqlQuery("SELECT * FROM form_vitals WHERE pid=?", array($pid) );
951 if ($existVitals) {
952 $widgetAuth = true;
954 else {
955 $widgetAuth = false;
957 $fixedWidth = true;
958 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
959 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
960 $widgetAuth, $fixedWidth);
962 <br/>
963 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
964 </div>
965 </td>
966 </tr>
967 <?php } // end if ($vitals_is_registered && acl_check('patients', 'med')) ?>
969 <?php
970 // This generates a section similar to Vitals for each LBF form that
971 // supports charting. The form ID is used as the "widget label".
973 $gfres = sqlStatement("SELECT option_id, title FROM list_options WHERE " .
974 "list_id = 'lbfnames' AND option_value > 0 ORDER BY seq, title");
975 while($gfrow = sqlFetchArray($gfres)) {
977 <tr>
978 <td width='650px'>
979 <?php // vitals expand collapse widget
980 $vitals_form_id = $gfrow['option_id'];
981 $widgetTitle = $gfrow['title'];
982 $widgetLabel = $vitals_form_id;
983 $widgetButtonLabel = xl("Trend");
984 $widgetButtonLink = "../encounter/trend_form.php?formname=$vitals_form_id";
985 $widgetButtonClass = "";
986 $linkMethod = "html";
987 $bodyClass = "notab";
988 // check to see if any instances exist for this patient
989 $existVitals = sqlQuery(
990 "SELECT * FROM forms WHERE pid = ? AND formdir = ? AND deleted = 0",
991 array($pid, $vitals_form_id));
992 $widgetAuth = $existVitals ? true : false;
993 $fixedWidth = true;
994 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
995 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
996 $widgetAuth, $fixedWidth);
998 <br/>
999 <div style='margin-left:10px' class='text'>
1000 <image src='../../pic/ajax-loader.gif'/>
1001 </div>
1002 <br/>
1003 </div> <!-- This is required by expand_collapse_widget(). -->
1004 </td>
1005 </tr>
1006 <?php
1007 } // end while
1010 </table>
1012 </div>
1013 <!-- end left column div -->
1015 <!-- start right column div -->
1016 <div>
1017 <table>
1018 <tr>
1019 <td>
1021 <div>
1022 <?php
1024 // If there is an ID Card or any Photos show the widget
1025 $photos = pic_array($pid, $GLOBALS['patient_photo_category_name']);
1026 if ($photos or $idcard_doc_id )
1028 $widgetTitle = xl("ID Card") . '/' . xl("Photos");
1029 $widgetLabel = "photos";
1030 $linkMethod = "javascript";
1031 $bodyClass = "notab-right";
1032 $widgetAuth = false;
1033 $fixedWidth = false;
1034 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel ,
1035 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
1036 $widgetAuth, $fixedWidth);
1038 <br />
1039 <?php
1040 if ($idcard_doc_id) {
1041 image_widget($idcard_doc_id, $GLOBALS['patient_id_category_name']);
1044 foreach ($photos as $photo_doc_id) {
1045 image_widget($photo_doc_id, $GLOBALS['patient_photo_category_name']);
1050 <br />
1051 </div>
1052 <div>
1053 <?php
1054 // Advance Directives
1055 if ($GLOBALS['advance_directives_warning']) {
1056 // advance directives expand collapse widget
1057 $widgetTitle = xl("Advance Directives");
1058 $widgetLabel = "directives";
1059 $widgetButtonLabel = xl("Edit");
1060 $widgetButtonLink = "return advdirconfigure();";
1061 $widgetButtonClass = "";
1062 $linkMethod = "javascript";
1063 $bodyClass = "summary_item small";
1064 $widgetAuth = true;
1065 $fixedWidth = false;
1066 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1067 $counterFlag = false; //flag to record whether any categories contain ad records
1068 $query = "SELECT id FROM categories WHERE name='Advance Directive'";
1069 $myrow2 = sqlQuery($query);
1070 if ($myrow2) {
1071 $parentId = $myrow2['id'];
1072 $query = "SELECT id, name FROM categories WHERE parent=?";
1073 $resNew1 = sqlStatement($query, array($parentId) );
1074 while ($myrows3 = sqlFetchArray($resNew1)) {
1075 $categoryId = $myrows3['id'];
1076 $nameDoc = $myrows3['name'];
1077 $query = "SELECT documents.date, documents.id " .
1078 "FROM documents " .
1079 "INNER JOIN categories_to_documents " .
1080 "ON categories_to_documents.document_id=documents.id " .
1081 "WHERE categories_to_documents.category_id=? " .
1082 "AND documents.foreign_id=? " .
1083 "ORDER BY documents.date DESC";
1084 $resNew2 = sqlStatement($query, array($categoryId, $pid) );
1085 $limitCounter = 0; // limit to one entry per category
1086 while (($myrows4 = sqlFetchArray($resNew2)) && ($limitCounter == 0)) {
1087 $dateTimeDoc = $myrows4['date'];
1088 // remove time from datetime stamp
1089 $tempParse = explode(" ",$dateTimeDoc);
1090 $dateDoc = $tempParse[0];
1091 $idDoc = $myrows4['id'];
1092 echo "<a href='$web_root/controller.php?document&retrieve&patient_id=" .
1093 htmlspecialchars($pid,ENT_QUOTES) . "&document_id=" .
1094 htmlspecialchars($idDoc,ENT_QUOTES) . "&as_file=true'>" .
1095 htmlspecialchars(xl_document_category($nameDoc),ENT_NOQUOTES) . "</a> " .
1096 htmlspecialchars($dateDoc,ENT_NOQUOTES);
1097 echo "<br>";
1098 $limitCounter = $limitCounter + 1;
1099 $counterFlag = true;
1103 if (!$counterFlag) {
1104 echo "&nbsp;&nbsp;" . htmlspecialchars(xl('None'),ENT_NOQUOTES);
1105 } ?>
1106 </div>
1107 <?php } // close advanced dir block
1109 // This is a feature for a specific client. -- Rod
1110 if ($GLOBALS['cene_specific']) {
1111 echo " <br />\n";
1113 $imagedir = $GLOBALS['OE_SITE_DIR'] . "/documents/$pid/demographics";
1114 $imagepath = "$web_root/sites/" . $_SESSION['site_id'] . "/documents/$pid/demographics";
1116 echo " <a href='' onclick=\"return sendimage($pid, 'photo');\" " .
1117 "title='Click to attach patient image'>\n";
1118 if (is_file("$imagedir/photo.jpg")) {
1119 echo " <img src='$imagepath/photo.jpg' /></a>\n";
1120 } else {
1121 echo " Attach Patient Image</a><br />\n";
1123 echo " <br />&nbsp;<br />\n";
1125 echo " <a href='' onclick=\"return sendimage($pid, 'fingerprint');\" " .
1126 "title='Click to attach fingerprint'>\n";
1127 if (is_file("$imagedir/fingerprint.jpg")) {
1128 echo " <img src='$imagepath/fingerprint.jpg' /></a>\n";
1129 } else {
1130 echo " Attach Biometric Fingerprint</a><br />\n";
1132 echo " <br />&nbsp;<br />\n";
1135 // This stuff only applies to athletic team use of OpenEMR. The client
1136 // insisted on being able to quickly change fitness and return date here:
1138 if (false && $GLOBALS['athletic_team']) {
1139 // blue green yellow red orange
1140 $fitcolors = array('#6677ff','#00cc00','#ffff00','#ff3333','#ff8800','#ffeecc','#ffccaa');
1141 if (!empty($GLOBALS['fitness_colors'])) $fitcolors = $GLOBALS['fitness_colors'];
1142 $fitcolor = $fitcolors[0];
1143 $form_fitness = $_POST['form_fitness'];
1144 $form_userdate1 = fixDate($_POST['form_userdate1'], '');
1145 $form_issue_id = $_POST['form_issue_id'];
1146 if ($form_submit) {
1147 $returndate = $form_userdate1 ? "'$form_userdate1'" : "NULL";
1148 sqlStatement("UPDATE patient_data SET fitness = ?, " .
1149 "userdate1 = ? WHERE pid = ?", array($form_fitness, $returndate, $pid) );
1150 // Update return date in the designated issue, if requested.
1151 if ($form_issue_id) {
1152 sqlStatement("UPDATE lists SET returndate = ? WHERE " .
1153 "id = ?", array($returndate, $form_issue_id) );
1155 } else {
1156 $form_fitness = $result['fitness'];
1157 if (! $form_fitness) $form_fitness = 1;
1158 $form_userdate1 = $result['userdate1'];
1160 $fitcolor = $fitcolors[$form_fitness - 1];
1161 echo " <form method='post' action='demographics.php' onsubmit='return validate()'>\n";
1162 echo " <span class='bold'>Fitness to Play:</span><br />\n";
1163 echo " <select name='form_fitness' style='background-color:$fitcolor'>\n";
1164 $res = sqlStatement("SELECT * FROM list_options WHERE " .
1165 "list_id = 'fitness' ORDER BY seq");
1166 while ($row = sqlFetchArray($res)) {
1167 $key = $row['option_id'];
1168 echo " <option value='" . htmlspecialchars($key,ENT_QUOTES) . "'";
1169 if ($key == $form_fitness) echo " selected";
1170 echo ">" . htmlspecialchars($row['title'],ENT_NOQUOTES) . "</option>\n";
1172 echo " </select>\n";
1173 echo " <br /><span class='bold'>Return to Play:</span><br>\n";
1174 echo " <input type='text' size='10' name='form_userdate1' id='form_userdate1' " .
1175 "value='$form_userdate1' " .
1176 "title='" . htmlspecialchars(xl('yyyy-mm-dd Date of return to play'),ENT_QUOTES) . "' " .
1177 "onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />\n" .
1178 " <img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22' " .
1179 "id='img_userdate1' border='0' alt='[?]' style='cursor:pointer' " .
1180 "title='" . htmlspecialchars(xl('Click here to choose a date'),ENT_QUOTES) . "'>\n";
1181 echo " <input type='hidden' name='form_original_userdate1' value='" . htmlspecialchars($form_userdate1,ENT_QUOTES) . "' />\n";
1182 echo " <input type='hidden' name='form_issue_id' value='' />\n";
1183 echo "<p><input type='submit' name='form_submit' value='Change' /></p>\n";
1184 echo " </form>\n";
1187 // Show current and upcoming appointments.
1188 if (isset($pid) && !$GLOBALS['disable_calendar']) {
1189 $query = "SELECT e.pc_eid, e.pc_aid, e.pc_title, e.pc_eventDate, " .
1190 "e.pc_startTime, e.pc_hometext, u.fname, u.lname, u.mname, " .
1191 "c.pc_catname, e.pc_apptstatus " .
1192 "FROM openemr_postcalendar_events AS e, users AS u, " .
1193 "openemr_postcalendar_categories AS c WHERE " .
1194 "e.pc_pid = ? AND e.pc_eventDate >= CURRENT_DATE AND " .
1195 "u.id = e.pc_aid AND e.pc_catid = c.pc_catid " .
1196 "ORDER BY e.pc_eventDate, e.pc_startTime";
1197 $res = sqlStatement($query, array($pid) );
1199 if ( (acl_check('patients', 'med')) && ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crw']) ) {
1200 // clinical summary expand collapse widget
1201 $widgetTitle = xl("Clinical Reminders");
1202 $widgetLabel = "clinical_reminders";
1203 $widgetButtonLabel = xl("Edit");
1204 $widgetButtonLink = "../reminder/clinical_reminders.php?patient_id=".$pid;;
1205 $widgetButtonClass = "";
1206 $linkMethod = "html";
1207 $bodyClass = "summary_item small";
1208 $widgetAuth = true;
1209 $fixedWidth = false;
1210 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1211 echo "<br/>";
1212 echo "<div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>";
1213 echo "</div>";
1214 } // end if crw
1216 // appointments expand collapse widget
1217 $widgetTitle = xl("Appointments");
1218 $widgetLabel = "appointments";
1219 $widgetButtonLabel = xl("Add");
1220 $widgetButtonLink = "return newEvt();";
1221 $widgetButtonClass = "";
1222 $linkMethod = "javascript";
1223 $bodyClass = "summary_item small";
1224 $widgetAuth = (isset($res) && $res != null);
1225 $fixedWidth = false;
1226 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1227 $count = 0;
1228 while($row = sqlFetchArray($res)) {
1229 $count++;
1230 $dayname = date("l", strtotime($row['pc_eventDate']));
1231 $dispampm = "am";
1232 $disphour = substr($row['pc_startTime'], 0, 2) + 0;
1233 $dispmin = substr($row['pc_startTime'], 3, 2);
1234 if ($disphour >= 12) {
1235 $dispampm = "pm";
1236 if ($disphour > 12) $disphour -= 12;
1238 $etitle = xl('(Click to edit)');
1239 if ($row['pc_hometext'] != "") {
1240 $etitle = xl('Comments').": ".($row['pc_hometext'])."\r\n".$etitle;
1242 echo "<a href='javascript:oldEvt(" . htmlspecialchars($row['pc_eid'],ENT_QUOTES) . ")' title='" . htmlspecialchars($etitle,ENT_QUOTES) . "'>";
1243 echo "<b>" . htmlspecialchars(xl($dayname) . ", " . $row['pc_eventDate'],ENT_NOQUOTES) . "</b>" . xlt("Status") . "(";
1244 echo " " . generate_display_field(array('data_type'=>'1','list_id'=>'apptstat'),$row['pc_apptstatus']) . ")<br>"; // can't use special char parser on this
1245 echo htmlspecialchars("$disphour:$dispmin " . xl($dispampm) . " " . xl_appt_category($row['pc_catname']),ENT_NOQUOTES) . "<br>\n";
1246 echo htmlspecialchars($row['fname'] . " " . $row['lname'],ENT_NOQUOTES) . "</a><br>\n";
1248 if (isset($res) && $res != null) {
1249 if ( $count < 1 ) {
1250 echo "&nbsp;&nbsp;" . htmlspecialchars(xl('None'),ENT_NOQUOTES);
1252 echo "</div>";
1256 // Show PAST appointments.
1257 if (isset($pid) && !$GLOBALS['disable_calendar'] && $GLOBALS['num_past_appointments_to_show'] > 0) {
1258 $query = "SELECT e.pc_eid, e.pc_aid, e.pc_title, e.pc_eventDate, " .
1259 "e.pc_startTime, e.pc_hometext, u.fname, u.lname, u.mname, " .
1260 "c.pc_catname, e.pc_apptstatus " .
1261 "FROM openemr_postcalendar_events AS e, users AS u, " .
1262 "openemr_postcalendar_categories AS c WHERE " .
1263 "e.pc_pid = ? AND e.pc_eventDate < CURRENT_DATE AND " .
1264 "u.id = e.pc_aid AND e.pc_catid = c.pc_catid " .
1265 "ORDER BY e.pc_eventDate, e.pc_startTime DESC " .
1266 "LIMIT " . $GLOBALS['num_past_appointments_to_show'];
1268 $pres = sqlStatement($query, array($pid) );
1270 // appointments expand collapse widget
1271 $widgetTitle = xl("Past Appoinments");
1272 $widgetLabel = "past_appointments";
1273 $widgetButtonLabel = '';
1274 $widgetButtonLink = '';
1275 $widgetButtonClass = '';
1276 $linkMethod = "javascript";
1277 $bodyClass = "summary_item small";
1278 $widgetAuth = false; //no button
1279 $fixedWidth = false;
1280 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1281 $count = 0;
1282 while($row = sqlFetchArray($pres)) {
1283 $count++;
1284 $dayname = date("l", strtotime($row['pc_eventDate']));
1285 $dispampm = "am";
1286 $disphour = substr($row['pc_startTime'], 0, 2) + 0;
1287 $dispmin = substr($row['pc_startTime'], 3, 2);
1288 if ($disphour >= 12) {
1289 $dispampm = "pm";
1290 if ($disphour > 12) $disphour -= 12;
1292 if ($row['pc_hometext'] != "") {
1293 $etitle = xl('Comments').": ".($row['pc_hometext'])."\r\n".$etitle;
1295 echo "<a href='javascript:oldEvt(" . htmlspecialchars($row['pc_eid'],ENT_QUOTES) . ")' title='" . htmlspecialchars($etitle,ENT_QUOTES) . "'>";
1296 echo "<b>" . htmlspecialchars(xl($dayname) . ", " . $row['pc_eventDate'],ENT_NOQUOTES) . "</b>" . xlt("Status") . "(";
1297 echo " " . generate_display_field(array('data_type'=>'1','list_id'=>'apptstat'),$row['pc_apptstatus']) . ")<br>"; // can't use special char parser on this
1298 echo htmlspecialchars("$disphour:$dispmin ") . xl($dispampm) . " ";
1299 echo htmlspecialchars($row['fname'] . " " . $row['lname'],ENT_NOQUOTES) . "</a><br>\n";
1301 if (isset($pres) && $res != null) {
1302 if ( $count < 1 ) {
1303 echo "&nbsp;&nbsp;" . htmlspecialchars(xl('None'),ENT_NOQUOTES);
1305 echo "</div>";
1308 // END of past appointments
1311 </div>
1313 <div id='stats_div'>
1314 <br/>
1315 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
1316 </div>
1317 </td>
1318 </tr>
1319 </table>
1321 </div> <!-- end right column div -->
1323 </td>
1325 </tr>
1326 </table>
1328 </div> <!-- end main content div -->
1330 <?php if (false && $GLOBALS['athletic_team']) { ?>
1331 <script language='JavaScript'>
1332 Calendar.setup({inputField:"form_userdate1", ifFormat:"%Y-%m-%d", button:"img_userdate1"});
1333 </script>
1334 <?php } ?>
1336 </body>
1337 </html>