Added access controls for encounter categories
[openemr.git] / library / ajax / execute_cdr_report.php
bloba3e2b48ecb5bb3342539ec94914f31de45591066
1 <?php
2 /**
3 * Run a CDR engine report.
5 * Copyright (C) 2012 Brady Miller <brady.g.miller@gmail.com>
7 * LICENSE: This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
18 * @package OpenEMR
19 * @author Brady Miller <brady.g.miller@gmail.com>
20 * @link http://www.open-emr.org
25 require_once(dirname(__FILE__) . "/../../interface/globals.php");
26 require_once(dirname(__FILE__) . "/../clinical_rules.php");
28 //To improve performance and not freeze the session when running this
29 // report, turn off session writing. Note that php session variables
30 // can not be modified after the line below. So, if need to do any php
31 // session work in the future, then will need to remove this line.
32 session_write_close();
34 //Remove time limit, since script can take many minutes
35 set_time_limit(0);
37 // Set the "nice" level of the process for these reports. When the "nice" level
38 // is increased, these cpu intensive reports will have less affect on the performance
39 // of other server activities, albeit it may negatively impact the performance
40 // of this report (note this is only applicable for linux).
41 if (!empty($GLOBALS['cdr_report_nice'])) {
42 proc_nice($GLOBALS['cdr_report_nice']);
45 // Start a report, which will be stored in the report_results sql table..
46 if (!empty($_POST['execute_report_id'])) {
48 $target_date = (!empty($_POST['date_target'])) ? $_POST['date_target'] : date('Y-m-d H:i:s');
49 $rule_filter = (!empty($_POST['type'])) ? $_POST['type'] : "";
50 $plan_filter = (!empty($_POST['plan'])) ? $_POST['plan'] : "";
51 $organize_method = (empty($plan_filter)) ? "default" : "plans";
52 $provider = $_POST['provider'];
53 $pat_prov_rel = (empty($_POST['pat_prov_rel'])) ? "primary" : $_POST['pat_prov_rel'];
56 // Process a new report and collect results
57 $options = array();
58 $array_date = array();
60 if ( ($rule_filter == "amc") || ($rule_filter == "amc_2011") || ($rule_filter == "amc_2014") || ($rule_filter == "amc_2014_stage1") || ($rule_filter == "amc_2014_stage2") ) {
61 // For AMC:
62 // need to make $target_date an array with two elements ('dateBegin' and 'dateTarget')
63 // need to send a manual data entry option (number of labs)
64 $array_date['dateBegin'] = $_POST['date_begin'];
65 $array_date['dateTarget'] = $target_date;
66 $options = array('labs_manual'=>$_POST['labs']);
68 else {
69 // For others, use the unmodified target date array and send an empty options array
70 $array_date = $target_date;
73 test_rules_clinic_batch_method($provider,$rule_filter,$array_date,"report",$plan_filter,$organize_method,$options,$pat_prov_rel,'',$_POST['execute_report_id']);
75 else {
76 echo "ERROR";