Remove concurrent_layout and clarify layout and themes selections (#272)
[openemr.git] / interface / patient_file / summary / pnotes.php
blob8141147dbe564a3b852661c1ddef65b07ac41ac5
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['assets_static_relative']; ?>/jquery-min-1-2-1/index.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 <a href="pnotes_full.php?<?php echo $urlparms; ?>" onclick="top.restoreSession()">
83 <span class="title"><?php echo htmlspecialchars( xl('Notes'), ENT_NOQUOTES); ?>
84 <?php
85 if ($docid) {
86 echo " " . xlt("linked to document") . " ";
87 $d = new Document($docid);
88 echo $d->get_url_file();
90 else if ($orderid) {
91 echo " " . xlt("linked to procedure order") . " $orderid";
94 </span>
95 <span class=more><?php echo htmlspecialchars( $tmore, ENT_NOQUOTES);?></span>
96 </a>
97 <?php endif; ?>
99 <br>
101 <table>
103 <?php
104 //display all of the notes for the day, as well as others that are active from previous dates, up to a certain number, $N
105 $N = 15;
107 // Get the billing note if there is one.
108 $billing_note = "";
109 $colorbeg = "";
110 $colorend = "";
111 $resnote = getPatientData($patient_id, "billing_note");
112 if(!empty($resnote['billing_note'])) {
113 $billing_note = $resnote['billing_note'];
114 $colorbeg = "<span style='color:red'>";
115 $colorend = "</span>";
118 //Display what the patient owes
119 $balance = get_patient_balance($patient_id);
120 if ($balance != "0") {
121 $formatted = sprintf((xl('$').'%01.2f'), $balance);
122 echo " <tr class='text billing'>\n";
123 echo " <td>" . $colorbeg . htmlspecialchars( xl('Balance Due'), ENT_NOQUOTES) .
124 $colorend . "</td><td>" . $colorbeg .
125 htmlspecialchars( $formatted, ENT_NOQUOTES) . $colorend."</td>\n";
126 echo " </tr>\n";
129 if ($billing_note) {
130 echo " <tr class='text billing'>\n";
131 echo " <td>" . $colorbeg . htmlspecialchars( xl('Billing Note'), ENT_NOQUOTES) .
132 $colorend . "</td><td>" . $colorbeg .
133 htmlspecialchars( $billing_note, ENT_NOQUOTES) . $colorend . "</td>\n";
134 echo " </tr>\n";
137 //retrieve all active notes
138 $result = getPnotesByDate("", 1, "id,date,body,user,title,assigned_to",
139 $patient_id, "all", 0, '', $docid, '', $orderid);
141 if ($result != null) {
142 $notes_count = 0;//number of notes so far displayed
143 foreach ($result as $iter) {
145 if ($notes_count >= $N) {
146 //we have more active notes to print, but we've reached our display maximum
147 echo " <tr>\n";
148 echo " <td colspan='3' align='center'>\n";
149 echo " <a ";
150 echo "href='pnotes_full.php?active=1&$urlparms" .
151 "' class='alert' onclick='top.restoreSession()'>";
152 echo htmlspecialchars( xl('Some notes were not displayed.','','',' '), ENT_NOQUOTES) .
153 htmlspecialchars( xl('Click here to view all.'), ENT_NOQUOTES) . "</a>\n";
154 echo " </td>\n";
155 echo " </tr>\n";
156 break;
159 $body = $iter['body'];
160 if (preg_match('/^\d\d\d\d-\d\d-\d\d \d\d\:\d\d /', $body)) {
161 $body = nl2br(htmlspecialchars( $body, ENT_NOQUOTES));
162 } else {
163 $body = htmlspecialchars( date('Y-m-d H:i', strtotime($iter['date'])), ENT_NOQUOTES) .
164 ' (' . htmlspecialchars( $iter['user'], ENT_NOQUOTES) . ') ' . nl2br(htmlspecialchars( $body, ENT_NOQUOTES));
167 echo " <tr class='text noterow' id='".htmlspecialchars( $iter['id'], ENT_QUOTES)."'>\n";
169 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
170 echo " <td valign='top' class='bold'>";
171 echo generate_display_field(array('data_type'=>'1','list_id'=>'note_type'), $iter['title']);
172 echo "</td>\n";
174 echo " <td valign='top'>$body</td>\n";
175 echo " </tr>\n";
177 $notes_count++;
182 </table>
184 </div> <!-- end pnotes -->
186 </body>
188 <script language="javascript">
189 // jQuery stuff to make the page a little easier to use
191 $(document).ready(function(){
192 $(".noterow").mouseover(function() { $(this).toggleClass("highlight"); });
193 $(".noterow").mouseout(function() { $(this).toggleClass("highlight"); });
194 $(".noterow").click(function() { EditNote(this); });
197 var EditNote = function(note) {
198 <?php if ( acl_check('patients', 'notes','',array('write','addonly') )): ?>
199 top.restoreSession();
200 location.href = "pnotes_full.php?<?php echo $urlparms; ?>&noteid=" + note.id + "&active=1";
201 <?php else: ?>
202 // no-op
203 alert("<?php echo htmlspecialchars( xl('You do not have access to view/edit this note'), ENT_QUOTES); ?>");
204 <?php endif; ?>
207 </script>
209 </html>