Skip to content

Commit

Permalink
AMC Reporting Module: Allow begin and end dates in report.
Browse files Browse the repository at this point in the history
  • Loading branch information
bradymiller committed May 25, 2011
1 parent dab6dab commit 3d315b6
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 11 deletions.
12 changes: 10 additions & 2 deletions interface/reports/cqm.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,16 @@ function GenXml(sNested) {
<tbody> <!-- added for better print-ability -->
<?php

//collect the results
$dataSheet = test_rules_clinic($provider,$rule_filter,$target_date,"report",'',$plan_filter,$organize_method);
if ($type_report == "amc") {
// For AMC, need to make $target_date an array with two elements ('dateBegin' and 'dateTarget')
$array_date = array();
$array_date['dateBegin'] = $begin_date;
$array_date['dateTarget'] = $target_date;
$dataSheet = test_rules_clinic($provider,$rule_filter,$array_date,"report",'',$plan_filter,$organize_method);
}
else {
$dataSheet = test_rules_clinic($provider,$rule_filter,$target_date,"report",'',$plan_filter,$organize_method);
}

$firstProviderFlag = TRUE;
$firstPlanFlag = TRUE;
Expand Down
23 changes: 15 additions & 8 deletions library/classes/rulesets/Amc/library/AbstractAmcReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ public function __construct( array $rowRule, array $patientIdArray, $dateTarget
$this->_amcPopulation = new AmcPopulation( $patientIdArray );
$this->_rowRule = $rowRule;
$this->_ruleId = isset( $rowRule['id'] ) ? $rowRule['id'] : '';
// Calculate measurement period
$tempDateArray = explode( "-",$dateTarget );
$tempYear = $tempDateArray[0];
$this->_beginMeasurement = $tempDateArray[0] . "-01-01 00:00:00";
$this->_endMeasurement = $tempDateArray[0] . "-12-31 23:59:59";
// Parse measurement period, which is stored as array in $dateTarget ('dateBegin' and 'dateTarget').
$this->_beginMeasurement = $dateTarget['dateBegin'];
$this->_endMeasurement = $dateTarget['dateTarget'];
}

public abstract function createNumerator();
Expand All @@ -69,20 +67,29 @@ public function execute()
$denominatorPatients = 0;
foreach ( $this->_amcPopulation as $patient )
{
if ( !$denominator->test( $patient, $this->_beginMeasurement, $this->_endMeasurement ) ) {
// 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;
}

if ( !$denominator->test( $patient, $tempBeginMeasurement, $this->_endMeasurement ) ) {
continue;
}

$denominatorPatients++;

if ( !$numerator->test( $patient, $this->_beginMeasurement, $this->_endMeasurement ) ) {
if ( !$numerator->test( $patient, $tempBeginMeasurement, $this->_endMeasurement ) ) {
continue;
}

$numeratorPatients++;
}

// TODO calculate results
$percentage = calculate_percentage( $denominatorPatients, 0, $numeratorPatients );
$result = new AmcResult( $this->_rowRule, $totalPatients, $denominatorPatients, 0, $numeratorPatients, $percentage );
$this->_resultsArray[]= $result;
Expand Down
16 changes: 15 additions & 1 deletion library/clinical_rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ function clinical_summary_widget($patient_id,$mode,$dateTarget='',$organize_mode
// inner and outer are only different if organize_mode is set to plans).
// $type - rule filter (active_alert,passive_alert,cqm,amc,patient_reminder). If blank then will test all rules.
// $dateTarget - target date. If blank then will test with current date as target.
// If an array, then is holding two dates ('dateBegin' and 'dateTarget')
// $mode - choose either 'report' or 'reminders-all' or 'reminders-due' (required)
// $patient_id - pid of patient. If blank then will check all patients.
// $plan - test for specific plan only
Expand All @@ -114,6 +115,12 @@ function clinical_summary_widget($patient_id,$mode,$dateTarget='',$organize_mode
//
function test_rules_clinic($provider='',$type='',$dateTarget='',$mode='',$patient_id='',$plan='',$organize_mode='default') {

// 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');

Expand Down Expand Up @@ -241,7 +248,14 @@ function test_rules_clinic($provider='',$type='',$dateTarget='',$mode='',$patien

require_once( dirname(__FILE__)."/classes/rulesets/ReportManager.php");
$manager = new ReportManager();
$tempResults = $manager->runReport( $rowRule, $patientData, $dateTarget );
if ($rowRule['amc_flag']) {
// Send array of dates ('dateBegin' and 'dateTarget')
$tempResults = $manager->runReport( $rowRule, $patientData, $dateArray );
}
else {
// Send target date
$tempResults = $manager->runReport( $rowRule, $patientData, $dateTarget );
}
if (!empty($tempResults)) {
foreach ($tempResults as $tempResult) {
array_push($results,$tempResult);
Expand Down

0 comments on commit 3d315b6

Please sign in to comment.