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());
}
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);
}
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());
}
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;
}
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());
}
Aggregations