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"));
}
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());
}
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());
}
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());
}
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());
}
Aggregations