Search in sources :

Example 86 with DataType

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

the class JsonParser method composeType.

protected void composeType(String prefix, DataType type) throws IOException {
    if (type == null) {
        ;
    } else if (type instanceof Address) {
        composeAddress(prefix + "Address", (Address) type);
    } else if (type instanceof Age) {
        composeAge(prefix + "Age", (Age) type);
    } else if (type instanceof Annotation) {
        composeAnnotation(prefix + "Annotation", (Annotation) type);
    } else if (type instanceof Attachment) {
        composeAttachment(prefix + "Attachment", (Attachment) type);
    } else if (type instanceof CodeableConcept) {
        composeCodeableConcept(prefix + "CodeableConcept", (CodeableConcept) type);
    } else if (type instanceof CodeableReference) {
        composeCodeableReference(prefix + "CodeableReference", (CodeableReference) type);
    } else if (type instanceof Coding) {
        composeCoding(prefix + "Coding", (Coding) type);
    } else if (type instanceof ContactDetail) {
        composeContactDetail(prefix + "ContactDetail", (ContactDetail) type);
    } else if (type instanceof ContactPoint) {
        composeContactPoint(prefix + "ContactPoint", (ContactPoint) type);
    } else if (type instanceof Contributor) {
        composeContributor(prefix + "Contributor", (Contributor) type);
    } else if (type instanceof Count) {
        composeCount(prefix + "Count", (Count) type);
    } else if (type instanceof DataRequirement) {
        composeDataRequirement(prefix + "DataRequirement", (DataRequirement) type);
    } else if (type instanceof Distance) {
        composeDistance(prefix + "Distance", (Distance) type);
    } else if (type instanceof Dosage) {
        composeDosage(prefix + "Dosage", (Dosage) type);
    } else if (type instanceof Duration) {
        composeDuration(prefix + "Duration", (Duration) type);
    } else if (type instanceof ElementDefinition) {
        composeElementDefinition(prefix + "ElementDefinition", (ElementDefinition) type);
    } else if (type instanceof Expression) {
        composeExpression(prefix + "Expression", (Expression) type);
    } else if (type instanceof Extension) {
        composeExtension(prefix + "Extension", (Extension) type);
    } else if (type instanceof HumanName) {
        composeHumanName(prefix + "HumanName", (HumanName) type);
    } else if (type instanceof Identifier) {
        composeIdentifier(prefix + "Identifier", (Identifier) type);
    } else if (type instanceof MarketingStatus) {
        composeMarketingStatus(prefix + "MarketingStatus", (MarketingStatus) type);
    } else if (type instanceof Meta) {
        composeMeta(prefix + "Meta", (Meta) type);
    } else if (type instanceof Money) {
        composeMoney(prefix + "Money", (Money) type);
    } else if (type instanceof Narrative) {
        composeNarrative(prefix + "Narrative", (Narrative) type);
    } else if (type instanceof ParameterDefinition) {
        composeParameterDefinition(prefix + "ParameterDefinition", (ParameterDefinition) type);
    } else if (type instanceof Period) {
        composePeriod(prefix + "Period", (Period) type);
    } else if (type instanceof Population) {
        composePopulation(prefix + "Population", (Population) type);
    } else if (type instanceof ProdCharacteristic) {
        composeProdCharacteristic(prefix + "ProdCharacteristic", (ProdCharacteristic) type);
    } else if (type instanceof ProductShelfLife) {
        composeProductShelfLife(prefix + "ProductShelfLife", (ProductShelfLife) type);
    } else if (type instanceof Quantity) {
        composeQuantity(prefix + "Quantity", (Quantity) type);
    } else if (type instanceof Range) {
        composeRange(prefix + "Range", (Range) type);
    } else if (type instanceof Ratio) {
        composeRatio(prefix + "Ratio", (Ratio) type);
    } else if (type instanceof RatioRange) {
        composeRatioRange(prefix + "RatioRange", (RatioRange) type);
    } else if (type instanceof Reference) {
        composeReference(prefix + "Reference", (Reference) type);
    } else if (type instanceof RelatedArtifact) {
        composeRelatedArtifact(prefix + "RelatedArtifact", (RelatedArtifact) type);
    } else if (type instanceof SampledData) {
        composeSampledData(prefix + "SampledData", (SampledData) type);
    } else if (type instanceof Signature) {
        composeSignature(prefix + "Signature", (Signature) type);
    } else if (type instanceof Timing) {
        composeTiming(prefix + "Timing", (Timing) type);
    } else if (type instanceof TriggerDefinition) {
        composeTriggerDefinition(prefix + "TriggerDefinition", (TriggerDefinition) type);
    } else if (type instanceof UsageContext) {
        composeUsageContext(prefix + "UsageContext", (UsageContext) type);
    } else if (type instanceof CodeType) {
        composeCodeCore(prefix + "Code", (CodeType) type, false);
        composeCodeExtras(prefix + "Code", (CodeType) type, false);
    } else if (type instanceof OidType) {
        composeOidCore(prefix + "Oid", (OidType) type, false);
        composeOidExtras(prefix + "Oid", (OidType) type, false);
    } else if (type instanceof CanonicalType) {
        composeCanonicalCore(prefix + "Canonical", (CanonicalType) type, false);
        composeCanonicalExtras(prefix + "Canonical", (CanonicalType) type, false);
    } else if (type instanceof UuidType) {
        composeUuidCore(prefix + "Uuid", (UuidType) type, false);
        composeUuidExtras(prefix + "Uuid", (UuidType) type, false);
    } else if (type instanceof UrlType) {
        composeUrlCore(prefix + "Url", (UrlType) type, false);
        composeUrlExtras(prefix + "Url", (UrlType) type, false);
    } else if (type instanceof UnsignedIntType) {
        composeUnsignedIntCore(prefix + "UnsignedInt", (UnsignedIntType) type, false);
        composeUnsignedIntExtras(prefix + "UnsignedInt", (UnsignedIntType) type, false);
    } else if (type instanceof MarkdownType) {
        composeMarkdownCore(prefix + "Markdown", (MarkdownType) type, false);
        composeMarkdownExtras(prefix + "Markdown", (MarkdownType) type, false);
    } else if (type instanceof IdType) {
        composeIdCore(prefix + "Id", (IdType) type, false);
        composeIdExtras(prefix + "Id", (IdType) type, false);
    } else if (type instanceof PositiveIntType) {
        composePositiveIntCore(prefix + "PositiveInt", (PositiveIntType) type, false);
        composePositiveIntExtras(prefix + "PositiveInt", (PositiveIntType) type, false);
    } else if (type instanceof DateType) {
        composeDateCore(prefix + "Date", (DateType) type, false);
        composeDateExtras(prefix + "Date", (DateType) type, false);
    } else if (type instanceof DateTimeType) {
        composeDateTimeCore(prefix + "DateTime", (DateTimeType) type, false);
        composeDateTimeExtras(prefix + "DateTime", (DateTimeType) type, false);
    } else if (type instanceof StringType) {
        composeStringCore(prefix + "String", (StringType) type, false);
        composeStringExtras(prefix + "String", (StringType) type, false);
    } else if (type instanceof IntegerType) {
        composeIntegerCore(prefix + "Integer", (IntegerType) type, false);
        composeIntegerExtras(prefix + "Integer", (IntegerType) type, false);
    } else if (type instanceof Integer64Type) {
        composeInteger64Core(prefix + "Integer64", (Integer64Type) type, false);
        composeInteger64Extras(prefix + "Integer64", (Integer64Type) type, false);
    } else if (type instanceof UriType) {
        composeUriCore(prefix + "Uri", (UriType) type, false);
        composeUriExtras(prefix + "Uri", (UriType) type, false);
    } else if (type instanceof InstantType) {
        composeInstantCore(prefix + "Instant", (InstantType) type, false);
        composeInstantExtras(prefix + "Instant", (InstantType) type, false);
    } else if (type instanceof BooleanType) {
        composeBooleanCore(prefix + "Boolean", (BooleanType) type, false);
        composeBooleanExtras(prefix + "Boolean", (BooleanType) type, false);
    } else if (type instanceof Base64BinaryType) {
        composeBase64BinaryCore(prefix + "Base64Binary", (Base64BinaryType) type, false);
        composeBase64BinaryExtras(prefix + "Base64Binary", (Base64BinaryType) type, false);
    } else if (type instanceof TimeType) {
        composeTimeCore(prefix + "Time", (TimeType) type, false);
        composeTimeExtras(prefix + "Time", (TimeType) type, false);
    } else if (type instanceof DecimalType) {
        composeDecimalCore(prefix + "Decimal", (DecimalType) type, false);
        composeDecimalExtras(prefix + "Decimal", (DecimalType) type, false);
    } else
        throw new Error("Unhandled type");
}
Also used : FHIRFormatError(org.hl7.fhir.exceptions.FHIRFormatError)

Example 87 with DataType

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

the class QuestionnaireResponseRenderer method renderAnswer.

public void renderAnswer(HierarchicalTableGenerator gen, ResourceWrapper q, Row r, BaseWrapper ans) throws UnsupportedEncodingException, IOException {
    List<BaseWrapper> items;
    Base b = ans.get("value[x]");
    if (b == null) {
        r.getCells().add(gen.new Cell(null, null, "null!", null, null));
    } else if (b.isPrimitive()) {
        r.getCells().add(gen.new Cell(null, null, b.primitiveValue(), null, null));
    } else {
        XhtmlNode x = new XhtmlNode(NodeType.Element, "span");
        Cell cell = gen.new Cell(null, null, null, null, null);
        Piece p = gen.new Piece("span");
        p.getChildren().add(x);
        cell.addPiece(p);
        render(x, (DataType) b);
        r.getCells().add(cell);
    }
    items = ans.children("item");
    for (BaseWrapper si : items) {
        renderTreeItem(gen, r.getSubRows(), q, si);
    }
}
Also used : BaseWrapper(org.hl7.fhir.r4b.renderers.utils.BaseWrappers.BaseWrapper) Piece(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece) DataType(org.hl7.fhir.r4b.model.DataType) Cell(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell) Base(org.hl7.fhir.r4b.model.Base) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 88 with DataType

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

the class DiagnosticReportRenderer method addObservationToTable.

private void addObservationToTable(XhtmlNode tbl, ObservationNode o, int i, String cs, boolean refRange, boolean flags, boolean note, boolean effectiveTime, boolean issued, DataType eff, DataType iss) throws UnsupportedEncodingException, FHIRException, IOException {
    XhtmlNode tr = tbl.tr();
    if (o.obs != null && o.obs.getReference() == null) {
        XhtmlNode td = tr.td().colspan(cs);
        td.i().tx("This Observation could not be resolved");
    } else {
        if (o.obs != null && o.obs.getResource() != null) {
            addObservationToTable(tr, o.obs.getResource(), i, o.obs.getReference(), refRange, flags, note, effectiveTime, issued, eff, iss);
        } else {
            XhtmlNode td = tr.td().colspan(cs);
            td.i().tx("Observation");
        }
        if (o.contained != null) {
            for (ObservationNode c : o.contained) {
                addObservationToTable(tbl, c, i + 1, cs, refRange, flags, note, effectiveTime, issued, eff, iss);
            }
        }
    }
}
Also used : XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 89 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.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 90 with DataType

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

the class ProfileUtilities method createExampleElement.

private org.hl7.fhir.r5.elementmodel.Element createExampleElement(StructureDefinition profile, ElementDefinition ed, ExampleValueAccessor accessor) throws FHIRException {
    DataType v = accessor.getExampleValue(ed);
    if (v != null) {
        return new ObjectConverter(context).convert(new Property(context, ed, profile), v);
    } else {
        org.hl7.fhir.r5.elementmodel.Element res = new org.hl7.fhir.r5.elementmodel.Element(tail(ed.getPath()), new Property(context, ed, profile));
        boolean hasValue = false;
        List<ElementDefinition> children = getChildMap(profile, ed);
        for (ElementDefinition child : children) {
            if (!child.hasContentReference()) {
                org.hl7.fhir.r5.elementmodel.Element e = createExampleElement(profile, child, accessor);
                if (e != null) {
                    hasValue = true;
                    res.getChildren().add(e);
                }
            }
        }
        if (hasValue)
            return res;
        else
            return null;
    }
}
Also used : ObjectConverter(org.hl7.fhir.r5.elementmodel.ObjectConverter) Element(org.hl7.fhir.r5.model.Element) DataType(org.hl7.fhir.r5.model.DataType) ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition) Property(org.hl7.fhir.r5.elementmodel.Property)

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