Session fixes in the patient notes module
[openemr.git] / interface / patient_file / summary / pnotes_fragment.php
blob3a621f5ebceb3af2b5c0fbeb3a71309478d2248b
1 <?php
2 /**
3 * Display patient notes.
5 * LICENSE: This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 3
8 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
16 * @package OpenEMR
17 * @author Brady Miller <brady@sparmy.com>
18 * @link http://www.open-emr.org
21 //SANITIZE ALL ESCAPES
22 $sanitize_all_escapes=true;
25 //STOP FAKE REGISTER GLOBALS
26 $fake_register_globals=false;
29 require_once("../../globals.php");
30 require_once("$srcdir/pnotes.inc");
31 require_once("$srcdir/acl.inc");
32 require_once("$srcdir/patient.inc");
33 require_once("$srcdir/options.inc.php");
34 require_once("$srcdir/classes/Document.class.php");
35 require_once("$srcdir/formatting.inc.php");
37 // form parameter docid can be passed to restrict the display to a document.
38 $docid = empty($_REQUEST['docid']) ? 0 : 0 + $_REQUEST['docid'];
40 <ul class="tabNav">
41 <li class="current" ><a href="#"><?php echo htmlspecialchars(xl('Inbox'),ENT_NOQUOTES); ?></a></li>
42 <li><a href="#"><?php echo htmlspecialchars(xl('Sent Items'),ENT_NOQUOTES); ?></a></li>
43 </ul>
44 <div class='tabContainer' >
45 <div class='tab current' >
46 <?php
47 //display all of the notes for the day, as well as others that are active from previous dates, up to a certain number, $N
48 $N = 3; ?>
50 <br/>
52 <?php
54 $has_note = 0;
55 $thisauth = acl_check('patients', 'notes');
56 if ($thisauth) {
57 $tmp = getPatientData($pid, "squad");
58 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad']))
59 $thisauth = 0;
61 if (!$thisauth) {
62 echo "<p>(" . htmlspecialchars(xl('Notes not authorized'),ENT_NOQUOTES) . ")</p>\n";
63 } else { ?>
64 <table width='100%' border='0' cellspacing='1' cellpadding='1' style='border-collapse:collapse;' >
65 <?php
67 $pres = getPatientData($pid,"lname, fname");
68 $patientname = $pres['lname'] . ", " . $pres['fname'];
69 //retrieve all active notes
70 $result = getPnotesByDate("", 1, "id,date,body,user,title,assigned_to,message_status",
71 $pid, "$N", 0, '', $docid);
73 if ($result != null) {
74 $notes_count = 0;//number of notes so far displayed
75 echo "<tr class='text' style='border-bottom:2px solid #000;' >\n";
76 echo "<td valign='top' class='text' ><b>". htmlspecialchars(xl('From'),ENT_NOQUOTES) ."</b></td>\n";
77 echo "<td valign='top' class='text' ><b>". htmlspecialchars(xl('Date'),ENT_NOQUOTES) ."</b></td>\n";
78 echo "<td valign='top' class='text' ><b>". htmlspecialchars(xl('Subject'),ENT_NOQUOTES) ."</b></td>\n";
79 echo "<td valign='top' class='text' ><b>". htmlspecialchars(xl('Content'),ENT_NOQUOTES) ."</b></td>\n";
80 echo "<td valign='top' class='text' ><b>". htmlspecialchars(xl('Status'),ENT_NOQUOTES) ."</b></td>\n";
81 echo "</tr>\n";
82 foreach ($result as $iter) {
83 $has_note = 1;
85 $body = $iter['body'];
86 if (preg_match('/^\d\d\d\d-\d\d-\d\d \d\d\:\d\d /', $body)) {
87 $body = nl2br(htmlspecialchars(oeFormatPatientNote($body),ENT_NOQUOTES));
88 } else {
89 $body = htmlspecialchars(oeFormatSDFT(strtotime($iter['date'])) . date(' H:i', strtotime($iter['date'])) .
90 ' (' . $iter['user'] . ') ',ENT_NOQUOTES) .
91 nl2br(htmlspecialchars(oeFormatPatientNote($body),ENT_NOQUOTES));
93 $body = preg_replace('/(\sto\s)-patient-(\))/','${1}'.$patientname.'${2}',$body);
94 $body = strlen($body) > 120 ? substr($body,0,120)."<b>.......</b>" : $body;
95 echo " <tr class='text' id='".htmlspecialchars($iter['id'],ENT_QUOTES)."' style='border-bottom:1px dashed;height:30px;' >\n";
97 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
98 echo "<td valign='top' class='text'>".htmlspecialchars($iter['user'],ENT_NOQUOTES)."</td>\n";
99 echo "<td valign='top' class='text'>".htmlspecialchars($iter['date'],ENT_NOQUOTES)."</td>\n";
100 echo " <td valign='top' class='text'><b>";
101 echo generate_display_field(array('data_type'=>'1','list_id'=>'note_type'), $iter['title']);
102 echo "</b></td>\n";
104 echo " <td valign='top' class='text'>$body</td>\n";
105 echo " <td valign='top' class='text'>";
106 echo generate_display_field(array('data_type'=>'1','list_id'=>'message_status'), $iter['message_status']);
107 echo "</td>\n";
108 echo " </tr>\n";
110 $notes_count++;
112 } ?>
114 </table>
116 <?php
117 if ($has_note < 1 ) { ?>
118 <span class='text'>
119 <?php echo htmlspecialchars(xl( "There are no notes on file for this patient."),ENT_NOQUOTES);
120 echo " ";
121 echo "<a href='pnotes_full.php' onclick='top.restoreSession()'>";
122 echo htmlspecialchars(xl("To add notes, please click here"),ENT_NOQUOTES);
123 echo "</a>."; ?>
124 </span>
125 <?php } else {
127 <br/>
128 <span class='text'>
129 <?php echo htmlspecialchars(xl('Displaying the following number of most recent notes:'),ENT_NOQUOTES); ?>
130 <b><?php echo $N;?></b><br>
131 <a href='pnotes_full.php?s=0' onclick='top.restoreSession()'><?php echo htmlspecialchars(xl('Click here to view them all.'),ENT_NOQUOTES); ?></a>
132 </span>
133 <?php
134 } ?>
136 <br/>
137 <br/>
139 <?php } ?>
140 </div>
141 <div class='tab'>
142 <?php
143 //display all of the notes for the day, as well as others that are active from previous dates, up to a certain number, $N
144 $M = 3; ?>
145 <br/>
146 <?php
147 $has_sent_note = 0;
148 if (!$thisauth) {
149 echo "<p>(" . htmlspecialchars(xl('Notes not authorized'),ENT_NOQUOTES) . ")</p>\n";
150 } else { ?>
151 <table width='100%' border='0' cellspacing='1' cellpadding='1' style='border-collapse:collapse;' >
152 <?php
153 //retrieve all active notes
154 $result_sent = getSentPnotesByDate("", 1, "id,date,body,user,title,assigned_to,pid",
155 $pid, "$M", 0, '', $docid);
156 if ($result_sent != null) {
157 $notes_sent_count = 0;//number of notes so far displayed
158 echo "<tr class='text' style='border-bottom:2px solid #000;' >\n";
159 echo "<td valign='top' class='text' ><b>". htmlspecialchars(xl('To'),ENT_NOQUOTES) ."</b></td>\n";
160 echo "<td valign='top' class='text' ><b>". htmlspecialchars(xl('Date'),ENT_NOQUOTES) ."</b></td>\n";
161 echo "<td valign='top' class='text' ><b>". htmlspecialchars(xl('Subject'),ENT_NOQUOTES) ."</b></td>\n";
162 echo "<td valign='top' class='text' ><b>". htmlspecialchars(xl('Content'),ENT_NOQUOTES) ."</b></td>\n";
163 echo "</tr>\n";
164 foreach ($result_sent as $iter) {
165 $has_sent_note = 1;
166 $body = $iter['body'];
167 if (preg_match('/^\d\d\d\d-\d\d-\d\d \d\d\:\d\d /', $body)) {
168 $body = nl2br(htmlspecialchars(oeFormatPatientNote($body),ENT_NOQUOTES));
169 } else {
170 $body = htmlspecialchars(oeFormatSDFT(strtotime($iter['date'])) . date(' H:i', strtotime($iter['date'])) .
171 ' (' . $iter['user'] . ') ',ENT_NOQUOTES) .
172 nl2br(htmlspecialchars(oeFormatPatientNote($body),ENT_NOQUOTES));
174 $body = preg_replace('/(:\d{2}\s\()'.$iter['pid'].'(\sto\s)/','${1}'.$patientname.'${2}',$body);
175 $body = strlen($body) > 120 ? substr($body,0,120)."<b>.......</b>" : $body;
176 echo " <tr class='text' id='".htmlspecialchars($iter['id'],ENT_QUOTES)."' style='border-bottom:1px dashed;height:30px;' >\n";
177 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
178 echo "<td valign='top' class='text'>".htmlspecialchars($iter['assigned_to'],ENT_NOQUOTES)."</td>\n";
179 echo "<td valign='top' class='text'>".htmlspecialchars($iter['date'],ENT_NOQUOTES)."</td>\n";
180 echo " <td valign='top' class='text'><b>";
181 echo generate_display_field(array('data_type'=>'1','list_id'=>'note_type'), $iter['title']);
182 echo "</b></td>\n";
183 echo " <td valign='top' class='text'>$body</td>\n";
184 echo " </tr>\n";
185 $notes_sent_count++;
187 } ?>
188 </table>
189 <?php
190 if ($has_sent_note < 1 ) { ?>
191 <span class='text'>
192 <?php echo htmlspecialchars(xl( "There are no notes on file for this patient."),ENT_NOQUOTES);
193 echo " ";
194 echo "<a href='pnotes_full.php' onclick='top.restoreSession()'>";
195 echo htmlspecialchars(xl("To add notes, please click here"),ENT_NOQUOTES);
196 echo "</a>."; ?>
197 </span>
198 <?php } else {
200 <br/>
201 <span class='text'>
202 <?php echo htmlspecialchars(xl('Displaying the following number of most recent notes'),ENT_NOQUOTES).":"; ?>
203 <b><?php echo $M;?></b><br>
204 <a href='pnotes_full.php?s=1' onclick='top.restoreSession()'><?php echo htmlspecialchars(xl('Click here to view them all.'),ENT_NOQUOTES); ?></a>
205 </span>
206 <?php
207 } ?>
208 <br/>
209 <br/>
210 <?php } ?>
211 </div>
212 </div>
214 <script language="javascript">
215 // jQuery stuff to make the page a little easier to use
217 tabbify();
219 $(document).ready(function(){
220 $(".noterow").mouseover(function() { $(this).toggleClass("highlight"); });
221 $(".noterow").mouseout(function() { $(this).toggleClass("highlight"); });
224 </script>