Search in sources :

Example 6 with LookupResult

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

the class LookupSnomedRestTest method lookupDefaultPropertiesTest.

// GET SNOMED CT with parameters, default properties
@Test
public void lookupDefaultPropertiesTest() throws Exception {
    String responseString = givenAuthenticatedRequest(FHIR_ROOT_CONTEXT).param("system", "http://snomed.info/sct").param("code", Concepts.IS_A).param("property", "designation", "sufficientlyDefined", "inactive", "effectiveTime").param("_format", "json").when().get("/CodeSystem/$lookup").then().assertThat().statusCode(200).extract().body().asString();
    LookupResult result = convertToResult(responseString);
    assertEquals("SNOMED CT", result.getName());
    assertEquals("Is a", result.getDisplay());
    // Designations
    Collection<Designation> designations = result.getDesignation();
    Designation ptDesignation = designations.stream().filter(d -> "Is a".equals(d.getValue())).findFirst().get();
    assertThat(ptDesignation.getUse().getCodeValue()).isEqualTo(Concepts.SYNONYM);
    assertThat(ptDesignation.getUse().getDisplay()).isEqualTo("Synonym");
    Designation fsnDesignation = designations.stream().filter(d -> d.getValue().equals("Is a (attribute)")).findFirst().get();
    assertThat(fsnDesignation.getUse().getCodeValue()).isEqualTo(Concepts.FULLY_SPECIFIED_NAME);
    assertThat(fsnDesignation.getUse().getDisplay()).isEqualTo("Fully specified name");
    // Properties
    Collection<Property> properties = result.getProperty();
    properties.forEach(System.out::println);
    Property definitionProperty = getProperty(properties, "sufficientlyDefined");
    assertThat(definitionProperty.getValue()).isEqualTo(false);
    Property statusProperty = getProperty(properties, "inactive");
    assertThat(statusProperty.getValue()).isEqualTo(false);
    Property effectiveTimeProperty = getProperty(properties, "effectiveTime");
    assertThat(effectiveTimeProperty.getValue()).isEqualTo("20110131");
    Set<String> codeValues = properties.stream().map(p -> p.getCode()).collect(Collectors.toSet());
    assertThat(codeValues).doesNotContain("parent");
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) CoreMatchers.hasItem(org.hamcrest.CoreMatchers.hasItem) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Collection(java.util.Collection) Assert.assertTrue(org.junit.Assert.assertTrue) Set(java.util.Set) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Test(org.junit.Test) LookupRequest(com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest) Collectors(java.util.stream.Collectors) Concepts(com.b2international.snowowl.snomed.common.SnomedConstants.Concepts) Designation(com.b2international.snowowl.fhir.core.model.Designation) LookupResult(com.b2international.snowowl.fhir.core.model.codesystem.LookupResult) Assert.assertNull(org.junit.Assert.assertNull) Property(com.b2international.snowowl.fhir.core.model.codesystem.Property) FhirRestTest(com.b2international.snowowl.fhir.tests.FhirRestTest) RestExtensions.givenAuthenticatedRequest(com.b2international.snowowl.test.commons.rest.RestExtensions.givenAuthenticatedRequest) Optional(java.util.Optional) Parameters(com.b2international.snowowl.fhir.core.model.dt.Parameters) Coding(com.b2international.snowowl.fhir.core.model.dt.Coding) Assert.assertEquals(org.junit.Assert.assertEquals) 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 7 with LookupResult

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

the class LookupSnomedRestTest method lookupVersionTest.

@Test
public void lookupVersionTest() throws Exception {
    String responseString = givenAuthenticatedRequest(FHIR_ROOT_CONTEXT).param("system", "http://snomed.info/sct/900000000000207008/version/20170131").param("code", Concepts.IS_A).param("property", "version").when().get("/CodeSystem/$lookup").then().assertThat().statusCode(200).extract().body().asString();
    LookupResult result = convertToResult(responseString);
    assertEquals("SNOMED CT", result.getName());
    assertEquals("20170131", result.getVersion());
}
Also used : LookupResult(com.b2international.snowowl.fhir.core.model.codesystem.LookupResult) Test(org.junit.Test) FhirRestTest(com.b2international.snowowl.fhir.tests.FhirRestTest)

Example 8 with LookupResult

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

the class LookupResultSerializationTest method lookupResultTest.

@Test
public void lookupResultTest() throws Exception {
    LookupResult lookupResult = LookupResult.builder().name("test").display("display").designation(List.of(Designation.builder().value("dValue").languageCode("uk").build())).property(List.of(Property.builder().code("1234").description("propDescription").valueString("sds").addSubProperty(SubProperty.builder().code("subCode").description("subDescription").valueInteger(1).build()).build())).build();
    Fhir fhirParameters = new Parameters.Fhir(lookupResult);
    JsonPath jsonPath = JsonPath.from(objectMapper.writeValueAsString(fhirParameters));
    assertThat(jsonPath.getString("resourceType"), equalTo("Parameters"));
    assertThat(jsonPath.getList("parameter.name"), hasItems("name", "display", "designation", "property"));
    assertThat(jsonPath, FhirParameterMatcher.hasParameter("name", FhirDataType.STRING, "test"));
    assertThat(jsonPath, FhirParameterMatcher.hasParameter("display", FhirDataType.STRING, "display"));
    assertThat(jsonPath.getString("parameter[2].name"), equalTo("designation"));
    assertThat(jsonPath.getString("parameter[2].part[0].name"), equalTo("language"));
    assertThat(jsonPath.getString("parameter[2].part[0].valueCode"), equalTo("uk"));
    assertThat(jsonPath.getString("parameter[2].part[1].name"), equalTo("value"));
    assertThat(jsonPath.getString("parameter[2].part[1].valueString"), equalTo("dValue"));
    assertThat(jsonPath.getString("parameter[3].name"), equalTo("property"));
    assertThat(jsonPath.getString("parameter[3].part[0].name"), equalTo("code"));
    assertThat(jsonPath.getString("parameter[3].part[0].valueCode"), equalTo("1234"));
    assertThat(jsonPath.getString("parameter[3].part[1].name"), equalTo("value"));
    assertThat(jsonPath.getString("parameter[3].part[1].valueString"), equalTo("sds"));
    assertThat(jsonPath.getString("parameter[3].part[2].name"), equalTo("description"));
    assertThat(jsonPath.getString("parameter[3].part[2].valueString"), equalTo("propDescription"));
    assertThat(jsonPath.getString("parameter[3].part[3].name"), equalTo("subproperty"));
    assertThat(jsonPath.getString("parameter[3].part[3].part[0].name"), equalTo("code"));
    assertThat(jsonPath.getString("parameter[3].part[3].part[0].valueCode"), equalTo("subCode"));
    assertThat(jsonPath.getString("parameter[3].part[3].part[1].name"), equalTo("value"));
    assertThat(jsonPath.getInt("parameter[3].part[3].part[1].valueInteger"), equalTo(1));
    assertThat(jsonPath.getString("parameter[3].part[3].part[2].name"), equalTo("description"));
    assertThat(jsonPath.getString("parameter[3].part[3].part[2].valueString"), equalTo("subDescription"));
}
Also used : LookupResult(com.b2international.snowowl.fhir.core.model.codesystem.LookupResult) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) JsonPath(io.restassured.path.json.JsonPath) 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