Improved fix for race conditions when creating a new instance of the main window.
[openemr.git] / interface / patient_file / summary / demographics.php
blobeeeeb0c24a2d1aa5acb3d5b3ccd46fe1da1c7334
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'] && isset($_GET['set_pid'])) {
28 include_once("$srcdir/pid.inc");
29 setpid($_GET['set_pid']);
32 $active_reminders = false;
33 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']) {
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','.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 // Get patient/employer/insurance information.
124 $result = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
125 $result2 = getEmployerData($pid);
126 $result3 = getInsuranceData($pid, "primary", "copay, provider, DATE_FORMAT(`date`,'%Y-%m-%d') as effdate");
127 $insco_name = "";
128 if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
129 $insco_name = getInsuranceProvider($result3['provider']);
132 <html>
134 <head>
135 <?php html_header_show();?>
136 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
137 <link rel="stylesheet" type="text/css" href="../../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
138 <style type="text/css">@import url(../../../library/dynarch_calendar.css);</style>
139 <script type="text/javascript" src="../../../library/textformat.js"></script>
140 <script type="text/javascript" src="../../../library/dynarch_calendar.js"></script>
141 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
142 <script type="text/javascript" src="../../../library/dynarch_calendar_setup.js"></script>
143 <script type="text/javascript" src="../../../library/dialog.js"></script>
144 <script type="text/javascript" src="../../../library/js/jquery-1.6.4.min.js"></script>
145 <script type="text/javascript" src="../../../library/js/common.js"></script>
146 <script type="text/javascript" src="../../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
147 <script type="text/javascript" language="JavaScript">
149 var mypcc = '<?php echo htmlspecialchars($GLOBALS['phone_country_code'],ENT_QUOTES); ?>';
151 function oldEvt(eventid) {
152 dlgopen('../../main/calendar/add_edit_event.php?eid=' + eventid, '_blank', 550, 350);
155 function advdirconfigure() {
156 dlgopen('advancedirectives.php', '_blank', 500, 450);
159 function refreshme() {
160 top.restoreSession();
161 location.reload();
164 // Process click on Delete link.
165 function deleteme() {
166 dlgopen('../deleter.php?patient=<?php echo htmlspecialchars($pid,ENT_QUOTES); ?>', '_blank', 500, 450);
167 return false;
170 // Called by the deleteme.php window on a successful delete.
171 function imdeleted() {
172 <?php if ($GLOBALS['concurrent_layout']) { ?>
173 parent.left_nav.clearPatient();
174 <?php } else { ?>
175 top.restoreSession();
176 top.location.href = '../main/main_screen.php';
177 <?php } ?>
180 function validate() {
181 var f = document.forms[0];
182 <?php
183 if ($GLOBALS['athletic_team']) {
184 echo " if (f.form_userdate1.value != f.form_original_userdate1.value) {\n";
185 $irow = sqlQuery("SELECT id, title FROM lists WHERE " .
186 "pid = ? AND enddate IS NULL ORDER BY begdate DESC LIMIT 1", array($pid));
187 if (!empty($irow)) {
189 if (confirm('Do you wish to also set this new return date in the issue titled "<?php echo htmlspecialchars($irow['title'],ENT_QUOTES); ?>"?')) {
190 f.form_issue_id.value = '<?php echo htmlspecialchars($irow['id'],ENT_QUOTES); ?>';
191 } else {
192 alert('OK, you will need to manually update the return date in any affected issue(s).');
194 <?php } else { ?>
195 alert('You have changed the return date but there are no open issues. You probably need to create or modify one.');
196 <?php
197 } // end empty $irow
198 echo " }\n";
199 } // end athletic team
201 return true;
204 function newEvt() {
205 dlgopen('../../main/calendar/add_edit_event.php?patientid=<?php echo htmlspecialchars($pid,ENT_QUOTES); ?>', '_blank', 550, 350);
206 return false;
209 function sendimage(pid, what) {
210 // alert('Not yet implemented.'); return false;
211 dlgopen('../upload_dialog.php?patientid=' + pid + '&file=' + what,
212 '_blank', 500, 400);
213 return false;
216 </script>
218 <script type="text/javascript">
220 function toggleIndicator(target,div) {
222 $mode = $(target).find(".indicator").text();
223 if ( $mode == "<?php echo htmlspecialchars(xl('collapse'),ENT_QUOTES); ?>" ) {
224 $(target).find(".indicator").text( "<?php echo htmlspecialchars(xl('expand'),ENT_QUOTES); ?>" );
225 $("#"+div).hide();
226 $.post( "../../../library/ajax/user_settings.php", { target: div, mode: 0 });
227 } else {
228 $(target).find(".indicator").text( "<?php echo htmlspecialchars(xl('collapse'),ENT_QUOTES); ?>" );
229 $("#"+div).show();
230 $.post( "../../../library/ajax/user_settings.php", { target: div, mode: 1 });
234 $(document).ready(function(){
235 var msg_updation='';
236 <?php
237 if($GLOBALS['erx_enable']){
238 //$soap_status=sqlQuery("select soap_import_status from patient_data where pid=?",array($pid));
239 $soap_status=sqlStatement("select soap_import_status,pid from patient_data where pid=? and soap_import_status in ('1','3')",array($pid));
240 while($row_soapstatus=sqlFetchArray($soap_status)){
241 //if($soap_status['soap_import_status']=='1' || $soap_status['soap_import_status']=='3'){ ?>
242 top.restoreSession();
243 $.ajax({
244 type: "POST",
245 url: "../../soap_functions/soap_patientfullmedication.php",
246 dataType: "html",
247 data: {
248 patient:<?php echo $row_soapstatus['pid']; ?>,
250 async: false,
251 success: function(thedata){
252 //alert(thedata);
253 msg_updation+=thedata;
255 error:function(){
256 alert('ajax error');
259 <?php
260 //}
261 //elseif($soap_status['soap_import_status']=='3'){ ?>
262 top.restoreSession();
263 $.ajax({
264 type: "POST",
265 url: "../../soap_functions/soap_allergy.php",
266 dataType: "html",
267 data: {
268 patient:<?php echo $row_soapstatus['pid']; ?>,
270 async: false,
271 success: function(thedata){
272 //alert(thedata);
273 msg_updation+=thedata;
275 error:function(){
276 alert('ajax error');
279 <?php
280 if($GLOBALS['erx_import_status_message']){ ?>
281 if(msg_updation)
282 alert(msg_updation);
283 <?php
285 //}
289 // load divs
290 $("#stats_div").load("stats.php", { 'embeddedScreen' : true }, function() {
291 // (note need to place javascript code here also to get the dynamic link to work)
292 $(".rx_modal").fancybox( {
293 'overlayOpacity' : 0.0,
294 'showCloseButton' : true,
295 'frameHeight' : 500,
296 'frameWidth' : 800,
297 'centerOnScroll' : false,
298 'callbackOnClose' : function() {
299 refreshme();
303 $("#pnotes_ps_expand").load("pnotes_fragment.php");
304 $("#disclosures_ps_expand").load("disc_fragment.php");
306 <?php if ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crw']) { ?>
307 top.restoreSession();
308 $("#clinical_reminders_ps_expand").load("clinical_reminders_fragment.php", { 'embeddedScreen' : true }, function() {
309 // (note need to place javascript code here also to get the dynamic link to work)
310 $(".medium_modal").fancybox( {
311 'overlayOpacity' : 0.0,
312 'showCloseButton' : true,
313 'frameHeight' : 500,
314 'frameWidth' : 800,
315 'centerOnScroll' : false,
316 'callbackOnClose' : function() {
317 refreshme();
321 <?php } // end crw?>
323 <?php if ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_prw']) { ?>
324 top.restoreSession();
325 $("#patient_reminders_ps_expand").load("patient_reminders_fragment.php");
326 <?php } // end prw?>
328 <?php if ($vitals_is_registered && acl_check('patients', 'med')) { ?>
329 // Initialize the Vitals form if it is registered and user is authorized.
330 $("#vitals_ps_expand").load("vitals_fragment.php");
331 <?php } ?>
333 <?php
334 // Initialize for each applicable LBF form.
335 $gfres = sqlStatement("SELECT option_id FROM list_options WHERE " .
336 "list_id = 'lbfnames' AND option_value > 0 ORDER BY seq, title");
337 while($gfrow = sqlFetchArray($gfres)) {
339 $("#<?php echo $gfrow['option_id']; ?>_ps_expand").load("lbf_fragment.php?formname=<?php echo $gfrow['option_id']; ?>");
340 <?php
344 // fancy box
345 enable_modals();
347 tabbify();
349 // modal for dialog boxes
350 $(".large_modal").fancybox( {
351 'overlayOpacity' : 0.0,
352 'showCloseButton' : true,
353 'frameHeight' : 600,
354 'frameWidth' : 1000,
355 'centerOnScroll' : false
358 // modal for image viewer
359 $(".image_modal").fancybox( {
360 'overlayOpacity' : 0.0,
361 'showCloseButton' : true,
362 'centerOnScroll' : false,
363 'autoscale' : true
366 $(".iframe1").fancybox( {
367 'left':10,
368 'overlayOpacity' : 0.0,
369 'showCloseButton' : true,
370 'frameHeight' : 300,
371 'frameWidth' : 350
373 // special size for patient portal
374 $(".small_modal").fancybox( {
375 'overlayOpacity' : 0.0,
376 'showCloseButton' : true,
377 'frameHeight' : 180,
378 'frameWidth' : 380,
379 'centerOnScroll' : false
382 <?php if ($active_reminders) { ?>
383 // show the active reminder modal
384 $("#reminder_popup_link").fancybox({
385 'overlayOpacity' : 0.0,
386 'showCloseButton' : true,
387 'frameHeight' : 500,
388 'frameWidth' : 500,
389 'centerOnScroll' : false
390 }).trigger('click');
391 <?php } ?>
395 // JavaScript stuff to do when a new patient is set.
397 function setMyPatient() {
398 <?php if ($GLOBALS['concurrent_layout']) { ?>
399 // Avoid race conditions with loading of the left_nav or Title frame.
400 if (!parent.allFramesLoaded()) {
401 setTimeout("setMyPatient()", 500);
402 return;
404 <?php if (isset($_GET['set_pid'])) { ?>
405 parent.left_nav.setPatient(<?php echo "'" . htmlspecialchars(($result['fname']) . " " . ($result['lname']),ENT_QUOTES) .
406 "'," . htmlspecialchars($pid,ENT_QUOTES) . ",'" . htmlspecialchars(($result['pubpid']),ENT_QUOTES) .
407 "','', ' " . htmlspecialchars(xl('DOB') . ": " . oeFormatShortDate($result['DOB_YMD']) . " " . xl('Age') . ": " . getPatientAge($result['DOB_YMD']), ENT_QUOTES) . "'"; ?>);
408 var EncounterDateArray = new Array;
409 var CalendarCategoryArray = new Array;
410 var EncounterIdArray = new Array;
411 var Count = 0;
412 <?php
413 //Encounter details are stored to javacript as array.
414 $result4 = sqlStatement("SELECT fe.encounter,fe.date,openemr_postcalendar_categories.pc_catname FROM form_encounter AS fe ".
415 " left join openemr_postcalendar_categories on fe.pc_catid=openemr_postcalendar_categories.pc_catid WHERE fe.pid = ? order by fe.date desc", array($pid));
416 if(sqlNumRows($result4)>0) {
417 while($rowresult4 = sqlFetchArray($result4)) {
419 EncounterIdArray[Count] = '<?php echo htmlspecialchars($rowresult4['encounter'], ENT_QUOTES); ?>';
420 EncounterDateArray[Count] = '<?php echo htmlspecialchars(oeFormatShortDate(date("Y-m-d", strtotime($rowresult4['date']))), ENT_QUOTES); ?>';
421 CalendarCategoryArray[Count] = '<?php echo htmlspecialchars(xl_appt_category($rowresult4['pc_catname']), ENT_QUOTES); ?>';
422 Count++;
423 <?php
427 parent.left_nav.setPatientEncounter(EncounterIdArray,EncounterDateArray,CalendarCategoryArray);
428 <?php } // end setting new pid ?>
429 parent.left_nav.setRadio(window.name, 'dem');
430 parent.left_nav.syncRadios();
431 <?php } // end concurrent layout ?>
434 $(window).load(function() {
435 setMyPatient();
438 </script>
440 <style type="css/text">
441 #pnotes_ps_expand {
442 height:auto;
443 width:100%;
445 </style>
447 </head>
449 <body class="body_top">
451 <a href='../reminder/active_reminder_popup.php' id='reminder_popup_link' style='visibility: false;' class='iframe' onclick='top.restoreSession()'></a>
453 <?php
454 $thisauth = acl_check('patients', 'demo');
455 if ($thisauth) {
456 if ($result['squad'] && ! acl_check('squads', $result['squad']))
457 $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();
466 if ($thisauth == 'write') {
467 echo "<table><tr><td><span class='title'>" .
468 htmlspecialchars(getPatientName($pid),ENT_NOQUOTES) .
469 "</span></td>";
471 if (acl_check('admin', 'super')) {
472 echo "<td style='padding-left:1em;'><a class='css_button iframe' href='../deleter.php?patient=" .
473 htmlspecialchars($pid,ENT_QUOTES) . "'>" .
474 "<span>".htmlspecialchars(xl('Delete'),ENT_NOQUOTES).
475 "</span></a></td>";
477 if($GLOBALS['erx_enable']){
478 echo '<td style="padding-left:1em;"><a class="css_button" href="../../eRx.php?page=medentry" onclick="top.restoreSession()">';
479 echo "<span>".htmlspecialchars(xl('NewCrop MedEntry'),ENT_NOQUOTES)."</span></a></td>";
480 echo '<td style="padding-left:1em;"><a class="css_button iframe1" href="../../soap_functions/soap_accountStatusDetails.php" onclick="top.restoreSession()">';
481 echo "<span>".htmlspecialchars(xl('NewCrop Account Status'),ENT_NOQUOTES)."</span></a></td><td id='accountstatus'></td>";
483 //Patient Portal
484 $portalUserSetting = true; //flag to see if patient has authorized access to portal
485 if($GLOBALS['portal_onsite_enable'] && $GLOBALS['portal_onsite_address']){
486 $portalStatus = sqlQuery("SELECT allow_patient_portal FROM patient_data WHERE pid=?",array($pid));
487 if ($portalStatus['allow_patient_portal']=='YES') {
488 $portalLogin = sqlQuery("SELECT pid FROM `patient_access_onsite` WHERE `pid`=?", array($pid));
489 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()'>";
490 if (empty($portalLogin)) {
491 echo "<span>".htmlspecialchars(xl('Create Onsite Portal Credentials'),ENT_NOQUOTES)."</span></a></td>";
493 else {
494 echo "<span>".htmlspecialchars(xl('Reset Onsite Portal Credentials'),ENT_NOQUOTES)."</span></a></td>";
497 else {
498 $portalUserSetting = false;
501 if($GLOBALS['portal_offsite_enable'] && $GLOBALS['portal_offsite_address']){
502 $portalStatus = sqlQuery("SELECT allow_patient_portal FROM patient_data WHERE pid=?",array($pid));
503 if ($portalStatus['allow_patient_portal']=='YES') {
504 $portalLogin = sqlQuery("SELECT pid FROM `patient_access_offsite` WHERE `pid`=?", array($pid));
505 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()'>";
506 if (empty($portalLogin)) {
507 echo "<span>".htmlspecialchars(xl('Create Offsite Portal Credentials'),ENT_NOQUOTES)."</span></a></td>";
509 else {
510 echo "<span>".htmlspecialchars(xl('Reset Offsite Portal Credentials'),ENT_NOQUOTES)."</span></a></td>";
513 else {
514 $portalUserSetting = false;
517 if (!($portalUserSetting)) {
518 // Show that the patient has not authorized portal access
519 echo "<td style='padding-left:1em;'>" . htmlspecialchars( xl('Patient has not authorized the Patient Portal.'), ENT_NOQUOTES) . "</td>";
521 //Patient Portal
523 // If patient is deceased, then show this (along with the number of days patient has been deceased for)
524 $days_deceased = is_patient_deceased($pid);
525 if ($days_deceased) {
526 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>";
529 echo "</tr></table>";
532 // Get the document ID of the patient ID card if access to it is wanted here.
533 $idcard_doc_id = false;
534 if ($GLOBALS['patient_id_category_name']) {
535 $idcard_doc_id = get_document_by_catg($pid, $GLOBALS['patient_id_category_name']);
539 <table cellspacing='0' cellpadding='0' border='0'>
540 <tr>
541 <td class="small" colspan='4'>
542 <a href="../history/history.php" onclick='top.restoreSession()'>
543 <?php echo htmlspecialchars(xl('History'),ENT_NOQUOTES); ?></a>
545 <?php //note that we have temporarily removed report screen from the modal view ?>
546 <a href="../report/patient_report.php" onclick='top.restoreSession()'>
547 <?php echo htmlspecialchars(xl('Report'),ENT_NOQUOTES); ?></a>
549 <?php //note that we have temporarily removed document screen from the modal view ?>
550 <a href="../../../controller.php?document&list&patient_id=<?php echo $pid;?>" onclick='top.restoreSession()'>
551 <?php echo htmlspecialchars(xl('Documents'),ENT_NOQUOTES); ?></a>
553 <a href="../transaction/transactions.php" class='iframe large_modal' onclick='top.restoreSession()'>
554 <?php echo htmlspecialchars(xl('Transactions'),ENT_NOQUOTES); ?></a>
556 <a href="stats_full.php?active=all" onclick='top.restoreSession()'>
557 <?php echo htmlspecialchars(xl('Issues'),ENT_NOQUOTES); ?></a>
558 </td>
559 </tr>
560 </table> <!-- end header -->
562 <div style='margin-top:10px'> <!-- start main content div -->
563 <table border="0" cellspacing="0" cellpadding="0" width="100%">
564 <tr>
565 <td align="left" valign="top">
566 <!-- start left column div -->
567 <div style='float:left; margin-right:20px'>
568 <table cellspacing=0 cellpadding=0>
569 <tr<?php if ($GLOBALS['athletic_team']) echo " style='display:none;'"; ?>>
570 <td>
571 <?php
572 // Billing expand collapse widget
573 $widgetTitle = xl("Billing");
574 $widgetLabel = "billing";
575 $widgetButtonLabel = xl("Edit");
576 $widgetButtonLink = "return newEvt();";
577 $widgetButtonClass = "";
578 $linkMethod = "javascript";
579 $bodyClass = "notab";
580 $widgetAuth = false;
581 $fixedWidth = true;
582 if ($GLOBALS['force_billing_widget_open']) {
583 $forceExpandAlways = true;
585 else {
586 $forceExpandAlways = false;
588 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
589 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
590 $widgetAuth, $fixedWidth, $forceExpandAlways);
592 <br>
593 <?php
594 if ($GLOBALS['oer_config']['ws_accounting']['enabled']) {
595 // Show current balance and billing note, if any.
596 echo " <div style='margin-left: 10px; margin-right: 10px'>" .
597 "<span class='bold'><font color='#ee6600'>" .
598 htmlspecialchars(xl('Balance Due'),ENT_NOQUOTES) .
599 ": " . htmlspecialchars(oeFormatMoney(get_patient_balance($pid)),ENT_NOQUOTES) .
600 "</font></span><br>";
601 if ($result['genericname2'] == 'Billing') {
602 echo "<span class='bold'><font color='red'>" .
603 htmlspecialchars(xl('Billing Note'),ENT_NOQUOTES) . ":" .
604 htmlspecialchars($result['genericval2'],ENT_NOQUOTES) .
605 "</font></span><br>";
607 if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
608 echo "<span class='bold'>" .
609 htmlspecialchars(xl('Primary Insurance'),ENT_NOQUOTES) . ': ' . htmlspecialchars($insco_name,ENT_NOQUOTES) .
610 "</span>&nbsp;&nbsp;&nbsp;";
611 if ($result3['copay'] > 0) {
612 echo "<span class='bold'>" .
613 htmlspecialchars(xl('Copay'),ENT_NOQUOTES) . ': ' . htmlspecialchars($result3['copay'],ENT_NOQUOTES) .
614 "</span>&nbsp;&nbsp;&nbsp;";
616 echo "<span class='bold'>" .
617 htmlspecialchars(xl('Effective Date'),ENT_NOQUOTES) . ': ' . htmlspecialchars(oeFormatShortDate($result3['effdate'],ENT_NOQUOTES)) .
618 "</span>";
620 echo "</div><br>";
623 </div> <!-- required for expand_collapse_widget -->
624 </td>
625 </tr>
626 <tr>
627 <td>
628 <?php
629 // Demographics expand collapse widget
630 $widgetTitle = xl("Demographics");
631 $widgetLabel = "demographics";
632 $widgetButtonLabel = xl("Edit");
633 $widgetButtonLink = "demographics_full.php";
634 $widgetButtonClass = "";
635 $linkMethod = "html";
636 $bodyClass = "";
637 $widgetAuth = ($thisauth == "write");
638 $fixedWidth = true;
639 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
640 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
641 $widgetAuth, $fixedWidth);
643 <div id="DEM" >
644 <ul class="tabNav">
645 <?php display_layout_tabs('DEM', $result, $result2); ?>
646 </ul>
647 <div class="tabContainer">
648 <?php display_layout_tabs_data('DEM', $result, $result2); ?>
649 </div>
650 </div>
651 </div> <!-- required for expand_collapse_widget -->
652 </td>
653 </tr>
655 <tr>
656 <td>
657 <?php
658 $insurance_count = 0;
659 foreach (array('primary','secondary','tertiary') as $instype) {
660 $enddate = 'Present';
661 $query = "SELECT * FROM insurance_data WHERE " .
662 "pid = ? AND type = ? " .
663 "ORDER BY date DESC";
664 $res = sqlStatement($query, array($pid, $instype) );
665 while( $row = sqlFetchArray($res) ) {
666 if ($row['provider'] ) $insurance_count++;
670 if ( $insurance_count > 0 ) {
671 // Insurance expand collapse widget
672 $widgetTitle = xl("Insurance");
673 $widgetLabel = "insurance";
674 $widgetButtonLabel = xl("Edit");
675 $widgetButtonLink = "demographics_full.php";
676 $widgetButtonClass = "";
677 $linkMethod = "html";
678 $bodyClass = "";
679 $widgetAuth = ($thisauth == "write");
680 $fixedWidth = true;
681 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
682 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
683 $widgetAuth, $fixedWidth);
685 if ( $insurance_count > 0 ) {
688 <ul class="tabNav"><?php
689 ///////////////////////////////// INSURANCE SECTION
690 $first = true;
691 foreach (array('primary','secondary','tertiary') as $instype) {
693 $query = "SELECT * FROM insurance_data WHERE " .
694 "pid = ? AND type = ? " .
695 "ORDER BY date DESC";
696 $res = sqlStatement($query, array($pid, $instype) );
698 $enddate = 'Present';
700 while( $row = sqlFetchArray($res) ) {
701 if ($row['provider'] ) {
703 $ins_description = ucfirst($instype);
704 $ins_description = xl($ins_description);
705 $ins_description .= strcmp($enddate, 'Present') != 0 ? " (".xl('Old').")" : "";
707 <li <?php echo $first ? 'class="current"' : '' ?>><a href="/play/javascript-tabbed-navigation/">
708 <?php echo htmlspecialchars($ins_description,ENT_NOQUOTES); ?></a></li>
709 <?php
710 $first = false;
712 $enddate = $row['date'];
715 // Display the eligibility tab
716 echo "<li><a href='/play/javascript-tabbed-navigation/'>" .
717 htmlspecialchars( xl('Eligibility'), ENT_NOQUOTES) . "</a></li>";
719 ?></ul><?php
721 } ?>
723 <div class="tabContainer">
724 <?php
725 $first = true;
726 foreach (array('primary','secondary','tertiary') as $instype) {
727 $enddate = 'Present';
729 $query = "SELECT * FROM insurance_data WHERE " .
730 "pid = ? AND type = ? " .
731 "ORDER BY date DESC";
732 $res = sqlStatement($query, array($pid, $instype) );
733 while( $row = sqlFetchArray($res) ) {
734 if ($row['provider'] ) {
736 <div class="tab <?php echo $first ? 'current' : '' ?>">
737 <table border='0' cellpadding='0' width='100%'>
738 <?php
739 $icobj = new InsuranceCompany($row['provider']);
740 $adobj = $icobj->get_address();
741 $insco_name = trim($icobj->get_name());
743 <tr>
744 <td valign='top' colspan='3'>
745 <span class='text'>
746 <?php if (strcmp($enddate, 'Present') != 0) echo htmlspecialchars(xl("Old"),ENT_NOQUOTES)." "; ?>
747 <?php $tempinstype=ucfirst($instype); echo htmlspecialchars(xl($tempinstype.' Insurance'),ENT_NOQUOTES); ?>
748 <?php if (strcmp($row['date'], '0000-00-00') != 0) { ?>
749 <?php echo htmlspecialchars(xl('from','',' ',' ').$row['date'],ENT_NOQUOTES); ?>
750 <?php } ?>
751 <?php echo htmlspecialchars(xl('until','',' ',' '),ENT_NOQUOTES);
752 echo (strcmp($enddate, 'Present') != 0) ? $enddate : htmlspecialchars(xl('Present'),ENT_NOQUOTES); ?>:</span>
753 </td>
754 </tr>
755 <tr>
756 <td valign='top'>
757 <span class='text'>
758 <?php
759 if ($insco_name) {
760 echo htmlspecialchars($insco_name,ENT_NOQUOTES) . '<br>';
761 if (trim($adobj->get_line1())) {
762 echo htmlspecialchars($adobj->get_line1(),ENT_NOQUOTES) . '<br>';
763 echo htmlspecialchars($adobj->get_city() . ', ' . $adobj->get_state() . ' ' . $adobj->get_zip(),ENT_NOQUOTES);
765 } else {
766 echo "<font color='red'><b>".htmlspecialchars(xl('Unassigned'),ENT_NOQUOTES)."</b></font>";
769 <br>
770 <?php echo htmlspecialchars(xl('Policy Number'),ENT_NOQUOTES); ?>:
771 <?php echo htmlspecialchars($row['policy_number'],ENT_NOQUOTES) ?><br>
772 <?php echo htmlspecialchars(xl('Plan Name'),ENT_NOQUOTES); ?>:
773 <?php echo htmlspecialchars($row['plan_name'],ENT_NOQUOTES); ?><br>
774 <?php echo htmlspecialchars(xl('Group Number'),ENT_NOQUOTES); ?>:
775 <?php echo htmlspecialchars($row['group_number'],ENT_NOQUOTES); ?></span>
776 </td>
777 <td valign='top'>
778 <span class='bold'><?php echo htmlspecialchars(xl('Subscriber'),ENT_NOQUOTES); ?>: </span><br>
779 <span class='text'><?php echo htmlspecialchars($row['subscriber_fname'] . ' ' . $row['subscriber_mname'] . ' ' . $row['subscriber_lname'],ENT_NOQUOTES); ?>
780 <?php
781 if ($row['subscriber_relationship'] != "") {
782 echo "(" . htmlspecialchars($row['subscriber_relationship'],ENT_NOQUOTES) . ")";
785 <br>
786 <?php echo htmlspecialchars(xl('S.S.'),ENT_NOQUOTES); ?>:
787 <?php echo htmlspecialchars($row['subscriber_ss'],ENT_NOQUOTES); ?><br>
788 <?php echo htmlspecialchars(xl('D.O.B.'),ENT_NOQUOTES); ?>:
789 <?php if ($row['subscriber_DOB'] != "0000-00-00 00:00:00") echo htmlspecialchars($row['subscriber_DOB'],ENT_NOQUOTES); ?><br>
790 <?php echo htmlspecialchars(xl('Phone'),ENT_NOQUOTES); ?>:
791 <?php echo htmlspecialchars($row['subscriber_phone'],ENT_NOQUOTES); ?>
792 </span>
793 </td>
794 <td valign='top'>
795 <span class='bold'><?php echo htmlspecialchars(xl('Subscriber Address'),ENT_NOQUOTES); ?>: </span><br>
796 <span class='text'><?php echo htmlspecialchars($row['subscriber_street'],ENT_NOQUOTES); ?><br>
797 <?php echo htmlspecialchars($row['subscriber_city'],ENT_NOQUOTES); ?>
798 <?php if($row['subscriber_state'] != "") echo ", "; echo htmlspecialchars($row['subscriber_state'],ENT_NOQUOTES); ?>
799 <?php if($row['subscriber_country'] != "") echo ", "; echo htmlspecialchars($row['subscriber_country'],ENT_NOQUOTES); ?>
800 <?php echo " " . htmlspecialchars($row['subscriber_postal_code'],ENT_NOQUOTES); ?></span>
802 <?php if (trim($row['subscriber_employer'])) { ?>
803 <br><span class='bold'><?php echo htmlspecialchars(xl('Subscriber Employer'),ENT_NOQUOTES); ?>: </span><br>
804 <span class='text'><?php echo htmlspecialchars($row['subscriber_employer'],ENT_NOQUOTES); ?><br>
805 <?php echo htmlspecialchars($row['subscriber_employer_street'],ENT_NOQUOTES); ?><br>
806 <?php echo htmlspecialchars($row['subscriber_employer_city'],ENT_NOQUOTES); ?>
807 <?php if($row['subscriber_employer_city'] != "") echo ", "; echo htmlspecialchars($row['subscriber_employer_state'],ENT_NOQUOTES); ?>
808 <?php if($row['subscriber_employer_country'] != "") echo ", "; echo htmlspecialchars($row['subscriber_employer_country'],ENT_NOQUOTES); ?>
809 <?php echo " " . htmlspecialchars($row['subscriber_employer_postal_code'],ENT_NOQUOTES); ?>
810 </span>
811 <?php } ?>
813 </td>
814 </tr>
815 <tr>
816 <td>
817 <?php if ($row['copay'] != "") { ?>
818 <span class='bold'><?php echo htmlspecialchars(xl('CoPay'),ENT_NOQUOTES); ?>: </span>
819 <span class='text'><?php echo htmlspecialchars($row['copay'],ENT_NOQUOTES); ?></span>
820 <br />
821 <?php } ?>
822 <span class='bold'><?php echo htmlspecialchars(xl('Accept Assignment'),ENT_NOQUOTES); ?>:</span>
823 <span class='text'><?php if($row['accept_assignment'] == "TRUE") echo xl("YES"); ?>
824 <?php if($row['accept_assignment'] == "FALSE") echo xl("NO"); ?></span>
825 <?php if (!empty($row['policy_type'])) { ?>
826 <br />
827 <span class='bold'><?php echo htmlspecialchars(xl('Secondary Medicare Type'),ENT_NOQUOTES); ?>: </span>
828 <span class='text'><?php echo htmlspecialchars($policy_types[$row['policy_type']],ENT_NOQUOTES); ?></span>
829 <?php } ?>
830 </td>
831 <td valign='top'></td>
832 <td valign='top'></td>
833 </tr>
835 </table>
836 </div>
837 <?php
839 } // end if ($row['provider'])
840 $enddate = $row['date'];
841 $first = false;
842 } // end while
843 } // end foreach
845 // Display the eligibility information
846 echo "<div class='tab'>";
847 show_eligibility_information($pid,true);
848 echo "</div>";
850 ///////////////////////////////// END INSURANCE SECTION
852 </div>
854 <?php } // ?>
856 </td>
857 </tr>
859 <tr>
860 <td width='650px'>
862 <?php
863 // Notes expand collapse widget
864 $widgetTitle = xl("Notes");
865 $widgetLabel = "pnotes";
866 $widgetButtonLabel = xl("Edit");
867 $widgetButtonLink = "pnotes_full.php?form_active=1";
868 $widgetButtonClass = "";
869 $linkMethod = "html";
870 $bodyClass = "notab";
871 $widgetAuth = true;
872 $fixedWidth = true;
873 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
874 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
875 $widgetAuth, $fixedWidth);
878 <br/>
879 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
880 </div>
881 </td>
882 </tr>
883 <?php if ( (acl_check('patients', 'med')) && ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_prw']) ) {
884 echo "<tr><td width='650px'>";
885 // patient reminders collapse widget
886 $widgetTitle = xl("Patient Reminders");
887 $widgetLabel = "patient_reminders";
888 $widgetButtonLabel = xl("Edit");
889 $widgetButtonLink = "../reminder/patient_reminders.php?mode=simple&patient_id=".$pid;
890 $widgetButtonClass = "";
891 $linkMethod = "html";
892 $bodyClass = "notab";
893 $widgetAuth = true;
894 $fixedWidth = true;
895 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth); ?>
896 <br/>
897 <div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>
898 </div>
899 </td>
900 </tr>
901 <?php } //end if prw is activated ?>
903 <tr>
904 <td width='650px'>
905 <?php
906 // disclosures expand collapse widget
907 $widgetTitle = xl("Disclosures");
908 $widgetLabel = "disclosures";
909 $widgetButtonLabel = xl("Edit");
910 $widgetButtonLink = "disclosure_full.php";
911 $widgetButtonClass = "";
912 $linkMethod = "html";
913 $bodyClass = "notab";
914 $widgetAuth = true;
915 $fixedWidth = true;
916 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
917 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
918 $widgetAuth, $fixedWidth);
920 <br/>
921 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
922 </div>
923 </td>
924 </tr>
926 <?php if ($vitals_is_registered && acl_check('patients', 'med')) { ?>
927 <tr>
928 <td width='650px'>
929 <?php // vitals expand collapse widget
930 $widgetTitle = xl("Vitals");
931 $widgetLabel = "vitals";
932 $widgetButtonLabel = xl("Trend");
933 $widgetButtonLink = "../encounter/trend_form.php?formname=vitals";
934 $widgetButtonClass = "";
935 $linkMethod = "html";
936 $bodyClass = "notab";
937 // check to see if any vitals exist
938 $existVitals = sqlQuery("SELECT * FROM form_vitals WHERE pid=?", array($pid) );
939 if ($existVitals) {
940 $widgetAuth = true;
942 else {
943 $widgetAuth = false;
945 $fixedWidth = true;
946 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
947 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
948 $widgetAuth, $fixedWidth);
950 <br/>
951 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
952 </div>
953 </td>
954 </tr>
955 <?php } // end if ($vitals_is_registered && acl_check('patients', 'med')) ?>
957 <?php
958 // This generates a section similar to Vitals for each LBF form that
959 // supports charting. The form ID is used as the "widget label".
961 $gfres = sqlStatement("SELECT option_id, title FROM list_options WHERE " .
962 "list_id = 'lbfnames' AND option_value > 0 ORDER BY seq, title");
963 while($gfrow = sqlFetchArray($gfres)) {
965 <tr>
966 <td width='650px'>
967 <?php // vitals expand collapse widget
968 $vitals_form_id = $gfrow['option_id'];
969 $widgetTitle = $gfrow['title'];
970 $widgetLabel = $vitals_form_id;
971 $widgetButtonLabel = xl("Trend");
972 $widgetButtonLink = "../encounter/trend_form.php?formname=$vitals_form_id";
973 $widgetButtonClass = "";
974 $linkMethod = "html";
975 $bodyClass = "notab";
976 // check to see if any instances exist for this patient
977 $existVitals = sqlQuery(
978 "SELECT * FROM forms WHERE pid = ? AND formdir = ? AND deleted = 0",
979 array($pid, $vitals_form_id));
980 $widgetAuth = $existVitals ? true : false;
981 $fixedWidth = true;
982 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
983 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
984 $widgetAuth, $fixedWidth);
986 <br/>
987 <div style='margin-left:10px' class='text'>
988 <image src='../../pic/ajax-loader.gif'/>
989 </div>
990 <br/>
991 </div> <!-- This is required by expand_collapse_widget(). -->
992 </td>
993 </tr>
994 <?php
995 } // end while
998 </table>
1000 </div>
1001 <!-- end left column div -->
1003 <!-- start right column div -->
1004 <div>
1005 <table>
1006 <tr>
1007 <td>
1009 <div>
1010 <?php
1012 // If there is an ID Card or any Photos show the widget
1013 $photos = pic_array($pid, $GLOBALS['patient_photo_category_name']);
1014 if ($photos or $idcard_doc_id )
1016 $widgetTitle = xl("ID Card") . '/' . xl("Photos");
1017 $widgetLabel = "photos";
1018 $linkMethod = "javascript";
1019 $bodyClass = "notab-right";
1020 $widgetAuth = false;
1021 $fixedWidth = false;
1022 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel ,
1023 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
1024 $widgetAuth, $fixedWidth);
1026 <br />
1027 <?php
1028 if ($idcard_doc_id) {
1029 image_widget($idcard_doc_id, $GLOBALS['patient_id_category_name']);
1032 foreach ($photos as $photo_doc_id) {
1033 image_widget($photo_doc_id, $GLOBALS['patient_photo_category_name']);
1038 <br />
1039 </div>
1040 <div>
1041 <?php
1042 // Advance Directives
1043 if ($GLOBALS['advance_directives_warning']) {
1044 // advance directives expand collapse widget
1045 $widgetTitle = xl("Advance Directives");
1046 $widgetLabel = "directives";
1047 $widgetButtonLabel = xl("Edit");
1048 $widgetButtonLink = "return advdirconfigure();";
1049 $widgetButtonClass = "";
1050 $linkMethod = "javascript";
1051 $bodyClass = "summary_item small";
1052 $widgetAuth = true;
1053 $fixedWidth = false;
1054 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1055 $counterFlag = false; //flag to record whether any categories contain ad records
1056 $query = "SELECT id FROM categories WHERE name='Advance Directive'";
1057 $myrow2 = sqlQuery($query);
1058 if ($myrow2) {
1059 $parentId = $myrow2['id'];
1060 $query = "SELECT id, name FROM categories WHERE parent=?";
1061 $resNew1 = sqlStatement($query, array($parentId) );
1062 while ($myrows3 = sqlFetchArray($resNew1)) {
1063 $categoryId = $myrows3['id'];
1064 $nameDoc = $myrows3['name'];
1065 $query = "SELECT documents.date, documents.id " .
1066 "FROM documents " .
1067 "INNER JOIN categories_to_documents " .
1068 "ON categories_to_documents.document_id=documents.id " .
1069 "WHERE categories_to_documents.category_id=? " .
1070 "AND documents.foreign_id=? " .
1071 "ORDER BY documents.date DESC";
1072 $resNew2 = sqlStatement($query, array($categoryId, $pid) );
1073 $limitCounter = 0; // limit to one entry per category
1074 while (($myrows4 = sqlFetchArray($resNew2)) && ($limitCounter == 0)) {
1075 $dateTimeDoc = $myrows4['date'];
1076 // remove time from datetime stamp
1077 $tempParse = explode(" ",$dateTimeDoc);
1078 $dateDoc = $tempParse[0];
1079 $idDoc = $myrows4['id'];
1080 echo "<a href='$web_root/controller.php?document&retrieve&patient_id=" .
1081 htmlspecialchars($pid,ENT_QUOTES) . "&document_id=" .
1082 htmlspecialchars($idDoc,ENT_QUOTES) . "&as_file=true'>" .
1083 htmlspecialchars(xl_document_category($nameDoc),ENT_NOQUOTES) . "</a> " .
1084 htmlspecialchars($dateDoc,ENT_NOQUOTES);
1085 echo "<br>";
1086 $limitCounter = $limitCounter + 1;
1087 $counterFlag = true;
1091 if (!$counterFlag) {
1092 echo "&nbsp;&nbsp;" . htmlspecialchars(xl('None'),ENT_NOQUOTES);
1093 } ?>
1094 </div>
1095 <?php } // close advanced dir block
1097 // This is a feature for a specific client. -- Rod
1098 if ($GLOBALS['cene_specific']) {
1099 echo " <br />\n";
1101 $imagedir = $GLOBALS['OE_SITE_DIR'] . "/documents/$pid/demographics";
1102 $imagepath = "$web_root/sites/" . $_SESSION['site_id'] . "/documents/$pid/demographics";
1104 echo " <a href='' onclick=\"return sendimage($pid, 'photo');\" " .
1105 "title='Click to attach patient image'>\n";
1106 if (is_file("$imagedir/photo.jpg")) {
1107 echo " <img src='$imagepath/photo.jpg' /></a>\n";
1108 } else {
1109 echo " Attach Patient Image</a><br />\n";
1111 echo " <br />&nbsp;<br />\n";
1113 echo " <a href='' onclick=\"return sendimage($pid, 'fingerprint');\" " .
1114 "title='Click to attach fingerprint'>\n";
1115 if (is_file("$imagedir/fingerprint.jpg")) {
1116 echo " <img src='$imagepath/fingerprint.jpg' /></a>\n";
1117 } else {
1118 echo " Attach Biometric Fingerprint</a><br />\n";
1120 echo " <br />&nbsp;<br />\n";
1123 // This stuff only applies to athletic team use of OpenEMR. The client
1124 // insisted on being able to quickly change fitness and return date here:
1126 if (false && $GLOBALS['athletic_team']) {
1127 // blue green yellow red orange
1128 $fitcolors = array('#6677ff','#00cc00','#ffff00','#ff3333','#ff8800','#ffeecc','#ffccaa');
1129 if (!empty($GLOBALS['fitness_colors'])) $fitcolors = $GLOBALS['fitness_colors'];
1130 $fitcolor = $fitcolors[0];
1131 $form_fitness = $_POST['form_fitness'];
1132 $form_userdate1 = fixDate($_POST['form_userdate1'], '');
1133 $form_issue_id = $_POST['form_issue_id'];
1134 if ($form_submit) {
1135 $returndate = $form_userdate1 ? "'$form_userdate1'" : "NULL";
1136 sqlStatement("UPDATE patient_data SET fitness = ?, " .
1137 "userdate1 = ? WHERE pid = ?", array($form_fitness, $returndate, $pid) );
1138 // Update return date in the designated issue, if requested.
1139 if ($form_issue_id) {
1140 sqlStatement("UPDATE lists SET returndate = ? WHERE " .
1141 "id = ?", array($returndate, $form_issue_id) );
1143 } else {
1144 $form_fitness = $result['fitness'];
1145 if (! $form_fitness) $form_fitness = 1;
1146 $form_userdate1 = $result['userdate1'];
1148 $fitcolor = $fitcolors[$form_fitness - 1];
1149 echo " <form method='post' action='demographics.php' onsubmit='return validate()'>\n";
1150 echo " <span class='bold'>Fitness to Play:</span><br />\n";
1151 echo " <select name='form_fitness' style='background-color:$fitcolor'>\n";
1152 $res = sqlStatement("SELECT * FROM list_options WHERE " .
1153 "list_id = 'fitness' ORDER BY seq");
1154 while ($row = sqlFetchArray($res)) {
1155 $key = $row['option_id'];
1156 echo " <option value='" . htmlspecialchars($key,ENT_QUOTES) . "'";
1157 if ($key == $form_fitness) echo " selected";
1158 echo ">" . htmlspecialchars($row['title'],ENT_NOQUOTES) . "</option>\n";
1160 echo " </select>\n";
1161 echo " <br /><span class='bold'>Return to Play:</span><br>\n";
1162 echo " <input type='text' size='10' name='form_userdate1' id='form_userdate1' " .
1163 "value='$form_userdate1' " .
1164 "title='" . htmlspecialchars(xl('yyyy-mm-dd Date of return to play'),ENT_QUOTES) . "' " .
1165 "onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />\n" .
1166 " <img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22' " .
1167 "id='img_userdate1' border='0' alt='[?]' style='cursor:pointer' " .
1168 "title='" . htmlspecialchars(xl('Click here to choose a date'),ENT_QUOTES) . "'>\n";
1169 echo " <input type='hidden' name='form_original_userdate1' value='" . htmlspecialchars($form_userdate1,ENT_QUOTES) . "' />\n";
1170 echo " <input type='hidden' name='form_issue_id' value='' />\n";
1171 echo "<p><input type='submit' name='form_submit' value='Change' /></p>\n";
1172 echo " </form>\n";
1175 // Show current and upcoming appointments.
1176 if (isset($pid) && !$GLOBALS['disable_calendar']) {
1177 $query = "SELECT e.pc_eid, e.pc_aid, e.pc_title, e.pc_eventDate, " .
1178 "e.pc_startTime, e.pc_hometext, u.fname, u.lname, u.mname, " .
1179 "c.pc_catname " .
1180 "FROM openemr_postcalendar_events AS e, users AS u, " .
1181 "openemr_postcalendar_categories AS c WHERE " .
1182 "e.pc_pid = ? AND e.pc_eventDate >= CURRENT_DATE AND " .
1183 "u.id = e.pc_aid AND e.pc_catid = c.pc_catid " .
1184 "ORDER BY e.pc_eventDate, e.pc_startTime";
1185 $res = sqlStatement($query, array($pid) );
1187 if ( (acl_check('patients', 'med')) && ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crw']) ) {
1188 // clinical summary expand collapse widget
1189 $widgetTitle = xl("Clinical Reminders");
1190 $widgetLabel = "clinical_reminders";
1191 $widgetButtonLabel = xl("Edit");
1192 $widgetButtonLink = "../reminder/clinical_reminders.php?patient_id=".$pid;;
1193 $widgetButtonClass = "";
1194 $linkMethod = "html";
1195 $bodyClass = "summary_item small";
1196 $widgetAuth = true;
1197 $fixedWidth = false;
1198 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1199 echo "<br/>";
1200 echo "<div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>";
1201 echo "</div>";
1202 } // end if crw
1204 // appointments expand collapse widget
1205 $widgetTitle = xl("Appointments");
1206 $widgetLabel = "appointments";
1207 $widgetButtonLabel = xl("Add");
1208 $widgetButtonLink = "return newEvt();";
1209 $widgetButtonClass = "";
1210 $linkMethod = "javascript";
1211 $bodyClass = "summary_item small";
1212 $widgetAuth = (isset($res) && $res != null);
1213 $fixedWidth = false;
1214 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1216 $count = 0;
1217 while($row = sqlFetchArray($res)) {
1218 $count++;
1219 $dayname = date("l", strtotime($row['pc_eventDate']));
1220 $dispampm = "am";
1221 $disphour = substr($row['pc_startTime'], 0, 2) + 0;
1222 $dispmin = substr($row['pc_startTime'], 3, 2);
1223 if ($disphour >= 12) {
1224 $dispampm = "pm";
1225 if ($disphour > 12) $disphour -= 12;
1227 $etitle = xl('(Click to edit)');
1228 if ($row['pc_hometext'] != "") {
1229 $etitle = xl('Comments').": ".($row['pc_hometext'])."\r\n".$etitle;
1231 echo "<a href='javascript:oldEvt(" . htmlspecialchars($row['pc_eid'],ENT_QUOTES) .
1232 ")' title='" . htmlspecialchars($etitle,ENT_QUOTES) . "'>";
1233 echo "<b>" . htmlspecialchars(xl($dayname) . ", " . $row['pc_eventDate'],ENT_NOQUOTES) . "</b><br>";
1234 echo htmlspecialchars("$disphour:$dispmin " . xl($dispampm) . " " . xl_appt_category($row['pc_catname']),ENT_NOQUOTES) . "<br>\n";
1235 echo htmlspecialchars($row['fname'] . " " . $row['lname'],ENT_NOQUOTES) . "</a><br>\n";
1237 if (isset($res) && $res != null) {
1238 if ( $count < 1 ) { echo "&nbsp;&nbsp;" . htmlspecialchars(xl('None'),ENT_NOQUOTES); }
1239 echo "</div>";
1243 </div>
1245 <div id='stats_div'>
1246 <br/>
1247 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
1248 </div>
1249 </td>
1250 </tr>
1251 </table>
1253 </div> <!-- end right column div -->
1255 </td>
1257 </tr>
1258 </table>
1260 </div> <!-- end main content div -->
1262 <?php if (false && $GLOBALS['athletic_team']) { ?>
1263 <script language='JavaScript'>
1264 Calendar.setup({inputField:"form_userdate1", ifFormat:"%Y-%m-%d", button:"img_userdate1"});
1265 </script>
1266 <?php } ?>
1268 </body>
1269 </html>