Example #1
0
// of other server activities, albeit it may negatively impact the performance
// of this report (note this is only applicable for linux).
if (!empty($GLOBALS['cdr_report_nice'])) {
    proc_nice($GLOBALS['cdr_report_nice']);
}
//  Start a report, which will be stored in the report_results sql table..
if (!empty($_POST['execute_report_id'])) {
    $target_date = !empty($_POST['date_target']) ? $_POST['date_target'] : date('Y-m-d H:i:s');
    $rule_filter = !empty($_POST['type']) ? $_POST['type'] : "";
    $plan_filter = !empty($_POST['plan']) ? $_POST['plan'] : "";
    $organize_method = empty($plan_filter) ? "default" : "plans";
    $provider = $_POST['provider'];
    $pat_prov_rel = empty($_POST['pat_prov_rel']) ? "primary" : $_POST['pat_prov_rel'];
    // Process a new report and collect results
    $options = array();
    $array_date = array();
    if ($rule_filter == "amc" || $rule_filter == "amc_2011" || $rule_filter == "amc_2014") {
        // For AMC:
        //   need to make $target_date an array with two elements ('dateBegin' and 'dateTarget')
        //   need to send a manual data entry option (number of labs)
        $array_date['dateBegin'] = $_POST['date_begin'];
        $array_date['dateTarget'] = $target_date;
        $options = array('labs_manual' => $_POST['labs']);
    } else {
        // For others, use the unmodified target date array and send an empty options array
        $array_date = $target_date;
    }
    test_rules_clinic_batch_method($provider, $rule_filter, $array_date, "report", $plan_filter, $organize_method, $options, $pat_prov_rel, '', $_POST['execute_report_id']);
} else {
    echo "ERROR";
}
$xml->open_submission();
// Add the file audit data
$xml->add_file_audit_data();
// Add the registry entries
if ($nested == 'false') {
    $xml->add_registry('A');
} else {
    $xml->add_registry('E');
}
// Add the measure groups.
if ($nested == 'false') {
    // Collect results (note using the batch method to decrease memory overhead and improve performance)
    $dataSheet = test_rules_clinic_batch_method('collate_outer', 'cqm_2011', $target_date, 'report', '', '');
} else {
    // Collect results (note using the batch method to decrease memory overhead and improve performance)
    $dataSheet = test_rules_clinic_batch_method('collate_inner', 'cqm_2011', $target_date, 'report', 'cqm', 'plans');
}
$firstProviderFlag = TRUE;
$firstPlanFlag = TRUE;
$existProvider = FALSE;
if ($nested == 'false') {
    $xml->open_measure_group('X');
}
foreach ($dataSheet as $row) {
    //print_r($row);
    if (isset($row['is_main']) || isset($row['is_sub'])) {
        if (isset($row['is_main'])) {
            // Add PQRI measures
            $pqri_measures = array();
            $pqri_measures['pqri-measure-number'] = getMeasureNumber($row);
            $pqri_measures['patient-population'] = getLabelNumber($row['population_label']);