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>;.
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']);
44 $row = sqlQuery("SELECT foreign_id FROM documents WHERE id = ?", array($docid));
45 $patient_id = intval($row['foreign_id']);
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";
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">
61 <body
class="body_bottom">
64 $thisauth = acl_check('patients', 'notes');
66 $tmp = getPatientData($patient_id, "squad");
67 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad']))
71 echo "<p>(" . htmlspecialchars( xl('Notes not authorized'), ENT_NOQUOTES
) . ")</p>\n";
72 echo "</body>\n</html>\n";
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
); ?
>
86 echo " " . xlt("linked to document") . " ";
87 $d = new Document($docid);
88 echo $d->get_url_file();
91 echo " " . xlt("linked to procedure order") . " $orderid";
95 <span
class=more
><?php
echo htmlspecialchars( $tmore, ENT_NOQUOTES
);?
></span
>
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
107 // Get the billing note if there is one.
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";
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";
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
148 echo " <td colspan='3' align='center'>\n";
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";
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
));
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']);
174 echo " <td valign='top'>$body</td>\n";
184 </div
> <!-- end pnotes
-->
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; ?>¬eid=" + note
.id +
"&active=1";
203 alert("<?php echo htmlspecialchars( xl('You do not have access to view/edit this note'), ENT_QUOTES); ?>");