use of org.hl7.fhir.dstu3.model.Timing 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.dstu3.model.Timing 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();
}
use of org.hl7.fhir.dstu3.model.Timing in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeTimingTimingRepeatComponent.
protected void composeTimingTimingRepeatComponent(Complex parent, String parentType, String name, Timing.TimingRepeatComponent element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeElement(t, "repeat", name, element, index);
if (element.hasBounds())
composeType(t, "Timing", "bounds", element.getBounds(), -1);
if (element.hasCountElement())
composePositiveInt(t, "Timing", "count", element.getCountElement(), -1);
if (element.hasCountMaxElement())
composePositiveInt(t, "Timing", "countMax", element.getCountMaxElement(), -1);
if (element.hasDurationElement())
composeDecimal(t, "Timing", "duration", element.getDurationElement(), -1);
if (element.hasDurationMaxElement())
composeDecimal(t, "Timing", "durationMax", element.getDurationMaxElement(), -1);
if (element.hasDurationUnitElement())
composeEnum(t, "Timing", "durationUnit", element.getDurationUnitElement(), -1);
if (element.hasFrequencyElement())
composePositiveInt(t, "Timing", "frequency", element.getFrequencyElement(), -1);
if (element.hasFrequencyMaxElement())
composePositiveInt(t, "Timing", "frequencyMax", element.getFrequencyMaxElement(), -1);
if (element.hasPeriodElement())
composeDecimal(t, "Timing", "period", element.getPeriodElement(), -1);
if (element.hasPeriodMaxElement())
composeDecimal(t, "Timing", "periodMax", element.getPeriodMaxElement(), -1);
if (element.hasPeriodUnitElement())
composeEnum(t, "Timing", "periodUnit", element.getPeriodUnitElement(), -1);
for (int i = 0; i < element.getDayOfWeek().size(); i++) composeEnum(t, "Timing", "dayOfWeek", element.getDayOfWeek().get(i), i);
for (int i = 0; i < element.getTimeOfDay().size(); i++) composeTime(t, "Timing", "timeOfDay", element.getTimeOfDay().get(i), i);
for (int i = 0; i < element.getWhen().size(); i++) composeEnum(t, "Timing", "when", element.getWhen().get(i), i);
if (element.hasOffsetElement())
composeUnsignedInt(t, "Timing", "offset", element.getOffsetElement(), -1);
}
use of org.hl7.fhir.dstu3.model.Timing in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeRequestGroupRequestGroupActionComponent.
protected void composeRequestGroupRequestGroupActionComponent(Complex parent, String parentType, String name, RequestGroup.RequestGroupActionComponent element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeBackboneElement(t, "action", name, element, index);
if (element.hasPrefixElement())
composeString(t, "RequestGroup", "prefix", element.getPrefixElement(), -1);
if (element.hasTitleElement())
composeString(t, "RequestGroup", "title", element.getTitleElement(), -1);
if (element.hasDescriptionElement())
composeString(t, "RequestGroup", "description", element.getDescriptionElement(), -1);
if (element.hasTextEquivalentElement())
composeString(t, "RequestGroup", "textEquivalent", element.getTextEquivalentElement(), -1);
if (element.hasPriorityElement())
composeEnum(t, "RequestGroup", "priority", element.getPriorityElement(), -1);
for (int i = 0; i < element.getCode().size(); i++) composeCodeableConcept(t, "RequestGroup", "code", element.getCode().get(i), i);
for (int i = 0; i < element.getDocumentation().size(); i++) composeRelatedArtifact(t, "RequestGroup", "documentation", element.getDocumentation().get(i), i);
for (int i = 0; i < element.getCondition().size(); i++) composeRequestGroupRequestGroupActionConditionComponent(t, "RequestGroup", "condition", element.getCondition().get(i), i);
for (int i = 0; i < element.getRelatedAction().size(); i++) composeRequestGroupRequestGroupActionRelatedActionComponent(t, "RequestGroup", "relatedAction", element.getRelatedAction().get(i), i);
if (element.hasTiming())
composeType(t, "RequestGroup", "timing", element.getTiming(), -1);
for (int i = 0; i < element.getParticipant().size(); i++) composeReference(t, "RequestGroup", "participant", element.getParticipant().get(i), i);
if (element.hasType())
composeCodeableConcept(t, "RequestGroup", "type", element.getType(), -1);
if (element.hasGroupingBehaviorElement())
composeEnum(t, "RequestGroup", "groupingBehavior", element.getGroupingBehaviorElement(), -1);
if (element.hasSelectionBehaviorElement())
composeEnum(t, "RequestGroup", "selectionBehavior", element.getSelectionBehaviorElement(), -1);
if (element.hasRequiredBehaviorElement())
composeEnum(t, "RequestGroup", "requiredBehavior", element.getRequiredBehaviorElement(), -1);
if (element.hasPrecheckBehaviorElement())
composeEnum(t, "RequestGroup", "precheckBehavior", element.getPrecheckBehaviorElement(), -1);
if (element.hasCardinalityBehaviorElement())
composeEnum(t, "RequestGroup", "cardinalityBehavior", element.getCardinalityBehaviorElement(), -1);
if (element.hasResource())
composeReference(t, "RequestGroup", "resource", element.getResource(), -1);
for (int i = 0; i < element.getAction().size(); i++) composeRequestGroupRequestGroupActionComponent(t, "RequestGroup", "action", element.getAction().get(i), i);
}
use of org.hl7.fhir.dstu3.model.Timing in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeActivityDefinition.
protected void composeActivityDefinition(Complex parent, String parentType, String name, ActivityDefinition element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeDomainResource(t, "ActivityDefinition", name, element, index);
if (element.hasUrlElement())
composeUri(t, "ActivityDefinition", "url", element.getUrlElement(), -1);
for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "ActivityDefinition", "identifier", element.getIdentifier().get(i), i);
if (element.hasVersionElement())
composeString(t, "ActivityDefinition", "version", element.getVersionElement(), -1);
if (element.hasNameElement())
composeString(t, "ActivityDefinition", "name", element.getNameElement(), -1);
if (element.hasTitleElement())
composeString(t, "ActivityDefinition", "title", element.getTitleElement(), -1);
if (element.hasSubtitleElement())
composeString(t, "ActivityDefinition", "subtitle", element.getSubtitleElement(), -1);
if (element.hasStatusElement())
composeEnum(t, "ActivityDefinition", "status", element.getStatusElement(), -1);
if (element.hasExperimentalElement())
composeBoolean(t, "ActivityDefinition", "experimental", element.getExperimentalElement(), -1);
if (element.hasSubject())
composeType(t, "ActivityDefinition", "subject", element.getSubject(), -1);
if (element.hasDateElement())
composeDateTime(t, "ActivityDefinition", "date", element.getDateElement(), -1);
if (element.hasPublisherElement())
composeString(t, "ActivityDefinition", "publisher", element.getPublisherElement(), -1);
for (int i = 0; i < element.getContact().size(); i++) composeContactDetail(t, "ActivityDefinition", "contact", element.getContact().get(i), i);
if (element.hasDescriptionElement())
composeMarkdown(t, "ActivityDefinition", "description", element.getDescriptionElement(), -1);
for (int i = 0; i < element.getUseContext().size(); i++) composeUsageContext(t, "ActivityDefinition", "useContext", element.getUseContext().get(i), i);
for (int i = 0; i < element.getJurisdiction().size(); i++) composeCodeableConcept(t, "ActivityDefinition", "jurisdiction", element.getJurisdiction().get(i), i);
if (element.hasPurposeElement())
composeMarkdown(t, "ActivityDefinition", "purpose", element.getPurposeElement(), -1);
if (element.hasUsageElement())
composeString(t, "ActivityDefinition", "usage", element.getUsageElement(), -1);
if (element.hasCopyrightElement())
composeMarkdown(t, "ActivityDefinition", "copyright", element.getCopyrightElement(), -1);
if (element.hasApprovalDateElement())
composeDate(t, "ActivityDefinition", "approvalDate", element.getApprovalDateElement(), -1);
if (element.hasLastReviewDateElement())
composeDate(t, "ActivityDefinition", "lastReviewDate", element.getLastReviewDateElement(), -1);
if (element.hasEffectivePeriod())
composePeriod(t, "ActivityDefinition", "effectivePeriod", element.getEffectivePeriod(), -1);
for (int i = 0; i < element.getTopic().size(); i++) composeCodeableConcept(t, "ActivityDefinition", "topic", element.getTopic().get(i), i);
for (int i = 0; i < element.getAuthor().size(); i++) composeContactDetail(t, "ActivityDefinition", "author", element.getAuthor().get(i), i);
for (int i = 0; i < element.getEditor().size(); i++) composeContactDetail(t, "ActivityDefinition", "editor", element.getEditor().get(i), i);
for (int i = 0; i < element.getReviewer().size(); i++) composeContactDetail(t, "ActivityDefinition", "reviewer", element.getReviewer().get(i), i);
for (int i = 0; i < element.getEndorser().size(); i++) composeContactDetail(t, "ActivityDefinition", "endorser", element.getEndorser().get(i), i);
for (int i = 0; i < element.getRelatedArtifact().size(); i++) composeRelatedArtifact(t, "ActivityDefinition", "relatedArtifact", element.getRelatedArtifact().get(i), i);
for (int i = 0; i < element.getLibrary().size(); i++) composeCanonical(t, "ActivityDefinition", "library", element.getLibrary().get(i), i);
if (element.hasKindElement())
composeEnum(t, "ActivityDefinition", "kind", element.getKindElement(), -1);
if (element.hasProfileElement())
composeCanonical(t, "ActivityDefinition", "profile", element.getProfileElement(), -1);
if (element.hasCode())
composeCodeableConcept(t, "ActivityDefinition", "code", element.getCode(), -1);
if (element.hasIntentElement())
composeEnum(t, "ActivityDefinition", "intent", element.getIntentElement(), -1);
if (element.hasPriorityElement())
composeEnum(t, "ActivityDefinition", "priority", element.getPriorityElement(), -1);
if (element.hasDoNotPerformElement())
composeBoolean(t, "ActivityDefinition", "doNotPerform", element.getDoNotPerformElement(), -1);
if (element.hasTiming())
composeType(t, "ActivityDefinition", "timing", element.getTiming(), -1);
if (element.hasLocation())
composeReference(t, "ActivityDefinition", "location", element.getLocation(), -1);
for (int i = 0; i < element.getParticipant().size(); i++) composeActivityDefinitionActivityDefinitionParticipantComponent(t, "ActivityDefinition", "participant", element.getParticipant().get(i), i);
if (element.hasProduct())
composeType(t, "ActivityDefinition", "product", element.getProduct(), -1);
if (element.hasQuantity())
composeQuantity(t, "ActivityDefinition", "quantity", element.getQuantity(), -1);
for (int i = 0; i < element.getDosage().size(); i++) composeDosage(t, "ActivityDefinition", "dosage", element.getDosage().get(i), i);
for (int i = 0; i < element.getBodySite().size(); i++) composeCodeableConcept(t, "ActivityDefinition", "bodySite", element.getBodySite().get(i), i);
for (int i = 0; i < element.getSpecimenRequirement().size(); i++) composeReference(t, "ActivityDefinition", "specimenRequirement", element.getSpecimenRequirement().get(i), i);
for (int i = 0; i < element.getObservationRequirement().size(); i++) composeReference(t, "ActivityDefinition", "observationRequirement", element.getObservationRequirement().get(i), i);
for (int i = 0; i < element.getObservationResultRequirement().size(); i++) composeReference(t, "ActivityDefinition", "observationResultRequirement", element.getObservationResultRequirement().get(i), i);
if (element.hasTransformElement())
composeCanonical(t, "ActivityDefinition", "transform", element.getTransformElement(), -1);
for (int i = 0; i < element.getDynamicValue().size(); i++) composeActivityDefinitionActivityDefinitionDynamicValueComponent(t, "ActivityDefinition", "dynamicValue", element.getDynamicValue().get(i), i);
}
Aggregations