4 * Patient Tracker (Patient Flow Board)
6 * This program displays the information entered in the Calendar program ,
7 * allowing the user to change status and view those changed here and in the Calendar
8 * Will allow the collection of length of time spent in each status
11 * @link http://www.open-emr.org
12 * @author Terry Hill <terry@lilysystems.com>
13 * @author Brady Miller <brady.g.miller@gmail.com>
14 * @author Ray Magauran <magauran@medexbank.com>
15 * @copyright Copyright (c) 2015-2017 Terry Hill <terry@lillysystems.com>
16 * @copyright Copyright (c) 2017-2021 Brady Miller <brady.g.miller@gmail.com>
17 * @copyright Copyright (c) 2017 Ray Magauran <magauran@medexbank.com>
18 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
21 require_once "../globals.php";
22 require_once "$srcdir/patient.inc.php";
23 require_once "$srcdir/options.inc.php";
24 require_once "$srcdir/patient_tracker.inc.php";
25 require_once "$srcdir/user.inc.php";
26 require_once "$srcdir/MedEx/API.php";
28 use OpenEMR\Common\Csrf\CsrfUtils
;
29 use OpenEMR\Core\Header
;
32 if (!CsrfUtils
::verifyCsrfToken($_POST["csrf_token_form"])) {
33 CsrfUtils
::csrfNotVerified();
37 // These settings are sticky user preferences linked to a given page.
38 // mdsupport - user_settings prefix
39 $uspfx = substr(__FILE__
, strlen($webserver_root)) . '.';
40 $setting_new_window = prevSetting($uspfx, 'setting_new_window', 'setting_new_window', ' ');
41 // flow board and recall board share bootstrap settings:
42 $setting_bootstrap_submenu = prevSetting('', 'setting_bootstrap_submenu', 'setting_bootstrap_submenu', ' ');
43 $setting_selectors = prevSetting($uspfx, 'setting_selectors', 'setting_selectors', 'block');
44 $form_apptcat = prevSetting($uspfx, 'form_apptcat', 'form_apptcat', '');
45 $form_apptstatus = prevSetting($uspfx, 'form_apptstatus', 'form_apptstatus', '');
46 $facility = prevSetting($uspfx, 'form_facility', 'form_facility', '');
47 $provider = prevSetting($uspfx, 'form_provider', 'form_provider', $_SESSION['authUserID']);
50 ($_POST['setting_new_window'] ??
'') ||
51 ($_POST['setting_bootstrap_submenu'] ??
'') ||
52 ($_POST['setting_selectors'] ??
'')
54 // These are not form elements. We only ever change them via ajax, so exit now.
58 //set default start date of flow board to value based on globals
59 if (!$GLOBALS['ptkr_date_range']) {
60 $from_date = date('Y-m-d');
61 } elseif (!is_null($_REQUEST['form_from_date'] ??
null)) {
62 $from_date = DateToYYYYMMDD($_REQUEST['form_from_date']);
63 } elseif (($GLOBALS['ptkr_start_date']) == 'D0') {
64 $from_date = date('Y-m-d');
65 } elseif (($GLOBALS['ptkr_start_date']) == 'B0') {
66 if (date(w
) == GLOBALS
['first_day_week']) {
67 //today is the first day of the week
68 $from_date = date('Y-m-d');
69 } elseif ($GLOBALS['first_day_week'] == 0) {
71 $from_date = date('Y-m-d', strtotime('previous sunday'));
72 } elseif ($GLOBALS['first_day_week'] == 1) {
74 $from_date = date('Y-m-d', strtotime('previous monday'));
75 } elseif ($GLOBALS['first_day_week'] == 6) {
77 $from_date = date('Y-m-d', strtotime('previous saturday'));
80 //shouldnt be able to get here...
81 $from_date = date('Y-m-d');
84 //set default end date of flow board to value based on globals
85 if ($GLOBALS['ptkr_date_range']) {
86 if (substr($GLOBALS['ptkr_end_date'], 0, 1) == 'Y') {
87 $ptkr_time = substr($GLOBALS['ptkr_end_date'], 1, 1);
88 $ptkr_future_time = mktime(0, 0, 0, date('m'), date('d'), date('Y') +
$ptkr_time);
89 } elseif (substr($GLOBALS['ptkr_end_date'], 0, 1) == 'M') {
90 $ptkr_time = substr($GLOBALS['ptkr_end_date'], 1, 1);
91 $ptkr_future_time = mktime(0, 0, 0, date('m') +
$ptkr_time, date('d'), date('Y'));
92 } elseif (substr($GLOBALS['ptkr_end_date'], 0, 1) == 'D') {
93 $ptkr_time = substr($GLOBALS['ptkr_end_date'], 1, 1);
94 $ptkr_future_time = mktime(0, 0, 0, date('m'), date('d') +
$ptkr_time, date('Y'));
97 $to_date = date('Y-m-d', $ptkr_future_time);
98 $to_date = !is_null($_REQUEST['form_to_date'] ??
null) ?
DateToYYYYMMDD($_REQUEST['form_to_date']) : $to_date;
100 $to_date = date('Y-m-d');
103 $form_patient_name = !is_null($_POST['form_patient_name'] ??
null) ?
$_POST['form_patient_name'] : null;
104 $form_patient_id = !is_null($_POST['form_patient_id'] ??
null) ?
$_POST['form_patient_id'] : null;
107 $lres = sqlStatement("SELECT option_id, title FROM list_options WHERE list_id = ? AND activity=1", array('apptstat'));
108 while ($lrow = sqlFetchArray($lres)) {
109 // if exists, remove the legend character
110 if ($lrow['title'][1] == ' ') {
111 $splitTitle = explode(' ', $lrow['title']);
112 array_shift($splitTitle);
113 $title = implode(' ', $splitTitle);
115 $title = $lrow['title'];
117 $statuses_list[$lrow['option_id']] = $title;
120 if ($GLOBALS['medex_enable'] == '1') {
121 $query2 = "SELECT * FROM medex_icons";
122 $iconed = sqlStatement($query2);
123 while ($icon = sqlFetchArray($iconed)) {
124 $icons[$icon['msg_type']][$icon['msg_status']]['html'] = $icon['i_html'];
126 $MedEx = new MedExApi\
MedEx('MedExBank.com');
127 $sql = "SELECT * FROM medex_prefs LIMIT 1";
128 $preferences = sqlStatement($sql);
129 $prefs = sqlFetchArray($preferences);
130 $results = json_decode($prefs['status'], true);
131 $logged_in = $results;
132 $logged_in = $results;
133 if (!empty($logged_in['token'])) {
134 $current_events = xlt("On-line");
136 $current_events = xlt("Currently off-line");
140 if (!($_REQUEST['flb_table'] ??
null)) {
144 <meta name
="author" content
="OpenEMR: MedExBank" />
145 <?php Header
::setupHeader(['datetime-picker', 'opener']); ?
>
146 <title
><?php
echo xlt('Flow Board'); ?
></title
>
148 <?php
require_once "$srcdir/restoreSession.php"; ?
>
151 <?php
if ($_SESSION['language_direction'] == "rtl") { ?
>
152 <link rel
="stylesheet" href
="<?php echo $GLOBALS['themes_static_relative']; ?>/misc/rtl_bootstrap_navbar.css?v=<?php echo $GLOBALS['v_js_includes']; ?>" />
154 <link rel
="stylesheet" href
="<?php echo $GLOBALS['themes_static_relative']; ?>/misc/bootstrap_navbar.css?v=<?php echo $GLOBALS['v_js_includes']; ?>" />
157 <script src
="<?php echo $GLOBALS['web_root']; ?>/interface/main/messages/js/reminder_appts.js?v=<?php echo $v_js_includes; ?>"></script
>
162 if (($GLOBALS['medex_enable'] == '1') && (empty($_REQUEST['nomenu']))) {
163 $logged_in = $MedEx->login();
164 $MedEx->display
->navigation($logged_in);
167 <div
class="container mt-3">
168 <div id
="flb_selectors" style
="display:<?php echo attr($setting_selectors); ?>;">
169 <h2
class="text-center"><?php
echo xlt('Flow Board'); ?
></h2
>
170 <div
class="jumbotron p-4">
171 <div
class="showRFlow text-center" id
="show_flows" name
="kiosk_hide">
172 <div name
="div_response" id
="div_response" class="nodisplay"></div
>
173 <form name
="flb" id
="flb" method
="post">
175 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
176 <div
class="text-center col-4 align-items-center">
177 <!-- Visit Categories Section
-->
179 <select id
="form_apptcat" name
="form_apptcat" class="form-control form-control-sm" onchange
="refineMe('apptcat');">
181 $categories = fetchAppointmentCategories();
182 echo "<option value=''>" . xlt("Visit Categories") . "</option>";
183 while ($cat = sqlFetchArray($categories)) {
184 echo "<option value='" . attr($cat['id']) . "'";
185 if ($cat['id'] == ($_POST['form_apptcat'] ??
null)) {
186 echo " selected='true' ";
188 echo ">" . xlt($cat['category']) . "</option>";
193 <!-- Visit Status Section
-->
195 <select id
="form_apptstatus" name
="form_apptstatus" class="form-control form-control-sm" onchange
="refineMe();">
196 <option value
=""><?php
echo xlt("Visit Status"); ?
></option
>
198 $apptstats = sqlStatement("SELECT * FROM list_options WHERE list_id = 'apptstat' AND activity = 1 ORDER BY seq");
199 while ($apptstat = sqlFetchArray($apptstats)) {
200 echo "<option value='" . attr($apptstat['option_id']) . "'";
201 if ($apptstat['option_id'] == ($_POST['form_apptstatus'] ??
null)) {
202 echo " selected='true' ";
204 echo ">" . xlt($apptstat['title']) . "</option>";
209 <!-- Facility Section
-->
211 <select
class="form-control form-control-sm" id
="form_facility" name
="form_facility"
213 $fac_sql = sqlStatement("SELECT * FROM facility ORDER BY id");
214 while ($fac = sqlFetchArray($fac_sql)) {
215 $true = ($fac['id'] == ($_POST['form_facility'] ??
null)) ?
"selected=true" : '';
216 ($select_facs ??
null) ?
$select_facs : $select_facs = '';
217 $select_facs .= "<option value=" . attr($fac['id']) . " " . $true . ">" . text($fac['name']) . "</option>\n";
218 ($count ??
null) ?
$count_facs : $count_facs = 0;
221 if ($count_facs < '1') {
224 ?
> onchange
="refineMe('facility');">
225 <option value
=""><?php
echo xlt('All Facilities'); ?
></option
>
226 <?php
echo $select_facs; ?
>
231 // Build a drop-down list of ACTIVE providers.
232 $query = "SELECT id, lname, fname FROM users WHERE " .
233 "authorized = 1 AND active = 1 AND username > '' ORDER BY lname, fname"; #(CHEMED) facility filter
234 $ures = sqlStatement($query);
235 while ($urow = sqlFetchArray($ures)) {
236 $provid = $urow['id'];
237 ($select_provs ??
null) ?
$select_provs : $select_provs = '';
238 $select_provs .= " <option value='" . attr($provid) . "'";
239 if (isset($_POST['form_provider']) && $provid == $_POST['form_provider']) {
240 $select_provs .= " selected";
241 } elseif (!isset($_POST['form_provider']) && $_SESSION['userauthorized'] && $provid == $_SESSION['authUserID']) {
242 $select_provs .= " selected";
244 $select_provs .= ">" . text($urow['lname']) . ", " . text($urow['fname']) . "\n";
245 ($count_provs ??
null) ?
$count_provs : $count_provs = 0;
249 <!-- Provider Section
-->
251 <select
class="form-control form-control-sm" id
="form_provider" name
="form_provider" <?php
252 if ($count_provs < '2') {
255 ?
> onchange
="refineMe('provider');">
256 <option value
="" selected
><?php
echo xlt('All Providers'); ?
></option
>
265 if ($GLOBALS['ptkr_date_range'] == '1') {
270 $style = 'display:none;';
272 <div
class="col-4 mt-3 nowrap row" style
="<?php echo $style; ?>">
274 <label
class="col-form-label col-sm-3 text-right" for="flow_from"><?php
echo xlt('From'); ?
>:</label
>
275 <div
class="col-sm-9">
276 <input type
="text" id
="form_from_date" name
="form_from_date" class="datepicker form-control form-control-sm text-center" value
="<?php echo attr(oeFormatShortDate($from_date)); ?>"/>
278 <label
class="col-form-label col-sm-3 text-right" for="flow_to"><?php
echo xlt('To{{Range}}'); ?
>:</label
>
279 <div
class="col-sm-9">
280 <input type
="text" id
="form_to_date" name
="form_to_date" class="datepicker form-control form-control-sm text-center" value
="<?php echo attr(oeFormatShortDate($to_date)); ?>"/>
283 <div
class="col-sm-12 mt-3 mx-auto">
284 <button id
="filter_submit" class="btn btn-primary btn-sm btn-filter"><?php
echo xlt('Filter'); ?
></button
>
285 <input type
="hidden" id
="kiosk" name
="kiosk" value
="<?php echo attr($_REQUEST['kiosk'] ?? ''); ?>" />
288 <div
class="col-4 mt-3 row">
289 <div
class="col-sm-12 text-center">
290 <!-- Patient Name Section
-->
291 <input type
="text" placeholder
="<?php echo xla('Patient Name'); ?>" class="form-control form-control-sm" id
="form_patient_name" name
="form_patient_name" value
="<?php echo ($form_patient_name) ? attr($form_patient_name) : ""; ?>" onKeyUp
="refineMe();" />
293 <div
class="col-sm-12 text-center">
294 <!-- Patient ID Section
-->
295 <input placeholder
="<?php echo xla('Patient ID'); ?>" class="form-control form-control-sm" type
="text" id
="form_patient_id" name
="form_patient_id" value
="<?php echo ($form_patient_id) ? attr($form_patient_id) : ""; ?>" onKeyUp
="refineMe();" />
297 <div
class="col-sm-12 mx-auto">
298 <div
class="text-center pt-3 mx-auto">
300 <?php
if ($GLOBALS['medex_enable'] == '1') { ?
>
302 <a href
="https://medexbank.com/cart/upload/index.php?route=information/campaigns&g=rem"
304 <?php
echo $current_events; ?
>
310 <div id
="message" class="warning"></div
>
316 <div
class="row-fluid">
317 <div
class="col-md-12">
318 <div
class="text-center row mx-auto divTable">
319 <div
class="col-sm-12" id
="loader">
320 <div
class="spinner-border" role
="status">
321 <span
class="sr-only"><?php
echo xlt('Loading data'); ?
>...</span
>
323 <h2
><?php
echo xlt('Loading data'); ?
>...</h2
>
325 <div id
="flb_table" name
="flb_table" class="w-100">
328 //end of if !$_REQUEST['flb_table'] - this is the table we fetch via ajax during a refreshMe() call
329 // get all appts for date range and refine view client side. very fast...
330 $appointments = array();
331 $datetime = date("Y-m-d H:i:s");
332 $appointments = fetch_Patient_Tracker_Events($from_date, $to_date, '', '', '', '', $form_patient_name, $form_patient_id);
333 $appointments = sortAppointments($appointments, 'date', 'time');
334 //grouping of the count of every status
335 $appointments_status = getApptStatus($appointments);
337 $chk_prov = array(); // list of providers with appointments
338 // Scan appointments for additional info
339 foreach ($appointments as $apt) {
340 $chk_prov[$apt['uprovider_id']] = $apt['ulname'] . ', ' . $apt['ufname'] . ' ' . $apt['umname'];
343 <div
class="col-sm-12 text-center m-1">
344 <div
class=" d-sm-block">
345 <span id
="status_summary">
347 $statuses_output = "<span class='text badge badge-light'><em>" . xlt('Total patients') . ':</em> ' . text($appointments_status['count_all']) . "</span>";
348 unset($appointments_status['count_all']);
349 foreach ($appointments_status as $status_symbol => $count) {
350 $statuses_output .= " | <span><em>" . text(xl_list_label($statuses_list[$status_symbol])) . ":</em> <span class='badge badge-light'>" . text($count) . "</span></span>";
352 echo $statuses_output;
356 <div id
="pull_kiosk_right" class="text-right">
357 <span
class="fa-stack fa-lg" id
="flb_caret" onclick
="toggleSelectors();" title
="<?php echo xla('Show/Hide the Selection Area'); ?>" style
="color:<?php echo $color = ($setting_selectors == 'none') ? 'var(--danger)' : 'var(--black)'; ?>;">
358 <i
class="far fa-square fa-stack-2x"></i
>
359 <i id
="print_caret" class='fa fa-caret-<?php echo $caret = ($setting_selectors == 'none
') ? 'down
' : 'up
'; ?> fa-stack-1x'></i
>
362 <a
class="btn btn-primary btn-setting" data
-toggle
="collapse" href
="#collapseSetting">
363 <?php
echo xlt('Setting'); ?
>
365 <a
class='btn btn-primary btn-refresh' id
='refreshme'><?php
echo xlt('Refresh'); ?
></a
>
366 <a
class='btn btn-primary btn-print' onclick
="print_FLB();"> <?php
echo xlt('Print'); ?
></a
>
367 <a
class='btn btn-primary' onclick
="kiosk_FLB();"> <?php
echo xlt('Kiosk'); ?
></a
>
368 <div
class="collapse mt-2 mb-2" id
="collapseSetting">
369 <input type
='checkbox' name
='setting_new_window' id
='setting_new_window' value
='<?php echo attr($setting_new_window); ?>' <?php
echo attr($setting_new_window); ?
> />
370 <?php
echo xlt('Open Patient in New Window'); ?
>
375 <div
class="table-responsive mt-3">
376 <table
class="table table-bordered">
377 <thead
class="table-primary">
378 <tr
class="small font-weight-bold text-center">
379 <?php
if ($GLOBALS['ptkr_show_pid']) { ?
>
380 <td
class="dehead text-center text-ovr-dark" name
="kiosk_hide">
381 <?php
echo xlt('PID'); ?
>
384 <td
class="dehead text-center text-ovr-dark" style
="max-width: 150px;">
385 <?php
echo xlt('Patient'); ?
>
387 <?php
if ($GLOBALS['ptkr_visit_reason'] == '1') { ?
>
388 <td
class="dehead text-center text-ovr-dark" name
="kiosk_hide">
389 <?php
echo xlt('Reason'); ?
>
392 <?php
if ($GLOBALS['ptkr_show_encounter']) { ?
>
393 <td
class="dehead text-center text-ovr-dark" name
="kiosk_hide">
394 <?php
echo xlt('Encounter'); ?
>
398 <?php
if ($GLOBALS['ptkr_date_range'] == '1') { ?
>
399 <td
class="dehead text-center text-ovr-dark" name
="kiosk_hide">
400 <?php
echo xlt('Appt Date'); ?
>
403 <td
class="dehead text-center text-ovr-dark">
404 <?php
echo xlt('Appt Time'); ?
>
406 <td
class="dehead text-center text-ovr-dark">
407 <?php
echo xlt('Arrive Time'); ?
>
409 <td
class="dehead text-center d-block d-sm-none text-ovr-dark">
410 <?php
echo xlt('Arrival'); ?
>
412 <td
class="dehead text-center d-sm-table-cell text-ovr-dark">
413 <?php
echo xlt('Appt Status'); ?
>
415 <td
class="dehead text-center d-sm-table-cell text-ovr-dark">
416 <?php
echo xlt('Current Status'); ?
>
418 <td
class="dehead text-center d-block d-table-cell d-sm-none text-ovr-dark">
419 <?php
echo xlt('Current'); ?
>
421 <td
class="dehead text-center text-ovr-dark" name
="kiosk_hide">
422 <?php
echo xlt('Visit Type'); ?
>
424 <?php
if (count($chk_prov) > 1) { ?
>
425 <td
class="dehead text-center d-sm-table-cell text-ovr-dark">
426 <?php
echo xlt('Provider'); ?
>
429 <td
class="dehead text-center text-ovr-dark">
430 <?php
echo xlt('Total Time'); ?
>
432 <td
class="dehead text-center d-sm-table-cell text-ovr-dark">
433 <?php
echo xlt('Check Out Time'); ?
>
435 <td
class="dehead text-center d-block d-table-cell d-sm-none text-ovr-dark">
436 <?php
echo xlt('Out Time'); ?
>
439 if ($GLOBALS['ptkr_show_staff']) { ?
>
440 <td
class="dehead text-center text-ovr-dark" name
="kiosk_hide">
441 <?php
echo xlt('Updated By'); ?
>
445 if ($_REQUEST['kiosk'] != '1') {
446 if ($GLOBALS['drug_screen']) { ?
>
447 <td
class="dehead center text-ovr-dark" name
="kiosk_hide">
448 <?php
echo xlt('Random Drug Screen'); ?
>
450 <td
class="dehead center text-ovr-dark" name
="kiosk_hide">
451 <?php
echo xlt('Drug Screen Completed'); ?
>
460 $prev_appt_date_time = "";
461 foreach ($appointments as $appointment) {
462 // Collect appt date and set up squashed date for use below
463 $date_appt = $appointment['pc_eventDate'];
464 $date_squash = str_replace("-", "", $date_appt);
465 if (empty($appointment['room']) && ($logged_in ??
null) && ($setting_bootstrap_submenu != 'hide')) {
466 //Patient has not arrived yet, display MedEx Reminder info
467 //one icon per type of response.
468 //If there was a SMS dialog, display it as a mouseover/title
469 //Display date received also as mouseover title.
474 $icon_here = array();
478 $query = "SELECT * FROM medex_outgoing WHERE msg_pc_eid =? ORDER BY medex_uid asc";
479 $myMedEx = sqlStatement($query, array($appointment['eid']));
481 * Each row for this pc_eid in the medex_outgoing table represents an event.
482 * Every event is recorded in $prog_text.
483 * A modality is represented by an icon (eg mail icon, phone icon, text icon).
484 * The state of the Modality is represented by the color of the icon:
488 * SENT/in process = yellow
490 * Icons are displayed in their highest state.
492 while ($row = sqlFetchArray($myMedEx)) {
493 // Need to convert $row['msg_date'] to localtime (stored as GMT) & then oeFormatShortDate it.
494 // I believe there is a new GLOBAL for server timezone??? If so, it will be easy.
495 // If not we need to import it from Medex through medex_preferences. It should really be in openEMR though.
496 // Delete when we figure this out.
498 if (!empty($row['msg_extra_text'])) {
499 $local = attr($row['msg_extra_text']) . " |";
501 $prog_text .= attr(oeFormatShortDate($row['msg_date'])) . " :: " . attr($row['msg_type']) . " : " . attr($row['msg_reply']) . " | " . $local . " |";
503 if ($row['msg_reply'] == 'Other') {
504 $other_title .= $row['msg_extra_text'] . "\n";
505 $icon_extra .= str_replace(
507 attr(oeFormatShortDate($row['msg_date'])) . "\n" . xla('Patient Message') . ":\n" . attr($row['msg_extra_text']) . "\n",
508 $icons[$row['msg_type']]['EXTRA']['html']
511 } elseif ($row['msg_reply'] == 'CANCELLED') {
512 $appointment[$row['msg_type']]['stage'] = "CANCELLED";
513 $icon_here[$row['msg_type']] = '';
514 } elseif ($row['msg_reply'] == "FAILED") {
515 $appointment[$row['msg_type']]['stage'] = "FAILED";
516 $icon_here[$row['msg_type']] = $icons[$row['msg_type']]['FAILED']['html'];
517 } elseif (($row['msg_reply'] == "CONFIRMED") ||
($appointment[$row['msg_type']]['stage'] == "CONFIRMED")) {
518 $appointment[$row['msg_type']]['stage'] = "CONFIRMED";
519 $icon_here[$row['msg_type']] = $icons[$row['msg_type']]['CONFIRMED']['html'];
520 } elseif (($row['msg_reply'] == "READ") ||
($appointment[$row['msg_type']]['stage'] == "READ")) {
521 $appointment[$row['msg_type']]['stage'] = "READ";
522 $icon_here[$row['msg_type']] = $icons[$row['msg_type']]['READ']['html'];
523 } elseif (($row['msg_reply'] == "SENT") ||
($appointment[$row['msg_type']]['stage'] == "SENT")) {
524 $appointment[$row['msg_type']]['stage'] = "SENT";
525 $icon_here[$row['msg_type']] = $icons[$row['msg_type']]['SENT']['html'];
526 } elseif (($row['msg_reply'] == "To Send") ||
(empty($appointment['stage']))) {
528 ($appointment[$row['msg_type']]['stage'] != "CONFIRMED") &&
529 ($appointment[$row['msg_type']]['stage'] != "READ") &&
530 ($appointment[$row['msg_type']]['stage'] != "SENT") &&
531 ($appointment[$row['msg_type']]['stage'] != "FAILED")
533 $appointment[$row['msg_type']]['stage'] = "QUEUED";
534 $icon_here[$row['msg_type']] = $icons[$row['msg_type']]['SCHEDULED']['html'];
537 //these are additional icons if present
538 if ($row['msg_reply'] == "CALL") {
539 $icon_here[$row['msg_type']] = $icons[$row['msg_type']]['CALL']['html'];
540 if (($appointment['allow_sms'] != "NO") && ($appointment['phone_cell'] > '')) {
541 $icon_4_CALL = "<span class='input-group-addon'
542 onclick='SMS_bot(" . attr_js($row['msg_pid']) . ");'>
543 <i class='fas fa-sms'></i>
546 } elseif ($row['msg_reply'] == "STOP") {
547 $icon2_here .= $icons[$row['msg_type']]['STOP']['html'];
548 } elseif ($row['msg_reply'] == "Other") {
549 $icon2_here .= $icons[$row['msg_type']]['Other']['html'];
552 //if pc_apptstatus == '-', update it now to=status
553 if (!empty($other_title)) {
554 $appointment['messages'] = $icon2_here . $icon_extra;
558 // Collect variables and do some processing
559 $docname = $chk_prov[$appointment['uprovider_id']];
560 if (strlen($docname) <= 3) {
563 $ptname = $appointment['lname'] . ', ' . $appointment['fname'] . ' ' . $appointment['mname'];
564 $ptname_short = $appointment['fname'][0] . " " . $appointment['lname'][0];
565 $appt_enc = $appointment['encounter'];
566 $appt_eid = (!empty($appointment['eid'])) ?
$appointment['eid'] : $appointment['pc_eid'];
567 $appt_pid = (!empty($appointment['pid'])) ?
$appointment['pid'] : $appointment['pc_pid'];
568 if ($appt_pid == 0) {
569 continue; // skip when $appt_pid = 0, since this means it is not a patient specific appt slot
571 $status = (!empty($appointment['status']) && (!is_numeric($appointment['status']))) ?
$appointment['status'] : $appointment['pc_apptstatus'];
572 $appt_room = (!empty($appointment['room'])) ?
$appointment['room'] : $appointment['pc_room'];
573 $appt_time = (!empty($appointment['appttime'])) ?
$appointment['appttime'] : $appointment['pc_startTime'];
574 $tracker_id = $appointment['id'];
576 if ($GLOBALS['ptkr_visit_reason']) {
577 $reason_visit = $appointment['pc_hometext'];
579 $newarrive = collect_checkin($tracker_id);
580 $newend = collect_checkout($tracker_id);
581 $colorevents = (collectApptStatusSettings($status));
582 $bgcolor = $colorevents['color'];
583 $statalert = $colorevents['time_alert'];
584 // process the time to allow items with a check out status to be displayed
585 if (is_checkout($status) && (($GLOBALS['checkout_roll_off'] > 0) && strlen($form_apptstatus) != 1)) {
586 $to_time = strtotime($newend);
587 $from_time = strtotime($datetime);
588 $display_check_out = round(abs($from_time - $to_time) / 60, 0);
589 if ($display_check_out >= $GLOBALS['checkout_roll_off']) {
594 echo '<tr data-apptstatus="' . attr($appointment['pc_apptstatus']) . '"
595 data-apptcat="' . attr($appointment['pc_catid']) . '"
596 data-facility="' . attr($appointment['pc_facility']) . '"
597 data-provider="' . attr($appointment['uprovider_id']) . '"
598 data-pid="' . attr($appointment['pc_pid']) . '"
599 data-pname="' . attr($ptname) . '"
601 style="background-color:' . attr($bgcolor) . ';" >';
603 if ($GLOBALS['ptkr_show_pid']) {
605 <td
class="detail text-center" name
="kiosk_hide">
606 <?php
echo text($appt_pid); ?
>
612 <td
class="detail text-center" name
="kiosk_hide">
613 <a href
="#" onclick
="return topatient(<?php echo attr_js($appt_pid); ?>,<?php echo attr_js($appt_enc); ?>)">
614 <?php
echo text($ptname); ?
></a
>
617 <td
class="detail text-center" style
="white-space: normal;" name
="kiosk_show">
618 <a href
="#" onclick
="return topatient(<?php echo attr_js($appt_pid); ?>,<?php echo attr_js($appt_enc); ?>)">
619 <?php
echo text($ptname_short); ?
></a
>
623 <?php
if ($GLOBALS['ptkr_visit_reason']) { ?
>
624 <td
class="detail text-center" name
="kiosk_hide">
625 <?php
echo text($reason_visit) ?
>
628 <?php
if ($GLOBALS['ptkr_show_encounter']) { ?
>
629 <td
class="detail text-center" name
="kiosk_hide">
631 if ($appt_enc != 0) {
632 echo text($appt_enc);
637 <?php
if ($GLOBALS['ptkr_date_range'] == '1') { ?
>
638 <td
class="detail text-center" name
="kiosk_hide">
639 <?php
echo text(oeFormatShortDate($appointment['pc_eventDate']));
643 <td
class="detail text-center">
644 <?php
echo text(oeFormatTime($appt_time)); ?
>
646 <td
class="detail text-center">
649 echo text(oeFormatTime($newarrive));
653 <td
class="detail text-center ">
654 <?php
if (empty($tracker_id)) { //for appt not yet with tracker id and for recurring appt ?>
655 <a
class="btn btn-primary btn-sm" onclick
="return calendarpopup(<?php echo attr_js($appt_eid) . "," . attr_js($date_squash); // calls popup for add edit calendar event?>)">
657 <a
class="btn btn-primary btn-s" onclick
="return bpopup(<?php echo attr_js($tracker_id); // calls popup for patient tracker status?>)">
660 if ($appointment['room'] > '') {
661 echo text(getListItemTitle('patient_flow_board_rooms', $appt_room));
663 echo text(getListItemTitle("apptstat", $status)); // drop down list for appointment status
670 //time in current status
671 $to_time = strtotime(date("Y-m-d H:i:s"));
673 if (strtotime($newend) != '') {
674 $from_time = strtotime($newarrive);
675 $to_time = strtotime($newend);
678 $from_time = (($appointment['start_datetime'] ??
null) ?
strtotime($appointment['start_datetime']) : null);
682 $timecheck = round(abs($to_time - ($from_time ??
null)) / 60, 0);
683 if ($timecheck >= $statalert && ($statalert > '0')) { // Determine if the time in status limit has been reached.
684 echo "<td class='text-center js-blink-infinite small' nowrap> "; // and if so blink
686 echo "<td class='detail text-center' nowrap> "; // and if not do not blink
688 if (($yestime == '1') && ($timecheck >= 1) && (strtotime($newarrive) != '')) {
689 echo text($timecheck . ' ' . ($timecheck >= 2 ?
xl('minutes') : xl('minute')));
690 } elseif (($icon_here ??
null) ||
($icon2_here ??
null)) {
691 echo "<span style='font-size:0.7rem;' onclick='return calendarpopup(" . attr_js($appt_eid) . "," . attr_js($date_squash) . ")'>" . implode($icon_here) . $icon2_here . "</span> " . $icon_4_CALL;
692 } elseif ($logged_in ??
null) {
693 $pat = $MedEx->display
->possibleModalities($appointment);
694 echo "<span style='font-size:0.7rem;' onclick='return calendarpopup(" . attr_js($appt_eid) . "," . attr_js($date_squash) . ")'>" . $pat['SMS'] . $pat['AVM'] . $pat['EMAIL'] . "</span>";
696 //end time in current status
699 <td
class="detail text-center" name
="kiosk_hide">
700 <?php
echo xlt($appointment['pc_title']); ?
>
703 if (count($chk_prov) > 1) { ?
>
704 <td
class="detail text-center d-sm-table-cell">
705 <?php
echo text($docname); ?
>
709 <td
class="detail text-center">
711 // total time in practice
712 if (strtotime($newend) != '') {
713 $from_time = strtotime($newarrive);
714 $to_time = strtotime($newend);
716 $from_time = strtotime($newarrive);
717 $to_time = strtotime(date("Y-m-d H:i:s"));
719 $timecheck2 = round(abs($to_time - $from_time) / 60, 0);
720 if (strtotime($newarrive) != '' && ($timecheck2 >= 1)) {
721 echo text($timecheck2 . ' ' . ($timecheck2 >= 2 ?
xl('minutes') : xl('minute')));
723 // end total time in practice
724 echo text($appointment['pc_time'] ??
''); ?
>
726 <td
class="detail text-center">
728 if (strtotime($newend) != '') {
729 echo text(oeFormatTime(substr($newend, 11))) ;
734 if ($GLOBALS['ptkr_show_staff'] == '1') {
736 <td
class="detail text-center" name
="kiosk_hide">
737 <?php
echo text($appointment['user']) ?
>
741 if ($GLOBALS['drug_screen']) {
742 if (strtotime($newarrive) != '') { ?
>
743 <td
class="detail text-center" name
="kiosk_hide">
745 if ($appointment['random_drug_test'] == '1') {
753 <td
class="detail text-center" name
="kiosk_hide"></td
>
755 if (strtotime($newarrive) != '' && $appointment['random_drug_test'] == '1') { ?
>
756 <td
class="detail text-center" name
="kiosk_hide">
758 if (strtotime($newend) != '') {
759 // the following block allows the check box for drug screens to be disabled once the status is check out ?>
760 <input type
='checkbox' disabled
='disable' class="drug_screen_completed" id
="<?php echo attr($appointment['pt_tracker_id']) ?>" <?php
echo ($appointment['drug_screen_completed'] == "1") ?
"checked" : ""; ?
> />
764 <input type
='checkbox' class="drug_screen_completed" id
='<?php echo attr($appointment['pt_tracker_id
']) ?>' name
="drug_screen_completed" <?php
echo ($appointment['drug_screen_completed'] == "1") ?
"checked" : ""; ?
> />
770 <td
class="detail text-center" name
="kiosk_hide"></td
>
784 if (!($_REQUEST['flb_table'] ??
null)) { ?
>
788 </div
><?php
//end container ?>
789 <!-- form used to open a
new top level window when a patient row is clicked
-->
790 <form name
='fnew' method
='post' target
='_blank' action
='../main/main_screen.php?auth=login&site=<?php echo attr_url($_SESSION['site_id
']); ?>'>
791 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
792 <input type
='hidden' name
='patientID' value
='0' />
793 <input type
='hidden' name
='encounterID' value
='0' />
796 <?php
echo myLocalJS(); ?
>
800 } //end of second !$_REQUEST['flb_table']
809 var auto_refresh
= null;
810 //this can be refined to redact HIPAA material using @media print options.
811 window
.parent
.$
("[name='flb']").attr('allowFullscreen', 'true');
812 $
("[name='kiosk_hide']").show();
813 $
("[name='kiosk_show']").hide();
815 function print_FLB() {
819 function toggleSelectors() {
820 top
.restoreSession();
821 if ($
("#flb_selectors").css('display') === 'none') {
822 $
.post("<?php echo $GLOBALS['webroot'] . "/interface/patient_tracker
/patient_tracker
.php
"; ?>", {
823 setting_selectors
: 'block',
824 csrf_token_form
: <?php
echo js_escape(CsrfUtils
::collectCsrfToken()); ?
>
827 $
("#flb_selectors").slideToggle();
828 if($
("#flb_caret").hasClass('text-danger')) {
829 $
("#flb_caret").removeClass('text-danger');
831 $
("#flb_caret").addClass('text-body');
834 $
.post("<?php echo $GLOBALS['webroot'] . "/interface/patient_tracker
/patient_tracker
.php
"; ?>", {
835 setting_selectors
: 'none',
836 csrf_token_form
: <?php
echo js_escape(CsrfUtils
::collectCsrfToken()); ?
>
839 $
("#flb_selectors").slideToggle();
840 if($
("#flb_caret").hasClass('text-body')) {
841 $
("#flb_caret").removeClass('text-body');
843 $
("#flb_caret").addClass('text-danger');
846 $
("#print_caret").toggleClass('fa-caret-up').toggleClass('fa-caret-down');
850 * This function refreshes the whole flb_table according to our to/from dates.
852 function refreshMe(fromTimer
) {
854 if (typeof fromTimer
=== 'undefined' ||
!fromTimer
) {
855 //Show loader in the first loading or manual loading not by timer
856 $
("#flb_table").html('');
858 skip_timeout_reset
= 0;
860 skip_timeout_reset
= 1;
863 var startRequestTime
= Date
.now();
864 top
.restoreSession();
865 var posting
= $
.post('../patient_tracker/patient_tracker.php', {
867 form_from_date
: $
("#form_from_date").val(),
868 form_to_date
: $
("#form_to_date").val(),
869 form_facility
: $
("#form_facility").val(),
870 form_provider
: $
("#form_provider").val(),
871 form_apptstatus
: $
("#form_apptstatus").val(),
872 form_patient_name
: $
("#form_patient_name").val(),
873 form_patient_id
: $
("#form_patient_id").val(),
874 form_apptcat
: $
("#form_apptcat").val(),
875 kiosk
: $
("#kiosk").val(),
876 skip_timeout_reset
: skip_timeout_reset
,
877 csrf_token_form
: <?php
echo js_escape(CsrfUtils
::collectCsrfToken()); ?
>
880 //minimum 400 ms of loader (In the first loading or manual loading not by timer)
881 if((typeof fromTimer
=== 'undefined' ||
!fromTimer
) && Date
.now() - startRequestTime
< 400 ){
882 setTimeout(drawTable
, 500, data
);
889 function drawTable(data
) {
892 $
("#flb_table").html(data
);
893 if ($
("#kiosk").val() === '') {
894 $
("[name='kiosk_hide']").show();
895 $
("[name='kiosk_show']").hide();
897 $
("[name='kiosk_hide']").hide();
898 $
("[name='kiosk_show']").show();
907 function refreshme() {
908 // Just need this to support refreshme call from the popup used for recurrent appt
913 * This function hides all then shows only the flb_table rows that match our selection, client side.
914 * It is called on initial load, on refresh and 'onchange/onkeyup' of a flow board parameter.
916 function refineMe() {
917 var apptcatV
= $
("#form_apptcat").val();
918 var apptstatV
= $
("#form_apptstatus").val();
919 var facV
= $
("#form_facility").val();
920 var provV
= $
("#form_provider").val();
921 var pidV
= String($
("#form_patient_id").val());
922 var pidRE
= new RegExp(pidV
, 'g');
923 var pnameV
= $
("#form_patient_name").val();
924 var pnameRE
= new RegExp(pnameV
, 'ig');
926 //and hide what we don't want to show
927 $
('#flb_table tbody tr').hide().filter(function () {
928 var d
= $
(this
).data();
929 meets_cat
= (apptcatV
=== '') ||
(apptcatV
== d
.apptcat
);
930 meets_stat
= (apptstatV
=== '') ||
(apptstatV
== d
.apptstatus
);
931 meets_fac
= (facV
=== '') ||
(facV
== d
.facility
);
932 meets_prov
= (provV
=== '') ||
(provV
== d
.provider
);
933 meets_pid
= (pidV
=== '');
934 if ((pidV
> '') && pidRE
.test(d
.pid
)) {
937 meets_pname
= (pnameV
=== '');
938 if ((pnameV
> '') && pnameRE
.test(d
.pname
)) {
941 return meets_pname
&& meets_pid
&& meets_cat
&& meets_stat
&& meets_fac
&& meets_prov
;
945 // popup for patient tracker status
946 function bpopup(tkid
) {
947 top
.restoreSession();
948 dlgopen('../patient_tracker/patient_tracker_status.php?tracker_id=' +
encodeURIComponent(tkid
) +
'&csrf_token_form=' +
<?php
echo js_url(CsrfUtils
::collectCsrfToken()); ?
>, '_blank', 500, 250);
952 // popup for calendar add edit
953 function calendarpopup(eid
, date_squash
) {
954 top
.restoreSession();
955 dlgopen('../main/calendar/add_edit_event.php?eid=' +
encodeURIComponent(eid
) +
'&date=' +
encodeURIComponent(date_squash
), '_blank', 775, 500);
959 // used to display the patient demographic and encounter screens
960 function topatient(newpid
, enc
) {
961 if ($
('#setting_new_window').val() === 'checked') {
962 openNewTopWindow(newpid
, enc
);
965 top
.restoreSession();
967 top
.RTop
.location
= "<?php echo $GLOBALS['webroot']; ?>/interface/patient_file/summary/demographics.php?set_pid=" +
encodeURIComponent(newpid
) +
"&set_encounterid=" +
encodeURIComponent(enc
);
970 top
.RTop
.location
= "<?php echo $GLOBALS['webroot']; ?>/interface/patient_file/summary/demographics.php?set_pid=" +
encodeURIComponent(newpid
);
975 // opens the demographic and encounter screens in a new window
976 function openNewTopWindow(newpid
, newencounterid
) {
977 document
.fnew
.patientID
.value
= newpid
;
978 document
.fnew
.encounterID
.value
= newencounterid
;
979 top
.restoreSession();
980 document
.fnew
.submit();
983 //opens the two-way SMS phone app
987 function SMS_bot(pid
) {
988 top
.restoreSession();
989 var from
= <?php
echo js_escape($from_date ??
''); ?
>;
990 var to
= <?php
echo js_escape($to_date ??
''); ?
>;
991 var oefrom
= <?php
echo js_escape(oeFormatShortDate($from_date ??
null)); ?
>;
992 var oeto
= <?php
echo js_escape(oeFormatShortDate($to_date ??
null)); ?
>;
993 window
.open('../main/messages/messages.php?nomenu=1&go=SMS_bot&pid=' +
encodeURIComponent(pid
) +
'&to=' +
encodeURIComponent(to
) +
'&from=' +
encodeURIComponent(from
) +
'&oeto=' +
encodeURIComponent(oeto
) +
'&oefrom=' +
encodeURIComponent(oefrom
), 'SMS_bot', 'width=370,height=600,resizable=0');
997 function kiosk_FLB() {
998 $
("#kiosk").val('1');
999 $
("[name='kiosk_hide']").hide();
1000 $
("[name='kiosk_show']").show();
1002 var i
= document
.getElementById("flb_table");
1004 if (i
.requestFullscreen
) {
1005 i
.requestFullscreen();
1006 } else if (i
.webkitRequestFullscreen
) {
1007 i
.webkitRequestFullscreen();
1008 } else if (i
.mozRequestFullScreen
) {
1009 i
.mozRequestFullScreen();
1010 } else if (i
.msRequestFullscreen
) {
1011 i
.msRequestFullscreen();
1016 function KioskUp() {
1017 var kv
= $
("#kiosk").val();
1019 $
("#kiosk").val('1');
1020 $
("[name='kiosk_hide']").show();
1021 $
("[name='kiosk_show']").hide();
1023 $
("#kiosk").val('0');
1024 $
("[name='kiosk_hide']").hide();
1025 $
("[name='kiosk_show']").show();
1031 $
("#kiosk").val('');
1032 $
("[name='kiosk_hide']").show();
1033 $
("[name='kiosk_show']").hide();
1035 onresize
= function () {
1036 var state
= 1 >= outerHeight
- innerHeight ?
"fullscreen" : "windowed";
1037 if (window
.state
=== state
) return;
1038 window
.state
= state
;
1039 var event
= document
.createEvent("Event");
1040 event
.initEvent(state
, true, true);
1041 window
.dispatchEvent(event
);
1044 ["fullscreenchange", "webkitfullscreenchange", "mozfullscreenchange", "msfullscreenchange"].forEach(
1045 eventType
=> document
.addEventListener(eventType
, KioskUp
, false)
1048 <?php
if ($GLOBALS['pat_trkr_timer'] != '0') { ?
>
1049 var reftime
= <?php
echo js_escape($GLOBALS['pat_trkr_timer']); ?
>;
1050 var parsetime
= reftime
.split(":");
1051 parsetime
= (parsetime
[0] * 60) +
(parsetime
[1] * 1) * 1000;
1052 if (auto_refresh
) clearInteral(auto_refresh
);
1053 auto_refresh
= setInterval(function () {
1054 refreshMe(true) // this will run after every parsetime seconds
1058 $
('.js-blink-infinite').each(function () {
1059 // set up blinking text
1061 setInterval(function () {
1062 if (elem
.css('visibility') === 'hidden') {
1063 elem
.css('visibility', 'visible');
1065 elem
.css('visibility', 'hidden');
1069 // toggle of the check box status for drug screen completed and ajax call to update the database
1070 $
('body').on('click', '.drug_screen_completed', function () {
1071 top
.restoreSession();
1073 testcomplete_toggle
= "true";
1075 testcomplete_toggle
= "false";
1077 $
.post("../../library/ajax/drug_screen_completed.php", {
1079 testcomplete
: testcomplete_toggle
,
1080 csrf_token_form
: <?php
echo js_escape(CsrfUtils
::collectCsrfToken()); ?
>
1084 // mdsupport - Immediately post changes to setting_new_window
1085 $
('body').on('click', '#setting_new_window', function () {
1086 $
('#setting_new_window').val(this
.checked ?
'checked' : ' ');
1087 top
.restoreSession();
1088 $
.post("<?php echo $GLOBALS['webroot'] . "/interface/patient_tracker
/patient_tracker
.php
"; ?>", {
1089 setting_new_window
: $
('#setting_new_window').val(),
1090 csrf_token_form
: <?php
echo js_escape(CsrfUtils
::collectCsrfToken()); ?
>
1096 $
('#filter_submit').click(function (e
) {
1101 $
('[data-toggle="tooltip"]').tooltip();
1103 $
('.datepicker').datetimepicker({
1104 <?php
$datetimepicker_timepicker = false; ?
>
1105 <?php
$datetimepicker_showseconds = false; ?
>
1106 <?php
$datetimepicker_formatInput = true; ?
>
1107 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
1108 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
1113 function initTableButtons() {
1114 $
('#refreshme').click(function () {