use of com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest in project snow-owl by b2ihealthcare.
the class FhirBatchApiRestTest method singleRequestWithInvalidParameters.
@Test
public void singleRequestWithInvalidParameters() {
LookupRequest request = LookupRequest.builder().coding(Coding.builder().system("http://snomed.info/sct").code(Concepts.IS_A).build()).build();
Json json = new Parameters.Json(request);
ParametersRequestEntry entry = ParametersRequestEntry.builder().request(BatchRequest.createPostRequest("CodeSystem/$lookup")).resource(new Parameters.Fhir(json.parameters())).build();
// Completely invalid request
RequestEntry entry2 = RequestEntry.builder().request(BatchRequest.createGetRequest("CodeSystem/$lookup?system=whatever?code=1234")).build();
Bundle bundle = Bundle.builder().language("en").total(2).type(BundleType.BATCH).addEntry(entry).addEntry(entry2).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")).body("entry[0].response.status", equalTo("200")).body("entry[0].resource.resourceType", equalTo("Parameters")).body("entry[1].response.status", equalTo("500")).body("entry[1].resource.resourceType", equalTo("OperationOutcome"));
}
use of com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest 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.codesystem.LookupRequest in project snow-owl by b2ihealthcare.
the class ExpandValueSetRequestDeserializationTest method fullCircleTest.
// @Test
public void fullCircleTest() throws Exception {
Coding coding = Coding.builder().system("http://hl7.org/fhir/issue-severity").code("fatal").build();
System.out.println("Building the lookup request object.");
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.codesystem.LookupRequest 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());
}
Aggregations