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/classes/Document.class.php");
22 require_once("$srcdir/gprelations.inc.php");
24 if ($GLOBALS['concurrent_layout'] && $_GET['set_pid']) {
25 require_once("$srcdir/pid.inc");
26 setpid($_GET['set_pid']);
28 // Check authorization.
29 if (!acl_check('patients','notes','',array('write','addonly') ))
30 die(htmlspecialchars( xl('Not authorized'), ENT_NOQUOTES
));
31 $tmp = getPatientData($pid, "squad");
32 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad']))
33 die(htmlspecialchars( xl('Not authorized for this squad.'), ENT_NOQUOTES
));
35 //the number of records to display per screen
38 $mode = $_REQUEST['mode'];
39 $offset = $_REQUEST['offset'];
40 $form_active = $_REQUEST['form_active'];
41 $form_inactive = $_REQUEST['form_inactive'];
42 $noteid = $_REQUEST['noteid'];
43 $form_doc_only = isset($_POST['mode']) ?
(empty($_POST['form_doc_only']) ?
0 : 1) : 1;
45 if (!isset($offset)) $offset = 0;
47 // if (!isset($active)) $active = "all";
51 if (!$form_inactive) $active = '1';
57 $form_active = $form_inactive = '1';
60 // form parameter docid can be passed to restrict the display to a document.
61 $docid = empty($_REQUEST['docid']) ?
0 : 0 +
$_REQUEST['docid'];
63 // this code handles changing the state of activity tags when the user updates
64 // them through the interface
66 if ($mode == "update") {
67 foreach ($_POST as $var => $val) {
68 if (strncmp($var, 'act', 3) == 0) {
69 $id = str_replace("act", "", $var);
70 if ($_POST["chk$id"]) {
76 setGpRelation(1, $docid, 6, $id, !empty($_POST["lnk$id"]));
81 elseif ($mode == "new") {
82 $note = $_POST['note'];
84 updatePnote($noteid, $note, $_POST['form_note_type'], $_POST['assigned_to']);
88 addPnote($pid, $note, $userauthorized, '1', $_POST['form_note_type'],
89 $_POST['assigned_to']);
92 elseif ($mode == "delete") {
95 newEvent("delete", $_SESSION['authUser'], $_SESSION['authProvider'], "pnotes: id ".$noteid);
102 $assigned_to = $_SESSION['authUser'];
104 $prow = getPnoteById($noteid, 'title,assigned_to,body');
105 $title = $prow['title'];
106 $assigned_to = $prow['assigned_to'];
109 // Get the users list. The "Inactive" test is a kludge, we should create
110 // a separate column for this.
111 $ures = sqlStatement("SELECT username, fname, lname FROM users " .
112 "WHERE username != '' AND active = 1 AND " .
113 "( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
114 "ORDER BY lname, fname");
116 $pres = getPatientData($pid, "lname, fname");
117 $patientname = $pres['lname'] . ", " . $pres['fname'];
120 $result = getPnotesByDate("", $active, 'id,date,body,user,activity,title,assigned_to',
126 <?php
html_header_show();?
>
128 <link rel
='stylesheet' href
="<?php echo $css_header;?>" type
="text/css">
130 <!-- supporting javascript code
-->
131 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script
>
132 <link rel
="stylesheet" type
="text/css" href
="../../../library/js/fancybox/jquery.fancybox-1.2.6.css" media
="screen" />
133 <script type
="text/javascript" src
="../../../library/dialog.js"></script
>
134 <script type
="text/javascript" src
="../../../library/js/jquery.1.3.2.js"></script
>
135 <script type
="text/javascript" src
="../../../library/js/common.js"></script
>
136 <script type
="text/javascript" src
="../../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script
>
137 <script type
="text/javascript">
138 function submitform(attr
) {
140 document
.forms
[0].submit();
144 <body
class="body_top">
146 <div id
="pnotes"> <!-- large outer DIV
-->
148 <form border
='0' method
='post' name
='new_note' id
="new_note" target
="_parent" action
='pnotes_full.php?docid=<?php echo htmlspecialchars( $docid, ENT_QUOTES); ?>'>
153 $title_docname = " " . xl("linked to document") . " ";
154 $d = new Document($docid);
155 $title_docname .= $d->get_url_file();
160 <div style
='float:left; margin-right: 5px'>
161 <span
class="title"><?php
echo xlt('Patient Note') . $title_docname; ?
></span
>
164 <?php
if ($noteid) { ?
>
165 <!-- existing note
-->
166 <a href
="#" class="css_button" id
="printnote"><span
><?php
echo htmlspecialchars( xl('Print'), ENT_NOQUOTES
); ?
></span
></a
>
168 <a
class="css_button large_button" id
='cancel' href
='javascript:;'>
169 <span
class='css_button_span large_button_span'><?php
echo htmlspecialchars( xl('Cancel'), ENT_NOQUOTES
);?
></span
>
176 <input type
='hidden' name
='mode' id
="mode" value
="new">
177 <input type
='hidden' name
='trigger' id
="trigger" value
="add">
178 <input type
='hidden' name
='offset' id
="offset" value
="<?php echo $offset ?>">
179 <input type
='hidden' name
='form_active' id
="form_active" value
="<?php echo htmlspecialchars( $form_active, ENT_QUOTES) ?>">
180 <input type
='hidden' name
='form_inactive' id
="form_inactive" value
="<?php echo htmlspecialchars( $form_inactive, ENT_QUOTES) ?>">
181 <input type
='hidden' name
='noteid' id
="noteid" value
="<?php echo htmlspecialchars( $noteid, ENT_QUOTES) ?>">
182 <input type
='hidden' name
='form_doc_only' id
="form_doc_only" value
="<?php echo htmlspecialchars( $form_doc_only, ENT_QUOTES) ?>">
183 <table border
='0' cellspacing
='8'>
188 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
189 echo htmlspecialchars( xl('Amend Existing Note'), ENT_NOQUOTES
) .
190 "<b> "" . generate_display_field(array('data_type'=>'1','list_id'=>'note_type'), $title) . ""</b>\n";
192 echo htmlspecialchars( xl('Add New Note'), ENT_NOQUOTES
) . "\n";
201 <b
><?php
echo htmlspecialchars( xl('Type'), ENT_NOQUOTES
); ?
>:</b
>
203 // Added 6/2009 by BM to incorporate the patient notes into the list_options listings
204 generate_form_field(array('data_type'=>1,'field_id'=>'note_type','list_id'=>'note_type','empty_title'=>'SKIP'), $title);
207 <b
><?php
echo htmlspecialchars( xl('To'), ENT_NOQUOTES
); ?
>:</b
>
208 <select name
='assigned_to'>
209 <option value
=''>** <?php
echo htmlspecialchars( xl('Close'), ENT_NOQUOTES
); ?
> **</option
>
211 while ($urow = sqlFetchArray($ures)) {
212 echo " <option value='" . htmlspecialchars( $urow['username'], ENT_QUOTES
) . "'";
213 if ($urow['username'] == $assigned_to) echo " selected";
214 echo ">" . htmlspecialchars( $urow['lname'], ENT_NOQUOTES
);
215 if ($urow['fname']) echo htmlspecialchars( ", ".$urow['fname'], ENT_NOQUOTES
);
226 $body = $prow['body'];
227 $body = preg_replace(array('/(\sto\s)-patient-(\))/','/(:\d{2}\s\()'.$pid.'(\sto\s)/'),'${1}'.$patientname.'${2}',$body);
228 $body = nl2br(htmlspecialchars( $body, ENT_NOQUOTES
));
229 echo "<div class='text'>".$body."</div>";
233 <textarea name
='note' id
='note' rows
='4' cols
='58'></textarea
>
235 <?php
if ($noteid) { ?
>
236 <!-- existing note
-->
237 <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
>
238 <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
>
240 <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
>
248 <form border
='0' method
='post' name
='update_activity' id
='update_activity'
249 action
="pnotes_full.php?docid=<?php echo htmlspecialchars( $docid, ENT_QUOTES); ?>">
251 <!-- start of previous notes DIV
-->
252 <div
class=pat_notes
>
255 <input type
='hidden' name
='mode' value
="update">
256 <input type
='hidden' name
='offset' id
='noteid' value
="<?php echo $offset;?>">
257 <input type
='hidden' name
='noteid' id
='noteid' value
="0">
260 <table width
='400' border
='0' cellpadding
='0' cellspacing
='0'>
264 if ($offset > ($N-1)) {
265 echo " <a class='link' href='pnotes_full.php" .
266 "?docid=" . htmlspecialchars( $docid, ENT_QUOTES
) .
267 "&form_active=" . htmlspecialchars( $form_active, ENT_QUOTES
) .
268 "&form_inactive=" . htmlspecialchars( $form_inactive, ENT_QUOTES
) .
269 "&form_doc_only=" . htmlspecialchars( $form_doc_only, ENT_QUOTES
) .
270 "&offset=" . ($offset-$N) . "' onclick='top.restoreSession()'>[" .
271 htmlspecialchars( xl('Previous'), ENT_NOQUOTES
) . "]</a>\n";
277 if ($result_count == $N) {
278 echo " <a class='link' href='pnotes_full.php" .
279 "?docid=" . htmlspecialchars( $docid, ENT_QUOTES
) .
280 "&form_active=" . htmlspecialchars( $form_active, ENT_QUOTES
) .
281 "&form_inactive=" . htmlspecialchars( $form_inactive, ENT_QUOTES
) .
282 "&form_doc_only=" . htmlspecialchars( $form_doc_only, ENT_QUOTES
) .
283 "&offset=" . ($offset+
$N) . "' onclick='top.restoreSession()'>[" .
284 htmlspecialchars( xl('Next'), ENT_NOQUOTES
) . "]</a>\n";
291 </div
> <!-- close the previous
-notes DIV
-->
293 <script language
='JavaScript'>
296 if ($GLOBALS['concurrent_layout'] && $_GET['set_pid']) {
297 $ndata = getPatientData($pid, "fname, lname, pubpid");
299 parent
.left_nav
.setPatient(<?php
echo "'" . htmlspecialchars( $ndata['fname']." ".$ndata['lname'], ENT_QUOTES
) . "',$pid,'" . htmlspecialchars( $ndata['pubpid'], ENT_QUOTES
) . "',window.name"; ?
>);
300 parent
.left_nav
.setRadio(window
.name
, 'pno');
304 // If this note references a new patient document, pop up a display
307 if ($noteid /* && $title == 'New Document' */ ) {
308 $prow = getPnoteById($noteid, 'body');
309 if (preg_match('/New scanned document (\d+): [^\n]+\/([^\n]+)/', $prow['body'], $matches)) {
310 $docid = $matches[1];
311 $docname = $matches[2];
313 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',
314 '_blank', 'resizable=1,scrollbars=1,width=600,height=500');
322 </div
> <!-- end outer
'pnotes' -->
326 <script language
="javascript">
328 // jQuery stuff to make the page a little easier to use
330 $
(document
).ready(function(){
331 $
("#appendnote").click(function() { AppendNote(); });
332 $
("#newnote").click(function() { NewNote(); });
333 $
("#printnote").click(function() { PrintNote(); });
335 $
(".change_activity").click(function() { top
.restoreSession(); $
("#update_activity").submit(); });
337 $
(".deletenote").click(function() { DeleteNote(this
); });
339 $
(".noterow").mouseover(function() { $
(this
).toggleClass("highlight"); });
340 $
(".noterow").mouseout(function() { $
(this
).toggleClass("highlight"); });
341 $
(".notecell").click(function() { EditNote(this
); });
345 var EditNote
= function(note
) {
346 top
.restoreSession();
347 $
("#noteid").val(note
.id
);
349 $
("#new_note").submit();
352 var NewNote
= function () {
353 top
.restoreSession();
354 $
("#noteid").val('');
355 $
("#new_note").submit();
358 var AppendNote
= function () {
359 top
.restoreSession();
360 $
("#new_note").submit();
363 var PrintNote
= function () {
364 top
.restoreSession();
365 window
.open('pnotes_print.php?noteid=<?php echo htmlspecialchars( $noteid, ENT_QUOTES); ?>', '_blank', 'resizable=1,scrollbars=1,width=600,height=500');
368 var DeleteNote
= function(note
) {
369 if (confirm("<?php echo htmlspecialchars( xl('Are you sure you want to delete this note?','','','\n ').xl('This action CANNOT be undone.'), ENT_QUOTES); ?>")) {
370 top
.restoreSession();
371 // strip the 'del' part of the object's ID
372 $
("#noteid").val(note
.id
.replace(/del
/, ""));
373 $
("#mode").val("delete");
374 $
("#new_note").submit();
379 $
(document
).ready(function(){
380 $
("#cancel").click(function() {
381 parent
.$
.fn
.fancybox
.close();