9b0139d9eb119b50fec3d85aeb062ddbe7dd733f
[openemr.git] / interface / patient_file / summary / pnotes_fragment.php
blob9b0139d9eb119b50fec3d85aeb062ddbe7dd733f
1 <?php
2 // This program is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU General Public License
4 // as published by the Free Software Foundation; either version 2
5 // of the License, or (at your option) any later version.
7 //SANITIZE ALL ESCAPES
8 $sanitize_all_escapes=true;
9 //
11 //STOP FAKE REGISTER GLOBALS
12 $fake_register_globals=false;
15 require_once("../../globals.php");
16 require_once("$srcdir/pnotes.inc");
17 require_once("$srcdir/acl.inc");
18 require_once("$srcdir/patient.inc");
19 require_once("$srcdir/options.inc.php");
20 require_once("$srcdir/classes/Document.class.php");
21 require_once("$srcdir/formatting.inc.php");
23 // form parameter docid can be passed to restrict the display to a document.
24 $docid = empty($_REQUEST['docid']) ? 0 : 0 + $_REQUEST['docid'];
26 <ul class="tabNav">
27 <li class="current" ><a href="#"><?php echo htmlspecialchars(xl('Inbox'),ENT_NOQUOTES); ?></a></li>
28 <li><a href="#"><?php echo htmlspecialchars(xl('Sent Items'),ENT_NOQUOTES); ?></a></li>
29 </ul>
30 <div class='tabContainer' >
31 <div class='tab current' >
32 <?php
33 //display all of the notes for the day, as well as others that are active from previous dates, up to a certain number, $N
34 $N = 3; ?>
36 <br/>
38 <?php
40 $has_note = 0;
41 $thisauth = acl_check('patients', 'notes');
42 if ($thisauth) {
43 $tmp = getPatientData($pid, "squad");
44 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad']))
45 $thisauth = 0;
47 if (!$thisauth) {
48 echo "<p>(" . htmlspecialchars(xl('Notes not authorized'),ENT_NOQUOTES) . ")</p>\n";
49 } else { ?>
50 <table width='100%' border='0' cellspacing='1' cellpadding='1' style='border-collapse:collapse;' >
51 <?php
53 $pres = getPatientData($pid,"lname, fname");
54 $patientname = $pres['lname'] . ", " . $pres['fname'];
55 //retrieve all active notes
56 $result = getPnotesByDate("", 1, "id,date,body,user,title,assigned_to,message_status",
57 $pid, "$N", 0, '', $docid);
59 if ($result != null) {
60 $notes_count = 0;//number of notes so far displayed
61 echo "<tr class='text' style='border-bottom:2px solid #000;' >\n";
62 echo "<td valign='top' class='text' ><b>". htmlspecialchars(xl('From'),ENT_NOQUOTES) ."</b></td>\n";
63 echo "<td valign='top' class='text' ><b>". htmlspecialchars(xl('Date'),ENT_NOQUOTES) ."</b></td>\n";
64 echo "<td valign='top' class='text' ><b>". htmlspecialchars(xl('Subject'),ENT_NOQUOTES) ."</b></td>\n";
65 echo "<td valign='top' class='text' ><b>". htmlspecialchars(xl('Content'),ENT_NOQUOTES) ."</b></td>\n";
66 echo "<td valign='top' class='text' ><b>". htmlspecialchars(xl('Status'),ENT_NOQUOTES) ."</b></td>\n";
67 echo "</tr>\n";
68 foreach ($result as $iter) {
69 $has_note = 1;
71 $body = $iter['body'];
72 if (preg_match('/^\d\d\d\d-\d\d-\d\d \d\d\:\d\d /', $body)) {
73 $body = nl2br(htmlspecialchars(oeFormatPatientNote($body),ENT_NOQUOTES));
74 } else {
75 $body = htmlspecialchars(oeFormatSDFT(strtotime($iter['date'])) . date(' H:i', strtotime($iter['date'])) .
76 ' (' . $iter['user'] . ') ',ENT_NOQUOTES) .
77 nl2br(htmlspecialchars(oeFormatPatientNote($body),ENT_NOQUOTES));
79 $body = preg_replace('/(\sto\s)-patient-(\))/','${1}'.$patientname.'${2}',$body);
80 $body = strlen($body) > 120 ? substr($body,0,120)."<b>.......</b>" : $body;
81 echo " <tr class='text' id='".htmlspecialchars($iter['id'],ENT_QUOTES)."' style='border-bottom:1px dashed;height:30px;' >\n";
83 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
84 echo "<td valign='top' class='text'>".htmlspecialchars($iter['user'],ENT_NOQUOTES)."</td>\n";
85 echo "<td valign='top' class='text'>".htmlspecialchars($iter['date'],ENT_NOQUOTES)."</td>\n";
86 echo " <td valign='top' class='text'><b>";
87 echo generate_display_field(array('data_type'=>'1','list_id'=>'note_type'), $iter['title']);
88 echo "</b></td>\n";
90 echo " <td valign='top' class='text'>$body</td>\n";
91 echo " <td valign='top' class='text'>";
92 echo generate_display_field(array('data_type'=>'1','list_id'=>'message_status'), $iter['message_status']);
93 echo "</td>\n";
94 echo " </tr>\n";
96 $notes_count++;
98 } ?>
100 </table>
102 <?php
103 if ($has_note < 1 ) { ?>
104 <span class='text'>
105 <?php echo htmlspecialchars(xl( "There are no notes on file for this patient."),ENT_NOQUOTES);
106 echo " ";
107 echo "<a href='pnotes_full.php'>";
108 echo htmlspecialchars(xl("To add notes, please click here"),ENT_NOQUOTES);
109 echo "</a>."; ?>
110 </span>
111 <?php } else {
113 <br/>
114 <span class='text'>
115 <?php echo htmlspecialchars(xl('Displaying the following number of most recent notes:'),ENT_NOQUOTES); ?>
116 <b><?php echo $N;?></b><br>
117 <a href='pnotes_full.php?s=0'><?php echo htmlspecialchars(xl('Click here to view them all.'),ENT_NOQUOTES); ?></a>
118 </span>
119 <?php
120 } ?>
122 <br/>
123 <br/>
125 <?php } ?>
126 </div>
127 <div class='tab'>
128 <?php
129 //display all of the notes for the day, as well as others that are active from previous dates, up to a certain number, $N
130 $M = 3; ?>
131 <br/>
132 <?php
133 $has_sent_note = 0;
134 if (!$thisauth) {
135 echo "<p>(" . htmlspecialchars(xl('Notes not authorized'),ENT_NOQUOTES) . ")</p>\n";
136 } else { ?>
137 <table width='100%' border='0' cellspacing='1' cellpadding='1' style='border-collapse:collapse;' >
138 <?php
139 //retrieve all active notes
140 $result_sent = getSentPnotesByDate("", 1, "id,date,body,user,title,assigned_to,pid",
141 $pid, "$M", 0, '', $docid);
142 if ($result_sent != null) {
143 $notes_sent_count = 0;//number of notes so far displayed
144 echo "<tr class='text' style='border-bottom:2px solid #000;' >\n";
145 echo "<td valign='top' class='text' ><b>". htmlspecialchars(xl('To'),ENT_NOQUOTES) ."</b></td>\n";
146 echo "<td valign='top' class='text' ><b>". htmlspecialchars(xl('Date'),ENT_NOQUOTES) ."</b></td>\n";
147 echo "<td valign='top' class='text' ><b>". htmlspecialchars(xl('Subject'),ENT_NOQUOTES) ."</b></td>\n";
148 echo "<td valign='top' class='text' ><b>". htmlspecialchars(xl('Content'),ENT_NOQUOTES) ."</b></td>\n";
149 echo "</tr>\n";
150 foreach ($result_sent as $iter) {
151 $has_sent_note = 1;
152 $body = $iter['body'];
153 if (preg_match('/^\d\d\d\d-\d\d-\d\d \d\d\:\d\d /', $body)) {
154 $body = nl2br(htmlspecialchars(oeFormatPatientNote($body),ENT_NOQUOTES));
155 } else {
156 $body = htmlspecialchars(oeFormatSDFT(strtotime($iter['date'])) . date(' H:i', strtotime($iter['date'])) .
157 ' (' . $iter['user'] . ') ',ENT_NOQUOTES) .
158 nl2br(htmlspecialchars(oeFormatPatientNote($body),ENT_NOQUOTES));
160 $body = preg_replace('/(:\d{2}\s\()'.$iter['pid'].'(\sto\s)/','${1}'.$patientname.'${2}',$body);
161 $body = strlen($body) > 120 ? substr($body,0,120)."<b>.......</b>" : $body;
162 echo " <tr class='text' id='".htmlspecialchars($iter['id'],ENT_QUOTES)."' style='border-bottom:1px dashed;height:30px;' >\n";
163 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
164 echo "<td valign='top' class='text'>".htmlspecialchars($iter['assigned_to'],ENT_NOQUOTES)."</td>\n";
165 echo "<td valign='top' class='text'>".htmlspecialchars($iter['date'],ENT_NOQUOTES)."</td>\n";
166 echo " <td valign='top' class='text'><b>";
167 echo generate_display_field(array('data_type'=>'1','list_id'=>'note_type'), $iter['title']);
168 echo "</b></td>\n";
169 echo " <td valign='top' class='text'>$body</td>\n";
170 echo " </tr>\n";
171 $notes_sent_count++;
173 } ?>
174 </table>
175 <?php
176 if ($has_sent_note < 1 ) { ?>
177 <span class='text'>
178 <?php echo htmlspecialchars(xl( "There are no notes on file for this patient."),ENT_NOQUOTES);
179 echo " ";
180 echo "<a href='pnotes_full.php'>";
181 echo htmlspecialchars(xl("To add notes, please click here"),ENT_NOQUOTES);
182 echo "</a>."; ?>
183 </span>
184 <?php } else {
186 <br/>
187 <span class='text'>
188 <?php echo htmlspecialchars(xl('Displaying the following number of most recent notes'),ENT_NOQUOTES).":"; ?>
189 <b><?php echo $M;?></b><br>
190 <a href='pnotes_full.php?s=1'><?php echo htmlspecialchars(xl('Click here to view them all.'),ENT_NOQUOTES); ?></a>
191 </span>
192 <?php
193 } ?>
194 <br/>
195 <br/>
196 <?php } ?>
197 </div>
198 </div>
200 <script language="javascript">
201 // jQuery stuff to make the page a little easier to use
203 tabbify();
205 $(document).ready(function(){
206 $(".noterow").mouseover(function() { $(this).toggleClass("highlight"); });
207 $(".noterow").mouseout(function() { $(this).toggleClass("highlight"); });
210 </script>