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 * @author Stephen Waite <stephen.waite@cmsvt.com>
11 * @author Ranganath Pathak <pathak@scrs1.org>
12 * @copyright Copyright (c) 2017-2019 Brady Miller <brady.g.miller@gmail.com>
13 * @copyright Copyright (c) 2017 Sharon Cohen <sharonco@matrix.co.il>
14 * @copyright Copyright (c) 2018-2019 Stephen Waite <stephen.waite@cmsvt.com>
15 * @copyright Copyright (c) 2018 Ranganath Pathak <pathak@scrs1.org>
16 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
20 require_once("../../globals.php");
21 require_once("$srcdir/patient.inc");
22 require_once("$srcdir/acl.inc");
23 require_once("$srcdir/options.inc.php");
24 require_once("../history/history.inc.php");
25 require_once("$srcdir/clinical_rules.php");
26 require_once("$srcdir/options.js.php");
27 require_once("$srcdir/group.inc");
28 require_once(dirname(__FILE__
)."/../../../library/appointments.inc.php");
30 use OpenEMR\Billing\EDI_270
;
31 use OpenEMR\Common\Csrf\CsrfUtils
;
32 use OpenEMR\Core\Header
;
33 use OpenEMR\Menu\PatientMenuRole
;
34 use OpenEMR\Reminder\BirthdayReminder
;
35 use OpenEMR\OeUI\OemrUI
;
36 use OpenEMR\Events\PatientDemographics\ViewEvent
;
38 if (isset($_GET['set_pid'])) {
39 include_once("$srcdir/pid.inc");
40 setpid($_GET['set_pid']);
43 $active_reminders = false;
44 $all_allergy_alerts = false;
45 if ($GLOBALS['enable_cdr']) {
47 if ($GLOBALS['enable_allergy_check'] && $GLOBALS['enable_alert_log']) {
48 //Check for new allergies conflicts and throw popup if any exist(note need alert logging to support this)
49 $new_allergy_alerts = allergy_conflict($pid, 'new', $_SESSION['authUser']);
50 if (!empty($new_allergy_alerts)) {
52 foreach ($new_allergy_alerts as $new_allergy_alert) {
53 $pod_warnings .= js_escape($new_allergy_alert) . ' + "\n"';
55 echo '<script type="text/javascript">alert(' . xlj('WARNING - FOLLOWING ACTIVE MEDICATIONS ARE ALLERGIES') . ' + "\n" + ' . $pod_warnings . ')</script>';
59 if ((!isset($_SESSION['alert_notify_pid']) ||
($_SESSION['alert_notify_pid'] != $pid)) && isset($_GET['set_pid']) && $GLOBALS['enable_cdr_crp']) {
60 // showing a new patient, so check for active reminders and allergy conflicts, which use in active reminder popup
61 $active_reminders = active_alert_summary($pid, "reminders-due", '', 'default', $_SESSION['authUser'], true);
62 if ($GLOBALS['enable_allergy_check']) {
63 $all_allergy_alerts = allergy_conflict($pid, 'all', $_SESSION['authUser'], true);
68 function print_as_money($money)
70 preg_match("/(\d*)\.?(\d*)/", $money, $moneymatches);
71 $tmp = wordwrap(strrev($moneymatches[1]), 3, ",", 1);
72 $ccheck = strrev($tmp);
73 if ($ccheck[0] == ",") {
74 $tmp = substr($ccheck, 1, strlen($ccheck)-1);
77 if ($moneymatches[2] != "") {
78 return "$ " . strrev($tmp) . "." . $moneymatches[2];
80 return "$ " . strrev($tmp);
84 // get an array from Photos category
85 function pic_array($pid, $picture_directory)
88 $sql_query = "select documents.id from documents join categories_to_documents " .
89 "on documents.id = categories_to_documents.document_id " .
90 "join categories on categories.id = categories_to_documents.category_id " .
91 "where categories.name like ? and documents.foreign_id = ?";
92 if ($query = sqlStatement($sql_query, array($picture_directory,$pid))) {
93 while ($results = sqlFetchArray($query)) {
94 array_push($pics, $results['id']);
100 // Get the document ID of the first document in a specific catg.
101 function get_document_by_catg($pid, $doc_catg)
106 if ($pid and $doc_catg) {
107 $result = sqlQuery("SELECT d.id, d.date, d.url FROM " .
108 "documents AS d, categories_to_documents AS cd, categories AS c " .
109 "WHERE d.foreign_id = ? " .
110 "AND cd.document_id = d.id " .
111 "AND c.id = cd.category_id " .
112 "AND c.name LIKE ? " .
113 "ORDER BY d.date DESC LIMIT 1", array($pid, $doc_catg));
116 return($result['id']);
119 // Display image in 'widget style'
120 function image_widget($doc_id, $doc_catg)
122 global $pid, $web_root;
123 $docobj = new Document($doc_id);
124 $image_file = $docobj->get_url_file();
125 $image_width = $GLOBALS['generate_doc_thumb'] == 1 ?
'' : 'width=100';
126 $extension = substr($image_file, strrpos($image_file, "."));
127 $viewable_types = array('.png','.jpg','.jpeg','.png','.bmp','.PNG','.JPG','.JPEG','.PNG','.BMP');
128 if (in_array($extension, $viewable_types)) { // extension matches list
129 $to_url = "<td> <a href = '$web_root" .
130 "/controller.php?document&retrieve&patient_id=" . attr_url($pid) . "&document_id=" . attr_url($doc_id) . "&as_file=false&original_file=true&disable_exit=false&show_original=true'" .
131 " onclick='top.restoreSession();' class='image_modal'>" .
132 " <img src = '$web_root" .
133 "/controller.php?document&retrieve&patient_id=" . attr_url($pid) . "&document_id=" . attr_url($doc_id) . "&as_file=false'" .
134 " $image_width alt='" . attr($doc_catg) . ":" . attr($image_file) . "'> </a> </td> <td valign='center'>" .
135 text($doc_catg) . '<br /> ' . text($image_file) .
138 $to_url = "<td> <a href='" . $web_root . "/controller.php?document&retrieve" .
139 "&patient_id=" . attr_url($pid) . "&document_id=" . attr_url($doc_id) . "'" .
140 " onclick='top.restoreSession()' class='css_button_small'>" .
142 xlt("View") . "</a> " .
143 text("$doc_catg - $image_file") .
149 echo "</tr></table>";
152 // Determine if the Vitals form is in use for this site.
153 $tmp = sqlQuery("SELECT count(*) AS count FROM registry WHERE " .
154 "directory = 'vitals' AND state = 1");
155 $vitals_is_registered = $tmp['count'];
157 // Get patient/employer/insurance information.
159 $result = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
160 $result2 = getEmployerData($pid);
161 $result3 = getInsuranceData($pid, "primary", "copay, provider, DATE_FORMAT(`date`,'%Y-%m-%d') as effdate");
163 if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
164 $insco_name = getInsuranceProvider($result3['provider']);
171 <?php Header
::setupHeader(['common']); ?
>
173 <script type
="text/javascript" language
="JavaScript">
174 function oldEvt(apptdate
, eventid
) {
175 let title
= <?php
echo xlj('Appointments'); ?
>;
176 dlgopen('../../main/calendar/add_edit_event.php?date=' +
encodeURIComponent(apptdate
) +
'&eid=' +
encodeURIComponent(eventid
), '_blank', 725, 500, '', title
);
179 function advdirconfigure() {
180 dlgopen('advancedirectives.php', '_blank', 400, 500);
183 function refreshme() {
184 top
.restoreSession();
188 // Process click on Delete link.
189 function deleteme() { // @todo don't think this is used any longer!!
190 dlgopen('../deleter.php?patient=' +
<?php
echo js_url($pid); ?
> +
'&csrf_token_form=' +
<?php
echo js_url(CsrfUtils
::collectCsrfToken()); ?
>, '_blank', 500, 450, '', '',{
199 // Called by the deleteme.php window on a successful delete.
200 function imdeleted() {
205 let title
= <?php
echo xlj('Appointments'); ?
>;
206 let url
= '../../main/calendar/add_edit_event.php?patientid=' +
<?php
echo js_url($pid); ?
>;
207 dlgopen(url
, '_blank', 725, 500, '', title
);
213 <script type
="text/javascript">
215 function toggleIndicator(target
,div
) {
216 // <i id="show_hide" class="fa fa-lg small fa-eye-slash" title="Click to Hide"></i>
217 $mode = $
(target
).find(".indicator").text();
218 if ( $mode == <?php
echo xlj('collapse'); ?
> ) {
219 $
(target
).find(".indicator").text(<?php
echo xlj('expand'); ?
>);
221 $
.post( "../../../library/ajax/user_settings.php",
225 csrf_token_form
: <?php
echo js_escape(CsrfUtils
::collectCsrfToken()); ?
>
229 $
(target
).find(".indicator").text(<?php
echo xlj('collapse'); ?
>);
231 $
.post( "../../../library/ajax/user_settings.php",
235 csrf_token_form
: <?php
echo js_escape(CsrfUtils
::collectCsrfToken()); ?
>
241 // edit prescriptions dialog.
242 // called from stats.php.
244 function editScripts(url
) {
245 var AddScript
= function () {
248 __this
.find("#clearButton").css("display", "");
249 __this
.find("#backButton").css("display", "");
250 __this
.find("#addButton").css("display", "none");
252 var iam
= top
.frames
.editScripts
;
253 iam
.location
.href
= '<?php echo $GLOBALS['webroot
']?>/controller.php?prescription&edit&id=0&pid=' +
<?php
echo js_url($pid); ?
>;
255 var ListScripts
= function () {
258 __this
.find("#clearButton").css("display", "none");
259 __this
.find("#backButton").css("display", "none");
260 __this
.find("#addButton").css("display", "");
261 var iam
= top
.frames
.editScripts
262 iam
.location
.href
= '<?php echo $GLOBALS['webroot
']?>/controller.php?prescription&list&id=' +
<?php
echo js_url($pid); ?
>;
265 let title
= <?php
echo xlj('Prescriptions'); ?
>;
266 let w
= 910; // for weno width
268 dlgopen(url
, 'editScripts', w
, 300, '', '', {
270 {text
: <?php
echo xlj('Add'); ?
>, close
: false, id
: 'addButton', class: 'btn-primary btn-sm', click
: AddScript
},
271 {text
: <?php
echo xlj('Clear'); ?
>, close
: false,id
: 'clearButton', style
: 'display:none;', class: 'btn-primary btn-sm', click
: AddScript
},
272 {text
: <?php
echo xlj('Back'); ?
>, close
: false, id
: 'backButton', style
: 'display:none;', class: 'btn-primary btn-sm', click
: ListScripts
},
273 {text
: <?php
echo xlj('Done'); ?
>, close
: true, id
: 'doneButton', class: 'btn-default btn-sm'}
275 onClosed
: 'refreshme',
278 dialogId
: 'editscripts',
283 function doPublish() {
284 let title
= <?php
echo xlj('Publish Patient to FHIR Server'); ?
>;
285 let url
= top
.webroot_url +
'/phpfhir/providerPublishUI.php?patient_id=' +
<?php
echo js_url($pid); ?
>;
287 dlgopen(url
, 'publish', 'modal-mlg', 750, '', '', {
289 {text
: <?php
echo xlj('Done'); ?
>, close
: true, style
: 'default btn-sm'}
298 $
(document
).ready(function(){
301 if ($GLOBALS['erx_enable']) {
302 //$soap_status=sqlQuery("select soap_import_status from patient_data where pid=?",array($pid));
303 $soap_status=sqlStatement("select soap_import_status,pid from patient_data where pid=? and soap_import_status in ('1','3')", array($pid));
304 while ($row_soapstatus=sqlFetchArray($soap_status)) {
305 //if($soap_status['soap_import_status']=='1' || $soap_status['soap_import_status']=='3'){ ?>
306 top
.restoreSession();
309 url
: "../../soap_functions/soap_patientfullmedication.php",
312 patient
:<?php
echo js_escape($row_soapstatus['pid']); ?
>,
315 success
: function(thedata
){
317 msg_updation+
=thedata
;
325 //elseif($soap_status['soap_import_status']=='3'){ ?>
326 top
.restoreSession();
329 url
: "../../soap_functions/soap_allergy.php",
332 patient
:<?php
echo js_escape($row_soapstatus['pid']); ?
>,
335 success
: function(thedata
){
337 msg_updation+
=thedata
;
344 if ($GLOBALS['erx_import_status_message']) { ?
>
355 $
("#stats_div").load("stats.php",
357 embeddedScreen
: true,
358 csrf_token_form
: <?php
echo js_escape(CsrfUtils
::collectCsrfToken()); ?
>
362 $
("#pnotes_ps_expand").load("pnotes_fragment.php",
364 csrf_token_form
: <?php
echo js_escape(CsrfUtils
::collectCsrfToken()); ?
>
367 $
("#disclosures_ps_expand").load("disc_fragment.php",
369 csrf_token_form
: <?php
echo js_escape(CsrfUtils
::collectCsrfToken()); ?
>
373 <?php
if ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crw']) { ?
>
374 top
.restoreSession();
375 $
("#clinical_reminders_ps_expand").load("clinical_reminders_fragment.php",
377 embeddedScreen
: true,
378 csrf_token_form
: <?php
echo js_escape(CsrfUtils
::collectCsrfToken()); ?
>
381 // (note need to place javascript code here also to get the dynamic link to work)
382 $
(".medium_modal").on('click', function(e
) {
383 e
.preventDefault();e
.stopPropagation();
384 dlgopen('', '', 800, 200, '', '', {
386 {text
: <?php
echo xlj('Close'); ?
>, close
: true, style
: 'default btn-sm'}
388 onClosed
: 'refreshme',
391 dialogId
: 'demreminder',
393 url
: $
(this
).attr('href')
399 <?php
if ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_prw']) { ?
>
400 top
.restoreSession();
401 $
("#patient_reminders_ps_expand").load("patient_reminders_fragment.php",
403 csrf_token_form
: <?php
echo js_escape(CsrfUtils
::collectCsrfToken()); ?
>
408 <?php
if ($vitals_is_registered && acl_check('patients', 'med')) { ?
>
409 // Initialize the Vitals form if it is registered and user is authorized.
410 $
("#vitals_ps_expand").load("vitals_fragment.php",
412 csrf_token_form
: <?php
echo js_escape(CsrfUtils
::collectCsrfToken()); ?
>
417 // Initialize track_anything
418 $
("#track_anything_ps_expand").load("track_anything_fragment.php",
420 csrf_token_form
: <?php
echo js_escape(CsrfUtils
::collectCsrfToken()); ?
>
425 // Initialize labdata
426 $
("#labdata_ps_expand").load("labdata_fragment.php",
428 csrf_token_form
: <?php
echo js_escape(CsrfUtils
::collectCsrfToken()); ?
>
432 // Initialize for each applicable LBF form.
433 $gfres = sqlStatement("SELECT grp_form_id FROM layout_group_properties WHERE " .
434 "grp_form_id LIKE 'LBF%' AND grp_group_id = '' AND grp_repeats > 0 AND grp_activity = 1 " .
435 "ORDER BY grp_seq, grp_title");
436 while ($gfrow = sqlFetchArray($gfres)) {
438 $
(<?php
echo js_escape("#".$gfrow['grp_form_id']."_ps_expand"); ?
>).load("lbf_fragment.php?formname=" +
<?php
echo js_url($gfrow['grp_form_id']); ?
>,
440 csrf_token_form
: <?php
echo js_escape(CsrfUtils
::collectCsrfToken()); ?
>
448 // modal for dialog boxes
449 $
(".large_modal").on('click', function(e
) {
450 e
.preventDefault();e
.stopPropagation();
451 dlgopen('', '', 1000, 600, '', '', {
453 {text
: <?php
echo xlj('Close'); ?
>, close
: true, style
: 'default btn-sm'}
459 url
: $
(this
).attr('href')
463 $
(".rx_modal").on('click', function(e
) {
464 e
.preventDefault();e
.stopPropagation();
465 var AddAmendment
= function () {
466 var iam
= top
.frames
.editAmendments
;
467 iam
.location
.href
= "<?php echo $GLOBALS['webroot']?>/interface/patient_file/summary/add_edit_amendments.php"
469 var ListAmendments
= function () {
470 var iam
= top
.frames
.editAmendments
;
471 iam
.location
.href
= "<?php echo $GLOBALS['webroot']?>/interface/patient_file/summary/list_amendments.php"
473 var title
= <?php
echo xlj('Amendments'); ?
>;
474 dlgopen('', 'editAmendments', 800, 300, '', title
, {
476 {text
: <?php
echo xlj('Add'); ?
>, close
: false, style
: 'primary btn-sm', click
: AddAmendment
},
477 {text
: <?php
echo xlj('List'); ?
>, close
: false, style
: 'primary btn-sm', click
: ListAmendments
},
478 {text
: <?php
echo xlj('Done'); ?
>, close
: true, style
: 'default btn-sm'}
480 onClosed
: 'refreshme',
485 url
: $
(this
).attr('href')
489 // modal for image viewer
490 $
(".image_modal").on('click', function(e
) {
491 e
.preventDefault();e
.stopPropagation();
492 dlgopen('', '', 400, 300, '', <?php
echo xlj('Patient Images'); ?
>, {
497 url
: $
(this
).attr('href')
501 $
(".deleter").on('click', function(e
) {
502 e
.preventDefault();e
.stopPropagation();
503 dlgopen('', '', 600, 360, '', '', {
505 {text
: <?php
echo xlj('Close'); ?
>, close
: true, style
: 'default btn-sm'}
507 //onClosed: 'imdeleted',
512 url
: $
(this
).attr('href')
516 $
(".iframe1").on('click', function(e
) {
517 e
.preventDefault();e
.stopPropagation();
518 dlgopen('', '', 350, 300, '', '', {
520 {text
: <?php
echo xlj('Close'); ?
>, close
: true, style
: 'default btn-sm'}
526 url
: $
(this
).attr('href')
529 // for patient portal
530 $
(".small_modal").on('click', function(e
) {
531 e
.preventDefault();e
.stopPropagation();
532 dlgopen('', '', 380, 200, '', '', {
534 {text
: <?php
echo xlj('Close'); ?
>, close
: true, style
: 'default btn-sm'}
540 url
: $
(this
).attr('href')
544 function openReminderPopup() {
546 dlgopen('', 'reminders', 500, 250, '', '', {
548 {text
: <?php
echo xlj('Close'); ?
>, close
: true, style
: 'default btn-sm'}
554 url
: $
("#reminder_popup_link").attr('href')
559 <?php
if ($GLOBALS['patient_birthday_alert']) {
560 // To display the birthday alert:
561 // 1. The patient is not deceased
562 // 2. The birthday is today (or in the past depending on global selection)
563 // 3. The notification has not been turned off (or shown depending on global selection) for this year
564 $birthdayAlert = new BirthdayReminder($pid, $_SESSION['authId']);
565 if ($birthdayAlert->isDisplayBirthdayAlert()) {
567 // show the active reminder modal
568 dlgopen('', 'bdayreminder', 300, 170, '', false, {
573 url
: $
("#birthday_popup").attr('href')
576 <?php
} elseif ($active_reminders ||
$all_allergy_alerts) { ?
>
579 <?php
} elseif ($active_reminders ||
$all_allergy_alerts) { ?
>
585 // JavaScript stuff to do when a new patient is set.
587 function setMyPatient() {
589 if (isset($_GET['set_pid'])) {
590 $date_of_death = is_patient_deceased($pid)['date_deceased']; ?
>
591 parent
.left_nav
.setPatient(<?php
echo js_escape($result['fname'] . " " . $result['lname']) .
592 "," . js_escape($pid) . "," . js_escape($result['pubpid']) . ",'',";
593 if (empty($date_of_death)) {
594 echo js_escape(" " . xl('DOB') . ": " . oeFormatShortDate($result['DOB_YMD']) . " " . xl('Age') . ": " . getPatientAgeDisplay($result['DOB_YMD']));
596 echo js_escape(" " . xl('DOB') . ": " . oeFormatShortDate($result['DOB_YMD']) . " " . xl('Age at death') . ": " . oeFormatAge($result['DOB_YMD'], $date_of_death));
598 var EncounterDateArray
= new Array;
599 var CalendarCategoryArray
= new Array;
600 var EncounterIdArray
= new Array;
603 //Encounter details are stored to javacript as array.
604 $result4 = sqlStatement("SELECT fe.encounter,fe.date,openemr_postcalendar_categories.pc_catname FROM form_encounter AS fe ".
605 " left join openemr_postcalendar_categories on fe.pc_catid=openemr_postcalendar_categories.pc_catid WHERE fe.pid = ? order by fe.date desc", array($pid));
606 if (sqlNumRows($result4)>0) {
607 while ($rowresult4 = sqlFetchArray($result4)) {?
>
608 EncounterIdArray
[Count
] = <?php
echo js_escape($rowresult4['encounter']); ?
>;
609 EncounterDateArray
[Count
] = <?php
echo js_escape(oeFormatShortDate(date("Y-m-d", strtotime($rowresult4['date'])))); ?
>;
610 CalendarCategoryArray
[Count
] = <?php
echo js_escape(xl_appt_category($rowresult4['pc_catname'])); ?
>;
616 parent
.left_nav
.setPatientEncounter(EncounterIdArray
,EncounterDateArray
,CalendarCategoryArray
);
618 } // end setting new pid ?>
619 parent
.left_nav
.syncRadios();
620 <?php
if ((isset($_GET['set_pid']) ) && (isset($_GET['set_encounterid'])) && ( intval($_GET['set_encounterid']) > 0 )) {
621 $encounter = intval($_GET['set_encounterid']);
622 $_SESSION['encounter'] = $encounter;
623 $query_result = sqlQuery("SELECT `date` FROM `form_encounter` WHERE `encounter` = ?", array($encounter)); ?
>
624 encurl
= 'encounter/encounter_top.php?set_encounter=' +
<?php
echo js_url($encounter);?
> +
'&pid=' +
<?php
echo js_url($pid);?
>;
625 parent
.left_nav
.setEncounter(<?php
echo js_escape(oeFormatShortDate(date("Y-m-d", strtotime($query_result['date'])))); ?
>, <?php
echo js_escape($encounter); ?
>, 'enc');
626 top
.restoreSession();
627 parent
.left_nav
.loadFrame('enc2', 'enc', 'patient_file/' + encurl
);
628 <?php
} // end setting new encounter id (only if new pid is also set) ?>
631 $
(window
).on('load', function() {
637 <style type
="css/text">
645 // This is for layout font size override.
647 getLayoutProperties('DEM', $grparr, 'grp_size');
648 if (!empty($grparr['']['grp_size'])) {
649 $FONTSIZE = $grparr['']['grp_size'];
651 /* Override font sizes in the theme. */
653 font
-size
: <?php
echo attr($FONTSIZE); ?
>pt
;
656 font
-size
: <?php
echo attr($FONTSIZE); ?
>pt
;
659 font
-size
: <?php
echo attr($FONTSIZE); ?
>pt
;
662 font
-size
: <?php
echo attr($FONTSIZE); ?
>pt
;
667 <title
><?php
echo xlt("Dashboard{{patient file}}"); ?
></title
>
670 $arrOeUiSettings = array(
671 'heading_title' => xl('Medical Record Dashboard'),
672 'include_patient_name' => true,
673 'expandable' => false,
674 'expandable_files' => array(),//all file names need suffix _xpd
675 'action' => "",//conceal, reveal, search, reset, link or back
676 'action_title' => "",
677 'action_href' => "",//only for actions - reset, link or back
678 'show_help_icon' => true,
679 'help_file_name' => "medical_dashboard_help.php"
681 $oemr_ui = new OemrUI($arrOeUiSettings);
685 <body
class="body_top patient-demographics">
686 <div id
="container_div" class="<?php echo $oemr_ui->oeContainer();?>">
687 <a href
='../reminder/active_reminder_popup.php' id
='reminder_popup_link' style
='display: none;' onclick
='top.restoreSession()'></a
>
689 <a href
='../birthday_alert/birthday_pop.php?pid=<?php echo attr_url($pid); ?>&user_id=<?php echo attr_url($_SESSION['authId
']); ?>' id
='birthday_popup' style
='display: none;' onclick
='top.restoreSession()'></a
>
692 $thisauth = acl_check('patients', 'demo');
694 if ($result['squad'] && ! acl_check('squads', $result['squad'])) {
699 // Create and fire the patient demographics view event
700 $viewEvent = new ViewEvent($pid);
701 $viewEvent = $GLOBALS["kernel"]->getEventDispatcher()->dispatch(ViewEvent
::EVENT_HANDLE
, $viewEvent, 10);
704 !$viewEvent->authorized()) {
705 echo "<p>(" . xlt('Demographics not authorized') . ")</p>\n";
706 echo "</body>\n</html>\n";
713 <div
class="col-sm-12">
714 <?php
require_once("$include_root/patient_file/summary/dashboard_header.php"); ?
>
722 <div
class="col-sm-12">
724 $list_id = "dashboard"; // to indicate nav item is active, count and give correct id
725 // Collect the patient menu then build it
726 $menuPatient = new PatientMenuRole();
727 $menuPatient->displayHorizNavBarMenu();
728 // Get the document ID of the patient ID card if access to it is wanted here.
729 $idcard_doc_id = false;
730 if ($GLOBALS['patient_id_category_name']) {
731 $idcard_doc_id = get_document_by_catg($pid, $GLOBALS['patient_id_category_name']);
737 <div style
='margin-top:10px' class="main"> <!-- start main content div
-->
738 <table border
="0" cellspacing
="0" cellpadding
="0" width
="100%">
740 <td
class="demographics-box" align
="left" valign
="top">
741 <!-- start left column div
-->
742 <div style
='float:left; margin-right:20px'>
744 <table cellspacing
=0 cellpadding
=0>
746 if (!$GLOBALS['hide_billing_widget']) { ?
>
750 // Billing expand collapse widget
751 $widgetTitle = xl("Billing");
752 $widgetLabel = "billing";
753 $widgetButtonLabel = xl("Edit");
754 $widgetButtonLink = "return newEvt();";
755 $widgetButtonClass = "";
756 $linkMethod = "javascript";
757 $bodyClass = "notab";
760 if ($GLOBALS['force_billing_widget_open']) {
761 $forceExpandAlways = true;
763 $forceExpandAlways = false;
766 expand_collapse_widget(
781 //PATIENT BALANCE,INS BALANCE naina@capminds.com
782 $patientbalance = get_patient_balance($pid, false);
783 //Debit the patient balance from insurance balance
784 $insurancebalance = get_patient_balance($pid, true) - $patientbalance;
785 $totalbalance=$patientbalance +
$insurancebalance;
787 // Show current balance and billing note, if any.
788 echo "<table border='0'><tr><td>" .
789 "<table ><tr><td><span class='bold'><font color='red'>" .
790 xlt('Patient Balance Due') .
791 " : " . text(oeFormatMoney($patientbalance)) .
792 "</font></span></td></tr>".
793 "<tr><td><span class='bold'><font color='red'>" .
794 xlt('Insurance Balance Due') .
795 " : " . text(oeFormatMoney($insurancebalance)) .
796 "</font></span></td></tr>".
797 "<tr><td><span class='bold'><font color='red'>" .
798 xlt('Total Balance Due').
799 " : " . text(oeFormatMoney($totalbalance)) .
800 "</font></span></td></td></tr>";
801 if (!empty($result['billing_note'])) {
802 echo "<tr><td><span class='bold'><font color='red'>" .
803 xlt('Billing Note') . ":" .
804 text($result['billing_note']) .
805 "</font></span></td></tr>";
808 if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
809 echo "<tr><td><span class='bold'>" .
810 xlt('Primary Insurance') . ': ' . text($insco_name) .
811 "</span> ";
812 if ($result3['copay'] > 0) {
813 echo "<span class='bold'>" .
814 xlt('Copay') . ': ' . text($result3['copay']) .
815 "</span> ";
817 echo "<span class='bold'>" .
818 xlt('Effective Date') . ': ' . text(oeFormatShortDate($result3['effdate'])) .
822 echo "</table></td></tr></td></tr></table><br>";
825 </div
> <!-- required
for expand_collapse_widget
-->
830 <?php
if (acl_check('patients', 'demo')) { ?
>
834 // Demographics expand collapse widget
835 $widgetTitle = xl("Demographics");
836 $widgetLabel = "demographics";
837 $widgetButtonLabel = xl("Edit");
838 $widgetButtonLink = "demographics_full.php";
839 $widgetButtonClass = "";
840 $linkMethod = "html";
842 $widgetAuth = acl_check('patients', 'demo', '', 'write');
844 expand_collapse_widget(
858 <?php
display_layout_tabs('DEM', $result, $result2); ?
>
860 <div
class="tabContainer">
861 <?php
display_layout_tabs_data('DEM', $result, $result2); ?
>
864 <!--</div
> required
for expand_collapse_widget
-->
871 $insurance_count = 0;
872 foreach (array('primary','secondary','tertiary') as $instype) {
873 $enddate = 'Present';
874 $query = "SELECT * FROM insurance_data WHERE " .
875 "pid = ? AND type = ? " .
876 "ORDER BY date DESC";
877 $res = sqlStatement($query, array($pid, $instype));
878 while ($row = sqlFetchArray($res)) {
879 if ($row['provider']) {
885 if ($insurance_count > 0) {
886 // Insurance expand collapse widget
887 $widgetTitle = xl("Insurance");
888 $widgetLabel = "insurance";
889 $widgetButtonLabel = xl("Edit");
890 $widgetButtonLink = "demographics_full.php";
891 $widgetButtonClass = "";
892 $linkMethod = "html";
894 $widgetAuth = acl_check('patients', 'demo', '', 'write');
896 expand_collapse_widget(
908 if ($insurance_count > 0) {
911 <ul
class="tabNav"><?php
912 ///////////////////////////////// INSURANCE SECTION
914 foreach (array('primary','secondary','tertiary') as $instype) {
915 $query = "SELECT * FROM insurance_data WHERE " .
916 "pid = ? AND type = ? " .
917 "ORDER BY date DESC";
918 $res = sqlStatement($query, array($pid, $instype));
920 $enddate = 'Present';
922 while ($row = sqlFetchArray($res)) {
923 if ($row['provider']) {
924 $ins_description = ucfirst($instype);
925 $ins_description = xl($ins_description);
926 $ins_description .= strcmp($enddate, 'Present') != 0 ?
" (".xl('Old').")" : "";
928 <li
<?php
echo $first ?
'class="current"' : '' ?
>><a href
="#">
929 <?php
echo text($ins_description); ?
></a
></li
>
934 $enddate = $row['date'];
938 // Display the eligibility tab
939 echo "<li><a id='eligibility' href='#'>" . xlt('Eligibility') . "</a></li>";
944 <div
class="tabContainer">
947 foreach (array('primary','secondary','tertiary') as $instype) {
948 $enddate = 'Present';
950 $query = "SELECT * FROM insurance_data WHERE " .
951 "pid = ? AND type = ? " .
952 "ORDER BY date DESC";
953 $res = sqlStatement($query, array($pid, $instype));
954 while ($row = sqlFetchArray($res)) {
955 if ($row['provider']) {
957 <div
class="tab <?php echo $first ? 'current' : '' ?>">
958 <table border
='0' cellpadding
='0' width
='100%'>
960 $icobj = new InsuranceCompany($row['provider']);
961 $adobj = $icobj->get_address();
962 $insco_name = trim($icobj->get_name());
965 <td valign
='top' colspan
='3'>
968 if (strcmp($enddate, 'Present') != 0) {
969 echo xlt("Old") . " ";
972 <?php
$tempinstype=ucfirst($instype);
973 echo xlt($tempinstype.' Insurance'); ?
>
974 <?php
if (strcmp($row['date'], '0000-00-00') != 0) { ?
>
975 <?php
echo ' ' . xlt('from') . ' ' . $row['date']; ?
>
977 <?php
echo ' ' . xlt('until') . ' ';
978 echo (strcmp($enddate, 'Present') != 0) ?
text($enddate) : xlt('Present'); ?
>:</span
>
986 echo text($insco_name) . '<br>';
987 if (trim($adobj->get_line1())) {
988 echo text($adobj->get_line1()) . '<br>';
989 echo text($adobj->get_city() . ', ' . $adobj->get_state() . ' ' . $adobj->get_zip());
992 echo "<font color='red'><b>" . xlt('Unassigned') . "</b></font>";
996 <?php
echo xlt('Policy Number'); ?
>: <?php
echo text($row['policy_number']) ?
><br
>
997 <?php
echo xlt('Plan Name'); ?
>: <?php
echo text($row['plan_name']); ?
><br
>
998 <?php
echo xlt('Group Number'); ?
>: <?php
echo text($row['group_number']); ?
>
1002 <span
class='bold'><?php
echo xlt('Subscriber'); ?
>: </span
><br
>
1003 <span
class='text'><?php
echo text($row['subscriber_fname'] . ' ' . $row['subscriber_mname'] . ' ' . $row['subscriber_lname']); ?
>
1005 if ($row['subscriber_relationship'] != "") {
1006 echo "(" . text($row['subscriber_relationship']) . ")";
1010 <?php
echo xlt('S.S.'); ?
>:
1011 <?php
echo text($row['subscriber_ss']); ?
><br
>
1012 <?php
echo xlt('D.O.B.'); ?
>:
1014 if ($row['subscriber_DOB'] != "0000-00-00 00:00:00") {
1015 echo text($row['subscriber_DOB']);
1018 <?php
echo xlt('Phone'); ?
>:
1019 <?php
echo text($row['subscriber_phone']); ?
>
1023 <span
class='bold'><?php
echo xlt('Subscriber Address'); ?
>: </span
><br
>
1024 <span
class='text'><?php
echo text($row['subscriber_street']); ?
><br
>
1025 <?php
echo text($row['subscriber_city']); ?
>
1027 if ($row['subscriber_state'] != "") {
1031 echo text($row['subscriber_state']); ?
>
1033 if ($row['subscriber_country'] != "") {
1037 echo text($row['subscriber_country']); ?
>
1038 <?php
echo " " . text($row['subscriber_postal_code']); ?
></span
>
1040 <?php
if (trim($row['subscriber_employer'])) { ?
>
1041 <br
><span
class='bold'><?php
echo xlt('Subscriber Employer'); ?
>: </span
><br
>
1042 <span
class='text'><?php
echo text($row['subscriber_employer']); ?
><br
>
1043 <?php
echo text($row['subscriber_employer_street']); ?
><br
>
1044 <?php
echo text($row['subscriber_employer_city']); ?
>
1046 if ($row['subscriber_employer_city'] != "") {
1050 echo text($row['subscriber_employer_state']); ?
>
1052 if ($row['subscriber_employer_country'] != "") {
1056 echo text($row['subscriber_employer_country']); ?
>
1057 <?php
echo " " . text($row['subscriber_employer_postal_code']); ?
>
1065 <?php
if ($row['copay'] != "") { ?
>
1066 <span
class='bold'><?php
echo xlt('CoPay'); ?
>: </span
>
1067 <span
class='text'><?php
echo text($row['copay']); ?
></span
>
1070 <span
class='bold'><?php
echo xlt('Accept Assignment'); ?
>:</span
>
1073 if ($row['accept_assignment'] == "TRUE") {
1076 if ($row['accept_assignment'] == "FALSE") {
1081 <?php
if (!empty($row['policy_type'])) { ?
>
1083 <span
class='bold'><?php
echo xlt('Secondary Medicare Type'); ?
>: </span
>
1084 <span
class='text'><?php
echo text($policy_types[$row['policy_type']]); ?
></span
>
1087 <td valign
='top'></td
>
1088 <td valign
='top'></td
>
1094 } // end if ($row['provider'])
1095 $enddate = $row['date'];
1100 // Display the eligibility information
1101 echo "<div class='tab'>\n" .
1102 "<div class='tab-content pre-scrollable' style='width:695px;overflow-x: hidden;'>\n";
1104 if ($GLOBALS['enable_oa']) {
1105 echo "<form method='post' action='./demographics.php'>\n";
1106 echo "<div class='col col-sm-12'>";
1107 echo "<button class='btn btn-success btn-xs btn-transmit pull-right' name='status_update' value='true'>" .
1108 xlt("Update Status") . "</button>";
1109 echo "</div><br>\n";
1110 if ($_POST['status_update'] === 'true') {
1111 unset($_POST['status_update']);
1112 $showEligibility = true;
1113 $ok = EDI_270
::requestEligibleTransaction($pid);
1115 EDI_270
::show_eligibility_information($pid, false);
1120 EDI_270
::show_eligibility_information($pid, true);
1124 EDI_270
::show_eligibility_information($pid, true);
1126 echo "</div></div>";
1128 ///////////////////////////////// END INSURANCE SECTION
1136 <?php
} // end if demographics authorized ?>
1138 <?php
if (acl_check('patients', 'notes')) { ?
>
1142 // Notes expand collapse widget
1143 $widgetTitle = xl("Messages");
1144 $widgetLabel = "pnotes";
1145 $widgetButtonLabel = xl("Edit");
1146 $widgetButtonLink = "pnotes_full.php?form_active=1";
1147 $widgetButtonClass = "";
1148 $linkMethod = "html";
1149 $bodyClass = "notab";
1150 $widgetAuth = acl_check('patients', 'notes', '', 'write');
1152 expand_collapse_widget(
1165 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1169 <?php
} // end if notes authorized ?>
1171 <?php
if (acl_check('patients', 'reminder') && $GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_prw']) {
1172 echo "<tr><td width='650px'>";
1173 // patient reminders collapse widget
1174 $widgetTitle = xl("Patient Reminders");
1175 $widgetLabel = "patient_reminders";
1176 $widgetButtonLabel = xl("Edit");
1177 $widgetButtonLink = "../reminder/patient_reminders.php?mode=simple&patient_id=" . attr_url($pid);
1178 $widgetButtonClass = "";
1179 $linkMethod = "html";
1180 $bodyClass = "notab";
1181 $widgetAuth = acl_check('patients', 'reminder', '', 'write');
1183 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel, $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth); ?
>
1185 <div style
='margin-left:10px' class='text'><image src
='../../pic/ajax-loader.gif'/></div
><br
/>
1189 <?php
} //end if prw is activated ?>
1191 <?php
if (acl_check('patients', 'disclosure')) { ?
>
1195 // disclosures expand collapse widget
1196 $widgetTitle = xl("Disclosures");
1197 $widgetLabel = "disclosures";
1198 $widgetButtonLabel = xl("Edit");
1199 $widgetButtonLink = "disclosure_full.php";
1200 $widgetButtonClass = "";
1201 $linkMethod = "html";
1202 $bodyClass = "notab";
1203 $widgetAuth = acl_check('patients', 'disclosure', '', 'write');
1205 expand_collapse_widget(
1218 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1222 <?php
} // end if disclosures authorized ?>
1224 <?php
if ($GLOBALS['amendments'] && acl_check('patients', 'amendment')) { ?
>
1227 <?php
// Amendments widget
1228 $widgetTitle = xlt('Amendments');
1229 $widgetLabel = "amendments";
1230 $widgetButtonLabel = xlt("Edit");
1231 $widgetButtonLink = $GLOBALS['webroot'] . "/interface/patient_file/summary/list_amendments.php?id=" . attr_url($pid);
1232 $widgetButtonClass = "rx_modal";
1233 $linkMethod = "html";
1234 $bodyClass = "summary_item small";
1235 $widgetAuth = acl_check('patients', 'amendment', '', 'write');
1236 $fixedWidth = false;
1237 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel, $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1238 $sql = "SELECT * FROM amendments WHERE pid = ? ORDER BY amendment_date DESC";
1239 $result = sqlStatement($sql, array($pid));
1241 if (sqlNumRows($result) == 0) {
1242 echo " <table><tr>\n";
1243 echo " <td colspan='" . attr($numcols) . "' class='text'> " . xlt('None{{Amendment}}') . "</td>\n";
1244 echo " </tr></table>\n";
1247 while ($row=sqlFetchArray($result)) {
1248 echo " ";
1249 echo "<a class= '" . attr($widgetButtonClass) . "' href='" . $GLOBALS['webroot'] . "/interface/patient_file/summary/add_edit_amendments.php?id=" . attr_url($row['amendment_id']) . "' onclick='top.restoreSession()'>" . text($row['amendment_date']);
1250 echo " " . text($row['amendment_desc']);
1256 <?php
} // end amendments authorized ?>
1258 <?php
if (acl_check('patients', 'lab')) { ?
>
1261 <?php
// labdata expand collapse widget
1262 $widgetTitle = xl("Labs");
1263 $widgetLabel = "labdata";
1264 $widgetButtonLabel = xl("Trend");
1265 $widgetButtonLink = "../summary/labdata.php";#"../encounter/trend_form.php?formname=labdata";
1266 $widgetButtonClass = "";
1267 $linkMethod = "html";
1268 $bodyClass = "notab";
1269 // check to see if any labdata exist
1270 $spruch = "SELECT procedure_report.date_collected AS date " .
1271 "FROM procedure_report " .
1272 "JOIN procedure_order ON procedure_report.procedure_order_id = procedure_order.procedure_order_id " .
1273 "WHERE procedure_order.patient_id = ? " .
1274 "ORDER BY procedure_report.date_collected DESC ";
1275 $existLabdata = sqlQuery($spruch, array($pid));
1276 if ($existLabdata) {
1279 $widgetAuth = false;
1283 expand_collapse_widget(
1296 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1300 <?php
} // end labs authorized ?>
1302 <?php
if ($vitals_is_registered && acl_check('patients', 'med')) { ?
>
1305 <?php
// vitals expand collapse widget
1306 $widgetTitle = xl("Vitals");
1307 $widgetLabel = "vitals";
1308 $widgetButtonLabel = xl("Trend");
1309 $widgetButtonLink = "../encounter/trend_form.php?formname=vitals";
1310 $widgetButtonClass = "";
1311 $linkMethod = "html";
1312 $bodyClass = "notab";
1313 // check to see if any vitals exist
1314 $existVitals = sqlQuery("SELECT * FROM form_vitals WHERE pid=?", array($pid));
1318 $widgetAuth = false;
1322 expand_collapse_widget(
1335 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1339 <?php
} // end if ($vitals_is_registered && acl_check('patients', 'med')) ?>
1342 // This generates a section similar to Vitals for each LBF form that
1343 // supports charting. The form ID is used as the "widget label".
1345 $gfres = sqlStatement("SELECT grp_form_id AS option_id, grp_title AS title, grp_aco_spec " .
1346 "FROM layout_group_properties WHERE " .
1347 "grp_form_id LIKE 'LBF%' AND grp_group_id = '' AND grp_repeats > 0 AND grp_activity = 1 " .
1348 "ORDER BY grp_seq, grp_title");
1349 while ($gfrow = sqlFetchArray($gfres)) {
1350 // $jobj = json_decode($gfrow['notes'], true);
1351 $LBF_ACO = empty($gfrow['grp_aco_spec']) ?
false : explode('|', $gfrow['grp_aco_spec']);
1352 if ($LBF_ACO && !acl_check($LBF_ACO[0], $LBF_ACO[1])) {
1357 <?php
// vitals expand collapse widget
1358 $vitals_form_id = $gfrow['option_id'];
1359 $widgetTitle = $gfrow['title'];
1360 $widgetLabel = $vitals_form_id;
1361 $widgetButtonLabel = xl("Trend");
1362 $widgetButtonLink = "../encounter/trend_form.php?formname=" . attr_url($vitals_form_id);
1363 $widgetButtonClass = "";
1364 $linkMethod = "html";
1365 $bodyClass = "notab";
1366 $widgetAuth = false;
1367 if (!$LBF_ACO ||
acl_check($LBF_ACO[0], $LBF_ACO[1], '', 'write')) {
1368 // check to see if any instances exist for this patient
1369 $existVitals = sqlQuery(
1370 "SELECT * FROM forms WHERE pid = ? AND formdir = ? AND deleted = 0",
1371 array($pid, $vitals_form_id)
1373 $widgetAuth = $existVitals;
1377 expand_collapse_widget(
1389 <div style
='margin-left:10px' class='text'>
1390 <image src
='../../pic/ajax-loader.gif'/>
1393 </div
> <!-- This is required by
expand_collapse_widget(). -->
1403 <!-- end left column div
-->
1405 <!-- start right column div
-->
1414 // If there is an ID Card or any Photos show the widget
1415 $photos = pic_array($pid, $GLOBALS['patient_photo_category_name']);
1416 if ($photos or $idcard_doc_id) {
1417 $widgetTitle = xl("ID Card") . '/' . xl("Photos");
1418 $widgetLabel = "photos";
1419 $linkMethod = "javascript";
1420 $bodyClass = "notab-right";
1421 $widgetAuth = false;
1422 $fixedWidth = false;
1423 expand_collapse_widget(
1437 if ($idcard_doc_id) {
1438 image_widget($idcard_doc_id, $GLOBALS['patient_id_category_name']);
1441 foreach ($photos as $photo_doc_id) {
1442 image_widget($photo_doc_id, $GLOBALS['patient_photo_category_name']);
1451 // Advance Directives
1452 if ($GLOBALS['advance_directives_warning']) {
1453 // advance directives expand collapse widget
1454 $widgetTitle = xl("Advance Directives");
1455 $widgetLabel = "directives";
1456 $widgetButtonLabel = xl("Edit");
1457 $widgetButtonLink = "return advdirconfigure();";
1458 $widgetButtonClass = "";
1459 $linkMethod = "javascript";
1460 $bodyClass = "summary_item small";
1462 $fixedWidth = false;
1463 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel, $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1464 $counterFlag = false; //flag to record whether any categories contain ad records
1465 $query = "SELECT id FROM categories WHERE name='Advance Directive'";
1466 $myrow2 = sqlQuery($query);
1468 $parentId = $myrow2['id'];
1469 $query = "SELECT id, name FROM categories WHERE parent=?";
1470 $resNew1 = sqlStatement($query, array($parentId));
1471 while ($myrows3 = sqlFetchArray($resNew1)) {
1472 $categoryId = $myrows3['id'];
1473 $nameDoc = $myrows3['name'];
1474 $query = "SELECT documents.date, documents.id " .
1476 "INNER JOIN categories_to_documents " .
1477 "ON categories_to_documents.document_id=documents.id " .
1478 "WHERE categories_to_documents.category_id=? " .
1479 "AND documents.foreign_id=? " .
1480 "ORDER BY documents.date DESC";
1481 $resNew2 = sqlStatement($query, array($categoryId, $pid));
1482 $limitCounter = 0; // limit to one entry per category
1483 while (($myrows4 = sqlFetchArray($resNew2)) && ($limitCounter == 0)) {
1484 $dateTimeDoc = $myrows4['date'];
1485 // remove time from datetime stamp
1486 $tempParse = explode(" ", $dateTimeDoc);
1487 $dateDoc = $tempParse[0];
1488 $idDoc = $myrows4['id'];
1489 echo "<a href='$web_root/controller.php?document&retrieve&patient_id=" .
1490 attr_url($pid) . "&document_id=" .
1491 attr_url($idDoc) . "&as_file=true' onclick='top.restoreSession()'>" .
1492 text(xl_document_category($nameDoc)) . "</a> " .
1495 $limitCounter = $limitCounter +
1;
1496 $counterFlag = true;
1501 if (!$counterFlag) {
1502 echo " " . xlt('None{{Advanced_Directives}}');
1506 } // close advanced dir block
1508 // Show Clinical Reminders for any user that has rules that are permitted.
1509 $clin_rem_check = resolve_rules_sql('', '0', true, '', $_SESSION['authUser']);
1510 if (!empty($clin_rem_check) && $GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crw'] &&
1511 acl_check('patients', 'alert')) {
1512 // clinical summary expand collapse widget
1513 $widgetTitle = xl("Clinical Reminders");
1514 $widgetLabel = "clinical_reminders";
1515 $widgetButtonLabel = xl("Edit");
1516 $widgetButtonLink = "../reminder/clinical_reminders.php?patient_id=" . attr_url($pid);
1518 $widgetButtonClass = "";
1519 $linkMethod = "html";
1520 $bodyClass = "summary_item small";
1521 $widgetAuth = acl_check('patients', 'alert', '', 'write');
1522 $fixedWidth = false;
1523 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel, $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1525 echo "<div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>";
1529 // Show current and upcoming appointments.
1531 // Recurring appointment support and Appointment Display Sets
1532 // added to Appointments by Ian Jardine ( epsdky ).
1534 if (isset($pid) && !$GLOBALS['disable_calendar'] && acl_check('patients', 'appt')) {
1536 $current_date2 = date('Y-m-d');
1538 $apptNum = (int)$GLOBALS['number_of_appts_to_show'];
1539 if ($apptNum != 0) {
1540 $apptNum2 = abs($apptNum);
1546 $mode1 = !$GLOBALS['appt_display_sets_option'];
1547 $colorSet1 = $GLOBALS['appt_display_sets_color_1'];
1548 $colorSet2 = $GLOBALS['appt_display_sets_color_2'];
1549 $colorSet3 = $GLOBALS['appt_display_sets_color_3'];
1550 $colorSet4 = $GLOBALS['appt_display_sets_color_4'];
1558 $events = fetchNextXAppts($current_date2, $pid, $apptNum2 +
$extraAppts, true);
1562 $apptNumber = count($events);
1564 if ($apptNumber <= $apptNum2) {
1565 $extraApptDate = '';
1567 } elseif ($mode1 && $apptNumber == $apptNum2 +
1) {
1568 $extraApptDate = $events[$apptNumber - 1]['pc_eventDate'];
1573 } elseif ($apptNumber == $apptNum2 +
6) {
1574 $extraApptDate = $events[$apptNumber - 1]['pc_eventDate'];
1579 } else { // mode 2 - $apptNum2 < $apptNumber < $apptNum2 + 6
1580 $extraApptDate = '';
1586 $limitApptIndx = $apptNum2 - 1;
1587 $limitApptDate = $events[$limitApptIndx]['pc_eventDate'];
1589 switch ($selectNum) {
1592 $lastApptIndx = $apptNumber - 1;
1593 $thisNumber = $lastApptIndx - $limitApptIndx;
1594 for ($i = 1; $i <= $thisNumber; ++
$i) {
1595 if ($events[$limitApptIndx +
$i]['pc_eventDate'] != $limitApptDate) {
1596 $extraApptDate = $events[$limitApptIndx +
$i]['pc_eventDate'];
1597 $events = array_slice($events, 0, $limitApptIndx +
$i);
1605 for ($i = 1; $i <= $limitApptIndx; ++
$i) {
1606 if ($events[$limitApptIndx - $i]['pc_eventDate'] != $limitApptDate) {
1607 $firstApptIndx = $apptNum2 - $i;
1616 if ($extraApptDate) {
1617 if ($extraApptDate != $limitApptDate) {
1618 $apptStyle2 = " style='background-color:" . attr($colorSet3) . ";'";
1620 $apptStyle2 = " style='background-color:" . attr($colorSet4) . ";'";
1627 // appointments expand collapse widget
1628 $widgetTitle = xl("Appointments");
1629 $widgetLabel = "appointments";
1630 $widgetButtonLabel = xl("Add");
1631 $widgetButtonLink = "return newEvt();";
1632 $widgetButtonClass = "";
1633 $linkMethod = "javascript";
1634 $bodyClass = "summary_item small";
1635 $widgetAuth = $resNotNull // $resNotNull reflects state of query in fetchAppointments
1636 && (acl_check('patients', 'appt', '', 'write') ||
acl_check('patients', 'appt', '', 'addonly'));
1637 $fixedWidth = false;
1638 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel, $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1643 $therapyGroupCategories = array();
1644 $query = sqlStatement("SELECT pc_catid FROM openemr_postcalendar_categories WHERE pc_cattype = 3 AND pc_active = 1");
1645 while ($result = sqlFetchArray($query)) {
1646 $therapyGroupCategories[] = $result['pc_catid'];
1650 foreach ($events as $row) { //////
1652 $dayname = date("l", strtotime($row['pc_eventDate'])); //////
1654 $disphour = substr($row['pc_startTime'], 0, 2) +
0;
1655 $dispmin = substr($row['pc_startTime'], 3, 2);
1656 if ($disphour >= 12) {
1658 if ($disphour > 12) {
1663 $etitle = xl('(Click to edit)');
1664 if ($row['pc_hometext'] != "") {
1665 $etitle = xl('Comments').": ".($row['pc_hometext'])."\r\n".$etitle;
1669 if ($extraApptDate && $count > $firstApptIndx) {
1670 $apptStyle = $apptStyle2;
1672 if ($row['pc_eventDate'] != $priorDate) {
1673 $priorDate = $row['pc_eventDate'];
1674 $toggleSet = !$toggleSet;
1678 $apptStyle = " style='background-color:" . attr($colorSet2) . ";'";
1680 $apptStyle = " style='background-color:" . attr($colorSet1) . ";'";
1685 echo "<div " . $apptStyle . ">";
1686 if (!in_array($row['pc_catid'], $therapyGroupCategories)) {
1687 echo "<a href='javascript:oldEvt(" . attr_js(preg_replace("/-/", "", $row['pc_eventDate'])) . ', ' . attr_js($row['pc_eid']) . ")' title='" . attr($etitle) . "'>";
1689 echo "<span title='" . attr($etitle) . "'>";
1692 echo "<b>" . text(oeFormatShortDate($row['pc_eventDate'])) . ", ";
1693 echo text(sprintf("%02d", $disphour) .":$dispmin " . xl($dispampm) . " (" . xl($dayname)) . ")</b> ";
1694 if ($row['pc_recurrtype']) {
1695 echo "<img src='" . $GLOBALS['webroot'] . "/interface/main/calendar/modules/PostCalendar/pntemplates/default/images/repeating8.png' border='0' style='margin:0px 2px 0px 2px;' title='" . xla("Repeating event") . "' alt='" . xla("Repeating event") . "'>";
1698 echo "<span title='" . generate_display_field(array('data_type'=>'1','list_id'=>'apptstat'), $row['pc_apptstatus']) . "'>";
1699 echo "<br>" . xlt('Status') . "( " . text($row['pc_apptstatus']) . " ) </span>";
1700 echo text(xl_appt_category($row['pc_catname'])) . "\n";
1701 if (in_array($row['pc_catid'], $therapyGroupCategories)) {
1702 echo "<br><span>" . xlt('Group name') .": " . text(getGroup($row['pc_gid'])['group_name']) . "</span>\n";
1705 if ($row['pc_hometext']) {
1706 echo " <span style='color:green'> Com</span>";
1709 echo "<br>" . text($row['ufname'] . " " . $row['ulname']);
1710 echo !in_array($row['pc_catid'], $therapyGroupCategories) ?
'</a>' : '<span>';
1715 if ($resNotNull) { //////
1717 echo " " . xlt('No Appointments');
1719 if ($extraApptDate) {
1720 echo "<div style='color:#0000cc;'><b>" . text($extraApptDate) . " ( + ) </b></div>";
1723 // Show Recall if one exists
1724 $query = sqlStatement("SELECT * FROM medex_recalls WHERE r_pid = ?", array($pid));
1726 while ($result2 = sqlFetchArray($query)) {
1727 //tabYourIt('recall', 'main/messages/messages.php?go=' + choice);
1728 //parent.left_nav.loadFrame('1', tabNAME, url);
1729 echo "  <b>Recall: <a onclick=\"top.left_nav.loadFrame('1', 'rcb', '../interface/main/messages/messages.php?go=addRecall');\">" . text(oeFormatShortDate($result2['r_eventDate'])). " (". text($result2['r_reason']).") </a></b>";
1732 //if there is no appt and no recall
1733 if (($count < 1) && ($count2 < 1)) {
1734 echo "<br /><br /> <a onclick=\"top.left_nav.loadFrame('1', 'rcb', '../interface/main/messages/messages.php?go=addRecall');\">" . xlt('No Recall') . "</a>";
1739 } // End of Appointments Widget.
1742 /* Widget that shows recurrences for appointments. */
1743 if (isset($pid) && !$GLOBALS['disable_calendar'] && $GLOBALS['appt_recurrences_widget'] &&
1744 acl_check('patients', 'appt')) {
1745 $widgetTitle = xl("Recurrent Appointments");
1746 $widgetLabel = "recurrent_appointments";
1747 $widgetButtonLabel = xl("Add");
1748 $widgetButtonLink = "return newEvt();";
1749 $widgetButtonClass = "";
1750 $linkMethod = "javascript";
1751 $bodyClass = "summary_item small";
1752 $widgetAuth = false;
1753 $fixedWidth = false;
1754 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel, $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1759 //Fetch patient's recurrences. Function returns array with recurrence appointments' category, recurrence pattern (interpreted), and end date.
1760 $recurrences = fetchRecurrences($pid);
1761 if (empty($recurrences)) { //if there are no recurrent appointments:
1763 echo "<span>" . " " . xlt('None{{Appointment}}') . "</span>";
1764 echo "</div></div>";
1766 foreach ($recurrences as $row) {
1767 //checks if there are recurrences and if they are current (git didn't end yet)
1768 if (!recurrence_is_current($row['pc_endDate'])) {
1773 echo "<span>" . xlt('Appointment Category') . ": <b>" . xlt($row['pc_catname']) . "</b></span>";
1775 echo "<span>" . xlt('Recurrence') . ': ' . text($row['pc_recurrspec']) . "</span>";
1777 $red_text = ""; //if ends in a week, make font red
1778 if (ends_in_a_week($row['pc_endDate'])) {
1779 $red_text = " style=\"color:red;\" ";
1782 echo "<span" . $red_text . ">" . xlt('End Date') . ': ' . text(oeFormatShortDate($row['pc_endDate'])) . "</span>";
1790 /* End of recurrence widget */
1792 // Show PAST appointments.
1793 // added by Terry Hill to allow reverse sorting of the appointments
1795 if ($GLOBALS['num_past_appointments_to_show'] < 0) {
1796 $direction = "DESC";
1797 ($showpast = -1 * $GLOBALS['num_past_appointments_to_show']);
1799 $showpast = $GLOBALS['num_past_appointments_to_show'];
1802 if (isset($pid) && !$GLOBALS['disable_calendar'] && $showpast > 0 &&
1803 acl_check('patients', 'appt')) {
1804 $query = "SELECT e.pc_eid, e.pc_aid, e.pc_title, e.pc_eventDate, " .
1805 "e.pc_startTime, e.pc_hometext, u.fname, u.lname, u.mname, " .
1806 "c.pc_catname, e.pc_apptstatus " .
1807 "FROM openemr_postcalendar_events AS e, users AS u, " .
1808 "openemr_postcalendar_categories AS c WHERE " .
1809 "e.pc_pid = ? AND e.pc_eventDate < CURRENT_DATE AND " .
1810 "u.id = e.pc_aid AND e.pc_catid = c.pc_catid " .
1811 "ORDER BY e.pc_eventDate " . escape_sort_order($direction) . " , e.pc_startTime DESC " .
1812 "LIMIT " . escape_limit($showpast);
1814 $pres = sqlStatement($query, array($pid));
1816 // appointments expand collapse widget
1817 $widgetTitle = xl("Past Appointments");
1818 $widgetLabel = "past_appointments";
1819 $widgetButtonLabel = '';
1820 $widgetButtonLink = '';
1821 $widgetButtonClass = '';
1822 $linkMethod = "javascript";
1823 $bodyClass = "summary_item small";
1824 $widgetAuth = false; //no button
1825 $fixedWidth = false;
1826 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel, $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1828 while ($row = sqlFetchArray($pres)) {
1830 $dayname = date("l", strtotime($row['pc_eventDate']));
1832 $disphour = substr($row['pc_startTime'], 0, 2) +
0;
1833 $dispmin = substr($row['pc_startTime'], 3, 2);
1834 if ($disphour >= 12) {
1836 if ($disphour > 12) {
1841 $petitle = xl('(Click to edit)');
1842 if ($row['pc_hometext'] != "") {
1843 $petitle = xl('Comments').": ".($row['pc_hometext'])."\r\n".$petitle;
1846 echo "<a href='javascript:oldEvt(" . attr_js(preg_replace("/-/", "", $row['pc_eventDate'])) . ', ' . attr_js($row['pc_eid']) . ")' title='" . attr($petitle) . "'>";
1847 echo "<b>" . text(xl($dayname) . ", " . oeFormatShortDate($row['pc_eventDate'])) . "</b> " . xlt("Status") . "(";
1848 echo " " . generate_display_field(array('data_type'=>'1','list_id'=>'apptstat'), $row['pc_apptstatus']) . ")<br>"; // can't use special char parser on this
1849 echo text("$disphour:$dispmin ") . xlt($dispampm) . " ";
1850 echo text($row['fname'] . " " . $row['lname']) . "</a><br>\n";
1853 if (isset($pres) && $res != null) {
1855 echo " " . xlt('None{{Appointment}}');
1862 // END of past appointments
1866 <div id
='stats_div'>
1868 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1873 <?php
// TRACK ANYTHING -----
1875 // Determine if track_anything form is in use for this site.
1876 $tmp = sqlQuery("SELECT count(*) AS count FROM registry WHERE " .
1877 "directory = 'track_anything' AND state = 1");
1878 $track_is_registered = $tmp['count'];
1879 if ($track_is_registered) {
1881 // track_anything expand collapse widget
1882 $widgetTitle = xl("Tracks");
1883 $widgetLabel = "track_anything";
1884 $widgetButtonLabel = xl("Tracks");
1885 $widgetButtonLink = "../../forms/track_anything/create.php";
1886 $widgetButtonClass = "";
1887 $widgetAuth = ""; // don't show the button
1888 $linkMethod = "html";
1889 $bodyClass = "notab";
1890 // check to see if any tracks exist
1891 $spruch = "SELECT id " .
1895 $existTracks = sqlQuery($spruch, array($pid, "track_anything"));
1897 $fixedWidth = false;
1898 expand_collapse_widget(
1911 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1915 } // end track_anything ?>
1918 </div
> <!-- end right column div
-->
1925 </div
> <!-- end main content div
-->
1926 </div
><!-- end container div
-->
1927 <?php
$oemr_ui->oeBelowContainerDiv();?
>
1928 <script language
='JavaScript'>
1929 // Array of skip conditions for the checkSkipConditions() function.
1931 <?php
echo $condition_str; ?
>
1933 checkSkipConditions();
1935 var isPost
= <?php
echo js_escape($showEligibility); ?
>;
1936 var listId
= '#' +
<?php
echo js_escape($list_id); ?
>;
1937 $
(document
).ready(function(){
1938 $
(listId
).addClass("active");
1939 if(isPost
=== true) {
1940 $
("#eligibility").click();
1941 $
("#eligibility").get(0).scrollIntoView();