use of com.b2international.snowowl.fhir.core.model.conceptmap.TranslateResult in project snow-owl by b2ihealthcare.
the class TranslateSnomedConceptMapRestTest method reverseTranslateMappingTest.
@Test
public void reverseTranslateMappingTest() throws Exception {
String response = givenAuthenticatedRequest(FHIR_ROOT_CONTEXT).param("code", "MO").param("system", SnomedUri.SNOMED_BASE_URI_STRING).param("targetsystem", SnomedUri.SNOMED_BASE_URI_STRING).param("reverse", true).when().get("/ConceptMap/$translate").then().extract().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());
assertEquals("4 match(es).", result.getMessage());
Collection<Match> matches = result.getMatches();
assertEquals(4, matches.size());
assertMatchExists(matches, 0, "equivalent");
assertMatchExists(matches, 1, "unmatched");
assertMatchExists(matches, 2, "unmatched");
assertMatchExists(matches, 3, "unmatched");
}
use of com.b2international.snowowl.fhir.core.model.conceptmap.TranslateResult in project snow-owl by b2ihealthcare.
the class TranslateSnomedConceptMapRestTest method translateMappingTest.
@Test
public void translateMappingTest() throws Exception {
String response = givenAuthenticatedRequest(FHIR_ROOT_CONTEXT).param("code", FhirTestConcepts.MICROORGANISM).param("system", SnomedUri.SNOMED_BASE_URI_STRING).param("targetsystem", SnomedUri.SNOMED_BASE_URI_STRING).when().get("/ConceptMap/$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());
assertEquals("4 match(es).", result.getMessage());
Collection<Match> matches = result.getMatches();
assertEquals(4, matches.size());
assertMatchExists(matches, 0, "equivalent");
assertMatchExists(matches, 1, "unmatched");
assertMatchExists(matches, 2, "unmatched");
assertMatchExists(matches, 3, "unmatched");
}
use of com.b2international.snowowl.fhir.core.model.conceptmap.TranslateResult 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.conceptmap.TranslateResult 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.conceptmap.TranslateResult in project snow-owl by b2ihealthcare.
the class TranslateResultSerializationTest method validResultTest.
@Test
public void validResultTest() throws Exception {
Match match = Match.builder().equivalence(ConceptMapEquivalence.EQUAL).build();
Match match2 = Match.builder().equivalence(ConceptMapEquivalence.DISJOINT).build();
TranslateResult translateResult = TranslateResult.builder().message("This is a test result").addMatch(match).addMatch(match2).build();
Fhir fhirParameters = new Parameters.Fhir(translateResult);
Parameter parameter = fhirParameters.getByName("result").get();
Boolean result = (Boolean) parameter.getValue();
assertEquals(true, result.booleanValue());
parameter = fhirParameters.getByName("message").get();
String message = (String) parameter.getValue();
assertEquals("This is a test result", message);
parameter = fhirParameters.getByName("match").get();
Parameters matchParameters = (Parameters) parameter.getValue();
parameter = matchParameters.getByName("equivalence").get();
assertEquals("equal", ((Code) parameter.getValue()).getCodeValue());
}
Aggregations