Allows display of appointments in descending order, take 2.
[openemr.git] / interface / patient_file / summary / demographics.php
blob75e5828fa728c590d80681ec41843cf9aa0ba1a5
1 <?php
2 /**
4 * Patient summary screen.
6 * LICENSE: This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
17 * @package OpenEMR
18 * @author Brady Miller <brady@sparmy.com>
19 * @link http://www.open-emr.org
22 //SANITIZE ALL ESCAPES
23 $sanitize_all_escapes=true;
26 //STOP FAKE REGISTER GLOBALS
27 $fake_register_globals=false;
30 require_once("../../globals.php");
31 require_once("$srcdir/patient.inc");
32 require_once("$srcdir/acl.inc");
33 require_once("$srcdir/classes/Address.class.php");
34 require_once("$srcdir/classes/InsuranceCompany.class.php");
35 require_once("$srcdir/classes/Document.class.php");
36 require_once("$srcdir/options.inc.php");
37 require_once("../history/history.inc.php");
38 require_once("$srcdir/formatting.inc.php");
39 require_once("$srcdir/edi.inc");
40 require_once("$srcdir/invoice_summary.inc.php");
41 require_once("$srcdir/clinical_rules.php");
43 if ($GLOBALS['concurrent_layout'] && isset($_GET['set_pid'])) {
44 include_once("$srcdir/pid.inc");
45 setpid($_GET['set_pid']);
48 $active_reminders = false;
49 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']) {
50 // showing a new patient, so check for active reminders
51 $active_reminders = active_alert_summary($pid,"reminders-due");
54 function print_as_money($money) {
55 preg_match("/(\d*)\.?(\d*)/",$money,$moneymatches);
56 $tmp = wordwrap(strrev($moneymatches[1]),3,",",1);
57 $ccheck = strrev($tmp);
58 if ($ccheck[0] == ",") {
59 $tmp = substr($ccheck,1,strlen($ccheck)-1);
61 if ($moneymatches[2] != "") {
62 return "$ " . strrev($tmp) . "." . $moneymatches[2];
63 } else {
64 return "$ " . strrev($tmp);
68 // get an array from Photos category
69 function pic_array($pid,$picture_directory) {
70 $pics = array();
71 $sql_query = "select documents.id from documents join categories_to_documents " .
72 "on documents.id = categories_to_documents.document_id " .
73 "join categories on categories.id = categories_to_documents.category_id " .
74 "where categories.name like ? and documents.foreign_id = ?";
75 if ($query = sqlStatement($sql_query, array($picture_directory,$pid))) {
76 while( $results = sqlFetchArray($query) ) {
77 array_push($pics,$results['id']);
80 return ($pics);
82 // Get the document ID of the first document in a specific catg.
83 function get_document_by_catg($pid,$doc_catg) {
85 $result = array();
87 if ($pid and $doc_catg) {
88 $result = sqlQuery("SELECT d.id, d.date, d.url FROM " .
89 "documents AS d, categories_to_documents AS cd, categories AS c " .
90 "WHERE d.foreign_id = ? " .
91 "AND cd.document_id = d.id " .
92 "AND c.id = cd.category_id " .
93 "AND c.name LIKE ? " .
94 "ORDER BY d.date DESC LIMIT 1", array($pid, $doc_catg) );
97 return($result['id']);
100 // Display image in 'widget style'
101 function image_widget($doc_id,$doc_catg)
103 global $pid, $web_root;
104 $docobj = new Document($doc_id);
105 $image_file = $docobj->get_url_file();
106 $extension = substr($image_file, strrpos($image_file,"."));
107 $viewable_types = array('.png','.jpg','.jpeg','.png','.bmp','.PNG','.JPG','.JPEG','.PNG','.BMP'); // image ext supported by fancybox viewer
108 if ( in_array($extension,$viewable_types) ) { // extention matches list
109 $to_url = "<td> <a href = $web_root" .
110 "/controller.php?document&retrieve&patient_id=$pid&document_id=$doc_id" .
111 "/tmp$extension" . // Force image type URL for fancybox
112 " onclick=top.restoreSession(); class='image_modal'>" .
113 " <img src = $web_root" .
114 "/controller.php?document&retrieve&patient_id=$pid&document_id=$doc_id" .
115 " width=100 alt='$doc_catg:$image_file'> </a> </td> <td valign='center'>".
116 htmlspecialchars($doc_catg) . '<br />&nbsp;' . htmlspecialchars($image_file) .
117 "</td>";
119 else {
120 $to_url = "<td> <a href='" . $web_root . "/controller.php?document&retrieve" .
121 "&patient_id=$pid&document_id=$doc_id'" .
122 " onclick='top.restoreSession()' class='css_button_small'>" .
123 "<span>" .
124 htmlspecialchars( xl("View"), ENT_QUOTES )."</a> &nbsp;" .
125 htmlspecialchars( "$doc_catg - $image_file", ENT_QUOTES ) .
126 "</span> </td>";
128 echo "<table><tr>";
129 echo $to_url;
130 echo "</tr></table>";
133 // Determine if the Vitals form is in use for this site.
134 $tmp = sqlQuery("SELECT count(*) AS count FROM registry WHERE " .
135 "directory = 'vitals' AND state = 1");
136 $vitals_is_registered = $tmp['count'];
138 // Get patient/employer/insurance information.
140 $result = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
141 $result2 = getEmployerData($pid);
142 $result3 = getInsuranceData($pid, "primary", "copay, provider, DATE_FORMAT(`date`,'%Y-%m-%d') as effdate");
143 $insco_name = "";
144 if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
145 $insco_name = getInsuranceProvider($result3['provider']);
148 <html>
150 <head>
151 <?php html_header_show();?>
152 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
153 <link rel="stylesheet" type="text/css" href="../../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
154 <style type="text/css">@import url(../../../library/dynarch_calendar.css);</style>
155 <script type="text/javascript" src="../../../library/textformat.js"></script>
156 <script type="text/javascript" src="../../../library/dynarch_calendar.js"></script>
157 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
158 <script type="text/javascript" src="../../../library/dynarch_calendar_setup.js"></script>
159 <script type="text/javascript" src="../../../library/dialog.js"></script>
160 <script type="text/javascript" src="../../../library/js/jquery-1.6.4.min.js"></script>
161 <script type="text/javascript" src="../../../library/js/common.js"></script>
162 <script type="text/javascript" src="../../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
163 <script type="text/javascript" language="JavaScript">
165 var mypcc = '<?php echo htmlspecialchars($GLOBALS['phone_country_code'],ENT_QUOTES); ?>';
167 function oldEvt(eventid) {
168 dlgopen('../../main/calendar/add_edit_event.php?eid=' + eventid, '_blank', 550, 350);
171 function advdirconfigure() {
172 dlgopen('advancedirectives.php', '_blank', 500, 450);
175 function refreshme() {
176 top.restoreSession();
177 location.reload();
180 // Process click on Delete link.
181 function deleteme() {
182 dlgopen('../deleter.php?patient=<?php echo htmlspecialchars($pid,ENT_QUOTES); ?>', '_blank', 500, 450);
183 return false;
186 // Called by the deleteme.php window on a successful delete.
187 function imdeleted() {
188 <?php if ($GLOBALS['concurrent_layout']) { ?>
189 parent.left_nav.clearPatient();
190 <?php } else { ?>
191 top.restoreSession();
192 top.location.href = '../main/main_screen.php';
193 <?php } ?>
196 function validate() {
197 var f = document.forms[0];
198 <?php
199 if ($GLOBALS['athletic_team']) {
200 echo " if (f.form_userdate1.value != f.form_original_userdate1.value) {\n";
201 $irow = sqlQuery("SELECT id, title FROM lists WHERE " .
202 "pid = ? AND enddate IS NULL ORDER BY begdate DESC LIMIT 1", array($pid));
203 if (!empty($irow)) {
205 if (confirm('Do you wish to also set this new return date in the issue titled "<?php echo htmlspecialchars($irow['title'],ENT_QUOTES); ?>"?')) {
206 f.form_issue_id.value = '<?php echo htmlspecialchars($irow['id'],ENT_QUOTES); ?>';
207 } else {
208 alert('OK, you will need to manually update the return date in any affected issue(s).');
210 <?php } else { ?>
211 alert('You have changed the return date but there are no open issues. You probably need to create or modify one.');
212 <?php
213 } // end empty $irow
214 echo " }\n";
215 } // end athletic team
217 return true;
220 function newEvt() {
221 dlgopen('../../main/calendar/add_edit_event.php?patientid=<?php echo htmlspecialchars($pid,ENT_QUOTES); ?>', '_blank', 550, 350);
222 return false;
225 function sendimage(pid, what) {
226 // alert('Not yet implemented.'); return false;
227 dlgopen('../upload_dialog.php?patientid=' + pid + '&file=' + what,
228 '_blank', 500, 400);
229 return false;
232 </script>
234 <script type="text/javascript">
236 function toggleIndicator(target,div) {
238 $mode = $(target).find(".indicator").text();
239 if ( $mode == "<?php echo htmlspecialchars(xl('collapse'),ENT_QUOTES); ?>" ) {
240 $(target).find(".indicator").text( "<?php echo htmlspecialchars(xl('expand'),ENT_QUOTES); ?>" );
241 $("#"+div).hide();
242 $.post( "../../../library/ajax/user_settings.php", { target: div, mode: 0 });
243 } else {
244 $(target).find(".indicator").text( "<?php echo htmlspecialchars(xl('collapse'),ENT_QUOTES); ?>" );
245 $("#"+div).show();
246 $.post( "../../../library/ajax/user_settings.php", { target: div, mode: 1 });
250 $(document).ready(function(){
251 var msg_updation='';
252 <?php
253 if($GLOBALS['erx_enable']){
254 //$soap_status=sqlQuery("select soap_import_status from patient_data where pid=?",array($pid));
255 $soap_status=sqlStatement("select soap_import_status,pid from patient_data where pid=? and soap_import_status in ('1','3')",array($pid));
256 while($row_soapstatus=sqlFetchArray($soap_status)){
257 //if($soap_status['soap_import_status']=='1' || $soap_status['soap_import_status']=='3'){ ?>
258 top.restoreSession();
259 $.ajax({
260 type: "POST",
261 url: "../../soap_functions/soap_patientfullmedication.php",
262 dataType: "html",
263 data: {
264 patient:<?php echo $row_soapstatus['pid']; ?>,
266 async: false,
267 success: function(thedata){
268 //alert(thedata);
269 msg_updation+=thedata;
271 error:function(){
272 alert('ajax error');
275 <?php
276 //}
277 //elseif($soap_status['soap_import_status']=='3'){ ?>
278 top.restoreSession();
279 $.ajax({
280 type: "POST",
281 url: "../../soap_functions/soap_allergy.php",
282 dataType: "html",
283 data: {
284 patient:<?php echo $row_soapstatus['pid']; ?>,
286 async: false,
287 success: function(thedata){
288 //alert(thedata);
289 msg_updation+=thedata;
291 error:function(){
292 alert('ajax error');
295 <?php
296 if($GLOBALS['erx_import_status_message']){ ?>
297 if(msg_updation)
298 alert(msg_updation);
299 <?php
301 //}
305 // load divs
306 $("#stats_div").load("stats.php", { 'embeddedScreen' : true }, function() {
307 // (note need to place javascript code here also to get the dynamic link to work)
308 $(".rx_modal").fancybox( {
309 'overlayOpacity' : 0.0,
310 'showCloseButton' : true,
311 'frameHeight' : 500,
312 'frameWidth' : 800,
313 'centerOnScroll' : false,
314 'callbackOnClose' : function() {
315 refreshme();
319 $("#pnotes_ps_expand").load("pnotes_fragment.php");
320 $("#disclosures_ps_expand").load("disc_fragment.php");
322 <?php if ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crw']) { ?>
323 top.restoreSession();
324 $("#clinical_reminders_ps_expand").load("clinical_reminders_fragment.php", { 'embeddedScreen' : true }, function() {
325 // (note need to place javascript code here also to get the dynamic link to work)
326 $(".medium_modal").fancybox( {
327 'overlayOpacity' : 0.0,
328 'showCloseButton' : true,
329 'frameHeight' : 500,
330 'frameWidth' : 800,
331 'centerOnScroll' : false,
332 'callbackOnClose' : function() {
333 refreshme();
337 <?php } // end crw?>
339 <?php if ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_prw']) { ?>
340 top.restoreSession();
341 $("#patient_reminders_ps_expand").load("patient_reminders_fragment.php");
342 <?php } // end prw?>
344 <?php if ($vitals_is_registered && acl_check('patients', 'med')) { ?>
345 // Initialize the Vitals form if it is registered and user is authorized.
346 $("#vitals_ps_expand").load("vitals_fragment.php");
347 <?php } ?>
349 // Initialize track_anything
350 $("#track_anything_ps_expand").load("track_anything_fragment.php");
353 // Initialize labdata
354 $("#labdata_ps_expand").load("labdata_fragment.php");
355 <?php
356 // Initialize for each applicable LBF form.
357 $gfres = sqlStatement("SELECT option_id FROM list_options WHERE " .
358 "list_id = 'lbfnames' AND option_value > 0 ORDER BY seq, title");
359 while($gfrow = sqlFetchArray($gfres)) {
361 $("#<?php echo $gfrow['option_id']; ?>_ps_expand").load("lbf_fragment.php?formname=<?php echo $gfrow['option_id']; ?>");
362 <?php
366 // fancy box
367 enable_modals();
369 tabbify();
371 // modal for dialog boxes
372 $(".large_modal").fancybox( {
373 'overlayOpacity' : 0.0,
374 'showCloseButton' : true,
375 'frameHeight' : 600,
376 'frameWidth' : 1000,
377 'centerOnScroll' : false
380 // modal for image viewer
381 $(".image_modal").fancybox( {
382 'overlayOpacity' : 0.0,
383 'showCloseButton' : true,
384 'centerOnScroll' : false,
385 'autoscale' : true
388 $(".iframe1").fancybox( {
389 'left':10,
390 'overlayOpacity' : 0.0,
391 'showCloseButton' : true,
392 'frameHeight' : 300,
393 'frameWidth' : 350
395 // special size for patient portal
396 $(".small_modal").fancybox( {
397 'overlayOpacity' : 0.0,
398 'showCloseButton' : true,
399 'frameHeight' : 200,
400 'frameWidth' : 380,
401 'centerOnScroll' : false
404 <?php if ($active_reminders) { ?>
405 // show the active reminder modal
406 $("#reminder_popup_link").fancybox({
407 'overlayOpacity' : 0.0,
408 'showCloseButton' : true,
409 'frameHeight' : 500,
410 'frameWidth' : 500,
411 'centerOnScroll' : false
412 }).trigger('click');
413 <?php } ?>
417 // JavaScript stuff to do when a new patient is set.
419 function setMyPatient() {
420 <?php if ($GLOBALS['concurrent_layout']) { ?>
421 // Avoid race conditions with loading of the left_nav or Title frame.
422 if (!parent.allFramesLoaded()) {
423 setTimeout("setMyPatient()", 500);
424 return;
426 <?php if (isset($_GET['set_pid'])) { ?>
427 parent.left_nav.setPatient(<?php echo "'" . htmlspecialchars(($result['fname']) . " " . ($result['lname']),ENT_QUOTES) .
428 "'," . htmlspecialchars($pid,ENT_QUOTES) . ",'" . htmlspecialchars(($result['pubpid']),ENT_QUOTES) .
429 "','', ' " . htmlspecialchars(xl('DOB') . ": " . oeFormatShortDate($result['DOB_YMD']) . " " . xl('Age') . ": " . getPatientAgeDisplay($result['DOB_YMD']), ENT_QUOTES) . "'"; ?>);
430 var EncounterDateArray = new Array;
431 var CalendarCategoryArray = new Array;
432 var EncounterIdArray = new Array;
433 var Count = 0;
434 <?php
435 //Encounter details are stored to javacript as array.
436 $result4 = sqlStatement("SELECT fe.encounter,fe.date,openemr_postcalendar_categories.pc_catname FROM form_encounter AS fe ".
437 " left join openemr_postcalendar_categories on fe.pc_catid=openemr_postcalendar_categories.pc_catid WHERE fe.pid = ? order by fe.date desc", array($pid));
438 if(sqlNumRows($result4)>0) {
439 while($rowresult4 = sqlFetchArray($result4)) {
441 EncounterIdArray[Count] = '<?php echo htmlspecialchars($rowresult4['encounter'], ENT_QUOTES); ?>';
442 EncounterDateArray[Count] = '<?php echo htmlspecialchars(oeFormatShortDate(date("Y-m-d", strtotime($rowresult4['date']))), ENT_QUOTES); ?>';
443 CalendarCategoryArray[Count] = '<?php echo htmlspecialchars(xl_appt_category($rowresult4['pc_catname']), ENT_QUOTES); ?>';
444 Count++;
445 <?php
449 parent.left_nav.setPatientEncounter(EncounterIdArray,EncounterDateArray,CalendarCategoryArray);
450 <?php } // end setting new pid ?>
451 parent.left_nav.setRadio(window.name, 'dem');
452 parent.left_nav.syncRadios();
453 <?php } // end concurrent layout ?>
456 $(window).load(function() {
457 setMyPatient();
460 </script>
462 <style type="css/text">
463 #pnotes_ps_expand {
464 height:auto;
465 width:100%;
467 </style>
469 </head>
471 <body class="body_top">
473 <a href='../reminder/active_reminder_popup.php' id='reminder_popup_link' style='visibility: false;' class='iframe' onclick='top.restoreSession()'></a>
475 <?php
476 $thisauth = acl_check('patients', 'demo');
477 if ($thisauth) {
478 if ($result['squad'] && ! acl_check('squads', $result['squad']))
479 $thisauth = 0;
481 if (!$thisauth) {
482 echo "<p>(" . htmlspecialchars(xl('Demographics not authorized'),ENT_NOQUOTES) . ")</p>\n";
483 echo "</body>\n</html>\n";
484 exit();
486 if ($thisauth) {
487 echo "<table><tr><td><span class='title'>" .
488 htmlspecialchars(getPatientName($pid),ENT_NOQUOTES) .
489 "</span></td>";
491 if (acl_check('admin', 'super')) {
492 echo "<td style='padding-left:1em;'><a class='css_button iframe' href='../deleter.php?patient=" .
493 htmlspecialchars($pid,ENT_QUOTES) . "' onclick='top.restoreSession()'>" .
494 "<span>".htmlspecialchars(xl('Delete'),ENT_NOQUOTES).
495 "</span></a></td>";
497 if($GLOBALS['erx_enable']){
498 echo '<td style="padding-left:1em;"><a class="css_button" href="../../eRx.php?page=medentry" onclick="top.restoreSession()">';
499 echo "<span>".htmlspecialchars(xl('NewCrop MedEntry'),ENT_NOQUOTES)."</span></a></td>";
500 echo '<td style="padding-left:1em;"><a class="css_button iframe1" href="../../soap_functions/soap_accountStatusDetails.php" onclick="top.restoreSession()">';
501 echo "<span>".htmlspecialchars(xl('NewCrop Account Status'),ENT_NOQUOTES)."</span></a></td><td id='accountstatus'></td>";
503 //Patient Portal
504 $portalUserSetting = true; //flag to see if patient has authorized access to portal
505 if($GLOBALS['portal_onsite_enable'] && $GLOBALS['portal_onsite_address']){
506 $portalStatus = sqlQuery("SELECT allow_patient_portal FROM patient_data WHERE pid=?",array($pid));
507 if ($portalStatus['allow_patient_portal']=='YES') {
508 $portalLogin = sqlQuery("SELECT pid FROM `patient_access_onsite` WHERE `pid`=?", array($pid));
509 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()'>";
510 if (empty($portalLogin)) {
511 echo "<span>".htmlspecialchars(xl('Create Onsite Portal Credentials'),ENT_NOQUOTES)."</span></a></td>";
513 else {
514 echo "<span>".htmlspecialchars(xl('Reset Onsite Portal Credentials'),ENT_NOQUOTES)."</span></a></td>";
517 else {
518 $portalUserSetting = false;
521 if($GLOBALS['portal_offsite_enable'] && $GLOBALS['portal_offsite_address']){
522 $portalStatus = sqlQuery("SELECT allow_patient_portal FROM patient_data WHERE pid=?",array($pid));
523 if ($portalStatus['allow_patient_portal']=='YES') {
524 $portalLogin = sqlQuery("SELECT pid FROM `patient_access_offsite` WHERE `pid`=?", array($pid));
525 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()'>";
526 if (empty($portalLogin)) {
527 echo "<span>".htmlspecialchars(xl('Create Offsite Portal Credentials'),ENT_NOQUOTES)."</span></a></td>";
529 else {
530 echo "<span>".htmlspecialchars(xl('Reset Offsite Portal Credentials'),ENT_NOQUOTES)."</span></a></td>";
533 else {
534 $portalUserSetting = false;
537 if (!($portalUserSetting)) {
538 // Show that the patient has not authorized portal access
539 echo "<td style='padding-left:1em;'>" . htmlspecialchars( xl('Patient has not authorized the Patient Portal.'), ENT_NOQUOTES) . "</td>";
541 //Patient Portal
543 // If patient is deceased, then show this (along with the number of days patient has been deceased for)
544 $days_deceased = is_patient_deceased($pid);
545 if ($days_deceased) {
546 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>";
549 echo "</tr></table>";
552 // Get the document ID of the patient ID card if access to it is wanted here.
553 $idcard_doc_id = false;
554 if ($GLOBALS['patient_id_category_name']) {
555 $idcard_doc_id = get_document_by_catg($pid, $GLOBALS['patient_id_category_name']);
559 <table cellspacing='0' cellpadding='0' border='0'>
560 <tr>
561 <td class="small" colspan='4'>
562 <a href="../history/history.php" onclick='top.restoreSession()'>
563 <?php echo htmlspecialchars(xl('History'),ENT_NOQUOTES); ?></a>
565 <?php //note that we have temporarily removed report screen from the modal view ?>
566 <a href="../report/patient_report.php" onclick='top.restoreSession()'>
567 <?php echo htmlspecialchars(xl('Report'),ENT_NOQUOTES); ?></a>
569 <?php //note that we have temporarily removed document screen from the modal view ?>
570 <a href="../../../controller.php?document&list&patient_id=<?php echo $pid;?>" onclick='top.restoreSession()'>
571 <?php echo htmlspecialchars(xl('Documents'),ENT_NOQUOTES); ?></a>
573 <a href="../transaction/transactions.php" class='iframe large_modal' onclick='top.restoreSession()'>
574 <?php echo htmlspecialchars(xl('Transactions'),ENT_NOQUOTES); ?></a>
576 <a href="stats_full.php?active=all" onclick='top.restoreSession()'>
577 <?php echo htmlspecialchars(xl('Issues'),ENT_NOQUOTES); ?></a>
579 <!-- DISPLAYING HOOKS STARTS HERE -->
580 <?php
581 $module_query = sqlStatement("SELECT msh.*,ms.menu_name,ms.path,m.mod_ui_name,m.type FROM modules_hooks_settings AS msh
582 LEFT OUTER JOIN modules_settings AS ms ON obj_name=enabled_hooks AND ms.mod_id=msh.mod_id
583 LEFT OUTER JOIN modules AS m ON m.mod_id=ms.mod_id
584 WHERE fld_type=3 AND mod_active=1 AND sql_run=1 AND attached_to='demographics' ORDER BY mod_id");
585 $DivId = 'mod_installer';
586 if (sqlNumRows($module_query)) {
587 $jid = 0;
588 $modid = '';
589 while ($modulerow = sqlFetchArray($module_query)) {
590 $DivId = 'mod_'.$modulerow['mod_id'];
591 $new_category = $modulerow['mod_ui_name'];
592 $modulePath = "";
593 $added = "";
594 if($modulerow['type'] == 0) {
595 $modulePath = $GLOBALS['customModDir'];
596 $added = "";
598 else{
599 $added = "index";
600 $modulePath = $GLOBALS['zendModDir'];
602 $relative_link = "../../modules/".$modulePath."/".$modulerow['path'];
603 $nickname = $modulerow['menu_name'] ? $modulerow['menu_name'] : 'Noname';
604 $jid++;
605 $modid = $modulerow['mod_id'];
608 <a href="<?php echo $relative_link; ?>" onclick='top.restoreSession()'>
609 <?php echo htmlspecialchars($nickname,ENT_NOQUOTES); ?></a>
610 <?php
614 <!-- DISPLAYING HOOKS ENDS HERE -->
616 </td>
617 </tr>
619 </table> <!-- end header -->
621 <div style='margin-top:10px'> <!-- start main content div -->
622 <table border="0" cellspacing="0" cellpadding="0" width="100%">
623 <tr>
624 <td align="left" valign="top">
625 <!-- start left column div -->
626 <div style='float:left; margin-right:20px'>
627 <table cellspacing=0 cellpadding=0>
628 <tr<?php if ($GLOBALS['athletic_team']) echo " style='display:none;'"; ?>>
629 <td>
630 <?php
631 // Billing expand collapse widget
632 $widgetTitle = xl("Billing");
633 $widgetLabel = "billing";
634 $widgetButtonLabel = xl("Edit");
635 $widgetButtonLink = "return newEvt();";
636 $widgetButtonClass = "";
637 $linkMethod = "javascript";
638 $bodyClass = "notab";
639 $widgetAuth = false;
640 $fixedWidth = true;
641 if ($GLOBALS['force_billing_widget_open']) {
642 $forceExpandAlways = true;
644 else {
645 $forceExpandAlways = false;
647 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
648 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
649 $widgetAuth, $fixedWidth, $forceExpandAlways);
651 <br>
652 <?php
653 //PATIENT BALANCE,INS BALANCE naina@capminds.com
654 $patientbalance = get_patient_balance($pid, false);
655 //Debit the patient balance from insurance balance
656 $insurancebalance = get_patient_balance($pid, true) - $patientbalance;
657 $totalbalance=$patientbalance + $insurancebalance;
658 if ($GLOBALS['oer_config']['ws_accounting']['enabled']) {
659 // Show current balance and billing note, if any.
660 echo "<table border='0'><tr><td>" .
661 "<table ><tr><td><span class='bold'><font color='red'>" .
662 xlt('Patient Balance Due') .
663 " : " . text(oeFormatMoney($patientbalance)) .
664 "</font></span></td></tr>".
665 "<tr><td><span class='bold'><font color='red'>" .
666 xlt('Insurance Balance Due') .
667 " : " . text(oeFormatMoney($insurancebalance)) .
668 "</font></span></td></tr>".
669 "<tr><td><span class='bold'><font color='red'>" .
670 xlt('Total Balance Due').
671 " : " . text(oeFormatMoney($totalbalance)) .
672 "</font></span></td></td></tr>";
673 if ($result['genericname2'] == 'Billing') {
674 echo "<tr><td><span class='bold'><font color='red'>" .
675 xlt('Billing Note') . ":" .
676 text($result['genericval2']) .
677 "</font></span></td></tr>";
679 if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
680 echo "<tr><td><span class='bold'>" .
681 xlt('Primary Insurance') . ': ' . text($insco_name) .
682 "</span>&nbsp;&nbsp;&nbsp;";
683 if ($result3['copay'] > 0) {
684 echo "<span class='bold'>" .
685 xlt('Copay') . ': ' . text($result3['copay']) .
686 "</span>&nbsp;&nbsp;&nbsp;";
688 echo "<span class='bold'>" .
689 xlt('Effective Date') . ': ' . text(oeFormatShortDate($result3['effdate'])) .
690 "</span></td></tr>";
692 echo "</table></td></tr></td></tr></table><br>";
695 </div> <!-- required for expand_collapse_widget -->
696 </td>
697 </tr>
698 <tr>
699 <td>
700 <?php
701 // Demographics expand collapse widget
702 $widgetTitle = xl("Demographics");
703 $widgetLabel = "demographics";
704 $widgetButtonLabel = xl("Edit");
705 $widgetButtonLink = "demographics_full.php";
706 $widgetButtonClass = "";
707 $linkMethod = "html";
708 $bodyClass = "";
709 $widgetAuth = acl_check('patients', 'demo', '', 'write');
710 $fixedWidth = true;
711 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
712 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
713 $widgetAuth, $fixedWidth);
715 <div id="DEM" >
716 <ul class="tabNav">
717 <?php display_layout_tabs('DEM', $result, $result2); ?>
718 </ul>
719 <div class="tabContainer">
720 <?php display_layout_tabs_data('DEM', $result, $result2); ?>
721 </div>
722 </div>
723 </div> <!-- required for expand_collapse_widget -->
724 </td>
725 </tr>
727 <tr>
728 <td>
729 <?php
730 $insurance_count = 0;
731 foreach (array('primary','secondary','tertiary') as $instype) {
732 $enddate = 'Present';
733 $query = "SELECT * FROM insurance_data WHERE " .
734 "pid = ? AND type = ? " .
735 "ORDER BY date DESC";
736 $res = sqlStatement($query, array($pid, $instype) );
737 while( $row = sqlFetchArray($res) ) {
738 if ($row['provider'] ) $insurance_count++;
742 if ( $insurance_count > 0 ) {
743 // Insurance expand collapse widget
744 $widgetTitle = xl("Insurance");
745 $widgetLabel = "insurance";
746 $widgetButtonLabel = xl("Edit");
747 $widgetButtonLink = "demographics_full.php";
748 $widgetButtonClass = "";
749 $linkMethod = "html";
750 $bodyClass = "";
751 $widgetAuth = acl_check('patients', 'demo', '', 'write');
752 $fixedWidth = true;
753 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
754 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
755 $widgetAuth, $fixedWidth);
757 if ( $insurance_count > 0 ) {
760 <ul class="tabNav"><?php
761 ///////////////////////////////// INSURANCE SECTION
762 $first = true;
763 foreach (array('primary','secondary','tertiary') as $instype) {
765 $query = "SELECT * FROM insurance_data WHERE " .
766 "pid = ? AND type = ? " .
767 "ORDER BY date DESC";
768 $res = sqlStatement($query, array($pid, $instype) );
770 $enddate = 'Present';
772 while( $row = sqlFetchArray($res) ) {
773 if ($row['provider'] ) {
775 $ins_description = ucfirst($instype);
776 $ins_description = xl($ins_description);
777 $ins_description .= strcmp($enddate, 'Present') != 0 ? " (".xl('Old').")" : "";
779 <li <?php echo $first ? 'class="current"' : '' ?>><a href="/play/javascript-tabbed-navigation/">
780 <?php echo htmlspecialchars($ins_description,ENT_NOQUOTES); ?></a></li>
781 <?php
782 $first = false;
784 $enddate = $row['date'];
787 // Display the eligibility tab
788 echo "<li><a href='/play/javascript-tabbed-navigation/'>" .
789 htmlspecialchars( xl('Eligibility'), ENT_NOQUOTES) . "</a></li>";
791 ?></ul><?php
793 } ?>
795 <div class="tabContainer">
796 <?php
797 $first = true;
798 foreach (array('primary','secondary','tertiary') as $instype) {
799 $enddate = 'Present';
801 $query = "SELECT * FROM insurance_data WHERE " .
802 "pid = ? AND type = ? " .
803 "ORDER BY date DESC";
804 $res = sqlStatement($query, array($pid, $instype) );
805 while( $row = sqlFetchArray($res) ) {
806 if ($row['provider'] ) {
808 <div class="tab <?php echo $first ? 'current' : '' ?>">
809 <table border='0' cellpadding='0' width='100%'>
810 <?php
811 $icobj = new InsuranceCompany($row['provider']);
812 $adobj = $icobj->get_address();
813 $insco_name = trim($icobj->get_name());
815 <tr>
816 <td valign='top' colspan='3'>
817 <span class='text'>
818 <?php if (strcmp($enddate, 'Present') != 0) echo htmlspecialchars(xl("Old"),ENT_NOQUOTES)." "; ?>
819 <?php $tempinstype=ucfirst($instype); echo htmlspecialchars(xl($tempinstype.' Insurance'),ENT_NOQUOTES); ?>
820 <?php if (strcmp($row['date'], '0000-00-00') != 0) { ?>
821 <?php echo htmlspecialchars(xl('from','',' ',' ').$row['date'],ENT_NOQUOTES); ?>
822 <?php } ?>
823 <?php echo htmlspecialchars(xl('until','',' ',' '),ENT_NOQUOTES);
824 echo (strcmp($enddate, 'Present') != 0) ? $enddate : htmlspecialchars(xl('Present'),ENT_NOQUOTES); ?>:</span>
825 </td>
826 </tr>
827 <tr>
828 <td valign='top'>
829 <span class='text'>
830 <?php
831 if ($insco_name) {
832 echo htmlspecialchars($insco_name,ENT_NOQUOTES) . '<br>';
833 if (trim($adobj->get_line1())) {
834 echo htmlspecialchars($adobj->get_line1(),ENT_NOQUOTES) . '<br>';
835 echo htmlspecialchars($adobj->get_city() . ', ' . $adobj->get_state() . ' ' . $adobj->get_zip(),ENT_NOQUOTES);
837 } else {
838 echo "<font color='red'><b>".htmlspecialchars(xl('Unassigned'),ENT_NOQUOTES)."</b></font>";
841 <br>
842 <?php echo htmlspecialchars(xl('Policy Number'),ENT_NOQUOTES); ?>:
843 <?php echo htmlspecialchars($row['policy_number'],ENT_NOQUOTES) ?><br>
844 <?php echo htmlspecialchars(xl('Plan Name'),ENT_NOQUOTES); ?>:
845 <?php echo htmlspecialchars($row['plan_name'],ENT_NOQUOTES); ?><br>
846 <?php echo htmlspecialchars(xl('Group Number'),ENT_NOQUOTES); ?>:
847 <?php echo htmlspecialchars($row['group_number'],ENT_NOQUOTES); ?></span>
848 </td>
849 <td valign='top'>
850 <span class='bold'><?php echo htmlspecialchars(xl('Subscriber'),ENT_NOQUOTES); ?>: </span><br>
851 <span class='text'><?php echo htmlspecialchars($row['subscriber_fname'] . ' ' . $row['subscriber_mname'] . ' ' . $row['subscriber_lname'],ENT_NOQUOTES); ?>
852 <?php
853 if ($row['subscriber_relationship'] != "") {
854 echo "(" . htmlspecialchars($row['subscriber_relationship'],ENT_NOQUOTES) . ")";
857 <br>
858 <?php echo htmlspecialchars(xl('S.S.'),ENT_NOQUOTES); ?>:
859 <?php echo htmlspecialchars($row['subscriber_ss'],ENT_NOQUOTES); ?><br>
860 <?php echo htmlspecialchars(xl('D.O.B.'),ENT_NOQUOTES); ?>:
861 <?php if ($row['subscriber_DOB'] != "0000-00-00 00:00:00") echo htmlspecialchars($row['subscriber_DOB'],ENT_NOQUOTES); ?><br>
862 <?php echo htmlspecialchars(xl('Phone'),ENT_NOQUOTES); ?>:
863 <?php echo htmlspecialchars($row['subscriber_phone'],ENT_NOQUOTES); ?>
864 </span>
865 </td>
866 <td valign='top'>
867 <span class='bold'><?php echo htmlspecialchars(xl('Subscriber Address'),ENT_NOQUOTES); ?>: </span><br>
868 <span class='text'><?php echo htmlspecialchars($row['subscriber_street'],ENT_NOQUOTES); ?><br>
869 <?php echo htmlspecialchars($row['subscriber_city'],ENT_NOQUOTES); ?>
870 <?php if($row['subscriber_state'] != "") echo ", "; echo htmlspecialchars($row['subscriber_state'],ENT_NOQUOTES); ?>
871 <?php if($row['subscriber_country'] != "") echo ", "; echo htmlspecialchars($row['subscriber_country'],ENT_NOQUOTES); ?>
872 <?php echo " " . htmlspecialchars($row['subscriber_postal_code'],ENT_NOQUOTES); ?></span>
874 <?php if (trim($row['subscriber_employer'])) { ?>
875 <br><span class='bold'><?php echo htmlspecialchars(xl('Subscriber Employer'),ENT_NOQUOTES); ?>: </span><br>
876 <span class='text'><?php echo htmlspecialchars($row['subscriber_employer'],ENT_NOQUOTES); ?><br>
877 <?php echo htmlspecialchars($row['subscriber_employer_street'],ENT_NOQUOTES); ?><br>
878 <?php echo htmlspecialchars($row['subscriber_employer_city'],ENT_NOQUOTES); ?>
879 <?php if($row['subscriber_employer_city'] != "") echo ", "; echo htmlspecialchars($row['subscriber_employer_state'],ENT_NOQUOTES); ?>
880 <?php if($row['subscriber_employer_country'] != "") echo ", "; echo htmlspecialchars($row['subscriber_employer_country'],ENT_NOQUOTES); ?>
881 <?php echo " " . htmlspecialchars($row['subscriber_employer_postal_code'],ENT_NOQUOTES); ?>
882 </span>
883 <?php } ?>
885 </td>
886 </tr>
887 <tr>
888 <td>
889 <?php if ($row['copay'] != "") { ?>
890 <span class='bold'><?php echo htmlspecialchars(xl('CoPay'),ENT_NOQUOTES); ?>: </span>
891 <span class='text'><?php echo htmlspecialchars($row['copay'],ENT_NOQUOTES); ?></span>
892 <br />
893 <?php } ?>
894 <span class='bold'><?php echo htmlspecialchars(xl('Accept Assignment'),ENT_NOQUOTES); ?>:</span>
895 <span class='text'><?php if($row['accept_assignment'] == "TRUE") echo xl("YES"); ?>
896 <?php if($row['accept_assignment'] == "FALSE") echo xl("NO"); ?></span>
897 <?php if (!empty($row['policy_type'])) { ?>
898 <br />
899 <span class='bold'><?php echo htmlspecialchars(xl('Secondary Medicare Type'),ENT_NOQUOTES); ?>: </span>
900 <span class='text'><?php echo htmlspecialchars($policy_types[$row['policy_type']],ENT_NOQUOTES); ?></span>
901 <?php } ?>
902 </td>
903 <td valign='top'></td>
904 <td valign='top'></td>
905 </tr>
907 </table>
908 </div>
909 <?php
911 } // end if ($row['provider'])
912 $enddate = $row['date'];
913 $first = false;
914 } // end while
915 } // end foreach
917 // Display the eligibility information
918 echo "<div class='tab'>";
919 show_eligibility_information($pid,true);
920 echo "</div>";
922 ///////////////////////////////// END INSURANCE SECTION
924 </div>
926 <?php } // ?>
928 </td>
929 </tr>
931 <tr>
932 <td width='650px'>
934 <?php
935 // Notes expand collapse widget
936 $widgetTitle = xl("Notes");
937 $widgetLabel = "pnotes";
938 $widgetButtonLabel = xl("Edit");
939 $widgetButtonLink = "pnotes_full.php?form_active=1";
940 $widgetButtonClass = "";
941 $linkMethod = "html";
942 $bodyClass = "notab";
943 $widgetAuth = true;
944 $fixedWidth = true;
945 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
946 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
947 $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 if ( (acl_check('patients', 'med')) && ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_prw']) ) {
956 echo "<tr><td width='650px'>";
957 // patient reminders collapse widget
958 $widgetTitle = xl("Patient Reminders");
959 $widgetLabel = "patient_reminders";
960 $widgetButtonLabel = xl("Edit");
961 $widgetButtonLink = "../reminder/patient_reminders.php?mode=simple&patient_id=".$pid;
962 $widgetButtonClass = "";
963 $linkMethod = "html";
964 $bodyClass = "notab";
965 $widgetAuth = true;
966 $fixedWidth = true;
967 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth); ?>
968 <br/>
969 <div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>
970 </div>
971 </td>
972 </tr>
973 <?php } //end if prw is activated ?>
975 <tr>
976 <td width='650px'>
977 <?php
978 // disclosures expand collapse widget
979 $widgetTitle = xl("Disclosures");
980 $widgetLabel = "disclosures";
981 $widgetButtonLabel = xl("Edit");
982 $widgetButtonLink = "disclosure_full.php";
983 $widgetButtonClass = "";
984 $linkMethod = "html";
985 $bodyClass = "notab";
986 $widgetAuth = true;
987 $fixedWidth = true;
988 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
989 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
990 $widgetAuth, $fixedWidth);
992 <br/>
993 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
994 </div>
995 </td>
996 </tr>
999 <?php // labdata ?>
1000 <tr>
1001 <td width='650px'>
1002 <?php // labdata expand collapse widget
1003 $widgetTitle = xl("Labs");
1004 $widgetLabel = "labdata";
1005 $widgetButtonLabel = xl("Trend");
1006 $widgetButtonLink = "../summary/labdata.php";#"../encounter/trend_form.php?formname=labdata";
1007 $widgetButtonClass = "";
1008 $linkMethod = "html";
1009 $bodyClass = "notab";
1010 // check to see if any labdata exist
1011 $spruch = "SELECT procedure_report.date_collected AS date " .
1012 "FROM procedure_report " .
1013 "JOIN procedure_order ON procedure_report.procedure_order_id = procedure_order.procedure_order_id " .
1014 "WHERE procedure_order.patient_id = ? " .
1015 "ORDER BY procedure_report.date_collected DESC ";
1016 $existLabdata = sqlQuery($spruch, array($pid) );
1017 if ($existLabdata) {
1018 $widgetAuth = true;
1020 else {
1021 $widgetAuth = false;
1023 $fixedWidth = true;
1024 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
1025 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
1026 $widgetAuth, $fixedWidth);
1028 <br/>
1029 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
1030 </div>
1031 </td>
1032 </tr>
1033 <?php // end labdata ?>
1038 <?php if ($vitals_is_registered && acl_check('patients', 'med')) { ?>
1039 <tr>
1040 <td width='650px'>
1041 <?php // vitals expand collapse widget
1042 $widgetTitle = xl("Vitals");
1043 $widgetLabel = "vitals";
1044 $widgetButtonLabel = xl("Trend");
1045 $widgetButtonLink = "../encounter/trend_form.php?formname=vitals";
1046 $widgetButtonClass = "";
1047 $linkMethod = "html";
1048 $bodyClass = "notab";
1049 // check to see if any vitals exist
1050 $existVitals = sqlQuery("SELECT * FROM form_vitals WHERE pid=?", array($pid) );
1051 if ($existVitals) {
1052 $widgetAuth = true;
1054 else {
1055 $widgetAuth = false;
1057 $fixedWidth = true;
1058 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
1059 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
1060 $widgetAuth, $fixedWidth);
1062 <br/>
1063 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
1064 </div>
1065 </td>
1066 </tr>
1067 <?php } // end if ($vitals_is_registered && acl_check('patients', 'med')) ?>
1069 <?php
1070 // This generates a section similar to Vitals for each LBF form that
1071 // supports charting. The form ID is used as the "widget label".
1073 $gfres = sqlStatement("SELECT option_id, title FROM list_options WHERE " .
1074 "list_id = 'lbfnames' AND option_value > 0 ORDER BY seq, title");
1075 while($gfrow = sqlFetchArray($gfres)) {
1077 <tr>
1078 <td width='650px'>
1079 <?php // vitals expand collapse widget
1080 $vitals_form_id = $gfrow['option_id'];
1081 $widgetTitle = $gfrow['title'];
1082 $widgetLabel = $vitals_form_id;
1083 $widgetButtonLabel = xl("Trend");
1084 $widgetButtonLink = "../encounter/trend_form.php?formname=$vitals_form_id";
1085 $widgetButtonClass = "";
1086 $linkMethod = "html";
1087 $bodyClass = "notab";
1088 // check to see if any instances exist for this patient
1089 $existVitals = sqlQuery(
1090 "SELECT * FROM forms WHERE pid = ? AND formdir = ? AND deleted = 0",
1091 array($pid, $vitals_form_id));
1092 $widgetAuth = $existVitals ? true : false;
1093 $fixedWidth = true;
1094 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
1095 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
1096 $widgetAuth, $fixedWidth);
1098 <br/>
1099 <div style='margin-left:10px' class='text'>
1100 <image src='../../pic/ajax-loader.gif'/>
1101 </div>
1102 <br/>
1103 </div> <!-- This is required by expand_collapse_widget(). -->
1104 </td>
1105 </tr>
1106 <?php
1107 } // end while
1110 </table>
1112 </div>
1113 <!-- end left column div -->
1115 <!-- start right column div -->
1116 <div>
1117 <table>
1118 <tr>
1119 <td>
1121 <div>
1122 <?php
1124 // If there is an ID Card or any Photos show the widget
1125 $photos = pic_array($pid, $GLOBALS['patient_photo_category_name']);
1126 if ($photos or $idcard_doc_id )
1128 $widgetTitle = xl("ID Card") . '/' . xl("Photos");
1129 $widgetLabel = "photos";
1130 $linkMethod = "javascript";
1131 $bodyClass = "notab-right";
1132 $widgetAuth = false;
1133 $fixedWidth = false;
1134 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel ,
1135 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
1136 $widgetAuth, $fixedWidth);
1138 <br />
1139 <?php
1140 if ($idcard_doc_id) {
1141 image_widget($idcard_doc_id, $GLOBALS['patient_id_category_name']);
1144 foreach ($photos as $photo_doc_id) {
1145 image_widget($photo_doc_id, $GLOBALS['patient_photo_category_name']);
1150 <br />
1151 </div>
1152 <div>
1153 <?php
1154 // Advance Directives
1155 if ($GLOBALS['advance_directives_warning']) {
1156 // advance directives expand collapse widget
1157 $widgetTitle = xl("Advance Directives");
1158 $widgetLabel = "directives";
1159 $widgetButtonLabel = xl("Edit");
1160 $widgetButtonLink = "return advdirconfigure();";
1161 $widgetButtonClass = "";
1162 $linkMethod = "javascript";
1163 $bodyClass = "summary_item small";
1164 $widgetAuth = true;
1165 $fixedWidth = false;
1166 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1167 $counterFlag = false; //flag to record whether any categories contain ad records
1168 $query = "SELECT id FROM categories WHERE name='Advance Directive'";
1169 $myrow2 = sqlQuery($query);
1170 if ($myrow2) {
1171 $parentId = $myrow2['id'];
1172 $query = "SELECT id, name FROM categories WHERE parent=?";
1173 $resNew1 = sqlStatement($query, array($parentId) );
1174 while ($myrows3 = sqlFetchArray($resNew1)) {
1175 $categoryId = $myrows3['id'];
1176 $nameDoc = $myrows3['name'];
1177 $query = "SELECT documents.date, documents.id " .
1178 "FROM documents " .
1179 "INNER JOIN categories_to_documents " .
1180 "ON categories_to_documents.document_id=documents.id " .
1181 "WHERE categories_to_documents.category_id=? " .
1182 "AND documents.foreign_id=? " .
1183 "ORDER BY documents.date DESC";
1184 $resNew2 = sqlStatement($query, array($categoryId, $pid) );
1185 $limitCounter = 0; // limit to one entry per category
1186 while (($myrows4 = sqlFetchArray($resNew2)) && ($limitCounter == 0)) {
1187 $dateTimeDoc = $myrows4['date'];
1188 // remove time from datetime stamp
1189 $tempParse = explode(" ",$dateTimeDoc);
1190 $dateDoc = $tempParse[0];
1191 $idDoc = $myrows4['id'];
1192 echo "<a href='$web_root/controller.php?document&retrieve&patient_id=" .
1193 htmlspecialchars($pid,ENT_QUOTES) . "&document_id=" .
1194 htmlspecialchars($idDoc,ENT_QUOTES) . "&as_file=true' onclick='top.restoreSession()'>" .
1195 htmlspecialchars(xl_document_category($nameDoc),ENT_NOQUOTES) . "</a> " .
1196 htmlspecialchars($dateDoc,ENT_NOQUOTES);
1197 echo "<br>";
1198 $limitCounter = $limitCounter + 1;
1199 $counterFlag = true;
1203 if (!$counterFlag) {
1204 echo "&nbsp;&nbsp;" . htmlspecialchars(xl('None'),ENT_NOQUOTES);
1205 } ?>
1206 </div>
1207 <?php } // close advanced dir block
1209 // This is a feature for a specific client. -- Rod
1210 if ($GLOBALS['cene_specific']) {
1211 echo " <br />\n";
1213 $imagedir = $GLOBALS['OE_SITE_DIR'] . "/documents/$pid/demographics";
1214 $imagepath = "$web_root/sites/" . $_SESSION['site_id'] . "/documents/$pid/demographics";
1216 echo " <a href='' onclick=\"return sendimage($pid, 'photo');\" " .
1217 "title='Click to attach patient image'>\n";
1218 if (is_file("$imagedir/photo.jpg")) {
1219 echo " <img src='$imagepath/photo.jpg' /></a>\n";
1220 } else {
1221 echo " Attach Patient Image</a><br />\n";
1223 echo " <br />&nbsp;<br />\n";
1225 echo " <a href='' onclick=\"return sendimage($pid, 'fingerprint');\" " .
1226 "title='Click to attach fingerprint'>\n";
1227 if (is_file("$imagedir/fingerprint.jpg")) {
1228 echo " <img src='$imagepath/fingerprint.jpg' /></a>\n";
1229 } else {
1230 echo " Attach Biometric Fingerprint</a><br />\n";
1232 echo " <br />&nbsp;<br />\n";
1235 // This stuff only applies to athletic team use of OpenEMR. The client
1236 // insisted on being able to quickly change fitness and return date here:
1238 if (false && $GLOBALS['athletic_team']) {
1239 // blue green yellow red orange
1240 $fitcolors = array('#6677ff','#00cc00','#ffff00','#ff3333','#ff8800','#ffeecc','#ffccaa');
1241 if (!empty($GLOBALS['fitness_colors'])) $fitcolors = $GLOBALS['fitness_colors'];
1242 $fitcolor = $fitcolors[0];
1243 $form_fitness = $_POST['form_fitness'];
1244 $form_userdate1 = fixDate($_POST['form_userdate1'], '');
1245 $form_issue_id = $_POST['form_issue_id'];
1246 if ($form_submit) {
1247 $returndate = $form_userdate1 ? "'$form_userdate1'" : "NULL";
1248 sqlStatement("UPDATE patient_data SET fitness = ?, " .
1249 "userdate1 = ? WHERE pid = ?", array($form_fitness, $returndate, $pid) );
1250 // Update return date in the designated issue, if requested.
1251 if ($form_issue_id) {
1252 sqlStatement("UPDATE lists SET returndate = ? WHERE " .
1253 "id = ?", array($returndate, $form_issue_id) );
1255 } else {
1256 $form_fitness = $result['fitness'];
1257 if (! $form_fitness) $form_fitness = 1;
1258 $form_userdate1 = $result['userdate1'];
1260 $fitcolor = $fitcolors[$form_fitness - 1];
1261 echo " <form method='post' action='demographics.php' onsubmit='return validate()'>\n";
1262 echo " <span class='bold'>Fitness to Play:</span><br />\n";
1263 echo " <select name='form_fitness' style='background-color:$fitcolor'>\n";
1264 $res = sqlStatement("SELECT * FROM list_options WHERE " .
1265 "list_id = 'fitness' ORDER BY seq");
1266 while ($row = sqlFetchArray($res)) {
1267 $key = $row['option_id'];
1268 echo " <option value='" . htmlspecialchars($key,ENT_QUOTES) . "'";
1269 if ($key == $form_fitness) echo " selected";
1270 echo ">" . htmlspecialchars($row['title'],ENT_NOQUOTES) . "</option>\n";
1272 echo " </select>\n";
1273 echo " <br /><span class='bold'>Return to Play:</span><br>\n";
1274 echo " <input type='text' size='10' name='form_userdate1' id='form_userdate1' " .
1275 "value='$form_userdate1' " .
1276 "title='" . htmlspecialchars(xl('yyyy-mm-dd Date of return to play'),ENT_QUOTES) . "' " .
1277 "onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />\n" .
1278 " <img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22' " .
1279 "id='img_userdate1' border='0' alt='[?]' style='cursor:pointer' " .
1280 "title='" . htmlspecialchars(xl('Click here to choose a date'),ENT_QUOTES) . "'>\n";
1281 echo " <input type='hidden' name='form_original_userdate1' value='" . htmlspecialchars($form_userdate1,ENT_QUOTES) . "' />\n";
1282 echo " <input type='hidden' name='form_issue_id' value='' />\n";
1283 echo "<p><input type='submit' name='form_submit' value='Change' /></p>\n";
1284 echo " </form>\n";
1287 // Show current and upcoming appointments.
1288 if (isset($pid) && !$GLOBALS['disable_calendar']) {
1289 $query = "SELECT e.pc_eid, e.pc_aid, e.pc_title, e.pc_eventDate, " .
1290 "e.pc_startTime, e.pc_hometext, u.fname, u.lname, u.mname, " .
1291 "c.pc_catname, e.pc_apptstatus " .
1292 "FROM openemr_postcalendar_events AS e, users AS u, " .
1293 "openemr_postcalendar_categories AS c WHERE " .
1294 "e.pc_pid = ? AND e.pc_eventDate >= CURRENT_DATE AND " .
1295 "u.id = e.pc_aid AND e.pc_catid = c.pc_catid " .
1296 "ORDER BY e.pc_eventDate, e.pc_startTime";
1297 $res = sqlStatement($query, array($pid) );
1299 if ( (acl_check('patients', 'med')) && ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crw']) ) {
1300 // clinical summary expand collapse widget
1301 $widgetTitle = xl("Clinical Reminders");
1302 $widgetLabel = "clinical_reminders";
1303 $widgetButtonLabel = xl("Edit");
1304 $widgetButtonLink = "../reminder/clinical_reminders.php?patient_id=".$pid;;
1305 $widgetButtonClass = "";
1306 $linkMethod = "html";
1307 $bodyClass = "summary_item small";
1308 $widgetAuth = true;
1309 $fixedWidth = false;
1310 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1311 echo "<br/>";
1312 echo "<div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>";
1313 echo "</div>";
1314 } // end if crw
1316 // appointments expand collapse widget
1317 $widgetTitle = xl("Appointments");
1318 $widgetLabel = "appointments";
1319 $widgetButtonLabel = xl("Add");
1320 $widgetButtonLink = "return newEvt();";
1321 $widgetButtonClass = "";
1322 $linkMethod = "javascript";
1323 $bodyClass = "summary_item small";
1324 $widgetAuth = (isset($res) && $res != null);
1325 $fixedWidth = false;
1326 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1327 $count = 0;
1328 while($row = sqlFetchArray($res)) {
1329 $count++;
1330 $dayname = date("l", strtotime($row['pc_eventDate']));
1331 $dispampm = "am";
1332 $disphour = substr($row['pc_startTime'], 0, 2) + 0;
1333 $dispmin = substr($row['pc_startTime'], 3, 2);
1334 if ($disphour >= 12) {
1335 $dispampm = "pm";
1336 if ($disphour > 12) $disphour -= 12;
1338 $etitle = xl('(Click to edit)');
1339 if ($row['pc_hometext'] != "") {
1340 $etitle = xl('Comments').": ".($row['pc_hometext'])."\r\n".$etitle;
1342 echo "<a href='javascript:oldEvt(" . htmlspecialchars($row['pc_eid'],ENT_QUOTES) . ")' title='" . htmlspecialchars($etitle,ENT_QUOTES) . "'>";
1343 echo "<b>" . htmlspecialchars(xl($dayname) . ", " . $row['pc_eventDate'],ENT_NOQUOTES) . "</b>" . xlt("Status") . "(";
1344 echo " " . generate_display_field(array('data_type'=>'1','list_id'=>'apptstat'),$row['pc_apptstatus']) . ")<br>"; // can't use special char parser on this
1345 echo htmlspecialchars("$disphour:$dispmin " . xl($dispampm) . " " . xl_appt_category($row['pc_catname']),ENT_NOQUOTES) . "<br>\n";
1346 echo htmlspecialchars($row['fname'] . " " . $row['lname'],ENT_NOQUOTES) . "</a><br>\n";
1348 if (isset($res) && $res != null) {
1349 if ( $count < 1 ) {
1350 echo "&nbsp;&nbsp;" . htmlspecialchars(xl('None'),ENT_NOQUOTES);
1352 echo "</div>";
1356 // Show PAST appointments.
1357 // added by Terry Hill to allow reverse sorting of the appointments
1358 $direction = "ASC";
1359 if ($GLOBALS['num_past_appointments_to_show'] < 0) {
1360 $direction = "DESC";
1361 ($showpast = -1 * $GLOBALS['num_past_appointments_to_show'] );
1363 else
1365 $showpast = $GLOBALS['num_past_appointments_to_show'];
1368 if (isset($pid) && !$GLOBALS['disable_calendar'] && $showpast > 0) {
1369 $query = "SELECT e.pc_eid, e.pc_aid, e.pc_title, e.pc_eventDate, " .
1370 "e.pc_startTime, e.pc_hometext, u.fname, u.lname, u.mname, " .
1371 "c.pc_catname, e.pc_apptstatus " .
1372 "FROM openemr_postcalendar_events AS e, users AS u, " .
1373 "openemr_postcalendar_categories AS c WHERE " .
1374 "e.pc_pid = ? AND e.pc_eventDate < CURRENT_DATE AND " .
1375 "u.id = e.pc_aid AND e.pc_catid = c.pc_catid " .
1376 "ORDER BY e.pc_eventDate $direction , e.pc_startTime DESC " .
1377 "LIMIT " . $showpast;
1379 $pres = sqlStatement($query, array($pid) );
1381 // appointments expand collapse widget
1382 $widgetTitle = xl("Past Appoinments");
1383 $widgetLabel = "past_appointments";
1384 $widgetButtonLabel = '';
1385 $widgetButtonLink = '';
1386 $widgetButtonClass = '';
1387 $linkMethod = "javascript";
1388 $bodyClass = "summary_item small";
1389 $widgetAuth = false; //no button
1390 $fixedWidth = false;
1391 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1392 $count = 0;
1393 while($row = sqlFetchArray($pres)) {
1394 $count++;
1395 $dayname = date("l", strtotime($row['pc_eventDate']));
1396 $dispampm = "am";
1397 $disphour = substr($row['pc_startTime'], 0, 2) + 0;
1398 $dispmin = substr($row['pc_startTime'], 3, 2);
1399 if ($disphour >= 12) {
1400 $dispampm = "pm";
1401 if ($disphour > 12) $disphour -= 12;
1403 if ($row['pc_hometext'] != "") {
1404 $etitle = xl('Comments').": ".($row['pc_hometext'])."\r\n".$etitle;
1406 echo "<a href='javascript:oldEvt(" . htmlspecialchars($row['pc_eid'],ENT_QUOTES) . ")' title='" . htmlspecialchars($etitle,ENT_QUOTES) . "'>";
1407 echo "<b>" . htmlspecialchars(xl($dayname) . ", " . $row['pc_eventDate'],ENT_NOQUOTES) . "</b>" . xlt("Status") . "(";
1408 echo " " . generate_display_field(array('data_type'=>'1','list_id'=>'apptstat'),$row['pc_apptstatus']) . ")<br>"; // can't use special char parser on this
1409 echo htmlspecialchars("$disphour:$dispmin ") . xl($dispampm) . " ";
1410 echo htmlspecialchars($row['fname'] . " " . $row['lname'],ENT_NOQUOTES) . "</a><br>\n";
1412 if (isset($pres) && $res != null) {
1413 if ( $count < 1 ) {
1414 echo "&nbsp;&nbsp;" . htmlspecialchars(xl('None'),ENT_NOQUOTES);
1416 echo "</div>";
1419 // END of past appointments
1422 </div>
1424 <div id='stats_div'>
1425 <br/>
1426 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
1427 </div>
1428 </td>
1429 </tr>
1431 <?php // TRACK ANYTHING -----
1433 // Determine if track_anything form is in use for this site.
1434 $tmp = sqlQuery("SELECT count(*) AS count FROM registry WHERE " .
1435 "directory = 'track_anything' AND state = 1");
1436 $track_is_registered = $tmp['count'];
1437 if($track_is_registered){
1438 echo "<tr> <td>";
1439 // track_anything expand collapse widget
1440 $widgetTitle = xl("Tracks");
1441 $widgetLabel = "track_anything";
1442 $widgetButtonLabel = xl("Tracks");
1443 $widgetButtonLink = "../../forms/track_anything/create.php";
1444 $widgetButtonClass = "";
1445 $widgetAuth = ""; // don't show the button
1446 $linkMethod = "html";
1447 $bodyClass = "notab";
1448 // check to see if any tracks exist
1449 $spruch = "SELECT id " .
1450 "FROM forms " .
1451 "WHERE pid = ? " .
1452 "AND formdir = ? ";
1453 $existTracks = sqlQuery($spruch, array($pid, "track_anything") );
1455 $fixedWidth = false;
1456 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
1457 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
1458 $widgetAuth, $fixedWidth);
1460 <br/>
1461 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
1462 </div>
1463 </td>
1464 </tr>
1465 <?php } // end track_anything ?>
1466 </table>
1468 </div> <!-- end right column div -->
1470 </td>
1472 </tr>
1473 </table>
1475 </div> <!-- end main content div -->
1477 <?php if (false && $GLOBALS['athletic_team']) { ?>
1478 <script language='JavaScript'>
1479 Calendar.setup({inputField:"form_userdate1", ifFormat:"%Y-%m-%d", button:"img_userdate1"});
1480 </script>
1481 <?php } ?>
1483 </body>
1484 </html>