Change form select interface so picking form from select menu automatically jumps...
[openemr.git] / interface / patient_file / summary / pnotes_full.php
blobcf5e637fafb776e0bee1dd2a91fdc8279eecb069
1 <?
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
16 $N = 25;
18 $note_types = array(
19 'Unassigned',
20 'Chart Note',
21 'Insurance',
22 'New Document',
23 'Pharmacy',
24 'Prior Auth',
25 'Referral',
26 'Test Scheduling',
27 'Other');
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
39 if (isset($mode)) {
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"]) {
45 reappearPnote($id);
46 } else {
47 disappearPnote($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);
56 if ($noteid) {
57 updatePnote($noteid, $note, $_POST['title'], $_POST['assigned_to']);
58 $noteid = '';
60 else {
61 addPnote($pid, $note, $userauthorized, '1', $_POST['title'],
62 $_POST['assigned_to']);
67 $title = '';
68 $assigned_to = $_SESSION['authUser'];
69 if ($noteid) {
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");
79 <html>
80 <head>
82 <link rel='stylesheet' href="<?echo $css_header;?>" type="text/css">
84 </head>
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>
92 </a>
93 <br>
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 ?>">
100 <center>
102 <table border='0' cellspacing='8'>
103 <tr>
104 <td class='text' align='center'>
105 <?php
106 if ($noteid) {
107 echo "<b>".xl('Amend Existing Note')." &quot;$title&quot;</b>\n";
108 } else {
109 echo "<b>".xl('Add New Note')."</b>\n";
112 </td>
113 </tr>
114 <tr>
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";
125 </select>
126 &nbsp; &nbsp;
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'];
135 echo "</option>\n";
138 <option value=''>** <? xl('Close','e'); ?> **</option>
139 </select>
140 </td>
141 </tr>
142 <tr>
143 <td>
144 <textarea name='note' rows='4' cols='80' wrap='virtual'></textarea>
145 </td>
146 </tr>
147 </table>
149 <a href="javascript:document.new_note.submit();" class='link_submit'>
150 <?php if ($noteid) { ?>
151 [<? xl('Append to This Note','e'); ?>]
152 <?php } else { ?>
153 [<? xl('Add New Note','e'); ?>]
154 <?php } ?>
155 </a>
156 <br>
157 </form>
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";
172 <br>
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">
183 <table border='0'>
184 <tr>
185 <td colspan='3' align='left'>
186 <a href="javascript:document.update_activity.submit();" class='link_submit'>[<? xl('Change Activity','e'); ?>]</a>
187 </td>
188 </tr>
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
192 //retrieve all notes
194 if ($result = getPnotesByDate("", $active,
195 'id,date,body,user,activity,title,assigned_to', $pid, $N, $offset))
197 $result_count = 0;
198 foreach ($result as $iter) {
199 $result_count++;
201 // if (getdate() == strtotime($iter{"date"})) {
202 // $date_string = "Today, " . date( "D F jS" ,strtotime($iter{"date"}));
203 // } else {
204 // $date_string = date( "D F jS" ,strtotime($iter{"date"}));
205 // }
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);
210 } else {
211 $body = date('Y-m-d H:i', strtotime($iter['date'])) .
212 ' (' . $iter['user'] . ') ' . nl2br($body);
215 if ($iter{"activity"}) {
216 $checked = "checked";
217 } else {
218 $checked = "";
221 echo " <tr>\n";
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";
229 echo " </td>\n";
230 echo " <td valign='top'>\n";
231 echo " <font class='text'>$body</font>\n";
232 echo " </td>\n";
233 echo " </tr>\n";
235 $notes_count++;
237 } else {
238 //no results
239 print "<tr><td></td><td></td></tr>\n";
243 <tr>
244 <td colspan='3' align='left'>
245 <a href="javascript:document.update_activity.submit();" class='link_submit'>[<? xl('Change Activity','e'); ?>]</a>
246 </td>
247 </tr>
249 </table>
250 </form>
252 <table width='400' border='0' cellpadding='0' cellspacing='0'>
253 <tr>
254 <td>
256 if ($offset > ($N-1)) {
257 echo " <a class='link' href='pnotes_full.php?active=" . $active . "&offset=" . ($offset-$N) . "'>[".xl('Previous')."]</a>\n";
260 </td>
261 <td align='right'>
263 if ($result_count == $N) {
264 echo " <a class='link' href='pnotes_full.php?active=" . $active . "&offset=" . ($offset+$N) . "'>[".xl('Next')."]</a>\n";
267 </td>
268 </tr>
269 </table>
271 </center>
273 <?php
274 // If this note references a new patient document, pop up a display
275 // of that document.
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');
286 </script>
287 <?php
292 </body>
293 </html>