use of com.b2international.snowowl.fhir.core.model.ParametersRequestEntry in project snow-owl by b2ihealthcare.
the class SandBoxRestTest method bulkRequestTest.
// @Test
public void bulkRequestTest() {
LookupRequest lookupRequest = LookupRequest.builder().code("23245-4").system("http://loinc.org").build();
Json json1 = new Parameters.Json(lookupRequest);
System.out.println("JSON params:" + json1);
ParametersRequestEntry entry = ParametersRequestEntry.builder().request(BatchRequest.createPostRequest("CodeSystem/$lookup")).resource(new Parameters.Fhir(json1.parameters())).build();
Bundle bundle = Bundle.builder().language("en").total(1).type(BundleType.BATCH).addEntry(entry).build();
givenAuthenticatedRequest(FHIR_ROOT_CONTEXT).contentType(APPLICATION_FHIR_JSON).body(bundle).when().post("/").prettyPeek().then().statusCode(200).body("resourceType", equalTo("Bundle")).body("type", is("batch-response"));
}
use of com.b2international.snowowl.fhir.core.model.ParametersRequestEntry in project snow-owl by b2ihealthcare.
the class BundleTest method deserializeRequestBundle.
@Test
public void deserializeRequestBundle() throws Exception {
String jsonCoding = "{ \"type\" : \"batch\", " + "\"resourceType\" : \"Bundle\", " + "\"entry\" : " + "[{\"request\" : " + "{\"method\" : \"POST\"," + "\"url\" : \"CodeSystem/$lookup\"}," + "\"resource\" : " + "{\"resourceType\" : \"Parameters\"," + "\"parameter\" : [" + "{\"valueUri\" : \"http://loinc.org\"," + "\"name\" : \"system\"}," + "{\"valueCode\" : \"23245-4\"," + "\"name\" : \"code\"}" + "]" + "}" + "}," + "{\"request\" : " + "{\"method\" : \"POST\"," + "\"url\" : \"CodeSystem/$lookup\"}," + "\"resource\" : " + "{\"resourceType\" : \"Parameters\"," + "\"parameter\" : [" + "{\"name\" : \"system\"," + "\"valueUri\" : \"http://snomed.info/sct\"}" + ",{\"valueCode\" : \"263495000\"," + "\"name\" : \"code\"}" + "]" + "}}" + "]}";
Bundle bundle = objectMapper.readValue(jsonCoding, Bundle.class);
assertEquals(BundleType.BATCH.getCode(), bundle.getType());
Iterator<Entry> iterator = bundle.getItems().iterator();
Entry bundleEntry = iterator.next();
assertTrue(bundleEntry instanceof ParametersRequestEntry);
ParametersRequestEntry requestEntry = (ParametersRequestEntry) bundleEntry;
BatchRequest batchRequest = requestEntry.getRequest();
assertEquals(HttpVerb.POST.getCode(), batchRequest.getMethod());
assertEquals("CodeSystem/$lookup", batchRequest.getUrl().getUriValue());
Fhir requestResource = requestEntry.getRequestResource();
// Back to Domain JSON...
Json json = new Parameters.Json(requestResource);
LookupRequest returnedLookupRequest = objectMapper.convertValue(json, LookupRequest.class);
assertEquals("23245-4", returnedLookupRequest.getCode());
assertEquals("http://loinc.org", returnedLookupRequest.getSystem());
bundleEntry = iterator.next();
assertTrue(bundleEntry instanceof ParametersRequestEntry);
requestEntry = (ParametersRequestEntry) bundleEntry;
batchRequest = requestEntry.getRequest();
assertEquals(HttpVerb.POST.getCode(), batchRequest.getMethod());
assertEquals("CodeSystem/$lookup", batchRequest.getUrl().getUriValue());
requestResource = requestEntry.getRequestResource();
// Back to Domain JSON...
json = new Parameters.Json(requestResource);
returnedLookupRequest = objectMapper.convertValue(json, LookupRequest.class);
assertEquals("263495000", returnedLookupRequest.getCode());
assertEquals("http://snomed.info/sct", returnedLookupRequest.getSystem());
}
use of com.b2international.snowowl.fhir.core.model.ParametersRequestEntry in project snow-owl by b2ihealthcare.
the class BundleTest method buildRequestBundle.
@Test
public void buildRequestBundle() throws Exception {
LookupRequest lookupRequest = LookupRequest.builder().code("23245-4").system("http://loinc.org").build();
Json json1 = new Parameters.Json(lookupRequest);
ParametersRequestEntry entry = ParametersRequestEntry.builder().request(BatchRequest.createPostRequest("CodeSystem/$lookup")).resource(new Parameters.Fhir(json1.parameters())).build();
Bundle bundle = Bundle.builder().language("en").total(1).type(BundleType.BATCH).addLink("self", "http://localhost:8080/snowowl/CodeSystem").addEntry(entry).build();
assertEquals("en", bundle.getLanguage().getCodeValue());
assertEquals(1, bundle.getTotal());
assertEquals(BundleType.BATCH.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 ParametersRequestEntry);
ParametersRequestEntry requestEntry = (ParametersRequestEntry) bundleEntry;
BatchRequest batchRequest = requestEntry.getRequest();
assertEquals(HttpVerb.POST.getCode(), batchRequest.getMethod());
assertEquals("CodeSystem/$lookup", batchRequest.getUrl().getUriValue());
Fhir requestResource = requestEntry.getRequestResource();
// Back to Domain JSON...
Json json = new Parameters.Json(requestResource);
LookupRequest returnedLookupRequest = objectMapper.convertValue(json, LookupRequest.class);
assertEquals("23245-4", returnedLookupRequest.getCode());
assertEquals("http://loinc.org", returnedLookupRequest.getSystem());
}
Aggregations