use of com.b2international.snowowl.fhir.core.model.dt.Parameters 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.dt.Parameters in project snow-owl by b2ihealthcare.
the class TranslateSnomedConceptMapRestTest method reverseTranslateSpecificMappingTest.
// From a specific Map type reference set
@Test
public void reverseTranslateSpecificMappingTest() throws Exception {
String mapTypeRefsetUri = "SNOMEDCT/" + FHIR_MAP_TYPE_REFSET_VERSION + "/refset/" + mapTypeRefSetIds.get(0);
String response = givenAuthenticatedRequest(FHIR_ROOT_CONTEXT).pathParam("id", mapTypeRefsetUri).param("code", "MO").param("system", SnomedUri.SNOMED_BASE_URI_STRING).param("targetsystem", SnomedUri.SNOMED_BASE_URI_STRING).param("reverse", true).when().get("/ConceptMap/{id}/$translate").asString();
Fhir parameters = objectMapper.readValue(response, Parameters.Fhir.class);
Json json = new Parameters.Json(parameters);
TranslateResult result = objectMapper.convertValue(json, TranslateResult.class);
assertTrue(result.getResult());
assertTrue(result.getMessage().startsWith("Results for reference set"));
Collection<Match> matches = result.getMatches();
assertEquals(1, matches.size());
Optional<Match> optionalMatch = matches.stream().filter(m -> m.getSource().getUriValue().equals("http://snomed.info/sct/id/" + mapTypeRefSetIds.get(0))).findFirst();
assertTrue(optionalMatch.isPresent());
Match match = optionalMatch.get();
assertEquals("equivalent", match.getEquivalence().getCodeValue());
assertEquals("MO", match.getConcept().getCodeValue());
}
use of com.b2international.snowowl.fhir.core.model.dt.Parameters in project snow-owl by b2ihealthcare.
the class TranslateSnomedConceptMapRestTest method translateSpecificMappingTest.
// From a specific Map type reference set
@Test
public void translateSpecificMappingTest() throws Exception {
String mapTypeRefsetUri = "SNOMEDCT/" + FHIR_MAP_TYPE_REFSET_VERSION + "/refset/" + mapTypeRefSetIds.get(0);
String response = givenAuthenticatedRequest(FHIR_ROOT_CONTEXT).pathParam("id", mapTypeRefsetUri).param("code", FhirTestConcepts.MICROORGANISM).param("system", SnomedUri.SNOMED_BASE_URI_STRING).param("targetsystem", SnomedUri.SNOMED_BASE_URI_STRING).when().get("/ConceptMap/{id}/$translate").asString();
Fhir parameters = objectMapper.readValue(response, Parameters.Fhir.class);
Json json = new Parameters.Json(parameters);
TranslateResult result = objectMapper.convertValue(json, TranslateResult.class);
assertTrue(result.getResult());
assertTrue(result.getMessage().startsWith("Results for reference set"));
Collection<Match> matches = result.getMatches();
assertEquals(1, matches.size());
Optional<Match> optionalMatch = matches.stream().filter(m -> m.getSource().getUriValue().equals("http://snomed.info/sct/id/" + mapTypeRefSetIds.get(0))).findFirst();
assertTrue(optionalMatch.isPresent());
Match match = optionalMatch.get();
assertEquals("equivalent", match.getEquivalence().getCodeValue());
assertEquals("MO", match.getConcept().getCodeValue());
}
use of com.b2international.snowowl.fhir.core.model.dt.Parameters in project snow-owl by b2ihealthcare.
the class ExpandValueSetRequestDeserializationTest method fullCircleTest.
// @Test
public void fullCircleTest() throws Exception {
Coding coding = Coding.builder().system("http://hl7.org/fhir/issue-severity").code("fatal").build();
System.out.println("Building the lookup request object.");
LookupRequest request = LookupRequest.builder().coding(coding).build();
Json json1 = new Parameters.Json(request);
System.out.println("JSON params:" + json1);
Fhir fhir = new Parameters.Fhir(json1.parameters());
String fhirJson = objectMapper.writeValueAsString(fhir);
System.out.println("This is the JSON request from the client: " + fhirJson);
System.out.println("This is happening in the server-side...");
Fhir parameters = objectMapper.readValue(fhirJson, Parameters.Fhir.class);
System.out.println("Deserialized into FHIR parameters..." + parameters.getParameters());
System.out.println("Back to Domain JSON...");
Json json = new Parameters.Json(parameters);
LookupRequest lookupRequest = objectMapper.convertValue(json, LookupRequest.class);
System.out.println("... and back to the object representation we started from:" + lookupRequest);
}
use of com.b2international.snowowl.fhir.core.model.dt.Parameters in project snow-owl by b2ihealthcare.
the class SubsumptionRequestDeserializationTest method lookupRequestCodingTest.
@Test
public void lookupRequestCodingTest() throws Exception {
String jsonParam = "{\"resourceType\":\"Parameters\"," + "\"parameter\":[" + "{\"name\":\"system\",\"valueUri\":\"http://snomed.info/sct\"}," + "{\"name\":\"codingA\", \"valueCoding\":" + "{\"code\":\"1234\"," + "\"system\":\"http://snomed.info/sct/version/20180131\"," + "\"userSelected\":false}" + "}," + "{\"name\":\"codingB\", \"valueCoding\":" + "{\"code\":\"5678\"," + "\"system\":\"http://snomed.info/sct/version/20180131\"," + "\"userSelected\":false}" + "}" + "]}";
// Magic to turn the FHIR params -> Parameters -> LookupRequest
Parameters.Fhir fhirParameters = objectMapper.readValue(jsonParam, Parameters.Fhir.class);
SubsumptionRequest request = objectMapper.convertValue(fhirParameters.toJson(), SubsumptionRequest.class);
assertEquals("http://snomed.info/sct", request.getSystem());
assertEquals("1234", request.getCodingA().getCodeValue());
assertEquals("5678", request.getCodingB().getCodeValue());
}
Aggregations