001package org.hl7.fhir.dstu2.model;
002
003
004
005
006import java.math.BigDecimal;
007
008/*
009  Copyright (c) 2011+, HL7, Inc.
010  All rights reserved.
011  
012  Redistribution and use in source and binary forms, with or without modification, 
013  are permitted provided that the following conditions are met:
014  
015   * Redistributions of source code must retain the above copyright notice, this 
016     list of conditions and the following disclaimer.
017   * Redistributions in binary form must reproduce the above copyright notice, 
018     this list of conditions and the following disclaimer in the documentation 
019     and/or other materials provided with the distribution.
020   * Neither the name of HL7 nor the names of its contributors may be used to 
021     endorse or promote products derived from this software without specific 
022     prior written permission.
023  
024  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
025  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
026  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
027  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
028  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
029  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
030  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
031  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
032  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
033  POSSIBILITY OF SUCH DAMAGE.
034  
035*/
036
037// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
038import java.util.ArrayList;
039import java.util.Date;
040import java.util.List;
041
042import ca.uhn.fhir.model.api.annotation.Block;
043import ca.uhn.fhir.model.api.annotation.Child;
044import ca.uhn.fhir.model.api.annotation.DatatypeDef;
045import ca.uhn.fhir.model.api.annotation.Description;
046import org.hl7.fhir.instance.model.api.IBaseDatatypeElement;
047import org.hl7.fhir.instance.model.api.ICompositeType;
048import org.hl7.fhir.exceptions.FHIRException;
049/**
050 * Specifies an event that may occur multiple times. Timing schedules are used to record when things are expected or requested to occur. The most common usage is in dosage instructions for medications. They are also used when planning care of various kinds.
051 */
052@DatatypeDef(name="Timing")
053public class Timing extends Type implements ICompositeType {
054
055    public enum UnitsOfTime {
056        /**
057         * null
058         */
059        S, 
060        /**
061         * null
062         */
063        MIN, 
064        /**
065         * null
066         */
067        H, 
068        /**
069         * null
070         */
071        D, 
072        /**
073         * null
074         */
075        WK, 
076        /**
077         * null
078         */
079        MO, 
080        /**
081         * null
082         */
083        A, 
084        /**
085         * added to help the parsers
086         */
087        NULL;
088        public static UnitsOfTime fromCode(String codeString) throws FHIRException {
089            if (codeString == null || "".equals(codeString))
090                return null;
091        if ("s".equals(codeString))
092          return S;
093        if ("min".equals(codeString))
094          return MIN;
095        if ("h".equals(codeString))
096          return H;
097        if ("d".equals(codeString))
098          return D;
099        if ("wk".equals(codeString))
100          return WK;
101        if ("mo".equals(codeString))
102          return MO;
103        if ("a".equals(codeString))
104          return A;
105        throw new FHIRException("Unknown UnitsOfTime code '"+codeString+"'");
106        }
107        public String toCode() {
108          switch (this) {
109            case S: return "s";
110            case MIN: return "min";
111            case H: return "h";
112            case D: return "d";
113            case WK: return "wk";
114            case MO: return "mo";
115            case A: return "a";
116            default: return "?";
117          }
118        }
119        public String getSystem() {
120          switch (this) {
121            case S: return "http://unitsofmeasure.org";
122            case MIN: return "http://unitsofmeasure.org";
123            case H: return "http://unitsofmeasure.org";
124            case D: return "http://unitsofmeasure.org";
125            case WK: return "http://unitsofmeasure.org";
126            case MO: return "http://unitsofmeasure.org";
127            case A: return "http://unitsofmeasure.org";
128            default: return "?";
129          }
130        }
131        public String getDefinition() {
132          switch (this) {
133            case S: return "";
134            case MIN: return "";
135            case H: return "";
136            case D: return "";
137            case WK: return "";
138            case MO: return "";
139            case A: return "";
140            default: return "?";
141          }
142        }
143        public String getDisplay() {
144          switch (this) {
145            case S: return "s";
146            case MIN: return "min";
147            case H: return "h";
148            case D: return "d";
149            case WK: return "wk";
150            case MO: return "mo";
151            case A: return "a";
152            default: return "?";
153          }
154        }
155    }
156
157  public static class UnitsOfTimeEnumFactory implements EnumFactory<UnitsOfTime> {
158    public UnitsOfTime fromCode(String codeString) throws IllegalArgumentException {
159      if (codeString == null || "".equals(codeString))
160            if (codeString == null || "".equals(codeString))
161                return null;
162        if ("s".equals(codeString))
163          return UnitsOfTime.S;
164        if ("min".equals(codeString))
165          return UnitsOfTime.MIN;
166        if ("h".equals(codeString))
167          return UnitsOfTime.H;
168        if ("d".equals(codeString))
169          return UnitsOfTime.D;
170        if ("wk".equals(codeString))
171          return UnitsOfTime.WK;
172        if ("mo".equals(codeString))
173          return UnitsOfTime.MO;
174        if ("a".equals(codeString))
175          return UnitsOfTime.A;
176        throw new IllegalArgumentException("Unknown UnitsOfTime code '"+codeString+"'");
177        }
178        public Enumeration<UnitsOfTime> fromType(Base code) throws FHIRException {
179          if (code == null || code.isEmpty())
180            return null;
181          String codeString = ((PrimitiveType) code).asStringValue();
182          if (codeString == null || "".equals(codeString))
183            return null;
184        if ("s".equals(codeString))
185          return new Enumeration<UnitsOfTime>(this, UnitsOfTime.S);
186        if ("min".equals(codeString))
187          return new Enumeration<UnitsOfTime>(this, UnitsOfTime.MIN);
188        if ("h".equals(codeString))
189          return new Enumeration<UnitsOfTime>(this, UnitsOfTime.H);
190        if ("d".equals(codeString))
191          return new Enumeration<UnitsOfTime>(this, UnitsOfTime.D);
192        if ("wk".equals(codeString))
193          return new Enumeration<UnitsOfTime>(this, UnitsOfTime.WK);
194        if ("mo".equals(codeString))
195          return new Enumeration<UnitsOfTime>(this, UnitsOfTime.MO);
196        if ("a".equals(codeString))
197          return new Enumeration<UnitsOfTime>(this, UnitsOfTime.A);
198        throw new FHIRException("Unknown UnitsOfTime code '"+codeString+"'");
199        }
200    public String toCode(UnitsOfTime code) {
201      if (code == UnitsOfTime.S)
202        return "s";
203      if (code == UnitsOfTime.MIN)
204        return "min";
205      if (code == UnitsOfTime.H)
206        return "h";
207      if (code == UnitsOfTime.D)
208        return "d";
209      if (code == UnitsOfTime.WK)
210        return "wk";
211      if (code == UnitsOfTime.MO)
212        return "mo";
213      if (code == UnitsOfTime.A)
214        return "a";
215      return "?";
216      }
217    }
218
219    public enum EventTiming {
220        /**
221         * null
222         */
223        HS, 
224        /**
225         * null
226         */
227        WAKE, 
228        /**
229         * null
230         */
231        C, 
232        /**
233         * null
234         */
235        CM, 
236        /**
237         * null
238         */
239        CD, 
240        /**
241         * null
242         */
243        CV, 
244        /**
245         * null
246         */
247        AC, 
248        /**
249         * null
250         */
251        ACM, 
252        /**
253         * null
254         */
255        ACD, 
256        /**
257         * null
258         */
259        ACV, 
260        /**
261         * null
262         */
263        PC, 
264        /**
265         * null
266         */
267        PCM, 
268        /**
269         * null
270         */
271        PCD, 
272        /**
273         * null
274         */
275        PCV, 
276        /**
277         * added to help the parsers
278         */
279        NULL;
280        public static EventTiming fromCode(String codeString) throws FHIRException {
281            if (codeString == null || "".equals(codeString))
282                return null;
283        if ("HS".equals(codeString))
284          return HS;
285        if ("WAKE".equals(codeString))
286          return WAKE;
287        if ("C".equals(codeString))
288          return C;
289        if ("CM".equals(codeString))
290          return CM;
291        if ("CD".equals(codeString))
292          return CD;
293        if ("CV".equals(codeString))
294          return CV;
295        if ("AC".equals(codeString))
296          return AC;
297        if ("ACM".equals(codeString))
298          return ACM;
299        if ("ACD".equals(codeString))
300          return ACD;
301        if ("ACV".equals(codeString))
302          return ACV;
303        if ("PC".equals(codeString))
304          return PC;
305        if ("PCM".equals(codeString))
306          return PCM;
307        if ("PCD".equals(codeString))
308          return PCD;
309        if ("PCV".equals(codeString))
310          return PCV;
311        throw new FHIRException("Unknown EventTiming code '"+codeString+"'");
312        }
313        public String toCode() {
314          switch (this) {
315            case HS: return "HS";
316            case WAKE: return "WAKE";
317            case C: return "C";
318            case CM: return "CM";
319            case CD: return "CD";
320            case CV: return "CV";
321            case AC: return "AC";
322            case ACM: return "ACM";
323            case ACD: return "ACD";
324            case ACV: return "ACV";
325            case PC: return "PC";
326            case PCM: return "PCM";
327            case PCD: return "PCD";
328            case PCV: return "PCV";
329            default: return "?";
330          }
331        }
332        public String getSystem() {
333          switch (this) {
334            case HS: return "http://hl7.org/fhir/v3/TimingEvent";
335            case WAKE: return "http://hl7.org/fhir/v3/TimingEvent";
336            case C: return "http://hl7.org/fhir/v3/TimingEvent";
337            case CM: return "http://hl7.org/fhir/v3/TimingEvent";
338            case CD: return "http://hl7.org/fhir/v3/TimingEvent";
339            case CV: return "http://hl7.org/fhir/v3/TimingEvent";
340            case AC: return "http://hl7.org/fhir/v3/TimingEvent";
341            case ACM: return "http://hl7.org/fhir/v3/TimingEvent";
342            case ACD: return "http://hl7.org/fhir/v3/TimingEvent";
343            case ACV: return "http://hl7.org/fhir/v3/TimingEvent";
344            case PC: return "http://hl7.org/fhir/v3/TimingEvent";
345            case PCM: return "http://hl7.org/fhir/v3/TimingEvent";
346            case PCD: return "http://hl7.org/fhir/v3/TimingEvent";
347            case PCV: return "http://hl7.org/fhir/v3/TimingEvent";
348            default: return "?";
349          }
350        }
351        public String getDefinition() {
352          switch (this) {
353            case HS: return "";
354            case WAKE: return "";
355            case C: return "";
356            case CM: return "";
357            case CD: return "";
358            case CV: return "";
359            case AC: return "";
360            case ACM: return "";
361            case ACD: return "";
362            case ACV: return "";
363            case PC: return "";
364            case PCM: return "";
365            case PCD: return "";
366            case PCV: return "";
367            default: return "?";
368          }
369        }
370        public String getDisplay() {
371          switch (this) {
372            case HS: return "HS";
373            case WAKE: return "WAKE";
374            case C: return "C";
375            case CM: return "CM";
376            case CD: return "CD";
377            case CV: return "CV";
378            case AC: return "AC";
379            case ACM: return "ACM";
380            case ACD: return "ACD";
381            case ACV: return "ACV";
382            case PC: return "PC";
383            case PCM: return "PCM";
384            case PCD: return "PCD";
385            case PCV: return "PCV";
386            default: return "?";
387          }
388        }
389    }
390
391  public static class EventTimingEnumFactory implements EnumFactory<EventTiming> {
392    public EventTiming fromCode(String codeString) throws IllegalArgumentException {
393      if (codeString == null || "".equals(codeString))
394            if (codeString == null || "".equals(codeString))
395                return null;
396        if ("HS".equals(codeString))
397          return EventTiming.HS;
398        if ("WAKE".equals(codeString))
399          return EventTiming.WAKE;
400        if ("C".equals(codeString))
401          return EventTiming.C;
402        if ("CM".equals(codeString))
403          return EventTiming.CM;
404        if ("CD".equals(codeString))
405          return EventTiming.CD;
406        if ("CV".equals(codeString))
407          return EventTiming.CV;
408        if ("AC".equals(codeString))
409          return EventTiming.AC;
410        if ("ACM".equals(codeString))
411          return EventTiming.ACM;
412        if ("ACD".equals(codeString))
413          return EventTiming.ACD;
414        if ("ACV".equals(codeString))
415          return EventTiming.ACV;
416        if ("PC".equals(codeString))
417          return EventTiming.PC;
418        if ("PCM".equals(codeString))
419          return EventTiming.PCM;
420        if ("PCD".equals(codeString))
421          return EventTiming.PCD;
422        if ("PCV".equals(codeString))
423          return EventTiming.PCV;
424        throw new IllegalArgumentException("Unknown EventTiming code '"+codeString+"'");
425        }
426        public Enumeration<EventTiming> fromType(Base code) throws FHIRException {
427          if (code == null || code.isEmpty())
428            return null;
429          String codeString = ((PrimitiveType) code).asStringValue();
430          if (codeString == null || "".equals(codeString))
431            return null;
432        if ("HS".equals(codeString))
433          return new Enumeration<EventTiming>(this, EventTiming.HS);
434        if ("WAKE".equals(codeString))
435          return new Enumeration<EventTiming>(this, EventTiming.WAKE);
436        if ("C".equals(codeString))
437          return new Enumeration<EventTiming>(this, EventTiming.C);
438        if ("CM".equals(codeString))
439          return new Enumeration<EventTiming>(this, EventTiming.CM);
440        if ("CD".equals(codeString))
441          return new Enumeration<EventTiming>(this, EventTiming.CD);
442        if ("CV".equals(codeString))
443          return new Enumeration<EventTiming>(this, EventTiming.CV);
444        if ("AC".equals(codeString))
445          return new Enumeration<EventTiming>(this, EventTiming.AC);
446        if ("ACM".equals(codeString))
447          return new Enumeration<EventTiming>(this, EventTiming.ACM);
448        if ("ACD".equals(codeString))
449          return new Enumeration<EventTiming>(this, EventTiming.ACD);
450        if ("ACV".equals(codeString))
451          return new Enumeration<EventTiming>(this, EventTiming.ACV);
452        if ("PC".equals(codeString))
453          return new Enumeration<EventTiming>(this, EventTiming.PC);
454        if ("PCM".equals(codeString))
455          return new Enumeration<EventTiming>(this, EventTiming.PCM);
456        if ("PCD".equals(codeString))
457          return new Enumeration<EventTiming>(this, EventTiming.PCD);
458        if ("PCV".equals(codeString))
459          return new Enumeration<EventTiming>(this, EventTiming.PCV);
460        throw new FHIRException("Unknown EventTiming code '"+codeString+"'");
461        }
462    public String toCode(EventTiming code) {
463      if (code == EventTiming.HS)
464        return "HS";
465      if (code == EventTiming.WAKE)
466        return "WAKE";
467      if (code == EventTiming.C)
468        return "C";
469      if (code == EventTiming.CM)
470        return "CM";
471      if (code == EventTiming.CD)
472        return "CD";
473      if (code == EventTiming.CV)
474        return "CV";
475      if (code == EventTiming.AC)
476        return "AC";
477      if (code == EventTiming.ACM)
478        return "ACM";
479      if (code == EventTiming.ACD)
480        return "ACD";
481      if (code == EventTiming.ACV)
482        return "ACV";
483      if (code == EventTiming.PC)
484        return "PC";
485      if (code == EventTiming.PCM)
486        return "PCM";
487      if (code == EventTiming.PCD)
488        return "PCD";
489      if (code == EventTiming.PCV)
490        return "PCV";
491      return "?";
492      }
493    }
494
495    @Block()
496    public static class TimingRepeatComponent extends Element implements IBaseDatatypeElement {
497        /**
498         * Either a duration for the length of the timing schedule, a range of possible length, or outer bounds for start and/or end limits of the timing schedule.
499         */
500        @Child(name = "bounds", type = {Duration.class, Range.class, Period.class}, order=1, min=0, max=1, modifier=false, summary=true)
501        @Description(shortDefinition="Length/Range of lengths, or (Start and/or end) limits", formalDefinition="Either a duration for the length of the timing schedule, a range of possible length, or outer bounds for start and/or end limits of the timing schedule." )
502        protected Type bounds;
503
504        /**
505         * A total count of the desired number of repetitions.
506         */
507        @Child(name = "count", type = {IntegerType.class}, order=2, min=0, max=1, modifier=false, summary=true)
508        @Description(shortDefinition="Number of times to repeat", formalDefinition="A total count of the desired number of repetitions." )
509        protected IntegerType count;
510
511        /**
512         * How long this thing happens for when it happens.
513         */
514        @Child(name = "duration", type = {DecimalType.class}, order=3, min=0, max=1, modifier=false, summary=true)
515        @Description(shortDefinition="How long when it happens", formalDefinition="How long this thing happens for when it happens." )
516        protected DecimalType duration;
517
518        /**
519         * The upper limit of how long this thing happens for when it happens.
520         */
521        @Child(name = "durationMax", type = {DecimalType.class}, order=4, min=0, max=1, modifier=false, summary=true)
522        @Description(shortDefinition="How long when it happens (Max)", formalDefinition="The upper limit of how long this thing happens for when it happens." )
523        protected DecimalType durationMax;
524
525        /**
526         * The units of time for the duration, in UCUM units.
527         */
528        @Child(name = "durationUnits", type = {CodeType.class}, order=5, min=0, max=1, modifier=false, summary=true)
529        @Description(shortDefinition="s | min | h | d | wk | mo | a - unit of time (UCUM)", formalDefinition="The units of time for the duration, in UCUM units." )
530        protected Enumeration<UnitsOfTime> durationUnits;
531
532        /**
533         * The number of times to repeat the action within the specified period / period range (i.e. both period and periodMax provided).
534         */
535        @Child(name = "frequency", type = {IntegerType.class}, order=6, min=0, max=1, modifier=false, summary=true)
536        @Description(shortDefinition="Event occurs frequency times per period", formalDefinition="The number of times to repeat the action within the specified period / period range (i.e. both period and periodMax provided)." )
537        protected IntegerType frequency;
538
539        /**
540         * If present, indicates that the frequency is a range - so repeat between [frequency] and [frequencyMax] times within the period or period range.
541         */
542        @Child(name = "frequencyMax", type = {IntegerType.class}, order=7, min=0, max=1, modifier=false, summary=true)
543        @Description(shortDefinition="Event occurs up to frequencyMax times per period", formalDefinition="If present, indicates that the frequency is a range - so repeat between [frequency] and [frequencyMax] times within the period or period range." )
544        protected IntegerType frequencyMax;
545
546        /**
547         * Indicates the duration of time over which repetitions are to occur; e.g. to express "3 times per day", 3 would be the frequency and "1 day" would be the period.
548         */
549        @Child(name = "period", type = {DecimalType.class}, order=8, min=0, max=1, modifier=false, summary=true)
550        @Description(shortDefinition="Event occurs frequency times per period", formalDefinition="Indicates the duration of time over which repetitions are to occur; e.g. to express \"3 times per day\", 3 would be the frequency and \"1 day\" would be the period." )
551        protected DecimalType period;
552
553        /**
554         * If present, indicates that the period is a range from [period] to [periodMax], allowing expressing concepts such as "do this once every 3-5 days.
555         */
556        @Child(name = "periodMax", type = {DecimalType.class}, order=9, min=0, max=1, modifier=false, summary=true)
557        @Description(shortDefinition="Upper limit of period (3-4 hours)", formalDefinition="If present, indicates that the period is a range from [period] to [periodMax], allowing expressing concepts such as \"do this once every 3-5 days." )
558        protected DecimalType periodMax;
559
560        /**
561         * The units of time for the period in UCUM units.
562         */
563        @Child(name = "periodUnits", type = {CodeType.class}, order=10, min=0, max=1, modifier=false, summary=true)
564        @Description(shortDefinition="s | min | h | d | wk | mo | a - unit of time (UCUM)", formalDefinition="The units of time for the period in UCUM units." )
565        protected Enumeration<UnitsOfTime> periodUnits;
566
567        /**
568         * A real world event that the occurrence of the event should be tied to.
569         */
570        @Child(name = "when", type = {CodeType.class}, order=11, min=0, max=1, modifier=false, summary=true)
571        @Description(shortDefinition="Regular life events the event is tied to", formalDefinition="A real world event that the occurrence of the event should be tied to." )
572        protected Enumeration<EventTiming> when;
573
574        private static final long serialVersionUID = -585686982L;
575
576    /*
577     * Constructor
578     */
579      public TimingRepeatComponent() {
580        super();
581      }
582
583        /**
584         * @return {@link #bounds} (Either a duration for the length of the timing schedule, a range of possible length, or outer bounds for start and/or end limits of the timing schedule.)
585         */
586        public Type getBounds() { 
587          return this.bounds;
588        }
589
590        /**
591         * @return {@link #bounds} (Either a duration for the length of the timing schedule, a range of possible length, or outer bounds for start and/or end limits of the timing schedule.)
592         */
593        public Duration getBoundsDuration() throws FHIRException { 
594          if (!(this.bounds instanceof Duration))
595            throw new FHIRException("Type mismatch: the type Duration was expected, but "+this.bounds.getClass().getName()+" was encountered");
596          return (Duration) this.bounds;
597        }
598
599        public boolean hasBoundsDuration() { 
600          return this.bounds instanceof Duration;
601        }
602
603        /**
604         * @return {@link #bounds} (Either a duration for the length of the timing schedule, a range of possible length, or outer bounds for start and/or end limits of the timing schedule.)
605         */
606        public Range getBoundsRange() throws FHIRException { 
607          if (!(this.bounds instanceof Range))
608            throw new FHIRException("Type mismatch: the type Range was expected, but "+this.bounds.getClass().getName()+" was encountered");
609          return (Range) this.bounds;
610        }
611
612        public boolean hasBoundsRange() { 
613          return this.bounds instanceof Range;
614        }
615
616        /**
617         * @return {@link #bounds} (Either a duration for the length of the timing schedule, a range of possible length, or outer bounds for start and/or end limits of the timing schedule.)
618         */
619        public Period getBoundsPeriod() throws FHIRException { 
620          if (!(this.bounds instanceof Period))
621            throw new FHIRException("Type mismatch: the type Period was expected, but "+this.bounds.getClass().getName()+" was encountered");
622          return (Period) this.bounds;
623        }
624
625        public boolean hasBoundsPeriod() { 
626          return this.bounds instanceof Period;
627        }
628
629        public boolean hasBounds() { 
630          return this.bounds != null && !this.bounds.isEmpty();
631        }
632
633        /**
634         * @param value {@link #bounds} (Either a duration for the length of the timing schedule, a range of possible length, or outer bounds for start and/or end limits of the timing schedule.)
635         */
636        public TimingRepeatComponent setBounds(Type value) { 
637          this.bounds = value;
638          return this;
639        }
640
641        /**
642         * @return {@link #count} (A total count of the desired number of repetitions.). This is the underlying object with id, value and extensions. The accessor "getCount" gives direct access to the value
643         */
644        public IntegerType getCountElement() { 
645          if (this.count == null)
646            if (Configuration.errorOnAutoCreate())
647              throw new Error("Attempt to auto-create TimingRepeatComponent.count");
648            else if (Configuration.doAutoCreate())
649              this.count = new IntegerType(); // bb
650          return this.count;
651        }
652
653        public boolean hasCountElement() { 
654          return this.count != null && !this.count.isEmpty();
655        }
656
657        public boolean hasCount() { 
658          return this.count != null && !this.count.isEmpty();
659        }
660
661        /**
662         * @param value {@link #count} (A total count of the desired number of repetitions.). This is the underlying object with id, value and extensions. The accessor "getCount" gives direct access to the value
663         */
664        public TimingRepeatComponent setCountElement(IntegerType value) { 
665          this.count = value;
666          return this;
667        }
668
669        /**
670         * @return A total count of the desired number of repetitions.
671         */
672        public int getCount() { 
673          return this.count == null || this.count.isEmpty() ? 0 : this.count.getValue();
674        }
675
676        /**
677         * @param value A total count of the desired number of repetitions.
678         */
679        public TimingRepeatComponent setCount(int value) { 
680            if (this.count == null)
681              this.count = new IntegerType();
682            this.count.setValue(value);
683          return this;
684        }
685
686        /**
687         * @return {@link #duration} (How long this thing happens for when it happens.). This is the underlying object with id, value and extensions. The accessor "getDuration" gives direct access to the value
688         */
689        public DecimalType getDurationElement() { 
690          if (this.duration == null)
691            if (Configuration.errorOnAutoCreate())
692              throw new Error("Attempt to auto-create TimingRepeatComponent.duration");
693            else if (Configuration.doAutoCreate())
694              this.duration = new DecimalType(); // bb
695          return this.duration;
696        }
697
698        public boolean hasDurationElement() { 
699          return this.duration != null && !this.duration.isEmpty();
700        }
701
702        public boolean hasDuration() { 
703          return this.duration != null && !this.duration.isEmpty();
704        }
705
706        /**
707         * @param value {@link #duration} (How long this thing happens for when it happens.). This is the underlying object with id, value and extensions. The accessor "getDuration" gives direct access to the value
708         */
709        public TimingRepeatComponent setDurationElement(DecimalType value) { 
710          this.duration = value;
711          return this;
712        }
713
714        /**
715         * @return How long this thing happens for when it happens.
716         */
717        public BigDecimal getDuration() { 
718          return this.duration == null ? null : this.duration.getValue();
719        }
720
721        /**
722         * @param value How long this thing happens for when it happens.
723         */
724        public TimingRepeatComponent setDuration(BigDecimal value) { 
725          if (value == null)
726            this.duration = null;
727          else {
728            if (this.duration == null)
729              this.duration = new DecimalType();
730            this.duration.setValue(value);
731          }
732          return this;
733        }
734
735        /**
736         * @return {@link #durationMax} (The upper limit of how long this thing happens for when it happens.). This is the underlying object with id, value and extensions. The accessor "getDurationMax" gives direct access to the value
737         */
738        public DecimalType getDurationMaxElement() { 
739          if (this.durationMax == null)
740            if (Configuration.errorOnAutoCreate())
741              throw new Error("Attempt to auto-create TimingRepeatComponent.durationMax");
742            else if (Configuration.doAutoCreate())
743              this.durationMax = new DecimalType(); // bb
744          return this.durationMax;
745        }
746
747        public boolean hasDurationMaxElement() { 
748          return this.durationMax != null && !this.durationMax.isEmpty();
749        }
750
751        public boolean hasDurationMax() { 
752          return this.durationMax != null && !this.durationMax.isEmpty();
753        }
754
755        /**
756         * @param value {@link #durationMax} (The upper limit of how long this thing happens for when it happens.). This is the underlying object with id, value and extensions. The accessor "getDurationMax" gives direct access to the value
757         */
758        public TimingRepeatComponent setDurationMaxElement(DecimalType value) { 
759          this.durationMax = value;
760          return this;
761        }
762
763        /**
764         * @return The upper limit of how long this thing happens for when it happens.
765         */
766        public BigDecimal getDurationMax() { 
767          return this.durationMax == null ? null : this.durationMax.getValue();
768        }
769
770        /**
771         * @param value The upper limit of how long this thing happens for when it happens.
772         */
773        public TimingRepeatComponent setDurationMax(BigDecimal value) { 
774          if (value == null)
775            this.durationMax = null;
776          else {
777            if (this.durationMax == null)
778              this.durationMax = new DecimalType();
779            this.durationMax.setValue(value);
780          }
781          return this;
782        }
783
784        /**
785         * @return {@link #durationUnits} (The units of time for the duration, in UCUM units.). This is the underlying object with id, value and extensions. The accessor "getDurationUnits" gives direct access to the value
786         */
787        public Enumeration<UnitsOfTime> getDurationUnitsElement() { 
788          if (this.durationUnits == null)
789            if (Configuration.errorOnAutoCreate())
790              throw new Error("Attempt to auto-create TimingRepeatComponent.durationUnits");
791            else if (Configuration.doAutoCreate())
792              this.durationUnits = new Enumeration<UnitsOfTime>(new UnitsOfTimeEnumFactory()); // bb
793          return this.durationUnits;
794        }
795
796        public boolean hasDurationUnitsElement() { 
797          return this.durationUnits != null && !this.durationUnits.isEmpty();
798        }
799
800        public boolean hasDurationUnits() { 
801          return this.durationUnits != null && !this.durationUnits.isEmpty();
802        }
803
804        /**
805         * @param value {@link #durationUnits} (The units of time for the duration, in UCUM units.). This is the underlying object with id, value and extensions. The accessor "getDurationUnits" gives direct access to the value
806         */
807        public TimingRepeatComponent setDurationUnitsElement(Enumeration<UnitsOfTime> value) { 
808          this.durationUnits = value;
809          return this;
810        }
811
812        /**
813         * @return The units of time for the duration, in UCUM units.
814         */
815        public UnitsOfTime getDurationUnits() { 
816          return this.durationUnits == null ? null : this.durationUnits.getValue();
817        }
818
819        /**
820         * @param value The units of time for the duration, in UCUM units.
821         */
822        public TimingRepeatComponent setDurationUnits(UnitsOfTime value) { 
823          if (value == null)
824            this.durationUnits = null;
825          else {
826            if (this.durationUnits == null)
827              this.durationUnits = new Enumeration<UnitsOfTime>(new UnitsOfTimeEnumFactory());
828            this.durationUnits.setValue(value);
829          }
830          return this;
831        }
832
833        /**
834         * @return {@link #frequency} (The number of times to repeat the action within the specified period / period range (i.e. both period and periodMax provided).). This is the underlying object with id, value and extensions. The accessor "getFrequency" gives direct access to the value
835         */
836        public IntegerType getFrequencyElement() { 
837          if (this.frequency == null)
838            if (Configuration.errorOnAutoCreate())
839              throw new Error("Attempt to auto-create TimingRepeatComponent.frequency");
840            else if (Configuration.doAutoCreate())
841              this.frequency = new IntegerType(); // bb
842          return this.frequency;
843        }
844
845        public boolean hasFrequencyElement() { 
846          return this.frequency != null && !this.frequency.isEmpty();
847        }
848
849        public boolean hasFrequency() { 
850          return this.frequency != null && !this.frequency.isEmpty();
851        }
852
853        /**
854         * @param value {@link #frequency} (The number of times to repeat the action within the specified period / period range (i.e. both period and periodMax provided).). This is the underlying object with id, value and extensions. The accessor "getFrequency" gives direct access to the value
855         */
856        public TimingRepeatComponent setFrequencyElement(IntegerType value) { 
857          this.frequency = value;
858          return this;
859        }
860
861        /**
862         * @return The number of times to repeat the action within the specified period / period range (i.e. both period and periodMax provided).
863         */
864        public int getFrequency() { 
865          return this.frequency == null || this.frequency.isEmpty() ? 0 : this.frequency.getValue();
866        }
867
868        /**
869         * @param value The number of times to repeat the action within the specified period / period range (i.e. both period and periodMax provided).
870         */
871        public TimingRepeatComponent setFrequency(int value) { 
872            if (this.frequency == null)
873              this.frequency = new IntegerType();
874            this.frequency.setValue(value);
875          return this;
876        }
877
878        /**
879         * @return {@link #frequencyMax} (If present, indicates that the frequency is a range - so repeat between [frequency] and [frequencyMax] times within the period or period range.). This is the underlying object with id, value and extensions. The accessor "getFrequencyMax" gives direct access to the value
880         */
881        public IntegerType getFrequencyMaxElement() { 
882          if (this.frequencyMax == null)
883            if (Configuration.errorOnAutoCreate())
884              throw new Error("Attempt to auto-create TimingRepeatComponent.frequencyMax");
885            else if (Configuration.doAutoCreate())
886              this.frequencyMax = new IntegerType(); // bb
887          return this.frequencyMax;
888        }
889
890        public boolean hasFrequencyMaxElement() { 
891          return this.frequencyMax != null && !this.frequencyMax.isEmpty();
892        }
893
894        public boolean hasFrequencyMax() { 
895          return this.frequencyMax != null && !this.frequencyMax.isEmpty();
896        }
897
898        /**
899         * @param value {@link #frequencyMax} (If present, indicates that the frequency is a range - so repeat between [frequency] and [frequencyMax] times within the period or period range.). This is the underlying object with id, value and extensions. The accessor "getFrequencyMax" gives direct access to the value
900         */
901        public TimingRepeatComponent setFrequencyMaxElement(IntegerType value) { 
902          this.frequencyMax = value;
903          return this;
904        }
905
906        /**
907         * @return If present, indicates that the frequency is a range - so repeat between [frequency] and [frequencyMax] times within the period or period range.
908         */
909        public int getFrequencyMax() { 
910          return this.frequencyMax == null || this.frequencyMax.isEmpty() ? 0 : this.frequencyMax.getValue();
911        }
912
913        /**
914         * @param value If present, indicates that the frequency is a range - so repeat between [frequency] and [frequencyMax] times within the period or period range.
915         */
916        public TimingRepeatComponent setFrequencyMax(int value) { 
917            if (this.frequencyMax == null)
918              this.frequencyMax = new IntegerType();
919            this.frequencyMax.setValue(value);
920          return this;
921        }
922
923        /**
924         * @return {@link #period} (Indicates the duration of time over which repetitions are to occur; e.g. to express "3 times per day", 3 would be the frequency and "1 day" would be the period.). This is the underlying object with id, value and extensions. The accessor "getPeriod" gives direct access to the value
925         */
926        public DecimalType getPeriodElement() { 
927          if (this.period == null)
928            if (Configuration.errorOnAutoCreate())
929              throw new Error("Attempt to auto-create TimingRepeatComponent.period");
930            else if (Configuration.doAutoCreate())
931              this.period = new DecimalType(); // bb
932          return this.period;
933        }
934
935        public boolean hasPeriodElement() { 
936          return this.period != null && !this.period.isEmpty();
937        }
938
939        public boolean hasPeriod() { 
940          return this.period != null && !this.period.isEmpty();
941        }
942
943        /**
944         * @param value {@link #period} (Indicates the duration of time over which repetitions are to occur; e.g. to express "3 times per day", 3 would be the frequency and "1 day" would be the period.). This is the underlying object with id, value and extensions. The accessor "getPeriod" gives direct access to the value
945         */
946        public TimingRepeatComponent setPeriodElement(DecimalType value) { 
947          this.period = value;
948          return this;
949        }
950
951        /**
952         * @return Indicates the duration of time over which repetitions are to occur; e.g. to express "3 times per day", 3 would be the frequency and "1 day" would be the period.
953         */
954        public BigDecimal getPeriod() { 
955          return this.period == null ? null : this.period.getValue();
956        }
957
958        /**
959         * @param value Indicates the duration of time over which repetitions are to occur; e.g. to express "3 times per day", 3 would be the frequency and "1 day" would be the period.
960         */
961        public TimingRepeatComponent setPeriod(BigDecimal value) { 
962          if (value == null)
963            this.period = null;
964          else {
965            if (this.period == null)
966              this.period = new DecimalType();
967            this.period.setValue(value);
968          }
969          return this;
970        }
971
972        /**
973         * @return {@link #periodMax} (If present, indicates that the period is a range from [period] to [periodMax], allowing expressing concepts such as "do this once every 3-5 days.). This is the underlying object with id, value and extensions. The accessor "getPeriodMax" gives direct access to the value
974         */
975        public DecimalType getPeriodMaxElement() { 
976          if (this.periodMax == null)
977            if (Configuration.errorOnAutoCreate())
978              throw new Error("Attempt to auto-create TimingRepeatComponent.periodMax");
979            else if (Configuration.doAutoCreate())
980              this.periodMax = new DecimalType(); // bb
981          return this.periodMax;
982        }
983
984        public boolean hasPeriodMaxElement() { 
985          return this.periodMax != null && !this.periodMax.isEmpty();
986        }
987
988        public boolean hasPeriodMax() { 
989          return this.periodMax != null && !this.periodMax.isEmpty();
990        }
991
992        /**
993         * @param value {@link #periodMax} (If present, indicates that the period is a range from [period] to [periodMax], allowing expressing concepts such as "do this once every 3-5 days.). This is the underlying object with id, value and extensions. The accessor "getPeriodMax" gives direct access to the value
994         */
995        public TimingRepeatComponent setPeriodMaxElement(DecimalType value) { 
996          this.periodMax = value;
997          return this;
998        }
999
1000        /**
1001         * @return If present, indicates that the period is a range from [period] to [periodMax], allowing expressing concepts such as "do this once every 3-5 days.
1002         */
1003        public BigDecimal getPeriodMax() { 
1004          return this.periodMax == null ? null : this.periodMax.getValue();
1005        }
1006
1007        /**
1008         * @param value If present, indicates that the period is a range from [period] to [periodMax], allowing expressing concepts such as "do this once every 3-5 days.
1009         */
1010        public TimingRepeatComponent setPeriodMax(BigDecimal value) { 
1011          if (value == null)
1012            this.periodMax = null;
1013          else {
1014            if (this.periodMax == null)
1015              this.periodMax = new DecimalType();
1016            this.periodMax.setValue(value);
1017          }
1018          return this;
1019        }
1020
1021        /**
1022         * @return {@link #periodUnits} (The units of time for the period in UCUM units.). This is the underlying object with id, value and extensions. The accessor "getPeriodUnits" gives direct access to the value
1023         */
1024        public Enumeration<UnitsOfTime> getPeriodUnitsElement() { 
1025          if (this.periodUnits == null)
1026            if (Configuration.errorOnAutoCreate())
1027              throw new Error("Attempt to auto-create TimingRepeatComponent.periodUnits");
1028            else if (Configuration.doAutoCreate())
1029              this.periodUnits = new Enumeration<UnitsOfTime>(new UnitsOfTimeEnumFactory()); // bb
1030          return this.periodUnits;
1031        }
1032
1033        public boolean hasPeriodUnitsElement() { 
1034          return this.periodUnits != null && !this.periodUnits.isEmpty();
1035        }
1036
1037        public boolean hasPeriodUnits() { 
1038          return this.periodUnits != null && !this.periodUnits.isEmpty();
1039        }
1040
1041        /**
1042         * @param value {@link #periodUnits} (The units of time for the period in UCUM units.). This is the underlying object with id, value and extensions. The accessor "getPeriodUnits" gives direct access to the value
1043         */
1044        public TimingRepeatComponent setPeriodUnitsElement(Enumeration<UnitsOfTime> value) { 
1045          this.periodUnits = value;
1046          return this;
1047        }
1048
1049        /**
1050         * @return The units of time for the period in UCUM units.
1051         */
1052        public UnitsOfTime getPeriodUnits() { 
1053          return this.periodUnits == null ? null : this.periodUnits.getValue();
1054        }
1055
1056        /**
1057         * @param value The units of time for the period in UCUM units.
1058         */
1059        public TimingRepeatComponent setPeriodUnits(UnitsOfTime value) { 
1060          if (value == null)
1061            this.periodUnits = null;
1062          else {
1063            if (this.periodUnits == null)
1064              this.periodUnits = new Enumeration<UnitsOfTime>(new UnitsOfTimeEnumFactory());
1065            this.periodUnits.setValue(value);
1066          }
1067          return this;
1068        }
1069
1070        /**
1071         * @return {@link #when} (A real world event that the occurrence of the event should be tied to.). This is the underlying object with id, value and extensions. The accessor "getWhen" gives direct access to the value
1072         */
1073        public Enumeration<EventTiming> getWhenElement() { 
1074          if (this.when == null)
1075            if (Configuration.errorOnAutoCreate())
1076              throw new Error("Attempt to auto-create TimingRepeatComponent.when");
1077            else if (Configuration.doAutoCreate())
1078              this.when = new Enumeration<EventTiming>(new EventTimingEnumFactory()); // bb
1079          return this.when;
1080        }
1081
1082        public boolean hasWhenElement() { 
1083          return this.when != null && !this.when.isEmpty();
1084        }
1085
1086        public boolean hasWhen() { 
1087          return this.when != null && !this.when.isEmpty();
1088        }
1089
1090        /**
1091         * @param value {@link #when} (A real world event that the occurrence of the event should be tied to.). This is the underlying object with id, value and extensions. The accessor "getWhen" gives direct access to the value
1092         */
1093        public TimingRepeatComponent setWhenElement(Enumeration<EventTiming> value) { 
1094          this.when = value;
1095          return this;
1096        }
1097
1098        /**
1099         * @return A real world event that the occurrence of the event should be tied to.
1100         */
1101        public EventTiming getWhen() { 
1102          return this.when == null ? null : this.when.getValue();
1103        }
1104
1105        /**
1106         * @param value A real world event that the occurrence of the event should be tied to.
1107         */
1108        public TimingRepeatComponent setWhen(EventTiming value) { 
1109          if (value == null)
1110            this.when = null;
1111          else {
1112            if (this.when == null)
1113              this.when = new Enumeration<EventTiming>(new EventTimingEnumFactory());
1114            this.when.setValue(value);
1115          }
1116          return this;
1117        }
1118
1119        protected void listChildren(List<Property> childrenList) {
1120          super.listChildren(childrenList);
1121          childrenList.add(new Property("bounds[x]", "Duration|Range|Period", "Either a duration for the length of the timing schedule, a range of possible length, or outer bounds for start and/or end limits of the timing schedule.", 0, java.lang.Integer.MAX_VALUE, bounds));
1122          childrenList.add(new Property("count", "integer", "A total count of the desired number of repetitions.", 0, java.lang.Integer.MAX_VALUE, count));
1123          childrenList.add(new Property("duration", "decimal", "How long this thing happens for when it happens.", 0, java.lang.Integer.MAX_VALUE, duration));
1124          childrenList.add(new Property("durationMax", "decimal", "The upper limit of how long this thing happens for when it happens.", 0, java.lang.Integer.MAX_VALUE, durationMax));
1125          childrenList.add(new Property("durationUnits", "code", "The units of time for the duration, in UCUM units.", 0, java.lang.Integer.MAX_VALUE, durationUnits));
1126          childrenList.add(new Property("frequency", "integer", "The number of times to repeat the action within the specified period / period range (i.e. both period and periodMax provided).", 0, java.lang.Integer.MAX_VALUE, frequency));
1127          childrenList.add(new Property("frequencyMax", "integer", "If present, indicates that the frequency is a range - so repeat between [frequency] and [frequencyMax] times within the period or period range.", 0, java.lang.Integer.MAX_VALUE, frequencyMax));
1128          childrenList.add(new Property("period", "decimal", "Indicates the duration of time over which repetitions are to occur; e.g. to express \"3 times per day\", 3 would be the frequency and \"1 day\" would be the period.", 0, java.lang.Integer.MAX_VALUE, period));
1129          childrenList.add(new Property("periodMax", "decimal", "If present, indicates that the period is a range from [period] to [periodMax], allowing expressing concepts such as \"do this once every 3-5 days.", 0, java.lang.Integer.MAX_VALUE, periodMax));
1130          childrenList.add(new Property("periodUnits", "code", "The units of time for the period in UCUM units.", 0, java.lang.Integer.MAX_VALUE, periodUnits));
1131          childrenList.add(new Property("when", "code", "A real world event that the occurrence of the event should be tied to.", 0, java.lang.Integer.MAX_VALUE, when));
1132        }
1133
1134      @Override
1135      public void setProperty(String name, Base value) throws FHIRException {
1136        if (name.equals("bounds[x]"))
1137          this.bounds = (Type) value; // Type
1138        else if (name.equals("count"))
1139          this.count = castToInteger(value); // IntegerType
1140        else if (name.equals("duration"))
1141          this.duration = castToDecimal(value); // DecimalType
1142        else if (name.equals("durationMax"))
1143          this.durationMax = castToDecimal(value); // DecimalType
1144        else if (name.equals("durationUnits"))
1145          this.durationUnits = new UnitsOfTimeEnumFactory().fromType(value); // Enumeration<UnitsOfTime>
1146        else if (name.equals("frequency"))
1147          this.frequency = castToInteger(value); // IntegerType
1148        else if (name.equals("frequencyMax"))
1149          this.frequencyMax = castToInteger(value); // IntegerType
1150        else if (name.equals("period"))
1151          this.period = castToDecimal(value); // DecimalType
1152        else if (name.equals("periodMax"))
1153          this.periodMax = castToDecimal(value); // DecimalType
1154        else if (name.equals("periodUnits"))
1155          this.periodUnits = new UnitsOfTimeEnumFactory().fromType(value); // Enumeration<UnitsOfTime>
1156        else if (name.equals("when"))
1157          this.when = new EventTimingEnumFactory().fromType(value); // Enumeration<EventTiming>
1158        else
1159          super.setProperty(name, value);
1160      }
1161
1162      @Override
1163      public Base addChild(String name) throws FHIRException {
1164        if (name.equals("boundsDuration")) {
1165          this.bounds = new Duration();
1166          return this.bounds;
1167        }
1168        else if (name.equals("boundsRange")) {
1169          this.bounds = new Range();
1170          return this.bounds;
1171        }
1172        else if (name.equals("boundsPeriod")) {
1173          this.bounds = new Period();
1174          return this.bounds;
1175        }
1176        else if (name.equals("count")) {
1177          throw new FHIRException("Cannot call addChild on a primitive type Timing.count");
1178        }
1179        else if (name.equals("duration")) {
1180          throw new FHIRException("Cannot call addChild on a primitive type Timing.duration");
1181        }
1182        else if (name.equals("durationMax")) {
1183          throw new FHIRException("Cannot call addChild on a primitive type Timing.durationMax");
1184        }
1185        else if (name.equals("durationUnits")) {
1186          throw new FHIRException("Cannot call addChild on a primitive type Timing.durationUnits");
1187        }
1188        else if (name.equals("frequency")) {
1189          throw new FHIRException("Cannot call addChild on a primitive type Timing.frequency");
1190        }
1191        else if (name.equals("frequencyMax")) {
1192          throw new FHIRException("Cannot call addChild on a primitive type Timing.frequencyMax");
1193        }
1194        else if (name.equals("period")) {
1195          throw new FHIRException("Cannot call addChild on a primitive type Timing.period");
1196        }
1197        else if (name.equals("periodMax")) {
1198          throw new FHIRException("Cannot call addChild on a primitive type Timing.periodMax");
1199        }
1200        else if (name.equals("periodUnits")) {
1201          throw new FHIRException("Cannot call addChild on a primitive type Timing.periodUnits");
1202        }
1203        else if (name.equals("when")) {
1204          throw new FHIRException("Cannot call addChild on a primitive type Timing.when");
1205        }
1206        else
1207          return super.addChild(name);
1208      }
1209
1210      public TimingRepeatComponent copy() {
1211        TimingRepeatComponent dst = new TimingRepeatComponent();
1212        copyValues(dst);
1213        dst.bounds = bounds == null ? null : bounds.copy();
1214        dst.count = count == null ? null : count.copy();
1215        dst.duration = duration == null ? null : duration.copy();
1216        dst.durationMax = durationMax == null ? null : durationMax.copy();
1217        dst.durationUnits = durationUnits == null ? null : durationUnits.copy();
1218        dst.frequency = frequency == null ? null : frequency.copy();
1219        dst.frequencyMax = frequencyMax == null ? null : frequencyMax.copy();
1220        dst.period = period == null ? null : period.copy();
1221        dst.periodMax = periodMax == null ? null : periodMax.copy();
1222        dst.periodUnits = periodUnits == null ? null : periodUnits.copy();
1223        dst.when = when == null ? null : when.copy();
1224        return dst;
1225      }
1226
1227      @Override
1228      public boolean equalsDeep(Base other) {
1229        if (!super.equalsDeep(other))
1230          return false;
1231        if (!(other instanceof TimingRepeatComponent))
1232          return false;
1233        TimingRepeatComponent o = (TimingRepeatComponent) other;
1234        return compareDeep(bounds, o.bounds, true) && compareDeep(count, o.count, true) && compareDeep(duration, o.duration, true)
1235           && compareDeep(durationMax, o.durationMax, true) && compareDeep(durationUnits, o.durationUnits, true)
1236           && compareDeep(frequency, o.frequency, true) && compareDeep(frequencyMax, o.frequencyMax, true)
1237           && compareDeep(period, o.period, true) && compareDeep(periodMax, o.periodMax, true) && compareDeep(periodUnits, o.periodUnits, true)
1238           && compareDeep(when, o.when, true);
1239      }
1240
1241      @Override
1242      public boolean equalsShallow(Base other) {
1243        if (!super.equalsShallow(other))
1244          return false;
1245        if (!(other instanceof TimingRepeatComponent))
1246          return false;
1247        TimingRepeatComponent o = (TimingRepeatComponent) other;
1248        return compareValues(count, o.count, true) && compareValues(duration, o.duration, true) && compareValues(durationMax, o.durationMax, true)
1249           && compareValues(durationUnits, o.durationUnits, true) && compareValues(frequency, o.frequency, true)
1250           && compareValues(frequencyMax, o.frequencyMax, true) && compareValues(period, o.period, true) && compareValues(periodMax, o.periodMax, true)
1251           && compareValues(periodUnits, o.periodUnits, true) && compareValues(when, o.when, true);
1252      }
1253
1254      public boolean isEmpty() {
1255        return super.isEmpty() && (bounds == null || bounds.isEmpty()) && (count == null || count.isEmpty())
1256           && (duration == null || duration.isEmpty()) && (durationMax == null || durationMax.isEmpty())
1257           && (durationUnits == null || durationUnits.isEmpty()) && (frequency == null || frequency.isEmpty())
1258           && (frequencyMax == null || frequencyMax.isEmpty()) && (period == null || period.isEmpty())
1259           && (periodMax == null || periodMax.isEmpty()) && (periodUnits == null || periodUnits.isEmpty())
1260           && (when == null || when.isEmpty());
1261      }
1262
1263  public String fhirType() {
1264    return "Timing.repeat";
1265
1266  }
1267
1268  }
1269
1270    /**
1271     * Identifies specific times when the event occurs.
1272     */
1273    @Child(name = "event", type = {DateTimeType.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1274    @Description(shortDefinition="When the event occurs", formalDefinition="Identifies specific times when the event occurs." )
1275    protected List<DateTimeType> event;
1276
1277    /**
1278     * A set of rules that describe when the event should occur.
1279     */
1280    @Child(name = "repeat", type = {}, order=1, min=0, max=1, modifier=false, summary=true)
1281    @Description(shortDefinition="When the event is to occur", formalDefinition="A set of rules that describe when the event should occur." )
1282    protected TimingRepeatComponent repeat;
1283
1284    /**
1285     * A code for the timing pattern. Some codes such as BID are ubiquitous, but many institutions define their own additional codes.
1286     */
1287    @Child(name = "code", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
1288    @Description(shortDefinition="QD | QOD | Q4H | Q6H | BID | TID | QID | AM | PM +", formalDefinition="A code for the timing pattern. Some codes such as BID are ubiquitous, but many institutions define their own additional codes." )
1289    protected CodeableConcept code;
1290
1291    private static final long serialVersionUID = 791565112L;
1292
1293  /*
1294   * Constructor
1295   */
1296    public Timing() {
1297      super();
1298    }
1299
1300    /**
1301     * @return {@link #event} (Identifies specific times when the event occurs.)
1302     */
1303    public List<DateTimeType> getEvent() { 
1304      if (this.event == null)
1305        this.event = new ArrayList<DateTimeType>();
1306      return this.event;
1307    }
1308
1309    public boolean hasEvent() { 
1310      if (this.event == null)
1311        return false;
1312      for (DateTimeType item : this.event)
1313        if (!item.isEmpty())
1314          return true;
1315      return false;
1316    }
1317
1318    /**
1319     * @return {@link #event} (Identifies specific times when the event occurs.)
1320     */
1321    // syntactic sugar
1322    public DateTimeType addEventElement() {//2 
1323      DateTimeType t = new DateTimeType();
1324      if (this.event == null)
1325        this.event = new ArrayList<DateTimeType>();
1326      this.event.add(t);
1327      return t;
1328    }
1329
1330    /**
1331     * @param value {@link #event} (Identifies specific times when the event occurs.)
1332     */
1333    public Timing addEvent(Date value) { //1
1334      DateTimeType t = new DateTimeType();
1335      t.setValue(value);
1336      if (this.event == null)
1337        this.event = new ArrayList<DateTimeType>();
1338      this.event.add(t);
1339      return this;
1340    }
1341
1342    /**
1343     * @param value {@link #event} (Identifies specific times when the event occurs.)
1344     */
1345    public boolean hasEvent(Date value) { 
1346      if (this.event == null)
1347        return false;
1348      for (DateTimeType v : this.event)
1349        if (v.equals(value)) // dateTime
1350          return true;
1351      return false;
1352    }
1353
1354    /**
1355     * @return {@link #repeat} (A set of rules that describe when the event should occur.)
1356     */
1357    public TimingRepeatComponent getRepeat() { 
1358      if (this.repeat == null)
1359        if (Configuration.errorOnAutoCreate())
1360          throw new Error("Attempt to auto-create Timing.repeat");
1361        else if (Configuration.doAutoCreate())
1362          this.repeat = new TimingRepeatComponent(); // cc
1363      return this.repeat;
1364    }
1365
1366    public boolean hasRepeat() { 
1367      return this.repeat != null && !this.repeat.isEmpty();
1368    }
1369
1370    /**
1371     * @param value {@link #repeat} (A set of rules that describe when the event should occur.)
1372     */
1373    public Timing setRepeat(TimingRepeatComponent value) { 
1374      this.repeat = value;
1375      return this;
1376    }
1377
1378    /**
1379     * @return {@link #code} (A code for the timing pattern. Some codes such as BID are ubiquitous, but many institutions define their own additional codes.)
1380     */
1381    public CodeableConcept getCode() { 
1382      if (this.code == null)
1383        if (Configuration.errorOnAutoCreate())
1384          throw new Error("Attempt to auto-create Timing.code");
1385        else if (Configuration.doAutoCreate())
1386          this.code = new CodeableConcept(); // cc
1387      return this.code;
1388    }
1389
1390    public boolean hasCode() { 
1391      return this.code != null && !this.code.isEmpty();
1392    }
1393
1394    /**
1395     * @param value {@link #code} (A code for the timing pattern. Some codes such as BID are ubiquitous, but many institutions define their own additional codes.)
1396     */
1397    public Timing setCode(CodeableConcept value) { 
1398      this.code = value;
1399      return this;
1400    }
1401
1402      protected void listChildren(List<Property> childrenList) {
1403        super.listChildren(childrenList);
1404        childrenList.add(new Property("event", "dateTime", "Identifies specific times when the event occurs.", 0, java.lang.Integer.MAX_VALUE, event));
1405        childrenList.add(new Property("repeat", "", "A set of rules that describe when the event should occur.", 0, java.lang.Integer.MAX_VALUE, repeat));
1406        childrenList.add(new Property("code", "CodeableConcept", "A code for the timing pattern. Some codes such as BID are ubiquitous, but many institutions define their own additional codes.", 0, java.lang.Integer.MAX_VALUE, code));
1407      }
1408
1409      @Override
1410      public void setProperty(String name, Base value) throws FHIRException {
1411        if (name.equals("event"))
1412          this.getEvent().add(castToDateTime(value));
1413        else if (name.equals("repeat"))
1414          this.repeat = (TimingRepeatComponent) value; // TimingRepeatComponent
1415        else if (name.equals("code"))
1416          this.code = castToCodeableConcept(value); // CodeableConcept
1417        else
1418          super.setProperty(name, value);
1419      }
1420
1421      @Override
1422      public Base addChild(String name) throws FHIRException {
1423        if (name.equals("event")) {
1424          throw new FHIRException("Cannot call addChild on a primitive type Timing.event");
1425        }
1426        else if (name.equals("repeat")) {
1427          this.repeat = new TimingRepeatComponent();
1428          return this.repeat;
1429        }
1430        else if (name.equals("code")) {
1431          this.code = new CodeableConcept();
1432          return this.code;
1433        }
1434        else
1435          return super.addChild(name);
1436      }
1437
1438  public String fhirType() {
1439    return "Timing";
1440
1441  }
1442
1443      public Timing copy() {
1444        Timing dst = new Timing();
1445        copyValues(dst);
1446        if (event != null) {
1447          dst.event = new ArrayList<DateTimeType>();
1448          for (DateTimeType i : event)
1449            dst.event.add(i.copy());
1450        };
1451        dst.repeat = repeat == null ? null : repeat.copy();
1452        dst.code = code == null ? null : code.copy();
1453        return dst;
1454      }
1455
1456      protected Timing typedCopy() {
1457        return copy();
1458      }
1459
1460      @Override
1461      public boolean equalsDeep(Base other) {
1462        if (!super.equalsDeep(other))
1463          return false;
1464        if (!(other instanceof Timing))
1465          return false;
1466        Timing o = (Timing) other;
1467        return compareDeep(event, o.event, true) && compareDeep(repeat, o.repeat, true) && compareDeep(code, o.code, true)
1468          ;
1469      }
1470
1471      @Override
1472      public boolean equalsShallow(Base other) {
1473        if (!super.equalsShallow(other))
1474          return false;
1475        if (!(other instanceof Timing))
1476          return false;
1477        Timing o = (Timing) other;
1478        return compareValues(event, o.event, true);
1479      }
1480
1481      public boolean isEmpty() {
1482        return super.isEmpty() && (event == null || event.isEmpty()) && (repeat == null || repeat.isEmpty())
1483           && (code == null || code.isEmpty());
1484      }
1485
1486
1487}