4 * Message and Reminder Center UI
7 * @link http://www.open-emr.org
8 * @author OpenEMR Support LLC
9 * @author Roberto Vasquez <robertogagliotta@gmail.com>
10 * @author Rod Roark <rod@sunsetsystems.com>
11 * @author Brady Miller <brady.g.miller@gmail.com>
12 * @author Ray Magauran <magauran@medfetch.com>
13 * @author Tyler Wrenn <tyler@tylerwrenn.com>
14 * @copyright Copyright (c) 2010 OpenEMR Support LLC
15 * @copyright Copyright (c) 2017 MedEXBank.com
16 * @copyright Copyright (c) 2018-2019 Brady Miller <brady.g.miller@gmail.com>
17 * @copyright Copyright (c) 2020 Tyler Wrenn <tyler@tylerwrenn.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/pnotes.inc");
23 require_once("$srcdir/patient.inc");
24 require_once("$srcdir/options.inc.php");
25 require_once("$srcdir/gprelations.inc.php");
26 require_once "$srcdir/user.inc";
27 require_once("$srcdir/MedEx/API.php");
29 use OpenEMR\Common\Acl\AclMain
;
30 use OpenEMR\Common\Csrf\CsrfUtils
;
31 use OpenEMR\Common\Logging\EventAuditLogger
;
32 use OpenEMR\Core\Header
;
33 use OpenEMR\OeUI\OemrUI
;
35 //Gets validation rules from Page Validation list.
36 $collectthis = collectValidationPageRules("/interface/main/messages/messages.php");
37 if (empty($collectthis)) {
40 $collectthis = json_sanitize($collectthis[array_keys($collectthis)[0]]["rules"]);
43 $MedEx = new MedExApi\
MedEx('MedExBank.com');
45 if ($GLOBALS['medex_enable'] == '1') {
46 if ($_REQUEST['SMS_bot']) {
47 $result = $MedEx->login('');
48 $MedEx->display
->SMS_bot($result);
51 $logged_in = $MedEx->login();
54 $setting_bootstrap_submenu = prevSetting('', 'setting_bootstrap_submenu', 'setting_bootstrap_submenu', ' ');
55 //use $uspfx as the first variable for page/script specific user settings instead of '' (which is like a global but you have to request it).
56 $uspfx = substr(__FILE__
, strlen($webserver_root)) . '.';
57 $rcb_selectors = prevSetting($uspfx, 'rcb_selectors', 'rcb_selectors', 'block');
58 $rcb_facility = prevSetting($uspfx, 'form_facility', 'form_facility', '');
59 $rcb_provider = prevSetting($uspfx, 'form_provider', 'form_provider', $_SESSION['authUserID']);
62 ($_POST['setting_bootstrap_submenu']) ||
63 ($_POST['rcb_selectors'])
65 // These are not form elements. We only ever change them via ajax, so exit now.
75 require_once($GLOBALS['srcdir'] . "/validation/validation_script.js.php");
77 <meta charset
="utf-8" />
78 <meta http
-equiv
="X-UA-Compatible" content
="IE=edge" />
79 <meta name
="description" content
="MedEx Bank" />
80 <meta name
="author" content
="OpenEMR: MedExBank" />
81 <?php Header
::setupHeader(['datetime-picker', 'opener', 'moment', 'select2']); ?
>
82 <link rel
="stylesheet" href
="<?php echo $webroot; ?>/interface/main/messages/css/reminder_style.css?v=<?php echo $v_js_includes; ?>">
85 var xljs1
= '<?php echo xla('Preferences updated successfully
'); ?>';
86 var format_date_moment_js
= '<?php echo attr(DateFormatRead("validateJS")); ?>';
87 <?php
require_once "$srcdir/restoreSession.php"; ?
>
90 <script src
="<?php echo $GLOBALS['web_root']; ?>/interface/main/messages/js/reminder_appts.js?v=<?php echo $v_js_includes; ?>"></script
>
92 @media only screen
and (max
-width
: 768px
) {
95 text
-align
: left
!important
;
99 background
-color
: var(--danger
);
105 if (($GLOBALS['medex_enable'] == '1') && (empty($_REQUEST['nomenu'])) && ($GLOBALS['disable_rcb'] != '1')) {
106 $MedEx->display
->navigation($logged_in);
107 echo "<br /><br /><br />";
110 if (!empty($_REQUEST['go'])) { ?
>
112 if (($_REQUEST['go'] == "setup") && (!$logged_in)) {
113 echo "<title>" . xlt('MedEx Setup') . "</title>";
114 $stage = $_REQUEST['stage'];
115 if (!is_numeric($stage)) {
116 echo "<br /><span class='title'>$stage " . xlt('Warning') . ": " . xlt('This is not a valid request') . ".</span>";
118 $MedEx->setup
->MedExBank($stage);
120 } elseif ($_REQUEST['go'] == "addRecall") {
121 echo "<title>" . xlt('New Recall') . "</title>";
122 $MedEx->display
->display_add_recall();
123 } elseif ($_REQUEST['go'] == 'Recalls') {
124 echo "<title>" . xlt('Recall Board') . "</title>";
125 $MedEx->display
->display_recalls($logged_in);
126 } elseif ((($_REQUEST['go'] == "setup") ||
($_REQUEST['go'] == 'Preferences')) && ($logged_in)) {
127 echo "<title>MedEx: " . xlt('Preferences') . "</title>";
128 $MedEx->display
->preferences();
129 } elseif ($_REQUEST['go'] == 'icons') {
130 echo "<title>MedEx: " . xlt('Icons') . "Ⓒ</title>";
131 $MedEx->display
->icon_template();
132 } elseif ($_REQUEST['go'] == 'SMS_bot') {
133 echo "<title>MedEx: SMS BotⒸ</title>";
134 $MedEx->display
->SMS_bot($logged_in);
137 echo "<title>" . xlt('MedEx Setup') . "</title>";
138 echo xlt('Warning: Navigation error. Please refresh this page.');
141 //original message.php stuff
143 if ($GLOBALS['enable_help'] == 1) {
144 $help_icon = '<a class="float-right oe-help-redirect" data-target="#myModal" data-toggle="modal" href="#" id="help-href" name="help-href" style="color: var(--gray)" title="' . xla("Click to view Help") . '"><i class="fa fa-question-circle" aria-hidden="true"></i></a>';
145 } elseif ($GLOBALS['enable_help'] == 2) {
146 $help_icon = '<a class="float-right oe-help-redirect" data-target="#myModal" data-toggle="modal" href="#" id="help-href" name="help-href" style="color: var(--gray300) !important" title="' . xla("To enable help - Go to Administration > Globals > Features > Enable Help Modal") . '"><i class="fa fa-question-circle" aria-hidden="true"></i></a>';
147 } elseif ($GLOBALS['enable_help'] == 0) {
150 $heading_caption = xlt('Messages') . ', ' . xlt('Reminders');
151 if ($GLOBALS['disable_rcb'] != '1') {
152 $heading_caption .= ', ' . xlt('Recalls');
155 $arrOeUiSettings = array(
156 'heading_title' => $heading_caption,
157 'include_patient_name' => false,// use only in appropriate pages
158 'expandable' => false,
159 'expandable_files' => array(""),//all file names need suffix _xpd
160 'action' => "",//conceal, reveal, search, reset, link or back
161 'action_title' => "",
162 'action_href' => "",//only for actions - reset, link or back
163 'show_help_icon' => true,
164 'help_file_name' => "message_center_help.php"
166 $oemr_ui = new OemrUI($arrOeUiSettings);
168 echo "<title>" . xlt('Message Center') . "</title>";
171 <body
class='body_top'>
172 <div id
="container_div" class="<?php echo attr($oemr_ui->oeContainer()); ?>">
174 <div
class="col-sm-12">
175 <div
class="clearfix">
176 <?php
echo $oemr_ui->pageHeading() . "\r\n"; ?
>
180 <div
class="container-fluid mb-3">
181 <ul
class="nav nav-pills">
182 <li
class="nav-item" id
='li-mess'>
183 <a href
='#' class="active nav-link font-weight-bold" id
='messages-li'><?php
echo xlt('Messages'); ?
></a
>
185 <li
class="nav-item" id
='li-remi'>
186 <a href
='#' id
='reminders-li' class="nav-link font-weight-bold"><?php
echo xlt('Reminders'); ?
></a
>
188 <?php
if ($GLOBALS['disable_rcb'] != '1') { ?
>
189 <li
class="nav-item" id
='li-reca'>
190 <a href
='#' id
='recalls-li' class="nav-link font-weight-bold"><?php
echo xlt('Recalls'); ?
></a
>
193 <?php
if ($logged_in) { ?
>
194 <li
class="nav-item" id
='li-sms'>
195 <a href
='#' id
='sms-li' class="nav-link font-weight-bold"><?php
echo xlt('SMS Zone'); ?
></a
>
200 <div
class="row" id
="messages-div">
201 <div
class="col-sm-12">
202 <div
class="jumbotron jumbotron-fluid py-3">
203 <div
class="col-sm-12 col-md-12 col-lg-12">
205 // Check to see if the user has Admin rights, and if so, allow access to See All.
206 $showall = isset($_GET['show_all']) ?
$_GET['show_all'] : "";
207 if ($showall == "yes") {
208 $show_all = $showall;
212 // Collect active variable and applicable html code for links
213 $form_active = (isset($_REQUEST['form_active']) ?
$_REQUEST['form_active'] : false);
214 $form_inactive = (isset($_REQUEST['form_inactive']) ?
$_REQUEST['form_inactive'] : false);
217 $activity_string_html = 'form_active=1';
218 } elseif ($form_inactive) {
220 $activity_string_html = 'form_inactive=1';
223 $activity_string_html = '';
225 //collect the task setting
226 $task = isset($_REQUEST['task']) ?
$_REQUEST['task'] : "";
227 if (AclMain
::aclCheckCore('admin', 'super')) {
228 if ($show_all == 'yes') {
230 $lnkvar = "messages.php?show_all=no&" . $activity_string_html;
231 $lnkattributes = "name='Just Mine' onclick='top.restoreSession()'";
232 $otherstuff = "<i id='just-mine-tooltip' class='fa fa-user fa-lg text-body' aria-hidden='true'></i>";
233 $messages = xl('All Messages');
236 $lnkvar = "messages.php?show_all=yes&" . $activity_string_html;
237 $lnkattributes = "name='See All' onclick='top.restoreSession()'";
238 $otherstuff = "<i id='see-all-tooltip' class='fa fa-users fa-lg text-body' aria-hidden='true'></i>";
239 $messages = xl('My Messages');
242 $messages = xlt('My Messages');
245 <div
class="oe-margin-b-20">
246 <span
class="title"><?php
echo text($messages); ?
></span
>
247 <a
class='more' href
="<?php echo $lnkvar; ?>" <?php
echo $lnkattributes; ?
>><?php
echo $otherstuff; ?
></a
>
249 <div
class="oe-margin-b-10">
251 //show the activity links
252 if (empty($task) ||
$task == "add" ||
$task == "delete") { ?
>
253 <?php
if ($active == "all") { ?
>
254 <span
class="font-weight-bold"><?php
echo xlt('All Messages'); ?
></span
>
256 <a href
="messages.php" class="link btn btn-secondary" onclick
="top.restoreSession()"><?php
echo xlt('Show All'); ?
></a
>
259 <?php
if ($active == '1') { ?
>
260 <span
class="font-weight-bold"><?php
echo xlt('Active Messages'); ?
></span
>
262 <a href
="messages.php?form_active=1" class="link btn btn-secondary" onclick
="top.restoreSession()"><?php
echo xlt('Show Active'); ?
></a
>
265 <?php
if ($active == '0') { ?
>
266 <span
class="font-weight-bold"><?php
echo xlt('Inactive Messages'); ?
></span
>
268 <a href
="messages.php?form_inactive=1" class="link btn btn-secondary" onclick
="top.restoreSession()"><?php
echo xlt('Show Inactive'); ?
></a
>
275 // Add a new message for a specific patient; the message is documented in Patient Notes.
276 // Add a new message; it's treated as a new note in Patient Notes.
277 $note = $_POST['note'];
278 $noteid = $_POST['noteid'];
279 $form_note_type = $_POST['form_note_type'];
280 $form_message_status = $_POST['form_message_status'];
281 $reply_to = explode(';', rtrim($_POST['reply_to'], ';'));
282 $assigned_to_list = explode(';', $_POST['assigned_to']);
283 $datetime = isset($_POST['form_datetime']) ?
DateTimeToYYYYMMDDHHMMSS($_POST['form_datetime']) : '';
284 foreach ($assigned_to_list as $assigned_to) {
285 if ($noteid && $assigned_to != '-patient-') {
286 updatePnote($noteid, $note, $form_note_type, $assigned_to, $form_message_status, $datetime);
289 if ($noteid && $assigned_to == '-patient-') {
290 // When $assigned_to == '-patient-' we don't update the current note, but
291 // instead create a new one with the current note's body prepended and
292 // attributed to the patient. This seems to be all for the patient portal.
293 $row = getPnoteById($noteid);
295 die("getPnoteById() did not find id '" . text($noteid) . "'");
297 $pres = sqlQuery("SELECT lname, fname " .
298 "FROM patient_data WHERE pid = ?", array($reply_to[0]));
299 $patientname = $pres['lname'] . ", " . $pres['fname'];
300 $note .= "\n\n$patientname on " . $row['date'] . " wrote:\n\n";
301 $note .= $row['body'];
303 // There's no note ID, and/or it's assigned to the patient.
304 // In these cases a new note is created.
305 foreach ($reply_to as $patient) {
306 addPnote($patient, $note, $userauthorized, '1', $form_note_type, $assigned_to, $datetime, $form_message_status);
314 $noteid = $_POST['noteid'];
315 $form_message_status = $_POST['form_message_status'];
316 $reply_to = $_POST['reply_to'];
317 if ($task == "save") {
318 updatePnoteMessageStatus($noteid, $form_message_status);
320 updatePnotePatient($noteid, $reply_to);
323 $note = $_POST['note'];
324 $title = $_POST['form_note_type'];
325 $reply_to = $_POST['reply_to'];
329 $noteid = $_GET['noteid'];
331 // Update the message if it already exists; it's appended to an existing note in Patient Notes.
332 $result = getPnoteById($noteid);
335 $title = $result['title'];
337 $body = $result['body'];
338 if ($reply_to == "") {
339 $reply_to = $result['pid'];
341 $form_message_status = $result['message_status'];
342 $datetime = $result['date'];
346 // Delete selected message(s) from the Messages box (only).
347 $delete_id = $_POST['delete_id'];
348 for ($i = 0; $i < count($delete_id); $i++
) {
349 deletePnote($delete_id[$i]);
350 EventAuditLogger
::instance()->newEvent("delete", $_SESSION['authUser'], $_SESSION['authProvider'], 1, "pnotes: id " . $delete_id[$i]);
354 if ($task == "addnew" or $task == "edit") {
355 // Display the Messages page layout.
356 echo "<form name='form_patient' id='new_note'
357 class='form-horizontal'
358 action=\"messages.php?showall=" . attr_url($showall) . "&sortby=" . attr_url($sortby) . "&sortorder=" . attr_url($sortorder) . "&begin=" . attr_url($begin) . "&$activity_string_html\"
360 <input type='hidden' name='noteid' id='noteid' value='" . attr($noteid) . "' />
361 <input type='hidden' name='task' id='task' value='add' />";
362 if ($task == "addnew") {
363 $message_legend = xl('Create New Message');
364 $onclick = "onclick=multi_sel_patient()";
365 } elseif ($task == "edit") {
366 $message_legend = xl('Add To Existing Message');
371 <div
class='col-md-12'>
372 <div
class="jumbotron jumbotron-fluid py-3">
373 <h4
><?php
echo text($message_legend); ?
></h4
>
375 <div
class="col-12 oe-custom-line">
377 <div
class="col-6 col-md-3">
378 <label
for="form_note_type"><?php
echo xlt('Type'); ?
>:</label
>
381 $title = "Unassigned";
383 // Added 6/2009 by BM to incorporate the patient notes into the list_options listings.
384 generate_form_field(array('data_type' => 1, 'field_id' => 'note_type', 'list_id' => 'note_type', 'empty_title' => 'SKIP', 'order_by' => 'title', 'class' => 'form-control'), $title);
387 <div
class="col-6 col-md-3">
388 <label
for="form_message_status"><?php
echo xlt('Status'); ?
>:</label
>
390 if ($form_message_status == "") {
391 $form_message_status = 'New';
393 generate_form_field(array('data_type' => 1, 'field_id' => 'message_status', 'list_id' => 'message_status', 'empty_title' => 'SKIP', 'order_by' => 'title', 'class' => 'form-control'), $form_message_status); ?
>
395 <div
class="col-6 col-md-4">
397 if ($task != "addnew" && $result['pid'] != 0) { ?
>
398 <a
class="patLink" onclick
="goPid('<?php echo attr(addslashes($result['pid'])); ?>')" title
='<?php echo xla('Click me to Open Patient Dashboard
') ?>'><?php
echo xlt('Patient'); ?
>:</a
><label
for="form_patient"> 
</label
>
401 <span
class='font-weight-bold <?php echo($task == "addnew" ? "text-danger" : "") ?>'><?php
echo xlt('Patient'); ?
>:</span
></a
><label
for="form_patient"></label
>
406 $prow = sqlQuery("SELECT lname, fname,pid, pubpid, DOB " .
407 "FROM patient_data WHERE pid = ?", array($reply_to));
408 $patientname = $prow['lname'] . ", " . $prow['fname'];
410 if ($task == "addnew" ||
$result['pid'] == 0) {
411 $cursor = "oe-cursor-add";
412 $background = "oe-patient-background";
413 } elseif ($task == "edit") {
414 $cursor = "oe-cursor-stop";
418 <input type
='text' id
='form_patient' name
='form_patient' class='form-control <?php echo $cursor . " " . $background;?>' onclick
="multi_sel_patient()" placeholder
='<?php echo xla("Click to add patient"); ?>' value
='<?php echo attr($patientname); ?>' readonly
/>
419 <input type
='hidden' class="form-control" name
='reply_to' id
='reply_to' value
='<?php echo attr($reply_to); ?>'/>
421 <div
class="col-6 col-md-2 d-flex flex-wrap">
423 if ($task == "addnew" ||
$result['pid'] == 0) {
424 echo "<label class='oe-empty-label' for='clear_patients'></label>";
425 echo '<button type="button" id="clear_patients" class="btn btn-secondary btn-undo float-left flip" value="' . xla('Clear') . '">' . xlt("Clear") . '</button>';
432 <div
class="col-12 oe-custom-line">
434 <?php
if ($GLOBALS['messages_due_date']) { ?
>
435 <div
class="col-6 col-sm-2">
436 <label
for="form_note_type"><?php
echo xlt('Due date'); ?
>:</label
>
437 <?php
generate_form_field(array('data_type' => 4, 'field_id' => 'datetime', 'edit_options' => 'F'), empty($datetime) ?
date('Y-m-d H:i') : $datetime) ?
>
440 <div
class="col-6 col-sm-4 d-flex align-items-end flex-wrap">
441 <label
for="assigned_to_text"><?php
echo xlt('To{{Destination}}'); ?
>:</label
>
442 <input type
='text' name
='assigned_to_text' class='form-control oe-cursor-stop' id
='assigned_to_text' readonly
='readonly' value
='' placeholder
='<?php echo xla("SELECT Users FROM The Dropdown LIST"); ?>' />
443 <input type
='hidden' name
='assigned_to' id
='assigned_to' />
445 <div
class="col-6 col-sm-4">
446 <label
class="oe-empty-label" for="users"></label
>
447 <select name
='users' id
='users' class='form-control' onchange
='addtolist(this);'>
449 echo "<option value='--'";
450 echo ">" . xlt('Select User');
452 $ures = sqlStatement("SELECT username, fname, lname FROM users " .
453 "WHERE username != '' AND active = 1 AND " .
454 "( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
455 "ORDER BY lname, fname");
456 while ($urow = sqlFetchArray($ures)) {
457 echo " <option value='" . attr($urow['username']) . "'";
458 echo ">" . text($urow['lname']);
459 if ($urow['fname']) {
460 echo ", " . text($urow['fname']);
467 <div
class="col-6 col-sm-2 d-flex align-items-end flex-wrap">
468 <label
class="oe-empty-label" for="users"></label
>
469 <button type
="button" name
="clear_user" id
="clear_user" class="btn btn-secondary btn-undo float-left flip" value
="<?php echo xla('Clear'); ?>"><?php
echo xlt('Clear'); ?
></button
>
472 <div
class='col-12 oe-margin-t-3'>
475 // Get the related document IDs if any.
477 "SELECT id1 FROM gprelations WHERE " .
478 "type1 = ? AND type2 = ? AND id2 = ?",
479 array('1', '6', $noteid)
481 if (sqlNumRows($tmp)) {
483 echo " <td class='text'><span class='font-weight-bold'>" . xlt('Linked document') . ":</span>\n";
484 while ($gprow = sqlFetchArray($tmp)) {
485 $d = new Document($gprow['id1']);
486 $enc_list = sqlStatement("SELECT fe.encounter,fe.date,openemr_postcalendar_categories.pc_catname FROM form_encounter AS fe " .
487 " LEFT JOIN openemr_postcalendar_categories ON fe.pc_catid=openemr_postcalendar_categories.pc_catid WHERE fe.pid = ? ORDER BY fe.date DESC", array($prow['pid']));
488 $str_dob = xl("DOB") . ":" . $prow['DOB'] . " " . xl("Age") . ":" . getPatientAge($prow['DOB']);
489 $pname = $prow['fname'] . " " . $prow['lname'];
490 echo "<a href='javascript:void(0);' ";
491 echo "onClick=\"gotoReport(" . attr(addslashes($d->get_id())) . ",'" . attr(addslashes($pname)) . "'," . attr(addslashes($prow['pid'])) . "," . attr(addslashes($prow['pubpid'])) . ",'" . attr(addslashes($str_dob)) . "');\">";
492 echo text($d->get_name()) . "-" . text($d->get_id());
498 // Get the related procedure order IDs if any.
500 "SELECT id1 FROM gprelations WHERE " .
501 "type1 = ? AND type2 = ? AND id2 = ?",
502 array('2', '6', $noteid)
504 if (sqlNumRows($tmp)) {
506 echo " <td class='text'><span class='font-weight-bold'>" . xlt('Linked procedure order') . ":</span>\n";
507 while ($gprow = sqlFetchArray($tmp)) {
509 echo $GLOBALS['webroot'] . "/interface/orders/single_order_results.php?orderid=";
510 echo attr_url($gprow['id1']);
511 echo "' target='_blank' onclick='top.restoreSession()'>";
512 echo text($gprow['id1']);
522 <!-- <div
class="row"> -->
527 $body = preg_replace('/(:\d{2}\s\()' . $result['pid'] . '(\sto\s)/', '${1}' . $patientname . '${2}', $body);
528 $body = preg_replace('/(\d{4}-\d{2}-\d{2} \d{2}:\d{2}\s\([^)(]+\s)(to)(\s[^)(]+\))/', '${1}' . xl('to{{Destination}}') . '${3}', $body);
529 $body = text(oeFormatPatientNote($body));
530 echo "<textarea type='text' class='form-control text oe-margin-t-3 p-2 mb-2 w-100' rows='3' readonly>" . $body . "</textarea>";
534 <textarea name
='note' id
='note' class='form-control oe-margin-t-3 p-1' rows
="5"><?php
echo nl2br(text($note)); ?
></textarea
>
536 <div
class="col-12 position-override oe-margin-t-10">
537 <?php
if ($noteid) { ?
>
538 <!-- This is
for displaying an existing note
. -->
539 <button type
="button" class="btn btn-primary btn-send-msg" id
="newnote" value
="<?php echo xla('Send message'); ?>"><?php
echo xlt('Send message'); ?
></button
>
540 <button type
="button" class="btn btn-primary btn-print" id
="printnote" value
="<?php echo xla('Print message'); ?>"><?php
echo xlt('Print message'); ?
></button
>
541 <button type
="button" class="btn btn-secondary btn-cancel" id
="cancel" value
="<?php echo xla('Cancel'); ?>"><?php
echo xlt('Cancel'); ?
></button
>
543 <!-- This is
for displaying a
new note
. -->
544 <button type
="button" class="btn btn-primary btn-send-msg" id
="newnote" value
="<?php echo xla('Send message'); ?>"><?php
echo xlt('Send message'); ?
></button
>
545 <button type
="button" class="btn btn-cancel btn-secondary" id
="cancel" value
="<?php echo xla('Cancel'); ?>"><?php
echo xlt('Cancel'); ?
></button
>
555 // This is for sorting the records.
556 $sort = array("users.lname", "patient_data.lname", "pnotes.title", "pnotes.date", "pnotes.message_status");
557 $sortby = (isset($_REQUEST['sortby']) && ($_REQUEST['sortby'] != "")) ?
$_REQUEST['sortby'] : $sort[3];
558 $sortorder = (isset($_REQUEST['sortorder']) && ($_REQUEST['sortorder'] != "")) ?
$_REQUEST['sortorder'] : "desc";
559 $begin = isset($_REQUEST['begin']) ?
$_REQUEST['begin'] : 0;
561 for ($i = 0; $i < count($sort); $i++
) {
562 $sortlink[$i] = "<a class='arrowhead' href=\"messages.php?show_all=" . attr($showall) . "&sortby=" . attr($sort[$i]) . "&sortorder=asc&$activity_string_html\" onclick=\"top.restoreSession()\" alt=\"" . xla('Sort Up') . "\"><i class='fa fa-sort-desc fa-lg' aria-hidden='true'></i></a>";
564 for ($i = 0; $i < count($sort); $i++
) {
565 if ($sortby == $sort[$i]) {
566 switch ($sortorder) {
568 $sortlink[$i] = "<a class='arrowhead' href=\"messages.php?show_all=" . attr($showall) . "&sortby=" . attr($sortby) . "&sortorder=desc&$activity_string_html\" onclick=\"top.restoreSession()\" alt=\"" . xla('Sort Up') . "\"><i class='fa fa-sort-asc fa-lg' aria-hidden='true'></i></a>";
571 $sortlink[$i] = "<a class='arrowhead' href=\"messages.php?show_all=" . attr($showall) . "&sortby=" . attr($sortby) . "&sortorder=asc&$activity_string_html\" onclick=\"top.restoreSession()\" alt=\"" . xla('Sort Down') . "\"><i class='fa fa-sort-desc fa-lg' aria-hidden='true'></i></a>";
576 // Manage page numbering and display beneath the Messages table.
578 $total = getPnotesByUser($active, $show_all, $_SESSION['authUser'], true);
579 if ($begin == "" or $begin == 0) {
582 $prev = $begin - $listnumber;
583 $next = $begin +
$listnumber;
585 $end = $listnumber +
$start - 1;
587 $chevron_icon_left = $_SESSION['language_direction'] == 'ltr' ?
'fa-chevron-circle-left' : 'fa-chevron-circle-right';
588 $chevron_icon_right = $_SESSION['language_direction'] == 'ltr' ?
'fa-chevron-circle-right' : 'fa-chevron-circle-left';
590 if ($end >= $total) {
597 $prevlink = "<a href=\"messages.php?show_all=" . attr($showall) . "&sortby=" . attr($sortby) . "&sortorder=" . attr($sortorder) . "&begin=" . attr($prev) . "&$activity_string_html\" onclick=\"top.restoreSession()\"><i class=\"fa " . $chevron_icon_left . " chevron_color\" aria-hidden=\"true\"></i></a>";
599 $prevlink = "<i class=\"fa " . $chevron_icon_left . " text-muted\" aria-hidden=\"true\" title=\"" . xla("On first page") . "\"></i>";
602 if ($next < $total) {
603 $nextlink = "<a href=\"messages.php?show_all=" . attr($showall) . "&sortby=" . attr($sortby) . "&sortorder=" . attr($sortorder) . "&begin=" . attr($next) . "&$activity_string_html\" onclick=\"top.restoreSession()\"><i class=\"fa . $chevron_icon_right . chevron_color\" aria-hidden=\"true\"></i></a>";
605 $nextlink = "<i class=\"fa " . $chevron_icon_right . " text-muted\" aria-hidden=\"true\" title=\"" . xla("On first page") . "\"></i>";
607 // Display the Messages table header.
609 <table class=\"w-100\">
612 <form name='MessageList' id='MessageList' action=\"messages.php?showall=" . attr($showall) . "&sortby=" . attr($sortby) . "&sortorder=" . attr($sortorder) . "&begin=" . attr($begin) . "&$activity_string_html\" method='post'>
613 <table class='table table-sm table-hover w-100'>
614 <input type='hidden' name='task' value='delete' />
615 <thead class='table-primary'>
617 <th align='center' width='25'><input type='checkbox' id='checkAll' onclick='selectAll()'></th>
618 <th width='20%' class='font-weight-bold'> " . xlt('From') . " $sortlink[0]</th>
619 <th width='20%' class='font-weight-bold'> " . xlt('Patient') . " $sortlink[1]</th>
620 <th class='font-weight-bold'> " . xlt('Type') . " $sortlink[2]</th>
621 <th width='15%' class='font-weight-bold'> " . xlt($GLOBALS['messages_due_date'] ?
'Due date' : 'Date') . " $sortlink[3]</th>
622 <th width='15%' class='font-weight-bold'> " . xlt('Status') . " $sortlink[4]</th>
625 // Display the Messages table body.
627 $result = getPnotesByUser($active, $show_all, $_SESSION['authUser'], false, $sortby, $sortorder, $begin, $listnumber);
628 while ($myrow = sqlFetchArray($result)) {
629 $name = $myrow['user'];
630 $name = $myrow['users_lname'];
631 if ($myrow['users_fname']) {
632 $name .= ", " . $myrow['users_fname'];
634 $patient = $myrow['pid'];
636 $patient = $myrow['patient_data_lname'];
637 if ($myrow['patient_data_fname']) {
638 $patient .= ", " . $myrow['patient_data_fname'];
641 $patient = "* " . xl('Patient must be set manually') . " *";
645 <tr id=\"row" . attr($count) . "\" height='24'>
647 <input type='checkbox' id=\"check" . attr($count) . "\" name=\"delete_id[]\" value=\"" .
648 attr($myrow['id']) . "\" onclick=\"if(this.checked==true){ selectRow('row" . attr(addslashes($count)) . "'); }else{ deselectRow('row" . attr(addslashes($count)) . "'); }\"></td>
650 <div>" . text($name) . "</div>
653 <div><a href=\"messages.php?showall=" . attr_url($showall) . "&sortby=" . attr_url($sortby) . "&sortorder=" . attr_url($sortorder) . "&begin=" . attr_url($begin) . "&task=edit¬eid=" .
654 attr_url($myrow['id']) . "&$activity_string_html\" onclick=\"top.restoreSession()\">" .
655 text($patient) . "</a></div>
659 xlt($myrow['title']) . "</div>
661 <div>" . text(oeFormatShortDate(substr($myrow['date'], 0, strpos($myrow['date'], " ")))) . "</div>
664 <div>" . text(getListItemTitle('message_status', $myrow['message_status'])) . "</div>
668 // Display the Messages table footer.
672 <div class='row oe-margin-t-10'>
674 <div class=\"col-12 col-md-12 col-lg-12\"><a href=\"messages.php?showall=" . attr_url($showall) . "&sortby=" . attr_url($sortby) . "&sortorder=" . attr_url($sortorder) . "&begin=" . attr_url($begin) . "&task=addnew&$activity_string_html\" class=\"btn btn-primary btn-add\" onclick=\"top.restoreSession()\">" .
675 xlt('Add New{{Message}}') . "</a> <a href=\"javascript:confirmDeleteSelected()\" class=\"btn btn-danger btn-delete\" onclick=\"top.restoreSession()\">" .
676 xlt('Delete') . "</a>
677 <div class=\"text-right\">$prevlink " . text($end) . " " . xlt('of') . " " . text($total) . " $nextlink</div>
687 // This is to confirm delete action.
688 function confirmDeleteSelected() {
690 var elem
= document
.forms
.namedItem("MessageList").getElementsByTagName("input");
692 for (i
=0; i
< elem
.length
; i++
){
693 if(elem
[i
].checked
== true){
694 int_checked
= ++int_checked
;
697 if (int_checked
> 0){
698 if (confirm("<?php echo xls('Do you really want to delete the selection?'); ?>")) {
699 document
.MessageList
.submit();
702 alert("<?php echo xls('Please select message(s) to delete'); ?>");
707 // This is to allow selection of all items in Messages table for deletion.
708 function selectAll() {
709 if (document
.getElementById("checkAll").checked
=== true) {
710 document
.getElementById("checkAll").checked
= true;<?php
711 for ($i = 1; $i <= $count; $i++
) {
712 echo "document.getElementById(\"check$i\").checked=true; document.getElementById(\"row$i\").style.background='var(--gray200)'; ";
715 document
.getElementById("checkAll").checked
= false;<?php
716 for ($i = 1; $i <= $count; $i++
) {
717 echo "document.getElementById(\"check$i\").checked=false; document.getElementById(\"row$i\").style.background='var(--light)'; ";
722 // The two functions below are for managing row styles in Messages table.
723 function selectRow(row
) {
724 document
.getElementById(row
).style
.background
= "var(--gray200)";
727 function deselectRow(row
) {
728 document
.getElementById(row
).style
.background
= "var(--light)";
737 </div
><!--end of messages div
-->
738 <div
class="row oe-display" id
="reminders-div">
739 <div
class="col-sm-12">
740 <div
class="jumbotron jumbotron-fluid py-3">
741 <div
class="col-sm-12 col-md-12 col-lg-12">
742 <div
class="oe-margin-b-10">
743 <span
class="title"><?php
echo xlt('Reminders'); ?
></span
>
746 // TajEmo Work by CB 2012/01/11 02:51:25 PM adding dated reminders
747 // I am asuming that at this point security checks have been performed
748 //require_once '../dated_reminders/dated_reminders.php';
749 require_once '../dated_reminders/dated_reminders.php';
754 </div
><!--end of reminders div
-->
755 <div
class="row oe-display" id
="recalls-div">
756 <div
class="col-sm-12">
757 <div
class="jumbotron jumbotron-fluid py-3">
758 <?php
if ($GLOBALS['disable_rcb'] != '1') { ?
>
759 <div
class="col-sm-6 col-md-6 col-lg-6">
760 <div
class="dr_container">
761 <span
class="title"><?php
echo xlt('Recalls'); ?
></span
>
763 <button
class="btn btn-primary btn-add" onclick
="goReminderRecall('addRecall');"><?php
echo xlt('New Recall'); ?
></button
>
764 <a
class="btn btn-secondary btn-transmit" onclick
="goReminderRecall('Recalls');"><span
><?php
echo xlt('Recall Board'); ?
></span
></a
>
771 </div
><!--end of recalls div
-->
772 <div
class="row oe-display" id
="sms-div">
773 <div
class="col-sm-12">
774 <div
class="jumbotron jumbotron-fluid py-3">
775 <?php
if ($logged_in) { ?
>
776 <div
class="col-sm-4 col-md-4 col-lg-4">
777 <span
class="title"><?php
echo xlt('SMS Zone'); ?
></span
>
779 <form id
="smsForm" class="input-group">
780 <select id
="SMS_patient" type
="text" class="form-control m-0 w-100" placeholder
="<?php echo xla("Patient Name
"); ?>" > </select
>
781 <span
class="input-group-addon" onclick
="SMS_direct();"><i
class="fas fa-phone"></i
></span
>
782 <input type
="hidden" id
="sms_pid" />
783 <input type
="hidden" id
="sms_mobile" value
="" />
784 <input type
="hidden" id
="sms_allow" value
="" />
790 </div
><!--end of sms div
-->
791 </div
><!--end of container div
-->
792 <?php
$oemr_ui->oeBelowContainerDiv();?
>
794 //home of the help modal ;)
795 //$GLOBALS['enable_help'] = 0; // Please comment out line if you want help modal to function on this page
796 if ($GLOBALS['enable_help'] == 1) {
797 echo "<script>var helpFile = 'message_center_help.php'</script>";
798 //help_modal.php lives in interface, set path accordingly
799 require "../../help_modal.php";
804 var collectvalidation
= <?php
echo $collectthis; ?
>;
807 $
("#reminders-div").hide();
808 $
("#recalls-div").hide();
809 $
("#sms-div").hide();
810 $
("#messages-li").click(function(){
811 $
("#messages-div").show(250);
812 $
("#reminders-div").hide(250);
813 $
("#recalls-div").hide(250);
814 $
("#sms-div").hide(250);
815 $
("#messages-li").addClass("active");
816 $
("#reminders-li").removeClass("active");
817 $
("#recalls-li").removeClass("active");
818 $
("#sms-li").removeClass("active");
821 $
("#reminders-li").click(function(){
822 $
("#messages-div").hide(250);
823 $
("#reminders-div").show(250);
824 $
("#recalls-div").hide(250);
825 $
("#sms-div").hide(250);
826 $
("#reminders-li").addClass("active");
827 $
("#messages-li").removeClass("active");
828 $
("#recalls-li").removeClass("active");
829 $
("#sms-li").removeClass("active");
831 $
("#recalls-li").click(function(){
832 $
("#messages-div").hide(250);
833 $
("#reminders-div").hide(250);
834 $
("#recalls-div").show(250);
835 $
("#sms-div").hide(250);
836 $
("#reminders-li").removeClass("active");
837 $
("#messages-li").removeClass("active");
838 $
("#recalls-li").addClass("active");
839 $
("#sms-li").removeClass("active");
841 $
("#sms-li").click(function(){
842 $
("#messages-div").hide(250);
843 $
("#reminders-div").hide(250);
844 $
("#recalls-div").hide(250);
845 $
("#sms-div").show(250);
846 $
("#reminders-li").removeClass("active");
847 $
("#messages-li").removeClass("active");
848 $
("#recalls-li").removeClass("active");
849 $
("#sms-li").addClass("active");
852 $
('.datetimepicker').datetimepicker({
853 <?php
$datetimepicker_timepicker = true; ?
>
854 <?php
$datetimepicker_showseconds = false; ?
>
855 <?php
$datetimepicker_formatInput = true; ?
>
856 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
857 ,minDate
: 0 //only future
862 $
( "ul.navbar-nav" ).children().click(function(){
863 $
(".collapse").collapse('hide');
867 $
('#see-all-tooltip').attr({"title": <?php
echo xlj('Click to show messages for all users'); ?
>, "data-toggle":"tooltip", "data-placement":"bottom"}).tooltip();
868 $
('#just-mine-tooltip').attr({"title": <?php
echo xlj('Click to show messages for only the current user'); ?
>, "data-toggle":"tooltip", "data-placement":"bottom"}).tooltip();
871 var f
= $
("#smsForm");
872 $
("#SMS_patient").select2({
876 data
: function(params
) {
882 processResults
: function(data
) {
884 results
: $
.map(data
, function(item
, index
) {
888 value
: item
.Label +
' ' + item
.mobile
,
900 $
('#SMS_patient').on('select2:select', function (e
) {
902 $
("#SMS_patient").val(e
.params
.data
.value
);
903 $
("#sms_pid").val(e
.params
.data
.pid
);
904 $
("#sms_mobile").val(e
.params
.data
.mobile
);
905 $
("#sms_allow").val(e
.params
.data
.allow
);
910 $
("#newnote").click(function (event
) {
913 $
("#printnote").click(function () {
916 var obj
= $
("#form_message_status");
917 obj
.onchange
= function () {
920 $
("#cancel").click(function () {
925 //clear button in messages
926 $
("#clear_user").click(function(){
927 $
("#assigned_to_text").val("<?php echo xls('Select Users From The Dropdown List'); ?>");
928 $
("#assigned_to").val("");
929 $
("#users").val("--");
932 //clear inputs of patients
933 $
("#clear_patients").click(function(){
934 $
("#reply_to").val("");
935 $
("#form_patient").val("");
939 var NewNote
= function (event
) {
940 top
.restoreSession();
941 if(document
.getElementById("form_message_status").value
!== 'Done'){
942 collectvalidation
.assigned_to
= {
943 presence
: {message
: "<?php echo xls('Recipient required unless status is Done'); ?>"}
947 delete collectvalidation
.assigned_to
;
950 $
('#newnote').attr('disabled', true);
952 var submit
= submitme(1, event
, 'new_note', collectvalidation
);
954 $
('#newnote').attr('disabled', false);
957 $
("#new_note").submit();
960 var PrintNote
= function () {
961 top
.restoreSession();
962 window
.open('../../patient_file/summary/pnotes_print.php?noteid=' +
<?php
echo js_url($noteid); ?
>, '_blank', 'resizable=1,scrollbars=1,width=600,height=500');
965 var SaveNote
= function () {
966 <?php
if ($noteid) { ?
>
967 top
.restoreSession();
968 $
("#task").val("save");
969 $
("#new_note").submit();
973 var CancelNote
= function () {
974 top
.restoreSession();
976 $
("#new_note").submit();
979 function gotoReport(doc_id
, pname
, pid
, pubpid
, str_dob
) {
980 EncounterDateArray
= [];
981 CalendarCategoryArray
= [];
982 EncounterIdArray
= [];
985 if (isset($enc_list) && sqlNumRows($enc_list) > 0) {
986 while ($row = sqlFetchArray($enc_list)) {
988 EncounterIdArray
[Count
] = '<?php echo attr($row['encounter
']); ?>';
989 EncounterDateArray
[Count
] = '<?php echo attr(oeFormatShortDate(date("Y-m-d", strtotime($row['date
'])))); ?>';
990 CalendarCategoryArray
[Count
] = '<?php echo attr(xl_appt_category($row['pc_catname
'])); ?>';
996 top
.restoreSession();
999 url
: '<?php echo $GLOBALS['webroot
'] . "/library/ajax/set_pt.php";?>',
1002 csrf_token_form
: <?php
echo js_escape(CsrfUtils
::collectCsrfToken()); ?
>
1006 parent
.left_nav
.setPatient(pname
, pid
, pubpid
, '', str_dob
);
1007 parent
.left_nav
.setPatientEncounter(EncounterIdArray
, EncounterDateArray
, CalendarCategoryArray
);
1008 var docurl
= '../controller.php?document&view' +
"&patient_id=" +
encodeURIComponent(pid
) +
"&document_id=" +
encodeURIComponent(doc_id
) +
"&";
1009 var paturl
= 'patient_file/summary/demographics.php?pid=' +
encodeURIComponent(pid
);
1010 parent
.left_nav
.loadFrame('dem1', 'pat', paturl
);
1011 parent
.left_nav
.loadFrame('doc0', 'enc', docurl
);
1012 top
.activateTabByName('enc', true);
1015 // This is for callback by the find-patient popup.
1016 function setpatient(pid
, lname
, fname
, dob
) {
1017 var f
= document
.getElementById('new_note');
1018 f
.form_patient
.value +
= lname +
', ' + fname +
'; ';
1019 f
.reply_to
.value +
= pid +
';';
1020 <?php
if ($noteid) { ?
>
1021 //used when direct messaging service inserts a pnote with indeterminate patient
1022 //to allow the user to assign the message to a patient.
1023 top
.restoreSession();
1024 $
("#task").val("savePatient");
1025 $
("#new_note").submit();
1029 // This is for callback by the multi_patients_finder popup.
1030 function setMultiPatients(patientsList
) {
1031 var f
= document
.getElementById('new_note');
1032 f
.form_patient
.value
='';
1033 f
.reply_to
.value
='';
1034 $
.each(patientsList
, function (key
, patient
) {
1035 f
.form_patient
.value +
= patient
.lname +
', ' + patient
.fname +
'; ';
1036 f
.reply_to
.value +
= patient
.pid +
';';
1039 <?php
if ($noteid) { ?
>
1040 //used when direct messaging service inserts a pnote with indeterminate patient
1041 //to allow the user to assign the message to a patient.
1042 top
.restoreSession();
1043 $
("#task").val("savePatient");
1044 $
("#new_note").submit();
1048 // This invokes the find-patient popup.
1049 function sel_patient() {
1050 dlgopen('../../main/calendar/find_patient_popup.php', '_blank', 625, 400);
1053 function multi_sel_patient() {
1054 $
('#reply_to').trigger('click');
1055 var url
= '../../main/finder/multi_patients_finder.php'
1056 // for edit selected list
1057 if ($
('#reply_to').val() !== '') {
1058 url
= url +
'?patients=' + $
('#reply_to').val() +
'&csrf_token_form=<?php echo attr_url(CsrfUtils::collectCsrfToken()); ?>';
1060 dlgopen(url
, '_blank', 625, 400);
1063 function addtolist(sel
) {
1064 $
('#assigned_to').trigger("click");
1065 var itemtext
= document
.getElementById('assigned_to_text');
1066 var item
= document
.getElementById('assigned_to');
1067 if (sel
.value
!== '--') {
1069 if (item
.value
.indexOf(sel
.value
) === -1) {
1070 itemtext
.value
= itemtext
.value +
' ; ' + sel
.options
[sel
.selectedIndex
].text
;
1071 item
.value
= item
.value +
';' + sel
.value
;
1074 itemtext
.value
= sel
.options
[sel
.selectedIndex
].text
;
1075 item
.value
= sel
.value
;
1080 function SMS_direct() {
1081 var pid
= $
("#sms_pid").val();
1082 var m
= $
("#sms_mobile").val();
1083 var allow
= $
("#sms_allow").val();
1084 if ((pid
=== '') ||
(m
=== '')) {
1085 alert('<?php echo xls("MedEx needs a valid mobile number to send SMS messages..."); ?>');
1086 } else if (allow
=== 'NO') {
1087 alert('<?php echo xls("This patient does not allow SMS messaging!"); ?>');
1089 top
.restoreSession();
1090 window
.open('messages.php?nomenu=1&go=SMS_bot&pid=' +
encodeURIComponent(pid
) +
'&m=' +
encodeURIComponent(m
), 'SMS_bot', 'width=370,height=600,resizable=0');