3 * Display patient notes.
6 * @link http://www.open-emr.org
7 * @author Brady Miller <brady.g.miller@gmail.com>
8 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
9 * @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");
15 require_once("$srcdir/acl.inc");
16 require_once("$srcdir/patient.inc");
17 require_once("$srcdir/options.inc.php");
19 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
23 // form parameter docid can be passed to restrict the display to a document.
24 $docid = empty($_REQUEST['docid']) ?
0 : 0 +
$_REQUEST['docid'];
26 //ajax for type 2 notes widget
27 if (isset($_GET['docUpdateId'])) {
28 return disappearPnote($_GET['docUpdateId']);
32 <?php
if ($GLOBALS['portal_offsite_enable'] == 1) { ?
>
34 <li
class="current" ><a href
="#"><?php
echo xlt('Inbox'); ?
></a
></li
>
35 <li
><a href
="#"><?php
echo xlt('Sent Items'); ?
></a
></li
>
38 <div
class='tabContainer' >
39 <div
class='tab current' >
41 //display all of the notes for the day, as well as others that are active from previous dates, up to a certain number, $N
42 $N = $GLOBALS['num_of_messages_displayed']; ?
>
49 $thisauth = acl_check('patients', 'notes');
51 $tmp = getPatientData($pid, "squad");
52 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad'])) {
58 echo "<p>(" . xlt('Notes not authorized') . ")</p>\n";
60 <table width
='100%' border
='0' cellspacing
='1' cellpadding
='1' style
='border-collapse:collapse;' >
63 $pres = getPatientData($pid, "lname, fname");
64 $patientname = $pres['lname'] . ", " . $pres['fname'];
65 //retrieve all active notes
66 $result = getPnotesByDate(
69 "id,date,body,user,title,assigned_to,message_status",
77 if ($result != null) {
78 $notes_count = 0;//number of notes so far displayed
79 echo "<tr class='text' style='border-bottom:2px solid #000;' >\n";
80 echo "<td valign='top' class='text' ><b>". xlt('From') . "</b></td>\n";
81 echo "<td valign='top' class='text' ><b>". xlt('To') . "</b></td>\n";
82 if ($GLOBALS['messages_due_date']) {
83 echo "<td valign='top' class='text' ><b>". xlt('Due date') . "</b></td>\n";
85 echo "<td valign='top' class='text' ><b>". xlt('Date') . "</b></td>\n";
87 echo "<td valign='top' class='text' ><b>". xlt('Subject') . "</b></td>\n";
88 echo "<td valign='top' class='text' ><b>". xlt('Content') . "</b></td>\n";
89 echo "<td valign='top' class='text' ></td>\n";
91 foreach ($result as $iter) {
94 $body = $iter['body'];
95 $body = preg_replace('/(\d{4}-\d{2}-\d{2} \d{2}:\d{2}\s\([^)(]+\s)(to)(\s[^)(]+\))/', '', $body);
96 $body = preg_replace('/(\sto\s)-patient-(\))/', '${1}'.$patientname.'${2}', $body);
97 echo " <tr class='text' id='" . text($iter['id']) . "' style='border-bottom:1px dashed;height:30px;' >\n";
99 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
100 echo "<td valign='top' class='text'>" . text($iter['user']) . "</td>\n";
101 echo "<td valign='top' class='text'>" . text($iter['assigned_to']) . "</td>\n";
102 echo "<td valign='top' class='text'>" . text(oeFormatDateTime(date('Y-m-d H:i', strtotime($iter['date'])))) . "</td>\n";
103 echo " <td valign='top' class='text'><b>";
104 echo generate_display_field(array('data_type'=>'1','list_id'=>'note_type'), $iter['title']);
107 echo " <td valign='top' class='text'>" . text($body) . "</td>\n";
108 echo "<td valign='top' class='text'><button data-id='" . attr($iter['id']) . "' class='complete_btn'>" . xlt('Completed') . "</button></td>\n";
118 if ($has_note < 1) { ?
>
121 echo xlt("There are no notes on file for this patient.");
122 if (acl_check('patients', 'notes', '', array('write', 'addonly'))) {
124 echo "<a href='pnotes_full.php' onclick='top.restoreSession()'>";
125 echo xlt("To add notes, please click here");
133 <?php
echo xlt('Displaying the following number of most recent notes:'); ?
>
134 <b
><?php
echo text($N);?
></b
><br
>
135 <a href
='pnotes_full.php?s=0' onclick
='top.restoreSession()'>
136 <?php
echo xlt('Click here to view them all.'); ?
></a
>
144 <?php
if ($GLOBALS['portal_offsite_enable'] == 1) { ?
>
147 //display all of the notes for the day, as well as others that are active from previous dates, up to a certain number, $N
148 $M = $GLOBALS['num_of_messages_displayed']; ?
>
153 echo "<p>(" . xlt('Notes not authorized') . ")</p>\n";
155 <table width
='100%' border
='0' cellspacing
='1' cellpadding
='1' style
='border-collapse:collapse;' >
157 //retrieve all active notes
158 $result_sent = getSentPnotesByDate(
161 "id,date,body,user,title,assigned_to,pid",
168 if ($result_sent != null) {
169 $notes_sent_count = 0;//number of notes so far displayed
170 echo "<tr class='text' style='border-bottom:2px solid #000;' >\n";
171 echo "<td valign='top' class='text' ><b>". xlt('To') ."</b></td>\n";
172 if ($GLOBALS['messages_due_date']) {
173 echo "<td valign='top' class='text' ><b>". xlt('Due date') ."</b></td>\n";
175 echo "<td valign='top' class='text' ><b>". xlt('Date') ."</b></td>\n";
177 echo "<td valign='top' class='text' ><b>". xlt('Subject') ."</b></td>\n";
178 echo "<td valign='top' class='text' ><b>". xlt('Content') ."</b></td>\n";
180 foreach ($result_sent as $iter) {
182 $body = $iter['body'];
183 if (preg_match('/^\d\d\d\d-\d\d-\d\d \d\d\:\d\d /', $body)) {
184 $body = nl2br(text(oeFormatPatientNote($body)));
186 $body = text(oeFormatSDFT(strtotime($iter['date'])) . date(' H:i', strtotime($iter['date'])) .
187 ' (' . $iter['user'] . ') ') .
188 nl2br(text(oeFormatPatientNote($body)));
191 $body = preg_replace('/(:\d{2}\s\()'.$iter['pid'].'(\sto\s)/', '${1}'.$patientname.'${2}', $body);
192 $body = strlen($body) > 120 ?
substr($body, 0, 120)."<b>.......</b>" : $body;
193 echo " <tr class='text' id='" . attr($iter['id']) . "' style='border-bottom:1px dashed;height:30px;' >\n";
194 // Modified 6/2009 by BM to incorporate the patient notes into the list_options listings
195 echo "<td valign='top' class='text'>" . text($iter['assigned_to']) . "</td>\n";
196 echo "<td valign='top' class='text'>" . text($iter['date']) . "</td>\n";
197 echo " <td valign='top' class='text'><b>";
198 echo generate_display_field(array('data_type'=>'1','list_id'=>'note_type'), $iter['title']);
200 echo " <td valign='top' class='text'>" . text($body) . "</td>\n";
207 if ($has_sent_note < 1) { ?
>
210 echo xlt("There are no notes on file for this patient.");
211 if (acl_check('patients', 'notes', '', array('write', 'addonly'))) {
213 echo "<a href='pnotes_full.php' onclick='top.restoreSession()'>";
214 echo xlt("To add notes, please click here");
222 <?php
echo text('Displaying the following number of most recent notes') . ":"; ?
>
223 <b
><?php
echo text($M);?
></b
><br
>
224 <a href
='pnotes_full.php?s=1' onclick
='top.restoreSession()'><?php
echo xlt('Click here to view them all.'); ?
></a
>
235 <script language
="javascript">
236 // jQuery stuff to make the page a little easier to use
240 $
(document
).ready(function(){
241 $
(".noterow").mouseover(function() { $
(this
).toggleClass("highlight"); });
242 $
(".noterow").mouseout(function() { $
(this
).toggleClass("highlight"); });
244 //Ajax call for type 2 note widget
245 $
(".complete_btn").on("click", function(){
246 //console.log($(this).attr('data-id'));
250 url
: "pnotes_fragment.php?docUpdateId=" +
encodeURIComponent(btn
.attr('data-id')),
252 csrf_token_form
: <?php
echo js_escape(collectCsrfToken()); ?
>
256 btn
.prop("disabled",true);
257 btn
.unbind('mouseenter mouseleave');
258 btn
.css('background-color', 'gray');