4 * CDR trigger log report.
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")]);
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'] ??
'');
41 <title
><?php
echo xlt('Alerts Log'); ?
></title
>
43 <?php Header
::setupHeader('datetime-picker'); ?
>
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 ?>
58 /* specifically include & exclude from printing */
64 #report_parameters_daterange {
68 #report_results table {
73 /* specifically exclude some from the screen */
75 #report_parameters_daterange {
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">
99 <div style
='float: left'>
104 <td
class='col-form-label'>
105 <?php
echo xlt('Begin Date'); ?
>:
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'>
114 <td
class='col-form-label'>
115 <?php
echo xlt('End Date'); ?
>:
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'>
126 <td align
='left' valign
='middle' height
="100%">
127 <table style
='border-left: 1px solid; width:100%; height:100%' >
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'); ?
>
144 </div
> <!-- end of search parameters
-->
148 <?php
if (!empty($_POST['search']) && ($_POST['search'] == 1)) { ?
>
149 <div id
="report_results">
150 <table
class="table">
154 <?php
echo xlt('Date'); ?
>
158 <?php
echo xlt('Patient ID'); ?
>
162 <?php
echo xlt('User ID'); ?
>
166 <?php
echo xlt('Category'); ?
>
170 <?php
echo xlt('All Alerts'); ?
>
174 <?php
echo xlt('New Alerts'); ?
>
178 <tbody
> <!-- added
for better
print-ability
-->
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");
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);
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
>
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']) . ")" .
219 } else { // $row['category'] == 'allergy_alert'
220 echo $alert . "<br />";
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']) . ")" .
240 } else { // $row['category'] == 'allergy_alert'
241 echo $alert . "<br />";
252 } // $row = sqlFetchArray($res) while
256 </div
> <!-- end of search results
-->
258 <?php
} // end of if search button clicked ?>