Interim autoloaded library/classes via composer classmap, take 4. (#422)
[openemr.git] / interface / patient_file / summary / pnotes_fragment.php
blob360e2bf4f7a6748b024c48d9d910c78348720f62
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/formatting.inc.php");
36 // form parameter docid can be passed to restrict the display to a document.
37 $docid = empty($_REQUEST['docid']) ? 0 : 0 + $_REQUEST['docid'];
39 <ul class="tabNav">
40 <li class="current" ><a href="#"><?php echo htmlspecialchars(xl('Inbox'),ENT_NOQUOTES); ?></a></li>
41 <li><a href="#"><?php echo htmlspecialchars(xl('Sent Items'),ENT_NOQUOTES); ?></a></li>
42 </ul>
43 <div class='tabContainer' >
44 <div class='tab current' >
45 <?php
46 //display all of the notes for the day, as well as others that are active from previous dates, up to a certain number, $N
47 $N = 3; ?>
49 <br/>
51 <?php
53 $has_note = 0;
54 $thisauth = acl_check('patients', 'notes');
55 if ($thisauth) {
56 $tmp = getPatientData($pid, "squad");
57 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad']))
58 $thisauth = 0;
60 if (!$thisauth) {
61 echo "<p>(" . htmlspecialchars(xl('Notes not authorized'),ENT_NOQUOTES) . ")</p>\n";
62 } else { ?>
63 <table width='100%' border='0' cellspacing='1' cellpadding='1' style='border-collapse:collapse;' >
64 <?php
66 $pres = getPatientData($pid,"lname, fname");
67 $patientname = $pres['lname'] . ", " . $pres['fname'];
68 //retrieve all active notes
69 $result = getPnotesByDate("", 1, "id,date,body,user,title,assigned_to,message_status",
70 $pid, "$N", 0, '', $docid);
72 if ($result != null) {
73 $notes_count = 0;//number of notes so far displayed
74 echo "<tr class='text' style='border-bottom:2px solid #000;' >\n";
75 echo "<td valign='top' class='text' ><b>". htmlspecialchars(xl('From'),ENT_NOQUOTES) ."</b></td>\n";
76 echo "<td valign='top' class='text' ><b>". htmlspecialchars(xl('Date'),ENT_NOQUOTES) ."</b></td>\n";
77 echo "<td valign='top' class='text' ><b>". htmlspecialchars(xl('Subject'),ENT_NOQUOTES) ."</b></td>\n";
78 echo "<td valign='top' class='text' ><b>". htmlspecialchars(xl('Content'),ENT_NOQUOTES) ."</b></td>\n";
79 echo "<td valign='top' class='text' ><b>". htmlspecialchars(xl('Status'),ENT_NOQUOTES) ."</b></td>\n";
80 echo "</tr>\n";
81 foreach ($result as $iter) {
82 $has_note = 1;
84 $body = $iter['body'];
85 if (preg_match('/^\d\d\d\d-\d\d-\d\d \d\d\:\d\d /', $body)) {
86 $body = nl2br(htmlspecialchars(oeFormatPatientNote($body),ENT_NOQUOTES));
87 } else {
88 $body = htmlspecialchars(oeFormatSDFT(strtotime($iter['date'])) . date(' H:i', strtotime($iter['date'])) .
89 ' (' . $iter['user'] . ') ',ENT_NOQUOTES) .
90 nl2br(htmlspecialchars(oeFormatPatientNote($body),ENT_NOQUOTES));
92 $body = preg_replace('/(\sto\s)-patient-(\))/','${1}'.$patientname.'${2}',$body);
93 $body = strlen($body) > 120 ? substr($body,0,120)."<b>.......</b>" : $body;
94 echo " <tr class='text' id='".htmlspecialchars($iter['id'],ENT_QUOTES)."' style='border-bottom:1px dashed;height:30px;' >\n";
96 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
97 echo "<td valign='top' class='text'>".htmlspecialchars($iter['user'],ENT_NOQUOTES)."</td>\n";
98 echo "<td valign='top' class='text'>".htmlspecialchars($iter['date'],ENT_NOQUOTES)."</td>\n";
99 echo " <td valign='top' class='text'><b>";
100 echo generate_display_field(array('data_type'=>'1','list_id'=>'note_type'), $iter['title']);
101 echo "</b></td>\n";
103 echo " <td valign='top' class='text'>$body</td>\n";
104 echo " <td valign='top' class='text'>";
105 echo generate_display_field(array('data_type'=>'1','list_id'=>'message_status'), $iter['message_status']);
106 echo "</td>\n";
107 echo " </tr>\n";
109 $notes_count++;
111 } ?>
113 </table>
115 <?php
116 if ($has_note < 1 ) { ?>
117 <span class='text'>
118 <?php echo htmlspecialchars(xl( "There are no notes on file for this patient."),ENT_NOQUOTES);
119 echo " ";
120 echo "<a href='pnotes_full.php' onclick='top.restoreSession()'>";
121 echo htmlspecialchars(xl("To add notes, please click here"),ENT_NOQUOTES);
122 echo "</a>."; ?>
123 </span>
124 <?php } else {
126 <br/>
127 <span class='text'>
128 <?php echo htmlspecialchars(xl('Displaying the following number of most recent notes:'),ENT_NOQUOTES); ?>
129 <b><?php echo $N;?></b><br>
130 <a href='pnotes_full.php?s=0' onclick='top.restoreSession()'><?php echo htmlspecialchars(xl('Click here to view them all.'),ENT_NOQUOTES); ?></a>
131 </span>
132 <?php
133 } ?>
135 <br/>
136 <br/>
138 <?php } ?>
139 </div>
140 <div class='tab'>
141 <?php
142 //display all of the notes for the day, as well as others that are active from previous dates, up to a certain number, $N
143 $M = 3; ?>
144 <br/>
145 <?php
146 $has_sent_note = 0;
147 if (!$thisauth) {
148 echo "<p>(" . htmlspecialchars(xl('Notes not authorized'),ENT_NOQUOTES) . ")</p>\n";
149 } else { ?>
150 <table width='100%' border='0' cellspacing='1' cellpadding='1' style='border-collapse:collapse;' >
151 <?php
152 //retrieve all active notes
153 $result_sent = getSentPnotesByDate("", 1, "id,date,body,user,title,assigned_to,pid",
154 $pid, "$M", 0, '', $docid);
155 if ($result_sent != null) {
156 $notes_sent_count = 0;//number of notes so far displayed
157 echo "<tr class='text' style='border-bottom:2px solid #000;' >\n";
158 echo "<td valign='top' class='text' ><b>". htmlspecialchars(xl('To'),ENT_NOQUOTES) ."</b></td>\n";
159 echo "<td valign='top' class='text' ><b>". htmlspecialchars(xl('Date'),ENT_NOQUOTES) ."</b></td>\n";
160 echo "<td valign='top' class='text' ><b>". htmlspecialchars(xl('Subject'),ENT_NOQUOTES) ."</b></td>\n";
161 echo "<td valign='top' class='text' ><b>". htmlspecialchars(xl('Content'),ENT_NOQUOTES) ."</b></td>\n";
162 echo "</tr>\n";
163 foreach ($result_sent as $iter) {
164 $has_sent_note = 1;
165 $body = $iter['body'];
166 if (preg_match('/^\d\d\d\d-\d\d-\d\d \d\d\:\d\d /', $body)) {
167 $body = nl2br(htmlspecialchars(oeFormatPatientNote($body),ENT_NOQUOTES));
168 } else {
169 $body = htmlspecialchars(oeFormatSDFT(strtotime($iter['date'])) . date(' H:i', strtotime($iter['date'])) .
170 ' (' . $iter['user'] . ') ',ENT_NOQUOTES) .
171 nl2br(htmlspecialchars(oeFormatPatientNote($body),ENT_NOQUOTES));
173 $body = preg_replace('/(:\d{2}\s\()'.$iter['pid'].'(\sto\s)/','${1}'.$patientname.'${2}',$body);
174 $body = strlen($body) > 120 ? substr($body,0,120)."<b>.......</b>" : $body;
175 echo " <tr class='text' id='".htmlspecialchars($iter['id'],ENT_QUOTES)."' style='border-bottom:1px dashed;height:30px;' >\n";
176 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
177 echo "<td valign='top' class='text'>".htmlspecialchars($iter['assigned_to'],ENT_NOQUOTES)."</td>\n";
178 echo "<td valign='top' class='text'>".htmlspecialchars($iter['date'],ENT_NOQUOTES)."</td>\n";
179 echo " <td valign='top' class='text'><b>";
180 echo generate_display_field(array('data_type'=>'1','list_id'=>'note_type'), $iter['title']);
181 echo "</b></td>\n";
182 echo " <td valign='top' class='text'>$body</td>\n";
183 echo " </tr>\n";
184 $notes_sent_count++;
186 } ?>
187 </table>
188 <?php
189 if ($has_sent_note < 1 ) { ?>
190 <span class='text'>
191 <?php echo htmlspecialchars(xl( "There are no notes on file for this patient."),ENT_NOQUOTES);
192 echo " ";
193 echo "<a href='pnotes_full.php' onclick='top.restoreSession()'>";
194 echo htmlspecialchars(xl("To add notes, please click here"),ENT_NOQUOTES);
195 echo "</a>."; ?>
196 </span>
197 <?php } else {
199 <br/>
200 <span class='text'>
201 <?php echo htmlspecialchars(xl('Displaying the following number of most recent notes'),ENT_NOQUOTES).":"; ?>
202 <b><?php echo $M;?></b><br>
203 <a href='pnotes_full.php?s=1' onclick='top.restoreSession()'><?php echo htmlspecialchars(xl('Click here to view them all.'),ENT_NOQUOTES); ?></a>
204 </span>
205 <?php
206 } ?>
207 <br/>
208 <br/>
209 <?php } ?>
210 </div>
211 </div>
213 <script language="javascript">
214 // jQuery stuff to make the page a little easier to use
216 tabbify();
218 $(document).ready(function(){
219 $(".noterow").mouseover(function() { $(this).toggleClass("highlight"); });
220 $(".noterow").mouseout(function() { $(this).toggleClass("highlight"); });
223 </script>