adding new buttons to reports (#738)
[openemr.git] / interface / reports / cdr_log.php
blob4c77c16a9d5f7b604b0a9bb7c2d9eb553352f723
1 <?php
2 /**
3 * CDR trigger log report.
5 * Copyright (C) 2015-2017 Brady Miller <brady.g.miller@gmail.com>
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 Brady Miller <brady.g.miller@gmail.com>
20 * @link http://www.open-emr.org
23 //STOP FAKE REGISTER GLOBALS
24 $fake_register_globals=false;
27 require_once("../globals.php");
28 require_once("../../library/patient.inc");
29 require_once "$srcdir/options.inc.php";
30 require_once "$srcdir/clinical_rules.php";
33 <html>
35 <head>
36 <?php html_header_show();?>
38 <title><?php echo xlt('Alerts Log'); ?></title>
40 <?php $include_standard_style_js = array("datetimepicker"); ?>
41 <?php require "{$GLOBALS['srcdir']}/templates/standard_header_template.php"; ?>
43 <script LANGUAGE="JavaScript">
45 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
47 $(document).ready(function() {
48 $('.datepicker').datetimepicker({
49 <?php $datetimepicker_timepicker = true; ?>
50 <?php $datetimepicker_showseconds = true; ?>
51 <?php $datetimepicker_formatInput = false; ?>
52 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
53 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
54 });
55 });
57 </script>
59 <style type="text/css">
61 /* specifically include & exclude from printing */
62 @media print {
63 #report_parameters {
64 visibility: hidden;
65 display: none;
67 #report_parameters_daterange {
68 visibility: visible;
69 display: inline;
71 #report_results table {
72 margin-top: 0px;
76 /* specifically exclude some from the screen */
77 @media screen {
78 #report_parameters_daterange {
79 visibility: hidden;
80 display: none;
84 </style>
85 </head>
87 <body class="body_top">
89 <!-- Required for the popup date selectors -->
90 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
92 <span class='title'><?php echo xlt('Alerts Log'); ?></span>
94 <form method='post' name='theform' id='theform' action='cdr_log.php?search=1' onsubmit='return top.restoreSession()'>
96 <div id="report_parameters">
98 <table>
99 <tr>
100 <td width='470px'>
101 <div style='float:left'>
103 <table class='text'>
105 <tr>
106 <td class='control-label'>
107 <?php echo xlt('Begin Date'); ?>:
108 </td>
109 <td>
110 <input type='text' name='form_begin_date' id='form_begin_date' size='20' value='<?php echo attr($_POST['form_begin_date']); ?>'
111 class='datepicker form-control'
112 title='<?php echo xla('yyyy-mm-dd hh:mm:ss'); ?>'>
113 </td>
114 </tr>
116 <tr>
117 <td class='control-label'>
118 <?php echo xlt('End Date'); ?>:
119 </td>
120 <td>
121 <input type='text' name='form_end_date' id='form_end_date' size='20' value='<?php echo attr($_POST['form_end_date']); ?>'
122 class='datepicker form-control'
123 title='<?php echo xla('yyyy-mm-dd hh:mm:ss'); ?>'>
124 </td>
125 </tr>
126 </table>
127 </div>
129 </td>
130 <td align='left' valign='middle' height="100%">
131 <table style='border-left:1px solid; width:100%; height:100%' >
132 <tr>
133 <td>
134 <div class="text-center">
135 <div class="btn-group" role="group">
136 <a id='search_button' href='#' class='btn btn-default btn-search' onclick='top.restoreSession(); $("#theform").submit()'>
137 <?php echo xlt('Search'); ?>
138 </a>
139 </div>
140 </div>
141 </td>
142 </tr>
143 </table>
144 </td>
145 </tr>
146 </table>
148 </div> <!-- end of search parameters -->
150 <br>
152 <?php if ($_GET['search'] == 1) { ?>
154 <div id="report_results">
155 <table>
157 <thead>
158 <th align='center'>
159 <?php echo xlt('Date'); ?>
160 </th>
162 <th align='center'>
163 <?php echo xlt('Patient ID'); ?>
164 </th>
166 <th align='center'>
167 <?php echo xlt('User ID'); ?>
168 </th>
170 <th align='center'>
171 <?php echo xlt('Category'); ?>
172 </th>
174 <th align='center'>
175 <?php echo xlt('All Alerts'); ?>
176 </th>
178 <th align='center'>
179 <?php echo xlt('New Alerts'); ?>
180 </th>
182 </thead>
183 <tbody> <!-- added for better print-ability -->
184 <?php
185 $res = listingCDRReminderLog($_POST['form_begin_date'],$_POST['form_end_date']);
187 while ($row = sqlFetchArray($res)) {
188 //Create category title
189 if ($row['category'] == 'clinical_reminder_widget') {
190 $category_title = xl("Passive Alert");
192 else if ($row['category'] == 'active_reminder_popup') {
193 $category_title = xl("Active Alert");
195 else if ($row['category'] == 'allergy_alert') {
196 $category_title = xl("Allergy Warning");
198 else {
199 $category_title = $row['category'];
201 //Prepare the targets
202 $all_alerts = json_decode($row['value'], true);
203 if (!empty($row['new_value'])) {
204 $new_alerts = json_decode($row['new_value'], true);
207 <tr>
208 <td><?php echo text($row['date']); ?></td>
209 <td><?php echo text($row['pid']); ?></td>
210 <td><?php echo text($row['uid']); ?></td>
211 <td><?php echo text($category_title); ?></td>
212 <td>
213 <?php
214 //list off all targets with rule information shown when hover
215 foreach ($all_alerts as $targetInfo => $alert) {
216 if ( ($row['category'] == 'clinical_reminder_widget') || ($row['category'] == 'active_reminder_popup') ) {
217 $rule_title = getListItemTitle("clinical_rules",$alert['rule_id']);
218 $catAndTarget = explode(':',$targetInfo);
219 $category = $catAndTarget[0];
220 $target = $catAndTarget[1];
221 echo "<span title='" .attr($rule_title) . "'>" .
222 generate_display_field(array('data_type'=>'1','list_id'=>'rule_action_category'),$category) .
223 ": " . generate_display_field(array('data_type'=>'1','list_id'=>'rule_action'),$target) .
224 " (" . generate_display_field(array('data_type'=>'1','list_id'=>'rule_reminder_due_opt'),$alert['due_status']) . ")" .
225 "<span><br>";
227 else { // $row['category'] == 'allergy_alert'
228 echo $alert . "<br>";
232 </td>
233 <td>
234 <?php
235 if (!empty($row['new_value'])) {
236 //list new targets with rule information shown when hover
237 foreach ($new_alerts as $targetInfo => $alert) {
238 if ( ($row['category'] == 'clinical_reminder_widget') || ($row['category'] == 'active_reminder_popup') ) {
239 $rule_title = getListItemTitle("clinical_rules",$alert['rule_id']);
240 $catAndTarget = explode(':',$targetInfo);
241 $category = $catAndTarget[0];
242 $target = $catAndTarget[1];
243 echo "<span title='" .attr($rule_title) . "'>" .
244 generate_display_field(array('data_type'=>'1','list_id'=>'rule_action_category'),$category) .
245 ": " . generate_display_field(array('data_type'=>'1','list_id'=>'rule_action'),$target) .
246 " (" . generate_display_field(array('data_type'=>'1','list_id'=>'rule_reminder_due_opt'),$alert['due_status']) . ")" .
247 "<span><br>";
249 else { // $row['category'] == 'allergy_alert'
250 echo $alert . "<br>";
254 else {
255 echo "&nbsp;";
258 </td>
259 </tr>
261 <?php
262 } // $row = sqlFetchArray($res) while
264 </tbody>
265 </table>
266 </div> <!-- end of search results -->
268 <?php } // end of if search button clicked ?>
270 </form>
272 </body>
274 </html>