Search in sources :

Example 11 with Parameter

use of com.ibm.cohort.cql.evaluation.parameters.Parameter in project quality-measure-and-cohort-service by Alvearie.

the class DefaultMeasurementPeriodStrategyTest method parameter_null_map_null__value_is_calulated.

@Test
public void parameter_null_map_null__value_is_calulated() throws Exception {
    Calendar c = Calendar.getInstance();
    c.clear();
    c.set(2020, Calendar.AUGUST, 15);
    Measure measure = new Measure();
    Map<String, Parameter> parameterOverrides = null;
    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()));
}
Also used : Calendar(java.util.Calendar) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) Measure(org.hl7.fhir.r4.model.Measure) DateParameter(com.ibm.cohort.cql.evaluation.parameters.DateParameter) DatetimeParameter(com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) Parameter(com.ibm.cohort.cql.evaluation.parameters.Parameter) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Example 12 with Parameter

use of com.ibm.cohort.cql.evaluation.parameters.Parameter in project quality-measure-and-cohort-service by Alvearie.

the class DefaultMeasurementPeriodStrategyTest method runGetMeasurementPeriodTest.

private void runGetMeasurementPeriodTest(String parameterName, String start, String end) {
    Measure measure = new Measure();
    Map<String, Parameter> parameterOverrides = Collections.singletonMap(parameterName, new IntervalParameter(new DateParameter(start), true, new DateParameter(end), true));
    Pair<String, String> result = new DefaultMeasurementPeriodStrategy().setMeasurementPeriodParameter(parameterName).getMeasurementPeriod(measure, parameterOverrides);
    assertEquals("Unexpected start", result.getLeft(), start);
    assertEquals("Unexpected end", result.getRight(), end);
}
Also used : DateParameter(com.ibm.cohort.cql.evaluation.parameters.DateParameter) Measure(org.hl7.fhir.r4.model.Measure) DateParameter(com.ibm.cohort.cql.evaluation.parameters.DateParameter) DatetimeParameter(com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) Parameter(com.ibm.cohort.cql.evaluation.parameters.Parameter) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter)

Example 13 with Parameter

use of com.ibm.cohort.cql.evaluation.parameters.Parameter in project quality-measure-and-cohort-service by Alvearie.

the class MeasureContextTest method when_invalid_parameters___fails_validation.

@Test
public void when_invalid_parameters___fails_validation() {
    Map<String, Parameter> parameters = new HashMap<>();
    parameters.put("Measurement Period", new IntervalParameter());
    MeasureContext context = new MeasureContext("measureId", parameters);
    Set<ConstraintViolation<MeasureContext>> violations = validator.validate(context);
    printViolations(violations);
    assertEquals(2, violations.size());
}
Also used : HashMap(java.util.HashMap) ConstraintViolation(javax.validation.ConstraintViolation) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) Parameter(com.ibm.cohort.cql.evaluation.parameters.Parameter) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) Test(org.junit.Test)

Example 14 with Parameter

use of com.ibm.cohort.cql.evaluation.parameters.Parameter in project quality-measure-and-cohort-service by Alvearie.

the class MeasureEvaluatorTest method id_based_library_link___successfully_loaded_and_evaluated.

@Test
public void id_based_library_link___successfully_loaded_and_evaluated() throws Exception {
    mockFhirResourceRetrieval("/metadata?_format=json", getCapabilityStatement());
    Patient patient = getPatient("123", AdministrativeGender.MALE, "1970-10-10");
    mockFhirResourceRetrieval(patient);
    Library library = mockLibraryRetrieval("TestDummyPopulations", DEFAULT_VERSION, "cql/fhir-measure/test-dummy-populations.cql");
    Measure measure = getCareGapMeasure("IDBasedLibraryMeasure", library, expressionsByPopulationType, "CareGap1", "CareGap2");
    measure.setLibrary(Arrays.asList(new CanonicalType("Library/" + library.getId())));
    mockFhirResourceRetrieval(measure);
    Map<String, Parameter> passingParameters = new HashMap<>();
    passingParameters.put("InInitialPopulation", new BooleanParameter(true));
    List<MeasureContext> measureContexts = new ArrayList<>();
    measureContexts.add(new MeasureContext(measure.getId(), passingParameters));
    List<MeasureReport> reports = evaluator.evaluatePatientMeasures(patient.getId(), measureContexts);
    assertEquals(1, reports.size());
    MeasureReport report = reports.get(0);
    verifyStandardPopulationCounts(report);
    verify(1, getRequestedFor(urlEqualTo("/Library/" + library.getId() + "?_format=json")));
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Patient(org.hl7.fhir.r4.model.Patient) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) CanonicalType(org.hl7.fhir.r4.model.CanonicalType) BooleanParameter(com.ibm.cohort.cql.evaluation.parameters.BooleanParameter) Measure(org.hl7.fhir.r4.model.Measure) ConceptParameter(com.ibm.cohort.cql.evaluation.parameters.ConceptParameter) RatioParameter(com.ibm.cohort.cql.evaluation.parameters.RatioParameter) IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) DateParameter(com.ibm.cohort.cql.evaluation.parameters.DateParameter) CodeParameter(com.ibm.cohort.cql.evaluation.parameters.CodeParameter) Parameter(com.ibm.cohort.cql.evaluation.parameters.Parameter) DatetimeParameter(com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) DecimalParameter(com.ibm.cohort.cql.evaluation.parameters.DecimalParameter) QuantityParameter(com.ibm.cohort.cql.evaluation.parameters.QuantityParameter) StringParameter(com.ibm.cohort.cql.evaluation.parameters.StringParameter) TimeParameter(com.ibm.cohort.cql.evaluation.parameters.TimeParameter) BooleanParameter(com.ibm.cohort.cql.evaluation.parameters.BooleanParameter) Library(org.hl7.fhir.r4.model.Library) Test(org.junit.Test)

Example 15 with Parameter

use of com.ibm.cohort.cql.evaluation.parameters.Parameter in project quality-measure-and-cohort-service by Alvearie.

the class MeasureEvaluatorTest method multilevel_library_dependencies___successfully_loaded_and_evaluated.

@Test
public void multilevel_library_dependencies___successfully_loaded_and_evaluated() throws Exception {
    mockFhirResourceRetrieval("/metadata?_format=json", getCapabilityStatement());
    Patient patient = getPatient("123", AdministrativeGender.MALE, "1970-10-10");
    mockFhirResourceRetrieval(patient);
    Library nestedHelperLibrary = mockLibraryRetrieval("NestedChild", DEFAULT_VERSION, "cql/fhir-measure-nested-libraries/test-nested-child.cql");
    Library helperLibrary = mockLibraryRetrieval("Child", DEFAULT_VERSION, "cql/fhir-measure-nested-libraries/test-child.cql");
    helperLibrary.addRelatedArtifact(asRelation(nestedHelperLibrary));
    Library library = mockLibraryRetrieval("Parent", DEFAULT_VERSION, "cql/fhir-measure-nested-libraries/test-parent.cql");
    library.addRelatedArtifact(asRelation(helperLibrary));
    Measure measure = getCareGapMeasure("NestedLibraryMeasure", library, expressionsByPopulationType, "CareGap1", "CareGap2");
    mockFhirResourceRetrieval(measure);
    Map<String, Parameter> passingParameters = new HashMap<>();
    passingParameters.put("InInitialPopulation", new BooleanParameter(true));
    List<MeasureContext> measureContexts = new ArrayList<>();
    measureContexts.add(new MeasureContext(measure.getId(), passingParameters));
    List<MeasureReport> reports = evaluator.evaluatePatientMeasures(patient.getId(), measureContexts);
    assertEquals(1, reports.size());
    MeasureReport report = reports.get(0);
    verifyStandardPopulationCounts(report);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Patient(org.hl7.fhir.r4.model.Patient) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) BooleanParameter(com.ibm.cohort.cql.evaluation.parameters.BooleanParameter) Measure(org.hl7.fhir.r4.model.Measure) ConceptParameter(com.ibm.cohort.cql.evaluation.parameters.ConceptParameter) RatioParameter(com.ibm.cohort.cql.evaluation.parameters.RatioParameter) IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) DateParameter(com.ibm.cohort.cql.evaluation.parameters.DateParameter) CodeParameter(com.ibm.cohort.cql.evaluation.parameters.CodeParameter) Parameter(com.ibm.cohort.cql.evaluation.parameters.Parameter) DatetimeParameter(com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) DecimalParameter(com.ibm.cohort.cql.evaluation.parameters.DecimalParameter) QuantityParameter(com.ibm.cohort.cql.evaluation.parameters.QuantityParameter) StringParameter(com.ibm.cohort.cql.evaluation.parameters.StringParameter) TimeParameter(com.ibm.cohort.cql.evaluation.parameters.TimeParameter) BooleanParameter(com.ibm.cohort.cql.evaluation.parameters.BooleanParameter) Library(org.hl7.fhir.r4.model.Library) Test(org.junit.Test)

Aggregations

Parameter (com.ibm.cohort.cql.evaluation.parameters.Parameter)60 Test (org.junit.Test)53 IntervalParameter (com.ibm.cohort.cql.evaluation.parameters.IntervalParameter)52 IntegerParameter (com.ibm.cohort.cql.evaluation.parameters.IntegerParameter)40 HashMap (java.util.HashMap)38 DatetimeParameter (com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter)35 StringParameter (com.ibm.cohort.cql.evaluation.parameters.StringParameter)34 DateParameter (com.ibm.cohort.cql.evaluation.parameters.DateParameter)33 DecimalParameter (com.ibm.cohort.cql.evaluation.parameters.DecimalParameter)32 BooleanParameter (com.ibm.cohort.cql.evaluation.parameters.BooleanParameter)26 CodeParameter (com.ibm.cohort.cql.evaluation.parameters.CodeParameter)26 QuantityParameter (com.ibm.cohort.cql.evaluation.parameters.QuantityParameter)26 TimeParameter (com.ibm.cohort.cql.evaluation.parameters.TimeParameter)26 Measure (org.hl7.fhir.r4.model.Measure)19 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)16 Patient (org.hl7.fhir.r4.model.Patient)15 Library (org.hl7.fhir.r4.model.Library)14 ConceptParameter (com.ibm.cohort.cql.evaluation.parameters.ConceptParameter)12 RatioParameter (com.ibm.cohort.cql.evaluation.parameters.RatioParameter)12 ArrayList (java.util.ArrayList)11