Moved recent v5.0.0 statement fix to current master.
[openemr.git] / interface / patient_file / summary / pnotes_full.php
blobd00676b5b5c9047dfd438d4b1d77d56ab902ad6c
1 <?php
2 /**
3 * Display, enter, modify and manage patient notes.
5 * LICENSE: This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 3
8 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
16 * @package OpenEMR
17 * @author Brady Miller <brady.g.miller@gmail.com>
18 * @link http://www.open-emr.org
23 /* Include required globals */
24 require_once('../../globals.php');
25 require_once($GLOBALS['srcdir'].'/pnotes.inc');
26 require_once($GLOBALS['srcdir'].'/patient.inc');
27 require_once($GLOBALS['srcdir'].'/acl.inc');
28 require_once($GLOBALS['srcdir'].'/log.inc');
29 require_once($GLOBALS['srcdir'].'/options.inc.php');
30 require_once($GLOBALS['srcdir'].'/gprelations.inc.php');
32 if ($_GET['set_pid']) {
33 require_once($GLOBALS['srcdir'].'/pid.inc');
34 setpid($_GET['set_pid']);
37 // form parameter docid can be passed to restrict the display to a document.
38 $docid = empty($_REQUEST['docid']) ? 0 : 0 + $_REQUEST['docid'];
40 // form parameter orderid can be passed to restrict the display to a procedure order.
41 $orderid = empty($_REQUEST['orderid']) ? 0 : intval($_REQUEST['orderid']);
43 $patient_id = $pid;
44 if ($docid) {
45 $row = sqlQuery("SELECT foreign_id FROM documents WHERE id = ?", array($docid));
46 $patient_id = intval($row['foreign_id']);
47 } else if ($orderid) {
48 $row = sqlQuery("SELECT patient_id FROM procedure_order WHERE procedure_order_id = ?", array($orderid));
49 $patient_id = intval($row['patient_id']);
52 // Check authorization.
53 if (!acl_check('patients', 'notes', '', array('write','addonly'))) {
54 die(htmlspecialchars(xl('Not authorized'), ENT_NOQUOTES));
57 $tmp = getPatientData($patient_id, "squad");
58 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad'])) {
59 die(htmlspecialchars(xl('Not authorized for this squad.'), ENT_NOQUOTES));
62 //the number of records to display per screen
63 $N = 15;
64 $M = 15;
66 $mode = $_REQUEST['mode'];
67 $offset = $_REQUEST['offset'];
68 $offset_sent = $_REQUEST['offset_sent'];
69 $form_active = $_REQUEST['form_active'];
70 $form_inactive = $_REQUEST['form_inactive'];
71 $noteid = $_REQUEST['noteid'];
72 $form_doc_only = isset($_POST['mode']) ? (empty($_POST['form_doc_only']) ? 0 : 1) : 1;
73 if ($_REQUEST['s'] == '1') {
74 $inbox = "";
75 $outbox = "current";
76 $inbox_style = "style='display:none;border:5px solid #FFFFFF;'";
77 $outbox_style = "style='border:5px solid #FFFFFF;'";
78 } else {
79 $inbox = "current";
80 $outbox = "";
81 $inbox_style = "style='border:5px solid #FFFFFF;'";
83 $outbox_style = "style='display:none;border:5px solid #FFFFFF;'";
86 if (!isset($offset)) {
87 $offset = 0;
90 if (!isset($offset_sent)) {
91 $offset_sent = 0;
94 // Collect active variable and applicable html code for links
95 if ($form_active) {
96 $active = '1';
97 $activity_string_html = 'form_active=1';
98 } else if ($form_inactive) {
99 $active = '0';
100 $activity_string_html = 'form_inactive=1';
101 } else {
102 $active = 'all';
103 $activity_string_html = '';
104 $form_active = $form_inactive = '0';
107 // this code handles changing the state of activity tags when the user updates
108 // them through the interface
109 if (isset($mode)) {
110 if ($mode == "update") {
111 foreach ($_POST as $var => $val) {
112 if (strncmp($var, 'act', 3) == 0) {
113 $id = str_replace("act", "", $var);
114 if ($_POST["chk$id"]) {
115 reappearPnote($id);
116 } else {
117 disappearPnote($id);
120 if ($docid) {
121 setGpRelation(1, $docid, 6, $id, !empty($_POST["lnk$id"]));
124 if ($orderid) {
125 setGpRelation(2, $orderid, 6, $id, !empty($_POST["lnk$id"]));
129 } elseif ($mode == "new") {
130 $note = $_POST['note'];
131 if ($noteid) {
132 updatePnote($noteid, $note, $_POST['form_note_type'], $_POST['assigned_to']);
133 } else {
134 $noteid = addPnote(
135 $patient_id,
136 $note,
137 $userauthorized,
138 '1',
139 $_POST['form_note_type'],
140 $_POST['assigned_to']
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 newEvent("delete", $_SESSION['authUser'], $_SESSION['authProvider'], 1, "pnotes: id ".$noteid);
159 $noteid = '';
163 $title = '';
164 $assigned_to = $_SESSION['authUser'];
165 if ($noteid) {
166 $prow = getPnoteById($noteid, 'title,assigned_to,body');
167 $title = $prow['title'];
168 $assigned_to = $prow['assigned_to'];
171 // Get the users list. The "Inactive" test is a kludge, we should create
172 // a separate column for this.
173 $ures = sqlStatement("SELECT username, fname, lname FROM users " .
174 "WHERE username != '' AND active = 1 AND " .
175 "( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
176 "ORDER BY lname, fname");
178 $pres = getPatientData($patient_id, "lname, fname");
179 $patientname = $pres['lname'] . ", " . $pres['fname'];
181 //retrieve all notes
182 $result = getPnotesByDate(
184 $active,
185 'id,date,body,user,activity,title,assigned_to,message_status',
186 $patient_id,
188 $offset,
190 $docid,
192 $orderid
194 $result_sent = getSentPnotesByDate(
196 $active,
197 'id,date,body,user,activity,title,assigned_to,message_status',
198 $patient_id,
200 $offset_sent,
202 $docid,
204 $orderid
208 <html>
209 <head>
210 <?php html_header_show();?>
212 <link rel='stylesheet' href="<?php echo $css_header;?>" type="text/css">
214 <!-- supporting javascript code -->
215 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-2/index.js"></script>
216 <link rel="stylesheet" type="text/css" href="../../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
217 <script type="text/javascript" src="../../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
218 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-3-2/index.js"></script>
219 <script type="text/javascript" src="../../../library/js/common.js"></script>
220 <script type="text/javascript" src="../../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
221 <script type="text/javascript">
222 /// todo, move this to a common library
224 $(document).ready(function(){
226 $("#dem_view").click( function() {
227 toggle( $(this), "#DEM" );
230 // load divs
231 $("#stats_div").load("stats.php");
232 $("#notes_div").load("pnotes_fragment.php");
234 // fancy box
235 enable_modals();
236 tabbify();
238 function show_div(name){
239 if(name == 'inbox'){
240 document.getElementById('inbox_div').style.display = '';
241 document.getElementById('outbox_div').style.display = 'none';
242 }else{
243 document.getElementById('inbox_div').style.display = 'none';
244 document.getElementById('outbox_div').style.display = '';
247 </script>
248 </head>
249 <body class="body_top">
251 <div id="pnotes"> <!-- large outer DIV -->
253 <form border='0' method='post' name='new_note' id="new_note" action='pnotes_full.php?docid=<?php echo htmlspecialchars($docid, ENT_QUOTES); ?>&orderid=<?php echo htmlspecialchars($orderid, ENT_QUOTES); ?>&<?php echo attr($activity_string_html);?>' onsubmit='return top.restoreSession()'>
255 <?php
256 $title_docname = "";
257 if ($docid) {
258 $title_docname .= " " . xl("linked to document") . " ";
259 $d = new Document($docid);
260 $title_docname .= $d->get_url_file();
263 if ($orderid) {
264 $title_docname .= " " . xl("linked to procedure order") . " $orderid";
267 $urlparms = "docid=$docid&orderid=$orderid";
270 <div>
271 <span class="title"><?php echo xlt('Patient Notes') . $title_docname; ?></span>
272 </div>
273 <div id='namecontainer_pnotes' class='namecontainer_pnotes' style='float:left;margin-right:10px'>
274 <?php echo htmlspecialchars(xl('for'), ENT_NOQUOTES);?>&nbsp;<span class="title">
275 <a href="../summary/demographics.php" onclick="top.restoreSession()"><?php echo htmlspecialchars(getPatientName($patient_id), ENT_NOQUOTES); ?></a></span>
276 </div>
277 <div>
278 <a href="pnotes_full_add.php?<?php echo $urlparms; ?>" class="css_button iframe" onclick='top.restoreSession()'><span><?php echo xlt('Add'); ?></span></a>
279 <a href="demographics.php" class="css_button" onclick="top.restoreSession()">
280 <span><?php echo htmlspecialchars(xl('View Patient'), ENT_NOQUOTES);?></span>
281 </a>
282 </div>
283 <br/>
284 <br/>
285 <div>
286 <?php if ($active == "all") { ?>
287 <span><?php echo xlt('Show All'); ?></span>
288 <?php } else { ?>
289 <a href="pnotes_full.php?<?php echo $urlparms; ?>" class="link" onclick="top.restoreSession()"><span><?php echo xlt('Show All'); ?></span></a>
290 <?php } ?>
292 <?php if ($active == '1') { ?>
293 <span><?php echo xlt('Show Active'); ?></span>
294 <?php } else { ?>
295 <a href="pnotes_full.php?form_active=1&<?php echo $urlparms; ?>" class="link" onclick="top.restoreSession()"><span><?php echo xlt('Show Active'); ?></span></a>
296 <?php } ?>
298 <?php if ($active == '0') { ?>
299 <span><?php echo xlt('Show Inactive'); ?></span>
300 <?php } else { ?>
301 <a href="pnotes_full.php?form_inactive=1&<?php echo $urlparms; ?>" class="link" onclick="top.restoreSession()"><span><?php echo xlt('Show Inactive'); ?></span></a>
302 <?php } ?>
303 </div>
305 <input type='hidden' name='mode' id="mode" value="new">
306 <input type='hidden' name='offset' id="offset" value="<?php echo $offset; ?>">
307 <input type='hidden' name='offset_sent' id="offset_sent" value="<?php echo $offset_sent; ?>">
308 <input type='hidden' name='form_active' id="form_active" value="<?php echo htmlspecialchars($form_active, ENT_QUOTES); ?>">
309 <input type='hidden' name='form_inactive' id="form_inactive" value="<?php echo htmlspecialchars($form_inactive, ENT_QUOTES); ?>">
310 <input type='hidden' name='noteid' id="noteid" value="<?php echo htmlspecialchars($noteid, ENT_QUOTES); ?>">
311 <input type='hidden' name='form_doc_only' id="form_doc_only" value="<?php echo htmlspecialchars($form_doc_only, ENT_QUOTES); ?>">
312 </form>
315 <?php
316 // Get the billing note if there is one.
317 $billing_note = "";
318 $colorbeg = "";
319 $colorend = "";
320 $resnote = getPatientData($patient_id, "billing_note");
321 if (!empty($resnote['billing_note'])) {
322 $billing_note = $resnote['billing_note'];
323 $colorbeg = "<span style='color:red'>";
324 $colorend = "</span>";
327 //Display what the patient owes
328 $balance = get_patient_balance($patient_id);
331 <?php if ($billing_note || $balance) { ?>
333 <div style='margin-top:3px'>
334 <table width='80%'>
335 <?php
336 if ($balance != "0") {
337 // $formatted = sprintf((xl('$').'%01.2f'), $balance);
338 $formatted = oeFormatMoney($balance);
339 echo " <tr class='text billing'>\n";
340 echo " <td>".$colorbeg . htmlspecialchars(xl('Balance Due'), ENT_NOQUOTES) .
341 $colorend."&nbsp;".$colorbeg. htmlspecialchars($formatted, ENT_NOQUOTES) .
342 $colorend."</td>\n";
343 echo " </tr>\n";
346 if ($billing_note) {
347 echo " <tr class='text billing'>\n";
348 echo " <td>".$colorbeg . htmlspecialchars(xl('Billing Note'), ENT_NOQUOTES) .
349 $colorend."&nbsp;".$colorbeg . htmlspecialchars($billing_note, ENT_NOQUOTES) .
350 $colorend."</td>\n";
351 echo " </tr>\n";
354 </table>
355 </div>
356 <br>
357 <?php } ?>
358 <ul class="tabNav">
359 <li class="<?php echo $inbox; ?>" ><a onclick="show_div('inbox')" href="#"><?php echo htmlspecialchars(xl('Inbox'), ENT_NOQUOTES); ?></a></li>
360 <li class="<?php echo $outbox; ?>" ><a onclick="show_div('outbox')" href="#"><?php echo htmlspecialchars(xl('Sent Items'), ENT_NOQUOTES); ?></a></li>
361 </ul>
362 <div class='tabContainer' >
363 <div id='inbox_div' <?php echo $inbox_style; ?> >
364 <form border='0' method='post' name='update_activity' id='update_activity'
365 action="pnotes_full.php?<?php echo $urlparms; ?>&<?php echo attr($activity_string_html);?>" onsubmit='return top.restoreSession()'>
366 <!-- start of previous notes DIV -->
367 <div class=pat_notes>
368 <input type='hidden' name='mode' value="update">
369 <input type='hidden' name='offset' id='offset' value="<?php echo $offset; ?>">
370 <input type='hidden' name='offset_sent' id='offset_sent' value="<?php echo $offset_sent; ?>">
371 <input type='hidden' name='noteid' id='noteid' value="0">
372 <table border='0' cellpadding="1" class="text">
373 <?php if ($result != "") : ?>
374 <tr>
375 <td colspan='5' style="padding: 5px;" >
376 <a href="#" class="change_activity" ><span><?php echo htmlspecialchars(xl('Update Active'), ENT_NOQUOTES); ?></span></a>
378 <a href="pnotes_full.php?<?php echo $urlparms; ?>&<?php echo attr($activity_string_html);?>" class="" id='Submit' onclick='top.restoreSession()'><span><?php echo htmlspecialchars(xl('Refresh'), ENT_NOQUOTES); ?></span></a>
379 </td>
380 </tr></table>
381 <?php endif; ?>
383 <table border='0' cellpadding="1" class="text" width = "80%">
384 <?php
385 // display all of the notes for the day, as well as others that are active
386 // from previous dates, up to a certain number, $N
388 if ($result != "") {
389 echo " <tr class=showborder_head align='left'>\n";
390 echo " <th style='width:100px';>&nbsp;</th>\n";
391 echo " <th>" . xlt('Active') . "&nbsp;</th>\n";
392 echo " <th>" . (($docid || $orderid) ? xlt('Linked') : '') . "</th>\n";
393 echo " <th>" . xlt('Type') . "</th>\n";
394 echo " <th>" . xlt('Content') . "</th>\n";
395 echo " </tr>\n";
397 $result_count = 0;
398 foreach ($result as $iter) {
399 $result_count++;
400 $row_note_id = $iter['id'];
402 $linked = "";
403 if ($docid) {
404 if (isGpRelation(1, $docid, 6, $row_note_id)) {
405 $linked = "checked";
406 } else {
407 // Skip unlinked notes if that is requested.
408 if ($form_doc_only) {
409 continue;
412 } else if ($orderid) {
413 if (isGpRelation(2, $orderid, 6, $row_note_id)) {
414 $linked = "checked";
415 } else {
416 // Skip unlinked notes if that is requested.
417 if ($form_doc_only) {
418 continue;
423 $body = $iter['body'];
424 if (preg_match('/^\d\d\d\d-\d\d-\d\d \d\d\:\d\d /', $body)) {
425 $body = nl2br(htmlspecialchars(oeFormatPatientNote($body), ENT_NOQUOTES));
426 } else {
427 $body = htmlspecialchars(oeFormatSDFT(strtotime($iter['date'])).date(' H:i', strtotime($iter['date'])), ENT_NOQUOTES) .
428 ' (' . htmlspecialchars($iter['user'], ENT_NOQUOTES) . ') ' . nl2br(htmlspecialchars(oeFormatPatientNote($body), ENT_NOQUOTES));
431 $body = preg_replace('/(\sto\s)-patient-(\))/', '${1}'.$patientname.'${2}', $body);
432 if (($iter{"activity"}) && ($iter['message_status'] != "Done")) {
433 $checked = "checked";
434 } else {
435 $checked = "";
438 // highlight the row if it's been selected for updating
439 if ($_REQUEST['noteid'] == $row_note_id) {
440 echo " <tr height=20 class='noterow highlightcolor' id='".htmlspecialchars($row_note_id, ENT_QUOTES)."'>\n";
441 } else {
442 echo " <tr class='noterow' id='".htmlspecialchars($row_note_id, ENT_QUOTES)."'>\n";
446 echo " <td><a href='pnotes_full_add.php?$urlparms&trigger=edit&noteid=".htmlspecialchars($row_note_id, ENT_QUOTES).
447 "' class='css_button_small iframe' onclick='top.restoreSession()'><span>". htmlspecialchars(xl('Edit'), ENT_NOQUOTES) ."</span></a>\n";
449 // display, or not, a button to delete the note
450 // if the user is an admin or if they are the author of the note, they can delete it
451 if (($iter['user'] == $_SESSION['authUser']) || (acl_check('admin', 'super', '', 'write'))) {
452 echo " <a href='#' class='deletenote css_button_small' id='del" . htmlspecialchars($row_note_id, ENT_QUOTES) .
453 "' title='" . htmlspecialchars(xl('Delete this note'), ENT_QUOTES) . "' onclick='top.restoreSession()'><span>" .
454 htmlspecialchars(xl('Delete'), ENT_NOQUOTES) . "</span>\n";
457 echo " </td>\n";
460 echo " <td class='text bold'>\n";
461 echo " <input type='hidden' name='act".htmlspecialchars($row_note_id, ENT_QUOTES)."' value='1' />\n";
462 echo " <input type='checkbox' name='chk".htmlspecialchars($row_note_id, ENT_QUOTES)."' $checked />\n";
463 echo " </td>\n";
465 echo " <td class='text bold'>\n";
466 if ($docid || $orderid) {
467 echo " <input type='checkbox' name='lnk" . htmlspecialchars($row_note_id, ENT_QUOTES) . "' $linked />\n";
470 echo " </td>\n";
472 echo " <td class='bold notecell' id='".htmlspecialchars($row_note_id, ENT_QUOTES)."'>" .
473 "<a href='pnotes_full_add.php?$urlparms&trigger=edit&noteid=".htmlspecialchars($row_note_id, ENT_QUOTES)."' class='iframe' onclick='top.restoreSession()'>\n";
474 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
475 echo generate_display_field(array('data_type'=>'1','list_id'=>'note_type'), $iter['title']);
476 echo " </a></td>\n";
478 echo " <td class='notecell' id='".htmlspecialchars($row_note_id, ENT_QUOTES)."'>\n";
479 echo " $body";
480 echo " </td>\n";
481 echo " </tr>\n";
483 $notes_count++;
485 } else {
486 //no results
487 print "<tr><td colspan='3' class='text'>" . htmlspecialchars(xl('None'), ENT_NOQUOTES) . ".</td></tr>\n";
492 </table>
493 </div>
494 </form>
496 <table width='400' border='0' cellpadding='0' cellspacing='0'>
497 <tr>
498 <td>
499 <?php
500 if ($offset > ($N-1)) {
501 echo " <a class='link' href='pnotes_full.php" .
502 "?$urlparms" .
503 "&form_active=" . htmlspecialchars($form_active, ENT_QUOTES) .
504 "&form_inactive=" . htmlspecialchars($form_inactive, ENT_QUOTES) .
505 "&form_doc_only=" . htmlspecialchars($form_doc_only, ENT_QUOTES) .
506 "&offset=" . ($offset-$N) . "&" . attr($activity_string_html) . "' onclick='top.restoreSession()'>[" .
507 htmlspecialchars(xl('Previous'), ENT_NOQUOTES) . "]</a>\n";
510 </td>
511 <td align='right'>
512 <?php
513 if ($result_count == $N) {
514 echo " <a class='link' href='pnotes_full.php" .
515 "?$urlparms" .
516 "&form_active=" . htmlspecialchars($form_active, ENT_QUOTES) .
517 "&form_inactive=" . htmlspecialchars($form_inactive, ENT_QUOTES) .
518 "&form_doc_only=" . htmlspecialchars($form_doc_only, ENT_QUOTES) .
519 "&offset=" . ($offset+$N) . "&" . attr($activity_string_html) . "' onclick='top.restoreSession()'>[" .
520 htmlspecialchars(xl('Next'), ENT_NOQUOTES) . "]</a>\n";
523 </td>
524 </tr>
525 </table>
527 </div>
528 <div id='outbox_div' <?php echo $outbox_style; ?> >
529 <table border='0' cellpadding="1" class="text">
530 <?php if ($result_sent != "") : ?>
531 <tr>
532 <td colspan='5' style="padding: 5px;" >
533 <a href="pnotes_full.php?<?php echo $urlparms; ?>&s=1&<?php echo attr($activity_string_html);?>"
534 class="" id='Submit' onclick='top.restoreSession()'><span><?php echo xlt('Refresh'); ?></span></a>
535 </td>
536 </tr></table>
537 <?php endif; ?>
539 <table border='0' cellpadding="1" class="text" width = "80%">
540 <?php
541 // display all of the notes for the day, as well as others that are active
542 // from previous dates, up to a certain number, $N
544 if ($result_sent != "") {
545 echo " <tr class=showborder_head align='left'>\n";
546 echo " <th style='width:100px';>&nbsp;</th>\n";
547 echo " <th>" . htmlspecialchars(xl('Active'), ENT_NOQUOTES) . "&nbsp;</th>\n";
548 echo " <th>" . (($docid || $orderid) ? htmlspecialchars(xl('Linked'), ENT_NOQUOTES) : '') . "</th>\n";
549 echo " <th>" . htmlspecialchars(xl('Type'), ENT_NOQUOTES) . "</th>\n";
550 echo " <th>" . htmlspecialchars(xl('Content'), ENT_NOQUOTES) . "</th>\n";
551 echo " </tr>\n";
553 $result_sent_count = 0;
554 foreach ($result_sent as $iter) {
555 $result_sent_count++;
556 $row_note_id = $iter['id'];
558 $linked = "";
559 if ($docid) {
560 if (isGpRelation(1, $docid, 6, $row_note_id)) {
561 $linked = "checked";
562 } else {
563 // Skip unlinked notes if that is requested.
564 if ($form_doc_only) {
565 continue;
568 } else if ($orderid) {
569 if (isGpRelation(2, $orderid, 6, $row_note_id)) {
570 $linked = "checked";
571 } else {
572 // Skip unlinked notes if that is requested.
573 if ($form_doc_only) {
574 continue;
579 $body = $iter['body'];
580 if (preg_match('/^\d\d\d\d-\d\d-\d\d \d\d\:\d\d /', $body)) {
581 $body = nl2br(htmlspecialchars(oeFormatPatientNote($body), ENT_NOQUOTES));
582 } else {
583 $body = htmlspecialchars(oeFormatSDFT(strtotime($iter['date'])).date(' H:i', strtotime($iter['date'])), ENT_NOQUOTES) .
584 ' (' . htmlspecialchars($iter['user'], ENT_NOQUOTES) . ') ' . nl2br(htmlspecialchars(oeFormatPatientNote($body), ENT_NOQUOTES));
587 $body = preg_replace('/(:\d{2}\s\()' . $patient_id . '(\sto\s)/', '${1}' . $patientname . '${2}', $body);
588 if (($iter{"activity"}) && ($iter['message_status'] != "Done")) {
589 $checked = "checked";
590 } else {
591 $checked = "";
594 // highlight the row if it's been selected for updating
595 if ($_REQUEST['noteid'] == $row_note_id) {
596 echo " <tr height=20 class='noterow highlightcolor' id='".htmlspecialchars($row_note_id, ENT_QUOTES)."'>\n";
597 } else {
598 echo " <tr class='noterow' id='".htmlspecialchars($row_note_id, ENT_QUOTES)."'>\n";
602 echo " <td><a href='pnotes_full_add.php?$urlparms&trigger=edit&noteid=".htmlspecialchars($row_note_id, ENT_QUOTES).
603 "' class='css_button_small iframe' onclick='top.restoreSession()'><span>". htmlspecialchars(xl('Edit'), ENT_NOQUOTES) ."</span></a>\n";
605 // display, or not, a button to delete the note
606 // if the user is an admin or if they are the author of the note, they can delete it
607 if (($iter['user'] == $_SESSION['authUser']) || (acl_check('admin', 'super', '', 'write'))) {
608 echo " <a href='#' class='deletenote css_button_small' id='del" . htmlspecialchars($row_note_id, ENT_QUOTES) .
609 "' title='" . htmlspecialchars(xl('Delete this note'), ENT_QUOTES) . "' onclick='top.restoreSession()'><span>" .
610 htmlspecialchars(xl('Delete'), ENT_NOQUOTES) . "</span>\n";
613 echo " </td>\n";
616 echo " <td class='text bold'>\n";
617 echo " <input type='hidden' name='act".htmlspecialchars($row_note_id, ENT_QUOTES)."' value='1' />\n";
618 echo " <input type='checkbox' name='chk".htmlspecialchars($row_note_id, ENT_QUOTES)."' $checked />\n";
619 echo " </td>\n";
621 echo " <td class='text bold'>\n";
622 if ($docid || $orderid) {
623 echo " <input type='checkbox' name='lnk" . htmlspecialchars($row_note_id, ENT_QUOTES) . "' $linked />\n";
626 echo " </td>\n";
628 echo " <td class='bold notecell' id='".htmlspecialchars($row_note_id, ENT_QUOTES)."'>" .
629 "<a href='pnotes_full_add.php?$urlparms&trigger=edit&noteid=".htmlspecialchars($row_note_id, ENT_QUOTES)."' class='iframe' onclick='top.restoreSession()'>\n";
630 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
631 echo generate_display_field(array('data_type'=>'1','list_id'=>'note_type'), $iter['title']);
632 echo " </a></td>\n";
634 echo " <td class='notecell' id='".htmlspecialchars($row_note_id, ENT_QUOTES)."'>\n";
635 echo " $body";
636 echo " </td>\n";
637 echo " </tr>\n";
639 $notes_sent_count++;
641 } else {
642 //no results
643 print "<tr><td colspan='3' class='text'>" . htmlspecialchars(xl('None'), ENT_NOQUOTES) . ".</td></tr>\n";
648 </table>
650 <table width='400' border='0' cellpadding='0' cellspacing='0'>
651 <tr>
652 <td>
653 <?php
654 if ($offset_sent > ($M-1)) {
655 echo " <a class='link' href='pnotes_full.php" .
656 "?$urlparms" .
657 "&s=1" .
658 "&form_active=" . htmlspecialchars($form_active, ENT_QUOTES) .
659 "&form_inactive=" . htmlspecialchars($form_inactive, ENT_QUOTES) .
660 "&form_doc_only=" . htmlspecialchars($form_doc_only, ENT_QUOTES) .
661 "&offset_sent=" . ($offset_sent-$M) . "&" . attr($activity_string_html) . "' onclick='top.restoreSession()'>[" .
662 htmlspecialchars(xl('Previous'), ENT_NOQUOTES) . "]</a>\n";
665 </td>
666 <td align='right'>
667 <?php
668 if ($result_sent_count == $M) {
669 echo " <a class='link' href='pnotes_full.php" .
670 "?$urlparms" .
671 "&s=1" .
672 "&form_active=" . htmlspecialchars($form_active, ENT_QUOTES) .
673 "&form_inactive=" . htmlspecialchars($form_inactive, ENT_QUOTES) .
674 "&form_doc_only=" . htmlspecialchars($form_doc_only, ENT_QUOTES) .
675 "&offset_sent=" . ($offset_sent+$M) . "&" . attr($activity_string_html) . "' onclick='top.restoreSession()'>[" .
676 htmlspecialchars(xl('Next'), ENT_NOQUOTES) . "]</a>\n";
679 </td>
680 </tr>
681 </table>
683 </div>
684 </div>
685 <script language='JavaScript'>
687 <?php
688 if ($_GET['set_pid']) {
689 $ndata = getPatientData($patient_id, "fname, lname, pubpid");
691 parent.left_nav.setPatient(<?php echo "'" . addslashes($ndata['fname']." ".$ndata['lname']) . "'," .
692 addslashes($patient_id) . ",'" . addslashes($ndata['pubpid']) . "',window.name"; ?>);
693 <?php
696 // If this note references a new patient document, pop up a display
697 // of that document.
699 if ($noteid /* && $title == 'New Document' */) {
700 $prow = getPnoteById($noteid, 'body');
701 if (preg_match('/New scanned document (\d+): [^\n]+\/([^\n]+)/', $prow['body'], $matches)) {
702 $docid = $matches[1];
703 $docname = $matches[2];
705 window.open('../../../controller.php?document&retrieve&patient_id=<?php echo htmlspecialchars($patient_id, ENT_QUOTES); ?>&document_id=<?php echo htmlspecialchars($docid, ENT_QUOTES); ?>&<?php echo htmlspecialchars($docname, ENT_QUOTES);?>&as_file=true',
706 '_blank', 'resizable=1,scrollbars=1,width=600,height=500');
707 <?php
712 </script>
714 </div> <!-- end outer 'pnotes' -->
716 </body>
718 <script language="javascript">
720 // jQuery stuff to make the page a little easier to use
722 $(document).ready(function(){
723 $("#appendnote").click(function() { AppendNote(); });
724 $("#newnote").click(function() { NewNote(); });
725 $("#printnote").click(function() { PrintNote(); });
727 $(".change_activity").click(function() { top.restoreSession(); $("#update_activity").submit(); });
729 $(".deletenote").click(function() { DeleteNote(this); });
731 $(".noterow").mouseover(function() { $(this).toggleClass("highlight"); });
732 $(".noterow").mouseout(function() { $(this).toggleClass("highlight"); });
733 $(".notecell").click(function() { EditNote(this); });
735 $("#note").focus();
737 var EditNote = function(note) {
738 top.restoreSession();
739 $("#noteid").val(note.id);
740 $("#mode").val("");
741 $("#new_note").submit();
744 var NewNote = function () {
745 top.restoreSession();
746 $("#noteid").val('');
747 $("#new_note").submit();
750 var AppendNote = function () {
751 top.restoreSession();
752 $("#new_note").submit();
755 var PrintNote = function () {
756 top.restoreSession();
757 window.open('pnotes_print.php?noteid=<?php echo htmlspecialchars($noteid, ENT_QUOTES); ?>', '_blank', 'resizable=1,scrollbars=1,width=600,height=500');
760 var DeleteNote = function(note) {
761 if (confirm("<?php echo htmlspecialchars(xl('Are you sure you want to delete this note?', '', '', '\n '), ENT_QUOTES) .
762 htmlspecialchars(xl('This action CANNOT be undone.'), ENT_QUOTES); ?>")) {
763 top.restoreSession();
764 // strip the 'del' part of the object's ID
765 $("#noteid").val(note.id.replace(/del/, ""));
766 $("#mode").val("delete");
767 $("#new_note").submit();
773 </script>
775 </html>