This commit helps in the following
[openemr.git] / interface / patient_file / summary / demographics.php
blobec1395d26a66803b8300fc0998051c5627208e87
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' : 200,
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;
459 if (!$thisauth) {
460 echo "<p>(" . htmlspecialchars(xl('Demographics not authorized'),ENT_NOQUOTES) . ")</p>\n";
461 echo "</body>\n</html>\n";
462 exit();
464 if ($thisauth) {
465 echo "<table><tr><td><span class='title'>" .
466 htmlspecialchars(getPatientName($pid),ENT_NOQUOTES) .
467 "</span></td>";
469 if (acl_check('admin', 'super')) {
470 echo "<td style='padding-left:1em;'><a class='css_button iframe' href='../deleter.php?patient=" .
471 htmlspecialchars($pid,ENT_QUOTES) . "'>" .
472 "<span>".htmlspecialchars(xl('Delete'),ENT_NOQUOTES).
473 "</span></a></td>";
475 if($GLOBALS['erx_enable']){
476 echo '<td style="padding-left:1em;"><a class="css_button" href="../../eRx.php?page=medentry" onclick="top.restoreSession()">';
477 echo "<span>".htmlspecialchars(xl('NewCrop MedEntry'),ENT_NOQUOTES)."</span></a></td>";
478 echo '<td style="padding-left:1em;"><a class="css_button iframe1" href="../../soap_functions/soap_accountStatusDetails.php" onclick="top.restoreSession()">';
479 echo "<span>".htmlspecialchars(xl('NewCrop Account Status'),ENT_NOQUOTES)."</span></a></td><td id='accountstatus'></td>";
481 //Patient Portal
482 $portalUserSetting = true; //flag to see if patient has authorized access to portal
483 if($GLOBALS['portal_onsite_enable'] && $GLOBALS['portal_onsite_address']){
484 $portalStatus = sqlQuery("SELECT allow_patient_portal FROM patient_data WHERE pid=?",array($pid));
485 if ($portalStatus['allow_patient_portal']=='YES') {
486 $portalLogin = sqlQuery("SELECT pid FROM `patient_access_onsite` WHERE `pid`=?", array($pid));
487 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()'>";
488 if (empty($portalLogin)) {
489 echo "<span>".htmlspecialchars(xl('Create Onsite Portal Credentials'),ENT_NOQUOTES)."</span></a></td>";
491 else {
492 echo "<span>".htmlspecialchars(xl('Reset Onsite Portal Credentials'),ENT_NOQUOTES)."</span></a></td>";
495 else {
496 $portalUserSetting = false;
499 if($GLOBALS['portal_offsite_enable'] && $GLOBALS['portal_offsite_address']){
500 $portalStatus = sqlQuery("SELECT allow_patient_portal FROM patient_data WHERE pid=?",array($pid));
501 if ($portalStatus['allow_patient_portal']=='YES') {
502 $portalLogin = sqlQuery("SELECT pid FROM `patient_access_offsite` WHERE `pid`=?", array($pid));
503 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()'>";
504 if (empty($portalLogin)) {
505 echo "<span>".htmlspecialchars(xl('Create Offsite Portal Credentials'),ENT_NOQUOTES)."</span></a></td>";
507 else {
508 echo "<span>".htmlspecialchars(xl('Reset Offsite Portal Credentials'),ENT_NOQUOTES)."</span></a></td>";
511 else {
512 $portalUserSetting = false;
515 if (!($portalUserSetting)) {
516 // Show that the patient has not authorized portal access
517 echo "<td style='padding-left:1em;'>" . htmlspecialchars( xl('Patient has not authorized the Patient Portal.'), ENT_NOQUOTES) . "</td>";
519 //Patient Portal
521 // If patient is deceased, then show this (along with the number of days patient has been deceased for)
522 $days_deceased = is_patient_deceased($pid);
523 if ($days_deceased) {
524 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>";
527 echo "</tr></table>";
530 // Get the document ID of the patient ID card if access to it is wanted here.
531 $idcard_doc_id = false;
532 if ($GLOBALS['patient_id_category_name']) {
533 $idcard_doc_id = get_document_by_catg($pid, $GLOBALS['patient_id_category_name']);
537 <table cellspacing='0' cellpadding='0' border='0'>
538 <tr>
539 <td class="small" colspan='4'>
540 <a href="../history/history.php" onclick='top.restoreSession()'>
541 <?php echo htmlspecialchars(xl('History'),ENT_NOQUOTES); ?></a>
543 <?php //note that we have temporarily removed report screen from the modal view ?>
544 <a href="../report/patient_report.php" onclick='top.restoreSession()'>
545 <?php echo htmlspecialchars(xl('Report'),ENT_NOQUOTES); ?></a>
547 <?php //note that we have temporarily removed document screen from the modal view ?>
548 <a href="../../../controller.php?document&list&patient_id=<?php echo $pid;?>" onclick='top.restoreSession()'>
549 <?php echo htmlspecialchars(xl('Documents'),ENT_NOQUOTES); ?></a>
551 <a href="../transaction/transactions.php" class='iframe large_modal' onclick='top.restoreSession()'>
552 <?php echo htmlspecialchars(xl('Transactions'),ENT_NOQUOTES); ?></a>
554 <a href="stats_full.php?active=all" onclick='top.restoreSession()'>
555 <?php echo htmlspecialchars(xl('Issues'),ENT_NOQUOTES); ?></a>
556 </td>
557 </tr>
558 </table> <!-- end header -->
560 <div style='margin-top:10px'> <!-- start main content div -->
561 <table border="0" cellspacing="0" cellpadding="0" width="100%">
562 <tr>
563 <td align="left" valign="top">
564 <!-- start left column div -->
565 <div style='float:left; margin-right:20px'>
566 <table cellspacing=0 cellpadding=0>
567 <tr<?php if ($GLOBALS['athletic_team']) echo " style='display:none;'"; ?>>
568 <td>
569 <?php
570 // Billing expand collapse widget
571 $widgetTitle = xl("Billing");
572 $widgetLabel = "billing";
573 $widgetButtonLabel = xl("Edit");
574 $widgetButtonLink = "return newEvt();";
575 $widgetButtonClass = "";
576 $linkMethod = "javascript";
577 $bodyClass = "notab";
578 $widgetAuth = false;
579 $fixedWidth = true;
580 if ($GLOBALS['force_billing_widget_open']) {
581 $forceExpandAlways = true;
583 else {
584 $forceExpandAlways = false;
586 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
587 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
588 $widgetAuth, $fixedWidth, $forceExpandAlways);
590 <br>
591 <?php
592 if ($GLOBALS['oer_config']['ws_accounting']['enabled']) {
593 // Show current balance and billing note, if any.
594 echo " <div style='margin-left: 10px; margin-right: 10px'>" .
595 "<span class='bold'><font color='#ee6600'>" .
596 htmlspecialchars(xl('Balance Due'),ENT_NOQUOTES) .
597 ": " . htmlspecialchars(oeFormatMoney(get_patient_balance($pid)),ENT_NOQUOTES) .
598 "</font></span><br>";
599 if ($result['genericname2'] == 'Billing') {
600 echo "<span class='bold'><font color='red'>" .
601 htmlspecialchars(xl('Billing Note'),ENT_NOQUOTES) . ":" .
602 htmlspecialchars($result['genericval2'],ENT_NOQUOTES) .
603 "</font></span><br>";
605 if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
606 echo "<span class='bold'>" .
607 htmlspecialchars(xl('Primary Insurance'),ENT_NOQUOTES) . ': ' . htmlspecialchars($insco_name,ENT_NOQUOTES) .
608 "</span>&nbsp;&nbsp;&nbsp;";
609 if ($result3['copay'] > 0) {
610 echo "<span class='bold'>" .
611 htmlspecialchars(xl('Copay'),ENT_NOQUOTES) . ': ' . htmlspecialchars($result3['copay'],ENT_NOQUOTES) .
612 "</span>&nbsp;&nbsp;&nbsp;";
614 echo "<span class='bold'>" .
615 htmlspecialchars(xl('Effective Date'),ENT_NOQUOTES) . ': ' . htmlspecialchars(oeFormatShortDate($result3['effdate'],ENT_NOQUOTES)) .
616 "</span>";
618 echo "</div><br>";
621 </div> <!-- required for expand_collapse_widget -->
622 </td>
623 </tr>
624 <tr>
625 <td>
626 <?php
627 // Demographics expand collapse widget
628 $widgetTitle = xl("Demographics");
629 $widgetLabel = "demographics";
630 $widgetButtonLabel = xl("Edit");
631 $widgetButtonLink = "demographics_full.php";
632 $widgetButtonClass = "";
633 $linkMethod = "html";
634 $bodyClass = "";
635 $widgetAuth = acl_check('patients', 'demo', '', 'write');
636 $fixedWidth = true;
637 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
638 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
639 $widgetAuth, $fixedWidth);
641 <div id="DEM" >
642 <ul class="tabNav">
643 <?php display_layout_tabs('DEM', $result, $result2); ?>
644 </ul>
645 <div class="tabContainer">
646 <?php display_layout_tabs_data('DEM', $result, $result2); ?>
647 </div>
648 </div>
649 </div> <!-- required for expand_collapse_widget -->
650 </td>
651 </tr>
653 <tr>
654 <td>
655 <?php
656 $insurance_count = 0;
657 foreach (array('primary','secondary','tertiary') as $instype) {
658 $enddate = 'Present';
659 $query = "SELECT * FROM insurance_data WHERE " .
660 "pid = ? AND type = ? " .
661 "ORDER BY date DESC";
662 $res = sqlStatement($query, array($pid, $instype) );
663 while( $row = sqlFetchArray($res) ) {
664 if ($row['provider'] ) $insurance_count++;
668 if ( $insurance_count > 0 ) {
669 // Insurance expand collapse widget
670 $widgetTitle = xl("Insurance");
671 $widgetLabel = "insurance";
672 $widgetButtonLabel = xl("Edit");
673 $widgetButtonLink = "demographics_full.php";
674 $widgetButtonClass = "";
675 $linkMethod = "html";
676 $bodyClass = "";
677 $widgetAuth = acl_check('patients', 'demo', '', 'write');
678 $fixedWidth = true;
679 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
680 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
681 $widgetAuth, $fixedWidth);
683 if ( $insurance_count > 0 ) {
686 <ul class="tabNav"><?php
687 ///////////////////////////////// INSURANCE SECTION
688 $first = true;
689 foreach (array('primary','secondary','tertiary') as $instype) {
691 $query = "SELECT * FROM insurance_data WHERE " .
692 "pid = ? AND type = ? " .
693 "ORDER BY date DESC";
694 $res = sqlStatement($query, array($pid, $instype) );
696 $enddate = 'Present';
698 while( $row = sqlFetchArray($res) ) {
699 if ($row['provider'] ) {
701 $ins_description = ucfirst($instype);
702 $ins_description = xl($ins_description);
703 $ins_description .= strcmp($enddate, 'Present') != 0 ? " (".xl('Old').")" : "";
705 <li <?php echo $first ? 'class="current"' : '' ?>><a href="/play/javascript-tabbed-navigation/">
706 <?php echo htmlspecialchars($ins_description,ENT_NOQUOTES); ?></a></li>
707 <?php
708 $first = false;
710 $enddate = $row['date'];
713 // Display the eligibility tab
714 echo "<li><a href='/play/javascript-tabbed-navigation/'>" .
715 htmlspecialchars( xl('Eligibility'), ENT_NOQUOTES) . "</a></li>";
717 ?></ul><?php
719 } ?>
721 <div class="tabContainer">
722 <?php
723 $first = true;
724 foreach (array('primary','secondary','tertiary') as $instype) {
725 $enddate = 'Present';
727 $query = "SELECT * FROM insurance_data WHERE " .
728 "pid = ? AND type = ? " .
729 "ORDER BY date DESC";
730 $res = sqlStatement($query, array($pid, $instype) );
731 while( $row = sqlFetchArray($res) ) {
732 if ($row['provider'] ) {
734 <div class="tab <?php echo $first ? 'current' : '' ?>">
735 <table border='0' cellpadding='0' width='100%'>
736 <?php
737 $icobj = new InsuranceCompany($row['provider']);
738 $adobj = $icobj->get_address();
739 $insco_name = trim($icobj->get_name());
741 <tr>
742 <td valign='top' colspan='3'>
743 <span class='text'>
744 <?php if (strcmp($enddate, 'Present') != 0) echo htmlspecialchars(xl("Old"),ENT_NOQUOTES)." "; ?>
745 <?php $tempinstype=ucfirst($instype); echo htmlspecialchars(xl($tempinstype.' Insurance'),ENT_NOQUOTES); ?>
746 <?php if (strcmp($row['date'], '0000-00-00') != 0) { ?>
747 <?php echo htmlspecialchars(xl('from','',' ',' ').$row['date'],ENT_NOQUOTES); ?>
748 <?php } ?>
749 <?php echo htmlspecialchars(xl('until','',' ',' '),ENT_NOQUOTES);
750 echo (strcmp($enddate, 'Present') != 0) ? $enddate : htmlspecialchars(xl('Present'),ENT_NOQUOTES); ?>:</span>
751 </td>
752 </tr>
753 <tr>
754 <td valign='top'>
755 <span class='text'>
756 <?php
757 if ($insco_name) {
758 echo htmlspecialchars($insco_name,ENT_NOQUOTES) . '<br>';
759 if (trim($adobj->get_line1())) {
760 echo htmlspecialchars($adobj->get_line1(),ENT_NOQUOTES) . '<br>';
761 echo htmlspecialchars($adobj->get_city() . ', ' . $adobj->get_state() . ' ' . $adobj->get_zip(),ENT_NOQUOTES);
763 } else {
764 echo "<font color='red'><b>".htmlspecialchars(xl('Unassigned'),ENT_NOQUOTES)."</b></font>";
767 <br>
768 <?php echo htmlspecialchars(xl('Policy Number'),ENT_NOQUOTES); ?>:
769 <?php echo htmlspecialchars($row['policy_number'],ENT_NOQUOTES) ?><br>
770 <?php echo htmlspecialchars(xl('Plan Name'),ENT_NOQUOTES); ?>:
771 <?php echo htmlspecialchars($row['plan_name'],ENT_NOQUOTES); ?><br>
772 <?php echo htmlspecialchars(xl('Group Number'),ENT_NOQUOTES); ?>:
773 <?php echo htmlspecialchars($row['group_number'],ENT_NOQUOTES); ?></span>
774 </td>
775 <td valign='top'>
776 <span class='bold'><?php echo htmlspecialchars(xl('Subscriber'),ENT_NOQUOTES); ?>: </span><br>
777 <span class='text'><?php echo htmlspecialchars($row['subscriber_fname'] . ' ' . $row['subscriber_mname'] . ' ' . $row['subscriber_lname'],ENT_NOQUOTES); ?>
778 <?php
779 if ($row['subscriber_relationship'] != "") {
780 echo "(" . htmlspecialchars($row['subscriber_relationship'],ENT_NOQUOTES) . ")";
783 <br>
784 <?php echo htmlspecialchars(xl('S.S.'),ENT_NOQUOTES); ?>:
785 <?php echo htmlspecialchars($row['subscriber_ss'],ENT_NOQUOTES); ?><br>
786 <?php echo htmlspecialchars(xl('D.O.B.'),ENT_NOQUOTES); ?>:
787 <?php if ($row['subscriber_DOB'] != "0000-00-00 00:00:00") echo htmlspecialchars($row['subscriber_DOB'],ENT_NOQUOTES); ?><br>
788 <?php echo htmlspecialchars(xl('Phone'),ENT_NOQUOTES); ?>:
789 <?php echo htmlspecialchars($row['subscriber_phone'],ENT_NOQUOTES); ?>
790 </span>
791 </td>
792 <td valign='top'>
793 <span class='bold'><?php echo htmlspecialchars(xl('Subscriber Address'),ENT_NOQUOTES); ?>: </span><br>
794 <span class='text'><?php echo htmlspecialchars($row['subscriber_street'],ENT_NOQUOTES); ?><br>
795 <?php echo htmlspecialchars($row['subscriber_city'],ENT_NOQUOTES); ?>
796 <?php if($row['subscriber_state'] != "") echo ", "; echo htmlspecialchars($row['subscriber_state'],ENT_NOQUOTES); ?>
797 <?php if($row['subscriber_country'] != "") echo ", "; echo htmlspecialchars($row['subscriber_country'],ENT_NOQUOTES); ?>
798 <?php echo " " . htmlspecialchars($row['subscriber_postal_code'],ENT_NOQUOTES); ?></span>
800 <?php if (trim($row['subscriber_employer'])) { ?>
801 <br><span class='bold'><?php echo htmlspecialchars(xl('Subscriber Employer'),ENT_NOQUOTES); ?>: </span><br>
802 <span class='text'><?php echo htmlspecialchars($row['subscriber_employer'],ENT_NOQUOTES); ?><br>
803 <?php echo htmlspecialchars($row['subscriber_employer_street'],ENT_NOQUOTES); ?><br>
804 <?php echo htmlspecialchars($row['subscriber_employer_city'],ENT_NOQUOTES); ?>
805 <?php if($row['subscriber_employer_city'] != "") echo ", "; echo htmlspecialchars($row['subscriber_employer_state'],ENT_NOQUOTES); ?>
806 <?php if($row['subscriber_employer_country'] != "") echo ", "; echo htmlspecialchars($row['subscriber_employer_country'],ENT_NOQUOTES); ?>
807 <?php echo " " . htmlspecialchars($row['subscriber_employer_postal_code'],ENT_NOQUOTES); ?>
808 </span>
809 <?php } ?>
811 </td>
812 </tr>
813 <tr>
814 <td>
815 <?php if ($row['copay'] != "") { ?>
816 <span class='bold'><?php echo htmlspecialchars(xl('CoPay'),ENT_NOQUOTES); ?>: </span>
817 <span class='text'><?php echo htmlspecialchars($row['copay'],ENT_NOQUOTES); ?></span>
818 <br />
819 <?php } ?>
820 <span class='bold'><?php echo htmlspecialchars(xl('Accept Assignment'),ENT_NOQUOTES); ?>:</span>
821 <span class='text'><?php if($row['accept_assignment'] == "TRUE") echo xl("YES"); ?>
822 <?php if($row['accept_assignment'] == "FALSE") echo xl("NO"); ?></span>
823 <?php if (!empty($row['policy_type'])) { ?>
824 <br />
825 <span class='bold'><?php echo htmlspecialchars(xl('Secondary Medicare Type'),ENT_NOQUOTES); ?>: </span>
826 <span class='text'><?php echo htmlspecialchars($policy_types[$row['policy_type']],ENT_NOQUOTES); ?></span>
827 <?php } ?>
828 </td>
829 <td valign='top'></td>
830 <td valign='top'></td>
831 </tr>
833 </table>
834 </div>
835 <?php
837 } // end if ($row['provider'])
838 $enddate = $row['date'];
839 $first = false;
840 } // end while
841 } // end foreach
843 // Display the eligibility information
844 echo "<div class='tab'>";
845 show_eligibility_information($pid,true);
846 echo "</div>";
848 ///////////////////////////////// END INSURANCE SECTION
850 </div>
852 <?php } // ?>
854 </td>
855 </tr>
857 <tr>
858 <td width='650px'>
860 <?php
861 // Notes expand collapse widget
862 $widgetTitle = xl("Notes");
863 $widgetLabel = "pnotes";
864 $widgetButtonLabel = xl("Edit");
865 $widgetButtonLink = "pnotes_full.php?form_active=1";
866 $widgetButtonClass = "";
867 $linkMethod = "html";
868 $bodyClass = "notab";
869 $widgetAuth = true;
870 $fixedWidth = true;
871 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
872 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
873 $widgetAuth, $fixedWidth);
876 <br/>
877 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
878 </div>
879 </td>
880 </tr>
881 <?php if ( (acl_check('patients', 'med')) && ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_prw']) ) {
882 echo "<tr><td width='650px'>";
883 // patient reminders collapse widget
884 $widgetTitle = xl("Patient Reminders");
885 $widgetLabel = "patient_reminders";
886 $widgetButtonLabel = xl("Edit");
887 $widgetButtonLink = "../reminder/patient_reminders.php?mode=simple&patient_id=".$pid;
888 $widgetButtonClass = "";
889 $linkMethod = "html";
890 $bodyClass = "notab";
891 $widgetAuth = true;
892 $fixedWidth = true;
893 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth); ?>
894 <br/>
895 <div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>
896 </div>
897 </td>
898 </tr>
899 <?php } //end if prw is activated ?>
901 <tr>
902 <td width='650px'>
903 <?php
904 // disclosures expand collapse widget
905 $widgetTitle = xl("Disclosures");
906 $widgetLabel = "disclosures";
907 $widgetButtonLabel = xl("Edit");
908 $widgetButtonLink = "disclosure_full.php";
909 $widgetButtonClass = "";
910 $linkMethod = "html";
911 $bodyClass = "notab";
912 $widgetAuth = true;
913 $fixedWidth = true;
914 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
915 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
916 $widgetAuth, $fixedWidth);
918 <br/>
919 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
920 </div>
921 </td>
922 </tr>
924 <?php if ($vitals_is_registered && acl_check('patients', 'med')) { ?>
925 <tr>
926 <td width='650px'>
927 <?php // vitals expand collapse widget
928 $widgetTitle = xl("Vitals");
929 $widgetLabel = "vitals";
930 $widgetButtonLabel = xl("Trend");
931 $widgetButtonLink = "../encounter/trend_form.php?formname=vitals";
932 $widgetButtonClass = "";
933 $linkMethod = "html";
934 $bodyClass = "notab";
935 // check to see if any vitals exist
936 $existVitals = sqlQuery("SELECT * FROM form_vitals WHERE pid=?", array($pid) );
937 if ($existVitals) {
938 $widgetAuth = true;
940 else {
941 $widgetAuth = false;
943 $fixedWidth = true;
944 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
945 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
946 $widgetAuth, $fixedWidth);
948 <br/>
949 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
950 </div>
951 </td>
952 </tr>
953 <?php } // end if ($vitals_is_registered && acl_check('patients', 'med')) ?>
955 <?php
956 // This generates a section similar to Vitals for each LBF form that
957 // supports charting. The form ID is used as the "widget label".
959 $gfres = sqlStatement("SELECT option_id, title FROM list_options WHERE " .
960 "list_id = 'lbfnames' AND option_value > 0 ORDER BY seq, title");
961 while($gfrow = sqlFetchArray($gfres)) {
963 <tr>
964 <td width='650px'>
965 <?php // vitals expand collapse widget
966 $vitals_form_id = $gfrow['option_id'];
967 $widgetTitle = $gfrow['title'];
968 $widgetLabel = $vitals_form_id;
969 $widgetButtonLabel = xl("Trend");
970 $widgetButtonLink = "../encounter/trend_form.php?formname=$vitals_form_id";
971 $widgetButtonClass = "";
972 $linkMethod = "html";
973 $bodyClass = "notab";
974 // check to see if any instances exist for this patient
975 $existVitals = sqlQuery(
976 "SELECT * FROM forms WHERE pid = ? AND formdir = ? AND deleted = 0",
977 array($pid, $vitals_form_id));
978 $widgetAuth = $existVitals ? true : false;
979 $fixedWidth = true;
980 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
981 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
982 $widgetAuth, $fixedWidth);
984 <br/>
985 <div style='margin-left:10px' class='text'>
986 <image src='../../pic/ajax-loader.gif'/>
987 </div>
988 <br/>
989 </div> <!-- This is required by expand_collapse_widget(). -->
990 </td>
991 </tr>
992 <?php
993 } // end while
996 </table>
998 </div>
999 <!-- end left column div -->
1001 <!-- start right column div -->
1002 <div>
1003 <table>
1004 <tr>
1005 <td>
1007 <div>
1008 <?php
1010 // If there is an ID Card or any Photos show the widget
1011 $photos = pic_array($pid, $GLOBALS['patient_photo_category_name']);
1012 if ($photos or $idcard_doc_id )
1014 $widgetTitle = xl("ID Card") . '/' . xl("Photos");
1015 $widgetLabel = "photos";
1016 $linkMethod = "javascript";
1017 $bodyClass = "notab-right";
1018 $widgetAuth = false;
1019 $fixedWidth = false;
1020 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel ,
1021 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
1022 $widgetAuth, $fixedWidth);
1024 <br />
1025 <?php
1026 if ($idcard_doc_id) {
1027 image_widget($idcard_doc_id, $GLOBALS['patient_id_category_name']);
1030 foreach ($photos as $photo_doc_id) {
1031 image_widget($photo_doc_id, $GLOBALS['patient_photo_category_name']);
1036 <br />
1037 </div>
1038 <div>
1039 <?php
1040 // Advance Directives
1041 if ($GLOBALS['advance_directives_warning']) {
1042 // advance directives expand collapse widget
1043 $widgetTitle = xl("Advance Directives");
1044 $widgetLabel = "directives";
1045 $widgetButtonLabel = xl("Edit");
1046 $widgetButtonLink = "return advdirconfigure();";
1047 $widgetButtonClass = "";
1048 $linkMethod = "javascript";
1049 $bodyClass = "summary_item small";
1050 $widgetAuth = true;
1051 $fixedWidth = false;
1052 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1053 $counterFlag = false; //flag to record whether any categories contain ad records
1054 $query = "SELECT id FROM categories WHERE name='Advance Directive'";
1055 $myrow2 = sqlQuery($query);
1056 if ($myrow2) {
1057 $parentId = $myrow2['id'];
1058 $query = "SELECT id, name FROM categories WHERE parent=?";
1059 $resNew1 = sqlStatement($query, array($parentId) );
1060 while ($myrows3 = sqlFetchArray($resNew1)) {
1061 $categoryId = $myrows3['id'];
1062 $nameDoc = $myrows3['name'];
1063 $query = "SELECT documents.date, documents.id " .
1064 "FROM documents " .
1065 "INNER JOIN categories_to_documents " .
1066 "ON categories_to_documents.document_id=documents.id " .
1067 "WHERE categories_to_documents.category_id=? " .
1068 "AND documents.foreign_id=? " .
1069 "ORDER BY documents.date DESC";
1070 $resNew2 = sqlStatement($query, array($categoryId, $pid) );
1071 $limitCounter = 0; // limit to one entry per category
1072 while (($myrows4 = sqlFetchArray($resNew2)) && ($limitCounter == 0)) {
1073 $dateTimeDoc = $myrows4['date'];
1074 // remove time from datetime stamp
1075 $tempParse = explode(" ",$dateTimeDoc);
1076 $dateDoc = $tempParse[0];
1077 $idDoc = $myrows4['id'];
1078 echo "<a href='$web_root/controller.php?document&retrieve&patient_id=" .
1079 htmlspecialchars($pid,ENT_QUOTES) . "&document_id=" .
1080 htmlspecialchars($idDoc,ENT_QUOTES) . "&as_file=true'>" .
1081 htmlspecialchars(xl_document_category($nameDoc),ENT_NOQUOTES) . "</a> " .
1082 htmlspecialchars($dateDoc,ENT_NOQUOTES);
1083 echo "<br>";
1084 $limitCounter = $limitCounter + 1;
1085 $counterFlag = true;
1089 if (!$counterFlag) {
1090 echo "&nbsp;&nbsp;" . htmlspecialchars(xl('None'),ENT_NOQUOTES);
1091 } ?>
1092 </div>
1093 <?php } // close advanced dir block
1095 // This is a feature for a specific client. -- Rod
1096 if ($GLOBALS['cene_specific']) {
1097 echo " <br />\n";
1099 $imagedir = $GLOBALS['OE_SITE_DIR'] . "/documents/$pid/demographics";
1100 $imagepath = "$web_root/sites/" . $_SESSION['site_id'] . "/documents/$pid/demographics";
1102 echo " <a href='' onclick=\"return sendimage($pid, 'photo');\" " .
1103 "title='Click to attach patient image'>\n";
1104 if (is_file("$imagedir/photo.jpg")) {
1105 echo " <img src='$imagepath/photo.jpg' /></a>\n";
1106 } else {
1107 echo " Attach Patient Image</a><br />\n";
1109 echo " <br />&nbsp;<br />\n";
1111 echo " <a href='' onclick=\"return sendimage($pid, 'fingerprint');\" " .
1112 "title='Click to attach fingerprint'>\n";
1113 if (is_file("$imagedir/fingerprint.jpg")) {
1114 echo " <img src='$imagepath/fingerprint.jpg' /></a>\n";
1115 } else {
1116 echo " Attach Biometric Fingerprint</a><br />\n";
1118 echo " <br />&nbsp;<br />\n";
1121 // This stuff only applies to athletic team use of OpenEMR. The client
1122 // insisted on being able to quickly change fitness and return date here:
1124 if (false && $GLOBALS['athletic_team']) {
1125 // blue green yellow red orange
1126 $fitcolors = array('#6677ff','#00cc00','#ffff00','#ff3333','#ff8800','#ffeecc','#ffccaa');
1127 if (!empty($GLOBALS['fitness_colors'])) $fitcolors = $GLOBALS['fitness_colors'];
1128 $fitcolor = $fitcolors[0];
1129 $form_fitness = $_POST['form_fitness'];
1130 $form_userdate1 = fixDate($_POST['form_userdate1'], '');
1131 $form_issue_id = $_POST['form_issue_id'];
1132 if ($form_submit) {
1133 $returndate = $form_userdate1 ? "'$form_userdate1'" : "NULL";
1134 sqlStatement("UPDATE patient_data SET fitness = ?, " .
1135 "userdate1 = ? WHERE pid = ?", array($form_fitness, $returndate, $pid) );
1136 // Update return date in the designated issue, if requested.
1137 if ($form_issue_id) {
1138 sqlStatement("UPDATE lists SET returndate = ? WHERE " .
1139 "id = ?", array($returndate, $form_issue_id) );
1141 } else {
1142 $form_fitness = $result['fitness'];
1143 if (! $form_fitness) $form_fitness = 1;
1144 $form_userdate1 = $result['userdate1'];
1146 $fitcolor = $fitcolors[$form_fitness - 1];
1147 echo " <form method='post' action='demographics.php' onsubmit='return validate()'>\n";
1148 echo " <span class='bold'>Fitness to Play:</span><br />\n";
1149 echo " <select name='form_fitness' style='background-color:$fitcolor'>\n";
1150 $res = sqlStatement("SELECT * FROM list_options WHERE " .
1151 "list_id = 'fitness' ORDER BY seq");
1152 while ($row = sqlFetchArray($res)) {
1153 $key = $row['option_id'];
1154 echo " <option value='" . htmlspecialchars($key,ENT_QUOTES) . "'";
1155 if ($key == $form_fitness) echo " selected";
1156 echo ">" . htmlspecialchars($row['title'],ENT_NOQUOTES) . "</option>\n";
1158 echo " </select>\n";
1159 echo " <br /><span class='bold'>Return to Play:</span><br>\n";
1160 echo " <input type='text' size='10' name='form_userdate1' id='form_userdate1' " .
1161 "value='$form_userdate1' " .
1162 "title='" . htmlspecialchars(xl('yyyy-mm-dd Date of return to play'),ENT_QUOTES) . "' " .
1163 "onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />\n" .
1164 " <img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22' " .
1165 "id='img_userdate1' border='0' alt='[?]' style='cursor:pointer' " .
1166 "title='" . htmlspecialchars(xl('Click here to choose a date'),ENT_QUOTES) . "'>\n";
1167 echo " <input type='hidden' name='form_original_userdate1' value='" . htmlspecialchars($form_userdate1,ENT_QUOTES) . "' />\n";
1168 echo " <input type='hidden' name='form_issue_id' value='' />\n";
1169 echo "<p><input type='submit' name='form_submit' value='Change' /></p>\n";
1170 echo " </form>\n";
1173 // Show current and upcoming appointments.
1174 if (isset($pid) && !$GLOBALS['disable_calendar']) {
1175 $query = "SELECT e.pc_eid, e.pc_aid, e.pc_title, e.pc_eventDate, " .
1176 "e.pc_startTime, e.pc_hometext, u.fname, u.lname, u.mname, " .
1177 "c.pc_catname, e.pc_apptstatus " .
1178 "FROM openemr_postcalendar_events AS e, users AS u, " .
1179 "openemr_postcalendar_categories AS c WHERE " .
1180 "e.pc_pid = ? AND e.pc_eventDate >= CURRENT_DATE AND " .
1181 "u.id = e.pc_aid AND e.pc_catid = c.pc_catid " .
1182 "ORDER BY e.pc_eventDate, e.pc_startTime";
1183 $res = sqlStatement($query, array($pid) );
1185 if ( (acl_check('patients', 'med')) && ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crw']) ) {
1186 // clinical summary expand collapse widget
1187 $widgetTitle = xl("Clinical Reminders");
1188 $widgetLabel = "clinical_reminders";
1189 $widgetButtonLabel = xl("Edit");
1190 $widgetButtonLink = "../reminder/clinical_reminders.php?patient_id=".$pid;;
1191 $widgetButtonClass = "";
1192 $linkMethod = "html";
1193 $bodyClass = "summary_item small";
1194 $widgetAuth = true;
1195 $fixedWidth = false;
1196 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1197 echo "<br/>";
1198 echo "<div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>";
1199 echo "</div>";
1200 } // end if crw
1202 // appointments expand collapse widget
1203 $widgetTitle = xl("Appointments");
1204 $widgetLabel = "appointments";
1205 $widgetButtonLabel = xl("Add");
1206 $widgetButtonLink = "return newEvt();";
1207 $widgetButtonClass = "";
1208 $linkMethod = "javascript";
1209 $bodyClass = "summary_item small";
1210 $widgetAuth = (isset($res) && $res != null);
1211 $fixedWidth = false;
1212 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1213 $count = 0;
1214 while($row = sqlFetchArray($res)) {
1215 $count++;
1216 $dayname = date("l", strtotime($row['pc_eventDate']));
1217 $dispampm = "am";
1218 $disphour = substr($row['pc_startTime'], 0, 2) + 0;
1219 $dispmin = substr($row['pc_startTime'], 3, 2);
1220 if ($disphour >= 12) {
1221 $dispampm = "pm";
1222 if ($disphour > 12) $disphour -= 12;
1224 $etitle = xl('(Click to edit)');
1225 if ($row['pc_hometext'] != "") {
1226 $etitle = xl('Comments').": ".($row['pc_hometext'])."\r\n".$etitle;
1228 echo "<a href='javascript:oldEvt(" . htmlspecialchars($row['pc_eid'],ENT_QUOTES) . ")' title='" . htmlspecialchars($etitle,ENT_QUOTES) . "'>";
1229 echo "<b>" . htmlspecialchars(xl($dayname) . ", " . $row['pc_eventDate'],ENT_NOQUOTES) . "</b>" . xlt("Status") . "(";
1230 echo " " . generate_display_field(array('data_type'=>'1','list_id'=>'apptstat'),$row['pc_apptstatus']) . ")<br>"; // can't use special char parser on this
1231 echo htmlspecialchars("$disphour:$dispmin " . xl($dispampm) . " " . xl_appt_category($row['pc_catname']),ENT_NOQUOTES) . "<br>\n";
1232 echo htmlspecialchars($row['fname'] . " " . $row['lname'],ENT_NOQUOTES) . "</a><br>\n";
1234 if (isset($res) && $res != null) {
1235 if ( $count < 1 ) {
1236 echo "&nbsp;&nbsp;" . htmlspecialchars(xl('None'),ENT_NOQUOTES);
1238 echo "</div>";
1242 // Show PAST appointments.
1243 if (isset($pid) && !$GLOBALS['disable_calendar'] && $GLOBALS['num_past_appointments_to_show'] > 0) {
1244 $query = "SELECT e.pc_eid, e.pc_aid, e.pc_title, e.pc_eventDate, " .
1245 "e.pc_startTime, e.pc_hometext, u.fname, u.lname, u.mname, " .
1246 "c.pc_catname, e.pc_apptstatus " .
1247 "FROM openemr_postcalendar_events AS e, users AS u, " .
1248 "openemr_postcalendar_categories AS c WHERE " .
1249 "e.pc_pid = ? AND e.pc_eventDate < CURRENT_DATE AND " .
1250 "u.id = e.pc_aid AND e.pc_catid = c.pc_catid " .
1251 "ORDER BY e.pc_eventDate, e.pc_startTime DESC " .
1252 "LIMIT " . $GLOBALS['num_past_appointments_to_show'];
1254 $pres = sqlStatement($query, array($pid) );
1256 // appointments expand collapse widget
1257 $widgetTitle = xl("Past Appoinments");
1258 $widgetLabel = "past_appointments";
1259 $widgetButtonLabel = '';
1260 $widgetButtonLink = '';
1261 $widgetButtonClass = '';
1262 $linkMethod = "javascript";
1263 $bodyClass = "summary_item small";
1264 $widgetAuth = false; //no button
1265 $fixedWidth = false;
1266 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1267 $count = 0;
1268 while($row = sqlFetchArray($pres)) {
1269 $count++;
1270 $dayname = date("l", strtotime($row['pc_eventDate']));
1271 $dispampm = "am";
1272 $disphour = substr($row['pc_startTime'], 0, 2) + 0;
1273 $dispmin = substr($row['pc_startTime'], 3, 2);
1274 if ($disphour >= 12) {
1275 $dispampm = "pm";
1276 if ($disphour > 12) $disphour -= 12;
1278 if ($row['pc_hometext'] != "") {
1279 $etitle = xl('Comments').": ".($row['pc_hometext'])."\r\n".$etitle;
1281 echo "<a href='javascript:oldEvt(" . htmlspecialchars($row['pc_eid'],ENT_QUOTES) . ")' title='" . htmlspecialchars($etitle,ENT_QUOTES) . "'>";
1282 echo "<b>" . htmlspecialchars(xl($dayname) . ", " . $row['pc_eventDate'],ENT_NOQUOTES) . "</b>" . xlt("Status") . "(";
1283 echo " " . generate_display_field(array('data_type'=>'1','list_id'=>'apptstat'),$row['pc_apptstatus']) . ")<br>"; // can't use special char parser on this
1284 echo htmlspecialchars("$disphour:$dispmin ") . xl($dispampm) . " ";
1285 echo htmlspecialchars($row['fname'] . " " . $row['lname'],ENT_NOQUOTES) . "</a><br>\n";
1287 if (isset($pres) && $res != null) {
1288 if ( $count < 1 ) {
1289 echo "&nbsp;&nbsp;" . htmlspecialchars(xl('None'),ENT_NOQUOTES);
1291 echo "</div>";
1294 // END of past appointments
1297 </div>
1299 <div id='stats_div'>
1300 <br/>
1301 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
1302 </div>
1303 </td>
1304 </tr>
1305 </table>
1307 </div> <!-- end right column div -->
1309 </td>
1311 </tr>
1312 </table>
1314 </div> <!-- end main content div -->
1316 <?php if (false && $GLOBALS['athletic_team']) { ?>
1317 <script language='JavaScript'>
1318 Calendar.setup({inputField:"form_userdate1", ifFormat:"%Y-%m-%d", button:"img_userdate1"});
1319 </script>
1320 <?php } ?>
1322 </body>
1323 </html>