Search in sources :

Example 1 with Designation

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

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

the class SnomedFhirCodeSystemLookupConverter method expandDesignations.

@Override
public List<Designation> expandDesignations(ServiceProvider context, CodeSystem codeSystem, Concept concept, LookupRequest request, String acceptLanguage) {
    SnomedConcept snomedConcept = concept.getInternalConceptAs();
    if (request.isPropertyRequested(SupportedCodeSystemRequestProperties.DESIGNATION)) {
        List<Designation> designations = new ArrayList<>();
        for (SnomedDescription description : snomedConcept.getDescriptions()) {
            Coding coding = Coding.builder().system(codeSystem.getUrl().getUriValue()).code(description.getTypeId()).display(SnomedDisplayTermType.PT.getLabel(description.getType())).build();
            designations.add(Designation.builder().languageCode(description.getLanguageCode()).use(coding).value(description.getTerm()).build());
        }
        return designations;
    } else {
        return FhirCodeSystemLookupConverter.super.expandDesignations(context, codeSystem, concept, request, acceptLanguage);
    }
}
Also used : Designation(com.b2international.snowowl.fhir.core.model.Designation) SnomedDescription(com.b2international.snowowl.snomed.core.domain.SnomedDescription) Coding(com.b2international.snowowl.fhir.core.model.dt.Coding) ArrayList(java.util.ArrayList) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept)

Example 3 with Designation

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

the class DesignationSerializationTest method designationTest.

@Test
public void designationTest() throws Exception {
    Coding coding = Coding.builder().code("1234").system("http://www.whocc.no/atc").version("20180131").build();
    Designation designation = Designation.builder().languageCode("en_uk").use(coding).value("dValue").build();
    Fhir fhirParameters = new Parameters.Fhir(designation);
    JsonPath jsonPath = JsonPath.from(objectMapper.writeValueAsString(fhirParameters));
    assertThat(jsonPath.getString("resourceType"), equalTo("Parameters"));
    assertThat(jsonPath.getString("parameter[0].name"), equalTo("language"));
    assertThat(jsonPath.getString("parameter[0].valueCode"), equalTo("en_uk"));
    assertThat(jsonPath.getString("parameter[2].name"), equalTo("value"));
    assertThat(jsonPath.getString("parameter[2].valueString"), equalTo("dValue"));
    jsonPath.setRoot("parameter[1]");
    assertThat(jsonPath.getString("name"), equalTo("use"));
    assertThat(jsonPath.getString("valueCoding.code"), equalTo("1234"));
    assertThat(jsonPath.getString("valueCoding.system"), equalTo("http://www.whocc.no/atc"));
    assertThat(jsonPath.getString("valueCoding.version"), equalTo("20180131"));
}
Also used : Designation(com.b2international.snowowl.fhir.core.model.Designation) Coding(com.b2international.snowowl.fhir.core.model.dt.Coding) 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)

Example 4 with Designation

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

the class IncludeTest method validate.

private void validate(Include include) {
    assertEquals(new Uri("system"), include.getSystem());
    assertEquals("version", include.getVersion());
    assertEquals("valueSetUri", include.getValueSets().iterator().next().getUriValue());
    ValueSetFilter filter = include.getFilters().iterator().next();
    assertEquals(new Code("filterProperty"), filter.getProperty());
    assertEquals(FilterOperator.EQUALS.getCode(), filter.getOperator());
    assertEquals(new Code("1234567"), filter.getValue());
    ValueSetConcept concept = include.getConcepts().iterator().next();
    assertEquals("code", concept.getCode().getCodeValue());
    assertEquals("display", concept.getDisplay());
    Designation designation = concept.getDesignations().iterator().next();
    assertEquals("gb_en", designation.getLanguage());
    assertEquals("designationValue", designation.getValue());
    assertEquals("internal", designation.getUse().getCode().getCodeValue());
}
Also used : Designation(com.b2international.snowowl.fhir.core.model.Designation) ValueSetFilter(com.b2international.snowowl.fhir.core.model.valueset.ValueSetFilter) ValueSetConcept(com.b2international.snowowl.fhir.core.model.valueset.ValueSetConcept) Uri(com.b2international.snowowl.fhir.core.model.dt.Uri) Code(com.b2international.snowowl.fhir.core.model.dt.Code)

Example 5 with Designation

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

Aggregations

Designation (com.b2international.snowowl.fhir.core.model.Designation)7 Coding (com.b2international.snowowl.fhir.core.model.dt.Coding)3 Test (org.junit.Test)3 LookupResult (com.b2international.snowowl.fhir.core.model.codesystem.LookupResult)2 Property (com.b2international.snowowl.fhir.core.model.codesystem.Property)2 Code (com.b2international.snowowl.fhir.core.model.dt.Code)2 Fhir (com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir)2 Uri (com.b2international.snowowl.fhir.core.model.dt.Uri)2 FhirRestTest (com.b2international.snowowl.fhir.tests.FhirRestTest)2 LookupRequest (com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest)1 Parameters (com.b2international.snowowl.fhir.core.model.dt.Parameters)1 ValueSetConcept (com.b2international.snowowl.fhir.core.model.valueset.ValueSetConcept)1 ValueSetFilter (com.b2international.snowowl.fhir.core.model.valueset.ValueSetFilter)1 FhirTest (com.b2international.snowowl.fhir.tests.FhirTest)1 Concepts (com.b2international.snowowl.snomed.common.SnomedConstants.Concepts)1 SnomedConcept (com.b2international.snowowl.snomed.core.domain.SnomedConcept)1 SnomedDescription (com.b2international.snowowl.snomed.core.domain.SnomedDescription)1 RestExtensions.givenAuthenticatedRequest (com.b2international.snowowl.test.commons.rest.RestExtensions.givenAuthenticatedRequest)1 JsonPath (io.restassured.path.json.JsonPath)1 ArrayList (java.util.ArrayList)1