Search in sources :

Example 1 with TranslateResult

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");
}
Also used : Parameters(com.b2international.snowowl.fhir.core.model.dt.Parameters) TranslateResult(com.b2international.snowowl.fhir.core.model.conceptmap.TranslateResult) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) Match(com.b2international.snowowl.fhir.core.model.conceptmap.Match) Test(org.junit.Test) FhirRestTest(com.b2international.snowowl.fhir.tests.FhirRestTest)

Example 2 with TranslateResult

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");
}
Also used : Parameters(com.b2international.snowowl.fhir.core.model.dt.Parameters) TranslateResult(com.b2international.snowowl.fhir.core.model.conceptmap.TranslateResult) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) Match(com.b2international.snowowl.fhir.core.model.conceptmap.Match) Test(org.junit.Test) FhirRestTest(com.b2international.snowowl.fhir.tests.FhirRestTest)

Example 3 with TranslateResult

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());
}
Also used : FhirTestConcepts(com.b2international.snowowl.fhir.tests.FhirTestConcepts) BeforeClass(org.junit.BeforeClass) SnomedUri(com.b2international.snowowl.snomed.fhir.SnomedUri) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) Collection(java.util.Collection) Assert.assertTrue(org.junit.Assert.assertTrue) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Test(org.junit.Test) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) Concepts(com.b2international.snowowl.snomed.common.SnomedConstants.Concepts) List(java.util.List) 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) TranslateResult(com.b2international.snowowl.fhir.core.model.conceptmap.TranslateResult) IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Match(com.b2international.snowowl.fhir.core.model.conceptmap.Match) Assert.assertEquals(org.junit.Assert.assertEquals) Parameters(com.b2international.snowowl.fhir.core.model.dt.Parameters) TranslateResult(com.b2international.snowowl.fhir.core.model.conceptmap.TranslateResult) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) Match(com.b2international.snowowl.fhir.core.model.conceptmap.Match) Test(org.junit.Test) FhirRestTest(com.b2international.snowowl.fhir.tests.FhirRestTest)

Example 4 with TranslateResult

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());
}
Also used : FhirTestConcepts(com.b2international.snowowl.fhir.tests.FhirTestConcepts) BeforeClass(org.junit.BeforeClass) SnomedUri(com.b2international.snowowl.snomed.fhir.SnomedUri) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) Collection(java.util.Collection) Assert.assertTrue(org.junit.Assert.assertTrue) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Test(org.junit.Test) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) Concepts(com.b2international.snowowl.snomed.common.SnomedConstants.Concepts) List(java.util.List) 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) TranslateResult(com.b2international.snowowl.fhir.core.model.conceptmap.TranslateResult) IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Match(com.b2international.snowowl.fhir.core.model.conceptmap.Match) Assert.assertEquals(org.junit.Assert.assertEquals) Parameters(com.b2international.snowowl.fhir.core.model.dt.Parameters) TranslateResult(com.b2international.snowowl.fhir.core.model.conceptmap.TranslateResult) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) Match(com.b2international.snowowl.fhir.core.model.conceptmap.Match) Test(org.junit.Test) FhirRestTest(com.b2international.snowowl.fhir.tests.FhirRestTest)

Example 5 with TranslateResult

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());
}
Also used : Parameters(com.b2international.snowowl.fhir.core.model.dt.Parameters) TranslateResult(com.b2international.snowowl.fhir.core.model.conceptmap.TranslateResult) Parameter(com.b2international.snowowl.fhir.core.model.dt.Parameter) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Match(com.b2international.snowowl.fhir.core.model.conceptmap.Match) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Aggregations

TranslateResult (com.b2international.snowowl.fhir.core.model.conceptmap.TranslateResult)7 Fhir (com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir)7 Test (org.junit.Test)7 Match (com.b2international.snowowl.fhir.core.model.conceptmap.Match)5 Parameters (com.b2international.snowowl.fhir.core.model.dt.Parameters)5 Json (com.b2international.snowowl.fhir.core.model.dt.Parameters.Json)4 FhirRestTest (com.b2international.snowowl.fhir.tests.FhirRestTest)4 FhirTest (com.b2international.snowowl.fhir.tests.FhirTest)3 IBranchPath (com.b2international.snowowl.core.api.IBranchPath)2 FhirTestConcepts (com.b2international.snowowl.fhir.tests.FhirTestConcepts)2 Concepts (com.b2international.snowowl.snomed.common.SnomedConstants.Concepts)2 SnomedUri (com.b2international.snowowl.snomed.fhir.SnomedUri)2 RestExtensions.givenAuthenticatedRequest (com.b2international.snowowl.test.commons.rest.RestExtensions.givenAuthenticatedRequest)2 JsonPath (io.restassured.path.json.JsonPath)2 Collection (java.util.Collection)2 List (java.util.List)2 Optional (java.util.Optional)2 CoreMatchers.equalTo (org.hamcrest.CoreMatchers.equalTo)2 Assert.assertEquals (org.junit.Assert.assertEquals)2 Assert.assertTrue (org.junit.Assert.assertTrue)2