Search in sources :

Example 6 with CodeSystem

use of com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem in project snow-owl by b2ihealthcare.

the class BundleEntryTest method responseEntryWithResourceTest.

@Test
public void responseEntryWithResourceTest() throws Exception {
    CodeSystem resource = CodeSystem.builder().status(PublicationStatus.ACTIVE).content(CodeSystemContentMode.COMPLETE).build();
    ResourceResponseEntry entry = ResourceResponseEntry.builder().fullUrl("test_url").response(BatchResponse.createOkResponse()).resource(resource).build();
    String json = objectMapper.writeValueAsString(entry);
    Entry readEntry = objectMapper.readValue(json, Entry.class);
    assertTrue(readEntry instanceof ResourceResponseEntry);
    assertEquals("test_url", readEntry.getFullUrl().getUriValue());
}
Also used : CodeSystem(com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 7 with CodeSystem

use of com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem in project snow-owl by b2ihealthcare.

the class FhirBatchApiRestTest method singleResourcePost.

@Test
public void singleResourcePost() {
    CodeSystem codeSystem = CodeSystem.builder().status(PublicationStatus.ACTIVE).content(CodeSystemContentMode.COMPLETE).build();
    ResourceRequestEntry entry = ResourceRequestEntry.builder().request(BatchRequest.createPostRequest("/CodeSystem")).resource(codeSystem).build();
    Bundle bundle = Bundle.builder().language("en").total(1).type(BundleType.BATCH).addEntry(entry).build();
    givenAuthenticatedRequest(FHIR_ROOT_CONTEXT).contentType(APPLICATION_FHIR_JSON).body(bundle).when().post("/").prettyPeek().then().statusCode(200).body("resourceType", equalTo("Bundle")).body("type", is("batch-response")).root("entry[0]").body("response.status", equalTo("405")).root("entry[0].resource").body("resourceType", equalTo("OperationOutcome"));
}
Also used : CodeSystem(com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem) Test(org.junit.Test) FhirRestTest(com.b2international.snowowl.fhir.tests.FhirRestTest)

Example 8 with CodeSystem

use of com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem in project snow-owl by b2ihealthcare.

the class BundleTest method buildResourceRequestBundle.

@Test
public void buildResourceRequestBundle() throws Exception {
    CodeSystem codeSystem = CodeSystem.builder().status(PublicationStatus.ACTIVE).content(CodeSystemContentMode.COMPLETE).build();
    ResourceRequestEntry entry = ResourceRequestEntry.builder().request(BatchRequest.createPostRequest("/CodeSystem")).resource(codeSystem).build();
    Bundle bundle = Bundle.builder().language("en").total(1).type(BundleType.BATCH).addEntry(entry).addLink("self", "http://localhost:8080/snowowl/CodeSystem").build();
    assertEquals("en", bundle.getLanguage().getCodeValue());
    assertEquals(1, bundle.getTotal());
    assertEquals(BundleType.BATCH.getCode(), bundle.getType());
    Link link = bundle.getLink().iterator().next();
    assertEquals("self", link.getRelation());
    assertEquals("http://localhost:8080/snowowl/CodeSystem", link.getUrl().getUriValue());
    Entry bundleEntry = bundle.getItems().iterator().next();
    assertTrue(bundleEntry instanceof ResourceRequestEntry);
    ResourceRequestEntry requestEntry = (ResourceRequestEntry) bundleEntry;
    BatchRequest batchRequest = requestEntry.getRequest();
    assertEquals(HttpVerb.POST.getCode(), batchRequest.getMethod());
    assertEquals("/CodeSystem", batchRequest.getUrl().getUriValue());
    FhirResource readCodeSystem = requestEntry.getRequestResource();
    assertTrue(readCodeSystem instanceof CodeSystem);
    String bundleString = objectMapper.writeValueAsString(bundle);
    Bundle readBundle = objectMapper.readValue(bundleString, Bundle.class);
    assertTrue(readBundle.getEntry().iterator().next() instanceof ResourceRequestEntry);
}
Also used : BatchRequest(com.b2international.snowowl.fhir.core.model.BatchRequest) ParametersRequestEntry(com.b2international.snowowl.fhir.core.model.ParametersRequestEntry) ParametersResponseEntry(com.b2international.snowowl.fhir.core.model.ParametersResponseEntry) ResourceRequestEntry(com.b2international.snowowl.fhir.core.model.ResourceRequestEntry) Entry(com.b2international.snowowl.fhir.core.model.Entry) ResourceResponseEntry(com.b2international.snowowl.fhir.core.model.ResourceResponseEntry) OperationOutcomeEntry(com.b2international.snowowl.fhir.core.model.OperationOutcomeEntry) FhirResource(com.b2international.snowowl.fhir.core.model.FhirResource) Bundle(com.b2international.snowowl.fhir.core.model.Bundle) CodeSystem(com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem) Link(com.b2international.snowowl.fhir.core.model.Link) ResourceRequestEntry(com.b2international.snowowl.fhir.core.model.ResourceRequestEntry) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 9 with CodeSystem

use of com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem in project snow-owl by b2ihealthcare.

the class BundleTest method deserializeResourceBundle.

@Test
public void deserializeResourceBundle() throws JsonProcessingException {
    FhirResource resource = CodeSystem.builder().status(PublicationStatus.ACTIVE).content(CodeSystemContentMode.COMPLETE).build();
    String resourceString = objectMapper.writeValueAsString(resource);
    CodeSystem fhirResource = objectMapper.readValue(resourceString, CodeSystem.class);
    assertEquals(null, fhirResource.getId());
    ResourceRequestEntry entry = ResourceRequestEntry.builder().resource(resource).request(BatchRequest.createPostRequest("/url")).build();
    Bundle bundle = Bundle.builder().type(BundleType.BATCH).entry(ImmutableList.of(entry)).build();
    String bundleString = objectMapper.writeValueAsString(bundle);
    Bundle readBundle = objectMapper.readValue(bundleString, Bundle.class);
    assertEquals(null, readBundle.getId());
}
Also used : FhirResource(com.b2international.snowowl.fhir.core.model.FhirResource) Bundle(com.b2international.snowowl.fhir.core.model.Bundle) CodeSystem(com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem) ResourceRequestEntry(com.b2international.snowowl.fhir.core.model.ResourceRequestEntry) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 10 with CodeSystem

use of com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem in project snow-owl by b2ihealthcare.

the class CodeSystemTest method serializeCodeSystem.

@Test
public void serializeCodeSystem() throws Exception {
    Identifier identifier = Identifier.builder().use(IdentifierUse.OFFICIAL).system(new Uri("www.hl7.org")).value("OID:1234.1234").build();
    CodeSystem codeSystem = CodeSystem.builder("repo/shortName").addProperty(SupportedConceptProperty.builder(CommonConceptProperties.CHILD).build()).description("Code system description").date("2018-03-09T19:50:21.000+0000").hierarchyMeaning(CodeSystemHierarchyMeaning.IS_A).addIdentifier(identifier).language("en").name("Local code system").narrative(NarrativeStatus.ADDITIONAL, "<div>Some html text</div>").title("title").publisher("B2i").status(PublicationStatus.ACTIVE).content(CodeSystemContentMode.COMPLETE).supplements(new Uri("http://b2i.sg/supplement")).url(new Uri("code system uri")).version("2018.01.01").addConcept(Concept.builder().code("conceptCode").definition("This is a code definition").display("Label").addDesignation(Designation.builder().languageCode("uk_en").use(Coding.builder().code("internal").system("http://b2i.sg/test").build()).value("conceptLabel_uk").build()).addProperty(CodeConceptProperty.builder().code("childConcept").value(new Code("childId")).build()).build()).build();
    applyFilter(codeSystem);
    JsonPath jsonPath = getJsonPath(codeSystem);
    assertThat(jsonPath.getString("resourceType"), equalTo("CodeSystem"));
    assertThat(jsonPath.getString("id"), equalTo("repo/shortName"));
    assertThat(jsonPath.getString("language"), equalTo("en"));
    assertThat(jsonPath.getString("text.status"), equalTo("additional"));
    assertThat(jsonPath.getString("text.div"), equalTo("<div>Some html text</div>"));
    assertThat(jsonPath.getString("url"), equalTo("code system uri"));
    assertThat(jsonPath.getString("identifier[0].use"), equalTo("official"));
    assertThat(jsonPath.getString("identifier[0].system"), equalTo("www.hl7.org"));
    assertThat(jsonPath.getString("identifier[0].value"), equalTo("OID:1234.1234"));
    assertThat(jsonPath.getString("version"), equalTo("2018.01.01"));
    assertThat(jsonPath.getString("name"), equalTo("Local code system"));
    assertThat(jsonPath.getString("title"), equalTo("title"));
    assertThat(jsonPath.getString("status"), equalTo("active"));
    assertThat(jsonPath.getString("publisher"), equalTo("B2i"));
    assertThat(jsonPath.getString("description"), equalTo("Code system description"));
    assertThat(jsonPath.getString("hierarchyMeaning"), equalTo("is-a"));
    assertThat(jsonPath.getString("content"), equalTo("complete"));
    assertThat(jsonPath.getString("supplements"), equalTo("http://b2i.sg/supplement"));
    assertThat(jsonPath.getString("property[0].code"), equalTo("child"));
    assertThat(jsonPath.getString("property[0].uri"), equalTo("http://hl7.org/fhir/concept-properties/child"));
    assertThat(jsonPath.getString("property[0].description"), equalTo("Child"));
    assertThat(jsonPath.getString("property[0].type"), equalTo("code"));
    jsonPath.setRoot("concept[0]");
    assertThat(jsonPath.getString("code"), equalTo("conceptCode"));
    assertThat(jsonPath.getString("display"), equalTo("Label"));
    assertThat(jsonPath.getString("definition"), equalTo("This is a code definition"));
    assertThat(jsonPath.getString("designation[0].language"), equalTo("uk_en"));
    assertThat(jsonPath.getString("designation[0].use.code"), equalTo("internal"));
    assertThat(jsonPath.getString("designation[0].use.system"), equalTo("http://b2i.sg/test"));
    assertThat(jsonPath.getString("designation[0].value"), equalTo("conceptLabel_uk"));
    assertThat(jsonPath.getString("designation[0].languageCode"), equalTo("uk_en"));
    assertThat(jsonPath.getString("property[0].code"), equalTo("childConcept"));
    assertThat(jsonPath.getString("property[0].valueCode"), equalTo("childId"));
}
Also used : Identifier(com.b2international.snowowl.fhir.core.model.dt.Identifier) JsonPath(io.restassured.path.json.JsonPath) Uri(com.b2international.snowowl.fhir.core.model.dt.Uri) CodeSystem(com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem) Code(com.b2international.snowowl.fhir.core.model.dt.Code) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Aggregations

CodeSystem (com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem)13 Test (org.junit.Test)10 FhirTest (com.b2international.snowowl.fhir.tests.FhirTest)9 Bundle (com.b2international.snowowl.fhir.core.model.Bundle)4 FhirResource (com.b2international.snowowl.fhir.core.model.FhirResource)3 ResourceRequestEntry (com.b2international.snowowl.fhir.core.model.ResourceRequestEntry)3 ResourceResponseEntry (com.b2international.snowowl.fhir.core.model.ResourceResponseEntry)3 JsonPath (io.restassured.path.json.JsonPath)3 Concept (com.b2international.snowowl.core.domain.Concept)2 Uri (com.b2international.snowowl.fhir.core.model.dt.Uri)2 ServiceProvider (com.b2international.snowowl.core.ServiceProvider)1 CodeSystemRequests (com.b2international.snowowl.core.codesystem.CodeSystemRequests)1 Concepts (com.b2international.snowowl.core.domain.Concepts)1 ConceptSearchRequestBuilder (com.b2international.snowowl.core.request.ConceptSearchRequestBuilder)1 BatchRequest (com.b2international.snowowl.fhir.core.model.BatchRequest)1 Entry (com.b2international.snowowl.fhir.core.model.Entry)1 Link (com.b2international.snowowl.fhir.core.model.Link)1 OperationOutcomeEntry (com.b2international.snowowl.fhir.core.model.OperationOutcomeEntry)1 ParametersRequestEntry (com.b2international.snowowl.fhir.core.model.ParametersRequestEntry)1 ParametersResponseEntry (com.b2international.snowowl.fhir.core.model.ParametersResponseEntry)1