use of com.ibm.cohort.cql.evaluation.parameters.IntervalParameter in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluationTest method when_serialize_deserialize___properties_are_unchanged.
@Test
public void when_serialize_deserialize___properties_are_unchanged() throws Exception {
FhirServerConfig dataServerConfig = new FhirServerConfig();
dataServerConfig.setEndpoint("dataserver");
FhirServerConfig termServerConfig = new FhirServerConfig();
termServerConfig.setEndpoint("termserver");
Map<String, Parameter> parameterOverrides = new HashMap<>();
parameterOverrides.put("Measurement Period", new IntervalParameter(new DateParameter("2019-07-04"), true, new DateParameter("2020-07-04"), true));
MeasureContext ctx = new MeasureContext("measureId", parameterOverrides);
MeasureEvaluation evaluation = new MeasureEvaluation();
evaluation.setDataServerConfig(dataServerConfig);
evaluation.setTerminologyServerConfig(termServerConfig);
evaluation.setPatientId("patientId");
evaluation.setMeasureContext(ctx);
evaluation.setEvidenceOptions(new MeasureEvidenceOptions(false, MeasureEvidenceOptions.DefineReturnOptions.ALL));
ObjectMapper om = new ObjectMapper();
String serialized = om.writeValueAsString(evaluation);
MeasureEvaluation deserialized = om.readValue(serialized, MeasureEvaluation.class);
assertEquals(evaluation, deserialized);
}
use of com.ibm.cohort.cql.evaluation.parameters.IntervalParameter in project quality-measure-and-cohort-service by Alvearie.
the class CohortEvaluationTest method when_serialize_deserialize___properties_are_unchanged.
@Test
public void when_serialize_deserialize___properties_are_unchanged() throws Exception {
FhirServerConfig dataServerConfig = new FhirServerConfig();
dataServerConfig.setEndpoint("dataserver");
FhirServerConfig termServerConfig = new FhirServerConfig();
termServerConfig.setEndpoint("termserver");
Map<String, Parameter> parameterOverrides = new HashMap<>();
parameterOverrides.put("Measurement Period", new IntervalParameter(new DateParameter("2019-07-04"), true, new DateParameter("2020-07-04"), true));
CohortEvaluation evaluation = new CohortEvaluation();
evaluation.setDataServerConfig(dataServerConfig);
evaluation.setTerminologyServerConfig(termServerConfig);
evaluation.setPatientIds("patientId");
evaluation.setParameters(parameterOverrides);
evaluation.setLoggingLevel(CqlDebug.TRACE);
evaluation.setEntrypoint("test-1.0.0.cql");
evaluation.setDefineToRun("fakeDefine");
ObjectMapper om = new ObjectMapper();
String serialized = om.writeValueAsString(evaluation);
CohortEvaluation deserialized = om.readValue(serialized, CohortEvaluation.class);
assertEquals(evaluation, deserialized);
}
use of com.ibm.cohort.cql.evaluation.parameters.IntervalParameter 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.IntervalParameter in project quality-measure-and-cohort-service by Alvearie.
the class DefaultMeasurementPeriodStrategyTest method parameter_not_null_datetime_with_ampersand___value_used.
@Test
public void parameter_not_null_datetime_with_ampersand___value_used() {
Measure measure = new Measure();
Map<String, Parameter> parameterOverrides = Collections.singletonMap(DefaultMeasurementPeriodStrategy.DEFAULT_MEASUREMENT_PERIOD_PARAMETER, new IntervalParameter(new DatetimeParameter("@2020-01-01T00:00:00.0"), true, new DatetimeParameter("@2021-01-01T00:00:00.0"), true));
Pair<String, String> result = new DefaultMeasurementPeriodStrategy().getMeasurementPeriod(measure, parameterOverrides);
assertEquals("Unexpected start", "2020-01-01", result.getLeft());
assertEquals("Unexpected end", "2021-01-01", result.getRight());
}
use of com.ibm.cohort.cql.evaluation.parameters.IntervalParameter in project quality-measure-and-cohort-service by Alvearie.
the class R4ParameterDefinitionWithDefaultToCohortParameterConverterTest method testPeriod__shouldReturnIntervalParameterOfDateTimeParameter.
@Test
public void testPeriod__shouldReturnIntervalParameterOfDateTimeParameter() {
ParameterDefinition parameterDefinition = getBaseParameterDefinition("Period");
Period fhirValue = new Period();
fhirValue.setStartElement(new DateTimeType("2020-01-01T12:00:00.0"));
fhirValue.setEndElement(new DateTimeType("2020-02-04T11:00:00.0-05:00"));
parameterDefinition.addExtension(CDMConstants.PARAMETER_DEFAULT_URL, fhirValue);
IntervalParameter expectedParameter = new IntervalParameter(new DatetimeParameter("2020-01-01T12:00:00.0"), true, new DatetimeParameter("2020-02-04T11:00:00.0-05:00"), true);
assertEquals(expectedParameter, R4ParameterDefinitionWithDefaultToCohortParameterConverter.toCohortParameter(parameterDefinition));
}
Aggregations