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");
}
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());
}
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"));
}
Aggregations