Search in sources :

Example 66 with Endpoint

use of org.hl7.fhir.r4.model.Endpoint in project cqf-ruler by DBCG.

the class CacheValueSetsProviderIT method uploadLocalServerEndpoint.

private Endpoint uploadLocalServerEndpoint() throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(CacheValueSetsProvider.class.getResourceAsStream("endpoint/LocalServerEndpoint.json")));
    String resourceString = reader.lines().collect(Collectors.joining(System.lineSeparator()));
    reader.close();
    // Don't want to update during loading because need to setAddress first
    Endpoint endpoint = (Endpoint) loadResource("json", resourceString);
    endpoint.setAddress("http://localhost:" + getPort() + "/fhir/");
    update(endpoint);
    return endpoint;
}
Also used : InputStreamReader(java.io.InputStreamReader) Endpoint(org.hl7.fhir.r4.model.Endpoint) BufferedReader(java.io.BufferedReader)

Example 67 with Endpoint

use of org.hl7.fhir.r4.model.Endpoint in project cqf-ruler by DBCG.

the class CacheValueSetsProviderIT method testCacheValueSetsAuthenticationErrorPassword.

@Test
public void testCacheValueSetsAuthenticationErrorPassword() throws Exception {
    Endpoint endpoint = uploadLocalServerEndpoint();
    StringAndListParam stringAndListParam = getStringAndListParamFromValueSet("valueset/AcuteInpatient.json");
    RequestDetails details = Mockito.mock(RequestDetails.class);
    Resource outcomeResource = cacheValueSetsProvider.cacheValuesets(details, endpoint.getIdElement(), stringAndListParam, null, "password");
    String detailMessage = "Password was provided, but not a user name.";
    validateOutcome(outcomeResource, detailMessage);
}
Also used : Endpoint(org.hl7.fhir.r4.model.Endpoint) StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) Resource(org.hl7.fhir.r4.model.Resource) RequestDetails(ca.uhn.fhir.rest.api.server.RequestDetails) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Example 68 with Endpoint

use of org.hl7.fhir.r4.model.Endpoint in project cqf-ruler by DBCG.

the class CacheValueSetsProviderIT method testCacheValueSetsNoCompose.

@Test
public void testCacheValueSetsNoCompose() throws Exception {
    Endpoint endpoint = uploadLocalServerEndpoint();
    RequestDetails details = Mockito.mock(RequestDetails.class);
    ValueSet vs = uploadValueSet("valueset/valueset-benzodiazepine-medications.json");
    assertTrue(vs.getCompose().getInclude().isEmpty());
    StringAndListParam stringAndListParam = getStringAndListParamFromValueSet(vs);
    Resource outcomeResource = cacheValueSetsProvider.cacheValuesets(details, endpoint.getIdElement(), stringAndListParam, null, null);
    assertTrue(outcomeResource instanceof Bundle);
    Bundle resultBundle = (Bundle) outcomeResource;
    assertEquals(1, resultBundle.getEntry().size());
    BundleEntryComponent entry = resultBundle.getEntry().get(0);
    assertTrue(entry.getResponse().getLocation().startsWith("ValueSet/" + vs.getIdElement().getIdPart()));
    assertEquals("200 OK", entry.getResponse().getStatus());
// ValueSet resultingValueSet = createClient(ourCtx, endpoint).read().resource(ValueSet.class).withId(vs.getIdElement()).execute();
// resultingValueSet not returning with a version
// assertTrue(resultingValueSet.getVersion().endsWith("-cached"));
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Endpoint(org.hl7.fhir.r4.model.Endpoint) StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) Bundle(org.hl7.fhir.r4.model.Bundle) Resource(org.hl7.fhir.r4.model.Resource) ValueSet(org.hl7.fhir.r4.model.ValueSet) RequestDetails(ca.uhn.fhir.rest.api.server.RequestDetails) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Example 69 with Endpoint

use of org.hl7.fhir.r4.model.Endpoint in project cqf-ruler by DBCG.

the class CacheValueSetsProviderIT method testCacheValueSetsValueSetDNE.

@Test
public void testCacheValueSetsValueSetDNE() throws Exception {
    Endpoint endpoint = uploadLocalServerEndpoint();
    StringAndListParam stringAndListParam = new StringAndListParam();
    stringAndListParam.setValuesAsQueryTokens(getFhirContext(), "valueset", Arrays.asList(QualifiedParamList.singleton("dne")));
    RequestDetails details = Mockito.mock(RequestDetails.class);
    Resource outcomeResource = cacheValueSetsProvider.cacheValuesets(details, endpoint.getIdElement(), stringAndListParam, null, null);
    validateOutcome(outcomeResource, "HTTP 404 : Resource ValueSet/" + "dne" + " is not known");
}
Also used : Endpoint(org.hl7.fhir.r4.model.Endpoint) StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) Resource(org.hl7.fhir.r4.model.Resource) RequestDetails(ca.uhn.fhir.rest.api.server.RequestDetails) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Example 70 with Endpoint

use of org.hl7.fhir.r4.model.Endpoint in project cqf-ruler by DBCG.

the class ProcessMessageProvider method constructMessageHeaderResource.

private MessageHeader constructMessageHeaderResource() {
    String message = "{\"resourceType\": \"MessageHeader\",\"id\": \"messageheader-example-reportheader\",\"meta\": {\"versionId\": \"1\",\"lastUpdated\": \"2020-11-29T02:03:28.045+00:00\",\"profile\": [\"http://hl7.org/fhir/us/medmorph/StructureDefinition/us-ph-messageheader\"]},\"extension\": [{\"url\": \"http://hl7.org/fhir/us/medmorph/StructureDefinition/ext-dataEncrypted\",\"valueBoolean\": false},{\"url\":\"http://hl7.org/fhir/us/medmorph/StructureDefinition/ext-messageProcessingCategory\",\"valueCode\": \"consequence\"}],\"eventCoding\": {\"system\": \"http://hl7.org/fhir/us/medmorph/CodeSystem/us-ph-messageheader-message-types\",\"code\": \"cancer-report-message\"},\"destination\": [{\"name\": \"PHA endpoint\",\"endpoint\": \"http://example.pha.org/fhir\"}],\"source\": {\"name\": \"Healthcare Organization\",\"software\": \"Backend Service App\",\"version\": \"3.1.45.AABB\",\"contact\": {\"system\": \"phone\",\"value\": \"+1 (917) 123 4567\"},\"endpoint\": \"http://example.healthcare.org/fhir\"},\"reason\": {\"coding\": [{\"system\": \"http://hl7.org/fhir/us/medmorph/CodeSystem/us-ph-triggerdefinition-namedevents\",\"code\": \"encounter-close\"}]}}";
    MessageHeader messageHeader = (MessageHeader) this.getFhirContext().newJsonParser().parseResource(message);
    messageHeader.setId(getUUID());
    return messageHeader;
}
Also used : MessageHeader(org.hl7.fhir.r4.model.MessageHeader)

Aggregations

Test (org.junit.jupiter.api.Test)36 Endpoint (org.hl7.fhir.dstu3.model.Endpoint)21 RequestDetails (ca.uhn.fhir.rest.api.server.RequestDetails)18 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)16 RestIntegrationTest (org.opencds.cqf.ruler.test.RestIntegrationTest)16 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)16 IGenericClient (ca.uhn.fhir.rest.client.api.IGenericClient)15 Endpoint (org.hl7.fhir.r4.model.Endpoint)15 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)14 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)14 Bundle (org.hl7.fhir.r4.model.Bundle)12 Organization (org.hl7.fhir.dstu3.model.Organization)11 Resource (org.hl7.fhir.r4.model.Resource)10 Resource (org.hl7.fhir.dstu3.model.Resource)9 Operation (ca.uhn.fhir.rest.annotation.Operation)7 List (java.util.List)7 Bundle (org.hl7.fhir.dstu3.model.Bundle)7 Description (ca.uhn.fhir.model.api.annotation.Description)6 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)6 ArrayList (java.util.ArrayList)6