Usability Improvements (#2807)
[openemr.git] / interface / patient_file / summary / pnotes_full.php
blob761d75b96a60567770286e24bdb45b98bd730f70
1 <?php
2 /**
3 * Display, enter, modify and manage patient notes.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Brady Miller <brady.g.miller@gmail.com>
8 * @copyright Copyright (c) 2018-2020 Brady Miller <brady.g.miller@gmail.com>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 require_once('../../globals.php');
14 require_once($GLOBALS['srcdir'].'/pnotes.inc');
15 require_once($GLOBALS['srcdir'].'/patient.inc');
16 require_once($GLOBALS['srcdir'].'/acl.inc');
17 require_once($GLOBALS['srcdir'].'/options.inc.php');
18 require_once($GLOBALS['srcdir'].'/gprelations.inc.php');
20 use OpenEMR\Common\Csrf\CsrfUtils;
21 use OpenEMR\Common\Logging\EventAuditLogger;
22 use OpenEMR\Core\Header;
23 use OpenEMR\Services\UserService;
25 if ($_GET['set_pid']) {
26 require_once($GLOBALS['srcdir'].'/pid.inc');
27 setpid($_GET['set_pid']);
30 // form parameter docid can be passed to restrict the display to a document.
31 $docid = empty($_REQUEST['docid']) ? 0 : 0 + $_REQUEST['docid'];
33 // form parameter orderid can be passed to restrict the display to a procedure order.
34 $orderid = empty($_REQUEST['orderid']) ? 0 : intval($_REQUEST['orderid']);
36 $patient_id = $pid;
38 $userService = new UserService();
40 if ($docid) {
41 $row = sqlQuery("SELECT foreign_id FROM documents WHERE id = ?", array($docid));
42 $patient_id = intval($row['foreign_id']);
43 } else if ($orderid) {
44 $row = sqlQuery("SELECT patient_id FROM procedure_order WHERE procedure_order_id = ?", array($orderid));
45 $patient_id = intval($row['patient_id']);
48 // Check authorization.
49 if (!acl_check('patients', 'notes', '', array('write','addonly'))) {
50 die(xlt('Not authorized'));
53 $tmp = getPatientData($patient_id, "squad");
54 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad'])) {
55 die(xlt('Not authorized for this squad.'));
58 //the number of records to display per screen
59 $N = 15;
60 $M = 15;
62 $mode = $_REQUEST['mode'];
63 $offset = $_REQUEST['offset'];
64 $offset_sent = $_REQUEST['offset_sent'];
65 $form_active = $_REQUEST['form_active'];
66 $form_inactive = $_REQUEST['form_inactive'];
67 $noteid = $_REQUEST['noteid'];
68 $form_doc_only = isset($_POST['mode']) ? (empty($_POST['form_doc_only']) ? 0 : 1) : 1;
69 if ($_REQUEST['s'] == '1') {
70 $inbox = "";
71 $outbox = "current";
72 $inbox_style = "style='display:none;border:5px solid var(--white);'";
73 $outbox_style = "style='border:5px solid var(--white);'";
74 } else {
75 $inbox = "current";
76 $outbox = "";
77 $inbox_style = "style='border:5px solid var(--white);'";
78 $outbox_style = "style='display:none;border:5px solid var(--white);'";
81 if (!isset($offset)) {
82 $offset = 0;
85 if (!isset($offset_sent)) {
86 $offset_sent = 0;
89 // Collect active variable and applicable html code for links
90 if ($form_active) {
91 $active = '1';
92 $activity_string_html = 'form_active=1';
93 } else if ($form_inactive) {
94 $active = '0';
95 $activity_string_html = 'form_inactive=1';
96 } else {
97 $active = 'all';
98 $activity_string_html = '';
99 $form_active = $form_inactive = '0';
102 // this code handles changing the state of activity tags when the user updates
103 // them through the interface
104 if (isset($mode)) {
105 if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) {
106 CsrfUtils::csrfNotVerified();
109 if ($mode == "update") {
110 foreach ($_POST as $var => $val) {
111 if (strncmp($var, 'act', 3) == 0) {
112 $id = str_replace("act", "", $var);
113 if ($_POST["chk$id"]) {
114 reappearPnote($id);
115 } else {
116 disappearPnote($id);
119 if ($docid) {
120 setGpRelation(1, $docid, 6, $id, !empty($_POST["lnk$id"]));
123 if ($orderid) {
124 setGpRelation(2, $orderid, 6, $id, !empty($_POST["lnk$id"]));
128 } elseif ($mode == "new") {
129 $note = $_POST['note'];
130 if ($noteid) {
131 updatePnote($noteid, $note, $_POST['form_note_type'], $_POST['assigned_to'], '', !empty($_POST['form_datetime']) ? DateTimeToYYYYMMDDHHMMSS($_POST['form_datetime']) : '');
132 } else {
133 $noteid = addPnote(
134 $patient_id,
135 $note,
136 $userauthorized,
137 '1',
138 $_POST['form_note_type'],
139 $_POST['assigned_to'],
140 !empty($_POST['form_datetime']) ? DateTimeToYYYYMMDDHHMMSS($_POST['form_datetime']) : ''
144 if ($docid) {
145 setGpRelation(1, $docid, 6, $noteid);
148 if ($orderid) {
149 setGpRelation(2, $orderid, 6, $noteid);
152 $noteid = '';
153 } elseif ($mode == "delete") {
154 if ($noteid) {
155 deletePnote($noteid);
156 EventAuditLogger::instance()->newEvent("delete", $_SESSION['authUser'], $_SESSION['authProvider'], 1, "pnotes: id ".$noteid);
159 $noteid = '';
161 if ($mode != "delete" && $mode != "update") {
162 exit(); // add exit for ajax save from pnotes_full_add.php sjp 12/20/2017
166 $title = '';
167 $assigned_to = $_SESSION['authUser'];
168 if ($noteid) {
169 $prow = getPnoteById($noteid, 'title,assigned_to,body');
170 $title = $prow['title'];
171 $assigned_to = $prow['assigned_to'];
174 // Get the users list. The "Inactive" test is a kludge, we should create
175 // a separate column for this.
176 $ures = sqlStatement("SELECT username, fname, lname FROM users " .
177 "WHERE username != '' AND active = 1 AND " .
178 "( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
179 "ORDER BY lname, fname");
181 $pres = getPatientData($patient_id, "lname, fname");
182 $patientname = $pres['lname'] . ", " . $pres['fname'];
184 //retrieve all notes
185 $result = getPnotesByDate(
187 $active,
188 'id,date,body,user,activity,title,assigned_to,message_status,update_date,update_by',
189 $patient_id,
191 $offset,
193 $docid,
195 $orderid
197 $result_sent = getSentPnotesByDate(
199 $active,
200 'id,date,body,user,activity,title,assigned_to,message_status,update_date,update_by',
201 $patient_id,
203 $offset_sent,
205 $docid,
207 $orderid
210 <!DOCTYPE html>
211 <html>
212 <head>
214 <?php Header::setupHeader(['common', 'jquery-ui', 'opener']); ?>
216 <script type="text/javascript">
217 /// todo, move this to a common library
219 $(function(){
221 $("#dem_view").click( function() {
222 toggle( $(this), "#DEM" );
225 // load divs
226 $("#stats_div").load("stats.php",
228 csrf_token_form: <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>
231 $("#notes_div").load("pnotes_fragment.php",
233 csrf_token_form: <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>
237 tabbify();
239 $(".note_modal").on('click', function(e) {
240 e.preventDefault();
241 e.stopPropagation();
242 dlgopen('', '', 700, 400, '', '', {
243 buttons: [
244 {text: <?php echo xlj('Close'); ?>, close: true, style: 'default btn-sm'}
246 allowResize: true,
247 allowDrag: true,
248 dialogId: '',
249 type: 'iframe',
250 url: $(this).attr('href')
256 function show_div(name){
257 if(name == 'inbox'){
258 document.getElementById('inbox_div').style.display = '';
259 document.getElementById('outbox_div').style.display = 'none';
260 }else{
261 document.getElementById('inbox_div').style.display = 'none';
262 document.getElementById('outbox_div').style.display = '';
266 function refreshme() {
267 top.restoreSession();
268 document.location.reload();
271 function restoreSession() {
272 return opener.top.restoreSession();
274 </script>
275 </head>
276 <body class="body_top">
278 <div class="container-fluid" id="pnotes"> <!-- large outer DIV -->
280 <form border='0' method='post' name='new_note' id="new_note" action='pnotes_full.php?docid=<?php echo attr_url($docid); ?>&orderid=<?php echo attr_url($orderid); ?>&<?php echo $activity_string_html; ?>' onsubmit='return top.restoreSession()'>
281 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
283 <?php
284 $title_docname = "";
285 if ($docid) {
286 $title_docname .= " " . xl("linked to document") . " ";
287 $d = new Document($docid);
288 $title_docname .= $d->get_url_file();
291 if ($orderid) {
292 $title_docname .= " " . xl("linked to procedure order") . " $orderid";
295 $urlparms = "docid=" . attr_url($docid) . "&orderid=" . attr_url($orderid);
296 $title = text(getPatientName($patient_id));
298 <title><?php echo $title; ?></title>
299 <div class="row">
300 <div class="col-md-12">
301 <div class="page-header">
302 <h3><?php echo xlt('Patient Messages') . text($title_docname) . " " . xlt('for');
303 if (!$orderid) {
304 ?>&nbsp;
305 <span><a href="../summary/demographics.php"
306 onclick="return top.restoreSession()"><?php echo $title; ?></a></span>
307 <?php } else { ?>
308 <span><?php echo $title; ?></span><?php } ?>
309 </h3>
310 </div>
311 </div>
312 </div>
313 <div class="row oe-margin-b-10">
314 <div class="col-md-12">
315 <a href="pnotes_full_add.php?<?php echo $urlparms; ?>" class="btn btn-secondary note_modal" onclick='return top.restoreSession()'><span><?php echo xlt('Add'); ?></span></a>
316 <a href="#" class="change_activity btn btn-secondary" ><span><?php echo xlt('Update Active'); ?></span></a>
317 <a href="pnotes_full.php?<?php echo $urlparms; ?>&<?php echo $activity_string_html;?>" class="btn btn-secondary" id='Submit' onclick='return top.restoreSession()'><span><?php echo xlt('Refresh'); ?></span></a>
318 <?php if (!$orderid) { ?>
319 <a href="demographics.php" class="btn btn-secondary" onclick="top.restoreSession()"><span><?php echo xlt('Back to Patient'); ?></span></a>
320 <?php } ?>
321 </div>
323 </div>
324 <div class="row oe-margin-b-10">
325 <div class="col-md-12">
326 <?php
327 // Get the billing note if there is one.
328 $billing_note = "";
329 $colorbeg = "";
330 $colorend = "";
331 $resnote = getPatientData($patient_id, "billing_note");
332 if (!empty($resnote['billing_note'])) {
333 $billing_note = $resnote['billing_note'];
334 $colorbeg = "<span style='color:red'>";
335 $colorend = "</span>";
338 //Display what the patient owes
339 $balance = get_patient_balance($patient_id);
342 <?php if ($billing_note || $balance) { ?>
343 <div style='margin-top:3px'>
344 <table width='80%'>
345 <?php
346 if ($balance != "0") {
347 // $formatted = sprintf((xl('$').'%01.2f'), $balance);
348 $formatted = oeFormatMoney($balance);
349 echo " <tr class='text billing'>\n";
350 echo " <td>" . $colorbeg . xlt('Balance Due') .
351 $colorend . "&nbsp;" . $colorbeg . text($formatted) .
352 $colorend . "</td>\n";
353 echo " </tr>\n";
356 if ($billing_note) {
357 echo " <tr class='text billing'>\n";
358 echo " <td>" . $colorbeg . xlt('Billing Note') .
359 $colorend . "&nbsp;" . $colorbeg . text($billing_note) .
360 $colorend . "</td>\n";
361 echo " </tr>\n";
364 </table>
365 </div>
367 <?php } ?>
368 </div>
370 </div>
371 <div class="row">
372 <div class="col-md-12">
373 <?php if ($active == "all") { ?>
374 <span><?php echo xlt('Show All'); ?></span>
375 <?php } else { ?>
376 <a href="pnotes_full.php?<?php echo $urlparms; ?>" class="link btn btn-secondary" onclick="return top.restoreSession()"><span><?php echo xlt('Show All'); ?></span></a>
377 <?php } ?>
379 <?php if ($active == '1') { ?>
380 <span><?php echo xlt('Show Active'); ?></span>
381 <?php } else { ?>
382 <a href="pnotes_full.php?form_active=1&<?php echo $urlparms; ?>" class="link btn btn-secondary" onclick="return top.restoreSession()"><span><?php echo xlt('Show Active'); ?></span></a>
383 <?php } ?>
385 <?php if ($active == '0') { ?>
386 <span><?php echo xlt('Show Inactive'); ?></span>
387 <?php } else { ?>
388 <a href="pnotes_full.php?form_inactive=1&<?php echo $urlparms; ?>" class="link btn btn-secondary" onclick="return top.restoreSession()"><span><?php echo xlt('Show Inactive'); ?></span></a>
389 <?php } ?>
390 </div>
391 </div>
393 <input type='hidden' name='mode' id="mode" value="new">
394 <input type='hidden' name='offset' id="offset" value="<?php echo attr($offset); ?>">
395 <input type='hidden' name='offset_sent' id="offset_sent" value="<?php echo attr($offset_sent); ?>">
396 <input type='hidden' name='form_active' id="form_active" value="<?php echo attr($form_active); ?>">
397 <input type='hidden' name='form_inactive' id="form_inactive" value="<?php echo attr($form_inactive); ?>">
398 <input type='hidden' name='noteid' id="noteid" value="<?php echo attr($noteid); ?>">
399 <input type='hidden' name='form_doc_only' id="form_doc_only" value="<?php echo attr($form_doc_only); ?>">
400 </form>
402 <?php if ($GLOBALS['portal_offsite_enable']) { ?>
403 <ul class="tabNav">
404 <li class="<?php echo $inbox; ?>" ><a onclick="show_div('inbox')" href="#"><?php echo xlt('Inbox'); ?></a></li>
405 <li class="<?php echo $outbox; ?>" ><a onclick="show_div('outbox')" href="#"><?php echo xlt('Sent Items'); ?></a></li>
406 </ul>
407 <?php } ?>
408 <div class='tabContainer' >
409 <div id='inbox_div' <?php echo $inbox_style; ?> >
410 <form border='0' method='post' name='update_activity' id='update_activity'
411 action="pnotes_full.php?<?php echo $urlparms; ?>&<?php echo $activity_string_html;?>" onsubmit='return top.restoreSession()'>
412 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
413 <!-- start of previous notes DIV -->
414 <div class=pat_notes>
415 <input type='hidden' name='mode' value="update">
416 <input type='hidden' name='offset' id='offset' value="<?php echo attr($offset); ?>">
417 <input type='hidden' name='offset_sent' id='offset_sent' value="<?php echo attr($offset_sent); ?>">
418 <input type='hidden' name='noteid' id='noteid' value="0">
419 <table border='0' cellpadding="1" class="text">
420 <?php if ($result != "") : ?>
421 </table>
422 <?php endif; ?>
424 <table border='0' cellpadding="1" class="text" width = "100%">
425 <?php
426 // display all of the notes for the day, as well as others that are active
427 // from previous dates, up to a certain number, $N
429 if ($result != "") {
430 echo " <tr class=showborder_head align='left'>\n";
431 echo " <th style='width:130px;'>" . xlt('Actions') . "</th>\n";
432 echo " <th>" . xlt('Active{{Note}}') . "&nbsp;</th>\n";
433 echo " <th>" . (($docid || $orderid) ? xlt('Linked') : '') . "</th>\n";
434 echo " <th>" . xlt('Type') . "</th>\n";
435 echo " <th>" . xlt('Content') . "</th>\n";
436 echo " <th>" . xlt('Status') . "</th>\n";
437 echo " <th>" . xlt('Last update') . "</th>\n";
438 echo " <th>" . xlt('Update by') . "</th>\n";
439 echo " </tr>\n";
441 $result_count = 0;
442 foreach ($result as $iter) {
443 $result_count++;
444 $row_note_id = $iter['id'];
446 $linked = "";
447 if ($docid) {
448 if (isGpRelation(1, $docid, 6, $row_note_id)) {
449 $linked = "checked";
450 } else {
451 // Skip unlinked notes if that is requested.
452 if ($form_doc_only) {
453 continue;
456 } else if ($orderid) {
457 if (isGpRelation(2, $orderid, 6, $row_note_id)) {
458 $linked = "checked";
459 } else {
460 // Skip unlinked notes if that is requested.
461 if ($form_doc_only) {
462 continue;
467 $body = $iter['body'];
468 $body = preg_replace('/(\sto\s)-patient-(\))/', '${1}'.$patientname.'${2}', $body);
469 $body = preg_replace('/(\d{4}-\d{2}-\d{2} \d{2}:\d{2}\s\([^)(]+\s)(to)(\s[^)(]+\))/', '${1}' . xl('to{{Destination}}') . '${3}', $body);
470 if (preg_match('/^\d\d\d\d-\d\d-\d\d \d\d\:\d\d /', $body)) {
471 $body = nl2br(text(oeFormatPatientNote($body)));
472 } else {
473 $body = text(oeFormatSDFT(strtotime($iter['date'])).date(' H:i', strtotime($iter['date']))) .
474 ' (' . text($iter['user']) . ') ' . nl2br(text(oeFormatPatientNote($body)));
477 if (($iter["activity"]) && ($iter['message_status'] != "Done")) {
478 $checked = "checked";
479 } else {
480 $checked = "";
483 // highlight the row if it's been selected for updating
484 if ($_REQUEST['noteid'] == $row_note_id) {
485 echo " <tr height=20 class='noterow highlightcolor' id='" . attr($row_note_id) . "'>\n";
486 } else {
487 echo " <tr class='noterow' id='" . attr($row_note_id) . "'>\n";
491 echo " <td><a href='pnotes_full_add.php?$urlparms&trigger=edit&noteid=" . attr_url($row_note_id) .
492 "' class='css_button_small note_modal' onclick='return top.restoreSession()'><span>" . xlt('Edit') ."</span></a>\n";
494 // display, or not, a button to delete the note
495 // if the user is an admin or if they are the author of the note, they can delete it
496 if (($iter['user'] == $_SESSION['authUser']) || (acl_check('admin', 'super', '', 'write'))) {
497 echo " <a href='#' class='deletenote css_button_small' id='del" . attr($row_note_id) .
498 "' title='" . xla('Delete this note') . "' onclick='return top.restoreSession()'><span>" .
499 xlt('Delete') . "</span>\n";
502 echo " </td>\n";
505 echo " <td class='text bold'>\n";
506 echo " <input type='hidden' name='act" . attr($row_note_id) . "' value='1' />\n";
507 echo " <input type='checkbox' name='chk" . attr($row_note_id) . "' $checked />\n";
508 echo " </td>\n";
510 echo " <td class='text bold'>\n";
511 if ($docid || $orderid) {
512 echo " <input type='checkbox' name='lnk" . attr($row_note_id) . "' $linked />\n";
515 echo " </td>\n";
517 echo " <td class='bold notecell' id='" . attr($row_note_id) . "'>" .
518 "<a href='pnotes_full_add.php?$urlparms&trigger=edit&noteid=" . attr_url($row_note_id) . "' class='note_modal' onclick='return top.restoreSession()'>\n";
519 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
520 echo generate_display_field(array('data_type'=>'1','list_id'=>'note_type'), $iter['title']);
521 echo " </a></td>\n";
523 echo " <td class='notecell' id='" . attr($row_note_id) . "'>\n";
524 echo " $body";
525 echo " </td>\n";
526 echo " <td class='notecell' id='" . attr($row_note_id) . "'>\n";
527 echo getListItemTitle("message_status", $iter['message_status']);
528 echo " </td>\n";
529 echo " <td class='notecell'>";
530 echo text(oeFormatDateTime($iter['update_date']));
531 echo " </td>\n";
532 echo " <td class='notecell'>";
533 $updateBy = $userService->getUser($iter['update_by']);
534 echo !is_null($updateBy) ? text($updateBy->getFname()) . ' ' . text($updateBy->getLname()) : '';
535 echo " </td>\n";
536 echo " </tr>\n";
538 $notes_count++;
540 } else {
541 //no results
542 print "<tr><td colspan='3' class='text'>" . xlt('None{{Note}}') . ".</td></tr>\n";
547 </table>
548 </div>
549 </form>
551 <table width='400' border='0' cellpadding='0' cellspacing='0'>
552 <tr>
553 <td>
554 <?php
555 if ($offset > ($N-1)) {
556 $offsetN = $offset-$N;
557 echo " <a class='link' href='pnotes_full.php" .
558 "?$urlparms" .
559 "&form_active=" . attr_url($form_active) .
560 "&form_inactive=" . attr_url($form_inactive) .
561 "&form_doc_only=" . attr_url($form_doc_only) .
562 "&offset=" . attr_url($offsetN) . "&" . $activity_string_html . "' onclick='return top.restoreSession()'>[" .
563 xlt('Previous') . "]</a>\n";
566 </td>
567 <td align='right'>
568 <?php
569 if ($result_count == $N) {
570 $offsetN = $offset+$N;
571 echo " <a class='link' href='pnotes_full.php" .
572 "?$urlparms" .
573 "&form_active=" . attr_url($form_active) .
574 "&form_inactive=" . attr_url($form_inactive) .
575 "&form_doc_only=" . attr_url($form_doc_only) .
576 "&offset=" . attr_url($offsetN) . "&" . $activity_string_html . "' onclick='return top.restoreSession()'>[" .
577 xlt('Next') . "]</a>\n";
580 </td>
581 </tr>
582 </table>
584 </div>
585 <div id='outbox_div' <?php echo $outbox_style; ?> >
586 <table border='0' cellpadding="1" class="text">
587 <?php if ($result_sent != "") : ?>
588 <tr>
589 <td colspan='5' style="padding: 5px;" >
590 <a href="pnotes_full.php?<?php echo $urlparms; ?>&s=1&<?php echo $activity_string_html; ?>"
591 class="" id='Submit' onclick='return top.restoreSession()'><span><?php echo xlt('Refresh'); ?></span></a>
592 </td>
593 </tr></table>
594 <?php endif; ?>
596 <table border='0' cellpadding="1" class="text" width = "80%">
597 <?php
598 // display all of the notes for the day, as well as others that are active
599 // from previous dates, up to a certain number, $N
601 if ($result_sent != "") {
602 echo " <tr class=showborder_head align='left'>\n";
603 echo " <th style='width:100px';>&nbsp;</th>\n";
604 echo " <th>" . xlt('Active{{Note}}') . "&nbsp;</th>\n";
605 echo " <th>" . (($docid || $orderid) ? xlt('Linked') : '') . "</th>\n";
606 echo " <th>" . xlt('Type') . "</th>\n";
607 echo " <th>" . xlt('Content') . "</th>\n";
608 echo " </tr>\n";
610 $result_sent_count = 0;
611 foreach ($result_sent as $iter) {
612 $result_sent_count++;
613 $row_note_id = $iter['id'];
615 $linked = "";
616 if ($docid) {
617 if (isGpRelation(1, $docid, 6, $row_note_id)) {
618 $linked = "checked";
619 } else {
620 // Skip unlinked notes if that is requested.
621 if ($form_doc_only) {
622 continue;
625 } else if ($orderid) {
626 if (isGpRelation(2, $orderid, 6, $row_note_id)) {
627 $linked = "checked";
628 } else {
629 // Skip unlinked notes if that is requested.
630 if ($form_doc_only) {
631 continue;
636 $body = $iter['body'];
637 if (preg_match('/^\d\d\d\d-\d\d-\d\d \d\d\:\d\d /', $body)) {
638 $body = nl2br(text(oeFormatPatientNote($body)));
639 } else {
640 $body = text(oeFormatSDFT(strtotime($iter['date'])).date(' H:i', strtotime($iter['date']))) .
641 ' (' . text($iter['user']) . ') ' . nl2br(text(oeFormatPatientNote($body)));
644 $body = preg_replace('/(:\d{2}\s\()' . $patient_id . '(\sto\s)/', '${1}' . $patientname . '${2}', $body);
645 if (($iter["activity"]) && ($iter['message_status'] != "Done")) {
646 $checked = "checked";
647 } else {
648 $checked = "";
651 // highlight the row if it's been selected for updating
652 if ($_REQUEST['noteid'] == $row_note_id) {
653 echo " <tr height=20 class='noterow highlightcolor' id='" . attr($row_note_id) . "'>\n";
654 } else {
655 echo " <tr class='noterow' id='" . attr($row_note_id) . "'>\n";
658 echo " <td><a href='pnotes_full_add.php?$urlparms&trigger=edit&noteid=" . attr_url($row_note_id) .
659 "' class='css_button_small note_modal' onclick='return top.restoreSession()'><span>" . xlt('Edit') . "</span></a>\n";
661 // display, or not, a button to delete the note
662 // if the user is an admin or if they are the author of the note, they can delete it
663 if (($iter['user'] == $_SESSION['authUser']) || (acl_check('admin', 'super', '', 'write'))) {
664 echo " <a href='#' class='deletenote css_button_small' id='del" . attr($row_note_id) .
665 "' title='" . xla('Delete this note') . "' onclick='return restoreSession()'><span>" .
666 xlt('Delete') . "</span>\n";
669 echo " </td>\n";
672 echo " <td class='text bold'>\n";
673 echo " <input type='hidden' name='act" . attr($row_note_id) . "' value='1' />\n";
674 echo " <input type='checkbox' name='chk" . attr($row_note_id) . "' $checked />\n";
675 echo " </td>\n";
677 echo " <td class='text bold'>\n";
678 if ($docid || $orderid) {
679 echo " <input type='checkbox' name='lnk" . attr($row_note_id) . "' $linked />\n";
682 echo " </td>\n";
684 echo " <td class='bold notecell' id='" . attr($row_note_id) . "'>" .
685 "<a href='pnotes_full_add.php?$urlparms&trigger=edit&noteid=" . attr_url($row_note_id) . "' class='note_modal' onclick='return top.restoreSession()'>\n";
686 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
687 echo generate_display_field(array('data_type'=>'1','list_id'=>'note_type'), $iter['title']);
688 echo " </a></td>\n";
690 echo " <td class='notecell' id='" . attr($row_note_id) . "'>\n";
691 echo " $body";
692 echo " </td>\n";
693 echo " </tr>\n";
695 $notes_sent_count++;
697 } else {
698 //no results
699 print "<tr><td colspan='3' class='text'>" . xlt('None{{Result}}') . ".</td></tr>\n";
704 </table>
706 <table width='400' border='0' cellpadding='0' cellspacing='0'>
707 <tr>
708 <td>
709 <?php
710 if ($offset_sent > ($M-1)) {
711 $offsetSentM = $offset_sent-$M;
712 echo " <a class='link' href='pnotes_full.php" .
713 "?$urlparms" .
714 "&s=1" .
715 "&form_active=" . attr_url($form_active) .
716 "&form_inactive=" . attr_url($form_inactive) .
717 "&form_doc_only=" . attr_url($form_doc_only) .
718 "&offset_sent=" . attr_url($offsetSentM) . "&" . $activity_string_html . "' onclick='return top.restoreSession()'>[" .
719 xlt('Previous') . "]</a>\n";
722 </td>
723 <td align='right'>
724 <?php
725 if ($result_sent_count == $M) {
726 $offsetSentM = $offset_sent+$M;
727 echo " <a class='link' href='pnotes_full.php" .
728 "?$urlparms" .
729 "&s=1" .
730 "&form_active=" . attr_url($form_active) .
731 "&form_inactive=" . attr_url($form_inactive) .
732 "&form_doc_only=" . attr_url($form_doc_only) .
733 "&offset_sent=" . attr_url($offsetSentM) . "&" . $activity_string_html . "' onclick='return top.restoreSession()'>[" .
734 xlt('Next') . "]</a>\n";
737 </td>
738 </tr>
739 </table>
741 </div>
742 </div>
743 <script language='JavaScript'>
745 <?php
746 if ($_GET['set_pid']) {
747 $ndata = getPatientData($patient_id, "fname, lname, pubpid");
749 parent.left_nav.setPatient(<?php echo js_escape($ndata['fname']." ".$ndata['lname']) . "," .
750 js_escape($patient_id) . "," . js_escape($ndata['pubpid']) . ",window.name"; ?>);
751 <?php
754 // If this note references a new patient document, pop up a display
755 // of that document.
757 if ($noteid /* && $title == 'New Document' */) {
758 $prow = getPnoteById($noteid, 'body');
759 if (preg_match('/New scanned document (\d+): [^\n]+\/([^\n]+)/', $prow['body'], $matches)) {
760 $docid = $matches[1];
761 $docname = $matches[2];
763 window.open('../../../controller.php?document&retrieve&patient_id=<?php echo attr_url($patient_id); ?>&document_id=<?php echo attr_url($docid); ?>&<?php echo attr_url($docname);?>&as_file=true',
764 '_blank', 'resizable=1,scrollbars=1,width=600,height=500');
765 <?php
770 </script>
772 </div> <!-- end outer 'pnotes' -->
774 </body>
776 <script language="javascript">
778 // jQuery stuff to make the page a little easier to use
780 $(function(){
781 $("#appendnote").click(function() { AppendNote(); });
782 $("#newnote").click(function() { NewNote(); });
783 $("#printnote").click(function() { PrintNote(); });
785 $(".change_activity").click(function() { top.restoreSession(); $("#update_activity").submit(); });
787 $(".deletenote").click(function() { DeleteNote(this); });
789 $(".noterow").mouseover(function() { $(this).toggleClass("highlight"); });
790 $(".noterow").mouseout(function() { $(this).toggleClass("highlight"); });
792 $("#note").focus();
794 var NewNote = function () {
795 top.restoreSession();
796 $("#noteid").val('');
797 $("#new_note").submit();
800 var AppendNote = function () {
801 top.restoreSession();
802 $("#new_note").submit();
805 var PrintNote = function () {
806 top.restoreSession();
807 window.open('pnotes_print.php?noteid=<?php echo attr_url($noteid); ?>', '_blank', 'resizable=1,scrollbars=1,width=600,height=500');
810 var DeleteNote = function(note) {
811 if (confirm(<?php echo xlj('Are you sure you want to delete this note?'); ?> + '\n ' + <?php echo xlj('This action CANNOT be undone.'); ?>)) {
812 top.restoreSession();
813 // strip the 'del' part of the object's ID
814 $("#noteid").val(note.id.replace(/del/, ""));
815 $("#mode").val("delete");
816 $("#new_note").submit();
822 </script>
824 </html>