Search in sources :

Example 1 with Builder

use of com.b2international.snowowl.fhir.core.model.conceptmap.TranslateRequest.Builder in project snow-owl by b2ihealthcare.

the class FhirConceptMapTranslateOperationController method translate.

/**
 * HTTP Get request to translate a code that could belongs to any {@link ConceptMap} in the system.
 * @return translation of the code
 */
@Operation(summary = "Translate a code", description = "Translate a code from one value set to another, based on the existing value set and concept maps resources, and/or other additional knowledge available to the server.")
@ApiResponses({ @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Bad request"), @ApiResponse(responseCode = "404", description = "Concept map not found") })
@GetMapping(value = "/$translate")
public Promise<Parameters.Fhir> translate(@Parameter(description = "The code to translate") @RequestParam(value = "code") final String code, @Parameter(description = "The code system's uri") @RequestParam(value = "system") final String system, @Parameter(description = "The code system's version, if null latest is used") @RequestParam(value = "version") final Optional<String> version, @Parameter(description = "The source value set") @RequestParam(value = "source") final Optional<String> source, @Parameter(description = "Value set in which a translation is sought") @RequestParam(value = "target") final Optional<String> target, @Parameter(description = "Target code system") @RequestParam(value = "targetsystem") final Optional<String> targetSystem, @Parameter(description = "If true, the mapping is reversed") @RequestParam(value = "reverse") final Optional<Boolean> isReverse) {
    // validation is triggered by builder.build()
    Builder builder = TranslateRequest.builder().code(code).system(system);
    version.ifPresent(builder::version);
    if (source.isPresent()) {
        builder.source(source.get());
    }
    if (target.isPresent()) {
        builder.target(target.get());
    }
    if (targetSystem.isPresent()) {
        builder.targetSystem(targetSystem.get());
    }
    if (isReverse.isPresent()) {
        builder.isReverse(isReverse.get());
    }
    return doTranslate(builder.build());
}
Also used : Builder(com.b2international.snowowl.fhir.core.model.conceptmap.TranslateRequest.Builder) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Aggregations

Builder (com.b2international.snowowl.fhir.core.model.conceptmap.TranslateRequest.Builder)1 Operation (io.swagger.v3.oas.annotations.Operation)1 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)1