immun updates (#4145)
[openemr.git] / interface / reports / amc_tracking.php
blobcc8f6bc7edee3df6674596f7b635065fe0681554
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");
15 require_once "$srcdir/options.inc.php";
16 require_once "$srcdir/amc.php";
18 use OpenEMR\Common\Csrf\CsrfUtils;
19 use OpenEMR\Core\Header;
21 if (!empty($_POST)) {
22 if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) {
23 CsrfUtils::csrfNotVerified();
27 // Collect form parameters (set defaults if empty)
28 $begin_date = (isset($_POST['form_begin_date'])) ? DateTimeToYYYYMMDDHHMMSS(trim($_POST['form_begin_date'])) : "";
29 $end_date = (isset($_POST['form_end_date'])) ? DateTimeToYYYYMMDDHHMMSS(trim($_POST['form_end_date'])) : "";
30 $rule = (isset($_POST['form_rule'])) ? trim($_POST['form_rule']) : "";
31 $provider = trim($_POST['form_provider'] ?? '');
35 <html>
37 <head>
39 <title><?php echo xlt('Automated Measure Calculations (AMC) Tracking'); ?></title>
41 <?php Header::setupHeader('datetime-picker') ?>
43 <script>
45 $(function () {
46 var win = top.printLogSetup ? top : opener.top;
47 win.printLogSetup(document.getElementById('printbutton'));
49 $('.datepicker').datetimepicker({
50 <?php $datetimepicker_timepicker = true; ?>
51 <?php $datetimepicker_showseconds = true; ?>
52 <?php $datetimepicker_formatInput = true; ?>
53 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
54 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
55 });
56 });
58 function send_sum(patient_id,transaction_id) {
59 if ( $('#send_sum_flag_' + patient_id + '_' + transaction_id).prop('checked') ) {
60 var mode = "add";
62 else {
63 var mode = "remove";
65 top.restoreSession();
66 $.post( "../../library/ajax/amc_misc_data.php",
67 { amc_id: "send_sum_amc",
68 complete: true,
69 mode: mode,
70 patient_id: patient_id,
71 object_category: "transactions",
72 object_id: transaction_id,
73 csrf_token_form: <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>
78 function send_sum_elec(patient_id,transaction_id) {
79 if ( $('#send_sum_elec_flag_' + patient_id + '_' + transaction_id).prop('checked') ) {
80 if ( !$('#send_sum_flag_' + patient_id + '_' + transaction_id).prop('checked') ) {
81 $('#send_sum_elec_flag_' + patient_id + '_' + transaction_id).prop("checked", false);
82 alert(<?php echo xlj('Can not set this unless the Summary of Care Sent toggle is set.'); ?>);
83 return false;
85 var mode = "add";
87 else {
88 var mode = "remove";
90 top.restoreSession();
91 $.post( "../../library/ajax/amc_misc_data.php",
92 { amc_id: "send_sum_elec_amc",
93 complete: true,
94 mode: mode,
95 patient_id: patient_id,
96 object_category: "transactions",
97 object_id: transaction_id,
98 csrf_token_form: <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>
103 function provide_rec_pat(patient_id,date_created) {
104 if ( $('#provide_rec_pat_flag_' + patient_id ).prop('checked') ) {
105 var mode = "complete_safe";
107 else {
108 var mode = "uncomplete_safe";
110 top.restoreSession();
111 $.post( "../../library/ajax/amc_misc_data.php",
112 { amc_id: "provide_rec_pat_amc",
113 complete: true,
114 mode: mode,
115 date_created: date_created,
116 patient_id: patient_id,
117 csrf_token_form: <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>
122 function provide_sum_pat(patient_id,encounter_id) {
123 if ( $('#provide_sum_pat_flag_' + patient_id + '_' + encounter_id).prop('checked') ) {
124 var mode = "add";
126 else {
127 var mode = "remove";
129 top.restoreSession();
130 $.post( "../../library/ajax/amc_misc_data.php",
131 { amc_id: "provide_sum_pat_amc",
132 complete: true,
133 mode: mode,
134 patient_id: patient_id,
135 object_category: "form_encounter",
136 object_id: encounter_id,
137 csrf_token_form: <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>
142 </script>
144 <style>
146 /* specifically include & exclude from printing */
147 @media print {
148 #report_parameters {
149 visibility: hidden;
150 display: none;
152 #report_parameters_daterange {
153 visibility: visible;
154 display: inline;
156 #report_results table {
157 margin-top: 0px;
161 /* specifically exclude some from the screen */
162 @media screen {
163 #report_parameters_daterange {
164 visibility: hidden;
165 display: none;
169 </style>
170 </head>
172 <body class="body_top">
174 <!-- Required for the popup date selectors -->
175 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
177 <span class='title'><?php echo xlt('Report'); ?> -
179 <?php echo xlt('Automated Measure Calculations (AMC) Tracking'); ?></span>
181 <form method='post' name='theform' id='theform' action='amc_tracking.php' onsubmit='return top.restoreSession()'>
182 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
184 <div id="report_parameters">
186 <table>
187 <tr>
188 <td width='470px'>
189 <div style='float:left'>
191 <table class='text'>
193 <tr>
194 <td class='col-form-label'>
195 <?php echo xlt('Begin Date'); ?>:
196 </td>
197 <td>
198 <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' />
199 </td>
200 </tr>
202 <tr>
203 <td class='col-form-label'>
204 <?php echo xlt('End Date'); ?>:
205 </td>
206 <td>
207 <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' />
208 </td>
209 </tr>
211 <tr>
212 <td class='col-form-label'>
213 <?php echo xlt('Rule'); ?>:
214 </td>
215 <td>
216 <select name='form_rule' class='form-control'>
217 <option value='send_sum_amc' <?php echo ($rule == "send_sum_amc") ? "selected" : ""; ?>><?php echo xlt('Send Summaries with Referrals'); ?></option>
218 <option value='provide_rec_pat_amc' <?php echo ($rule == "provide_rec_pat_amc") ? "selected" : ""; ?>><?php echo xlt('Patient Requested Medical Records'); ?></option>
219 <option value='provide_sum_pat_amc' <?php echo ($rule == "provide_sum_pat_amc") ? "selected" : ""; ?>><?php echo xlt('Provide Records to Patient for Visit'); ?></option>
220 </select>
221 </td>
222 </tr>
224 <tr>
225 <td class='col-form-label'>
226 <?php echo xlt('Provider'); ?>:
227 </td>
228 <td>
229 <?php
231 // Build a drop-down list of providers.
234 $query = "SELECT id, lname, fname FROM users WHERE " .
235 "authorized = 1 ORDER BY lname, fname"; //(CHEMED) facility filter
237 $ures = sqlStatement($query);
239 echo " <select name='form_provider' class='form-control'>\n";
240 echo " <option value=''>-- " . xlt('All') . " --\n";
242 while ($urow = sqlFetchArray($ures)) {
243 $provid = $urow['id'];
244 echo " <option value='" . attr($provid) . "'";
245 if ($provid == ($_POST['form_provider'] ?? '')) {
246 echo " selected";
249 echo ">" . text($urow['lname'] . ", " . $urow['fname']) . "\n";
252 echo " </select>\n";
255 </td>
256 </tr>
257 </table>
259 </div>
261 </td>
262 <td class='h-100' align='left' valign='middle'>
263 <table class='w-100 h-100' style='border-left: 1px solid;'>
264 <tr>
265 <td>
266 <div class="text-center">
267 <div class="btn-group" role="group">
268 <a href='#' class='btn btn-secondary btn-save' onclick='$("#form_refresh").attr("value","true"); top.restoreSession(); $("#theform").submit();'>
269 <?php echo xlt('Submit'); ?>
270 </a>
271 <?php if (!empty($_POST['form_refresh'])) { ?>
272 <a href='#' class='btn btn-secondary btn-print' id='printbutton'>
273 <?php echo xlt('Print'); ?>
274 </a>
275 <?php } ?>
276 </div>
277 </div>
278 </td>
279 </tr>
280 </table>
281 </td>
282 </tr>
283 </table>
285 </div> <!-- end of search parameters -->
287 <br />
289 <?php
290 if (!empty($_POST['form_refresh'])) {
294 <div id="report_results">
295 <table class='table'>
297 <thead class='thead-light'>
298 <th>
299 <?php echo xlt('Patient Name'); ?>
300 </th>
302 <th>
303 <?php echo xlt('Patient ID'); ?>
304 </th>
306 <th>
307 <?php
308 if ($rule == "send_sum_amc") {
309 echo xlt('Referral Date');
310 } elseif ($rule == "provide_rec_pat_amc") {
311 echo xlt('Record Request Date');
312 } else { // $rule == "provide_sum_pat_amc"
313 echo xlt('Encounter Date');
316 </th>
318 <th>
319 <?php
320 if ($rule == "send_sum_amc") {
321 echo xlt('Referral ID');
322 } elseif ($rule == "provide_rec_pat_amc") {
323 echo "&nbsp";
324 } else { // $rule == "provide_sum_pat_amc"
325 echo xlt('Encounter ID');
328 </th>
330 <th>
331 <?php
332 if ($rule == "provide_rec_pat_amc") {
333 echo xlt('Medical Records Sent');
334 } elseif ($rule == "send_sum_amc") {
335 echo xlt('Summary of Care Sent');
336 } else { // $rule == "provide_sum_pat_amc"
337 echo xlt('Medical Summary Given');
340 </th>
341 <?php
342 if ($rule == "send_sum_amc") {
343 echo "<th>";
344 echo xlt('Summary of Care Sent Electronically');
345 echo "<th>";
349 </thead>
350 <tbody> <!-- added for better print-ability -->
351 <?php
353 // Send the request for information
354 $resultsArray = amcTrackingRequest($rule, $begin_date, $end_date, $provider);
358 <?php
359 foreach ($resultsArray as $result) {
360 echo "<tr bgcolor='" . attr($bgcolor ?? '') . "'>";
361 echo "<td>" . text($result['lname'] . "," . $result['fname']) . "</td>";
362 echo "<td>" . text($result['pid']) . "</td>";
363 echo "<td>" . text(oeFormatDateTime($result['date'], "global", true)) . "</td>";
364 if ($rule == "send_sum_amc" || $rule == "provide_sum_pat_amc") {
365 echo "<td>" . text($result['id']) . "</td>";
366 } else { //$rule == "provide_rec_pat_amc"
367 echo "<td>&nbsp</td>";
370 if ($rule == "send_sum_amc") {
371 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>";
372 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>";
373 } elseif ($rule == "provide_rec_pat_amc") {
374 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>";
375 } else { //$rule == "provide_sum_pat_amc"
376 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>";
379 echo "</tr>";
383 </tbody>
384 </table>
385 </div> <!-- end of search results -->
386 <?php } else { ?>
387 <div class='text'>
388 <?php echo xlt('Please input search criteria above, and click Submit to view results.'); ?>
389 </div>
390 <?php } ?>
392 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
394 </form>
396 </body>
398 </html>