Search in sources :

Example 1 with LookupResult

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

the class LookupSnomedRestTest method lookupSnomedCodeSystemCodeTest.

// GET SNOMED CT with properties
@Test
public void lookupSnomedCodeSystemCodeTest() throws Exception {
    String responseString = givenAuthenticatedRequest(FHIR_ROOT_CONTEXT).param("system", "http://snomed.info/sct").param("code", // procedure by method
    "128927009").param("property", "inactive").param("property", // method
    "http://snomed.info/id/260686004").param("_format", "json").when().get("/CodeSystem/$lookup").then().assertThat().statusCode(200).extract().body().asString();
    LookupResult result = convertToResult(responseString);
    // Mandatory parameters
    assertEquals("SNOMED CT", result.getName());
    assertEquals("Procedure by method", result.getDisplay());
    assertNull(result.getVersion());
    // Designations
    Collection<Designation> designations = result.getDesignation();
    assertTrue(designations.isEmpty());
    // Properties
    Collection<Property> properties = result.getProperty();
    assertEquals(2, properties.size());
    Property inactiveProperty = getProperty(properties, "inactive");
    assertThat(inactiveProperty.getValue()).isEqualTo(false);
    Property associatedMProperty = getProperty(properties, Concepts.METHOD);
    // method = Action
    assertThat(associatedMProperty.getValue()).isEqualTo("129264002");
}
Also used : Designation(com.b2international.snowowl.fhir.core.model.Designation) LookupResult(com.b2international.snowowl.fhir.core.model.codesystem.LookupResult) Property(com.b2international.snowowl.fhir.core.model.codesystem.Property) Test(org.junit.Test) FhirRestTest(com.b2international.snowowl.fhir.tests.FhirRestTest)

Example 2 with LookupResult

use of com.b2international.snowowl.fhir.core.model.codesystem.LookupResult 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 3 with LookupResult

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

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

the class BundleTest method deserializeResponseBundle.

@Test
public void deserializeResponseBundle() throws Exception {
    String jsonResponse = "{\"resourceType\":\"Bundle\"," + "\"id\":\"ID\"," + "\"type\":\"batch-response\"," + "\"link\":[" + "{" + "\"relation\":\"self\"," + "\"url\":\"http://b2i.sg\"" + "}" + "]," + "\"entry\":[" + "{" + "\"resource\":{" + "\"resourceType\":\"Parameters\"," + "\"parameter\":[" + "{" + "\"name\":\"name\"," + "\"valueString\":\"LOINC\"" + "}," + "{" + "\"name\":\"version\"," + "\"valueString\":\"2.61\"" + "}," + "{" + "\"name\":\"display\"," + "\"valueString\":\"LOINC code label\"" + "}," + "{" + "\"name\":\"property\"," + "\"part\":[" + "{" + "\"name\":\"code\"," + "\"valueCode\":\"parent\"" + "}," + "{" + "\"name\":\"value\"," + "\"valueCode\":\"Parent code\"" + "}" + "]" + "}," + "{" + "\"name\":\"designation\"," + "\"part\":[" + "{" + "\"name\":\"language\"," + "\"valueCode\":\"en\"" + "}," + "{" + "\"name\":\"use\"," + "\"valueCoding\":{" + "\"system\":\"http://snomed.info/sct\"," + "\"code\":\"900000000000013009\"," + "\"display\":\"Synonym\"" + "}" + "}," + "{" + "\"name\":\"value\"," + "\"valueString\":\"SNOMED CT synonym\"" + "}" + "]" + "}" + "]" + "}," + "\"response\":{" + "\"status\":\"200\"" + "}" + "}" + "]" + "}";
    Bundle bundle = objectMapper.readValue(jsonResponse, Bundle.class);
    assertEquals(BundleType.BATCH_RESPONSE.getCode(), bundle.getType());
    Iterator<Entry> iterator = bundle.getItems().iterator();
    Entry bundleEntry = iterator.next();
    assertTrue(bundleEntry instanceof ParametersResponseEntry);
    ParametersResponseEntry responseEntry = (ParametersResponseEntry) bundleEntry;
    Fhir responseResource = responseEntry.getResponseResource();
    // Back to Domain JSON...
    Json json = new Parameters.Json(responseResource);
    LookupResult lookupResult = objectMapper.convertValue(json, LookupResult.class);
    assertEquals("LOINC", lookupResult.getName());
}
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) 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) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 5 with LookupResult

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

the class BundleEntryTest method responseEntryWithParametersTest.

@Test
public void responseEntryWithParametersTest() 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();
    Json json1 = new Parameters.Json(lookupResult);
    System.out.println("JSON params:" + json1);
    ParametersResponseEntry entry = ParametersResponseEntry.builder().fullUrl("test_url").response(BatchResponse.createOkResponse()).resource(new Parameters.Fhir(json1.parameters())).build();
    String json = objectMapper.writeValueAsString(entry);
    Entry readEntry = objectMapper.readValue(json, Entry.class);
    assertTrue(readEntry instanceof ParametersResponseEntry);
    assertEquals("test_url", readEntry.getFullUrl().getUriValue());
}
Also used : LookupResult(com.b2international.snowowl.fhir.core.model.codesystem.LookupResult) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Aggregations

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