3 * Audit Log Tamper Report.
6 * @link http://www.open-emr.org
7 * @author Anil N <aniln@ensoftek.com>
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2014 Ensoftek
10 * @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 include_once("../globals.php");
16 include_once("$srcdir/log.inc");
21 <title
><?php
echo xlt("Audit Log Tamper Report"); ?
></title
>
23 <?php
html_header_show();?
>
25 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
26 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
28 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script
>
29 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
30 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script
>
38 border
-collapse
: collapse
;
41 background
-color
: #cccccc;
42 cursor
: pointer
; cursor
: hand
;
49 background
-color
: #ffffff;
50 border
-bottom
: 1px solid
#808080;
56 background
-color
: #336699;
64 //function to disable the event type field if the event name is disclosure
65 function eventTypeChange(eventname
)
67 if (eventname
== "disclosure") {
68 document
.theform
.type_event
.disabled
= true;
71 document
.theform
.type_event
.disabled
= false;
75 // VicarePlus :: This invokes the find-patient popup.
76 function sel_patient() {
77 dlgopen('../main/calendar/find_patient_popup.php?pflag=0', '_blank', 500, 400);
80 // VicarePlus :: This is for callback by the find-patient popup.
81 function setpatient(pid
, lname
, fname
, dob
) {
82 var f
= document
.theform
;
83 f
.form_patient
.value
= lname +
', ' + fname
;
84 f
.form_pid
.value
= pid
;
89 <body
class="body_top">
90 <font
class="title"><?php
echo xlt('Audit Log Tamper Report'); ?
></font
>
94 if ($_GET["start_date"]) {
95 $start_date = $_GET['start_date'];
98 if ($_GET["end_date"]) {
99 $end_date = $_GET['end_date'];
102 if ($_GET["form_patient"]) {
103 $form_patient = $_GET['form_patient'];
107 * Start date should not be greater than end date - Date Validation
109 if ($start_date && $end_date) {
110 if ($start_date > $end_date) {
111 echo "<table><tr class='alert'><td colspan=7>";
112 echo xlt('Start Date should not be greater than End Date');
113 echo "</td></tr></table>";
120 $form_user = $_REQUEST['form_user'];
121 $form_pid = $_REQUEST['form_pid'];
122 if ($form_patient == '') {
126 $get_sdate=$start_date ?
$start_date : date("Y-m-d H:i:s");
127 $get_edate=$end_date ?
$end_date : date("Y-m-d H:i:s");
131 <FORM METHOD
="GET" name
="theform" id
="theform" onSubmit
='top.restoreSession()'>
134 $sortby = $_GET['sortby'];
136 <input type
="hidden" name
="sortby" id
="sortby" value
="<?php echo attr($sortby); ?>">
137 <input type
=hidden name
=csum value
="">
140 <span
class="text"><?php
echo xlt('Start Date'); ?
>: </span
>
142 <input type
="text" size
="18" class="datetimepicker" 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'); ?>" />
145 <span
class="text"><?php
echo xlt('End Date'); ?
>: </span
>
147 <input type
="text" size
="18" class="datetimepicker" 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'); ?>" />
151  
; 
;<span
class='text'><?php
echo xlt('Patient'); ?
>: </span
>
154 <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
'); ?>' />
155 <input type
='hidden' name
='form_pid' value
='<?php echo attr($form_pid); ?>' />
160 <span
class='text'><?php
echo xlt('Include Checksum'); ?
>: </span
>
164 $check_sum = isset($_GET['check_sum']);
166 <input type
="checkbox" name
="check_sum" <?php
echo ($check_sum) ?
"checked" : ""; ?
>>
169 <input type
=hidden name
="event" value
=<?php
echo attr($event) ; ?
>>
170 <a href
="javascript:document.theform.submit();" class='link_submit'>[<?php
echo xlt('Refresh'); ?
>]</a
>
177 <?php
if ($start_date && $end_date && $err_message!=1) { ?
>
179 <span
class="text" id
="display_tamper" style
="display:none;"><?php
echo xlt('Following rows in the audit log have been tampered'); ?
></span
>
182 <th id
="sortby_date" class="text" title
="<?php echo xla('Sort by Tamper date/time'); ?>"><?php
echo xlt('Tamper Date'); ?
></th
>
183 <th id
="sortby_user" class="text" title
="<?php echo xla('Sort by User'); ?>"><?php
echo xlt('User'); ?
></th
>
184 <th id
="sortby_pid" class="text" title
="<?php echo xla('Sort by PatientID'); ?>"><?php
echo xlt('PatientID'); ?
></th
>
185 <th id
="sortby_comments" class="text" title
="<?php echo xla('Sort by Comments'); ?>"><?php
echo xlt('Comments'); ?
></th
>
186 <?php
if ($check_sum) {?
>
187 <th id
="sortby_newchecksum" class="text" title
="<?php xla('Sort by New Checksum'); ?>"><?php
echo xlt('Tampered Checksum'); ?
></th
>
188 <th id
="sortby_oldchecksum" class="text" title
="<?php xla('Sort by Old Checksum'); ?>"><?php
echo xlt('Original Checksum'); ?
></th
>
193 $eventname = $_GET['eventname'];
194 $type_event = $_GET['type_event'];
196 <input type
=hidden name
=event value
=<?php
echo attr($eventname)."-".attr($type_event) ?
>>
198 $type_event = "update";
201 if ($eventname != "" && $type_event != "") {
202 $getevent=$eventname."-".$type_event;
205 if (($eventname == "") && ($type_event != "")) {
207 } else if ($type_event =="" && $eventname != "") {
209 } else if ($eventname == "") {
217 if ($ret = getEvents(array('sdate' => $get_sdate,'edate' => $get_edate, 'user' => $form_user, 'patient' => $form_pid, 'sortby' => $_GET['sortby'], 'levent' =>$gev, 'tevent' =>$tevent))) {
218 foreach ($ret as $iter) {
220 $patterns = array ('/^success/','/^failure/','/ encounter/');
221 $replace = array ( xl('success'), xl('failure'), xl('encounter', '', ' '));
224 $log_id = $iter['id'];
225 $commentEncrStatus = "No";
226 $logEncryptData = logCommentEncryptData($log_id);
228 if (count($logEncryptData) > 0) {
229 $commentEncrStatus = $logEncryptData['encrypt'];
230 $checkSumOld = $logEncryptData['checksum'];
231 $concatLogColumns = $iter['date'].$iter['event'].$iter['user'].$iter['groupname'].$iter['comments'].$iter['patient_id'].$iter['success'].$iter['checksum'].$iter['crt_user'];
232 $checkSumNew = sha1($concatLogColumns);
234 if ($checkSumOld != $checkSumNew) {
244 if ($commentEncrStatus == "Yes") {
245 $decrypt_comment = trim(aes256Decrypt($iter["comments"]));
246 $trans_comments = preg_replace($patterns, $replace, $decrypt_comment);
248 $comments = trim($iter["comments"]);
249 $trans_comments = preg_replace($patterns, $replace, $comments);
252 //Alter Checksum value records only display here
254 $dispArr[] = $icnt++
;
256 <TR
class="oneresult">
257 <TD
class="text tamperColor"><?php
echo oeFormatShortDate(substr($iter["date"], 0, 10)) . substr($iter["date"], 10) ?
></TD
>
258 <TD
class="text tamperColor"><?php
echo text($iter["user"]); ?
></TD
>
259 <TD
class="text tamperColor"><?php
echo text($iter["patient_id"]);?
></TD
>
260 <TD
class="text tamperColor"><?php
echo text($trans_comments);?
></TD
>
261 <?php
if ($check_sum) { ?
>
262 <TD
class="text tamperColor"><?php
echo text($checkSumNew);?
></TD
>
263 <TD
class="text tamperColor"><?php
echo text($checkSumOld);?
></TD
>
271 if (count($dispArr) == 0) {?
>
272 <TR
class="oneresult">
279 <TD
class="text" colspan
="<?php echo $colspan;?>" align
="center"><?php
echo xlt('No audit log tampering detected in the selected date range.'); ?
></TD
>
283 <script type
="text/javascript">$
('#display_tamper').css('display', 'block');</script
>
292 <script language
="javascript">
294 // jQuery stuff to make the page a little easier to use
295 $
(document
).ready(function(){
296 // funny thing here... good learning experience
297 // the TR has TD children which have their own background and text color
298 // toggling the TR color doesn't change the TD color
299 // so we need to change all the TR's children (the TD's) just as we did the TR
300 // thus we have two calls to toggleClass:
301 // 1 - for the parent (the TR)
302 // 2 - for each of the children (the TDs)
303 $
(".oneresult").mouseover(function() { $
(this
).toggleClass("highlight"); $
(this
).children().toggleClass("highlight"); });
304 $
(".oneresult").mouseout(function() { $
(this
).toggleClass("highlight"); $
(this
).children().toggleClass("highlight"); });
306 // click-able column headers to sort the list
307 $
("#sortby_date").click(function() { $
("#sortby").val("date"); $
("#theform").submit(); });
308 $
("#sortby_event").click(function() { $
("#sortby").val("event"); $
("#theform").submit(); });
309 $
("#sortby_user").click(function() { $
("#sortby").val("user"); $
("#theform").submit(); });
310 $
("#sortby_cuser").click(function() { $
("#sortby").val("user"); $
("#theform").submit(); });
311 $
("#sortby_group").click(function() { $
("#sortby").val("groupname"); $
("#theform").submit(); });
312 $
("#sortby_pid").click(function() { $
("#sortby").val("patient_id"); $
("#theform").submit(); });
313 $
("#sortby_success").click(function() { $
("#sortby").val("success"); $
("#theform").submit(); });
314 $
("#sortby_comments").click(function() { $
("#sortby").val("comments"); $
("#theform").submit(); });
315 $
("#sortby_oldchecksum").click(function() { $
("#sortby").val("checksum"); $
("#theform").submit(); });
316 $
("#sortby_newchecksum").click(function() { $
("#sortby").val("checksum"); $
("#theform").submit(); });
318 $
('.datetimepicker').datetimepicker({
319 <?php
$datetimepicker_timepicker = true; ?
>
320 <?php
$datetimepicker_showseconds = true; ?
>
321 <?php
$datetimepicker_formatInput = false; ?
>
322 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
323 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>