Search in sources :

Example 51 with PropertyWrapper

use of org.hl7.fhir.r5.renderers.utils.BaseWrappers.PropertyWrapper 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 52 with PropertyWrapper

use of org.hl7.fhir.r5.renderers.utils.BaseWrappers.PropertyWrapper 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)

Aggregations

XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)32 PropertyWrapper (org.hl7.fhir.r4b.renderers.utils.BaseWrappers.PropertyWrapper)17 PropertyWrapper (org.hl7.fhir.r5.renderers.utils.BaseWrappers.PropertyWrapper)17 ArrayList (java.util.ArrayList)14 BaseWrapper (org.hl7.fhir.r4b.renderers.utils.BaseWrappers.BaseWrapper)13 BaseWrapper (org.hl7.fhir.r5.renderers.utils.BaseWrappers.BaseWrapper)13 HashMap (java.util.HashMap)5 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)5 ElementDefinition (org.hl7.fhir.r4b.model.ElementDefinition)5 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)5 ElementDefinition (org.hl7.fhir.dstu2.model.ElementDefinition)4 ElementDefinition (org.hl7.fhir.dstu2016may.model.ElementDefinition)4 ElementDefinition (org.hl7.fhir.dstu3.model.ElementDefinition)4 StructureDefinition (org.hl7.fhir.r4b.model.StructureDefinition)3 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)3 List (java.util.List)2 StructureDefinition (org.hl7.fhir.dstu2.model.StructureDefinition)2 StructureDefinition (org.hl7.fhir.dstu2016may.model.StructureDefinition)2 StructureDefinition (org.hl7.fhir.dstu3.model.StructureDefinition)2 DateType (org.hl7.fhir.r4b.model.DateType)2