Search in sources :

Example 1 with ErrorInfo

use of org.openehealth.ipf.commons.ihe.xds.core.responses.ErrorInfo in project MobileAccessGateway by i4mi.

the class Iti68ResponseConverter method retrievedDocumentSetToHttResponse.

public static Object retrievedDocumentSetToHttResponse(@Body RetrievedDocumentSet retrievedDocumentSet, @Headers Map<String, Object> headers) throws IOException {
    if (Status.SUCCESS.equals(retrievedDocumentSet.getStatus())) {
        List<RetrievedDocument> documentResponses = retrievedDocumentSet.getDocuments();
        if (documentResponses.size() == 1) {
            RetrievedDocument documentResponse = documentResponses.get(0);
            final InputStream in = documentResponse.getDataHandler().getInputStream();
            byte[] byteArray = org.apache.commons.io.IOUtils.toByteArray(in);
            headers.clear();
            headers.put("Content-Type", documentResponse.getMimeType());
            return byteArray;
        }
    } else {
        headers.put(Exchange.HTTP_RESPONSE_CODE, 400);
        List<ErrorInfo> errors = retrievedDocumentSet.getErrors();
        StringBuffer result = new StringBuffer();
        for (ErrorInfo error : errors) {
            result.append(error.getCodeContext());
        }
        return result;
    }
    return null;
}
Also used : RetrievedDocument(org.openehealth.ipf.commons.ihe.xds.core.responses.RetrievedDocument) InputStream(java.io.InputStream) ErrorInfo(org.openehealth.ipf.commons.ihe.xds.core.responses.ErrorInfo)

Example 2 with ErrorInfo

use of org.openehealth.ipf.commons.ihe.xds.core.responses.ErrorInfo in project ipf by oehf.

the class RegistryResponseValidatorTest method testInvalidErrorCode.

@Test
public void testInvalidErrorCode() {
    response.getErrors().add(new ErrorInfo(null, null, Severity.ERROR, null, null));
    expectFailure(INVALID_ERROR_CODE_IN_RESPONSE);
}
Also used : ErrorInfo(org.openehealth.ipf.commons.ihe.xds.core.responses.ErrorInfo) Test(org.junit.jupiter.api.Test)

Example 3 with ErrorInfo

use of org.openehealth.ipf.commons.ihe.xds.core.responses.ErrorInfo 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;
}
Also used : OperationOutcomeIssueComponent(org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent) Coding(org.hl7.fhir.r4.model.Coding) StringType(org.hl7.fhir.r4.model.StringType) OperationOutcome(org.hl7.fhir.r4.model.OperationOutcome) ErrorInfo(org.openehealth.ipf.commons.ihe.xds.core.responses.ErrorInfo) Severity(org.openehealth.ipf.commons.ihe.xds.core.responses.Severity) ErrorCode(org.openehealth.ipf.commons.ihe.xds.core.responses.ErrorCode) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Aggregations

ErrorInfo (org.openehealth.ipf.commons.ihe.xds.core.responses.ErrorInfo)3 InputStream (java.io.InputStream)1 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)1 Coding (org.hl7.fhir.r4.model.Coding)1 OperationOutcome (org.hl7.fhir.r4.model.OperationOutcome)1 OperationOutcomeIssueComponent (org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent)1 StringType (org.hl7.fhir.r4.model.StringType)1 Test (org.junit.jupiter.api.Test)1 ErrorCode (org.openehealth.ipf.commons.ihe.xds.core.responses.ErrorCode)1 RetrievedDocument (org.openehealth.ipf.commons.ihe.xds.core.responses.RetrievedDocument)1 Severity (org.openehealth.ipf.commons.ihe.xds.core.responses.Severity)1