Highway to PSR2
[openemr.git] / interface / patient_file / summary / disclosure_full.php
blob76bf5d9a1973d83be51f86379db2bc67a2b2a087
1 <?php
2 /**
4 * Patient disclosures main screen.
6 * Copyright (C) Visolve <vicareplus_engg@visolve.com>
8 * LICENSE: This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
19 * @package OpenEMR
20 * @author Visolve <vicareplus_engg@visolve.com>
21 * @author Brady Miller <brady.g.miller@gmail.com>
22 * @link http://www.open-emr.org
27 require_once("../../globals.php");
28 require_once("$srcdir/log.inc");
29 require_once("$srcdir/options.inc.php");
31 //retrieve the user name
32 $res = sqlQuery("select username from users where username=?", array($_SESSION{"authUser"}));
33 $uname=$res{"username"};
34 //if the mode variable is set to disclosure, retrieve the values from 'disclosure_form ' in record_disclosure.php to store it in database.
35 if (isset($_POST["mode"]) and $_POST["mode"] == "disclosure") {
36 $dates=trim($_POST['dates']);
37 $event=trim($_POST['form_disclosure_type']);
38 $recipient_name=trim($_POST['recipient_name']);
39 $disclosure_desc=trim($_POST['desc_disc']);
40 $disclosure_id=trim($_POST['disclosure_id']);
41 if (isset($_POST["updatemode"]) and $_POST["updatemode"] == "disclosure_update") {
42 //update the recorded disclosure in the extended_log table.
43 updateRecordedDisclosure($dates, $event, $recipient_name, $disclosure_desc, $disclosure_id);
44 } else {
45 //insert the disclosure records in the extended_log table.
46 recordDisclosure($dates, $event, $pid, $recipient_name, $disclosure_desc, $uname);
50 if (isset($_GET['deletelid'])) {
51 $deletelid=$_GET['deletelid'];
52 //function to delete the recorded disclosures
53 deleteDisclosure($deletelid);
56 <html>
57 <head>
58 <link rel='stylesheet' href="<?php echo $css_header;?>" type="text/css">
59 <!-- supporting javascript code -->
60 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-2/index.js"></script>
61 <link rel="stylesheet" type="text/css" href="../../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
62 <script type="text/javascript" src="../../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
63 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-3-2/index.js"></script>
64 <script type="text/javascript" src="../../../library/js/common.js"></script>
65 <script type="text/javascript" src="../../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
66 </head>
67 <body class="body_top">
68 <div>
69 <span class="title"><?php echo xlt('Disclosures'); ?></span>
70 </div>
71 <div class="disclosure_wrap">
72 <div style='float: left; margin-right: 10px'><?php echo xlt('for'); ?>&nbsp;
73 <span class="title"><a href="../summary/demographics.php" onclick="top.restoreSession()"><?php $pname = getPatientName($pid);
74 echo text($pname); ?></a></span>
75 </div>
76 <div>
77 <a href="record_disclosure.php" class="css_button iframe" onclick="top.restoreSession()"><span><?php echo xlt('Record'); ?></span></a>
78 </div>
79 <div>
80 <a href="demographics.php"
81 class="css_button" onclick="top.restoreSession()"> <span><?php echo xlt('View Patient') ?></span></a>
82 </div>
83 </div>
84 <br>
85 <br>
86 <?php
87 $N=15;
88 $offset = $_REQUEST['offset'];
89 if (!isset($offset)) {
90 $offset = 0;
93 $disclQry = " SELECT el.id, el.event, el.recipient, el.description, el.date, CONCAT(u.fname, ' ', u.lname) as user_fullname FROM extended_log el" .
94 " LEFT JOIN users u ON u.username = el.user " .
95 " WHERE el.patient_id = ? AND el.event IN (SELECT option_id FROM list_options WHERE list_id='disclosure_type' AND activity = 1)" .
96 " ORDER BY el.date DESC ";
97 $r2= sqlStatement($disclQry, array($pid));
98 $totalRecords=sqlNumRows($r2);
100 //echo "select id,event,recipient,description,date from extended_log where patient_id=$pid AND event in (select option_id from list_options where list_id='disclosure_type') order by date desc limit $offset ,$N";
101 //display all of the disclosures for the day, as well as others that are active from previous dates, up to a certain number, $N
102 $disclInnerQry = " SELECT el.id, el.event, el.recipient, el.description, el.date, CONCAT(u.fname, ' ', u.lname) as user_fullname FROM extended_log el" .
103 " LEFT JOIN users u ON u.username = el.user" .
104 " WHERE patient_id = ? AND event IN (SELECT option_id FROM list_options WHERE list_id = 'disclosure_type' AND activity = 1)" .
105 " ORDER BY date DESC LIMIT $offset, $N";
107 $r1= sqlStatement($disclInnerQry, array($pid));
108 $n=sqlNumRows($r1);
109 $noOfRecordsLeft=($totalRecords - $offset);
110 if ($n>0) {?>
111 <table border='0' class="text">
112 <tr>
113 <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>
114 </tr>
115 </table>
116 <div id='pnotes'>
117 <table border='0' cellpadding="1" width='80%'>
118 <tr class="showborder_head" align='left' height="22">
119 <th style='width: 120px';>&nbsp;</th>
120 <th style="border-style: 1px solid #000" width="140px"><?php echo xlt('Recipient Name'); ?></th>
121 <th style="border-style: 1px solid #000" width="140px"><?php echo xlt('Disclosure Type'); ?></th>
122 <th style="border-style: 1px solid #000"><?php echo xlt('Description'); ?></th>
123 <th style="border-style: 1px solid #000"><?php echo xlt('Provider'); ?></th>
124 </tr>
125 <?php
126 $result2 = array();
127 for ($iter = 0; $frow = sqlFetchArray($r1); $iter++) {
128 $result2[$iter] = $frow;
131 foreach ($result2 as $iter) {
132 $description =nl2br(text($iter{description})); //for line break if there is any new lines in the input text area field.
134 <!-- List the recipient name, description, date and edit and delete options-->
135 <tr class="noterow" height='25'>
136 <!--buttons for edit and delete.-->
137 <td valign='top'><a href='record_disclosure.php?editlid=<?php echo text($iter{id}); ?>'
138 class='css_button_small iframe' onclick='top.restoreSession()'><span><?php echo xlt('Edit');?></span></a>
139 <a href='#' class='deletenote css_button_small'
140 id='<?php echo text($iter{id}); ?>' onclick='top.restoreSession()'><span><?php echo xlt('Delete');?></span></a></td>
141 <td class="text" valign='top'><?php echo text($iter{recipient});?>&nbsp;</td>
142 <td class='text' valign='top'><?php echo text(getListItemTitle('disclosure_type', $iter['event'])); ?>&nbsp;</td>
143 <td class='text'><?php echo text($iter{date})." ".$description;?>&nbsp;</td>
144 <td class='text'><?php echo text($iter{user_fullname});?></td>
145 </tr>
146 <?php
148 } else {?>
149 <br>
150 <!-- Display None, if there is no disclosure -->
151 <span class='text' colspan='3'><?php echo xlt('None');?></span>
152 <?php
155 </table>
156 <table width='400' border='0' cellpadding='0' cellspacing='0'>
157 <tr>
158 <td>
159 <?php
160 if ($offset > ($N-1) && $n!=0) {
161 echo " <a class='link' href='disclosure_full.php?active=" . $active .
162 "&offset=" . ($offset-$N) . "' onclick='top.restoreSession()'>[" .
163 xlt('Previous') . "]</a>\n";
167 <?php
169 if ($n >= $N && $noOfRecordsLeft!=$N) {
170 echo "&nbsp;&nbsp; <a class='link' href='disclosure_full.php?active=" . $active.
171 "&offset=" . ($offset+$N) ."&leftrecords=".$noOfRecordsLeft."' onclick='top.restoreSession()'>[" .
172 xlt('Next') . "]</a>\n";
175 </td>
176 </tr>
177 </table>
178 </div>
179 </body>
181 <script type="text/javascript">
182 $(document).ready(function()
184 /// todo, move this to a common library
185 //for row highlight.
186 $(".noterow").mouseover(function() { $(this).toggleClass("highlight"); });
187 $(".noterow").mouseout(function() { $(this).toggleClass("highlight"); });
188 //fancy box
189 enable_modals();
190 //for deleting the disclosures
191 $(".deletenote").click(function() { DeleteNote(this); });
193 var DeleteNote = function(logevent)
195 if (confirm("<?php echo htmlspecialchars(xl('Are you sure you want to delete this disclosure?', '', '', '\n ') . xl('This action CANNOT be undone.'), ENT_QUOTES); ?>"))
197 top.restoreSession();
198 window.location.replace("disclosure_full.php?deletelid="+logevent.id)
202 </script>
203 </html>