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.
8 $sanitize_all_escapes=true;
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/gprelations.inc.php");
23 if ($_GET['set_pid']) {
24 require_once("$srcdir/pid.inc");
25 setpid($_GET['set_pid']);
28 // form parameter docid can be passed to restrict the display to a document.
29 $docid = empty($_REQUEST['docid']) ?
0 : intval($_REQUEST['docid']);
31 // form parameter orderid can be passed to restrict the display to a procedure order.
32 $orderid = empty($_REQUEST['orderid']) ?
0 : intval($_REQUEST['orderid']);
36 $row = sqlQuery("SELECT foreign_id FROM documents WHERE id = ?", array($docid));
37 $patient_id = intval($row['foreign_id']);
40 $row = sqlQuery("SELECT patient_id FROM procedure_order WHERE procedure_order_id = ?", array($orderid));
41 $patient_id = intval($row['patient_id']);
44 // Check authorization.
45 if (!acl_check('patients','notes','',array('write','addonly') ))
46 die(htmlspecialchars( xl('Not authorized'), ENT_NOQUOTES
));
47 $tmp = getPatientData($patient_id, "squad");
48 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad']))
49 die(htmlspecialchars( xl('Not authorized for this squad.'), ENT_NOQUOTES
));
51 //the number of records to display per screen
54 $mode = $_REQUEST['mode'];
55 $offset = $_REQUEST['offset'];
56 $form_active = $_REQUEST['form_active'];
57 $form_inactive = $_REQUEST['form_inactive'];
58 $noteid = $_REQUEST['noteid'];
59 $form_doc_only = isset($_POST['mode']) ?
(empty($_POST['form_doc_only']) ?
0 : 1) : 1;
61 if (!isset($offset)) $offset = 0;
63 // if (!isset($active)) $active = "all";
67 if (!$form_inactive) $active = '1';
73 $form_active = $form_inactive = '1';
76 // this code handles changing the state of activity tags when the user updates
77 // them through the interface
79 if ($mode == "update") {
80 foreach ($_POST as $var => $val) {
81 if (strncmp($var, 'act', 3) == 0) {
82 $id = str_replace("act", "", $var);
83 if ($_POST["chk$id"]) {
89 setGpRelation(1, $docid, 6, $id, !empty($_POST["lnk$id"]));
92 setGpRelation(2, $orderid, 6, $id, !empty($_POST["lnk$id"]));
97 elseif ($mode == "new") {
98 $note = $_POST['note'];
100 updatePnote($noteid, $note, $_POST['form_note_type'], $_POST['assigned_to']);
104 $noteid = addPnote($patient_id, $note, $userauthorized, '1', $_POST['form_note_type'],
105 $_POST['assigned_to']);
108 setGpRelation(1, $docid, 6, $noteid);
111 setGpRelation(2, $orderid, 6, $noteid);
115 elseif ($mode == "delete") {
117 deletePnote($noteid);
118 newEvent("delete", $_SESSION['authUser'], $_SESSION['authProvider'], "pnotes: id ".$noteid);
125 $assigned_to = $_SESSION['authUser'];
127 $prow = getPnoteById($noteid, 'title,assigned_to,body');
128 $title = $prow['title'];
129 $assigned_to = $prow['assigned_to'];
132 // Get the users list. The "Inactive" test is a kludge, we should create
133 // a separate column for this.
134 $ures = sqlStatement("SELECT username, fname, lname FROM users " .
135 "WHERE username != '' AND active = 1 AND " .
136 "( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
137 "ORDER BY lname, fname");
139 $pres = getPatientData($patient_id, "lname, fname");
140 $patientname = $pres['lname'] . ", " . $pres['fname'];
143 $result = getPnotesByDate("", $active, 'id,date,body,user,activity,title,assigned_to',
144 $patient_id, $N, $offset);
149 <?php
html_header_show();?
>
151 <link rel
='stylesheet' href
="<?php echo $css_header;?>" type
="text/css">
153 <!-- supporting javascript code
-->
154 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-1/index.js"></script
>
155 <link rel
="stylesheet" type
="text/css" href
="../../../library/js/fancybox/jquery.fancybox-1.2.6.css" media
="screen" />
156 <script type
="text/javascript" src
="../../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
157 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-3-2/index.js"></script
>
158 <script type
="text/javascript" src
="../../../library/js/common.js"></script
>
159 <script type
="text/javascript" src
="../../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script
>
160 <script type
="text/javascript">
161 function submitform(attr
) {
163 document
.forms
[0].submit();
167 <body
class="body_top">
169 <div id
="pnotes"> <!-- large outer DIV
-->
174 $title_docname .= " " . xl("linked to document") . " ";
175 $d = new Document($docid);
176 $title_docname .= $d->get_url_file();
179 $title_docname .= " " . xl("linked to procedure order") . " $orderid";
182 $urlparms = "docid=$docid&orderid=$orderid";
185 <form border
='0' method
='post' name
='new_note' id
="new_note" target
="_parent"
186 action
='pnotes_full.php?<?php echo $urlparms; ?>'>
189 <div style
='float:left; margin-right: 5px'>
190 <span
class="title"><?php
echo xlt('Patient Note') . $title_docname; ?
></span
>
193 <?php
if ($noteid) { ?
>
194 <!-- existing note
-->
195 <a href
="#" class="css_button" id
="printnote"><span
><?php
echo xlt('View Printable Version'); ?
></span
></a
>
197 <a
class="css_button large_button" id
='cancel' href
='javascript:;'>
198 <span
class='css_button_span large_button_span'><?php
echo htmlspecialchars( xl('Cancel'), ENT_NOQUOTES
);?
></span
>
205 <input type
='hidden' name
='mode' id
="mode" value
="new">
206 <input type
='hidden' name
='trigger' id
="trigger" value
="add">
207 <input type
='hidden' name
='offset' id
="offset" value
="<?php echo $offset ?>">
208 <input type
='hidden' name
='form_active' id
="form_active" value
="<?php echo htmlspecialchars( $form_active, ENT_QUOTES) ?>">
209 <input type
='hidden' name
='form_inactive' id
="form_inactive" value
="<?php echo htmlspecialchars( $form_inactive, ENT_QUOTES) ?>">
210 <input type
='hidden' name
='noteid' id
="noteid" value
="<?php echo htmlspecialchars( $noteid, ENT_QUOTES) ?>">
211 <input type
='hidden' name
='form_doc_only' id
="form_doc_only" value
="<?php echo htmlspecialchars( $form_doc_only, ENT_QUOTES) ?>">
212 <table border
='0' cellspacing
='8'>
217 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
218 echo htmlspecialchars( xl('Amend Existing Note'), ENT_NOQUOTES
) .
219 "<b> "" . generate_display_field(array('data_type'=>'1','list_id'=>'note_type'), $title) . ""</b>\n";
221 echo htmlspecialchars( xl('Add New Note'), ENT_NOQUOTES
) . "\n";
230 <b
><?php
echo htmlspecialchars( xl('Type'), ENT_NOQUOTES
); ?
>:</b
>
232 // Added 6/2009 by BM to incorporate the patient notes into the list_options listings
233 generate_form_field(array('data_type'=>1,'field_id'=>'note_type','list_id'=>'note_type','empty_title'=>'SKIP'), $title);
236 <b
><?php
echo htmlspecialchars( xl('To'), ENT_NOQUOTES
); ?
>:</b
>
237 <select name
='assigned_to'>
238 <option value
=''>** <?php
echo htmlspecialchars( xl('Close'), ENT_NOQUOTES
); ?
> **</option
>
240 while ($urow = sqlFetchArray($ures)) {
241 echo " <option value='" . htmlspecialchars( $urow['username'], ENT_QUOTES
) . "'";
242 if ($urow['username'] == $assigned_to) echo " selected";
243 echo ">" . htmlspecialchars( $urow['lname'], ENT_NOQUOTES
);
244 if ($urow['fname']) echo htmlspecialchars( ", ".$urow['fname'], ENT_NOQUOTES
);
255 $body = $prow['body'];
256 $body = preg_replace(array('/(\sto\s)-patient-(\))/', '/(:\d{2}\s\()' . $patient_id . '(\sto\s)/'), '${1}' . $patientname . '${2}', $body);
257 $body = nl2br(htmlspecialchars( $body, ENT_NOQUOTES
));
258 echo "<div class='text'>".$body."</div>";
262 <textarea name
='note' id
='note' rows
='4' cols
='58'></textarea
>
264 <?php
if ($noteid) { ?
>
265 <!-- existing note
-->
266 <a href
="#" class="css_button" id
="newnote" title
="<?php echo htmlspecialchars( xl('Add as a new note'), ENT_QUOTES); ?>" ><span
><?php
echo htmlspecialchars( xl('Save as new note'), ENT_NOQUOTES
); ?
></span
></a
>
267 <a href
="#" class="css_button" id
="appendnote" title
="<?php echo htmlspecialchars( xl('Append to the existing note'), ENT_QUOTES); ?>"><span
><?php
echo htmlspecialchars( xl('Append this note'), ENT_NOQUOTES
); ?
></span
></a
>
269 <a href
="#" class="css_button" id
="newnote" title
="<?php echo htmlspecialchars( xl('Add as a new note'), ENT_QUOTES); ?>" ><span
><?php
echo htmlspecialchars( xl('Save as new note'), ENT_NOQUOTES
); ?
></span
></a
>
277 <form border
='0' method
='post' name
='update_activity' id
='update_activity'
278 action
="pnotes_full.php?<?php echo $urlparms; ?>">
280 <!-- start of previous notes DIV
-->
281 <div
class=pat_notes
>
284 <input type
='hidden' name
='mode' value
="update">
285 <input type
='hidden' name
='offset' id
='noteid' value
="<?php echo $offset;?>">
286 <input type
='hidden' name
='noteid' id
='noteid' value
="0">
289 <table width
='400' border
='0' cellpadding
='0' cellspacing
='0'>
293 if ($offset > ($N-1)) {
294 echo " <a class='link' href='pnotes_full.php" .
296 "&form_active=" . htmlspecialchars( $form_active, ENT_QUOTES
) .
297 "&form_inactive=" . htmlspecialchars( $form_inactive, ENT_QUOTES
) .
298 "&form_doc_only=" . htmlspecialchars( $form_doc_only, ENT_QUOTES
) .
299 "&offset=" . ($offset-$N) . "' onclick='top.restoreSession()'>[" .
300 htmlspecialchars( xl('Previous'), ENT_NOQUOTES
) . "]</a>\n";
306 if ($result_count == $N) {
307 echo " <a class='link' href='pnotes_full.php" .
309 "&form_active=" . htmlspecialchars( $form_active, ENT_QUOTES
) .
310 "&form_inactive=" . htmlspecialchars( $form_inactive, ENT_QUOTES
) .
311 "&form_doc_only=" . htmlspecialchars( $form_doc_only, ENT_QUOTES
) .
312 "&offset=" . ($offset+
$N) . "' onclick='top.restoreSession()'>[" .
313 htmlspecialchars( xl('Next'), ENT_NOQUOTES
) . "]</a>\n";
320 </div
> <!-- close the previous
-notes DIV
-->
322 <script language
='JavaScript'>
325 if ($_GET['set_pid']) {
326 $ndata = getPatientData($patient_id, "fname, lname, pubpid");
328 parent
.left_nav
.setPatient(<?php
echo "'" . addslashes($ndata['fname']." ".$ndata['lname']) . "'," . addslashes($patient_id) . ",'" . addslashes($ndata['pubpid']) . "',window.name"; ?
>);
332 // If this note references a new patient document, pop up a display
335 if ($noteid /* && $title == 'New Document' */ ) {
336 $prow = getPnoteById($noteid, 'body');
337 if (preg_match('/New scanned document (\d+): [^\n]+\/([^\n]+)/', $prow['body'], $matches)) {
338 $docid = $matches[1];
339 $docname = $matches[2];
341 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',
342 '_blank', 'resizable=1,scrollbars=1,width=600,height=500');
350 </div
> <!-- end outer
'pnotes' -->
354 <script language
="javascript">
356 // jQuery stuff to make the page a little easier to use
358 $
(document
).ready(function(){
359 $
("#appendnote").click(function() { AppendNote(); });
360 $
("#newnote").click(function() { NewNote(); });
361 $
("#printnote").click(function() { PrintNote(); });
363 $
(".change_activity").click(function() { top
.restoreSession(); $
("#update_activity").submit(); });
365 $
(".deletenote").click(function() { DeleteNote(this
); });
367 $
(".noterow").mouseover(function() { $
(this
).toggleClass("highlight"); });
368 $
(".noterow").mouseout(function() { $
(this
).toggleClass("highlight"); });
369 $
(".notecell").click(function() { EditNote(this
); });
373 var EditNote
= function(note
) {
374 top
.restoreSession();
375 $
("#noteid").val(note
.id
);
377 $
("#new_note").submit();
380 var NewNote
= function () {
381 top
.restoreSession();
382 $
("#noteid").val('');
383 $
("#new_note").submit();
386 var AppendNote
= function () {
387 top
.restoreSession();
388 $
("#new_note").submit();
391 var PrintNote
= function () {
392 top
.restoreSession();
393 window
.open('pnotes_print.php?noteid=<?php echo htmlspecialchars( $noteid, ENT_QUOTES); ?>', '_blank', 'resizable=1,scrollbars=1,width=600,height=500');
396 var DeleteNote
= function(note
) {
397 if (confirm("<?php echo htmlspecialchars( xl('Are you sure you want to delete this note?','','','\n ').xl('This action CANNOT be undone.'), ENT_QUOTES); ?>")) {
398 top
.restoreSession();
399 // strip the 'del' part of the object's ID
400 $
("#noteid").val(note
.id
.replace(/del
/, ""));
401 $
("#mode").val("delete");
402 $
("#new_note").submit();
407 $
(document
).ready(function(){
408 $
("#cancel").click(function() {
409 parent
.$
.fn
.fancybox
.close();