Interim autoloaded library/classes via composer classmap, take 4. (#422)
[openemr.git] / interface / patient_file / summary / pnotes_full.php
blobb1847f0a5dcedca3f1689f38c714a421430bb13d
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@sparmy.com>
18 * @link http://www.open-emr.org
21 //SANITIZE ALL ESCAPES
22 $sanitize_all_escapes=true;
24 //STOP FAKE REGISTER GLOBALS
25 $fake_register_globals=false;
27 /* Include required globals */
28 require_once('../../globals.php');
29 require_once($GLOBALS['srcdir'].'/pnotes.inc');
30 require_once($GLOBALS['srcdir'].'/patient.inc');
31 require_once($GLOBALS['srcdir'].'/acl.inc');
32 require_once($GLOBALS['srcdir'].'/log.inc');
33 require_once($GLOBALS['srcdir'].'/options.inc.php');
34 require_once($GLOBALS['srcdir'].'/gprelations.inc.php');
35 require_once($GLOBALS['srcdir'].'/formatting.inc.php');
37 if ($_GET['set_pid']) {
38 require_once($GLOBALS['srcdir'].'/pid.inc');
39 setpid($_GET['set_pid']);
42 // form parameter docid can be passed to restrict the display to a document.
43 $docid = empty($_REQUEST['docid']) ? 0 : 0 + $_REQUEST['docid'];
45 // form parameter orderid can be passed to restrict the display to a procedure order.
46 $orderid = empty($_REQUEST['orderid']) ? 0 : intval($_REQUEST['orderid']);
48 $patient_id = $pid;
49 if ($docid) {
50 $row = sqlQuery("SELECT foreign_id FROM documents WHERE id = ?", array($docid));
51 $patient_id = intval($row['foreign_id']);
53 else if ($orderid) {
54 $row = sqlQuery("SELECT patient_id FROM procedure_order WHERE procedure_order_id = ?", array($orderid));
55 $patient_id = intval($row['patient_id']);
58 // Check authorization.
59 if (!acl_check('patients','notes','',array('write','addonly') ))
60 die(htmlspecialchars( xl('Not authorized'), ENT_NOQUOTES));
61 $tmp = getPatientData($patient_id, "squad");
62 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad']))
63 die(htmlspecialchars( xl('Not authorized for this squad.'), ENT_NOQUOTES));
65 //the number of records to display per screen
66 $N = 15;
67 $M = 15;
69 $mode = $_REQUEST['mode'];
70 $offset = $_REQUEST['offset'];
71 $offset_sent = $_REQUEST['offset_sent'];
72 $form_active = $_REQUEST['form_active'];
73 $form_inactive = $_REQUEST['form_inactive'];
74 $noteid = $_REQUEST['noteid'];
75 $form_doc_only = isset($_POST['mode']) ? (empty($_POST['form_doc_only']) ? 0 : 1) : 1;
76 if($_REQUEST['s'] == '1'){
77 $inbox = "";
78 $outbox = "current";
79 $inbox_style = "style='display:none;border:5px solid #FFFFFF;'";
80 $outbox_style = "style='border:5px solid #FFFFFF;'";
81 }else{
82 $inbox = "current";
83 $outbox = "";
84 $inbox_style = "style='border:5px solid #FFFFFF;'";;
85 $outbox_style = "style='display:none;border:5px solid #FFFFFF;'";
88 if (!isset($offset)) $offset = 0;
89 if (!isset($offset_sent)) $offset_sent = 0;
91 // Collect active variable and applicable html code for links
92 if ($form_active) {
93 $active = '1';
94 $activity_string_html = 'form_active=1';
96 else if ($form_inactive) {
97 $active = '0';
98 $activity_string_html = 'form_inactive=1';
100 else {
101 $active = 'all';
102 $activity_string_html = '';
103 $form_active = $form_inactive = '0';
106 // this code handles changing the state of activity tags when the user updates
107 // them through the interface
108 if (isset($mode)) {
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);
118 if ($docid) {
119 setGpRelation(1, $docid, 6, $id, !empty($_POST["lnk$id"]));
121 if ($orderid) {
122 setGpRelation(2, $orderid, 6, $id, !empty($_POST["lnk$id"]));
127 elseif ($mode == "new") {
128 $note = $_POST['note'];
129 if ($noteid) {
130 updatePnote($noteid, $note, $_POST['form_note_type'], $_POST['assigned_to']);
132 else {
133 $noteid = addPnote($patient_id, $note, $userauthorized, '1',
134 $_POST['form_note_type'], $_POST['assigned_to']);
136 if ($docid) {
137 setGpRelation(1, $docid, 6, $noteid);
139 if ($orderid) {
140 setGpRelation(2, $orderid, 6, $noteid);
142 $noteid = '';
144 elseif ($mode == "delete") {
145 if ($noteid) {
146 deletePnote($noteid);
147 newEvent("delete", $_SESSION['authUser'], $_SESSION['authProvider'], 1, "pnotes: id ".$noteid);
149 $noteid = '';
153 $title = '';
154 $assigned_to = $_SESSION['authUser'];
155 if ($noteid) {
156 $prow = getPnoteById($noteid, 'title,assigned_to,body');
157 $title = $prow['title'];
158 $assigned_to = $prow['assigned_to'];
161 // Get the users list. The "Inactive" test is a kludge, we should create
162 // a separate column for this.
163 $ures = sqlStatement("SELECT username, fname, lname FROM users " .
164 "WHERE username != '' AND active = 1 AND " .
165 "( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
166 "ORDER BY lname, fname");
168 $pres = getPatientData($patient_id, "lname, fname");
169 $patientname = $pres['lname'] . ", " . $pres['fname'];
171 //retrieve all notes
172 $result = getPnotesByDate("", $active, 'id,date,body,user,activity,title,assigned_to,message_status',
173 $patient_id, $N, $offset, '', $docid, '', $orderid);
174 $result_sent = getSentPnotesByDate("", $active, 'id,date,body,user,activity,title,assigned_to,message_status',
175 $patient_id, $M, $offset_sent, '', $docid, '', $orderid);
178 <html>
179 <head>
180 <?php html_header_show();?>
182 <link rel='stylesheet' href="<?php echo $css_header;?>" type="text/css">
184 <!-- supporting javascript code -->
185 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-1/index.js"></script>
186 <link rel="stylesheet" type="text/css" href="../../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
187 <script type="text/javascript" src="../../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
188 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-3-2/index.js"></script>
189 <script type="text/javascript" src="../../../library/js/common.js"></script>
190 <script type="text/javascript" src="../../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
191 <script type="text/javascript">
192 /// todo, move this to a common library
194 $(document).ready(function(){
196 $("#dem_view").click( function() {
197 toggle( $(this), "#DEM" );
200 // load divs
201 $("#stats_div").load("stats.php");
202 $("#notes_div").load("pnotes_fragment.php");
204 // fancy box
205 enable_modals();
206 tabbify();
208 function show_div(name){
209 if(name == 'inbox'){
210 document.getElementById('inbox_div').style.display = '';
211 document.getElementById('outbox_div').style.display = 'none';
212 }else{
213 document.getElementById('inbox_div').style.display = 'none';
214 document.getElementById('outbox_div').style.display = '';
217 </script>
218 </head>
219 <body class="body_top">
221 <div id="pnotes"> <!-- large outer DIV -->
223 <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()'>
225 <?php
226 $title_docname = "";
227 if ($docid) {
228 $title_docname .= " " . xl("linked to document") . " ";
229 $d = new Document($docid);
230 $title_docname .= $d->get_url_file();
232 if ($orderid) {
233 $title_docname .= " " . xl("linked to procedure order") . " $orderid";
236 $urlparms = "docid=$docid&orderid=$orderid";
239 <div>
240 <span class="title"><?php echo xlt('Patient Notes') . $title_docname; ?></span>
241 </div>
242 <div id='namecontainer_pnotes' class='namecontainer_pnotes' style='float:left;margin-right:10px'>
243 <?php echo htmlspecialchars( xl('for'), ENT_NOQUOTES);?>&nbsp;<span class="title">
244 <a href="../summary/demographics.php" onclick="top.restoreSession()"><?php echo htmlspecialchars( getPatientName($patient_id), ENT_NOQUOTES); ?></a></span>
245 </div>
246 <div>
247 <a href="pnotes_full_add.php?<?php echo $urlparms; ?>" class="css_button iframe" onclick='top.restoreSession()'><span><?php echo xlt('Add'); ?></span></a>
248 <a href="demographics.php" class="css_button" onclick="top.restoreSession()">
249 <span><?php echo htmlspecialchars( xl('View Patient'), ENT_NOQUOTES);?></span>
250 </a>
251 </div>
252 <br/>
253 <br/>
254 <div>
255 <?php if ($active == "all") { ?>
256 <span><?php echo xlt('Show All'); ?></span>
257 <?php } else { ?>
258 <a href="pnotes_full.php?<?php echo $urlparms; ?>" class="link" onclick="top.restoreSession()"><span><?php echo xlt('Show All'); ?></span></a>
259 <?php } ?>
261 <?php if ($active == '1') { ?>
262 <span><?php echo xlt('Show Active'); ?></span>
263 <?php } else { ?>
264 <a href="pnotes_full.php?form_active=1&<?php echo $urlparms; ?>" class="link" onclick="top.restoreSession()"><span><?php echo xlt('Show Active'); ?></span></a>
265 <?php } ?>
267 <?php if ($active == '0') { ?>
268 <span><?php echo xlt('Show Inactive'); ?></span>
269 <?php } else { ?>
270 <a href="pnotes_full.php?form_inactive=1&<?php echo $urlparms; ?>" class="link" onclick="top.restoreSession()"><span><?php echo xlt('Show Inactive'); ?></span></a>
271 <?php } ?>
272 </div>
274 <input type='hidden' name='mode' id="mode" value="new">
275 <input type='hidden' name='offset' id="offset" value="<?php echo $offset; ?>">
276 <input type='hidden' name='offset_sent' id="offset_sent" value="<?php echo $offset_sent; ?>">
277 <input type='hidden' name='form_active' id="form_active" value="<?php echo htmlspecialchars( $form_active, ENT_QUOTES); ?>">
278 <input type='hidden' name='form_inactive' id="form_inactive" value="<?php echo htmlspecialchars( $form_inactive, ENT_QUOTES); ?>">
279 <input type='hidden' name='noteid' id="noteid" value="<?php echo htmlspecialchars( $noteid, ENT_QUOTES); ?>">
280 <input type='hidden' name='form_doc_only' id="form_doc_only" value="<?php echo htmlspecialchars( $form_doc_only, ENT_QUOTES); ?>">
281 </form>
284 <?php
285 // Get the billing note if there is one.
286 $billing_note = "";
287 $colorbeg = "";
288 $colorend = "";
289 $resnote = getPatientData($patient_id, "billing_note");
290 if(!empty($resnote['billing_note'])) {
291 $billing_note = $resnote['billing_note'];
292 $colorbeg = "<span style='color:red'>";
293 $colorend = "</span>";
296 //Display what the patient owes
297 $balance = get_patient_balance($patient_id);
300 <?php if ($billing_note || $balance ) { ?>
302 <div style='margin-top:3px'>
303 <table width='80%'>
304 <?php
305 if ($balance != "0") {
306 // $formatted = sprintf((xl('$').'%01.2f'), $balance);
307 $formatted = oeFormatMoney($balance);
308 echo " <tr class='text billing'>\n";
309 echo " <td>".$colorbeg . htmlspecialchars( xl('Balance Due'), ENT_NOQUOTES) .
310 $colorend."&nbsp;".$colorbeg. htmlspecialchars( $formatted, ENT_NOQUOTES) .
311 $colorend."</td>\n";
312 echo " </tr>\n";
315 if ($billing_note) {
316 echo " <tr class='text billing'>\n";
317 echo " <td>".$colorbeg . htmlspecialchars( xl('Billing Note'), ENT_NOQUOTES) .
318 $colorend."&nbsp;".$colorbeg . htmlspecialchars( $billing_note, ENT_NOQUOTES) .
319 $colorend."</td>\n";
320 echo " </tr>\n";
323 </table>
324 </div>
325 <br>
326 <?php } ?>
327 <ul class="tabNav">
328 <li class="<?php echo $inbox; ?>" ><a onclick="show_div('inbox')" href="#"><?php echo htmlspecialchars(xl('Inbox'),ENT_NOQUOTES); ?></a></li>
329 <li class="<?php echo $outbox; ?>" ><a onclick="show_div('outbox')" href="#"><?php echo htmlspecialchars(xl('Sent Items'),ENT_NOQUOTES); ?></a></li>
330 </ul>
331 <div class='tabContainer' >
332 <div id='inbox_div' <?php echo $inbox_style; ?> >
333 <form border='0' method='post' name='update_activity' id='update_activity'
334 action="pnotes_full.php?<?php echo $urlparms; ?>&<?php echo attr($activity_string_html);?>" onsubmit='return top.restoreSession()'>
335 <!-- start of previous notes DIV -->
336 <div class=pat_notes>
337 <input type='hidden' name='mode' value="update">
338 <input type='hidden' name='offset' id='offset' value="<?php echo $offset; ?>">
339 <input type='hidden' name='offset_sent' id='offset_sent' value="<?php echo $offset_sent; ?>">
340 <input type='hidden' name='noteid' id='noteid' value="0">
341 <table border='0' cellpadding="1" class="text">
342 <?php if ($result != ""): ?>
343 <tr>
344 <td colspan='5' style="padding: 5px;" >
345 <a href="#" class="change_activity" ><span><?php echo htmlspecialchars( xl('Update Active'), ENT_NOQUOTES); ?></span></a>
347 <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>
348 </td>
349 </tr></table>
350 <?php endif; ?>
352 <table border='0' cellpadding="1" class="text" width = "80%">
353 <?php
354 // display all of the notes for the day, as well as others that are active
355 // from previous dates, up to a certain number, $N
357 if ($result != "") {
358 echo " <tr class=showborder_head align='left'>\n";
359 echo " <th style='width:100px';>&nbsp;</th>\n";
360 echo " <th>" . xlt('Active') . "&nbsp;</th>\n";
361 echo " <th>" . (($docid || $orderid) ? xlt('Linked') : '') . "</th>\n";
362 echo " <th>" . xlt('Type') . "</th>\n";
363 echo " <th>" . xlt('Content') . "</th>\n";
364 echo " </tr>\n";
366 $result_count = 0;
367 foreach ($result as $iter) {
368 $result_count++;
369 $row_note_id = $iter['id'];
371 $linked = "";
372 if ($docid) {
373 if (isGpRelation(1, $docid, 6, $row_note_id)) {
374 $linked = "checked";
376 else {
377 // Skip unlinked notes if that is requested.
378 if ($form_doc_only) continue;
381 else if ($orderid) {
382 if (isGpRelation(2, $orderid, 6, $row_note_id)) {
383 $linked = "checked";
385 else {
386 // Skip unlinked notes if that is requested.
387 if ($form_doc_only) continue;
391 $body = $iter['body'];
392 if (preg_match('/^\d\d\d\d-\d\d-\d\d \d\d\:\d\d /', $body)) {
393 $body = nl2br(htmlspecialchars( oeFormatPatientNote($body), ENT_NOQUOTES));
394 } else {
395 $body = htmlspecialchars( oeFormatSDFT(strtotime($iter['date'])).date(' H:i', strtotime($iter['date'])), ENT_NOQUOTES) .
396 ' (' . htmlspecialchars( $iter['user'], ENT_NOQUOTES) . ') ' . nl2br(htmlspecialchars( oeFormatPatientNote($body), ENT_NOQUOTES));
398 $body = preg_replace('/(\sto\s)-patient-(\))/','${1}'.$patientname.'${2}',$body);
399 if ( ($iter{"activity"}) && ($iter['message_status'] != "Done") ) {
400 $checked = "checked";
401 } else {
402 $checked = "";
405 // highlight the row if it's been selected for updating
406 if ($_REQUEST['noteid'] == $row_note_id) {
407 echo " <tr height=20 class='noterow highlightcolor' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>\n";
409 else {
410 echo " <tr class='noterow' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>\n";
414 echo " <td><a href='pnotes_full_add.php?$urlparms&trigger=edit&noteid=".htmlspecialchars( $row_note_id, ENT_QUOTES).
415 "' class='css_button_small iframe' onclick='top.restoreSession()'><span>". htmlspecialchars( xl('Edit'), ENT_NOQUOTES) ."</span></a>\n";
417 // display, or not, a button to delete the note
418 // if the user is an admin or if they are the author of the note, they can delete it
419 if (($iter['user'] == $_SESSION['authUser']) || (acl_check('admin','super','','write'))) {
420 echo " <a href='#' class='deletenote css_button_small' id='del" . htmlspecialchars( $row_note_id, ENT_QUOTES) .
421 "' title='" . htmlspecialchars( xl('Delete this note'), ENT_QUOTES) . "' onclick='top.restoreSession()'><span>" .
422 htmlspecialchars( xl('Delete'), ENT_NOQUOTES) . "</span>\n";
424 echo " </td>\n";
427 echo " <td class='text bold'>\n";
428 echo " <input type='hidden' name='act".htmlspecialchars( $row_note_id, ENT_QUOTES)."' value='1' />\n";
429 echo " <input type='checkbox' name='chk".htmlspecialchars( $row_note_id, ENT_QUOTES)."' $checked />\n";
430 echo " </td>\n";
432 echo " <td class='text bold'>\n";
433 if ($docid || $orderid) {
434 echo " <input type='checkbox' name='lnk" . htmlspecialchars($row_note_id, ENT_QUOTES) . "' $linked />\n";
436 echo " </td>\n";
438 echo " <td class='bold notecell' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>" .
439 "<a href='pnotes_full_add.php?$urlparms&trigger=edit&noteid=".htmlspecialchars( $row_note_id, ENT_QUOTES)."' class='iframe' onclick='top.restoreSession()'>\n";
440 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
441 echo generate_display_field(array('data_type'=>'1','list_id'=>'note_type'), $iter['title']);
442 echo " </a></td>\n";
444 echo " <td class='notecell' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>\n";
445 echo " $body";
446 echo " </td>\n";
447 echo " </tr>\n";
449 $notes_count++;
451 } else {
452 //no results
453 print "<tr><td colspan='3' class='text'>" . htmlspecialchars( xl('None'), ENT_NOQUOTES) . ".</td></tr>\n";
458 </table>
459 </div>
460 </form>
462 <table width='400' border='0' cellpadding='0' cellspacing='0'>
463 <tr>
464 <td>
465 <?php
466 if ($offset > ($N-1)) {
467 echo " <a class='link' href='pnotes_full.php" .
468 "?$urlparms" .
469 "&form_active=" . htmlspecialchars( $form_active, ENT_QUOTES) .
470 "&form_inactive=" . htmlspecialchars( $form_inactive, ENT_QUOTES) .
471 "&form_doc_only=" . htmlspecialchars( $form_doc_only, ENT_QUOTES) .
472 "&offset=" . ($offset-$N) . "&" . attr($activity_string_html) . "' onclick='top.restoreSession()'>[" .
473 htmlspecialchars( xl('Previous'), ENT_NOQUOTES) . "]</a>\n";
476 </td>
477 <td align='right'>
478 <?php
479 if ($result_count == $N) {
480 echo " <a class='link' href='pnotes_full.php" .
481 "?$urlparms" .
482 "&form_active=" . htmlspecialchars( $form_active, ENT_QUOTES) .
483 "&form_inactive=" . htmlspecialchars( $form_inactive, ENT_QUOTES) .
484 "&form_doc_only=" . htmlspecialchars( $form_doc_only, ENT_QUOTES) .
485 "&offset=" . ($offset+$N) . "&" . attr($activity_string_html) . "' onclick='top.restoreSession()'>[" .
486 htmlspecialchars( xl('Next'), ENT_NOQUOTES) . "]</a>\n";
489 </td>
490 </tr>
491 </table>
493 </div>
494 <div id='outbox_div' <?php echo $outbox_style; ?> >
495 <table border='0' cellpadding="1" class="text">
496 <?php if ($result_sent != ""): ?>
497 <tr>
498 <td colspan='5' style="padding: 5px;" >
499 <a href="pnotes_full.php?<?php echo $urlparms; ?>&s=1&<?php echo attr($activity_string_html);?>"
500 class="" id='Submit' onclick='top.restoreSession()'><span><?php echo xlt('Refresh'); ?></span></a>
501 </td>
502 </tr></table>
503 <?php endif; ?>
505 <table border='0' cellpadding="1" class="text" width = "80%">
506 <?php
507 // display all of the notes for the day, as well as others that are active
508 // from previous dates, up to a certain number, $N
510 if ($result_sent != "") {
511 echo " <tr class=showborder_head align='left'>\n";
512 echo " <th style='width:100px';>&nbsp;</th>\n";
513 echo " <th>" . htmlspecialchars( xl('Active'), ENT_NOQUOTES) . "&nbsp;</th>\n";
514 echo " <th>" . (($docid || $orderid) ? htmlspecialchars( xl('Linked'), ENT_NOQUOTES) : '') . "</th>\n";
515 echo " <th>" . htmlspecialchars( xl('Type'), ENT_NOQUOTES) . "</th>\n";
516 echo " <th>" . htmlspecialchars( xl('Content'), ENT_NOQUOTES) . "</th>\n";
517 echo " </tr>\n";
519 $result_sent_count = 0;
520 foreach ($result_sent as $iter) {
521 $result_sent_count++;
522 $row_note_id = $iter['id'];
524 $linked = "";
525 if ($docid) {
526 if (isGpRelation(1, $docid, 6, $row_note_id)) {
527 $linked = "checked";
529 else {
530 // Skip unlinked notes if that is requested.
531 if ($form_doc_only) continue;
534 else if ($orderid) {
535 if (isGpRelation(2, $orderid, 6, $row_note_id)) {
536 $linked = "checked";
538 else {
539 // Skip unlinked notes if that is requested.
540 if ($form_doc_only) continue;
544 $body = $iter['body'];
545 if (preg_match('/^\d\d\d\d-\d\d-\d\d \d\d\:\d\d /', $body)) {
546 $body = nl2br(htmlspecialchars( oeFormatPatientNote($body), ENT_NOQUOTES));
547 } else {
548 $body = htmlspecialchars( oeFormatSDFT(strtotime($iter['date'])).date(' H:i', strtotime($iter['date'])), ENT_NOQUOTES) .
549 ' (' . htmlspecialchars( $iter['user'], ENT_NOQUOTES) . ') ' . nl2br(htmlspecialchars( oeFormatPatientNote($body), ENT_NOQUOTES));
551 $body = preg_replace('/(:\d{2}\s\()' . $patient_id . '(\sto\s)/','${1}' . $patientname . '${2}', $body);
552 if (($iter{"activity"}) && ($iter['message_status'] != "Done") ) {
553 $checked = "checked";
554 } else {
555 $checked = "";
558 // highlight the row if it's been selected for updating
559 if ($_REQUEST['noteid'] == $row_note_id) {
560 echo " <tr height=20 class='noterow highlightcolor' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>\n";
562 else {
563 echo " <tr class='noterow' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>\n";
567 echo " <td><a href='pnotes_full_add.php?$urlparms&trigger=edit&noteid=".htmlspecialchars( $row_note_id, ENT_QUOTES).
568 "' class='css_button_small iframe' onclick='top.restoreSession()'><span>". htmlspecialchars( xl('Edit'), ENT_NOQUOTES) ."</span></a>\n";
570 // display, or not, a button to delete the note
571 // if the user is an admin or if they are the author of the note, they can delete it
572 if (($iter['user'] == $_SESSION['authUser']) || (acl_check('admin','super','','write'))) {
573 echo " <a href='#' class='deletenote css_button_small' id='del" . htmlspecialchars( $row_note_id, ENT_QUOTES) .
574 "' title='" . htmlspecialchars( xl('Delete this note'), ENT_QUOTES) . "' onclick='top.restoreSession()'><span>" .
575 htmlspecialchars( xl('Delete'), ENT_NOQUOTES) . "</span>\n";
577 echo " </td>\n";
580 echo " <td class='text bold'>\n";
581 echo " <input type='hidden' name='act".htmlspecialchars( $row_note_id, ENT_QUOTES)."' value='1' />\n";
582 echo " <input type='checkbox' name='chk".htmlspecialchars( $row_note_id, ENT_QUOTES)."' $checked />\n";
583 echo " </td>\n";
585 echo " <td class='text bold'>\n";
586 if ($docid || $orderid) {
587 echo " <input type='checkbox' name='lnk" . htmlspecialchars($row_note_id, ENT_QUOTES) . "' $linked />\n";
589 echo " </td>\n";
591 echo " <td class='bold notecell' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>" .
592 "<a href='pnotes_full_add.php?$urlparms&trigger=edit&noteid=".htmlspecialchars( $row_note_id, ENT_QUOTES)."' class='iframe' onclick='top.restoreSession()'>\n";
593 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
594 echo generate_display_field(array('data_type'=>'1','list_id'=>'note_type'), $iter['title']);
595 echo " </a></td>\n";
597 echo " <td class='notecell' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>\n";
598 echo " $body";
599 echo " </td>\n";
600 echo " </tr>\n";
602 $notes_sent_count++;
604 } else {
605 //no results
606 print "<tr><td colspan='3' class='text'>" . htmlspecialchars( xl('None'), ENT_NOQUOTES) . ".</td></tr>\n";
611 </table>
613 <table width='400' border='0' cellpadding='0' cellspacing='0'>
614 <tr>
615 <td>
616 <?php
617 if ($offset_sent > ($M-1)) {
618 echo " <a class='link' href='pnotes_full.php" .
619 "?$urlparms" .
620 "&s=1" .
621 "&form_active=" . htmlspecialchars( $form_active, ENT_QUOTES) .
622 "&form_inactive=" . htmlspecialchars( $form_inactive, ENT_QUOTES) .
623 "&form_doc_only=" . htmlspecialchars( $form_doc_only, ENT_QUOTES) .
624 "&offset_sent=" . ($offset_sent-$M) . "&" . attr($activity_string_html) . "' onclick='top.restoreSession()'>[" .
625 htmlspecialchars( xl('Previous'), ENT_NOQUOTES) . "]</a>\n";
628 </td>
629 <td align='right'>
630 <?php
631 if ($result_sent_count == $M) {
632 echo " <a class='link' href='pnotes_full.php" .
633 "?$urlparms" .
634 "&s=1" .
635 "&form_active=" . htmlspecialchars( $form_active, ENT_QUOTES) .
636 "&form_inactive=" . htmlspecialchars( $form_inactive, ENT_QUOTES) .
637 "&form_doc_only=" . htmlspecialchars( $form_doc_only, ENT_QUOTES) .
638 "&offset_sent=" . ($offset_sent+$M) . "&" . attr($activity_string_html) . "' onclick='top.restoreSession()'>[" .
639 htmlspecialchars( xl('Next'), ENT_NOQUOTES) . "]</a>\n";
642 </td>
643 </tr>
644 </table>
646 </div>
647 </div>
648 <script language='JavaScript'>
650 <?php
651 if ($_GET['set_pid']) {
652 $ndata = getPatientData($patient_id, "fname, lname, pubpid");
654 parent.left_nav.setPatient(<?php echo "'" . addslashes($ndata['fname']." ".$ndata['lname']) . "'," .
655 addslashes($patient_id) . ",'" . addslashes($ndata['pubpid']) . "',window.name"; ?>);
656 <?php
659 // If this note references a new patient document, pop up a display
660 // of that document.
662 if ($noteid /* && $title == 'New Document' */ ) {
663 $prow = getPnoteById($noteid, 'body');
664 if (preg_match('/New scanned document (\d+): [^\n]+\/([^\n]+)/', $prow['body'], $matches)) {
665 $docid = $matches[1];
666 $docname = $matches[2];
668 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',
669 '_blank', 'resizable=1,scrollbars=1,width=600,height=500');
670 <?php
675 </script>
677 </div> <!-- end outer 'pnotes' -->
679 </body>
681 <script language="javascript">
683 // jQuery stuff to make the page a little easier to use
685 $(document).ready(function(){
686 $("#appendnote").click(function() { AppendNote(); });
687 $("#newnote").click(function() { NewNote(); });
688 $("#printnote").click(function() { PrintNote(); });
690 $(".change_activity").click(function() { top.restoreSession(); $("#update_activity").submit(); });
692 $(".deletenote").click(function() { DeleteNote(this); });
694 $(".noterow").mouseover(function() { $(this).toggleClass("highlight"); });
695 $(".noterow").mouseout(function() { $(this).toggleClass("highlight"); });
696 $(".notecell").click(function() { EditNote(this); });
698 $("#note").focus();
700 var EditNote = function(note) {
701 top.restoreSession();
702 $("#noteid").val(note.id);
703 $("#mode").val("");
704 $("#new_note").submit();
707 var NewNote = function () {
708 top.restoreSession();
709 $("#noteid").val('');
710 $("#new_note").submit();
713 var AppendNote = function () {
714 top.restoreSession();
715 $("#new_note").submit();
718 var PrintNote = function () {
719 top.restoreSession();
720 window.open('pnotes_print.php?noteid=<?php echo htmlspecialchars( $noteid, ENT_QUOTES); ?>', '_blank', 'resizable=1,scrollbars=1,width=600,height=500');
723 var DeleteNote = function(note) {
724 if (confirm("<?php echo htmlspecialchars( xl('Are you sure you want to delete this note?','','','\n '), ENT_QUOTES) .
725 htmlspecialchars( xl('This action CANNOT be undone.'), ENT_QUOTES); ?>")) {
726 top.restoreSession();
727 // strip the 'del' part of the object's ID
728 $("#noteid").val(note.id.replace(/del/, ""));
729 $("#mode").val("delete");
730 $("#new_note").submit();
736 </script>
738 </html>