PHP 7.2 fix #1484
[openemr.git] / interface / patient_file / summary / disclosure_full.php
blob3f155fe333d131b83ed4653f6357688a17ddb4aa
1 <?php
2 /**
3 * Patient disclosures main screen.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Visolve <vicareplus_engg@visolve.com>
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) Visolve <vicareplus_engg@visolve.com>
10 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once("../../globals.php");
16 require_once("$srcdir/log.inc");
17 require_once("$srcdir/options.inc.php");
19 use OpenEMR\Core\Header;
21 //retrieve the user name
22 $res = sqlQuery("select username from users where username=?", array($_SESSION{"authUser"}));
23 $uname=$res{"username"};
24 //if the mode variable is set to disclosure, retrieve the values from 'disclosure_form ' in record_disclosure.php to store it in database.
25 if (isset($_POST["mode"]) and $_POST["mode"] == "disclosure") {
26 $dates=trim($_POST['dates']);
27 $event=trim($_POST['form_disclosure_type']);
28 $recipient_name=trim($_POST['recipient_name']);
29 $disclosure_desc=trim($_POST['desc_disc']);
30 $disclosure_id=trim($_POST['disclosure_id']);
31 if (isset($_POST["updatemode"]) and $_POST["updatemode"] == "disclosure_update") {
32 //update the recorded disclosure in the extended_log table.
33 updateRecordedDisclosure($dates, $event, $recipient_name, $disclosure_desc, $disclosure_id);
34 } else {
35 //insert the disclosure records in the extended_log table.
36 recordDisclosure($dates, $event, $pid, $recipient_name, $disclosure_desc, $uname);
38 // added ajax submit to record_disclosure thus an exit() 12/19/17
39 exit();
42 if (isset($_GET['deletelid'])) {
43 $deletelid=$_GET['deletelid'];
44 //function to delete the recorded disclosures
45 deleteDisclosure($deletelid);
48 <html>
49 <head>
51 <?php Header::setupHeader(['common']); ?>
53 </head>
55 <body class="body_top">
56 <div>
57 <span class="title"><?php echo xlt('Disclosures'); ?></span>
58 </div>
59 <div class="disclosure_wrap">
60 <div style='float: left; margin-right: 10px'><?php echo xlt('for'); ?>&nbsp;
61 <span class="title"><a href="../summary/demographics.php" onclick="top.restoreSession()"><?php $pname = getPatientName($pid);
62 echo text($pname); ?></a></span>
63 </div>
64 <div>
65 <a href="record_disclosure.php" class="css_button iframe" onclick="top.restoreSession()"><span><?php echo xlt('Record'); ?></span></a>
66 </div>
67 <div>
68 <a href="demographics.php"
69 class="css_button" onclick="top.restoreSession()"> <span><?php echo xlt('View Patient') ?></span></a>
70 </div>
71 </div>
72 <br>
73 <br>
74 <?php
75 $N=15;
76 $offset = $_REQUEST['offset'];
77 if (!isset($offset)) {
78 $offset = 0;
81 $disclQry = " SELECT el.id, el.event, el.recipient, el.description, el.date, CONCAT(u.fname, ' ', u.lname) as user_fullname FROM extended_log el" .
82 " LEFT JOIN users u ON u.username = el.user " .
83 " WHERE el.patient_id = ? AND el.event IN (SELECT option_id FROM list_options WHERE list_id='disclosure_type' AND activity = 1)" .
84 " ORDER BY el.date DESC ";
85 $r2= sqlStatement($disclQry, array($pid));
86 $totalRecords=sqlNumRows($r2);
88 $disclInnerQry = " SELECT el.id, el.event, el.recipient, el.description, el.date, CONCAT(u.fname, ' ', u.lname) as user_fullname FROM extended_log el" .
89 " LEFT JOIN users u ON u.username = el.user" .
90 " WHERE patient_id = ? AND event IN (SELECT option_id FROM list_options WHERE list_id = 'disclosure_type' AND activity = 1)" .
91 " ORDER BY date DESC LIMIT " . escape_limit($offset) . " , " . escape_limit($N);
93 $r1= sqlStatement($disclInnerQry, array($pid));
94 $n=sqlNumRows($r1);
95 $noOfRecordsLeft=($totalRecords - $offset);
96 if ($n>0) {?>
97 <table border='0' class="text">
98 <tr>
99 <td colspan='5' style="padding: 5px;"><a href="disclosure_full.php" class="" id='Submit' onclick="top.restoreSession()"><span><?php echo xlt('Refresh'); ?></span></a></td>
100 </tr>
101 </table>
102 <div id='pnotes'>
103 <table border='0' cellpadding="1" width='80%'>
104 <tr class="showborder_head" align='left' height="22">
105 <th style='width: 120px';>&nbsp;</th>
106 <th style="border-style: 1px solid #000" width="140px"><?php echo xlt('Recipient Name'); ?></th>
107 <th style="border-style: 1px solid #000" width="140px"><?php echo xlt('Disclosure Type'); ?></th>
108 <th style="border-style: 1px solid #000"><?php echo xlt('Description'); ?></th>
109 <th style="border-style: 1px solid #000"><?php echo xlt('Provider'); ?></th>
110 </tr>
111 <?php
112 $result2 = array();
113 for ($iter = 0; $frow = sqlFetchArray($r1); $iter++) {
114 $result2[$iter] = $frow;
117 foreach ($result2 as $iter) {
118 $description =nl2br(text($iter{'description'})); //for line break if there is any new lines in the input text area field.
120 <!-- List the recipient name, description, date and edit and delete options-->
121 <tr class="noterow" height='25'>
122 <!--buttons for edit and delete.-->
123 <td valign='top'><a href='record_disclosure.php?editlid=<?php echo text($iter{'id'}); ?>'
124 class='css_button_small iframe' onclick='top.restoreSession()'><span><?php echo xlt('Edit');?></span></a>
125 <a href='#' class='deletenote css_button_small'
126 id='<?php echo text($iter{'id'}); ?>' onclick='top.restoreSession()'><span><?php echo xlt('Delete');?></span></a></td>
127 <td class="text" valign='top'><?php echo text($iter{'recipient'});?>&nbsp;</td>
128 <td class='text' valign='top'><?php echo text(getListItemTitle('disclosure_type', $iter['event'])); ?>&nbsp;</td>
129 <td class='text'><?php echo text($iter{'date'})." ".$description;?>&nbsp;</td>
130 <td class='text'><?php echo text($iter{'user_fullname'});?></td>
131 </tr>
132 <?php
134 } else {?>
135 <br>
136 <!-- Display None, if there is no disclosure -->
137 <span class='text' colspan='3'><?php echo xlt('None');?></span>
138 <?php
141 </table>
142 <table width='400' border='0' cellpadding='0' cellspacing='0'>
143 <tr>
144 <td>
145 <?php
146 if ($offset > ($N-1) && $n!=0) {
147 echo " <a class='link' href='disclosure_full.php?active=" . $active .
148 "&offset=" . attr($offset-$N) . "' onclick='top.restoreSession()'>[" .
149 xlt('Previous') . "]</a>\n";
153 <?php
155 if ($n >= $N && $noOfRecordsLeft!=$N) {
156 echo "&nbsp;&nbsp; <a class='link' href='disclosure_full.php?active=" . $active.
157 "&offset=" . attr($offset+$N) ."&leftrecords=".$noOfRecordsLeft."' onclick='top.restoreSession()'>[" .
158 xlt('Next') . "]</a>\n";
161 </td>
162 </tr>
163 </table>
164 </div>
165 </body>
167 <script type="text/javascript">
168 $(document).ready(function () {
169 // todo, move this to a common library
170 //for row highlight.
171 $(".noterow").mouseover(function () {
172 $(this).toggleClass("highlight");
174 $(".noterow").mouseout(function () {
175 $(this).toggleClass("highlight");
178 //for deleting the disclosures
179 $(".deletenote").click(function () {
180 DeleteNote(this);
183 var DeleteNote = function (logevent) {
184 if (confirm("<?php echo htmlspecialchars(xl('Are you sure you want to delete this disclosure?', '', '', '\n ') . xl('This action CANNOT be undone.'), ENT_QUOTES); ?>")) {
185 top.restoreSession();
186 window.location.replace("disclosure_full.php?deletelid=" + logevent.id)
190 $(".iframe").on('click', function(e) {
191 e.preventDefault();e.stopPropagation();
192 dlgopen('', '', 500, 310, '', '', {
193 allowResize: true,
194 allowDrag: true,
195 dialogId: '',
196 type: 'iframe',
197 url: $(this).attr('href')
202 // for record disclosure dlgclose callback
203 function refreshme() {
204 top.restoreSession();
205 document.location.reload();
207 </script>
208 </html>