use of org.hl7.fhir.r5.model.Timing.TimingRepeatComponent in project org.hl7.fhir.core by hapifhir.
the class Convert method makeTimingFromBoundedPIVL.
private Timing makeTimingFromBoundedPIVL(Element ivl, Element pivl) throws Exception {
Timing t = new Timing();
t.setRepeat(new TimingRepeatComponent());
Element p = cda.getChild(pivl, "period");
t.getRepeat().setBounds(makePeriodFromIVL(ivl));
t.getRepeat().setPeriod(new BigDecimal(p.getAttribute("value")));
t.getRepeat().setPeriodUnit(convertTimeUnit(p.getAttribute("unit")));
return t;
}
use of org.hl7.fhir.r5.model.Timing.TimingRepeatComponent in project org.hl7.fhir.core by hapifhir.
the class Convert method makeTimingFromBoundedEIVL.
private Type makeTimingFromBoundedEIVL(Element ivl, Element eivl) throws Exception {
Timing t = new Timing();
t.setRepeat(new TimingRepeatComponent());
Element e = cda.getChild(eivl, "event");
t.getRepeat().setBounds(makePeriodFromIVL(ivl));
t.getRepeat().addWhen(convertEventTiming(e.getAttribute("code")));
return t;
}
use of org.hl7.fhir.r5.model.Timing.TimingRepeatComponent in project org.hl7.fhir.core by hapifhir.
the class TimingRepeatComponent10_30Test method testMedicationRequestConversion.
@Test
@DisplayName("Issue #383 - Test 10_30 TimingRepeatComponent with Timing.when as null")
public void testMedicationRequestConversion() {
final int SET_COUNT = 11;
org.hl7.fhir.dstu2.model.Timing src_timing = new org.hl7.fhir.dstu2.model.Timing();
org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent src_timing_repeat = new org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent();
src_timing_repeat.setCount(SET_COUNT);
src_timing.setRepeat(src_timing_repeat);
org.hl7.fhir.dstu3.model.Timing tgt_timing = (Timing) VersionConvertorFactory_10_30.convertType(src_timing);
org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent tgt_timing_repeat = tgt_timing.getRepeat();
Assertions.assertEquals(SET_COUNT, tgt_timing_repeat.getCount(), "Count field not preserved through version conversion.");
Assertions.assertFalse(tgt_timing_repeat.hasWhen(), "hasWhen() should return false for this conversion.");
Assertions.assertTrue(tgt_timing_repeat.getWhen().isEmpty(), "When no _when time_ is provided, getWhen() should return an empty list.");
}
use of org.hl7.fhir.r5.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.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.r5.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();
}
Aggregations