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