Session fixes in the patient notes module
[openemr.git] / interface / patient_file / summary / pnotes_full.php
blob70f203f48b7f0bd8c5f149aef3193ce6a45eb0ec
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'].'/classes/Document.class.php');
35 require_once($GLOBALS['srcdir'].'/gprelations.inc.php');
36 require_once($GLOBALS['srcdir'].'/formatting.inc.php');
38 if ($GLOBALS['concurrent_layout'] && $_GET['set_pid']) {
39 require_once($GLOBALS['srcdir'].'/pid.inc');
40 setpid($_GET['set_pid']);
43 // form parameter docid can be passed to restrict the display to a document.
44 $docid = empty($_REQUEST['docid']) ? 0 : 0 + $_REQUEST['docid'];
46 // form parameter orderid can be passed to restrict the display to a procedure order.
47 $orderid = empty($_REQUEST['orderid']) ? 0 : intval($_REQUEST['orderid']);
49 $patient_id = $pid;
50 if ($docid) {
51 $row = sqlQuery("SELECT foreign_id FROM documents WHERE id = ?", array($docid));
52 $patient_id = intval($row['foreign_id']);
54 else if ($orderid) {
55 $row = sqlQuery("SELECT patient_id FROM procedure_order WHERE procedure_order_id = ?", array($orderid));
56 $patient_id = intval($row['patient_id']);
59 // Check authorization.
60 if (!acl_check('patients','notes','',array('write','addonly') ))
61 die(htmlspecialchars( xl('Not authorized'), ENT_NOQUOTES));
62 $tmp = getPatientData($patient_id, "squad");
63 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad']))
64 die(htmlspecialchars( xl('Not authorized for this squad.'), ENT_NOQUOTES));
66 //the number of records to display per screen
67 $N = 15;
68 $M = 15;
70 $mode = $_REQUEST['mode'];
71 $offset = $_REQUEST['offset'];
72 $offset_sent = $_REQUEST['offset_sent'];
73 $form_active = $_REQUEST['form_active'];
74 $form_inactive = $_REQUEST['form_inactive'];
75 $noteid = $_REQUEST['noteid'];
76 $form_doc_only = isset($_POST['mode']) ? (empty($_POST['form_doc_only']) ? 0 : 1) : 1;
77 if($_REQUEST['s'] == '1'){
78 $inbox = "";
79 $outbox = "current";
80 $inbox_style = "style='display:none;border:5px solid #FFFFFF;'";
81 $outbox_style = "style='border:5px solid #FFFFFF;'";
82 }else{
83 $inbox = "current";
84 $outbox = "";
85 $inbox_style = "style='border:5px solid #FFFFFF;'";;
86 $outbox_style = "style='display:none;border:5px solid #FFFFFF;'";
89 if (!isset($offset)) $offset = 0;
90 if (!isset($offset_sent)) $offset_sent = 0;
92 // Collect active variable and applicable html code for links
93 if ($form_active) {
94 $active = '1';
95 $activity_string_html = 'form_active=1';
97 else if ($form_inactive) {
98 $active = '0';
99 $activity_string_html = 'form_inactive=1';
101 else {
102 $active = 'all';
103 $activity_string_html = '';
104 $form_active = $form_inactive = '1';
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);
119 if ($docid) {
120 setGpRelation(1, $docid, 6, $id, !empty($_POST["lnk$id"]));
122 if ($orderid) {
123 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']);
133 else {
134 $noteid = addPnote($patient_id, $note, $userauthorized, '1',
135 $_POST['form_note_type'], $_POST['assigned_to']);
137 if ($docid) {
138 setGpRelation(1, $docid, 6, $noteid);
140 if ($orderid) {
141 setGpRelation(2, $orderid, 6, $noteid);
143 $noteid = '';
145 elseif ($mode == "delete") {
146 if ($noteid) {
147 deletePnote($noteid);
148 newEvent("delete", $_SESSION['authUser'], $_SESSION['authProvider'], 1, "pnotes: id ".$noteid);
150 $noteid = '';
154 $title = '';
155 $assigned_to = $_SESSION['authUser'];
156 if ($noteid) {
157 $prow = getPnoteById($noteid, 'title,assigned_to,body');
158 $title = $prow['title'];
159 $assigned_to = $prow['assigned_to'];
162 // Get the users list. The "Inactive" test is a kludge, we should create
163 // a separate column for this.
164 $ures = sqlStatement("SELECT username, fname, lname FROM users " .
165 "WHERE username != '' AND active = 1 AND " .
166 "( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
167 "ORDER BY lname, fname");
169 $pres = getPatientData($patient_id, "lname, fname");
170 $patientname = $pres['lname'] . ", " . $pres['fname'];
172 //retrieve all notes
173 $result = getPnotesByDate("", $active, 'id,date,body,user,activity,title,assigned_to,message_status',
174 $patient_id, $N, $offset, '', $docid, '', $orderid);
175 $result_sent = getSentPnotesByDate("", $active, 'id,date,body,user,activity,title,assigned_to,message_status',
176 $patient_id, $M, $offset_sent, '', $docid, '', $orderid);
179 <html>
180 <head>
181 <?php html_header_show();?>
183 <link rel='stylesheet' href="<?php echo $css_header;?>" type="text/css">
185 <!-- supporting javascript code -->
186 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script>
187 <link rel="stylesheet" type="text/css" href="../../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
188 <script type="text/javascript" src="../../../library/dialog.js"></script>
189 <script type="text/javascript" src="../../../library/js/jquery.1.3.2.js"></script>
190 <script type="text/javascript" src="../../../library/js/common.js"></script>
191 <script type="text/javascript" src="../../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
192 <script type="text/javascript">
193 /// todo, move this to a common library
195 $(document).ready(function(){
197 $("#dem_view").click( function() {
198 toggle( $(this), "#DEM" );
201 // load divs
202 $("#stats_div").load("stats.php");
203 $("#notes_div").load("pnotes_fragment.php");
205 // fancy box
206 enable_modals();
207 tabbify();
209 function show_div(name){
210 if(name == 'inbox'){
211 document.getElementById('inbox_div').style.display = '';
212 document.getElementById('outbox_div').style.display = 'none';
213 }else{
214 document.getElementById('inbox_div').style.display = 'none';
215 document.getElementById('outbox_div').style.display = '';
218 </script>
219 </head>
220 <body class="body_top">
222 <div id="pnotes"> <!-- large outer DIV -->
224 <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()'>
226 <?php
227 $title_docname = "";
228 if ($docid) {
229 $title_docname .= " " . xl("linked to document") . " ";
230 $d = new Document($docid);
231 $title_docname .= $d->get_url_file();
233 if ($orderid) {
234 $title_docname .= " " . xl("linked to procedure order") . " $orderid";
237 $urlparms = "docid=$docid&orderid=$orderid";
240 <div>
241 <span class="title"><?php echo xlt('Patient Notes') . $title_docname; ?></span>
242 </div>
243 <div style='float:left;margin-right:10px'>
244 <?php echo htmlspecialchars( xl('for'), ENT_NOQUOTES);?>&nbsp;<span class="title">
245 <a href="../summary/demographics.php" onclick="top.restoreSession()"><?php echo htmlspecialchars( getPatientName($patient_id), ENT_NOQUOTES); ?></a></span>
246 </div>
247 <div>
248 <a href="pnotes_full_add.php?<?php echo $urlparms; ?>" class="css_button iframe" onclick='top.restoreSession()'><span><?php echo xlt('Add'); ?></span></a>
249 <a href="demographics.php" <?php if (!$GLOBALS['concurrent_layout']) echo "target='Main'"; ?> class="css_button" onclick="top.restoreSession()">
250 <span><?php echo htmlspecialchars( xl('View Patient'), ENT_NOQUOTES);?></span>
251 </a>
252 </div>
253 <br/>
254 <br/>
255 <div>
256 <?php if ($active == "all") { ?>
257 <span><?php echo xlt('Show All'); ?></span>
258 <?php } else { ?>
259 <a href="pnotes_full.php?<?php echo $urlparms; ?>" class="link" onclick="top.restoreSession()"><span><?php echo xlt('Show All'); ?></span></a>
260 <?php } ?>
262 <?php if ($active == '1') { ?>
263 <span><?php echo xlt('Show Active'); ?></span>
264 <?php } else { ?>
265 <a href="pnotes_full.php?form_active=1&<?php echo $urlparms; ?>" class="link" onclick="top.restoreSession()"><span><?php echo xlt('Show Active'); ?></span></a>
266 <?php } ?>
268 <?php if ($active == '0') { ?>
269 <span><?php echo xlt('Show Inactive'); ?></span>
270 <?php } else { ?>
271 <a href="pnotes_full.php?form_inactive=1&<?php echo $urlparms; ?>" class="link" onclick="top.restoreSession()"><span><?php echo xlt('Show Inactive'); ?></span></a>
272 <?php } ?>
273 </div>
275 <input type='hidden' name='mode' id="mode" value="new">
276 <input type='hidden' name='offset' id="offset" value="<?php echo $offset; ?>">
277 <input type='hidden' name='offset_sent' id="offset_sent" value="<?php echo $offset_sent; ?>">
278 <input type='hidden' name='form_active' id="form_active" value="<?php echo htmlspecialchars( $form_active, ENT_QUOTES); ?>">
279 <input type='hidden' name='form_inactive' id="form_inactive" value="<?php echo htmlspecialchars( $form_inactive, ENT_QUOTES); ?>">
280 <input type='hidden' name='noteid' id="noteid" value="<?php echo htmlspecialchars( $noteid, ENT_QUOTES); ?>">
281 <input type='hidden' name='form_doc_only' id="form_doc_only" value="<?php echo htmlspecialchars( $form_doc_only, ENT_QUOTES); ?>">
282 </form>
285 <?php
286 // Get the billing note if there is one.
287 $billing_note = "";
288 $colorbeg = "";
289 $colorend = "";
290 $resnote = getPatientData($patient_id, "genericname2, genericval2");
291 if($resnote && $resnote['genericname2'] == 'Billing') {
292 $billing_note = $resnote['genericval2'];
293 $colorbeg = "<span style='color:red'>";
294 $colorend = "</span>";
297 //Display what the patient owes
298 $balance = get_patient_balance($patient_id);
301 <?php if ($billing_note || $balance ) { ?>
303 <div style='margin-top:3px'>
304 <table width='80%'>
305 <?php
306 if ($balance != "0") {
307 // $formatted = sprintf((xl('$').'%01.2f'), $balance);
308 $formatted = oeFormatMoney($balance);
309 echo " <tr class='text billing'>\n";
310 echo " <td>".$colorbeg . htmlspecialchars( xl('Balance Due'), ENT_NOQUOTES) .
311 $colorend."&nbsp;".$colorbeg. htmlspecialchars( $formatted, ENT_NOQUOTES) .
312 $colorend."</td>\n";
313 echo " </tr>\n";
316 if ($billing_note) {
317 echo " <tr class='text billing'>\n";
318 echo " <td>".$colorbeg . htmlspecialchars( xl('Billing Note'), ENT_NOQUOTES) .
319 $colorend."&nbsp;".$colorbeg . htmlspecialchars( $billing_note, ENT_NOQUOTES) .
320 $colorend."</td>\n";
321 echo " </tr>\n";
324 </table>
325 </div>
326 <br>
327 <?php } ?>
328 <ul class="tabNav">
329 <li class="<?php echo $inbox; ?>" ><a onclick="show_div('inbox')" href="#"><?php echo htmlspecialchars(xl('Inbox'),ENT_NOQUOTES); ?></a></li>
330 <li class="<?php echo $outbox; ?>" ><a onclick="show_div('outbox')" href="#"><?php echo htmlspecialchars(xl('Sent Items'),ENT_NOQUOTES); ?></a></li>
331 </ul>
332 <div class='tabContainer' >
333 <div id='inbox_div' <?php echo $inbox_style; ?> >
334 <form border='0' method='post' name='update_activity' id='update_activity'
335 action="pnotes_full.php?<?php echo $urlparms; ?>&<?php echo attr($activity_string_html);?>" onsubmit='return top.restoreSession()'>
336 <!-- start of previous notes DIV -->
337 <div class=pat_notes>
338 <input type='hidden' name='mode' value="update">
339 <input type='hidden' name='offset' id='offset' value="<?php echo $offset; ?>">
340 <input type='hidden' name='offset_sent' id='offset_sent' value="<?php echo $offset_sent; ?>">
341 <input type='hidden' name='noteid' id='noteid' value="0">
342 <table border='0' cellpadding="1" class="text">
343 <?php if ($result != ""): ?>
344 <tr>
345 <td colspan='5' style="padding: 5px;" >
346 <a href="#" class="change_activity" ><span><?php echo htmlspecialchars( xl('Update Active'), ENT_NOQUOTES); ?></span></a>
348 <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>
349 </td>
350 </tr></table>
351 <?php endif; ?>
353 <table border='0' cellpadding="1" class="text" width = "80%">
354 <?php
355 // display all of the notes for the day, as well as others that are active
356 // from previous dates, up to a certain number, $N
358 if ($result != "") {
359 echo " <tr class=showborder_head align='left'>\n";
360 echo " <th style='width:100px';>&nbsp;</th>\n";
361 echo " <th>" . xlt('Active') . "&nbsp;</th>\n";
362 echo " <th>" . (($docid || $orderid) ? xlt('Linked') : '') . "</th>\n";
363 echo " <th>" . xlt('Type') . "</th>\n";
364 echo " <th>" . xlt('Content') . "</th>\n";
365 echo " </tr>\n";
367 $result_count = 0;
368 foreach ($result as $iter) {
369 $result_count++;
370 $row_note_id = $iter['id'];
372 $linked = "";
373 if ($docid) {
374 if (isGpRelation(1, $docid, 6, $row_note_id)) {
375 $linked = "checked";
377 else {
378 // Skip unlinked notes if that is requested.
379 if ($form_doc_only) continue;
382 else if ($orderid) {
383 if (isGpRelation(2, $orderid, 6, $row_note_id)) {
384 $linked = "checked";
386 else {
387 // Skip unlinked notes if that is requested.
388 if ($form_doc_only) continue;
392 $body = $iter['body'];
393 if (preg_match('/^\d\d\d\d-\d\d-\d\d \d\d\:\d\d /', $body)) {
394 $body = nl2br(htmlspecialchars( oeFormatPatientNote($body), ENT_NOQUOTES));
395 } else {
396 $body = htmlspecialchars( oeFormatSDFT(strtotime($iter['date'])).date(' H:i', strtotime($iter['date'])), ENT_NOQUOTES) .
397 ' (' . htmlspecialchars( $iter['user'], ENT_NOQUOTES) . ') ' . nl2br(htmlspecialchars( oeFormatPatientNote($body), ENT_NOQUOTES));
399 $body = preg_replace('/(\sto\s)-patient-(\))/','${1}'.$patientname.'${2}',$body);
400 if ( ($iter{"activity"}) && ($iter['message_status'] != "Done") ) {
401 $checked = "checked";
402 } else {
403 $checked = "";
406 // highlight the row if it's been selected for updating
407 if ($_REQUEST['noteid'] == $row_note_id) {
408 echo " <tr height=20 class='noterow highlightcolor' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>\n";
410 else {
411 echo " <tr class='noterow' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>\n";
415 echo " <td><a href='pnotes_full_add.php?$urlparms&trigger=edit&noteid=".htmlspecialchars( $row_note_id, ENT_QUOTES).
416 "' class='css_button_small iframe' onclick='top.restoreSession()'><span>". htmlspecialchars( xl('Edit'), ENT_NOQUOTES) ."</span></a>\n";
418 // display, or not, a button to delete the note
419 // if the user is an admin or if they are the author of the note, they can delete it
420 if (($iter['user'] == $_SESSION['authUser']) || (acl_check('admin','super','','write'))) {
421 echo " <a href='#' class='deletenote css_button_small' id='del" . htmlspecialchars( $row_note_id, ENT_QUOTES) .
422 "' title='" . htmlspecialchars( xl('Delete this note'), ENT_QUOTES) . "' onclick='top.restoreSession()'><span>" .
423 htmlspecialchars( xl('Delete'), ENT_NOQUOTES) . "</span>\n";
425 echo " </td>\n";
428 echo " <td class='text bold'>\n";
429 echo " <input type='hidden' name='act".htmlspecialchars( $row_note_id, ENT_QUOTES)."' value='1' />\n";
430 echo " <input type='checkbox' name='chk".htmlspecialchars( $row_note_id, ENT_QUOTES)."' $checked />\n";
431 echo " </td>\n";
433 echo " <td class='text bold'>\n";
434 if ($docid || $orderid) {
435 echo " <input type='checkbox' name='lnk" . htmlspecialchars($row_note_id, ENT_QUOTES) . "' $linked />\n";
437 echo " </td>\n";
439 echo " <td class='bold notecell' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>" .
440 "<a href='pnotes_full_add.php?$urlparms&trigger=edit&noteid=".htmlspecialchars( $row_note_id, ENT_QUOTES)."' class='iframe' onclick='top.restoreSession()'>\n";
441 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
442 echo generate_display_field(array('data_type'=>'1','list_id'=>'note_type'), $iter['title']);
443 echo " </a></td>\n";
445 echo " <td class='notecell' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>\n";
446 echo " $body";
447 echo " </td>\n";
448 echo " </tr>\n";
450 $notes_count++;
452 } else {
453 //no results
454 print "<tr><td colspan='3' class='text'>" . htmlspecialchars( xl('None'), ENT_NOQUOTES) . ".</td></tr>\n";
459 </table>
460 </div>
461 </form>
463 <table width='400' border='0' cellpadding='0' cellspacing='0'>
464 <tr>
465 <td>
466 <?php
467 if ($offset > ($N-1)) {
468 echo " <a class='link' href='pnotes_full.php" .
469 "?$urlparms" .
470 "&form_active=" . htmlspecialchars( $form_active, ENT_QUOTES) .
471 "&form_inactive=" . htmlspecialchars( $form_inactive, ENT_QUOTES) .
472 "&form_doc_only=" . htmlspecialchars( $form_doc_only, ENT_QUOTES) .
473 "&offset=" . ($offset-$N) . "&" . attr($activity_string_html) . "' onclick='top.restoreSession()'>[" .
474 htmlspecialchars( xl('Previous'), ENT_NOQUOTES) . "]</a>\n";
477 </td>
478 <td align='right'>
479 <?php
480 if ($result_count == $N) {
481 echo " <a class='link' href='pnotes_full.php" .
482 "?$urlparms" .
483 "&form_active=" . htmlspecialchars( $form_active, ENT_QUOTES) .
484 "&form_inactive=" . htmlspecialchars( $form_inactive, ENT_QUOTES) .
485 "&form_doc_only=" . htmlspecialchars( $form_doc_only, ENT_QUOTES) .
486 "&offset=" . ($offset+$N) . "&" . attr($activity_string_html) . "' onclick='top.restoreSession()'>[" .
487 htmlspecialchars( xl('Next'), ENT_NOQUOTES) . "]</a>\n";
490 </td>
491 </tr>
492 </table>
494 </div>
495 <div id='outbox_div' <?php echo $outbox_style; ?> >
496 <table border='0' cellpadding="1" class="text">
497 <?php if ($result_sent != ""): ?>
498 <tr>
499 <td colspan='5' style="padding: 5px;" >
500 <a href="pnotes_full.php?<?php echo $urlparms; ?>&s=1&<?php echo attr($activity_string_html);?>"
501 class="" id='Submit' onclick='top.restoreSession()'><span><?php echo xlt('Refresh'); ?></span></a>
502 </td>
503 </tr></table>
504 <?php endif; ?>
506 <table border='0' cellpadding="1" class="text" width = "80%">
507 <?php
508 // display all of the notes for the day, as well as others that are active
509 // from previous dates, up to a certain number, $N
511 if ($result_sent != "") {
512 echo " <tr class=showborder_head align='left'>\n";
513 echo " <th style='width:100px';>&nbsp;</th>\n";
514 echo " <th>" . htmlspecialchars( xl('Active'), ENT_NOQUOTES) . "&nbsp;</th>\n";
515 echo " <th>" . (($docid || $orderid) ? htmlspecialchars( xl('Linked'), ENT_NOQUOTES) : '') . "</th>\n";
516 echo " <th>" . htmlspecialchars( xl('Type'), ENT_NOQUOTES) . "</th>\n";
517 echo " <th>" . htmlspecialchars( xl('Content'), ENT_NOQUOTES) . "</th>\n";
518 echo " </tr>\n";
520 $result_sent_count = 0;
521 foreach ($result_sent as $iter) {
522 $result_sent_count++;
523 $row_note_id = $iter['id'];
525 $linked = "";
526 if ($docid) {
527 if (isGpRelation(1, $docid, 6, $row_note_id)) {
528 $linked = "checked";
530 else {
531 // Skip unlinked notes if that is requested.
532 if ($form_doc_only) continue;
535 else if ($orderid) {
536 if (isGpRelation(2, $orderid, 6, $row_note_id)) {
537 $linked = "checked";
539 else {
540 // Skip unlinked notes if that is requested.
541 if ($form_doc_only) continue;
545 $body = $iter['body'];
546 if (preg_match('/^\d\d\d\d-\d\d-\d\d \d\d\:\d\d /', $body)) {
547 $body = nl2br(htmlspecialchars( oeFormatPatientNote($body), ENT_NOQUOTES));
548 } else {
549 $body = htmlspecialchars( oeFormatSDFT(strtotime($iter['date'])).date(' H:i', strtotime($iter['date'])), ENT_NOQUOTES) .
550 ' (' . htmlspecialchars( $iter['user'], ENT_NOQUOTES) . ') ' . nl2br(htmlspecialchars( oeFormatPatientNote($body), ENT_NOQUOTES));
552 $body = preg_replace('/(:\d{2}\s\()' . $patient_id . '(\sto\s)/','${1}' . $patientname . '${2}', $body);
553 if (($iter{"activity"}) && ($iter['message_status'] != "Done") ) {
554 $checked = "checked";
555 } else {
556 $checked = "";
559 // highlight the row if it's been selected for updating
560 if ($_REQUEST['noteid'] == $row_note_id) {
561 echo " <tr height=20 class='noterow highlightcolor' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>\n";
563 else {
564 echo " <tr class='noterow' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>\n";
568 echo " <td><a href='pnotes_full_add.php?$urlparms&trigger=edit&noteid=".htmlspecialchars( $row_note_id, ENT_QUOTES).
569 "' class='css_button_small iframe' onclick='top.restoreSession()'><span>". htmlspecialchars( xl('Edit'), ENT_NOQUOTES) ."</span></a>\n";
571 // display, or not, a button to delete the note
572 // if the user is an admin or if they are the author of the note, they can delete it
573 if (($iter['user'] == $_SESSION['authUser']) || (acl_check('admin','super','','write'))) {
574 echo " <a href='#' class='deletenote css_button_small' id='del" . htmlspecialchars( $row_note_id, ENT_QUOTES) .
575 "' title='" . htmlspecialchars( xl('Delete this note'), ENT_QUOTES) . "' onclick='top.restoreSession()'><span>" .
576 htmlspecialchars( xl('Delete'), ENT_NOQUOTES) . "</span>\n";
578 echo " </td>\n";
581 echo " <td class='text bold'>\n";
582 echo " <input type='hidden' name='act".htmlspecialchars( $row_note_id, ENT_QUOTES)."' value='1' />\n";
583 echo " <input type='checkbox' name='chk".htmlspecialchars( $row_note_id, ENT_QUOTES)."' $checked />\n";
584 echo " </td>\n";
586 echo " <td class='text bold'>\n";
587 if ($docid || $orderid) {
588 echo " <input type='checkbox' name='lnk" . htmlspecialchars($row_note_id, ENT_QUOTES) . "' $linked />\n";
590 echo " </td>\n";
592 echo " <td class='bold notecell' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>" .
593 "<a href='pnotes_full_add.php?$urlparms&trigger=edit&noteid=".htmlspecialchars( $row_note_id, ENT_QUOTES)."' class='iframe' onclick='top.restoreSession()'>\n";
594 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
595 echo generate_display_field(array('data_type'=>'1','list_id'=>'note_type'), $iter['title']);
596 echo " </a></td>\n";
598 echo " <td class='notecell' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>\n";
599 echo " $body";
600 echo " </td>\n";
601 echo " </tr>\n";
603 $notes_sent_count++;
605 } else {
606 //no results
607 print "<tr><td colspan='3' class='text'>" . htmlspecialchars( xl('None'), ENT_NOQUOTES) . ".</td></tr>\n";
612 </table>
614 <table width='400' border='0' cellpadding='0' cellspacing='0'>
615 <tr>
616 <td>
617 <?php
618 if ($offset_sent > ($M-1)) {
619 echo " <a class='link' href='pnotes_full.php" .
620 "?$urlparms" .
621 "&s=1" .
622 "&form_active=" . htmlspecialchars( $form_active, ENT_QUOTES) .
623 "&form_inactive=" . htmlspecialchars( $form_inactive, ENT_QUOTES) .
624 "&form_doc_only=" . htmlspecialchars( $form_doc_only, ENT_QUOTES) .
625 "&offset_sent=" . ($offset_sent-$M) . "&" . attr($activity_string_html) . "' onclick='top.restoreSession()'>[" .
626 htmlspecialchars( xl('Previous'), ENT_NOQUOTES) . "]</a>\n";
629 </td>
630 <td align='right'>
631 <?php
632 if ($result_sent_count == $M) {
633 echo " <a class='link' href='pnotes_full.php" .
634 "?$urlparms" .
635 "&s=1" .
636 "&form_active=" . htmlspecialchars( $form_active, ENT_QUOTES) .
637 "&form_inactive=" . htmlspecialchars( $form_inactive, ENT_QUOTES) .
638 "&form_doc_only=" . htmlspecialchars( $form_doc_only, ENT_QUOTES) .
639 "&offset_sent=" . ($offset_sent+$M) . "&" . attr($activity_string_html) . "' onclick='top.restoreSession()'>[" .
640 htmlspecialchars( xl('Next'), ENT_NOQUOTES) . "]</a>\n";
643 </td>
644 </tr>
645 </table>
647 </div>
648 </div>
649 <script language='JavaScript'>
651 <?php
652 if ($GLOBALS['concurrent_layout'] && $_GET['set_pid']) {
653 $ndata = getPatientData($patient_id, "fname, lname, pubpid");
655 parent.left_nav.setPatient(<?php echo "'" . htmlspecialchars( $ndata['fname']." ".$ndata['lname'], ENT_QUOTES) . "'," .
656 htmlspecialchars( $patient_id, ENT_QUOTES) . ",'" . htmlspecialchars( $ndata['pubpid'], ENT_QUOTES) . "',window.name"; ?>);
657 parent.left_nav.setRadio(window.name, 'pno');
658 <?php
661 // If this note references a new patient document, pop up a display
662 // of that document.
664 if ($noteid /* && $title == 'New Document' */ ) {
665 $prow = getPnoteById($noteid, 'body');
666 if (preg_match('/New scanned document (\d+): [^\n]+\/([^\n]+)/', $prow['body'], $matches)) {
667 $docid = $matches[1];
668 $docname = $matches[2];
670 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',
671 '_blank', 'resizable=1,scrollbars=1,width=600,height=500');
672 <?php
677 </script>
679 </div> <!-- end outer 'pnotes' -->
681 </body>
683 <script language="javascript">
685 // jQuery stuff to make the page a little easier to use
687 $(document).ready(function(){
688 $("#appendnote").click(function() { AppendNote(); });
689 $("#newnote").click(function() { NewNote(); });
690 $("#printnote").click(function() { PrintNote(); });
692 $(".change_activity").click(function() { top.restoreSession(); $("#update_activity").submit(); });
694 $(".deletenote").click(function() { DeleteNote(this); });
696 $(".noterow").mouseover(function() { $(this).toggleClass("highlight"); });
697 $(".noterow").mouseout(function() { $(this).toggleClass("highlight"); });
698 $(".notecell").click(function() { EditNote(this); });
700 $("#note").focus();
702 var EditNote = function(note) {
703 top.restoreSession();
704 $("#noteid").val(note.id);
705 $("#mode").val("");
706 $("#new_note").submit();
709 var NewNote = function () {
710 top.restoreSession();
711 $("#noteid").val('');
712 $("#new_note").submit();
715 var AppendNote = function () {
716 top.restoreSession();
717 $("#new_note").submit();
720 var PrintNote = function () {
721 top.restoreSession();
722 window.open('pnotes_print.php?noteid=<?php echo htmlspecialchars( $noteid, ENT_QUOTES); ?>', '_blank', 'resizable=1,scrollbars=1,width=600,height=500');
725 var DeleteNote = function(note) {
726 if (confirm("<?php echo htmlspecialchars( xl('Are you sure you want to delete this note?','','','\n '), ENT_QUOTES) .
727 htmlspecialchars( xl('This action CANNOT be undone.'), ENT_QUOTES); ?>")) {
728 top.restoreSession();
729 // strip the 'del' part of the object's ID
730 $("#noteid").val(note.id.replace(/del/, ""));
731 $("#mode").val("delete");
732 $("#new_note").submit();
738 </script>
740 </html>