Search in sources :

Example 1 with Identifier

use of com.ibm.cohort.engine.measure.Identifier in project quality-measure-and-cohort-service by Alvearie.

the class MeasureContextProvider method getMeasureContexts.

public static List<MeasureContext> getMeasureContexts(File input) throws IOException {
    ObjectMapper objectMapper = new ObjectMapper();
    ExecutionConfiguration parsedInput = objectMapper.readValue(input, ExecutionConfiguration.class);
    // Throws an exception if invalid input is encountered
    parsedInput.validate();
    return parsedInput.getMeasureConfigurations().stream().map(x -> {
        MeasureIdentifier measureIdentifier = x.getIdentifier();
        Identifier identifier = null;
        if (measureIdentifier != null) {
            identifier = new Identifier(measureIdentifier.getSystem(), measureIdentifier.getValue());
        }
        return new MeasureContext(x.getMeasureId(), x.getParameters(), identifier, x.getVersion());
    }).collect(Collectors.toList());
}
Also used : List(java.util.List) Map(java.util.Map) Identifier(com.ibm.cohort.engine.measure.Identifier) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) MeasureContext(com.ibm.cohort.engine.measure.MeasureContext) Collections(java.util.Collections) Collectors(java.util.stream.Collectors) File(java.io.File) Parameter(com.ibm.cohort.cql.evaluation.parameters.Parameter) ParameterHelper(com.ibm.cohort.cli.ParameterHelper) MeasureContext(com.ibm.cohort.engine.measure.MeasureContext) Identifier(com.ibm.cohort.engine.measure.Identifier) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with Identifier

use of com.ibm.cohort.engine.measure.Identifier in project quality-measure-and-cohort-service by Alvearie.

the class CohortEngineRestHandlerTest method testEvaluateMeasureMoreThanOneFormOfId.

@PrepareForTest({ Response.class, TenantManager.class, ServiceBaseUtility.class })
@Test
public void testEvaluateMeasureMoreThanOneFormOfId() 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", getCapabilityStatement());
    mockFhirResourceRetrieval(patient);
    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, new Identifier().setValue("identifier"));
    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);
}
Also used : FhirContext(ca.uhn.fhir.context.FhirContext) HashMap(java.util.HashMap) MeasureEvaluation(com.ibm.cohort.engine.api.service.model.MeasureEvaluation) PatientListMeasureEvaluation(com.ibm.cohort.engine.api.service.model.PatientListMeasureEvaluation) Patient(org.hl7.fhir.r4.model.Patient) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IAttachment(com.ibm.websphere.jaxrs20.multipart.IAttachment) Response(javax.ws.rs.core.Response) MeasureContext(com.ibm.cohort.engine.measure.MeasureContext) IMultipartBody(com.ibm.websphere.jaxrs20.multipart.IMultipartBody) DateParameter(com.ibm.cohort.cql.evaluation.parameters.DateParameter) Identifier(com.ibm.cohort.engine.measure.Identifier) ByteArrayInputStream(java.io.ByteArrayInputStream) Measure(org.hl7.fhir.r4.model.Measure) DateParameter(com.ibm.cohort.cql.evaluation.parameters.DateParameter) Parameter(com.ibm.cohort.cql.evaluation.parameters.Parameter) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) FhirServerConfig(com.ibm.cohort.fhir.client.config.FhirServerConfig) Library(org.hl7.fhir.r4.model.Library) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IParser(ca.uhn.fhir.parser.IParser) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Parameter (com.ibm.cohort.cql.evaluation.parameters.Parameter)2 Identifier (com.ibm.cohort.engine.measure.Identifier)2 MeasureContext (com.ibm.cohort.engine.measure.MeasureContext)2 FhirContext (ca.uhn.fhir.context.FhirContext)1 IParser (ca.uhn.fhir.parser.IParser)1 ParameterHelper (com.ibm.cohort.cli.ParameterHelper)1 DateParameter (com.ibm.cohort.cql.evaluation.parameters.DateParameter)1 IntervalParameter (com.ibm.cohort.cql.evaluation.parameters.IntervalParameter)1 MeasureEvaluation (com.ibm.cohort.engine.api.service.model.MeasureEvaluation)1 PatientListMeasureEvaluation (com.ibm.cohort.engine.api.service.model.PatientListMeasureEvaluation)1 FhirServerConfig (com.ibm.cohort.fhir.client.config.FhirServerConfig)1 IAttachment (com.ibm.websphere.jaxrs20.multipart.IAttachment)1 IMultipartBody (com.ibm.websphere.jaxrs20.multipart.IMultipartBody)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 IOException (java.io.IOException)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1