Search in sources :

Example 56 with BaseWrapper

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

the class BundleRenderer method addSection.

private void addSection(XhtmlNode x, BaseWrapper section, int level, boolean nested) throws UnsupportedEncodingException, FHIRException, IOException {
    if (section.has("title") || section.has("code") || section.has("text") || section.has("section")) {
        XhtmlNode div = x.div();
        if (section.has("title")) {
            div.h(level).tx(section.get("title").primitiveValue());
        } else if (section.has("code")) {
            renderBase(div.h(level), section.get("code"));
        }
        if (section.has("text")) {
            Base narrative = section.get("text");
            x.addChildren(narrative.getXhtml());
        }
        if (section.has("section")) {
            List<BaseWrapper> sections = section.children("section");
            for (BaseWrapper child : sections) {
                if (nested) {
                    addSection(x.blockquote().para(), child, level + 1, true);
                } else {
                    addSection(x, child, level + 1, true);
                }
            }
        }
    }
// children
}
Also used : BaseWrapper(org.hl7.fhir.r5.renderers.utils.BaseWrappers.BaseWrapper) Base(org.hl7.fhir.r5.model.Base) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 57 with BaseWrapper

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

the class DiagnosticReportRenderer method populateSubjectSummary.

private void populateSubjectSummary(XhtmlNode container, BaseWrapper subject) throws UnsupportedEncodingException, FHIRException, IOException, EOperationOutcome {
    ResourceWrapper r = fetchResource(subject);
    if (r == null)
        container.tx("Unable to get Patient Details");
    else if (r.getName().equals("Patient"))
        generatePatientSummary(container, r);
    else
        container.tx("Not done yet");
}
Also used : ResourceWrapper(org.hl7.fhir.r5.renderers.utils.BaseWrappers.ResourceWrapper)

Example 58 with BaseWrapper

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

the class DiagnosticReportRenderer method render.

public boolean render(XhtmlNode x, ResourceWrapper dr) throws IOException, FHIRException, EOperationOutcome {
    XhtmlNode h2 = x.h2();
    render(h2, getProperty(dr, "code").value());
    h2.tx(" ");
    PropertyWrapper pw = getProperty(dr, "category");
    if (valued(pw)) {
        h2.tx("(");
        boolean first = true;
        for (BaseWrapper b : pw.getValues()) {
            if (first)
                first = false;
            else
                h2.tx(", ");
            render(h2, b);
        }
        h2.tx(") ");
    }
    XhtmlNode tbl = x.table("grid");
    XhtmlNode tr;
    if (dr.has("subject")) {
        tr = tbl.tr();
        tr.td().tx("Subject");
        populateSubjectSummary(tr.td(), getProperty(dr, "subject").value());
    }
    DataType eff = null;
    DataType iss = null;
    if (dr.has("effective[x]")) {
        tr = tbl.tr();
        tr.td().tx("When For");
        eff = (DataType) getProperty(dr, "effective[x]").value().getBase();
        render(tr.td(), eff);
    }
    if (dr.has("issued")) {
        tr = tbl.tr();
        tr.td().tx("Reported");
        eff = (DataType) getProperty(dr, "issued").value().getBase();
        render(tr.td(), getProperty(dr, "issued").value());
    }
    pw = getProperty(dr, "perfomer");
    if (valued(pw)) {
        tr = tbl.tr();
        tr.td().tx(Utilities.pluralize("Performer", pw.getValues().size()));
        XhtmlNode tdr = tr.td();
        for (BaseWrapper v : pw.getValues()) {
            tdr.tx(" ");
            render(tdr, v);
        }
    }
    pw = getProperty(dr, "identifier");
    if (valued(pw)) {
        tr = tbl.tr();
        tr.td().tx(Utilities.pluralize("Identifier", pw.getValues().size()) + ":");
        XhtmlNode tdr = tr.td();
        for (BaseWrapper v : pw.getValues()) {
            tdr.tx(" ");
            render(tdr, v);
        }
    }
    pw = getProperty(dr, "request");
    if (valued(pw)) {
        tr = tbl.tr();
        tr.td().tx(Utilities.pluralize("Request", pw.getValues().size()) + ":");
        XhtmlNode tdr = tr.td();
        for (BaseWrapper v : pw.getValues()) {
            tdr.tx(" ");
            render(tdr, v);
        }
        tdr.br();
    }
    x.para().b().tx("Report Details");
    pw = getProperty(dr, "result");
    if (valued(pw)) {
        List<ObservationNode> observations = fetchObservations(pw.getValues(), dr);
        buildObservationsTable(x, observations, eff, iss);
    }
    pw = getProperty(dr, "conclusion");
    if (valued(pw)) {
        render(x.para(), pw.value());
    }
    pw = getProperty(dr, "conclusionCode");
    if (!valued(pw)) {
        pw = getProperty(dr, "codedDiagnosis");
    }
    if (valued(pw)) {
        XhtmlNode p = x.para();
        p.b().tx("Coded Conclusions :");
        XhtmlNode ul = x.ul();
        for (BaseWrapper v : pw.getValues()) {
            render(ul.li(), v);
        }
    }
    return false;
}
Also used : PropertyWrapper(org.hl7.fhir.r5.renderers.utils.BaseWrappers.PropertyWrapper) BaseWrapper(org.hl7.fhir.r5.renderers.utils.BaseWrappers.BaseWrapper) DataType(org.hl7.fhir.r5.model.DataType) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 59 with BaseWrapper

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

the class LibraryRenderer method renderArtifact.

private void renderArtifact(XhtmlNode t, BaseWrapper ra, ResourceWrapper lib, boolean label, boolean display, boolean citation) throws UnsupportedEncodingException, FHIRException, IOException {
    XhtmlNode tr = t.tr();
    tr.td().tx(ra.has("type") ? ra.get("type").primitiveValue() : null);
    if (label) {
        tr.td().tx(ra.has("label") ? ra.get("label").primitiveValue() : null);
    }
    if (display) {
        tr.td().tx(ra.has("display") ? ra.get("display").primitiveValue() : null);
    }
    if (citation) {
        tr.td().markdown(ra.has("citation") ? ra.get("citation").primitiveValue() : null, "Citation");
    }
    if (ra.has("resource")) {
        renderCanonical(lib, tr.td(), ra.get("resource").primitiveValue());
    } else {
        tr.td().tx(ra.has("url") ? ra.get("url").primitiveValue() : null);
    }
}
Also used : XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 60 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.r5.renderers.utils.BaseWrappers.PropertyWrapper) 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