use of com.ibm.cohort.engine.measure.evidence.MeasureEvidenceOptions in project quality-measure-and-cohort-service by Alvearie.
the class CDMMeasureEvaluation method evaluatePatientMeasure.
/**
* Evaluate a CDM Patient Quality Measure
*
* @param measure CDM Patient Quality Measure
* @param context CQL Engine Execution Context pre-configured for use in
* measure evaluation
* @param patientIds Patient ID(s) of the patient to evaluate (first element when generating INDIVIDUAL type report)
* @param evidenceOptions MeasureEvidenceOptions to indicate whether or not to return evaluated resources and define level results
* @param parameterMap Map of parameter names to Parameter objects
* @param type Type of report to be generated
* @return MeasureReport with population components filled out.
*/
public MeasureReport evaluatePatientMeasure(Measure measure, Context context, List<String> patientIds, MeasureEvidenceOptions evidenceOptions, Map<String, Parameter> parameterMap, MeasureReport.MeasureReportType type) {
context.setExpressionCaching(true);
boolean includeEvaluatedResources = (evidenceOptions != null) ? evidenceOptions.isIncludeEvaluatedResources() : false;
MeasureReport report;
switch(type) {
case INDIVIDUAL:
report = evaluation.evaluatePatientMeasure(measure, context, patientIds.get(0), includeEvaluatedResources);
break;
case SUBJECTLIST:
report = evaluation.evaluatePatientListMeasure(measure, context, patientIds, includeEvaluatedResources);
break;
default:
throw new IllegalStateException("Unsupported measure report type requested: " + type);
}
setReportMeasureToMeasureId(report, measure);
MeasureScoring scoring = MeasureScoring.fromCode(measure.getScoring().getCodingFirstRep().getCode());
switch(scoring) {
case PROPORTION:
case RATIO:
// implement custom logic for CDM care-gaps
Iterator<Measure.MeasureGroupComponent> it = measure.getGroup().iterator();
for (int i = 0; it.hasNext(); i++) {
Measure.MeasureGroupComponent group = it.next();
MeasureReport.MeasureReportGroupComponent reportGroup = report.getGroup().get(i);
boolean evaluateCareGaps = isEligibleForCareGapEvaluation(reportGroup);
for (Measure.MeasureGroupPopulationComponent pop : group.getPopulation()) {
if (pop.getCode().hasCoding(CDMConstants.CDM_CODE_SYSTEM_MEASURE_POPULATION_TYPE, CDMConstants.CARE_GAP)) {
Boolean result = Boolean.FALSE;
if (evaluateCareGaps) {
result = evaluateCriteria(context, pop.getCriteria().getExpression());
}
MeasureReport.MeasureReportGroupPopulationComponent output = new MeasureReport.MeasureReportGroupPopulationComponent();
// need this to differentiate between multiple instances of care-gap
output.setId(pop.getId());
output.setCode(pop.getCode());
output.setCount(result ? 1 : 0);
reportGroup.addPopulation(output);
}
}
}
break;
default:
}
if (context instanceof CDMContext) {
CDMContext defineContext = (CDMContext) context;
// Grab the define results from the expression cache
MeasureEvidenceOptions.DefineReturnOptions defineReturnOptions = (evidenceOptions != null) ? evidenceOptions.getDefineReturnOption() : MeasureEvidenceOptions.DefineReturnOptions.NONE;
addDefineEvaluationToReport(report, defineContext, defineReturnOptions);
}
List<Extension> parameterExtensions = getParameterExtensions(measure, context, parameterMap);
parameterExtensions.forEach(report::addExtension);
return report;
}
use of com.ibm.cohort.engine.measure.evidence.MeasureEvidenceOptions in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method measure_default_invalid_type.
@Test(expected = InvalidOperatorArgument.class)
public void measure_default_invalid_type() throws Exception {
CapabilityStatement metadata = getCapabilityStatement();
mockFhirResourceRetrieval("/metadata?_format=json", metadata);
Patient patient = getPatient("123", AdministrativeGender.MALE, "1970-10-10");
mockFhirResourceRetrieval(patient);
Library library = mockLibraryRetrieval("TestAdultMales", DEFAULT_VERSION, "cql/fhir-measure/test-parameter-defaults.cql");
expressionsByPopulationType.clear();
expressionsByPopulationType.put(MeasurePopulationType.INITIALPOPULATION, INITIAL_POPULATION);
expressionsByPopulationType.put(MeasurePopulationType.DENOMINATOR, DENOMINATOR);
expressionsByPopulationType.put(MeasurePopulationType.NUMERATOR, NUMERATOR);
Measure measure = getProportionMeasure("ProportionMeasureName", library, expressionsByPopulationType);
measure.addExtension(createMeasureParameter("SomeAge", new StringType("invalid")));
mockFhirResourceRetrieval(measure);
evaluator.evaluatePatientMeasure(measure.getId(), patient.getId(), null, new MeasureEvidenceOptions());
}
use of com.ibm.cohort.engine.measure.evidence.MeasureEvidenceOptions in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method in_populations_evaluated_resources_returned.
@Test
public void in_populations_evaluated_resources_returned() throws Exception {
CapabilityStatement metadata = getCapabilityStatement();
mockFhirResourceRetrieval("/metadata?_format=json", metadata);
Patient patient = getPatient("123", AdministrativeGender.MALE, "1970-10-10");
mockFhirResourceRetrieval(patient);
Library library = setupDefineReturnLibrary();
expressionsByPopulationType.clear();
expressionsByPopulationType.put(MeasurePopulationType.INITIALPOPULATION, INITIAL_POPULATION);
expressionsByPopulationType.put(MeasurePopulationType.DENOMINATOR, DENOMINATOR);
expressionsByPopulationType.put(MeasurePopulationType.NUMERATOR, NUMERATOR);
Measure measure = getProportionMeasure("ProportionMeasureName", library, expressionsByPopulationType);
mockFhirResourceRetrieval(measure);
MeasureReport report = evaluator.evaluatePatientMeasure(measure.getId(), patient.getId(), null, new MeasureEvidenceOptions(true, DefineReturnOptions.NONE));
assertNotNull(report);
assertFalse(report.getEvaluatedResource().isEmpty());
assertEquals(null, report.getExtensionByUrl(CDMConstants.EVIDENCE_URL));
}
Aggregations