The Third Reminders email bug fix - contributed by arnabnaha
[openemr.git] / interface / patient_file / summary / pnotes_full.php
blobd876dfec10d0b4830b36488a53646d0e1dbff9c7
1 <?php
2 // This program is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU General Public License
4 // as published by the Free Software Foundation; either version 2
5 // of the License, or (at your option) any later version.
7 //SANITIZE ALL ESCAPES
8 $sanitize_all_escapes=true;
9 //
11 //STOP FAKE REGISTER GLOBALS
12 $fake_register_globals=false;
15 require_once("../../globals.php");
16 require_once("$srcdir/pnotes.inc");
17 require_once("$srcdir/patient.inc");
18 require_once("$srcdir/acl.inc");
19 require_once("$srcdir/log.inc");
20 require_once("$srcdir/options.inc.php");
21 require_once("$srcdir/classes/Document.class.php");
22 require_once("$srcdir/gprelations.inc.php");
23 require_once("$srcdir/formatting.inc.php");
25 if ($GLOBALS['concurrent_layout'] && $_GET['set_pid']) {
26 require_once("$srcdir/pid.inc");
27 setpid($_GET['set_pid']);
30 // Check authorization.
31 if (!acl_check('patients','notes','',array('write','addonly') ))
32 die(htmlspecialchars( xl('Not authorized'), ENT_NOQUOTES));
33 $tmp = getPatientData($pid, "squad");
34 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad']))
35 die(htmlspecialchars( xl('Not authorized for this squad.'), ENT_NOQUOTES));
37 //the number of records to display per screen
38 $N = 15;
39 $M = 15;
41 $mode = $_REQUEST['mode'];
42 $offset = $_REQUEST['offset'];
43 $offset_sent = $_REQUEST['offset_sent'];
44 $form_active = $_REQUEST['form_active'];
45 $form_inactive = $_REQUEST['form_inactive'];
46 $noteid = $_REQUEST['noteid'];
47 $form_doc_only = isset($_POST['mode']) ? (empty($_POST['form_doc_only']) ? 0 : 1) : 1;
48 if($_REQUEST['s'] == '1'){
49 $inbox = "";
50 $outbox = "current";
51 $inbox_style = "style='display:none;border:5px solid #FFFFFF;'";
52 $outbox_style = "style='border:5px solid #FFFFFF;'";
53 }else{
54 $inbox = "current";
55 $outbox = "";
56 $inbox_style = "style='border:5px solid #FFFFFF;'";;
57 $outbox_style = "style='display:none;border:5px solid #FFFFFF;'";
60 if (!isset($offset)) $offset = 0;
61 if (!isset($offset_sent)) $offset_sent = 0;
63 // Collect active variable and applicable html code for links
64 if ($form_active) {
65 $active = '1';
66 $activity_string_html = 'form_active=1';
68 else if ($form_inactive) {
69 $active = '0';
70 $activity_string_html = 'form_inactive=1';
72 else {
73 $active = 'all';
74 $activity_string_html = '';
75 $form_active = $form_inactive = '1';
78 // form parameter docid can be passed to restrict the display to a document.
79 $docid = empty($_REQUEST['docid']) ? 0 : 0 + $_REQUEST['docid'];
81 // this code handles changing the state of activity tags when the user updates
82 // them through the interface
83 if (isset($mode)) {
84 if ($mode == "update") {
85 foreach ($_POST as $var => $val) {
86 if (strncmp($var, 'act', 3) == 0) {
87 $id = str_replace("act", "", $var);
88 if ($_POST["chk$id"]) {
89 reappearPnote($id);
90 } else {
91 disappearPnote($id);
93 if ($docid) {
94 setGpRelation(1, $docid, 6, $id, !empty($_POST["lnk$id"]));
99 elseif ($mode == "new") {
100 $note = $_POST['note'];
102 if ($noteid) {
103 updatePnote($noteid, $note, $_POST['form_note_type'], $_POST['assigned_to']);
104 $noteid = '';
106 else {
107 addPnote($pid, $note, $userauthorized, '1', $_POST['form_note_type'],
108 $_POST['assigned_to']);
111 elseif ($mode == "delete") {
112 if ($noteid) {
113 deletePnote($noteid);
114 newEvent("delete", $_SESSION['authUser'], $_SESSION['authProvider'], 1, "pnotes: id ".$noteid);
116 $noteid = '';
120 $title = '';
121 $assigned_to = $_SESSION['authUser'];
122 if ($noteid) {
123 $prow = getPnoteById($noteid, 'title,assigned_to,body');
124 $title = $prow['title'];
125 $assigned_to = $prow['assigned_to'];
128 // Get the users list. The "Inactive" test is a kludge, we should create
129 // a separate column for this.
130 $ures = sqlStatement("SELECT username, fname, lname FROM users " .
131 "WHERE username != '' AND active = 1 AND " .
132 "( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
133 "ORDER BY lname, fname");
135 $pres = sqlQuery("SELECT lname, fname " .
136 "FROM patient_data WHERE pid = ?", array($pid) );
137 $patientname = $pres['lname'] . ", " . $pres['fname'];
139 //retrieve all notes
140 $result = getPnotesByDate("", $active, 'id,date,body,user,activity,title,assigned_to,message_status',
141 $pid, $N, $offset);
142 $result_sent = getSentPnotesByDate("", $active, 'id,date,body,user,activity,title,assigned_to,message_status',
143 $pid, $M, $offset_sent);
146 <html>
147 <head>
148 <?php html_header_show();?>
150 <link rel='stylesheet' href="<?php echo $css_header;?>" type="text/css">
152 <!-- supporting javascript code -->
153 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script>
154 <link rel="stylesheet" type="text/css" href="../../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
155 <script type="text/javascript" src="../../../library/dialog.js"></script>
156 <script type="text/javascript" src="../../../library/js/jquery.1.3.2.js"></script>
157 <script type="text/javascript" src="../../../library/js/common.js"></script>
158 <script type="text/javascript" src="../../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
159 <script type="text/javascript">
160 /// todo, move this to a common library
162 $(document).ready(function(){
164 $("#dem_view").click( function() {
165 toggle( $(this), "#DEM" );
168 // load divs
169 $("#stats_div").load("stats.php");
170 $("#notes_div").load("pnotes_fragment.php");
172 // fancy box
173 enable_modals();
174 tabbify();
176 function show_div(name){
177 if(name == 'inbox'){
178 document.getElementById('inbox_div').style.display = '';
179 document.getElementById('outbox_div').style.display = 'none';
180 }else{
181 document.getElementById('inbox_div').style.display = 'none';
182 document.getElementById('outbox_div').style.display = '';
185 </script>
186 </head>
187 <body class="body_top">
189 <div id="pnotes"> <!-- large outer DIV -->
191 <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);?>'>
194 <div>
195 <span class="title"><?php echo htmlspecialchars( xl('Patient Notes'), ENT_NOQUOTES); ?></span>
196 </div>
197 <div style='float:left;margin-right:10px'>
198 <?php echo htmlspecialchars( xl('for'), ENT_NOQUOTES);?>&nbsp;<span class="title">
199 <a href="../summary/demographics.php" onclick="top.restoreSession()"><?php echo htmlspecialchars( getPatientName($pid), ENT_NOQUOTES); ?></a></span>
200 </div>
201 <div>
202 <a href="pnotes_full_add.php" class="css_button iframe"><span><?php echo htmlspecialchars( xl('Add'), ENT_NOQUOTES); ?></span></a>
203 <a href="demographics.php" <?php if (!$GLOBALS['concurrent_layout']) echo "target='Main'"; ?> class="css_button" onclick="top.restoreSession()">
204 <span><?php echo htmlspecialchars( xl('View Patient'), ENT_NOQUOTES);?></span>
205 </a>
206 </div>
207 <br/>
208 <br/>
209 <div>
210 <?php if ($active == "all") { ?>
211 <span><?php echo xlt('Show All'); ?></span>
212 <?php } else { ?>
213 <a href="pnotes_full.php" class="link" onclick="top.restoreSession()"><span><?php echo xlt('Show All'); ?></span></a>
214 <?php } ?>
216 <?php if ($active == '1') { ?>
217 <span><?php echo xlt('Show Active'); ?></span>
218 <?php } else { ?>
219 <a href="pnotes_full.php?form_active=1" class="link" onclick="top.restoreSession()"><span><?php echo xlt('Show Active'); ?></span></a>
220 <?php } ?>
222 <?php if ($active == '0') { ?>
223 <span><?php echo xlt('Show Inactive'); ?></span>
224 <?php } else { ?>
225 <a href="pnotes_full.php?form_inactive=1" class="link" onclick="top.restoreSession()"><span><?php echo xlt('Show Inactive'); ?></span></a>
226 <?php } ?>
227 </div>
229 <?php
230 $title_docname = "";
231 if ($docid) {
232 $title_docname = " " . htmlspecialchars( xl("linked to document"), ENT_NOQUOTES) . " ";
233 $d = new Document($docid);
234 $title_docname .= $d->get_url_file();
237 <input type='hidden' name='mode' id="mode" value="new">
238 <input type='hidden' name='offset' id="offset" value="<?php echo $offset; ?>">
239 <input type='hidden' name='offset_sent' id="offset_sent" value="<?php echo $offset_sent; ?>">
240 <input type='hidden' name='form_active' id="form_active" value="<?php echo htmlspecialchars( $form_active, ENT_QUOTES); ?>">
241 <input type='hidden' name='form_inactive' id="form_inactive" value="<?php echo htmlspecialchars( $form_inactive, ENT_QUOTES); ?>">
242 <input type='hidden' name='noteid' id="noteid" value="<?php echo htmlspecialchars( $noteid, ENT_QUOTES); ?>">
243 <input type='hidden' name='form_doc_only' id="form_doc_only" value="<?php echo htmlspecialchars( $form_doc_only, ENT_QUOTES); ?>">
244 </form>
247 <?php
248 // Get the billing note if there is one.
249 $billing_note = "";
250 $colorbeg = "";
251 $colorend = "";
252 $sql = "select genericname2, genericval2 " .
253 "from patient_data where pid = ? limit 1";
254 $resnote = sqlQuery($sql, array($pid) );
255 if($resnote && $resnote['genericname2'] == 'Billing') {
256 $billing_note = $resnote['genericval2'];
257 $colorbeg = "<span style='color:red'>";
258 $colorend = "</span>";
261 //Display what the patient owes
262 $balance = get_patient_balance($pid);
265 <?php if ($billing_note || $balance ) { ?>
267 <div style='margin-top:3px'>
268 <table width='80%'>
269 <?php
270 if ($balance != "0") {
271 // $formatted = sprintf((xl('$').'%01.2f'), $balance);
272 $formatted = oeFormatMoney($balance);
273 echo " <tr class='text billing'>\n";
274 echo " <td>".$colorbeg . htmlspecialchars( xl('Balance Due'), ENT_NOQUOTES) .
275 $colorend."&nbsp;".$colorbeg. htmlspecialchars( $formatted, ENT_NOQUOTES) .
276 $colorend."</td>\n";
277 echo " </tr>\n";
280 if ($billing_note) {
281 echo " <tr class='text billing'>\n";
282 echo " <td>".$colorbeg . htmlspecialchars( xl('Billing Note'), ENT_NOQUOTES) .
283 $colorend."&nbsp;".$colorbeg . htmlspecialchars( $billing_note, ENT_NOQUOTES) .
284 $colorend."</td>\n";
285 echo " </tr>\n";
288 </table>
289 </div>
290 <br>
291 <?php } ?>
292 <ul class="tabNav">
293 <li class="<?php echo $inbox; ?>" ><a onclick="show_div('inbox')" href="#"><?php echo htmlspecialchars(xl('Inbox'),ENT_NOQUOTES); ?></a></li>
294 <li class="<?php echo $outbox; ?>" ><a onclick="show_div('outbox')" href="#"><?php echo htmlspecialchars(xl('Sent Items'),ENT_NOQUOTES); ?></a></li>
295 </ul>
296 <div class='tabContainer' >
297 <div id='inbox_div' <?php echo $inbox_style; ?> >
298 <form border='0' method='post' name='update_activity' id='update_activity'
299 action="pnotes_full.php?docid=<?php echo htmlspecialchars( $docid, ENT_QUOTES); ?>&<?php echo attr($activity_string_html);?>">
300 <!-- start of previous notes DIV -->
301 <div class=pat_notes>
302 <input type='hidden' name='mode' value="update">
303 <input type='hidden' name='offset' id='offset' value="<?php echo $offset; ?>">
304 <input type='hidden' name='offset_sent' id='offset_sent' value="<?php echo $offset_sent; ?>">
305 <input type='hidden' name='noteid' id='noteid' value="0">
306 <table border='0' cellpadding="1" class="text">
307 <?php if ($result != ""): ?>
308 <tr>
309 <td colspan='5' style="padding: 5px;" >
310 <a href="#" class="change_activity" ><span><?php echo htmlspecialchars( xl('Update Active'), ENT_NOQUOTES); ?></span></a>
312 <a href="pnotes_full.php?<?php echo attr($activity_string_html);?>" class="" id='Submit'><span><?php echo htmlspecialchars( xl('Refresh'), ENT_NOQUOTES); ?></span></a>
313 </td>
314 </tr></table>
315 <?php endif; ?>
317 <table border='0' cellpadding="1" class="text" width = "80%">
318 <?php
319 // display all of the notes for the day, as well as others that are active
320 // from previous dates, up to a certain number, $N
322 if ($result != "") {
323 echo " <tr class=showborder_head align='left'>\n";
324 echo " <th style='width:100px';>&nbsp;</th>\n";
325 echo " <th>" . htmlspecialchars( xl('Active'), ENT_NOQUOTES) . "&nbsp;</th>\n";
326 echo " <th>" . ($docid ? htmlspecialchars( xl('Linked'), ENT_NOQUOTES) : '') . "</th>\n";
327 echo " <th>" . htmlspecialchars( xl('Type'), ENT_NOQUOTES) . "</th>\n";
328 echo " <th>" . htmlspecialchars( xl('Content'), ENT_NOQUOTES) . "</th>\n";
329 echo " </tr>\n";
331 $result_count = 0;
332 foreach ($result as $iter) {
333 $result_count++;
334 $row_note_id = $iter['id'];
336 $linked = "";
337 if ($docid) {
338 if (isGpRelation(1, $docid, 6, $row_note_id)) {
339 $linked = "checked";
341 else {
342 // Skip unlinked notes if that is requested.
343 if ($form_doc_only) continue;
347 $body = $iter['body'];
348 if (preg_match('/^\d\d\d\d-\d\d-\d\d \d\d\:\d\d /', $body)) {
349 $body = nl2br(htmlspecialchars( oeFormatPatientNote($body), ENT_NOQUOTES));
350 } else {
351 $body = htmlspecialchars( oeFormatSDFT(strtotime($iter['date'])).date(' H:i', strtotime($iter['date'])), ENT_NOQUOTES) .
352 ' (' . htmlspecialchars( $iter['user'], ENT_NOQUOTES) . ') ' . nl2br(htmlspecialchars( oeFormatPatientNote($body), ENT_NOQUOTES));
354 $body = preg_replace('/(\sto\s)-patient-(\))/','${1}'.$patientname.'${2}',$body);
355 if ( ($iter{"activity"}) && ($iter['message_status'] != "Done") ) {
356 $checked = "checked";
357 } else {
358 $checked = "";
361 // highlight the row if it's been selected for updating
362 if ($_REQUEST['noteid'] == $row_note_id) {
363 echo " <tr height=20 class='noterow highlightcolor' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>\n";
365 else {
366 echo " <tr class='noterow' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>\n";
370 echo " <td><a href='pnotes_full_add.php?trigger=edit&noteid=".htmlspecialchars( $row_note_id, ENT_QUOTES).
371 "' class='css_button_small iframe'><span>". htmlspecialchars( xl('Edit'), ENT_NOQUOTES) ."</span></a>\n";
373 // display, or not, a button to delete the note
374 // if the user is an admin or if they are the author of the note, they can delete it
375 if (($iter['user'] == $_SESSION['authUser']) || (acl_check('admin','super','','write'))) {
376 echo " <a href='#' class='deletenote css_button_small' id='del" . htmlspecialchars( $row_note_id, ENT_QUOTES) .
377 "' title='" . htmlspecialchars( xl('Delete this note'), ENT_QUOTES) . "'><span>" .
378 htmlspecialchars( xl('Delete'), ENT_NOQUOTES) . "</span>\n";
380 echo " </td>\n";
383 echo " <td class='text bold'>\n";
384 echo " <input type='hidden' name='act".htmlspecialchars( $row_note_id, ENT_QUOTES)."' value='1' />\n";
385 echo " <input type='checkbox' name='chk".htmlspecialchars( $row_note_id, ENT_QUOTES)."' $checked />\n";
386 echo " </td>\n";
388 echo " <td class='text bold'>\n";
389 if ($docid) {
390 echo " <input type='checkbox' name='lnk".htmlspecialchars( $row_note_id, ENT_QUOTES)."' $linked />\n";
392 echo " </td>\n";
394 echo " <td class='bold notecell' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>" .
395 "<a href='pnotes_full_add.php?trigger=edit&noteid=".htmlspecialchars( $row_note_id, ENT_QUOTES)."' class='iframe'>\n";
396 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
397 echo generate_display_field(array('data_type'=>'1','list_id'=>'note_type'), $iter['title']);
398 echo " </a></td>\n";
400 echo " <td class='notecell' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>\n";
401 echo " $body";
402 echo " </td>\n";
403 echo " </tr>\n";
405 $notes_count++;
407 } else {
408 //no results
409 print "<tr><td colspan='3' class='text'>" . htmlspecialchars( xl('None'), ENT_NOQUOTES) . ".</td></tr>\n";
414 </table>
415 </div>
416 </form>
418 <table width='400' border='0' cellpadding='0' cellspacing='0'>
419 <tr>
420 <td>
421 <?php
422 if ($offset > ($N-1)) {
423 echo " <a class='link' href='pnotes_full.php" .
424 "?docid=" . htmlspecialchars( $docid, ENT_QUOTES) .
425 "&form_active=" . htmlspecialchars( $form_active, ENT_QUOTES) .
426 "&form_inactive=" . htmlspecialchars( $form_inactive, ENT_QUOTES) .
427 "&form_doc_only=" . htmlspecialchars( $form_doc_only, ENT_QUOTES) .
428 "&offset=" . ($offset-$N) . "&" . attr($activity_string_html) . "' onclick='top.restoreSession()'>[" .
429 htmlspecialchars( xl('Previous'), ENT_NOQUOTES) . "]</a>\n";
432 </td>
433 <td align='right'>
434 <?php
435 if ($result_count == $N) {
436 echo " <a class='link' href='pnotes_full.php" .
437 "?docid=" . htmlspecialchars( $docid, ENT_QUOTES) .
438 "&form_active=" . htmlspecialchars( $form_active, ENT_QUOTES) .
439 "&form_inactive=" . htmlspecialchars( $form_inactive, ENT_QUOTES) .
440 "&form_doc_only=" . htmlspecialchars( $form_doc_only, ENT_QUOTES) .
441 "&offset=" . ($offset+$N) . "&" . attr($activity_string_html) . "' onclick='top.restoreSession()'>[" .
442 htmlspecialchars( xl('Next'), ENT_NOQUOTES) . "]</a>\n";
445 </td>
446 </tr>
447 </table>
449 </div>
450 <div id='outbox_div' <?php echo $outbox_style; ?> >
451 <table border='0' cellpadding="1" class="text">
452 <?php if ($result_sent != ""): ?>
453 <tr>
454 <td colspan='5' style="padding: 5px;" >
455 <a href="pnotes_full.php?s=1&<?php echo attr($activity_string_html);?>" class="" id='Submit'><span><?php echo htmlspecialchars( xl('Refresh'), ENT_NOQUOTES); ?></span></a>
456 </td>
457 </tr></table>
458 <?php endif; ?>
460 <table border='0' cellpadding="1" class="text" width = "80%">
461 <?php
462 // display all of the notes for the day, as well as others that are active
463 // from previous dates, up to a certain number, $N
465 if ($result_sent != "") {
466 echo " <tr class=showborder_head align='left'>\n";
467 echo " <th style='width:100px';>&nbsp;</th>\n";
468 echo " <th>" . htmlspecialchars( xl('Active'), ENT_NOQUOTES) . "&nbsp;</th>\n";
469 echo " <th>" . ($docid ? htmlspecialchars( xl('Linked'), ENT_NOQUOTES) : '') . "</th>\n";
470 echo " <th>" . htmlspecialchars( xl('Type'), ENT_NOQUOTES) . "</th>\n";
471 echo " <th>" . htmlspecialchars( xl('Content'), ENT_NOQUOTES) . "</th>\n";
472 echo " </tr>\n";
474 $result_sent_count = 0;
475 foreach ($result_sent as $iter) {
476 $result_sent_count++;
477 $row_note_id = $iter['id'];
479 $linked = "";
480 if ($docid) {
481 if (isGpRelation(1, $docid, 6, $row_note_id)) {
482 $linked = "checked";
484 else {
485 // Skip unlinked notes if that is requested.
486 if ($form_doc_only) continue;
490 $body = $iter['body'];
491 if (preg_match('/^\d\d\d\d-\d\d-\d\d \d\d\:\d\d /', $body)) {
492 $body = nl2br(htmlspecialchars( oeFormatPatientNote($body), ENT_NOQUOTES));
493 } else {
494 $body = htmlspecialchars( oeFormatSDFT(strtotime($iter['date'])).date(' H:i', strtotime($iter['date'])), ENT_NOQUOTES) .
495 ' (' . htmlspecialchars( $iter['user'], ENT_NOQUOTES) . ') ' . nl2br(htmlspecialchars( oeFormatPatientNote($body), ENT_NOQUOTES));
497 $body = preg_replace('/(:\d{2}\s\()'.$pid.'(\sto\s)/','${1}'.$patientname.'${2}',$body);
498 if (($iter{"activity"}) && ($iter['message_status'] != "Done") ) {
499 $checked = "checked";
500 } else {
501 $checked = "";
504 // highlight the row if it's been selected for updating
505 if ($_REQUEST['noteid'] == $row_note_id) {
506 echo " <tr height=20 class='noterow highlightcolor' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>\n";
508 else {
509 echo " <tr class='noterow' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>\n";
513 echo " <td><a href='pnotes_full_add.php?trigger=edit&noteid=".htmlspecialchars( $row_note_id, ENT_QUOTES).
514 "' class='css_button_small iframe'><span>". htmlspecialchars( xl('Edit'), ENT_NOQUOTES) ."</span></a>\n";
516 // display, or not, a button to delete the note
517 // if the user is an admin or if they are the author of the note, they can delete it
518 if (($iter['user'] == $_SESSION['authUser']) || (acl_check('admin','super','','write'))) {
519 echo " <a href='#' class='deletenote css_button_small' id='del" . htmlspecialchars( $row_note_id, ENT_QUOTES) .
520 "' title='" . htmlspecialchars( xl('Delete this note'), ENT_QUOTES) . "'><span>" .
521 htmlspecialchars( xl('Delete'), ENT_NOQUOTES) . "</span>\n";
523 echo " </td>\n";
526 echo " <td class='text bold'>\n";
527 echo " <input type='hidden' name='act".htmlspecialchars( $row_note_id, ENT_QUOTES)."' value='1' />\n";
528 echo " <input type='checkbox' name='chk".htmlspecialchars( $row_note_id, ENT_QUOTES)."' $checked />\n";
529 echo " </td>\n";
531 echo " <td class='text bold'>\n";
532 if ($docid) {
533 echo " <input type='checkbox' name='lnk".htmlspecialchars( $row_note_id, ENT_QUOTES)."' $linked />\n";
535 echo " </td>\n";
537 echo " <td class='bold notecell' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>" .
538 "<a href='pnotes_full_add.php?trigger=edit&noteid=".htmlspecialchars( $row_note_id, ENT_QUOTES)."' class='iframe'>\n";
539 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
540 echo generate_display_field(array('data_type'=>'1','list_id'=>'note_type'), $iter['title']);
541 echo " </a></td>\n";
543 echo " <td class='notecell' id='".htmlspecialchars( $row_note_id, ENT_QUOTES)."'>\n";
544 echo " $body";
545 echo " </td>\n";
546 echo " </tr>\n";
548 $notes_sent_count++;
550 } else {
551 //no results
552 print "<tr><td colspan='3' class='text'>" . htmlspecialchars( xl('None'), ENT_NOQUOTES) . ".</td></tr>\n";
557 </table>
559 <table width='400' border='0' cellpadding='0' cellspacing='0'>
560 <tr>
561 <td>
562 <?php
563 if ($offset_sent > ($M-1)) {
564 echo " <a class='link' href='pnotes_full.php" .
565 "?docid=" . htmlspecialchars( $docid, ENT_QUOTES) .
566 "&s=1" .
567 "&form_active=" . htmlspecialchars( $form_active, ENT_QUOTES) .
568 "&form_inactive=" . htmlspecialchars( $form_inactive, ENT_QUOTES) .
569 "&form_doc_only=" . htmlspecialchars( $form_doc_only, ENT_QUOTES) .
570 "&offset_sent=" . ($offset_sent-$M) . "&" . attr($activity_string_html) . "' onclick='top.restoreSession()'>[" .
571 htmlspecialchars( xl('Previous'), ENT_NOQUOTES) . "]</a>\n";
574 </td>
575 <td align='right'>
576 <?php
577 if ($result_sent_count == $M) {
578 echo " <a class='link' href='pnotes_full.php" .
579 "?docid=" . htmlspecialchars( $docid, ENT_QUOTES) .
580 "&s=1" .
581 "&form_active=" . htmlspecialchars( $form_active, ENT_QUOTES) .
582 "&form_inactive=" . htmlspecialchars( $form_inactive, ENT_QUOTES) .
583 "&form_doc_only=" . htmlspecialchars( $form_doc_only, ENT_QUOTES) .
584 "&offset_sent=" . ($offset_sent+$M) . "&" . attr($activity_string_html) . "' onclick='top.restoreSession()'>[" .
585 htmlspecialchars( xl('Next'), ENT_NOQUOTES) . "]</a>\n";
588 </td>
589 </tr>
590 </table>
592 </div>
593 </div>
594 <script language='JavaScript'>
596 <?php
597 if ($GLOBALS['concurrent_layout'] && $_GET['set_pid']) {
598 $ndata = getPatientData($pid, "fname, lname, pubpid");
600 parent.left_nav.setPatient(<?php echo "'" . htmlspecialchars( $ndata['fname']." ".$ndata['lname'], ENT_QUOTES) . "'," .
601 htmlspecialchars( $pid, ENT_QUOTES) . ",'" . htmlspecialchars( $ndata['pubpid'], ENT_QUOTES) . "',window.name"; ?>);
602 parent.left_nav.setRadio(window.name, 'pno');
603 <?php
606 // If this note references a new patient document, pop up a display
607 // of that document.
609 if ($noteid /* && $title == 'New Document' */ ) {
610 $prow = getPnoteById($noteid, 'body');
611 if (preg_match('/New scanned document (\d+): [^\n]+\/([^\n]+)/', $prow['body'], $matches)) {
612 $docid = $matches[1];
613 $docname = $matches[2];
615 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',
616 '_blank', 'resizable=1,scrollbars=1,width=600,height=500');
617 <?php
622 </script>
624 </div> <!-- end outer 'pnotes' -->
626 </body>
628 <script language="javascript">
630 // jQuery stuff to make the page a little easier to use
632 $(document).ready(function(){
633 $("#appendnote").click(function() { AppendNote(); });
634 $("#newnote").click(function() { NewNote(); });
635 $("#printnote").click(function() { PrintNote(); });
637 $(".change_activity").click(function() { top.restoreSession(); $("#update_activity").submit(); });
639 $(".deletenote").click(function() { DeleteNote(this); });
641 $(".noterow").mouseover(function() { $(this).toggleClass("highlight"); });
642 $(".noterow").mouseout(function() { $(this).toggleClass("highlight"); });
643 $(".notecell").click(function() { EditNote(this); });
645 $("#note").focus();
647 var EditNote = function(note) {
648 top.restoreSession();
649 $("#noteid").val(note.id);
650 $("#mode").val("");
651 $("#new_note").submit();
654 var NewNote = function () {
655 top.restoreSession();
656 $("#noteid").val('');
657 $("#new_note").submit();
660 var AppendNote = function () {
661 top.restoreSession();
662 $("#new_note").submit();
665 var PrintNote = function () {
666 top.restoreSession();
667 window.open('pnotes_print.php?noteid=<?php echo htmlspecialchars( $noteid, ENT_QUOTES); ?>', '_blank', 'resizable=1,scrollbars=1,width=600,height=500');
670 var DeleteNote = function(note) {
671 if (confirm("<?php echo htmlspecialchars( xl('Are you sure you want to delete this note?','','','\n '), ENT_QUOTES) .
672 htmlspecialchars( xl('This action CANNOT be undone.'), ENT_QUOTES); ?>")) {
673 top.restoreSession();
674 // strip the 'del' part of the object's ID
675 $("#noteid").val(note.id.replace(/del/, ""));
676 $("#mode").val("delete");
677 $("#new_note").submit();
683 </script>
686 </html>