Search in sources :

Example 76 with DataType

use of org.hl7.fhir.r5.model.DataType in project org.hl7.fhir.core by hapifhir.

the class StructureMapUtilities method describeTransformCCorC.

@SuppressWarnings("rawtypes")
private String describeTransformCCorC(StructureMapGroupRuleTargetComponent tgt) throws FHIRException {
    if (tgt.getParameter().size() < 2)
        return null;
    DataType p1 = tgt.getParameter().get(0).getValue();
    DataType p2 = tgt.getParameter().get(1).getValue();
    if (p1 instanceof IdType || p2 instanceof IdType)
        return null;
    if (!(p1 instanceof PrimitiveType) || !(p2 instanceof PrimitiveType))
        return null;
    String uri = ((PrimitiveType) p1).asStringValue();
    String code = ((PrimitiveType) p2).asStringValue();
    if (Utilities.noString(uri))
        throw new FHIRException("Describe Transform, but the uri is blank");
    if (Utilities.noString(code))
        throw new FHIRException("Describe Transform, but the code is blank");
    Coding c = buildCoding(uri, code);
    return TerminologyRenderer.describeSystem(c.getSystem()) + "#" + c.getCode() + (c.hasDisplay() ? "(" + c.getDisplay() + ")" : "");
}
Also used : FHIRException(org.hl7.fhir.exceptions.FHIRException)

Example 77 with DataType

use of org.hl7.fhir.r5.model.DataType in project org.hl7.fhir.core by hapifhir.

the class StructureMapUtilities method getParam.

private Base getParam(Variables vars, StructureMapGroupRuleTargetParameterComponent parameter) throws DefinitionException {
    DataType p = parameter.getValue();
    if (!(p instanceof IdType))
        return p;
    else {
        String n = ((IdType) p).asStringValue();
        Base b = vars.get(VariableMode.INPUT, n);
        if (b == null)
            b = vars.get(VariableMode.OUTPUT, n);
        if (b == null)
            throw new DefinitionException("Variable " + n + " not found (" + vars.summary() + ")");
        return b;
    }
}
Also used : DefinitionException(org.hl7.fhir.exceptions.DefinitionException)

Example 78 with DataType

use of org.hl7.fhir.r5.model.DataType in project org.hl7.fhir.core by hapifhir.

the class DataRenderer method renderExtensionsInList.

public void renderExtensionsInList(XhtmlNode ul, DataType element) throws FHIRFormatError, DefinitionException, IOException {
    for (Extension ext : element.getExtension()) {
        if (canRender(ext)) {
            String lbl = getExtensionLabel(ext);
            XhtmlNode li = ul.li();
            li.tx(lbl);
            li.tx(": ");
            render(li, ext.getValue());
        }
    }
}
Also used : Extension(org.hl7.fhir.r5.model.Extension) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 79 with DataType

use of org.hl7.fhir.r5.model.DataType 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 80 with DataType

use of org.hl7.fhir.r5.model.DataType 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)

Aggregations

DataType (org.hl7.fhir.r5.model.DataType)14 FHIRException (org.hl7.fhir.exceptions.FHIRException)11 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)11 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)8 HashMap (java.util.HashMap)7 List (java.util.List)7 Map (java.util.Map)7 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)7 Collectors (java.util.stream.Collectors)6 DataType (org.hl7.cql.model.DataType)6 ModelInfo (org.hl7.elm_modelinfo.r1.ModelInfo)6 Piece (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece)6 ArrayList (java.util.ArrayList)5 StructType (org.apache.spark.sql.types.StructType)5 BooleanType (org.hl7.fhir.r5.model.BooleanType)5 ValueSet (org.hl7.fhir.r5.model.ValueSet)5 Arrays (java.util.Arrays)4 QName (javax.xml.namespace.QName)4 DataType (org.hl7.fhir.r4b.model.DataType)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3