Search in sources :

Example 66 with Measure

use of org.hl7.fhir.r4b.model.Measure in project quality-measure-and-cohort-service by Alvearie.

the class RestFhirMeasureResolverIntegrationTest method resolve_by_url_without_version___returns_newest_semver.

@Test
public void resolve_by_url_without_version___returns_newest_semver() throws Exception {
    String measureName = "Measure1";
    mockMultipleSearchResults(measureName, "1.0.0", "1.1.0");
    Measure resolved = resolver.resolveByCanonicalUrl(getUrlForName(measureName));
    assertEquals("1.1.0", resolved.getVersion());
}
Also used : Measure(org.hl7.fhir.r4.model.Measure) Test(org.junit.Test)

Example 67 with Measure

use of org.hl7.fhir.r4b.model.Measure in project quality-measure-and-cohort-service by Alvearie.

the class MeasureEvaluationSeederTest method create_noLibraryOnMeasure.

@Test(expected = IllegalArgumentException.class)
public void create_noLibraryOnMeasure() {
    Measure measure = createMeasure();
    FhirResourceResolver<Library> libraryResolver = Mockito.mock(FhirResourceResolver.class);
    R4LibraryDependencyGatherer dependencyGatherer = Mockito.mock(R4LibraryDependencyGatherer.class);
    Mockito.when(dependencyGatherer.gatherForMeasure(measure)).thenReturn(Collections.emptyList());
    MeasureEvaluationSeeder seeder = new MeasureEvaluationSeeder(null, null, dependencyGatherer, libraryResolver);
    seeder.create(measure, periodStart, periodEnd, null, null);
}
Also used : Measure(org.hl7.fhir.r4.model.Measure) R4LibraryDependencyGatherer(com.ibm.cohort.cql.hapi.R4LibraryDependencyGatherer) Library(org.hl7.fhir.r4.model.Library) Test(org.junit.Test)

Example 68 with Measure

use of org.hl7.fhir.r4b.model.Measure in project quality-measure-and-cohort-service by Alvearie.

the class MeasureEvaluationSeederTest method create_fullContext.

@Test
public void create_fullContext() throws IOException {
    TerminologyProvider terminologyProvider = Mockito.mock(TerminologyProvider.class);
    CqlDataProvider dataProvider = Mockito.mock(CqlDataProvider.class);
    Map<String, CqlDataProvider> dataProviders = new HashMap<>();
    dataProviders.put(fhirUri, dataProvider);
    Measure measure = createMeasure();
    Library library = createLibrary("/cql/seeder/Test-1.0.0.xml");
    FhirResourceResolver<Library> libraryResolver = Mockito.mock(FhirResourceResolver.class);
    Mockito.when(libraryResolver.resolveByName(libraryName, libraryVersion)).thenReturn(library);
    R4LibraryDependencyGatherer dependencyGatherer = Mockito.mock(R4LibraryDependencyGatherer.class);
    Mockito.when(dependencyGatherer.gatherForMeasure(measure)).thenReturn(Collections.singletonList(library));
    MeasureEvaluationSeeder seeder = new MeasureEvaluationSeeder(terminologyProvider, dataProviders, dependencyGatherer, libraryResolver);
    seeder.enableExpressionCaching();
    IMeasureEvaluationSeed actual = seeder.create(measure, periodStart, periodEnd, productLine, null);
    Interval expectedInterval = createInterval();
    Assert.assertEquals(0, expectedInterval.compareTo(actual.getMeasurementPeriod()));
    Assert.assertSame(measure, actual.getMeasure());
    Assert.assertSame(dataProvider, actual.getDataProvider());
    // Attempt to validate the `Context` by looking for key fields under our control.
    Assert.assertSame(terminologyProvider, actual.getContext().resolveTerminologyProvider());
    Assert.assertEquals(productLine, actual.getContext().resolveParameterRef(null, "Product Line"));
    Assert.assertTrue(actual.getContext().isExpressionCachingEnabled());
    Assert.assertNotNull(actual.getContext().getDebugMap());
}
Also used : TerminologyProvider(org.opencds.cqf.cql.engine.terminology.TerminologyProvider) HashMap(java.util.HashMap) Measure(org.hl7.fhir.r4.model.Measure) R4LibraryDependencyGatherer(com.ibm.cohort.cql.hapi.R4LibraryDependencyGatherer) Library(org.hl7.fhir.r4.model.Library) CqlDataProvider(com.ibm.cohort.cql.data.CqlDataProvider) Interval(org.opencds.cqf.cql.engine.runtime.Interval) Test(org.junit.Test)

Example 69 with Measure

use of org.hl7.fhir.r4b.model.Measure in project quality-measure-and-cohort-service by Alvearie.

the class MeasureEvaluationSeederTest method createMeasure.

private Measure createMeasure() {
    CanonicalType libraryRef = new CanonicalType();
    libraryRef.setValue(libraryUrl);
    Measure measure = new Measure();
    measure.setLibrary(Collections.singletonList(libraryRef));
    return measure;
}
Also used : Measure(org.hl7.fhir.r4.model.Measure) CanonicalType(org.hl7.fhir.r4.model.CanonicalType)

Example 70 with Measure

use of org.hl7.fhir.r4b.model.Measure in project quality-measure-and-cohort-service by Alvearie.

the class MeasureEvaluationSeederTest method create_minimalContext.

@Test
public void create_minimalContext() throws IOException {
    TerminologyProvider terminologyProvider = Mockito.mock(TerminologyProvider.class);
    CqlDataProvider dataProvider = Mockito.mock(CqlDataProvider.class);
    Map<String, CqlDataProvider> dataProviders = new HashMap<>();
    dataProviders.put(fhirUri, dataProvider);
    Library library = createLibrary("/cql/seeder/Test-1.0.0.xml");
    FhirResourceResolver<Library> libraryResolver = Mockito.mock(FhirResourceResolver.class);
    Mockito.when(libraryResolver.resolveByName(libraryName, libraryVersion)).thenReturn(library);
    Measure measure = createMeasure();
    R4LibraryDependencyGatherer dependencyGatherer = Mockito.mock(R4LibraryDependencyGatherer.class);
    Mockito.when(dependencyGatherer.gatherForMeasure(measure)).thenReturn(Collections.singletonList(library));
    MeasureEvaluationSeeder seeder = new MeasureEvaluationSeeder(terminologyProvider, dataProviders, dependencyGatherer, libraryResolver);
    seeder.disableDebugLogging();
    IMeasureEvaluationSeed actual = seeder.create(measure, periodStart, periodEnd, null, null);
    Interval expectedInterval = createInterval();
    Assert.assertEquals(0, expectedInterval.compareTo(actual.getMeasurementPeriod()));
    Assert.assertSame(measure, actual.getMeasure());
    Assert.assertSame(dataProvider, actual.getDataProvider());
    // Attempt to validate the `Context` by looking for key fields under our control.
    Assert.assertSame(terminologyProvider, actual.getContext().resolveTerminologyProvider());
    Assert.assertThrows(NullPointerException.class, () -> actual.getContext().resolveParameterRef(null, "Product Line"));
    Assert.assertFalse(actual.getContext().isExpressionCachingEnabled());
    Assert.assertNull(actual.getContext().getDebugMap());
}
Also used : TerminologyProvider(org.opencds.cqf.cql.engine.terminology.TerminologyProvider) HashMap(java.util.HashMap) Measure(org.hl7.fhir.r4.model.Measure) R4LibraryDependencyGatherer(com.ibm.cohort.cql.hapi.R4LibraryDependencyGatherer) Library(org.hl7.fhir.r4.model.Library) CqlDataProvider(com.ibm.cohort.cql.data.CqlDataProvider) Interval(org.opencds.cqf.cql.engine.runtime.Interval) Test(org.junit.Test)

Aggregations

Measure (org.hl7.fhir.r4.model.Measure)119 Test (org.junit.Test)97 Library (org.hl7.fhir.r4.model.Library)61 Patient (org.hl7.fhir.r4.model.Patient)45 MeasureReport (org.hl7.fhir.r4.model.MeasureReport)44 HashMap (java.util.HashMap)24 ArrayList (java.util.ArrayList)23 DateParameter (com.ibm.cohort.cql.evaluation.parameters.DateParameter)22 IntervalParameter (com.ibm.cohort.cql.evaluation.parameters.IntervalParameter)22 Parameter (com.ibm.cohort.cql.evaluation.parameters.Parameter)22 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)21 ByteArrayOutputStream (java.io.ByteArrayOutputStream)21 MeasureEvidenceOptions (com.ibm.cohort.engine.measure.evidence.MeasureEvidenceOptions)20 CapabilityStatement (org.hl7.fhir.r4.model.CapabilityStatement)20 Test (org.junit.jupiter.api.Test)18 Extension (org.hl7.fhir.r4.model.Extension)15 StringType (org.hl7.fhir.r4.model.StringType)15 DatetimeParameter (com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter)14 CanonicalType (org.hl7.fhir.r4.model.CanonicalType)14 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)14