Search in sources :

Example 36 with Fhir

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

the class LookupResultSerializationTest method lookupResultTest.

@Test
public void lookupResultTest() throws Exception {
    LookupResult lookupResult = LookupResult.builder().name("test").display("display").designation(List.of(Designation.builder().value("dValue").languageCode("uk").build())).property(List.of(Property.builder().code("1234").description("propDescription").valueString("sds").addSubProperty(SubProperty.builder().code("subCode").description("subDescription").valueInteger(1).build()).build())).build();
    Fhir fhirParameters = new Parameters.Fhir(lookupResult);
    JsonPath jsonPath = JsonPath.from(objectMapper.writeValueAsString(fhirParameters));
    assertThat(jsonPath.getString("resourceType"), equalTo("Parameters"));
    assertThat(jsonPath.getList("parameter.name"), hasItems("name", "display", "designation", "property"));
    assertThat(jsonPath, FhirParameterMatcher.hasParameter("name", FhirDataType.STRING, "test"));
    assertThat(jsonPath, FhirParameterMatcher.hasParameter("display", FhirDataType.STRING, "display"));
    assertThat(jsonPath.getString("parameter[2].name"), equalTo("designation"));
    assertThat(jsonPath.getString("parameter[2].part[0].name"), equalTo("language"));
    assertThat(jsonPath.getString("parameter[2].part[0].valueCode"), equalTo("uk"));
    assertThat(jsonPath.getString("parameter[2].part[1].name"), equalTo("value"));
    assertThat(jsonPath.getString("parameter[2].part[1].valueString"), equalTo("dValue"));
    assertThat(jsonPath.getString("parameter[3].name"), equalTo("property"));
    assertThat(jsonPath.getString("parameter[3].part[0].name"), equalTo("code"));
    assertThat(jsonPath.getString("parameter[3].part[0].valueCode"), equalTo("1234"));
    assertThat(jsonPath.getString("parameter[3].part[1].name"), equalTo("value"));
    assertThat(jsonPath.getString("parameter[3].part[1].valueString"), equalTo("sds"));
    assertThat(jsonPath.getString("parameter[3].part[2].name"), equalTo("description"));
    assertThat(jsonPath.getString("parameter[3].part[2].valueString"), equalTo("propDescription"));
    assertThat(jsonPath.getString("parameter[3].part[3].name"), equalTo("subproperty"));
    assertThat(jsonPath.getString("parameter[3].part[3].part[0].name"), equalTo("code"));
    assertThat(jsonPath.getString("parameter[3].part[3].part[0].valueCode"), equalTo("subCode"));
    assertThat(jsonPath.getString("parameter[3].part[3].part[1].name"), equalTo("value"));
    assertThat(jsonPath.getInt("parameter[3].part[3].part[1].valueInteger"), equalTo(1));
    assertThat(jsonPath.getString("parameter[3].part[3].part[2].name"), equalTo("description"));
    assertThat(jsonPath.getString("parameter[3].part[3].part[2].valueString"), equalTo("subDescription"));
}
Also used : LookupResult(com.b2international.snowowl.fhir.core.model.codesystem.LookupResult) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) JsonPath(io.restassured.path.json.JsonPath) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 37 with Fhir

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

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

the class ParameterDeserializationTest method arrayParameterTest.

@Test
public void arrayParameterTest() throws Exception {
    String jsonParam = "{\"resourceType\":\"Parameters\"," + "\"parameter\":[" + "{\"name\":\"designation\",\"part\":[" + "{\"name\":\"value\",\"valueString\":\"Bicarbonate [Moles/volume] in Serum\"}" + "]" + "}]}";
    Fhir fhirParameters = objectMapper.readValue(jsonParam, Parameters.Fhir.class);
    Optional<Parameter> parameterOptional = fhirParameters.getParameters().stream().findFirst();
    assertTrue(parameterOptional.isPresent());
    Parameter parameter = parameterOptional.get();
    assertEquals("designation", parameter.getName());
    assertEquals(FhirDataType.PART, parameter.getType());
    Parameters parameters = (Parameters) parameter.getValue();
    Parameter designationParamater = parameters.getParameters().stream().findFirst().get();
    assertEquals("value", designationParamater.getName());
    assertEquals(FhirDataType.STRING, designationParamater.getType());
    assertEquals("Bicarbonate [Moles/volume] in Serum", designationParamater.getValue());
}
Also used : Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 39 with Fhir

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

the class ParameterDeserializationTest method codingParameterTest.

@Test
public void codingParameterTest() throws Exception {
    String jsonParam = "{\"resourceType\":\"Parameters\"," + "\"parameter\":[" + "{\"name\":\"use\", \"valueCoding\":{\"code\":\"1234\"," + "\"system\":\"http://snomed.info/sct/version/20180131\"," + "\"userSelected\":false}" + "}]}";
    Fhir fhirParameters = objectMapper.readValue(jsonParam, Parameters.Fhir.class);
    Optional<Parameter> parameterOptional = fhirParameters.getParameters().stream().findFirst();
    assertTrue(parameterOptional.isPresent());
    Parameter parameter = parameterOptional.get();
    assertEquals("use", parameter.getName());
    assertEquals(FhirDataType.CODING, parameter.getType());
    Coding coding = (Coding) parameter.getValue();
    assertEquals("1234", coding.getCodeValue());
    assertEquals("http://snomed.info/sct/version/20180131", coding.getSystemValue());
    assertEquals(false, coding.isUserSelected());
}
Also used : Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 40 with Fhir

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

the class ParameterDeserializationTest method codeableConceptParameterTest.

@Test
public void codeableConceptParameterTest() throws Exception {
    String jsonParam = "{\"resourceType\":\"Parameters\"," + "\"parameter\":[" + "{\"name\":\"codeableConcept\", \"valueCodeableConcept\":{\"text\":\"textTest\"," + "\"coding\":[{\"code\":\"test\"," + "\"system\":\"systemTest\"," + "\"display\":\"displayTest\"}]" + "}" + "}]}";
    Fhir fhirParameters = objectMapper.readValue(jsonParam, Parameters.Fhir.class);
    Optional<Parameter> parameterOptional = fhirParameters.getParameters().stream().findFirst();
    Parameter parameter = parameterOptional.get();
    assertEquals("codeableConcept", parameter.getName());
    assertEquals(FhirDataType.CODEABLECONCEPT, parameter.getType());
    CodeableConcept codeableConcept = (CodeableConcept) parameter.getValue();
    assertEquals("textTest", codeableConcept.getText());
    Coding coding = codeableConcept.getCodings().iterator().next();
    assertEquals("test", coding.getCodeValue());
    assertEquals("systemTest", coding.getSystemValue());
    assertEquals("displayTest", coding.getDisplay());
}
Also used : Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) 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