use of com.b2international.snowowl.fhir.core.model.ParametersResponseEntry 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.ParametersResponseEntry in project snow-owl by b2ihealthcare.
the class BundleTest method buildResponseBundle.
@Test
public void buildResponseBundle() 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").addSubProperty(SubProperty.builder().code("subCode").description("subCodeDescription").valueInteger(1).build()).build()).build();
Json json1 = new Parameters.Json(lookupResult);
ParametersResponseEntry entry = ParametersResponseEntry.builder().resource(new Parameters.Fhir(json1.parameters())).response(BatchResponse.createOkResponse()).build();
Bundle bundle = Bundle.builder().language("en").type(BundleType.BATCH_RESPONSE).addLink("self", "http://localhost:8080/snowowl/CodeSystem").addEntry(entry).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());
Entry bundleEntry = bundle.getItems().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());
}
use of com.b2international.snowowl.fhir.core.model.ParametersResponseEntry in project snow-owl by b2ihealthcare.
the class BundleTest method deserializeResponseBundle.
@Test
public void deserializeResponseBundle() throws Exception {
String jsonResponse = "{\"resourceType\":\"Bundle\"," + "\"id\":\"ID\"," + "\"type\":\"batch-response\"," + "\"link\":[" + "{" + "\"relation\":\"self\"," + "\"url\":\"http://b2i.sg\"" + "}" + "]," + "\"entry\":[" + "{" + "\"resource\":{" + "\"resourceType\":\"Parameters\"," + "\"parameter\":[" + "{" + "\"name\":\"name\"," + "\"valueString\":\"LOINC\"" + "}," + "{" + "\"name\":\"version\"," + "\"valueString\":\"2.61\"" + "}," + "{" + "\"name\":\"display\"," + "\"valueString\":\"LOINC code label\"" + "}," + "{" + "\"name\":\"property\"," + "\"part\":[" + "{" + "\"name\":\"code\"," + "\"valueCode\":\"parent\"" + "}," + "{" + "\"name\":\"value\"," + "\"valueCode\":\"Parent code\"" + "}" + "]" + "}," + "{" + "\"name\":\"designation\"," + "\"part\":[" + "{" + "\"name\":\"language\"," + "\"valueCode\":\"en\"" + "}," + "{" + "\"name\":\"use\"," + "\"valueCoding\":{" + "\"system\":\"http://snomed.info/sct\"," + "\"code\":\"900000000000013009\"," + "\"display\":\"Synonym\"" + "}" + "}," + "{" + "\"name\":\"value\"," + "\"valueString\":\"SNOMED CT synonym\"" + "}" + "]" + "}" + "]" + "}," + "\"response\":{" + "\"status\":\"200\"" + "}" + "}" + "]" + "}";
Bundle bundle = objectMapper.readValue(jsonResponse, Bundle.class);
assertEquals(BundleType.BATCH_RESPONSE.getCode(), bundle.getType());
Iterator<Entry> iterator = bundle.getItems().iterator();
Entry bundleEntry = iterator.next();
assertTrue(bundleEntry instanceof ParametersResponseEntry);
ParametersResponseEntry responseEntry = (ParametersResponseEntry) bundleEntry;
Fhir responseResource = responseEntry.getResponseResource();
// Back to Domain JSON...
Json json = new Parameters.Json(responseResource);
LookupResult lookupResult = objectMapper.convertValue(json, LookupResult.class);
assertEquals("LOINC", lookupResult.getName());
}
Aggregations