Search in sources :

Example 21 with Fhir

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

the class ParameterDeserializationTest method lookupRequestCodingTest.

@Test
public void lookupRequestCodingTest() throws Exception {
    String jsonParam = "{\"resourceType\":\"Parameters\"," + "\"parameter\":[" + "{\"name\":\"code\",\"valueCode\":\"1234\"}," + "{\"name\":\"system\",\"valueUri\":\"http://snomed.info/sct/version/20180131\"}," + "{\"name\":\"date\",\"valueDateTime\":\"2018-03-09T20:50:21.000+0100\"}," + "{\"name\":\"displayLanguage\",\"valueCode\":\"us-en\"}," + "{\"name\":\"property\",\"valueCode\":\"prop1\"}," + "{\"name\":\"property\",\"valueCode\":\"prop2\"}," + "{\"name\":\"coding\", \"valueCoding\":" + "{\"code\":\"1234\"," + "\"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);
    LookupRequest lookupRequest = objectMapper.convertValue(fhirParameters.toJson(), LookupRequest.class);
    assertEquals("1234", lookupRequest.getCode());
    assertEquals("http://snomed.info/sct/version/20180131", lookupRequest.getSystem());
    assertEquals(Dates.parse("2018-03-09T20:50:21.000+0100", FhirDates.DATE_TIME_FORMAT), lookupRequest.getDate());
    assertEquals("us-en", lookupRequest.getDisplayLanguage().getCodeValue());
    Coding coding = lookupRequest.getCoding();
    assertEquals("1234", coding.getCodeValue());
    assertEquals("http://snomed.info/sct/version/20180131", coding.getSystemValue());
    assertEquals(false, coding.isUserSelected());
    assertFalse(lookupRequest.getProperties().isEmpty());
    Collection<String> properties = lookupRequest.getPropertyCodes();
    assertThat(properties.toArray(), arrayContainingInAnyOrder("prop1", "prop2"));
}
Also used : 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 22 with Fhir

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

the class ParameterSerializationTest method integerParameterTest.

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

        private Integer parameterName = 1;

        public Integer getParameterName() {
            return parameterName;
        }

        public void setParameterName(Integer parameterName) {
            this.parameterName = parameterName;
        }
    }
    String expected = buildExpectedJson("{\"name\":\"parameterName\",\"valueInteger\":1}");
    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 23 with Fhir

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

the class ParameterSerializationTest method collectionParameterTest.

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

        @FhirType(FhirDataType.PART)
        private Collection<Code> parameterName = Lists.newArrayList(new Code("first"), new Code("second"));

        public Collection<Code> getParameterName() {
            return parameterName;
        }

        public void setParameterName(Collection<Code> parameterName) {
            this.parameterName = parameterName;
        }
    }
    String expected = buildExpectedJson("{\"name\":\"parameterName\"," + "\"part\":[{" + "\"name\":\"codeValue\"," + "\"valueCode\":\"first\"" + "}]" + "},{" + "\"name\":\"parameterName\"," + "\"part\":[{" + "\"name\":\"codeValue\"," + "\"valueCode\":\"second\"" + "}]}");
    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) Collection(java.util.Collection) 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 24 with Fhir

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

the class ParameterSerializationTest method codeParameterTest.

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

        private Code parameterName = new Code("test");

        public Code getParameterName() {
            return parameterName;
        }

        public void setParameterName(Code parameterName) {
            this.parameterName = parameterName;
        }
    }
    String expected = buildExpectedJson("{\"name\":\"parameterName\",\"valueCode\":\"test\"}");
    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 25 with Fhir

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

the class ParameterSerializationTest method codeableConceptParameterTest.

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

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

        public CodeableConcept getParameterName() {
            return parameterName;
        }

        public void setParameterName(CodeableConcept parameterName) {
            this.parameterName = parameterName;
        }
    }
    String expected = buildExpectedJson("{\"name\":\"parameterName\"," + "\"valueCodeableConcept\":{\"text\":\"textTest\"," + "\"coding\":[{\"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)

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