use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir in project snow-owl by b2ihealthcare.
the class ValidateFhirCodeRestTest method invalidParametersOnInstancePostTest.
@Test
public void invalidParametersOnInstancePostTest() throws Exception {
// URL
ValidateCodeRequest request = ValidateCodeRequest.builder().url(// should not be specified on the instance level
"fhir/issue-severity").code("fatal").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("OperationOutcome")).body("issue.severity", hasItem("error")).body("issue.code", hasItem("invalid")).body("issue.diagnostics", hasItem("Parameter 'url' cannot be specified when the code system ID is set.")).body("issue.details.text", hasItem("Parameter 'ValidateCodeRequest.url' content is invalid")).statusCode(400);
// Coding
request = ValidateCodeRequest.builder().coding(// should not be specified on the instance level
Coding.builder().system("http://hl7.org/fhir/issue-severity").code("fatal").build()).build();
fhirParameters = new Parameters.Fhir(request);
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("OperationOutcome")).body("issue.severity", hasItem("error")).body("issue.code", hasItem("invalid")).body("issue.diagnostics", hasItem("Parameter 'coding' cannot be specified when the code system ID is set.")).body("issue.details.text", hasItem("Parameter 'ValidateCodeRequest.coding' content is invalid")).statusCode(400);
// CodeableConcept
request = ValidateCodeRequest.builder().codeableConcept(// should not be specified on the instance level
CodeableConcept.builder().addCoding(Coding.builder().system("http://hl7.org/fhir/issue-severity").code("fatal").build()).build()).build();
fhirParameters = new Parameters.Fhir(request);
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("OperationOutcome")).body("issue.severity", hasItem("error")).body("issue.code", hasItem("invalid")).body("issue.diagnostics", hasItem("Parameter 'codeableConcept' cannot be specified when the code system ID is set.")).body("issue.details.text", hasItem("Parameter 'ValidateCodeRequest.codeableConcept' content is invalid")).statusCode(400);
}
use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir in project snow-owl by b2ihealthcare.
the class FhirCodeSystemValidateCodeOperationController method validateCode.
/**
* HTTP Get request to validate that a coded value is in the code system specified by the ID param in the path.
* The code system is identified by its Code System ID within the path - 'instance' level call
* If the operation is not called at the instance level, one of the parameters "url" or "codeSystem" must be provided.
* The operation returns a result (true / false), an error message, and the recommended display for the code.
* When invoking this operation, a client SHALL provide one (and only one) of the parameters (code+system, coding, or codeableConcept).
* Other parameters (including version and display) are optional.
*
* @param codeSystemId the code system to validate against
* @param code to code to validate
* @param version the version of the code system to validate against
* @param date the date for which the validation should be checked
* @param isAbstract If this parameter has a value of true, the client is stating that the validation is being performed in a context
* where a concept designated as 'abstract' is appropriate/allowed.
*
* @return validation results as {@link OperationOutcome}
*/
@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 = "400", description = "Bad request"), @ApiResponse(responseCode = "404", description = "Code system not found") })
@GetMapping("/{codeSystemId:**}/$validate-code")
public Promise<Parameters.Fhir> validateCode(@Parameter(description = "The id of the code system to validate against") @PathVariable("codeSystemId") String codeSystemId, @Parameter(description = "The code to be validated") @RequestParam(value = "code") final String code, @Parameter(description = "The version of the code system") @RequestParam(value = "version") final Optional<String> version, @Parameter(description = "The display string of the code") @RequestParam(value = "display") final Optional<String> display, @Parameter(description = "The date stamp of the code system to validate against") @RequestParam(value = "date") final Optional<String> date, @Parameter(description = "The abstract status of the code") @RequestParam(value = "abstract") final Optional<Boolean> isAbstract) {
ValidateCodeRequest.Builder builder = ValidateCodeRequest.builder().code(code).version(version.orElse(null)).display(display.orElse(null)).isAbstract(isAbstract.orElse(null));
if (date.isPresent()) {
builder.date(date.get());
}
// Convert to FHIR parameters and delegate to the POST call
Json json = new Parameters.Json(builder.build());
Fhir fhir = new Parameters.Fhir(json.parameters());
return validateCode(codeSystemId, fhir);
}
use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir in project snow-owl by b2ihealthcare.
the class FhirCodeSystemValidateCodeOperationController method validateCodeByUrl.
/**
* HTTP Get request to validate that a coded value is in the code system specified by the URI parameter
* The code system is identified by its Code System ID within the path
* If the operation is not called at the instance level, one of the parameters "url" or "codeSystem" must be provided.
* The operation returns a result (true / false), an error message, and the recommended display for the code.
* When invoking this operation, a client SHALL provide one (and only one) of the parameters (code+system, coding, or codeableConcept).
* Other parameters (including version and display) are optional.
*
* @param url the code system to validate against
* @param code to code to validate
* @param version the version of the code system to validate against
* @param date the date for which the validation should be checked
* @param isAbstract If this parameter has a value of true, the client is stating that the validation is being performed in a context
* where a concept designated as 'abstract' is appropriate/allowed.
*
* @return validation results as {@link OperationOutcome}
*/
@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 = "400", description = "Bad request"), @ApiResponse(responseCode = "404", description = "Code system not found") })
@GetMapping("/$validate-code")
public Promise<Parameters.Fhir> validateCodeByUrl(@Parameter(description = "The uri of the code system to validate against") @RequestParam("url") String url, @Parameter(description = "The code to be validated") @RequestParam(value = "code") final String code, @Parameter(description = "The version of the code system") @RequestParam(value = "version") final Optional<String> version, @Parameter(description = "The display string of the code") @RequestParam(value = "display") final Optional<String> display, @Parameter(description = "The date stamp of the code system to validate against") @RequestParam(value = "date") final Optional<String> date, @Parameter(description = "The abstract status of the code") @RequestParam(value = "abstract") final Optional<Boolean> isAbstract) {
ValidateCodeRequest.Builder builder = ValidateCodeRequest.builder().url(url).code(code).version(version.orElse(null)).display(display.orElse(null)).isAbstract(isAbstract.orElse(null));
if (date.isPresent()) {
builder.date(date.get());
}
// Convert to FHIR parameters and delegate to the POST call
Json json = new Parameters.Json(builder.build());
Fhir fhir = new Parameters.Fhir(json.parameters());
return validateCode(fhir);
}
use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir in project snow-owl by b2ihealthcare.
the class PropertySerializationTest method basicPropertyTest.
@Test
public void basicPropertyTest() throws Exception {
Property property = Property.builder().code("123").valueInteger(2).description("propertyDescription").build();
Fhir fhirParameters = new Parameters.Fhir(property);
JsonPath jsonPath = JsonPath.from(objectMapper.writeValueAsString(fhirParameters));
assertThat(jsonPath.getString("resourceType"), equalTo("Parameters"));
assertThat(jsonPath.getList("parameter").size(), is(3));
assertThat(jsonPath, FhirParameterMatcher.hasParameter("code", FhirDataType.CODE, "123"));
assertThat(jsonPath, FhirParameterMatcher.hasParameter("value", FhirDataType.INTEGER, 2));
assertThat(jsonPath, FhirParameterMatcher.hasParameter("description", FhirDataType.STRING, "propertyDescription"));
}
use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir in project snow-owl by b2ihealthcare.
the class PropertySerializationTest method minimalPropertyTest.
@Test
public void minimalPropertyTest() throws Exception {
Property property = Property.builder().code("123").build();
Fhir fhirParameters = new Parameters.Fhir(property);
JsonPath jsonPath = JsonPath.from(objectMapper.writeValueAsString(fhirParameters));
assertThat(jsonPath.getString("resourceType"), equalTo("Parameters"));
assertThat(jsonPath.getList("parameter").size(), is(1));
assertThat(jsonPath, FhirParameterMatcher.hasParameter("code", FhirDataType.CODE, "123"));
}
Aggregations