Search in sources :

Example 46 with FhirServerConfig

use of com.ibm.cohort.fhir.client.config.FhirServerConfig in project quality-measure-and-cohort-service by Alvearie.

the class MeasureEvaluationTest method when_serialize_deserialize___properties_are_unchanged.

@Test
public void when_serialize_deserialize___properties_are_unchanged() throws Exception {
    FhirServerConfig dataServerConfig = new FhirServerConfig();
    dataServerConfig.setEndpoint("dataserver");
    FhirServerConfig termServerConfig = new FhirServerConfig();
    termServerConfig.setEndpoint("termserver");
    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 ctx = new MeasureContext("measureId", parameterOverrides);
    MeasureEvaluation evaluation = new MeasureEvaluation();
    evaluation.setDataServerConfig(dataServerConfig);
    evaluation.setTerminologyServerConfig(termServerConfig);
    evaluation.setPatientId("patientId");
    evaluation.setMeasureContext(ctx);
    evaluation.setEvidenceOptions(new MeasureEvidenceOptions(false, MeasureEvidenceOptions.DefineReturnOptions.ALL));
    ObjectMapper om = new ObjectMapper();
    String serialized = om.writeValueAsString(evaluation);
    MeasureEvaluation deserialized = om.readValue(serialized, MeasureEvaluation.class);
    assertEquals(evaluation, deserialized);
}
Also used : MeasureContext(com.ibm.cohort.engine.measure.MeasureContext) DateParameter(com.ibm.cohort.cql.evaluation.parameters.DateParameter) HashMap(java.util.HashMap) DateParameter(com.ibm.cohort.cql.evaluation.parameters.DateParameter) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) Parameter(com.ibm.cohort.cql.evaluation.parameters.Parameter) FhirServerConfig(com.ibm.cohort.fhir.client.config.FhirServerConfig) MeasureEvidenceOptions(com.ibm.cohort.engine.measure.evidence.MeasureEvidenceOptions) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 47 with FhirServerConfig

use of com.ibm.cohort.fhir.client.config.FhirServerConfig in project quality-measure-and-cohort-service by Alvearie.

the class CohortEvaluationTest method when_serialize_deserialize___properties_are_unchanged.

@Test
public void when_serialize_deserialize___properties_are_unchanged() throws Exception {
    FhirServerConfig dataServerConfig = new FhirServerConfig();
    dataServerConfig.setEndpoint("dataserver");
    FhirServerConfig termServerConfig = new FhirServerConfig();
    termServerConfig.setEndpoint("termserver");
    Map<String, Parameter> parameterOverrides = new HashMap<>();
    parameterOverrides.put("Measurement Period", new IntervalParameter(new DateParameter("2019-07-04"), true, new DateParameter("2020-07-04"), true));
    CohortEvaluation evaluation = new CohortEvaluation();
    evaluation.setDataServerConfig(dataServerConfig);
    evaluation.setTerminologyServerConfig(termServerConfig);
    evaluation.setPatientIds("patientId");
    evaluation.setParameters(parameterOverrides);
    evaluation.setLoggingLevel(CqlDebug.TRACE);
    evaluation.setEntrypoint("test-1.0.0.cql");
    evaluation.setDefineToRun("fakeDefine");
    ObjectMapper om = new ObjectMapper();
    String serialized = om.writeValueAsString(evaluation);
    CohortEvaluation deserialized = om.readValue(serialized, CohortEvaluation.class);
    assertEquals(evaluation, deserialized);
}
Also used : DateParameter(com.ibm.cohort.cql.evaluation.parameters.DateParameter) HashMap(java.util.HashMap) DateParameter(com.ibm.cohort.cql.evaluation.parameters.DateParameter) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) Parameter(com.ibm.cohort.cql.evaluation.parameters.Parameter) FhirServerConfig(com.ibm.cohort.fhir.client.config.FhirServerConfig) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 48 with FhirServerConfig

use of com.ibm.cohort.fhir.client.config.FhirServerConfig in project quality-measure-and-cohort-service by Alvearie.

the class EnhancedHealthCheckInputTest method when_serialize_deserialize___properties_are_unchanged.

@Test
public void when_serialize_deserialize___properties_are_unchanged() throws Exception {
    FhirServerConfig dataServerConfig = new FhirServerConfig();
    dataServerConfig.setEndpoint("dataserver");
    FhirServerConfig termServerConfig = new FhirServerConfig();
    termServerConfig.setEndpoint("termserver");
    EnhancedHealthCheckInput input = new EnhancedHealthCheckInput();
    input.setDataServerConfig(dataServerConfig);
    input.setTerminologyServerConfig(termServerConfig);
    ObjectMapper om = new ObjectMapper();
    String serialized = om.writeValueAsString(input);
    EnhancedHealthCheckInput deserialized = om.readValue(serialized, EnhancedHealthCheckInput.class);
    assertEquals(input, deserialized);
}
Also used : FhirServerConfig(com.ibm.cohort.fhir.client.config.FhirServerConfig) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 49 with FhirServerConfig

use of com.ibm.cohort.fhir.client.config.FhirServerConfig in project quality-measure-and-cohort-service by Alvearie.

the class EnhancedHealthCheckResultsTest method when_serialize_deserialize___properties_are_unchanged.

@Test
public void when_serialize_deserialize___properties_are_unchanged() throws Exception {
    FhirServerConfig dataServerConfig = new FhirServerConfig();
    dataServerConfig.setEndpoint("dataserver");
    FhirServerConfig termServerConfig = new FhirServerConfig();
    termServerConfig.setEndpoint("termserver");
    EnhancedHealthCheckResults results = new EnhancedHealthCheckResults();
    FhirServerConnectionStatusInfo dataServerConnectionResults = new FhirServerConnectionStatusInfo();
    dataServerConnectionResults.setServerConfigType(FhirServerConfigType.dataServerConfig);
    dataServerConnectionResults.setConnectionResults(FhirConnectionStatus.notAttempted);
    FhirServerConnectionStatusInfo terminologyServerConnectionResults = new FhirServerConnectionStatusInfo();
    terminologyServerConnectionResults.setServerConfigType(FhirServerConfigType.terminologyServerConfig);
    terminologyServerConnectionResults.setConnectionResults(FhirConnectionStatus.notAttempted);
    results.setDataServerConnectionResults(dataServerConnectionResults);
    results.setTerminologyServerConnectionResults(terminologyServerConnectionResults);
    ObjectMapper om = new ObjectMapper();
    String serialized = om.writeValueAsString(results);
    EnhancedHealthCheckResults deserialized = om.readValue(serialized, EnhancedHealthCheckResults.class);
    assertEquals(results, deserialized);
}
Also used : FhirServerConfig(com.ibm.cohort.fhir.client.config.FhirServerConfig) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 50 with FhirServerConfig

use of com.ibm.cohort.fhir.client.config.FhirServerConfig in project quality-measure-and-cohort-service by Alvearie.

the class FhirClientTimeoutTest method testFhirClientContext_requestTimesOut.

@Test(expected = FhirClientConnectionException.class)
public void testFhirClientContext_requestTimesOut() {
    FhirServerConfig fhirServerConfig = getFhirServerConfig();
    fhirServerConfig.setSocketTimeout(CONFIG_TIMEOUT_MILLIS);
    FHIRClientContext fhirClientContext = new FHIRClientContext.Builder().withDefaultClient(fhirServerConfig).build();
    fhirClientContext.getDataClient().read().resource(Patient.class).withId(PATIENT_ID).execute();
}
Also used : DefaultFhirClientBuilder(com.ibm.cohort.fhir.client.config.DefaultFhirClientBuilder) FhirServerConfig(com.ibm.cohort.fhir.client.config.FhirServerConfig) Test(org.junit.Test)

Aggregations

FhirServerConfig (com.ibm.cohort.fhir.client.config.FhirServerConfig)63 Test (org.junit.Test)52 Patient (org.hl7.fhir.r4.model.Patient)39 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)36 ByteArrayOutputStream (java.io.ByteArrayOutputStream)22 HashMap (java.util.HashMap)21 File (java.io.File)18 IAttachment (com.ibm.websphere.jaxrs20.multipart.IAttachment)15 Response (javax.ws.rs.core.Response)15 CqlEvaluator (com.ibm.cohort.cql.evaluation.CqlEvaluator)14 CqlVersionedIdentifier (com.ibm.cohort.cql.library.CqlVersionedIdentifier)14 FileWriter (java.io.FileWriter)14 CqlEvaluationResult (com.ibm.cohort.cql.evaluation.CqlEvaluationResult)13 PrintStream (java.io.PrintStream)13 Writer (java.io.Writer)13 ByteArrayInputStream (java.io.ByteArrayInputStream)11 IGenericClient (ca.uhn.fhir.rest.client.api.IGenericClient)10 IMultipartBody (com.ibm.websphere.jaxrs20.multipart.IMultipartBody)10 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)10 IParser (ca.uhn.fhir.parser.IParser)9