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['webroot'] ?>/library/js/jquery.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 <?php
if ($GLOBALS['concurrent_layout']) { ?
>
82 <a href
="pnotes_full.php?<?php echo $urlparms; ?>" onclick
="top.restoreSession()">
84 <a href
="pnotes_full.php?<?php echo $urlparms; ?>" target
="Main" onclick
="top.restoreSession()">
87 <span
class="title"><?php
echo htmlspecialchars( xl('Notes'), ENT_NOQUOTES
); ?
>
90 echo " " . xlt("linked to document") . " ";
91 $d = new Document($docid);
92 echo $d->get_url_file();
95 echo " " . xlt("linked to procedure order") . " $orderid";
99 <span
class=more
><?php
echo htmlspecialchars( $tmore, ENT_NOQUOTES
);?
></span
>
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
111 // Get the billing note if there is one.
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";
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";
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
154 echo " <td colspan='3' align='center'>\n";
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";
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
));
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']);
181 echo " <td valign='top'>$body</td>\n";
191 </div
> <!-- end pnotes
-->
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; ?>¬eid=" + note
.id +
"&active=1";
210 location
.href
= "pnotes_full.php?<?php echo $urlparms; ?>¬eid=" + note
.id +
"&active=1";
214 alert("<?php echo htmlspecialchars( xl('You do not have access to view/edit this note'), ENT_QUOTES); ?>");