use of org.openehealth.ipf.commons.ihe.xds.core.responses.ErrorCode in project MobileAccessGateway by i4mi.
the class BaseResponseConverter method processErrorAsOutcome.
/**
* XDS error response -> FHIR OperationOutcome
* @param input
* @return
*/
public OperationOutcome processErrorAsOutcome(Response input) {
OperationOutcome outcome = new OperationOutcome();
List<ErrorInfo> errors = input.getErrors();
for (ErrorInfo info : errors) {
OperationOutcomeIssueComponent issue = outcome.addIssue();
Severity sevirity = info.getSeverity();
if (sevirity.equals(Severity.ERROR))
issue.setSeverity(OperationOutcome.IssueSeverity.ERROR);
else if (sevirity.equals(Severity.WARNING))
issue.setSeverity(OperationOutcome.IssueSeverity.WARNING);
ErrorCode errorCode = info.getErrorCode();
issue.setCode(IssueType.INVALID);
// TODO map error codes
// if (errorCode.equals(ErrorCode.REGISTRY_ERROR)) issue.setCode(IssueType.STRUCTURE);
// else if (errorCode.equals(ErrorCode.REGISTRY_METADATA_ERROR)) issue.setCode(IssueType.STRUCTURE);
// else
issue.setDetails(new CodeableConcept().setText(info.getCodeContext()).addCoding(new Coding().setCode(errorCode.toString())));
issue.setLocation(Collections.singletonList(new StringType(info.getLocation())));
}
return outcome;
}
Aggregations