use of com.b2international.snowowl.fhir.core.model.codesystem.ValidateCodeRequest in project snow-owl by b2ihealthcare.
the class ValidateFhirCodeRestTest method validCodePostTest.
@Test
public void validCodePostTest() throws Exception {
ValidateCodeRequest request = ValidateCodeRequest.builder().code("login").build();
Fhir fhirParameters = new Parameters.Fhir(request);
String jsonBody = objectMapper.writeValueAsString(fhirParameters);
givenAuthenticatedRequest(FHIR_ROOT_CONTEXT).contentType(APPLICATION_FHIR_JSON).pathParam("id", FHIR_ISSUE_TYPE_CODESYSTEM_ID).body(jsonBody).when().post("/CodeSystem/{id}/$validate-code").then().body("resourceType", equalTo("Parameters")).body("parameter[0].name", equalTo("result")).body("parameter[0].valueBoolean", equalTo(true)).statusCode(200);
}
use of com.b2international.snowowl.fhir.core.model.codesystem.ValidateCodeRequest in project snow-owl by b2ihealthcare.
the class FhirCodeSystemValidateCodeOperationController method validateCode.
/**
* POST-based $validate-code end-point.
* All parameters are in the request body
* @param body - FHIR parameters
* @return out - FHIR parameters
*/
@Operation(summary = "Validate a code in a code system", description = "Validate that a coded value is in a code system.")
@ApiResponses({ @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "404", description = "Not found"), @ApiResponse(responseCode = "400", description = "Bad request") })
@PostMapping(value = "/$validate-code", consumes = AbstractFhirController.APPLICATION_FHIR_JSON)
public Promise<Parameters.Fhir> validateCode(@Parameter(description = "The validate-code request parameters") @RequestBody Parameters.Fhir body) {
final ValidateCodeRequest request = toRequest(body, ValidateCodeRequest.class);
request.validate();
return FhirRequests.codeSystems().prepareValidateCode().setRequest(request).buildAsync().execute(getBus()).then(this::toResponse);
}
use of com.b2international.snowowl.fhir.core.model.codesystem.ValidateCodeRequest in project snow-owl by b2ihealthcare.
the class ValidateCodeSystemCodeRequestTest method fullCircleTest.
@Test
public void fullCircleTest() throws Exception {
Coding coding = Coding.builder().system("http://hl7.org/fhir/issue-severity").code("fatal").build();
ValidateCodeRequest request = ValidateCodeRequest.builder().url("http://hl7.org/fhir/issue-severity").coding(coding).isAbstract(true).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);
ValidateCodeRequest validateRequest = objectMapper.convertValue(json, ValidateCodeRequest.class);
System.out.println("... and back to the object representation we started from:" + validateRequest);
}
use of com.b2international.snowowl.fhir.core.model.codesystem.ValidateCodeRequest in project snow-owl by b2ihealthcare.
the class ValidateCodeSystemCodeRequestTest method testDeserialization.
@Test
public void testDeserialization() {
Coding coding = Coding.builder().system("http://hl7.org/fhir/issue-severity").code("fatal").build();
ValidateCodeRequest request = ValidateCodeRequest.builder().url("http://hl7.org/fhir/issue-severity").coding(coding).isAbstract(true).build();
Fhir fhirParameters = new Parameters.Fhir(request);
Optional<Parameter> findFirst = fhirParameters.getParameters().stream().filter(p -> {
Uri uri = (Uri) p.getValue();
return uri.getUriValue().equals("http://hl7.org/fhir/issue-severity");
}).findFirst();
assertTrue(findFirst.isPresent());
}
use of com.b2international.snowowl.fhir.core.model.codesystem.ValidateCodeRequest in project snow-owl by b2ihealthcare.
the class ValidateCodeSystemCodeRequestTest method onlyCodeSpecifiedTest.
@Test
public void onlyCodeSpecifiedTest() {
// This is valid as the code system can also be provided as a path parameter
ValidateCodeRequest request = ValidateCodeRequest.builder().code("A").build();
assertEquals("A", request.getCode());
}
Aggregations