Search in sources :

Example 46 with PropertyWrapper

use of org.hl7.fhir.r4b.renderers.utils.BaseWrappers.PropertyWrapper in project org.hl7.fhir.core by hapifhir.

the class ParametersRenderer method render.

@Override
public boolean render(XhtmlNode x, ResourceWrapper params) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome {
    x.h2().tx("Parameters");
    XhtmlNode tbl = x.table("grid");
    PropertyWrapper pw = getProperty(params, "parameter");
    if (valued(pw)) {
        paramsW(tbl, pw.getValues(), 0);
    }
    return false;
}
Also used : PropertyWrapper(org.hl7.fhir.r4b.renderers.utils.BaseWrappers.PropertyWrapper) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 47 with PropertyWrapper

use of org.hl7.fhir.r4b.renderers.utils.BaseWrappers.PropertyWrapper in project org.hl7.fhir.core by hapifhir.

the class DiagnosticReportRenderer method scanObsForFlags.

private boolean scanObsForFlags(List<ObservationNode> observations) throws UnsupportedEncodingException, FHIRException, IOException {
    for (ObservationNode o : observations) {
        if (o.obs != null && o.obs.getResource() != null) {
            PropertyWrapper pw = getProperty(o.obs.getResource(), "interpretation");
            if (valued(pw)) {
                return true;
            }
            pw = getProperty(o.obs.getResource(), "status");
            if (valued(pw)) {
                if (!pw.value().getBase().primitiveValue().equals("final")) {
                    return true;
                }
            }
        }
        if (o.contained != null) {
            if (scanObsForFlags(o.contained)) {
                return true;
            }
        }
    }
    return false;
}
Also used : PropertyWrapper(org.hl7.fhir.r4b.renderers.utils.BaseWrappers.PropertyWrapper)

Example 48 with PropertyWrapper

use of org.hl7.fhir.r4b.renderers.utils.BaseWrappers.PropertyWrapper 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.r4b.renderers.utils.BaseWrappers.PropertyWrapper) BaseWrapper(org.hl7.fhir.r4b.renderers.utils.BaseWrappers.BaseWrapper) DataType(org.hl7.fhir.r4b.model.DataType) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 49 with PropertyWrapper

use of org.hl7.fhir.r4b.renderers.utils.BaseWrappers.PropertyWrapper in project org.hl7.fhir.core by hapifhir.

the class DiagnosticReportRenderer method fetchObservations.

private List<ObservationNode> fetchObservations(List<BaseWrapper> list, ResourceWrapper rw) throws UnsupportedEncodingException, FHIRException, IOException {
    List<ObservationNode> res = new ArrayList<ObservationNode>();
    for (BaseWrapper b : list) {
        if (b.has("reference")) {
            ObservationNode obs = new ObservationNode();
            obs.ref = b.get("reference").primitiveValue();
            obs.obs = resolveReference(rw, obs.ref);
            if (obs.obs != null && obs.obs.getResource() != null) {
                PropertyWrapper t = getProperty(obs.obs.getResource(), "contained");
                if (t != null && t.hasValues()) {
                    obs.contained = fetchObservations(t.getValues(), rw);
                }
            }
            res.add(obs);
        }
    }
    return res;
}
Also used : PropertyWrapper(org.hl7.fhir.r4b.renderers.utils.BaseWrappers.PropertyWrapper) BaseWrapper(org.hl7.fhir.r4b.renderers.utils.BaseWrappers.BaseWrapper) ArrayList(java.util.ArrayList)

Example 50 with PropertyWrapper

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

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