minor changes to prior commit
[openemr.git] / interface / main / messages / messages.php
blob422b0013a3656276829b2385d99c7e1dae16ea71
1 <?php
2 /**
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.
7 * @Package OpenEMR
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 //validation library
32 $use_validate_js = 1;
33 require_once($GLOBALS['srcdir'] . "/validation/validation_script.js.php");
34 //Gets validation rules from Page Validation list.
35 $collectthis = collectValidationPageRules("/interface/main/messages/messages.php");
36 if (empty($collectthis)) {
37 $collectthis = "{}";
38 } else {
39 $collectthis = $collectthis[array_keys($collectthis)[0]]["rules"];
42 $MedEx = new MedExApi\MedEx('MedExBank.com');
44 if ($GLOBALS['medex_enable'] == '1') {
45 $logged_in = $MedEx->login();
46 if ($_REQUEST['SMS_bot']) {
47 $MedEx->display->SMS_bot($logged_in);
48 exit();
52 $setting_bootstrap_submenu = prevSetting('', 'setting_bootstrap_submenu', 'setting_bootstrap_submenu', ' ');
53 //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).
54 $uspfx = substr(__FILE__, strlen($webserver_root)) . '.';
55 $rcb_selectors = prevSetting($uspfx, 'rcb_selectors', 'rcb_selectors', 'block');
56 $rcb_facility = prevSetting($uspfx, 'form_facility', 'form_facility', '');
57 $rcb_provider = prevSetting($uspfx, 'form_provider', 'form_provider', $_SESSION['authUserID']);
59 if (($_POST['setting_bootstrap_submenu']) ||
60 ($_POST['rcb_selectors'])) {
61 // These are not form elements. We only ever change them via ajax, so exit now.
62 exit();
65 <!DOCTYPE html>
66 <html>
67 <head>
68 <link rel="stylesheet" href="<?php echo $webroot; ?>/interface/main/messages/css/reminder_style.css?v=<?php echo $v_js_includes; ?>" type="text/css">
69 <link rel="stylesheet" href="<?php echo $GLOBALS['web_root']; ?>/library/css/bootstrap_navbar.css?v=<?php echo $v_js_includes; ?>" type="text/css">
71 <?php Header::setupHeader(['datetime-picker', 'jquery-ui', 'jquery-ui-redmond', 'opener', 'moment']); ?>
72 <script>
73 var xljs1 = '<?php echo xl('Preferences updated successfully'); ?>';
74 var format_date_moment_js = '<?php echo attr(DateFormatRead("validateJS")); ?>';
75 <?php require_once "$srcdir/restoreSession.php"; ?>
76 </script>
78 <script type="text/javascript" src="<?php echo $GLOBALS['web_root']; ?>/interface/main/messages/js/reminder_appts.js?v=<?php echo $v_js_includes; ?>"></script>
80 <link rel="shortcut icon" href="<?php echo $webroot; ?>/sites/default/favicon.ico" />
82 <meta charset="utf-8">
83 <meta http-equiv="X-UA-Compatible" content="IE=edge">
84 <meta name="description" content="MedEx Bank">
85 <meta name="author" content="OpenEMR: MedExBank">
86 <meta name="viewport" content="width=device-width, initial-scale=1">
87 <style>
88 @media only screen and (max-width: 768px) {
89 [class*="col-"] {
90 width: 100%;
91 text-align: left!important;
93 .navbar-toggle>span.icon-bar {
94 background-color: #68171A ! important;
96 .navbar-default .navbar-toggle {
97 border-color: #4a4a4a;
99 .navbar-default .navbar-toggle:focus, .navbar-default .navbar-toggle:hover {
100 background-color: #f2f2f2 !important;
101 font-weight: 900 !important;
102 color: #000000 !important;
104 .navbar-color {
105 background-color: #E5E5E5;
107 .icon-bar {
108 background-color: #68171A;
110 .navbar-header {
111 float: none;
113 .navbar-toggle {
114 display: block;
115 background-color: #f2f2f2;
117 .navbar-nav {
118 float: none!important;
120 .navbar-nav>li {
121 float: none;
123 .navbar-collapse.collapse.in {
124 z-index: 100;
125 background-color: #dfdfdf;
126 font-weight: 700;
127 color: #000000 !important;
132 </style>
134 <?php
135 if (($GLOBALS['medex_enable'] == '1') && (empty($_REQUEST['nomenu'])) && ($GLOBALS['disable_rcb'] != '1')) {
136 $MedEx->display->navigation($logged_in);
137 echo "<br />";
140 if (!empty($_REQUEST['go'])) { ?>
141 <?php
142 if (($_REQUEST['go'] == "setup") && (!$logged_in)) {
143 echo "<title>" . xlt('MedEx Setup') . "</title></head><body class='body_top'>";
144 $stage = $_REQUEST['stage'];
145 if (!is_numeric($stage)) {
146 echo "<br /><span class='title'>$stage " . xlt('Warning') . ": " . xlt('This is not a valid request') . ".</span>";
147 } else {
148 $MedEx->setup->MedExBank($stage);
150 } elseif ($_REQUEST['go'] == "addRecall") {
151 echo "<title>" . xlt('New Recall') . "</title></head><body class='body_top'>";
152 $MedEx->display->display_add_recall();
153 } elseif ($_REQUEST['go'] == 'Recalls') {
154 echo "<title>" . xlt('Recall Board') . "</title></head><body class='body_top'>";
155 $MedEx->display->display_recalls($logged_in);
156 } elseif ((($_REQUEST['go'] == "setup") || ($_REQUEST['go'] == 'Preferences')) && ($logged_in)) {
157 echo "<title>MedEx" . xlt('Preferences') . "</title></head><body class='body_top'>";
158 $MedEx->display->preferences();
159 } elseif ($_REQUEST['go'] == 'icons') {
160 echo "<title>MedEx" . xlt('Icons') . "</title></head><body class='body_top'>";
161 $MedEx->display->icon_template();
162 } elseif ($_REQUEST['go'] == 'SMS_bot') {
163 echo "<title>MedEx" . xlt('SMS') . "</title></head><body class='body_top'>";
164 $MedEx->display->SMS_bot($logged_in);
165 } else {
166 echo "<title>" . xlt('MedEx Setup') . "</title></head><body class='body_top'>";
167 echo xlt('Warning: Navigation error. Please refresh this page.');
169 } else {
170 //original message.php stuff
171 echo "<title>" . xlt('Message Center') . "</title>
172 </head>
173 <body class='body_top'>";
174 if ($GLOBALS['enable_help'] == 1) {
175 $help_icon = '<a class="pull-right oe-help-redirect" data-target="#myModal" data-toggle="modal" href="#" id="help-href" name="help-href" style="color:#676666" title="' . xla("Click to view Help") . '"><i class="fa fa-question-circle" aria-hidden="true"></i></a>';
176 } elseif ($GLOBALS['enable_help'] == 2) {
177 $help_icon = '<a class="pull-right oe-help-redirect" data-target="#myModal" data-toggle="modal" href="#" id="help-href" name="help-href" style="color:#DCD6D0 !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>';
178 } elseif ($GLOBALS['enable_help'] == 0) {
179 $help_icon = '';
182 <div class="container">
183 <div class="row">
184 <div class="page-header clearfix">
185 <h2 id="header_title" class="clearfix"><span id='header_text'>
186 <?php
187 echo xlt('Messages, Reminders');
188 if ($GLOBALS['disable_rcb'] != '1') {
189 echo ", " . xlt('Recalls');
192 </span><?php echo $help_icon; ?></h2>
193 </div>
194 </div>
195 <div class="row" >
196 <nav class="navbar navbar-default navbar-color navbar-static-top" >
197 <div class="container-fluid">
198 <div class="navbar-header">
199 <button class="navbar-toggle" data-target="#myNavbar" data-toggle="collapse" type="button"><span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span></button>
200 </div>
201 <div class="collapse navbar-collapse" id="myNavbar" >
202 <ul class="nav navbar-nav" >
203 <li class="active oe-bold-black" id='li-mess'>
204 <a href='#' style="font-weight:700; color:#000000" id='messages-li'><?php echo xlt('Messages'); ?></a>
205 </li>
206 <li class="oe-bold-black" id='li-remi' >
207 <a href='#' id='reminders-li' style="font-weight:700; color:#000000"><?php echo xlt('Reminders'); ?></a>
208 </li>
209 <?php if ($GLOBALS['disable_rcb'] != '1') { ?>
210 <li class="oe-bold-black" id='li-reca'>
211 <a href='#' id='recalls-li' style="font-weight:700; color:#000000"><?php echo xlt('Recalls'); ?></a>
212 </li>
213 <?php }?>
214 <?php if ($logged_in) { ?>
215 <li class="oe-bold-black" id='li-sms'>
216 <a href='#' id='sms-li' style="font-weight:700; color:#000000"><?php echo xlt('SMS Zone'); ?></a>
217 </li>
218 <?php }?>
219 </ul>
220 </div>
221 </div>
222 </nav>
223 </div>
224 <div class="row" id="messages-div">
225 <fieldset>
226 <div class="col-sm-12 col-md-12 col-lg-12">
227 <?php
228 // Check to see if the user has Admin rights, and if so, allow access to See All.
229 $showall = isset($_GET['show_all']) ? $_GET['show_all'] : "";
230 if ($showall == "yes") {
231 $show_all = $showall;
232 } else {
233 $show_all = "no";
235 // Collect active variable and applicable html code for links
236 $form_active = (isset($_REQUEST['form_active']) ? $_REQUEST['form_active'] : false);
237 $form_inactive = (isset($_REQUEST['form_inactive']) ? $_REQUEST['form_inactive'] : false);
238 if ($form_active) {
239 $active = '1';
240 $activity_string_html = 'form_active=1';
241 } elseif ($form_inactive) {
242 $active = '0';
243 $activity_string_html = 'form_inactive=1';
244 } else {
245 $active = 'all';
246 $activity_string_html = '';
248 //collect the task setting
249 $task = isset($_REQUEST['task']) ? $_REQUEST['task'] : "";
250 if (acl_check('admin', 'super')) {
251 if ($show_all == 'yes') {
252 $showall = "yes";
253 $lnkvar = "\"messages.php?show_all=no&$activity_string_html\" name='Just Mine' onclick=\"top.restoreSession()\"><i id='just-mine-tooltip' class='fa fa-user fa-lg' aria-hidden='true'></i>";
254 $messages = xlt('All Messages');
255 } else {
256 $showall = "no";
257 $lnkvar = "\"messages.php?show_all=yes&$activity_string_html\" name='See All' onclick=\"top.restoreSession()\"><i id='see-all-tooltip' class='fa fa-users fa-lg' aria-hidden='true'></i>";
258 $messages = xlt('My Messages');
260 } else {
261 $messages = xlt('My Messages');
264 <div class="oe-margin-b-20">
265 <span class="title"><?php echo $messages; ?></span>
266 <a class='more' href=<?php echo $lnkvar; ?></a>
267 </div>
268 <div class="oe-margin-b-10">
269 <?php
270 //show the activity links
271 if (empty($task) || $task == "add" || $task == "delete") { ?>
272 <?php if ($active == "all") { ?>
273 <span><strong><?php echo xlt('All Messages'); ?></strong></span>
274 <?php } else { ?>
275 <a href="messages.php" class="link btn btn-default"
276 onclick="top.restoreSession()"><span><?php echo xlt('Show All'); ?></span></a>
277 <?php } ?>
279 <?php if ($active == '1') { ?>
280 <span><strong><?php echo xlt('Active Messages'); ?></strong></span>
281 <?php } else { ?>
282 <a href="messages.php?form_active=1" class="link btn btn-default"
283 onclick="top.restoreSession()"><span><?php echo xlt('Show Active'); ?></span></a>
284 <?php } ?>
286 <?php if ($active == '0') { ?>
287 <span><strong><?php echo xlt('Inactive Messages'); ?></strong></span>
288 <?php } else { ?>
289 <a href="messages.php?form_inactive=1" class="link btn btn-default"
290 onclick="top.restoreSession()"><span><?php echo xlt('Show Inactive'); ?></span></a>
291 <?php } ?>
292 <?php } ?>
293 </div>
294 <?php
295 switch ($task) {
296 case "add":
297 // Add a new message for a specific patient; the message is documented in Patient Notes.
298 // Add a new message; it's treated as a new note in Patient Notes.
299 $note = $_POST['note'];
300 $noteid = $_POST['noteid'];
301 $form_note_type = $_POST['form_note_type'];
302 $form_message_status = $_POST['form_message_status'];
303 $reply_to = explode(';', rtrim($_POST['reply_to'], ';'));
304 $assigned_to_list = explode(';', $_POST['assigned_to']);
305 $datetime = isset($_POST['form_datetime']) ? DateTimeToYYYYMMDDHHMMSS($_POST['form_datetime']) : '';
306 foreach ($assigned_to_list as $assigned_to) {
307 if ($noteid && $assigned_to != '-patient-') {
308 updatePnote($noteid, $note, $form_note_type, $assigned_to, $form_message_status, $datetime);
309 $noteid = '';
310 } else {
311 if ($noteid && $assigned_to == '-patient-') {
312 // When $assigned_to == '-patient-' we don't update the current note, but
313 // instead create a new one with the current note's body prepended and
314 // attributed to the patient. This seems to be all for the patient portal.
315 $row = getPnoteById($noteid);
316 if (!$row) {
317 die("getPnoteById() did not find id '" . text($noteid) . "'");
319 $pres = sqlQuery("SELECT lname, fname " .
320 "FROM patient_data WHERE pid = ?", array($reply_to[0]));
321 $patientname = $pres['lname'] . ", " . $pres['fname'];
322 $note .= "\n\n$patientname on " . $row['date'] . " wrote:\n\n";
323 $note .= $row['body'];
325 // There's no note ID, and/or it's assigned to the patient.
326 // In these cases a new note is created.
327 foreach ($reply_to as $patient) {
328 addPnote($patient, $note, $userauthorized, '1', $form_note_type, $assigned_to, $datetime, $form_message_status);
332 break;
333 case "savePatient":
334 case "save":
335 // Update alert.
336 $noteid = $_POST['noteid'];
337 $form_message_status = $_POST['form_message_status'];
338 $reply_to = $_POST['reply_to'];
339 if ($task == "save") {
340 updatePnoteMessageStatus($noteid, $form_message_status);
341 } else {
342 updatePnotePatient($noteid, $reply_to);
344 $task = "edit";
345 $note = $_POST['note'];
346 $title = $_POST['form_note_type'];
347 $reply_to = $_POST['reply_to'];
348 break;
349 case "edit":
350 if ($noteid == "") {
351 $noteid = $_GET['noteid'];
353 // Update the message if it already exists; it's appended to an existing note in Patient Notes.
354 $result = getPnoteById($noteid);
355 if ($result) {
356 if ($title == "") {
357 $title = $result['title'];
359 $body = $result['body'];
360 if ($reply_to == "") {
361 $reply_to = $result['pid'];
363 $form_message_status = $result['message_status'];
364 $datetime = $result['date'];
366 break;
367 case "delete":
368 // Delete selected message(s) from the Messages box (only).
369 $delete_id = $_POST['delete_id'];
370 for ($i = 0; $i < count($delete_id); $i++) {
371 deletePnote($delete_id[$i]);
372 newEvent("delete", $_SESSION['authUser'], $_SESSION['authProvider'], 1, "pnotes: id " . $delete_id[$i]);
374 break;
376 if ($task == "addnew" or $task == "edit") {
377 // Display the Messages page layout.
378 echo "<form name='form_patient' id='new_note'
379 class='form-horizontal'
380 action=\"messages.php?showall=" . attr($showall) . "&sortby=" . attr($sortby) . "&sortorder=" . attr($sortorder) . "&begin=" . attr($begin) . "&$activity_string_html\"
381 method='post'>
382 <input type=hidden name=noteid id=noteid value='" . attr($noteid) . "'>
383 <input type=hidden name=task id=task value=add>";
384 if ($task == "addnew") {
385 $message_legend = xlt('Create New Message');
386 $onclick = "onclick=multi_sel_patient()";
387 } elseif ($task == "edit") {
388 $message_legend = xlt('Add To Existing Message');
389 $onclick = "";
393 <div class='col-md-12'>
394 <fieldset>
395 <legend><?php echo attr($message_legend); ?></legend>
396 <div class="row">
397 <div class="col-xs-12 col-sm-12 col-md-12 col-lg-10 oe-custom-line col-lg-offset-1">
398 <div class="row">
399 <div class="col-xs-3 col-sm-3">
400 <label class="control-label" for="form_note_type"><?php echo xlt('Type'); ?>:</label>
401 <?php
402 if ($title == "") {
403 $title = "Unassigned";
405 // Added 6/2009 by BM to incorporate the patient notes into the list_options listings.
406 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);
408 </div>
409 <div class="col-xs-3 col-sm-3">
410 <label class="control-label" for="form_message_status"><?php echo xlt('Status'); ?>:</label>
411 <?php
412 if ($form_message_status == "") {
413 $form_message_status = 'New';
415 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); ?>
416 </div>
417 <div class="col-xs-4">
418 <label class="control-label" for="form_patient">
419 <?php
420 if ($task != "addnew" && $result['pid'] != 0) { ?>
421 <a class="patLink"
422 onclick="goPid('<?php echo attr($result['pid']); ?>')"><?php echo xlt('Patient'); ?>
423 :</a>
424 <?php
425 } else { ?>
426 <b class='<?php echo($task == "addnew" ? "required" : "") ?>'><?php echo xlt('Patient'); ?>
427 :</b>
428 <?php
431 </label>
432 <?php
433 if ($reply_to) {
434 $prow = sqlQuery("SELECT lname, fname,pid, pubpid, DOB " .
435 "FROM patient_data WHERE pid = ?", array($reply_to));
436 $patientname = $prow['lname'] . ", " . $prow['fname'];
438 if ($task == "addnew" || $result['pid']==0) {
439 $cursor = "oe-cursor-add";
440 $background = "oe-patient-background";
441 } elseif ($task == "edit") {
442 $cursor = "oe-cursor-stop";
443 $background = '';
446 <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/>
447 <input type='hidden' class="form-control" name='reply_to' id='reply_to' value='<?php echo attr($reply_to); ?>'/>
448 </div>
449 <div class="col-xs-2">
450 <?php
451 if ($task=="addnew" || $result['pid']==0) {
452 echo "<label class='control-label oe-empty-label' for='clear_patients'></label>";
453 echo '<button type="button" id="clear_patients" class="btn btn-default btn-undo pull-left flip" value="' . xla('Clear') .'">' . xlt("Clear") . '</button>';
454 } ?>
455 </div>
456 </div>
457 </div>
458 </div>
459 <div class="row">
460 <div class="col-xs-12 col-sm-12 col-md-12 col-lg-10 oe-custom-line col-lg-offset-1">
461 <div class="row">
462 <?php if ($GLOBALS['messages_due_date']) { ?>
463 <div class="col-xs-6 col-sm-2">
464 <label class="control-label" for="form_note_type"><?php echo xlt('Due date'); ?>:</label>
465 <?php generate_form_field(array('data_type' => 4, 'field_id' => 'datetime', 'edit_options' => 'F'), empty($datetime) ? date('Y-m-d H:i') : $datetime) ?>
466 </div>
467 <?php } ?>
468 <div class="col-xs-6 col-sm-4">
469 <label class="control-label" for="assigned_to_text"><?php echo xlt('To'); ?>:</label>
470 <input type='text' name='assigned_to_text' class='form-control oe-cursor-stop' id='assigned_to_text' readonly='readonly'
471 value='' placeholder='<?php echo xla("SELECT Users FROM The Dropdown LIST"); ?>'>
472 <input type='hidden' name='assigned_to' id='assigned_to'>
473 </div>
474 <div class="col-xs-6 col-sm-4">
475 <label class="control-label oe-empty-label" for="users"></label>
476 <select name='users' id='users' class='form-control' onchange='addtolist(this);'>
477 <?php
478 echo "<option value='--'";
479 echo ">" . xlt('Select User');
480 echo "</option>\n";
481 $ures = sqlStatement("SELECT username, fname, lname FROM users " .
482 "WHERE username != '' AND active = 1 AND " .
483 "( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
484 "ORDER BY lname, fname");
485 while ($urow = sqlFetchArray($ures)) {
486 echo " <option value='" . attr($urow['username']) . "'";
487 echo ">" . text($urow['lname']);
488 if ($urow['fname']) {
489 echo ", " . text($urow['fname']);
491 echo "</option>\n";
493 if ($GLOBALS['portal_offsite_enable']) {
494 echo "<option value='-" . xla('patient') . "-'";
495 echo ">-" . xlt('Patient') . "-";
496 echo "</option>\n";
499 </select>
500 </div>
501 <div class="col-xs-6 col-sm-2">
502 <label class="control-label oe-empty-label" for="users"></label>
503 <button type="button" name="clear_user" id="clear_user" class="btn btn-default btn-undo pull-left flip" value="<?php echo xla('Clear'); ?>"><?php echo xlt('Clear'); ?></button>
504 </div>
505 </div>
506 <div class='col-xs-12 oe-margin-t-3'>
507 <?php
508 if ($noteid) {
509 // Get the related document IDs if any.
510 $tmp = sqlStatement(
511 "SELECT id1 FROM gprelations WHERE " .
512 "type1 = ? AND type2 = ? AND id2 = ?",
513 array('1', '6', $noteid)
515 if (sqlNumRows($tmp)) {
516 echo " <tr>\n";
517 echo " <td class='text'><b>";
518 echo xlt('Linked document') . ":</b>\n";
519 while ($gprow = sqlFetchArray($tmp)) {
520 $d = new Document($gprow['id1']);
521 $enc_list = sqlStatement("SELECT fe.encounter,fe.date,openemr_postcalendar_categories.pc_catname FROM form_encounter AS fe " .
522 " 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']));
523 $str_dob = htmlspecialchars(xl("DOB") . ":" . $prow['DOB'] . " " . xl("Age") . ":" . getPatientAge($prow['DOB']));
524 $pname = $prow['fname'] . " " . $prow['lname'];
525 echo "<a href='javascript:void(0);' ";
526 echo "onClick=\"gotoReport(" . addslashes(attr($d->get_id())) . ",'" . addslashes(attr($pname)) . "'," . addslashes(attr($prow['pid'])) . "," . addslashes(attr($prow['pubpid'])) . ",'" . addslashes(attr($str_dob)) . "');\">";
527 echo text($d->get_url_file());
528 echo "</a>\n";
530 echo " </td>\n";
531 echo " </tr>\n";
533 // Get the related procedure order IDs if any.
534 $tmp = sqlStatement(
535 "SELECT id1 FROM gprelations WHERE " .
536 "type1 = ? AND type2 = ? AND id2 = ?",
537 array('2', '6', $noteid)
539 if (sqlNumRows($tmp)) {
540 echo " <tr>\n";
541 echo " <td class='text'><b>";
542 echo xlt('Linked procedure order') . ":</b>\n";
543 while ($gprow = sqlFetchArray($tmp)) {
544 echo " <a href='";
545 echo $GLOBALS['webroot'] . "/interface/orders/single_order_results.php?orderid=";
546 echo attr($gprow['id1']);
547 echo "' target='_blank' onclick='top.restoreSession()'>";
548 echo text($gprow['id1']);
549 echo "</a>\n";
551 echo " </td>\n";
552 echo " </tr>\n";
556 </div>
557 </div>
558 <div class="row">
559 <div class='col-xs-12'>
560 <?php
562 if ($noteid) {
563 $body = preg_replace('/(:\d{2}\s\()' . $result['pid'] . '(\sto\s)/', '${1}' . $patientname . '${2}', $body);
564 $body = preg_replace('/(\d{4}-\d{2}-\d{2} \d{2}:\d{2}\s\([^)(]+\s)(to)(\s[^)(]+\))/', '${1}' . xl('to') . '${3}', $body);
565 $body =nl2br(htmlspecialchars(oeFormatPatientNote($body), ENT_NOQUOTES));
566 echo "<div class='text oe-margin-t-3' style='background-color:white; color: gray; border:1px solid #999; padding: 5px;'>" . $body . "</div>";
570 <textarea name='note' id='note' class='form-control oe-margin-t-3'
571 style='margin-left:-1px !important; background-color:white; color: gray; border:1px solid #999; padding: 5px; height:100px!important;'><?php echo nl2br(text($note)); ?></textarea>
572 </div>
573 <div class="col-xs-12 position-override oe-margin-t-10">
574 <?php if ($noteid) { ?>
575 <!-- This is for displaying an existing note. -->
576 <button type="button" class="btn btn-default btn-send-msg" id="newnote"
577 value="<?php echo xla('Send message'); ?>"><?php echo xlt('Send message'); ?></button>
578 <button type="button" class="btn btn-default btn-print" id="printnote"
579 value="<?php echo xla('Print message'); ?>"><?php echo xlt('Print message'); ?></button>
580 <button type="button" class="btn btn-link btn-cancel oe-opt-btn-separate-left" id="cancel"
581 value="<?php echo xla('Cancel'); ?>"><?php echo xlt('Cancel'); ?></button>
582 <?php } else { ?>
583 <!-- This is for displaying a new note. -->
584 <button type="button" class="btn btn-default btn-send-msg" id="newnote"
585 value="<?php echo xla('Send message'); ?>"><?php echo xlt('Send message'); ?></button>
586 <button type="button" class="btn btn-link btn-cancel oe-opt-btn-separate-left" id="cancel"
587 value="<?php echo xla('Cancel'); ?>"><?php echo xlt('Cancel'); ?></button>
588 <?php }
590 </div>
591 </div>
592 </fieldset>
593 </div>
594 </form>
595 <?php
596 } else {
597 // This is for sorting the records.
598 $sort = array("users.lname", "patient_data.lname", "pnotes.title", "pnotes.date", "pnotes.message_status");
599 $sortby = (isset($_REQUEST['sortby']) && ($_REQUEST['sortby'] != "")) ? $_REQUEST['sortby'] : $sort[3];
600 $sortorder = (isset($_REQUEST['sortorder']) && ($_REQUEST['sortorder'] != "")) ? $_REQUEST['sortorder'] : "desc";
601 $begin = isset($_REQUEST['begin']) ? $_REQUEST['begin'] : 0;
603 for ($i = 0; $i < count($sort); $i++) {
604 $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>";
606 for ($i = 0; $i < count($sort); $i++) {
607 if ($sortby == $sort[$i]) {
608 switch ($sortorder) {
609 case "asc":
610 $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>";
611 break;
612 case "desc":
613 $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>";
614 break;
615 } break;
618 // Manage page numbering and display beneath the Messages table.
619 $listnumber = 25;
620 $total = getPnotesByUser($active, $show_all, $_SESSION['authUser'], true);
621 if ($begin == "" or $begin == 0) {
622 $begin = 0;
624 $prev = $begin - $listnumber;
625 $next = $begin + $listnumber;
626 $start = $begin + 1;
627 $end = $listnumber + $start - 1;
629 $chevron_icon_left = $_SESSION['language_direction'] == 'ltr' ? 'fa-chevron-circle-left' : 'fa-chevron-circle-right';
630 $chevron_icon_right = $_SESSION['language_direction'] == 'ltr' ? 'fa-chevron-circle-right' : 'fa-chevron-circle-left';
632 if ($end >= $total) {
633 $end = $total;
635 if ($end < $start) {
636 $start = 0;
638 if ($prev >= 0) {
639 $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>";
640 } else {
641 $prevlink = "<i class=\"fa ". $chevron_icon_left ." \" style=\"color:grey\" aria-hidden=\"true\" title=\"". xla("On first page") . "\"></i>";
644 if ($next < $total) {
645 $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>";
646 } else {
647 $nextlink = "<i class=\"fa . $chevron_icon_right .\" style=\"color:grey\" aria-hidden=\"true\" title=\"". xla("On first page") . "\"></i>";
649 // Display the Messages table header.
650 echo "
651 <table width=100%>
652 <tr>
653 <td>
654 <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>
655 <table border=0 cellpadding=1 cellspacing=0 style=\"border-left: 1px #000000 solid; width:100%; border-right: 1px #000000 solid; border-top: 1px #000000 solid;\">
656 <input type=hidden name=task value=delete>
657 <tr height=\"24\" style=\"background:lightgrey\" class=\"head\">
658 <td align=\"center\" width=\"25\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\"><input type=checkbox id=\"checkAll\" onclick=\"selectAll()\"></td>
659 <td width=\"20%\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\" class=bold>&nbsp;<b>" .
660 xlt('From') . "</b> $sortlink[0]</td>
661 <td width=\"20%\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\" class=bold>&nbsp;<b>" .
662 xlt('Patient') . "</b> $sortlink[1]</td>
663 <td style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\" class=bold>&nbsp;<b>" .
664 xlt('Type') . "</b> $sortlink[2]</td>
665 <td width=\"15%\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\" class=bold>&nbsp;<b>" .
666 xlt($GLOBALS['messages_due_date'] ? 'Due date' : 'Date') . "</b> $sortlink[3]</td>
667 <td width=\"15%\" style=\"border-bottom: 1px #000000 solid; \" class=bold>&nbsp;<b>" .
668 xlt('Status') . "</b> $sortlink[4]</td>
669 </tr>";
670 // Display the Messages table body.
671 $count = 0;
672 $result = getPnotesByUser($active, $show_all, $_SESSION['authUser'], false, $sortby, $sortorder, $begin, $listnumber);
673 while ($myrow = sqlFetchArray($result)) {
674 $name = $myrow['user'];
675 $name = $myrow['users_lname'];
676 if ($myrow['users_fname']) {
677 $name .= ", " . $myrow['users_fname'];
679 $patient = $myrow['pid'];
680 if ($patient > 0) {
681 $patient = $myrow['patient_data_lname'];
682 if ($myrow['patient_data_fname']) {
683 $patient .= ", " . $myrow['patient_data_fname'];
685 } else {
686 $patient = "* " . xlt('Patient must be set manually') . " *";
688 $count++;
689 echo "
690 <tr id=\"row$count\" style=\"background:white\" height=\"24\">
691 <td align=\"center\" style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\">
692 <input type=checkbox id=\"check$count\" name=\"delete_id[]\" value=\"" .
693 attr($myrow['id']) . "\" onclick=\"if(this.checked==true){ selectRow('row$count'); }else{ deselectRow('row$count'); }\"></td>
694 <td style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\">
695 <table cellspacing=0 cellpadding=0 width=100%><tr><td width=5></td><td class=\"text\">" .
696 text($name) . "</td><td width=5></td></tr>
697 </table></td>
698 <td style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\">
699 <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&noteid=" .
700 attr($myrow['id']) . "&$activity_string_html\" onclick=\"top.restoreSession()\">" .
701 text($patient) . "</a></td><td width=5></td></tr>
702 </table></td>
703 <td style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\">
704 <table cellspacing=0 cellpadding=0 width=100%><tr><td width=5></td><td class=\"text\">" .
705 xlt($myrow['title']) . "</td><td width=5></td></tr>
706 </table></td>
707 <td style=\"border-bottom: 1px #000000 solid; border-right: 1px #000000 solid;\">
708 <table cellspacing=0 cellpadding=0 width=100%><tr><td width=5></td><td class=\"text\">" .
709 text(oeFormatShortDate(substr($myrow['date'], 0, strpos($myrow['date'], " ")))) . "</td><td width=5></td></tr>
710 </table>
711 </td>
712 <td style=\"border-bottom: 1px #000000 solid;\">
713 <table cellspacing=0 cellpadding=0 width=100%><tr><td width=5></td><td class=\"text\">" .
714 xlt($myrow['message_status']) . "</td><td width=5></td></tr>
715 </table>
716 </td>
717 </tr>";
719 // Display the Messages table footer.
721 echo " </table>
722 </form>
723 <div class='row oe-margin-t-10'>
725 <div class=\"col-xs-12 col-md-12 col-lg-12\"><a href=\"messages.php?showall=" . attr($showall) . "&sortby=" . attr($sortby) . "&sortorder=" . attr($sortorder) . "&begin=" . attr($begin) . "&task=addnew&$activity_string_html\" class=\"btn btn-default btn-add\" onclick=\"top.restoreSession()\">" .
726 xlt('Add New') . "</a> &nbsp; <a href=\"javascript:confirmDeleteSelected()\" class=\"btn btn-default btn-delete\" onclick=\"top.restoreSession()\">" .
727 xlt('Delete') . "</a>
728 <div class=\"text-right\">$prevlink &nbsp; $end " .xlt('of') . " $total &nbsp; $nextlink</div>
729 </div>
730 </div>
731 </td>
732 </tr>
733 </table>
734 <br>";
737 <script language="javascript">
738 // This is to confirm delete action.
739 function confirmDeleteSelected() {
740 var int_checked = 0;
741 var elem = document.forms.namedItem("MessageList").getElementsByTagName("input");
743 for (i=0; i < elem.length; i++){
744 if(elem[i].checked == true){
745 int_checked = ++int_checked;
748 if (int_checked > 0){
749 if (confirm("<?php echo xls('Do you really want to delete the selection?'); ?>")) {
750 document.MessageList.submit();
752 } else {
753 alert("<?php echo xls('Please select message(s) to delete'); ?>");
758 // This is to allow selection of all items in Messages table for deletion.
759 function selectAll() {
760 if (document.getElementById("checkAll").checked === true) {
761 document.getElementById("checkAll").checked = true;<?php
762 for ($i = 1; $i <= $count; $i++) {
763 echo "document.getElementById(\"check$i\").checked=true; document.getElementById(\"row$i\").style.background='#E7E7E7'; ";
764 } ?>
765 } else {
766 document.getElementById("checkAll").checked = false;<?php
767 for ($i = 1; $i <= $count; $i++) {
768 echo "document.getElementById(\"check$i\").checked=false; document.getElementById(\"row$i\").style.background='#F7F7F7'; ";
769 } ?>
773 // The two functions below are for managing row styles in Messages table.
774 function selectRow(row) {
775 document.getElementById(row).style.background = "#E7E7E7";
778 function deselectRow(row) {
779 document.getElementById(row).style.background = "#F7F7F7";
781 </script>
782 <?php
785 </div>
786 </fieldset>
787 </div><!--end of messages div-->
788 <div class="row oe-display" id="reminders-div">
789 <fieldset>
790 <div class="col-sm-12 col-md-12 col-lg-12">
791 <div class="oe-margin-b-10">
792 <span class="title"><?php echo xlt('Reminders'); ?></span>
793 </div>
794 <?php
795 // TajEmo Work by CB 2012/01/11 02:51:25 PM adding dated reminders
796 // I am asuming that at this point security checks have been performed
797 //require_once '../dated_reminders/dated_reminders.php';
798 require_once '../dated_reminders/dated_reminders.php';
800 </div>
801 </fieldset>
802 </div><!--end of reminders div-->
803 <div class="row oe-display" id="recalls-div">
804 <fieldset>
805 <?php if ($GLOBALS['disable_rcb'] != '1') { ?>
806 <div class="col-sm-6 col-md-6 col-lg-6">
807 <div class="dr_container">
808 <span class="title"><?php echo xlt('Recalls'); ?></span>
809 <br/><br/>
810 <a class="btn btn-default btn-add"
811 onclick="goReminderRecall('addRecall');"><span><?php echo xlt('New Recall'); ?></span></a>
812 &nbsp;
813 <a class="btn btn-default btn-transmit"
814 onclick="goReminderRecall('Recalls');"><span><?php echo xlt('Recall Board'); ?></span></a>
815 &nbsp;
816 </div>
817 </div>
818 <?php } ?>
819 </fieldset>
820 </div><!--end of recalls div-->
821 <div class="row oe-display" id="sms-div">
822 <fieldset>
823 <?php if ($logged_in) { ?>
824 <div class="col-sm-4 col-md-4 col-lg-4">
825 <span class="title"><?php echo xlt('SMS Zone'); ?></span>
826 <br/><br/>
827 <form id="smsForm" class="input-group">
828 <input id="SMS_patient" type="text" style="margin:0;max-width:100%;" class="form-control"
829 placeholder="<?php echo xla("Patient Name"); ?>" />
830 <span class="input-group-addon" onclick="SMS_direct();"><i
831 class="glyphicon glyphicon-phone"></i></span>
832 <input type="hidden" id="sms_pid">
833 <input type="hidden" id="sms_mobile" value="">
834 <input type="hidden" id="sms_allow" value="">
835 </form>
836 </div>
837 <?php } ?>
838 </fieldset>
839 </div><!--end of sms div-->
840 </div><!--end of container div-->
841 <br>
842 <?php
843 //home of the help modal ;)
844 //$GLOBALS['enable_help'] = 0; // Please comment out line if you want help modal to function on this page
845 if ($GLOBALS['enable_help'] == 1) {
846 echo "<script>var helpFile = 'message_center_help.php'</script>";
847 //help_modal.php lives in interface, set path accordingly
848 require "../../help_modal.php";
851 <script language="javascript">
853 var collectvalidation = <?php echo($collectthis); ?>;
855 $(document).ready(function(){
856 $("#reminders-div").hide();
857 $("#recalls-div").hide();
858 $("#sms-div").hide();
859 $("#messages-li").click(function(){
860 $("#messages-div").show(250);
861 $("#reminders-div").hide(250);
862 $("#recalls-div").hide(250);
863 $("#sms-div").hide(250);
864 $("#li-mess").addClass("active");
865 $("#li-remi").removeClass("active");
866 $("#li-reca").removeClass("active");
867 $("#li-sms").removeClass("active");
870 $("#reminders-li").click(function(){
871 $("#messages-div").hide(250);
872 $("#reminders-div").show(250);
873 $("#recalls-div").hide(250);
874 $("#sms-div").hide(250);
875 $("#li-remi").addClass("active");
876 $("#li-mess").removeClass("active");
877 $("#li-reca").removeClass("active");
878 $("#li-sms").removeClass("active");
880 $("#recalls-li").click(function(){
881 $("#messages-div").hide(250);
882 $("#reminders-div").hide(250);
883 $("#recalls-div").show(250);
884 $("#sms-div").hide(250);
885 $("#li-remi").removeClass("active");
886 $("#li-mess").removeClass("active");
887 $("#li-reca").addClass("active");
888 $("#li-sms").removeClass("active");
890 $("#sms-li").click(function(){
891 $("#messages-div").hide(250);
892 $("#reminders-div").hide(250);
893 $("#recalls-div").hide(250);
894 $("#sms-div").show(250);
895 $("#li-remi").removeClass("active");
896 $("#li-mess").removeClass("active");
897 $("#li-reca").removeClass("active");
898 $("#li-sms").addClass("active");
901 $('.datetimepicker').datetimepicker({
902 <?php $datetimepicker_timepicker = true; ?>
903 <?php $datetimepicker_showseconds = false; ?>
904 <?php $datetimepicker_formatInput = true; ?>
905 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
906 ,minDate : 0 //only future
910 $(document).ready(function(){
911 $( "ul.navbar-nav" ).children().click(function(){
912 $(".collapse").collapse('hide');
915 $(document).ready(function(){
916 //for jquery tooltip to function if jquery 1.12.1.js is called via jquery-ui in the Header::setupHeader
917 // the relevant css file needs to be called i.e. jquery-ui-darkness
918 $('#see-all-tooltip').attr( "title", "<?php echo xla('Click to show messages for all users'); ?>" );
919 $('#see-all-tooltip').tooltip();
920 $('#just-mine-tooltip').attr( "title", "<?php echo xla('Click to show messages for only the current user'); ?>" );
921 $('#just-mine-tooltip').tooltip();
922 });
923 $(function () {
924 var f = $("#smsForm");
925 $("#SMS_patient").autocomplete({
926 source: "save.php?go=sms_search",
927 minLength: 2,
928 select: function (event, ui) {
929 event.preventDefault();
930 $("#SMS_patient").val(ui.item.label + ' ' + ui.item.mobile);
931 $("#sms_pid").val(ui.item.pid);
932 $("#sms_mobile").val(ui.item.mobile);
933 $("#sms_allow").val(ui.item.allow);
937 jQuery.ui.autocomplete.prototype._resizeMenu = function () {
938 var ul = this.menu.element;
939 ul.outerWidth(this.element.outerWidth());
941 $(document).ready(function () {
942 $("#newnote").click(function (event) {
943 NewNote(event);
945 $("#printnote").click(function () {
946 PrintNote();
948 var obj = $("#form_message_status");
949 obj.onchange = function () {
950 SaveNote();
952 $("#cancel").click(function () {
953 CancelNote();
955 $("#note").focus();
957 //clear button in messages
958 $("#clear_user").click(function(){
959 $("#assigned_to_text").val("<?php echo xls('Select Users From The Dropdown List'); ?>");
960 $("#assigned_to").val("");
961 $("#users").val("--");
964 //clear inputs of patients
965 $("#clear_patients").click(function(){
966 $("#reply_to").val("");
967 $("#form_patient").val("");
971 var NewNote = function (event) {
972 top.restoreSession();
973 if(document.getElementById("form_message_status").value !== 'Done'){
974 collectvalidation.assigned_to = {
975 presence: {message: "<?php echo xls('Recipient required unless status is Done'); ?>"}
978 else{
979 delete collectvalidation.assigned_to;
982 $('#newnote').attr('disabled', true);
984 var submit = submitme(1, event, 'new_note', collectvalidation);
985 if(!submit){
986 $('#newnote').attr('disabled', false);
988 else {
989 $("#new_note").submit();
992 var PrintNote = function () {
993 top.restoreSession();
994 window.open('../../patient_file/summary/pnotes_print.php?noteid=<?php echo htmlspecialchars($noteid, ENT_QUOTES); ?>', '_blank', 'resizable=1,scrollbars=1,width=600,height=500');
997 var SaveNote = function () {
998 <?php if ($noteid) { ?>
999 top.restoreSession();
1000 $("#task").val("save");
1001 $("#new_note").submit();
1002 <?php } ?>
1005 var CancelNote = function () {
1006 top.restoreSession();
1007 $("#task").val("");
1008 $("#new_note").submit();
1011 function gotoReport(doc_id, pname, pid, pubpid, str_dob) {
1012 EncounterDateArray = [];
1013 CalendarCategoryArray = [];
1014 EncounterIdArray = [];
1015 Count = 0;
1016 <?php
1017 if (isset($enc_list) && sqlNumRows($enc_list) > 0) {
1018 while ($row = sqlFetchArray($enc_list)) {
1020 EncounterIdArray[Count] = '<?php echo attr($row['encounter']); ?>';
1021 EncounterDateArray[Count] = '<?php echo attr(oeFormatShortDate(date("Y-m-d", strtotime($row['date'])))); ?>';
1022 CalendarCategoryArray[Count] = '<?php echo attr(xl_appt_category($row['pc_catname'])); ?>';
1023 Count++;
1024 <?php
1028 top.restoreSession();
1029 $.ajax({
1030 type: 'get',
1031 url: '<?php echo $GLOBALS['webroot'] . "/library/ajax/set_pt.php";?>',
1032 data: {set_pid: pid},
1033 async: false
1035 parent.left_nav.setPatient(pname, pid, pubpid, '', str_dob);
1036 parent.left_nav.setPatientEncounter(EncounterIdArray, EncounterDateArray, CalendarCategoryArray);
1037 <?php if ($GLOBALS['new_tabs_layout']) { ?>
1038 var docurl = '../controller.php?document&view' + "&patient_id=" + pid + "&document_id=" + doc_id + "&";
1039 var paturl = 'patient_file/summary/demographics.php?pid=' + pid;
1040 parent.left_nav.loadFrame('dem1', 'pat', paturl);
1041 parent.left_nav.loadFrame('doc0', 'enc', docurl);
1042 top.activateTabByName('enc', true);
1043 <?php } else { ?>
1044 var docurl = '<?php echo $GLOBALS['webroot'] . "/controller.php?document&view"; ?>' + "&patient_id=" + pid + "&document_id=" + doc_id + "&";
1045 var paturl = '<?php echo $GLOBALS['webroot'] . "/interface/patient_file/summary/demographics.php?pid="; ?>' + pid;
1046 var othername = (window.name === 'RTop') ? 'RBot' : 'RTop';
1047 parent.frames[othername].location.href = paturl;
1048 location.href = docurl;
1049 <?php } ?>
1052 // This is for callback by the find-patient popup.
1053 function setpatient(pid, lname, fname, dob) {
1054 var f = document.getElementById('new_note');
1055 f.form_patient.value += lname + ', ' + fname + '; ';
1056 f.reply_to.value += pid + ';';
1057 <?php if ($noteid) { ?>
1058 //used when direct messaging service inserts a pnote with indeterminate patient
1059 //to allow the user to assign the message to a patient.
1060 top.restoreSession();
1061 $("#task").val("savePatient");
1062 $("#new_note").submit();
1063 <?php } ?>
1066 // This is for callback by the multi_patients_finder popup.
1067 function setMultiPatients(patientsList) {
1068 var f = document.getElementById('new_note');
1069 f.form_patient.value='';
1070 f.reply_to.value='';
1071 $.each(patientsList, function (key, patient) {
1072 f.form_patient.value += patient.lname + ', ' + patient.fname + '; ';
1073 f.reply_to.value += patient.pid + ';';
1076 <?php if ($noteid) { ?>
1077 //used when direct messaging service inserts a pnote with indeterminate patient
1078 //to allow the user to assign the message to a patient.
1079 top.restoreSession();
1080 $("#task").val("savePatient");
1081 $("#new_note").submit();
1082 <?php } ?>
1085 // This invokes the find-patient popup.
1086 function sel_patient() {
1087 dlgopen('../../main/calendar/find_patient_popup.php', '_blank', 625, 400);
1090 function multi_sel_patient() {
1091 $('#reply_to').trigger('click');
1092 var url = '../../main/finder/multi_patients_finder.php'
1093 // for edit selected list
1094 if($('#reply_to').val() !== ''){
1095 url = url+'?patients='+$('#reply_to').val();
1097 dlgopen(url, '_blank', 625, 400);
1100 function addtolist(sel) {
1101 $('#assigned_to').trigger("click");
1102 var itemtext = document.getElementById('assigned_to_text');
1103 var item = document.getElementById('assigned_to');
1104 if (sel.value !== '--') {
1105 if (item.value) {
1106 if (item.value.indexOf(sel.value) === -1) {
1107 itemtext.value = itemtext.value + ' ; ' + sel.options[sel.selectedIndex].text;
1108 item.value = item.value + ';' + sel.value;
1110 } else {
1111 itemtext.value = sel.options[sel.selectedIndex].text;
1112 item.value = sel.value;
1117 function SMS_direct() {
1118 var pid = $("#sms_pid").val();
1119 var m = $("#sms_mobile").val();
1120 var allow = $("#sms_allow").val();
1121 if ((pid === '') || (m === '')) {
1122 alert('MedEx needs a valid mobile number to send SMS messages...');
1123 } else if (allow === 'NO') {
1124 alert('This patient does not allow SMS messaging!');
1125 } else {
1126 top.restoreSession();
1127 window.open('messages.php?nomenu=1&go=SMS_bot&pid=' + pid + '&m=' + m, 'SMS_bot', 'width=370,height=600,resizable=0');
1130 </script>
1131 <?php
1134 </body>
1135 </html>