4 * Patient summary screen.
7 * @link http://www.open-emr.org
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
14 require_once("../../globals.php");
15 require_once("$srcdir/patient.inc");
16 require_once("$srcdir/acl.inc");
17 require_once("$srcdir/options.inc.php");
18 require_once("../history/history.inc.php");
19 require_once("$srcdir/edi.inc");
20 require_once("$srcdir/invoice_summary.inc.php");
21 require_once("$srcdir/clinical_rules.php");
22 require_once("$srcdir/options.js.php");
23 require_once("$srcdir/group.inc");
25 require_once(dirname(__FILE__
)."/../../../library/appointments.inc.php");
27 if (isset($_GET['set_pid'])) {
28 include_once("$srcdir/pid.inc");
29 setpid($_GET['set_pid']);
32 $active_reminders = false;
33 $all_allergy_alerts = false;
34 if ($GLOBALS['enable_cdr']) {
36 if ($GLOBALS['enable_allergy_check'] && $GLOBALS['enable_alert_log']) {
37 //Check for new allergies conflicts and throw popup if any exist(note need alert logging to support this)
38 $new_allergy_alerts = allergy_conflict($pid, 'new', $_SESSION['authUser']);
39 if (!empty($new_allergy_alerts)) {
40 $pop_warning = '<script type="text/javascript">alert(\'' . xls('WARNING - FOLLOWING ACTIVE MEDICATIONS ARE ALLERGIES') . ':\n';
41 foreach ($new_allergy_alerts as $new_allergy_alert) {
42 $pop_warning .= addslashes($new_allergy_alert) . '\n';
45 $pop_warning .= '\')</script>';
50 if ((!isset($_SESSION['alert_notify_pid']) ||
($_SESSION['alert_notify_pid'] != $pid)) && isset($_GET['set_pid']) && $GLOBALS['enable_cdr_crp']) {
51 // showing a new patient, so check for active reminders and allergy conflicts, which use in active reminder popup
52 $active_reminders = active_alert_summary($pid, "reminders-due", '', 'default', $_SESSION['authUser'], true);
53 if ($GLOBALS['enable_allergy_check']) {
54 $all_allergy_alerts = allergy_conflict($pid, 'all', $_SESSION['authUser'], true);
59 function print_as_money($money)
61 preg_match("/(\d*)\.?(\d*)/", $money, $moneymatches);
62 $tmp = wordwrap(strrev($moneymatches[1]), 3, ",", 1);
63 $ccheck = strrev($tmp);
64 if ($ccheck[0] == ",") {
65 $tmp = substr($ccheck, 1, strlen($ccheck)-1);
68 if ($moneymatches[2] != "") {
69 return "$ " . strrev($tmp) . "." . $moneymatches[2];
71 return "$ " . strrev($tmp);
75 // get an array from Photos category
76 function pic_array($pid, $picture_directory)
79 $sql_query = "select documents.id from documents join categories_to_documents " .
80 "on documents.id = categories_to_documents.document_id " .
81 "join categories on categories.id = categories_to_documents.category_id " .
82 "where categories.name like ? and documents.foreign_id = ?";
83 if ($query = sqlStatement($sql_query, array($picture_directory,$pid))) {
84 while ($results = sqlFetchArray($query)) {
85 array_push($pics, $results['id']);
91 // Get the document ID of the first document in a specific catg.
92 function get_document_by_catg($pid, $doc_catg)
97 if ($pid and $doc_catg) {
98 $result = sqlQuery("SELECT d.id, d.date, d.url FROM " .
99 "documents AS d, categories_to_documents AS cd, categories AS c " .
100 "WHERE d.foreign_id = ? " .
101 "AND cd.document_id = d.id " .
102 "AND c.id = cd.category_id " .
103 "AND c.name LIKE ? " .
104 "ORDER BY d.date DESC LIMIT 1", array($pid, $doc_catg));
107 return($result['id']);
110 // Display image in 'widget style'
111 function image_widget($doc_id, $doc_catg)
113 global $pid, $web_root;
114 $docobj = new Document($doc_id);
115 $image_file = $docobj->get_url_file();
116 $image_width = $GLOBALS['generate_doc_thumb'] == 1 ?
'' : 'width=100';
117 $extension = substr($image_file, strrpos($image_file, "."));
118 $viewable_types = array('.png','.jpg','.jpeg','.png','.bmp','.PNG','.JPG','.JPEG','.PNG','.BMP'); // image ext supported by fancybox viewer
119 if (in_array($extension, $viewable_types)) { // extention matches list
120 $to_url = "<td> <a href = $web_root" .
121 "/controller.php?document&retrieve&patient_id=$pid&document_id=$doc_id&as_file=false&original_file=true&disable_exit=false&show_original=true" .
122 "/tmp$extension" . // Force image type URL for fancybo
123 " onclick=top.restoreSession(); class='image_modal'>" .
124 " <img src = $web_root" .
125 "/controller.php?document&retrieve&patient_id=$pid&document_id=$doc_id&as_file=false" .
126 " $image_width alt='$doc_catg:$image_file'> </a> </td> <td valign='center'>".
127 htmlspecialchars($doc_catg) . '<br /> ' . htmlspecialchars($image_file) .
130 $to_url = "<td> <a href='" . $web_root . "/controller.php?document&retrieve" .
131 "&patient_id=$pid&document_id=$doc_id'" .
132 " onclick='top.restoreSession()' class='css_button_small'>" .
134 htmlspecialchars(xl("View"), ENT_QUOTES
)."</a> " .
135 htmlspecialchars("$doc_catg - $image_file", ENT_QUOTES
) .
141 echo "</tr></table>";
144 // Determine if the Vitals form is in use for this site.
145 $tmp = sqlQuery("SELECT count(*) AS count FROM registry WHERE " .
146 "directory = 'vitals' AND state = 1");
147 $vitals_is_registered = $tmp['count'];
149 // Get patient/employer/insurance information.
151 $result = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
152 $result2 = getEmployerData($pid);
153 $result3 = getInsuranceData($pid, "primary", "copay, provider, DATE_FORMAT(`date`,'%Y-%m-%d') as effdate");
155 if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
156 $insco_name = getInsuranceProvider($result3['provider']);
162 <?php
html_header_show();?
>
163 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
164 <link rel
="stylesheet" type
="text/css" href
="../../../library/js/fancybox/jquery.fancybox-1.2.6.css" media
="screen" />
165 <script type
="text/javascript" src
="../../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script
>
166 <script type
="text/javascript" src
="../../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
167 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-7-2/index.js"></script
>
168 <script type
="text/javascript" src
="../../../library/js/common.js?v=<?php echo $v_js_includes; ?>"></script
>
169 <script type
="text/javascript" src
="../../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script
>
170 <script type
="text/javascript" language
="JavaScript">
172 var mypcc
= '<?php echo htmlspecialchars($GLOBALS['phone_country_code
'], ENT_QUOTES); ?>';
174 function oldEvt(apptdate
, eventid
) {
175 dlgopen('../../main/calendar/add_edit_event.php?date=' + apptdate +
'&eid=' + eventid
, '_blank', 775, 500);
178 function advdirconfigure() {
179 dlgopen('advancedirectives.php', '_blank', 400, 500);
182 function refreshme() {
183 top
.restoreSession();
187 // Process click on Delete link.
188 function deleteme() {
189 dlgopen('../deleter.php?patient=<?php echo htmlspecialchars($pid, ENT_QUOTES); ?>', '_blank', 500, 450);
193 // Called by the deleteme.php window on a successful delete.
194 function imdeleted() {
195 <?php
if ($GLOBALS['new_tabs_layout']) { ?
>
198 parent
.left_nav
.clearPatient();
203 dlgopen('../../main/calendar/add_edit_event.php?patientid=<?php echo htmlspecialchars($pid, ENT_QUOTES); ?>', '_blank', 775, 500);
207 function sendimage(pid
, what
) {
208 // alert('Not yet implemented.'); return false;
209 dlgopen('../upload_dialog.php?patientid=' + pid +
'&file=' + what
,
216 <script type
="text/javascript">
218 function toggleIndicator(target
,div
) {
220 $mode = $
(target
).find(".indicator").text();
221 if ( $mode == "<?php echo htmlspecialchars(xl('collapse'), ENT_QUOTES); ?>" ) {
222 $
(target
).find(".indicator").text( "<?php echo htmlspecialchars(xl('expand'), ENT_QUOTES); ?>" );
224 $
.post( "../../../library/ajax/user_settings.php", { target
: div
, mode
: 0 });
226 $
(target
).find(".indicator").text( "<?php echo htmlspecialchars(xl('collapse'), ENT_QUOTES); ?>" );
228 $
.post( "../../../library/ajax/user_settings.php", { target
: div
, mode
: 1 });
232 $
(document
).ready(function(){
235 if ($GLOBALS['erx_enable']) {
236 //$soap_status=sqlQuery("select soap_import_status from patient_data where pid=?",array($pid));
237 $soap_status=sqlStatement("select soap_import_status,pid from patient_data where pid=? and soap_import_status in ('1','3')", array($pid));
238 while ($row_soapstatus=sqlFetchArray($soap_status)) {
239 //if($soap_status['soap_import_status']=='1' || $soap_status['soap_import_status']=='3'){ ?>
240 top
.restoreSession();
243 url
: "../../soap_functions/soap_patientfullmedication.php",
246 patient
:<?php
echo $row_soapstatus['pid']; ?
>,
249 success
: function(thedata
){
251 msg_updation+
=thedata
;
259 //elseif($soap_status['soap_import_status']=='3'){ ?>
260 top
.restoreSession();
263 url
: "../../soap_functions/soap_allergy.php",
266 patient
:<?php
echo $row_soapstatus['pid']; ?
>,
269 success
: function(thedata
){
271 msg_updation+
=thedata
;
278 if ($GLOBALS['erx_import_status_message']) { ?
>
289 $
("#stats_div").load("stats.php", { 'embeddedScreen' : true }, function() {
290 // (note need to place javascript code here also to get the dynamic link to work)
291 $
(".rx_modal").fancybox( {
292 'overlayOpacity' : 0.0,
293 'showCloseButton' : true,
296 'centerOnScroll' : false,
297 'callbackOnClose' : function() {
302 $
("#pnotes_ps_expand").load("pnotes_fragment.php");
303 $
("#disclosures_ps_expand").load("disc_fragment.php");
305 <?php
if ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crw']) { ?
>
306 top
.restoreSession();
307 $
("#clinical_reminders_ps_expand").load("clinical_reminders_fragment.php", { 'embeddedScreen' : true }, function() {
308 // (note need to place javascript code here also to get the dynamic link to work)
309 $
(".medium_modal").fancybox( {
310 'overlayOpacity' : 0.0,
311 'showCloseButton' : true,
314 'centerOnScroll' : false,
315 'callbackOnClose' : function() {
322 <?php
if ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_prw']) { ?
>
323 top
.restoreSession();
324 $
("#patient_reminders_ps_expand").load("patient_reminders_fragment.php");
327 <?php
if ($vitals_is_registered && acl_check('patients', 'med')) { ?
>
328 // Initialize the Vitals form if it is registered and user is authorized.
329 $
("#vitals_ps_expand").load("vitals_fragment.php");
332 // Initialize track_anything
333 $
("#track_anything_ps_expand").load("track_anything_fragment.php");
336 // Initialize labdata
337 $
("#labdata_ps_expand").load("labdata_fragment.php");
339 // Initialize for each applicable LBF form.
340 $gfres = sqlStatement("SELECT option_id FROM list_options WHERE " .
341 "list_id = 'lbfnames' AND option_value > 0 AND activity = 1 ORDER BY seq, title");
342 while ($gfrow = sqlFetchArray($gfres)) { ?
>
343 $
("#<?php echo $gfrow['option_id']; ?>_ps_expand").load("lbf_fragment.php?formname=<?php echo $gfrow['option_id']; ?>");<?php
352 // modal for dialog boxes
353 $
(".large_modal").fancybox( {
354 'overlayOpacity' : 0.0,
355 'showCloseButton' : true,
358 'centerOnScroll' : false
361 // modal for image viewer
362 $
(".image_modal").fancybox( {
363 'overlayOpacity' : 0.0,
364 'showCloseButton' : true,
365 'centerOnScroll' : false,
369 $
(".iframe1").fancybox( {
371 'overlayOpacity' : 0.0,
372 'showCloseButton' : true,
376 // special size for patient portal
377 $
(".small_modal").fancybox( {
378 'overlayOpacity' : 0.0,
379 'showCloseButton' : true,
382 'centerOnScroll' : false
385 <?php
if ($active_reminders ||
$all_allergy_alerts) { ?
>
386 // show the active reminder modal
387 $
("#reminder_popup_link").fancybox({
388 'overlayOpacity' : 0.0,
389 'showCloseButton' : true,
392 'centerOnScroll' : false
398 // JavaScript stuff to do when a new patient is set.
400 function setMyPatient() {
401 // Avoid race conditions with loading of the left_nav or Title frame.
402 if (!parent
.allFramesLoaded()) {
403 setTimeout("setMyPatient()", 500);
406 <?php
if (isset($_GET['set_pid'])) { ?
>
407 parent
.left_nav
.setPatient(<?php
echo "'" . addslashes($result['fname']) . " " . addslashes($result['lname']) .
408 "'," . addslashes($pid) . ",'" . addslashes($result['pubpid']) .
409 "','', ' " . xls('DOB') . ": " . addslashes(oeFormatShortDate($result['DOB_YMD'])) . " " . xls('Age') . ": " . addslashes(getPatientAgeDisplay($result['DOB_YMD'])) . "'"; ?
>);
410 var EncounterDateArray
= new Array;
411 var CalendarCategoryArray
= new Array;
412 var EncounterIdArray
= new Array;
415 //Encounter details are stored to javacript as array.
416 $result4 = sqlStatement("SELECT fe.encounter,fe.date,openemr_postcalendar_categories.pc_catname FROM form_encounter AS fe ".
417 " left join openemr_postcalendar_categories on fe.pc_catid=openemr_postcalendar_categories.pc_catid WHERE fe.pid = ? order by fe.date desc", array($pid));
418 if (sqlNumRows($result4)>0) {
419 while ($rowresult4 = sqlFetchArray($result4)) {
421 EncounterIdArray
[Count
] = '<?php echo addslashes($rowresult4['encounter
']); ?>';
422 EncounterDateArray
[Count
] = '<?php echo addslashes(oeFormatShortDate(date("Y-m-d", strtotime($rowresult4['date
'])))); ?>';
423 CalendarCategoryArray
[Count
] = '<?php echo addslashes(xl_appt_category($rowresult4['pc_catname
'])); ?>';
429 parent
.left_nav
.setPatientEncounter(EncounterIdArray
,EncounterDateArray
,CalendarCategoryArray
);
430 <?php
} // end setting new pid ?>
431 parent
.left_nav
.syncRadios();
432 <?php
if ((isset($_GET['set_pid']) ) && (isset($_GET['set_encounterid'])) && ( intval($_GET['set_encounterid']) > 0 )) {
433 $encounter = intval($_GET['set_encounterid']);
434 $_SESSION['encounter'] = $encounter;
435 $query_result = sqlQuery("SELECT `date` FROM `form_encounter` WHERE `encounter` = ?", array($encounter)); ?
>
436 encurl
= 'encounter/encounter_top.php?set_encounter=' +
<?php
echo attr($encounter);?
> +
'&pid=' +
<?php
echo attr($pid);?
>;
437 <?php
if ($GLOBALS['new_tabs_layout']) { ?
>
438 parent
.left_nav
.setEncounter('<?php echo oeFormatShortDate(date("Y-m-d", strtotime($query_result['date
']))); ?>', '<?php echo attr($encounter); ?>', 'enc');
439 top
.restoreSession();
440 parent
.left_nav
.loadFrame('enc2', 'enc', 'patient_file/' + encurl
);
442 var othername
= (window
.name
== 'RTop') ?
'RBot' : 'RTop';
443 parent
.left_nav
.setEncounter('<?php echo oeFormatShortDate(date("Y-m-d", strtotime($query_result['date
']))); ?>', '<?php echo attr($encounter); ?>', othername
);
444 top
.restoreSession();
445 parent
.frames
[othername
].location
.href
= '../' + encurl
;
447 <?php
} // end setting new encounter id (only if new pid is also set) ?>
450 $
(window
).load(function() {
456 <style type
="css/text">
465 <body
class="body_top patient-demographics">
467 <a href
='../reminder/active_reminder_popup.php' id
='reminder_popup_link' style
='visibility: false;' class='iframe' onclick
='top.restoreSession()'></a
>
470 $thisauth = acl_check('patients', 'demo');
472 if ($result['squad'] && ! acl_check('squads', $result['squad'])) {
478 echo "<p>(" . htmlspecialchars(xl('Demographics not authorized'), ENT_NOQUOTES
) . ")</p>\n";
479 echo "</body>\n</html>\n";
485 <table
class="table_header">
489 <?php
echo htmlspecialchars(getPatientName($pid), ENT_NOQUOTES
); ?
>
492 <?php
if (acl_check('admin', 'super') && $GLOBALS['allow_pat_delete']) : ?
>
493 <td style
='padding-left:1em;' class="delete">
494 <a
class='css_button iframe'
495 href
='../deleter.php?patient=<?php echo htmlspecialchars($pid, ENT_QUOTES);?>'
496 onclick
='top.restoreSession()'>
497 <span
><?php
echo htmlspecialchars(xl('Delete'), ENT_NOQUOTES
);?
></span
>
500 <?php
endif; // Allow PT delete
501 if ($GLOBALS['erx_enable']) : ?
>
502 <td style
="padding-left:1em;" class="erx">
503 <a
class="css_button" href
="../../eRx.php?page=medentry" onclick
="top.restoreSession()">
504 <span
><?php
echo htmlspecialchars(xl('NewCrop MedEntry'), ENT_NOQUOTES
);?
></span
>
507 <td style
="padding-left:1em;">
508 <a
class="css_button iframe1"
509 href
="../../soap_functions/soap_accountStatusDetails.php"
510 onclick
="top.restoreSession()">
511 <span
><?php
echo htmlspecialchars(xl('NewCrop Account Status'), ENT_NOQUOTES
);?
></span
>
514 <td id
='accountstatus'></td
>
515 <?php
endif; // eRX Enabled
517 $portalUserSetting = true; //flag to see if patient has authorized access to portal
518 if (($GLOBALS['portal_onsite_enable'] && $GLOBALS['portal_onsite_address']) ||
519 ($GLOBALS['portal_onsite_two_enable'] && $GLOBALS['portal_onsite_two_address']) ) :
520 $portalStatus = sqlQuery("SELECT allow_patient_portal FROM patient_data WHERE pid=?", array($pid));
521 if ($portalStatus['allow_patient_portal']=='YES') :
522 $portalLogin = sqlQuery("SELECT pid FROM `patient_access_onsite` WHERE `pid`=?", array($pid));?
>
523 <td style
='padding-left:1em;'>
524 <a
class='css_button iframe small_modal'
525 href
='create_portallogin.php?portalsite=on&patient=<?php echo htmlspecialchars($pid, ENT_QUOTES);?>'
526 onclick
='top.restoreSession()'>
527 <?php
$display = (empty($portalLogin)) ?
xlt('Create Onsite Portal Credentials') : xlt('Reset Onsite Portal Credentials'); ?
>
528 <span
><?php
echo $display; ?
></span
>
533 $portalUserSetting = false;
534 endif; // allow patient portal
535 endif; // Onsite Patient Portal
536 if ($GLOBALS['portal_offsite_enable'] && $GLOBALS['portal_offsite_address']) :
537 $portalStatus = sqlQuery("SELECT allow_patient_portal FROM patient_data WHERE pid=?", array($pid));
538 if ($portalStatus['allow_patient_portal']=='YES') :
539 $portalLogin = sqlQuery("SELECT pid FROM `patient_access_offsite` WHERE `pid`=?", array($pid));
541 <td style
='padding-left:1em;'>
542 <a
class='css_button iframe small_modal'
543 href
='create_portallogin.php?portalsite=off&patient=<?php echo htmlspecialchars($pid, ENT_QUOTES);?>'
544 onclick
='top.restoreSession()'>
546 <?php
$text = (empty($portalLogin)) ?
xlt('Create Offsite Portal Credentials') : xlt('Reset Offsite Portal Credentials'); ?
>
553 $portalUserSetting = false;
554 endif; // allow_patient_portal
555 endif; // portal_offsite_enable
556 if (!($portalUserSetting)) : // Show that the patient has not authorized portal access ?>
557 <td style
='padding-left:1em;'>
558 <?php
echo htmlspecialchars(xl('Patient has not authorized the Patient Portal.'), ENT_NOQUOTES
);?
>
563 // If patient is deceased, then show this (along with the number of days patient has been deceased for)
564 $days_deceased = is_patient_deceased($pid);
565 if ($days_deceased != null) : ?
>
566 <td
class="deceased" style
="padding-left:1em;font-weight:bold;color:red">
568 if ($days_deceased == 0) {
569 echo xlt("DECEASED (Today)");
570 } else if ($days_deceased == 1) {
571 echo xlt("DECEASED (1 day ago)");
573 echo xlt("DECEASED") . " (" . text($days_deceased) . " " . xlt("days ago") . ")";
585 // Get the document ID of the patient ID card if access to it is wanted here.
586 $idcard_doc_id = false;
587 if ($GLOBALS['patient_id_category_name']) {
588 $idcard_doc_id = get_document_by_catg($pid, $GLOBALS['patient_id_category_name']);
592 <table cellspacing
='0' cellpadding
='0' border
='0' class="subnav">
594 <td
class="small" colspan
='4'>
595 <a href
="../history/history.php" onclick
='top.restoreSession()'>
596 <?php
echo htmlspecialchars(xl('History'), ENT_NOQUOTES
); ?
></a
>
598 <?php
//note that we have temporarily removed report screen from the modal view ?>
599 <a href
="../report/patient_report.php" onclick
='top.restoreSession()'>
600 <?php
echo htmlspecialchars(xl('Report'), ENT_NOQUOTES
); ?
></a
>
602 <?php
//note that we have temporarily removed document screen from the modal view ?>
603 <a href
="../../../controller.php?document&list&patient_id=<?php echo $pid;?>" onclick
='top.restoreSession()'>
604 <?php
echo htmlspecialchars(xl('Documents'), ENT_NOQUOTES
); ?
></a
>
606 <a href
="../transaction/transactions.php" onclick
='top.restoreSession()'>
607 <?php
echo htmlspecialchars(xl('Transactions'), ENT_NOQUOTES
); ?
></a
>
609 <a href
="stats_full.php?active=all" onclick
='top.restoreSession()'>
610 <?php
echo htmlspecialchars(xl('Issues'), ENT_NOQUOTES
); ?
></a
>
612 <a href
="../../reports/pat_ledger.php?form=1&patient_id=<?php echo attr($pid);?>" onclick
='top.restoreSession()'>
613 <?php
echo xlt('Ledger'); ?
></a
>
615 <a href
="../../reports/external_data.php" onclick
='top.restoreSession()'>
616 <?php
echo xlt('External Data'); ?
></a
>
618 <!-- DISPLAYING HOOKS STARTS HERE
-->
620 $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
621 LEFT OUTER JOIN modules_settings AS ms ON obj_name=enabled_hooks AND ms.mod_id=msh.mod_id
622 LEFT OUTER JOIN modules AS m ON m.mod_id=ms.mod_id
623 WHERE fld_type=3 AND mod_active=1 AND sql_run=1 AND attached_to='demographics' ORDER BY mod_id");
624 $DivId = 'mod_installer';
625 if (sqlNumRows($module_query)) {
628 while ($modulerow = sqlFetchArray($module_query)) {
629 $DivId = 'mod_'.$modulerow['mod_id'];
630 $new_category = $modulerow['mod_ui_name'];
633 if ($modulerow['type'] == 0) {
634 $modulePath = $GLOBALS['customModDir'];
638 $modulePath = $GLOBALS['zendModDir'];
641 if (!acl_check('admin', 'super') && !zh_acl_check($_SESSION['authUserID'], $modulerow['obj_name'])) {
645 $relative_link = "../../modules/".$modulePath."/".$modulerow['path'];
646 $nickname = $modulerow['menu_name'] ?
$modulerow['menu_name'] : 'Noname';
648 $modid = $modulerow['mod_id'];
651 <a href
="<?php echo $relative_link; ?>" onclick
='top.restoreSession()'>
652 <?php
echo xlt($nickname); ?
></a
>
657 <!-- DISPLAYING HOOKS ENDS HERE
-->
661 </table
> <!-- end header
-->
663 <div style
='margin-top:10px' class="main"> <!-- start main content div
-->
664 <table border
="0" cellspacing
="0" cellpadding
="0" width
="100%">
666 <td
class="demographics-box" align
="left" valign
="top">
667 <!-- start left column div
-->
668 <div style
='float:left; margin-right:20px'>
670 <table cellspacing
=0 cellpadding
=0>
671 <?php
if (!$GLOBALS['hide_billing_widget']) { ?
>
675 // Billing expand collapse widget
676 $widgetTitle = xl("Billing");
677 $widgetLabel = "billing";
678 $widgetButtonLabel = xl("Edit");
679 $widgetButtonLink = "return newEvt();";
680 $widgetButtonClass = "";
681 $linkMethod = "javascript";
682 $bodyClass = "notab";
685 if ($GLOBALS['force_billing_widget_open']) {
686 $forceExpandAlways = true;
688 $forceExpandAlways = false;
691 expand_collapse_widget(
706 //PATIENT BALANCE,INS BALANCE naina@capminds.com
707 $patientbalance = get_patient_balance($pid, false);
708 //Debit the patient balance from insurance balance
709 $insurancebalance = get_patient_balance($pid, true) - $patientbalance;
710 $totalbalance=$patientbalance +
$insurancebalance;
712 // Show current balance and billing note, if any.
713 echo "<table border='0'><tr><td>" .
714 "<table ><tr><td><span class='bold'><font color='red'>" .
715 xlt('Patient Balance Due') .
716 " : " . text(oeFormatMoney($patientbalance)) .
717 "</font></span></td></tr>".
718 "<tr><td><span class='bold'><font color='red'>" .
719 xlt('Insurance Balance Due') .
720 " : " . text(oeFormatMoney($insurancebalance)) .
721 "</font></span></td></tr>".
722 "<tr><td><span class='bold'><font color='red'>" .
723 xlt('Total Balance Due').
724 " : " . text(oeFormatMoney($totalbalance)) .
725 "</font></span></td></td></tr>";
726 if (!empty($result['billing_note'])) {
727 echo "<tr><td><span class='bold'><font color='red'>" .
728 xlt('Billing Note') . ":" .
729 text($result['billing_note']) .
730 "</font></span></td></tr>";
733 if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
734 echo "<tr><td><span class='bold'>" .
735 xlt('Primary Insurance') . ': ' . text($insco_name) .
736 "</span> ";
737 if ($result3['copay'] > 0) {
738 echo "<span class='bold'>" .
739 xlt('Copay') . ': ' . text($result3['copay']) .
740 "</span> ";
743 echo "<span class='bold'>" .
744 xlt('Effective Date') . ': ' . text(oeFormatShortDate($result3['effdate'])) .
748 echo "</table></td></tr></td></tr></table><br>";
751 </div
> <!-- required
for expand_collapse_widget
-->
756 <?php
if (acl_check('patients', 'demo')) { ?
>
760 // Demographics expand collapse widget
761 $widgetTitle = xl("Demographics");
762 $widgetLabel = "demographics";
763 $widgetButtonLabel = xl("Edit");
764 $widgetButtonLink = "demographics_full.php";
765 $widgetButtonClass = "";
766 $linkMethod = "html";
768 $widgetAuth = acl_check('patients', 'demo', '', 'write');
770 expand_collapse_widget(
784 <?php
display_layout_tabs('DEM', $result, $result2); ?
>
786 <div
class="tabContainer">
787 <?php
display_layout_tabs_data('DEM', $result, $result2); ?
>
790 </div
> <!-- required
for expand_collapse_widget
-->
797 $insurance_count = 0;
798 foreach (array('primary','secondary','tertiary') as $instype) {
799 $enddate = 'Present';
800 $query = "SELECT * FROM insurance_data WHERE " .
801 "pid = ? AND type = ? " .
802 "ORDER BY date DESC";
803 $res = sqlStatement($query, array($pid, $instype));
804 while ($row = sqlFetchArray($res)) {
805 if ($row['provider']) {
811 if ($insurance_count > 0) {
812 // Insurance expand collapse widget
813 $widgetTitle = xl("Insurance");
814 $widgetLabel = "insurance";
815 $widgetButtonLabel = xl("Edit");
816 $widgetButtonLink = "demographics_full.php";
817 $widgetButtonClass = "";
818 $linkMethod = "html";
820 $widgetAuth = acl_check('patients', 'demo', '', 'write');
822 expand_collapse_widget(
834 if ($insurance_count > 0) {
837 <ul
class="tabNav"><?php
838 ///////////////////////////////// INSURANCE SECTION
840 foreach (array('primary','secondary','tertiary') as $instype) {
841 $query = "SELECT * FROM insurance_data WHERE " .
842 "pid = ? AND type = ? " .
843 "ORDER BY date DESC";
844 $res = sqlStatement($query, array($pid, $instype));
846 $enddate = 'Present';
848 while ($row = sqlFetchArray($res)) {
849 if ($row['provider']) {
850 $ins_description = ucfirst($instype);
851 $ins_description = xl($ins_description);
852 $ins_description .= strcmp($enddate, 'Present') != 0 ?
" (".xl('Old').")" : "";
854 <li
<?php
echo $first ?
'class="current"' : '' ?
>><a href
="#">
855 <?php
echo htmlspecialchars($ins_description, ENT_NOQUOTES
); ?
></a
></li
>
860 $enddate = $row['date'];
864 // Display the eligibility tab
865 echo "<li><a href='#'>" .
866 htmlspecialchars(xl('Eligibility'), ENT_NOQUOTES
) . "</a></li>";
871 <div
class="tabContainer">
874 foreach (array('primary','secondary','tertiary') as $instype) {
875 $enddate = 'Present';
877 $query = "SELECT * FROM insurance_data WHERE " .
878 "pid = ? AND type = ? " .
879 "ORDER BY date DESC";
880 $res = sqlStatement($query, array($pid, $instype));
881 while ($row = sqlFetchArray($res)) {
882 if ($row['provider']) {
884 <div
class="tab <?php echo $first ? 'current' : '' ?>">
885 <table border
='0' cellpadding
='0' width
='100%'>
887 $icobj = new InsuranceCompany($row['provider']);
888 $adobj = $icobj->get_address();
889 $insco_name = trim($icobj->get_name());
892 <td valign
='top' colspan
='3'>
894 <?php
if (strcmp($enddate, 'Present') != 0) {
895 echo htmlspecialchars(xl("Old"), ENT_NOQUOTES
)." ";
897 <?php
$tempinstype=ucfirst($instype);
898 echo htmlspecialchars(xl($tempinstype.' Insurance'), ENT_NOQUOTES
); ?
>
899 <?php
if (strcmp($row['date'], '0000-00-00') != 0) { ?
>
900 <?php
echo htmlspecialchars(xl('from', '', ' ', ' ').$row['date'], ENT_NOQUOTES
); ?
>
902 <?php
echo htmlspecialchars(xl('until', '', ' ', ' '), ENT_NOQUOTES
);
903 echo (strcmp($enddate, 'Present') != 0) ?
$enddate : htmlspecialchars(xl('Present'), ENT_NOQUOTES
); ?
>:</span
>
911 echo htmlspecialchars($insco_name, ENT_NOQUOTES
) . '<br>';
912 if (trim($adobj->get_line1())) {
913 echo htmlspecialchars($adobj->get_line1(), ENT_NOQUOTES
) . '<br>';
914 echo htmlspecialchars($adobj->get_city() . ', ' . $adobj->get_state() . ' ' . $adobj->get_zip(), ENT_NOQUOTES
);
917 echo "<font color='red'><b>".htmlspecialchars(xl('Unassigned'), ENT_NOQUOTES
)."</b></font>";
921 <?php
echo htmlspecialchars(xl('Policy Number'), ENT_NOQUOTES
); ?
>:
922 <?php
echo htmlspecialchars($row['policy_number'], ENT_NOQUOTES
) ?
><br
>
923 <?php
echo htmlspecialchars(xl('Plan Name'), ENT_NOQUOTES
); ?
>:
924 <?php
echo htmlspecialchars($row['plan_name'], ENT_NOQUOTES
); ?
><br
>
925 <?php
echo htmlspecialchars(xl('Group Number'), ENT_NOQUOTES
); ?
>:
926 <?php
echo htmlspecialchars($row['group_number'], ENT_NOQUOTES
); ?
></span
>
929 <span
class='bold'><?php
echo htmlspecialchars(xl('Subscriber'), ENT_NOQUOTES
); ?
>: </span
><br
>
930 <span
class='text'><?php
echo htmlspecialchars($row['subscriber_fname'] . ' ' . $row['subscriber_mname'] . ' ' . $row['subscriber_lname'], ENT_NOQUOTES
); ?
>
932 if ($row['subscriber_relationship'] != "") {
933 echo "(" . htmlspecialchars($row['subscriber_relationship'], ENT_NOQUOTES
) . ")";
937 <?php
echo htmlspecialchars(xl('S.S.'), ENT_NOQUOTES
); ?
>:
938 <?php
echo htmlspecialchars($row['subscriber_ss'], ENT_NOQUOTES
); ?
><br
>
939 <?php
echo htmlspecialchars(xl('D.O.B.'), ENT_NOQUOTES
); ?
>:
940 <?php
if ($row['subscriber_DOB'] != "0000-00-00 00:00:00") {
941 echo htmlspecialchars($row['subscriber_DOB'], ENT_NOQUOTES
);
943 <?php
echo htmlspecialchars(xl('Phone'), ENT_NOQUOTES
); ?
>:
944 <?php
echo htmlspecialchars($row['subscriber_phone'], ENT_NOQUOTES
); ?
>
948 <span
class='bold'><?php
echo htmlspecialchars(xl('Subscriber Address'), ENT_NOQUOTES
); ?
>: </span
><br
>
949 <span
class='text'><?php
echo htmlspecialchars($row['subscriber_street'], ENT_NOQUOTES
); ?
><br
>
950 <?php
echo htmlspecialchars($row['subscriber_city'], ENT_NOQUOTES
); ?
>
951 <?php
if ($row['subscriber_state'] != "") {
955 echo htmlspecialchars($row['subscriber_state'], ENT_NOQUOTES
); ?
>
956 <?php
if ($row['subscriber_country'] != "") {
960 echo htmlspecialchars($row['subscriber_country'], ENT_NOQUOTES
); ?
>
961 <?php
echo " " . htmlspecialchars($row['subscriber_postal_code'], ENT_NOQUOTES
); ?
></span
>
963 <?php
if (trim($row['subscriber_employer'])) { ?
>
964 <br
><span
class='bold'><?php
echo htmlspecialchars(xl('Subscriber Employer'), ENT_NOQUOTES
); ?
>: </span
><br
>
965 <span
class='text'><?php
echo htmlspecialchars($row['subscriber_employer'], ENT_NOQUOTES
); ?
><br
>
966 <?php
echo htmlspecialchars($row['subscriber_employer_street'], ENT_NOQUOTES
); ?
><br
>
967 <?php
echo htmlspecialchars($row['subscriber_employer_city'], ENT_NOQUOTES
); ?
>
968 <?php
if ($row['subscriber_employer_city'] != "") {
972 echo htmlspecialchars($row['subscriber_employer_state'], ENT_NOQUOTES
); ?
>
973 <?php
if ($row['subscriber_employer_country'] != "") {
977 echo htmlspecialchars($row['subscriber_employer_country'], ENT_NOQUOTES
); ?
>
978 <?php
echo " " . htmlspecialchars($row['subscriber_employer_postal_code'], ENT_NOQUOTES
); ?
>
986 <?php
if ($row['copay'] != "") { ?
>
987 <span
class='bold'><?php
echo htmlspecialchars(xl('CoPay'), ENT_NOQUOTES
); ?
>: </span
>
988 <span
class='text'><?php
echo htmlspecialchars($row['copay'], ENT_NOQUOTES
); ?
></span
>
991 <span
class='bold'><?php
echo htmlspecialchars(xl('Accept Assignment'), ENT_NOQUOTES
); ?
>:</span
>
992 <span
class='text'><?php
if ($row['accept_assignment'] == "TRUE") {
995 <?php
if ($row['accept_assignment'] == "FALSE") {
998 <?php
if (!empty($row['policy_type'])) { ?
>
1000 <span
class='bold'><?php
echo htmlspecialchars(xl('Secondary Medicare Type'), ENT_NOQUOTES
); ?
>: </span
>
1001 <span
class='text'><?php
echo htmlspecialchars($policy_types[$row['policy_type']], ENT_NOQUOTES
); ?
></span
>
1004 <td valign
='top'></td
>
1005 <td valign
='top'></td
>
1011 } // end if ($row['provider'])
1012 $enddate = $row['date'];
1017 // Display the eligibility information
1018 echo "<div class='tab'>";
1019 show_eligibility_information($pid, true);
1022 ///////////////////////////////// END INSURANCE SECTION
1030 <?php
} // end if demographics authorized ?>
1032 <?php
if (acl_check('patients', 'notes')) { ?
>
1036 // Notes expand collapse widget
1037 $widgetTitle = xl("Notes");
1038 $widgetLabel = "pnotes";
1039 $widgetButtonLabel = xl("Edit");
1040 $widgetButtonLink = "pnotes_full.php?form_active=1";
1041 $widgetButtonClass = "";
1042 $linkMethod = "html";
1043 $bodyClass = "notab";
1044 $widgetAuth = acl_check('patients', 'notes', '', 'write');
1046 expand_collapse_widget(
1059 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1063 <?php
} // end if notes authorized ?>
1065 <?php
if (acl_check('patients', 'reminder') && $GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_prw']) {
1066 echo "<tr><td width='650px'>";
1067 // patient reminders collapse widget
1068 $widgetTitle = xl("Patient Reminders");
1069 $widgetLabel = "patient_reminders";
1070 $widgetButtonLabel = xl("Edit");
1071 $widgetButtonLink = "../reminder/patient_reminders.php?mode=simple&patient_id=".$pid;
1072 $widgetButtonClass = "";
1073 $linkMethod = "html";
1074 $bodyClass = "notab";
1075 $widgetAuth = acl_check('patients', 'reminder', '', 'write');
1077 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel, $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth); ?
>
1079 <div style
='margin-left:10px' class='text'><image src
='../../pic/ajax-loader.gif'/></div
><br
/>
1083 <?php
} //end if prw is activated ?>
1085 <?php
if (acl_check('patients', 'disclosure')) { ?
>
1089 // disclosures expand collapse widget
1090 $widgetTitle = xl("Disclosures");
1091 $widgetLabel = "disclosures";
1092 $widgetButtonLabel = xl("Edit");
1093 $widgetButtonLink = "disclosure_full.php";
1094 $widgetButtonClass = "";
1095 $linkMethod = "html";
1096 $bodyClass = "notab";
1097 $widgetAuth = acl_check('patients', 'disclosure', '', 'write');
1099 expand_collapse_widget(
1112 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1116 <?php
} // end if disclosures authorized ?>
1118 <?php
if ($GLOBALS['amendments'] && acl_check('patients', 'amendment')) { ?
>
1121 <?php
// Amendments widget
1122 $widgetTitle = xlt('Amendments');
1123 $widgetLabel = "amendments";
1124 $widgetButtonLabel = xlt("Edit");
1125 $widgetButtonLink = $GLOBALS['webroot'] . "/interface/patient_file/summary/main_frameset.php?feature=amendment";
1126 $widgetButtonClass = "iframe rx_modal";
1127 $linkMethod = "html";
1128 $bodyClass = "summary_item small";
1129 $widgetAuth = acl_check('patients', 'amendment', '', 'write');
1130 $fixedWidth = false;
1131 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel, $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1132 $sql = "SELECT * FROM amendments WHERE pid = ? ORDER BY amendment_date DESC";
1133 $result = sqlStatement($sql, array($pid));
1135 if (sqlNumRows($result) == 0) {
1136 echo " <table><tr>\n";
1137 echo " <td colspan='$numcols' class='text'> " . xlt('None') . "</td>\n";
1138 echo " </tr></table>\n";
1141 while ($row=sqlFetchArray($result)) {
1142 echo " ";
1143 echo "<a class= '" . $widgetButtonClass . "' href='" . $widgetButtonLink . "&id=" . attr($row['amendment_id']) . "' onclick='top.restoreSession()'>" . text($row['amendment_date']);
1144 echo " " . text($row['amendment_desc']);
1150 <?php
} // end amendments authorized ?>
1152 <?php
if (acl_check('patients', 'lab')) { ?
>
1155 <?php
// labdata expand collapse widget
1156 $widgetTitle = xl("Labs");
1157 $widgetLabel = "labdata";
1158 $widgetButtonLabel = xl("Trend");
1159 $widgetButtonLink = "../summary/labdata.php";#"../encounter/trend_form.php?formname=labdata";
1160 $widgetButtonClass = "";
1161 $linkMethod = "html";
1162 $bodyClass = "notab";
1163 // check to see if any labdata exist
1164 $spruch = "SELECT procedure_report.date_collected AS date " .
1165 "FROM procedure_report " .
1166 "JOIN procedure_order ON procedure_report.procedure_order_id = procedure_order.procedure_order_id " .
1167 "WHERE procedure_order.patient_id = ? " .
1168 "ORDER BY procedure_report.date_collected DESC ";
1169 $existLabdata = sqlQuery($spruch, array($pid));
1170 if ($existLabdata) {
1173 $widgetAuth = false;
1177 expand_collapse_widget(
1190 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1194 <?php
} // end labs authorized ?>
1196 <?php
if ($vitals_is_registered && acl_check('patients', 'med')) { ?
>
1199 <?php
// vitals expand collapse widget
1200 $widgetTitle = xl("Vitals");
1201 $widgetLabel = "vitals";
1202 $widgetButtonLabel = xl("Trend");
1203 $widgetButtonLink = "../encounter/trend_form.php?formname=vitals";
1204 $widgetButtonClass = "";
1205 $linkMethod = "html";
1206 $bodyClass = "notab";
1207 // check to see if any vitals exist
1208 $existVitals = sqlQuery("SELECT * FROM form_vitals WHERE pid=?", array($pid));
1212 $widgetAuth = false;
1216 expand_collapse_widget(
1229 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1233 <?php
} // end if ($vitals_is_registered && acl_check('patients', 'med')) ?>
1236 // This generates a section similar to Vitals for each LBF form that
1237 // supports charting. The form ID is used as the "widget label".
1239 $gfres = sqlStatement("SELECT option_id, title, notes FROM list_options WHERE " .
1240 "list_id = 'lbfnames' AND " .
1241 "option_value > 0 AND activity = 1 " .
1242 "ORDER BY seq, title");
1243 while ($gfrow = sqlFetchArray($gfres)) {
1244 $jobj = json_decode($gfrow['notes'], true);
1245 $LBF_ACO = empty($jobj['aco']) ?
false : explode('|', $jobj['aco']);
1246 if ($LBF_ACO && !acl_check($LBF_ACO[0], $LBF_ACO[1])) {
1251 <?php
// vitals expand collapse widget
1252 $vitals_form_id = $gfrow['option_id'];
1253 $widgetTitle = $gfrow['title'];
1254 $widgetLabel = $vitals_form_id;
1255 $widgetButtonLabel = xl("Trend");
1256 $widgetButtonLink = "../encounter/trend_form.php?formname=$vitals_form_id";
1257 $widgetButtonClass = "";
1258 $linkMethod = "html";
1259 $bodyClass = "notab";
1260 $widgetAuth = false;
1261 if (!$LBF_ACO ||
acl_check($LBF_ACO[0], $LBF_ACO[1], '', 'write')) {
1262 // check to see if any instances exist for this patient
1263 $existVitals = sqlQuery(
1264 "SELECT * FROM forms WHERE pid = ? AND formdir = ? AND deleted = 0",
1265 array($pid, $vitals_form_id)
1267 $widgetAuth = $existVitals;
1271 expand_collapse_widget(
1283 <div style
='margin-left:10px' class='text'>
1284 <image src
='../../pic/ajax-loader.gif'/>
1287 </div
> <!-- This is required by
expand_collapse_widget(). -->
1297 <!-- end left column div
-->
1299 <!-- start right column div
-->
1308 // If there is an ID Card or any Photos show the widget
1309 $photos = pic_array($pid, $GLOBALS['patient_photo_category_name']);
1310 if ($photos or $idcard_doc_id) {
1311 $widgetTitle = xl("ID Card") . '/' . xl("Photos");
1312 $widgetLabel = "photos";
1313 $linkMethod = "javascript";
1314 $bodyClass = "notab-right";
1315 $widgetAuth = false;
1316 $fixedWidth = false;
1317 expand_collapse_widget(
1331 if ($idcard_doc_id) {
1332 image_widget($idcard_doc_id, $GLOBALS['patient_id_category_name']);
1335 foreach ($photos as $photo_doc_id) {
1336 image_widget($photo_doc_id, $GLOBALS['patient_photo_category_name']);
1345 // Advance Directives
1346 if ($GLOBALS['advance_directives_warning']) {
1347 // advance directives expand collapse widget
1348 $widgetTitle = xl("Advance Directives");
1349 $widgetLabel = "directives";
1350 $widgetButtonLabel = xl("Edit");
1351 $widgetButtonLink = "return advdirconfigure();";
1352 $widgetButtonClass = "";
1353 $linkMethod = "javascript";
1354 $bodyClass = "summary_item small";
1356 $fixedWidth = false;
1357 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel, $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1358 $counterFlag = false; //flag to record whether any categories contain ad records
1359 $query = "SELECT id FROM categories WHERE name='Advance Directive'";
1360 $myrow2 = sqlQuery($query);
1362 $parentId = $myrow2['id'];
1363 $query = "SELECT id, name FROM categories WHERE parent=?";
1364 $resNew1 = sqlStatement($query, array($parentId));
1365 while ($myrows3 = sqlFetchArray($resNew1)) {
1366 $categoryId = $myrows3['id'];
1367 $nameDoc = $myrows3['name'];
1368 $query = "SELECT documents.date, documents.id " .
1370 "INNER JOIN categories_to_documents " .
1371 "ON categories_to_documents.document_id=documents.id " .
1372 "WHERE categories_to_documents.category_id=? " .
1373 "AND documents.foreign_id=? " .
1374 "ORDER BY documents.date DESC";
1375 $resNew2 = sqlStatement($query, array($categoryId, $pid));
1376 $limitCounter = 0; // limit to one entry per category
1377 while (($myrows4 = sqlFetchArray($resNew2)) && ($limitCounter == 0)) {
1378 $dateTimeDoc = $myrows4['date'];
1379 // remove time from datetime stamp
1380 $tempParse = explode(" ", $dateTimeDoc);
1381 $dateDoc = $tempParse[0];
1382 $idDoc = $myrows4['id'];
1383 echo "<a href='$web_root/controller.php?document&retrieve&patient_id=" .
1384 htmlspecialchars($pid, ENT_QUOTES
) . "&document_id=" .
1385 htmlspecialchars($idDoc, ENT_QUOTES
) . "&as_file=true' onclick='top.restoreSession()'>" .
1386 htmlspecialchars(xl_document_category($nameDoc), ENT_NOQUOTES
) . "</a> " .
1387 htmlspecialchars($dateDoc, ENT_NOQUOTES
);
1389 $limitCounter = $limitCounter +
1;
1390 $counterFlag = true;
1395 if (!$counterFlag) {
1396 echo " " . htmlspecialchars(xl('None'), ENT_NOQUOTES
);
1400 } // close advanced dir block
1402 // Show Clinical Reminders for any user that has rules that are permitted.
1403 $clin_rem_check = resolve_rules_sql('', '0', true, '', $_SESSION['authUser']);
1404 if (!empty($clin_rem_check) && $GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crw'] &&
1405 acl_check('patients', 'alert')) {
1406 // clinical summary expand collapse widget
1407 $widgetTitle = xl("Clinical Reminders");
1408 $widgetLabel = "clinical_reminders";
1409 $widgetButtonLabel = xl("Edit");
1410 $widgetButtonLink = "../reminder/clinical_reminders.php?patient_id=".$pid;
1412 $widgetButtonClass = "";
1413 $linkMethod = "html";
1414 $bodyClass = "summary_item small";
1415 $widgetAuth = acl_check('patients', 'alert', '', 'write');
1416 $fixedWidth = false;
1417 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel, $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1419 echo "<div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>";
1423 // Show current and upcoming appointments.
1425 // Recurring appointment support and Appointment Display Sets
1426 // added to Appointments by Ian Jardine ( epsdky ).
1428 if (isset($pid) && !$GLOBALS['disable_calendar'] && acl_check('patients', 'appt')) {
1430 $current_date2 = date('Y-m-d');
1432 $apptNum = (int)$GLOBALS['number_of_appts_to_show'];
1433 if ($apptNum != 0) {
1434 $apptNum2 = abs($apptNum);
1440 $mode1 = !$GLOBALS['appt_display_sets_option'];
1441 $colorSet1 = $GLOBALS['appt_display_sets_color_1'];
1442 $colorSet2 = $GLOBALS['appt_display_sets_color_2'];
1443 $colorSet3 = $GLOBALS['appt_display_sets_color_3'];
1444 $colorSet4 = $GLOBALS['appt_display_sets_color_4'];
1452 $events = fetchNextXAppts($current_date2, $pid, $apptNum2 +
$extraAppts, true);
1456 $apptNumber = count($events);
1458 if ($apptNumber <= $apptNum2) {
1459 $extraApptDate = '';
1461 } else if ($mode1 && $apptNumber == $apptNum2 +
1) {
1462 $extraApptDate = $events[$apptNumber - 1]['pc_eventDate'];
1467 } else if ($apptNumber == $apptNum2 +
6) {
1468 $extraApptDate = $events[$apptNumber - 1]['pc_eventDate'];
1473 } else { // mode 2 - $apptNum2 < $apptNumber < $apptNum2 + 6
1474 $extraApptDate = '';
1480 $limitApptIndx = $apptNum2 - 1;
1481 $limitApptDate = $events[$limitApptIndx]['pc_eventDate'];
1483 switch ($selectNum) {
1486 $lastApptIndx = $apptNumber - 1;
1487 $thisNumber = $lastApptIndx - $limitApptIndx;
1488 for ($i = 1; $i <= $thisNumber; ++
$i) {
1489 if ($events[$limitApptIndx +
$i]['pc_eventDate'] != $limitApptDate) {
1490 $extraApptDate = $events[$limitApptIndx +
$i]['pc_eventDate'];
1491 $events = array_slice($events, 0, $limitApptIndx +
$i);
1499 for ($i = 1; $i <= $limitApptIndx; ++
$i) {
1500 if ($events[$limitApptIndx - $i]['pc_eventDate'] != $limitApptDate) {
1501 $firstApptIndx = $apptNum2 - $i;
1510 if ($extraApptDate) {
1511 if ($extraApptDate != $limitApptDate) {
1512 $apptStyle2 = " style='background-color:" . attr($colorSet3) . ";'";
1514 $apptStyle2 = " style='background-color:" . attr($colorSet4) . ";'";
1521 // appointments expand collapse widget
1522 $widgetTitle = xl("Appointments");
1523 $widgetLabel = "appointments";
1524 $widgetButtonLabel = xl("Add");
1525 $widgetButtonLink = "return newEvt();";
1526 $widgetButtonClass = "";
1527 $linkMethod = "javascript";
1528 $bodyClass = "summary_item small";
1529 $widgetAuth = $resNotNull // $resNotNull reflects state of query in fetchAppointments
1530 && (acl_check('patients', 'appt', '', 'write') ||
acl_check('patients', 'appt', '', 'addonly'));
1531 $fixedWidth = false;
1532 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel, $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1537 $therapyGroupCategories = array();
1538 $query = sqlStatement("SELECT pc_catid FROM openemr_postcalendar_categories WHERE pc_cattype = 3 AND pc_active = 1");
1539 while ($result = sqlFetchArray($query)) {
1540 $therapyGroupCategories[] = $result['pc_catid'];
1544 foreach ($events as $row) { //////
1546 $dayname = date("l", strtotime($row['pc_eventDate'])); //////
1548 $disphour = substr($row['pc_startTime'], 0, 2) +
0;
1549 $dispmin = substr($row['pc_startTime'], 3, 2);
1550 if ($disphour >= 12) {
1552 if ($disphour > 12) {
1557 $etitle = xl('(Click to edit)');
1558 if ($row['pc_hometext'] != "") {
1559 $etitle = xl('Comments').": ".($row['pc_hometext'])."\r\n".$etitle;
1563 if ($extraApptDate && $count > $firstApptIndx) {
1564 $apptStyle = $apptStyle2;
1566 if ($row['pc_eventDate'] != $priorDate) {
1567 $priorDate = $row['pc_eventDate'];
1568 $toggleSet = !$toggleSet;
1572 $apptStyle = " style='background-color:" . attr($colorSet2) . ";'";
1574 $apptStyle = " style='background-color:" . attr($colorSet1) . ";'";
1579 echo "<div " . $apptStyle . ">";
1580 if (!in_array($row['pc_catid'], $therapyGroupCategories)) {
1581 echo "<a href='javascript:oldEvt(" . htmlspecialchars(preg_replace("/-/", "", $row['pc_eventDate']), ENT_QUOTES
) . ', ' . htmlspecialchars($row['pc_eid'], ENT_QUOTES
) . ")' title='" . htmlspecialchars($etitle, ENT_QUOTES
) . "'>";
1583 echo "<span title='" . htmlspecialchars($etitle, ENT_QUOTES
) . "'>";
1586 echo "<b>" . htmlspecialchars($row['pc_eventDate'], ENT_NOQUOTES
) . ", ";
1587 echo htmlspecialchars(sprintf("%02d", $disphour) .":$dispmin " . xl($dispampm) . " (" . xl($dayname), ENT_NOQUOTES
) . ")</b> ";
1588 if ($row['pc_recurrtype']) {
1589 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
)."'>";
1592 echo "<span title='" . generate_display_field(array('data_type'=>'1','list_id'=>'apptstat'), $row['pc_apptstatus']) . "'>";
1593 echo "<br>" . xlt('Status') . "( " . htmlspecialchars($row['pc_apptstatus'], ENT_NOQUOTES
) . " ) </span>";
1594 echo htmlspecialchars(xl_appt_category($row['pc_catname']), ENT_NOQUOTES
) . "\n";
1595 if (in_array($row['pc_catid'], $therapyGroupCategories)) {
1596 echo "<br><span>" . xlt('Group name') .": " . text(getGroup($row['pc_gid'])['group_name']) . "</span>\n";
1599 if ($row['pc_hometext']) {
1600 echo " <span style='color:green'> Com</span>";
1603 echo "<br>" . htmlspecialchars($row['ufname'] . " " . $row['ulname'], ENT_NOQUOTES
);
1604 echo !in_array($row['pc_catid'], $therapyGroupCategories) ?
'</a>' : '<span>';
1609 if ($resNotNull) { //////
1611 echo " " . htmlspecialchars(xl('None'), ENT_NOQUOTES
);
1613 if ($extraApptDate) {
1614 echo "<div style='color:#0000cc;'><b>" . attr($extraApptDate) . " ( + ) </b></div>";
1616 echo "<div><hr></div>";
1622 } // End of Appointments.
1625 /* Widget that shows recurrences for appointments. */
1626 if (isset($pid) && !$GLOBALS['disable_calendar'] && $GLOBALS['appt_recurrences_widget'] &&
1627 acl_check('patients', 'appt')) {
1628 $widgetTitle = xl("Recurrent Appointments");
1629 $widgetLabel = "recurrent_appointments";
1630 $widgetButtonLabel = xl("Add");
1631 $widgetButtonLink = "return newEvt();";
1632 $widgetButtonClass = "";
1633 $linkMethod = "javascript";
1634 $bodyClass = "summary_item small";
1635 $widgetAuth = false;
1636 $fixedWidth = false;
1637 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel, $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1642 //Fetch patient's recurrences. Function returns array with recurrence appointments' category, recurrence pattern (interpreted), and end date.
1643 $recurrences = fetchRecurrences($pid);
1644 if ($recurrences[0] == false) { //if there are no recurrent appointments:
1646 echo "<span>" . " " . xlt('None') . "</span>";
1647 echo "</div></div>";
1649 foreach ($recurrences as $row) {
1650 //checks if there are recurrences and if they are current (git didn't end yet)
1651 if ($row == false ||
!recurrence_is_current($row['pc_endDate'])) {
1656 echo "<span>" . xlt('Appointment Category') . ': ' . xlt($row['pc_catname']) . "</span>";
1658 echo "<span>" . xlt('Recurrence') . ': ' . text($row['pc_recurrspec']) . "</span>";
1660 $red_text = ""; //if ends in a week, make font red
1661 if (ends_in_a_week($row['pc_endDate'])) {
1662 $red_text = " style=\"color:red;\" ";
1665 echo "<span" . $red_text . ">" . xlt('End Date') . ': ' . text($row['pc_endDate']) . "</span>";
1673 /* End of recurrence widget */
1675 // Show PAST appointments.
1676 // added by Terry Hill to allow reverse sorting of the appointments
1678 if ($GLOBALS['num_past_appointments_to_show'] < 0) {
1679 $direction = "DESC";
1680 ($showpast = -1 * $GLOBALS['num_past_appointments_to_show']);
1682 $showpast = $GLOBALS['num_past_appointments_to_show'];
1685 if (isset($pid) && !$GLOBALS['disable_calendar'] && $showpast > 0 &&
1686 acl_check('patients', 'appt')) {
1687 $query = "SELECT e.pc_eid, e.pc_aid, e.pc_title, e.pc_eventDate, " .
1688 "e.pc_startTime, e.pc_hometext, u.fname, u.lname, u.mname, " .
1689 "c.pc_catname, e.pc_apptstatus " .
1690 "FROM openemr_postcalendar_events AS e, users AS u, " .
1691 "openemr_postcalendar_categories AS c WHERE " .
1692 "e.pc_pid = ? AND e.pc_eventDate < CURRENT_DATE AND " .
1693 "u.id = e.pc_aid AND e.pc_catid = c.pc_catid " .
1694 "ORDER BY e.pc_eventDate $direction , e.pc_startTime DESC " .
1695 "LIMIT " . $showpast;
1697 $pres = sqlStatement($query, array($pid));
1699 // appointments expand collapse widget
1700 $widgetTitle = xl("Past Appointments");
1701 $widgetLabel = "past_appointments";
1702 $widgetButtonLabel = '';
1703 $widgetButtonLink = '';
1704 $widgetButtonClass = '';
1705 $linkMethod = "javascript";
1706 $bodyClass = "summary_item small";
1707 $widgetAuth = false; //no button
1708 $fixedWidth = false;
1709 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel, $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1711 while ($row = sqlFetchArray($pres)) {
1713 $dayname = date("l", strtotime($row['pc_eventDate']));
1715 $disphour = substr($row['pc_startTime'], 0, 2) +
0;
1716 $dispmin = substr($row['pc_startTime'], 3, 2);
1717 if ($disphour >= 12) {
1719 if ($disphour > 12) {
1724 if ($row['pc_hometext'] != "") {
1725 $etitle = xl('Comments').": ".($row['pc_hometext'])."\r\n".$etitle;
1728 echo "<a href='javascript:oldEvt(" . htmlspecialchars(preg_replace("/-/", "", $row['pc_eventDate']), ENT_QUOTES
) . ', ' . htmlspecialchars($row['pc_eid'], ENT_QUOTES
) . ")' title='" . htmlspecialchars($etitle, ENT_QUOTES
) . "'>";
1729 echo "<b>" . htmlspecialchars(xl($dayname) . ", " . $row['pc_eventDate'], ENT_NOQUOTES
) . "</b>" . xlt("Status") . "(";
1730 echo " " . generate_display_field(array('data_type'=>'1','list_id'=>'apptstat'), $row['pc_apptstatus']) . ")<br>"; // can't use special char parser on this
1731 echo htmlspecialchars("$disphour:$dispmin ") . xl($dispampm) . " ";
1732 echo htmlspecialchars($row['fname'] . " " . $row['lname'], ENT_NOQUOTES
) . "</a><br>\n";
1735 if (isset($pres) && $res != null) {
1737 echo " " . htmlspecialchars(xl('None'), ENT_NOQUOTES
);
1744 // END of past appointments
1748 <div id
='stats_div'>
1750 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1755 <?php
// TRACK ANYTHING -----
1757 // Determine if track_anything form is in use for this site.
1758 $tmp = sqlQuery("SELECT count(*) AS count FROM registry WHERE " .
1759 "directory = 'track_anything' AND state = 1");
1760 $track_is_registered = $tmp['count'];
1761 if ($track_is_registered) {
1763 // track_anything expand collapse widget
1764 $widgetTitle = xl("Tracks");
1765 $widgetLabel = "track_anything";
1766 $widgetButtonLabel = xl("Tracks");
1767 $widgetButtonLink = "../../forms/track_anything/create.php";
1768 $widgetButtonClass = "";
1769 $widgetAuth = ""; // don't show the button
1770 $linkMethod = "html";
1771 $bodyClass = "notab";
1772 // check to see if any tracks exist
1773 $spruch = "SELECT id " .
1777 $existTracks = sqlQuery($spruch, array($pid, "track_anything"));
1779 $fixedWidth = false;
1780 expand_collapse_widget(
1793 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1797 } // end track_anything ?>
1800 </div
> <!-- end right column div
-->
1807 </div
> <!-- end main content div
-->
1809 <script language
='JavaScript'>
1810 // Array of skip conditions for the checkSkipConditions() function.
1812 <?php
echo $condition_str; ?
>
1814 checkSkipConditions();