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