4 * Display patient notes.
7 * @link http://www.open-emr.org
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 require_once("../../globals.php");
14 require_once("$srcdir/pnotes.inc.php");
15 require_once("$srcdir/patient.inc.php");
16 require_once("$srcdir/options.inc.php");
18 use OpenEMR\Common\Acl\AclMain
;
19 use OpenEMR\Core\Header
;
21 // form parameter docid can be passed to restrict the display to a document.
22 $docid = empty($_REQUEST['docid']) ?
0 : intval($_REQUEST['docid']);
24 // form parameter orderid can be passed to restrict the display to a procedure order.
25 $orderid = empty($_REQUEST['orderid']) ?
0 : intval($_REQUEST['orderid']);
29 $row = sqlQuery("SELECT foreign_id FROM documents WHERE id = ?", array($docid));
30 $patient_id = intval($row['foreign_id']);
32 $row = sqlQuery("SELECT patient_id FROM procedure_order WHERE procedure_order_id = ?", array($orderid));
33 $patient_id = intval($row['patient_id']);
36 $urlparms = "docid=" . attr_url($docid) . "&orderid=" . attr_url($orderid);
40 <?php Header
::setupHeader(); ?
>
42 <body
class="body_bottom">
45 $thisauth = AclMain
::aclCheckCore('patients', 'notes');
47 $tmp = getPatientData($patient_id, "squad");
48 if ($tmp['squad'] && !AclMain
::aclCheckCore('squads', $tmp['squad'])) {
54 echo "<p>(" . xlt('Notes not authorized') . ")</p>\n";
55 echo "</body>\n</html>\n";
62 <?php
if (AclMain
::aclCheckCore('patients', 'notes', '', array('write','addonly'))) : ?
>
63 <a href
="pnotes_full.php?<?php echo $urlparms; ?>" onclick
="top.restoreSession()">
65 <span
class="title"><?php
echo xlt('Notes'); ?
>
68 echo " " . xlt("linked to document") . " ";
69 $d = new Document($docid);
70 echo text($d->get_url_file());
72 echo " " . xlt("linked to procedure order") . " " . text($orderid);
76 <span
class="more"><?php
echo text($tmore);?
></span
>
85 //display all of the notes for the day, as well as others that are active from previous dates, up to a certain number, $N
88 // Get the billing note if there is one.
92 $resnote = getPatientData($patient_id, "billing_note");
93 if (!empty($resnote['billing_note'])) {
94 $billing_note = $resnote['billing_note'];
95 $colorbeg = "<span style='color:red'>";
96 $colorend = "</span>";
99 //Display what the patient owes
100 $balance = get_patient_balance($patient_id);
101 if ($balance != "0") {
102 $formatted = sprintf((xl('$') . '%01.2f'), $balance);
103 echo " <tr class='text billing'>\n";
104 echo " <td>" . $colorbeg . xlt('Balance Due') .
105 $colorend . "</td><td>" . $colorbeg .
106 text($formatted) . $colorend . "</td>\n";
111 echo " <tr class='text billing'>\n";
112 echo " <td>" . $colorbeg . xlt('Billing Note') .
113 $colorend . "</td><td>" . $colorbeg .
114 text($billing_note) . $colorend . "</td>\n";
118 //retrieve all active notes
119 $result = getPnotesByDate(
122 "id,date,body,user,title,assigned_to",
132 if ($result != null) {
133 $notes_count = 0;//number of notes so far displayed
134 foreach ($result as $iter) {
135 if ($notes_count >= $N) {
136 //we have more active notes to print, but we've reached our display maximum
138 echo " <td colspan='3' align='center'>\n";
140 echo "href='pnotes_full.php?active=1&$urlparms" .
141 "' class='alert' onclick='top.restoreSession()'>";
142 echo xlt('Some notes were not displayed.') . ' ' .
143 xlt('Click here to view all.') . "</a>\n";
149 $body = $iter['body'];
150 if (preg_match('/^\d\d\d\d-\d\d-\d\d \d\d\:\d\d /', $body)) {
151 $body = nl2br(text($body));
153 $body = text(date('Y-m-d H:i', strtotime($iter['date']))) .
154 ' (' . text($iter['user']) . ') ' . nl2br(text($body));
157 echo " <tr class='text noterow' id='" . text($iter['id']) . "'>\n";
159 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
160 echo " <td valign='top' class='bold'>";
161 echo generate_display_field(array('data_type' => '1','list_id' => 'note_type'), $iter['title']);
164 echo " <td valign='top'>$body</td>\n";
174 </div
> <!-- end pnotes
-->
179 // jQuery stuff to make the page a little easier to use
182 $
(".noterow").on("mouseover", function() { $
(this
).toggleClass("highlight"); });
183 $
(".noterow").on("mouseout", function() { $
(this
).toggleClass("highlight"); });