UNPKG

fhirbuilder

Version:
90 lines (89 loc) 2.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RepeatBuilder = void 0; const models_1 = require("../../models"); const ElementBuilder_1 = require("../base/ElementBuilder"); class RepeatBuilder extends ElementBuilder_1.ElementBuilder { repeat; constructor() { super(); this.repeat = new models_1.Repeat(); } build() { return Object.assign(this.repeat, super.build()); } setBounds(type, bounds) { this.repeat[type] = bounds; return this; } setCount(count) { this.repeat.count = count; return this; } setCountMax(countMax) { this.repeat.countMax = countMax; return this; } setDuration(duration) { this.repeat.duration = duration; return this; } setDurationMax(durationMax) { this.repeat.durationMax = durationMax; return this; } setDurationUnit(durationUnit) { this.repeat.durationUnit = durationUnit; return this; } setFrequency(frequency) { this.repeat.frequency = frequency; return this; } setFrequencyMax(frequencyMax) { this.repeat.frequencyMax = frequencyMax; return this; } setPeriod(period) { this.repeat.period = period; return this; } setPeriodMax(periodMax) { this.repeat.periodMax = periodMax; return this; } setPeriodUnit(periodUnit) { this.repeat.periodUnit = periodUnit; return this; } addDayOfWeek(dayOfWeek) { this.repeat.dayOfWeek = this.repeat.dayOfWeek || []; this.repeat.dayOfWeek.push(dayOfWeek); return this; } addTimeOfDay(timeOfDay) { this.repeat.timeOfDay = this.repeat.timeOfDay || []; this.repeat.timeOfDay.push(timeOfDay); return this; } addWhen(when) { this.repeat.when = this.repeat.when || []; this.repeat.when.push(when); return this; } setOffset(offset) { this.repeat.offset = offset; return this; } addPrimitiveExtension(param, extension) { if (param === '_when' || param === '_dayOfWeek' || param === '_timeOfDay') { this.repeat[param] = extension; } else { const internalParam = param; this.repeat[internalParam] = extension; } return this; } } exports.RepeatBuilder = RepeatBuilder;