Search in sources :

Example 26 with Enumeration

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

the class FamilyMemberHistory method setProperty.

@Override
public void setProperty(String name, Base value) throws FHIRException {
    if (name.equals("identifier"))
        this.getIdentifier().add(castToIdentifier(value));
    else if (name.equals("patient"))
        // Reference
        this.patient = castToReference(value);
    else if (name.equals("date"))
        // DateTimeType
        this.date = castToDateTime(value);
    else if (name.equals("status"))
        // Enumeration<FamilyHistoryStatus>
        this.status = new FamilyHistoryStatusEnumFactory().fromType(value);
    else if (name.equals("name"))
        // StringType
        this.name = castToString(value);
    else if (name.equals("relationship"))
        // CodeableConcept
        this.relationship = castToCodeableConcept(value);
    else if (name.equals("gender"))
        // Enumeration<AdministrativeGender>
        this.gender = new AdministrativeGenderEnumFactory().fromType(value);
    else if (name.equals("born[x]"))
        // Type
        this.born = (Type) value;
    else if (name.equals("age[x]"))
        // Type
        this.age = (Type) value;
    else if (name.equals("deceased[x]"))
        // Type
        this.deceased = (Type) value;
    else if (name.equals("note"))
        // Annotation
        this.note = castToAnnotation(value);
    else if (name.equals("condition"))
        this.getCondition().add((FamilyMemberHistoryConditionComponent) value);
    else
        super.setProperty(name, value);
}
Also used : AdministrativeGenderEnumFactory(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGenderEnumFactory)

Example 27 with Enumeration

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

the class DocumentManifest method setProperty.

@Override
public void setProperty(String name, Base value) throws FHIRException {
    if (name.equals("masterIdentifier"))
        // Identifier
        this.masterIdentifier = castToIdentifier(value);
    else if (name.equals("identifier"))
        this.getIdentifier().add(castToIdentifier(value));
    else if (name.equals("subject"))
        // Reference
        this.subject = castToReference(value);
    else if (name.equals("recipient"))
        this.getRecipient().add(castToReference(value));
    else if (name.equals("type"))
        // CodeableConcept
        this.type = castToCodeableConcept(value);
    else if (name.equals("author"))
        this.getAuthor().add(castToReference(value));
    else if (name.equals("created"))
        // DateTimeType
        this.created = castToDateTime(value);
    else if (name.equals("source"))
        // UriType
        this.source = castToUri(value);
    else if (name.equals("status"))
        // Enumeration<DocumentReferenceStatus>
        this.status = new DocumentReferenceStatusEnumFactory().fromType(value);
    else if (name.equals("description"))
        // StringType
        this.description = castToString(value);
    else if (name.equals("content"))
        this.getContent().add((DocumentManifestContentComponent) value);
    else if (name.equals("related"))
        this.getRelated().add((DocumentManifestRelatedComponent) value);
    else
        super.setProperty(name, value);
}
Also used : DocumentReferenceStatusEnumFactory(org.hl7.fhir.dstu2.model.Enumerations.DocumentReferenceStatusEnumFactory)

Example 28 with Enumeration

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

the class QuestionnaireBuilder method addQuestion.

private QuestionComponent addQuestion(GroupComponent group, AnswerFormat af, String path, String id, String name, List<QuestionnaireResponse.GroupComponent> answerGroups, ValueSet vs) throws FHIRException {
    QuestionComponent result = group.addQuestion();
    if (vs != null) {
        result.setOptions(new Reference());
        if (vs.getExpansion() == null) {
            result.getOptions().setReference(vs.getUrl());
            ToolingExtensions.addFilterOnly(result.getOptions(), true);
        } else {
            if (Utilities.noString(vs.getId())) {
                vs.setId(nextId("vs"));
                questionnaire.getContained().add(vs);
                vsCache.put(vs.getUrl(), vs.getId());
                vs.setText(null);
                vs.setCodeSystem(null);
                vs.setCompose(null);
                vs.getContact().clear();
                vs.setPublisherElement(null);
                vs.setCopyrightElement(null);
            }
            result.getOptions().setReference("#" + vs.getId());
        }
    }
    result.setLinkId(path + '.' + id);
    result.setText(name);
    result.setType(af);
    result.setRequired(false);
    result.setRepeats(false);
    if (id.endsWith("/1"))
        id = id.substring(0, id.length() - 2);
    if (answerGroups != null) {
        for (QuestionnaireResponse.GroupComponent ag : answerGroups) {
            List<Base> children = new ArrayList<Base>();
            QuestionnaireResponse.QuestionComponent aq = null;
            Element obj = (Element) ag.getUserData("object");
            if (isPrimitive((TypeRefComponent) obj))
                children.add(obj);
            else if (obj instanceof Enumeration) {
                String value = ((Enumeration) obj).toString();
                children.add(new StringType(value));
            } else
                children = obj.listChildrenByName(id);
            for (Base child : children) {
                if (child != null) {
                    if (aq == null) {
                        aq = ag.addQuestion();
                        aq.setLinkId(result.getLinkId());
                        aq.setText(result.getText());
                    }
                    aq.addAnswer().setValue(convertType(child, af, vs, result.getLinkId()));
                }
            }
        }
    }
    return result;
}
Also used : Enumeration(org.hl7.fhir.dstu2.model.Enumeration) StringType(org.hl7.fhir.dstu2.model.StringType) QuestionComponent(org.hl7.fhir.dstu2.model.Questionnaire.QuestionComponent) Reference(org.hl7.fhir.dstu2.model.Reference) Element(org.hl7.fhir.dstu2.model.Element) ArrayList(java.util.ArrayList) QuestionnaireResponse(org.hl7.fhir.dstu2.model.QuestionnaireResponse) Base(org.hl7.fhir.dstu2.model.Base)

Example 29 with Enumeration

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

the class RdfParser method composeEnum.

private void composeEnum(Complex parent, String parentType, String name, Enumeration<? extends Enum> value, int index) {
    if (value == null)
        return;
    Complex t = parent.predicate("fhir:" + parentType + "." + name);
    t.predicate("fhir:value", ttlLiteral(value.asStringValue()));
    composeElement(t, parentType, name, value, index);
    decorateCode(t, value);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 30 with Enumeration

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

the class NarrativeGenerator method renderLeaf.

private void renderLeaf(ResourceWrapper res, BaseWrapper ew, ElementDefinition defn, XhtmlNode x, boolean title, boolean showCodeDetails, Map<String, String> displayHints) throws FHIRException, UnsupportedEncodingException, IOException {
    if (ew == null)
        return;
    Base e = ew.getBase();
    if (e instanceof StringType)
        x.addText(((StringType) e).getValue());
    else if (e instanceof CodeType)
        x.addText(((CodeType) e).getValue());
    else if (e instanceof IdType)
        x.addText(((IdType) e).getValue());
    else if (e instanceof Extension)
        x.addText("Extensions: Todo");
    else if (e instanceof InstantType)
        x.addText(((InstantType) e).toHumanDisplay());
    else if (e instanceof DateTimeType)
        x.addText(((DateTimeType) e).toHumanDisplay());
    else if (e instanceof Base64BinaryType)
        x.addText(new Base64().encodeAsString(((Base64BinaryType) e).getValue()));
    else if (e instanceof org.hl7.fhir.dstu2016may.model.DateType)
        x.addText(((org.hl7.fhir.dstu2016may.model.DateType) e).toHumanDisplay());
    else if (e instanceof Enumeration) {
        Object ev = ((Enumeration<?>) e).getValue();
        // todo: look up a display name if there is one
        x.addText(ev == null ? "" : ev.toString());
    } else if (e instanceof BooleanType)
        x.addText(((BooleanType) e).getValue().toString());
    else if (e instanceof CodeableConcept) {
        renderCodeableConcept((CodeableConcept) e, x, showCodeDetails);
    } else if (e instanceof Coding) {
        renderCoding((Coding) e, x, showCodeDetails);
    } else if (e instanceof Annotation) {
        renderAnnotation((Annotation) e, x);
    } else if (e instanceof Identifier) {
        renderIdentifier((Identifier) e, x);
    } else if (e instanceof org.hl7.fhir.dstu2016may.model.IntegerType) {
        x.addText(Integer.toString(((org.hl7.fhir.dstu2016may.model.IntegerType) e).getValue()));
    } else if (e instanceof org.hl7.fhir.dstu2016may.model.DecimalType) {
        x.addText(((org.hl7.fhir.dstu2016may.model.DecimalType) e).getValue().toString());
    } else if (e instanceof HumanName) {
        renderHumanName((HumanName) e, x);
    } else if (e instanceof SampledData) {
        renderSampledData((SampledData) e, x);
    } else if (e instanceof Address) {
        renderAddress((Address) e, x);
    } else if (e instanceof ContactPoint) {
        renderContactPoint((ContactPoint) e, x);
    } else if (e instanceof UriType) {
        renderUri((UriType) e, x);
    } else if (e instanceof Timing) {
        renderTiming((Timing) e, x);
    } else if (e instanceof Range) {
        renderRange((Range) e, x);
    } else if (e instanceof Quantity) {
        renderQuantity((Quantity) e, x, showCodeDetails);
    } else if (e instanceof Ratio) {
        renderQuantity(((Ratio) e).getNumerator(), x, showCodeDetails);
        x.addText("/");
        renderQuantity(((Ratio) e).getDenominator(), x, showCodeDetails);
    } else if (e instanceof Period) {
        Period p = (Period) e;
        x.addText(!p.hasStart() ? "??" : p.getStartElement().toHumanDisplay());
        x.addText(" --> ");
        x.addText(!p.hasEnd() ? "(ongoing)" : p.getEndElement().toHumanDisplay());
    } else if (e instanceof Reference) {
        Reference r = (Reference) e;
        XhtmlNode c = x;
        ResourceWithReference tr = null;
        if (r.hasReferenceElement()) {
            tr = resolveReference(res, r.getReference());
            if (!r.getReference().startsWith("#")) {
                if (tr != null && tr.getReference() != null)
                    c = x.addTag("a").attribute("href", tr.getReference());
                else
                    c = x.addTag("a").attribute("href", r.getReference());
            }
        }
        // what to display: if text is provided, then that. if the reference was resolved, then show the generated narrative
        if (r.hasDisplayElement()) {
            c.addText(r.getDisplay());
            if (tr != null) {
                c.addText(". Generated Summary: ");
                generateResourceSummary(c, tr.getResource(), true, r.getReference().startsWith("#"));
            }
        } else if (tr != null) {
            generateResourceSummary(c, tr.getResource(), r.getReference().startsWith("#"), r.getReference().startsWith("#"));
        } else {
            c.addText(r.getReference());
        }
    } else if (e instanceof Resource) {
        return;
    } else if (e instanceof ElementDefinition) {
        x.addText("todo-bundle");
    } else if (e != null && !(e instanceof Attachment) && !(e instanceof Narrative) && !(e instanceof Meta))
        throw new NotImplementedException("type " + e.getClass().getName() + " not handled yet");
}
Also used : Meta(org.hl7.fhir.dstu2016may.model.Meta) Base64(org.apache.commons.codec.binary.Base64) Address(org.hl7.fhir.dstu2016may.model.Address) StringType(org.hl7.fhir.dstu2016may.model.StringType) NotImplementedException(org.apache.commons.lang3.NotImplementedException) Attachment(org.hl7.fhir.dstu2016may.model.Attachment) UriType(org.hl7.fhir.dstu2016may.model.UriType) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) HumanName(org.hl7.fhir.dstu2016may.model.HumanName) ContactPoint(org.hl7.fhir.dstu2016may.model.ContactPoint) Identifier(org.hl7.fhir.dstu2016may.model.Identifier) Coding(org.hl7.fhir.dstu2016may.model.Coding) Narrative(org.hl7.fhir.dstu2016may.model.Narrative) SampledData(org.hl7.fhir.dstu2016may.model.SampledData) Ratio(org.hl7.fhir.dstu2016may.model.Ratio) ElementDefinition(org.hl7.fhir.dstu2016may.model.ElementDefinition) InstantType(org.hl7.fhir.dstu2016may.model.InstantType) Enumeration(org.hl7.fhir.dstu2016may.model.Enumeration) Reference(org.hl7.fhir.dstu2016may.model.Reference) BooleanType(org.hl7.fhir.dstu2016may.model.BooleanType) Resource(org.hl7.fhir.dstu2016may.model.Resource) DomainResource(org.hl7.fhir.dstu2016may.model.DomainResource) Quantity(org.hl7.fhir.dstu2016may.model.Quantity) Period(org.hl7.fhir.dstu2016may.model.Period) Range(org.hl7.fhir.dstu2016may.model.Range) Base(org.hl7.fhir.dstu2016may.model.Base) Annotation(org.hl7.fhir.dstu2016may.model.Annotation) IdType(org.hl7.fhir.dstu2016may.model.IdType) Extension(org.hl7.fhir.dstu2016may.model.Extension) DateTimeType(org.hl7.fhir.dstu2016may.model.DateTimeType) CodeType(org.hl7.fhir.dstu2016may.model.CodeType) EventTiming(org.hl7.fhir.dstu2016may.model.Timing.EventTiming) Timing(org.hl7.fhir.dstu2016may.model.Timing) Base64BinaryType(org.hl7.fhir.dstu2016may.model.Base64BinaryType) CodeableConcept(org.hl7.fhir.dstu2016may.model.CodeableConcept)

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