4 * Run a CDR engine report.
7 * @link https://www.open-emr.org
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2012-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(dirname(__FILE__
) . "/../../interface/globals.php");
14 require_once(dirname(__FILE__
) . "/../clinical_rules.php");
16 use OpenEMR\ClinicialDecisionRules\AMC\CertificationReportTypes
;
17 use OpenEMR\Common\Csrf\CsrfUtils
;
19 if (!CsrfUtils
::verifyCsrfToken($_POST["csrf_token_form"])) {
20 CsrfUtils
::csrfNotVerified();
23 //Remove time limit, since script can take many minutes
26 // Set the "nice" level of the process for these reports. When the "nice" level
27 // is increased, these cpu intensive reports will have less affect on the performance
28 // of other server activities, albeit it may negatively impact the performance
29 // of this report (note this is only applicable for linux).
30 if (!empty($GLOBALS['cdr_report_nice'])) {
31 proc_nice($GLOBALS['cdr_report_nice']);
34 // Start a report, which will be stored in the report_results sql table..
35 if (!empty($_POST['execute_report_id'])) {
36 $target_date = (!empty($_POST['date_target'])) ?
$_POST['date_target'] : date('Y-m-d H:i:s');
37 $rule_filter = (!empty($_POST['type'])) ?
$_POST['type'] : "";
38 $plan_filter = (!empty($_POST['plan'])) ?
$_POST['plan'] : "";
39 $organize_method = (empty($plan_filter)) ?
"default" : "plans";
40 $provider = $_POST['provider'];
41 $pat_prov_rel = (empty($_POST['pat_prov_rel'])) ?
"primary" : $_POST['pat_prov_rel'];
44 // Process a new report and collect results
46 $array_date = array();
48 // all 'amc' reports start with 'amc_', will need to make sure a user can't define their own rule with this pattern
49 if (CertificationReportTypes
::isAMCReportType($rule_filter)) {
51 // need to make $target_date an array with two elements ('dateBegin' and 'dateTarget')
52 // need to send a manual data entry option (number of labs)
53 $array_date['dateBegin'] = $_POST['date_begin'] ??
null;
54 $array_date['dateTarget'] = $target_date;
55 $options = array('labs_manual' => $_POST['labs'] ??
0);
57 // For others, use the unmodified target date array and send an empty options array
58 $array_date = $target_date;
61 test_rules_clinic_batch_method(
71 $_POST['execute_report_id']