Removed athletic_team code.
[openemr.git] / interface / patient_file / summary / demographics.php
blob1128e77cd22858182125b44d88a16fc2e643524f
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");
42 require_once("$srcdir/options.js.php");
43 ////////////
44 require_once(dirname(__FILE__)."/../../../library/appointments.inc.php");
46 if ($GLOBALS['concurrent_layout'] && isset($_GET['set_pid'])) {
47 include_once("$srcdir/pid.inc");
48 setpid($_GET['set_pid']);
51 $active_reminders = false;
52 $all_allergy_alerts = false;
53 if ($GLOBALS['enable_cdr']) {
54 //CDR Engine stuff
55 if ($GLOBALS['enable_allergy_check'] && $GLOBALS['enable_alert_log']) {
56 //Check for new allergies conflicts and throw popup if any exist(note need alert logging to support this)
57 $new_allergy_alerts = allergy_conflict($pid,'new',$_SESSION['authUser']);
58 if (!empty($new_allergy_alerts)) {
59 $pop_warning = '<script type="text/javascript">alert(\'' . xls('WARNING - FOLLOWING ACTIVE MEDICATIONS ARE ALLERGIES') . ':\n';
60 foreach ($new_allergy_alerts as $new_allergy_alert) {
61 $pop_warning .= addslashes($new_allergy_alert) . '\n';
63 $pop_warning .= '\')</script>';
64 echo $pop_warning;
67 if ((!isset($_SESSION['alert_notify_pid']) || ($_SESSION['alert_notify_pid'] != $pid)) && isset($_GET['set_pid']) && $GLOBALS['enable_cdr_crp']) {
68 // showing a new patient, so check for active reminders and allergy conflicts, which use in active reminder popup
69 $active_reminders = active_alert_summary($pid,"reminders-due",'','default',$_SESSION['authUser'],TRUE);
70 if ($GLOBALS['enable_allergy_check']) {
71 $all_allergy_alerts = allergy_conflict($pid,'all',$_SESSION['authUser'],TRUE);
76 function print_as_money($money) {
77 preg_match("/(\d*)\.?(\d*)/",$money,$moneymatches);
78 $tmp = wordwrap(strrev($moneymatches[1]),3,",",1);
79 $ccheck = strrev($tmp);
80 if ($ccheck[0] == ",") {
81 $tmp = substr($ccheck,1,strlen($ccheck)-1);
83 if ($moneymatches[2] != "") {
84 return "$ " . strrev($tmp) . "." . $moneymatches[2];
85 } else {
86 return "$ " . strrev($tmp);
90 // get an array from Photos category
91 function pic_array($pid,$picture_directory) {
92 $pics = array();
93 $sql_query = "select documents.id from documents join categories_to_documents " .
94 "on documents.id = categories_to_documents.document_id " .
95 "join categories on categories.id = categories_to_documents.category_id " .
96 "where categories.name like ? and documents.foreign_id = ?";
97 if ($query = sqlStatement($sql_query, array($picture_directory,$pid))) {
98 while( $results = sqlFetchArray($query) ) {
99 array_push($pics,$results['id']);
102 return ($pics);
104 // Get the document ID of the first document in a specific catg.
105 function get_document_by_catg($pid,$doc_catg) {
107 $result = array();
109 if ($pid and $doc_catg) {
110 $result = sqlQuery("SELECT d.id, d.date, d.url FROM " .
111 "documents AS d, categories_to_documents AS cd, categories AS c " .
112 "WHERE d.foreign_id = ? " .
113 "AND cd.document_id = d.id " .
114 "AND c.id = cd.category_id " .
115 "AND c.name LIKE ? " .
116 "ORDER BY d.date DESC LIMIT 1", array($pid, $doc_catg) );
119 return($result['id']);
122 // Display image in 'widget style'
123 function image_widget($doc_id,$doc_catg)
125 global $pid, $web_root;
126 $docobj = new Document($doc_id);
127 $image_file = $docobj->get_url_file();
128 $extension = substr($image_file, strrpos($image_file,"."));
129 $viewable_types = array('.png','.jpg','.jpeg','.png','.bmp','.PNG','.JPG','.JPEG','.PNG','.BMP'); // image ext supported by fancybox viewer
130 if ( in_array($extension,$viewable_types) ) { // extention matches list
131 $to_url = "<td> <a href = $web_root" .
132 "/controller.php?document&retrieve&patient_id=$pid&document_id=$doc_id" .
133 "/tmp$extension" . // Force image type URL for fancybox
134 " onclick=top.restoreSession(); class='image_modal'>" .
135 " <img src = $web_root" .
136 "/controller.php?document&retrieve&patient_id=$pid&document_id=$doc_id" .
137 " width=100 alt='$doc_catg:$image_file'> </a> </td> <td valign='center'>".
138 htmlspecialchars($doc_catg) . '<br />&nbsp;' . htmlspecialchars($image_file) .
139 "</td>";
141 else {
142 $to_url = "<td> <a href='" . $web_root . "/controller.php?document&retrieve" .
143 "&patient_id=$pid&document_id=$doc_id'" .
144 " onclick='top.restoreSession()' class='css_button_small'>" .
145 "<span>" .
146 htmlspecialchars( xl("View"), ENT_QUOTES )."</a> &nbsp;" .
147 htmlspecialchars( "$doc_catg - $image_file", ENT_QUOTES ) .
148 "</span> </td>";
150 echo "<table><tr>";
151 echo $to_url;
152 echo "</tr></table>";
155 // Determine if the Vitals form is in use for this site.
156 $tmp = sqlQuery("SELECT count(*) AS count FROM registry WHERE " .
157 "directory = 'vitals' AND state = 1");
158 $vitals_is_registered = $tmp['count'];
160 // Get patient/employer/insurance information.
162 $result = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
163 $result2 = getEmployerData($pid);
164 $result3 = getInsuranceData($pid, "primary", "copay, provider, DATE_FORMAT(`date`,'%Y-%m-%d') as effdate");
165 $insco_name = "";
166 if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
167 $insco_name = getInsuranceProvider($result3['provider']);
170 <html>
172 <head>
173 <?php html_header_show();?>
174 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
175 <link rel="stylesheet" type="text/css" href="../../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
176 <style type="text/css">@import url(../../../library/dynarch_calendar.css);</style>
177 <script type="text/javascript" src="../../../library/textformat.js"></script>
178 <script type="text/javascript" src="../../../library/dynarch_calendar.js"></script>
179 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
180 <script type="text/javascript" src="../../../library/dynarch_calendar_setup.js"></script>
181 <script type="text/javascript" src="../../../library/dialog.js"></script>
182 <script type="text/javascript" src="../../../library/js/jquery-1.6.4.min.js"></script>
183 <script type="text/javascript" src="../../../library/js/common.js"></script>
184 <script type="text/javascript" src="../../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
185 <script type="text/javascript" language="JavaScript">
187 var mypcc = '<?php echo htmlspecialchars($GLOBALS['phone_country_code'],ENT_QUOTES); ?>';
188 //////////
189 function oldEvt(apptdate, eventid) {
190 dlgopen('../../main/calendar/add_edit_event.php?date=' + apptdate + '&eid=' + eventid, '_blank', 775, 375);
193 function advdirconfigure() {
194 dlgopen('advancedirectives.php', '_blank', 500, 450);
197 function refreshme() {
198 top.restoreSession();
199 location.reload();
202 // Process click on Delete link.
203 function deleteme() {
204 dlgopen('../deleter.php?patient=<?php echo htmlspecialchars($pid,ENT_QUOTES); ?>', '_blank', 500, 450);
205 return false;
208 // Called by the deleteme.php window on a successful delete.
209 function imdeleted() {
210 <?php if ($GLOBALS['concurrent_layout']) { ?>
211 parent.left_nav.clearPatient();
212 <?php } else { ?>
213 top.restoreSession();
214 top.location.href = '../main/main_screen.php';
215 <?php } ?>
218 function newEvt() {
219 dlgopen('../../main/calendar/add_edit_event.php?patientid=<?php echo htmlspecialchars($pid,ENT_QUOTES); ?>', '_blank', 775, 375);
220 return false;
223 function sendimage(pid, what) {
224 // alert('Not yet implemented.'); return false;
225 dlgopen('../upload_dialog.php?patientid=' + pid + '&file=' + what,
226 '_blank', 500, 400);
227 return false;
230 </script>
232 <script type="text/javascript">
234 function toggleIndicator(target,div) {
236 $mode = $(target).find(".indicator").text();
237 if ( $mode == "<?php echo htmlspecialchars(xl('collapse'),ENT_QUOTES); ?>" ) {
238 $(target).find(".indicator").text( "<?php echo htmlspecialchars(xl('expand'),ENT_QUOTES); ?>" );
239 $("#"+div).hide();
240 $.post( "../../../library/ajax/user_settings.php", { target: div, mode: 0 });
241 } else {
242 $(target).find(".indicator").text( "<?php echo htmlspecialchars(xl('collapse'),ENT_QUOTES); ?>" );
243 $("#"+div).show();
244 $.post( "../../../library/ajax/user_settings.php", { target: div, mode: 1 });
248 $(document).ready(function(){
249 var msg_updation='';
250 <?php
251 if($GLOBALS['erx_enable']){
252 //$soap_status=sqlQuery("select soap_import_status from patient_data where pid=?",array($pid));
253 $soap_status=sqlStatement("select soap_import_status,pid from patient_data where pid=? and soap_import_status in ('1','3')",array($pid));
254 while($row_soapstatus=sqlFetchArray($soap_status)){
255 //if($soap_status['soap_import_status']=='1' || $soap_status['soap_import_status']=='3'){ ?>
256 top.restoreSession();
257 $.ajax({
258 type: "POST",
259 url: "../../soap_functions/soap_patientfullmedication.php",
260 dataType: "html",
261 data: {
262 patient:<?php echo $row_soapstatus['pid']; ?>,
264 async: false,
265 success: function(thedata){
266 //alert(thedata);
267 msg_updation+=thedata;
269 error:function(){
270 alert('ajax error');
273 <?php
274 //}
275 //elseif($soap_status['soap_import_status']=='3'){ ?>
276 top.restoreSession();
277 $.ajax({
278 type: "POST",
279 url: "../../soap_functions/soap_allergy.php",
280 dataType: "html",
281 data: {
282 patient:<?php echo $row_soapstatus['pid']; ?>,
284 async: false,
285 success: function(thedata){
286 //alert(thedata);
287 msg_updation+=thedata;
289 error:function(){
290 alert('ajax error');
293 <?php
294 if($GLOBALS['erx_import_status_message']){ ?>
295 if(msg_updation)
296 alert(msg_updation);
297 <?php
299 //}
303 // load divs
304 $("#stats_div").load("stats.php", { 'embeddedScreen' : true }, function() {
305 // (note need to place javascript code here also to get the dynamic link to work)
306 $(".rx_modal").fancybox( {
307 'overlayOpacity' : 0.0,
308 'showCloseButton' : true,
309 'frameHeight' : 500,
310 'frameWidth' : 800,
311 'centerOnScroll' : false,
312 'callbackOnClose' : function() {
313 refreshme();
317 $("#pnotes_ps_expand").load("pnotes_fragment.php");
318 $("#disclosures_ps_expand").load("disc_fragment.php");
320 <?php if ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crw']) { ?>
321 top.restoreSession();
322 $("#clinical_reminders_ps_expand").load("clinical_reminders_fragment.php", { 'embeddedScreen' : true }, function() {
323 // (note need to place javascript code here also to get the dynamic link to work)
324 $(".medium_modal").fancybox( {
325 'overlayOpacity' : 0.0,
326 'showCloseButton' : true,
327 'frameHeight' : 500,
328 'frameWidth' : 800,
329 'centerOnScroll' : false,
330 'callbackOnClose' : function() {
331 refreshme();
335 <?php } // end crw?>
337 <?php if ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_prw']) { ?>
338 top.restoreSession();
339 $("#patient_reminders_ps_expand").load("patient_reminders_fragment.php");
340 <?php } // end prw?>
342 <?php if ($vitals_is_registered && acl_check('patients', 'med')) { ?>
343 // Initialize the Vitals form if it is registered and user is authorized.
344 $("#vitals_ps_expand").load("vitals_fragment.php");
345 <?php } ?>
347 // Initialize track_anything
348 $("#track_anything_ps_expand").load("track_anything_fragment.php");
351 // Initialize labdata
352 $("#labdata_ps_expand").load("labdata_fragment.php");
353 <?php
354 // Initialize for each applicable LBF form.
355 $gfres = sqlStatement("SELECT option_id FROM list_options WHERE " .
356 "list_id = 'lbfnames' AND option_value > 0 ORDER BY seq, title");
357 while($gfrow = sqlFetchArray($gfres)) {
359 $("#<?php echo $gfrow['option_id']; ?>_ps_expand").load("lbf_fragment.php?formname=<?php echo $gfrow['option_id']; ?>");
360 <?php
364 // fancy box
365 enable_modals();
367 tabbify();
369 // modal for dialog boxes
370 $(".large_modal").fancybox( {
371 'overlayOpacity' : 0.0,
372 'showCloseButton' : true,
373 'frameHeight' : 600,
374 'frameWidth' : 1000,
375 'centerOnScroll' : false
378 // modal for image viewer
379 $(".image_modal").fancybox( {
380 'overlayOpacity' : 0.0,
381 'showCloseButton' : true,
382 'centerOnScroll' : false,
383 'autoscale' : true
386 $(".iframe1").fancybox( {
387 'left':10,
388 'overlayOpacity' : 0.0,
389 'showCloseButton' : true,
390 'frameHeight' : 300,
391 'frameWidth' : 350
393 // special size for patient portal
394 $(".small_modal").fancybox( {
395 'overlayOpacity' : 0.0,
396 'showCloseButton' : true,
397 'frameHeight' : 200,
398 'frameWidth' : 380,
399 'centerOnScroll' : false
402 <?php if ($active_reminders || $all_allergy_alerts) { ?>
403 // show the active reminder modal
404 $("#reminder_popup_link").fancybox({
405 'overlayOpacity' : 0.0,
406 'showCloseButton' : true,
407 'frameHeight' : 500,
408 'frameWidth' : 500,
409 'centerOnScroll' : false
410 }).trigger('click');
411 <?php } ?>
415 // JavaScript stuff to do when a new patient is set.
417 function setMyPatient() {
418 <?php if ($GLOBALS['concurrent_layout']) { ?>
419 // Avoid race conditions with loading of the left_nav or Title frame.
420 if (!parent.allFramesLoaded()) {
421 setTimeout("setMyPatient()", 500);
422 return;
424 <?php if (isset($_GET['set_pid'])) { ?>
425 parent.left_nav.setPatient(<?php echo "'" . htmlspecialchars(($result['fname']) . " " . ($result['lname']),ENT_QUOTES) .
426 "'," . htmlspecialchars($pid,ENT_QUOTES) . ",'" . htmlspecialchars(($result['pubpid']),ENT_QUOTES) .
427 "','', ' " . htmlspecialchars(xl('DOB') . ": " . oeFormatShortDate($result['DOB_YMD']) . " " . xl('Age') . ": " . getPatientAgeDisplay($result['DOB_YMD']), ENT_QUOTES) . "'"; ?>);
428 var EncounterDateArray = new Array;
429 var CalendarCategoryArray = new Array;
430 var EncounterIdArray = new Array;
431 var Count = 0;
432 <?php
433 //Encounter details are stored to javacript as array.
434 $result4 = sqlStatement("SELECT fe.encounter,fe.date,openemr_postcalendar_categories.pc_catname FROM form_encounter AS fe ".
435 " left join openemr_postcalendar_categories on fe.pc_catid=openemr_postcalendar_categories.pc_catid WHERE fe.pid = ? order by fe.date desc", array($pid));
436 if(sqlNumRows($result4)>0) {
437 while($rowresult4 = sqlFetchArray($result4)) {
439 EncounterIdArray[Count] = '<?php echo htmlspecialchars($rowresult4['encounter'], ENT_QUOTES); ?>';
440 EncounterDateArray[Count] = '<?php echo htmlspecialchars(oeFormatShortDate(date("Y-m-d", strtotime($rowresult4['date']))), ENT_QUOTES); ?>';
441 CalendarCategoryArray[Count] = '<?php echo htmlspecialchars(xl_appt_category($rowresult4['pc_catname']), ENT_QUOTES); ?>';
442 Count++;
443 <?php
447 parent.left_nav.setPatientEncounter(EncounterIdArray,EncounterDateArray,CalendarCategoryArray);
448 <?php } // end setting new pid ?>
449 parent.left_nav.setRadio(window.name, 'dem');
450 parent.left_nav.syncRadios();
451 <?php if ( (isset($_GET['set_pid']) ) && (isset($_GET['set_encounterid'])) && ( intval($_GET['set_encounterid']) > 0 ) ) {
452 $encounter = intval($_GET['set_encounterid']);
453 $_SESSION['encounter'] = $encounter;
454 $query_result = sqlQuery("SELECT `date` FROM `form_encounter` WHERE `encounter` = ?", array($encounter)); ?>
455 var othername = (window.name == 'RTop') ? 'RBot' : 'RTop';
456 parent.left_nav.setEncounter('<?php echo oeFormatShortDate(date("Y-m-d", strtotime($query_result['date']))); ?>', '<?php echo attr($encounter); ?>', othername);
457 parent.left_nav.setRadio(othername, 'enc');
458 parent.frames[othername].location.href = '../encounter/encounter_top.php?set_encounter=' + <?php echo attr($encounter);?> + '&pid=' + <?php echo attr($pid);?>;
459 <?php } // end setting new encounter id (only if new pid is also set) ?>
460 <?php } // end concurrent layout ?>
463 $(window).load(function() {
464 setMyPatient();
467 </script>
469 <style type="css/text">
470 #pnotes_ps_expand {
471 height:auto;
472 width:100%;
474 </style>
476 </head>
478 <body class="body_top">
480 <a href='../reminder/active_reminder_popup.php' id='reminder_popup_link' style='visibility: false;' class='iframe' onclick='top.restoreSession()'></a>
482 <?php
483 $thisauth = acl_check('patients', 'demo');
484 if ($thisauth) {
485 if ($result['squad'] && ! acl_check('squads', $result['squad']))
486 $thisauth = 0;
488 if (!$thisauth) {
489 echo "<p>(" . htmlspecialchars(xl('Demographics not authorized'),ENT_NOQUOTES) . ")</p>\n";
490 echo "</body>\n</html>\n";
491 exit();
493 if ($thisauth) {
494 echo "<table><tr><td><span class='title'>" .
495 htmlspecialchars(getPatientName($pid),ENT_NOQUOTES) .
496 "</span></td>";
498 if (acl_check('admin', 'super') && $GLOBALS['allow_pat_delete']) {
499 echo "<td style='padding-left:1em;'><a class='css_button iframe' href='../deleter.php?patient=" .
500 htmlspecialchars($pid,ENT_QUOTES) . "' onclick='top.restoreSession()'>" .
501 "<span>".htmlspecialchars(xl('Delete'),ENT_NOQUOTES).
502 "</span></a></td>";
504 if($GLOBALS['erx_enable']){
505 echo '<td style="padding-left:1em;"><a class="css_button" href="../../eRx.php?page=medentry" onclick="top.restoreSession()">';
506 echo "<span>".htmlspecialchars(xl('NewCrop MedEntry'),ENT_NOQUOTES)."</span></a></td>";
507 echo '<td style="padding-left:1em;"><a class="css_button iframe1" href="../../soap_functions/soap_accountStatusDetails.php" onclick="top.restoreSession()">';
508 echo "<span>".htmlspecialchars(xl('NewCrop Account Status'),ENT_NOQUOTES)."</span></a></td><td id='accountstatus'></td>";
510 //Patient Portal
511 $portalUserSetting = true; //flag to see if patient has authorized access to portal
512 if($GLOBALS['portal_onsite_enable'] && $GLOBALS['portal_onsite_address']){
513 $portalStatus = sqlQuery("SELECT allow_patient_portal FROM patient_data WHERE pid=?",array($pid));
514 if ($portalStatus['allow_patient_portal']=='YES') {
515 $portalLogin = sqlQuery("SELECT pid FROM `patient_access_onsite` WHERE `pid`=?", array($pid));
516 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()'>";
517 if (empty($portalLogin)) {
518 echo "<span>".htmlspecialchars(xl('Create Onsite Portal Credentials'),ENT_NOQUOTES)."</span></a></td>";
520 else {
521 echo "<span>".htmlspecialchars(xl('Reset Onsite Portal Credentials'),ENT_NOQUOTES)."</span></a></td>";
524 else {
525 $portalUserSetting = false;
528 if($GLOBALS['portal_offsite_enable'] && $GLOBALS['portal_offsite_address']){
529 $portalStatus = sqlQuery("SELECT allow_patient_portal FROM patient_data WHERE pid=?",array($pid));
530 if ($portalStatus['allow_patient_portal']=='YES') {
531 $portalLogin = sqlQuery("SELECT pid FROM `patient_access_offsite` WHERE `pid`=?", array($pid));
532 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()'>";
533 if (empty($portalLogin)) {
534 echo "<span>".htmlspecialchars(xl('Create Offsite Portal Credentials'),ENT_NOQUOTES)."</span></a></td>";
536 else {
537 echo "<span>".htmlspecialchars(xl('Reset Offsite Portal Credentials'),ENT_NOQUOTES)."</span></a></td>";
540 else {
541 $portalUserSetting = false;
544 if (!($portalUserSetting)) {
545 // Show that the patient has not authorized portal access
546 echo "<td style='padding-left:1em;'>" . htmlspecialchars( xl('Patient has not authorized the Patient Portal.'), ENT_NOQUOTES) . "</td>";
548 //Patient Portal
550 // If patient is deceased, then show this (along with the number of days patient has been deceased for)
551 $days_deceased = is_patient_deceased($pid);
552 if ($days_deceased) {
553 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>";
556 echo "</tr></table>";
559 // Get the document ID of the patient ID card if access to it is wanted here.
560 $idcard_doc_id = false;
561 if ($GLOBALS['patient_id_category_name']) {
562 $idcard_doc_id = get_document_by_catg($pid, $GLOBALS['patient_id_category_name']);
566 <table cellspacing='0' cellpadding='0' border='0'>
567 <tr>
568 <td class="small" colspan='4'>
569 <a href="../history/history.php" onclick='top.restoreSession()'>
570 <?php echo htmlspecialchars(xl('History'),ENT_NOQUOTES); ?></a>
572 <?php //note that we have temporarily removed report screen from the modal view ?>
573 <a href="../report/patient_report.php" onclick='top.restoreSession()'>
574 <?php echo htmlspecialchars(xl('Report'),ENT_NOQUOTES); ?></a>
576 <?php //note that we have temporarily removed document screen from the modal view ?>
577 <a href="../../../controller.php?document&list&patient_id=<?php echo $pid;?>" onclick='top.restoreSession()'>
578 <?php echo htmlspecialchars(xl('Documents'),ENT_NOQUOTES); ?></a>
580 <a href="../transaction/transactions.php" class='iframe large_modal' onclick='top.restoreSession()'>
581 <?php echo htmlspecialchars(xl('Transactions'),ENT_NOQUOTES); ?></a>
583 <a href="stats_full.php?active=all" onclick='top.restoreSession()'>
584 <?php echo htmlspecialchars(xl('Issues'),ENT_NOQUOTES); ?></a>
586 <a href="../../reports/pat_ledger.php?form=1&patient_id=<?php echo attr($pid);?>" onclick='top.restoreSession()'>
587 <?php echo xlt('Ledger'); ?></a>
589 <a href="../../reports/external_data.php" onclick='top.restoreSession()'>
590 <?php echo xlt('External Data'); ?></a>
592 <!-- DISPLAYING HOOKS STARTS HERE -->
593 <?php
594 $module_query = sqlStatement("SELECT msh.*,ms.menu_name,ms.path,m.mod_ui_name,m.type FROM modules_hooks_settings AS msh
595 LEFT OUTER JOIN modules_settings AS ms ON obj_name=enabled_hooks AND ms.mod_id=msh.mod_id
596 LEFT OUTER JOIN modules AS m ON m.mod_id=ms.mod_id
597 WHERE fld_type=3 AND mod_active=1 AND sql_run=1 AND attached_to='demographics' ORDER BY mod_id");
598 $DivId = 'mod_installer';
599 if (sqlNumRows($module_query)) {
600 $jid = 0;
601 $modid = '';
602 while ($modulerow = sqlFetchArray($module_query)) {
603 $DivId = 'mod_'.$modulerow['mod_id'];
604 $new_category = $modulerow['mod_ui_name'];
605 $modulePath = "";
606 $added = "";
607 if($modulerow['type'] == 0) {
608 $modulePath = $GLOBALS['customModDir'];
609 $added = "";
611 else{
612 $added = "index";
613 $modulePath = $GLOBALS['zendModDir'];
615 $relative_link = "../../modules/".$modulePath."/".$modulerow['path'];
616 $nickname = $modulerow['menu_name'] ? $modulerow['menu_name'] : 'Noname';
617 $jid++;
618 $modid = $modulerow['mod_id'];
621 <a href="<?php echo $relative_link; ?>" onclick='top.restoreSession()'>
622 <?php echo htmlspecialchars($nickname,ENT_NOQUOTES); ?></a>
623 <?php
627 <!-- DISPLAYING HOOKS ENDS HERE -->
629 </td>
630 </tr>
632 </table> <!-- end header -->
634 <div style='margin-top:10px'> <!-- start main content div -->
635 <table border="0" cellspacing="0" cellpadding="0" width="100%">
636 <tr>
637 <td class="demographics-box" align="left" valign="top">
638 <!-- start left column div -->
639 <div style='float:left; margin-right:20px'>
640 <table cellspacing=0 cellpadding=0>
641 <tr>
642 <td>
643 <?php
644 // Billing expand collapse widget
645 $widgetTitle = xl("Billing");
646 $widgetLabel = "billing";
647 $widgetButtonLabel = xl("Edit");
648 $widgetButtonLink = "return newEvt();";
649 $widgetButtonClass = "";
650 $linkMethod = "javascript";
651 $bodyClass = "notab";
652 $widgetAuth = false;
653 $fixedWidth = true;
654 if ($GLOBALS['force_billing_widget_open']) {
655 $forceExpandAlways = true;
657 else {
658 $forceExpandAlways = false;
660 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
661 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
662 $widgetAuth, $fixedWidth, $forceExpandAlways);
664 <br>
665 <?php
666 //PATIENT BALANCE,INS BALANCE naina@capminds.com
667 $patientbalance = get_patient_balance($pid, false);
668 //Debit the patient balance from insurance balance
669 $insurancebalance = get_patient_balance($pid, true) - $patientbalance;
670 $totalbalance=$patientbalance + $insurancebalance;
671 if ($GLOBALS['oer_config']['ws_accounting']['enabled']) {
672 // Show current balance and billing note, if any.
673 echo "<table border='0'><tr><td>" .
674 "<table ><tr><td><span class='bold'><font color='red'>" .
675 xlt('Patient Balance Due') .
676 " : " . text(oeFormatMoney($patientbalance)) .
677 "</font></span></td></tr>".
678 "<tr><td><span class='bold'><font color='red'>" .
679 xlt('Insurance Balance Due') .
680 " : " . text(oeFormatMoney($insurancebalance)) .
681 "</font></span></td></tr>".
682 "<tr><td><span class='bold'><font color='red'>" .
683 xlt('Total Balance Due').
684 " : " . text(oeFormatMoney($totalbalance)) .
685 "</font></span></td></td></tr>";
686 if (!empty($result['billing_note'])) {
687 echo "<tr><td><span class='bold'><font color='red'>" .
688 xlt('Billing Note') . ":" .
689 text($result['billing_note']) .
690 "</font></span></td></tr>";
692 if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
693 echo "<tr><td><span class='bold'>" .
694 xlt('Primary Insurance') . ': ' . text($insco_name) .
695 "</span>&nbsp;&nbsp;&nbsp;";
696 if ($result3['copay'] > 0) {
697 echo "<span class='bold'>" .
698 xlt('Copay') . ': ' . text($result3['copay']) .
699 "</span>&nbsp;&nbsp;&nbsp;";
701 echo "<span class='bold'>" .
702 xlt('Effective Date') . ': ' . text(oeFormatShortDate($result3['effdate'])) .
703 "</span></td></tr>";
705 echo "</table></td></tr></td></tr></table><br>";
708 </div> <!-- required for expand_collapse_widget -->
709 </td>
710 </tr>
711 <tr>
712 <td>
713 <?php
714 // Demographics expand collapse widget
715 $widgetTitle = xl("Demographics");
716 $widgetLabel = "demographics";
717 $widgetButtonLabel = xl("Edit");
718 $widgetButtonLink = "demographics_full.php";
719 $widgetButtonClass = "";
720 $linkMethod = "html";
721 $bodyClass = "";
722 $widgetAuth = acl_check('patients', 'demo', '', 'write');
723 $fixedWidth = true;
724 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
725 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
726 $widgetAuth, $fixedWidth);
728 <div id="DEM" >
729 <ul class="tabNav">
730 <?php display_layout_tabs('DEM', $result, $result2); ?>
731 </ul>
732 <div class="tabContainer">
733 <?php display_layout_tabs_data('DEM', $result, $result2); ?>
734 </div>
735 </div>
736 </div> <!-- required for expand_collapse_widget -->
737 </td>
738 </tr>
740 <tr>
741 <td>
742 <?php
743 $insurance_count = 0;
744 foreach (array('primary','secondary','tertiary') as $instype) {
745 $enddate = 'Present';
746 $query = "SELECT * FROM insurance_data WHERE " .
747 "pid = ? AND type = ? " .
748 "ORDER BY date DESC";
749 $res = sqlStatement($query, array($pid, $instype) );
750 while( $row = sqlFetchArray($res) ) {
751 if ($row['provider'] ) $insurance_count++;
755 if ( $insurance_count > 0 ) {
756 // Insurance expand collapse widget
757 $widgetTitle = xl("Insurance");
758 $widgetLabel = "insurance";
759 $widgetButtonLabel = xl("Edit");
760 $widgetButtonLink = "demographics_full.php";
761 $widgetButtonClass = "";
762 $linkMethod = "html";
763 $bodyClass = "";
764 $widgetAuth = acl_check('patients', 'demo', '', 'write');
765 $fixedWidth = true;
766 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
767 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
768 $widgetAuth, $fixedWidth);
770 if ( $insurance_count > 0 ) {
773 <ul class="tabNav"><?php
774 ///////////////////////////////// INSURANCE SECTION
775 $first = true;
776 foreach (array('primary','secondary','tertiary') as $instype) {
778 $query = "SELECT * FROM insurance_data WHERE " .
779 "pid = ? AND type = ? " .
780 "ORDER BY date DESC";
781 $res = sqlStatement($query, array($pid, $instype) );
783 $enddate = 'Present';
785 while( $row = sqlFetchArray($res) ) {
786 if ($row['provider'] ) {
788 $ins_description = ucfirst($instype);
789 $ins_description = xl($ins_description);
790 $ins_description .= strcmp($enddate, 'Present') != 0 ? " (".xl('Old').")" : "";
792 <li <?php echo $first ? 'class="current"' : '' ?>><a href="/play/javascript-tabbed-navigation/">
793 <?php echo htmlspecialchars($ins_description,ENT_NOQUOTES); ?></a></li>
794 <?php
795 $first = false;
797 $enddate = $row['date'];
800 // Display the eligibility tab
801 echo "<li><a href='/play/javascript-tabbed-navigation/'>" .
802 htmlspecialchars( xl('Eligibility'), ENT_NOQUOTES) . "</a></li>";
804 ?></ul><?php
806 } ?>
808 <div class="tabContainer">
809 <?php
810 $first = true;
811 foreach (array('primary','secondary','tertiary') as $instype) {
812 $enddate = 'Present';
814 $query = "SELECT * FROM insurance_data WHERE " .
815 "pid = ? AND type = ? " .
816 "ORDER BY date DESC";
817 $res = sqlStatement($query, array($pid, $instype) );
818 while( $row = sqlFetchArray($res) ) {
819 if ($row['provider'] ) {
821 <div class="tab <?php echo $first ? 'current' : '' ?>">
822 <table border='0' cellpadding='0' width='100%'>
823 <?php
824 $icobj = new InsuranceCompany($row['provider']);
825 $adobj = $icobj->get_address();
826 $insco_name = trim($icobj->get_name());
828 <tr>
829 <td valign='top' colspan='3'>
830 <span class='text'>
831 <?php if (strcmp($enddate, 'Present') != 0) echo htmlspecialchars(xl("Old"),ENT_NOQUOTES)." "; ?>
832 <?php $tempinstype=ucfirst($instype); echo htmlspecialchars(xl($tempinstype.' Insurance'),ENT_NOQUOTES); ?>
833 <?php if (strcmp($row['date'], '0000-00-00') != 0) { ?>
834 <?php echo htmlspecialchars(xl('from','',' ',' ').$row['date'],ENT_NOQUOTES); ?>
835 <?php } ?>
836 <?php echo htmlspecialchars(xl('until','',' ',' '),ENT_NOQUOTES);
837 echo (strcmp($enddate, 'Present') != 0) ? $enddate : htmlspecialchars(xl('Present'),ENT_NOQUOTES); ?>:</span>
838 </td>
839 </tr>
840 <tr>
841 <td valign='top'>
842 <span class='text'>
843 <?php
844 if ($insco_name) {
845 echo htmlspecialchars($insco_name,ENT_NOQUOTES) . '<br>';
846 if (trim($adobj->get_line1())) {
847 echo htmlspecialchars($adobj->get_line1(),ENT_NOQUOTES) . '<br>';
848 echo htmlspecialchars($adobj->get_city() . ', ' . $adobj->get_state() . ' ' . $adobj->get_zip(),ENT_NOQUOTES);
850 } else {
851 echo "<font color='red'><b>".htmlspecialchars(xl('Unassigned'),ENT_NOQUOTES)."</b></font>";
854 <br>
855 <?php echo htmlspecialchars(xl('Policy Number'),ENT_NOQUOTES); ?>:
856 <?php echo htmlspecialchars($row['policy_number'],ENT_NOQUOTES) ?><br>
857 <?php echo htmlspecialchars(xl('Plan Name'),ENT_NOQUOTES); ?>:
858 <?php echo htmlspecialchars($row['plan_name'],ENT_NOQUOTES); ?><br>
859 <?php echo htmlspecialchars(xl('Group Number'),ENT_NOQUOTES); ?>:
860 <?php echo htmlspecialchars($row['group_number'],ENT_NOQUOTES); ?></span>
861 </td>
862 <td valign='top'>
863 <span class='bold'><?php echo htmlspecialchars(xl('Subscriber'),ENT_NOQUOTES); ?>: </span><br>
864 <span class='text'><?php echo htmlspecialchars($row['subscriber_fname'] . ' ' . $row['subscriber_mname'] . ' ' . $row['subscriber_lname'],ENT_NOQUOTES); ?>
865 <?php
866 if ($row['subscriber_relationship'] != "") {
867 echo "(" . htmlspecialchars($row['subscriber_relationship'],ENT_NOQUOTES) . ")";
870 <br>
871 <?php echo htmlspecialchars(xl('S.S.'),ENT_NOQUOTES); ?>:
872 <?php echo htmlspecialchars($row['subscriber_ss'],ENT_NOQUOTES); ?><br>
873 <?php echo htmlspecialchars(xl('D.O.B.'),ENT_NOQUOTES); ?>:
874 <?php if ($row['subscriber_DOB'] != "0000-00-00 00:00:00") echo htmlspecialchars($row['subscriber_DOB'],ENT_NOQUOTES); ?><br>
875 <?php echo htmlspecialchars(xl('Phone'),ENT_NOQUOTES); ?>:
876 <?php echo htmlspecialchars($row['subscriber_phone'],ENT_NOQUOTES); ?>
877 </span>
878 </td>
879 <td valign='top'>
880 <span class='bold'><?php echo htmlspecialchars(xl('Subscriber Address'),ENT_NOQUOTES); ?>: </span><br>
881 <span class='text'><?php echo htmlspecialchars($row['subscriber_street'],ENT_NOQUOTES); ?><br>
882 <?php echo htmlspecialchars($row['subscriber_city'],ENT_NOQUOTES); ?>
883 <?php if($row['subscriber_state'] != "") echo ", "; echo htmlspecialchars($row['subscriber_state'],ENT_NOQUOTES); ?>
884 <?php if($row['subscriber_country'] != "") echo ", "; echo htmlspecialchars($row['subscriber_country'],ENT_NOQUOTES); ?>
885 <?php echo " " . htmlspecialchars($row['subscriber_postal_code'],ENT_NOQUOTES); ?></span>
887 <?php if (trim($row['subscriber_employer'])) { ?>
888 <br><span class='bold'><?php echo htmlspecialchars(xl('Subscriber Employer'),ENT_NOQUOTES); ?>: </span><br>
889 <span class='text'><?php echo htmlspecialchars($row['subscriber_employer'],ENT_NOQUOTES); ?><br>
890 <?php echo htmlspecialchars($row['subscriber_employer_street'],ENT_NOQUOTES); ?><br>
891 <?php echo htmlspecialchars($row['subscriber_employer_city'],ENT_NOQUOTES); ?>
892 <?php if($row['subscriber_employer_city'] != "") echo ", "; echo htmlspecialchars($row['subscriber_employer_state'],ENT_NOQUOTES); ?>
893 <?php if($row['subscriber_employer_country'] != "") echo ", "; echo htmlspecialchars($row['subscriber_employer_country'],ENT_NOQUOTES); ?>
894 <?php echo " " . htmlspecialchars($row['subscriber_employer_postal_code'],ENT_NOQUOTES); ?>
895 </span>
896 <?php } ?>
898 </td>
899 </tr>
900 <tr>
901 <td>
902 <?php if ($row['copay'] != "") { ?>
903 <span class='bold'><?php echo htmlspecialchars(xl('CoPay'),ENT_NOQUOTES); ?>: </span>
904 <span class='text'><?php echo htmlspecialchars($row['copay'],ENT_NOQUOTES); ?></span>
905 <br />
906 <?php } ?>
907 <span class='bold'><?php echo htmlspecialchars(xl('Accept Assignment'),ENT_NOQUOTES); ?>:</span>
908 <span class='text'><?php if($row['accept_assignment'] == "TRUE") echo xl("YES"); ?>
909 <?php if($row['accept_assignment'] == "FALSE") echo xl("NO"); ?></span>
910 <?php if (!empty($row['policy_type'])) { ?>
911 <br />
912 <span class='bold'><?php echo htmlspecialchars(xl('Secondary Medicare Type'),ENT_NOQUOTES); ?>: </span>
913 <span class='text'><?php echo htmlspecialchars($policy_types[$row['policy_type']],ENT_NOQUOTES); ?></span>
914 <?php } ?>
915 </td>
916 <td valign='top'></td>
917 <td valign='top'></td>
918 </tr>
920 </table>
921 </div>
922 <?php
924 } // end if ($row['provider'])
925 $enddate = $row['date'];
926 $first = false;
927 } // end while
928 } // end foreach
930 // Display the eligibility information
931 echo "<div class='tab'>";
932 show_eligibility_information($pid,true);
933 echo "</div>";
935 ///////////////////////////////// END INSURANCE SECTION
937 </div>
939 <?php } // ?>
941 </td>
942 </tr>
944 <tr>
945 <td width='650px'>
947 <?php
948 // Notes expand collapse widget
949 $widgetTitle = xl("Notes");
950 $widgetLabel = "pnotes";
951 $widgetButtonLabel = xl("Edit");
952 $widgetButtonLink = "pnotes_full.php?form_active=1";
953 $widgetButtonClass = "";
954 $linkMethod = "html";
955 $bodyClass = "notab";
956 $widgetAuth = true;
957 $fixedWidth = true;
958 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
959 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
960 $widgetAuth, $fixedWidth);
963 <br/>
964 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
965 </div>
966 </td>
967 </tr>
968 <?php if ( (acl_check('patients', 'med')) && ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_prw']) ) {
969 echo "<tr><td width='650px'>";
970 // patient reminders collapse widget
971 $widgetTitle = xl("Patient Reminders");
972 $widgetLabel = "patient_reminders";
973 $widgetButtonLabel = xl("Edit");
974 $widgetButtonLink = "../reminder/patient_reminders.php?mode=simple&patient_id=".$pid;
975 $widgetButtonClass = "";
976 $linkMethod = "html";
977 $bodyClass = "notab";
978 $widgetAuth = true;
979 $fixedWidth = true;
980 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth); ?>
981 <br/>
982 <div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>
983 </div>
984 </td>
985 </tr>
986 <?php } //end if prw is activated ?>
988 <tr>
989 <td width='650px'>
990 <?php
991 // disclosures expand collapse widget
992 $widgetTitle = xl("Disclosures");
993 $widgetLabel = "disclosures";
994 $widgetButtonLabel = xl("Edit");
995 $widgetButtonLink = "disclosure_full.php";
996 $widgetButtonClass = "";
997 $linkMethod = "html";
998 $bodyClass = "notab";
999 $widgetAuth = true;
1000 $fixedWidth = true;
1001 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
1002 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
1003 $widgetAuth, $fixedWidth);
1005 <br/>
1006 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
1007 </div>
1008 </td>
1009 </tr>
1010 <?php if ($GLOBALS['amendments']) { ?>
1011 <tr>
1012 <td width='650px'>
1013 <?php // Amendments widget
1014 $widgetTitle = xlt('Amendments');
1015 $widgetLabel = "amendments";
1016 $widgetButtonLabel = xlt("Edit");
1017 $widgetButtonLink = $GLOBALS['webroot'] . "/interface/patient_file/summary/main_frameset.php?feature=amendment";
1018 $widgetButtonClass = "iframe rx_modal";
1019 $linkMethod = "html";
1020 $bodyClass = "summary_item small";
1021 $widgetAuth = true;
1022 $fixedWidth = false;
1023 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1024 $sql = "SELECT * FROM amendments WHERE pid = ? ORDER BY amendment_date DESC";
1025 $result = sqlStatement($sql, array($pid) );
1027 if (sqlNumRows($result) == 0) {
1028 echo " <table><tr>\n";
1029 echo " <td colspan='$numcols' class='text'>&nbsp;&nbsp;" . xlt('None') . "</td>\n";
1030 echo " </tr></table>\n";
1033 while ($row=sqlFetchArray($result)){
1034 echo "&nbsp;&nbsp;";
1035 echo "<a class= '" . $widgetButtonClass . "' href='" . $widgetButtonLink . "&id=" . attr($row['amendment_id']) . "' onclick='top.restoreSession()'>" . text($row['amendment_date']);
1036 echo "&nbsp; " . text($row['amendment_desc']);
1038 echo "</a><br>\n";
1039 } ?>
1040 </td>
1041 </tr>
1042 <?php } ?>
1043 <?php // labdata ?>
1044 <tr>
1045 <td width='650px'>
1046 <?php // labdata expand collapse widget
1047 $widgetTitle = xl("Labs");
1048 $widgetLabel = "labdata";
1049 $widgetButtonLabel = xl("Trend");
1050 $widgetButtonLink = "../summary/labdata.php";#"../encounter/trend_form.php?formname=labdata";
1051 $widgetButtonClass = "";
1052 $linkMethod = "html";
1053 $bodyClass = "notab";
1054 // check to see if any labdata exist
1055 $spruch = "SELECT procedure_report.date_collected AS date " .
1056 "FROM procedure_report " .
1057 "JOIN procedure_order ON procedure_report.procedure_order_id = procedure_order.procedure_order_id " .
1058 "WHERE procedure_order.patient_id = ? " .
1059 "ORDER BY procedure_report.date_collected DESC ";
1060 $existLabdata = sqlQuery($spruch, array($pid) );
1061 if ($existLabdata) {
1062 $widgetAuth = true;
1064 else {
1065 $widgetAuth = false;
1067 $fixedWidth = true;
1068 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
1069 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
1070 $widgetAuth, $fixedWidth);
1072 <br/>
1073 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
1074 </div>
1075 </td>
1076 </tr>
1077 <?php // end labdata ?>
1082 <?php if ($vitals_is_registered && acl_check('patients', 'med')) { ?>
1083 <tr>
1084 <td width='650px'>
1085 <?php // vitals expand collapse widget
1086 $widgetTitle = xl("Vitals");
1087 $widgetLabel = "vitals";
1088 $widgetButtonLabel = xl("Trend");
1089 $widgetButtonLink = "../encounter/trend_form.php?formname=vitals";
1090 $widgetButtonClass = "";
1091 $linkMethod = "html";
1092 $bodyClass = "notab";
1093 // check to see if any vitals exist
1094 $existVitals = sqlQuery("SELECT * FROM form_vitals WHERE pid=?", array($pid) );
1095 if ($existVitals) {
1096 $widgetAuth = true;
1098 else {
1099 $widgetAuth = false;
1101 $fixedWidth = true;
1102 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
1103 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
1104 $widgetAuth, $fixedWidth);
1106 <br/>
1107 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
1108 </div>
1109 </td>
1110 </tr>
1111 <?php } // end if ($vitals_is_registered && acl_check('patients', 'med')) ?>
1113 <?php
1114 // This generates a section similar to Vitals for each LBF form that
1115 // supports charting. The form ID is used as the "widget label".
1117 $gfres = sqlStatement("SELECT option_id, title FROM list_options WHERE " .
1118 "list_id = 'lbfnames' AND option_value > 0 ORDER BY seq, title");
1119 while($gfrow = sqlFetchArray($gfres)) {
1121 <tr>
1122 <td width='650px'>
1123 <?php // vitals expand collapse widget
1124 $vitals_form_id = $gfrow['option_id'];
1125 $widgetTitle = $gfrow['title'];
1126 $widgetLabel = $vitals_form_id;
1127 $widgetButtonLabel = xl("Trend");
1128 $widgetButtonLink = "../encounter/trend_form.php?formname=$vitals_form_id";
1129 $widgetButtonClass = "";
1130 $linkMethod = "html";
1131 $bodyClass = "notab";
1132 // check to see if any instances exist for this patient
1133 $existVitals = sqlQuery(
1134 "SELECT * FROM forms WHERE pid = ? AND formdir = ? AND deleted = 0",
1135 array($pid, $vitals_form_id));
1136 $widgetAuth = $existVitals ? true : false;
1137 $fixedWidth = true;
1138 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
1139 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
1140 $widgetAuth, $fixedWidth);
1142 <br/>
1143 <div style='margin-left:10px' class='text'>
1144 <image src='../../pic/ajax-loader.gif'/>
1145 </div>
1146 <br/>
1147 </div> <!-- This is required by expand_collapse_widget(). -->
1148 </td>
1149 </tr>
1150 <?php
1151 } // end while
1154 </table>
1156 </div>
1157 <!-- end left column div -->
1159 <!-- start right column div -->
1160 <div>
1161 <table>
1162 <tr>
1163 <td>
1165 <div>
1166 <?php
1168 // If there is an ID Card or any Photos show the widget
1169 $photos = pic_array($pid, $GLOBALS['patient_photo_category_name']);
1170 if ($photos or $idcard_doc_id )
1172 $widgetTitle = xl("ID Card") . '/' . xl("Photos");
1173 $widgetLabel = "photos";
1174 $linkMethod = "javascript";
1175 $bodyClass = "notab-right";
1176 $widgetAuth = false;
1177 $fixedWidth = false;
1178 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel ,
1179 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
1180 $widgetAuth, $fixedWidth);
1182 <br />
1183 <?php
1184 if ($idcard_doc_id) {
1185 image_widget($idcard_doc_id, $GLOBALS['patient_id_category_name']);
1188 foreach ($photos as $photo_doc_id) {
1189 image_widget($photo_doc_id, $GLOBALS['patient_photo_category_name']);
1194 <br />
1195 </div>
1196 <div>
1197 <?php
1198 // Advance Directives
1199 if ($GLOBALS['advance_directives_warning']) {
1200 // advance directives expand collapse widget
1201 $widgetTitle = xl("Advance Directives");
1202 $widgetLabel = "directives";
1203 $widgetButtonLabel = xl("Edit");
1204 $widgetButtonLink = "return advdirconfigure();";
1205 $widgetButtonClass = "";
1206 $linkMethod = "javascript";
1207 $bodyClass = "summary_item small";
1208 $widgetAuth = true;
1209 $fixedWidth = false;
1210 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1211 $counterFlag = false; //flag to record whether any categories contain ad records
1212 $query = "SELECT id FROM categories WHERE name='Advance Directive'";
1213 $myrow2 = sqlQuery($query);
1214 if ($myrow2) {
1215 $parentId = $myrow2['id'];
1216 $query = "SELECT id, name FROM categories WHERE parent=?";
1217 $resNew1 = sqlStatement($query, array($parentId) );
1218 while ($myrows3 = sqlFetchArray($resNew1)) {
1219 $categoryId = $myrows3['id'];
1220 $nameDoc = $myrows3['name'];
1221 $query = "SELECT documents.date, documents.id " .
1222 "FROM documents " .
1223 "INNER JOIN categories_to_documents " .
1224 "ON categories_to_documents.document_id=documents.id " .
1225 "WHERE categories_to_documents.category_id=? " .
1226 "AND documents.foreign_id=? " .
1227 "ORDER BY documents.date DESC";
1228 $resNew2 = sqlStatement($query, array($categoryId, $pid) );
1229 $limitCounter = 0; // limit to one entry per category
1230 while (($myrows4 = sqlFetchArray($resNew2)) && ($limitCounter == 0)) {
1231 $dateTimeDoc = $myrows4['date'];
1232 // remove time from datetime stamp
1233 $tempParse = explode(" ",$dateTimeDoc);
1234 $dateDoc = $tempParse[0];
1235 $idDoc = $myrows4['id'];
1236 echo "<a href='$web_root/controller.php?document&retrieve&patient_id=" .
1237 htmlspecialchars($pid,ENT_QUOTES) . "&document_id=" .
1238 htmlspecialchars($idDoc,ENT_QUOTES) . "&as_file=true' onclick='top.restoreSession()'>" .
1239 htmlspecialchars(xl_document_category($nameDoc),ENT_NOQUOTES) . "</a> " .
1240 htmlspecialchars($dateDoc,ENT_NOQUOTES);
1241 echo "<br>";
1242 $limitCounter = $limitCounter + 1;
1243 $counterFlag = true;
1247 if (!$counterFlag) {
1248 echo "&nbsp;&nbsp;" . htmlspecialchars(xl('None'),ENT_NOQUOTES);
1249 } ?>
1250 </div>
1251 <?php } // close advanced dir block
1253 // This is a feature for a specific client. -- Rod
1254 if ($GLOBALS['cene_specific']) {
1255 echo " <br />\n";
1257 $imagedir = $GLOBALS['OE_SITE_DIR'] . "/documents/$pid/demographics";
1258 $imagepath = "$web_root/sites/" . $_SESSION['site_id'] . "/documents/$pid/demographics";
1260 echo " <a href='' onclick=\"return sendimage($pid, 'photo');\" " .
1261 "title='Click to attach patient image'>\n";
1262 if (is_file("$imagedir/photo.jpg")) {
1263 echo " <img src='$imagepath/photo.jpg' /></a>\n";
1264 } else {
1265 echo " Attach Patient Image</a><br />\n";
1267 echo " <br />&nbsp;<br />\n";
1269 echo " <a href='' onclick=\"return sendimage($pid, 'fingerprint');\" " .
1270 "title='Click to attach fingerprint'>\n";
1271 if (is_file("$imagedir/fingerprint.jpg")) {
1272 echo " <img src='$imagepath/fingerprint.jpg' /></a>\n";
1273 } else {
1274 echo " Attach Biometric Fingerprint</a><br />\n";
1276 echo " <br />&nbsp;<br />\n";
1279 // Show current and upcoming appointments.
1280 if (isset($pid) && !$GLOBALS['disable_calendar']) {
1282 $current_date2 = date('Y-m-d');
1283 $events = array();
1284 $apptNum = (int)$GLOBALS['number_of_appts_to_show'];
1285 if($apptNum != 0) $apptNum2 = abs($apptNum);
1286 else $apptNum2 = 10;
1287 $events = fetchNextXAppts($current_date2, $pid, $apptNum2);
1288 $events = sortAppointments($events);
1289 //////
1291 // Show Clinical Reminders for any user that has rules that are permitted.
1292 $clin_rem_check = resolve_rules_sql('','0',TRUE,'',$_SESSION['authUser']);
1293 if ( (!empty($clin_rem_check)) && ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crw']) ) {
1294 // clinical summary expand collapse widget
1295 $widgetTitle = xl("Clinical Reminders");
1296 $widgetLabel = "clinical_reminders";
1297 $widgetButtonLabel = xl("Edit");
1298 $widgetButtonLink = "../reminder/clinical_reminders.php?patient_id=".$pid;;
1299 $widgetButtonClass = "";
1300 $linkMethod = "html";
1301 $bodyClass = "summary_item small";
1302 $widgetAuth = true;
1303 $fixedWidth = false;
1304 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1305 echo "<br/>";
1306 echo "<div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>";
1307 echo "</div>";
1308 } // end if crw
1310 // appointments expand collapse widget
1311 $widgetTitle = xl("Appointments");
1312 $widgetLabel = "appointments";
1313 $widgetButtonLabel = xl("Add");
1314 $widgetButtonLink = "return newEvt();";
1315 $widgetButtonClass = "";
1316 $linkMethod = "javascript";
1317 $bodyClass = "summary_item small";
1318 $widgetAuth = $resNotNull; // $resNotNull refects state of query (appts) in fetchAppointments()
1319 $fixedWidth = false;
1320 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1321 $count = 0;
1322 foreach($events as $row) { //////
1323 $count++;
1324 $dayname = date("D", strtotime($row['pc_eventDate'])); //////
1325 $dispampm = "am";
1326 $disphour = substr($row['pc_startTime'], 0, 2) + 0;
1327 $dispmin = substr($row['pc_startTime'], 3, 2);
1328 if ($disphour >= 12) {
1329 $dispampm = "pm";
1330 if ($disphour > 12) $disphour -= 12;
1332 $etitle = xl('(Click to edit)');
1333 if ($row['pc_hometext'] != "") {
1334 $etitle = xl('Comments').": ".($row['pc_hometext'])."\r\n".$etitle;
1336 ////////////
1337 echo "<a href='javascript:oldEvt(" . htmlspecialchars(preg_replace("/-/", "", $row['pc_eventDate']),ENT_QUOTES) . ', ' . htmlspecialchars($row['pc_eid'],ENT_QUOTES) . ")' title='" . htmlspecialchars($etitle,ENT_QUOTES) . "'>";
1338 ////////////
1339 echo "<b>" . htmlspecialchars($row['pc_eventDate'] . " (" . xl($dayname),ENT_NOQUOTES) . ")</b><br>";
1340 echo htmlspecialchars("$disphour:$dispmin " . xl($dispampm),ENT_NOQUOTES) . " ";
1341 if ($row['pc_recurrtype']) echo "<img src='" . $GLOBALS['webroot'] . "/interface/main/calendar/modules/PostCalendar/pntemplates/default/images/repeating8.png' border='0' style='margin:0px 2px 0px 2px;' title='".htmlspecialchars(xl("Repeating event"),ENT_QUOTES)."' alt='".htmlspecialchars(xl("Repeating event"),ENT_QUOTES)."'>";
1342 echo "<span title='" . generate_display_field(array('data_type'=>'1','list_id'=>'apptstat'),$row['pc_apptstatus']) . "'> ( " . htmlspecialchars($row['pc_apptstatus'],ENT_NOQUOTES) . " )</span>";
1343 if ($row['pc_hometext']) echo "<font color='green'> CMT</font>";
1344 echo "<br>" . htmlspecialchars(xl_appt_category($row['pc_catname']),ENT_NOQUOTES) . "<br>\n";
1345 echo htmlspecialchars($row['ufname'] . " " . $row['ulname'],ENT_NOQUOTES) . "</a><br>\n";
1347 if ($resNotNull) { //////
1348 if ( $count < 1 ) {
1349 echo "&nbsp;&nbsp;" . htmlspecialchars(xl('None'),ENT_NOQUOTES);
1351 echo "</div>";
1355 // Show PAST appointments.
1356 // added by Terry Hill to allow reverse sorting of the appointments
1357 $direction = "ASC";
1358 if ($GLOBALS['num_past_appointments_to_show'] < 0) {
1359 $direction = "DESC";
1360 ($showpast = -1 * $GLOBALS['num_past_appointments_to_show'] );
1362 else
1364 $showpast = $GLOBALS['num_past_appointments_to_show'];
1367 if (isset($pid) && !$GLOBALS['disable_calendar'] && $showpast > 0) {
1368 $query = "SELECT e.pc_eid, e.pc_aid, e.pc_title, e.pc_eventDate, " .
1369 "e.pc_startTime, e.pc_hometext, u.fname, u.lname, u.mname, " .
1370 "c.pc_catname, e.pc_apptstatus " .
1371 "FROM openemr_postcalendar_events AS e, users AS u, " .
1372 "openemr_postcalendar_categories AS c WHERE " .
1373 "e.pc_pid = ? AND e.pc_eventDate < CURRENT_DATE AND " .
1374 "u.id = e.pc_aid AND e.pc_catid = c.pc_catid " .
1375 "ORDER BY e.pc_eventDate $direction , e.pc_startTime DESC " .
1376 "LIMIT " . $showpast;
1378 $pres = sqlStatement($query, array($pid) );
1380 // appointments expand collapse widget
1381 $widgetTitle = xl("Past Appoinments");
1382 $widgetLabel = "past_appointments";
1383 $widgetButtonLabel = '';
1384 $widgetButtonLink = '';
1385 $widgetButtonClass = '';
1386 $linkMethod = "javascript";
1387 $bodyClass = "summary_item small";
1388 $widgetAuth = false; //no button
1389 $fixedWidth = false;
1390 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1391 $count = 0;
1392 while($row = sqlFetchArray($pres)) {
1393 $count++;
1394 $dayname = date("l", strtotime($row['pc_eventDate']));
1395 $dispampm = "am";
1396 $disphour = substr($row['pc_startTime'], 0, 2) + 0;
1397 $dispmin = substr($row['pc_startTime'], 3, 2);
1398 if ($disphour >= 12) {
1399 $dispampm = "pm";
1400 if ($disphour > 12) $disphour -= 12;
1402 if ($row['pc_hometext'] != "") {
1403 $etitle = xl('Comments').": ".($row['pc_hometext'])."\r\n".$etitle;
1405 echo "<a href='javascript:oldEvt(" . htmlspecialchars($row['pc_eid'],ENT_QUOTES) . ")' title='" . htmlspecialchars($etitle,ENT_QUOTES) . "'>";
1406 echo "<b>" . htmlspecialchars(xl($dayname) . ", " . $row['pc_eventDate'],ENT_NOQUOTES) . "</b>" . xlt("Status") . "(";
1407 echo " " . generate_display_field(array('data_type'=>'1','list_id'=>'apptstat'),$row['pc_apptstatus']) . ")<br>"; // can't use special char parser on this
1408 echo htmlspecialchars("$disphour:$dispmin ") . xl($dispampm) . " ";
1409 echo htmlspecialchars($row['fname'] . " " . $row['lname'],ENT_NOQUOTES) . "</a><br>\n";
1411 if (isset($pres) && $res != null) {
1412 if ( $count < 1 ) {
1413 echo "&nbsp;&nbsp;" . htmlspecialchars(xl('None'),ENT_NOQUOTES);
1415 echo "</div>";
1418 // END of past appointments
1421 </div>
1423 <div id='stats_div'>
1424 <br/>
1425 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
1426 </div>
1427 </td>
1428 </tr>
1430 <?php // TRACK ANYTHING -----
1432 // Determine if track_anything form is in use for this site.
1433 $tmp = sqlQuery("SELECT count(*) AS count FROM registry WHERE " .
1434 "directory = 'track_anything' AND state = 1");
1435 $track_is_registered = $tmp['count'];
1436 if($track_is_registered){
1437 echo "<tr> <td>";
1438 // track_anything expand collapse widget
1439 $widgetTitle = xl("Tracks");
1440 $widgetLabel = "track_anything";
1441 $widgetButtonLabel = xl("Tracks");
1442 $widgetButtonLink = "../../forms/track_anything/create.php";
1443 $widgetButtonClass = "";
1444 $widgetAuth = ""; // don't show the button
1445 $linkMethod = "html";
1446 $bodyClass = "notab";
1447 // check to see if any tracks exist
1448 $spruch = "SELECT id " .
1449 "FROM forms " .
1450 "WHERE pid = ? " .
1451 "AND formdir = ? ";
1452 $existTracks = sqlQuery($spruch, array($pid, "track_anything") );
1454 $fixedWidth = false;
1455 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
1456 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
1457 $widgetAuth, $fixedWidth);
1459 <br/>
1460 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
1461 </div>
1462 </td>
1463 </tr>
1464 <?php } // end track_anything ?>
1465 </table>
1467 </div> <!-- end right column div -->
1469 </td>
1471 </tr>
1472 </table>
1474 </div> <!-- end main content div -->
1476 <script language='JavaScript'>
1477 // Array of skip conditions for the checkSkipConditions() function.
1478 var skipArray = [
1479 <?php echo $condition_str; ?>
1481 checkSkipConditions();
1482 </script>
1484 </body>
1485 </html>