MU2 for items e2 and f1.
[openemr.git] / interface / reports / cdr_log.php
blob5e53f67ae0da9690d9951d36bce62368202f8655
1 <?php
2 /**
3 * CDR trigger log report.
5 * Copyright (C) 2015 Brady Miller <brady@sparmy.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@sparmy.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 require_once("../globals.php");
32 require_once("../../library/patient.inc");
33 require_once("$srcdir/formatting.inc.php");
34 require_once "$srcdir/options.inc.php";
35 require_once "$srcdir/clinical_rules.php";
38 <html>
40 <head>
41 <?php html_header_show();?>
43 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
45 <title><?php echo xlt('Alerts Log'); ?></title>
47 <script type="text/javascript" src="../../library/overlib_mini.js"></script>
48 <script type="text/javascript" src="../../library/textformat.js"></script>
49 <script type="text/javascript" src="../../library/dialog.js"></script>
50 <script type="text/javascript" src="../../library/js/jquery.1.3.2.js"></script>
52 <script LANGUAGE="JavaScript">
54 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
56 </script>
58 <style type="text/css">
60 /* specifically include & exclude from printing */
61 @media print {
62 #report_parameters {
63 visibility: hidden;
64 display: none;
66 #report_parameters_daterange {
67 visibility: visible;
68 display: inline;
70 #report_results table {
71 margin-top: 0px;
75 /* specifically exclude some from the screen */
76 @media screen {
77 #report_parameters_daterange {
78 visibility: hidden;
79 display: none;
83 </style>
84 </head>
86 <body class="body_top">
88 <!-- Required for the popup date selectors -->
89 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
91 <span class='title'><?php echo xlt('Alerts Log'); ?></span>
93 <form method='post' name='theform' id='theform' action='cdr_log.php?search=1' onsubmit='return top.restoreSession()'>
95 <div id="report_parameters">
97 <table>
98 <tr>
99 <td width='470px'>
100 <div style='float:left'>
102 <table class='text'>
104 <tr>
105 <td class='label'>
106 <?php echo xlt('Begin Date'); ?>:
107 </td>
108 <td>
109 <input type='text' name='form_begin_date' id='form_begin_date' size='20' value='<?php echo attr($_POST['form_begin_date']); ?>'
110 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' title='<?php echo xla('yyyy-mm-dd hh:mm:ss'); ?>'>
111 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
112 id='img_begin_date' border='0' alt='[?]' style='cursor:pointer'
113 title='<?php echo xla('Click here to choose a date'); ?>'>
114 </td>
115 </tr>
117 <tr>
118 <td class='label'>
119 <?php echo xlt('End Date'); ?>:
120 </td>
121 <td>
122 <input type='text' name='form_end_date' id='form_end_date' size='20' value='<?php echo attr($_POST['form_end_date']); ?>'
123 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' title='<?php echo xla('yyyy-mm-dd hh:mm:ss'); ?>'>
124 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
125 id='img_end_date' border='0' alt='[?]' style='cursor:pointer'
126 title='<?php echo xla('Click here to choose a date'); ?>'>
127 </td>
128 </tr>
129 </table>
130 </div>
132 </td>
133 <td align='left' valign='middle' height="100%">
134 <table style='border-left:1px solid; width:100%; height:100%' >
135 <tr>
136 <td>
137 <div style='margin-left:15px'>
138 <a id='search_button' href='#' class='css_button' onclick='top.restoreSession(); $("#theform").submit()'>
139 <span>
140 <?php echo xlt('Search'); ?>
141 </span>
142 </a>
143 </div>
144 </td>
145 </tr>
146 </table>
147 </td>
148 </tr>
149 </table>
151 </div> <!-- end of search parameters -->
153 <br>
155 <?php if ($_GET['search'] == 1) { ?>
157 <div id="report_results">
158 <table>
160 <thead>
161 <th align='center'>
162 <?php echo xlt('Date'); ?>
163 </th>
165 <th align='center'>
166 <?php echo xlt('Patient ID'); ?>
167 </th>
169 <th align='center'>
170 <?php echo xlt('User ID'); ?>
171 </th>
173 <th align='center'>
174 <?php echo xlt('Category'); ?>
175 </th>
177 <th align='center'>
178 <?php echo xlt('All Alerts'); ?>
179 </th>
181 <th align='center'>
182 <?php echo xlt('New Alerts'); ?>
183 </th>
185 </thead>
186 <tbody> <!-- added for better print-ability -->
187 <?php
188 $res = listingCDRReminderLog($_POST['form_begin_date'],$_POST['form_end_date']);
190 while ($row = sqlFetchArray($res)) {
191 //Create category title
192 if ($row['category'] == 'clinical_reminder_widget') {
193 $category_title = xl("Passive Alert");
195 else if ($row['category'] == 'active_reminder_popup') {
196 $category_title = xl("Active Alert");
198 else if ($row['category'] == 'allergy_alert') {
199 $category_title = xl("Allergy Warning");
201 else {
202 $category_title = $row['category'];
204 //Prepare the targets
205 $all_alerts = json_decode($row['value'], true);
206 if (!empty($row['new_value'])) {
207 $new_alerts = json_decode($row['new_value'], true);
210 <tr>
211 <td><?php echo text($row['date']); ?></td>
212 <td><?php echo text($row['pid']); ?></td>
213 <td><?php echo text($row['uid']); ?></td>
214 <td><?php echo text($category_title); ?></td>
215 <td>
216 <?php
217 //list off all targets with rule information shown when hover
218 foreach ($all_alerts as $targetInfo => $alert) {
219 if ( ($row['category'] == 'clinical_reminder_widget') || ($row['category'] == 'active_reminder_popup') ) {
220 $rule_title = getListItemTitle("clinical_rules",$alert['rule_id']);
221 $catAndTarget = explode(':',$targetInfo);
222 $category = $catAndTarget[0];
223 $target = $catAndTarget[1];
224 echo "<span title='" .attr($rule_title) . "'>" .
225 generate_display_field(array('data_type'=>'1','list_id'=>'rule_action_category'),$category) .
226 ": " . generate_display_field(array('data_type'=>'1','list_id'=>'rule_action'),$target) .
227 " (" . generate_display_field(array('data_type'=>'1','list_id'=>'rule_reminder_due_opt'),$alert['due_status']) . ")" .
228 "<span><br>";
230 else { // $row['category'] == 'allergy_alert'
231 echo $alert . "<br>";
235 </td>
236 <td>
237 <?php
238 if (!empty($row['new_value'])) {
239 //list new targets with rule information shown when hover
240 foreach ($new_alerts as $targetInfo => $alert) {
241 if ( ($row['category'] == 'clinical_reminder_widget') || ($row['category'] == 'active_reminder_popup') ) {
242 $rule_title = getListItemTitle("clinical_rules",$alert['rule_id']);
243 $catAndTarget = explode(':',$targetInfo);
244 $category = $catAndTarget[0];
245 $target = $catAndTarget[1];
246 echo "<span title='" .attr($rule_title) . "'>" .
247 generate_display_field(array('data_type'=>'1','list_id'=>'rule_action_category'),$category) .
248 ": " . generate_display_field(array('data_type'=>'1','list_id'=>'rule_action'),$target) .
249 " (" . generate_display_field(array('data_type'=>'1','list_id'=>'rule_reminder_due_opt'),$alert['due_status']) . ")" .
250 "<span><br>";
252 else { // $row['category'] == 'allergy_alert'
253 echo $alert . "<br>";
257 else {
258 echo "&nbsp;";
261 </td>
262 </tr>
264 <?php
265 } // $row = sqlFetchArray($res) while
267 </tbody>
268 </table>
269 </div> <!-- end of search results -->
271 <?php } // end of if search button clicked ?>
273 </form>
275 </body>
277 <!-- stuff for the popup calendar -->
278 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
279 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
280 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
281 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
282 <script language="Javascript">
283 Calendar.setup({inputField:"form_begin_date", ifFormat:"%Y-%m-%d %H:%M:%S", button:"img_begin_date", showsTime:'true'});
284 Calendar.setup({inputField:"form_end_date", ifFormat:"%Y-%m-%d %H:%M:%S", button:"img_end_date", showsTime:'true'});
285 </script>
287 </html>