Search in sources :

Example 1 with Parameter

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

the class SandBoxRestTest method buildCode.

// @Test
public void buildCode() throws IOException {
    Coding coding = Coding.builder().system("http://hl7.org/fhir/issue-severity").code("fatal").build();
    LookupRequest request = LookupRequest.builder().coding(coding).addProperty("name").build();
    Json json1 = new Parameters.Json(request);
    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);
    Parameters parameters2 = json.parameters();
    List<Parameter> parameters3 = parameters2.getParameters();
    for (Parameter parameter : parameters3) {
        System.out.println("P: " + parameter);
    }
    LookupRequest lookupRequest = objectMapper.convertValue(json, LookupRequest.class);
    System.out.println("... and back to the object representation we started from:" + lookupRequest);
    Json finalJson = new Parameters.Json(lookupRequest);
    Fhir finalFhir = new Parameters.Fhir(finalJson.parameters());
    String stringJson = objectMapper.writeValueAsString(finalFhir);
    System.out.println("Final final: " + stringJson);
/*
			*/
// String jsonBody = objectMapper.writeValueAsString(fhirParameters);
// System.out.println("Json: " + jsonBody);
}
Also used : Parameters(com.b2international.snowowl.fhir.core.model.dt.Parameters) 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) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) LookupRequest(com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest)

Example 2 with Parameter

use of com.b2international.snowowl.fhir.core.model.dt.Parameter 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 3 with Parameter

use of com.b2international.snowowl.fhir.core.model.dt.Parameter 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)

Example 4 with Parameter

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

the class LookupRequestDeserializationTest 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) 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) 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) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 5 with Parameter

use of com.b2international.snowowl.fhir.core.model.dt.Parameter 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

Parameter (com.b2international.snowowl.fhir.core.model.dt.Parameter)5 Parameters (com.b2international.snowowl.fhir.core.model.dt.Parameters)5 Fhir (com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir)5 LookupRequest (com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest)4 Coding (com.b2international.snowowl.fhir.core.model.dt.Coding)4 Json (com.b2international.snowowl.fhir.core.model.dt.Parameters.Json)4 FhirTest (com.b2international.snowowl.fhir.tests.FhirTest)4 Test (org.junit.Test)4 IssueSeverity (com.b2international.snowowl.fhir.core.codesystems.IssueSeverity)3 IssueType (com.b2international.snowowl.fhir.core.codesystems.IssueType)3 OperationOutcomeCode (com.b2international.snowowl.fhir.core.codesystems.OperationOutcomeCode)3 ValidationException (com.b2international.snowowl.fhir.core.exceptions.ValidationException)3 Issue (com.b2international.snowowl.fhir.core.model.Issue)3 Builder (com.b2international.snowowl.fhir.core.model.Issue.Builder)3 FhirExceptionIssueMatcher (com.b2international.snowowl.fhir.tests.FhirExceptionIssueMatcher)3 Optional (java.util.Optional)3 Assert.assertTrue (org.junit.Assert.assertTrue)3 Uri (com.b2international.snowowl.fhir.core.model.dt.Uri)2 ExpandValueSetRequest (com.b2international.snowowl.fhir.core.model.valueset.ExpandValueSetRequest)2 Match (com.b2international.snowowl.fhir.core.model.conceptmap.Match)1