Remove time limit from the clinical reminder script
[openemr.git] / interface / logview / logview.php
blob4fdaeaf766bb5795cc859188d2026a563cb4f6cc
1 <?php
2 include_once("../globals.php");
3 include_once("$srcdir/log.inc");
4 include_once("$srcdir/formdata.inc.php");
5 require_once("$srcdir/formatting.inc.php");
6 ?>
7 <html>
8 <head>
9 <?php html_header_show();?>
10 <link rel="stylesheet" href='<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.css' type='text/css'>
11 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script>
12 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.js"></script>
13 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
14 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar_setup.js"></script>
16 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-1.2.2.min.js"></script>
17 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
18 <style>
19 #logview {
20 width: 100%;
22 #logview table {
23 width:100%;
24 border-collapse: collapse;
26 #logview th {
27 background-color: #cccccc;
28 cursor: pointer; cursor: hand;
29 padding: 5px 5px;
30 align: left;
31 text-align: left;
34 #logview td {
35 background-color: #ffffff;
36 border-bottom: 1px solid #808080;
37 cursor: default;
38 padding: 5px 5px;
39 vertical-align: top;
41 .highlight {
42 background-color: #336699;
43 color: #336699;
45 </style>
46 <script>
47 //function to disable the event type field if the event name is disclosure
48 function eventTypeChange(eventname)
50 if (eventname == "disclosure") {
51 document.theform.type_event.disabled = true;
53 else {
54 document.theform.type_event.disabled = false;
58 // VicarePlus :: This invokes the find-patient popup.
59 function sel_patient() {
60 dlgopen('../main/calendar/find_patient_popup.php?pflag=0', '_blank', 500, 400);
63 // VicarePlus :: This is for callback by the find-patient popup.
64 function setpatient(pid, lname, fname, dob) {
65 var f = document.theform;
66 f.form_patient.value = lname + ', ' + fname;
67 f.form_pid.value = pid;
70 </script>
71 </head>
72 <body class="body_top">
73 <font class="title"><?php xl('Logs Viewer','e'); ?></font>
74 <br>
75 <?php
76 $err_message=0;
77 if ($_GET["start_date"])
78 $start_date = formData('start_date','G');
80 if ($_GET["end_date"])
81 $end_date = formData('end_date','G');
83 if ($_GET["form_patient"])
84 $form_patient = formData('form_patient','G');
87 * Start date should not be greater than end date - Date Validation
89 if ($start_date && $end_date)
91 if($start_date > $end_date){
92 echo "<table><tr class='alert'><td colspan=7>"; xl('Start Date should not be greater than End Date',e);
93 echo "</td></tr></table>";
94 $err_message=1;
99 <?php
100 $form_user = formData('form_user','R');
101 $form_pid = formData('form_pid','R');
102 if ($form_patient == '' ) $form_pid = '';
104 $res = sqlStatement("select distinct LEFT(date,10) as date from log order by date desc limit 30");
105 for($iter=0;$row=sqlFetchArray($res);$iter++) {
106 $ret[$iter] = $row;
109 // Get the users list.
110 $sqlQuery = "SELECT username, fname, lname FROM users " .
111 "WHERE active = 1 AND ( info IS NULL OR info NOT LIKE '%Inactive%' ) ";
113 $ures = sqlStatement($sqlQuery);
116 <?php
117 $get_sdate=$start_date ? $start_date : date("Y-m-d");
118 $get_edate=$end_date ? $end_date : date("Y-m-d");
122 <br>
123 <FORM METHOD="GET" name="theform" id="theform">
124 <?php
126 $sortby = formData('sortby','G') ;
128 <input type="hidden" name="sortby" id="sortby" value="<?php echo $sortby; ?>">
129 <input type=hidden name=csum value="">
130 <table>
131 <tr><td>
132 <span class="text"><?php xl('Start Date','e'); ?>: </span>
133 </td><td>
134 <input type="text" size="10" name="start_date" id="start_date" value="<?php echo $start_date ? substr($start_date, 0, 10) : date('Y-m-d'); ?>" title="<?php xl('yyyy-mm-dd Date of service','e'); ?>" onkeyup="datekeyup(this,mypcc)" onblur="dateblur(this,mypcc)" />
135 <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 xl('Click here to choose a date','e'); ?>">&nbsp;
136 </td>
137 <td>
138 <span class="text"><?php xl('End Date','e'); ?>: </span>
139 </td><td>
140 <input type="text" size="10" name="end_date" id="end_date" value="<?php echo $end_date ? substr($end_date, 0, 10) : date('Y-m-d'); ?>" title="<?php xl('yyyy-mm-dd Date of service','e'); ?>" onkeyup="datekeyup(this,mypcc)" onblur="dateblur(this,mypcc)" />
141 <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 xl('Click here to choose a date','e'); ?>">&nbsp;
142 </td>
143 <!--VicarePlus :: Feature For Generating Log For The Selected Patient --!>
144 <td>
145 &nbsp;&nbsp;<span class='text'><?php echo htmlspecialchars(xl('Patient'),ENT_NOQUOTES); ?>: </span>
146 </td>
147 <td>
148 <input type='text' size='20' name='form_patient' style='width:100%;cursor:pointer;cursor:hand' value='<?php echo $form_patient ? $form_patient : htmlspecialchars(xl('Click To Select'),ENT_QUOTES); ?>' onclick='sel_patient()' title='<?php echo htmlspecialchars(xl('Click to select patient'),ENT_QUOTES); ?>' />
149 <input type='hidden' name='form_pid' value='<?php echo $form_pid; ?>' />
150 </td>
151 </tr>
152 <tr><td>
153 <span class='text'><?php xl('User','e'); ?>: </span>
154 </td>
155 <td>
156 <?php
157 echo "<select name='form_user'>\n";
158 echo " <option value=''>" . xl('All') . "</option>\n";
159 while ($urow = sqlFetchArray($ures)) {
160 if (!trim($urow['username'])) continue;
161 echo " <option value='" . $urow['username'] . "'";
162 if ($urow['username'] == $form_user) echo " selected";
163 echo ">" . $urow['lname'];
164 if ($urow['fname']) echo ", " . $urow['fname'];
165 echo "</option>\n";
167 echo "</select>\n";
169 </td>
170 <td>
171 <!-- list of events name -->
172 <span class='text'><?php xl('Name of Events','e'); ?>: </span>
173 </td>
174 <td>
175 <?php
176 $res = sqlStatement("select distinct event from log order by event ASC");
177 $ename_list=array(); $j=0;
178 while ($erow = sqlFetchArray($res)) {
179 if (!trim($erow['event'])) continue;
180 $data = explode('-', $erow['event']);
181 $data_c = count($data);
182 $ename=$data[0];
183 for($i=1;$i<($data_c-1);$i++)
185 $ename.="-".$data[$i];
187 $ename_list[$j]=$ename;
188 $j=$j+1;
190 $res1 = sqlStatement("select distinct event from extended_log order by event ASC");
191 $j=0;
192 while ($row = sqlFetchArray($res1)) {
193 if (!trim($row['event'])) continue;
194 $new_event = explode('-', $row['event']);
195 $no = count($new_event);
196 $events=$new_event[0];
197 for($i=1;$i<($no-1);$i++)
199 $events.="-".$new_event[$i];
201 if ($events=="disclosure")
202 $ename_list[$j]=$events;
203 $j=$j+1;
205 $ename_list=array_unique($ename_list);
206 $ename_list=array_merge($ename_list);
207 $ecount=count($ename_list);
208 echo "<select name='eventname' onchange='eventTypeChange(this.options[this.selectedIndex].value);'>\n";
209 echo " <option value=''>" . xl('All') . "</option>\n";
210 for($k=0;$k<$ecount;$k++) {
211 echo " <option value='" .$ename_list[$k]. "'";
212 if ($ename_list[$k] == $eventname && $ename_list[$k]!= "") echo " selected";
213 echo ">" . $ename_list[$k];
214 echo "</option>\n";
216 echo "</select>\n";
218 </td>
219 <!-- type of events ends -->
220 <td>
221 &nbsp;&nbsp;<span class='text'><?php xl('Type of Events','e'); ?>: </span>
222 </td><td>
223 <?php
224 $event_types=array("select", "update", "insert", "delete", "replace");
225 $lcount=count($event_types);
226 if($eventname=="disclosure"){
227 echo "<select name='type_event' disabled='disabled'>\n";
228 echo " <option value=''>" . xl('All') . "</option>\n";
229 echo "</option>\n";
231 else{
232 echo "<select name='type_event'>\n";}
233 echo " <option value=''>" . xl('All') . "</option>\n";
234 for($k=0;$k<$lcount;$k++) {
235 echo " <option value='" .$event_types[$k]. "'";
236 if ($event_types[$k] == $type_event && $event_types[$k]!= "") echo " selected";
237 echo ">" . $event_types[$k];
238 echo "</option>\n";
240 echo "</select>\n";
242 </td>
243 <tr><td>
244 <span class='text'><?php xl('Include Checksum','e'); ?>: </span>
245 </td><td>
246 <?php
248 $check_sum = formData('check_sum','G');
250 <input type="checkbox" name="check_sum" " <?php if ($check_sum == 'on') echo "checked"; ?>"></input>
251 </td>
252 <td>
253 <input type=hidden name="event" value=<?php echo $event ; ?>>
254 <a href="javascript:document.theform.submit();" class='link_submit'>[<?php xl('Refresh','e'); ?>]</a>
255 </td>
256 </tr>
257 </table>
258 </FORM>
261 <?php if ($start_date && $end_date && $err_message!=1) { ?>
262 <div id="logview">
263 <table>
264 <tr>
265 <!-- <TH><?php xl('Date', 'e'); ?><TD> -->
266 <th id="sortby_date" class="text" title="<?php xl('Sort by date/time','e'); ?>"><?php xl('Date','e'); ?></th>
267 <th id="sortby_event" class="text" title="<?php xl('Sort by Event','e'); ?>"><?php xl('Event','e'); ?></th>
268 <th id="sortby_user" class="text" title="<?php xl('Sort by User','e'); ?>"><?php xl('User','e'); ?></th>
269 <th id="sortby_cuser" class="text" title="<?php xl('Sort by Crt User','e'); ?>"><?php xl('Certificate User','e'); ?></th>
270 <th id="sortby_group" class="text" title="<?php xl('Sort by Group','e'); ?>"><?php xl('Group','e'); ?></th>
271 <th id="sortby_pid" class="text" title="<?php xl('Sort by PatientID','e'); ?>"><?php xl('PatientID','e'); ?></th>
272 <th id="sortby_success" class="text" title="<?php xl('Sort by Success','e'); ?>"><?php xl('Success','e'); ?></th>
273 <th id="sortby_comments" class="text" title="<?php xl('Sort by Comments','e'); ?>"><?php xl('Comments','e'); ?></th>
274 <?php if($check_sum) {?>
275 <th id="sortby_checksum" class="text" title="<?php xl('Sort by Checksum','e'); ?>"><?php xl('Checksum','e'); ?></th>
276 <?php } ?>
277 </tr>
278 <?php
280 $eventname = formData('eventname','G');
281 $type_event = formData('type_event','G');
283 <input type=hidden name=event value=<?php echo $eventname."-".$type_event ?>>
284 <?php
286 $tevent=""; $gev="";
287 if($eventname != "" && $type_event != "")
289 $getevent=$eventname."-".$type_event;
292 if(($eventname == "") && ($type_event != ""))
293 { $tevent=$type_event;
295 else if($type_event =="" && $eventname != "")
296 {$gev=$eventname;}
297 else if ($eventname == "")
298 {$gev = "";}
299 else
300 {$gev = $getevent;}
302 if ($ret = getEvents(array('sdate' => $get_sdate,'edate' => $get_edate, 'user' => $form_user, 'patient' => $form_pid, 'sortby' => $_GET['sortby'], 'levent' =>$gev, 'tevent' =>$tevent))) {
305 foreach ($ret as $iter) {
306 //translate comments
307 $patterns = array ('/^success/','/^failure/','/ encounter/');
308 $replace = array ( xl('success'), xl('failure'), xl('encounter','',' '));
309 $trans_comments = preg_replace($patterns, $replace, $iter["comments"]);
312 <TR class="oneresult">
313 <TD class="text"><?php echo oeFormatShortDate(substr($iter["date"], 0, 10)) . substr($iter["date"], 10) ?></TD>
314 <TD class="text"><?php echo xl($iter["event"])?></TD>
315 <TD class="text"><?php echo $iter["user"]?></TD>
316 <TD class="text"><?php echo $iter["crt_user"]?></TD>
317 <TD class="text"><?php echo $iter["groupname"]?></TD>
318 <TD class="text"><?php echo $iter["patient_id"]?></TD>
319 <TD class="text"><?php echo $iter["success"]?></TD>
320 <TD class="text"><?php echo $trans_comments?></TD>
321 <?php if($check_sum) { ?>
322 <TD class="text"><?php echo $iter["checksum"]?></TD>
323 <?php } ?>
324 </TR>
326 <?php
330 if (($eventname=="disclosure") || ($gev == ""))
332 $eventname="disclosure";
333 if ($ret = getEvents(array('sdate' => $get_sdate,'edate' => $get_edate, 'user' => $form_user, 'patient' => $form_pid, 'sortby' => $_GET['sortby'], 'event' =>$eventname))) {
334 foreach ($ret as $iter) {
335 $comments=xl('Recipient Name').":".$iter["recipient"].";".xl('Disclosure Info').":".$iter["description"];
337 <TR class="oneresult">
338 <TD class="text"><?php echo htmlspecialchars(oeFormatShortDate(substr($iter["date"], 0, 10)) . substr($iter["date"], 10),ENT_NOQUOTES); ?></TD>
339 <TD class="text"><?php echo htmlspecialchars(xl($iter["event"]),ENT_NOQUOTES);?></TD>
340 <TD class="text"><?php echo htmlspecialchars($iter["user"],ENT_NOQUOTES);?></TD>
341 <TD class="text"><?php echo htmlspecialchars($iter["crt_user"],ENT_NOQUOTES);?></TD>
342 <TD class="text"><?php echo htmlspecialchars($iter["groupname"],ENT_NOQUOTES);?></TD>
343 <TD class="text"><?php echo htmlspecialchars($iter["patient_id"],ENT_NOQUOTES);?></TD>
344 <TD class="text"><?php echo htmlspecialchars($iter["success"],ENT_NOQUOTES);?></TD>
345 <TD class="text"><?php echo htmlspecialchars($comments,ENT_NOQUOTES);?></TD>
346 <?php if($check_sum) { ?>
347 <TD class="text"><?php echo htmlspecialchars($iter["checksum"],ENT_NOQUOTES);?></TD>
348 <?php } ?>
349 </TR>
350 <?php
355 </table>
356 </div>
358 <?php } ?>
360 </body>
362 <script language="javascript">
364 // jQuery stuff to make the page a little easier to use
365 $(document).ready(function(){
366 // funny thing here... good learning experience
367 // the TR has TD children which have their own background and text color
368 // toggling the TR color doesn't change the TD color
369 // so we need to change all the TR's children (the TD's) just as we did the TR
370 // thus we have two calls to toggleClass:
371 // 1 - for the parent (the TR)
372 // 2 - for each of the children (the TDs)
373 $(".oneresult").mouseover(function() { $(this).toggleClass("highlight"); $(this).children().toggleClass("highlight"); });
374 $(".oneresult").mouseout(function() { $(this).toggleClass("highlight"); $(this).children().toggleClass("highlight"); });
376 // click-able column headers to sort the list
377 $("#sortby_date").click(function() { $("#sortby").val("date"); $("#theform").submit(); });
378 $("#sortby_event").click(function() { $("#sortby").val("event"); $("#theform").submit(); });
379 $("#sortby_user").click(function() { $("#sortby").val("user"); $("#theform").submit(); });
380 $("#sortby_cuser").click(function() { $("#sortby").val("user"); $("#theform").submit(); });
381 $("#sortby_group").click(function() { $("#sortby").val("groupname"); $("#theform").submit(); });
382 $("#sortby_pid").click(function() { $("#sortby").val("patient_id"); $("#theform").submit(); });
383 $("#sortby_success").click(function() { $("#sortby").val("success"); $("#theform").submit(); });
384 $("#sortby_comments").click(function() { $("#sortby").val("comments"); $("#theform").submit(); });
385 $("#sortby_checksum").click(function() { $("#sortby").val("checksum"); $("#theform").submit(); });
389 /* required for popup calendar */
390 Calendar.setup({inputField:"start_date", ifFormat:"%Y-%m-%d", button:"img_begin_date"});
391 Calendar.setup({inputField:"end_date", ifFormat:"%Y-%m-%d", button:"img_end_date"});
393 </script>
395 </html>