Search in sources :

Example 76 with BaseWrapper

use of org.hl7.fhir.r5.renderers.utils.BaseWrappers.BaseWrapper in project org.hl7.fhir.core by hapifhir.

the class LibraryRenderer method render.

public boolean render(XhtmlNode x, ResourceWrapper lib) throws FHIRFormatError, DefinitionException, IOException {
    PropertyWrapper authors = lib.getChildByName("author");
    PropertyWrapper editors = lib.getChildByName("editor");
    PropertyWrapper reviewers = lib.getChildByName("reviewer");
    PropertyWrapper endorsers = lib.getChildByName("endorser");
    if ((authors != null && authors.hasValues()) || (editors != null && editors.hasValues()) || (reviewers != null && reviewers.hasValues()) || (endorsers != null && endorsers.hasValues())) {
        boolean email = hasCT(authors, "email") || hasCT(editors, "email") || hasCT(reviewers, "email") || hasCT(endorsers, "email");
        boolean phone = hasCT(authors, "phone") || hasCT(editors, "phone") || hasCT(reviewers, "phone") || hasCT(endorsers, "phone");
        boolean url = hasCT(authors, "url") || hasCT(editors, "url") || hasCT(reviewers, "url") || hasCT(endorsers, "url");
        x.h2().tx("Participants");
        XhtmlNode t = x.table("grid");
        if (authors != null) {
            for (BaseWrapper cd : authors.getValues()) {
                participantRow(t, "Author", cd, email, phone, url);
            }
        }
        if (authors != null) {
            for (BaseWrapper cd : editors.getValues()) {
                participantRow(t, "Editor", cd, email, phone, url);
            }
        }
        if (authors != null) {
            for (BaseWrapper cd : reviewers.getValues()) {
                participantRow(t, "Reviewer", cd, email, phone, url);
            }
        }
        if (authors != null) {
            for (BaseWrapper cd : endorsers.getValues()) {
                participantRow(t, "Endorser", cd, email, phone, url);
            }
        }
    }
    PropertyWrapper artifacts = lib.getChildByName("relatedArtifact");
    if (artifacts != null && artifacts.hasValues()) {
        x.h2().tx("Related Artifacts");
        XhtmlNode t = x.table("grid");
        boolean label = false;
        boolean display = false;
        boolean citation = false;
        for (BaseWrapper ra : artifacts.getValues()) {
            label = label || ra.has("label");
            display = display || ra.has("display");
            citation = citation || ra.has("citation");
        }
        for (BaseWrapper ra : artifacts.getValues()) {
            renderArtifact(t, ra, lib, label, display, citation);
        }
    }
    PropertyWrapper parameters = lib.getChildByName("parameter");
    if (parameters != null && parameters.hasValues()) {
        x.h2().tx("Parameters");
        XhtmlNode t = x.table("grid");
        boolean doco = false;
        for (BaseWrapper p : parameters.getValues()) {
            doco = doco || p.has("documentation");
        }
        for (BaseWrapper p : parameters.getValues()) {
            renderParameter(t, p, doco);
        }
    }
    PropertyWrapper dataRequirements = lib.getChildByName("dataRequirement");
    if (dataRequirements != null && dataRequirements.hasValues()) {
        x.h2().tx("Data Requirements");
        for (BaseWrapper p : dataRequirements.getValues()) {
            renderDataRequirement(x, (DataRequirement) p.getBase());
        }
    }
    PropertyWrapper contents = lib.getChildByName("content");
    if (contents != null) {
        x.h2().tx("Contents");
        boolean isCql = false;
        int counter = 0;
        for (BaseWrapper p : contents.getValues()) {
            Attachment att = (Attachment) p.getBase();
            renderAttachment(x, att, isCql, counter, lib.getId());
            isCql = isCql || (att.hasContentType() && att.getContentType().startsWith("text/cql"));
            counter++;
        }
    }
    return false;
}
Also used : PropertyWrapper(org.hl7.fhir.r4b.renderers.utils.BaseWrappers.PropertyWrapper) BaseWrapper(org.hl7.fhir.r4b.renderers.utils.BaseWrappers.BaseWrapper) Attachment(org.hl7.fhir.r4b.model.Attachment) ContactPoint(org.hl7.fhir.r4b.model.ContactPoint) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 77 with BaseWrapper

use of org.hl7.fhir.r5.renderers.utils.BaseWrappers.BaseWrapper in project org.hl7.fhir.core by hapifhir.

the class LibraryRenderer method participantRow.

private void participantRow(XhtmlNode t, String label, BaseWrapper cd, boolean email, boolean phone, boolean url) throws UnsupportedEncodingException, FHIRException, IOException {
    XhtmlNode tr = t.tr();
    tr.td().tx(label);
    tr.td().tx(cd.get("name") != null ? cd.get("name").primitiveValue() : null);
    PropertyWrapper telecoms = cd.getChildByName("telecom");
    if (email) {
        renderContactPoint(tr.td(), getContactPoint(telecoms, "email"));
    }
    if (phone) {
        renderContactPoint(tr.td(), getContactPoint(telecoms, "phone"));
    }
    if (url) {
        renderContactPoint(tr.td(), getContactPoint(telecoms, "url"));
    }
}
Also used : PropertyWrapper(org.hl7.fhir.r4b.renderers.utils.BaseWrappers.PropertyWrapper) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 78 with BaseWrapper

use of org.hl7.fhir.r5.renderers.utils.BaseWrappers.BaseWrapper in project org.hl7.fhir.core by hapifhir.

the class ResourceRenderer method renderResourceHeader.

protected void renderResourceHeader(ResourceWrapper r, XhtmlNode x) throws UnsupportedEncodingException, FHIRException, IOException {
    XhtmlNode div = x.div().style("display: inline-block").style("background-color: #d9e0e7").style("padding: 6px").style("margin: 4px").style("border: 1px solid #8da1b4").style("border-radius: 5px").style("line-height: 60%");
    String id = getPrimitiveValue(r, "id");
    String lang = getPrimitiveValue(r, "language");
    String ir = getPrimitiveValue(r, "implicitRules");
    BaseWrapper meta = r.getChildByName("meta").hasValues() ? r.getChildByName("meta").getValues().get(0) : null;
    String versionId = getPrimitiveValue(meta, "versionId");
    String lastUpdated = getPrimitiveValue(meta, "lastUpdated");
    String source = getPrimitiveValue(meta, "source");
    if (id != null || lang != null || versionId != null || lastUpdated != null) {
        XhtmlNode p = plateStyle(div.para());
        p.tx("Resource ");
        if (id != null) {
            p.tx("\"" + id + "\" ");
        }
        if (versionId != null) {
            p.tx("Version \"" + versionId + "\" ");
        }
        if (lastUpdated != null) {
            p.tx("Updated \"");
            renderDateTime(p, lastUpdated);
            p.tx("\" ");
        }
        if (lang != null) {
            p.tx(" (Language \"" + lang + "\") ");
        }
    }
    if (ir != null) {
        plateStyle(div.para()).b().tx("Special rules apply: " + ir + "!");
    }
    if (source != null) {
        plateStyle(div.para()).tx("Information Source: " + source + "!");
    }
    if (meta != null) {
        PropertyWrapper pl = meta.getChildByName("profile");
        if (pl.hasValues()) {
            XhtmlNode p = plateStyle(div.para());
            p.tx(Utilities.pluralize("Profile", pl.getValues().size()) + ": ");
            boolean first = true;
            for (BaseWrapper bw : pl.getValues()) {
                if (first)
                    first = false;
                else
                    p.tx(", ");
                renderCanonical(r, p, bw.getBase().primitiveValue());
            }
        }
        PropertyWrapper tl = meta.getChildByName("tag");
        if (tl.hasValues()) {
            XhtmlNode p = plateStyle(div.para());
            p.tx(Utilities.pluralize("Tag", tl.getValues().size()) + ": ");
            boolean first = true;
            for (BaseWrapper bw : tl.getValues()) {
                if (first)
                    first = false;
                else
                    p.tx(", ");
                String system = getPrimitiveValue(bw, "system");
                String version = getPrimitiveValue(bw, "version");
                String code = getPrimitiveValue(bw, "system");
                String display = getPrimitiveValue(bw, "system");
                renderCoding(p, new Coding(system, version, code, display));
            }
        }
        PropertyWrapper sl = meta.getChildByName("security");
        if (sl.hasValues()) {
            XhtmlNode p = plateStyle(div.para());
            p.tx(Utilities.pluralize("Security Label", tl.getValues().size()) + ": ");
            boolean first = true;
            for (BaseWrapper bw : sl.getValues()) {
                if (first)
                    first = false;
                else
                    p.tx(", ");
                String system = getPrimitiveValue(bw, "system");
                String version = getPrimitiveValue(bw, "version");
                String code = getPrimitiveValue(bw, "system");
                String display = getPrimitiveValue(bw, "system");
                renderCoding(p, new Coding(system, version, code, display));
            }
        }
    }
}
Also used : PropertyWrapper(org.hl7.fhir.r4b.renderers.utils.BaseWrappers.PropertyWrapper) BaseWrapper(org.hl7.fhir.r4b.renderers.utils.BaseWrappers.BaseWrapper) Coding(org.hl7.fhir.r4b.model.Coding) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 79 with BaseWrapper

use of org.hl7.fhir.r5.renderers.utils.BaseWrappers.BaseWrapper in project org.hl7.fhir.core by hapifhir.

the class ListRenderer method render.

public boolean render(XhtmlNode x, ResourceWrapper list) throws FHIRFormatError, DefinitionException, IOException {
    if (list.has("title")) {
        x.h2().tx(list.get("title").primitiveValue());
    }
    XhtmlNode t = x.table("clstu");
    XhtmlNode tr = t.tr();
    XhtmlNode td = tr.td();
    if (list.has("date")) {
        td.tx("Date: " + list.get("date").dateTimeValue().toHumanDisplay());
    }
    if (list.has("mode")) {
        td.tx("Mode: " + list.get("mode").primitiveValue());
    }
    if (list.has("status")) {
        td.tx("Status: " + list.get("status").primitiveValue());
    }
    if (list.has("code")) {
        td.tx("Code: " + displayBase(list.get("code")));
    }
    tr = t.tr();
    td = tr.td();
    if (list.has("subject")) {
        td.tx("Subject: ");
        shortForRef(td, list.get("subject"));
    }
    if (list.has("encounter")) {
        td.tx("Encounter: ");
        shortForRef(td, list.get("encounter"));
    }
    if (list.has("source")) {
        td.tx("Source: ");
        shortForRef(td, list.get("encounter"));
    }
    if (list.has("orderedBy")) {
        td.tx("Order: " + displayBase(list.get("orderedBy")));
    }
    // for (Annotation a : list.getNote()) {
    // renderAnnotation(a, x);
    // }
    boolean flag = false;
    boolean deleted = false;
    boolean date = false;
    for (BaseWrapper e : list.children("entry")) {
        flag = flag || e.has("flag");
        deleted = deleted || e.has("deleted");
        date = date || e.has("date");
    }
    t = x.table("grid");
    tr = t.tr().style("backgound-color: #eeeeee");
    tr.td().b().tx("Items");
    if (date) {
        tr.td().tx("Date");
    }
    if (flag) {
        tr.td().tx("Flag");
    }
    if (deleted) {
        tr.td().tx("Deleted");
    }
    for (BaseWrapper e : list.children("entry")) {
        tr = t.tr();
        shortForRef(tr.td(), e.get("item"));
        if (date) {
            tr.td().tx(e.has("date") ? e.get("date").dateTimeValue().toHumanDisplay() : "");
        }
        if (flag) {
            tr.td().tx(e.has("flag") ? displayBase(e.get("flag")) : "");
        }
        if (deleted) {
            tr.td().tx(e.has("deleted") ? e.get("deleted").primitiveValue() : "");
        }
    }
    return false;
}
Also used : BaseWrapper(org.hl7.fhir.r4b.renderers.utils.BaseWrappers.BaseWrapper) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Aggregations

XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)48 BaseWrapper (org.hl7.fhir.r4b.renderers.utils.BaseWrappers.BaseWrapper)20 BaseWrapper (org.hl7.fhir.r5.renderers.utils.BaseWrappers.BaseWrapper)20 PropertyWrapper (org.hl7.fhir.r4b.renderers.utils.BaseWrappers.PropertyWrapper)15 PropertyWrapper (org.hl7.fhir.r5.renderers.utils.BaseWrappers.PropertyWrapper)15 ArrayList (java.util.ArrayList)14 NotImplementedException (org.apache.commons.lang3.NotImplementedException)11 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)7 ElementDefinition (org.hl7.fhir.r4b.model.ElementDefinition)7 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)7 Base64 (org.apache.commons.codec.binary.Base64)6 ElementDefinition (org.hl7.fhir.dstu3.model.ElementDefinition)6 HashMap (java.util.HashMap)5 ElementDefinition (org.hl7.fhir.dstu2016may.model.ElementDefinition)5 ResourceWrapper (org.hl7.fhir.r4b.renderers.utils.BaseWrappers.ResourceWrapper)5 ResourceWrapper (org.hl7.fhir.r5.renderers.utils.BaseWrappers.ResourceWrapper)5 ElementDefinition (org.hl7.fhir.dstu2.model.ElementDefinition)4 StructureDefinition (org.hl7.fhir.dstu3.model.StructureDefinition)3 Base (org.hl7.fhir.r4b.model.Base)3 Extension (org.hl7.fhir.r4b.model.Extension)3