Search in sources :

Example 16 with OperationOutcomeIssueComponent

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

the class ToolingExtensions method readValidationMessage.

public static ValidationMessage readValidationMessage(OperationOutcomeIssueComponent issue, Source source) {
    ValidationMessage vm = new ValidationMessage();
    vm.setSource(source);
    vm.setLevel(mapSeverity(issue.getSeverity()));
    vm.setType(mapType(issue.getCode()));
    if (issue.hasExtension(ToolingExtensions.EXT_ISSUE_LINE))
        vm.setLine(ToolingExtensions.readIntegerExtension(issue, ToolingExtensions.EXT_ISSUE_LINE, 0));
    if (issue.hasExtension(ToolingExtensions.EXT_ISSUE_COL))
        vm.setCol(ToolingExtensions.readIntegerExtension(issue, ToolingExtensions.EXT_ISSUE_COL, 0));
    if (issue.hasExpression())
        vm.setLocation(issue.getExpression().get(0).asStringValue());
    vm.setMessage(issue.getDetails().getText());
    if (issue.hasExtension("http://hl7.org/fhir/StructureDefinition/rendering-xhtml"))
        vm.setHtml(ToolingExtensions.readStringExtension(issue, "http://hl7.org/fhir/StructureDefinition/rendering-xhtml"));
    return vm;
}
Also used : ValidationMessage(org.hl7.fhir.utilities.validation.ValidationMessage)

Example 17 with OperationOutcomeIssueComponent

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

the class NarrativeGenerator method generate.

/**
 * This generate is optimised for the build tool in that it tracks the source extension.
 * But it can be used for any other use.
 *
 * @param vs
 * @param codeSystems
 * @throws DefinitionException
 * @throws Exception
 */
public boolean generate(ResourceContext rcontext, OperationOutcome op) throws DefinitionException {
    XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
    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(gen(i.getDetails()));
            smartAddText(tr.td(), i.getDiagnostics());
            if (hasSource) {
                Extension ext = ExtensionHelper.getExtension(i, ToolingExtensions.EXT_ISSUE_SOURCE);
                tr.td().addText(ext == null ? "" : gen(ext));
            }
        }
    }
    inject(op, x, hasSource ? NarrativeStatus.EXTENSIONS : NarrativeStatus.GENERATED);
    return true;
}
Also used : Extension(org.hl7.fhir.dstu3.model.Extension) OperationOutcomeIssueComponent(org.hl7.fhir.dstu3.model.OperationOutcome.OperationOutcomeIssueComponent) StringType(org.hl7.fhir.dstu3.model.StringType) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 18 with OperationOutcomeIssueComponent

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

the class ToolingExtensions method readValidationMessage.

public static ValidationMessage readValidationMessage(OperationOutcomeIssueComponent issue, Source source) {
    ValidationMessage vm = new ValidationMessage();
    vm.setSource(source);
    vm.setLevel(mapSeverity(issue.getSeverity()));
    vm.setType(mapType(issue.getCode()));
    if (issue.hasExtension(ToolingExtensions.EXT_ISSUE_LINE))
        vm.setLine(ToolingExtensions.readIntegerExtension(issue, ToolingExtensions.EXT_ISSUE_LINE, 0));
    if (issue.hasExtension(ToolingExtensions.EXT_ISSUE_COL))
        vm.setCol(ToolingExtensions.readIntegerExtension(issue, ToolingExtensions.EXT_ISSUE_COL, 0));
    if (issue.hasExpression())
        vm.setLocation(issue.getExpression().get(0).asStringValue());
    vm.setMessage(issue.getDetails().getText());
    if (issue.hasExtension("http://hl7.org/fhir/StructureDefinition/rendering-xhtml"))
        vm.setHtml(ToolingExtensions.readStringExtension(issue, "http://hl7.org/fhir/StructureDefinition/rendering-xhtml"));
    return vm;
}
Also used : ValidationMessage(org.hl7.fhir.utilities.validation.ValidationMessage)

Example 19 with OperationOutcomeIssueComponent

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

the class NarrativeGenerator method generate.

/**
 * This generate is optimised for the build tool in that it tracks the source extension.
 * But it can be used for any other use.
 *
 * @param vs
 * @param codeSystems
 * @throws DefinitionException
 * @throws Exception
 */
public boolean generate(ResourceContext rcontext, OperationOutcome op) throws DefinitionException {
    XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
    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(gen(i.getDetails()));
            smartAddText(tr.td(), i.getDiagnostics());
            if (hasSource) {
                Extension ext = ExtensionHelper.getExtension(i, ToolingExtensions.EXT_ISSUE_SOURCE);
                tr.td().addText(ext == null ? "" : gen(ext));
            }
        }
    }
    inject(op, x, hasSource ? NarrativeStatus.EXTENSIONS : NarrativeStatus.GENERATED);
    return true;
}
Also used : OperationOutcomeIssueComponent(org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 20 with OperationOutcomeIssueComponent

use of org.hl7.fhir.r4.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.r5.model.Extension) OperationOutcomeIssueComponent(org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent) StringType(org.hl7.fhir.r5.model.StringType) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Aggregations

OperationOutcomeIssueComponent (org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent)22 OperationOutcome (org.hl7.fhir.r4.model.OperationOutcome)19 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