use of org.hl7.fhir.r4b.model.Measure in project quality-measure-and-cohort-service by Alvearie.
the class MeasureHelperTest method testResolveByCanonicalUrl.
@Test
public void testResolveByCanonicalUrl() throws Exception {
Measure measure = getCohortMeasure("Test", getLibrary("123", DEFAULT_VERSION, "cql/basic/Test-1.0.0.xml"), "Female");
measure.setUrl("http://fhir.ibm.com/fhir-server/api/v4/Measure/Test-1.0.0");
MappingBuilder builder = get(urlMatching("/Measure\\?url=.*&_format=json"));
mockFhirResourceRetrieval(builder, getBundle(measure));
Measure actual = MeasureHelper.loadMeasure(measure.getUrl(), resolver);
assertNotNull(actual);
assertEquals("Test", actual.getName());
}
use of org.hl7.fhir.r4b.model.Measure in project quality-measure-and-cohort-service by Alvearie.
the class MeasureHelperTest method testResolveByID.
@Test
public void testResolveByID() throws Exception {
Measure measure = getCohortMeasure("Test", getLibrary("123", DEFAULT_VERSION, "cql/basic/Test-1.0.0.xml"), "Female");
mockFhirResourceRetrieval(measure);
Measure actual = MeasureHelper.loadMeasure(measure.getId(), resolver);
assertNotNull(actual);
assertEquals("Test", actual.getName());
}
use of org.hl7.fhir.r4b.model.Measure in project quality-measure-and-cohort-service by Alvearie.
the class MeasureTestBase method getCohortMeasure.
public Measure getCohortMeasure(String measureName, Library library, String expression) throws Exception {
Measure measure = getTemplateMeasure(measureName, library, MeasureScoring.COHORT);
Measure.MeasureGroupComponent group = new Measure.MeasureGroupComponent();
addPopulations(group, Collections.singletonMap(MeasurePopulationType.INITIALPOPULATION, expression));
measure.addGroup(group);
return measure;
}
use of org.hl7.fhir.r4b.model.Measure in project quality-measure-and-cohort-service by Alvearie.
the class MeasureTestBase method getProportionMeasure.
public Measure getProportionMeasure(String measureName, Library library, Map<MeasurePopulationType, String> expressionsByPopType) throws Exception {
Measure measure = getTemplateMeasure(measureName, library, MeasureScoring.PROPORTION);
Measure.MeasureGroupComponent group = new Measure.MeasureGroupComponent();
addPopulations(group, expressionsByPopType);
measure.addGroup(group);
return measure;
}
use of org.hl7.fhir.r4b.model.Measure in project quality-measure-and-cohort-service by Alvearie.
the class CohortEngineRestHandlerTest method testEvaluateMeasureMissingPatient.
@PrepareForTest({ Response.class, TenantManager.class, ServiceBaseUtility.class })
@Test
public void testEvaluateMeasureMissingPatient() throws Exception {
prepMocks();
PowerMockito.mockStatic(ServiceBaseUtility.class);
PowerMockito.when(ServiceBaseUtility.apiSetup(VERSION, logger, MethodNames.EVALUATE_MEASURE.getName())).thenReturn(null);
mockResponseClasses();
Library library = TestHelper.getTemplateLibrary();
Measure measure = TestHelper.getTemplateMeasure(library);
Patient patient = getPatient("patientId", AdministrativeGender.MALE, 40);
mockFhirResourceRetrieval("/metadata?_format=json", getCapabilityStatement());
mockNotFound("/Patient/" + patient.getId() + "\\?_format=json");
FhirServerConfig clientConfig = getFhirServerConfig();
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 measureContext = new MeasureContext(measure.getId(), parameterOverrides);
MeasureEvaluation evaluationRequest = new MeasureEvaluation();
evaluationRequest.setDataServerConfig(clientConfig);
evaluationRequest.setPatientId(patient.getId());
evaluationRequest.setMeasureContext(measureContext);
// evaluationRequest.setEvidenceOptions(evidenceOptions);
FhirContext fhirContext = FhirContext.forR4();
IParser parser = fhirContext.newJsonParser().setPrettyPrint(true);
// Create the metadata part of the request
ObjectMapper om = new ObjectMapper();
String json = om.writeValueAsString(evaluationRequest);
ByteArrayInputStream jsonIs = new ByteArrayInputStream(json.getBytes());
IAttachment rootPart = mockAttachment(jsonIs);
// Create the ZIP part of the request
ByteArrayOutputStream baos = new ByteArrayOutputStream();
TestHelper.createMeasureArtifact(baos, parser, measure, library);
ByteArrayInputStream zipIs = new ByteArrayInputStream(baos.toByteArray());
IAttachment measurePart = mockAttachment(zipIs);
// Assemble them together into a reasonable facsimile of the real request
IMultipartBody body = mock(IMultipartBody.class);
when(body.getAttachment(CohortEngineRestHandler.REQUEST_DATA_PART)).thenReturn(rootPart);
when(body.getAttachment(CohortEngineRestHandler.MEASURE_PART)).thenReturn(measurePart);
Response loadResponse = restHandler.evaluateMeasure(mockRequestContext, VERSION, body);
assertNotNull(loadResponse);
PowerMockito.verifyStatic(Response.class);
Response.status(400);
}
Aggregations