Search in sources :

Example 1 with TranslateRequest

use of com.b2international.snowowl.fhir.core.model.conceptmap.TranslateRequest 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 2 with TranslateRequest

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

the class TranslateRequestDeserializationTest method validRequestTest.

@Test
public void validRequestTest() throws Exception {
    TranslateRequest request = TranslateRequest.builder().code("fatal").system("http://hl7.org/fhir/issue-severity").targetSystem(SnomedUri.SNOMED_BASE_URI).build();
    Fhir fhirParameters = new Parameters.Fhir(request);
    Parameter parameter = fhirParameters.getByName("code").get();
    assertEquals("fatal", ((Code) parameter.getValue()).getCodeValue());
    parameter = fhirParameters.getByName("system").get();
    assertEquals("http://hl7.org/fhir/issue-severity", ((Uri) parameter.getValue()).getUriValue());
    parameter = fhirParameters.getByName("targetsystem").get();
    assertEquals(SnomedUri.SNOMED_BASE_URI_STRING, ((Uri) parameter.getValue()).getUriValue());
}
Also used : TranslateRequest(com.b2international.snowowl.fhir.core.model.conceptmap.TranslateRequest) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 3 with TranslateRequest

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

the class TranslateRequestDeserializationTest method validRequestWithCodingTest.

@Test
public void validRequestWithCodingTest() throws Exception {
    TranslateRequest request = TranslateRequest.builder().coding(Coding.builder().system("http://hl7.org/fhir/issue-severity").code("fatal").build()).targetSystem(SnomedUri.SNOMED_BASE_URI).build();
    Fhir fhirParameters = new Parameters.Fhir(request);
    Parameter parameter = fhirParameters.getByName("coding").get();
    Coding coding = (Coding) parameter.getValue();
    assertEquals("fatal", coding.getCodeValue());
    assertEquals("http://hl7.org/fhir/issue-severity", coding.getSystem().getUriValue());
    parameter = fhirParameters.getByName("targetsystem").get();
    assertEquals(SnomedUri.SNOMED_BASE_URI_STRING, ((Uri) parameter.getValue()).getUriValue());
}
Also used : TranslateRequest(com.b2international.snowowl.fhir.core.model.conceptmap.TranslateRequest) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 4 with TranslateRequest

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

the class TranslateRequestDeserializationTest method validRequestWithDependencyTest.

@Test
public void validRequestWithDependencyTest() throws Exception {
    Coding dependencyCoding = Coding.builder().code("1234").system("http://www.whocc.no/atc").version("20180131").build();
    CodeableConcept cc = CodeableConcept.builder().addCoding(dependencyCoding).text("text").build();
    TranslateRequest request = TranslateRequest.builder().coding(Coding.builder().system("http://hl7.org/fhir/issue-severity").code("fatal").build()).targetSystem(SnomedUri.SNOMED_BASE_URI).addDependency(Dependency.builder().element("element").concept(cc).build()).build();
    Fhir fhirParameters = new Parameters.Fhir(request);
    Parameter parameter = fhirParameters.getByName("coding").get();
    Coding coding = (Coding) parameter.getValue();
    assertEquals("fatal", coding.getCodeValue());
    assertEquals("http://hl7.org/fhir/issue-severity", coding.getSystem().getUriValue());
    parameter = fhirParameters.getByName("targetsystem").get();
    assertEquals(SnomedUri.SNOMED_BASE_URI_STRING, ((Uri) parameter.getValue()).getUriValue());
    parameter = fhirParameters.getByName("dependency").get();
    Parameters dependencyParameters = (Parameters) parameter.getValue();
    parameter = dependencyParameters.getByName("concept").get();
    assertEquals("text", ((CodeableConcept) parameter.getValue()).getText());
}
Also used : TranslateRequest(com.b2international.snowowl.fhir.core.model.conceptmap.TranslateRequest) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Aggregations

TranslateRequest (com.b2international.snowowl.fhir.core.model.conceptmap.TranslateRequest)4 Fhir (com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir)3 FhirTest (com.b2international.snowowl.fhir.tests.FhirTest)3 Test (org.junit.Test)3 Operation (io.swagger.v3.oas.annotations.Operation)1 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)1