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>;.
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");
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">
52 border
-collapse
: collapse
;
55 background
-color
: #cccccc;
56 cursor
: pointer
; cursor
: hand
;
63 background
-color
: #ffffff;
64 border
-bottom
: 1px solid
#808080;
70 background
-color
: #336699;
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;
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
;
103 <body
class="body_top">
104 <font
class="title"><?php
echo xlt('Audit Log Tamper Report'); ?
></font
>
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>";
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");
140 <FORM METHOD
="GET" name
="theform" id
="theform" onSubmit
='top.restoreSession()'>
143 $sortby = $_GET['sortby'];
145 <input type
="hidden" name
="sortby" id
="sortby" value
="<?php echo attr($sortby); ?>">
146 <input type
=hidden name
=csum value
="">
149 <span
class="text"><?php
echo xlt('Start Date'); ?
>: </span
>
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'); ?>"> 
;
155 <span
class="text"><?php
echo xlt('End Date'); ?
>: </span
>
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'); ?>"> 
;
162  
; 
;<span
class='text'><?php
echo xlt('Patient'); ?
>: </span
>
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); ?>' />
171 <span
class='text'><?php
echo xlt('Include Checksum'); ?
>: </span
>
175 $check_sum = $_GET['check_sum'];
177 <input type
="checkbox" name
="check_sum" " <?php if ($check_sum == 'on') echo "checked
"; ?>"></input
>
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
>
188 <?php
if ($start_date && $end_date && $err_message!=1) { ?
>
190 <span
class="text" id
="display_tamper" style
="display:none;"><?php
echo xlt('Following rows in the audit log have been tampered'); ?
></span
>
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
>
204 $eventname = $_GET['eventname'];
205 $type_event = $_GET['type_event'];
207 <input type
=hidden name
=event value
=<?php
echo attr($eventname)."-".attr($type_event) ?
>>
209 $type_event = "update";
212 if($eventname != "" && $type_event != ""){
213 $getevent=$eventname."-".$type_event;
216 if(($eventname == "") && ($type_event != "")){
218 }else if($type_event =="" && $eventname != ""){
220 }else if ($eventname == ""){
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) {
231 $patterns = array ('/^success/','/^failure/','/ encounter/');
232 $replace = array ( xl('success'), xl('failure'), xl('encounter','',' '));
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){
255 if($commentEncrStatus == "Yes"){
256 $decrypt_comment = trim(aes256Decrypt($iter["comments"]));
257 $trans_comments = preg_replace($patterns, $replace, $decrypt_comment);
259 $comments = trim($iter["comments"]);
260 $trans_comments = preg_replace($patterns, $replace, $comments);
263 //Alter Checksum value records only display here
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
>
282 if( count($dispArr) == 0 ){?
>
283 <TR
class="oneresult">
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
>
292 <script type
="text/javascript">$
('#display_tamper').css('display', 'block');</script
>
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});