2 include_once("../../globals.php");
3 include_once("$srcdir/pnotes.inc");
4 include_once("$srcdir/patient.inc");
5 include_once("$srcdir/acl.inc");
7 // Check authorization.
8 $thisauth = acl_check('patients', 'notes');
9 if ($thisauth != 'write' && $thisauth != 'addonly')
10 die("Not authorized.");
11 $tmp = getPatientData($pid, "squad");
12 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad']))
13 die("Not authorized for this squad.");
15 //the number of records to display per screen
29 $mode = $_REQUEST['mode'];
30 $offset = $_REQUEST['offset'];
31 $active = $_REQUEST['active'];
32 $noteid = $_REQUEST['noteid'];
34 if (!isset($offset)) $offset = 0;
35 if (!isset($active)) $active = "all";
37 // this code handles changing the state of activity tags when the user updates
38 // them through the interface
40 if ($mode == "update") {
41 foreach ($_POST as $var => $val) {
42 if (strncmp($var, 'act', 3) == 0) {
43 $id = str_replace("act", "", $var);
44 if ($_POST["chk$id"]) {
52 elseif ($mode == "new") {
53 $note = $_POST['note'];
54 // The subroutine will do its own addslashes().
55 if (get_magic_quotes_gpc()) $note = stripslashes($note);
57 updatePnote($noteid, $note, $_POST['title'], $_POST['assigned_to']);
61 addPnote($pid, $note, $userauthorized, '1', $_POST['title'],
62 $_POST['assigned_to']);
68 $assigned_to = $_SESSION['authUser'];
70 $prow = getPnoteById($noteid, 'title,assigned_to');
71 $title = $prow['title'];
72 $assigned_to = $prow['assigned_to'];
75 // Get the users list.
76 $ures = sqlStatement("SELECT username, fname, lname FROM users " .
77 "ORDER BY lname, fname");
82 <link rel
='stylesheet' href
="<?echo $css_header;?>" type
="text/css">
85 <body
<?
echo $top_bg_line;?
> topmargin
='0' rightmargin
='0' leftmargin
='2'
86 bottommargin
='0' marginwidth
='2' marginheight
='0'>
88 <form border
='0' method
='post' name
='new_note' action
='pnotes_full.php'>
90 <a href
="../summary/patient_summary.php" target
="Main">
91 <font
class='title'><?
xl('Patient Notes','e'); ?
></font
><font
class='back'>(<?
xl('Back','e'); ?
>)</font
>
95 <input type
='hidden' name
='mode' value
="new">
96 <input type
='hidden' name
='offset' value
="<? echo $offset ?>">
97 <input type
='hidden' name
='active' value
="<? echo $active ?>">
98 <input type
='hidden' name
='noteid' value
="<? echo $noteid ?>">
102 <table border
='0' cellspacing
='8'>
104 <td
class='text' align
='center'>
107 echo "<b>".xl('Amend Existing Note')." "$title"</b>\n";
109 echo "<b>".xl('Add New Note')."</b>\n";
115 <td
class='text' align
='center'>
116 <b
><?
xl('Type','e'); ?
>:</b
>
117 <select name
='title'>
119 foreach ($note_types as $value) {
120 echo " <option value='$value'";
121 if ($value == $title) echo " selected";
122 echo ">$value</option>\n";
127 <b
><?
xl('To','e'); ?
>:</b
>
128 <select name
='assigned_to'>
130 while ($urow = sqlFetchArray($ures)) {
131 echo " <option value='" . $urow['username'] . "'";
132 if ($urow['username'] == $assigned_to) echo " selected";
133 echo ">" . $urow['lname'];
134 if ($urow['fname']) echo ", " . $urow['fname'];
138 <option value
=''>** <?
xl('Close','e'); ?
> **</option
>
144 <textarea name
='note' rows
='4' cols
='80' wrap
='virtual'></textarea
>
149 <a href
="javascript:document.new_note.submit();" class='link_submit'>
150 <?php
if ($noteid) { ?
>
151 [<?
xl('Append to This Note','e'); ?
>]
153 [<?
xl('Add New Note','e'); ?
>]
159 <form border
='0' method
='post' name
='update_activity' action
="pnotes_full.php">
161 <?
//change the view on the current mode, whether all, active, or inactive
162 $all_class = "link"; $active_class = "link"; $inactive_class = "link";
163 if ($active=="all") {
164 $all_class="link_selected";
165 } elseif ($active==1) {
166 $active_class="link_selected";
167 } elseif ($active==0) {
168 $inactive_class="link_selected";
173 <font
class='text'><?
xl('View','e'); ?
>: </font
>
174 <a href
="pnotes_full.php?offset=0&active=all" class='<?echo $all_class;?>'>[<?
xl('All','e'); ?
>]</a
>
175 <a href
="pnotes_full.php?offset=0&active=1" class='<?echo $active_class;?>'>[<?
xl('Only Active','e'); ?
>]</a
>
176 <a href
="pnotes_full.php?offset=0&active=0" class='<?echo $inactive_class;?>'>[<?
xl('Only Inactive','e'); ?
>]</a
>
178 <input type
='hidden' name
='mode' value
="update">
179 <input type
='hidden' name
='offset' value
="<?echo $offset;?>">
180 <input type
='hidden' name
='active' value
="<?echo $active;?>">
181 <input type
='hidden' name
='noteid' value
="0">
185 <td colspan
='3' align
='left'>
186 <a href
="javascript:document.update_activity.submit();" class='link_submit'>[<?
xl('Change Activity','e'); ?
>]</a
>
190 //display all of the notes for the day, as well as others that are active from previous dates, up to a certain number, $N
194 if ($result = getPnotesByDate("", $active,
195 'id,date,body,user,activity,title,assigned_to', $pid, $N, $offset))
198 foreach ($result as $iter) {
201 // if (getdate() == strtotime($iter{"date"})) {
202 // $date_string = "Today, " . date( "D F jS" ,strtotime($iter{"date"}));
204 // $date_string = date( "D F jS" ,strtotime($iter{"date"}));
207 $body = $iter['body'];
208 if (preg_match('/^\d\d\d\d-\d\d-\d\d \d\d\:\d\d /', $body)) {
209 $body = nl2br($body);
211 $body = date('Y-m-d H:i', strtotime($iter['date'])) .
212 ' (' . $iter['user'] . ') ' . nl2br($body);
215 if ($iter{"activity"}) {
216 $checked = "checked";
222 echo " <td valign='top'>\n";
223 echo " <input type='hidden' name='act" . $iter{"id"} . "' value='1'>\n";
224 echo " <input type='checkbox' name='chk" . $iter{"id"} . "' $checked>\n";
226 echo " <a href='javascript:document.forms[1].noteid.value=" .
227 $iter['id'] . ";document.update_activity.submit();' " .
228 "class='link_submit'>" . $iter['title'] . "</a>\n";
230 echo " <td valign='top'>\n";
231 echo " <font class='text'>$body</font>\n";
239 print "<tr><td></td><td></td></tr>\n";
244 <td colspan
='3' align
='left'>
245 <a href
="javascript:document.update_activity.submit();" class='link_submit'>[<?
xl('Change Activity','e'); ?
>]</a
>
252 <table width
='400' border
='0' cellpadding
='0' cellspacing
='0'>
256 if ($offset > ($N-1)) {
257 echo " <a class='link' href='pnotes_full.php?active=" . $active . "&offset=" . ($offset-$N) . "'>[".xl('Previous')."]</a>\n";
263 if ($result_count == $N) {
264 echo " <a class='link' href='pnotes_full.php?active=" . $active . "&offset=" . ($offset+
$N) . "'>[".xl('Next')."]</a>\n";
274 // If this note references a new patient document, pop up a display
277 if ($noteid && $title == 'New Document') {
278 $prow = getPnoteById($noteid, 'body');
279 if (preg_match('/New scanned document (\d+): [^\n]+\/([^\n]+)/', $prow['body'], $matches)) {
280 $docid = $matches[1];
281 $docname = $matches[2];
283 <script language
="JavaScript">
284 window
.open('../../../controller.php?document&retrieve&patient_id=<?php echo $pid ?>&document_id=<?php echo $docid ?>&<?php echo $docname?>&as_file=true',
285 '_blank', 'resizable=1,scrollbars=1,width=600,height=500');