use of org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent 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.hasOffset()) {
st = Integer.toString(rep.getOffset()) + "min ";
}
b.append("Do " + st);
for (Enumeration<EventTiming> wh : rep.getWhen()) b.append(displayEventCode(wh.getValue()));
} 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.TimingRepeatComponent in project org.hl7.fhir.core by hapifhir.
the class DataRenderer 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()) {
if (p.hasValue()) {
c.append(displayDateTime(p));
} else if (!renderExpression(c, p)) {
c.append("??");
}
}
b.append("Events: " + c.toString());
}
if (s.hasRepeat()) {
TimingRepeatComponent rep = s.getRepeat();
if (rep.hasBoundsPeriod() && rep.getBoundsPeriod().hasStart())
b.append("Starting " + displayDateTime(rep.getBoundsPeriod().getStartElement()));
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.hasOffset()) {
st = Integer.toString(rep.getOffset()) + "min ";
}
b.append("Do " + st);
for (Enumeration<EventTiming> wh : rep.getWhen()) b.append(displayEventCode(wh.getValue()));
} 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 " + displayDateTime(rep.getBoundsPeriod().getEndElement()));
}
return b.toString();
}
use of org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent in project eCRNow by drajer-health.
the class PlanDefinitionProcessor method getTimingSchedule.
private TimingSchedule getTimingSchedule(Timing t, TriggerType type) {
if (t != null && t.hasRepeat()) {
TimingRepeatComponent rc = t.getRepeat();
// Create Timing Data
TimingSchedule ts = new TimingSchedule();
ts.setTriggerType(type);
ts.setNumOfRepeat(rc.getCount());
ts.setMaxRepeat(rc.getCountMax());
ts.setFrequency(rc.getFrequency());
ts.setFrequencyMax(rc.getFrequencyMax());
ts.setFrequencyPeriod(rc.getPeriod());
ts.setFrequencyPeriodUnit(rc.getPeriodUnitElement().getValue());
ts.setDuration(rc.getDuration());
ts.setDurationUnit(rc.getDurationUnit());
logger.info("Found Timing Element with Frequency Period {} {} AND Duration {} {}", rc.getPeriod(), rc.getPeriodUnitElement().getValueAsString(), rc.getDuration(), rc.getDurationUnit());
return ts;
}
return null;
}
Aggregations