4 * Patient summary screen.
7 * @link http://www.open-emr.org
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @author Sharon Cohen <sharonco@matrix.co.il>
10 * @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
11 * @copyright Copyright (c) 2017 Sharon Cohen <sharonco@matrix.co.il>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
16 require_once("../../globals.php");
17 require_once("$srcdir/patient.inc");
18 require_once("$srcdir/acl.inc");
19 require_once("$srcdir/options.inc.php");
20 require_once("../history/history.inc.php");
21 require_once("$srcdir/edi.inc");
22 require_once("$srcdir/invoice_summary.inc.php");
23 require_once("$srcdir/clinical_rules.php");
24 require_once("$srcdir/options.js.php");
25 require_once("$srcdir/group.inc");
26 require_once(dirname(__FILE__
)."/../../../library/appointments.inc.php");
27 use OpenEMR\Reminder\BirthdayReminder
;
29 if (isset($_GET['set_pid'])) {
30 include_once("$srcdir/pid.inc");
31 setpid($_GET['set_pid']);
34 $active_reminders = false;
35 $all_allergy_alerts = false;
36 if ($GLOBALS['enable_cdr']) {
38 if ($GLOBALS['enable_allergy_check'] && $GLOBALS['enable_alert_log']) {
39 //Check for new allergies conflicts and throw popup if any exist(note need alert logging to support this)
40 $new_allergy_alerts = allergy_conflict($pid, 'new', $_SESSION['authUser']);
41 if (!empty($new_allergy_alerts)) {
42 $pop_warning = '<script type="text/javascript">alert(\'' . xls('WARNING - FOLLOWING ACTIVE MEDICATIONS ARE ALLERGIES') . ':\n';
43 foreach ($new_allergy_alerts as $new_allergy_alert) {
44 $pop_warning .= addslashes($new_allergy_alert) . '\n';
47 $pop_warning .= '\')</script>';
52 if ((!isset($_SESSION['alert_notify_pid']) ||
($_SESSION['alert_notify_pid'] != $pid)) && isset($_GET['set_pid']) && $GLOBALS['enable_cdr_crp']) {
53 // showing a new patient, so check for active reminders and allergy conflicts, which use in active reminder popup
54 $active_reminders = active_alert_summary($pid, "reminders-due", '', 'default', $_SESSION['authUser'], true);
55 if ($GLOBALS['enable_allergy_check']) {
56 $all_allergy_alerts = allergy_conflict($pid, 'all', $_SESSION['authUser'], true);
61 function print_as_money($money)
63 preg_match("/(\d*)\.?(\d*)/", $money, $moneymatches);
64 $tmp = wordwrap(strrev($moneymatches[1]), 3, ",", 1);
65 $ccheck = strrev($tmp);
66 if ($ccheck[0] == ",") {
67 $tmp = substr($ccheck, 1, strlen($ccheck)-1);
70 if ($moneymatches[2] != "") {
71 return "$ " . strrev($tmp) . "." . $moneymatches[2];
73 return "$ " . strrev($tmp);
77 // get an array from Photos category
78 function pic_array($pid, $picture_directory)
81 $sql_query = "select documents.id from documents join categories_to_documents " .
82 "on documents.id = categories_to_documents.document_id " .
83 "join categories on categories.id = categories_to_documents.category_id " .
84 "where categories.name like ? and documents.foreign_id = ?";
85 if ($query = sqlStatement($sql_query, array($picture_directory,$pid))) {
86 while ($results = sqlFetchArray($query)) {
87 array_push($pics, $results['id']);
93 // Get the document ID of the first document in a specific catg.
94 function get_document_by_catg($pid, $doc_catg)
99 if ($pid and $doc_catg) {
100 $result = sqlQuery("SELECT d.id, d.date, d.url FROM " .
101 "documents AS d, categories_to_documents AS cd, categories AS c " .
102 "WHERE d.foreign_id = ? " .
103 "AND cd.document_id = d.id " .
104 "AND c.id = cd.category_id " .
105 "AND c.name LIKE ? " .
106 "ORDER BY d.date DESC LIMIT 1", array($pid, $doc_catg));
109 return($result['id']);
112 // Display image in 'widget style'
113 function image_widget($doc_id, $doc_catg)
115 global $pid, $web_root;
116 $docobj = new Document($doc_id);
117 $image_file = $docobj->get_url_file();
118 $image_width = $GLOBALS['generate_doc_thumb'] == 1 ?
'' : 'width=100';
119 $extension = substr($image_file, strrpos($image_file, "."));
120 $viewable_types = array('.png','.jpg','.jpeg','.png','.bmp','.PNG','.JPG','.JPEG','.PNG','.BMP'); // image ext supported by fancybox viewer
121 if (in_array($extension, $viewable_types)) { // extention matches list
122 $to_url = "<td> <a href = $web_root" .
123 "/controller.php?document&retrieve&patient_id=$pid&document_id=$doc_id&as_file=false&original_file=true&disable_exit=false&show_original=true" .
124 "/tmp$extension" . // Force image type URL for fancybo
125 " onclick=top.restoreSession(); class='image_modal'>" .
126 " <img src = $web_root" .
127 "/controller.php?document&retrieve&patient_id=$pid&document_id=$doc_id&as_file=false" .
128 " $image_width alt='$doc_catg:$image_file'> </a> </td> <td valign='center'>".
129 htmlspecialchars($doc_catg) . '<br /> ' . htmlspecialchars($image_file) .
132 $to_url = "<td> <a href='" . $web_root . "/controller.php?document&retrieve" .
133 "&patient_id=$pid&document_id=$doc_id'" .
134 " onclick='top.restoreSession()' class='css_button_small'>" .
136 htmlspecialchars(xl("View"), ENT_QUOTES
)."</a> " .
137 htmlspecialchars("$doc_catg - $image_file", ENT_QUOTES
) .
143 echo "</tr></table>";
146 // Determine if the Vitals form is in use for this site.
147 $tmp = sqlQuery("SELECT count(*) AS count FROM registry WHERE " .
148 "directory = 'vitals' AND state = 1");
149 $vitals_is_registered = $tmp['count'];
151 // Get patient/employer/insurance information.
153 $result = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
154 $result2 = getEmployerData($pid);
155 $result3 = getInsuranceData($pid, "primary", "copay, provider, DATE_FORMAT(`date`,'%Y-%m-%d') as effdate");
157 if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
158 $insco_name = getInsuranceProvider($result3['provider']);
164 <?php
html_header_show();?
>
165 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
166 <link rel
="stylesheet" type
="text/css" href
="../../../library/js/fancybox/jquery.fancybox-1.2.6.css" media
="screen" />
167 <script type
="text/javascript" src
="../../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script
>
168 <script type
="text/javascript" src
="../../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
169 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-7-2/index.js"></script
>
170 <script type
="text/javascript" src
="../../../library/js/common.js?v=<?php echo $v_js_includes; ?>"></script
>
171 <script type
="text/javascript" src
="../../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script
>
172 <script type
="text/javascript" language
="JavaScript">
174 var mypcc
= '<?php echo htmlspecialchars($GLOBALS['phone_country_code
'], ENT_QUOTES); ?>';
176 function oldEvt(apptdate
, eventid
) {
177 dlgopen('../../main/calendar/add_edit_event.php?date=' + apptdate +
'&eid=' + eventid
, '_blank', 775, 500);
180 function advdirconfigure() {
181 dlgopen('advancedirectives.php', '_blank', 400, 500);
184 function refreshme() {
185 top
.restoreSession();
189 // Process click on Delete link.
190 function deleteme() {
191 dlgopen('../deleter.php?patient=<?php echo htmlspecialchars($pid, ENT_QUOTES); ?>', '_blank', 500, 450);
195 // Called by the deleteme.php window on a successful delete.
196 function imdeleted() {
197 <?php
if ($GLOBALS['new_tabs_layout']) { ?
>
200 parent
.left_nav
.clearPatient();
205 dlgopen('../../main/calendar/add_edit_event.php?patientid=<?php echo htmlspecialchars($pid, ENT_QUOTES); ?>', '_blank', 775, 500);
209 function sendimage(pid
, what
) {
210 // alert('Not yet implemented.'); return false;
211 dlgopen('../upload_dialog.php?patientid=' + pid +
'&file=' + what
,
218 <script type
="text/javascript">
220 function toggleIndicator(target
,div
) {
222 $mode = $
(target
).find(".indicator").text();
223 if ( $mode == "<?php echo htmlspecialchars(xl('collapse'), ENT_QUOTES); ?>" ) {
224 $
(target
).find(".indicator").text( "<?php echo htmlspecialchars(xl('expand'), ENT_QUOTES); ?>" );
226 $
.post( "../../../library/ajax/user_settings.php", { target
: div
, mode
: 0 });
228 $
(target
).find(".indicator").text( "<?php echo htmlspecialchars(xl('collapse'), ENT_QUOTES); ?>" );
230 $
.post( "../../../library/ajax/user_settings.php", { target
: div
, mode
: 1 });
234 $
(document
).ready(function(){
237 if ($GLOBALS['erx_enable']) {
238 //$soap_status=sqlQuery("select soap_import_status from patient_data where pid=?",array($pid));
239 $soap_status=sqlStatement("select soap_import_status,pid from patient_data where pid=? and soap_import_status in ('1','3')", array($pid));
240 while ($row_soapstatus=sqlFetchArray($soap_status)) {
241 //if($soap_status['soap_import_status']=='1' || $soap_status['soap_import_status']=='3'){ ?>
242 top
.restoreSession();
245 url
: "../../soap_functions/soap_patientfullmedication.php",
248 patient
:<?php
echo $row_soapstatus['pid']; ?
>,
251 success
: function(thedata
){
253 msg_updation+
=thedata
;
261 //elseif($soap_status['soap_import_status']=='3'){ ?>
262 top
.restoreSession();
265 url
: "../../soap_functions/soap_allergy.php",
268 patient
:<?php
echo $row_soapstatus['pid']; ?
>,
271 success
: function(thedata
){
273 msg_updation+
=thedata
;
280 if ($GLOBALS['erx_import_status_message']) { ?
>
291 $
("#stats_div").load("stats.php", { 'embeddedScreen' : true }, function() {
292 // (note need to place javascript code here also to get the dynamic link to work)
293 $
(".rx_modal").fancybox( {
294 'overlayOpacity' : 0.0,
295 'showCloseButton' : true,
298 'centerOnScroll' : false,
299 'callbackOnClose' : function() {
304 $
("#pnotes_ps_expand").load("pnotes_fragment.php");
305 $
("#disclosures_ps_expand").load("disc_fragment.php");
307 <?php
if ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crw']) { ?
>
308 top
.restoreSession();
309 $
("#clinical_reminders_ps_expand").load("clinical_reminders_fragment.php", { 'embeddedScreen' : true }, function() {
310 // (note need to place javascript code here also to get the dynamic link to work)
311 $
(".medium_modal").fancybox( {
312 'overlayOpacity' : 0.0,
313 'showCloseButton' : true,
316 'centerOnScroll' : false,
317 'callbackOnClose' : function() {
324 <?php
if ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_prw']) { ?
>
325 top
.restoreSession();
326 $
("#patient_reminders_ps_expand").load("patient_reminders_fragment.php");
329 <?php
if ($vitals_is_registered && acl_check('patients', 'med')) { ?
>
330 // Initialize the Vitals form if it is registered and user is authorized.
331 $
("#vitals_ps_expand").load("vitals_fragment.php");
334 // Initialize track_anything
335 $
("#track_anything_ps_expand").load("track_anything_fragment.php");
338 // Initialize labdata
339 $
("#labdata_ps_expand").load("labdata_fragment.php");
341 // Initialize for each applicable LBF form.
342 $gfres = sqlStatement("SELECT grp_form_id FROM layout_group_properties WHERE " .
343 "grp_form_id LIKE 'LBF%' AND grp_group_id = '' AND grp_repeats > 0 AND grp_activity = 1 " .
344 "ORDER BY grp_seq, grp_title");
345 while ($gfrow = sqlFetchArray($gfres)) {
347 $
("#<?php echo attr($gfrow['grp_form_id']); ?>_ps_expand").load("lbf_fragment.php?formname=<?php echo attr($gfrow['grp_form_id']); ?>");
356 // modal for dialog boxes
357 $
(".large_modal").fancybox( {
358 'overlayOpacity' : 0.0,
359 'showCloseButton' : true,
362 'centerOnScroll' : false
365 // modal for image viewer
366 $
(".image_modal").fancybox( {
367 'overlayOpacity' : 0.0,
368 'showCloseButton' : true,
369 'centerOnScroll' : false,
373 $
(".iframe1").fancybox( {
375 'overlayOpacity' : 0.0,
376 'showCloseButton' : true,
380 // special size for patient portal
381 $
(".small_modal").fancybox( {
382 'overlayOpacity' : 0.0,
383 'showCloseButton' : true,
386 'centerOnScroll' : false
389 function openReminderPopup() {
390 $
("#reminder_popup_link").fancybox({
391 'overlayOpacity' : 0.0,
392 'showCloseButton' : true,
395 'centerOnScroll' : false,
400 <?php
if ($GLOBALS['patient_birthday_alert']) {
401 // To display the birthday alert:
402 // 1. The patient is not deceased
403 // 2. The birthday is today (or in the past depending on global selection)
404 // 3. The notification has not been turned off (or shown depending on global selection) for this year
405 $birthdayAlert = new BirthdayReminder($pid, $_SESSION['authId']);
406 if ($birthdayAlert->isDisplayBirthdayAlert()) {
408 // show the active reminder modal
409 $
("#birthday_popup").fancybox({
410 'overlayOpacity' : 0.0,
411 'showCloseButton' : true,
414 'centerOnScroll' : false,
415 'callbackOnClose' : function () {
416 <?php
if ($active_reminders ||
$all_allergy_alerts) { ?
>
417 //working only with setTimeout 0, must call openReminderPopup only ofter callbackOnClose is finished (fancybox v1 isn't support multi instances)
418 setTimeout(function () {
424 <?php
} elseif ($active_reminders ||
$all_allergy_alerts) { ?
>
427 <?php
} elseif ($active_reminders ||
$all_allergy_alerts) { ?
>
435 // JavaScript stuff to do when a new patient is set.
437 function setMyPatient() {
438 // Avoid race conditions with loading of the left_nav or Title frame.
439 if (!parent
.allFramesLoaded()) {
440 setTimeout("setMyPatient()", 500);
443 <?php
if (isset($_GET['set_pid'])) { ?
>
444 parent
.left_nav
.setPatient(<?php
echo "'" . addslashes($result['fname']) . " " . addslashes($result['lname']) .
445 "'," . addslashes($pid) . ",'" . addslashes($result['pubpid']) .
446 "','', ' " . xls('DOB') . ": " . addslashes(oeFormatShortDate($result['DOB_YMD'])) . " " . xls('Age') . ": " . addslashes(getPatientAgeDisplay($result['DOB_YMD'])) . "'"; ?
>);
447 var EncounterDateArray
= new Array;
448 var CalendarCategoryArray
= new Array;
449 var EncounterIdArray
= new Array;
452 //Encounter details are stored to javacript as array.
453 $result4 = sqlStatement("SELECT fe.encounter,fe.date,openemr_postcalendar_categories.pc_catname FROM form_encounter AS fe ".
454 " left join openemr_postcalendar_categories on fe.pc_catid=openemr_postcalendar_categories.pc_catid WHERE fe.pid = ? order by fe.date desc", array($pid));
455 if (sqlNumRows($result4)>0) {
456 while ($rowresult4 = sqlFetchArray($result4)) {
458 EncounterIdArray
[Count
] = '<?php echo addslashes($rowresult4['encounter
']); ?>';
459 EncounterDateArray
[Count
] = '<?php echo addslashes(oeFormatShortDate(date("Y-m-d", strtotime($rowresult4['date
'])))); ?>';
460 CalendarCategoryArray
[Count
] = '<?php echo addslashes(xl_appt_category($rowresult4['pc_catname
'])); ?>';
466 parent
.left_nav
.setPatientEncounter(EncounterIdArray
,EncounterDateArray
,CalendarCategoryArray
);
467 <?php
} // end setting new pid ?>
468 parent
.left_nav
.syncRadios();
469 <?php
if ((isset($_GET['set_pid']) ) && (isset($_GET['set_encounterid'])) && ( intval($_GET['set_encounterid']) > 0 )) {
470 $encounter = intval($_GET['set_encounterid']);
471 $_SESSION['encounter'] = $encounter;
472 $query_result = sqlQuery("SELECT `date` FROM `form_encounter` WHERE `encounter` = ?", array($encounter)); ?
>
473 encurl
= 'encounter/encounter_top.php?set_encounter=' +
<?php
echo attr($encounter);?
> +
'&pid=' +
<?php
echo attr($pid);?
>;
474 <?php
if ($GLOBALS['new_tabs_layout']) { ?
>
475 parent
.left_nav
.setEncounter('<?php echo oeFormatShortDate(date("Y-m-d", strtotime($query_result['date
']))); ?>', '<?php echo attr($encounter); ?>', 'enc');
476 top
.restoreSession();
477 parent
.left_nav
.loadFrame('enc2', 'enc', 'patient_file/' + encurl
);
479 var othername
= (window
.name
== 'RTop') ?
'RBot' : 'RTop';
480 parent
.left_nav
.setEncounter('<?php echo oeFormatShortDate(date("Y-m-d", strtotime($query_result['date
']))); ?>', '<?php echo attr($encounter); ?>', othername
);
481 top
.restoreSession();
482 parent
.frames
[othername
].location
.href
= '../' + encurl
;
484 <?php
} // end setting new encounter id (only if new pid is also set) ?>
487 $
(window
).load(function() {
493 <style type
="css/text">
501 // This is for layout font size override.
503 getLayoutProperties('DEM', $grparr, 'grp_size');
504 if (!empty($grparr['']['grp_size'])) {
505 $FONTSIZE = $grparr['']['grp_size'];
507 /* Override font sizes in the theme. */
509 font
-size
: <?php
echo attr($FONTSIZE); ?
>pt
;
512 font
-size
: <?php
echo attr($FONTSIZE); ?
>pt
;
515 font
-size
: <?php
echo attr($FONTSIZE); ?
>pt
;
518 font
-size
: <?php
echo attr($FONTSIZE); ?
>pt
;
526 <body
class="body_top patient-demographics">
528 <a href
='../reminder/active_reminder_popup.php' id
='reminder_popup_link' style
='display: none;' class='iframe' onclick
='top.restoreSession()'></a
>
530 <a href
='../birthday_alert/birthday_pop.php?pid=<?php echo attr($pid); ?>&user_id=<?php echo attr($_SESSION['authId
']); ?>' id
='birthday_popup' style
='display: none;' class='iframe' onclick
='top.restoreSession()'></a
>
532 $thisauth = acl_check('patients', 'demo');
534 if ($result['squad'] && ! acl_check('squads', $result['squad'])) {
540 echo "<p>(" . htmlspecialchars(xl('Demographics not authorized'), ENT_NOQUOTES
) . ")</p>\n";
541 echo "</body>\n</html>\n";
547 <table
class="table_header">
551 <?php
echo htmlspecialchars(getPatientName($pid), ENT_NOQUOTES
); ?
>
554 <?php
if (acl_check('admin', 'super') && $GLOBALS['allow_pat_delete']) : ?
>
555 <td style
='padding-left:1em;' class="delete">
556 <a
class='css_button iframe'
557 href
='../deleter.php?patient=<?php echo htmlspecialchars($pid, ENT_QUOTES);?>'
558 onclick
='top.restoreSession()'>
559 <span
><?php
echo htmlspecialchars(xl('Delete'), ENT_NOQUOTES
);?
></span
>
562 <?php
endif; // Allow PT delete
563 if ($GLOBALS['erx_enable']) : ?
>
564 <td style
="padding-left:1em;" class="erx">
565 <a
class="css_button" href
="../../eRx.php?page=medentry" onclick
="top.restoreSession()">
566 <span
><?php
echo htmlspecialchars(xl('NewCrop MedEntry'), ENT_NOQUOTES
);?
></span
>
569 <td style
="padding-left:1em;">
570 <a
class="css_button iframe1"
571 href
="../../soap_functions/soap_accountStatusDetails.php"
572 onclick
="top.restoreSession()">
573 <span
><?php
echo htmlspecialchars(xl('NewCrop Account Status'), ENT_NOQUOTES
);?
></span
>
576 <td id
='accountstatus'></td
>
577 <?php
endif; // eRX Enabled
579 $portalUserSetting = true; //flag to see if patient has authorized access to portal
580 if (($GLOBALS['portal_onsite_enable'] && $GLOBALS['portal_onsite_address']) ||
581 ($GLOBALS['portal_onsite_two_enable'] && $GLOBALS['portal_onsite_two_address']) ) :
582 $portalStatus = sqlQuery("SELECT allow_patient_portal FROM patient_data WHERE pid=?", array($pid));
583 if ($portalStatus['allow_patient_portal']=='YES') :
584 $portalLogin = sqlQuery("SELECT pid FROM `patient_access_onsite` WHERE `pid`=?", array($pid));?
>
585 <td style
='padding-left:1em;'>
586 <a
class='css_button iframe small_modal'
587 href
='create_portallogin.php?portalsite=on&patient=<?php echo htmlspecialchars($pid, ENT_QUOTES);?>'
588 onclick
='top.restoreSession()'>
589 <?php
$display = (empty($portalLogin)) ?
xlt('Create Onsite Portal Credentials') : xlt('Reset Onsite Portal Credentials'); ?
>
590 <span
><?php
echo $display; ?
></span
>
595 $portalUserSetting = false;
596 endif; // allow patient portal
597 endif; // Onsite Patient Portal
598 if ($GLOBALS['portal_offsite_enable'] && $GLOBALS['portal_offsite_address']) :
599 $portalStatus = sqlQuery("SELECT allow_patient_portal FROM patient_data WHERE pid=?", array($pid));
600 if ($portalStatus['allow_patient_portal']=='YES') :
601 $portalLogin = sqlQuery("SELECT pid FROM `patient_access_offsite` WHERE `pid`=?", array($pid));
603 <td style
='padding-left:1em;'>
604 <a
class='css_button iframe small_modal'
605 href
='create_portallogin.php?portalsite=off&patient=<?php echo htmlspecialchars($pid, ENT_QUOTES);?>'
606 onclick
='top.restoreSession()'>
608 <?php
$text = (empty($portalLogin)) ?
xlt('Create Offsite Portal Credentials') : xlt('Reset Offsite Portal Credentials'); ?
>
615 $portalUserSetting = false;
616 endif; // allow_patient_portal
617 endif; // portal_offsite_enable
618 if (!($portalUserSetting)) : // Show that the patient has not authorized portal access ?>
619 <td style
='padding-left:1em;'>
620 <?php
echo htmlspecialchars(xl('Patient has not authorized the Patient Portal.'), ENT_NOQUOTES
);?
>
625 // If patient is deceased, then show this (along with the number of days patient has been deceased for)
626 $days_deceased = is_patient_deceased($pid);
627 if ($days_deceased != null) : ?
>
628 <td
class="deceased" style
="padding-left:1em;font-weight:bold;color:red">
630 if ($days_deceased == 0) {
631 echo xlt("DECEASED (Today)");
632 } else if ($days_deceased == 1) {
633 echo xlt("DECEASED (1 day ago)");
635 echo xlt("DECEASED") . " (" . text($days_deceased) . " " . xlt("days ago") . ")";
647 // Get the document ID of the patient ID card if access to it is wanted here.
648 $idcard_doc_id = false;
649 if ($GLOBALS['patient_id_category_name']) {
650 $idcard_doc_id = get_document_by_catg($pid, $GLOBALS['patient_id_category_name']);
654 <table cellspacing
='0' cellpadding
='0' border
='0' class="subnav">
656 <td
class="small" colspan
='4'>
657 <a href
="../history/history.php" onclick
='top.restoreSession()'>
658 <?php
echo htmlspecialchars(xl('History'), ENT_NOQUOTES
); ?
></a
>
660 <?php
//note that we have temporarily removed report screen from the modal view ?>
661 <a href
="../report/patient_report.php" onclick
='top.restoreSession()'>
662 <?php
echo htmlspecialchars(xl('Report'), ENT_NOQUOTES
); ?
></a
>
664 <?php
//note that we have temporarily removed document screen from the modal view ?>
665 <a href
="../../../controller.php?document&list&patient_id=<?php echo $pid;?>" onclick
='top.restoreSession()'>
666 <?php
echo htmlspecialchars(xl('Documents'), ENT_NOQUOTES
); ?
></a
>
668 <a href
="../transaction/transactions.php" onclick
='top.restoreSession()'>
669 <?php
echo htmlspecialchars(xl('Transactions'), ENT_NOQUOTES
); ?
></a
>
671 <a href
="stats_full.php?active=all" onclick
='top.restoreSession()'>
672 <?php
echo htmlspecialchars(xl('Issues'), ENT_NOQUOTES
); ?
></a
>
674 <a href
="../../reports/pat_ledger.php?form=1&patient_id=<?php echo attr($pid);?>" onclick
='top.restoreSession()'>
675 <?php
echo xlt('Ledger'); ?
></a
>
677 <a href
="../../reports/external_data.php" onclick
='top.restoreSession()'>
678 <?php
echo xlt('External Data'); ?
></a
>
680 <!-- DISPLAYING HOOKS STARTS HERE
-->
682 $module_query = sqlStatement("SELECT msh.*,ms.obj_name,ms.menu_name,ms.path,m.mod_ui_name,m.type FROM modules_hooks_settings AS msh
683 LEFT OUTER JOIN modules_settings AS ms ON obj_name=enabled_hooks AND ms.mod_id=msh.mod_id
684 LEFT OUTER JOIN modules AS m ON m.mod_id=ms.mod_id
685 WHERE fld_type=3 AND mod_active=1 AND sql_run=1 AND attached_to='demographics' ORDER BY mod_id");
686 $DivId = 'mod_installer';
687 if (sqlNumRows($module_query)) {
690 while ($modulerow = sqlFetchArray($module_query)) {
691 $DivId = 'mod_'.$modulerow['mod_id'];
692 $new_category = $modulerow['mod_ui_name'];
695 if ($modulerow['type'] == 0) {
696 $modulePath = $GLOBALS['customModDir'];
700 $modulePath = $GLOBALS['zendModDir'];
703 if (!acl_check('admin', 'super') && !zh_acl_check($_SESSION['authUserID'], $modulerow['obj_name'])) {
707 $relative_link = "../../modules/".$modulePath."/".$modulerow['path'];
708 $nickname = $modulerow['menu_name'] ?
$modulerow['menu_name'] : 'Noname';
710 $modid = $modulerow['mod_id'];
713 <a href
="<?php echo $relative_link; ?>" onclick
='top.restoreSession()'>
714 <?php
echo xlt($nickname); ?
></a
>
719 <!-- DISPLAYING HOOKS ENDS HERE
-->
723 </table
> <!-- end header
-->
725 <div style
='margin-top:10px' class="main"> <!-- start main content div
-->
726 <table border
="0" cellspacing
="0" cellpadding
="0" width
="100%">
728 <td
class="demographics-box" align
="left" valign
="top">
729 <!-- start left column div
-->
730 <div style
='float:left; margin-right:20px'>
732 <table cellspacing
=0 cellpadding
=0>
733 <?php
if (!$GLOBALS['hide_billing_widget']) { ?
>
737 // Billing expand collapse widget
738 $widgetTitle = xl("Billing");
739 $widgetLabel = "billing";
740 $widgetButtonLabel = xl("Edit");
741 $widgetButtonLink = "return newEvt();";
742 $widgetButtonClass = "";
743 $linkMethod = "javascript";
744 $bodyClass = "notab";
747 if ($GLOBALS['force_billing_widget_open']) {
748 $forceExpandAlways = true;
750 $forceExpandAlways = false;
753 expand_collapse_widget(
768 //PATIENT BALANCE,INS BALANCE naina@capminds.com
769 $patientbalance = get_patient_balance($pid, false);
770 //Debit the patient balance from insurance balance
771 $insurancebalance = get_patient_balance($pid, true) - $patientbalance;
772 $totalbalance=$patientbalance +
$insurancebalance;
774 // Show current balance and billing note, if any.
775 echo "<table border='0'><tr><td>" .
776 "<table ><tr><td><span class='bold'><font color='red'>" .
777 xlt('Patient Balance Due') .
778 " : " . text(oeFormatMoney($patientbalance)) .
779 "</font></span></td></tr>".
780 "<tr><td><span class='bold'><font color='red'>" .
781 xlt('Insurance Balance Due') .
782 " : " . text(oeFormatMoney($insurancebalance)) .
783 "</font></span></td></tr>".
784 "<tr><td><span class='bold'><font color='red'>" .
785 xlt('Total Balance Due').
786 " : " . text(oeFormatMoney($totalbalance)) .
787 "</font></span></td></td></tr>";
788 if (!empty($result['billing_note'])) {
789 echo "<tr><td><span class='bold'><font color='red'>" .
790 xlt('Billing Note') . ":" .
791 text($result['billing_note']) .
792 "</font></span></td></tr>";
795 if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
796 echo "<tr><td><span class='bold'>" .
797 xlt('Primary Insurance') . ': ' . text($insco_name) .
798 "</span> ";
799 if ($result3['copay'] > 0) {
800 echo "<span class='bold'>" .
801 xlt('Copay') . ': ' . text($result3['copay']) .
802 "</span> ";
805 echo "<span class='bold'>" .
806 xlt('Effective Date') . ': ' . text(oeFormatShortDate($result3['effdate'])) .
810 echo "</table></td></tr></td></tr></table><br>";
813 </div
> <!-- required
for expand_collapse_widget
-->
818 <?php
if (acl_check('patients', 'demo')) { ?
>
822 // Demographics expand collapse widget
823 $widgetTitle = xl("Demographics");
824 $widgetLabel = "demographics";
825 $widgetButtonLabel = xl("Edit");
826 $widgetButtonLink = "demographics_full.php";
827 $widgetButtonClass = "";
828 $linkMethod = "html";
830 $widgetAuth = acl_check('patients', 'demo', '', 'write');
832 expand_collapse_widget(
846 <?php
display_layout_tabs('DEM', $result, $result2); ?
>
848 <div
class="tabContainer">
849 <?php
display_layout_tabs_data('DEM', $result, $result2); ?
>
852 </div
> <!-- required
for expand_collapse_widget
-->
859 $insurance_count = 0;
860 foreach (array('primary','secondary','tertiary') as $instype) {
861 $enddate = 'Present';
862 $query = "SELECT * FROM insurance_data WHERE " .
863 "pid = ? AND type = ? " .
864 "ORDER BY date DESC";
865 $res = sqlStatement($query, array($pid, $instype));
866 while ($row = sqlFetchArray($res)) {
867 if ($row['provider']) {
873 if ($insurance_count > 0) {
874 // Insurance expand collapse widget
875 $widgetTitle = xl("Insurance");
876 $widgetLabel = "insurance";
877 $widgetButtonLabel = xl("Edit");
878 $widgetButtonLink = "demographics_full.php";
879 $widgetButtonClass = "";
880 $linkMethod = "html";
882 $widgetAuth = acl_check('patients', 'demo', '', 'write');
884 expand_collapse_widget(
896 if ($insurance_count > 0) {
899 <ul
class="tabNav"><?php
900 ///////////////////////////////// INSURANCE SECTION
902 foreach (array('primary','secondary','tertiary') as $instype) {
903 $query = "SELECT * FROM insurance_data WHERE " .
904 "pid = ? AND type = ? " .
905 "ORDER BY date DESC";
906 $res = sqlStatement($query, array($pid, $instype));
908 $enddate = 'Present';
910 while ($row = sqlFetchArray($res)) {
911 if ($row['provider']) {
912 $ins_description = ucfirst($instype);
913 $ins_description = xl($ins_description);
914 $ins_description .= strcmp($enddate, 'Present') != 0 ?
" (".xl('Old').")" : "";
916 <li
<?php
echo $first ?
'class="current"' : '' ?
>><a href
="#">
917 <?php
echo htmlspecialchars($ins_description, ENT_NOQUOTES
); ?
></a
></li
>
922 $enddate = $row['date'];
926 // Display the eligibility tab
927 echo "<li><a href='#'>" .
928 htmlspecialchars(xl('Eligibility'), ENT_NOQUOTES
) . "</a></li>";
933 <div
class="tabContainer">
936 foreach (array('primary','secondary','tertiary') as $instype) {
937 $enddate = 'Present';
939 $query = "SELECT * FROM insurance_data WHERE " .
940 "pid = ? AND type = ? " .
941 "ORDER BY date DESC";
942 $res = sqlStatement($query, array($pid, $instype));
943 while ($row = sqlFetchArray($res)) {
944 if ($row['provider']) {
946 <div
class="tab <?php echo $first ? 'current' : '' ?>">
947 <table border
='0' cellpadding
='0' width
='100%'>
949 $icobj = new InsuranceCompany($row['provider']);
950 $adobj = $icobj->get_address();
951 $insco_name = trim($icobj->get_name());
954 <td valign
='top' colspan
='3'>
957 if (strcmp($enddate, 'Present') != 0) {
958 echo htmlspecialchars(xl("Old"), ENT_NOQUOTES
)." ";
961 <?php
$tempinstype=ucfirst($instype);
962 echo htmlspecialchars(xl($tempinstype.' Insurance'), ENT_NOQUOTES
); ?
>
963 <?php
if (strcmp($row['date'], '0000-00-00') != 0) { ?
>
964 <?php
echo htmlspecialchars(xl('from', '', ' ', ' ').$row['date'], ENT_NOQUOTES
); ?
>
966 <?php
echo htmlspecialchars(xl('until', '', ' ', ' '), ENT_NOQUOTES
);
967 echo (strcmp($enddate, 'Present') != 0) ?
$enddate : htmlspecialchars(xl('Present'), ENT_NOQUOTES
); ?
>:</span
>
975 echo htmlspecialchars($insco_name, ENT_NOQUOTES
) . '<br>';
976 if (trim($adobj->get_line1())) {
977 echo htmlspecialchars($adobj->get_line1(), ENT_NOQUOTES
) . '<br>';
978 echo htmlspecialchars($adobj->get_city() . ', ' . $adobj->get_state() . ' ' . $adobj->get_zip(), ENT_NOQUOTES
);
981 echo "<font color='red'><b>".htmlspecialchars(xl('Unassigned'), ENT_NOQUOTES
)."</b></font>";
985 <?php
echo htmlspecialchars(xl('Policy Number'), ENT_NOQUOTES
); ?
>:
986 <?php
echo htmlspecialchars($row['policy_number'], ENT_NOQUOTES
) ?
><br
>
987 <?php
echo htmlspecialchars(xl('Plan Name'), ENT_NOQUOTES
); ?
>:
988 <?php
echo htmlspecialchars($row['plan_name'], ENT_NOQUOTES
); ?
><br
>
989 <?php
echo htmlspecialchars(xl('Group Number'), ENT_NOQUOTES
); ?
>:
990 <?php
echo htmlspecialchars($row['group_number'], ENT_NOQUOTES
); ?
></span
>
993 <span
class='bold'><?php
echo htmlspecialchars(xl('Subscriber'), ENT_NOQUOTES
); ?
>: </span
><br
>
994 <span
class='text'><?php
echo htmlspecialchars($row['subscriber_fname'] . ' ' . $row['subscriber_mname'] . ' ' . $row['subscriber_lname'], ENT_NOQUOTES
); ?
>
996 if ($row['subscriber_relationship'] != "") {
997 echo "(" . htmlspecialchars($row['subscriber_relationship'], ENT_NOQUOTES
) . ")";
1001 <?php
echo htmlspecialchars(xl('S.S.'), ENT_NOQUOTES
); ?
>:
1002 <?php
echo htmlspecialchars($row['subscriber_ss'], ENT_NOQUOTES
); ?
><br
>
1003 <?php
echo htmlspecialchars(xl('D.O.B.'), ENT_NOQUOTES
); ?
>:
1005 if ($row['subscriber_DOB'] != "0000-00-00 00:00:00") {
1006 echo htmlspecialchars($row['subscriber_DOB'], ENT_NOQUOTES
);
1009 <?php
echo htmlspecialchars(xl('Phone'), ENT_NOQUOTES
); ?
>:
1010 <?php
echo htmlspecialchars($row['subscriber_phone'], ENT_NOQUOTES
); ?
>
1014 <span
class='bold'><?php
echo htmlspecialchars(xl('Subscriber Address'), ENT_NOQUOTES
); ?
>: </span
><br
>
1015 <span
class='text'><?php
echo htmlspecialchars($row['subscriber_street'], ENT_NOQUOTES
); ?
><br
>
1016 <?php
echo htmlspecialchars($row['subscriber_city'], ENT_NOQUOTES
); ?
>
1018 if ($row['subscriber_state'] != "") {
1022 echo htmlspecialchars($row['subscriber_state'], ENT_NOQUOTES
); ?
>
1024 if ($row['subscriber_country'] != "") {
1028 echo htmlspecialchars($row['subscriber_country'], ENT_NOQUOTES
); ?
>
1029 <?php
echo " " . htmlspecialchars($row['subscriber_postal_code'], ENT_NOQUOTES
); ?
></span
>
1031 <?php
if (trim($row['subscriber_employer'])) { ?
>
1032 <br
><span
class='bold'><?php
echo htmlspecialchars(xl('Subscriber Employer'), ENT_NOQUOTES
); ?
>: </span
><br
>
1033 <span
class='text'><?php
echo htmlspecialchars($row['subscriber_employer'], ENT_NOQUOTES
); ?
><br
>
1034 <?php
echo htmlspecialchars($row['subscriber_employer_street'], ENT_NOQUOTES
); ?
><br
>
1035 <?php
echo htmlspecialchars($row['subscriber_employer_city'], ENT_NOQUOTES
); ?
>
1037 if ($row['subscriber_employer_city'] != "") {
1041 echo htmlspecialchars($row['subscriber_employer_state'], ENT_NOQUOTES
); ?
>
1043 if ($row['subscriber_employer_country'] != "") {
1047 echo htmlspecialchars($row['subscriber_employer_country'], ENT_NOQUOTES
); ?
>
1048 <?php
echo " " . htmlspecialchars($row['subscriber_employer_postal_code'], ENT_NOQUOTES
); ?
>
1056 <?php
if ($row['copay'] != "") { ?
>
1057 <span
class='bold'><?php
echo htmlspecialchars(xl('CoPay'), ENT_NOQUOTES
); ?
>: </span
>
1058 <span
class='text'><?php
echo htmlspecialchars($row['copay'], ENT_NOQUOTES
); ?
></span
>
1061 <span
class='bold'><?php
echo htmlspecialchars(xl('Accept Assignment'), ENT_NOQUOTES
); ?
>:</span
>
1064 if ($row['accept_assignment'] == "TRUE") {
1067 if ($row['accept_assignment'] == "FALSE") {
1072 <?php
if (!empty($row['policy_type'])) { ?
>
1074 <span
class='bold'><?php
echo htmlspecialchars(xl('Secondary Medicare Type'), ENT_NOQUOTES
); ?
>: </span
>
1075 <span
class='text'><?php
echo htmlspecialchars($policy_types[$row['policy_type']], ENT_NOQUOTES
); ?
></span
>
1078 <td valign
='top'></td
>
1079 <td valign
='top'></td
>
1085 } // end if ($row['provider'])
1086 $enddate = $row['date'];
1091 // Display the eligibility information
1092 echo "<div class='tab'>";
1093 show_eligibility_information($pid, true);
1096 ///////////////////////////////// END INSURANCE SECTION
1104 <?php
} // end if demographics authorized ?>
1106 <?php
if (acl_check('patients', 'notes')) { ?
>
1110 // Notes expand collapse widget
1111 $widgetTitle = xl("Notes");
1112 $widgetLabel = "pnotes";
1113 $widgetButtonLabel = xl("Edit");
1114 $widgetButtonLink = "pnotes_full.php?form_active=1";
1115 $widgetButtonClass = "";
1116 $linkMethod = "html";
1117 $bodyClass = "notab";
1118 $widgetAuth = acl_check('patients', 'notes', '', 'write');
1120 expand_collapse_widget(
1133 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1137 <?php
} // end if notes authorized ?>
1139 <?php
if (acl_check('patients', 'reminder') && $GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_prw']) {
1140 echo "<tr><td width='650px'>";
1141 // patient reminders collapse widget
1142 $widgetTitle = xl("Patient Reminders");
1143 $widgetLabel = "patient_reminders";
1144 $widgetButtonLabel = xl("Edit");
1145 $widgetButtonLink = "../reminder/patient_reminders.php?mode=simple&patient_id=".$pid;
1146 $widgetButtonClass = "";
1147 $linkMethod = "html";
1148 $bodyClass = "notab";
1149 $widgetAuth = acl_check('patients', 'reminder', '', 'write');
1151 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel, $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth); ?
>
1153 <div style
='margin-left:10px' class='text'><image src
='../../pic/ajax-loader.gif'/></div
><br
/>
1157 <?php
} //end if prw is activated ?>
1159 <?php
if (acl_check('patients', 'disclosure')) { ?
>
1163 // disclosures expand collapse widget
1164 $widgetTitle = xl("Disclosures");
1165 $widgetLabel = "disclosures";
1166 $widgetButtonLabel = xl("Edit");
1167 $widgetButtonLink = "disclosure_full.php";
1168 $widgetButtonClass = "";
1169 $linkMethod = "html";
1170 $bodyClass = "notab";
1171 $widgetAuth = acl_check('patients', 'disclosure', '', 'write');
1173 expand_collapse_widget(
1186 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1190 <?php
} // end if disclosures authorized ?>
1192 <?php
if ($GLOBALS['amendments'] && acl_check('patients', 'amendment')) { ?
>
1195 <?php
// Amendments widget
1196 $widgetTitle = xlt('Amendments');
1197 $widgetLabel = "amendments";
1198 $widgetButtonLabel = xlt("Edit");
1199 $widgetButtonLink = $GLOBALS['webroot'] . "/interface/patient_file/summary/main_frameset.php?feature=amendment";
1200 $widgetButtonClass = "iframe rx_modal";
1201 $linkMethod = "html";
1202 $bodyClass = "summary_item small";
1203 $widgetAuth = acl_check('patients', 'amendment', '', 'write');
1204 $fixedWidth = false;
1205 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel, $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1206 $sql = "SELECT * FROM amendments WHERE pid = ? ORDER BY amendment_date DESC";
1207 $result = sqlStatement($sql, array($pid));
1209 if (sqlNumRows($result) == 0) {
1210 echo " <table><tr>\n";
1211 echo " <td colspan='$numcols' class='text'> " . xlt('None') . "</td>\n";
1212 echo " </tr></table>\n";
1215 while ($row=sqlFetchArray($result)) {
1216 echo " ";
1217 echo "<a class= '" . $widgetButtonClass . "' href='" . $widgetButtonLink . "&id=" . attr($row['amendment_id']) . "' onclick='top.restoreSession()'>" . text($row['amendment_date']);
1218 echo " " . text($row['amendment_desc']);
1224 <?php
} // end amendments authorized ?>
1226 <?php
if (acl_check('patients', 'lab')) { ?
>
1229 <?php
// labdata expand collapse widget
1230 $widgetTitle = xl("Labs");
1231 $widgetLabel = "labdata";
1232 $widgetButtonLabel = xl("Trend");
1233 $widgetButtonLink = "../summary/labdata.php";#"../encounter/trend_form.php?formname=labdata";
1234 $widgetButtonClass = "";
1235 $linkMethod = "html";
1236 $bodyClass = "notab";
1237 // check to see if any labdata exist
1238 $spruch = "SELECT procedure_report.date_collected AS date " .
1239 "FROM procedure_report " .
1240 "JOIN procedure_order ON procedure_report.procedure_order_id = procedure_order.procedure_order_id " .
1241 "WHERE procedure_order.patient_id = ? " .
1242 "ORDER BY procedure_report.date_collected DESC ";
1243 $existLabdata = sqlQuery($spruch, array($pid));
1244 if ($existLabdata) {
1247 $widgetAuth = false;
1251 expand_collapse_widget(
1264 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1268 <?php
} // end labs authorized ?>
1270 <?php
if ($vitals_is_registered && acl_check('patients', 'med')) { ?
>
1273 <?php
// vitals expand collapse widget
1274 $widgetTitle = xl("Vitals");
1275 $widgetLabel = "vitals";
1276 $widgetButtonLabel = xl("Trend");
1277 $widgetButtonLink = "../encounter/trend_form.php?formname=vitals";
1278 $widgetButtonClass = "";
1279 $linkMethod = "html";
1280 $bodyClass = "notab";
1281 // check to see if any vitals exist
1282 $existVitals = sqlQuery("SELECT * FROM form_vitals WHERE pid=?", array($pid));
1286 $widgetAuth = false;
1290 expand_collapse_widget(
1303 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1307 <?php
} // end if ($vitals_is_registered && acl_check('patients', 'med')) ?>
1310 // This generates a section similar to Vitals for each LBF form that
1311 // supports charting. The form ID is used as the "widget label".
1313 $gfres = sqlStatement("SELECT grp_form_id AS option_id, grp_title AS title, grp_aco_spec " .
1314 "FROM layout_group_properties WHERE " .
1315 "grp_form_id LIKE 'LBF%' AND grp_group_id = '' AND grp_repeats > 0 AND grp_activity = 1 " .
1316 "ORDER BY grp_seq, grp_title");
1317 while ($gfrow = sqlFetchArray($gfres)) {
1318 // $jobj = json_decode($gfrow['notes'], true);
1319 $LBF_ACO = empty($gfrow['grp_aco_spec']) ?
false : explode('|', $gfrow['grp_aco_spec']);
1320 if ($LBF_ACO && !acl_check($LBF_ACO[0], $LBF_ACO[1])) {
1325 <?php
// vitals expand collapse widget
1326 $vitals_form_id = $gfrow['option_id'];
1327 $widgetTitle = $gfrow['title'];
1328 $widgetLabel = $vitals_form_id;
1329 $widgetButtonLabel = xl("Trend");
1330 $widgetButtonLink = "../encounter/trend_form.php?formname=$vitals_form_id";
1331 $widgetButtonClass = "";
1332 $linkMethod = "html";
1333 $bodyClass = "notab";
1334 $widgetAuth = false;
1335 if (!$LBF_ACO ||
acl_check($LBF_ACO[0], $LBF_ACO[1], '', 'write')) {
1336 // check to see if any instances exist for this patient
1337 $existVitals = sqlQuery(
1338 "SELECT * FROM forms WHERE pid = ? AND formdir = ? AND deleted = 0",
1339 array($pid, $vitals_form_id)
1341 $widgetAuth = $existVitals;
1345 expand_collapse_widget(
1357 <div style
='margin-left:10px' class='text'>
1358 <image src
='../../pic/ajax-loader.gif'/>
1361 </div
> <!-- This is required by
expand_collapse_widget(). -->
1371 <!-- end left column div
-->
1373 <!-- start right column div
-->
1382 // If there is an ID Card or any Photos show the widget
1383 $photos = pic_array($pid, $GLOBALS['patient_photo_category_name']);
1384 if ($photos or $idcard_doc_id) {
1385 $widgetTitle = xl("ID Card") . '/' . xl("Photos");
1386 $widgetLabel = "photos";
1387 $linkMethod = "javascript";
1388 $bodyClass = "notab-right";
1389 $widgetAuth = false;
1390 $fixedWidth = false;
1391 expand_collapse_widget(
1405 if ($idcard_doc_id) {
1406 image_widget($idcard_doc_id, $GLOBALS['patient_id_category_name']);
1409 foreach ($photos as $photo_doc_id) {
1410 image_widget($photo_doc_id, $GLOBALS['patient_photo_category_name']);
1419 // Advance Directives
1420 if ($GLOBALS['advance_directives_warning']) {
1421 // advance directives expand collapse widget
1422 $widgetTitle = xl("Advance Directives");
1423 $widgetLabel = "directives";
1424 $widgetButtonLabel = xl("Edit");
1425 $widgetButtonLink = "return advdirconfigure();";
1426 $widgetButtonClass = "";
1427 $linkMethod = "javascript";
1428 $bodyClass = "summary_item small";
1430 $fixedWidth = false;
1431 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel, $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1432 $counterFlag = false; //flag to record whether any categories contain ad records
1433 $query = "SELECT id FROM categories WHERE name='Advance Directive'";
1434 $myrow2 = sqlQuery($query);
1436 $parentId = $myrow2['id'];
1437 $query = "SELECT id, name FROM categories WHERE parent=?";
1438 $resNew1 = sqlStatement($query, array($parentId));
1439 while ($myrows3 = sqlFetchArray($resNew1)) {
1440 $categoryId = $myrows3['id'];
1441 $nameDoc = $myrows3['name'];
1442 $query = "SELECT documents.date, documents.id " .
1444 "INNER JOIN categories_to_documents " .
1445 "ON categories_to_documents.document_id=documents.id " .
1446 "WHERE categories_to_documents.category_id=? " .
1447 "AND documents.foreign_id=? " .
1448 "ORDER BY documents.date DESC";
1449 $resNew2 = sqlStatement($query, array($categoryId, $pid));
1450 $limitCounter = 0; // limit to one entry per category
1451 while (($myrows4 = sqlFetchArray($resNew2)) && ($limitCounter == 0)) {
1452 $dateTimeDoc = $myrows4['date'];
1453 // remove time from datetime stamp
1454 $tempParse = explode(" ", $dateTimeDoc);
1455 $dateDoc = $tempParse[0];
1456 $idDoc = $myrows4['id'];
1457 echo "<a href='$web_root/controller.php?document&retrieve&patient_id=" .
1458 htmlspecialchars($pid, ENT_QUOTES
) . "&document_id=" .
1459 htmlspecialchars($idDoc, ENT_QUOTES
) . "&as_file=true' onclick='top.restoreSession()'>" .
1460 htmlspecialchars(xl_document_category($nameDoc), ENT_NOQUOTES
) . "</a> " .
1461 htmlspecialchars($dateDoc, ENT_NOQUOTES
);
1463 $limitCounter = $limitCounter +
1;
1464 $counterFlag = true;
1469 if (!$counterFlag) {
1470 echo " " . htmlspecialchars(xl('None'), ENT_NOQUOTES
);
1474 } // close advanced dir block
1476 // Show Clinical Reminders for any user that has rules that are permitted.
1477 $clin_rem_check = resolve_rules_sql('', '0', true, '', $_SESSION['authUser']);
1478 if (!empty($clin_rem_check) && $GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crw'] &&
1479 acl_check('patients', 'alert')) {
1480 // clinical summary expand collapse widget
1481 $widgetTitle = xl("Clinical Reminders");
1482 $widgetLabel = "clinical_reminders";
1483 $widgetButtonLabel = xl("Edit");
1484 $widgetButtonLink = "../reminder/clinical_reminders.php?patient_id=".$pid;
1486 $widgetButtonClass = "";
1487 $linkMethod = "html";
1488 $bodyClass = "summary_item small";
1489 $widgetAuth = acl_check('patients', 'alert', '', 'write');
1490 $fixedWidth = false;
1491 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel, $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1493 echo "<div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>";
1497 // Show current and upcoming appointments.
1499 // Recurring appointment support and Appointment Display Sets
1500 // added to Appointments by Ian Jardine ( epsdky ).
1502 if (isset($pid) && !$GLOBALS['disable_calendar'] && acl_check('patients', 'appt')) {
1504 $current_date2 = date('Y-m-d');
1506 $apptNum = (int)$GLOBALS['number_of_appts_to_show'];
1507 if ($apptNum != 0) {
1508 $apptNum2 = abs($apptNum);
1514 $mode1 = !$GLOBALS['appt_display_sets_option'];
1515 $colorSet1 = $GLOBALS['appt_display_sets_color_1'];
1516 $colorSet2 = $GLOBALS['appt_display_sets_color_2'];
1517 $colorSet3 = $GLOBALS['appt_display_sets_color_3'];
1518 $colorSet4 = $GLOBALS['appt_display_sets_color_4'];
1526 $events = fetchNextXAppts($current_date2, $pid, $apptNum2 +
$extraAppts, true);
1530 $apptNumber = count($events);
1532 if ($apptNumber <= $apptNum2) {
1533 $extraApptDate = '';
1535 } else if ($mode1 && $apptNumber == $apptNum2 +
1) {
1536 $extraApptDate = $events[$apptNumber - 1]['pc_eventDate'];
1541 } else if ($apptNumber == $apptNum2 +
6) {
1542 $extraApptDate = $events[$apptNumber - 1]['pc_eventDate'];
1547 } else { // mode 2 - $apptNum2 < $apptNumber < $apptNum2 + 6
1548 $extraApptDate = '';
1554 $limitApptIndx = $apptNum2 - 1;
1555 $limitApptDate = $events[$limitApptIndx]['pc_eventDate'];
1557 switch ($selectNum) {
1560 $lastApptIndx = $apptNumber - 1;
1561 $thisNumber = $lastApptIndx - $limitApptIndx;
1562 for ($i = 1; $i <= $thisNumber; ++
$i) {
1563 if ($events[$limitApptIndx +
$i]['pc_eventDate'] != $limitApptDate) {
1564 $extraApptDate = $events[$limitApptIndx +
$i]['pc_eventDate'];
1565 $events = array_slice($events, 0, $limitApptIndx +
$i);
1573 for ($i = 1; $i <= $limitApptIndx; ++
$i) {
1574 if ($events[$limitApptIndx - $i]['pc_eventDate'] != $limitApptDate) {
1575 $firstApptIndx = $apptNum2 - $i;
1584 if ($extraApptDate) {
1585 if ($extraApptDate != $limitApptDate) {
1586 $apptStyle2 = " style='background-color:" . attr($colorSet3) . ";'";
1588 $apptStyle2 = " style='background-color:" . attr($colorSet4) . ";'";
1595 // appointments expand collapse widget
1596 $widgetTitle = xl("Appointments");
1597 $widgetLabel = "appointments";
1598 $widgetButtonLabel = xl("Add");
1599 $widgetButtonLink = "return newEvt();";
1600 $widgetButtonClass = "";
1601 $linkMethod = "javascript";
1602 $bodyClass = "summary_item small";
1603 $widgetAuth = $resNotNull // $resNotNull reflects state of query in fetchAppointments
1604 && (acl_check('patients', 'appt', '', 'write') ||
acl_check('patients', 'appt', '', 'addonly'));
1605 $fixedWidth = false;
1606 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel, $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1611 $therapyGroupCategories = array();
1612 $query = sqlStatement("SELECT pc_catid FROM openemr_postcalendar_categories WHERE pc_cattype = 3 AND pc_active = 1");
1613 while ($result = sqlFetchArray($query)) {
1614 $therapyGroupCategories[] = $result['pc_catid'];
1618 foreach ($events as $row) { //////
1620 $dayname = date("l", strtotime($row['pc_eventDate'])); //////
1622 $disphour = substr($row['pc_startTime'], 0, 2) +
0;
1623 $dispmin = substr($row['pc_startTime'], 3, 2);
1624 if ($disphour >= 12) {
1626 if ($disphour > 12) {
1631 $etitle = xl('(Click to edit)');
1632 if ($row['pc_hometext'] != "") {
1633 $etitle = xl('Comments').": ".($row['pc_hometext'])."\r\n".$etitle;
1637 if ($extraApptDate && $count > $firstApptIndx) {
1638 $apptStyle = $apptStyle2;
1640 if ($row['pc_eventDate'] != $priorDate) {
1641 $priorDate = $row['pc_eventDate'];
1642 $toggleSet = !$toggleSet;
1646 $apptStyle = " style='background-color:" . attr($colorSet2) . ";'";
1648 $apptStyle = " style='background-color:" . attr($colorSet1) . ";'";
1653 echo "<div " . $apptStyle . ">";
1654 if (!in_array($row['pc_catid'], $therapyGroupCategories)) {
1655 echo "<a href='javascript:oldEvt(" . htmlspecialchars(preg_replace("/-/", "", $row['pc_eventDate']), ENT_QUOTES
) . ', ' . htmlspecialchars($row['pc_eid'], ENT_QUOTES
) . ")' title='" . htmlspecialchars($etitle, ENT_QUOTES
) . "'>";
1657 echo "<span title='" . htmlspecialchars($etitle, ENT_QUOTES
) . "'>";
1660 echo "<b>" . htmlspecialchars($row['pc_eventDate'], ENT_NOQUOTES
) . ", ";
1661 echo htmlspecialchars(sprintf("%02d", $disphour) .":$dispmin " . xl($dispampm) . " (" . xl($dayname), ENT_NOQUOTES
) . ")</b> ";
1662 if ($row['pc_recurrtype']) {
1663 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
)."'>";
1666 echo "<span title='" . generate_display_field(array('data_type'=>'1','list_id'=>'apptstat'), $row['pc_apptstatus']) . "'>";
1667 echo "<br>" . xlt('Status') . "( " . htmlspecialchars($row['pc_apptstatus'], ENT_NOQUOTES
) . " ) </span>";
1668 echo htmlspecialchars(xl_appt_category($row['pc_catname']), ENT_NOQUOTES
) . "\n";
1669 if (in_array($row['pc_catid'], $therapyGroupCategories)) {
1670 echo "<br><span>" . xlt('Group name') .": " . text(getGroup($row['pc_gid'])['group_name']) . "</span>\n";
1673 if ($row['pc_hometext']) {
1674 echo " <span style='color:green'> Com</span>";
1677 echo "<br>" . htmlspecialchars($row['ufname'] . " " . $row['ulname'], ENT_NOQUOTES
);
1678 echo !in_array($row['pc_catid'], $therapyGroupCategories) ?
'</a>' : '<span>';
1683 if ($resNotNull) { //////
1685 echo " " . htmlspecialchars(xl('None'), ENT_NOQUOTES
);
1687 if ($extraApptDate) {
1688 echo "<div style='color:#0000cc;'><b>" . attr($extraApptDate) . " ( + ) </b></div>";
1690 echo "<div><hr></div>";
1696 } // End of Appointments.
1699 /* Widget that shows recurrences for appointments. */
1700 if (isset($pid) && !$GLOBALS['disable_calendar'] && $GLOBALS['appt_recurrences_widget'] &&
1701 acl_check('patients', 'appt')) {
1702 $widgetTitle = xl("Recurrent Appointments");
1703 $widgetLabel = "recurrent_appointments";
1704 $widgetButtonLabel = xl("Add");
1705 $widgetButtonLink = "return newEvt();";
1706 $widgetButtonClass = "";
1707 $linkMethod = "javascript";
1708 $bodyClass = "summary_item small";
1709 $widgetAuth = false;
1710 $fixedWidth = false;
1711 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel, $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1716 //Fetch patient's recurrences. Function returns array with recurrence appointments' category, recurrence pattern (interpreted), and end date.
1717 $recurrences = fetchRecurrences($pid);
1718 if ($recurrences[0] == false) { //if there are no recurrent appointments:
1720 echo "<span>" . " " . xlt('None') . "</span>";
1721 echo "</div></div>";
1723 foreach ($recurrences as $row) {
1724 //checks if there are recurrences and if they are current (git didn't end yet)
1725 if ($row == false ||
!recurrence_is_current($row['pc_endDate'])) {
1730 echo "<span>" . xlt('Appointment Category') . ': ' . xlt($row['pc_catname']) . "</span>";
1732 echo "<span>" . xlt('Recurrence') . ': ' . text($row['pc_recurrspec']) . "</span>";
1734 $red_text = ""; //if ends in a week, make font red
1735 if (ends_in_a_week($row['pc_endDate'])) {
1736 $red_text = " style=\"color:red;\" ";
1739 echo "<span" . $red_text . ">" . xlt('End Date') . ': ' . text($row['pc_endDate']) . "</span>";
1747 /* End of recurrence widget */
1749 // Show PAST appointments.
1750 // added by Terry Hill to allow reverse sorting of the appointments
1752 if ($GLOBALS['num_past_appointments_to_show'] < 0) {
1753 $direction = "DESC";
1754 ($showpast = -1 * $GLOBALS['num_past_appointments_to_show']);
1756 $showpast = $GLOBALS['num_past_appointments_to_show'];
1759 if (isset($pid) && !$GLOBALS['disable_calendar'] && $showpast > 0 &&
1760 acl_check('patients', 'appt')) {
1761 $query = "SELECT e.pc_eid, e.pc_aid, e.pc_title, e.pc_eventDate, " .
1762 "e.pc_startTime, e.pc_hometext, u.fname, u.lname, u.mname, " .
1763 "c.pc_catname, e.pc_apptstatus " .
1764 "FROM openemr_postcalendar_events AS e, users AS u, " .
1765 "openemr_postcalendar_categories AS c WHERE " .
1766 "e.pc_pid = ? AND e.pc_eventDate < CURRENT_DATE AND " .
1767 "u.id = e.pc_aid AND e.pc_catid = c.pc_catid " .
1768 "ORDER BY e.pc_eventDate $direction , e.pc_startTime DESC " .
1769 "LIMIT " . $showpast;
1771 $pres = sqlStatement($query, array($pid));
1773 // appointments expand collapse widget
1774 $widgetTitle = xl("Past Appointments");
1775 $widgetLabel = "past_appointments";
1776 $widgetButtonLabel = '';
1777 $widgetButtonLink = '';
1778 $widgetButtonClass = '';
1779 $linkMethod = "javascript";
1780 $bodyClass = "summary_item small";
1781 $widgetAuth = false; //no button
1782 $fixedWidth = false;
1783 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel, $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1785 while ($row = sqlFetchArray($pres)) {
1787 $dayname = date("l", strtotime($row['pc_eventDate']));
1789 $disphour = substr($row['pc_startTime'], 0, 2) +
0;
1790 $dispmin = substr($row['pc_startTime'], 3, 2);
1791 if ($disphour >= 12) {
1793 if ($disphour > 12) {
1798 if ($row['pc_hometext'] != "") {
1799 $etitle = xl('Comments').": ".($row['pc_hometext'])."\r\n".$etitle;
1802 echo "<a href='javascript:oldEvt(" . htmlspecialchars(preg_replace("/-/", "", $row['pc_eventDate']), ENT_QUOTES
) . ', ' . htmlspecialchars($row['pc_eid'], ENT_QUOTES
) . ")' title='" . htmlspecialchars($etitle, ENT_QUOTES
) . "'>";
1803 echo "<b>" . htmlspecialchars(xl($dayname) . ", " . $row['pc_eventDate'], ENT_NOQUOTES
) . "</b>" . xlt("Status") . "(";
1804 echo " " . generate_display_field(array('data_type'=>'1','list_id'=>'apptstat'), $row['pc_apptstatus']) . ")<br>"; // can't use special char parser on this
1805 echo htmlspecialchars("$disphour:$dispmin ") . xl($dispampm) . " ";
1806 echo htmlspecialchars($row['fname'] . " " . $row['lname'], ENT_NOQUOTES
) . "</a><br>\n";
1809 if (isset($pres) && $res != null) {
1811 echo " " . htmlspecialchars(xl('None'), ENT_NOQUOTES
);
1818 // END of past appointments
1822 <div id
='stats_div'>
1824 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1829 <?php
// TRACK ANYTHING -----
1831 // Determine if track_anything form is in use for this site.
1832 $tmp = sqlQuery("SELECT count(*) AS count FROM registry WHERE " .
1833 "directory = 'track_anything' AND state = 1");
1834 $track_is_registered = $tmp['count'];
1835 if ($track_is_registered) {
1837 // track_anything expand collapse widget
1838 $widgetTitle = xl("Tracks");
1839 $widgetLabel = "track_anything";
1840 $widgetButtonLabel = xl("Tracks");
1841 $widgetButtonLink = "../../forms/track_anything/create.php";
1842 $widgetButtonClass = "";
1843 $widgetAuth = ""; // don't show the button
1844 $linkMethod = "html";
1845 $bodyClass = "notab";
1846 // check to see if any tracks exist
1847 $spruch = "SELECT id " .
1851 $existTracks = sqlQuery($spruch, array($pid, "track_anything"));
1853 $fixedWidth = false;
1854 expand_collapse_widget(
1867 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1871 } // end track_anything ?>
1874 </div
> <!-- end right column div
-->
1881 </div
> <!-- end main content div
-->
1883 <script language
='JavaScript'>
1884 // Array of skip conditions for the checkSkipConditions() function.
1886 <?php
echo $condition_str; ?
>
1888 checkSkipConditions();