Search in sources :

Example 31 with Fhir

use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir 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 32 with Fhir

use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir in project snow-owl by b2ihealthcare.

the class ValidateFhirCodeRestTest method validCodePostTest.

@Test
public void validCodePostTest() throws Exception {
    ValidateCodeRequest request = ValidateCodeRequest.builder().code("login").build();
    Fhir fhirParameters = new Parameters.Fhir(request);
    String jsonBody = objectMapper.writeValueAsString(fhirParameters);
    givenAuthenticatedRequest(FHIR_ROOT_CONTEXT).contentType(APPLICATION_FHIR_JSON).pathParam("id", FHIR_ISSUE_TYPE_CODESYSTEM_ID).body(jsonBody).when().post("/CodeSystem/{id}/$validate-code").then().body("resourceType", equalTo("Parameters")).body("parameter[0].name", equalTo("result")).body("parameter[0].valueBoolean", equalTo(true)).statusCode(200);
}
Also used : Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) ValidateCodeRequest(com.b2international.snowowl.fhir.core.model.codesystem.ValidateCodeRequest) Test(org.junit.Test) FhirRestTest(com.b2international.snowowl.fhir.tests.FhirRestTest)

Example 33 with Fhir

use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir in project snow-owl by b2ihealthcare.

the class ExpandValueSetRequestDeserializationTest method testDeserialization.

// @Test
public void testDeserialization() {
    Coding coding = Coding.builder().system("http://hl7.org/fhir/issue-severity").code("fatal").build();
    LookupRequest request = LookupRequest.builder().coding(coding).build();
    Fhir fhirParameters = new Parameters.Fhir(request);
    fhirParameters.getParameters().forEach(p -> System.out.println(p));
    Optional<Parameter> findFirst = fhirParameters.getParameters().stream().filter(p -> {
        Coding pCoding = (Coding) p.getValue();
        return pCoding.getSystemValue().equals("http://hl7.org/fhir/issue-severity");
    }).findFirst();
    assertTrue(findFirst.isPresent());
}
Also used : OperationOutcomeCode(com.b2international.snowowl.fhir.core.codesystems.OperationOutcomeCode) ValidationException(com.b2international.snowowl.fhir.core.exceptions.ValidationException) IssueSeverity(com.b2international.snowowl.fhir.core.codesystems.IssueSeverity) Parameter(com.b2international.snowowl.fhir.core.model.dt.Parameter) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Assert.assertTrue(org.junit.Assert.assertTrue) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Test(org.junit.Test) Uri(com.b2international.snowowl.fhir.core.model.dt.Uri) LookupRequest(com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest) IssueType(com.b2international.snowowl.fhir.core.codesystems.IssueType) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) ExpandValueSetRequest(com.b2international.snowowl.fhir.core.model.valueset.ExpandValueSetRequest) Issue(com.b2international.snowowl.fhir.core.model.Issue) Optional(java.util.Optional) Builder(com.b2international.snowowl.fhir.core.model.Issue.Builder) Parameters(com.b2international.snowowl.fhir.core.model.dt.Parameters) Coding(com.b2international.snowowl.fhir.core.model.dt.Coding) FhirExceptionIssueMatcher(com.b2international.snowowl.fhir.tests.FhirExceptionIssueMatcher) Coding(com.b2international.snowowl.fhir.core.model.dt.Coding) Parameter(com.b2international.snowowl.fhir.core.model.dt.Parameter) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) LookupRequest(com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest)

Example 34 with Fhir

use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir 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 35 with Fhir

use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir in project snow-owl by b2ihealthcare.

the class ExpandValueSetRequestDeserializationTest method deserializationTest.

@Test
public void deserializationTest() throws Exception {
    ExpandValueSetRequest request = ExpandValueSetRequest.builder().url("http://valueset.url").valueSetVersion("20190101").contextDirection("direction-code").count(1).addDesignation("uk_en").addDesignation("us_en").date(TEST_DATE_STRING).filter("filter").build();
    Json json = new Parameters.Json(request);
    // System.out.println("JSON params:" + json);
    Fhir fhirParameters = new Parameters.Fhir(request);
    // fhirParameters.getParameters().forEach(p -> System.out.println(p));
    Optional<Parameter> findFirst = fhirParameters.getParameters().stream().filter(p -> {
        Uri url = (Uri) p.getValue();
        return url.getUriValue().equals("http://valueset.url");
    }).findFirst();
    assertTrue(findFirst.isPresent());
// Fhir fhir = new Parameters.Fhir(json.parameters());
// printPrettyJson(fhir);
// String fhirJson = objectMapper.writeValueAsString(fhir);
// System.out.println("This is the JSON request from the client: " + fhirJson);
}
Also used : OperationOutcomeCode(com.b2international.snowowl.fhir.core.codesystems.OperationOutcomeCode) ValidationException(com.b2international.snowowl.fhir.core.exceptions.ValidationException) IssueSeverity(com.b2international.snowowl.fhir.core.codesystems.IssueSeverity) Parameter(com.b2international.snowowl.fhir.core.model.dt.Parameter) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Assert.assertTrue(org.junit.Assert.assertTrue) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Test(org.junit.Test) Uri(com.b2international.snowowl.fhir.core.model.dt.Uri) LookupRequest(com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest) IssueType(com.b2international.snowowl.fhir.core.codesystems.IssueType) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) ExpandValueSetRequest(com.b2international.snowowl.fhir.core.model.valueset.ExpandValueSetRequest) Issue(com.b2international.snowowl.fhir.core.model.Issue) Optional(java.util.Optional) Builder(com.b2international.snowowl.fhir.core.model.Issue.Builder) Parameters(com.b2international.snowowl.fhir.core.model.dt.Parameters) Coding(com.b2international.snowowl.fhir.core.model.dt.Coding) FhirExceptionIssueMatcher(com.b2international.snowowl.fhir.tests.FhirExceptionIssueMatcher) ExpandValueSetRequest(com.b2international.snowowl.fhir.core.model.valueset.ExpandValueSetRequest) Parameter(com.b2international.snowowl.fhir.core.model.dt.Parameter) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) Uri(com.b2international.snowowl.fhir.core.model.dt.Uri) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Aggregations

Fhir (com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir)52 Test (org.junit.Test)44 FhirTest (com.b2international.snowowl.fhir.tests.FhirTest)35 Json (com.b2international.snowowl.fhir.core.model.dt.Parameters.Json)23 Parameters (com.b2international.snowowl.fhir.core.model.dt.Parameters)19 LookupRequest (com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest)11 Coding (com.b2international.snowowl.fhir.core.model.dt.Coding)10 FhirRestTest (com.b2international.snowowl.fhir.tests.FhirRestTest)9 ValidateCodeRequest (com.b2international.snowowl.fhir.core.model.codesystem.ValidateCodeRequest)8 JsonPath (io.restassured.path.json.JsonPath)8 TranslateResult (com.b2international.snowowl.fhir.core.model.conceptmap.TranslateResult)7 Optional (java.util.Optional)6 Assert.assertTrue (org.junit.Assert.assertTrue)6 Bundle (com.b2international.snowowl.fhir.core.model.Bundle)5 Entry (com.b2international.snowowl.fhir.core.model.Entry)5 Issue (com.b2international.snowowl.fhir.core.model.Issue)5 OperationOutcomeEntry (com.b2international.snowowl.fhir.core.model.OperationOutcomeEntry)5 ParametersRequestEntry (com.b2international.snowowl.fhir.core.model.ParametersRequestEntry)5 ParametersResponseEntry (com.b2international.snowowl.fhir.core.model.ParametersResponseEntry)5 ResourceRequestEntry (com.b2international.snowowl.fhir.core.model.ResourceRequestEntry)5