fix: quick fix to enforce support of x509 database connection on install (#6157)
[openemr.git] / interface / reports / amc_tracking.php
blob3599e6f17379554398b6c2fad28f18b42d984af6
1 <?php
3 /**
4 * AMC Tracking.
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2011-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/amc.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("Automated Measure Calculations (AMC) Tracking")]);
25 exit;
28 if (!empty($_POST)) {
29 if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) {
30 CsrfUtils::csrfNotVerified();
34 // Collect form parameters (set defaults if empty)
35 $begin_date = (isset($_POST['form_begin_date'])) ? DateTimeToYYYYMMDDHHMMSS(trim($_POST['form_begin_date'])) : "";
36 $end_date = (isset($_POST['form_end_date'])) ? DateTimeToYYYYMMDDHHMMSS(trim($_POST['form_end_date'])) : "";
37 $rule = (isset($_POST['form_rule'])) ? trim($_POST['form_rule']) : "";
38 $provider = trim($_POST['form_provider'] ?? '');
42 <html>
44 <head>
46 <title><?php echo xlt('Automated Measure Calculations (AMC) Tracking'); ?></title>
48 <?php Header::setupHeader('datetime-picker') ?>
50 <script>
52 $(function () {
53 var win = top.printLogSetup ? top : opener.top;
54 win.printLogSetup(document.getElementById('printbutton'));
56 $('.datepicker').datetimepicker({
57 <?php $datetimepicker_timepicker = true; ?>
58 <?php $datetimepicker_showseconds = true; ?>
59 <?php $datetimepicker_formatInput = true; ?>
60 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
61 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
62 });
63 });
65 function send_sum(patient_id,transaction_id) {
66 if ( $('#send_sum_flag_' + patient_id + '_' + transaction_id).prop('checked') ) {
67 var mode = "add";
69 else {
70 var mode = "remove";
72 top.restoreSession();
73 $.post( "../../library/ajax/amc_misc_data.php",
74 { amc_id: "send_sum_amc",
75 complete: true,
76 mode: mode,
77 patient_id: patient_id,
78 object_category: "transactions",
79 object_id: transaction_id,
80 csrf_token_form: <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>
85 function send_sum_elec(patient_id,transaction_id) {
86 if ( $('#send_sum_elec_flag_' + patient_id + '_' + transaction_id).prop('checked') ) {
87 if ( !$('#send_sum_flag_' + patient_id + '_' + transaction_id).prop('checked') ) {
88 $('#send_sum_elec_flag_' + patient_id + '_' + transaction_id).prop("checked", false);
89 alert(<?php echo xlj('Can not set this unless the Summary of Care Sent toggle is set.'); ?>);
90 return false;
92 var mode = "add";
94 else {
95 var mode = "remove";
97 top.restoreSession();
98 $.post( "../../library/ajax/amc_misc_data.php",
99 { amc_id: "send_sum_elec_amc",
100 complete: true,
101 mode: mode,
102 patient_id: patient_id,
103 object_category: "transactions",
104 object_id: transaction_id,
105 csrf_token_form: <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>
110 function provide_rec_pat(patient_id,date_created) {
111 if ( $('#provide_rec_pat_flag_' + patient_id ).prop('checked') ) {
112 var mode = "complete_safe";
114 else {
115 var mode = "uncomplete_safe";
117 top.restoreSession();
118 $.post( "../../library/ajax/amc_misc_data.php",
119 { amc_id: "provide_rec_pat_amc",
120 complete: true,
121 mode: mode,
122 date_created: date_created,
123 patient_id: patient_id,
124 csrf_token_form: <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>
129 function provide_sum_pat(patient_id,encounter_id) {
130 if ( $('#provide_sum_pat_flag_' + patient_id + '_' + encounter_id).prop('checked') ) {
131 var mode = "add";
133 else {
134 var mode = "remove";
136 top.restoreSession();
137 $.post( "../../library/ajax/amc_misc_data.php",
138 { amc_id: "provide_sum_pat_amc",
139 complete: true,
140 mode: mode,
141 patient_id: patient_id,
142 object_category: "form_encounter",
143 object_id: encounter_id,
144 csrf_token_form: <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>
149 </script>
151 <style>
153 /* specifically include & exclude from printing */
154 @media print {
155 #report_parameters {
156 visibility: hidden;
157 display: none;
159 #report_parameters_daterange {
160 visibility: visible;
161 display: inline;
163 #report_results table {
164 margin-top: 0px;
168 /* specifically exclude some from the screen */
169 @media screen {
170 #report_parameters_daterange {
171 visibility: hidden;
172 display: none;
176 </style>
177 </head>
179 <body class="body_top">
181 <!-- Required for the popup date selectors -->
182 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
184 <span class='title'><?php echo xlt('Report'); ?> -
186 <?php echo xlt('Automated Measure Calculations (AMC) Tracking'); ?></span>
188 <form method='post' name='theform' id='theform' action='amc_tracking.php' onsubmit='return top.restoreSession()'>
189 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
191 <div id="report_parameters">
193 <table>
194 <tr>
195 <td width='470px'>
196 <div style='float:left'>
198 <table class='text'>
200 <tr>
201 <td class='col-form-label'>
202 <?php echo xlt('Begin Date'); ?>:
203 </td>
204 <td>
205 <input type='text' name='form_begin_date' id="form_begin_date" size='20' value='<?php echo attr(oeFormatDateTime($begin_date, 0, true)); ?>' class='datepicker form-control' />
206 </td>
207 </tr>
209 <tr>
210 <td class='col-form-label'>
211 <?php echo xlt('End Date'); ?>:
212 </td>
213 <td>
214 <input type='text' name='form_end_date' id="form_end_date" size='20' value='<?php echo attr(oeFormatDateTime($end_date, 0, true)); ?>' class='datepicker form-control' />
215 </td>
216 </tr>
218 <tr>
219 <td class='col-form-label'>
220 <?php echo xlt('Rule'); ?>:
221 </td>
222 <td>
223 <select name='form_rule' class='form-control'>
224 <option value='send_sum_amc' <?php echo ($rule == "send_sum_amc") ? "selected" : ""; ?>><?php echo xlt('Send Summaries with Referrals'); ?></option>
225 <option value='provide_rec_pat_amc' <?php echo ($rule == "provide_rec_pat_amc") ? "selected" : ""; ?>><?php echo xlt('Patient Requested Medical Records'); ?></option>
226 <option value='provide_sum_pat_amc' <?php echo ($rule == "provide_sum_pat_amc") ? "selected" : ""; ?>><?php echo xlt('Provide Records to Patient for Visit'); ?></option>
227 </select>
228 </td>
229 </tr>
231 <tr>
232 <td class='col-form-label'>
233 <?php echo xlt('Provider'); ?>:
234 </td>
235 <td>
236 <?php
238 // Build a drop-down list of providers.
241 $query = "SELECT id, lname, fname FROM users WHERE " .
242 "authorized = 1 ORDER BY lname, fname"; //(CHEMED) facility filter
244 $ures = sqlStatement($query);
246 echo " <select name='form_provider' class='form-control'>\n";
247 echo " <option value=''>-- " . xlt('All') . " --\n";
249 while ($urow = sqlFetchArray($ures)) {
250 $provid = $urow['id'];
251 echo " <option value='" . attr($provid) . "'";
252 if ($provid == ($_POST['form_provider'] ?? '')) {
253 echo " selected";
256 echo ">" . text($urow['lname'] . ", " . $urow['fname']) . "\n";
259 echo " </select>\n";
262 </td>
263 </tr>
264 </table>
266 </div>
268 </td>
269 <td class='h-100' align='left' valign='middle'>
270 <table class='w-100 h-100' style='border-left: 1px solid;'>
271 <tr>
272 <td>
273 <div class="text-center">
274 <div class="btn-group" role="group">
275 <a href='#' class='btn btn-secondary btn-save' onclick='$("#form_refresh").attr("value","true"); top.restoreSession(); $("#theform").submit();'>
276 <?php echo xlt('Submit'); ?>
277 </a>
278 <?php if (!empty($_POST['form_refresh'])) { ?>
279 <a href='#' class='btn btn-secondary btn-print' id='printbutton'>
280 <?php echo xlt('Print'); ?>
281 </a>
282 <?php } ?>
283 </div>
284 </div>
285 </td>
286 </tr>
287 </table>
288 </td>
289 </tr>
290 </table>
292 </div> <!-- end of search parameters -->
294 <br />
296 <?php
297 if (!empty($_POST['form_refresh'])) {
301 <div id="report_results">
302 <table class='table'>
304 <thead class='thead-light'>
305 <th>
306 <?php echo xlt('Patient Name'); ?>
307 </th>
309 <th>
310 <?php echo xlt('Patient ID'); ?>
311 </th>
313 <th>
314 <?php
315 if ($rule == "send_sum_amc") {
316 echo xlt('Referral Date');
317 } elseif ($rule == "provide_rec_pat_amc") {
318 echo xlt('Record Request Date');
319 } else { // $rule == "provide_sum_pat_amc"
320 echo xlt('Encounter Date');
323 </th>
325 <th>
326 <?php
327 if ($rule == "send_sum_amc") {
328 echo xlt('Referral ID');
329 } elseif ($rule == "provide_rec_pat_amc") {
330 echo "&nbsp";
331 } else { // $rule == "provide_sum_pat_amc"
332 echo xlt('Encounter ID');
335 </th>
337 <th>
338 <?php
339 if ($rule == "provide_rec_pat_amc") {
340 echo xlt('Medical Records Sent');
341 } elseif ($rule == "send_sum_amc") {
342 echo xlt('Summary of Care Sent');
343 } else { // $rule == "provide_sum_pat_amc"
344 echo xlt('Medical Summary Given');
347 </th>
348 <?php
349 if ($rule == "send_sum_amc") {
350 echo "<th>";
351 echo xlt('Summary of Care Sent Electronically');
352 echo "<th>";
356 </thead>
357 <tbody> <!-- added for better print-ability -->
358 <?php
360 // Send the request for information
361 $resultsArray = amcTrackingRequest($rule, $begin_date, $end_date, $provider);
365 <?php
366 foreach ($resultsArray as $result) {
367 echo "<tr bgcolor='" . attr($bgcolor ?? '') . "'>";
368 echo "<td>" . text($result['lname'] . "," . $result['fname']) . "</td>";
369 echo "<td>" . text($result['pid']) . "</td>";
370 echo "<td>" . text(oeFormatDateTime($result['date'], "global", true)) . "</td>";
371 if ($rule == "send_sum_amc" || $rule == "provide_sum_pat_amc") {
372 echo "<td>" . text($result['id']) . "</td>";
373 } else { //$rule == "provide_rec_pat_amc"
374 echo "<td>&nbsp</td>";
377 if ($rule == "send_sum_amc") {
378 echo "<td><input type='checkbox' id='send_sum_flag_" . attr($result['pid']) . "_" . attr($result['id']) . "' onclick='send_sum(" . attr_js($result['pid']) . "," . attr_js($result['id']) . ")'>" . xlt('Yes') . "</td>";
379 echo "<td><input type='checkbox' id='send_sum_elec_flag_" . attr($result['pid']) . "_" . attr($result['id']) . "' onclick='send_sum_elec(" . attr_js($result['pid']) . "," . attr_js($result['id']) . ")'>" . xlt('Yes') . "</td>";
380 } elseif ($rule == "provide_rec_pat_amc") {
381 echo "<td><input type='checkbox' id='provide_rec_pat_flag_" . attr($result['pid']) . "' onclick='provide_rec_pat(" . attr_js($result['pid']) . "," . attr_js($result['date']) . ")'>" . xlt('Yes') . "</td>";
382 } else { //$rule == "provide_sum_pat_amc"
383 echo "<td><input type='checkbox' id='provide_sum_pat_flag_" . attr($result['pid']) . "_" . attr($result['id']) . "' onclick='provide_sum_pat(" . attr_js($result['pid']) . "," . attr_js($result['id']) . ")'>" . xlt('Yes') . "</td>";
386 echo "</tr>";
390 </tbody>
391 </table>
392 </div> <!-- end of search results -->
393 <?php } else { ?>
394 <div class='text'>
395 <?php echo xlt('Please input search criteria above, and click Submit to view results.'); ?>
396 </div>
397 <?php } ?>
399 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
401 </form>
403 </body>
405 </html>