Search in sources :

Example 81 with Source

use of org.hl7.fhir.utilities.validation.ValidationMessage.Source 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 void generate(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.addTag("p").addText("All OK");
    if (op.getIssue().size() > 0) {
        XhtmlNode tbl = x.addTag("table");
        // on the basis that we'll most likely be rendered using the standard fhir css, but it doesn't really matter
        tbl.setAttribute("class", "grid");
        XhtmlNode tr = tbl.addTag("tr");
        tr.addTag("td").addTag("b").addText("Severity");
        tr.addTag("td").addTag("b").addText("Location");
        tr.addTag("td").addTag("b").addText("Code");
        tr.addTag("td").addTag("b").addText("Details");
        tr.addTag("td").addTag("b").addText("Diagnostics");
        if (hasSource)
            tr.addTag("td").addTag("b").addText("Source");
        for (OperationOutcomeIssueComponent i : op.getIssue()) {
            tr = tbl.addTag("tr");
            tr.addTag("td").addText(i.getSeverity().toString());
            XhtmlNode td = tr.addTag("td");
            boolean d = false;
            for (StringType s : i.getLocation()) {
                if (d)
                    td.addText(", ");
                else
                    d = true;
                td.addText(s.getValue());
            }
            tr.addTag("td").addText(i.getCode().getDisplay());
            tr.addTag("td").addText(gen(i.getDetails()));
            smartAddText(tr.addTag("td"), i.getDiagnostics());
            if (hasSource) {
                Extension ext = ExtensionHelper.getExtension(i, ToolingExtensions.EXT_ISSUE_SOURCE);
                tr.addTag("td").addText(ext == null ? "" : gen(ext));
            }
        }
    }
    inject(op, x, hasSource ? NarrativeStatus.EXTENSIONS : NarrativeStatus.GENERATED);
}
Also used : Extension(org.hl7.fhir.dstu2.model.Extension) OperationOutcomeIssueComponent(org.hl7.fhir.dstu2.model.OperationOutcome.OperationOutcomeIssueComponent) StringType(org.hl7.fhir.dstu2.model.StringType) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 82 with Source

use of org.hl7.fhir.utilities.validation.ValidationMessage.Source in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeOrder.

protected void composeOrder(Complex parent, String parentType, String name, Order element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "Order", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "Order", "identifier", element.getIdentifier().get(i), i);
    if (element.hasDateElement())
        composeDateTime(t, "Order", "date", element.getDateElement(), -1);
    if (element.hasSubject())
        composeReference(t, "Order", "subject", element.getSubject(), -1);
    if (element.hasSource())
        composeReference(t, "Order", "source", element.getSource(), -1);
    if (element.hasTarget())
        composeReference(t, "Order", "target", element.getTarget(), -1);
    if (element.hasReason())
        composeType(t, "Order", "reason", element.getReason(), -1);
    if (element.hasWhen())
        composeOrderOrderWhenComponent(t, "Order", "when", element.getWhen(), -1);
    for (int i = 0; i < element.getDetail().size(); i++) composeReference(t, "Order", "detail", element.getDetail().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 83 with Source

use of org.hl7.fhir.utilities.validation.ValidationMessage.Source in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeQuestionnaireResponse.

protected void composeQuestionnaireResponse(Complex parent, String parentType, String name, QuestionnaireResponse element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "QuestionnaireResponse", name, element, index);
    if (element.hasIdentifier())
        composeIdentifier(t, "QuestionnaireResponse", "identifier", element.getIdentifier(), -1);
    if (element.hasQuestionnaire())
        composeReference(t, "QuestionnaireResponse", "questionnaire", element.getQuestionnaire(), -1);
    if (element.hasStatusElement())
        composeEnum(t, "QuestionnaireResponse", "status", element.getStatusElement(), -1);
    if (element.hasSubject())
        composeReference(t, "QuestionnaireResponse", "subject", element.getSubject(), -1);
    if (element.hasAuthor())
        composeReference(t, "QuestionnaireResponse", "author", element.getAuthor(), -1);
    if (element.hasAuthoredElement())
        composeDateTime(t, "QuestionnaireResponse", "authored", element.getAuthoredElement(), -1);
    if (element.hasSource())
        composeReference(t, "QuestionnaireResponse", "source", element.getSource(), -1);
    if (element.hasEncounter())
        composeReference(t, "QuestionnaireResponse", "encounter", element.getEncounter(), -1);
    for (int i = 0; i < element.getItem().size(); i++) composeQuestionnaireResponseQuestionnaireResponseItemComponent(t, "QuestionnaireResponse", "item", element.getItem().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 84 with Source

use of org.hl7.fhir.utilities.validation.ValidationMessage.Source in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeConceptMap.

protected void composeConceptMap(Complex parent, String parentType, String name, ConceptMap element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "ConceptMap", name, element, index);
    if (element.hasUrlElement())
        composeUri(t, "ConceptMap", "url", element.getUrlElement(), -1);
    if (element.hasIdentifier())
        composeIdentifier(t, "ConceptMap", "identifier", element.getIdentifier(), -1);
    if (element.hasVersionElement())
        composeString(t, "ConceptMap", "version", element.getVersionElement(), -1);
    if (element.hasNameElement())
        composeString(t, "ConceptMap", "name", element.getNameElement(), -1);
    if (element.hasStatusElement())
        composeEnum(t, "ConceptMap", "status", element.getStatusElement(), -1);
    if (element.hasExperimentalElement())
        composeBoolean(t, "ConceptMap", "experimental", element.getExperimentalElement(), -1);
    if (element.hasPublisherElement())
        composeString(t, "ConceptMap", "publisher", element.getPublisherElement(), -1);
    for (int i = 0; i < element.getContact().size(); i++) composeConceptMapConceptMapContactComponent(t, "ConceptMap", "contact", element.getContact().get(i), i);
    if (element.hasDateElement())
        composeDateTime(t, "ConceptMap", "date", element.getDateElement(), -1);
    if (element.hasDescriptionElement())
        composeString(t, "ConceptMap", "description", element.getDescriptionElement(), -1);
    for (int i = 0; i < element.getUseContext().size(); i++) composeCodeableConcept(t, "ConceptMap", "useContext", element.getUseContext().get(i), i);
    if (element.hasRequirementsElement())
        composeString(t, "ConceptMap", "requirements", element.getRequirementsElement(), -1);
    if (element.hasCopyrightElement())
        composeString(t, "ConceptMap", "copyright", element.getCopyrightElement(), -1);
    if (element.hasSource())
        composeType(t, "ConceptMap", "source", element.getSource(), -1);
    if (element.hasTarget())
        composeType(t, "ConceptMap", "target", element.getTarget(), -1);
    for (int i = 0; i < element.getElement().size(); i++) composeConceptMapSourceElementComponent(t, "ConceptMap", "element", element.getElement().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 85 with Source

use of org.hl7.fhir.utilities.validation.ValidationMessage.Source in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeAuditEventAuditEventSourceComponent.

protected void composeAuditEventAuditEventSourceComponent(Complex parent, String parentType, String name, AuditEvent.AuditEventSourceComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "source", name, element, index);
    if (element.hasSiteElement())
        composeString(t, "AuditEvent", "site", element.getSiteElement(), -1);
    if (element.hasIdentifier())
        composeIdentifier(t, "AuditEvent", "identifier", element.getIdentifier(), -1);
    for (int i = 0; i < element.getType().size(); i++) composeCoding(t, "AuditEvent", "type", element.getType().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Aggregations

FHIRException (org.hl7.fhir.exceptions.FHIRException)125 FileInputStream (java.io.FileInputStream)59 FileOutputStream (java.io.FileOutputStream)55 IOException (java.io.IOException)55 ArrayList (java.util.ArrayList)48 File (java.io.File)45 CSFileInputStream (org.hl7.fhir.utilities.CSFileInputStream)45 TextFile (org.hl7.fhir.utilities.TextFile)41 CSFile (org.hl7.fhir.utilities.CSFile)35 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)35 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)30 XmlParser (org.hl7.fhir.r5.formats.XmlParser)28 Date (java.util.Date)27 HashMap (java.util.HashMap)26 Reference (org.hl7.fhir.r4.model.Reference)26 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)24 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)24 Coding (org.hl7.fhir.r4.model.Coding)24 JsonObject (com.google.gson.JsonObject)22 NotImplementedException (org.apache.commons.lang3.NotImplementedException)22