Mangled path fax send (#7515)
[openemr.git] / interface / patient_file / summary / pnotes.php
blob9ddca2bc8b6aea71dc832097af9f71c8fe8aa2ac
1 <?php
3 /**
4 * Display patient notes.
6 * @package OpenEMR
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']);
27 $patient_id = $pid;
28 if ($docid) {
29 $row = sqlQuery("SELECT foreign_id FROM documents WHERE id = ?", array($docid));
30 $patient_id = intval($row['foreign_id']);
31 } elseif ($orderid) {
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);
38 <html>
39 <head>
40 <?php Header::setupHeader(); ?>
41 </head>
42 <body class="body_bottom">
44 <?php
45 $thisauth = AclMain::aclCheckCore('patients', 'notes');
46 if ($thisauth) {
47 $tmp = getPatientData($patient_id, "squad");
48 if ($tmp['squad'] && !AclMain::aclCheckCore('squads', $tmp['squad'])) {
49 $thisauth = 0;
53 if (!$thisauth) {
54 echo "<p>(" . xlt('Notes not authorized') . ")</p>\n";
55 echo "</body>\n</html>\n";
56 exit();
60 <div id='pnotes'>
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'); ?>
66 <?php
67 if ($docid) {
68 echo " " . xlt("linked to document") . " ";
69 $d = new Document($docid);
70 echo text($d->get_url_file());
71 } elseif ($orderid) {
72 echo " " . xlt("linked to procedure order") . " " . text($orderid);
75 </span>
76 <span class="more"><?php echo text($tmore);?></span>
77 </a>
78 <?php endif; ?>
80 <br />
82 <table>
84 <?php
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
86 $N = 15;
88 // Get the billing note if there is one.
89 $billing_note = "";
90 $colorbeg = "";
91 $colorend = "";
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";
107 echo " </tr>\n";
110 if ($billing_note) {
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";
115 echo " </tr>\n";
118 //retrieve all active notes
119 $result = getPnotesByDate(
122 "id,date,body,user,title,assigned_to",
123 $patient_id,
124 "all",
127 $docid,
129 $orderid
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
137 echo " <tr>\n";
138 echo " <td colspan='3' align='center'>\n";
139 echo " <a ";
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";
144 echo " </td>\n";
145 echo " </tr>\n";
146 break;
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));
152 } else {
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']);
162 echo "</td>\n";
164 echo " <td valign='top'>$body</td>\n";
165 echo " </tr>\n";
167 $notes_count++;
172 </table>
174 </div> <!-- end pnotes -->
176 </body>
178 <script>
179 // jQuery stuff to make the page a little easier to use
181 $(function () {
182 $(".noterow").on("mouseover", function() { $(this).toggleClass("highlight"); });
183 $(".noterow").on("mouseout", function() { $(this).toggleClass("highlight"); });
186 </script>
188 </html>