Search in sources :

Example 56 with ApiResponses

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);
}
Also used : BadRequestException(com.b2international.snowowl.fhir.core.exceptions.BadRequestException) ValidateCodeRequest(com.b2international.snowowl.fhir.core.model.codesystem.ValidateCodeRequest) Uri(com.b2international.snowowl.fhir.core.model.dt.Uri) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 57 with ApiResponses

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);
}
Also used : Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) ValidateCodeRequest(com.b2international.snowowl.fhir.core.model.codesystem.ValidateCodeRequest) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 58 with ApiResponses

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);
}
Also used : SubsumptionRequest(com.b2international.snowowl.fhir.core.model.codesystem.SubsumptionRequest) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 59 with ApiResponses

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);
}
Also used : TranslateRequest(com.b2international.snowowl.fhir.core.model.conceptmap.TranslateRequest) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 60 with ApiResponses

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);
}
Also used : Entry(com.b2international.snowowl.fhir.core.model.Entry) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Bundle(com.b2international.snowowl.fhir.core.model.Bundle) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Aggregations

Operation (io.swagger.v3.oas.annotations.Operation)99 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)99 ApiResponses (io.swagger.v3.oas.models.responses.ApiResponses)47 ProtectedApi (org.gluu.oxtrust.service.filter.ProtectedApi)47 ApiResponse (io.swagger.v3.oas.models.responses.ApiResponse)46 Operation (io.swagger.v3.oas.models.Operation)39 OpenAPI (io.swagger.v3.oas.models.OpenAPI)34 PathItem (io.swagger.v3.oas.models.PathItem)34 Test (org.testng.annotations.Test)31 ArrayList (java.util.ArrayList)23 Schema (io.swagger.v3.oas.models.media.Schema)22 StringSchema (io.swagger.v3.oas.models.media.StringSchema)21 Content (io.swagger.v3.oas.models.media.Content)20 MediaType (io.swagger.v3.oas.models.media.MediaType)20 ObjectSchema (io.swagger.v3.oas.models.media.ObjectSchema)19 IntegerSchema (io.swagger.v3.oas.models.media.IntegerSchema)17 Path (javax.ws.rs.Path)17 Produces (javax.ws.rs.Produces)17 ArraySchema (io.swagger.v3.oas.models.media.ArraySchema)16 Components (io.swagger.v3.oas.models.Components)10