fix: ccda zip import and php warnings and deprecations (#7416)
[openemr.git] / interface / patient_file / summary / pnotes_full.php
blob3a56ec2fb1e1b8ddf0562a4ce4edd6b83622b3a9
1 <?php
3 /**
4 * Display, enter, modify and manage patient notes.
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2018-2020 Brady Miller <brady.g.miller@gmail.com>
10 * @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.php');
15 require_once($GLOBALS['srcdir'] . '/patient.inc.php');
16 require_once($GLOBALS['srcdir'] . '/options.inc.php');
17 require_once($GLOBALS['srcdir'] . '/gprelations.inc.php');
19 use OpenEMR\Common\Acl\AclMain;
20 use OpenEMR\Common\Csrf\CsrfUtils;
21 use OpenEMR\Common\Logging\EventAuditLogger;
22 use OpenEMR\Core\Header;
23 use OpenEMR\Services\UserService;
25 if (!empty($_GET['set_pid'])) {
26 require_once($GLOBALS['srcdir'] . '/pid.inc.php');
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 } elseif ($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 (!AclMain::aclCheckCore('patients', 'notes', '', array('write','addonly'))) {
50 die(xlt('Not authorized'));
53 $tmp = getPatientData($patient_id, "squad");
54 if ($tmp['squad'] && ! AclMain::aclCheckCore('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'] ?? null;
63 $offset = $_REQUEST['offset'] ?? null;
64 $offset_sent = $_REQUEST['offset_sent'] ?? null;
65 $form_active = $_REQUEST['form_active'] ?? null;
66 $form_inactive = $_REQUEST['form_inactive'] ?? null;
67 $noteid = $_REQUEST['noteid'] ?? null;
68 $form_doc_only = isset($_POST['mode']) ? (empty($_POST['form_doc_only']) ? 0 : 1) : 1;
69 if (!empty($_REQUEST['s']) && ($_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 } elseif ($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', 'opener']); ?>
216 <script>
217 /// todo, move this to a common library
219 $(function () {
221 $("#dem_view").click( function() {
222 toggle( $(this), "#DEM" );
225 // load divs
227 // I can't find a reason to load this!
228 /*$("#stats_div").load("stats.php",
230 csrf_token_form: <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>
232 );*/
234 $("#notes_div").load("pnotes_fragment.php",
236 csrf_token_form: <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>
240 tabbify();
242 $(".note_modal").on('click', function(e) {
243 e.preventDefault();
244 e.stopPropagation();
245 dlgopen('', '', 700, 400, '', '', {
246 buttons: [
247 {text: <?php echo xlj('Close'); ?>, close: true, style: 'default btn-sm'}
249 allowResize: true,
250 allowDrag: true,
251 dialogId: '',
252 type: 'iframe',
253 url: $(this).attr('href')
259 function show_div(name){
260 if(name == 'inbox'){
261 document.getElementById('inbox_div').style.display = '';
262 document.getElementById('outbox_div').style.display = 'none';
263 }else{
264 document.getElementById('inbox_div').style.display = 'none';
265 document.getElementById('outbox_div').style.display = '';
269 function refreshme() {
270 top.restoreSession();
271 document.location.reload();
274 function restoreSession() {
275 return opener.top.restoreSession();
277 </script>
278 </head>
279 <body>
281 <div class="container mt-3" id="pnotes"> <!-- large outer DIV -->
283 <form 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()'>
284 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
286 <?php
287 $title_docname = "";
288 if ($docid) {
289 $title_docname .= " " . xl("linked to document") . " ";
290 $d = new Document($docid);
291 $title_docname .= $d->get_url_file();
294 if ($orderid) {
295 $title_docname .= " " . xl("linked to procedure order") . " $orderid";
298 $urlparms = "docid=" . attr_url($docid) . "&orderid=" . attr_url($orderid);
299 $title = text(getPatientName($patient_id));
301 <title><?php echo $title; ?></title>
302 <div class="row">
303 <div class="col-12">
304 <h3><?php echo xlt('Patient Messages') . text($title_docname) . " " . xlt('for');
305 if (!$orderid) {
306 ?><span>
307 <a href="../summary/demographics.php" onclick="return top.restoreSession()"><?php echo $title; ?></a>
308 </span>
309 <?php } else { ?>
310 <span><?php echo $title; ?></span><?php } ?>
311 </h3>
312 </div>
313 <div class="row oe-margin-b-10">
314 <div class="col-12">
315 <div class="btn-group">
316 <a href="pnotes_full_add.php?<?php echo $urlparms; ?>" class="btn btn-primary btn-add note_modal" onclick='return top.restoreSession()'><?php echo xlt('Add'); ?></a>
317 <?php if (!$orderid) { ?>
318 <a href="demographics.php" class="btn btn-secondary btn-back" onclick="top.restoreSession()"><?php echo xlt('Back to Patient'); ?></a>
319 <?php } ?>
320 <a href="pnotes_full.php?<?php echo $urlparms; ?>&<?php echo $activity_string_html;?>" class="btn btn-secondary btn-update" id='Submit' onclick='return top.restoreSession()'><?php echo xlt('Refresh'); ?></a>
321 <a href="#" class="change_activity btn btn-secondary btn"><?php echo xlt('Update Active'); ?></a>
322 </div>
323 </div>
325 </div>
326 <div class="row oe-margin-b-10">
327 <div class="col-12">
328 <?php
329 // Get the billing note if there is one.
330 $billing_note = "";
331 $colorbeg = "";
332 $colorend = "";
333 $resnote = getPatientData($patient_id, "billing_note");
334 if (!empty($resnote['billing_note'])) {
335 $billing_note = $resnote['billing_note'];
336 $colorbeg = "<span class='text-danger'>";
337 $colorend = "</span>";
340 //Display what the patient owes
341 $balance = get_patient_balance($patient_id);
344 <?php if ($billing_note || $balance) { ?>
345 <div class="table-responsive mt-1">
346 <table class="table">
347 <?php
348 if ($balance != "0") {
349 // $formatted = sprintf((xl('$').'%01.2f'), $balance);
350 $formatted = oeFormatMoney($balance);
351 echo " <tr class='text billing'>\n";
352 echo " <td>" . $colorbeg . xlt('Balance Due') .
353 $colorend . "&nbsp;" . $colorbeg . text($formatted) .
354 $colorend . "</td>\n";
355 echo " </tr>\n";
358 if ($billing_note) {
359 echo " <tr class='text billing'>\n";
360 echo " <td>" . $colorbeg . xlt('Billing Note') .
361 $colorend . "&nbsp;" . $colorbeg . text($billing_note) .
362 $colorend . "</td>\n";
363 echo " </tr>\n";
366 </table>
367 </div>
368 <?php } ?>
369 </div>
370 </div>
372 <input type='hidden' name='mode' id="mode" value="new" />
373 <input type='hidden' name='offset' id="offset" value="<?php echo attr($offset); ?>" />
374 <input type='hidden' name='offset_sent' id="offset_sent" value="<?php echo attr($offset_sent); ?>" />
375 <input type='hidden' name='form_active' id="form_active" value="<?php echo attr($form_active); ?>" />
376 <input type='hidden' name='form_inactive' id="form_inactive" value="<?php echo attr($form_inactive); ?>" />
377 <input type='hidden' name='noteid' id="noteid" value="<?php echo attr($noteid); ?>" />
378 <input type='hidden' name='form_doc_only' id="form_doc_only" value="<?php echo attr($form_doc_only); ?>" />
379 </form>
381 <div class='tabContainer jumbotron p-4'>
382 <?php if ($active == "all") { ?>
383 <span><?php echo xlt('Show All'); ?></span>
384 <?php } else { ?>
385 <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>
386 <?php } ?>
388 <?php if ($active == '1') { ?>
389 <span><?php echo xlt('Show Active'); ?></span>
390 <?php } else { ?>
391 <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>
392 <?php } ?>
394 <?php if ($active == '0') { ?>
395 <span><?php echo xlt('Show Inactive'); ?></span>
396 <?php } else { ?>
397 <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>
398 <?php } ?>
399 <div id='inbox_div' class="table-responsive">
400 <form method='post' name='update_activity' id='update_activity'
401 action="pnotes_full.php?<?php echo $urlparms; ?>&<?php echo $activity_string_html;?>" onsubmit='return top.restoreSession()'>
402 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
404 <!-- start of previous notes DIV -->
405 <div class="pat_notes">
406 <input type='hidden' name='mode' value="update" />
407 <input type='hidden' name='offset' id='offset' value="<?php echo attr($offset); ?>" />
408 <input type='hidden' name='offset_sent' id='offset_sent' value="<?php echo attr($offset_sent); ?>" />
409 <input type='hidden' name='noteid' id='noteid' value="0" />
411 <table class="table table-borderless text">
412 <?php if ($result != "") : ?>
413 </table>
414 <?php endif; ?>
416 <table class="table table-borderless text">
417 <?php
418 // display all of the notes for the day, as well as others that are active
419 // from previous dates, up to a certain number, $N
421 if ($result != "") {
422 echo " <tr class='showborder_head'>\n";
423 echo " <th>" . xlt('Actions') . "</th>\n";
424 echo " <th>" . xlt('Active{{Note}}') . "&nbsp;</th>\n";
425 echo " <th>" . (($docid || $orderid) ? xlt('Linked') : '') . "</th>\n";
426 echo " <th>" . xlt('Type') . "</th>\n";
427 echo " <th>" . xlt('Content') . "</th>\n";
428 echo " <th>" . xlt('Status') . "</th>\n";
429 echo " <th>" . xlt('Last update') . "</th>\n";
430 echo " <th>" . xlt('Update by') . "</th>\n";
431 echo " </tr>\n";
433 $result_count = 0;
434 foreach ($result as $iter) {
435 $result_count++;
436 $row_note_id = $iter['id'];
438 $linked = "";
439 if ($docid) {
440 if (isGpRelation(1, $docid, 6, $row_note_id)) {
441 $linked = "checked";
442 } else {
443 // Skip unlinked notes if that is requested.
444 if ($form_doc_only) {
445 continue;
448 } elseif ($orderid) {
449 if (isGpRelation(2, $orderid, 6, $row_note_id)) {
450 $linked = "checked";
451 } else {
452 // Skip unlinked notes if that is requested.
453 if ($form_doc_only) {
454 continue;
459 $body = $iter['body'];
460 $body = preg_replace('/(\sto\s)-patient-(\))/', '${1}' . $patientname . '${2}', $body);
461 $body = preg_replace('/(\d{4}-\d{2}-\d{2} \d{2}:\d{2}\s\([^)(]+\s)(to)(\s[^)(]+\))/', '${1}' . xl('to{{Destination}}') . '${3}', $body);
462 if (preg_match('/^\d\d\d\d-\d\d-\d\d \d\d\:\d\d /', $body)) {
463 $body = pnoteConvertLinks(nl2br(text(oeFormatPatientNote($body))));
464 } else {
465 $body = text(oeFormatSDFT(strtotime($iter['date'])) . date(' H:i', strtotime($iter['date']))) .
466 ' (' . text($iter['user']) . ') ' . pnoteConvertLinks(nl2br(text(oeFormatPatientNote($body))));
469 if (($iter["activity"]) && ($iter['message_status'] != "Done")) {
470 $checked = "checked";
471 } else {
472 $checked = "";
475 // highlight the row if it's been selected for updating
476 if (!empty($_REQUEST['noteid']) && ($_REQUEST['noteid'] == $row_note_id)) {
477 echo " <tr class='noterow highlightcolor' id='" . attr($row_note_id) . "'>\n";
478 } else {
479 echo " <tr class='noterow' id='" . attr($row_note_id) . "'>\n";
483 echo " <td class='text-nowrap'><a href='pnotes_full_add.php?$urlparms&trigger=edit&noteid=" . attr_url($row_note_id) .
484 "' class='btn btn-primary btn-sm btn-edit note_modal' onclick='return top.restoreSession()'>" . xlt('Edit') . "</a>\n";
486 // display, or not, a button to delete the note
487 // if the user is an admin or if they are the author of the note, they can delete it
488 if (($iter['user'] == $_SESSION['authUser']) || (AclMain::aclCheckCore('admin', 'super', '', 'write'))) {
489 echo " <a href='#' class='deletenote btn btn-danger btn-sm btn-delete' id='del" . attr($row_note_id) .
490 "' title='" . xla('Delete this note') . "' onclick='return top.restoreSession()'>" .
491 xlt('Delete') . "</a>\n";
494 echo " </td>\n";
497 echo " <td class='text font-weight-bold'>\n";
498 echo " <input type='hidden' name='act" . attr($row_note_id) . "' value='1' />\n";
499 echo " <input type='checkbox' name='chk" . attr($row_note_id) . "' $checked />\n";
500 echo " </td>\n";
502 echo " <td class='text font-weight-bold'>\n";
503 if ($docid || $orderid) {
504 echo " <input type='checkbox' name='lnk" . attr($row_note_id) . "' $linked />\n";
507 echo " </td>\n";
509 echo " <td class='font-weight-bold notecell' id='" . attr($row_note_id) . "'>" .
510 "<a href='pnotes_full_add.php?$urlparms&trigger=edit&noteid=" . attr_url($row_note_id) . "' class='note_modal' onclick='return top.restoreSession()'>\n";
511 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
512 echo generate_display_field(array('data_type' => '1','list_id' => 'note_type'), $iter['title']);
513 echo " </a></td>\n";
515 echo " <td class='notecell' id='" . attr($row_note_id) . "'>\n";
516 echo " $body";
517 echo " </td>\n";
518 echo " <td class='notecell' id='" . attr($row_note_id) . "'>\n";
519 echo getListItemTitle("message_status", $iter['message_status']);
520 echo " </td>\n";
521 echo " <td class='notecell'>";
522 echo text(oeFormatDateTime($iter['update_date']));
523 echo " </td>\n";
524 echo " <td class='notecell'>";
525 $updateBy = $userService->getUser($iter['update_by']);
526 echo !is_null($updateBy) ? text($updateBy['fname']) . ' ' . text($updateBy['lname']) : '';
527 echo " </td>\n";
528 echo " </tr>\n";
530 } else {
531 //no results
532 print "<tr><td colspan='3' class='text'>" . xlt('None{{Note}}') . ".</td></tr>\n";
535 </table>
536 </div>
537 </form>
539 <table class="table table-borderless">
540 <tr>
541 <td>
542 <?php
543 if ($offset > ($N - 1)) {
544 $offsetN = $offset - $N;
545 echo " <a class='link' href='pnotes_full.php" .
546 "?$urlparms" .
547 "&form_active=" . attr_url($form_active) .
548 "&form_inactive=" . attr_url($form_inactive) .
549 "&form_doc_only=" . attr_url($form_doc_only) .
550 "&offset=" . attr_url($offsetN) . "&" . $activity_string_html . "' onclick='return top.restoreSession()'>[" .
551 xlt('Previous') . "]</a>\n";
554 </td>
555 <td class="text-right">
556 <?php
557 if ($result_count == $N) {
558 $offsetN = $offset + $N;
559 echo " <a class='link' href='pnotes_full.php" .
560 "?$urlparms" .
561 "&form_active=" . attr_url($form_active) .
562 "&form_inactive=" . attr_url($form_inactive) .
563 "&form_doc_only=" . attr_url($form_doc_only) .
564 "&offset=" . attr_url($offsetN) . "&" . $activity_string_html . "' onclick='return top.restoreSession()'>[" .
565 xlt('Next') . "]</a>\n";
568 </td>
569 </tr>
570 </table>
571 </div>
573 <div id='outbox_div table-resonsive' <?php echo $outbox_style; ?> >
574 <table class="table table-borderless text">
575 <?php if ($result_sent != "") : ?>
576 <tr>
577 <td colspan="5" class="p-1">
578 <a href="pnotes_full.php?<?php echo $urlparms; ?>&s=1&<?php echo $activity_string_html; ?>"
579 id='Submit' onclick='return top.restoreSession()'><?php echo xlt('Refresh'); ?></a>
580 </td>
581 </tr>
582 </table>
583 <?php endif; ?>
585 <table class="table table-borderless text w-75">
586 <?php
587 // display all of the notes for the day, as well as others that are active
588 // from previous dates, up to a certain number, $N
590 if ($result_sent != "") {
591 echo " <tr class='showborder_head'>\n";
592 echo " <th>&nbsp;</th>\n";
593 echo " <th>" . xlt('Active{{Note}}') . "&nbsp;</th>\n";
594 echo " <th>" . (($docid || $orderid) ? xlt('Linked') : '') . "</th>\n";
595 echo " <th>" . xlt('Type') . "</th>\n";
596 echo " <th>" . xlt('Content') . "</th>\n";
597 echo " </tr>\n";
599 $result_sent_count = 0;
600 foreach ($result_sent as $iter) {
601 $result_sent_count++;
602 $row_note_id = $iter['id'];
604 $linked = "";
605 if ($docid) {
606 if (isGpRelation(1, $docid, 6, $row_note_id)) {
607 $linked = "checked";
608 } else {
609 // Skip unlinked notes if that is requested.
610 if ($form_doc_only) {
611 continue;
614 } elseif ($orderid) {
615 if (isGpRelation(2, $orderid, 6, $row_note_id)) {
616 $linked = "checked";
617 } else {
618 // Skip unlinked notes if that is requested.
619 if ($form_doc_only) {
620 continue;
625 $body = $iter['body'];
626 if (preg_match('/^\d\d\d\d-\d\d-\d\d \d\d\:\d\d /', $body)) {
627 $body = pnoteConvertLinks(nl2br(text(oeFormatPatientNote($body))));
628 } else {
629 $body = text(oeFormatSDFT(strtotime($iter['date'])) . date(' H:i', strtotime($iter['date']))) .
630 ' (' . text($iter['user']) . ') ' . pnoteConvertLinks(nl2br(text(oeFormatPatientNote($body))));
633 $body = preg_replace('/(:\d{2}\s\()' . $patient_id . '(\sto\s)/', '${1}' . $patientname . '${2}', $body);
634 if (($iter["activity"]) && ($iter['message_status'] != "Done")) {
635 $checked = "checked";
636 } else {
637 $checked = "";
640 // highlight the row if it's been selected for updating
641 if ($_REQUEST['noteid'] == $row_note_id) {
642 echo " <tr class='noterow highlightcolor' id='" . attr($row_note_id) . "'>\n";
643 } else {
644 echo " <tr class='noterow' id='" . attr($row_note_id) . "'>\n";
647 echo " <td><a href='pnotes_full_add.php?$urlparms&trigger=edit&noteid=" . attr_url($row_note_id) .
648 "' class='btn btn-primary btn-sm btn-edit note_modal' onclick='return top.restoreSession()'>" . xlt('Edit') . "</a>\n";
650 // display, or not, a button to delete the note
651 // if the user is an admin or if they are the author of the note, they can delete it
652 if (($iter['user'] == $_SESSION['authUser']) || (AclMain::aclCheckCore('admin', 'super', '', 'write'))) {
653 echo " <a href='#' class='deletenote btn btn-danger btn-sm btn-delete' id='del" . attr($row_note_id) .
654 "' title='" . xla('Delete this note') . "' onclick='return restoreSession()'><span>" .
655 xlt('Delete') . "</span>\n";
658 echo " </td>\n";
661 echo " <td class='text font-weight-bold'>\n";
662 echo " <input type='hidden' name='act" . attr($row_note_id) . "' value='1' />\n";
663 echo " <input type='checkbox' name='chk" . attr($row_note_id) . "' $checked />\n";
664 echo " </td>\n";
666 echo " <td class='text font-weight-bold'>\n";
667 if ($docid || $orderid) {
668 echo " <input type='checkbox' name='lnk" . attr($row_note_id) . "' $linked />\n";
671 echo " </td>\n";
673 echo " <td class='font-weight-bold notecell' id='" . attr($row_note_id) . "'>" .
674 "<a href='pnotes_full_add.php?$urlparms&trigger=edit&noteid=" . attr_url($row_note_id) . "' class='note_modal' onclick='return top.restoreSession()'>\n";
675 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
676 echo generate_display_field(array('data_type' => '1','list_id' => 'note_type'), $iter['title']);
677 echo " </a></td>\n";
679 echo " <td class='notecell' id='" . attr($row_note_id) . "'>\n";
680 echo " $body";
681 echo " </td>\n";
682 echo " </tr>\n";
684 $notes_sent_count++;
686 } else {
687 //no results
688 print "<tr><td colspan='3' class='text'>" . xlt('None{{Result}}') . ".</td></tr>\n";
691 </table>
693 <table class="table table-borderless">
694 <tr>
695 <td>
696 <?php
697 if ($offset_sent > ($M - 1)) {
698 $offsetSentM = $offset_sent - $M;
699 echo " <a class='link' href='pnotes_full.php" .
700 "?$urlparms" .
701 "&s=1" .
702 "&form_active=" . attr_url($form_active) .
703 "&form_inactive=" . attr_url($form_inactive) .
704 "&form_doc_only=" . attr_url($form_doc_only) .
705 "&offset_sent=" . attr_url($offsetSentM) . "&" . $activity_string_html . "' onclick='return top.restoreSession()'>[" .
706 xlt('Previous') . "]</a>\n";
709 </td>
710 <td>
711 <?php
712 if ($result_sent_count == $M) {
713 $offsetSentM = $offset_sent + $M;
714 echo " <a class='link' href='pnotes_full.php" .
715 "?$urlparms" .
716 "&s=1" .
717 "&form_active=" . attr_url($form_active) .
718 "&form_inactive=" . attr_url($form_inactive) .
719 "&form_doc_only=" . attr_url($form_doc_only) .
720 "&offset_sent=" . attr_url($offsetSentM) . "&" . $activity_string_html . "' onclick='return top.restoreSession()'>[" .
721 xlt('Next') . "]</a>\n";
724 </td>
725 </tr>
726 </table>
727 </div>
728 </div>
729 </div> <!-- end outer 'pnotes' -->
730 </body>
731 <script>
732 <?php
733 if (!empty($_GET['set_pid'])) {
734 $ndata = getPatientData($patient_id, "fname, lname, pubpid");
736 parent.left_nav.setPatient(<?php echo js_escape($ndata['fname'] . " " . $ndata['lname']) . "," .
737 js_escape($patient_id) . "," . js_escape($ndata['pubpid']) . ",window.name"; ?>);
738 <?php
741 // If this note references a new patient document, pop up a display
742 // of that document.
744 if ($noteid /* && $title == 'New Document' */) {
745 $prow = getPnoteById($noteid, 'body');
746 if (preg_match('/New scanned document (\d+): [^\n]+\/([^\n]+)/', $prow['body'], $matches)) {
747 $docid = $matches[1];
748 $docname = $matches[2];
750 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',
751 '_blank', 'resizable=1,scrollbars=1,width=600,height=500');
752 <?php
756 </script>
758 <script>
759 // jQuery stuff to make the page a little easier to use
761 $(function () {
762 $("#appendnote").click(function() { AppendNote(); });
763 $("#newnote").click(function() { NewNote(); });
764 $("#printnote").click(function() { PrintNote(); });
766 $(".change_activity").click(function() { top.restoreSession(); $("#update_activity").submit(); });
768 $(".deletenote").click(function() { DeleteNote(this); });
770 $(".noterow").mouseover(function() { $(this).toggleClass("highlight"); });
771 $(".noterow").mouseout(function() { $(this).toggleClass("highlight"); });
773 $("#note").focus();
775 var NewNote = function () {
776 top.restoreSession();
777 $("#noteid").val('');
778 $("#new_note").submit();
781 var AppendNote = function () {
782 top.restoreSession();
783 $("#new_note").submit();
786 var PrintNote = function () {
787 top.restoreSession();
788 window.open('pnotes_print.php?noteid=<?php echo attr_url($noteid); ?>', '_blank', 'resizable=1,scrollbars=1,width=600,height=500');
791 var DeleteNote = function(note) {
792 if (confirm(<?php echo xlj('Are you sure you want to delete this note?'); ?> + '\n ' + <?php echo xlj('This action CANNOT be undone.'); ?>)) {
793 top.restoreSession();
794 // strip the 'del' part of the object's ID
795 $("#noteid").val(note.id.replace(/del/, ""));
796 $("#mode").val("delete");
797 $("#new_note").submit();
803 </script>
805 </html>