3 * Message and Reminder Center UI
4 * 2013/02/08 Minor tweaks by EMR Direct to allow integration with Direct messaging
5 * 2013-03-27 by sunsetsystems: Fixed some weirdness with assigning a message recipient,
6 * and allowing a message to be closed with a new note appended and no recipient.
8 * @link http://www.open-emr.org
9 * @author OpenEMR Support LLC
10 * @author Roberto Vasquez robertogagliotta@gmail.com
11 * @author Rod Roark rod@sunsetsystems.com
12 * @author Brady Miller brady.g.miller@gmail.com
13 * @author Ray Magauran magauran@medfetch.com
14 * @copyright Copyright (c) 2010 OpenEMR Support LLC
15 * @copyright Copyright (c) 2017 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/pnotes.inc");
21 require_once("$srcdir/patient.inc");
22 require_once("$srcdir/acl.inc");
23 require_once("$srcdir/log.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\Core\Header
;
31 $MedEx = new MedExApi\
MedEx('MedExBank.com');
33 if ($GLOBALS['medex_enable'] == '1') {
34 $logged_in = $MedEx->login();
35 if ($_REQUEST['SMS_bot']) {
36 $MedEx->display
->SMS_bot($logged_in);
41 $setting_bootstrap_submenu = prevSetting('', 'setting_bootstrap_submenu', 'setting_bootstrap_submenu', ' ');
42 //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).
43 $uspfx = substr(__FILE__
, strlen($webserver_root)) . '.';
44 $rcb_selectors = prevSetting($uspfx, 'rcb_selectors', 'rcb_selectors', 'block');
45 $rcb_facility = prevSetting($uspfx, 'form_facility', 'form_facility', '');
46 $rcb_provider = prevSetting($uspfx, 'form_provider', 'form_provider', $_SESSION['authUserID']);
48 if (($_POST['setting_bootstrap_submenu']) ||
49 ($_POST['rcb_selectors'])) {
50 // These are not form elements. We only ever change them via ajax, so exit now.
57 <link rel
="stylesheet" href
="<?php echo $webroot; ?>/interface/main/messages/css/reminder_style.css?v=<?php echo $v_js_includes; ?>" type
="text/css">
58 <link rel
="stylesheet" href
="<?php echo $GLOBALS['web_root']; ?>/library/css/bootstrap_navbar.css?v=<?php echo $v_js_includes; ?>" type
="text/css">
60 <?php Header
::setupHeader(['datetime-picker', 'jquery-ui', 'jquery-ui-redmond', 'opener', 'moment', 'pure']); ?
>
63 var xljs1
= '<?php echo xl('Preferences updated successfully
'); ?>';
64 var format_date_moment_js
= '<?php echo attr(DateFormatRead("validateJS")); ?>';
65 <?php
require_once "$srcdir/restoreSession.php"; ?
>
68 <script type
="text/javascript" src
="<?php echo $GLOBALS['web_root']; ?>/interface/main/messages/js/reminder_appts.js?v=<?php echo $v_js_includes; ?>"></script
>
70 <link rel
="shortcut icon" href
="<?php echo $webroot; ?>/sites/default/favicon.ico" />
72 <meta charset
="utf-8">
73 <meta http
-equiv
="X-UA-Compatible" content
="IE=edge">
74 <meta name
="description" content
="MedEx Bank">
75 <meta name
="author" content
="OpenEMR: MedExBank">
76 <meta name
="viewport" content
="width=device-width, initial-scale=1">
79 border
: solid black
0.5pt
;
80 box
-shadow
: 3px
3px
3px
#7b777760;
88 if (($GLOBALS['medex_enable'] == '1') && (empty($_REQUEST['nomenu']))) {
89 $MedEx->display
->navigation($logged_in);
93 if (!empty($_REQUEST['go'])) { ?
>
95 if (($_REQUEST['go'] == "setup") && (!$logged_in)) {
96 echo "<title>" . xlt('MedEx Setup') . "</title></head><body class='body_top'>";
97 $stage = $_REQUEST['stage'];
98 if (!is_numeric($stage)) {
99 echo "<br /><span class='title'>$stage " . xlt('Warning') . ": " . xlt('This is not a valid request') . ".</span>";
101 $MedEx->setup
->MedExBank($stage);
103 } elseif ($_REQUEST['go'] == "addRecall") {
104 echo "<title>" . xlt('New Recall') . "</title></head><body class='body_top'>";
105 $MedEx->display
->display_add_recall();
106 } else if ($_REQUEST['go'] == 'Recalls') {
107 echo "<title>" . xlt('Recall Board') . "</title></head><body class='body_top'>";
108 $MedEx->display
->display_recalls($logged_in);
109 } elseif ((($_REQUEST['go'] == "setup") ||
($_REQUEST['go'] == 'Preferences')) && ($logged_in)) {
110 echo "<title>MedEx" . xlt('Preferences') . "</title></head><body class='body_top'>";
111 $MedEx->display
->preferences();
112 } elseif ($_REQUEST['go'] == 'icons') {
113 echo "<title>MedEx" . xlt('Icons') . "</title></head><body class='body_top'>";
114 $MedEx->display
->icon_template();
115 } elseif ($_REQUEST['go'] == 'SMS_bot') {
116 echo "<title>MedEx" . xlt('SMS') . "</title></head><body class='body_top'>";
117 $MedEx->display
->SMS_bot($logged_in);
119 echo "<title>" . xlt('MedEx Setup') . "</title></head><body class='body_top'>";
120 echo xlt('Warning: Navigation error. Please refresh this page.');
123 //original message.php stuff
124 echo "<title>" . xlt('Message Center') . "</title></head><body class='body_top'>";
126 <div
class="container">
127 <?php
if ($GLOBALS['disable_rcb'] != '1' ||
$logged_in) { ?
>
129 <?php
if ($GLOBALS['disable_rcb'] != '1') { ?
>
130 <div
class="col-sm-6 col-md-6 col-lg-6">
131 <div
class="dr_container">
132 <span
class="title"><?php
echo xlt('Recalls'); ?
></span
>
134 <a
class="btn btn-primary"
135 onclick
="goReminderRecall('addRecall');"><span
><?php
echo xlt('New Recall'); ?
></span
></a
>
137 <a
class="btn btn-primary"
138 onclick
="goReminderRecall('Recalls');"><span
><?php
echo xlt('Recall Board'); ?
></span
></a
>
143 <?php
if ($logged_in) { ?
>
144 <div
class="col-sm-4 col-md-4 col-lg-4">
145 <span
class="title"><?php
echo xlt('SMS Zone'); ?
></span
>
148 <form id
="smsForm" class="input-group">
149 <input id
="SMS_patient" type
="text" style
="margin:0;max-width:100%;" class="form-control"
150 placeholder
="<?php echo xla("Patient Name
"); ?>" />
151 <span
class="input-group-addon" onclick
="SMS_direct();"><i
152 class="glyphicon glyphicon-phone"></i
></span
>
153 <input type
="hidden" id
="sms_pid">
154 <input type
="hidden" id
="sms_mobile" value
="">
155 <input type
="hidden" id
="sms_allow" value
="">
163 <div
class="col-sm-12 col-md-12 col-lg-12">
165 <span
class="title"><?php
echo xlt('Reminders'); ?
></span
><br
/><br
/>
167 // TajEmo Work by CB 2012/01/11 02:51:25 PM adding dated reminders
168 // I am asuming that at this point security checks have been performed
169 require_once '../dated_reminders/dated_reminders.php';
175 <div
class="col-sm-12 col-md-12 text-center">
178 // Check to see if the user has Admin rights, and if so, allow access to See All.
179 $showall = isset($_GET['show_all']) ?
$_GET['show_all'] : "";
180 if ($showall == "yes") {
181 $show_all = $showall;
185 // Collect active variable and applicable html code for links
186 $form_active = (isset($_REQUEST['form_active']) ?
$_REQUEST['form_active'] : false);
187 $form_inactive = (isset($_REQUEST['form_inactive']) ?
$_REQUEST['form_inactive'] : false);
190 $activity_string_html = 'form_active=1';
191 } else if ($form_inactive) {
193 $activity_string_html = 'form_inactive=1';
196 $activity_string_html = '';
198 //collect the task setting
199 $task = isset($_REQUEST['task']) ?
$_REQUEST['task'] : "";
200 if (acl_check('admin', 'super')) {
201 if ($show_all == 'yes') {
203 $lnkvar = "\"messages.php?show_all=no&$activity_string_html\" name='Just Mine' onclick=\"top.restoreSession()\">(" . xlt('Just Mine') . ")";
206 $lnkvar = "\"messages.php?show_all=yes&$activity_string_html\" name='See All' onclick=\"top.restoreSession()\">(" . xlt('See All') . ")";
214 <span
class="title"><?php
echo xlt('Messages'); ?
></span
>
215 <a
class='more' href
=<?php
echo $lnkvar; ?
></a
>
220 //show the activity links
221 if (empty($task) ||
$task == "add" ||
$task == "delete") { ?
>
222 <?php
if ($active == "all") { ?
>
223 <span
><?php
echo xlt('Show All'); ?
></span
>
225 <a href
="messages.php" class="link"
226 onclick
="top.restoreSession()"><span
><?php
echo xlt('Show All'); ?
></span
></a
>
229 <?php
if ($active == '1') { ?
>
230 <span
><?php
echo xlt('Show Active'); ?
></span
>
232 <a href
="messages.php?form_active=1" class="link"
233 onclick
="top.restoreSession()"><span
><?php
echo xlt('Show Active'); ?
></span
></a
>
236 <?php
if ($active == '0') { ?
>
237 <span
><?php
echo xlt('Show Inactive'); ?
></span
>
239 <a href
="messages.php?form_inactive=1" class="link"
240 onclick
="top.restoreSession()"><span
><?php
echo xlt('Show Inactive'); ?
></span
></a
>
247 // Add a new message for a specific patient; the message is documented in Patient Notes.
248 // Add a new message; it's treated as a new note in Patient Notes.
249 $note = $_POST['note'];
250 $noteid = $_POST['noteid'];
251 $form_note_type = $_POST['form_note_type'];
252 $form_message_status = $_POST['form_message_status'];
253 $reply_to = explode(';', rtrim($_POST['reply_to'], ';'));
254 $assigned_to_list = explode(';', $_POST['assigned_to']);
255 foreach ($assigned_to_list as $assigned_to) {
256 if ($noteid && $assigned_to != '-patient-') {
257 updatePnote($noteid, $note, $form_note_type, $assigned_to, $form_message_status);
260 if ($noteid && $assigned_to == '-patient-') {
261 // When $assigned_to == '-patient-' we don't update the current note, but
262 // instead create a new one with the current note's body prepended and
263 // attributed to the patient. This seems to be all for the patient portal.
264 $row = getPnoteById($noteid);
266 die("getPnoteById() did not find id '" . text($noteid) . "'");
268 $pres = sqlQuery("SELECT lname, fname " .
269 "FROM patient_data WHERE pid = ?", array($reply_to[0]));
270 $patientname = $pres['lname'] . ", " . $pres['fname'];
271 $note .= "\n\n$patientname on " . $row['date'] . " wrote:\n\n";
272 $note .= $row['body'];
274 // There's no note ID, and/or it's assigned to the patient.
275 // In these cases a new note is created.
276 foreach ($reply_to as $patient) {
277 addPnote($patient, $note, $userauthorized, '1', $form_note_type, $assigned_to, '', $form_message_status);
285 $noteid = $_POST['noteid'];
286 $form_message_status = $_POST['form_message_status'];
287 $reply_to = $_POST['reply_to'];
288 if ($task == "save") {
289 updatePnoteMessageStatus($noteid, $form_message_status);
291 updatePnotePatient($noteid, $reply_to);
294 $note = $_POST['note'];
295 $title = $_POST['form_note_type'];
296 $reply_to = $_POST['reply_to'];
300 $noteid = $_GET['noteid'];
302 // Update the message if it already exists; it's appended to an existing note in Patient Notes.
303 $result = getPnoteById($noteid);
306 $title = $result['title'];
308 $body = $result['body'];
309 if ($reply_to == "") {
310 $reply_to = $result['pid'];
312 $form_message_status = $result['message_status'];
316 // Delete selected message(s) from the Messages box (only).
317 $delete_id = $_POST['delete_id'];
318 for ($i = 0; $i < count($delete_id); $i++
) {
319 deletePnote($delete_id[$i]);
320 newEvent("delete", $_SESSION['authUser'], $_SESSION['authProvider'], 1, "pnotes: id " . $delete_id[$i]);
324 if ($task == "addnew" or $task == "edit") {
325 // Display the Messages page layout.
327 <form name='form_patient' id='new_note'
328 class='form-horizontal'
329 action=\"messages.php?showall=" . attr($showall) . "&sortby=" . attr($sortby) . "&sortorder=" . attr($sortorder) . "&begin=" . attr($begin) . "&$activity_string_html\"
331 <input type=hidden name=noteid id=noteid value='" . attr($noteid) . "'>
332 <input type=hidden name=task id=task value=add>";
334 <div id
="pnotes" class="form-inline text-center">
335 <table border
='0' cellspacing
='8'>
337 <td
class='text form-group'>
338 <b
><?php
echo xlt('Type'); ?
>:</b
>
341 $title = "Unassigned";
343 // Added 6/2009 by BM to incorporate the patient notes into the list_options listings.
344 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);
347 <b
><?php
echo xlt('Status'); ?
>:</b
>
349 if ($form_message_status == "") {
350 $form_message_status = 'New';
352 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); ?
>
356 <td
class='text form-group'>
358 if ($task != "addnew" && $result['pid'] != 0) { ?
>
360 onclick
="goPid('<?php echo attr($result['pid']); ?>')"><?php
echo xlt('Patient'); ?
>
364 <b
class='<?php echo($task == "addnew" ? "required" : "") ?>'><?php
echo xlt('Patient'); ?
>
370 $prow = sqlQuery("SELECT lname, fname,pid, pubpid, DOB " .
371 "FROM patient_data WHERE pid = ?", array($reply_to));
372 $patientname = $prow['lname'] . ", " . $prow['fname'];
376 <input type
='text' size
='10' name
='form_patient' id
='form_patient' class="form-control" style
='width:150px;' value
='<?php echo attr($patientname); ?>' readonly
/>
377 <input type
='hidden' class="form-control" name
='reply_to' id
='reply_to'
378 value
='<?php echo attr($reply_to); ?>'/>
381 if ($task=="addnew" ||
$result['pid']==0) {
382 echo '<input type="button" value="' . xla('Add Patient') . '" style="float: none; display: inline-block;" onclick="multi_sel_patient()"/> ';
383 echo '<input type="button" id="clear_patients" style="float: none; display: inline-block;" value="' . xla("Clear") .'"/>';
388 <td
class='text form-group'>
389 <b
><?php
echo htmlspecialchars(xl('To'), ENT_QUOTES
); ?
>:</b
>
390 <input type
='textbox' name
='assigned_to_text' class='form-control' id
='assigned_to_text'
391 size
='40' readonly
='readonly'
392 value
='' placeholder
='<?php echo xla("SELECT Users FROM The Dropdown LIST"); ?>'>
393 <input type
='hidden' name
='assigned_to' id
='assigned_to'>
394 <select name
='users' id
='users' class='form-control' onchange
='addtolist(this);'>
396 echo "<option value='--'";
397 echo ">" . xlt('Select User');
399 $ures = sqlStatement("SELECT username, fname, lname FROM users " .
400 "WHERE username != '' AND active = 1 AND " .
401 "( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
402 "ORDER BY lname, fname");
403 while ($urow = sqlFetchArray($ures)) {
404 echo " <option value='" . attr($urow['username']) . "'";
405 echo ">" . text($urow['lname']);
406 if ($urow['fname']) {
407 echo ", " . text($urow['fname']);
411 if ($GLOBALS['portal_offsite_enable']) {
412 echo "<option value='-" . xla('patient') . "-'";
413 echo ">-" . xlt('Patient') . "-";
418 <input type
="button" name
="clear_user" id
="clear_user" style
="float: none; display: inline-block;" value
="<?php echo xla('Clear'); ?>">
423 // Get the related document IDs if any.
425 "SELECT id1 FROM gprelations WHERE " .
426 "type1 = ? AND type2 = ? AND id2 = ?",
427 array('1', '6', $noteid)
429 if (sqlNumRows($tmp)) {
431 echo " <td class='text'><b>";
432 echo xlt('Linked document') . ":</b>\n";
433 while ($gprow = sqlFetchArray($tmp)) {
434 $d = new Document($gprow['id1']);
435 $enc_list = sqlStatement("SELECT fe.encounter,fe.date,openemr_postcalendar_categories.pc_catname FROM form_encounter AS fe " .
436 " 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']));
437 $str_dob = htmlspecialchars(xl("DOB") . ":" . $prow['DOB'] . " " . xl("Age") . ":" . getPatientAge($prow['DOB']));
438 $pname = $prow['fname'] . " " . $prow['lname'];
439 echo "<a href='javascript:void(0);' ";
440 echo "onClick=\"gotoReport(" . addslashes(attr($d->get_id())) . ",'" . addslashes(attr($pname)) . "'," . addslashes(attr($prow['pid'])) . "," . addslashes(attr($prow['pubpid'])) . ",'" . addslashes(attr($str_dob)) . "');\">";
441 echo text($d->get_url_file());
447 // Get the related procedure order IDs if any.
449 "SELECT id1 FROM gprelations WHERE " .
450 "type1 = ? AND type2 = ? AND id2 = ?",
451 array('2', '6', $noteid)
453 if (sqlNumRows($tmp)) {
455 echo " <td class='text'><b>";
456 echo xlt('Linked procedure order') . ":</b>\n";
457 while ($gprow = sqlFetchArray($tmp)) {
459 echo $GLOBALS['webroot'] . "/interface/orders/single_order_results.php?orderid=";
460 echo attr($gprow['id1']);
461 echo "' target='_blank' onclick='top.restoreSession()'>";
462 echo text($gprow['id1']);
476 $body = preg_replace('/(:\d{2}\s\()' . $result['pid'] . '(\sto\s)/', '${1}' . $patientname . '${2}', $body);
477 $body = preg_replace('/(\d{4}-\d{2}-\d{2} \d{2}:\d{2}\s\([^)(]+\s)(to)(\s[^)(]+\))/', '${1}' . xl('to') . '${3}', $body);
478 $body = nl2br(text($body));
479 echo "<div class='text' style='background-color:white; color: gray; border:1px solid #999; padding: 5px; width: 640px;'>" . $body . "</div>";
483 <textarea name
='note' id
='note' class='form-control'
484 style
='margin:6px; background-color:white; color: gray; border:1px solid #999; padding: 5px; height:100px; width: 640px;'><?php
echo nl2br(text($note)); ?
></textarea
>
490 <?php
if ($noteid) { ?
>
491 <!-- This is
for displaying an existing note
. -->
492 <input type
="button" class="form-control btn btn-primary" id
="newnote"
493 value
="<?php echo xla('Send message'); ?>">
494 <input type
="button" class="form-control btn btn-primary" id
="printnote"
495 value
="<?php echo xla('Print message'); ?>">
496 <input type
="button" class="form-control btn btn-primary" id
="cancel"
497 value
="<?php echo xla('Cancel'); ?>">
499 <!-- This is
for displaying a
new note
. -->
500 <input type
="button" class="form-control btn btn-primary" id
="newnote"
501 value
="<?php echo xla('Send message'); ?>">
502 <input type
="button" class="form-control" id
="cancel" value
="<?php echo xla('Cancel'); ?>">
511 // This is for sorting the records.
512 $sort = array("users.lname", "patient_data.lname", "pnotes.title", "pnotes.date", "pnotes.message_status");
513 $sortby = (isset($_REQUEST['sortby']) && ($_REQUEST['sortby'] != "")) ?
$_REQUEST['sortby'] : $sort[0];
514 $sortorder = (isset($_REQUEST['sortorder']) && ($_REQUEST['sortorder'] != "")) ?
$_REQUEST['sortorder'] : "asc";
515 $begin = isset($_REQUEST['begin']) ?
$_REQUEST['begin'] : 0;
517 for ($i = 0; $i < count($sort); $i++
) {
518 $sortlink[$i] = "<a href=\"messages.php?show_all=" . attr($showall) . "&sortby=" . attr($sort[$i]) . "&sortorder=asc&$activity_string_html\" onclick=\"top.restoreSession()\"><img src=\"../../../images/sortdown.gif\" border=0 alt=\"" . xla('Sort Up') . "\"></a>";
520 for ($i = 0; $i < count($sort); $i++
) {
521 if ($sortby == $sort[$i]) {
522 switch ($sortorder) {
524 $sortlink[$i] = "<a href=\"messages.php?show_all=" . attr($showall) . "&sortby=" . attr($sortby) . "&sortorder=desc&$activity_string_html\" onclick=\"top.restoreSession()\"><img src=\"../../../images/sortup.gif\" border=0 alt=\"" . xla('Sort Up') . "\"></a>";
527 $sortlink[$i] = "<a href=\"messages.php?show_all=" . attr($showall) . "&sortby=" . attr($sortby) . "&sortorder=asc&$activity_string_html\" onclick=\"top.restoreSession()\"><img src=\"../../../images/sortdown.gif\" border=0 alt=\"" . xla('Sort Down') . "\"></a>";
533 // Manage page numbering and display beneath the Messages table.
535 $total = getPnotesByUser($active, $show_all, $_SESSION['authUser'], true);
536 if ($begin == "" or $begin == 0) {
539 $prev = $begin - $listnumber;
540 $next = $begin +
$listnumber;
542 $end = $listnumber +
$start - 1;
543 if ($end >= $total) {
550 $prevlink = "<a href=\"messages.php?show_all=" . attr($showall) . "&sortby=" . attr($sortby) . "&sortorder=" . attr($sortorder) . "&begin=" . attr($prev) . "&$activity_string_html\" onclick=\"top.restoreSession()\"><<</a>";
555 if ($next < $total) {
556 $nextlink = "<a href=\"messages.php?show_all=" . attr($showall) . "&sortby=" . attr($sortby) . "&sortorder=" . attr($sortorder) . "&begin=" . attr($next) . "&$activity_string_html\" onclick=\"top.restoreSession()\">>></a>";
560 // Display the Messages table header.
565 <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>
566 <table border=0 cellpadding=1 cellspacing=0 width=90% style=\"border-left: 1px #000000 solid; border-right: 1px #000000 solid; border-top: 1px #000000 solid;\">
567 <input type=hidden name=task value=delete>
568 <tr height=\"24\" style=\"background:lightgrey\">
569 <td align=\"center\" width=\"25\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\"><input type=checkbox id=\"checkAll\" onclick=\"selectAll()\"></td>
570 <td width=\"20%\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\" class=bold> <b>" .
571 xlt('From') . "</b> $sortlink[0]</td>
572 <td width=\"20%\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\" class=bold> <b>" .
573 xlt('Patient') . "</b> $sortlink[1]</td>
574 <td style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\" class=bold> <b>" .
575 xlt('Type') . "</b> $sortlink[2]</td>
576 <td width=\"15%\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\" class=bold> <b>" .
577 xlt('Date') . "</b> $sortlink[3]</td>
578 <td width=\"15%\" style=\"border-bottom: 1px #000000 solid; \" class=bold> <b>" .
579 xlt('Status') . "</b> $sortlink[4]</td>
581 // Display the Messages table body.
583 $result = getPnotesByUser($active, $show_all, $_SESSION['authUser'], false, $sortby, $sortorder, $begin, $listnumber);
584 while ($myrow = sqlFetchArray($result)) {
585 $name = $myrow['user'];
586 $name = $myrow['users_lname'];
587 if ($myrow['users_fname']) {
588 $name .= ", " . $myrow['users_fname'];
590 $patient = $myrow['pid'];
592 $patient = $myrow['patient_data_lname'];
593 if ($myrow['patient_data_fname']) {
594 $patient .= ", " . $myrow['patient_data_fname'];
597 $patient = "* " . xlt('Patient must be set manually') . " *";
601 <tr id=\"row$count\" style=\"background:white\" height=\"24\">
602 <td align=\"center\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\">
603 <input type=checkbox id=\"check$count\" name=\"delete_id[]\" value=\"" .
604 attr($myrow['id']) . "\" onclick=\"if(this.checked==true){ selectRow('row$count'); }else{ deselectRow('row$count'); }\"></td>
605 <td style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\">
606 <table cellspacing=0 cellpadding=0 width=100%><tr><td width=5></td><td class=\"text\">" .
607 text($name) . "</td><td width=5></td></tr>
609 <td style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\">
610 <table cellspacing=0 cellpadding=0 width=100%><tr><td width=5></td><td class=\"text\"><a href=\"messages.php?showall=" . attr($showall) . "&sortby=" . attr($sortby) . "&sortorder=" . attr($sortorder) . "&begin=" . attr($begin) . "&task=edit¬eid=" .
611 attr($myrow['id']) . "&$activity_string_html\" onclick=\"top.restoreSession()\">" .
612 text($patient) . "</a></td><td width=5></td></tr>
614 <td style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\">
615 <table cellspacing=0 cellpadding=0 width=100%><tr><td width=5></td><td class=\"text\">" .
616 xlt($myrow['title']) . "</td><td width=5></td></tr>
618 <td style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\">
619 <table cellspacing=0 cellpadding=0 width=100%><tr><td width=5></td><td class=\"text\">" .
620 text(oeFormatShortDate(substr($myrow['date'], 0, strpos($myrow['date'], " ")))) . "</td><td width=5></td></tr>
623 <td style=\"border-bottom: 1px #000000 solid;\">
624 <table cellspacing=0 cellpadding=0 width=100%><tr><td width=5></td><td class=\"text\">" .
625 xlt($myrow['message_status']) . "</td><td width=5></td></tr>
630 // Display the Messages table footer.
634 <table class='table'>
636 <td class=\"text\"><a href=\"messages.php?showall=" . attr($showall) . "&sortby=" . attr($sortby) . "&sortorder=" . attr($sortorder) . "&begin=" . attr($begin) . "&task=addnew&$activity_string_html\" onclick=\"top.restoreSession()\">" .
637 xlt('Add New') . "</a> <a href=\"javascript:confirmDeleteSelected()\" onclick=\"top.restoreSession()\">" .
638 xlt('Delete') . "</a></td>
639 <td align=right class=\"text amount-msg\">$prevlink $end of $total $nextlink</td>
648 <script language
="javascript">
649 // This is to confirm delete action.
650 function confirmDeleteSelected() {
651 if (confirm("<?php echo xls('Do you really want to delete the selection?'); ?>")) {
652 document
.MessageList
.submit();
656 // This is to allow selection of all items in Messages table for deletion.
657 function selectAll() {
658 if (document
.getElementById("checkAll").checked
=== true) {
659 document
.getElementById("checkAll").checked
= true;<?php
660 for ($i = 1; $i <= $count; $i++
) {
661 echo "document.getElementById(\"check$i\").checked=true; document.getElementById(\"row$i\").style.background='#E7E7E7'; ";
664 document
.getElementById("checkAll").checked
= false;<?php
665 for ($i = 1; $i <= $count; $i++
) {
666 echo "document.getElementById(\"check$i\").checked=false; document.getElementById(\"row$i\").style.background='#F7F7F7'; ";
671 // The two functions below are for managing row styles in Messages table.
672 function selectRow(row
) {
673 document
.getElementById(row
).style
.background
= "#E7E7E7";
676 function deselectRow(row
) {
677 document
.getElementById(row
).style
.background
= "#F7F7F7";
683 <div
class="col-sm-2"></div
>
685 <script language
="javascript">
687 var f
= $
("#smsForm");
688 $
("#SMS_patient").autocomplete({
689 source
: "save.php?go=sms_search",
691 select
: function (event
, ui
) {
692 event
.preventDefault();
693 $
("#SMS_patient").val(ui
.item
.label +
' ' + ui
.item
.mobile
);
694 $
("#sms_pid").val(ui
.item
.pid
);
695 $
("#sms_mobile").val(ui
.item
.mobile
);
696 $
("#sms_allow").val(ui
.item
.allow
);
700 jQuery
.ui
.autocomplete
.prototype
._resizeMenu
= function () {
701 var ul
= this
.menu
.element
;
702 ul
.outerWidth(this
.element
.outerWidth());
704 $
(document
).ready(function () {
705 $
("#newnote").click(function () {
708 $
("#printnote").click(function () {
711 var obj
= $
("#form_message_status");
712 obj
.onchange
= function () {
715 $
("#cancel").click(function () {
720 //clear button in messages
721 $
("#clear_user").click(function(){
722 $
("#assigned_to_text").val("<?php echo xls('Select Users From The Dropdown List'); ?>");
723 $
("#assigned_to").val("");
724 $
("#users").val("--");
727 //clear inputs of patients
728 $
("#clear_patients").click(function(){
729 $
("#reply_to").val("");
730 $
("#form_patient").val("");
734 var NewNote
= function () {
735 top
.restoreSession();
736 var f
= document
.getElementById('new_note');
737 if (f
.reply_to
.value
.length
=== 0 || f
.reply_to
.value
=== '0') {
738 alert('<?php echo xls('Please choose a patient
'); ?>');
740 else if (f
.assigned_to
.value
.length
=== 0 &&
741 document
.getElementById("form_message_status").value
!== 'Done') {
742 alert('<?php echo xls('Recipient required unless status is Done
'); ?>');
745 $
("#new_note").submit();
748 var PrintNote
= function () {
749 top
.restoreSession();
750 window
.open('../../patient_file/summary/pnotes_print.php?noteid=<?php echo htmlspecialchars($noteid, ENT_QUOTES); ?>', '_blank', 'resizable=1,scrollbars=1,width=600,height=500');
753 var SaveNote
= function () {
754 <?php
if ($noteid) { ?
>
755 top
.restoreSession();
756 $
("#task").val("save");
757 $
("#new_note").submit();
761 var CancelNote
= function () {
762 top
.restoreSession();
764 $
("#new_note").submit();
767 function gotoReport(doc_id
, pname
, pid
, pubpid
, str_dob
) {
768 EncounterDateArray
= [];
769 CalendarCategoryArray
= [];
770 EncounterIdArray
= [];
773 if (isset($enc_list) && sqlNumRows($enc_list) > 0) {
774 while ($row = sqlFetchArray($enc_list)) {
776 EncounterIdArray
[Count
] = '<?php echo attr($row['encounter
']); ?>';
777 EncounterDateArray
[Count
] = '<?php echo attr(oeFormatShortDate(date("Y-m-d", strtotime($row['date
'])))); ?>';
778 CalendarCategoryArray
[Count
] = '<?php echo attr(xl_appt_category($row['pc_catname
'])); ?>';
784 top
.restoreSession();
787 url
: '<?php echo $GLOBALS['webroot
'] . "/library/ajax/set_pt.php";?>',
788 data
: {set_pid
: pid
},
791 parent
.left_nav
.setPatient(pname
, pid
, pubpid
, '', str_dob
);
792 parent
.left_nav
.setPatientEncounter(EncounterIdArray
, EncounterDateArray
, CalendarCategoryArray
);
793 <?php
if ($GLOBALS['new_tabs_layout']) { ?
>
794 var docurl
= '../controller.php?document&view' +
"&patient_id=" + pid +
"&document_id=" + doc_id +
"&";
795 var paturl
= 'patient_file/summary/demographics.php?pid=' + pid
;
796 parent
.left_nav
.loadFrame('dem1', 'pat', paturl
);
797 parent
.left_nav
.loadFrame('doc0', 'enc', docurl
);
798 top
.activateTabByName('enc', true);
800 var docurl
= '<?php echo $GLOBALS['webroot
'] . "/controller.php?document&view"; ?>' +
"&patient_id=" + pid +
"&document_id=" + doc_id +
"&";
801 var paturl
= '<?php echo $GLOBALS['webroot
'] . "/interface/patient_file/summary/demographics.php?pid="; ?>' + pid
;
802 var othername
= (window
.name
=== 'RTop') ?
'RBot' : 'RTop';
803 parent
.frames
[othername
].location
.href
= paturl
;
804 location
.href
= docurl
;
808 // This is for callback by the find-patient popup.
809 function setpatient(pid
, lname
, fname
, dob
) {
810 var f
= document
.getElementById('new_note');
811 f
.form_patient
.value +
= lname +
', ' + fname +
'; ';
812 f
.reply_to
.value +
= pid +
';';
813 <?php
if ($noteid) { ?
>
814 //used when direct messaging service inserts a pnote with indeterminate patient
815 //to allow the user to assign the message to a patient.
816 top
.restoreSession();
817 $
("#task").val("savePatient");
818 $
("#new_note").submit();
822 // This is for callback by the multi_patients_finder popup.
823 function setMultiPatients(patientsList
) {
824 var f
= document
.getElementById('new_note');
825 f
.form_patient
.value
='';
827 $
.each(patientsList
, function (key
, patient
) {
828 f
.form_patient
.value +
= patient
.lname +
', ' + patient
.fname +
'; ';
829 f
.reply_to
.value +
= patient
.pid +
';';
832 <?php
if ($noteid) { ?
>
833 //used when direct messaging service inserts a pnote with indeterminate patient
834 //to allow the user to assign the message to a patient.
835 top
.restoreSession();
836 $
("#task").val("savePatient");
837 $
("#new_note").submit();
841 // This invokes the find-patient popup.
842 function sel_patient() {
843 dlgopen('../../main/calendar/find_patient_popup.php', '_blank', 625, 400);
846 function multi_sel_patient() {
847 var url
= '../../main/finder/multi_patients_finder.php'
848 // for edit selected list
849 if($
('#reply_to').val() !== ''){
850 url
= url+
'?patients='+$
('#reply_to').val();
852 dlgopen(url
, '_blank', 625, 400);
855 function addtolist(sel
) {
856 var itemtext
= document
.getElementById('assigned_to_text');
857 var item
= document
.getElementById('assigned_to');
858 if (sel
.value
!== '--') {
860 if (item
.value
.indexOf(sel
.value
) === -1) {
861 itemtext
.value
= itemtext
.value +
' ; ' + sel
.options
[sel
.selectedIndex
].text
;
862 item
.value
= item
.value +
';' + sel
.value
;
865 itemtext
.value
= sel
.options
[sel
.selectedIndex
].text
;
866 item
.value
= sel
.value
;
871 function SMS_direct() {
872 var pid
= $
("#sms_pid").val();
873 var m
= $
("#sms_mobile").val();
874 var allow
= $
("#sms_allow").val();
875 if ((pid
=== '') ||
(m
=== '')) {
876 alert('MedEx needs a valid mobile number to send SMS messages...');
877 } else if (allow
=== 'NO') {
878 alert('This patient does not allow SMS messaging!');
880 top
.restoreSession();
881 window
.open('messages.php?nomenu=1&go=SMS_bot&pid=' + pid +
'&m=' + m
, 'SMS_bot', 'width=370,height=600,resizable=0');