Search in sources :

Example 61 with FhirServerConfig

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

the class ValueSetImporterTest method testImportAllExistingResources.

@Test
public void testImportAllExistingResources() throws IOException {
    FhirServerConfig fhirConfig = getFhirServerConfig();
    fhirConfig.setLogInfo(Collections.singletonList(FhirServerConfig.LogInfo.REQUEST_SUMMARY));
    mockFhirResourceRetrieval("/metadata?_format=json", getCapabilityStatement());
    Bundle oneResult = new Bundle();
    Bundle.BundleEntryComponent entryComponent = new Bundle.BundleEntryComponent();
    ValueSet set = new ValueSet();
    String url = "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1114.7";
    set.setUrl(url);
    entryComponent.setFullUrl(url);
    entryComponent.setResource(set);
    oneResult.addEntry(entryComponent);
    mockFhirResourceRetrieval(resourcePath, oneResult);
    runTest(fhirConfig, defaultInputFile);
    verify(1, getRequestedFor(urlEqualTo(resourcePath)));
    verify(exactly(0), postRequestedFor(urlEqualTo("/ValueSet?_format=json")));
}
Also used : Bundle(org.hl7.fhir.r4.model.Bundle) FhirServerConfig(com.ibm.cohort.fhir.client.config.FhirServerConfig) ValueSet(org.hl7.fhir.r4.model.ValueSet) Test(org.junit.Test)

Example 62 with FhirServerConfig

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

the class ValueSetImporterTest method testImportAllNewResources.

@Test
public void testImportAllNewResources() throws IOException {
    FhirServerConfig fhirConfig = getFhirServerConfig();
    fhirConfig.setLogInfo(Collections.singletonList(FhirServerConfig.LogInfo.REQUEST_SUMMARY));
    mockFhirResourceRetrieval("/metadata?_format=json", getCapabilityStatement());
    String valueSetId = UUID.randomUUID().toString();
    Bundle noResults = new Bundle();
    mockFhirResourceRetrieval(resourcePath, noResults);
    mockFhirResourcePost("/ValueSet?_format=json", valueSetId, "1");
    runTest(fhirConfig, defaultInputFile);
    verify(1, postRequestedFor(urlEqualTo("/ValueSet?_format=json")));
}
Also used : Bundle(org.hl7.fhir.r4.model.Bundle) FhirServerConfig(com.ibm.cohort.fhir.client.config.FhirServerConfig) Test(org.junit.Test)

Example 63 with FhirServerConfig

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

the class ValueSetImporterTest method testImportAllNewResourcesWithComments.

@Test
public void testImportAllNewResourcesWithComments() throws IOException {
    FhirServerConfig fhirConfig = getFhirServerConfig();
    fhirConfig.setLogInfo(Collections.singletonList(FhirServerConfig.LogInfo.REQUEST_SUMMARY));
    mockFhirResourceRetrieval("/metadata?_format=json", getCapabilityStatement());
    String valueSetId = UUID.randomUUID().toString();
    Bundle noResults = new Bundle();
    mockFhirResourceRetrieval(resourcePath, noResults);
    mockFhirResourcePost("/ValueSet?_format=json", valueSetId, "1");
    String inputFile = "src/test/resources/2.16.840.1.113762.1.4.1114.7-Comments.xlsx";
    runTest(fhirConfig, inputFile);
    verify(1, postRequestedFor(urlEqualTo("/ValueSet?_format=json")));
}
Also used : Bundle(org.hl7.fhir.r4.model.Bundle) 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