Search in sources :

Example 1 with Uri

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

the class BundleTest method serializeResourceBundle.

@Test
public void serializeResourceBundle() throws Exception {
    CodeSystem codeSystem = CodeSystem.builder("repo/shortName").status(PublicationStatus.ACTIVE).name("Local code system").content(CodeSystemContentMode.COMPLETE).url(new Uri("code system uri")).build();
    ResourceResponseEntry entry = ResourceResponseEntry.builder().fullUrl("full_Url").response(BatchResponse.createOkResponse()).resource(codeSystem).build();
    Bundle bundle = Bundle.builder("bundle_Id?").language("en").total(1).type(BundleType.SEARCHSET).addLink("self", "http://localhost:8080/snowowl/CodeSystem").addEntry(entry).build();
    applyFilter(bundle);
    JsonPath jsonPath = JsonPath.from(objectMapper.writeValueAsString(bundle));
    assertThat(jsonPath.getString("resourceType"), equalTo("Bundle"));
    assertThat(jsonPath.getString("id"), equalTo("bundle_Id?"));
    assertThat(jsonPath.getString("language"), equalTo("en"));
    assertThat(jsonPath.getString("type"), equalTo("searchset"));
    assertThat(jsonPath.getInt("total"), equalTo(1));
    jsonPath.setRoot("link[0]");
    assertThat(jsonPath.getString("relation"), equalTo("self"));
    assertThat(jsonPath.getString("url"), equalTo("http://localhost:8080/snowowl/CodeSystem"));
    jsonPath.setRoot("entry[0]");
    assertThat(jsonPath.getString("fullUrl"), equalTo("full_Url"));
    assertThat(jsonPath.getString("response.status"), equalTo("200"));
    jsonPath.setRoot("entry[0].resource");
    assertThat(jsonPath.getString("resourceType"), equalTo("CodeSystem"));
    assertThat(jsonPath.getString("id"), equalTo("repo/shortName"));
    assertThat(jsonPath.getString("url"), equalTo("code system uri"));
    assertThat(jsonPath.getString("name"), equalTo("Local code system"));
    assertThat(jsonPath.getString("status"), equalTo("active"));
    assertThat(jsonPath.getString("content"), equalTo("complete"));
}
Also used : Bundle(com.b2international.snowowl.fhir.core.model.Bundle) ResourceResponseEntry(com.b2international.snowowl.fhir.core.model.ResourceResponseEntry) JsonPath(io.restassured.path.json.JsonPath) CodeSystem(com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem) Uri(com.b2international.snowowl.fhir.core.model.dt.Uri) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 2 with Uri

use of com.b2international.snowowl.fhir.core.model.dt.Uri 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 3 with Uri

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

the class QuantityTest method deserialize.

@Test
public void deserialize() throws Exception {
    Quantity readQuantity = objectMapper.readValue(objectMapper.writeValueAsString(quantity), Quantity.class);
    assertEquals(Double.valueOf(12.3), readQuantity.getValue());
    assertEquals("mg", readQuantity.getUnit());
    assertEquals(new Uri("uri:LOINC"), readQuantity.getSystem());
    assertEquals(new Code("code"), readQuantity.getCode());
    assertEquals(QuantityComparator.GREATER_OR_EQUAL_TO.getCode(), readQuantity.getComparator());
}
Also used : Quantity(com.b2international.snowowl.fhir.core.model.dt.Quantity) Uri(com.b2international.snowowl.fhir.core.model.dt.Uri) Code(com.b2international.snowowl.fhir.core.model.dt.Code) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 4 with Uri

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

the class ReferenceTest method build.

@Test
public void build() throws ParseException {
    assertEquals("reference url", reference.getReference());
    assertEquals("displayString", reference.getDisplay());
    assertEquals(new Uri("system"), reference.getIdentifier().getSystem());
}
Also used : Uri(com.b2international.snowowl.fhir.core.model.dt.Uri) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 5 with Uri

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

the class ReferenceTest method deserialize.

@Test
public void deserialize() throws Exception {
    Reference readReference = objectMapper.readValue(objectMapper.writeValueAsString(reference), Reference.class);
    assertEquals("reference url", readReference.getReference());
    assertEquals("displayString", readReference.getDisplay());
    assertEquals(new Uri("system"), readReference.getIdentifier().getSystem());
}
Also used : Reference(com.b2international.snowowl.fhir.core.model.dt.Reference) Uri(com.b2international.snowowl.fhir.core.model.dt.Uri) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Aggregations

Uri (com.b2international.snowowl.fhir.core.model.dt.Uri)21 FhirTest (com.b2international.snowowl.fhir.tests.FhirTest)15 Test (org.junit.Test)15 Code (com.b2international.snowowl.fhir.core.model.dt.Code)10 OperationOutcomeCode (com.b2international.snowowl.fhir.core.codesystems.OperationOutcomeCode)4 JsonPath (io.restassured.path.json.JsonPath)3 Designation (com.b2international.snowowl.fhir.core.model.Designation)2 Extension (com.b2international.snowowl.fhir.core.model.Extension)2 IntegerExtension (com.b2international.snowowl.fhir.core.model.IntegerExtension)2 StringExtension (com.b2international.snowowl.fhir.core.model.StringExtension)2 CodeSystem (com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem)2 Coding (com.b2international.snowowl.fhir.core.model.dt.Coding)2 SnowOwlConfiguration (com.b2international.snowowl.core.config.SnowOwlConfiguration)1 SnowOwlOpenApiWebMvcResource (com.b2international.snowowl.core.rest.SnowOwlOpenApiWebMvcResource)1 IssueSeverity (com.b2international.snowowl.fhir.core.codesystems.IssueSeverity)1 IssueType (com.b2international.snowowl.fhir.core.codesystems.IssueType)1 BadRequestException (com.b2international.snowowl.fhir.core.exceptions.BadRequestException)1 ValidationException (com.b2international.snowowl.fhir.core.exceptions.ValidationException)1 Bundle (com.b2international.snowowl.fhir.core.model.Bundle)1 Issue (com.b2international.snowowl.fhir.core.model.Issue)1