fix to immun expiration date print on shot record
[openemr.git] / interface / patient_file / summary / pnotes.php
blob9ea9bf5b2587b07196b1336365b1142501c08fd8
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");
36 // form parameter docid can be passed to restrict the display to a document.
37 $docid = empty($_REQUEST['docid']) ? 0 : intval($_REQUEST['docid']);
39 // form parameter orderid can be passed to restrict the display to a procedure order.
40 $orderid = empty($_REQUEST['orderid']) ? 0 : intval($_REQUEST['orderid']);
42 $patient_id = $pid;
43 if ($docid) {
44 $row = sqlQuery("SELECT foreign_id FROM documents WHERE id = ?", array($docid));
45 $patient_id = intval($row['foreign_id']);
47 else if ($orderid) {
48 $row = sqlQuery("SELECT patient_id FROM procedure_order WHERE procedure_order_id = ?", array($orderid));
49 $patient_id = intval($row['patient_id']);
51 $urlparms = "docid=$docid&orderid=$orderid";
53 <html>
54 <head>
55 <?php html_header_show();?>
57 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script>
58 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
60 </head>
61 <body class="body_bottom">
63 <?php
64 $thisauth = acl_check('patients', 'notes');
65 if ($thisauth) {
66 $tmp = getPatientData($patient_id, "squad");
67 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad']))
68 $thisauth = 0;
70 if (!$thisauth) {
71 echo "<p>(" . htmlspecialchars( xl('Notes not authorized'), ENT_NOQUOTES) . ")</p>\n";
72 echo "</body>\n</html>\n";
73 exit();
77 <div id='pnotes'>
79 <?php if ( acl_check('patients', 'notes','',array('write','addonly') )): ?>
81 <?php if ($GLOBALS['concurrent_layout']) { ?>
82 <a href="pnotes_full.php?<?php echo $urlparms; ?>" onclick="top.restoreSession()">
83 <?php } else { ?>
84 <a href="pnotes_full.php?<?php echo $urlparms; ?>" target="Main" onclick="top.restoreSession()">
85 <?php } ?>
87 <span class="title"><?php echo htmlspecialchars( xl('Notes'), ENT_NOQUOTES); ?>
88 <?php
89 if ($docid) {
90 echo " " . xlt("linked to document") . " ";
91 $d = new Document($docid);
92 echo $d->get_url_file();
94 else if ($orderid) {
95 echo " " . xlt("linked to procedure order") . " $orderid";
98 </span>
99 <span class=more><?php echo htmlspecialchars( $tmore, ENT_NOQUOTES);?></span>
100 </a>
101 <?php endif; ?>
103 <br>
105 <table>
107 <?php
108 //display all of the notes for the day, as well as others that are active from previous dates, up to a certain number, $N
109 $N = 15;
111 // Get the billing note if there is one.
112 $billing_note = "";
113 $colorbeg = "";
114 $colorend = "";
115 $sql = "select genericname2, genericval2 " .
116 "from patient_data where pid = ? limit 1";
117 $resnote = sqlQuery($sql, array($patient_id) );
118 if($resnote && $resnote['genericname2'] == 'Billing') {
119 $billing_note = $resnote['genericval2'];
120 $colorbeg = "<span style='color:red'>";
121 $colorend = "</span>";
124 //Display what the patient owes
125 $balance = get_patient_balance($patient_id);
126 if ($balance != "0") {
127 $formatted = sprintf((xl('$').'%01.2f'), $balance);
128 echo " <tr class='text billing'>\n";
129 echo " <td>" . $colorbeg . htmlspecialchars( xl('Balance Due'), ENT_NOQUOTES) .
130 $colorend . "</td><td>" . $colorbeg .
131 htmlspecialchars( $formatted, ENT_NOQUOTES) . $colorend."</td>\n";
132 echo " </tr>\n";
135 if ($billing_note) {
136 echo " <tr class='text billing'>\n";
137 echo " <td>" . $colorbeg . htmlspecialchars( xl('Billing Note'), ENT_NOQUOTES) .
138 $colorend . "</td><td>" . $colorbeg .
139 htmlspecialchars( $billing_note, ENT_NOQUOTES) . $colorend . "</td>\n";
140 echo " </tr>\n";
143 //retrieve all active notes
144 $result = getPnotesByDate("", 1, "id,date,body,user,title,assigned_to",
145 $patient_id, "all", 0, '', $docid, '', $orderid);
147 if ($result != null) {
148 $notes_count = 0;//number of notes so far displayed
149 foreach ($result as $iter) {
151 if ($notes_count >= $N) {
152 //we have more active notes to print, but we've reached our display maximum
153 echo " <tr>\n";
154 echo " <td colspan='3' align='center'>\n";
155 echo " <a ";
156 if (!$GLOBALS['concurrent_layout']) echo "target='Main' ";
157 echo "href='pnotes_full.php?active=1&$urlparms" .
158 "' class='alert' onclick='top.restoreSession()'>";
159 echo htmlspecialchars( xl('Some notes were not displayed.','','',' '), ENT_NOQUOTES) .
160 htmlspecialchars( xl('Click here to view all.'), ENT_NOQUOTES) . "</a>\n";
161 echo " </td>\n";
162 echo " </tr>\n";
163 break;
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( $body, ENT_NOQUOTES));
169 } else {
170 $body = htmlspecialchars( date('Y-m-d H:i', strtotime($iter['date'])), ENT_NOQUOTES) .
171 ' (' . htmlspecialchars( $iter['user'], ENT_NOQUOTES) . ') ' . nl2br(htmlspecialchars( $body, ENT_NOQUOTES));
174 echo " <tr class='text noterow' id='".htmlspecialchars( $iter['id'], ENT_QUOTES)."'>\n";
176 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
177 echo " <td valign='top' class='bold'>";
178 echo generate_display_field(array('data_type'=>'1','list_id'=>'note_type'), $iter['title']);
179 echo "</td>\n";
181 echo " <td valign='top'>$body</td>\n";
182 echo " </tr>\n";
184 $notes_count++;
189 </table>
191 </div> <!-- end pnotes -->
193 </body>
195 <script language="javascript">
196 // jQuery stuff to make the page a little easier to use
198 $(document).ready(function(){
199 $(".noterow").mouseover(function() { $(this).toggleClass("highlight"); });
200 $(".noterow").mouseout(function() { $(this).toggleClass("highlight"); });
201 $(".noterow").click(function() { EditNote(this); });
204 var EditNote = function(note) {
205 <?php if ( acl_check('patients', 'notes','',array('write','addonly') )): ?>
206 top.restoreSession();
207 <?php if (!$GLOBALS['concurrent_layout']): ?>
208 top.Main.location.href = "pnotes_full.php?<?php echo $urlparms; ?>&noteid=" + note.id + "&active=1";
209 <?php else: ?>
210 location.href = "pnotes_full.php?<?php echo $urlparms; ?>&noteid=" + note.id + "&active=1";
211 <?php endif; ?>
212 <?php else: ?>
213 // no-op
214 alert("<?php echo htmlspecialchars( xl('You do not have access to view/edit this note'), ENT_QUOTES); ?>");
215 <?php endif; ?>
218 </script>
220 </html>