Search in sources :

Example 11 with Parameters

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

Example 12 with Parameters

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());
}
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 13 with Parameters

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());
}
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 14 with Parameters

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);
}
Also used : Parameters(com.b2international.snowowl.fhir.core.model.dt.Parameters) Coding(com.b2international.snowowl.fhir.core.model.dt.Coding) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) LookupRequest(com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest)

Example 15 with Parameters

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

Aggregations

Parameters (com.b2international.snowowl.fhir.core.model.dt.Parameters)18 Fhir (com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir)16 Json (com.b2international.snowowl.fhir.core.model.dt.Parameters.Json)14 Test (org.junit.Test)13 FhirTest (com.b2international.snowowl.fhir.tests.FhirTest)8 LookupRequest (com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest)5 Match (com.b2international.snowowl.fhir.core.model.conceptmap.Match)5 TranslateResult (com.b2international.snowowl.fhir.core.model.conceptmap.TranslateResult)5 FhirRestTest (com.b2international.snowowl.fhir.tests.FhirRestTest)5 Coding (com.b2international.snowowl.fhir.core.model.dt.Coding)4 Bundle (com.b2international.snowowl.fhir.core.model.Bundle)3 Entry (com.b2international.snowowl.fhir.core.model.Entry)3 OperationOutcomeEntry (com.b2international.snowowl.fhir.core.model.OperationOutcomeEntry)3 ParametersRequestEntry (com.b2international.snowowl.fhir.core.model.ParametersRequestEntry)3 ParametersResponseEntry (com.b2international.snowowl.fhir.core.model.ParametersResponseEntry)3 ResourceRequestEntry (com.b2international.snowowl.fhir.core.model.ResourceRequestEntry)3 ResourceResponseEntry (com.b2international.snowowl.fhir.core.model.ResourceResponseEntry)3 LookupResult (com.b2international.snowowl.fhir.core.model.codesystem.LookupResult)3 Concepts (com.b2international.snowowl.snomed.common.SnomedConstants.Concepts)3 RestExtensions.givenAuthenticatedRequest (com.b2international.snowowl.test.commons.rest.RestExtensions.givenAuthenticatedRequest)3