use of com.b2international.snowowl.fhir.core.model.dt.Parameter in project snow-owl by b2ihealthcare.
the class SandBoxRestTest method buildCode.
// @Test
public void buildCode() throws IOException {
Coding coding = Coding.builder().system("http://hl7.org/fhir/issue-severity").code("fatal").build();
LookupRequest request = LookupRequest.builder().coding(coding).addProperty("name").build();
Json json1 = new Parameters.Json(request);
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);
Parameters parameters2 = json.parameters();
List<Parameter> parameters3 = parameters2.getParameters();
for (Parameter parameter : parameters3) {
System.out.println("P: " + parameter);
}
LookupRequest lookupRequest = objectMapper.convertValue(json, LookupRequest.class);
System.out.println("... and back to the object representation we started from:" + lookupRequest);
Json finalJson = new Parameters.Json(lookupRequest);
Fhir finalFhir = new Parameters.Fhir(finalJson.parameters());
String stringJson = objectMapper.writeValueAsString(finalFhir);
System.out.println("Final final: " + stringJson);
/*
*/
// String jsonBody = objectMapper.writeValueAsString(fhirParameters);
// System.out.println("Json: " + jsonBody);
}
use of com.b2international.snowowl.fhir.core.model.dt.Parameter in project snow-owl by b2ihealthcare.
the class ExpandValueSetRequestDeserializationTest 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.Parameter in project snow-owl by b2ihealthcare.
the class ExpandValueSetRequestDeserializationTest method deserializationTest.
@Test
public void deserializationTest() throws Exception {
ExpandValueSetRequest request = ExpandValueSetRequest.builder().url("http://valueset.url").valueSetVersion("20190101").contextDirection("direction-code").count(1).addDesignation("uk_en").addDesignation("us_en").date(TEST_DATE_STRING).filter("filter").build();
Json json = new Parameters.Json(request);
// System.out.println("JSON params:" + json);
Fhir fhirParameters = new Parameters.Fhir(request);
// fhirParameters.getParameters().forEach(p -> System.out.println(p));
Optional<Parameter> findFirst = fhirParameters.getParameters().stream().filter(p -> {
Uri url = (Uri) p.getValue();
return url.getUriValue().equals("http://valueset.url");
}).findFirst();
assertTrue(findFirst.isPresent());
// Fhir fhir = new Parameters.Fhir(json.parameters());
// printPrettyJson(fhir);
// String fhirJson = objectMapper.writeValueAsString(fhir);
// System.out.println("This is the JSON request from the client: " + fhirJson);
}
use of com.b2international.snowowl.fhir.core.model.dt.Parameter 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.Parameter in project snow-owl by b2ihealthcare.
the class TranslateResultSerializationTest method validResultTest.
@Test
public void validResultTest() throws Exception {
Match match = Match.builder().equivalence(ConceptMapEquivalence.EQUAL).build();
Match match2 = Match.builder().equivalence(ConceptMapEquivalence.DISJOINT).build();
TranslateResult translateResult = TranslateResult.builder().message("This is a test result").addMatch(match).addMatch(match2).build();
Fhir fhirParameters = new Parameters.Fhir(translateResult);
Parameter parameter = fhirParameters.getByName("result").get();
Boolean result = (Boolean) parameter.getValue();
assertEquals(true, result.booleanValue());
parameter = fhirParameters.getByName("message").get();
String message = (String) parameter.getValue();
assertEquals("This is a test result", message);
parameter = fhirParameters.getByName("match").get();
Parameters matchParameters = (Parameters) parameter.getValue();
parameter = matchParameters.getByName("equivalence").get();
assertEquals("equal", ((Code) parameter.getValue()).getCodeValue());
}
Aggregations