use of com.b2international.snowowl.fhir.core.model.dt.CodeableConcept in project snow-owl by b2ihealthcare.
the class IssueTest method build.
@Test
public void build() throws Exception {
Issue issue = Issue.builder().severity(IssueSeverity.ERROR).code(IssueType.REQUIRED).addExpression("Issue expression").addLocation("Issue location").details(CodeableConcept.builder().addCoding(Coding.builder().code("A").display("A display").build()).text("Text").build()).build();
assertEquals(IssueSeverity.ERROR.getCode(), issue.getSeverity());
assertEquals(IssueType.REQUIRED.getCode(), issue.getCode());
assertThat(issue.getExpressions(), hasItems("Issue expression"));
assertThat(issue.getLocations(), hasItems("Issue location"));
CodeableConcept details = issue.getDetails();
assertEquals(1, details.getCodings().size());
assertEquals("Text", details.getText());
Coding coding = details.getCodings().iterator().next();
assertEquals("A", coding.getCode().getCodeValue());
assertEquals("A display", coding.getDisplay());
}
use of com.b2international.snowowl.fhir.core.model.dt.CodeableConcept in project snow-owl by b2ihealthcare.
the class FhirValidateCodeRequest method collectCodingsToValidate.
private Set<Coding> collectCodingsToValidate(ValidateCodeRequest request) {
Set<Coding> codings = new HashSet<>(3);
if (request.getCode() != null) {
Coding coding = Coding.builder().code(request.getCode()).display(request.getDisplay()).build();
codings.add(coding);
}
if (request.getCoding() != null) {
codings.add(request.getCoding());
}
CodeableConcept codeableConcept = request.getCodeableConcept();
if (codeableConcept != null) {
if (codeableConcept.getCodings() != null) {
codeableConcept.getCodings().forEach(c -> codings.add(c));
}
}
return codings;
}
use of com.b2international.snowowl.fhir.core.model.dt.CodeableConcept in project snow-owl by b2ihealthcare.
the class ValidationException method toOperationOutcome.
/**
* Creates an OperationOutcome representation from this exception. Useful when
* the exception must be propagated through protocols where Java serialization
* cannot be used (eg. HTTP), or the possible receiver cannot understand
* serialized Java class and object byte sequences.
*
* @return {@link OperationOutcome} representation of this
* {@link FhirException}, never <code>null</code>.
*/
@Override
public OperationOutcome toOperationOutcome() {
if (violations.isEmpty()) {
throw new IllegalArgumentException("There are no violations to report.");
}
Builder outcomeBuilder = OperationOutcome.builder();
for (ConstraintViolation<?> violation : violations) {
String issueDetails = String.format(getOperationOutcomeCode().getDisplayName(), violation.getPropertyPath());
StringBuilder builder = new StringBuilder(issueDetails);
builder.append(" [");
builder.append(violation.getInvalidValue());
builder.append("]. Violation: ");
builder.append(violation.getMessage());
builder.append(".");
Coding coding = Coding.builder().code(getOperationOutcomeCode().getCodeValue()).system(OperationOutcomeCode.CODE_SYSTEM_URI).display(builder.toString()).build();
CodeableConcept codeableConcept = CodeableConcept.builder().addCoding(coding).text(builder.toString()).build();
String location = violation.getRootBean().getClass().getSimpleName() + "." + violation.getPropertyPath().toString();
Issue issue = Issue.builder().severity(IssueSeverity.ERROR).code(IssueType.INVALID).details(codeableConcept).diagnostics(getMessage()).addLocation(location).build();
outcomeBuilder.addIssue(issue);
}
return outcomeBuilder.build();
}
use of com.b2international.snowowl.fhir.core.model.dt.CodeableConcept in project snow-owl by b2ihealthcare.
the class RestTest method validate.
private void validate(Rest rest) {
assertEquals("documentation", rest.getDocumentation());
assertEquals(RestfulCapabilityMode.CLIENT.getCode(), rest.getMode());
assertEquals("serviceDescription", rest.getSecurity().getDescription());
CodeableConcept serviceConcept = rest.getSecurity().getServices().iterator().next();
assertEquals("codingTest", serviceConcept.getText());
Resource restResource = rest.getResources().iterator().next();
assertEquals("profile", restResource.getProfile().getUriValue());
assertEquals("name", restResource.getOperations().iterator().next().getName());
assertEquals("compartment", rest.getCompartments().iterator().next().getUriValue());
assertEquals("name", rest.getSearchParams().iterator().next().getName());
}
use of com.b2international.snowowl.fhir.core.model.dt.CodeableConcept in project snow-owl by b2ihealthcare.
the class CodeableConcepTest method deserialize.
@Test
public void deserialize() throws JsonProcessingException {
Coding coding = Coding.builder().code("codingCode").display("codingDisplay").system("http://www.whocc.no/atc").version("20180131").build();
CodeableConcept cc = CodeableConcept.builder().addCoding(coding).text("text").build();
String serializedString = objectMapper.writeValueAsString(cc);
CodeableConcept codeableConcept = objectMapper.readValue(serializedString, CodeableConcept.class);
assertEquals("text", codeableConcept.getText());
Coding builtCoding = codeableConcept.getCodings().iterator().next();
assertEquals("codingCode", builtCoding.getCode().getCodeValue());
assertEquals("codingDisplay", builtCoding.getDisplay());
assertEquals("http://www.whocc.no/atc", builtCoding.getSystem().getUriValue());
assertEquals("20180131", builtCoding.getVersion());
}
Aggregations