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);
}
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);
}
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;
}
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);
}
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");
}
Aggregations