Fee sheet and Codes revenue code (#7415)
[openemr.git] / interface / reports / cdr_log.php
blobc208f98338fef50ae35924ad72f6c402e0d1a192
1 <?php
3 /**
4 * CDR trigger log report.
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2015-2018 Brady Miller <brady.g.miller@gmail.com>
10 * @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.php");
15 require_once "$srcdir/options.inc.php";
16 require_once "$srcdir/clinical_rules.php";
18 use OpenEMR\Common\Acl\AclMain;
19 use OpenEMR\Common\Csrf\CsrfUtils;
20 use OpenEMR\Common\Twig\TwigContainer;
21 use OpenEMR\Core\Header;
23 if (!AclMain::aclCheckCore('patients', 'med')) {
24 echo (new TwigContainer(null, $GLOBALS['kernel']))->getTwig()->render('core/unauthorized.html.twig', ['pageTitle' => xl("Alerts Log")]);
25 exit;
28 if (!empty($_POST)) {
29 if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) {
30 CsrfUtils::csrfNotVerified();
34 $form_begin_date = DateTimeToYYYYMMDDHHMMSS($_POST['form_begin_date'] ?? '');
35 $form_end_date = DateTimeToYYYYMMDDHHMMSS($_POST['form_end_date'] ?? '');
38 <html>
40 <head>
41 <title><?php echo xlt('Alerts Log'); ?></title>
43 <?php Header::setupHeader('datetime-picker'); ?>
45 <script>
46 $(function () {
47 $('.datepicker').datetimepicker({
48 <?php $datetimepicker_timepicker = true; ?>
49 <?php $datetimepicker_showseconds = true; ?>
50 <?php $datetimepicker_formatInput = true; ?>
51 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
52 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
53 });
54 });
55 </script>
57 <style>
58 /* specifically include & exclude from printing */
59 @media print {
60 #report_parameters {
61 visibility: hidden;
62 display: none;
64 #report_parameters_daterange {
65 visibility: visible;
66 display: inline;
68 #report_results table {
69 margin-top: 0px;
73 /* specifically exclude some from the screen */
74 @media screen {
75 #report_parameters_daterange {
76 visibility: hidden;
77 display: none;
80 </style>
81 </head>
83 <body class="body_top">
85 <!-- Required for the popup date selectors -->
86 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
88 <span class='title'><?php echo xlt('Alerts Log'); ?></span>
90 <form method='post' name='theform' id='theform' action='cdr_log.php' onsubmit='return top.restoreSession()'>
91 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
92 <input type="hidden" name="search" value="1" />
94 <div id="report_parameters">
96 <table>
97 <tr>
98 <td width='470px'>
99 <div style='float: left'>
101 <table class='text'>
103 <tr>
104 <td class='col-form-label'>
105 <?php echo xlt('Begin Date'); ?>:
106 </td>
107 <td>
108 <input type='text' name='form_begin_date' id='form_begin_date' size='20' value='<?php echo attr(oeFormatDateTime($form_begin_date, 0, true)); ?>'
109 class='datepicker form-control'>
110 </td>
111 </tr>
113 <tr>
114 <td class='col-form-label'>
115 <?php echo xlt('End Date'); ?>:
116 </td>
117 <td>
118 <input type='text' name='form_end_date' id='form_end_date' size='20' value='<?php echo attr(oeFormatDateTime($form_end_date, 0, true)); ?>'
119 class='datepicker form-control'>
120 </td>
121 </tr>
122 </table>
123 </div>
125 </td>
126 <td align='left' valign='middle' height="100%">
127 <table style='border-left: 1px solid; width:100%; height:100%' >
128 <tr>
129 <td>
130 <div class="text-center">
131 <div class="btn-group" role="group">
132 <a id='search_button' href='#' class='btn btn-secondary btn-search' onclick='top.restoreSession(); $("#theform").submit()'>
133 <?php echo xlt('Search'); ?>
134 </a>
135 </div>
136 </div>
137 </td>
138 </tr>
139 </table>
140 </td>
141 </tr>
142 </table>
144 </div> <!-- end of search parameters -->
146 <br />
148 <?php if (!empty($_POST['search']) && ($_POST['search'] == 1)) { ?>
149 <div id="report_results">
150 <table class="table">
152 <thead>
153 <th align='center'>
154 <?php echo xlt('Date'); ?>
155 </th>
157 <th align='center'>
158 <?php echo xlt('Patient ID'); ?>
159 </th>
161 <th align='center'>
162 <?php echo xlt('User ID'); ?>
163 </th>
165 <th align='center'>
166 <?php echo xlt('Category'); ?>
167 </th>
169 <th align='center'>
170 <?php echo xlt('All Alerts'); ?>
171 </th>
173 <th align='center'>
174 <?php echo xlt('New Alerts'); ?>
175 </th>
177 </thead>
178 <tbody> <!-- added for better print-ability -->
179 <?php
180 $res = listingCDRReminderLog($form_begin_date, $form_end_date);
182 while ($row = sqlFetchArray($res)) {
183 //Create category title
184 if ($row['category'] == 'clinical_reminder_widget') {
185 $category_title = xl("Passive Alert");
186 } elseif ($row['category'] == 'active_reminder_popup') {
187 $category_title = xl("Active Alert");
188 } elseif ($row['category'] == 'allergy_alert') {
189 $category_title = xl("Allergy Warning");
190 } else {
191 $category_title = $row['category'];
194 //Prepare the targets
195 $all_alerts = json_decode($row['value'], true);
196 if (!empty($row['new_value'])) {
197 $new_alerts = json_decode($row['new_value'], true);
200 <tr>
201 <td><?php echo text(oeFormatDateTime($row['date'], "global", true)); ?></td>
202 <td><?php echo text($row['pid']); ?></td>
203 <td><?php echo text($row['uid']); ?></td>
204 <td><?php echo text($category_title); ?></td>
205 <td>
206 <?php
207 //list off all targets with rule information shown when hover
208 foreach ($all_alerts as $targetInfo => $alert) {
209 if (($row['category'] == 'clinical_reminder_widget') || ($row['category'] == 'active_reminder_popup')) {
210 $rule_title = getListItemTitle("clinical_rules", $alert['rule_id']);
211 $catAndTarget = explode(':', $targetInfo);
212 $category = $catAndTarget[0];
213 $target = $catAndTarget[1];
214 echo "<span title='" . attr($rule_title) . "'>" .
215 generate_display_field(array('data_type' => '1','list_id' => 'rule_action_category'), $category) .
216 ": " . generate_display_field(array('data_type' => '1','list_id' => 'rule_action'), $target) .
217 " (" . generate_display_field(array('data_type' => '1','list_id' => 'rule_reminder_due_opt'), $alert['due_status']) . ")" .
218 "<span><br />";
219 } else { // $row['category'] == 'allergy_alert'
220 echo $alert . "<br />";
224 </td>
225 <td>
226 <?php
227 if (!empty($row['new_value'])) {
228 //list new targets with rule information shown when hover
229 foreach ($new_alerts as $targetInfo => $alert) {
230 if (($row['category'] == 'clinical_reminder_widget') || ($row['category'] == 'active_reminder_popup')) {
231 $rule_title = getListItemTitle("clinical_rules", $alert['rule_id']);
232 $catAndTarget = explode(':', $targetInfo);
233 $category = $catAndTarget[0];
234 $target = $catAndTarget[1];
235 echo "<span title='" . attr($rule_title) . "'>" .
236 generate_display_field(array('data_type' => '1','list_id' => 'rule_action_category'), $category) .
237 ": " . generate_display_field(array('data_type' => '1','list_id' => 'rule_action'), $target) .
238 " (" . generate_display_field(array('data_type' => '1','list_id' => 'rule_reminder_due_opt'), $alert['due_status']) . ")" .
239 "<span><br />";
240 } else { // $row['category'] == 'allergy_alert'
241 echo $alert . "<br />";
244 } else {
245 echo "&nbsp;";
248 </td>
249 </tr>
251 <?php
252 } // $row = sqlFetchArray($res) while
254 </tbody>
255 </table>
256 </div> <!-- end of search results -->
258 <?php } // end of if search button clicked ?>
260 </form>
262 </body>
264 </html>