Search in sources :

Example 31 with Range

use of org.hl7.fhir.dstu2.model.Range in project org.hl7.fhir.core by hapifhir.

the class DataRenderer method displayRange.

public String displayRange(Range q) {
    StringBuilder b = new StringBuilder();
    if (q.hasLow())
        b.append(q.getLow().getValue().toString());
    else
        b.append("?");
    b.append("-");
    if (q.hasHigh())
        b.append(q.getHigh().getValue().toString());
    else
        b.append("?");
    if (q.getLow().hasUnit())
        b.append(" " + q.getLow().getUnit());
    return b.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder)

Example 32 with Range

use of org.hl7.fhir.dstu2.model.Range in project org.hl7.fhir.core by hapifhir.

the class DiagnosticReportRenderer method addObservationToTable.

private void addObservationToTable(XhtmlNode tr, ResourceWrapper obs, int i, String ref, boolean refRange, boolean flags, boolean note, boolean effectiveTime, boolean issued, DataType eff, DataType iss) throws UnsupportedEncodingException, FHIRException, IOException {
    // code (+bodysite)
    XhtmlNode td = tr.td();
    PropertyWrapper pw = getProperty(obs, "code");
    if (valued(pw)) {
        render(td.ah(ref), pw.value());
    }
    pw = getProperty(obs, "bodySite");
    if (valued(pw)) {
        td.tx(" (");
        render(td, pw.value());
        td.tx(")");
    }
    // value / dataAbsentReason (in red)
    td = tr.td();
    pw = getProperty(obs, "value[x]");
    if (valued(pw)) {
        render(td, pw.value());
    } else {
        pw = getProperty(obs, "dataAbsentReason");
        if (valued(pw)) {
            XhtmlNode span = td.span("color: maroon", "Error");
            span.tx("Error: ");
            render(span.b(), pw.value());
        }
    }
    if (refRange) {
        // reference range
        td = tr.td();
        pw = getProperty(obs, "referenceRange");
        if (valued(pw)) {
            boolean first = true;
            for (BaseWrapper v : pw.getValues()) {
                if (first)
                    first = false;
                else
                    td.br();
                PropertyWrapper pwr = getProperty(v, "type");
                if (valued(pwr)) {
                    render(td, pwr.value());
                    td.tx(": ");
                }
                PropertyWrapper pwt = getProperty(v, "text");
                if (valued(pwt)) {
                    render(td, pwt.value());
                } else {
                    PropertyWrapper pwl = getProperty(v, "low");
                    PropertyWrapper pwh = getProperty(v, "high");
                    if (valued(pwl) && valued(pwh)) {
                        render(td, pwl.value());
                        td.tx(" - ");
                        render(td, pwh.value());
                    } else if (valued(pwl)) {
                        td.tx(">");
                        render(td, pwl.value());
                    } else if (valued(pwh)) {
                        td.tx("<");
                        render(td, pwh.value());
                    } else {
                        td.tx("??");
                    }
                }
                pwr = getProperty(v, "appliesTo");
                PropertyWrapper pwrA = getProperty(v, "age");
                if (valued(pwr) || valued(pwrA)) {
                    boolean firstA = true;
                    td.tx(" for ");
                    if (valued(pwr)) {
                        for (BaseWrapper va : pwr.getValues()) {
                            if (firstA)
                                firstA = false;
                            else
                                td.tx(", ");
                            render(td, va);
                        }
                    }
                    if (valued(pwrA)) {
                        if (firstA)
                            firstA = false;
                        else
                            td.tx(", ");
                        td.tx("Age ");
                        render(td, pwrA.value());
                    }
                }
            }
        }
    }
    if (flags) {
        // flags (status other than F, interpretation, )
        td = tr.td();
        boolean first = true;
        pw = getProperty(obs, "status");
        if (valued(pw)) {
            if (!pw.value().getBase().primitiveValue().equals("final")) {
                if (first)
                    first = false;
                else
                    td.br();
                render(td, pw.value());
            }
        }
        pw = getProperty(obs, "interpretation");
        if (valued(pw)) {
            for (BaseWrapper v : pw.getValues()) {
                if (first)
                    first = false;
                else
                    td.br();
                render(td, v);
            }
        }
    }
    if (note) {
        td = tr.td();
        pw = getProperty(obs, "note");
        if (valued(pw)) {
            render(td, pw.value());
        }
    }
    if (effectiveTime) {
        // effective if different to DR
        td = tr.td();
        pw = getProperty(obs, "effective[x]");
        if (valued(pw)) {
            if (!Base.compareDeep(pw.value().getBase(), eff, true)) {
                render(td, pw.value());
            }
        }
    }
    if (issued) {
        // issued if different to DR
        td = tr.td();
        pw = getProperty(obs, "issued");
        if (valued(pw)) {
            if (!Base.compareDeep(pw.value().getBase(), eff, true)) {
                render(td, pw.value());
            }
        }
    }
}
Also used : PropertyWrapper(org.hl7.fhir.r4b.renderers.utils.BaseWrappers.PropertyWrapper) BaseWrapper(org.hl7.fhir.r4b.renderers.utils.BaseWrappers.BaseWrapper) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 33 with Range

use of org.hl7.fhir.dstu2.model.Range in project org.hl7.fhir.core by hapifhir.

the class DiagnosticReportRenderer method buildObservationsTable.

private void buildObservationsTable(XhtmlNode root, List<ObservationNode> observations, DataType eff, DataType iss) throws UnsupportedEncodingException, FHIRException, IOException {
    XhtmlNode tbl = root.table("grid");
    boolean refRange = scanObsForRefRange(observations);
    boolean flags = scanObsForFlags(observations);
    boolean note = scanObsForNote(observations);
    boolean effectiveTime = scanObsForEffective(observations, eff);
    boolean issued = scanObsForIssued(observations, iss);
    int cs = 2;
    if (refRange)
        cs++;
    if (flags)
        cs++;
    if (note)
        cs++;
    if (issued)
        cs++;
    if (effectiveTime)
        cs++;
    XhtmlNode tr = tbl.tr();
    tr.td().b().tx("Code");
    tr.td().b().tx("Value");
    if (refRange) {
        tr.td().b().tx("Reference Range");
    }
    if (flags) {
        tr.td().b().tx("Flags");
    }
    if (note) {
        tr.td().b().tx("Note");
    }
    if (effectiveTime) {
        tr.td().b().tx("When For");
    }
    if (issued) {
        tr.td().b().tx("Reported");
    }
    for (ObservationNode o : observations) {
        addObservationToTable(tbl, o, 0, Integer.toString(cs), refRange, flags, note, effectiveTime, issued, eff, iss);
    }
}
Also used : XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 34 with Range

use of org.hl7.fhir.dstu2.model.Range in project org.hl7.fhir.core by hapifhir.

the class DiagnosticReportRenderer method addObservationToTable.

private void addObservationToTable(XhtmlNode tr, ResourceWrapper obs, int i, String ref, boolean refRange, boolean flags, boolean note, boolean effectiveTime, boolean issued, DataType eff, DataType iss) throws UnsupportedEncodingException, FHIRException, IOException {
    // code (+bodysite)
    XhtmlNode td = tr.td();
    PropertyWrapper pw = getProperty(obs, "code");
    if (valued(pw)) {
        render(td.ah(ref), pw.value());
    }
    pw = getProperty(obs, "bodySite");
    if (valued(pw)) {
        td.tx(" (");
        render(td, pw.value());
        td.tx(")");
    }
    // value / dataAbsentReason (in red)
    td = tr.td();
    pw = getProperty(obs, "value[x]");
    if (valued(pw)) {
        render(td, pw.value());
    } else {
        pw = getProperty(obs, "dataAbsentReason");
        if (valued(pw)) {
            XhtmlNode span = td.span("color: maroon", "Error");
            span.tx("Error: ");
            render(span.b(), pw.value());
        }
    }
    if (refRange) {
        // reference range
        td = tr.td();
        pw = getProperty(obs, "referenceRange");
        if (valued(pw)) {
            boolean first = true;
            for (BaseWrapper v : pw.getValues()) {
                if (first)
                    first = false;
                else
                    td.br();
                PropertyWrapper pwr = getProperty(v, "type");
                if (valued(pwr)) {
                    render(td, pwr.value());
                    td.tx(": ");
                }
                PropertyWrapper pwt = getProperty(v, "text");
                if (valued(pwt)) {
                    render(td, pwt.value());
                } else {
                    PropertyWrapper pwl = getProperty(v, "low");
                    PropertyWrapper pwh = getProperty(v, "high");
                    if (valued(pwl) && valued(pwh)) {
                        render(td, pwl.value());
                        td.tx(" - ");
                        render(td, pwh.value());
                    } else if (valued(pwl)) {
                        td.tx(">");
                        render(td, pwl.value());
                    } else if (valued(pwh)) {
                        td.tx("<");
                        render(td, pwh.value());
                    } else {
                        td.tx("??");
                    }
                }
                pwr = getProperty(v, "appliesTo");
                PropertyWrapper pwrA = getProperty(v, "age");
                if (valued(pwr) || valued(pwrA)) {
                    boolean firstA = true;
                    td.tx(" for ");
                    if (valued(pwr)) {
                        for (BaseWrapper va : pwr.getValues()) {
                            if (firstA)
                                firstA = false;
                            else
                                td.tx(", ");
                            render(td, va);
                        }
                    }
                    if (valued(pwrA)) {
                        if (firstA)
                            firstA = false;
                        else
                            td.tx(", ");
                        td.tx("Age ");
                        render(td, pwrA.value());
                    }
                }
            }
        }
    }
    if (flags) {
        // flags (status other than F, interpretation, )
        td = tr.td();
        boolean first = true;
        pw = getProperty(obs, "status");
        if (valued(pw)) {
            if (!pw.value().getBase().primitiveValue().equals("final")) {
                if (first)
                    first = false;
                else
                    td.br();
                render(td, pw.value());
            }
        }
        pw = getProperty(obs, "interpretation");
        if (valued(pw)) {
            for (BaseWrapper v : pw.getValues()) {
                if (first)
                    first = false;
                else
                    td.br();
                render(td, v);
            }
        }
    }
    if (note) {
        td = tr.td();
        pw = getProperty(obs, "note");
        if (valued(pw)) {
            render(td, pw.value());
        }
    }
    if (effectiveTime) {
        // effective if different to DR
        td = tr.td();
        pw = getProperty(obs, "effective[x]");
        if (valued(pw)) {
            if (!Base.compareDeep(pw.value().getBase(), eff, true)) {
                render(td, pw.value());
            }
        }
    }
    if (issued) {
        // issued if different to DR
        td = tr.td();
        pw = getProperty(obs, "issued");
        if (valued(pw)) {
            if (!Base.compareDeep(pw.value().getBase(), eff, true)) {
                render(td, pw.value());
            }
        }
    }
}
Also used : PropertyWrapper(org.hl7.fhir.r5.renderers.utils.BaseWrappers.PropertyWrapper) BaseWrapper(org.hl7.fhir.r5.renderers.utils.BaseWrappers.BaseWrapper) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 35 with Range

use of org.hl7.fhir.dstu2.model.Range in project org.hl7.fhir.core by hapifhir.

the class NarrativeGenerator method addObservationToTable.

private void addObservationToTable(XhtmlNode tr, ResourceWrapper obs, int i) {
    // TODO Auto-generated method stub
    // code (+bodysite)
    XhtmlNode td = tr.td();
    PropertyWrapper pw = getProperty(obs, "result");
    if (valued(pw)) {
        displayCodeableConcept(td, pw.value());
    }
    pw = getProperty(obs, "bodySite");
    if (valued(pw)) {
        td.tx(" (");
        displayCodeableConcept(td, pw.value());
        td.tx(")");
    }
    // value / dataAbsentReason (in red)
    td = tr.td();
    pw = getProperty(obs, "value[x]");
    if (valued(pw)) {
        if (pw.getTypeCode().equals("CodeableConcept"))
            displayCodeableConcept(td, pw.value());
        else if (pw.getTypeCode().equals("string"))
            displayText(td, pw.value());
        else
            td.addText(pw.getTypeCode() + " not rendered yet");
    }
    // units
    td = tr.td();
    td.tx("to do");
    // reference range
    td = tr.td();
    td.tx("to do");
    // flags (status other than F, interpretation, )
    td = tr.td();
    td.tx("to do");
    // issued if different to DR
    td = tr.td();
    td.tx("to do");
}
Also used : XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Aggregations

Test (org.junit.jupiter.api.Test)18 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)15 Quantity (org.hl7.fhir.r4.model.Quantity)14 Resource (org.hl7.fhir.r4.model.Resource)13 NotImplementedException (org.apache.commons.lang3.NotImplementedException)12 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)12 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)12 Search (ca.uhn.fhir.rest.annotation.Search)11 Trace (com.newrelic.api.agent.Trace)10 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)10 Beneficiary (gov.cms.bfd.model.rif.Beneficiary)9 ArrayList (java.util.ArrayList)9 DateRangeParam (ca.uhn.fhir.rest.param.DateRangeParam)8 Operation (gov.cms.bfd.server.war.Operation)8 OffsetLinkBuilder (gov.cms.bfd.server.war.commons.OffsetLinkBuilder)8 Date (java.util.Date)8 Range (org.hl7.fhir.r4.model.Range)8 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)7 List (java.util.List)7 Bundle (org.hl7.fhir.r4.model.Bundle)7