added new datepicker to amendments gui
[openemr.git] / interface / reports / audit_log_tamper_report.php
blob5c5683010a24a1ab5e7cba4f89f6689e993e71ab
1 <?php
2 /**
3 * Audit Log Tamper Report.
5 * Copyright (C) 2014 Ensoftek
7 * LICENSE: This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
18 * @package OpenEMR
19 * @author Anil N <aniln@ensoftek.com>
20 * @link http://www.open-emr.org
23 //SANITIZE ALL ESCAPES
24 $sanitize_all_escapes=true;
27 //STOP FAKE REGISTER GLOBALS
28 $fake_register_globals=false;
31 include_once("../globals.php");
32 include_once("$srcdir/log.inc");
33 require_once("$srcdir/formatting.inc.php");
35 <html>
36 <head>
37 <?php html_header_show();?>
38 <link rel="stylesheet" href='<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.css' type='text/css'>
39 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
40 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.js"></script>
41 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
42 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar_setup.js"></script>
44 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-2/index.js"></script>
45 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
46 <style>
47 #logview {
48 width: 100%;
50 #logview table {
51 width:100%;
52 border-collapse: collapse;
54 #logview th {
55 background-color: #cccccc;
56 cursor: pointer; cursor: hand;
57 padding: 5px 5px;
58 align: left;
59 text-align: left;
62 #logview td {
63 background-color: #ffffff;
64 border-bottom: 1px solid #808080;
65 cursor: default;
66 padding: 5px 5px;
67 vertical-align: top;
69 .highlight {
70 background-color: #336699;
71 color: #336699;
73 .tamperColor{
74 color:red;
76 </style>
77 <script>
78 //function to disable the event type field if the event name is disclosure
79 function eventTypeChange(eventname)
81 if (eventname == "disclosure") {
82 document.theform.type_event.disabled = true;
84 else {
85 document.theform.type_event.disabled = false;
89 // VicarePlus :: This invokes the find-patient popup.
90 function sel_patient() {
91 dlgopen('../main/calendar/find_patient_popup.php?pflag=0', '_blank', 500, 400);
94 // VicarePlus :: This is for callback by the find-patient popup.
95 function setpatient(pid, lname, fname, dob) {
96 var f = document.theform;
97 f.form_patient.value = lname + ', ' + fname;
98 f.form_pid.value = pid;
101 </script>
102 </head>
103 <body class="body_top">
104 <font class="title"><?php echo xlt('Audit Log Tamper Report'); ?></font>
105 <br>
106 <?php
107 $err_message=0;
108 if ($_GET["start_date"])
109 $start_date = $_GET['start_date'];
111 if ($_GET["end_date"])
112 $end_date = $_GET['end_date'];
114 if ($_GET["form_patient"])
115 $form_patient = $_GET['form_patient'];
118 * Start date should not be greater than end date - Date Validation
120 if ($start_date && $end_date)
122 if($start_date > $end_date){
123 echo "<table><tr class='alert'><td colspan=7>"; echo xlt('Start Date should not be greater than End Date');
124 echo "</td></tr></table>";
125 $err_message=1;
130 <?php
131 $form_user = $_REQUEST['form_user'];
132 $form_pid = $_REQUEST['form_pid'];
133 if ($form_patient == '' ) $form_pid = '';
135 $get_sdate=$start_date ? $start_date : date("Y-m-d H:i:s");
136 $get_edate=$end_date ? $end_date : date("Y-m-d H:i:s");
139 <br>
140 <FORM METHOD="GET" name="theform" id="theform" onSubmit='top.restoreSession()'>
141 <?php
143 $sortby = $_GET['sortby'];
145 <input type="hidden" name="sortby" id="sortby" value="<?php echo attr($sortby); ?>">
146 <input type=hidden name=csum value="">
147 <table>
148 <tr><td>
149 <span class="text"><?php echo xlt('Start Date'); ?>: </span>
150 </td><td>
151 <input type="text" size="18" name="start_date" id="start_date" value="<?php echo $start_date ? $start_date : date('Y-m-d H:i:s'); ?>" title="<?php echo xla('yyyy-mm-dd H:m Start date'); ?>" onkeyup="datekeyup(this,mypcc,true)" onblur="dateblur(this,mypcc,true)" />
152 <img src="../pic/show_calendar.gif" align="absbottom" width="24" height="22" id="img_begin_date" border="0" alt="[?]" style="cursor: pointer; cursor: hand" title="<?php echo xla('Click here to choose date time'); ?>">&nbsp;
153 </td>
154 <td>
155 <span class="text"><?php echo xlt('End Date'); ?>: </span>
156 </td><td>
157 <input type="text" size="18" name="end_date" id="end_date" value="<?php echo $end_date ? $end_date : date('Y-m-d H:i:s'); ?>" title="<?php echo xla('yyyy-mm-dd H:m End date'); ?>" onkeyup="datekeyup(this,mypcc,true)" onblur="dateblur(this,mypcc,true)" />
158 <img src="../pic/show_calendar.gif" align="absbottom" width="24" height="22" id="img_end_date" border="0" alt="[?]" style="cursor: pointer; cursor: hand" title="<?php echo xla('Click here to choose date time'); ?>">&nbsp;
159 </td>
161 <td>
162 &nbsp;&nbsp;<span class='text'><?php echo xlt('Patient'); ?>: </span>
163 </td>
164 <td>
165 <input type='text' size='20' name='form_patient' style='width:100%;cursor:pointer;cursor:hand' value='<?php echo attr($form_patient) ? attr($form_patient) : xla('Click To Select'); ?>' onclick='sel_patient()' title='<?php echo xlt('Click to select patient'); ?>' />
166 <input type='hidden' name='form_pid' value='<?php echo attr($form_pid); ?>' />
167 </td>
168 </tr>
170 <tr><td>
171 <span class='text'><?php echo xlt('Include Checksum'); ?>: </span>
172 </td><td>
173 <?php
175 $check_sum = $_GET['check_sum'];
177 <input type="checkbox" name="check_sum" " <?php if ($check_sum == 'on') echo "checked"; ?>"></input>
178 </td>
179 <td>
180 <input type=hidden name="event" value=<?php echo attr($event) ; ?>>
181 <a href="javascript:document.theform.submit();" class='link_submit'>[<?php echo xlt('Refresh'); ?>]</a>
182 </td>
183 </tr>
184 </table>
185 </FORM>
188 <?php if ($start_date && $end_date && $err_message!=1) { ?>
189 <div id="logview">
190 <span class="text" id="display_tamper" style="display:none;"><?php echo xlt('Following rows in the audit log have been tampered'); ?></span>
191 <table>
192 <tr>
193 <th id="sortby_date" class="text" title="<?php echo xla('Sort by Tamper date/time'); ?>"><?php echo xlt('Tamper Date'); ?></th>
194 <th id="sortby_user" class="text" title="<?php echo xla('Sort by User'); ?>"><?php echo xlt('User'); ?></th>
195 <th id="sortby_pid" class="text" title="<?php echo xla('Sort by PatientID'); ?>"><?php echo xlt('PatientID'); ?></th>
196 <th id="sortby_comments" class="text" title="<?php echo xla('Sort by Comments'); ?>"><?php echo xlt('Comments'); ?></th>
197 <?php if($check_sum) {?>
198 <th id="sortby_newchecksum" class="text" title="<?php xla('Sort by New Checksum'); ?>"><?php xlt('Tampered Checksum'); ?></th>
199 <th id="sortby_oldchecksum" class="text" title="<?php xla('Sort by Old Checksum'); ?>"><?php xlt('Original Checksum'); ?></th>
200 <?php } ?>
201 </tr>
202 <?php
204 $eventname = $_GET['eventname'];
205 $type_event = $_GET['type_event'];
207 <input type=hidden name=event value=<?php echo attr($eventname)."-".attr($type_event) ?>>
208 <?php
209 $type_event = "update";
210 $tevent="";
211 $gev="";
212 if($eventname != "" && $type_event != ""){
213 $getevent=$eventname."-".$type_event;
216 if(($eventname == "") && ($type_event != "")){
217 $tevent=$type_event;
218 }else if($type_event =="" && $eventname != ""){
219 $gev=$eventname;
220 }else if ($eventname == ""){
221 $gev = "";
222 }else{
223 $gev = $getevent;
226 $dispArr = array();
227 $icnt = 1;
228 if ($ret = getEvents(array('sdate' => $get_sdate,'edate' => $get_edate, 'user' => $form_user, 'patient' => $form_pid, 'sortby' => $_GET['sortby'], 'levent' =>$gev, 'tevent' =>$tevent))) {
229 foreach ($ret as $iter) {
230 //translate comments
231 $patterns = array ('/^success/','/^failure/','/ encounter/');
232 $replace = array ( xl('success'), xl('failure'), xl('encounter','',' '));
234 $dispCheck = false;
235 $log_id = $iter['id'];
236 $commentEncrStatus = "No";
237 $logEncryptData = logCommentEncryptData($log_id);
239 if(count($logEncryptData) > 0){
240 $commentEncrStatus = $logEncryptData['encrypt'];
241 $checkSumOld = $logEncryptData['checksum'];
242 $concatLogColumns = $iter['date'].$iter['event'].$iter['user'].$iter['groupname'].$iter['comments'].$iter['patient_id'].$iter['success'].$iter['checksum'].$iter['crt_user'];
243 $checkSumNew = sha1($concatLogColumns);
245 if($checkSumOld != $checkSumNew){
246 $dispCheck = true;
247 }else{
248 $dispCheck = false;
249 continue;
251 }else{
252 continue;
255 if($commentEncrStatus == "Yes"){
256 $decrypt_comment = trim(aes256Decrypt($iter["comments"]));
257 $trans_comments = preg_replace($patterns, $replace, $decrypt_comment);
258 }else{
259 $comments = trim($iter["comments"]);
260 $trans_comments = preg_replace($patterns, $replace, $comments);
263 //Alter Checksum value records only display here
264 if($dispCheck){
265 $dispArr[] = $icnt++;
267 <TR class="oneresult">
268 <TD class="text tamperColor"><?php echo oeFormatShortDate(substr($iter["date"], 0, 10)) . substr($iter["date"], 10) ?></TD>
269 <TD class="text tamperColor"><?php echo text($iter["user"]); ?></TD>
270 <TD class="text tamperColor"><?php echo text($iter["patient_id"]);?></TD>
271 <TD class="text tamperColor"><?php echo text($trans_comments);?></TD>
272 <?php if($check_sum) { ?>
273 <TD class="text tamperColor"><?php echo text($checkSumNew);?></TD>
274 <TD class="text tamperColor"><?php echo text($checkSumOld);?></TD>
275 <?php } ?>
276 </TR>
277 <?php
282 if( count($dispArr) == 0 ){?>
283 <TR class="oneresult">
284 <?php
285 $colspan = 4;
286 if($check_sum) $colspan=6;
288 <TD class="text" colspan="<?php echo $colspan;?>" align="center"><?php echo xlt('No audit log tampering detected in the selected date range.'); ?></TD>
289 </TR>
290 <?php
291 }else{?>
292 <script type="text/javascript">$('#display_tamper').css('display', 'block');</script>
293 <?php
297 </table>
298 </div>
299 <?php } ?>
300 </body>
301 <script language="javascript">
303 // jQuery stuff to make the page a little easier to use
304 $(document).ready(function(){
305 // funny thing here... good learning experience
306 // the TR has TD children which have their own background and text color
307 // toggling the TR color doesn't change the TD color
308 // so we need to change all the TR's children (the TD's) just as we did the TR
309 // thus we have two calls to toggleClass:
310 // 1 - for the parent (the TR)
311 // 2 - for each of the children (the TDs)
312 $(".oneresult").mouseover(function() { $(this).toggleClass("highlight"); $(this).children().toggleClass("highlight"); });
313 $(".oneresult").mouseout(function() { $(this).toggleClass("highlight"); $(this).children().toggleClass("highlight"); });
315 // click-able column headers to sort the list
316 $("#sortby_date").click(function() { $("#sortby").val("date"); $("#theform").submit(); });
317 $("#sortby_event").click(function() { $("#sortby").val("event"); $("#theform").submit(); });
318 $("#sortby_user").click(function() { $("#sortby").val("user"); $("#theform").submit(); });
319 $("#sortby_cuser").click(function() { $("#sortby").val("user"); $("#theform").submit(); });
320 $("#sortby_group").click(function() { $("#sortby").val("groupname"); $("#theform").submit(); });
321 $("#sortby_pid").click(function() { $("#sortby").val("patient_id"); $("#theform").submit(); });
322 $("#sortby_success").click(function() { $("#sortby").val("success"); $("#theform").submit(); });
323 $("#sortby_comments").click(function() { $("#sortby").val("comments"); $("#theform").submit(); });
324 $("#sortby_oldchecksum").click(function() { $("#sortby").val("checksum"); $("#theform").submit(); });
325 $("#sortby_newchecksum").click(function() { $("#sortby").val("checksum"); $("#theform").submit(); });
329 /* required for popup calendar */
330 Calendar.setup({inputField:"start_date", ifFormat:"%Y-%m-%d %H:%M:%S", button:"img_begin_date", showsTime:true});
331 Calendar.setup({inputField:"end_date", ifFormat:"%Y-%m-%d %H:%M:%S", button:"img_end_date", showsTime:true});
333 </script>
335 </html>