use of com.b2international.snowowl.fhir.core.model.dt.Parameters in project snow-owl by b2ihealthcare.
the class BundleTest method buildMixedBundle.
@Test
public void buildMixedBundle() throws Exception {
LookupResult lookupResult = LookupResult.builder().name("test").display("display").addDesignation(Designation.builder().value("dValue").languageCode("uk").build()).addProperty(Property.builder().code("1234").description("propDescription").valueString("stringValue").build()).build();
OperationOutcome operationOutcome = OperationOutcome.builder().addIssue(Issue.builder().code(IssueType.CODE_INVALID).diagnostics("Invalid code").severity(IssueSeverity.ERROR).build()).build();
Json json1 = new Parameters.Json(lookupResult);
ParametersResponseEntry lookupResultEntry = ParametersResponseEntry.builder().resource(new Parameters.Fhir(json1.parameters())).response(BatchResponse.createOkResponse()).build();
OperationOutcomeEntry operationOutcomeEntry = OperationOutcomeEntry.builder().operationOutcome(operationOutcome).build();
Bundle bundle = Bundle.builder().language("en").type(BundleType.BATCH_RESPONSE).addLink("self", "http://localhost:8080/snowowl/CodeSystem").addEntry(lookupResultEntry).addEntry(operationOutcomeEntry).build();
assertEquals("en", bundle.getLanguage().getCodeValue());
assertEquals(BundleType.BATCH_RESPONSE.getCode(), bundle.getType());
Link link = bundle.getLink().iterator().next();
assertEquals("self", link.getRelation());
assertEquals("http://localhost:8080/snowowl/CodeSystem", link.getUrl().getUriValue());
Iterator<Entry> iterator = bundle.getItems().iterator();
Entry bundleEntry = iterator.next();
assertTrue(bundleEntry instanceof ParametersResponseEntry);
ParametersResponseEntry responseEntry = (ParametersResponseEntry) bundleEntry;
assertEquals("200", responseEntry.getResponse().getStatus());
Fhir requestResource = responseEntry.getResponseResource();
// Back to Domain JSON...
Json json = new Parameters.Json(requestResource);
LookupResult returnedResponse = objectMapper.convertValue(json, LookupResult.class);
assertEquals("test", returnedResponse.getName());
assertEquals("display", returnedResponse.getDisplay());
bundleEntry = iterator.next();
assertTrue(bundleEntry instanceof OperationOutcomeEntry);
OperationOutcomeEntry ooce = (OperationOutcomeEntry) bundleEntry;
Collection<Issue> issues = ooce.getOperationOutcome().getIssues();
assertEquals(1, issues.size());
assertEquals(IssueSeverity.ERROR.getCode(), issues.iterator().next().getSeverity());
}
use of com.b2international.snowowl.fhir.core.model.dt.Parameters 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.Parameters in project snow-owl by b2ihealthcare.
the class ValidateFhirCodeRestTest method convertToValidateCodeResult.
private ValidateCodeResult convertToValidateCodeResult(String responseString) throws Exception {
Fhir parameters = objectMapper.readValue(responseString, Parameters.Fhir.class);
Json json = new Parameters.Json(parameters);
return objectMapper.convertValue(json, ValidateCodeResult.class);
}
use of com.b2international.snowowl.fhir.core.model.dt.Parameters in project snow-owl by b2ihealthcare.
the class LookupRequestDeserializationTest method fullCircleTest.
@Test
public void fullCircleTest() throws Exception {
Coding coding = Coding.builder().system("http://hl7.org/fhir/issue-severity").code("fatal").build();
LookupRequest request = LookupRequest.builder().coding(coding).build();
Json json1 = new Parameters.Json(request);
System.out.println("JSON params:" + json1);
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);
LookupRequest lookupRequest = objectMapper.convertValue(json, LookupRequest.class);
System.out.println("... and back to the object representation we started from:" + lookupRequest);
}
use of com.b2international.snowowl.fhir.core.model.dt.Parameters in project snow-owl by b2ihealthcare.
the class SandBoxRestTest method convertToSubsumptionResult.
private SubsumptionResult convertToSubsumptionResult(String responseString) throws Exception {
Fhir parameters = objectMapper.readValue(responseString, Parameters.Fhir.class);
Json json = new Parameters.Json(parameters);
return objectMapper.convertValue(json, SubsumptionResult.class);
}
Aggregations