Fixed multiple bugs in linking patient notes to documents.
[openemr.git] / interface / patient_file / summary / pnotes_full.php
blobb952d30620b03c170c04792f39b59301d68b76bb
1 <?php
2 /**
3 * pnotes_full.php -- display patient notes.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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 // Check authorization.
44 if (!acl_check('patients','notes','',array('write','addonly') ))
45 die(htmlspecialchars( xl('Not authorized'), ENT_NOQUOTES));
46 $tmp = getPatientData($pid, "squad");
47 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad']))
48 die(htmlspecialchars( xl('Not authorized for this squad.'), ENT_NOQUOTES));
50 //the number of records to display per screen
51 $N = 15;
52 $M = 15;
54 $mode = $_REQUEST['mode'];
55 $offset = $_REQUEST['offset'];
56 $offset_sent = $_REQUEST['offset_sent'];
57 $form_active = $_REQUEST['form_active'];
58 $form_inactive = $_REQUEST['form_inactive'];
59 $noteid = $_REQUEST['noteid'];
60 $form_doc_only = isset($_POST['mode']) ? (empty($_POST['form_doc_only']) ? 0 : 1) : 1;
61 if($_REQUEST['s'] == '1'){
62 $inbox = "";
63 $outbox = "current";
64 $inbox_style = "style='display:none;border:5px solid #FFFFFF;'";
65 $outbox_style = "style='border:5px solid #FFFFFF;'";
66 }else{
67 $inbox = "current";
68 $outbox = "";
69 $inbox_style = "style='border:5px solid #FFFFFF;'";;
70 $outbox_style = "style='display:none;border:5px solid #FFFFFF;'";
73 if (!isset($offset)) $offset = 0;
74 if (!isset($offset_sent)) $offset_sent = 0;
76 // Collect active variable and applicable html code for links
77 if ($form_active) {
78 $active = '1';
79 $activity_string_html = 'form_active=1';
81 else if ($form_inactive) {
82 $active = '0';
83 $activity_string_html = 'form_inactive=1';
85 else {
86 $active = 'all';
87 $activity_string_html = '';
88 $form_active = $form_inactive = '1';
91 // form parameter docid can be passed to restrict the display to a document.
92 $docid = empty($_REQUEST['docid']) ? 0 : 0 + $_REQUEST['docid'];
94 // this code handles changing the state of activity tags when the user updates
95 // them through the interface
96 if (isset($mode)) {
97 if ($mode == "update") {
98 foreach ($_POST as $var => $val) {
99 if (strncmp($var, 'act', 3) == 0) {
100 $id = str_replace("act", "", $var);
101 if ($_POST["chk$id"]) {
102 reappearPnote($id);
103 } else {
104 disappearPnote($id);
106 if ($docid) {
107 setGpRelation(1, $docid, 6, $id, !empty($_POST["lnk$id"]));
112 elseif ($mode == "new") {
113 $note = $_POST['note'];
114 if ($noteid) {
115 updatePnote($noteid, $note, $_POST['form_note_type'], $_POST['assigned_to']);
117 else {
118 $noteid = addPnote($pid, $note, $userauthorized, '1',
119 $_POST['form_note_type'], $_POST['assigned_to']);
121 if ($docid) {
122 setGpRelation(1, $docid, 6, $noteid);
124 $noteid = '';
126 elseif ($mode == "delete") {
127 if ($noteid) {
128 deletePnote($noteid);
129 newEvent("delete", $_SESSION['authUser'], $_SESSION['authProvider'], 1, "pnotes: id ".$noteid);
131 $noteid = '';
135 $title = '';
136 $assigned_to = $_SESSION['authUser'];
137 if ($noteid) {
138 $prow = getPnoteById($noteid, 'title,assigned_to,body');
139 $title = $prow['title'];
140 $assigned_to = $prow['assigned_to'];
143 // Get the users list. The "Inactive" test is a kludge, we should create
144 // a separate column for this.
145 $ures = sqlStatement("SELECT username, fname, lname FROM users " .
146 "WHERE username != '' AND active = 1 AND " .
147 "( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
148 "ORDER BY lname, fname");
150 $pres = getPatientData($pid, "lname, fname");
151 $patientname = $pres['lname'] . ", " . $pres['fname'];
153 //retrieve all notes
154 $result = getPnotesByDate("", $active, 'id,date,body,user,activity,title,assigned_to,message_status',
155 $pid, $N, $offset);
156 $result_sent = getSentPnotesByDate("", $active, 'id,date,body,user,activity,title,assigned_to,message_status',
157 $pid, $M, $offset_sent);
160 <html>
161 <head>
162 <?php html_header_show();?>
164 <link rel='stylesheet' href="<?php echo $css_header;?>" type="text/css">
166 <!-- supporting javascript code -->
167 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script>
168 <link rel="stylesheet" type="text/css" href="../../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
169 <script type="text/javascript" src="../../../library/dialog.js"></script>
170 <script type="text/javascript" src="../../../library/js/jquery.1.3.2.js"></script>
171 <script type="text/javascript" src="../../../library/js/common.js"></script>
172 <script type="text/javascript" src="../../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
173 <script type="text/javascript">
174 /// todo, move this to a common library
176 $(document).ready(function(){
178 $("#dem_view").click( function() {
179 toggle( $(this), "#DEM" );
182 // load divs
183 $("#stats_div").load("stats.php");
184 $("#notes_div").load("pnotes_fragment.php");
186 // fancy box
187 enable_modals();
188 tabbify();
190 function show_div(name){
191 if(name == 'inbox'){
192 document.getElementById('inbox_div').style.display = '';
193 document.getElementById('outbox_div').style.display = 'none';
194 }else{
195 document.getElementById('inbox_div').style.display = 'none';
196 document.getElementById('outbox_div').style.display = '';
199 </script>
200 </head>
201 <body class="body_top">
203 <div id="pnotes"> <!-- large outer DIV -->
205 <form border='0' method='post' name='new_note' id="new_note" action='pnotes_full.php?docid=<?php echo htmlspecialchars( $docid, ENT_QUOTES); ?>&<?php echo attr($activity_string_html);?>'>
207 <?php
208 $title_docname = "";
209 if ($docid) {
210 $title_docname = " " . xl("linked to document") . " ";
211 $d = new Document($docid);
212 $title_docname .= $d->get_url_file();
216 <div>
217 <span class="title"><?php echo xlt('Patient Notes') . $title_docname; ?></span>
218 </div>
219 <div style='float:left;margin-right:10px'>
220 <?php echo htmlspecialchars( xl('for'), ENT_NOQUOTES);?>&nbsp;<span class="title">
221 <a href="../summary/demographics.php" onclick="top.restoreSession()"><?php echo htmlspecialchars( getPatientName($pid), ENT_NOQUOTES); ?></a></span>
222 </div>
223 <div>
224 <a href="pnotes_full_add.php?docid=<?php echo attr($docid); ?>" class="css_button iframe"><span><?php echo xlt('Add'); ?></span></a>
225 <a href="demographics.php" <?php if (!$GLOBALS['concurrent_layout']) echo "target='Main'"; ?> class="css_button" onclick="top.restoreSession()">
226 <span><?php echo htmlspecialchars( xl('View Patient'), ENT_NOQUOTES);?></span>
227 </a>
228 </div>
229 <br/>
230 <br/>
231 <div>
232 <?php if ($active == "all") { ?>
233 <span><?php echo xlt('Show All'); ?></span>
234 <?php } else { ?>
235 <a href="pnotes_full.php?docid=<?php echo attr($docid); ?>" class="link" onclick="top.restoreSession()"><span><?php echo xlt('Show All'); ?></span></a>
236 <?php } ?>
238 <?php if ($active == '1') { ?>
239 <span><?php echo xlt('Show Active'); ?></span>
240 <?php } else { ?>
241 <a href="pnotes_full.php?form_active=1&docid=<?php echo attr($docid); ?>" class="link" onclick="top.restoreSession()"><span><?php echo xlt('Show Active'); ?></span></a>
242 <?php } ?>
244 <?php if ($active == '0') { ?>
245 <span><?php echo xlt('Show Inactive'); ?></span>
246 <?php } else { ?>
247 <a href="pnotes_full.php?form_inactive=1&docid=<?php echo attr($docid); ?>" class="link" onclick="top.restoreSession()"><span><?php echo xlt('Show Inactive'); ?></span></a>
248 <?php } ?>
249 </div>
251 <input type='hidden' name='mode' id="mode" value="new">
252 <input type='hidden' name='offset' id="offset" value="<?php echo $offset; ?>">
253 <input type='hidden' name='offset_sent' id="offset_sent" value="<?php echo $offset_sent; ?>">
254 <input type='hidden' name='form_active' id="form_active" value="<?php echo htmlspecialchars( $form_active, ENT_QUOTES); ?>">
255 <input type='hidden' name='form_inactive' id="form_inactive" value="<?php echo htmlspecialchars( $form_inactive, ENT_QUOTES); ?>">
256 <input type='hidden' name='noteid' id="noteid" value="<?php echo htmlspecialchars( $noteid, ENT_QUOTES); ?>">
257 <input type='hidden' name='form_doc_only' id="form_doc_only" value="<?php echo htmlspecialchars( $form_doc_only, ENT_QUOTES); ?>">
258 </form>
261 <?php
262 // Get the billing note if there is one.
263 $billing_note = "";
264 $colorbeg = "";
265 $colorend = "";
266 $resnote = getPatientData($pid, "genericname2, genericval2");
267 if($resnote && $resnote['genericname2'] == 'Billing') {
268 $billing_note = $resnote['genericval2'];
269 $colorbeg = "<span style='color:red'>";
270 $colorend = "</span>";
273 //Display what the patient owes
274 $balance = get_patient_balance($pid);
277 <?php if ($billing_note || $balance ) { ?>
279 <div style='margin-top:3px'>
280 <table width='80%'>
281 <?php
282 if ($balance != "0") {
283 // $formatted = sprintf((xl('$').'%01.2f'), $balance);
284 $formatted = oeFormatMoney($balance);
285 echo " <tr class='text billing'>\n";
286 echo " <td>".$colorbeg . htmlspecialchars( xl('Balance Due'), ENT_NOQUOTES) .
287 $colorend."&nbsp;".$colorbeg. htmlspecialchars( $formatted, ENT_NOQUOTES) .
288 $colorend."</td>\n";
289 echo " </tr>\n";
292 if ($billing_note) {
293 echo " <tr class='text billing'>\n";
294 echo " <td>".$colorbeg . htmlspecialchars( xl('Billing Note'), ENT_NOQUOTES) .
295 $colorend."&nbsp;".$colorbeg . htmlspecialchars( $billing_note, ENT_NOQUOTES) .
296 $colorend."</td>\n";
297 echo " </tr>\n";
300 </table>
301 </div>
302 <br>
303 <?php } ?>
304 <ul class="tabNav">
305 <li class="<?php echo $inbox; ?>" ><a onclick="show_div('inbox')" href="#"><?php echo htmlspecialchars(xl('Inbox'),ENT_NOQUOTES); ?></a></li>
306 <li class="<?php echo $outbox; ?>" ><a onclick="show_div('outbox')" href="#"><?php echo htmlspecialchars(xl('Sent Items'),ENT_NOQUOTES); ?></a></li>
307 </ul>
308 <div class='tabContainer' >
309 <div id='inbox_div' <?php echo $inbox_style; ?> >
310 <form border='0' method='post' name='update_activity' id='update_activity'
311 action="pnotes_full.php?docid=<?php echo htmlspecialchars( $docid, ENT_QUOTES); ?>&<?php echo attr($activity_string_html);?>">
312 <!-- start of previous notes DIV -->
313 <div class=pat_notes>
314 <input type='hidden' name='mode' value="update">
315 <input type='hidden' name='offset' id='offset' value="<?php echo $offset; ?>">
316 <input type='hidden' name='offset_sent' id='offset_sent' value="<?php echo $offset_sent; ?>">
317 <input type='hidden' name='noteid' id='noteid' value="0">
318 <table border='0' cellpadding="1" class="text">
319 <?php if ($result != ""): ?>
320 <tr>
321 <td colspan='5' style="padding: 5px;" >
322 <a href="#" class="change_activity" ><span><?php echo htmlspecialchars( xl('Update Active'), ENT_NOQUOTES); ?></span></a>
324 <a href="pnotes_full.php?docid=<?php echo attr($docid); ?>&<?php echo attr($activity_string_html);?>" class="" id='Submit'><span><?php echo htmlspecialchars( xl('Refresh'), ENT_NOQUOTES); ?></span></a>
325 </td>
326 </tr></table>
327 <?php endif; ?>
329 <table border='0' cellpadding="1" class="text" width = "80%">
330 <?php
331 // display all of the notes for the day, as well as others that are active
332 // from previous dates, up to a certain number, $N
334 if ($result != "") {
335 echo " <tr class=showborder_head align='left'>\n";
336 echo " <th style='width:100px';>&nbsp;</th>\n";
337 echo " <th>" . htmlspecialchars( xl('Active'), ENT_NOQUOTES) . "&nbsp;</th>\n";
338 echo " <th>" . ($docid ? htmlspecialchars( xl('Linked'), ENT_NOQUOTES) : '') . "</th>\n";
339 echo " <th>" . htmlspecialchars( xl('Type'), ENT_NOQUOTES) . "</th>\n";
340 echo " <th>" . htmlspecialchars( xl('Content'), ENT_NOQUOTES) . "</th>\n";
341 echo " </tr>\n";
343 $result_count = 0;
344 foreach ($result as $iter) {
345 $result_count++;
346 $row_note_id = $iter['id'];
348 $linked = "";
349 if ($docid) {
350 if (isGpRelation(1, $docid, 6, $row_note_id)) {
351 $linked = "checked";
353 else {
354 // Skip unlinked notes if that is requested.
355 if ($form_doc_only) continue;
359 $body = $iter['body'];
360 if (preg_match('/^\d\d\d\d-\d\d-\d\d \d\d\:\d\d /', $body)) {
361 $body = nl2br(htmlspecialchars( oeFormatPatientNote($body), ENT_NOQUOTES));
362 } else {
363 $body = htmlspecialchars( oeFormatSDFT(strtotime($iter['date'])).date(' H:i', strtotime($iter['date'])), ENT_NOQUOTES) .
364 ' (' . htmlspecialchars( $iter['user'], ENT_NOQUOTES) . ') ' . nl2br(htmlspecialchars( oeFormatPatientNote($body), ENT_NOQUOTES));
366 $body = preg_replace('/(\sto\s)-patient-(\))/','${1}'.$patientname.'${2}',$body);
367 if ( ($iter{"activity"}) && ($iter['message_status'] != "Done") ) {
368 $checked = "checked";
369 } else {
370 $checked = "";
373 // highlight the row if it's been selected for updating
374 if ($_REQUEST['noteid'] == $row_note_id) {
375 echo " <tr height=20 class='noterow highlightcolor' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>\n";
377 else {
378 echo " <tr class='noterow' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>\n";
382 echo " <td><a href='pnotes_full_add.php?trigger=edit&noteid=".htmlspecialchars( $row_note_id, ENT_QUOTES).
383 "' class='css_button_small iframe'><span>". htmlspecialchars( xl('Edit'), ENT_NOQUOTES) ."</span></a>\n";
385 // display, or not, a button to delete the note
386 // if the user is an admin or if they are the author of the note, they can delete it
387 if (($iter['user'] == $_SESSION['authUser']) || (acl_check('admin','super','','write'))) {
388 echo " <a href='#' class='deletenote css_button_small' id='del" . htmlspecialchars( $row_note_id, ENT_QUOTES) .
389 "' title='" . htmlspecialchars( xl('Delete this note'), ENT_QUOTES) . "'><span>" .
390 htmlspecialchars( xl('Delete'), ENT_NOQUOTES) . "</span>\n";
392 echo " </td>\n";
395 echo " <td class='text bold'>\n";
396 echo " <input type='hidden' name='act".htmlspecialchars( $row_note_id, ENT_QUOTES)."' value='1' />\n";
397 echo " <input type='checkbox' name='chk".htmlspecialchars( $row_note_id, ENT_QUOTES)."' $checked />\n";
398 echo " </td>\n";
400 echo " <td class='text bold'>\n";
401 if ($docid) {
402 echo " <input type='checkbox' name='lnk".htmlspecialchars( $row_note_id, ENT_QUOTES)."' $linked />\n";
404 echo " </td>\n";
406 echo " <td class='bold notecell' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>" .
407 "<a href='pnotes_full_add.php?trigger=edit&noteid=".htmlspecialchars( $row_note_id, ENT_QUOTES)."' class='iframe'>\n";
408 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
409 echo generate_display_field(array('data_type'=>'1','list_id'=>'note_type'), $iter['title']);
410 echo " </a></td>\n";
412 echo " <td class='notecell' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>\n";
413 echo " $body";
414 echo " </td>\n";
415 echo " </tr>\n";
417 $notes_count++;
419 } else {
420 //no results
421 print "<tr><td colspan='3' class='text'>" . htmlspecialchars( xl('None'), ENT_NOQUOTES) . ".</td></tr>\n";
426 </table>
427 </div>
428 </form>
430 <table width='400' border='0' cellpadding='0' cellspacing='0'>
431 <tr>
432 <td>
433 <?php
434 if ($offset > ($N-1)) {
435 echo " <a class='link' href='pnotes_full.php" .
436 "?docid=" . htmlspecialchars( $docid, ENT_QUOTES) .
437 "&form_active=" . htmlspecialchars( $form_active, ENT_QUOTES) .
438 "&form_inactive=" . htmlspecialchars( $form_inactive, ENT_QUOTES) .
439 "&form_doc_only=" . htmlspecialchars( $form_doc_only, ENT_QUOTES) .
440 "&offset=" . ($offset-$N) . "&" . attr($activity_string_html) . "' onclick='top.restoreSession()'>[" .
441 htmlspecialchars( xl('Previous'), ENT_NOQUOTES) . "]</a>\n";
444 </td>
445 <td align='right'>
446 <?php
447 if ($result_count == $N) {
448 echo " <a class='link' href='pnotes_full.php" .
449 "?docid=" . htmlspecialchars( $docid, ENT_QUOTES) .
450 "&form_active=" . htmlspecialchars( $form_active, ENT_QUOTES) .
451 "&form_inactive=" . htmlspecialchars( $form_inactive, ENT_QUOTES) .
452 "&form_doc_only=" . htmlspecialchars( $form_doc_only, ENT_QUOTES) .
453 "&offset=" . ($offset+$N) . "&" . attr($activity_string_html) . "' onclick='top.restoreSession()'>[" .
454 htmlspecialchars( xl('Next'), ENT_NOQUOTES) . "]</a>\n";
457 </td>
458 </tr>
459 </table>
461 </div>
462 <div id='outbox_div' <?php echo $outbox_style; ?> >
463 <table border='0' cellpadding="1" class="text">
464 <?php if ($result_sent != ""): ?>
465 <tr>
466 <td colspan='5' style="padding: 5px;" >
467 <a href="pnotes_full.php?docid=<?php echo attr($docid); ?>&s=1&<?php echo attr($activity_string_html);?>"
468 class="" id='Submit'><span><?php echo xlt('Refresh'); ?></span></a>
469 </td>
470 </tr></table>
471 <?php endif; ?>
473 <table border='0' cellpadding="1" class="text" width = "80%">
474 <?php
475 // display all of the notes for the day, as well as others that are active
476 // from previous dates, up to a certain number, $N
478 if ($result_sent != "") {
479 echo " <tr class=showborder_head align='left'>\n";
480 echo " <th style='width:100px';>&nbsp;</th>\n";
481 echo " <th>" . htmlspecialchars( xl('Active'), ENT_NOQUOTES) . "&nbsp;</th>\n";
482 echo " <th>" . ($docid ? htmlspecialchars( xl('Linked'), ENT_NOQUOTES) : '') . "</th>\n";
483 echo " <th>" . htmlspecialchars( xl('Type'), ENT_NOQUOTES) . "</th>\n";
484 echo " <th>" . htmlspecialchars( xl('Content'), ENT_NOQUOTES) . "</th>\n";
485 echo " </tr>\n";
487 $result_sent_count = 0;
488 foreach ($result_sent as $iter) {
489 $result_sent_count++;
490 $row_note_id = $iter['id'];
492 $linked = "";
493 if ($docid) {
494 if (isGpRelation(1, $docid, 6, $row_note_id)) {
495 $linked = "checked";
497 else {
498 // Skip unlinked notes if that is requested.
499 if ($form_doc_only) continue;
503 $body = $iter['body'];
504 if (preg_match('/^\d\d\d\d-\d\d-\d\d \d\d\:\d\d /', $body)) {
505 $body = nl2br(htmlspecialchars( oeFormatPatientNote($body), ENT_NOQUOTES));
506 } else {
507 $body = htmlspecialchars( oeFormatSDFT(strtotime($iter['date'])).date(' H:i', strtotime($iter['date'])), ENT_NOQUOTES) .
508 ' (' . htmlspecialchars( $iter['user'], ENT_NOQUOTES) . ') ' . nl2br(htmlspecialchars( oeFormatPatientNote($body), ENT_NOQUOTES));
510 $body = preg_replace('/(:\d{2}\s\()'.$pid.'(\sto\s)/','${1}'.$patientname.'${2}',$body);
511 if (($iter{"activity"}) && ($iter['message_status'] != "Done") ) {
512 $checked = "checked";
513 } else {
514 $checked = "";
517 // highlight the row if it's been selected for updating
518 if ($_REQUEST['noteid'] == $row_note_id) {
519 echo " <tr height=20 class='noterow highlightcolor' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>\n";
521 else {
522 echo " <tr class='noterow' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>\n";
526 echo " <td><a href='pnotes_full_add.php?trigger=edit&noteid=".htmlspecialchars( $row_note_id, ENT_QUOTES).
527 "' class='css_button_small iframe'><span>". htmlspecialchars( xl('Edit'), ENT_NOQUOTES) ."</span></a>\n";
529 // display, or not, a button to delete the note
530 // if the user is an admin or if they are the author of the note, they can delete it
531 if (($iter['user'] == $_SESSION['authUser']) || (acl_check('admin','super','','write'))) {
532 echo " <a href='#' class='deletenote css_button_small' id='del" . htmlspecialchars( $row_note_id, ENT_QUOTES) .
533 "' title='" . htmlspecialchars( xl('Delete this note'), ENT_QUOTES) . "'><span>" .
534 htmlspecialchars( xl('Delete'), ENT_NOQUOTES) . "</span>\n";
536 echo " </td>\n";
539 echo " <td class='text bold'>\n";
540 echo " <input type='hidden' name='act".htmlspecialchars( $row_note_id, ENT_QUOTES)."' value='1' />\n";
541 echo " <input type='checkbox' name='chk".htmlspecialchars( $row_note_id, ENT_QUOTES)."' $checked />\n";
542 echo " </td>\n";
544 echo " <td class='text bold'>\n";
545 if ($docid) {
546 echo " <input type='checkbox' name='lnk".htmlspecialchars( $row_note_id, ENT_QUOTES)."' $linked />\n";
548 echo " </td>\n";
550 echo " <td class='bold notecell' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>" .
551 "<a href='pnotes_full_add.php?trigger=edit&noteid=".htmlspecialchars( $row_note_id, ENT_QUOTES)."' class='iframe'>\n";
552 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
553 echo generate_display_field(array('data_type'=>'1','list_id'=>'note_type'), $iter['title']);
554 echo " </a></td>\n";
556 echo " <td class='notecell' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>\n";
557 echo " $body";
558 echo " </td>\n";
559 echo " </tr>\n";
561 $notes_sent_count++;
563 } else {
564 //no results
565 print "<tr><td colspan='3' class='text'>" . htmlspecialchars( xl('None'), ENT_NOQUOTES) . ".</td></tr>\n";
570 </table>
572 <table width='400' border='0' cellpadding='0' cellspacing='0'>
573 <tr>
574 <td>
575 <?php
576 if ($offset_sent > ($M-1)) {
577 echo " <a class='link' href='pnotes_full.php" .
578 "?docid=" . htmlspecialchars( $docid, ENT_QUOTES) .
579 "&s=1" .
580 "&form_active=" . htmlspecialchars( $form_active, ENT_QUOTES) .
581 "&form_inactive=" . htmlspecialchars( $form_inactive, ENT_QUOTES) .
582 "&form_doc_only=" . htmlspecialchars( $form_doc_only, ENT_QUOTES) .
583 "&offset_sent=" . ($offset_sent-$M) . "&" . attr($activity_string_html) . "' onclick='top.restoreSession()'>[" .
584 htmlspecialchars( xl('Previous'), ENT_NOQUOTES) . "]</a>\n";
587 </td>
588 <td align='right'>
589 <?php
590 if ($result_sent_count == $M) {
591 echo " <a class='link' href='pnotes_full.php" .
592 "?docid=" . htmlspecialchars( $docid, ENT_QUOTES) .
593 "&s=1" .
594 "&form_active=" . htmlspecialchars( $form_active, ENT_QUOTES) .
595 "&form_inactive=" . htmlspecialchars( $form_inactive, ENT_QUOTES) .
596 "&form_doc_only=" . htmlspecialchars( $form_doc_only, ENT_QUOTES) .
597 "&offset_sent=" . ($offset_sent+$M) . "&" . attr($activity_string_html) . "' onclick='top.restoreSession()'>[" .
598 htmlspecialchars( xl('Next'), ENT_NOQUOTES) . "]</a>\n";
601 </td>
602 </tr>
603 </table>
605 </div>
606 </div>
607 <script language='JavaScript'>
609 <?php
610 if ($GLOBALS['concurrent_layout'] && $_GET['set_pid']) {
611 $ndata = getPatientData($pid, "fname, lname, pubpid");
613 parent.left_nav.setPatient(<?php echo "'" . htmlspecialchars( $ndata['fname']." ".$ndata['lname'], ENT_QUOTES) . "'," .
614 htmlspecialchars( $pid, ENT_QUOTES) . ",'" . htmlspecialchars( $ndata['pubpid'], ENT_QUOTES) . "',window.name"; ?>);
615 parent.left_nav.setRadio(window.name, 'pno');
616 <?php
619 // If this note references a new patient document, pop up a display
620 // of that document.
622 if ($noteid /* && $title == 'New Document' */ ) {
623 $prow = getPnoteById($noteid, 'body');
624 if (preg_match('/New scanned document (\d+): [^\n]+\/([^\n]+)/', $prow['body'], $matches)) {
625 $docid = $matches[1];
626 $docname = $matches[2];
628 window.open('../../../controller.php?document&retrieve&patient_id=<?php echo htmlspecialchars( $pid, ENT_QUOTES); ?>&document_id=<?php echo htmlspecialchars( $docid, ENT_QUOTES); ?>&<?php echo htmlspecialchars( $docname, ENT_QUOTES);?>&as_file=true',
629 '_blank', 'resizable=1,scrollbars=1,width=600,height=500');
630 <?php
635 </script>
637 </div> <!-- end outer 'pnotes' -->
639 </body>
641 <script language="javascript">
643 // jQuery stuff to make the page a little easier to use
645 $(document).ready(function(){
646 $("#appendnote").click(function() { AppendNote(); });
647 $("#newnote").click(function() { NewNote(); });
648 $("#printnote").click(function() { PrintNote(); });
650 $(".change_activity").click(function() { top.restoreSession(); $("#update_activity").submit(); });
652 $(".deletenote").click(function() { DeleteNote(this); });
654 $(".noterow").mouseover(function() { $(this).toggleClass("highlight"); });
655 $(".noterow").mouseout(function() { $(this).toggleClass("highlight"); });
656 $(".notecell").click(function() { EditNote(this); });
658 $("#note").focus();
660 var EditNote = function(note) {
661 top.restoreSession();
662 $("#noteid").val(note.id);
663 $("#mode").val("");
664 $("#new_note").submit();
667 var NewNote = function () {
668 top.restoreSession();
669 $("#noteid").val('');
670 $("#new_note").submit();
673 var AppendNote = function () {
674 top.restoreSession();
675 $("#new_note").submit();
678 var PrintNote = function () {
679 top.restoreSession();
680 window.open('pnotes_print.php?noteid=<?php echo htmlspecialchars( $noteid, ENT_QUOTES); ?>', '_blank', 'resizable=1,scrollbars=1,width=600,height=500');
683 var DeleteNote = function(note) {
684 if (confirm("<?php echo htmlspecialchars( xl('Are you sure you want to delete this note?','','','\n '), ENT_QUOTES) .
685 htmlspecialchars( xl('This action CANNOT be undone.'), ENT_QUOTES); ?>")) {
686 top.restoreSession();
687 // strip the 'del' part of the object's ID
688 $("#noteid").val(note.id.replace(/del/, ""));
689 $("#mode").val("delete");
690 $("#new_note").submit();
696 </script>
699 </html>