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"));
}
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);
}
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());
}
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());
}
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());
}
Aggregations