Search in sources :

Example 1 with Property

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

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

the class PropertySerializationTest method basicPropertyTest.

@Test
public void basicPropertyTest() throws Exception {
    Property property = Property.builder().code("123").valueInteger(2).description("propertyDescription").build();
    Fhir fhirParameters = new Parameters.Fhir(property);
    JsonPath jsonPath = JsonPath.from(objectMapper.writeValueAsString(fhirParameters));
    assertThat(jsonPath.getString("resourceType"), equalTo("Parameters"));
    assertThat(jsonPath.getList("parameter").size(), is(3));
    assertThat(jsonPath, FhirParameterMatcher.hasParameter("code", FhirDataType.CODE, "123"));
    assertThat(jsonPath, FhirParameterMatcher.hasParameter("value", FhirDataType.INTEGER, 2));
    assertThat(jsonPath, FhirParameterMatcher.hasParameter("description", FhirDataType.STRING, "propertyDescription"));
}
Also used : Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) JsonPath(io.restassured.path.json.JsonPath) Property(com.b2international.snowowl.fhir.core.model.codesystem.Property) SubProperty(com.b2international.snowowl.fhir.core.model.dt.SubProperty) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 3 with Property

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

the class PropertySerializationTest method minimalPropertyTest.

@Test
public void minimalPropertyTest() throws Exception {
    Property property = Property.builder().code("123").build();
    Fhir fhirParameters = new Parameters.Fhir(property);
    JsonPath jsonPath = JsonPath.from(objectMapper.writeValueAsString(fhirParameters));
    assertThat(jsonPath.getString("resourceType"), equalTo("Parameters"));
    assertThat(jsonPath.getList("parameter").size(), is(1));
    assertThat(jsonPath, FhirParameterMatcher.hasParameter("code", FhirDataType.CODE, "123"));
}
Also used : Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) JsonPath(io.restassured.path.json.JsonPath) Property(com.b2international.snowowl.fhir.core.model.codesystem.Property) SubProperty(com.b2international.snowowl.fhir.core.model.dt.SubProperty) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 4 with Property

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

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

the class PropertySerializationTest method dateTimePropertyTest.

@Test
public void dateTimePropertyTest() throws Exception {
    Date date = Dates.parse("2018-03-09T20:50:21.000+0100", FhirDates.DATE_TIME_FORMAT);
    Property property = Property.builder().code("123").valueDateTime(date).description("propertyDescription").build();
    Fhir fhirParameters = new Parameters.Fhir(property);
    JsonPath jsonPath = JsonPath.from(objectMapper.writeValueAsString(fhirParameters));
    assertThat(jsonPath.getString("resourceType"), equalTo("Parameters"));
    assertThat(jsonPath.getList("parameter").size(), is(3));
    assertThat(jsonPath, FhirParameterMatcher.hasParameter("code", FhirDataType.CODE, "123"));
    assertThat(jsonPath, FhirParameterMatcher.hasParameter("value", FhirDataType.DATETIME, "2018-03-09T19:50:21.000+0000"));
    assertThat(jsonPath, FhirParameterMatcher.hasParameter("description", FhirDataType.STRING, "propertyDescription"));
}
Also used : Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) JsonPath(io.restassured.path.json.JsonPath) Property(com.b2international.snowowl.fhir.core.model.codesystem.Property) SubProperty(com.b2international.snowowl.fhir.core.model.dt.SubProperty) Date(java.util.Date) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Aggregations

Property (com.b2international.snowowl.fhir.core.model.codesystem.Property)7 Test (org.junit.Test)6 Fhir (com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir)5 SubProperty (com.b2international.snowowl.fhir.core.model.dt.SubProperty)4 FhirTest (com.b2international.snowowl.fhir.tests.FhirTest)4 JsonPath (io.restassured.path.json.JsonPath)4 Designation (com.b2international.snowowl.fhir.core.model.Designation)2 LookupResult (com.b2international.snowowl.fhir.core.model.codesystem.LookupResult)2 FhirRestTest (com.b2international.snowowl.fhir.tests.FhirRestTest)2 LookupRequest (com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest)1 Coding (com.b2international.snowowl.fhir.core.model.dt.Coding)1 Parameters (com.b2international.snowowl.fhir.core.model.dt.Parameters)1 Concepts (com.b2international.snowowl.snomed.common.SnomedConstants.Concepts)1 RelationshipValue (com.b2international.snowowl.snomed.core.domain.RelationshipValue)1 SnomedConcept (com.b2international.snowowl.snomed.core.domain.SnomedConcept)1 RestExtensions.givenAuthenticatedRequest (com.b2international.snowowl.test.commons.rest.RestExtensions.givenAuthenticatedRequest)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Date (java.util.Date)1 Optional (java.util.Optional)1