bug fixins (#1951)
[openemr.git] / interface / reports / cdr_log.php
blob9c4f8d60f5e69d62020b197bec91fae4fe0469a8
1 <?php
2 /**
3 * CDR trigger log report.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Brady Miller <brady.g.miller@gmail.com>
8 * @copyright Copyright (c) 2015-2017 Brady Miller <brady.g.miller@gmail.com>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 require_once("../globals.php");
14 require_once("../../library/patient.inc");
15 require_once "$srcdir/options.inc.php";
16 require_once "$srcdir/clinical_rules.php";
18 use OpenEMR\Core\Header;
20 $form_begin_date = DateTimeToYYYYMMDDHHMMSS($_POST['form_begin_date']);
21 $form_end_date = DateTimeToYYYYMMDDHHMMSS($_POST['form_end_date']);
24 <html>
26 <head>
27 <title><?php echo xlt('Alerts Log'); ?></title>
29 <?php Header::setupHeader('datetime-picker'); ?>
31 <script LANGUAGE="JavaScript">
32 $(document).ready(function() {
33 $('.datepicker').datetimepicker({
34 <?php $datetimepicker_timepicker = true; ?>
35 <?php $datetimepicker_showseconds = true; ?>
36 <?php $datetimepicker_formatInput = true; ?>
37 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
38 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
39 });
40 });
41 </script>
43 <style type="text/css">
44 /* specifically include & exclude from printing */
45 @media print {
46 #report_parameters {
47 visibility: hidden;
48 display: none;
50 #report_parameters_daterange {
51 visibility: visible;
52 display: inline;
54 #report_results table {
55 margin-top: 0px;
59 /* specifically exclude some from the screen */
60 @media screen {
61 #report_parameters_daterange {
62 visibility: hidden;
63 display: none;
66 </style>
67 </head>
69 <body class="body_top">
71 <!-- Required for the popup date selectors -->
72 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
74 <span class='title'><?php echo xlt('Alerts Log'); ?></span>
76 <form method='post' name='theform' id='theform' action='cdr_log.php?search=1' onsubmit='return top.restoreSession()'>
78 <div id="report_parameters">
80 <table>
81 <tr>
82 <td width='470px'>
83 <div style='float:left'>
85 <table class='text'>
87 <tr>
88 <td class='control-label'>
89 <?php echo xlt('Begin Date'); ?>:
90 </td>
91 <td>
92 <input type='text' name='form_begin_date' id='form_begin_date' size='20' value='<?php echo attr(oeFormatDateTime($form_begin_date, 0, true)); ?>'
93 class='datepicker form-control'>
94 </td>
95 </tr>
97 <tr>
98 <td class='control-label'>
99 <?php echo xlt('End Date'); ?>:
100 </td>
101 <td>
102 <input type='text' name='form_end_date' id='form_end_date' size='20' value='<?php echo attr(oeFormatDateTime($form_end_date, 0, true)); ?>'
103 class='datepicker form-control'>
104 </td>
105 </tr>
106 </table>
107 </div>
109 </td>
110 <td align='left' valign='middle' height="100%">
111 <table style='border-left:1px solid; width:100%; height:100%' >
112 <tr>
113 <td>
114 <div class="text-center">
115 <div class="btn-group" role="group">
116 <a id='search_button' href='#' class='btn btn-default btn-search' onclick='top.restoreSession(); $("#theform").submit()'>
117 <?php echo xlt('Search'); ?>
118 </a>
119 </div>
120 </div>
121 </td>
122 </tr>
123 </table>
124 </td>
125 </tr>
126 </table>
128 </div> <!-- end of search parameters -->
130 <br>
132 <?php if ($_GET['search'] == 1) { ?>
134 <div id="report_results">
135 <table>
137 <thead>
138 <th align='center'>
139 <?php echo xlt('Date'); ?>
140 </th>
142 <th align='center'>
143 <?php echo xlt('Patient ID'); ?>
144 </th>
146 <th align='center'>
147 <?php echo xlt('User ID'); ?>
148 </th>
150 <th align='center'>
151 <?php echo xlt('Category'); ?>
152 </th>
154 <th align='center'>
155 <?php echo xlt('All Alerts'); ?>
156 </th>
158 <th align='center'>
159 <?php echo xlt('New Alerts'); ?>
160 </th>
162 </thead>
163 <tbody> <!-- added for better print-ability -->
164 <?php
165 $res = listingCDRReminderLog($form_begin_date, $form_end_date);
167 while ($row = sqlFetchArray($res)) {
168 //Create category title
169 if ($row['category'] == 'clinical_reminder_widget') {
170 $category_title = xl("Passive Alert");
171 } else if ($row['category'] == 'active_reminder_popup') {
172 $category_title = xl("Active Alert");
173 } else if ($row['category'] == 'allergy_alert') {
174 $category_title = xl("Allergy Warning");
175 } else {
176 $category_title = $row['category'];
179 //Prepare the targets
180 $all_alerts = json_decode($row['value'], true);
181 if (!empty($row['new_value'])) {
182 $new_alerts = json_decode($row['new_value'], true);
185 <tr>
186 <td><?php echo text(oeFormatDateTime($row['date'], "global", true)); ?></td>
187 <td><?php echo text($row['pid']); ?></td>
188 <td><?php echo text($row['uid']); ?></td>
189 <td><?php echo text($category_title); ?></td>
190 <td>
191 <?php
192 //list off all targets with rule information shown when hover
193 foreach ($all_alerts as $targetInfo => $alert) {
194 if (($row['category'] == 'clinical_reminder_widget') || ($row['category'] == 'active_reminder_popup')) {
195 $rule_title = getListItemTitle("clinical_rules", $alert['rule_id']);
196 $catAndTarget = explode(':', $targetInfo);
197 $category = $catAndTarget[0];
198 $target = $catAndTarget[1];
199 echo "<span title='" .attr($rule_title) . "'>" .
200 generate_display_field(array('data_type'=>'1','list_id'=>'rule_action_category'), $category) .
201 ": " . generate_display_field(array('data_type'=>'1','list_id'=>'rule_action'), $target) .
202 " (" . generate_display_field(array('data_type'=>'1','list_id'=>'rule_reminder_due_opt'), $alert['due_status']) . ")" .
203 "<span><br>";
204 } else { // $row['category'] == 'allergy_alert'
205 echo $alert . "<br>";
209 </td>
210 <td>
211 <?php
212 if (!empty($row['new_value'])) {
213 //list new targets with rule information shown when hover
214 foreach ($new_alerts as $targetInfo => $alert) {
215 if (($row['category'] == 'clinical_reminder_widget') || ($row['category'] == 'active_reminder_popup')) {
216 $rule_title = getListItemTitle("clinical_rules", $alert['rule_id']);
217 $catAndTarget = explode(':', $targetInfo);
218 $category = $catAndTarget[0];
219 $target = $catAndTarget[1];
220 echo "<span title='" .attr($rule_title) . "'>" .
221 generate_display_field(array('data_type'=>'1','list_id'=>'rule_action_category'), $category) .
222 ": " . generate_display_field(array('data_type'=>'1','list_id'=>'rule_action'), $target) .
223 " (" . generate_display_field(array('data_type'=>'1','list_id'=>'rule_reminder_due_opt'), $alert['due_status']) . ")" .
224 "<span><br>";
225 } else { // $row['category'] == 'allergy_alert'
226 echo $alert . "<br>";
229 } else {
230 echo "&nbsp;";
233 </td>
234 </tr>
236 <?php
237 } // $row = sqlFetchArray($res) while
239 </tbody>
240 </table>
241 </div> <!-- end of search results -->
243 <?php } // end of if search button clicked ?>
245 </form>
247 </body>
249 </html>