Search in sources :

Example 41 with Fhir

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

the class ParameterSerializationTest method stringParameterTest.

@Test
public void stringParameterTest() throws Exception {
    @SuppressWarnings("unused")
    @JsonPropertyOrder({ "parameterName" })
    class StringTestParameterObject {

        private String parameterName = "test";

        public String getParameterName() {
            return parameterName;
        }

        public void setParameterName(String parameterName) {
            this.parameterName = parameterName;
        }
    }
    String expected = buildExpectedJson("{\"name\":\"parameterName\",\"valueString\":\"test\"}");
    Fhir fhirParameters = new Parameters.Fhir(new StringTestParameterObject());
    Assert.assertEquals(expected, objectMapper.writeValueAsString(fhirParameters));
}
Also used : Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) JsonPropertyOrder(com.fasterxml.jackson.annotation.JsonPropertyOrder) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 42 with Fhir

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

the class ParameterSerializationTest method codingParameterTest.

@Test
public void codingParameterTest() throws Exception {
    @SuppressWarnings("unused")
    @JsonPropertyOrder({ "parameterName" })
    class Test {

        private Coding parameterName = Coding.builder().code("test").display("displayTest").system("systemTest").build();

        public Coding getParameterName() {
            return parameterName;
        }

        public void setParameterName(Coding parameterName) {
            this.parameterName = parameterName;
        }
    }
    String expected = buildExpectedJson("{\"name\":\"parameterName\"," + "\"valueCoding\":{\"code\":\"test\"," + "\"system\":\"systemTest\"," + "\"display\":\"displayTest\"}}");
    Fhir fhirParameters = new Parameters.Fhir(new Test());
    Assert.assertEquals(expected, objectMapper.writeValueAsString(fhirParameters));
}
Also used : FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) JsonPropertyOrder(com.fasterxml.jackson.annotation.JsonPropertyOrder) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 43 with Fhir

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

the class TranslateRequestDeserializationTest method validRequestWithCodingTest.

@Test
public void validRequestWithCodingTest() throws Exception {
    TranslateRequest request = TranslateRequest.builder().coding(Coding.builder().system("http://hl7.org/fhir/issue-severity").code("fatal").build()).targetSystem(SnomedUri.SNOMED_BASE_URI).build();
    Fhir fhirParameters = new Parameters.Fhir(request);
    Parameter parameter = fhirParameters.getByName("coding").get();
    Coding coding = (Coding) parameter.getValue();
    assertEquals("fatal", coding.getCodeValue());
    assertEquals("http://hl7.org/fhir/issue-severity", coding.getSystem().getUriValue());
    parameter = fhirParameters.getByName("targetsystem").get();
    assertEquals(SnomedUri.SNOMED_BASE_URI_STRING, ((Uri) parameter.getValue()).getUriValue());
}
Also used : TranslateRequest(com.b2international.snowowl.fhir.core.model.conceptmap.TranslateRequest) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 44 with Fhir

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

the class TranslateRequestDeserializationTest method validRequestWithDependencyTest.

@Test
public void validRequestWithDependencyTest() throws Exception {
    Coding dependencyCoding = Coding.builder().code("1234").system("http://www.whocc.no/atc").version("20180131").build();
    CodeableConcept cc = CodeableConcept.builder().addCoding(dependencyCoding).text("text").build();
    TranslateRequest request = TranslateRequest.builder().coding(Coding.builder().system("http://hl7.org/fhir/issue-severity").code("fatal").build()).targetSystem(SnomedUri.SNOMED_BASE_URI).addDependency(Dependency.builder().element("element").concept(cc).build()).build();
    Fhir fhirParameters = new Parameters.Fhir(request);
    Parameter parameter = fhirParameters.getByName("coding").get();
    Coding coding = (Coding) parameter.getValue();
    assertEquals("fatal", coding.getCodeValue());
    assertEquals("http://hl7.org/fhir/issue-severity", coding.getSystem().getUriValue());
    parameter = fhirParameters.getByName("targetsystem").get();
    assertEquals(SnomedUri.SNOMED_BASE_URI_STRING, ((Uri) parameter.getValue()).getUriValue());
    parameter = fhirParameters.getByName("dependency").get();
    Parameters dependencyParameters = (Parameters) parameter.getValue();
    parameter = dependencyParameters.getByName("concept").get();
    assertEquals("text", ((CodeableConcept) parameter.getValue()).getText());
}
Also used : TranslateRequest(com.b2international.snowowl.fhir.core.model.conceptmap.TranslateRequest) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 45 with Fhir

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

the class ValidateCodeResultTest method fullCircleTest.

@Test
public void fullCircleTest() throws Exception {
    ValidateCodeResult request = ValidateCodeResult.builder().artefactNotFoundResult("http://hl7.org/fhir/issue-severity").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);
    ValidateCodeResult validateRequest = objectMapper.convertValue(json, ValidateCodeResult.class);
    System.out.println("... and back to the object representation we started from:" + validateRequest);
}
Also used : Parameters(com.b2international.snowowl.fhir.core.model.dt.Parameters) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) ValidateCodeResult(com.b2international.snowowl.fhir.core.model.ValidateCodeResult) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) 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