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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations