Search in sources :

Example 1 with Link

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

the class BundleTest method buildResponseBundle.

@Test
public void buildResponseBundle() throws Exception {
    LookupResult lookupResult = LookupResult.builder().name("test").display("display").addDesignation(Designation.builder().value("dValue").languageCode("uk").build()).addProperty(Property.builder().code("1234").description("propDescription").valueString("stringValue").addSubProperty(SubProperty.builder().code("subCode").description("subCodeDescription").valueInteger(1).build()).build()).build();
    Json json1 = new Parameters.Json(lookupResult);
    ParametersResponseEntry entry = ParametersResponseEntry.builder().resource(new Parameters.Fhir(json1.parameters())).response(BatchResponse.createOkResponse()).build();
    Bundle bundle = Bundle.builder().language("en").type(BundleType.BATCH_RESPONSE).addLink("self", "http://localhost:8080/snowowl/CodeSystem").addEntry(entry).build();
    assertEquals("en", bundle.getLanguage().getCodeValue());
    assertEquals(BundleType.BATCH_RESPONSE.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 ParametersResponseEntry);
    ParametersResponseEntry responseEntry = (ParametersResponseEntry) bundleEntry;
    assertEquals("200", responseEntry.getResponse().getStatus());
    Fhir requestResource = responseEntry.getResponseResource();
    // Back to Domain JSON...
    Json json = new Parameters.Json(requestResource);
    LookupResult returnedResponse = objectMapper.convertValue(json, LookupResult.class);
    assertEquals("test", returnedResponse.getName());
    assertEquals("display", returnedResponse.getDisplay());
}
Also used : 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) Parameters(com.b2international.snowowl.fhir.core.model.dt.Parameters) Bundle(com.b2international.snowowl.fhir.core.model.Bundle) ParametersResponseEntry(com.b2international.snowowl.fhir.core.model.ParametersResponseEntry) LookupResult(com.b2international.snowowl.fhir.core.model.codesystem.LookupResult) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Link(com.b2international.snowowl.fhir.core.model.Link) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 2 with Link

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

the class BundleTest method buildMixedBundle.

@Test
public void buildMixedBundle() throws Exception {
    LookupResult lookupResult = LookupResult.builder().name("test").display("display").addDesignation(Designation.builder().value("dValue").languageCode("uk").build()).addProperty(Property.builder().code("1234").description("propDescription").valueString("stringValue").build()).build();
    OperationOutcome operationOutcome = OperationOutcome.builder().addIssue(Issue.builder().code(IssueType.CODE_INVALID).diagnostics("Invalid code").severity(IssueSeverity.ERROR).build()).build();
    Json json1 = new Parameters.Json(lookupResult);
    ParametersResponseEntry lookupResultEntry = ParametersResponseEntry.builder().resource(new Parameters.Fhir(json1.parameters())).response(BatchResponse.createOkResponse()).build();
    OperationOutcomeEntry operationOutcomeEntry = OperationOutcomeEntry.builder().operationOutcome(operationOutcome).build();
    Bundle bundle = Bundle.builder().language("en").type(BundleType.BATCH_RESPONSE).addLink("self", "http://localhost:8080/snowowl/CodeSystem").addEntry(lookupResultEntry).addEntry(operationOutcomeEntry).build();
    assertEquals("en", bundle.getLanguage().getCodeValue());
    assertEquals(BundleType.BATCH_RESPONSE.getCode(), bundle.getType());
    Link link = bundle.getLink().iterator().next();
    assertEquals("self", link.getRelation());
    assertEquals("http://localhost:8080/snowowl/CodeSystem", link.getUrl().getUriValue());
    Iterator<Entry> iterator = bundle.getItems().iterator();
    Entry bundleEntry = iterator.next();
    assertTrue(bundleEntry instanceof ParametersResponseEntry);
    ParametersResponseEntry responseEntry = (ParametersResponseEntry) bundleEntry;
    assertEquals("200", responseEntry.getResponse().getStatus());
    Fhir requestResource = responseEntry.getResponseResource();
    // Back to Domain JSON...
    Json json = new Parameters.Json(requestResource);
    LookupResult returnedResponse = objectMapper.convertValue(json, LookupResult.class);
    assertEquals("test", returnedResponse.getName());
    assertEquals("display", returnedResponse.getDisplay());
    bundleEntry = iterator.next();
    assertTrue(bundleEntry instanceof OperationOutcomeEntry);
    OperationOutcomeEntry ooce = (OperationOutcomeEntry) bundleEntry;
    Collection<Issue> issues = ooce.getOperationOutcome().getIssues();
    assertEquals(1, issues.size());
    assertEquals(IssueSeverity.ERROR.getCode(), issues.iterator().next().getSeverity());
}
Also used : Parameters(com.b2international.snowowl.fhir.core.model.dt.Parameters) Issue(com.b2international.snowowl.fhir.core.model.Issue) Bundle(com.b2international.snowowl.fhir.core.model.Bundle) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) OperationOutcomeEntry(com.b2international.snowowl.fhir.core.model.OperationOutcomeEntry) 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) OperationOutcome(com.b2international.snowowl.fhir.core.model.OperationOutcome) ParametersResponseEntry(com.b2international.snowowl.fhir.core.model.ParametersResponseEntry) LookupResult(com.b2international.snowowl.fhir.core.model.codesystem.LookupResult) Link(com.b2international.snowowl.fhir.core.model.Link) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 3 with Link

use of com.b2international.snowowl.fhir.core.model.Link 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 4 with Link

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

the class BundleTest method buildRequestBundle.

@Test
public void buildRequestBundle() throws Exception {
    LookupRequest lookupRequest = LookupRequest.builder().code("23245-4").system("http://loinc.org").build();
    Json json1 = new Parameters.Json(lookupRequest);
    ParametersRequestEntry entry = ParametersRequestEntry.builder().request(BatchRequest.createPostRequest("CodeSystem/$lookup")).resource(new Parameters.Fhir(json1.parameters())).build();
    Bundle bundle = Bundle.builder().language("en").total(1).type(BundleType.BATCH).addLink("self", "http://localhost:8080/snowowl/CodeSystem").addEntry(entry).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 ParametersRequestEntry);
    ParametersRequestEntry requestEntry = (ParametersRequestEntry) bundleEntry;
    BatchRequest batchRequest = requestEntry.getRequest();
    assertEquals(HttpVerb.POST.getCode(), batchRequest.getMethod());
    assertEquals("CodeSystem/$lookup", batchRequest.getUrl().getUriValue());
    Fhir requestResource = requestEntry.getRequestResource();
    // Back to Domain JSON...
    Json json = new Parameters.Json(requestResource);
    LookupRequest returnedLookupRequest = objectMapper.convertValue(json, LookupRequest.class);
    assertEquals("23245-4", returnedLookupRequest.getCode());
    assertEquals("http://loinc.org", returnedLookupRequest.getSystem());
}
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) Bundle(com.b2international.snowowl.fhir.core.model.Bundle) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) ParametersRequestEntry(com.b2international.snowowl.fhir.core.model.ParametersRequestEntry) Link(com.b2international.snowowl.fhir.core.model.Link) LookupRequest(com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Aggregations

Bundle (com.b2international.snowowl.fhir.core.model.Bundle)4 Entry (com.b2international.snowowl.fhir.core.model.Entry)4 Link (com.b2international.snowowl.fhir.core.model.Link)4 OperationOutcomeEntry (com.b2international.snowowl.fhir.core.model.OperationOutcomeEntry)4 ParametersRequestEntry (com.b2international.snowowl.fhir.core.model.ParametersRequestEntry)4 ParametersResponseEntry (com.b2international.snowowl.fhir.core.model.ParametersResponseEntry)4 ResourceRequestEntry (com.b2international.snowowl.fhir.core.model.ResourceRequestEntry)4 ResourceResponseEntry (com.b2international.snowowl.fhir.core.model.ResourceResponseEntry)4 FhirTest (com.b2international.snowowl.fhir.tests.FhirTest)4 Test (org.junit.Test)4 Fhir (com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir)3 Json (com.b2international.snowowl.fhir.core.model.dt.Parameters.Json)3 BatchRequest (com.b2international.snowowl.fhir.core.model.BatchRequest)2 LookupResult (com.b2international.snowowl.fhir.core.model.codesystem.LookupResult)2 Parameters (com.b2international.snowowl.fhir.core.model.dt.Parameters)2 FhirResource (com.b2international.snowowl.fhir.core.model.FhirResource)1 Issue (com.b2international.snowowl.fhir.core.model.Issue)1 OperationOutcome (com.b2international.snowowl.fhir.core.model.OperationOutcome)1 CodeSystem (com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem)1 LookupRequest (com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest)1