3 * Patient Tracker (Patient Flow Board)
5 * This program displays the information entered in the Calendar program ,
6 * allowing the user to change status and view those changed here and in the Calendar
7 * Will allow the collection of length of time spent in each status
10 * @link http://www.open-emr.org
11 * @author Terry Hill <terry@lilysystems.com>
12 * @author Brady Miller <brady.g.miller@gmail.com>
13 * @copyright Copyright (c) 2015-2017 Terry Hill <terry@lillysystems.com>
14 * @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
15 * @copyright Copyright (c) 2017 Ray Magauran <magauran@medexbank.com>
16 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
19 require_once "../globals.php";
20 require_once "$srcdir/patient.inc";
21 require_once "$srcdir/options.inc.php";
22 require_once "$srcdir/patient_tracker.inc.php";
23 require_once "$srcdir/user.inc";
24 require_once "$srcdir/MedEx/API.php";
26 use OpenEMR\Core\Header
;
28 // These settings are sticky user preferences linked to a given page.
29 // mdsupport - user_settings prefix
30 $uspfx = substr(__FILE__
, strlen($webserver_root)) . '.';
31 $setting_new_window = prevSetting($uspfx, 'setting_new_window', 'setting_new_window', ' ');
32 // flow board and recall board share bootstrap settings:
33 $setting_bootstrap_submenu = prevSetting('', 'setting_bootstrap_submenu', 'setting_bootstrap_submenu', ' ');
34 $setting_selectors = prevSetting($uspfx, 'setting_selectors', 'setting_selectors', 'block');
35 $form_apptcat = prevSetting($uspfx, 'form_apptcat', 'form_apptcat', '');
36 $form_apptstatus = prevSetting($uspfx, 'form_apptstatus', 'form_apptstatus', '');
37 $facility = prevSetting($uspfx, 'form_facility', 'form_facility', '');
38 $provider = prevSetting($uspfx, 'form_provider', 'form_provider', $_SESSION['authUserID']);
40 if (($_POST['setting_new_window']) ||
41 ($_POST['setting_bootstrap_submenu']) ||
42 ($_POST['setting_selectors'])) {
43 // These are not form elements. We only ever change them via ajax, so exit now.
46 if ($_POST['saveCALLback'] == "Save") {
47 $sqlINSERT = "INSERT INTO medex_outgoing (msg_pc_eid,msg_pid,campaign_uid,msg_type,msg_reply,msg_extra_text)
49 (?,?,?,'NOTES','CALLED',?)";
50 sqlQuery($sqlINSERT, array($_POST['pc_eid'], $_POST['pc_pid'], $_POST['campaign_uid'], $_POST['txtCALLback']));
53 //set default start date of flow board to value based on globals
54 if (!$GLOBALS['ptkr_date_range']) {
55 $from_date = date('Y-m-d');
56 } elseif (!is_null($_REQUEST['form_from_date'])) {
57 $from_date = DateToYYYYMMDD($_REQUEST['form_from_date']);
58 } elseif (($GLOBALS['ptkr_start_date'])=='D0') {
59 $from_date = date('Y-m-d');
60 } elseif (($GLOBALS['ptkr_start_date'])=='B0') {
61 if (date(w
)==GLOBALS
['first_day_week']) {
62 //today is the first day of the week
63 $from_date = date('Y-m-d');
64 } elseif ($GLOBALS['first_day_week']==0) {
66 $from_date = date('Y-m-d', strtotime('previous sunday'));
67 } elseif ($GLOBALS['first_day_week']==1) {
69 $from_date = date('Y-m-d', strtotime('previous monday'));
70 } elseif ($GLOBALS['first_day_week']==6) {
72 $from_date = date('Y-m-d', strtotime('previous saturday'));
75 //shouldnt be able to get here...
76 $from_date = date('Y-m-d');
79 //set default end date of flow board to value based on globals
80 if ($GLOBALS['ptkr_date_range']) {
81 if (substr($GLOBALS['ptkr_end_date'], 0, 1) == 'Y') {
82 $ptkr_time = substr($GLOBALS['ptkr_end_date'], 1, 1);
83 $ptkr_future_time = mktime(0, 0, 0, date('m'), date('d'), date('Y') +
$ptkr_time);
84 } elseif (substr($GLOBALS['ptkr_end_date'], 0, 1) == 'M') {
85 $ptkr_time = substr($GLOBALS['ptkr_end_date'], 1, 1);
86 $ptkr_future_time = mktime(0, 0, 0, date('m') +
$ptkr_time, date('d'), date('Y'));
87 } elseif (substr($GLOBALS['ptkr_end_date'], 0, 1) == 'D') {
88 $ptkr_time = substr($GLOBALS['ptkr_end_date'], 1, 1);
89 $ptkr_future_time = mktime(0, 0, 0, date('m'), date('d') +
$ptkr_time, date('Y'));
92 $to_date = date('Y-m-d', $ptkr_future_time);
93 $to_date = !is_null($_REQUEST['form_to_date']) ?
DateToYYYYMMDD($_REQUEST['form_to_date']) : $to_date;
95 $to_date = date('Y-m-d');
98 $form_patient_name = !is_null($_POST['form_patient_name']) ?
$_POST['form_patient_name'] : null;
99 $form_patient_id = !is_null($_POST['form_patient_id']) ?
$_POST['form_patient_id'] : null;
101 // get all appts for date range and refine view client side. very fast...
102 $appointments = array();
103 $datetime = date("Y-m-d H:i:s");
104 $appointments = fetch_Patient_Tracker_Events($from_date, $to_date, '', '', '', '', $form_patient_name, $form_patient_id);
105 $appointments = sortAppointments($appointments, 'date', 'time');
106 //grouping of the count of every status
107 $appointments_status = getApptStatus($appointments);
110 $lres = sqlStatement("SELECT option_id, title FROM list_options WHERE list_id = ? AND activity=1", array('apptstat'));
111 while ($lrow = sqlFetchArray($lres)) {
112 // if exists, remove the legend character
113 if ($lrow['title'][1] == ' ') {
114 $splitTitle = explode(' ', $lrow['title']);
115 array_shift($splitTitle);
116 $title = implode(' ', $splitTitle);
118 $title = $lrow['title'];
120 $statuses_list[$lrow['option_id']] = $title;
123 $chk_prov = array(); // list of providers with appointments
124 // Scan appointments for additional info
125 foreach ($appointments as $apt) {
126 $chk_prov[$apt['uprovider_id']] = $apt['ulname'] . ', ' . $apt['ufname'] . ' ' . $apt['umname'];
129 if ($GLOBALS['medex_enable'] == '1') {
130 $query2 = "SELECT * FROM medex_icons";
131 $iconed = sqlStatement($query2);
132 while ($icon = sqlFetchArray($iconed)) {
133 $icons[$icon['msg_type']][$icon['msg_status']]['html'] = $icon['i_html'];
135 $MedEx = new MedExApi\
MedEx('MedExBank.com');
136 $logged_in = $MedEx->login();
137 $sql = "SELECT * FROM medex_prefs LIMIT 1";
138 $preferences = sqlStatement($sql);
139 $prefs = sqlFetchArray($preferences);
141 $results = $MedEx->campaign
->events($logged_in['token']);
142 foreach ($results['events'] as $event) {
143 if ($event['M_group'] != 'REMINDER') {
146 $icon = $icons[$event['M_type']]['SCHEDULED']['html'];
147 if ($event['E_timing'] == '1') {
148 $action = xl("before");
150 if ($event['E_timing'] == '2') {
151 $action = xl("before (PM)");
153 if ($event['E_timing'] == '3') {
154 $action = xl("after");
156 if ($event['E_timing'] == '4') {
157 $action = xl("after (PM)");
159 $days = ($event['E_fire_time'] == '1') ?
xl("day") : xl("days");
160 $current_events .= $icon . " " . (int)$event['E_fire_time'] . " " . text($days) . " " . text($action) . "<br />";
163 $current_events = $icons['SMS']['FAILED']['html'] . " " . xlt("Currently off-line");
167 if (!$_REQUEST['flb_table']) {
171 <title
><?php
echo xlt('Flow Board'); ?
></title
>
173 <?php Header
::setupHeader(['datetime-picker', 'jquery-ui', 'jquery-ui-cupertino', 'opener', 'pure']); ?
>
175 <script type
="text/javascript">
176 <?php
require_once "$srcdir/restoreSession.php"; ?
>
179 <link rel
="stylesheet" href
="<?php echo $GLOBALS['web_root']; ?>/library/css/bootstrap_navbar.css?v=<?php echo $v_js_includes; ?>" type
="text/css">
180 <script type
="text/javascript" src
="<?php echo $GLOBALS['web_root']; ?>/interface/main/messages/js/reminder_appts.js?v=<?php echo $v_js_includes; ?>"></script
>
182 <link rel
="shortcut icon" href
="<?php echo $webroot; ?>/sites/default/favicon.ico" />
184 <meta charset
="utf-8">
185 <meta http
-equiv
="X-UA-Compatible" content
="IE=edge">
186 <meta name
="author" content
="OpenEMR: MedExBank">
187 <meta name
="viewport" content
="width=device-width, initial-scale=1">
198 border
: solid black
0.5pt
;
199 box
-shadow
: 3px
3px
3px
#7b777760;
208 background
-color
: white
;
217 box
-shadow
: 2px
3px
9px
#c0c0c0;
226 font
-family
: Georgia
, serif
;
229 text
-transform
: uppercase
;
232 border
-bottom
: 2px solid
#455832;
236 .ui
-datepicker
-year
{
250 text
-decoration
:none
;
256 <body
class="body_top">
258 if (($GLOBALS['medex_enable'] == '1') && (empty($_REQUEST['nomenu']))) {
259 $MedEx->display
->navigation($logged_in);
262 <div
class="container-fluid" style
="margin-top: 20px;">
263 <div
class="row-fluid" id
="flb_selectors" style
="display:<?php echo attr($setting_selectors); ?>;">
264 <div
class="col-sm-12">
265 <div
class="showRFlow" id
="show_flows" style
="text-align:center;margin:20px auto;" name
="kiosk_hide">
266 <div
class="title"><?php
echo xlt('Flow Board'); ?
></div
>
267 <div name
="div_response" id
="div_response" class="nodisplay"></div
>
269 if ($GLOBALS['medex_enable'] == '1') {
273 $last_col_width = "nodisplay";
277 <form name
="flb" id
="flb" method
="post">
278 <div
class=" text-center row divTable" style
="width: 85%;padding: 10px 10px 0;margin: 10px auto;">
279 <div
class="col-sm-<?php echo $col_width; ?> text-center" style
="margin-top:15px;">
280 <select id
="form_apptcat" name
="form_apptcat" class="form-group ui-selectmenu-button ui-button ui-widget ui-selectmenu-button-closed ui-corner-all"
281 onchange
="refineMe('apptcat');" title
="">
283 $categories = fetchAppointmentCategories();
284 echo "<option value=''>" . xlt("Visit Categories") . "</option>";
285 while ($cat = sqlFetchArray($categories)) {
286 echo "<option value='" . attr($cat['id']) . "'";
287 if ($cat['id'] == $_POST['form_apptcat']) {
288 echo " selected='true' ";
290 echo ">" . xlt($cat['category']) . "</option>";
295 <select id
="form_apptstatus" name
="form_apptstatus" class="form-group ui-selectmenu-button ui-button ui-widget ui-selectmenu-button-closed ui-corner-all"
296 onchange
="refineMe();">
297 <option value
=""><?php
echo xlt("Visit Status"); ?
></option
>
300 $apptstats = sqlStatement("SELECT * FROM list_options WHERE list_id = 'apptstat' AND activity = 1 ORDER BY seq");
301 while ($apptstat = sqlFetchArray($apptstats)) {
302 echo "<option value='" . attr($apptstat['option_id']) . "'";
303 if ($apptstat['option_id'] == $_POST['form_apptstatus']) {
304 echo " selected='true' ";
306 echo ">" . xlt($apptstat['title']) . "</option>";
312 placeholder
="<?php echo xla('Patient Name'); ?>"
313 class="form-control input-sm" id
="form_patient_name" name
="form_patient_name"
314 value
="<?php echo ($form_patient_name) ? attr($form_patient_name) : ""; ?>"
315 onKeyUp
="refineMe();">
317 <div
class="col-sm-<?php echo $col_width; ?> text-center" style
="margin-top:15px;">
318 <select
class="form-group ui-selectmenu-button ui-button ui-widget ui-selectmenu-button-closed ui-corner-all" id
="form_facility" name
="form_facility"
320 $fac_sql = sqlStatement("SELECT * FROM facility ORDER BY id");
321 while ($fac = sqlFetchArray($fac_sql)) {
322 $true = ($fac['id'] == $_POST['form_facility']) ?
"selected=true" : '';
323 $select_facs .= "<option value=" . attr($fac['id']) . " " . $true . ">" . text($fac['name']) . "</option>\n";
326 if ($count_facs < '1') {
329 ?
> onchange
="refineMe('facility');">
330 <option value
=""><?php
echo xlt('All Facilities'); ?
></option
>
331 <?php
echo $select_facs; ?
>
335 // Build a drop-down list of ACTIVE providers.
336 $query = "SELECT id, lname, fname FROM users WHERE " .
337 "authorized = 1 AND active = 1 AND username > '' ORDER BY lname, fname"; #(CHEMED) facility filter
338 $ures = sqlStatement($query);
339 while ($urow = sqlFetchArray($ures)) {
340 $provid = $urow['id'];
341 $select_provs .= " <option value='" . attr($provid) . "'";
342 if (isset($_POST['form_provider']) && $provid == $_POST['form_provider']) {
343 $select_provs .= " selected";
344 } elseif (!isset($_POST['form_provider']) && $_SESSION['userauthorized'] && $provid == $_SESSION['authUserID']) {
345 $select_provs .= " selected";
347 $select_provs .= ">" . text($urow['lname']) . ", " . text($urow['fname']) . "\n";
352 <select
class="form-group ui-selectmenu-button ui-button ui-widget ui-selectmenu-button-closed ui-corner-all" id
="form_provider" name
="form_provider" <?php
353 if ($count_provs < '2') {
356 ?
> onchange
="refineMe('provider');">
357 <option value
="" selected
><?php
echo xlt('All Providers'); ?
></option
>
363 <input placeholder
="<?php echo xla('Patient ID'); ?>"
364 class="form-control input-sm" type
="text"
365 id
="form_patient_id" name
="form_patient_id"
366 value
="<?php echo ($form_patient_id) ? attr($form_patient_id) : ""; ?>"
367 onKeyUp
="refineMe();">
369 <div
class="col-sm-<?php echo $col_width; ?>">
370 <div style
="margin: 0 auto;" class="input-append">
371 <table
class="table-hover table-condensed" style
="margin:0 auto;">
373 if ($GLOBALS['ptkr_date_range'] == '1') {
378 $style = 'display:none;';
380 <tr style
="<?php echo $style; ?>" class="align-bottom">
381 <td
class="text-right align-bottom">
382 <label
for="flow_from"><?php
echo xlt('From'); ?
>:</label
></td
>
385 id
="form_from_date" name
="form_from_date"
386 class="datepicker form-control input-sm text-center"
387 value
="<?php echo attr(oeFormatShortDate($from_date)); ?>"
388 style
="max-width:140px;min-width:85px;">
391 <tr style
="<?php echo $style; ?>">
392 <td
class="text-right">
393 <label
for="flow_to"> 
; 
;<?php
echo xlt('To'); ?
>:</label
></td
>
396 id
="form_to_date" name
="form_to_date"
397 class="datepicker form-control input-sm text-center"
398 value
="<?php echo attr(oeFormatShortDate($to_date)); ?>"
399 style
="max-width:140px;min-width:85px;">
403 <td
class="text-center" colspan
="2">
405 class="btn btn-primary"
406 type
="submit" id
="filter_submit"
407 value
="<?php echo xla('Filter'); ?>">
408 <input type
="hidden" id
="kiosk" name
="kiosk"
409 value
="<?php echo attr($_REQUEST['kiosk']); ?>">
415 <div
class="col-sm-<?php echo $col_width . " " . $last_col_width; ?> text-center">
417 if ($GLOBALS['medex_enable'] == '1') {
420 <div
class="text-center" style
="margin: 0 auto;">
421 <span
class="bold" style
="text-decoration:underline;font-size:1.2em;">MedEx
<?php
echo xlt('Reminders'); ?
></span
><br
/>
422 <div
class="text-left blockquote" style
="width: 65%;margin: 5px auto;">
423 <a href
="https://medexbank.com/cart/upload/index.php?route=information/campaigns&g=rem"
425 <?php
echo $current_events; ?
>
431 <div id
="message" class="warning"></div
>
437 <div
class="row-fluid">
438 <div
class="row divTable">
439 <div
class="col-sm-12 text-center" style
='margin:5px;'>
440 <span
class="hidden-xs" id
="status_summary">
442 $statuses_output = "<span style='margin:0 10px;'><em>" . xlt('Total patients') . ':</em> <span class="badge">' . text($appointments_status['count_all']) . "</span></span>";
443 unset($appointments_status['count_all']);
444 foreach ($appointments_status as $status_symbol => $count) {
445 $statuses_output .= " | <span style='margin:0 10px;'><em>" . text(xl_list_label($statuses_list[$status_symbol])) . ":</em> <span class='badge'>" . text($count) . "</span></span>";
447 echo $statuses_output;
450 <span id
="pull_kiosk_right" class="pull-right">
451 <a id
='setting_cog'><i
class="fa fa-cog fa-2x fa-fw"> 
;</i
></a
>
453 <label
for='setting_new_window' id
='settings'>
454 <input type
='checkbox' name
='setting_new_window' id
='setting_new_window'
455 value
='<?php echo $setting_new_window; ?>' <?php
echo $setting_new_window; ?
> />
456 <?php
echo xlt('Open Patient in New Window'); ?
>
458 <a id
='refreshme'><i
class="fa fa-refresh fa-2x fa-fw"> 
;</i
></a
>
459 <span
class="fa-stack fa-lg" id
="flb_caret" onclick
="toggleSelectors();"
460 title
="<?php echo xla('Show/Hide the Selection Area'); ?>"
461 style
="color:<?php echo $color = ($setting_selectors == 'none') ? 'red' : 'black'; ?>;">
462 <i
class="fa fa-square-o fa-stack-2x"></i
>
464 class='fa fa-caret-<?php echo $caret = ($setting_selectors == 'none
') ? 'down
' : 'up
'; ?> fa-stack-1x'></i
>
467 <a
class='btn btn-primary' onclick
="print_FLB();"> <?php
echo xlt('Print'); ?
> </a
>
469 <?php
if ($GLOBALS['new_tabs_layout']) { ?
>
470 <a
class='btn btn-primary' onclick
="kiosk_FLB();"> <?php
echo xlt('Kiosk'); ?
> </a
>
475 <div
class="col-sm-12 textclear" id
="flb_table" name
="flb_table">
478 //end of if !$_REQUEST['flb_table'] - this is the table we fetch via ajax during a refreshMe() call
480 <table
class="table table-responsive table-condensed table-hover table-bordered">
482 <tr bgcolor
="#cccff" class="small bold text-center">
483 <?php
if ($GLOBALS['ptkr_show_pid']) { ?
>
484 <td
class="dehead hidden-xs text-center" name
="kiosk_hide">
485 <?php
echo xlt('PID'); ?
>
488 <td
class="dehead text-center" style
="max-width:150px;">
489 <?php
echo xlt('Patient'); ?
>
491 <?php
if ($GLOBALS['ptkr_visit_reason'] == '1') { ?
>
492 <td
class="dehead hidden-xs text-center" name
="kiosk_hide">
493 <?php
echo xlt('Reason'); ?
>
496 <?php
if ($GLOBALS['ptkr_show_encounter']) { ?
>
497 <td
class="dehead text-center hidden-xs hidden-sm" name
="kiosk_hide">
498 <?php
echo xlt('Encounter'); ?
>
502 <?php
if ($GLOBALS['ptkr_date_range'] == '1') { ?
>
503 <td
class="dehead hidden-xs text-center" name
="kiosk_hide">
504 <?php
echo xlt('Appt Date'); ?
>
507 <td
class="dehead text-center">
508 <?php
echo xlt('Appt Time'); ?
>
510 <td
class="dehead hidden-xs text-center">
511 <?php
echo xlt('Arrive Time'); ?
>
513 <td
class="dehead visible-xs hidden-sm hidden-md hidden-lg text-center">
514 <?php
echo xlt('Arrival'); ?
>
516 <td
class="dehead hidden-xs text-center">
517 <?php
echo xlt('Appt Status'); ?
>
519 <td
class="dehead hidden-xs text-center">
520 <?php
echo xlt('Current Status'); ?
>
522 <td
class="dehead visible-xs hidden-sm hidden-md hidden-lg text-center">
523 <?php
echo xlt('Current'); ?
>
525 <td
class="dehead hidden-xs text-center" name
="kiosk_hide">
526 <?php
echo xlt('Visit Type'); ?
>
528 <?php
if (count($chk_prov) > 1) { ?
>
529 <td
class="dehead text-center hidden-xs">
530 <?php
echo xlt('Provider'); ?
>
533 <td
class="dehead text-center">
534 <?php
echo xlt('Total Time'); ?
>
536 <td
class="dehead hidden-xs text-center">
537 <?php
echo xlt('Check Out Time'); ?
>
539 <td
class="dehead visible-xs hidden-sm hidden-md hidden-lg text-center">
540 <?php
echo xlt('Out Time'); ?
>
543 if ($GLOBALS['ptkr_show_staff']) { ?
>
544 <td
class="dehead hidden-xs hidden-sm text-center" name
="kiosk_hide">
545 <?php
echo xlt('Updated By'); ?
>
549 if ($_REQUEST['kiosk'] != '1') {
550 if ($GLOBALS['drug_screen']) { ?
>
551 <td
class="dehead center hidden-xs " name
="kiosk_hide">
552 <?php
echo xlt('Random Drug Screen'); ?
>
554 <td
class="dehead center hidden-xs " name
="kiosk_hide">
555 <?php
echo xlt('Drug Screen Completed'); ?
>
564 $prev_appt_date_time = "";
565 foreach ($appointments as $appointment) {
566 // Collect appt date and set up squashed date for use below
567 $date_appt = $appointment['pc_eventDate'];
568 $date_squash = str_replace("-", "", $date_appt);
569 if (empty($appointment['room']) && ($logged_in)) {
570 //Patient has not arrived yet, display MedEx Reminder info
571 //one icon per type of response.
572 //If there was a SMS dialog, display it as a mouseover/title
573 //Display date received also as mouseover title.
580 $icon_here = array();
586 $query = "SELECT * FROM medex_outgoing WHERE msg_pc_eid =? ORDER BY msg_date";
587 $myMedEx = sqlStatement($query, array($appointment['eid']));
589 * Each row for this pc_eid in the medex_outgoing table represents an event.
590 * Every event is recorded in $prog_text.
591 * A modality is represented by an icon (eg mail icon, phone icon, text icon).
592 * The state of the Modality is represented by the color of the icon:
596 * SENT/in process = yellow
598 * Icons are displayed in their highest state.
601 while ($row = sqlFetchArray($myMedEx)) {
602 // Need to convert $row['msg_date'] to localtime (stored as GMT) & then oeFormatShortDate it.
603 // I believe there is a new GLOBAL for server timezone??? If so, it will be easy.
604 // If not we need to import it from Medex through medex_preferences. It should really be in openEMR though.
605 // Delete when we figure this out.
607 if (!empty($row['msg_extra_text'])) {
608 $local = attr($row['msg_extra_text']) . " |";
610 $prog_text .= attr(oeFormatShortDate($row['msg_date'])) . " :: " . attr($row['msg_type']) . " : " . attr($row['msg_reply']) . " | " . $local . " |";
612 if ($row['msg_reply'] == 'Other') {
613 $other_title .= $row['msg_extra_text'] . "\n";
614 $icon_extra .= str_replace(
616 attr(oeFormatShortDate($row['msg_date'])) . "\n" . xla('Patient Message') . ":\n" . attr($row['msg_extra_text']) . "\n",
617 $icons[$row['msg_type']]['EXTRA']['html']
620 } elseif ($row['msg_reply'] == "FAILED") {
621 $appointment[$row['msg_type']]['stage'] = "FAILED";
622 $icon_here[$row['msg_type']] = $icons[$row['msg_type']]['FAILED']['html'];
623 } elseif (($row['msg_reply'] == "CONFIRMED") ||
($FINAL)) {
624 $appointment[$row['msg_type']]['stage'] = "CONFIRMED";
625 $FINAL = $icons[$row['msg_type']]['CONFIRMED']['html'];
626 $icon_here[$row['msg_type']] = $FINAL;
628 } elseif ($row['msg_type'] == "NOTES") {
630 $FINAL = $icons['NOTES']['CALLED']['html'];
631 $FINAL = str_replace("Call Back: COMPLETED", attr(oeFormatShortDate($row['msg_date'])) . " :: " . xla('Callback Performed') . " | " . xla('NOTES') . ": " . $row['msg_extra_text'] . " | ", $FINAL);
632 $icon_CALL = $icon_4_call;
634 } elseif (($row['msg_reply'] == "READ") ||
($appointment[$row['msg_type']]['stage'] == "READ")) {
635 $appointment[$row['msg_type']]['stage'] = "READ";
636 $icon_here[$row['msg_type']] = $icons[$row['msg_type']]['READ']['html'];
637 } elseif (($row['msg_reply'] == "SENT") ||
($appointment[$row['msg_type']]['stage'] == "SENT")) {
638 $appointment[$row['msg_type']]['stage'] = "SENT";
639 $icon_here[$row['msg_type']] = $icons[$row['msg_type']]['SENT']['html'];
640 } elseif (($row['msg_reply'] == "To Send") ||
(empty($appointment['stage']))) {
641 if (($appointment[$row['msg_type']]['stage'] != "CONFIRMED") &&
642 ($appointment[$row['msg_type']]['stage'] != "READ") &&
643 ($appointment[$row['msg_type']]['stage'] != "SENT") &&
644 ($appointment[$row['msg_type']]['stage'] != "FAILED")) {
645 $appointment[$row['msg_type']]['stage'] = "QUEUED";
646 $icon_here[$row['msg_type']] = $icons[$row['msg_type']]['SCHEDULED']['html'];
649 //these are additional icons if present
650 if (($row['msg_reply'] == "CALL") && (!$CALLED)) {
652 $icon_4_CALL = $icons[$row['msg_type']]['CALL']['html'];
653 $icon_CALL = "<span onclick=\"doCALLback('" . attr($date_squash) . "','" . attr($appointment['eid']) . "','" . attr($appointment['pc_cattype']) . "')\">" . $icon_4_CALL . "</span>
654 <span class='hidden' name='progCALLback_" . attr($appointment['eid']) . "' id='progCALLback_" . attr($appointment['eid']) . "'>
655 <form id='notation_" . attr($appointment['eid']) . "' method='post'
657 <h4>" . xlt('Call Back Notes') . ":</h4>
658 <input type='hidden' name='pc_eid' id='pc_eid' value='" . attr($appointment['eid']) . "'>
659 <input type='hidden' name='pc_pid' id='pc_pid' value='" . attr($appointment['pc_pid']) . "'>
660 <input type='hidden' name='campaign_uid' id='campaign_uid' value='" . attr($row['campaign_uid']) . "'>
661 <textarea name='txtCALLback' id='txtCALLback' rows=6 cols=20></textarea>
662 <input type='submit' name='saveCALLback' id='saveCALLback' value='" . xla("Save") ."'>
666 } elseif ($row['msg_reply'] == "STOP") {
667 $icon2_here .= $icons[$row['msg_type']]['STOP']['html'];
668 } elseif ($row['msg_reply'] == "Other") {
669 $icon2_here .= $icons[$row['msg_type']]['Other']['html'];
670 } elseif ($row['msg_reply'] == "CALLED") {
671 $icon2_here .= $icons[$row['msg_type']]['CALLED']['html'];
674 //if pc_apptstatus == '-', update it now to=status
675 if (!empty($other_title)) {
676 $appointment['messages'] = $icon2_here . $icon_extra;
680 // Collect variables and do some processing
681 $docname = $chk_prov[$appointment['uprovider_id']];
682 if (strlen($docname) <= 3) {
685 $ptname = $appointment['lname'] . ', ' . $appointment['fname'] . ' ' . $appointment['mname'];
686 $ptname_short = $appointment['fname'][0] . " " . $appointment['lname'][0];
687 $appt_enc = $appointment['encounter'];
688 $appt_eid = (!empty($appointment['eid'])) ?
$appointment['eid'] : $appointment['pc_eid'];
689 $appt_pid = (!empty($appointment['pid'])) ?
$appointment['pid'] : $appointment['pc_pid'];
690 if ($appt_pid == 0) {
691 continue; // skip when $appt_pid = 0, since this means it is not a patient specific appt slot
693 $status = (!empty($appointment['status']) && (!is_numeric($appointment['status']))) ?
$appointment['status'] : $appointment['pc_apptstatus'];
694 $appt_room = (!empty($appointment['room'])) ?
$appointment['room'] : $appointment['pc_room'];
695 $appt_time = (!empty($appointment['appttime'])) ?
$appointment['appttime'] : $appointment['pc_startTime'];
696 $tracker_id = $appointment['id'];
698 if ($GLOBALS['ptkr_visit_reason']) {
699 $reason_visit = $appointment['pc_hometext'];
701 $newarrive = collect_checkin($tracker_id);
702 $newend = collect_checkout($tracker_id);
703 $colorevents = (collectApptStatusSettings($status));
704 $bgcolor = $colorevents['color'];
705 $statalert = $colorevents['time_alert'];
706 // process the time to allow items with a check out status to be displayed
707 if (is_checkout($status) && (($GLOBALS['checkout_roll_off'] > 0) && strlen($form_apptstatus) != 1)) {
708 $to_time = strtotime($newend);
709 $from_time = strtotime($datetime);
710 $display_check_out = round(abs($from_time - $to_time) / 60, 0);
711 if ($display_check_out >= $GLOBALS['checkout_roll_off']) {
716 echo '<tr data-apptstatus="' . attr($appointment['pc_apptstatus']) . '"
717 data-apptcat="' . attr($appointment['pc_catid']) . '"
718 data-facility="' . attr($appointment['pc_facility']) . '"
719 data-provider="' . attr($appointment['uprovider_id']) . '"
720 data-pid="' . attr($appointment['pc_pid']) . '"
721 data-pname="' . attr($ptname) . '"
723 bgcolor="' . attr($bgcolor) . '" >';
724 if ($GLOBALS['ptkr_show_pid']) {
726 <td
class="detail hidden-xs" align
="center" name
="kiosk_hide">
727 <?php
echo text($appt_pid); ?
>
733 <td
class="detail text-center hidden-xs" name
="kiosk_hide">
735 onclick
="return topatient('<?php echo attr($appt_pid); ?>','<?php echo attr($appt_enc); ?>')">
736 <?php
echo text($ptname); ?
></a
>
738 <td
class="detail text-center visible-xs hidden-sm hidden-md hidden-lg"
739 style
="white-space: normal;" name
="kiosk_hide">
741 onclick
="return topatient('<?php echo attr($appt_pid); ?>','<?php echo attr($appt_enc); ?>')">
742 <?php
echo text($ptname_short); ?
></a
>
745 <td
class="detail text-center" style
="white-space: normal;" name
="kiosk_show">
747 onclick
="return topatient('<?php echo attr($appt_pid); ?>','<?php echo attr($appt_enc); ?>')">
748 <?php
echo text($ptname_short); ?
></a
>
752 <?php
if ($GLOBALS['ptkr_visit_reason']) { ?
>
753 <td
class="detail hidden-xs text-center" name
="kiosk_hide">
754 <?php
echo text($reason_visit) ?
>
757 <?php
if ($GLOBALS['ptkr_show_encounter']) { ?
>
758 <td
class="detail hidden-xs hidden-sm text-center" name
="kiosk_hide">
759 <?php
if ($appt_enc != 0) {
760 echo text($appt_enc);
764 if ($GLOBALS['ptkr_date_range'] == '1') { ?
>
765 <td
class="detail hidden-xs text-center" name
="kiosk_hide">
766 <?php
echo text(oeFormatShortDate($appointment['pc_eventDate']));
770 <td
class="detail" align
="center">
771 <?php
echo oeFormatTime($appt_time) ?
>
773 <td
class="detail text-center">
776 echo oeFormatTime($newarrive);
780 <td
class="detail hidden-xs text-center small">
781 <?php
if (empty($tracker_id)) { //for appt not yet with tracker id and for recurring appt ?>
782 <a onclick
="return calendarpopup(<?php echo attr($appt_eid) . "," . attr($date_squash); // calls popup for add edit calendar event?>)">
784 <a onclick
="return bpopup(<?php echo attr($tracker_id); // calls popup for patient tracker status?>)">
786 if ($appointment['room'] > '') {
787 echo getListItemTitle('patient_flow_board_rooms', $appt_room);
789 echo text(getListItemTitle("apptstat", $status)); // drop down list for appointment status
796 //time in current status
797 $to_time = strtotime(date("Y-m-d H:i:s"));
799 if (strtotime($newend) != '') {
800 $from_time = strtotime($newarrive);
801 $to_time = strtotime($newend);
804 $from_time = strtotime($appointment['start_datetime']);
808 $timecheck = round(abs($to_time - $from_time) / 60, 0);
809 if ($timecheck >= $statalert && ($statalert > '0')) { // Determine if the time in status limit has been reached.
810 echo "<td class='text-center js-blink-infinite small' nowrap> "; // and if so blink
812 echo "<td class='detail text-center' nowrap> "; // and if not do not blink
814 if (($yestime == '1') && ($timecheck >= 1) && (strtotime($newarrive) != '')) {
815 echo text($timecheck . ' ' . ($timecheck >= 2 ?
xl('minutes') : xl('minute')));
816 } else if ($icon_here ||
$icon2_here ||
$icon_CALL) {
817 echo "<span style='font-size:0.7em;' onclick='return calendarpopup(" . attr($appt_eid) . "," . attr($date_squash) . ")'>" . implode($icon_here) . $icon2_here . "</span> " . $icon_CALL;
818 } else if ($logged_in) {
819 $pat = $MedEx->display
->possibleModalities($appointment);
820 echo "<span style='font-size:0.7em;'>" . $pat['SMS'] . $pat['AVM'] . $pat['EMAIL'] . "</span>";
822 //end time in current status
825 <td
class="detail hidden-xs text-center" name
="kiosk_hide">
826 <?php
echo xlt($appointment['pc_title']); ?
>
829 if (count($chk_prov) > 1) { ?
>
830 <td
class="detail text-center hidden-xs">
831 <?php
echo text($docname); ?
>
835 <td
class="detail text-center">
837 // total time in practice
838 if (strtotime($newend) != '') {
839 $from_time = strtotime($newarrive);
840 $to_time = strtotime($newend);
842 $from_time = strtotime($newarrive);
843 $to_time = strtotime(date("Y-m-d H:i:s"));
845 $timecheck2 = round(abs($to_time - $from_time) / 60, 0);
846 if (strtotime($newarrive) != '' && ($timecheck2 >= 1)) {
847 echo text($timecheck2 . ' ' . ($timecheck2 >= 2 ?
xl('minutes') : xl('minute')));
849 // end total time in practice
850 echo text($appointment['pc_time']); ?
>
852 <td
class="detail text-center">
857 if ($GLOBALS['ptkr_show_staff'] == '1') {
859 <td
class="detail hidden-xs hidden-sm text-center" name
="kiosk_hide">
860 <?php
echo text($appointment['user']) ?
>
864 if ($GLOBALS['drug_screen']) {
865 if (strtotime($newarrive) != '') { ?
>
866 <td
class="detail hidden-xs text-center" name
="kiosk_hide">
868 if (text($appointment['random_drug_test']) == '1') {
877 if (strtotime($newarrive) != '' && $appointment['random_drug_test'] == '1') { ?
>
878 <td
class="detail hidden-xs text-center" name
="kiosk_hide">
880 if (strtotime($newend) != '') {
881 // the following block allows the check box for drug screens to be disabled once the status is check out ?>
882 <input type
=checkbox disabled
='disable' class="drug_screen_completed"
883 id
="<?php echo htmlspecialchars($appointment['pt_tracker_id'], ENT_NOQUOTES) ?>" <?php
if ($appointment['drug_screen_completed'] == "1") {
889 <input type
=checkbox
class="drug_screen_completed"
890 id
='<?php echo htmlspecialchars($appointment['pt_tracker_id
'], ENT_NOQUOTES) ?>'
891 name
="drug_screen_completed" <?php
if ($appointment['drug_screen_completed'] == "1") {
910 if (!$_REQUEST['flb_table']) { ?
>
913 </div
><?php
//end container ?>
914 <!-- form used to open a
new top level window when a patient row is clicked
-->
915 <form name
='fnew' method
='post' target
='_blank'
916 action
='../main/main_screen.php?auth=login&site=<?php echo attr($_SESSION['site_id
']); ?>'>
917 <input type
='hidden' name
='patientID' value
='0'/>
918 <input type
='hidden' name
='encounterID' value
='0'/>
921 <?php
echo myLocalJS(); ?
>
925 } //end of second !$_REQUEST['flb_table']
927 //$content = ob_get_clean();
935 <script type
="text/javascript">
936 var auto_refresh
= null;
937 //this can be refined to redact HIPAA material using @media print options.
938 top
.restoreSession();
940 window
.parent
.$
("[name='flb']").attr('allowFullscreen', 'true');
942 $
(this
).attr('allowFullscreen', 'true');
945 if ($_REQUEST['kiosk'] == '1') { ?
>
946 $
("[name='kiosk_hide']").hide();
947 $
("[name='kiosk_show']").show();
949 $
("[name='kiosk_hide']").show();
950 $
("[name='kiosk_show']").hide();
952 function print_FLB() {
956 function toggleSelectors() {
957 if ($
("#flb_selectors").css('display') === 'none') {
958 $
.post("<?php echo $GLOBALS['webroot'] . "/interface/patient_tracker
/patient_tracker
.php
"; ?>", {
959 'setting_selectors': 'block',
960 success
: function (data
) {
962 $
("#flb_selectors").slideToggle();
963 $
("#flb_caret").css('color', '#000');
967 $
.post("<?php echo $GLOBALS['webroot'] . "/interface/patient_tracker
/patient_tracker
.php
"; ?>", {
968 'setting_selectors': 'none',
969 success
: function (data
) {
970 $
("#flb_selectors").slideToggle();
971 $
("#flb_caret").css('color', 'red');
975 $
("#print_caret").toggleClass('fa-caret-up').toggleClass('fa-caret-down');
979 * This function refreshes the whole flb_table according to our to/from dates.
981 function refreshMe() {
982 top
.restoreSession();
983 var posting
= $
.post('../patient_tracker/patient_tracker.php', {
985 form_from_date
: $
("#form_from_date").val(),
986 form_to_date
: $
("#form_to_date").val(),
987 form_facility
: $
("#form_facility").val(),
988 form_provider
: $
("#form_provider").val(),
989 form_apptstatus
: $
("#form_apptstatus").val(),
990 form_patient_name
: $
("#form_patient_name").val(),
991 form_patient_id
: $
("#form_patient_id").val(),
992 form_apptcat
: $
("#form_apptcat").val(),
993 kiosk
: $
("#kiosk").val()
996 $
("#flb_table").html(data
);
997 if ($
("#kiosk").val() === '') {
998 $
("[name='kiosk_hide']").show();
999 $
("[name='kiosk_show']").hide();
1001 $
("[name='kiosk_hide']").hide();
1002 $
("[name='kiosk_show']").show();
1008 function refreshme() {
1009 // Just need this to support refreshme call from the popup used for recurrent appt
1014 * This function hides all then shows only the flb_table rows that match our selection, client side.
1015 * It is called on initial load, on refresh and 'onchange/onkeyup' of a flow board parameter.
1017 function refineMe() {
1018 var apptcatV
= $
("#form_apptcat").val();
1019 var apptstatV
= $
("#form_apptstatus").val();
1020 var facV
= $
("#form_facility").val();
1021 var provV
= $
("#form_provider").val();
1022 var pidV
= String($
("#form_patient_id").val());
1023 var pidRE
= new RegExp(pidV
, 'g');
1024 var pnameV
= $
("#form_patient_name").val();
1025 var pnameRE
= new RegExp(pnameV
, 'ig');
1027 //and hide what we don't want to show
1028 $
('#flb_table tbody tr').hide().filter(function () {
1029 var d
= $
(this
).data();
1030 meets_cat
= (apptcatV
=== '') ||
(apptcatV
== d
.apptcat
);
1031 meets_stat
= (apptstatV
=== '') ||
(apptstatV
== d
.apptstatus
);
1032 meets_fac
= (facV
=== '') ||
(facV
== d
.facility
);
1033 meets_prov
= (provV
=== '') ||
(provV
== d
.provider
);
1034 meets_pid
= (pidV
=== '');
1035 if ((pidV
> '') && pidRE
.test(d
.pid
)) {
1038 meets_pname
= (pnameV
=== '');
1039 if ((pnameV
> '') && pnameRE
.test(d
.pname
)) {
1042 return meets_pname
&& meets_pid
&& meets_cat
&& meets_stat
&& meets_fac
&& meets_prov
;
1046 // popup for patient tracker status
1047 function bpopup(tkid
) {
1048 top
.restoreSession();
1049 dlgopen('../patient_tracker/patient_tracker_status.php?tracker_id=' + tkid
, '_blank', 500, 250);
1053 // popup for calendar add edit
1054 function calendarpopup(eid
, date_squash
) {
1055 top
.restoreSession();
1056 dlgopen('../main/calendar/add_edit_event.php?eid=' + eid +
'&date=' + date_squash
, '_blank', 775, 500);
1060 // used to display the patient demographic and encounter screens
1061 function topatient(newpid
, enc
) {
1062 if ($
('#setting_new_window').val() === 'checked') {
1063 openNewTopWindow(newpid
, enc
);
1066 top
.restoreSession();
1068 top
.RTop
.location
= "<?php echo $GLOBALS['webroot']; ?>/interface/patient_file/summary/demographics.php?set_pid=" + newpid +
"&set_encounterid=" + enc
;
1071 top
.RTop
.location
= "<?php echo $GLOBALS['webroot']; ?>/interface/patient_file/summary/demographics.php?set_pid=" + newpid
;
1076 function doCALLback(eventdate
, eid
, pccattype
) {
1077 $
("#progCALLback_" + eid
).parent().removeClass('js-blink-infinite').css('animation-name', 'none');
1078 $
("#progCALLback_" + eid
).removeClass("hidden");
1079 clearInterval(auto_refresh
);
1082 // opens the demographic and encounter screens in a new window
1083 function openNewTopWindow(newpid
, newencounterid
) {
1084 document
.fnew
.patientID
.value
= newpid
;
1085 document
.fnew
.encounterID
.value
= newencounterid
;
1086 top
.restoreSession();
1087 document
.fnew
.submit();
1090 //opens the two-way SMS phone app
1094 function SMS_bot(pid
) {
1095 top
.restoreSession();
1096 var from
= '<?php echo attr($from_date); ?>';
1097 var to
= '<?php echo attr($to_date); ?>';
1098 var oefrom
= '<?php echo attr(oeFormatShortDate($from_date)); ?>';
1099 var oeto
= '<?php echo attr(oeFormatShortDate($to_date)); ?>';
1100 window
.open('../main/messages/messages.php?nomenu=1&go=SMS_bot&pid=' + pid +
'&to=' + to +
'&from=' + from +
'&oeto=' + oeto +
'&oefrom=' + oefrom
, 'SMS_bot', 'width=370,height=600,resizable=0');
1104 function kiosk_FLB() {
1105 $
("#kiosk").val('1');
1106 $
("[name='kiosk_hide']").hide();
1107 $
("[name='kiosk_show']").show();
1108 var i
= document
.getElementById("flb_table");
1110 if (i
.requestFullscreen
) {
1111 i
.requestFullscreen();
1112 } else if (i
.webkitRequestFullscreen
) {
1113 i
.webkitRequestFullscreen();
1114 } else if (i
.mozRequestFullScreen
) {
1115 i
.mozRequestFullScreen();
1116 } else if (i
.msRequestFullscreen
) {
1117 i
.msRequestFullscreen();
1122 $
(document
).ready(function () {
1124 $
("#kiosk").val('');
1125 $
("[name='kiosk_hide']").show();
1126 $
("[name='kiosk_show']").hide();
1128 onresize
= function () {
1129 var state
= 1 >= outerHeight
- innerHeight ?
"fullscreen" : "windowed";
1130 if (window
.state
=== state
) return;
1131 window
.state
= state
;
1132 var event
= document
.createEvent("Event");
1133 event
.initEvent(state
, true, true);
1134 window
.dispatchEvent(event
);
1137 addEventListener('windowed', function (e
) {
1138 $
("#kiosk").val('');
1139 $
("[name='kiosk_hide']").show();
1140 $
("[name='kiosk_show']").hide();
1143 addEventListener('fullscreen', function (e
) {
1144 $
("#kiosk").val('1');
1145 $
("[name='kiosk_hide']").hide();
1146 $
("[name='kiosk_show']").show();
1151 if ($GLOBALS['pat_trkr_timer'] != '0') {
1153 var reftime
= "<?php echo attr($GLOBALS['pat_trkr_timer']); ?>";
1154 var parsetime
= reftime
.split(":");
1155 parsetime
= (parsetime
[0] * 60) +
(parsetime
[1] * 1) * 1000;
1156 if (auto_refresh
) clearInteral(auto_refresh
);
1157 auto_refresh
= setInterval(function () {
1158 refreshMe() // this will run after every parsetime seconds
1164 $
('#settings').css("display", "none");
1165 $
('.js-blink-infinite').each(function () {
1166 // set up blinking text
1168 setInterval(function () {
1169 if (elem
.css('visibility') === 'hidden') {
1170 elem
.css('visibility', 'visible');
1172 elem
.css('visibility', 'hidden');
1176 // toggle of the check box status for drug screen completed and ajax call to update the database
1177 $
(".drug_screen_completed").change(function () {
1178 top
.restoreSession();
1180 testcomplete_toggle
= "true";
1182 testcomplete_toggle
= "false";
1184 $
.post("../../library/ajax/drug_screen_completed.php", {
1186 testcomplete
: testcomplete_toggle
1190 // mdsupport - Immediately post changes to setting_new_window
1191 $
('#setting_new_window').click(function () {
1192 $
('#setting_new_window').val(this
.checked ?
'checked' : ' ');
1193 $
.post("<?php echo basename(__FILE__) ?>", {
1194 'setting_new_window': $
('#setting_new_window').val(),
1195 success
: function (data
) {
1200 $
('#setting_cog').click(function () {
1201 $
(this
).css("display", "none");
1202 $
('#settings').css("display", "inline");
1205 $
('#refreshme').click(function () {
1210 $
('#filter_submit').click(function (e
) {
1216 $
('[data-toggle="tooltip"]').tooltip();
1218 $
('.datepicker').datetimepicker({
1219 <?php
$datetimepicker_timepicker = false; ?
>
1220 <?php
$datetimepicker_showseconds = false; ?
>
1221 <?php
$datetimepicker_formatInput = true; ?
>
1222 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
1223 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>