use of com.ibm.cohort.cql.evaluation.parameters.Parameter in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method in_denominator_and_denominator_exclusions___caregaps_evaluated_correctly.
@Test
public void in_denominator_and_denominator_exclusions___caregaps_evaluated_correctly() throws Exception {
Map<String, Parameter> parameters = new HashMap<>();
parameters.put("InDenominator", new BooleanParameter(true));
parameters.put("InDenominatorExclusion", new BooleanParameter(true));
expectationsByPopulationType.put(MeasurePopulationType.DENOMINATOR, 0);
expectationsByPopulationType.put(MeasurePopulationType.DENOMINATOREXCLUSION, 1);
Map<String, Integer> expectationsByCareGap = new HashMap<>();
expectationsByCareGap.put("CareGap1", 0);
expectationsByCareGap.put("CareGap2", 0);
runCareGapTest(parameters, expectationsByCareGap);
}
use of com.ibm.cohort.cql.evaluation.parameters.Parameter in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method measure_report_generated___named_parameters_on_measure_report.
@Test
public void measure_report_generated___named_parameters_on_measure_report() throws Exception {
CapabilityStatement metadata = getCapabilityStatement();
mockFhirResourceRetrieval("/metadata?_format=json", metadata);
Patient patient = getPatient("123", AdministrativeGender.MALE, "1970-10-10");
mockFhirResourceRetrieval(patient);
Library library = mockLibraryRetrieval("TestDummyPopulations", DEFAULT_VERSION, "cql/fhir-measure/test-dummy-populations.xml", ELM_MIME_TYPE);
Measure measure = getCohortMeasure("CohortMeasureName", library, INITIAL_POPULATION);
mockFhirResourceRetrieval(measure);
Map<String, Parameter> parameterMap = new HashMap<>();
parameterMap.put("integerParam", new IntegerParameter(1));
parameterMap.put("decimalParam", new DecimalParameter("1.0"));
parameterMap.put("stringParam", new StringParameter("1"));
parameterMap.put("booleanParam", new BooleanParameter(false));
parameterMap.put("datetimeParam", new DatetimeParameter("2020-01-01"));
parameterMap.put("dateParam", new DateParameter("2020-01-01"));
parameterMap.put("timeParam", new TimeParameter("01:00:00"));
parameterMap.put("quantityParam", new QuantityParameter("1.0", "ml"));
parameterMap.put("ratioParam", new RatioParameter(new QuantityParameter("1.0", "ml"), new QuantityParameter("2.0", "ml")));
parameterMap.put("codeParam", new CodeParameter("1", "2", "3", "4"));
parameterMap.put("conceptParam", new ConceptParameter("1", new CodeParameter("1", "2", "3", "4")));
parameterMap.put("datetimeIntervalParam", new IntervalParameter(new DatetimeParameter("2020-01-01"), true, new DatetimeParameter("2021-01-01"), true));
parameterMap.put("quantityIntervalParam", new IntervalParameter(new QuantityParameter("1.0", "ml"), true, new QuantityParameter("2.0", "ml"), true));
MeasureReport report = evaluator.evaluatePatientMeasure(measure.getId(), patient.getId(), parameterMap);
assertNotNull(report);
List<String> parameterNames = report.getExtension().stream().filter(x -> x.getUrl().equals(MEASURE_PARAMETER_VALUE_URL)).map(x -> (ParameterDefinition) x.getValue()).map(ParameterDefinition::getName).collect(Collectors.toList());
// Expected parameters are the ones listed above, plus the special parameters
// measurement period and product line
assertEquals(parameterMap.size() + 2, parameterNames.size());
assertTrue(parameterNames.containsAll(parameterMap.keySet()));
assertTrue(parameterNames.contains(CDMConstants.MEASUREMENT_PERIOD));
assertTrue(parameterNames.contains(CDMConstants.PRODUCT_LINE));
}
use of com.ibm.cohort.cql.evaluation.parameters.Parameter in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method not_in_initial_population___caregaps_evaluated_correctly.
@Test
public void not_in_initial_population___caregaps_evaluated_correctly() throws Exception {
Map<String, Parameter> parameters = new HashMap<>();
parameters.put("InInitialPopulation", new BooleanParameter(false));
expectationsByPopulationType.put(MeasurePopulationType.INITIALPOPULATION, 0);
expectationsByPopulationType.put(MeasurePopulationType.DENOMINATOR, 0);
Map<String, Integer> expectationsByCareGap = new HashMap<>();
expectationsByCareGap.put("CareGap1", 0);
expectationsByCareGap.put("CareGap2", 0);
runCareGapTest(parameters, expectationsByCareGap);
}
use of com.ibm.cohort.cql.evaluation.parameters.Parameter in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method measure_report_generated___java_overrides_overwrite_measure_params.
@Test
public void measure_report_generated___java_overrides_overwrite_measure_params() throws Exception {
CapabilityStatement metadata = getCapabilityStatement();
mockFhirResourceRetrieval("/metadata?_format=json", metadata);
Patient patient = getPatient("123", AdministrativeGender.MALE, "1970-10-10");
mockFhirResourceRetrieval(patient);
Library library = mockLibraryRetrieval("TestDummyPopulations", DEFAULT_VERSION, "cql/fhir-measure/test-dummy-populations.xml", ELM_MIME_TYPE);
Measure measure = getCohortMeasure("CohortMeasureName", library, INITIAL_POPULATION);
String duplicateParamName = "duplicateParam";
int fhirMeasureIntValue = 10;
int javaParameterIntValue = 99;
measure.addExtension(createParameterExtension(duplicateParamName, new IntegerType(fhirMeasureIntValue)));
mockFhirResourceRetrieval(measure);
Map<String, Parameter> parameterMap = new HashMap<>();
parameterMap.put(duplicateParamName, new IntegerParameter(javaParameterIntValue));
MeasureReport report = evaluator.evaluatePatientMeasure(measure.getId(), patient.getId(), parameterMap);
assertNotNull(report);
// Make sure report only contained one entry for the duplicate parameter
List<Type> filteredReportParams = report.getExtension().stream().filter(x -> x.getUrl().equals(MEASURE_PARAMETER_VALUE_URL)).map(x -> (ParameterDefinition) x.getValue()).filter(x -> x.getName().equals(duplicateParamName)).map(x -> x.getExtensionByUrl(PARAMETER_VALUE_URL).getValue()).collect(Collectors.toList());
assertEquals(1, filteredReportParams.size());
// Sanity check input parameter values were different before checking for correct value
assertNotEquals(fhirMeasureIntValue, javaParameterIntValue);
assertEquals(javaParameterIntValue, ((IntegerType) filteredReportParams.get(0)).getValue().intValue());
}
use of com.ibm.cohort.cql.evaluation.parameters.Parameter in project quality-measure-and-cohort-service by Alvearie.
the class DefaultMeasurementPeriodStrategyTest method paramter_null___value_is_calulated.
@Test
public void paramter_null___value_is_calulated() throws Exception {
Calendar c = Calendar.getInstance();
c.clear();
c.set(2020, Calendar.OCTOBER, 20);
Measure measure = new Measure();
Map<String, Parameter> parameterOverrides = Collections.emptyMap();
Pair<String, String> result = new DefaultMeasurementPeriodStrategy().setNow(c.getTime()).getMeasurementPeriod(measure, parameterOverrides);
DateFormat sdf = new SimpleDateFormat(DefaultMeasurementPeriodStrategy.TARGET_DATE_FORMAT);
assertEquals("Unexpected end", result.getRight(), sdf.format(c.getTime()));
}
Aggregations