/**
 * Process clinic rules.
 *
 * Test the clinic rules of entire clinic and create a report or patient reminders (can also test
 * on one patient or patients of one provider). The structure of the returned results is dependent on the
 * $organize_mode and $mode parameters.
 * <pre>The results are dependent on the $organize_mode parameter settings
 *   'default' organize_mode:
 *     Returns a two-dimensional array of results organized by rules (dependent on the following $mode settings):
 *       'reminders-due' mode - returns an array of reminders (action array elements plus a 'pid' and 'due_status')
 *       'reminders-all' mode - returns an array of reminders (action array elements plus a 'pid' and 'due_status')
 *       'report' mode        - returns an array of rows for the Clinical Quality Measures (CQM) report
 *   'plans' organize_mode:
 *     Returns similar to default, but organizes by the active plans
 * </pre>
 *
 * @param  integer      $provider      id of a selected provider. If blank, then will test entire clinic. If 'collate_outer' or 'collate_inner', then will test each provider in entire clinic; outer will nest plans  inside collated providers, while inner will nest the providers inside the plans (note inner and outer are only different if organize_mode is set to plans).
 * @param  string       $type          rule filter (active_alert,passive_alert,cqm,amc,patient_reminder). If blank then will test all rules. 
 * @param  string/array $dateTarget    target date (format Y-m-d H:i:s). If blank then will test with current date as target. If an array, then is holding two dates ('dateBegin' and 'dateTarget').
 * @param  string       $mode          choose either 'report' or 'reminders-all' or 'reminders-due' (required)
 * @param  integer      $patient_id    pid of patient. If blank then will check all patients.
 * @param  string       $plan          test for specific plan only
 * @param  string       $organize_mode Way to organize the results (default, plans). See above for organization structure of the results.
 * @param  array        $options       can hold various option (for now, used to hold the manual number of labs for the AMC report)
 * @param  string       $pat_prov_rel  How to choose patients that are related to a chosen provider. 'primary' selects patients that the provider is set as primary provider. 'encounter' selectes patients that the provider has seen. This parameter is only applicable if the $provider parameter is set to a provider or collation setting.
 * @param  integer      $start         applicable patient to start at (when batching process)
 * @param  integer      $batchSize     number of patients to batch (when batching process)
 * @return array                       See above for organization structure of the results.
 */
function test_rules_clinic($provider = '', $type = '', $dateTarget = '', $mode = '', $patient_id = '', $plan = '', $organize_mode = 'default', $options = array(), $pat_prov_rel = 'primary', $start = NULL, $batchSize = NULL)
{
    // If dateTarget is an array, then organize them.
    if (is_array($dateTarget)) {
        $dateArray = $dateTarget;
        $dateTarget = $dateTarget['dateTarget'];
    }
    // Set date to current if not set
    $dateTarget = $dateTarget ? $dateTarget : date('Y-m-d H:i:s');
    // Prepare the results array
    $results = array();
    // If set the $provider to collate_outer (or collate_inner without plans organize mode),
    // then run through this function recursively and return results.
    if ($provider == "collate_outer" || $provider == "collate_inner" && $organize_mode != 'plans') {
        // First, collect an array of all providers
        $query = "SELECT id, lname, fname, npi, federaltaxid FROM users WHERE authorized = 1 ORDER BY lname, fname";
        $ures = sqlStatementCdrEngine($query);
        // Second, run through each provider recursively
        while ($urow = sqlFetchArray($ures)) {
            $newResults = test_rules_clinic($urow['id'], $type, $dateTarget, $mode, $patient_id, $plan, $organize_mode, $options, $pat_prov_rel, $start, $batchSize);
            if (!empty($newResults)) {
                $provider_item['is_provider'] = TRUE;
                $provider_item['prov_lname'] = $urow['lname'];
                $provider_item['prov_fname'] = $urow['fname'];
                $provider_item['npi'] = $urow['npi'];
                $provider_item['federaltaxid'] = $urow['federaltaxid'];
                array_push($results, $provider_item);
                $results = array_merge($results, $newResults);
            }
        }
        // done, so now can return results
        return $results;
    }
    // If set organize-mode to plans, then collects active plans and run through this
    // function recursively and return results.
    if ($organize_mode == "plans") {
        // First, collect active plans
        $plans_resolve = resolve_plans_sql($plan, $patient_id);
        // Second, run through function recursively
        foreach ($plans_resolve as $plan_item) {
            //  (if collate_inner, then nest a collation of providers within each plan)
            if ($provider == "collate_inner") {
                // First, collect an array of all providers
                $query = "SELECT id, lname, fname, npi, federaltaxid FROM users WHERE authorized = 1 ORDER BY lname, fname";
                $ures = sqlStatementCdrEngine($query);
                // Second, run through each provider recursively
                $provider_results = array();
                while ($urow = sqlFetchArray($ures)) {
                    $newResults = test_rules_clinic($urow['id'], $type, $dateTarget, $mode, $patient_id, $plan_item['id'], 'default', $options, $pat_prov_rel, $start, $batchSize);
                    if (!empty($newResults)) {
                        $provider_item['is_provider'] = TRUE;
                        $provider_item['prov_lname'] = $urow['lname'];
                        $provider_item['prov_fname'] = $urow['fname'];
                        $provider_item['npi'] = $urow['npi'];
                        $provider_item['federaltaxid'] = $urow['federaltaxid'];
                        array_push($provider_results, $provider_item);
                        $provider_results = array_merge($provider_results, $newResults);
                    }
                }
                if (!empty($provider_results)) {
                    $plan_item['is_plan'] = TRUE;
                    array_push($results, $plan_item);
                    $results = array_merge($results, $provider_results);
                }
            } else {
                // (not collate_inner, so do not nest providers within each plan)
                $newResults = test_rules_clinic($provider, $type, $dateTarget, $mode, $patient_id, $plan_item['id'], 'default', $options, $pat_prov_rel, $start, $batchSize);
                if (!empty($newResults)) {
                    $plan_item['is_plan'] = TRUE;
                    array_push($results, $plan_item);
                    $results = array_merge($results, $newResults);
                }
            }
        }
        // done, so now can return results
        return $results;
    }
    // Collect applicable patient pids
    $patientData = array();
    $patientData = buildPatientArray($patient_id, $provider, $pat_prov_rel, $start, $batchSize);
    // Go through each patient(s)
    //
    //  If in report mode, then tabulate for each rule:
    //    Total Patients
    //    Patients that pass the filter
    //    Patients that pass the target
    //  If in reminders mode, then create reminders for each rule:
    //    Reminder that action is due soon
    //    Reminder that action is due
    //    Reminder that action is post-due
    //Collect applicable rules
    // Note that due to a limitation in the this function, the patient_id is explicitly
    //  for grouping items when not being done in real-time or for official reporting.
    //  So for cases such as patient reminders on a clinic scale, the calling function
    //  will actually need rather than pass in a explicit patient_id for each patient in
    //  a separate call to this function.
    if ($mode != "report") {
        // Use per patient custom rules (if exist)
        // Note as discussed above, this only works for single patient instances.
        $rules = resolve_rules_sql($type, $patient_id, FALSE, $plan);
    } else {
        // $mode = "report"
        // Only use default rules (do not use patient custom rules)
        $rules = resolve_rules_sql($type, $patient_id, FALSE, $plan);
    }
    foreach ($rules as $rowRule) {
        // If using cqm or amc type, then use the hard-coded rules set.
        // Note these rules are only used in report mode.
        if ($rowRule['cqm_flag'] || $rowRule['amc_flag']) {
            require_once dirname(__FILE__) . "/classes/rulesets/ReportManager.php";
            $manager = new ReportManager();
            if ($rowRule['amc_flag']) {
                // Send array of dates ('dateBegin' and 'dateTarget')
                $tempResults = $manager->runReport($rowRule, $patientData, $dateArray, $options);
            } else {
                // Send target date
                $tempResults = $manager->runReport($rowRule, $patientData, $dateTarget);
            }
            if (!empty($tempResults)) {
                foreach ($tempResults as $tempResult) {
                    array_push($results, $tempResult);
                }
            }
            // Go on to the next rule
            continue;
        }
        // If in reminder mode then need to collect the measurement dates
        //  from rule_reminder table
        $target_dates = array();
        if ($mode != "report") {
            // Calculate the dates to check for
            if ($type == "patient_reminder") {
                $reminder_interval_type = "patient_reminder";
            } else {
                // $type == "passive_alert" or $type == "active_alert"
                $reminder_interval_type = "clinical_reminder";
            }
            $target_dates = calculate_reminder_dates($rowRule['id'], $dateTarget, $reminder_interval_type);
        } else {
            // $mode == "report"
            // Only use the target date in the report
            $target_dates[0] = $dateTarget;
        }
        //Reset the counters
        $total_patients = 0;
        $pass_filter = 0;
        $exclude_filter = 0;
        $pass_target = 0;
        // Find the number of target groups
        $targetGroups = returnTargetGroups($rowRule['id']);
        if (count($targetGroups) == 1 || $mode == "report") {
            //skip this section if not report and more than one target group
            foreach ($patientData as $rowPatient) {
                // Count the total patients
                $total_patients++;
                $dateCounter = 1;
                // for reminder mode to keep track of which date checking
                foreach ($target_dates as $dateFocus) {
                    //Skip if date is set to SKIP
                    if ($dateFocus == "SKIP") {
                        $dateCounter++;
                        continue;
                    }
                    //Set date counter and reminder token (applicable for reminders only)
                    if ($dateCounter == 1) {
                        $reminder_due = "soon_due";
                    } else {
                        if ($dateCounter == 2) {
                            $reminder_due = "due";
                        } else {
                            // $dateCounter == 3
                            $reminder_due = "past_due";
                        }
                    }
                    // First, deal with deceased patients
                    //  (for now will simply not pass the filter, but can add a database item
                    //   if ever want to create rules for dead people)
                    // Could also place this function at the total_patients level if wanted.
                    //  (But then would lose the option of making rules for dead people)
                    // Note using the dateTarget rather than dateFocus
                    if (is_patient_deceased($rowPatient['pid'], $dateTarget)) {
                        continue;
                    }
                    // Check if pass filter
                    $passFilter = test_filter($rowPatient['pid'], $rowRule['id'], $dateFocus);
                    if ($passFilter === "EXCLUDED") {
                        // increment EXCLUDED and pass_filter counters
                        //  and set as FALSE for reminder functionality.
                        $pass_filter++;
                        $exclude_filter++;
                        $passFilter = FALSE;
                    }
                    if ($passFilter) {
                        // increment pass filter counter
                        $pass_filter++;
                    } else {
                        $dateCounter++;
                        continue;
                    }
                    // Check if pass target
                    $passTarget = test_targets($rowPatient['pid'], $rowRule['id'], '', $dateFocus);
                    if ($passTarget) {
                        // increment pass target counter
                        $pass_target++;
                        // send to reminder results
                        if ($mode == "reminders-all") {
                            // place the completed actions into the reminder return array
                            $actionArray = resolve_action_sql($rowRule['id'], '1');
                            foreach ($actionArray as $action) {
                                $action_plus = $action;
                                $action_plus['due_status'] = "not_due";
                                $action_plus['pid'] = $rowPatient['pid'];
                                $results = reminder_results_integrate($results, $action_plus);
                            }
                        }
                        break;
                    } else {
                        // send to reminder results
                        if ($mode != "report") {
                            // place the uncompleted actions into the reminder return array
                            $actionArray = resolve_action_sql($rowRule['id'], '1');
                            foreach ($actionArray as $action) {
                                $action_plus = $action;
                                $action_plus['due_status'] = $reminder_due;
                                $action_plus['pid'] = $rowPatient['pid'];
                                $results = reminder_results_integrate($results, $action_plus);
                            }
                        }
                    }
                    $dateCounter++;
                }
            }
        }
        // Calculate and save the data for the rule
        $percentage = calculate_percentage($pass_filter, $exclude_filter, $pass_target);
        if ($mode == "report") {
            $newRow = array('is_main' => TRUE, 'total_patients' => $total_patients, 'excluded' => $exclude_filter, 'pass_filter' => $pass_filter, 'pass_target' => $pass_target, 'percentage' => $percentage);
            $newRow = array_merge($newRow, $rowRule);
            array_push($results, $newRow);
        }
        // Now run through the target groups if more than one
        if (count($targetGroups) > 1) {
            foreach ($targetGroups as $i) {
                //Reset the target counter
                $pass_target = 0;
                foreach ($patientData as $rowPatient) {
                    $dateCounter = 1;
                    // for reminder mode to keep track of which date checking
                    foreach ($target_dates as $dateFocus) {
                        //Skip if date is set to SKIP
                        if ($dateFocus == "SKIP") {
                            $dateCounter++;
                            continue;
                        }
                        //Set date counter and reminder token (applicable for reminders only)
                        if ($dateCounter == 1) {
                            $reminder_due = "soon_due";
                        } else {
                            if ($dateCounter == 2) {
                                $reminder_due = "due";
                            } else {
                                // $dateCounter == 3
                                $reminder_due = "past_due";
                            }
                        }
                        // First, deal with deceased patients
                        //  (for now will simply not pass the filter, but can add a database item
                        //   if ever want to create rules for dead people)
                        // Could also place this function at the total_patients level if wanted.
                        //  (But then would lose the option of making rules for dead people)
                        // Note using the dateTarget rather than dateFocus
                        if (is_patient_deceased($rowPatient['pid'], $dateTarget)) {
                            continue;
                        }
                        // Check if pass filter
                        $passFilter = test_filter($rowPatient['pid'], $rowRule['id'], $dateFocus);
                        if ($passFilter === "EXCLUDED") {
                            $passFilter = FALSE;
                        }
                        if (!$passFilter) {
                            // increment pass filter counter
                            $dateCounter++;
                            continue;
                        }
                        //Check if pass target
                        $passTarget = test_targets($rowPatient['pid'], $rowRule['id'], $i, $dateFocus);
                        if ($passTarget) {
                            // increment pass target counter
                            $pass_target++;
                            // send to reminder results
                            if ($mode == "reminders-all") {
                                // place the completed actions into the reminder return array
                                $actionArray = resolve_action_sql($rowRule['id'], $i);
                                foreach ($actionArray as $action) {
                                    $action_plus = $action;
                                    $action_plus['due_status'] = "not_due";
                                    $action_plus['pid'] = $rowPatient['pid'];
                                    $results = reminder_results_integrate($results, $action_plus);
                                }
                            }
                            break;
                        } else {
                            // send to reminder results
                            if ($mode != "report") {
                                // place the actions into the reminder return array
                                $actionArray = resolve_action_sql($rowRule['id'], $i);
                                foreach ($actionArray as $action) {
                                    $action_plus = $action;
                                    $action_plus['due_status'] = $reminder_due;
                                    $action_plus['pid'] = $rowPatient['pid'];
                                    $results = reminder_results_integrate($results, $action_plus);
                                }
                            }
                        }
                        $dateCounter++;
                    }
                }
                // Calculate and save the data for the rule
                $percentage = calculate_percentage($pass_filter, $exclude_filter, $pass_target);
                // Collect action for title (just use the first one, if more than one)
                $actionArray = resolve_action_sql($rowRule['id'], $i);
                $action = $actionArray[0];
                if ($mode == "report") {
                    $newRow = array('is_sub' => TRUE, 'action_category' => $action['category'], 'action_item' => $action['item'], 'total_patients' => '', 'excluded' => '', 'pass_filter' => '', 'pass_target' => $pass_target, 'percentage' => $percentage);
                    array_push($results, $newRow);
                }
            }
        }
    }
    // Return the data
    return $results;
}
Beispiel #2
0
$harddrive_out = format_bytes(kb2bytes($harddrive[2])) . '<small> / ' . format_bytes(kb2bytes($harddrive[1])) . ' <small>(' . calculate_percentage(kb2bytes($harddrive[2]), kb2bytes($harddrive[1])) . '% Free)</small></small>';
#bandwidth info
$vnstat = explode(';', shell_exec('vnstat --oneline'));
$vnstat[8] = '&#8595; ' . $vnstat[8];
$vnstat[9] = ' <small>&#8593; ' . $vnstat[9];
$vnstat[10] = ' <small>&#8597; ' . $vnstat[10];
$vnstat[11] = ' @ ~' . $vnstat[11];
#ram and swap
$memory = array('Total RAM' => 'MemTotal', 'Free RAM' => 'MemFree', 'Cached RAM' => 'Cached', 'Total Swap' => 'SwapTotal', 'Free Swap' => 'SwapFree');
foreach ($memory as $key => $value) {
    $memory[$key] = kb2bytes(numbers_only(exec('grep -E "^' . $value . '" /proc/meminfo')));
}
$memory['Used Swap'] = $memory['Total Swap'] - $memory['Free Swap'];
$memory['Used RAM'] = $memory['Total RAM'] - $memory['Free RAM'] - $memory['Cached RAM'];
$memory['RAM Percent Free'] = calculate_percentage($memory['Used RAM'], $memory['Total RAM']);
$memory['Swap Percent Free'] = calculate_percentage($memory['Used Swap'], $memory['Total Swap']);
$memory_out = format_bytes($memory['Used RAM']) . '<small> / ' . format_bytes($memory['Total RAM']) . ' <small> *' . format_bytes($memory['Cached RAM']) . ' Cached (' . $memory['RAM Percent Free'] . '% Free)</small></small>';
$swap_out = 'swap<span>' . format_bytes($memory['Used Swap']) . '<small> / ' . format_bytes($memory['Total Swap']) . ' <small>(' . $memory['Swap Percent Free'] . '% Free)</small></small></span>';
?>
<!DOCTYPE html>
<html>
	<head>
		<title>#/g/tv - Shell Server</title>
		<meta name="robots" content="noindex, nofollow, noarchive, nosnippet, noodp" /> <!-- I f*****g hate robots... -->
		<meta name="description" content="Status page for #/g/tv shell server." />
		<meta charset="UTF-8" />
		<style type="text/css">
			span { color: #fff;display: block;font-size: 1.3em;margin-bottom: .5em;padding: 0 .5em; }
			html { background-color: #000;color: #777;font-family: sans-serif; font-size: 1.8em;padding: 1em 2em; }
			div { float: right;text-align: right; }
			a { color: #68c;display: block;font-size: 1.7em;text-decoration: none; }
Beispiel #3
0
function test_rules_clinic($provider = '', $type = '', $dateTarget = '', $mode = '', $patient_id = '', $plan = '', $organize_mode = 'default')
{
    // Set date to current if not set
    $dateTarget = $dateTarget ? $dateTarget : date('Y-m-d H:i:s');
    // Prepare the results array
    $results = array();
    // If set the $provider to collate_outer (or collate_inner without plans organize mode),
    // then run through this function recursively and return results.
    if ($provider == "collate_outer" || $provider == "collate_inner" && $organize_mode != 'plans') {
        // First, collect an array of all providers
        $query = "SELECT id, lname, fname, npi, federaltaxid FROM users WHERE authorized = 1 ORDER BY lname, fname";
        $ures = sqlStatement($query);
        // Second, run through each provider recursively
        while ($urow = sqlFetchArray($ures)) {
            $newResults = test_rules_clinic($urow['id'], $type, $dateTarget, $mode, $patient_id, $plan, $organize_mode);
            if (!empty($newResults)) {
                $provider_item['is_provider'] = TRUE;
                $provider_item['prov_lname'] = $urow['lname'];
                $provider_item['prov_fname'] = $urow['fname'];
                $provider_item['npi'] = $urow['npi'];
                $provider_item['federaltaxid'] = $urow['federaltaxid'];
                array_push($results, $provider_item);
                $results = array_merge($results, $newResults);
            }
        }
        // done, so now can return results
        return $results;
    }
    // If set organize-mode to plans, then collects active plans and run through this
    // function recursively and return results.
    if ($organize_mode == "plans") {
        // First, collect active plans
        $plans_resolve = resolve_plans_sql($plan, $patient_id);
        // Second, run through function recursively
        foreach ($plans_resolve as $plan_item) {
            //  (if collate_inner, then nest a collation of providers within each plan)
            if ($provider == "collate_inner") {
                // First, collect an array of all providers
                $query = "SELECT id, lname, fname, npi, federaltaxid FROM users WHERE authorized = 1 ORDER BY lname, fname";
                $ures = sqlStatement($query);
                // Second, run through each provider recursively
                $provider_results = array();
                while ($urow = sqlFetchArray($ures)) {
                    $newResults = test_rules_clinic($urow['id'], $type, $dateTarget, $mode, $patient_id, $plan_item['id']);
                    if (!empty($newResults)) {
                        $provider_item['is_provider'] = TRUE;
                        $provider_item['prov_lname'] = $urow['lname'];
                        $provider_item['prov_fname'] = $urow['fname'];
                        $provider_item['npi'] = $urow['npi'];
                        $provider_item['federaltaxid'] = $urow['federaltaxid'];
                        array_push($provider_results, $provider_item);
                        $provider_results = array_merge($provider_results, $newResults);
                    }
                }
                if (!empty($provider_results)) {
                    $plan_item['is_plan'] = TRUE;
                    array_push($results, $plan_item);
                    $results = array_merge($results, $provider_results);
                }
            } else {
                // (not collate_inner, so do not nest providers within each plan)
                $newResults = test_rules_clinic($provider, $type, $dateTarget, $mode, $patient_id, $plan_item['id']);
                if (!empty($newResults)) {
                    $plan_item['is_plan'] = TRUE;
                    array_push($results, $plan_item);
                    $results = array_merge($results, $newResults);
                }
            }
        }
        // done, so now can return results
        return $results;
    }
    // Collect all patient ids
    $patientData = array();
    if (!empty($patient_id)) {
        // only look at the selected patient
        array_push($patientData, $patient_id);
    } else {
        if (empty($provider)) {
            // Look at entire practice
            $rez = sqlStatement("SELECT `pid` FROM `patient_data`");
            for ($iter = 0; $row = sqlFetchArray($rez); $iter++) {
                $patientData[$iter] = $row;
            }
        } else {
            // Look at one provider
            $rez = sqlStatement("SELECT `pid` FROM `patient_data` " . "WHERE providerID=?", array($provider));
            for ($iter = 0; $row = sqlFetchArray($rez); $iter++) {
                $patientData[$iter] = $row;
            }
        }
    }
    // Go through each patient(s)
    //
    //  If in report mode, then tabulate for each rule:
    //    Total Patients
    //    Patients that pass the filter
    //    Patients that pass the target
    //  If in reminders mode, then create reminders for each rule:
    //    Reminder that action is due soon
    //    Reminder that action is due
    //    Reminder that action is post-due
    //Collect applicable rules
    if ($mode != "report") {
        // Use per patient custom rules (if exist)
        $rules = resolve_rules_sql($type, $patient_id, FALSE, $plan);
    } else {
        // $mode = "report"
        // Only use default rules (do not use patient custom rules)
        $rules = resolve_rules_sql($type, $patient_id, FALSE, $plan);
    }
    foreach ($rules as $rowRule) {
        // If using cqm or amc type, then use the hard-coded rules set.
        // Note these rules are only used in report mode.
        if ($rowRule['cqm_flag'] || $rowRule['amc_flag']) {
            // Ensure the ruleSet class file has been included
            // (will only require if needed, since it's gonna be large)
            require_once dirname(__FILE__) . "/classes/rulesets/ruleSet.class.php";
            // Run the class rule set
            $rule_results = new ruleSet($rowRule, $dateTarget, $patientData);
            // Collect/add the results to the results array
            $tempResults = $rule_results->return_results();
            if (!empty($tempResults)) {
                foreach ($tempResults as $tempResult) {
                    array_push($results, $tempResult);
                }
            }
            // Go on to the next rule
            continue;
        }
        // If in reminder mode then need to collect the measurement dates
        //  from rule_reminder table
        $target_dates = array();
        if ($mode != "report") {
            // Calculate the dates to check for
            if ($type == "patient_reminder") {
                $reminder_interval_type = "patient_reminder";
            } else {
                // $type == "passive_alert" or $type == "active_alert"
                $reminder_interval_type = "clinical_reminder";
            }
            $target_dates = calculate_reminder_dates($rowRule['id'], $dateTarget, $reminder_interval_type);
        } else {
            // $mode == "report"
            // Only use the target date in the report
            $target_dates[0] = $dateTarget;
        }
        //Reset the counters
        $total_patients = 0;
        $pass_filter = 0;
        $exclude_filter = 0;
        $pass_target = 0;
        foreach ($patientData as $rowPatient) {
            // Count the total patients
            $total_patients++;
            $dateCounter = 1;
            // for reminder mode to keep track of which date checking
            foreach ($target_dates as $dateFocus) {
                //Skip if date is set to SKIP
                if ($dateFocus == "SKIP") {
                    $dateCounter++;
                    continue;
                }
                //Set date counter and reminder token (applicable for reminders only)
                if ($dateCounter == 1) {
                    $reminder_due = "soon_due";
                } else {
                    if ($dateCounter == 2) {
                        $reminder_due = "due";
                    } else {
                        // $dateCounter == 3
                        $reminder_due = "past_due";
                    }
                }
                // Check if pass filter
                $passFilter = test_filter($rowPatient['pid'], $rowRule['id'], $dateFocus);
                if ($passFilter === "EXCLUDED") {
                    // increment EXCLUDED and pass_filter counters
                    //  and set as FALSE for reminder functionality.
                    $pass_filter++;
                    $exclude_filter++;
                    $passFilter = FALSE;
                }
                if ($passFilter) {
                    // increment pass filter counter
                    $pass_filter++;
                } else {
                    $dateCounter++;
                    continue;
                }
                // Check if pass target
                $passTarget = test_targets($rowPatient['pid'], $rowRule['id'], '', $dateFocus);
                if ($passTarget) {
                    // increment pass target counter
                    $pass_target++;
                    // send to reminder results
                    if ($mode == "reminders-all") {
                        // place the completed actions into the reminder return array
                        $actionArray = resolve_action_sql($rowRule['id'], '1');
                        foreach ($actionArray as $action) {
                            $action_plus = $action;
                            $action_plus['due_status'] = "not_due";
                            $action_plus['pid'] = $rowPatient['pid'];
                            $results = reminder_results_integrate($results, $action_plus);
                        }
                    }
                    break;
                } else {
                    // send to reminder results
                    if ($mode != "report") {
                        // place the uncompleted actions into the reminder return array
                        $actionArray = resolve_action_sql($rowRule['id'], '1');
                        foreach ($actionArray as $action) {
                            $action_plus = $action;
                            $action_plus['due_status'] = $reminder_due;
                            $action_plus['pid'] = $rowPatient['pid'];
                            $results = reminder_results_integrate($results, $action_plus);
                        }
                    }
                }
                $dateCounter++;
            }
        }
        // Calculate and save the data for the rule
        $percentage = calculate_percentage($pass_filter, $exclude_filter, $pass_target);
        if ($mode == "report") {
            $newRow = array('is_main' => TRUE, 'total_patients' => $total_patients, 'excluded' => $exclude_filter, 'pass_filter' => $pass_filter, 'pass_target' => $pass_target, 'percentage' => $percentage);
            $newRow = array_merge($newRow, $rowRule);
            array_push($results, $newRow);
        }
        // Find the number of target groups, and go through each one if more than one
        $targetGroups = returnTargetGroups($rowRule['id']);
        if (count($targetGroups) > 1) {
            $firstGroup = true;
            foreach ($targetGroups as $i) {
                // skip first group if not in report mode
                //  (this is because first group was already queried above)
                if ($mode != "report" && $firstGroup) {
                    $firstGroup = false;
                    continue;
                }
                //Reset the target counter
                $pass_target = 0;
                foreach ($patientData as $rowPatient) {
                    $dateCounter = 1;
                    // for reminder mode to keep track of which date checking
                    foreach ($target_dates as $dateFocus) {
                        //Skip if date is set to SKIP
                        if ($dateFocus == "SKIP") {
                            $dateCounter++;
                            continue;
                        }
                        //Set date counter and reminder token (applicable for reminders only)
                        if ($dateCounter == 1) {
                            $reminder_due = "soon_due";
                        } else {
                            if ($dateCounter == 2) {
                                $reminder_due = "due";
                            } else {
                                // $dateCounter == 3
                                $reminder_due = "past_due";
                            }
                        }
                        //Check if pass target
                        $passTarget = test_targets($rowPatient['pid'], $rowRule['id'], $i, $dateFocus);
                        if ($passTarget) {
                            // increment pass target counter
                            $pass_target++;
                            // send to reminder results
                            if ($mode == "reminders-all") {
                                // place the completed actions into the reminder return array
                                $actionArray = resolve_action_sql($rowRule['id'], '1');
                                foreach ($actionArray as $action) {
                                    $action_plus = $action;
                                    $action_plus['due_status'] = "not_due";
                                    $action_plus['pid'] = $rowPatient['pid'];
                                    $results = reminder_results_integrate($results, $action_plus);
                                }
                            }
                            break;
                        } else {
                            // send to reminder results
                            if ($mode != "report") {
                                // place the actions into the reminder return array
                                $actionArray = resolve_action_sql($rowRule['id'], $i);
                                foreach ($actionArray as $action) {
                                    $action_plus = $action;
                                    $action_plus['due_status'] = $reminder_due;
                                    $action_plus['pid'] = $rowPatient['pid'];
                                    $results = reminder_results_integrate($results, $action_plus);
                                }
                            }
                        }
                        $dateCounter++;
                    }
                }
                // Calculate and save the data for the rule
                $percentage = calculate_percentage($pass_filter, $exclude_filter, $pass_target);
                // Collect action for title (just use the first one, if more than one)
                $actionArray = resolve_action_sql($rowRule['id'], $i);
                $action = $actionArray[0];
                if ($mode == "report") {
                    $newRow = array('is_sub' => TRUE, 'action_category' => $action['category'], 'action_item' => $action['item'], 'total_patients' => '', 'excluded' => '', 'pass_filter' => '', 'pass_target' => $pass_target, 'percentage' => $percentage);
                    array_push($results, $newRow);
                }
            }
        }
    }
    // Return the data
    return $results;
}
 public function execute()
 {
     $populationCriterias = $this->createPopulationCriteria();
     if (!is_array($populationCriterias)) {
         $tmpPopulationCriterias = array();
         $tmpPopulationCriterias[] = $populationCriterias;
         $populationCriterias = $tmpPopulationCriterias;
     }
     foreach ($populationCriterias as $populationCriteria) {
         if ($populationCriteria instanceof CqmPopulationCrtiteriaFactory) {
             $initialPatientPopulationFilter = $populationCriteria->createInitialPatientPopulation();
             if (!$initialPatientPopulationFilter instanceof CqmFilterIF) {
                 throw new Exception("InitialPatientPopulation must be an instance of CqmFilterIF");
             }
             $denominator = $populationCriteria->createDenominator();
             if (!$denominator instanceof CqmFilterIF) {
                 throw new Exception("Denominator must be an instance of CqmFilterIF");
             }
             $numerators = $populationCriteria->createNumerators();
             if (!is_array($numerators)) {
                 $tmpNumerators = array();
                 $tmpNumerators[] = $numerators;
                 $numerators = $tmpNumerators;
             }
             $exclusion = $populationCriteria->createExclusion();
             if (!$exclusion instanceof CqmFilterIF) {
                 throw new Exception("Exclusion must be an instance of CqmFilterIF");
             }
             $totalPatients = count($this->_cqmPopulation);
             $initialPatientPopulation = 0;
             $denominatorPatientPopulation = 0;
             $exclusionsPatientPopulation = 0;
             $numeratorPatientPopulations = $this->initNumeratorPopulations($numerators);
             foreach ($this->_cqmPopulation as $patient) {
                 if (!$initialPatientPopulationFilter->test($patient, $this->_beginMeasurement, $this->_endMeasurement)) {
                     continue;
                 }
                 $initialPatientPopulation++;
                 if (!$denominator->test($patient, $this->_beginMeasurement, $this->_endMeasurement)) {
                     continue;
                 }
                 $denominatorPatientPopulation++;
                 if ($exclusion->test($patient, $this->_beginMeasurement, $this->_endMeasurement)) {
                     $exclusionsPatientPopulation++;
                 }
                 foreach ($numerators as $numerator) {
                     $this->testNumerator($patient, $numerator, $numeratorPatientPopulations);
                 }
             }
             // tally results, run exclusion on each numerator
             $pass_filt = $denominatorPatientPopulation;
             $exclude_filt = $exclusionsPatientPopulation;
             foreach ($numeratorPatientPopulations as $title => $pass_targ) {
                 $percentage = calculate_percentage($pass_filt, $exclude_filt, $pass_targ);
                 $this->_resultsArray[] = new CqmResult($this->_rowRule, $title, $populationCriteria->getTitle(), $totalPatients, $pass_filt, $exclude_filt, $pass_targ, $percentage);
             }
         }
     }
     return $this->_resultsArray;
 }
Beispiel #5
0
 private function rule_htn_bp_measure_cqm()
 {
     $rule_id = $this->rule['id'];
     $dateTarget = $this->dateTarget;
     $patientData = $this->patientData;
     // Calculate measurement period
     $tempDateArray = explode("-", $dateTarget);
     $tempYear = $tempDateArray[0];
     $begin_measurement = $tempDateArray[0] . "-01-01 00:00:00";
     $end_measurement = $tempDateArray[0] . "-12-31 23:59:59";
     // Collect results
     $total_pat = 0;
     $pass_filt = 0;
     $exclude_filt = 0;
     $pass_targ = 0;
     $perc = 0;
     foreach ($patientData as $rowPatient) {
         // increment total patients counter
         $total_pat++;
         // get patient id
         $patient_id = $this->get_patient_id($rowPatient);
         // filter for age greater than 18
         // utilize the convertDobtoAgeYearDecimal() function from library/clinical_rules.php
         if (convertDobtoAgeYearDecimal($this->get_DOB($patient_id), $begin_measurement) < 18) {
             continue;
         }
         // filter for diagnosis of HTN
         // utlize the exist_lists_item() function from library/clinical_rules.php
         if (!(exist_lists_item($patient_id, 'medical_problem', 'CUSTOM::HTN', $end_measurement) || exist_lists_item($patient_id, 'medical_problem', 'ICD9::401.0', $end_measurement) || exist_lists_item($patient_id, 'medical_problem', 'ICD9::401.1', $end_measurement) || exist_lists_item($patient_id, 'medical_problem', 'ICD9::401.9', $end_measurement) || exist_lists_item($patient_id, 'medical_problem', 'ICD9::402.00', $end_measurement) || exist_lists_item($patient_id, 'medical_problem', 'ICD9::402.01', $end_measurement) || exist_lists_item($patient_id, 'medical_problem', 'ICD9::402.10', $end_measurement) || exist_lists_item($patient_id, 'medical_problem', 'ICD9::402.11', $end_measurement) || exist_lists_item($patient_id, 'medical_problem', 'ICD9::402.90', $end_measurement) || exist_lists_item($patient_id, 'medical_problem', 'ICD9::402.91', $end_measurement) || exist_lists_item($patient_id, 'medical_problem', 'ICD9::403.00', $end_measurement) || exist_lists_item($patient_id, 'medical_problem', 'ICD9::403.01', $end_measurement) || exist_lists_item($patient_id, 'medical_problem', 'ICD9::403.10', $end_measurement) || exist_lists_item($patient_id, 'medical_problem', 'ICD9::403.11', $end_measurement) || exist_lists_item($patient_id, 'medical_problem', 'ICD9::403.90', $end_measurement) || exist_lists_item($patient_id, 'medical_problem', 'ICD9::403.91', $end_measurement) || exist_lists_item($patient_id, 'medical_problem', 'ICD9::404.00', $end_measurement) || exist_lists_item($patient_id, 'medical_problem', 'ICD9::404.01', $end_measurement) || exist_lists_item($patient_id, 'medical_problem', 'ICD9::404.02', $end_measurement) || exist_lists_item($patient_id, 'medical_problem', 'ICD9::404.03', $end_measurement) || exist_lists_item($patient_id, 'medical_problem', 'ICD9::404.10', $end_measurement) || exist_lists_item($patient_id, 'medical_problem', 'ICD9::404.11', $end_measurement) || exist_lists_item($patient_id, 'medical_problem', 'ICD9::404.12', $end_measurement) || exist_lists_item($patient_id, 'medical_problem', 'ICD9::404.13', $end_measurement) || exist_lists_item($patient_id, 'medical_problem', 'ICD9::404.90', $end_measurement) || exist_lists_item($patient_id, 'medical_problem', 'ICD9::404.91', $end_measurement) || exist_lists_item($patient_id, 'medical_problem', 'ICD9::404.92', $end_measurement) || exist_lists_item($patient_id, 'medical_problem', 'ICD9::404.93', $end_measurement))) {
             continue;
         }
         // filter for 2 specified encounters
         // make a function for this and wrap in the encounter titles
         if (!($this->exist_encounter($patient_id, 'enc_outpatient', $begin_measurement, $end_measurement, 2) || $this->exist_encounter($patient_id, 'enc_nurs_fac', $begin_measurement, $end_measurement, 2))) {
             continue;
         }
         // Filter has been passed
         $pass_filt++;
         // See if BP has been done within the measurement period (on a day of a specified encounter)
         $query = "SELECT form_vitals.bps, form_vitals.bpd " . "FROM `form_vitals` " . "LEFT JOIN `form_encounter` " . "ON ( DATE(form_vitals.date) = DATE(form_encounter.date)) " . "LEFT JOIN `enc_category_map` " . "ON (enc_category_map.main_cat_id = form_encounter.pc_catid) " . "WHERE form_vitals.pid = ?" . "AND form_vitals.bps IS NOT NULL " . "AND form_vitals.bpd IS NOT NULL " . "AND form_vitals.date >= ? " . "AND form_vitals.date <= ? " . "AND ( enc_category_map.rule_enc_id = 'enc_outpatient' OR enc_category_map.rule_enc_id = 'enc_nurs_fac' )";
         $res = sqlStatement($query, array($patient_id, $begin_measurement, $end_measurement));
         $number = sqlNumRows($res);
         if ($number < 1) {
             continue;
         }
         error_log("passed target", 0);
         // Target has been passed
         $pass_targ++;
     }
     // Calculate Percentage (use calculate_percentage() function from library/clinical_rules.php
     $perc = calculate_percentage($pass_filt, $exclude_filt, $pass_targ);
     // Set results
     $this->set_result($rule_id, $total_pat, $pass_filt, $exclude_filt, $pass_targ, $perc);
 }
Beispiel #6
0
		<?php 
$percentageY = calculate_percentage($meet_expect[0]['total'], $meet_expect[1]['actual']);
$percentageN = 100 - $percentageY;
$progress_bar9 = $percentageY;
$progress_bar_9 = $percentageN;
echo "<div class='progress'>\n\t\t\t<div class='bar'  style='float:left; width:{$percentageY}%;background:{$statusY}'>YES " . $percentageY . "% </div>\n    \t\t<div class='view_expectations bar'><div class='bar' style='float:right; width:{$percentageN}%;background:{$statusN}'>  NO " . $percentageN . "% </div></div>\n    \t\t</div></td>";
?>
	</td>
	</tr>
	<tr>
	<td colspan="2">
		<p >Would you be willing to re-train facility staff on the use and importance of the tool?</p>
	</td>
	<td colspan="2">
		<?php 
$percentageY = calculate_percentage($retrain[0]['total'], $retrain[0]['actual']);
$percentageN = 100 - $percentageY;
$progress_bar10 = $percentageY;
$progress_bar_10 = $percentageN;
echo "\n\t\t\t<div class='progress'>\n\t\t\t<div class='bar' style='float:left; width:{$percentageY}%; background:{$statusY}'>YES " . $percentageY . "% </div>\n    \t\t<div class='bar' style='float:right; width:{$percentageN}%; background:{$statusN}'> NO " . $percentageN . "% </div>\n    \t\t\t\n    \t\t\t</div>";
?>
	</td>
	</tr>
	</table>

<script>
	$(function () { 
		<?php 
echo $facility_evaluation;
//first chart
echo $frequency_of_use;
 public function execute()
 {
     // If itemization is turned on, then iterate the rule id iterator
     //
     // Note that when AMC rules suports different patient populations and
     // numerator caclulation, then it will need to change placement of
     // this and mimick the CQM rules mechanism
     if ($GLOBALS['report_itemizing_temp_flag_and_id']) {
         $GLOBALS['report_itemized_test_id_iterator']++;
     }
     $numerator = $this->createNumerator();
     if (!$numerator instanceof AmcFilterIF) {
         throw new Exception("Numerator must be an instance of AmcFilterIF");
     }
     $denominator = $this->createDenominator();
     if (!$denominator instanceof AmcFilterIF) {
         throw new Exception("Denominator must be an instance of AmcFilterIF");
     }
     $totalPatients = count($this->_amcPopulation);
     // Figure out object to be counted
     //   (patients, labs, transitions, visits, or prescriptions)
     $object_to_count = $this->getObjectToCount();
     if (empty($object_to_count)) {
         $object_to_count = "patients";
     }
     $numeratorObjects = 0;
     $denominatorObjects = 0;
     foreach ($this->_amcPopulation as $patient) {
         // If begin measurement is empty, then make the begin
         //  measurement the patient dob.
         $tempBeginMeasurement = "";
         if (empty($this->_beginMeasurement)) {
             $tempBeginMeasurement = $patient->dob;
         } else {
             $tempBeginMeasurement = $this->_beginMeasurement;
         }
         // Count Denominators
         if ($object_to_count == "patients") {
             // Counting patients
             if (!$denominator->test($patient, $tempBeginMeasurement, $this->_endMeasurement)) {
                 continue;
             }
             $denominatorObjects++;
         } else {
             // Counting objects other than patients
             //   First, collect the pertinent objects
             $objects = $this->collectObjects($patient, $object_to_count, $tempBeginMeasurement, $this->_endMeasurement);
             //   Second, test each object
             $objects_pass = array();
             foreach ($objects as $object) {
                 $patient->object = $object;
                 if ($denominator->test($patient, $tempBeginMeasurement, $this->_endMeasurement)) {
                     $denominatorObjects++;
                     array_push($objects_pass, $object);
                 }
             }
         }
         // Count Numerators
         if ($object_to_count == "patients") {
             // Counting patients
             if (!$numerator->test($patient, $tempBeginMeasurement, $this->_endMeasurement)) {
                 // If itemization is turned on, then record the "failed" item
                 if ($GLOBALS['report_itemizing_temp_flag_and_id']) {
                     insertItemReportTracker($GLOBALS['report_itemizing_temp_flag_and_id'], $GLOBALS['report_itemized_test_id_iterator'], 0, $patient->id);
                 }
                 continue;
             } else {
                 $numeratorObjects++;
                 // If itemization is turned on, then record the "passed" item
                 if ($GLOBALS['report_itemizing_temp_flag_and_id']) {
                     insertItemReportTracker($GLOBALS['report_itemizing_temp_flag_and_id'], $GLOBALS['report_itemized_test_id_iterator'], 1, $patient->id);
                 }
             }
         } else {
             // Counting objects other than patients
             //   test each object that passed the above denominator testing
             foreach ($objects_pass as $object) {
                 $patient->object = $object;
                 if ($numerator->test($patient, $tempBeginMeasurement, $this->_endMeasurement)) {
                     $numeratorObjects++;
                     // If itemization is turned on, then record the "passed" item
                     if ($GLOBALS['report_itemizing_temp_flag_and_id']) {
                         insertItemReportTracker($GLOBALS['report_itemizing_temp_flag_and_id'], $GLOBALS['report_itemized_test_id_iterator'], 1, $patient->id);
                     }
                 } else {
                     // If itemization is turned on, then record the "failed" item
                     if ($GLOBALS['report_itemizing_temp_flag_and_id']) {
                         insertItemReportTracker($GLOBALS['report_itemizing_temp_flag_and_id'], $GLOBALS['report_itemized_test_id_iterator'], 0, $patient->id);
                     }
                 }
             }
         }
     }
     // Deal with the manually added labs for the electronic labs AMC measure
     if ($object_to_count == "labs") {
         $denominatorObjects = $denominatorObjects + $this->_manualLabNumber;
     }
     $percentage = calculate_percentage($denominatorObjects, 0, $numeratorObjects);
     $result = new AmcResult($this->_rowRule, $totalPatients, $denominatorObjects, 0, $numeratorObjects, $percentage);
     $this->_resultsArray[] = $result;
 }
Beispiel #8
0
 public function execute()
 {
     $populationCriterias = $this->createPopulationCriteria();
     if (!is_array($populationCriterias)) {
         $tmpPopulationCriterias = array();
         $tmpPopulationCriterias[] = $populationCriterias;
         $populationCriterias = $tmpPopulationCriterias;
     }
     foreach ($populationCriterias as $populationCriteria) {
         // If itemization is turned on, then iterate the rule id iterator
         if ($GLOBALS['report_itemizing_temp_flag_and_id']) {
             $GLOBALS['report_itemized_test_id_iterator']++;
         }
         if ($populationCriteria instanceof CqmPopulationCrtiteriaFactory) {
             $initialPatientPopulationFilter = $populationCriteria->createInitialPatientPopulation();
             if (!$initialPatientPopulationFilter instanceof CqmFilterIF) {
                 throw new Exception("InitialPatientPopulation must be an instance of CqmFilterIF");
             }
             $denominator = $populationCriteria->createDenominator();
             if (!$denominator instanceof CqmFilterIF) {
                 throw new Exception("Denominator must be an instance of CqmFilterIF");
             }
             $numerators = $populationCriteria->createNumerators();
             if (!is_array($numerators)) {
                 $tmpNumerators = array();
                 $tmpNumerators[] = $numerators;
                 $numerators = $tmpNumerators;
             }
             $exclusion = $populationCriteria->createExclusion();
             if (!$exclusion instanceof CqmFilterIF) {
                 throw new Exception("Exclusion must be an instance of CqmFilterIF");
             }
             $totalPatients = count($this->_cqmPopulation);
             $initialPatientPopulation = 0;
             $denominatorPatientPopulation = 0;
             $exclusionsPatientPopulation = 0;
             $numeratorPatientPopulations = $this->initNumeratorPopulations($numerators);
             foreach ($this->_cqmPopulation as $patient) {
                 if (!$initialPatientPopulationFilter->test($patient, $this->_beginMeasurement, $this->_endMeasurement)) {
                     continue;
                 }
                 $initialPatientPopulation++;
                 if (!$denominator->test($patient, $this->_beginMeasurement, $this->_endMeasurement)) {
                     continue;
                 }
                 $denominatorPatientPopulation++;
                 if ($exclusion->test($patient, $this->_beginMeasurement, $this->_endMeasurement)) {
                     $exclusionsPatientPopulation++;
                     // If itemization is turned on, then record the "excluded" item
                     if ($GLOBALS['report_itemizing_temp_flag_and_id']) {
                         insertItemReportTracker($GLOBALS['report_itemizing_temp_flag_and_id'], $GLOBALS['report_itemized_test_id_iterator'], 2, $patient->id);
                     }
                 }
                 foreach ($numerators as $numerator) {
                     $this->testNumerator($patient, $numerator, $numeratorPatientPopulations);
                 }
             }
             // tally results, run exclusion on each numerator
             $pass_filt = $denominatorPatientPopulation;
             $exclude_filt = $exclusionsPatientPopulation;
             foreach ($numeratorPatientPopulations as $title => $pass_targ) {
                 $percentage = calculate_percentage($pass_filt, $exclude_filt, $pass_targ);
                 $this->_resultsArray[] = new CqmResult($this->_rowRule, $title, $populationCriteria->getTitle(), $totalPatients, $pass_filt, $exclude_filt, $pass_targ, $percentage);
             }
         }
     }
     return $this->_resultsArray;
 }
 public function execute()
 {
     $numerator = $this->createNumerator();
     if (!$numerator instanceof AmcFilterIF) {
         throw new Exception("Numerator must be an instance of AmcFilterIF");
     }
     $denominator = $this->createDenominator();
     if (!$denominator instanceof AmcFilterIF) {
         throw new Exception("Denominator must be an instance of AmcFilterIF");
     }
     $totalPatients = count($this->_amcPopulation);
     // Figure out object to be counted
     //   (patients, labs, transitions, visits, or prescriptions)
     $object_to_count = $this->getObjectToCount();
     if (empty($object_to_count)) {
         $object_to_count = "patients";
     }
     $numeratorObjects = 0;
     $denominatorObjects = 0;
     foreach ($this->_amcPopulation as $patient) {
         // If begin measurement is empty, then make the begin
         //  measurement the patient dob.
         $tempBeginMeasurement = "";
         if (empty($this->_beginMeasurement)) {
             $tempBeginMeasurement = $patient->dob;
         } else {
             $tempBeginMeasurement = $this->_beginMeasurement;
         }
         // Count Denominators
         if ($object_to_count == "patients") {
             // Counting patients
             if (!$denominator->test($patient, $tempBeginMeasurement, $this->_endMeasurement)) {
                 continue;
             }
             $denominatorObjects++;
         } else {
             // Counting objects other than patients
             //   First, collect the pertinent objects
             $objects = $this->collectObjects($patient, $object_to_count, $tempBeginMeasurement, $this->_endMeasurement);
             //   Second, test each object
             $objects_pass = array();
             foreach ($objects as $object) {
                 $patient->object = $object;
                 if ($denominator->test($patient, $tempBeginMeasurement, $this->_endMeasurement)) {
                     $denominatorObjects++;
                     array_push($objects_pass, $object);
                 }
             }
         }
         // Count Numerators
         if ($object_to_count == "patients") {
             // Counting patients
             if (!$numerator->test($patient, $tempBeginMeasurement, $this->_endMeasurement)) {
                 continue;
             }
             $numeratorObjects++;
         } else {
             // Counting objects other than patients
             //   test each object that passed the above denominator testing
             foreach ($objects_pass as $object) {
                 $patient->object = $object;
                 if ($numerator->test($patient, $tempBeginMeasurement, $this->_endMeasurement)) {
                     $numeratorObjects++;
                 }
             }
         }
     }
     // Deal with the manually added labs for the electronic labs AMC measure
     if ($object_to_count == "labs") {
         $denominatorObjects = $denominatorObjects + $this->_manualLabNumber;
     }
     $percentage = calculate_percentage($denominatorObjects, 0, $numeratorObjects);
     $result = new AmcResult($this->_rowRule, $totalPatients, $denominatorObjects, 0, $numeratorObjects, $percentage);
     $this->_resultsArray[] = $result;
 }
Beispiel #10
0
 public function execute()
 {
     $populationCriterias = $this->createPopulationCriteria();
     if (!is_array($populationCriterias)) {
         $tmpPopulationCriterias = array();
         $tmpPopulationCriterias[] = $populationCriterias;
         $populationCriterias = $tmpPopulationCriterias;
     }
     foreach ($populationCriterias as $populationCriteria) {
         // If itemization is turned on, then iterate the rule id iterator
         if ($GLOBALS['report_itemizing_temp_flag_and_id']) {
             $GLOBALS['report_itemized_test_id_iterator']++;
         }
         if ($populationCriteria instanceof CqmPopulationCrtiteriaFactory) {
             $initialPatientPopulationFilter = $populationCriteria->createInitialPatientPopulation();
             if (!$initialPatientPopulationFilter instanceof CqmFilterIF) {
                 throw new Exception("InitialPatientPopulation must be an instance of CqmFilterIF");
             }
             $denominator = $populationCriteria->createDenominator();
             if (!$denominator instanceof CqmFilterIF) {
                 throw new Exception("Denominator must be an instance of CqmFilterIF");
             }
             $numerators = $populationCriteria->createNumerators();
             if (!is_array($numerators)) {
                 $tmpNumerators = array();
                 $tmpNumerators[] = $numerators;
                 $numerators = $tmpNumerators;
             }
             $exclusion = $populationCriteria->createExclusion();
             if (!$exclusion instanceof CqmFilterIF) {
                 throw new Exception("Exclusion must be an instance of CqmFilterIF");
             }
             //Denominator Exception added
             $denomExept = false;
             if (method_exists($populationCriteria, 'createDenominatorException')) {
                 $denomExept = true;
             }
             $totalPatients = count($this->_cqmPopulation);
             $initialPatientPopulation = 0;
             $denominatorPatientPopulation = 0;
             $exclusionsPatientPopulation = 0;
             $exceptionsPatientPopulation = 0;
             // this is a bridge to no where variable (calculated but not used below). Will keep for now, though.
             $patExclArr = array();
             $patExceptArr = array();
             $numeratorPatientPopulations = $this->initNumeratorPopulations($numerators);
             foreach ($this->_cqmPopulation as $patient) {
                 if (!$initialPatientPopulationFilter->test($patient, $this->_beginMeasurement, $this->_endMeasurement)) {
                     continue;
                 }
                 $initialPatientPopulation++;
                 // If itemization is turned on, then record the "Initial Patient population" item
                 if ($GLOBALS['report_itemizing_temp_flag_and_id']) {
                     insertItemReportTracker($GLOBALS['report_itemizing_temp_flag_and_id'], $GLOBALS['report_itemized_test_id_iterator'], 3, $patient->id);
                 }
                 if (!$denominator->test($patient, $this->_beginMeasurement, $this->_endMeasurement)) {
                     continue;
                 }
                 $denominatorPatientPopulation++;
                 if ($exclusion->test($patient, $this->_beginMeasurement, $this->_endMeasurement)) {
                     $exclusionsPatientPopulation++;
                     $patExclArr[] = $patient->id;
                 }
                 //Denominator Exception added
                 if ($denomExept) {
                     $denom_exception = $populationCriteria->createDenominatorException();
                     if ($denom_exception->test($patient, $this->_beginMeasurement, $this->_endMeasurement)) {
                         $exceptionsPatientPopulation++;
                         // this is a bridge to no where variable (not used below). Will keep for now, though.
                         $patExceptArr[] = $patient->id;
                     }
                 }
                 foreach ($numerators as $numerator) {
                     $this->testNumerator($patient, $numerator, $numeratorPatientPopulations);
                 }
             }
             // tally results, run exclusion on each numerator
             $pass_filt = $denominatorPatientPopulation;
             $exclude_filt = $exclusionsPatientPopulation;
             foreach ($numeratorPatientPopulations as $title => $pass_targ) {
                 if (count($patExclArr) > 0) {
                     foreach ($patExclArr as $patVal) {
                         // If itemization is turned on, then record the "excluded" item
                         if ($GLOBALS['report_itemizing_temp_flag_and_id']) {
                             insertItemReportTracker($GLOBALS['report_itemizing_temp_flag_and_id'], $GLOBALS['report_itemized_test_id_iterator'], 2, $patVal, $title);
                         }
                     }
                 }
                 if (count($patExceptArr) > 0) {
                     foreach ($patExceptArr as $patVal) {
                         // If itemization is turned on, then record the "exception" item
                         if ($GLOBALS['report_itemizing_temp_flag_and_id']) {
                             insertItemReportTracker($GLOBALS['report_itemizing_temp_flag_and_id'], $GLOBALS['report_itemized_test_id_iterator'], 4, $patVal, $title);
                         }
                     }
                 }
                 $percentage = calculate_percentage($pass_filt, $exclude_filt, $pass_targ);
                 $this->_resultsArray[] = new CqmResult($this->_rowRule, $title, $populationCriteria->getTitle(), $totalPatients, $pass_filt, $exclude_filt, $pass_targ, $percentage);
             }
         }
     }
     return $this->_resultsArray;
 }