minor changes to prior commit
[openemr.git] / interface / patient_file / summary / pnotes.php
blob955412a8236d634e29b81800101f1ed19e984ca7
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.g.miller@gmail.com>
18 * @link http://www.open-emr.org
23 require_once("../../globals.php");
24 require_once("$srcdir/pnotes.inc");
25 require_once("$srcdir/acl.inc");
26 require_once("$srcdir/patient.inc");
27 require_once("$srcdir/options.inc.php");
29 // form parameter docid can be passed to restrict the display to a document.
30 $docid = empty($_REQUEST['docid']) ? 0 : intval($_REQUEST['docid']);
32 // form parameter orderid can be passed to restrict the display to a procedure order.
33 $orderid = empty($_REQUEST['orderid']) ? 0 : intval($_REQUEST['orderid']);
35 $patient_id = $pid;
36 if ($docid) {
37 $row = sqlQuery("SELECT foreign_id FROM documents WHERE id = ?", array($docid));
38 $patient_id = intval($row['foreign_id']);
39 } else if ($orderid) {
40 $row = sqlQuery("SELECT patient_id FROM procedure_order WHERE procedure_order_id = ?", array($orderid));
41 $patient_id = intval($row['patient_id']);
44 $urlparms = "docid=$docid&orderid=$orderid";
46 <html>
47 <head>
48 <?php html_header_show();?>
50 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/manual-added-packages/jquery-min-1-2-2/index.js"></script>
51 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
53 </head>
54 <body class="body_bottom">
56 <?php
57 $thisauth = acl_check('patients', 'notes');
58 if ($thisauth) {
59 $tmp = getPatientData($patient_id, "squad");
60 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad'])) {
61 $thisauth = 0;
65 if (!$thisauth) {
66 echo "<p>(" . htmlspecialchars(xl('Notes not authorized'), ENT_NOQUOTES) . ")</p>\n";
67 echo "</body>\n</html>\n";
68 exit();
72 <div id='pnotes'>
74 <?php if (acl_check('patients', 'notes', '', array('write','addonly'))) : ?>
76 <a href="pnotes_full.php?<?php echo $urlparms; ?>" onclick="top.restoreSession()">
78 <span class="title"><?php echo htmlspecialchars(xl('Notes'), ENT_NOQUOTES); ?>
79 <?php
80 if ($docid) {
81 echo " " . xlt("linked to document") . " ";
82 $d = new Document($docid);
83 echo $d->get_url_file();
84 } else if ($orderid) {
85 echo " " . xlt("linked to procedure order") . " $orderid";
88 </span>
89 <span class=more><?php echo htmlspecialchars($tmore, ENT_NOQUOTES);?></span>
90 </a>
91 <?php endif; ?>
93 <br>
95 <table>
97 <?php
98 //display all of the notes for the day, as well as others that are active from previous dates, up to a certain number, $N
99 $N = 15;
101 // Get the billing note if there is one.
102 $billing_note = "";
103 $colorbeg = "";
104 $colorend = "";
105 $resnote = getPatientData($patient_id, "billing_note");
106 if (!empty($resnote['billing_note'])) {
107 $billing_note = $resnote['billing_note'];
108 $colorbeg = "<span style='color:red'>";
109 $colorend = "</span>";
112 //Display what the patient owes
113 $balance = get_patient_balance($patient_id);
114 if ($balance != "0") {
115 $formatted = sprintf((xl('$').'%01.2f'), $balance);
116 echo " <tr class='text billing'>\n";
117 echo " <td>" . $colorbeg . htmlspecialchars(xl('Balance Due'), ENT_NOQUOTES) .
118 $colorend . "</td><td>" . $colorbeg .
119 htmlspecialchars($formatted, ENT_NOQUOTES) . $colorend."</td>\n";
120 echo " </tr>\n";
123 if ($billing_note) {
124 echo " <tr class='text billing'>\n";
125 echo " <td>" . $colorbeg . htmlspecialchars(xl('Billing Note'), ENT_NOQUOTES) .
126 $colorend . "</td><td>" . $colorbeg .
127 htmlspecialchars($billing_note, ENT_NOQUOTES) . $colorend . "</td>\n";
128 echo " </tr>\n";
131 //retrieve all active notes
132 $result = getPnotesByDate(
135 "id,date,body,user,title,assigned_to",
136 $patient_id,
137 "all",
140 $docid,
142 $orderid
145 if ($result != null) {
146 $notes_count = 0;//number of notes so far displayed
147 foreach ($result as $iter) {
148 if ($notes_count >= $N) {
149 //we have more active notes to print, but we've reached our display maximum
150 echo " <tr>\n";
151 echo " <td colspan='3' align='center'>\n";
152 echo " <a ";
153 echo "href='pnotes_full.php?active=1&$urlparms" .
154 "' class='alert' onclick='top.restoreSession()'>";
155 echo htmlspecialchars(xl('Some notes were not displayed.', '', '', ' '), ENT_NOQUOTES) .
156 htmlspecialchars(xl('Click here to view all.'), ENT_NOQUOTES) . "</a>\n";
157 echo " </td>\n";
158 echo " </tr>\n";
159 break;
162 $body = $iter['body'];
163 if (preg_match('/^\d\d\d\d-\d\d-\d\d \d\d\:\d\d /', $body)) {
164 $body = nl2br(htmlspecialchars($body, ENT_NOQUOTES));
165 } else {
166 $body = htmlspecialchars(date('Y-m-d H:i', strtotime($iter['date'])), ENT_NOQUOTES) .
167 ' (' . htmlspecialchars($iter['user'], ENT_NOQUOTES) . ') ' . nl2br(htmlspecialchars($body, ENT_NOQUOTES));
170 echo " <tr class='text noterow' id='".htmlspecialchars($iter['id'], ENT_QUOTES)."'>\n";
172 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
173 echo " <td valign='top' class='bold'>";
174 echo generate_display_field(array('data_type'=>'1','list_id'=>'note_type'), $iter['title']);
175 echo "</td>\n";
177 echo " <td valign='top'>$body</td>\n";
178 echo " </tr>\n";
180 $notes_count++;
185 </table>
187 </div> <!-- end pnotes -->
189 </body>
191 <script language="javascript">
192 // jQuery stuff to make the page a little easier to use
194 $(document).ready(function(){
195 $(".noterow").mouseover(function() { $(this).toggleClass("highlight"); });
196 $(".noterow").mouseout(function() { $(this).toggleClass("highlight"); });
199 </script>
201 </html>