use of org.hl7.fhir.dstu2.model.DateTimeType 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.dstu2.model.DateTimeType 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.dstu2.model.DateTimeType 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");
}
use of org.hl7.fhir.dstu2.model.DateTimeType in project org.hl7.fhir.core by hapifhir.
the class QuestionnaireBuilder method convertType.
@SuppressWarnings("unchecked")
private Type convertType(Base value, QuestionnaireItemType af, ValueSet vs, String path) throws FHIRException {
switch(af) {
// simple cases
case BOOLEAN:
if (value instanceof BooleanType)
return (Type) value;
case DECIMAL:
if (value instanceof DecimalType)
return (Type) value;
case INTEGER:
if (value instanceof IntegerType)
return (Type) value;
case DATE:
if (value instanceof DateType)
return (Type) value;
case DATETIME:
if (value instanceof DateTimeType)
return (Type) value;
case INSTANT:
if (value instanceof InstantType)
return (Type) value;
case TIME:
if (value instanceof TimeType)
return (Type) value;
case STRING:
if (value instanceof StringType)
return (Type) value;
else if (value instanceof UriType)
return new StringType(((UriType) value).asStringValue());
case TEXT:
if (value instanceof StringType)
return (Type) value;
case QUANTITY:
if (value instanceof Quantity)
return (Type) value;
// ? QuestionnaireItemTypeAttachment: ...?
case CHOICE:
case OPENCHOICE:
if (value instanceof Coding)
return (Type) value;
else if (value instanceof Enumeration) {
Coding cc = new Coding();
cc.setCode(((Enumeration<Enum<?>>) value).asStringValue());
cc.setSystem(getSystemForCode(vs, cc.getCode(), path));
return cc;
} else if (value instanceof StringType) {
Coding cc = new Coding();
cc.setCode(((StringType) value).asStringValue());
cc.setSystem(getSystemForCode(vs, cc.getCode(), path));
return cc;
}
case REFERENCE:
if (value instanceof Reference)
return (Type) value;
else if (value instanceof StringType) {
Reference r = new Reference();
r.setReference(((StringType) value).asStringValue());
}
}
throw new FHIRException("Unable to convert from '" + value.getClass().toString() + "' for Answer Format " + af.toCode() + ", path = " + path);
}
use of org.hl7.fhir.dstu2.model.DateTimeType in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method displayTiming.
private String displayTiming(Timing s) throws FHIRException {
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
if (s.hasCode())
b.append("Code: " + displayCodeableConcept(s.getCode()));
if (s.getEvent().size() > 0) {
CommaSeparatedStringBuilder c = new CommaSeparatedStringBuilder();
for (DateTimeType p : s.getEvent()) {
c.append(p.toHumanDisplay());
}
b.append("Events: " + c.toString());
}
if (s.hasRepeat()) {
TimingRepeatComponent rep = s.getRepeat();
if (rep.hasBoundsPeriod() && rep.getBoundsPeriod().hasStart())
b.append("Starting " + rep.getBoundsPeriod().getStartElement().toHumanDisplay());
if (rep.hasCount())
b.append("Count " + Integer.toString(rep.getCount()) + " times");
if (rep.hasDuration())
b.append("Duration " + rep.getDuration().toPlainString() + displayTimeUnits(rep.getPeriodUnit()));
if (rep.hasWhen()) {
String st = "";
if (rep.hasPeriod()) {
st = rep.getPeriod().toPlainString();
if (rep.hasPeriodMax())
st = st + "-" + rep.getPeriodMax().toPlainString();
st = st + displayTimeUnits(rep.getPeriodUnit());
}
b.append("Do " + st + displayEventCode(rep.getWhen()));
} else {
String st = "";
if (!rep.hasFrequency() || (!rep.hasFrequencyMax() && rep.getFrequency() == 1))
st = "Once";
else {
st = Integer.toString(rep.getFrequency());
if (rep.hasFrequencyMax())
st = st + "-" + Integer.toString(rep.getFrequency());
}
if (rep.hasPeriod()) {
st = st + " per " + rep.getPeriod().toPlainString();
if (rep.hasPeriodMax())
st = st + "-" + rep.getPeriodMax().toPlainString();
st = st + " " + displayTimeUnits(rep.getPeriodUnit());
}
b.append("Do " + st);
}
if (rep.hasBoundsPeriod() && rep.getBoundsPeriod().hasEnd())
b.append("Until " + rep.getBoundsPeriod().getEndElement().toHumanDisplay());
}
return b.toString();
}
Aggregations