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