use of io.swagger.v3.oas.annotations.responses.ApiResponses in project snow-owl by b2ihealthcare.
the class FhirCodeSystemValidateCodeOperationController method validateCode.
/**
* POST-based $validate-code end-point.
* All parameters are in the request body, except the codeSystemId
* @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 = "/{codeSystemId:**}/$validate-code", consumes = AbstractFhirController.APPLICATION_FHIR_JSON)
public Promise<Parameters.Fhir> validateCode(@Parameter(description = "The id of the code system to validate against") @PathVariable("codeSystemId") String codeSystemId, @Parameter(description = "The validate-code request parameters") @RequestBody Parameters.Fhir body) {
final ValidateCodeRequest request = toRequest(body, ValidateCodeRequest.class);
// Validate for parameters that are not allowed on the instance level
if (request.getUrl() != null) {
throw new BadRequestException("Parameter 'url' cannot be specified when the code system ID is set.", "ValidateCodeRequest.url");
}
if (request.getCoding() != null) {
throw new BadRequestException("Parameter 'coding' cannot be specified when the code system ID is set.", "ValidateCodeRequest.coding");
}
if (request.getCodeableConcept() != null) {
throw new BadRequestException("Parameter 'codeableConcept' cannot be specified when the code system ID is set.", "ValidateCodeRequest.codeableConcept");
}
if (request.getCodeSystem() != null) {
throw new BadRequestException("Validation against external code systems is not supported", "ValidateCodeRequest.codeSystem");
}
// before execution set the codesystem to the path variable
request.setUrl(new Uri(codeSystemId));
return FhirRequests.codeSystems().prepareValidateCode().setRequest(request).buildAsync().execute(getBus()).then(this::toResponse);
}
use of io.swagger.v3.oas.annotations.responses.ApiResponses 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 io.swagger.v3.oas.annotations.responses.ApiResponses in project snow-owl by b2ihealthcare.
the class FhirCodeSystemSubsumesOperationController method subsumes.
/*
* Subsumes POST method without codeSystemId and body
*/
@Operation(summary = "Subsumption testing", description = "Test the subsumption relationship between code/Coding A and code/Coding B given the semantics of subsumption in the underlying code system (see hierarchyMeaning).")
@ApiResponses({ @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "404", description = "Not found"), @ApiResponse(responseCode = "400", description = "Bad request") })
@PostMapping(value = "/$subsumes", consumes = AbstractFhirController.APPLICATION_FHIR_JSON)
public Promise<Parameters.Fhir> subsumes(@Parameter(description = "The lookup request parameters") @RequestBody Parameters.Fhir body) {
SubsumptionRequest request = toRequest(body, SubsumptionRequest.class);
validateSubsumptionRequest(request);
return FhirRequests.codeSystems().prepareSubsumes().setRequest(request).buildAsync().execute(getBus()).then(this::toResponse);
}
use of io.swagger.v3.oas.annotations.responses.ApiResponses in project snow-owl by b2ihealthcare.
the class FhirConceptMapTranslateOperationController method translate.
/**
* HTTP POST request to translate a code that belongs to a {@link ConceptMap} specified by its ID.
* @param conceptMapId
* @return translation of the code
*/
@Operation(summary = "Translate a code based on a specific Concept Map", description = "Translate a code from one value set to another, based on the existing value set and specific concept map.")
@ApiResponses({ @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "404", description = "Not found"), @ApiResponse(responseCode = "400", description = "Bad request") })
@PostMapping(value = "/{conceptMapId:**}/$translate", consumes = AbstractFhirController.APPLICATION_FHIR_JSON)
public Promise<Parameters.Fhir> translate(@Parameter(description = "The id of the conceptMap to base the translation on") @PathVariable("conceptMapId") String conceptMapId, @Parameter(description = "The translate request parameters") @RequestBody Parameters.Fhir body) {
// validation is triggered by builder.build()
final TranslateRequest request = toRequest(body, TranslateRequest.class);
request.setUrl(conceptMapId);
return doTranslate(request);
}
use of io.swagger.v3.oas.annotations.responses.ApiResponses in project snow-owl by b2ihealthcare.
the class FhirBundleController method getBatchResponse.
@Operation(summary = "Perform batch operations", description = "Executes the FHIR requests included in the bundle provided.")
@ApiResponses({ @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Bad Request") })
@RequestMapping(value = "/", method = RequestMethod.POST, consumes = AbstractFhirController.APPLICATION_FHIR_JSON)
public Promise<Bundle> getBatchResponse(@Parameter(name = "bundle", description = "The bundle including the list of requests to perform") @RequestBody final Bundle bundle, HttpServletRequest request) throws JsonProcessingException {
Collection<Entry> entries = bundle.getEntry();
Bundle responseBundle = Bundle.builder().language("en").type(BundleType.BATCH_RESPONSE).build();
ObjectNode rootNode = (ObjectNode) objectMapper.valueToTree(responseBundle);
ArrayNode arrayNode = rootNode.putArray("entry");
for (Entry entry : entries) {
FhirBatchRequestProcessor requestProcessor = FhirBatchRequestProcessor.getInstance(entry, objectMapper, this);
requestProcessor.process(arrayNode, request);
}
Bundle treeToValue = objectMapper.treeToValue(rootNode, Bundle.class);
return Promise.immediate(treeToValue);
}
Aggregations