Search in sources :

Example 91 with Enumeration

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

the class CompartmentDefinition method setProperty.

@Override
public Base setProperty(String name, Base value) throws FHIRException {
    if (name.equals("url")) {
        // UriType
        this.url = castToUri(value);
    } else if (name.equals("name")) {
        // StringType
        this.name = castToString(value);
    } else if (name.equals("title")) {
        // StringType
        this.title = castToString(value);
    } else if (name.equals("status")) {
        value = new PublicationStatusEnumFactory().fromType(castToCode(value));
        // Enumeration<PublicationStatus>
        this.status = (Enumeration) value;
    } else if (name.equals("experimental")) {
        // BooleanType
        this.experimental = castToBoolean(value);
    } else if (name.equals("date")) {
        // DateTimeType
        this.date = castToDateTime(value);
    } else if (name.equals("publisher")) {
        // StringType
        this.publisher = castToString(value);
    } else if (name.equals("contact")) {
        this.getContact().add(castToContactDetail(value));
    } else if (name.equals("description")) {
        // MarkdownType
        this.description = castToMarkdown(value);
    } else if (name.equals("purpose")) {
        // MarkdownType
        this.purpose = castToMarkdown(value);
    } else if (name.equals("useContext")) {
        this.getUseContext().add(castToUsageContext(value));
    } else if (name.equals("jurisdiction")) {
        this.getJurisdiction().add(castToCodeableConcept(value));
    } else if (name.equals("code")) {
        value = new CompartmentTypeEnumFactory().fromType(castToCode(value));
        // Enumeration<CompartmentType>
        this.code = (Enumeration) value;
    } else if (name.equals("search")) {
        // BooleanType
        this.search = castToBoolean(value);
    } else if (name.equals("resource")) {
        this.getResource().add((CompartmentDefinitionResourceComponent) value);
    } else
        return super.setProperty(name, value);
    return value;
}
Also used : PublicationStatusEnumFactory(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatusEnumFactory)

Example 92 with Enumeration

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

the class CodeSystem method setProperty.

@Override
public Base setProperty(String name, Base value) throws FHIRException {
    if (name.equals("url")) {
        // UriType
        this.url = castToUri(value);
    } else if (name.equals("identifier")) {
        // Identifier
        this.identifier = castToIdentifier(value);
    } else if (name.equals("version")) {
        // StringType
        this.version = castToString(value);
    } else if (name.equals("name")) {
        // StringType
        this.name = castToString(value);
    } else if (name.equals("title")) {
        // StringType
        this.title = castToString(value);
    } else if (name.equals("status")) {
        value = new PublicationStatusEnumFactory().fromType(castToCode(value));
        // Enumeration<PublicationStatus>
        this.status = (Enumeration) value;
    } else if (name.equals("experimental")) {
        // BooleanType
        this.experimental = castToBoolean(value);
    } else if (name.equals("date")) {
        // DateTimeType
        this.date = castToDateTime(value);
    } else if (name.equals("publisher")) {
        // StringType
        this.publisher = castToString(value);
    } else if (name.equals("contact")) {
        this.getContact().add(castToContactDetail(value));
    } else if (name.equals("description")) {
        // MarkdownType
        this.description = castToMarkdown(value);
    } else if (name.equals("useContext")) {
        this.getUseContext().add(castToUsageContext(value));
    } else if (name.equals("jurisdiction")) {
        this.getJurisdiction().add(castToCodeableConcept(value));
    } else if (name.equals("purpose")) {
        // MarkdownType
        this.purpose = castToMarkdown(value);
    } else if (name.equals("copyright")) {
        // MarkdownType
        this.copyright = castToMarkdown(value);
    } else if (name.equals("caseSensitive")) {
        // BooleanType
        this.caseSensitive = castToBoolean(value);
    } else if (name.equals("valueSet")) {
        // UriType
        this.valueSet = castToUri(value);
    } else if (name.equals("hierarchyMeaning")) {
        value = new CodeSystemHierarchyMeaningEnumFactory().fromType(castToCode(value));
        // Enumeration<CodeSystemHierarchyMeaning>
        this.hierarchyMeaning = (Enumeration) value;
    } else if (name.equals("compositional")) {
        // BooleanType
        this.compositional = castToBoolean(value);
    } else if (name.equals("versionNeeded")) {
        // BooleanType
        this.versionNeeded = castToBoolean(value);
    } else if (name.equals("content")) {
        value = new CodeSystemContentModeEnumFactory().fromType(castToCode(value));
        // Enumeration<CodeSystemContentMode>
        this.content = (Enumeration) value;
    } else if (name.equals("count")) {
        // UnsignedIntType
        this.count = castToUnsignedInt(value);
    } else if (name.equals("filter")) {
        this.getFilter().add((CodeSystemFilterComponent) value);
    } else if (name.equals("property")) {
        this.getProperty().add((PropertyComponent) value);
    } else if (name.equals("concept")) {
        this.getConcept().add((ConceptDefinitionComponent) value);
    } else
        return super.setProperty(name, value);
    return value;
}
Also used : PublicationStatusEnumFactory(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatusEnumFactory)

Example 93 with Enumeration

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

the class XLSXWriter method itemList.

private String itemList(List l) {
    StringBuilder s = new StringBuilder();
    for (int i = 0; i < l.size(); i++) {
        Object o = l.get(i);
        String val = "";
        if (o instanceof StringType) {
            val = ((StringType) o).getValue();
        } else if (o instanceof UriType) {
            val = ((UriType) o).getValue();
        } else if (o instanceof IdType) {
            val = ((IdType) o).getValue();
        } else if (o instanceof Enumeration<?>) {
            val = o.toString();
        } else if (o instanceof TypeRefComponent) {
            TypeRefComponent t = (TypeRefComponent) o;
            val = t.getWorkingCode();
            if (val == null)
                val = "";
            if (val.startsWith("http://hl7.org/fhir/StructureDefinition/"))
                val = val.substring(40);
            if (t.hasTargetProfile())
                val = val + "(" + canonicalList(t.getTargetProfile()) + ")";
            if (t.hasProfile())
                val = val + " {" + canonicalList(t.getProfile()) + "}";
            if (t.hasAggregation())
                val = val + " <<" + aggList(t.getAggregation()) + ">>";
        } else if (o instanceof Coding) {
            Coding t = (Coding) o;
            val = (t.getSystem() == null ? "" : t.getSystem()) + (t.getCode() == null ? "" : "#" + t.getCode()) + (t.getDisplay() == null ? "" : " (" + t.getDisplay() + ")");
        } else if (o instanceof ElementDefinitionConstraintComponent) {
            ElementDefinitionConstraintComponent c = (ElementDefinitionConstraintComponent) o;
            val = c.getKey() + ":" + c.getHuman() + " {" + c.getExpression() + "}";
        } else if (o instanceof ElementDefinitionSlicingDiscriminatorComponent) {
            ElementDefinitionSlicingDiscriminatorComponent c = (ElementDefinitionSlicingDiscriminatorComponent) o;
            val = c.getType().toCode() + ":" + c.getPath() + "}";
        } else {
            val = o.toString();
            val = val.substring(val.indexOf("[") + 1);
            val = val.substring(0, val.indexOf("]"));
        }
        s = s.append(val);
        if (i == 0)
            s.append("\n");
    }
    return s.toString();
}
Also used : ElementDefinitionSlicingDiscriminatorComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) StringType(org.hl7.fhir.r4.model.StringType) TypeRefComponent(org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent) Coding(org.hl7.fhir.r4.model.Coding) ElementDefinitionConstraintComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent) UriType(org.hl7.fhir.r4.model.UriType) IdType(org.hl7.fhir.r4.model.IdType)

Example 94 with Enumeration

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

the class ProfileDrivenRenderer method displayLeaf.

private boolean displayLeaf(ResourceWrapper res, BaseWrapper ew, ElementDefinition defn, XhtmlNode x, String name, boolean showCodeDetails, boolean allowLinks) throws FHIRException, UnsupportedEncodingException, IOException {
    if (ew == null)
        return false;
    Base e = ew.getBase();
    if (e == null)
        return false;
    Map<String, String> displayHints = readDisplayHints(defn);
    if (name.endsWith("[x]"))
        name = name.substring(0, name.length() - 3);
    if (!showCodeDetails && e instanceof PrimitiveType && isDefault(displayHints, ((PrimitiveType) e)))
        return false;
    if (e instanceof StringType) {
        x.addText(name + ": " + ((StringType) e).getValue());
        return true;
    } else if (e instanceof CodeType) {
        x.addText(name + ": " + ((CodeType) e).getValue());
        return true;
    } else if (e instanceof IdType) {
        x.addText(name + ": " + ((IdType) e).getValue());
        return true;
    } else if (e instanceof UriType) {
        if (Utilities.isAbsoluteUrlLinkable(((UriType) e).getValue()) && allowLinks) {
            x.tx(name + ": ");
            x.ah(((UriType) e).getValue()).addText(((UriType) e).getValue());
        } else {
            x.addText(name + ": " + ((UriType) e).getValue());
        }
        return true;
    } else if (e instanceof DateTimeType) {
        x.addText(name + ": " + ((DateTimeType) e).toHumanDisplay());
        return true;
    } else if (e instanceof InstantType) {
        x.addText(name + ": " + ((InstantType) e).toHumanDisplay());
        return true;
    } else if (e instanceof Extension) {
        // x.tx("Extensions: todo");
        return false;
    } else if (e instanceof org.hl7.fhir.r5.model.DateType) {
        x.addText(name + ": " + ((org.hl7.fhir.r5.model.DateType) e).toHumanDisplay());
        return true;
    } else if (e instanceof Enumeration) {
        // todo: look up a display name if there is one
        x.addText(((Enumeration<?>) e).getValue().toString());
        return true;
    } else if (e instanceof BooleanType) {
        if (((BooleanType) e).hasValue()) {
            x.addText(name);
            x.addText(": ");
            x.addText(((BooleanType) e).getValueAsString());
            return true;
        }
    } else if (e instanceof CodeableReference) {
        if (((CodeableReference) e).hasReference()) {
            Reference r = ((CodeableReference) e).getReference();
            renderReference(res, x, r, allowLinks);
        } else {
            renderCodeableConcept(x, ((CodeableReference) e).getConcept(), showCodeDetails);
        }
        return true;
    } else if (e instanceof CodeableConcept) {
        renderCodeableConcept(x, (CodeableConcept) e, showCodeDetails);
        return true;
    } else if (e instanceof Coding) {
        renderCoding(x, (Coding) e, showCodeDetails);
        return true;
    } else if (e instanceof Annotation) {
        renderAnnotation(x, (Annotation) e, showCodeDetails);
        return true;
    } else if (e instanceof org.hl7.fhir.r5.model.IntegerType) {
        x.addText(Integer.toString(((org.hl7.fhir.r5.model.IntegerType) e).getValue()));
        return true;
    } else if (e instanceof org.hl7.fhir.r5.model.DecimalType) {
        x.addText(((org.hl7.fhir.r5.model.DecimalType) e).getValue().toString());
        return true;
    } else if (e instanceof Identifier) {
        renderIdentifier(x, (Identifier) e);
        return true;
    } else if (e instanceof HumanName) {
        renderHumanName(x, (HumanName) e);
        return true;
    } else if (e instanceof SampledData) {
        renderSampledData(x, (SampledData) e);
        return true;
    } else if (e instanceof Address) {
        renderAddress(x, (Address) e);
        return true;
    } else if (e instanceof ContactPoint) {
        if (allowLinks) {
            renderContactPoint(x, (ContactPoint) e);
        } else {
            displayContactPoint(x, (ContactPoint) e);
        }
        return true;
    } else if (e instanceof Timing) {
        renderTiming(x, (Timing) e);
        return true;
    } else if (e instanceof Quantity) {
        renderQuantity(x, (Quantity) e, showCodeDetails);
        return true;
    } else if (e instanceof Ratio) {
        renderQuantity(x, ((Ratio) e).getNumerator(), showCodeDetails);
        x.tx("/");
        renderQuantity(x, ((Ratio) e).getDenominator(), showCodeDetails);
        return true;
    } else if (e instanceof Period) {
        Period p = (Period) e;
        x.addText(name + ": ");
        x.addText(!p.hasStart() ? "?ngen-2?" : p.getStartElement().toHumanDisplay());
        x.tx(" --> ");
        x.addText(!p.hasEnd() ? "(ongoing)" : p.getEndElement().toHumanDisplay());
        return true;
    } else if (e instanceof Reference) {
        Reference r = (Reference) e;
        if (r.hasDisplayElement())
            x.addText(r.getDisplay());
        else if (r.hasReferenceElement()) {
            ResourceWithReference tr = resolveReference(res, r.getReference());
            // getDisplayForReference(tr.getReference()));
            x.addText(tr == null ? r.getReference() : "?ngen-3");
        } else
            x.tx("?ngen-4?");
        return true;
    } else if (e instanceof Narrative) {
        return false;
    } else if (e instanceof Resource) {
        return false;
    } else if (e instanceof ContactDetail) {
        ContactDetail cd = (ContactDetail) e;
        if (cd.hasName()) {
            x.tx(cd.getName() + ": ");
        }
        boolean first = true;
        for (ContactPoint c : cd.getTelecom()) {
            if (first)
                first = false;
            else
                x.tx(",");
            if (allowLinks) {
                renderContactPoint(x, c);
            } else {
                displayContactPoint(x, c);
            }
        }
        return true;
    } else if (e instanceof Range) {
        return false;
    } else if (e instanceof Meta) {
        return false;
    } else if (e instanceof Dosage) {
        return false;
    } else if (e instanceof Signature) {
        return false;
    } else if (e instanceof UsageContext) {
        return false;
    } else if (e instanceof RelatedArtifact) {
        return false;
    } else if (e instanceof ElementDefinition) {
        return false;
    } else if (e instanceof Base64BinaryType) {
        return false;
    } else if (!(e instanceof Attachment))
        throw new NotImplementedException("type " + e.getClass().getName() + " not handled yet");
    return false;
}
Also used : Meta(org.hl7.fhir.r5.model.Meta) Address(org.hl7.fhir.r5.model.Address) StringType(org.hl7.fhir.r5.model.StringType) Attachment(org.hl7.fhir.r5.model.Attachment) Dosage(org.hl7.fhir.r5.model.Dosage) Identifier(org.hl7.fhir.r5.model.Identifier) Coding(org.hl7.fhir.r5.model.Coding) Narrative(org.hl7.fhir.r5.model.Narrative) SampledData(org.hl7.fhir.r5.model.SampledData) PrimitiveType(org.hl7.fhir.r5.model.PrimitiveType) ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition) InstantType(org.hl7.fhir.r5.model.InstantType) Resource(org.hl7.fhir.r5.model.Resource) DomainResource(org.hl7.fhir.r5.model.DomainResource) Period(org.hl7.fhir.r5.model.Period) ResourceWithReference(org.hl7.fhir.r5.renderers.utils.Resolver.ResourceWithReference) Range(org.hl7.fhir.r5.model.Range) RelatedArtifact(org.hl7.fhir.r5.model.RelatedArtifact) IdType(org.hl7.fhir.r5.model.IdType) DateTimeType(org.hl7.fhir.r5.model.DateTimeType) UsageContext(org.hl7.fhir.r5.model.UsageContext) Timing(org.hl7.fhir.r5.model.Timing) CodeableConcept(org.hl7.fhir.r5.model.CodeableConcept) NotImplementedException(org.apache.commons.lang3.NotImplementedException) UriType(org.hl7.fhir.r5.model.UriType) HumanName(org.hl7.fhir.r5.model.HumanName) ContactPoint(org.hl7.fhir.r5.model.ContactPoint) Ratio(org.hl7.fhir.r5.model.Ratio) Enumeration(org.hl7.fhir.r5.model.Enumeration) Reference(org.hl7.fhir.r5.model.Reference) ResourceWithReference(org.hl7.fhir.r5.renderers.utils.Resolver.ResourceWithReference) CodeableReference(org.hl7.fhir.r5.model.CodeableReference) BooleanType(org.hl7.fhir.r5.model.BooleanType) Quantity(org.hl7.fhir.r5.model.Quantity) Base(org.hl7.fhir.r5.model.Base) Annotation(org.hl7.fhir.r5.model.Annotation) Extension(org.hl7.fhir.r5.model.Extension) ContactDetail(org.hl7.fhir.r5.model.ContactDetail) CodeableReference(org.hl7.fhir.r5.model.CodeableReference) Signature(org.hl7.fhir.r5.model.Signature) CodeType(org.hl7.fhir.r5.model.CodeType) Base64BinaryType(org.hl7.fhir.r5.model.Base64BinaryType)

Example 95 with Enumeration

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

the class CodeSystemRenderer method generateFilters.

private void generateFilters(XhtmlNode x, CodeSystem cs) {
    if (cs.hasFilter()) {
        x.para().b().tx(getContext().getWorker().translator().translate("xhtml-gen-cs", "Filters", getContext().getLang()));
        XhtmlNode tbl = x.table("grid");
        XhtmlNode tr = tbl.tr();
        tr.td().b().tx(getContext().getWorker().translator().translate("xhtml-gen-cs", "Code", getContext().getLang()));
        tr.td().b().tx(getContext().getWorker().translator().translate("xhtml-gen-cs", "Description", getContext().getLang()));
        tr.td().b().tx(getContext().getWorker().translator().translate("xhtml-gen-cs", "operator", getContext().getLang()));
        tr.td().b().tx(getContext().getWorker().translator().translate("xhtml-gen-cs", "Value", getContext().getLang()));
        for (CodeSystemFilterComponent f : cs.getFilter()) {
            tr = tbl.tr();
            tr.td().tx(f.getCode());
            tr.td().tx(f.getDescription());
            XhtmlNode td = tr.td();
            for (Enumeration<org.hl7.fhir.r5.model.Enumerations.FilterOperator> t : f.getOperator()) td.tx(t.asStringValue() + " ");
            tr.td().tx(f.getValue());
        }
    }
}
Also used : CodeSystemFilterComponent(org.hl7.fhir.r5.model.CodeSystem.CodeSystemFilterComponent) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Aggregations

CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)14 ArrayList (java.util.ArrayList)11 NotImplementedException (org.apache.commons.lang3.NotImplementedException)11 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)10 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)10 FHIRException (org.hl7.fhir.exceptions.FHIRException)7 StringType (org.hl7.fhir.r5.model.StringType)7 ConformanceResourceStatusEnumFactory (org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatusEnumFactory)6 Enumeration (org.hl7.fhir.dstu3.model.Enumeration)6 Enumeration (org.hl7.fhir.r4.model.Enumeration)6 StringType (org.hl7.fhir.r4b.model.StringType)6 Enumeration (org.hl7.fhir.r5.model.Enumeration)6 UriType (org.hl7.fhir.r5.model.UriType)6 Base64 (org.apache.commons.codec.binary.Base64)5 PublicationStatusEnumFactory (org.hl7.fhir.dstu3.model.Enumerations.PublicationStatusEnumFactory)5 StringType (org.hl7.fhir.dstu3.model.StringType)5 Enumeration (org.hl7.fhir.dstu2.model.Enumeration)4 Reference (org.hl7.fhir.dstu2.model.Reference)4 StringType (org.hl7.fhir.dstu2.model.StringType)4 Patient (org.hl7.fhir.r4.model.Patient)4