Search in sources :

Example 51 with OperationOutcomeIssueComponent

use of org.hl7.fhir.r4b.model.OperationOutcome.OperationOutcomeIssueComponent in project org.hl7.fhir.core by hapifhir.

the class OperationOutcomeRenderer method render.

public boolean render(XhtmlNode x, OperationOutcome op) throws FHIRFormatError, DefinitionException, IOException {
    boolean hasSource = false;
    boolean success = true;
    for (OperationOutcomeIssueComponent i : op.getIssue()) {
        success = success && i.getSeverity() == IssueSeverity.INFORMATION;
        hasSource = hasSource || ExtensionHelper.hasExtension(i, ToolingExtensions.EXT_ISSUE_SOURCE);
    }
    if (success)
        x.para().tx("All OK");
    if (op.getIssue().size() > 0) {
        // on the basis that we'll most likely be rendered using the standard fhir css, but it doesn't really matter
        XhtmlNode tbl = x.table("grid");
        XhtmlNode tr = tbl.tr();
        tr.td().b().tx("Severity");
        tr.td().b().tx("Location");
        tr.td().b().tx("Code");
        tr.td().b().tx("Details");
        tr.td().b().tx("Diagnostics");
        if (hasSource)
            tr.td().b().tx("Source");
        for (OperationOutcomeIssueComponent i : op.getIssue()) {
            tr = tbl.tr();
            tr.td().addText(i.getSeverity().toString());
            XhtmlNode td = tr.td();
            boolean d = false;
            for (StringType s : i.getLocation()) {
                if (d)
                    td.tx(", ");
                else
                    d = true;
                td.addText(s.getValue());
            }
            tr.td().addText(i.getCode().getDisplay());
            tr.td().addText(display(i.getDetails()));
            smartAddText(tr.td(), i.getDiagnostics());
            if (hasSource) {
                Extension ext = ExtensionHelper.getExtension(i, ToolingExtensions.EXT_ISSUE_SOURCE);
                tr.td().addText(ext == null ? "" : display(ext));
            }
        }
    }
    return true;
}
Also used : Extension(org.hl7.fhir.r4b.model.Extension) OperationOutcomeIssueComponent(org.hl7.fhir.r4b.model.OperationOutcome.OperationOutcomeIssueComponent) StringType(org.hl7.fhir.r4b.model.StringType) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 52 with OperationOutcomeIssueComponent

use of org.hl7.fhir.r4b.model.OperationOutcome.OperationOutcomeIssueComponent in project MobileAccessGateway by i4mi.

the class Iti93ResponseConverter method translateToFhir.

/**
 * translate ITI-44 response to ITI-93 response
 */
public Bundle translateToFhir(byte[] input, Map<String, Object> parameters) {
    try {
        // FIX for xmlns:xmlns
        String content = new String(input);
        content = content.replace("xmlns:xmlns", "xmlns:xxxxx");
        MCCIIN000002UV01Type msg = HL7V3Transformer.unmarshallMessage(MCCIIN000002UV01Type.class, new ByteArrayInputStream(content.getBytes()));
        Bundle responseBundle = new Bundle().setType(Bundle.BundleType.MESSAGE);
        Bundle requestBundle = (Bundle) parameters.get(Utils.KEPT_BODY);
        MessageHeader header = (MessageHeader) requestBundle.getEntryFirstRep().getResource();
        MessageSourceComponent source = new MessageSourceComponent();
        source.setEndpoint(config.getBaseurl());
        header.setSource(source);
        MessageHeaderResponseComponent response = new MessageHeaderResponseComponent();
        response.setCode(ResponseType.OK);
        for (net.ihe.gazelle.hl7v3.mccimt000200UV01.MCCIMT000200UV01Acknowledgement akk : msg.getAcknowledgement()) {
            CS code = akk.getTypeCode();
            if (!code.getCode().equals("AA") && !code.getCode().equals("CA")) {
                response.setCode(ResponseType.FATALERROR);
                OperationOutcome outcome = new OperationOutcome();
                response.setDetails((Reference) new Reference().setResource(outcome));
                for (MCCIMT000200UV01AcknowledgementDetail detail : akk.getAcknowledgementDetail()) {
                    OperationOutcomeIssueComponent issue = outcome.addIssue();
                    issue.setDetails(new CodeableConcept().setText(toText(detail.getText())).addCoding(transform(detail.getCode())));
                }
            }
        }
        response.setIdentifier(header.getId());
        header.setId((String) null);
        header.setResponse(response);
        header.setFocus(null);
        BundleEntryComponent cmp = responseBundle.addEntry();
        cmp.setResource(header);
        return responseBundle;
    } catch (JAXBException e) {
        throw new InvalidRequestException("failed parsing response");
    }
}
Also used : MCCIMT000200UV01AcknowledgementDetail(net.ihe.gazelle.hl7v3.mccimt000200UV01.MCCIMT000200UV01AcknowledgementDetail) OperationOutcomeIssueComponent(org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent) Bundle(org.hl7.fhir.r4.model.Bundle) Reference(org.hl7.fhir.r4.model.Reference) JAXBException(javax.xml.bind.JAXBException) MessageSourceComponent(org.hl7.fhir.r4.model.MessageHeader.MessageSourceComponent) MessageHeaderResponseComponent(org.hl7.fhir.r4.model.MessageHeader.MessageHeaderResponseComponent) MCCIIN000002UV01Type(net.ihe.gazelle.hl7v3.mcciin000002UV01.MCCIIN000002UV01Type) CS(net.ihe.gazelle.hl7v3.datatypes.CS) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) ByteArrayInputStream(java.io.ByteArrayInputStream) OperationOutcome(org.hl7.fhir.r4.model.OperationOutcome) InvalidRequestException(ca.uhn.fhir.rest.server.exceptions.InvalidRequestException) MessageHeader(org.hl7.fhir.r4.model.MessageHeader) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 53 with OperationOutcomeIssueComponent

use of org.hl7.fhir.r4b.model.OperationOutcome.OperationOutcomeIssueComponent in project MobileAccessGateway by i4mi.

the class BasePMIRResponseConverter method error.

public OperationOutcome error(IssueType type, String diagnostics) {
    OperationOutcome result = new OperationOutcome();
    OperationOutcomeIssueComponent issue = result.addIssue();
    issue.setSeverity(OperationOutcome.IssueSeverity.ERROR);
    issue.setCode(type);
    issue.setDiagnostics(diagnostics);
    return result;
}
Also used : OperationOutcomeIssueComponent(org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent) OperationOutcome(org.hl7.fhir.r4.model.OperationOutcome)

Example 54 with OperationOutcomeIssueComponent

use of org.hl7.fhir.r4b.model.OperationOutcome.OperationOutcomeIssueComponent 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

OperationOutcomeIssueComponent (org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent)23 OperationOutcome (org.hl7.fhir.r4.model.OperationOutcome)20 Test (org.junit.jupiter.api.Test)17 OperationOutcomeIssueComponent (org.hl7.fhir.dstu3.model.OperationOutcome.OperationOutcomeIssueComponent)10 Order (org.junit.jupiter.api.Order)10 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)10 RestIntegrationTest (org.opencds.cqf.ruler.test.RestIntegrationTest)10 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)10 OperationOutcomeIssueComponent (org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent)8 OperationOutcome (org.hl7.fhir.dstu3.model.OperationOutcome)7 OperationOutcome (org.hl7.fhir.r5.model.OperationOutcome)5 CacheVerificationLogger (org.hl7.fhir.utilities.tests.CacheVerificationLogger)5 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)5 ValidationEngine (org.hl7.fhir.validation.ValidationEngine)5 BufferedReader (java.io.BufferedReader)4 InputStreamReader (java.io.InputStreamReader)4 Nonnull (javax.annotation.Nonnull)4 ValueSet (org.hl7.fhir.dstu3.model.ValueSet)4 IBaseOperationOutcome (org.hl7.fhir.instance.model.api.IBaseOperationOutcome)3 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)3