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")]);
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'] ??
'');
46 <title
><?php
echo xlt('Automated Measure Calculations (AMC) Tracking'); ?
></title
>
48 <?php Header
::setupHeader('datetime-picker') ?
>
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 ?>
65 function send_sum(patient_id
,transaction_id
) {
66 if ( $
('#send_sum_flag_' + patient_id +
'_' + transaction_id
).prop('checked') ) {
73 $
.post( "../../library/ajax/amc_misc_data.php",
74 { amc_id
: "send_sum_amc",
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.'); ?
>);
98 $
.post( "../../library/ajax/amc_misc_data.php",
99 { amc_id
: "send_sum_elec_amc",
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";
115 var mode
= "uncomplete_safe";
117 top
.restoreSession();
118 $
.post( "../../library/ajax/amc_misc_data.php",
119 { amc_id
: "provide_rec_pat_amc",
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') ) {
136 top
.restoreSession();
137 $
.post( "../../library/ajax/amc_misc_data.php",
138 { amc_id
: "provide_sum_pat_amc",
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()); ?
>
153 /* specifically include & exclude from printing */
159 #report_parameters_daterange {
163 #report_results table {
168 /* specifically exclude some from the screen */
170 #report_parameters_daterange {
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">
196 <div style
='float:left'>
201 <td
class='col-form-label'>
202 <?php
echo xlt('Begin Date'); ?
>:
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' />
210 <td
class='col-form-label'>
211 <?php
echo xlt('End Date'); ?
>:
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' />
219 <td
class='col-form-label'>
220 <?php
echo xlt('Rule'); ?
>:
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
>
232 <td
class='col-form-label'>
233 <?php
echo xlt('Provider'); ?
>:
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'] ??
'')) {
256 echo ">" . text($urow['lname'] . ", " . $urow['fname']) . "\n";
269 <td
class='h-100' align
='left' valign
='middle'>
270 <table
class='w-100 h-100' style
='border-left: 1px solid;'>
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'); ?
>
278 <?php
if (!empty($_POST['form_refresh'])) { ?
>
279 <a href
='#' class='btn btn-secondary btn-print' id
='printbutton'>
280 <?php
echo xlt('Print'); ?
>
292 </div
> <!-- end of search parameters
-->
297 if (!empty($_POST['form_refresh'])) {
301 <div id
="report_results">
302 <table
class='table'>
304 <thead
class='thead-light'>
306 <?php
echo xlt('Patient Name'); ?
>
310 <?php
echo xlt('Patient ID'); ?
>
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');
327 if ($rule == "send_sum_amc") {
328 echo xlt('Referral ID');
329 } elseif ($rule == "provide_rec_pat_amc") {
331 } else { // $rule == "provide_sum_pat_amc"
332 echo xlt('Encounter ID');
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');
349 if ($rule == "send_sum_amc") {
351 echo xlt('Summary of Care Sent Electronically');
357 <tbody
> <!-- added
for better
print-ability
-->
360 // Send the request for information
361 $resultsArray = amcTrackingRequest($rule, $begin_date, $end_date, $provider);
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> </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>";
392 </div
> <!-- end of search results
-->
395 <?php
echo xlt('Please input search criteria above, and click Submit to view results.'); ?
>
399 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>