Search in sources :

Example 11 with IssueType

use of org.hl7.fhir.r4.model.OperationOutcome.IssueType in project summary-care-record-api by NHSDigital.

the class GetScrControllerTest method verifyOperationOutcome.

private void verifyOperationOutcome(String responseBody, IssueType code, IssueSeverity severity, String details) {
    var response = parser.parseResource(responseBody);
    assertThat(response).isInstanceOf(OperationOutcome.class);
    OperationOutcome operationOutcome = (OperationOutcome) response;
    assertThat(operationOutcome.getIssueFirstRep().getCode()).isEqualTo(code);
    assertThat(operationOutcome.getIssueFirstRep().getSeverity()).isEqualTo(severity);
    assertThat(operationOutcome.getIssueFirstRep().getDetails().getText()).isEqualTo(details);
}
Also used : OperationOutcome(org.hl7.fhir.r4.model.OperationOutcome)

Example 12 with IssueType

use of org.hl7.fhir.r4.model.OperationOutcome.IssueType in project elexis-server by elexis.

the class ResourceProviderUtil method generateOperationOutcome.

private OperationOutcome generateOperationOutcome(IFhirTransformerException e) {
    OperationOutcome opOutcome = new OperationOutcome();
    OperationOutcomeIssueComponent ooc = new OperationOutcomeIssueComponent();
    OperationOutcome.IssueSeverity severity = OperationOutcome.IssueSeverity.valueOf(e.getSeverity().toUpperCase());
    ooc.setSeverity(severity);
    IssueType issueType = e.getCode() == 412 ? IssueType.PROCESSING : IssueType.BUSINESSRULE;
    ooc.setCode(issueType);
    ooc.setDiagnostics(e.getMessage());
    opOutcome.addIssue(ooc);
    return opOutcome;
}
Also used : OperationOutcomeIssueComponent(org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent) OperationOutcome(org.hl7.fhir.r4.model.OperationOutcome) IssueType(org.hl7.fhir.r4.model.OperationOutcome.IssueType)

Example 13 with IssueType

use of org.hl7.fhir.r4.model.OperationOutcome.IssueType in project pathling by aehrc.

the class ErrorHandlingInterceptor method buildException.

@Nonnull
@SuppressWarnings("SameParameterValue")
private static BaseServerResponseException buildException(final int theStatusCode, @Nonnull final String message, @Nonnull final IssueType issueType) {
    final OperationOutcome opOutcome = new OperationOutcome();
    final OperationOutcomeIssueComponent issue = new OperationOutcomeIssueComponent();
    issue.setSeverity(IssueSeverity.ERROR);
    issue.setDiagnostics(message);
    issue.setCode(issueType);
    opOutcome.addIssue(issue);
    final BaseServerResponseException ex = BaseServerResponseException.newInstance(theStatusCode, message);
    ex.setOperationOutcome(opOutcome);
    return ex;
}
Also used : OperationOutcomeIssueComponent(org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent) OperationOutcome(org.hl7.fhir.r4.model.OperationOutcome) BaseServerResponseException(ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException) Nonnull(javax.annotation.Nonnull)

Example 14 with IssueType

use of org.hl7.fhir.r4.model.OperationOutcome.IssueType in project org.hl7.fhir.core by hapifhir.

the class ParserBase method logError.

public void logError(int line, int col, String path, IssueType type, String message, IssueSeverity level) throws FHIRFormatError {
    if (policy == ValidationPolicy.EVERYTHING) {
        ValidationMessage msg = new ValidationMessage(Source.InstanceValidator, type, line, col, path, message, level);
        errors.add(msg);
    } else if (level == IssueSeverity.FATAL || (level == IssueSeverity.ERROR && policy == ValidationPolicy.QUICK))
        throw new FHIRFormatError(message + String.format(" at line %d col %d", line, col));
}
Also used : ValidationMessage(org.hl7.fhir.utilities.validation.ValidationMessage) FHIRFormatError(org.hl7.fhir.exceptions.FHIRFormatError)

Example 15 with IssueType

use of org.hl7.fhir.r4.model.OperationOutcome.IssueType in project org.hl7.fhir.core by hapifhir.

the class BaseWorkerContext method processValidationResult.

public ValidationResult processValidationResult(Parameters pOut) {
    boolean ok = false;
    String message = "No Message returned";
    String display = null;
    String system = null;
    String code = null;
    TerminologyServiceErrorClass err = TerminologyServiceErrorClass.UNKNOWN;
    for (ParametersParameterComponent p : pOut.getParameter()) {
        if (p.hasValue()) {
            if (p.getName().equals("result")) {
                ok = ((BooleanType) p.getValue()).getValue().booleanValue();
            } else if (p.getName().equals("message")) {
                message = ((StringType) p.getValue()).getValue();
            } else if (p.getName().equals("display")) {
                display = ((StringType) p.getValue()).getValue();
            } else if (p.getName().equals("system")) {
                system = ((StringType) p.getValue()).getValue();
            } else if (p.getName().equals("code")) {
                code = ((StringType) p.getValue()).getValue();
            } else if (p.getName().equals("cause")) {
                try {
                    IssueType it = IssueType.fromCode(((StringType) p.getValue()).getValue());
                    if (it == IssueType.UNKNOWN) {
                        err = TerminologyServiceErrorClass.UNKNOWN;
                    } else if (it == IssueType.NOTFOUND) {
                        err = TerminologyServiceErrorClass.CODESYSTEM_UNSUPPORTED;
                    } else if (it == IssueType.NOTSUPPORTED) {
                        err = TerminologyServiceErrorClass.VALUESET_UNSUPPORTED;
                    } else {
                        err = null;
                    }
                } catch (FHIRException e) {
                }
            }
        }
    }
    if (!ok) {
        return new ValidationResult(IssueSeverity.ERROR, message + " (from " + txClient.getAddress() + ")", err).setTxLink(txLog.getLastId());
    } else if (message != null && !message.equals("No Message returned")) {
        return new ValidationResult(IssueSeverity.WARNING, message + " (from " + txClient.getAddress() + ")", system, new ConceptDefinitionComponent().setDisplay(display).setCode(code)).setTxLink(txLog.getLastId());
    } else if (display != null) {
        return new ValidationResult(system, new ConceptDefinitionComponent().setDisplay(display).setCode(code)).setTxLink(txLog.getLastId());
    } else {
        return new ValidationResult(system, new ConceptDefinitionComponent().setCode(code)).setTxLink(txLog.getLastId());
    }
}
Also used : TerminologyServiceErrorClass(org.hl7.fhir.r4b.terminologies.ValueSetExpander.TerminologyServiceErrorClass) ConceptDefinitionComponent(org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent) StringType(org.hl7.fhir.r4b.model.StringType) IssueType(org.hl7.fhir.utilities.validation.ValidationMessage.IssueType) BooleanType(org.hl7.fhir.r4b.model.BooleanType) FHIRException(org.hl7.fhir.exceptions.FHIRException) ParametersParameterComponent(org.hl7.fhir.r4b.model.Parameters.ParametersParameterComponent)

Aggregations

ValidationMessage (org.hl7.fhir.utilities.validation.ValidationMessage)8 OperationOutcome (org.hl7.fhir.r4.model.OperationOutcome)6 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)5 FHIRException (org.hl7.fhir.exceptions.FHIRException)4 OperationOutcomeIssueComponent (org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent)4 IssueSeverity (org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity)4 IssueType (org.hl7.fhir.utilities.validation.ValidationMessage.IssueType)4 OperationOutcome (org.hl7.fhir.dstu3.model.OperationOutcome)2 OperationOutcomeIssueComponent (org.hl7.fhir.dstu3.model.OperationOutcome.OperationOutcomeIssueComponent)2 BaseServerResponseException (ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException)1 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 Nonnull (javax.annotation.Nonnull)1 BooleanType (org.hl7.fhir.dstu3.model.BooleanType)1 ConceptDefinitionComponent (org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent)1 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)1 Coding (org.hl7.fhir.dstu3.model.Coding)1 Meta (org.hl7.fhir.dstu3.model.Meta)1 Parameters (org.hl7.fhir.dstu3.model.Parameters)1