001package org.hl7.fhir.r5.model;
002
003
004/*
005  Copyright (c) 2011+, HL7, Inc.
006  All rights reserved.
007  
008  Redistribution and use in source and binary forms, with or without modification, \
009  are permitted provided that the following conditions are met:
010  
011   * Redistributions of source code must retain the above copyright notice, this \
012     list of conditions and the following disclaimer.
013   * Redistributions in binary form must reproduce the above copyright notice, \
014     this list of conditions and the following disclaimer in the documentation \
015     and/or other materials provided with the distribution.
016   * Neither the name of HL7 nor the names of its contributors may be used to 
017     endorse or promote products derived from this software without specific 
018     prior written permission.
019  
020  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
021  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
022  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
023  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
024  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
025  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
026  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
027  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
028  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
029  POSSIBILITY OF SUCH DAMAGE.
030  */
031
032// Generated on Thu, Mar 23, 2023 19:59+1100 for FHIR v5.0.0
033
034import java.util.ArrayList;
035import java.util.Date;
036import java.util.List;
037import java.math.*;
038import org.hl7.fhir.utilities.Utilities;
039import org.hl7.fhir.r5.model.Enumerations.*;
040import org.hl7.fhir.instance.model.api.IBaseDatatypeElement;
041import org.hl7.fhir.exceptions.FHIRException;
042import org.hl7.fhir.instance.model.api.ICompositeType;
043import ca.uhn.fhir.model.api.annotation.Child;
044import ca.uhn.fhir.model.api.annotation.ChildOrder;
045import ca.uhn.fhir.model.api.annotation.DatatypeDef;
046import ca.uhn.fhir.model.api.annotation.Description;
047import ca.uhn.fhir.model.api.annotation.Block;
048
049/**
050 * Timing Type: Specifies an event that may occur multiple times. Timing schedules are used to record when things are planned, 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, and may be used for reporting the schedule to which past regular activities were carried out.
051 */
052@DatatypeDef(name="Timing")
053public class Timing extends BackboneType implements ICompositeType {
054
055    public enum EventTiming {
056        /**
057         * Event occurs during the morning. The exact time is unspecified and established by institution convention or patient interpretation.
058         */
059        MORN, 
060        /**
061         * Event occurs during the early morning. The exact time is unspecified and established by institution convention or patient interpretation.
062         */
063        MORN_EARLY, 
064        /**
065         * Event occurs during the late morning. The exact time is unspecified and established by institution convention or patient interpretation.
066         */
067        MORN_LATE, 
068        /**
069         * Event occurs around 12:00pm. The exact time is unspecified and established by institution convention or patient interpretation.
070         */
071        NOON, 
072        /**
073         * Event occurs during the afternoon. The exact time is unspecified and established by institution convention or patient interpretation.
074         */
075        AFT, 
076        /**
077         * Event occurs during the early afternoon. The exact time is unspecified and established by institution convention or patient interpretation.
078         */
079        AFT_EARLY, 
080        /**
081         * Event occurs during the late afternoon. The exact time is unspecified and established by institution convention or patient interpretation.
082         */
083        AFT_LATE, 
084        /**
085         * Event occurs during the evening. The exact time is unspecified and established by institution convention or patient interpretation.
086         */
087        EVE, 
088        /**
089         * Event occurs during the early evening. The exact time is unspecified and established by institution convention or patient interpretation.
090         */
091        EVE_EARLY, 
092        /**
093         * Event occurs during the late evening. The exact time is unspecified and established by institution convention or patient interpretation.
094         */
095        EVE_LATE, 
096        /**
097         * Event occurs during the night. The exact time is unspecified and established by institution convention or patient interpretation.
098         */
099        NIGHT, 
100        /**
101         * Event occurs [offset] after subject goes to sleep. The exact time is unspecified and established by institution convention or patient interpretation.
102         */
103        PHS, 
104        /**
105         * Event occurs a single time (with no repetitions) as soon as possible after the scheduled or actual start of the overall event.
106         */
107        IMD, 
108        /**
109         * 
110         */
111        HS, 
112        /**
113         * 
114         */
115        WAKE, 
116        /**
117         * 
118         */
119        C, 
120        /**
121         * 
122         */
123        CM, 
124        /**
125         * 
126         */
127        CD, 
128        /**
129         * 
130         */
131        CV, 
132        /**
133         * 
134         */
135        AC, 
136        /**
137         * 
138         */
139        ACM, 
140        /**
141         * 
142         */
143        ACD, 
144        /**
145         * 
146         */
147        ACV, 
148        /**
149         * 
150         */
151        PC, 
152        /**
153         * 
154         */
155        PCM, 
156        /**
157         * 
158         */
159        PCD, 
160        /**
161         * 
162         */
163        PCV, 
164        /**
165         * added to help the parsers with the generic types
166         */
167        NULL;
168        public static EventTiming fromCode(String codeString) throws FHIRException {
169            if (codeString == null || "".equals(codeString))
170                return null;
171        if ("MORN".equals(codeString))
172          return MORN;
173        if ("MORN.early".equals(codeString))
174          return MORN_EARLY;
175        if ("MORN.late".equals(codeString))
176          return MORN_LATE;
177        if ("NOON".equals(codeString))
178          return NOON;
179        if ("AFT".equals(codeString))
180          return AFT;
181        if ("AFT.early".equals(codeString))
182          return AFT_EARLY;
183        if ("AFT.late".equals(codeString))
184          return AFT_LATE;
185        if ("EVE".equals(codeString))
186          return EVE;
187        if ("EVE.early".equals(codeString))
188          return EVE_EARLY;
189        if ("EVE.late".equals(codeString))
190          return EVE_LATE;
191        if ("NIGHT".equals(codeString))
192          return NIGHT;
193        if ("PHS".equals(codeString))
194          return PHS;
195        if ("IMD".equals(codeString))
196          return IMD;
197        if ("HS".equals(codeString))
198          return HS;
199        if ("WAKE".equals(codeString))
200          return WAKE;
201        if ("C".equals(codeString))
202          return C;
203        if ("CM".equals(codeString))
204          return CM;
205        if ("CD".equals(codeString))
206          return CD;
207        if ("CV".equals(codeString))
208          return CV;
209        if ("AC".equals(codeString))
210          return AC;
211        if ("ACM".equals(codeString))
212          return ACM;
213        if ("ACD".equals(codeString))
214          return ACD;
215        if ("ACV".equals(codeString))
216          return ACV;
217        if ("PC".equals(codeString))
218          return PC;
219        if ("PCM".equals(codeString))
220          return PCM;
221        if ("PCD".equals(codeString))
222          return PCD;
223        if ("PCV".equals(codeString))
224          return PCV;
225        if (Configuration.isAcceptInvalidEnums())
226          return null;
227        else
228          throw new FHIRException("Unknown EventTiming code '"+codeString+"'");
229        }
230        public String toCode() {
231          switch (this) {
232            case MORN: return "MORN";
233            case MORN_EARLY: return "MORN.early";
234            case MORN_LATE: return "MORN.late";
235            case NOON: return "NOON";
236            case AFT: return "AFT";
237            case AFT_EARLY: return "AFT.early";
238            case AFT_LATE: return "AFT.late";
239            case EVE: return "EVE";
240            case EVE_EARLY: return "EVE.early";
241            case EVE_LATE: return "EVE.late";
242            case NIGHT: return "NIGHT";
243            case PHS: return "PHS";
244            case IMD: return "IMD";
245            case HS: return "HS";
246            case WAKE: return "WAKE";
247            case C: return "C";
248            case CM: return "CM";
249            case CD: return "CD";
250            case CV: return "CV";
251            case AC: return "AC";
252            case ACM: return "ACM";
253            case ACD: return "ACD";
254            case ACV: return "ACV";
255            case PC: return "PC";
256            case PCM: return "PCM";
257            case PCD: return "PCD";
258            case PCV: return "PCV";
259            case NULL: return null;
260            default: return "?";
261          }
262        }
263        public String getSystem() {
264          switch (this) {
265            case MORN: return "http://hl7.org/fhir/event-timing";
266            case MORN_EARLY: return "http://hl7.org/fhir/event-timing";
267            case MORN_LATE: return "http://hl7.org/fhir/event-timing";
268            case NOON: return "http://hl7.org/fhir/event-timing";
269            case AFT: return "http://hl7.org/fhir/event-timing";
270            case AFT_EARLY: return "http://hl7.org/fhir/event-timing";
271            case AFT_LATE: return "http://hl7.org/fhir/event-timing";
272            case EVE: return "http://hl7.org/fhir/event-timing";
273            case EVE_EARLY: return "http://hl7.org/fhir/event-timing";
274            case EVE_LATE: return "http://hl7.org/fhir/event-timing";
275            case NIGHT: return "http://hl7.org/fhir/event-timing";
276            case PHS: return "http://hl7.org/fhir/event-timing";
277            case IMD: return "http://hl7.org/fhir/event-timing";
278            case HS: return "http://terminology.hl7.org/CodeSystem/v3-TimingEvent";
279            case WAKE: return "http://terminology.hl7.org/CodeSystem/v3-TimingEvent";
280            case C: return "http://terminology.hl7.org/CodeSystem/v3-TimingEvent";
281            case CM: return "http://terminology.hl7.org/CodeSystem/v3-TimingEvent";
282            case CD: return "http://terminology.hl7.org/CodeSystem/v3-TimingEvent";
283            case CV: return "http://terminology.hl7.org/CodeSystem/v3-TimingEvent";
284            case AC: return "http://terminology.hl7.org/CodeSystem/v3-TimingEvent";
285            case ACM: return "http://terminology.hl7.org/CodeSystem/v3-TimingEvent";
286            case ACD: return "http://terminology.hl7.org/CodeSystem/v3-TimingEvent";
287            case ACV: return "http://terminology.hl7.org/CodeSystem/v3-TimingEvent";
288            case PC: return "http://terminology.hl7.org/CodeSystem/v3-TimingEvent";
289            case PCM: return "http://terminology.hl7.org/CodeSystem/v3-TimingEvent";
290            case PCD: return "http://terminology.hl7.org/CodeSystem/v3-TimingEvent";
291            case PCV: return "http://terminology.hl7.org/CodeSystem/v3-TimingEvent";
292            case NULL: return null;
293            default: return "?";
294          }
295        }
296        public String getDefinition() {
297          switch (this) {
298            case MORN: return "Event occurs during the morning. The exact time is unspecified and established by institution convention or patient interpretation.";
299            case MORN_EARLY: return "Event occurs during the early morning. The exact time is unspecified and established by institution convention or patient interpretation.";
300            case MORN_LATE: return "Event occurs during the late morning. The exact time is unspecified and established by institution convention or patient interpretation.";
301            case NOON: return "Event occurs around 12:00pm. The exact time is unspecified and established by institution convention or patient interpretation.";
302            case AFT: return "Event occurs during the afternoon. The exact time is unspecified and established by institution convention or patient interpretation.";
303            case AFT_EARLY: return "Event occurs during the early afternoon. The exact time is unspecified and established by institution convention or patient interpretation.";
304            case AFT_LATE: return "Event occurs during the late afternoon. The exact time is unspecified and established by institution convention or patient interpretation.";
305            case EVE: return "Event occurs during the evening. The exact time is unspecified and established by institution convention or patient interpretation.";
306            case EVE_EARLY: return "Event occurs during the early evening. The exact time is unspecified and established by institution convention or patient interpretation.";
307            case EVE_LATE: return "Event occurs during the late evening. The exact time is unspecified and established by institution convention or patient interpretation.";
308            case NIGHT: return "Event occurs during the night. The exact time is unspecified and established by institution convention or patient interpretation.";
309            case PHS: return "Event occurs [offset] after subject goes to sleep. The exact time is unspecified and established by institution convention or patient interpretation.";
310            case IMD: return "Event occurs a single time (with no repetitions) as soon as possible after the scheduled or actual start of the overall event.";
311            case HS: return "";
312            case WAKE: return "";
313            case C: return "";
314            case CM: return "";
315            case CD: return "";
316            case CV: return "";
317            case AC: return "";
318            case ACM: return "";
319            case ACD: return "";
320            case ACV: return "";
321            case PC: return "";
322            case PCM: return "";
323            case PCD: return "";
324            case PCV: return "";
325            case NULL: return null;
326            default: return "?";
327          }
328        }
329        public String getDisplay() {
330          switch (this) {
331            case MORN: return "Morning";
332            case MORN_EARLY: return "Early Morning";
333            case MORN_LATE: return "Late Morning";
334            case NOON: return "Noon";
335            case AFT: return "Afternoon";
336            case AFT_EARLY: return "Early Afternoon";
337            case AFT_LATE: return "Late Afternoon";
338            case EVE: return "Evening";
339            case EVE_EARLY: return "Early Evening";
340            case EVE_LATE: return "Late Evening";
341            case NIGHT: return "Night";
342            case PHS: return "After Sleep";
343            case IMD: return "Immediate";
344            case HS: return "HS";
345            case WAKE: return "WAKE";
346            case C: return "C";
347            case CM: return "CM";
348            case CD: return "CD";
349            case CV: return "CV";
350            case AC: return "AC";
351            case ACM: return "ACM";
352            case ACD: return "ACD";
353            case ACV: return "ACV";
354            case PC: return "PC";
355            case PCM: return "PCM";
356            case PCD: return "PCD";
357            case PCV: return "PCV";
358            case NULL: return null;
359            default: return "?";
360          }
361        }
362    }
363
364  public static class EventTimingEnumFactory implements EnumFactory<EventTiming> {
365    public EventTiming fromCode(String codeString) throws IllegalArgumentException {
366      if (codeString == null || "".equals(codeString))
367            if (codeString == null || "".equals(codeString))
368                return null;
369        if ("MORN".equals(codeString))
370          return EventTiming.MORN;
371        if ("MORN.early".equals(codeString))
372          return EventTiming.MORN_EARLY;
373        if ("MORN.late".equals(codeString))
374          return EventTiming.MORN_LATE;
375        if ("NOON".equals(codeString))
376          return EventTiming.NOON;
377        if ("AFT".equals(codeString))
378          return EventTiming.AFT;
379        if ("AFT.early".equals(codeString))
380          return EventTiming.AFT_EARLY;
381        if ("AFT.late".equals(codeString))
382          return EventTiming.AFT_LATE;
383        if ("EVE".equals(codeString))
384          return EventTiming.EVE;
385        if ("EVE.early".equals(codeString))
386          return EventTiming.EVE_EARLY;
387        if ("EVE.late".equals(codeString))
388          return EventTiming.EVE_LATE;
389        if ("NIGHT".equals(codeString))
390          return EventTiming.NIGHT;
391        if ("PHS".equals(codeString))
392          return EventTiming.PHS;
393        if ("IMD".equals(codeString))
394          return EventTiming.IMD;
395        if ("HS".equals(codeString))
396          return EventTiming.HS;
397        if ("WAKE".equals(codeString))
398          return EventTiming.WAKE;
399        if ("C".equals(codeString))
400          return EventTiming.C;
401        if ("CM".equals(codeString))
402          return EventTiming.CM;
403        if ("CD".equals(codeString))
404          return EventTiming.CD;
405        if ("CV".equals(codeString))
406          return EventTiming.CV;
407        if ("AC".equals(codeString))
408          return EventTiming.AC;
409        if ("ACM".equals(codeString))
410          return EventTiming.ACM;
411        if ("ACD".equals(codeString))
412          return EventTiming.ACD;
413        if ("ACV".equals(codeString))
414          return EventTiming.ACV;
415        if ("PC".equals(codeString))
416          return EventTiming.PC;
417        if ("PCM".equals(codeString))
418          return EventTiming.PCM;
419        if ("PCD".equals(codeString))
420          return EventTiming.PCD;
421        if ("PCV".equals(codeString))
422          return EventTiming.PCV;
423        throw new IllegalArgumentException("Unknown EventTiming code '"+codeString+"'");
424        }
425        public Enumeration<EventTiming> fromType(PrimitiveType<?> code) throws FHIRException {
426          if (code == null)
427            return null;
428          if (code.isEmpty())
429            return new Enumeration<EventTiming>(this, EventTiming.NULL, code);
430          String codeString = ((PrimitiveType) code).asStringValue();
431          if (codeString == null || "".equals(codeString))
432            return new Enumeration<EventTiming>(this, EventTiming.NULL, code);
433        if ("MORN".equals(codeString))
434          return new Enumeration<EventTiming>(this, EventTiming.MORN, code);
435        if ("MORN.early".equals(codeString))
436          return new Enumeration<EventTiming>(this, EventTiming.MORN_EARLY, code);
437        if ("MORN.late".equals(codeString))
438          return new Enumeration<EventTiming>(this, EventTiming.MORN_LATE, code);
439        if ("NOON".equals(codeString))
440          return new Enumeration<EventTiming>(this, EventTiming.NOON, code);
441        if ("AFT".equals(codeString))
442          return new Enumeration<EventTiming>(this, EventTiming.AFT, code);
443        if ("AFT.early".equals(codeString))
444          return new Enumeration<EventTiming>(this, EventTiming.AFT_EARLY, code);
445        if ("AFT.late".equals(codeString))
446          return new Enumeration<EventTiming>(this, EventTiming.AFT_LATE, code);
447        if ("EVE".equals(codeString))
448          return new Enumeration<EventTiming>(this, EventTiming.EVE, code);
449        if ("EVE.early".equals(codeString))
450          return new Enumeration<EventTiming>(this, EventTiming.EVE_EARLY, code);
451        if ("EVE.late".equals(codeString))
452          return new Enumeration<EventTiming>(this, EventTiming.EVE_LATE, code);
453        if ("NIGHT".equals(codeString))
454          return new Enumeration<EventTiming>(this, EventTiming.NIGHT, code);
455        if ("PHS".equals(codeString))
456          return new Enumeration<EventTiming>(this, EventTiming.PHS, code);
457        if ("IMD".equals(codeString))
458          return new Enumeration<EventTiming>(this, EventTiming.IMD, code);
459        if ("HS".equals(codeString))
460          return new Enumeration<EventTiming>(this, EventTiming.HS, code);
461        if ("WAKE".equals(codeString))
462          return new Enumeration<EventTiming>(this, EventTiming.WAKE, code);
463        if ("C".equals(codeString))
464          return new Enumeration<EventTiming>(this, EventTiming.C, code);
465        if ("CM".equals(codeString))
466          return new Enumeration<EventTiming>(this, EventTiming.CM, code);
467        if ("CD".equals(codeString))
468          return new Enumeration<EventTiming>(this, EventTiming.CD, code);
469        if ("CV".equals(codeString))
470          return new Enumeration<EventTiming>(this, EventTiming.CV, code);
471        if ("AC".equals(codeString))
472          return new Enumeration<EventTiming>(this, EventTiming.AC, code);
473        if ("ACM".equals(codeString))
474          return new Enumeration<EventTiming>(this, EventTiming.ACM, code);
475        if ("ACD".equals(codeString))
476          return new Enumeration<EventTiming>(this, EventTiming.ACD, code);
477        if ("ACV".equals(codeString))
478          return new Enumeration<EventTiming>(this, EventTiming.ACV, code);
479        if ("PC".equals(codeString))
480          return new Enumeration<EventTiming>(this, EventTiming.PC, code);
481        if ("PCM".equals(codeString))
482          return new Enumeration<EventTiming>(this, EventTiming.PCM, code);
483        if ("PCD".equals(codeString))
484          return new Enumeration<EventTiming>(this, EventTiming.PCD, code);
485        if ("PCV".equals(codeString))
486          return new Enumeration<EventTiming>(this, EventTiming.PCV, code);
487        throw new FHIRException("Unknown EventTiming code '"+codeString+"'");
488        }
489    public String toCode(EventTiming code) {
490      if (code == EventTiming.MORN)
491        return "MORN";
492      if (code == EventTiming.MORN_EARLY)
493        return "MORN.early";
494      if (code == EventTiming.MORN_LATE)
495        return "MORN.late";
496      if (code == EventTiming.NOON)
497        return "NOON";
498      if (code == EventTiming.AFT)
499        return "AFT";
500      if (code == EventTiming.AFT_EARLY)
501        return "AFT.early";
502      if (code == EventTiming.AFT_LATE)
503        return "AFT.late";
504      if (code == EventTiming.EVE)
505        return "EVE";
506      if (code == EventTiming.EVE_EARLY)
507        return "EVE.early";
508      if (code == EventTiming.EVE_LATE)
509        return "EVE.late";
510      if (code == EventTiming.NIGHT)
511        return "NIGHT";
512      if (code == EventTiming.PHS)
513        return "PHS";
514      if (code == EventTiming.IMD)
515        return "IMD";
516      if (code == EventTiming.HS)
517        return "HS";
518      if (code == EventTiming.WAKE)
519        return "WAKE";
520      if (code == EventTiming.C)
521        return "C";
522      if (code == EventTiming.CM)
523        return "CM";
524      if (code == EventTiming.CD)
525        return "CD";
526      if (code == EventTiming.CV)
527        return "CV";
528      if (code == EventTiming.AC)
529        return "AC";
530      if (code == EventTiming.ACM)
531        return "ACM";
532      if (code == EventTiming.ACD)
533        return "ACD";
534      if (code == EventTiming.ACV)
535        return "ACV";
536      if (code == EventTiming.PC)
537        return "PC";
538      if (code == EventTiming.PCM)
539        return "PCM";
540      if (code == EventTiming.PCD)
541        return "PCD";
542      if (code == EventTiming.PCV)
543        return "PCV";
544      return "?";
545      }
546    public String toSystem(EventTiming code) {
547      return code.getSystem();
548      }
549    }
550
551    public enum UnitsOfTime {
552        /**
553         * 
554         */
555        S, 
556        /**
557         * 
558         */
559        MIN, 
560        /**
561         * 
562         */
563        H, 
564        /**
565         * 
566         */
567        D, 
568        /**
569         * 
570         */
571        WK, 
572        /**
573         * 
574         */
575        MO, 
576        /**
577         * 
578         */
579        A, 
580        /**
581         * added to help the parsers with the generic types
582         */
583        NULL;
584        public static UnitsOfTime fromCode(String codeString) throws FHIRException {
585            if (codeString == null || "".equals(codeString))
586                return null;
587        if ("s".equals(codeString))
588          return S;
589        if ("min".equals(codeString))
590          return MIN;
591        if ("h".equals(codeString))
592          return H;
593        if ("d".equals(codeString))
594          return D;
595        if ("wk".equals(codeString))
596          return WK;
597        if ("mo".equals(codeString))
598          return MO;
599        if ("a".equals(codeString))
600          return A;
601        if (Configuration.isAcceptInvalidEnums())
602          return null;
603        else
604          throw new FHIRException("Unknown UnitsOfTime code '"+codeString+"'");
605        }
606        public String toCode() {
607          switch (this) {
608            case S: return "s";
609            case MIN: return "min";
610            case H: return "h";
611            case D: return "d";
612            case WK: return "wk";
613            case MO: return "mo";
614            case A: return "a";
615            case NULL: return null;
616            default: return "?";
617          }
618        }
619        public String getSystem() {
620          switch (this) {
621            case S: return "http://unitsofmeasure.org";
622            case MIN: return "http://unitsofmeasure.org";
623            case H: return "http://unitsofmeasure.org";
624            case D: return "http://unitsofmeasure.org";
625            case WK: return "http://unitsofmeasure.org";
626            case MO: return "http://unitsofmeasure.org";
627            case A: return "http://unitsofmeasure.org";
628            case NULL: return null;
629            default: return "?";
630          }
631        }
632        public String getDefinition() {
633          switch (this) {
634            case S: return "";
635            case MIN: return "";
636            case H: return "";
637            case D: return "";
638            case WK: return "";
639            case MO: return "";
640            case A: return "";
641            case NULL: return null;
642            default: return "?";
643          }
644        }
645        public String getDisplay() {
646          switch (this) {
647            case S: return "?";
648            case MIN: return "??";
649            case H: return "??";
650            case D: return "?";
651            case WK: return "??";
652            case MO: return "?";
653            case A: return "?";
654            case NULL: return null;
655            default: return "?";
656          }
657        }
658    }
659
660  public static class UnitsOfTimeEnumFactory implements EnumFactory<UnitsOfTime> {
661    public UnitsOfTime fromCode(String codeString) throws IllegalArgumentException {
662      if (codeString == null || "".equals(codeString))
663            if (codeString == null || "".equals(codeString))
664                return null;
665        if ("s".equals(codeString))
666          return UnitsOfTime.S;
667        if ("min".equals(codeString))
668          return UnitsOfTime.MIN;
669        if ("h".equals(codeString))
670          return UnitsOfTime.H;
671        if ("d".equals(codeString))
672          return UnitsOfTime.D;
673        if ("wk".equals(codeString))
674          return UnitsOfTime.WK;
675        if ("mo".equals(codeString))
676          return UnitsOfTime.MO;
677        if ("a".equals(codeString))
678          return UnitsOfTime.A;
679        throw new IllegalArgumentException("Unknown UnitsOfTime code '"+codeString+"'");
680        }
681        public Enumeration<UnitsOfTime> fromType(PrimitiveType<?> code) throws FHIRException {
682          if (code == null)
683            return null;
684          if (code.isEmpty())
685            return new Enumeration<UnitsOfTime>(this, UnitsOfTime.NULL, code);
686          String codeString = ((PrimitiveType) code).asStringValue();
687          if (codeString == null || "".equals(codeString))
688            return new Enumeration<UnitsOfTime>(this, UnitsOfTime.NULL, code);
689        if ("s".equals(codeString))
690          return new Enumeration<UnitsOfTime>(this, UnitsOfTime.S, code);
691        if ("min".equals(codeString))
692          return new Enumeration<UnitsOfTime>(this, UnitsOfTime.MIN, code);
693        if ("h".equals(codeString))
694          return new Enumeration<UnitsOfTime>(this, UnitsOfTime.H, code);
695        if ("d".equals(codeString))
696          return new Enumeration<UnitsOfTime>(this, UnitsOfTime.D, code);
697        if ("wk".equals(codeString))
698          return new Enumeration<UnitsOfTime>(this, UnitsOfTime.WK, code);
699        if ("mo".equals(codeString))
700          return new Enumeration<UnitsOfTime>(this, UnitsOfTime.MO, code);
701        if ("a".equals(codeString))
702          return new Enumeration<UnitsOfTime>(this, UnitsOfTime.A, code);
703        throw new FHIRException("Unknown UnitsOfTime code '"+codeString+"'");
704        }
705    public String toCode(UnitsOfTime code) {
706      if (code == UnitsOfTime.S)
707        return "s";
708      if (code == UnitsOfTime.MIN)
709        return "min";
710      if (code == UnitsOfTime.H)
711        return "h";
712      if (code == UnitsOfTime.D)
713        return "d";
714      if (code == UnitsOfTime.WK)
715        return "wk";
716      if (code == UnitsOfTime.MO)
717        return "mo";
718      if (code == UnitsOfTime.A)
719        return "a";
720      return "?";
721      }
722    public String toSystem(UnitsOfTime code) {
723      return code.getSystem();
724      }
725    }
726
727    @Block()
728    public static class TimingRepeatComponent extends Element implements IBaseDatatypeElement {
729        /**
730         * 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.
731         */
732        @Child(name = "bounds", type = {Duration.class, Range.class, Period.class}, order=1, min=0, max=1, modifier=false, summary=true)
733        @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." )
734        protected DataType bounds;
735
736        /**
737         * A total count of the desired number of repetitions across the duration of the entire timing specification. If countMax is present, this element indicates the lower bound of the allowed range of count values.
738         */
739        @Child(name = "count", type = {PositiveIntType.class}, order=2, min=0, max=1, modifier=false, summary=true)
740        @Description(shortDefinition="Number of times to repeat", formalDefinition="A total count of the desired number of repetitions across the duration of the entire timing specification. If countMax is present, this element indicates the lower bound of the allowed range of count values." )
741        protected PositiveIntType count;
742
743        /**
744         * If present, indicates that the count is a range - so to perform the action between [count] and [countMax] times.
745         */
746        @Child(name = "countMax", type = {PositiveIntType.class}, order=3, min=0, max=1, modifier=false, summary=true)
747        @Description(shortDefinition="Maximum number of times to repeat", formalDefinition="If present, indicates that the count is a range - so to perform the action between [count] and [countMax] times." )
748        protected PositiveIntType countMax;
749
750        /**
751         * How long this thing happens for when it happens. If durationMax is present, this element indicates the lower bound of the allowed range of the duration.
752         */
753        @Child(name = "duration", type = {DecimalType.class}, order=4, min=0, max=1, modifier=false, summary=true)
754        @Description(shortDefinition="How long when it happens", formalDefinition="How long this thing happens for when it happens. If durationMax is present, this element indicates the lower bound of the allowed range of the duration." )
755        protected DecimalType duration;
756
757        /**
758         * If present, indicates that the duration is a range - so to perform the action between [duration] and [durationMax] time length.
759         */
760        @Child(name = "durationMax", type = {DecimalType.class}, order=5, min=0, max=1, modifier=false, summary=true)
761        @Description(shortDefinition="How long when it happens (Max)", formalDefinition="If present, indicates that the duration is a range - so to perform the action between [duration] and [durationMax] time length." )
762        protected DecimalType durationMax;
763
764        /**
765         * The units of time for the duration, in UCUM units
766Normal practice is to use the 'mo' code as a calendar month when calculating the next occurrence.
767         */
768        @Child(name = "durationUnit", type = {CodeType.class}, order=6, min=0, max=1, modifier=false, summary=true)
769        @Description(shortDefinition="s | min | h | d | wk | mo | a - unit of time (UCUM)", formalDefinition="The units of time for the duration, in UCUM units\nNormal practice is to use the 'mo' code as a calendar month when calculating the next occurrence." )
770        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/units-of-time")
771        protected Enumeration<UnitsOfTime> durationUnit;
772
773        /**
774         * The number of times to repeat the action within the specified period. If frequencyMax is present, this element indicates the lower bound of the allowed range of the frequency.
775         */
776        @Child(name = "frequency", type = {PositiveIntType.class}, order=7, min=0, max=1, modifier=false, summary=true)
777        @Description(shortDefinition="Indicates the number of repetitions that should occur within a period. I.e. Event occurs frequency times per period", formalDefinition="The number of times to repeat the action within the specified period. If frequencyMax is present, this element indicates the lower bound of the allowed range of the frequency." )
778        protected PositiveIntType frequency;
779
780        /**
781         * If present, indicates that the frequency is a range - so to repeat between [frequency] and [frequencyMax] times within the period or period range.
782         */
783        @Child(name = "frequencyMax", type = {PositiveIntType.class}, order=8, min=0, max=1, modifier=false, summary=true)
784        @Description(shortDefinition="Event occurs up to frequencyMax times per period", formalDefinition="If present, indicates that the frequency is a range - so to repeat between [frequency] and [frequencyMax] times within the period or period range." )
785        protected PositiveIntType frequencyMax;
786
787        /**
788         * 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. If periodMax is present, this element indicates the lower bound of the allowed range of the period length.
789         */
790        @Child(name = "period", type = {DecimalType.class}, order=9, min=0, max=1, modifier=false, summary=true)
791        @Description(shortDefinition="The duration to which the frequency applies. I.e. 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. If periodMax is present, this element indicates the lower bound of the allowed range of the period length." )
792        protected DecimalType period;
793
794        /**
795         * 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.
796         */
797        @Child(name = "periodMax", type = {DecimalType.class}, order=10, min=0, max=1, modifier=false, summary=true)
798        @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." )
799        protected DecimalType periodMax;
800
801        /**
802         * The units of time for the period in UCUM units
803Normal practice is to use the 'mo' code as a calendar month when calculating the next occurrence.
804         */
805        @Child(name = "periodUnit", type = {CodeType.class}, order=11, min=0, max=1, modifier=false, summary=true)
806        @Description(shortDefinition="s | min | h | d | wk | mo | a - unit of time (UCUM)", formalDefinition="The units of time for the period in UCUM units\nNormal practice is to use the 'mo' code as a calendar month when calculating the next occurrence." )
807        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/units-of-time")
808        protected Enumeration<UnitsOfTime> periodUnit;
809
810        /**
811         * If one or more days of week is provided, then the action happens only on the specified day(s).
812         */
813        @Child(name = "dayOfWeek", type = {CodeType.class}, order=12, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
814        @Description(shortDefinition="mon | tue | wed | thu | fri | sat | sun", formalDefinition="If one or more days of week is provided, then the action happens only on the specified day(s)." )
815        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/days-of-week")
816        protected List<Enumeration<DaysOfWeek>> dayOfWeek;
817
818        /**
819         * Specified time of day for action to take place.
820         */
821        @Child(name = "timeOfDay", type = {TimeType.class}, order=13, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
822        @Description(shortDefinition="Time of day for action", formalDefinition="Specified time of day for action to take place." )
823        protected List<TimeType> timeOfDay;
824
825        /**
826         * An approximate time period during the day, potentially linked to an event of daily living that indicates when the action should occur.
827         */
828        @Child(name = "when", type = {CodeType.class}, order=14, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
829        @Description(shortDefinition="Code for time period of occurrence", formalDefinition="An approximate time period during the day, potentially linked to an event of daily living that indicates when the action should occur." )
830        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/event-timing")
831        protected List<Enumeration<EventTiming>> when;
832
833        /**
834         * The number of minutes from the event. If the event code does not indicate whether the minutes is before or after the event, then the offset is assumed to be after the event.
835         */
836        @Child(name = "offset", type = {UnsignedIntType.class}, order=15, min=0, max=1, modifier=false, summary=true)
837        @Description(shortDefinition="Minutes from event (before or after)", formalDefinition="The number of minutes from the event. If the event code does not indicate whether the minutes is before or after the event, then the offset is assumed to be after the event." )
838        protected UnsignedIntType offset;
839
840        private static final long serialVersionUID = -122116223L;
841
842    /**
843     * Constructor
844     */
845      public TimingRepeatComponent() {
846        super();
847      }
848
849        /**
850         * @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.)
851         */
852        public DataType getBounds() { 
853          return this.bounds;
854        }
855
856        /**
857         * @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.)
858         */
859        public Duration getBoundsDuration() throws FHIRException { 
860          if (this.bounds == null)
861            this.bounds = new Duration();
862          if (!(this.bounds instanceof Duration))
863            throw new FHIRException("Type mismatch: the type Duration was expected, but "+this.bounds.getClass().getName()+" was encountered");
864          return (Duration) this.bounds;
865        }
866
867        public boolean hasBoundsDuration() { 
868          return this != null && this.bounds instanceof Duration;
869        }
870
871        /**
872         * @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.)
873         */
874        public Range getBoundsRange() throws FHIRException { 
875          if (this.bounds == null)
876            this.bounds = new Range();
877          if (!(this.bounds instanceof Range))
878            throw new FHIRException("Type mismatch: the type Range was expected, but "+this.bounds.getClass().getName()+" was encountered");
879          return (Range) this.bounds;
880        }
881
882        public boolean hasBoundsRange() { 
883          return this != null && this.bounds instanceof Range;
884        }
885
886        /**
887         * @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.)
888         */
889        public Period getBoundsPeriod() throws FHIRException { 
890          if (this.bounds == null)
891            this.bounds = new Period();
892          if (!(this.bounds instanceof Period))
893            throw new FHIRException("Type mismatch: the type Period was expected, but "+this.bounds.getClass().getName()+" was encountered");
894          return (Period) this.bounds;
895        }
896
897        public boolean hasBoundsPeriod() { 
898          return this != null && this.bounds instanceof Period;
899        }
900
901        public boolean hasBounds() { 
902          return this.bounds != null && !this.bounds.isEmpty();
903        }
904
905        /**
906         * @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.)
907         */
908        public TimingRepeatComponent setBounds(DataType value) { 
909          if (value != null && !(value instanceof Duration || value instanceof Range || value instanceof Period))
910            throw new FHIRException("Not the right type for Timing.repeat.bounds[x]: "+value.fhirType());
911          this.bounds = value;
912          return this;
913        }
914
915        /**
916         * @return {@link #count} (A total count of the desired number of repetitions across the duration of the entire timing specification. If countMax is present, this element indicates the lower bound of the allowed range of count values.). This is the underlying object with id, value and extensions. The accessor "getCount" gives direct access to the value
917         */
918        public PositiveIntType getCountElement() { 
919          if (this.count == null)
920            if (Configuration.errorOnAutoCreate())
921              throw new Error("Attempt to auto-create TimingRepeatComponent.count");
922            else if (Configuration.doAutoCreate())
923              this.count = new PositiveIntType(); // bb
924          return this.count;
925        }
926
927        public boolean hasCountElement() { 
928          return this.count != null && !this.count.isEmpty();
929        }
930
931        public boolean hasCount() { 
932          return this.count != null && !this.count.isEmpty();
933        }
934
935        /**
936         * @param value {@link #count} (A total count of the desired number of repetitions across the duration of the entire timing specification. If countMax is present, this element indicates the lower bound of the allowed range of count values.). This is the underlying object with id, value and extensions. The accessor "getCount" gives direct access to the value
937         */
938        public TimingRepeatComponent setCountElement(PositiveIntType value) { 
939          this.count = value;
940          return this;
941        }
942
943        /**
944         * @return A total count of the desired number of repetitions across the duration of the entire timing specification. If countMax is present, this element indicates the lower bound of the allowed range of count values.
945         */
946        public int getCount() { 
947          return this.count == null || this.count.isEmpty() ? 0 : this.count.getValue();
948        }
949
950        /**
951         * @param value A total count of the desired number of repetitions across the duration of the entire timing specification. If countMax is present, this element indicates the lower bound of the allowed range of count values.
952         */
953        public TimingRepeatComponent setCount(int value) { 
954            if (this.count == null)
955              this.count = new PositiveIntType();
956            this.count.setValue(value);
957          return this;
958        }
959
960        /**
961         * @return {@link #countMax} (If present, indicates that the count is a range - so to perform the action between [count] and [countMax] times.). This is the underlying object with id, value and extensions. The accessor "getCountMax" gives direct access to the value
962         */
963        public PositiveIntType getCountMaxElement() { 
964          if (this.countMax == null)
965            if (Configuration.errorOnAutoCreate())
966              throw new Error("Attempt to auto-create TimingRepeatComponent.countMax");
967            else if (Configuration.doAutoCreate())
968              this.countMax = new PositiveIntType(); // bb
969          return this.countMax;
970        }
971
972        public boolean hasCountMaxElement() { 
973          return this.countMax != null && !this.countMax.isEmpty();
974        }
975
976        public boolean hasCountMax() { 
977          return this.countMax != null && !this.countMax.isEmpty();
978        }
979
980        /**
981         * @param value {@link #countMax} (If present, indicates that the count is a range - so to perform the action between [count] and [countMax] times.). This is the underlying object with id, value and extensions. The accessor "getCountMax" gives direct access to the value
982         */
983        public TimingRepeatComponent setCountMaxElement(PositiveIntType value) { 
984          this.countMax = value;
985          return this;
986        }
987
988        /**
989         * @return If present, indicates that the count is a range - so to perform the action between [count] and [countMax] times.
990         */
991        public int getCountMax() { 
992          return this.countMax == null || this.countMax.isEmpty() ? 0 : this.countMax.getValue();
993        }
994
995        /**
996         * @param value If present, indicates that the count is a range - so to perform the action between [count] and [countMax] times.
997         */
998        public TimingRepeatComponent setCountMax(int value) { 
999            if (this.countMax == null)
1000              this.countMax = new PositiveIntType();
1001            this.countMax.setValue(value);
1002          return this;
1003        }
1004
1005        /**
1006         * @return {@link #duration} (How long this thing happens for when it happens. If durationMax is present, this element indicates the lower bound of the allowed range of the duration.). This is the underlying object with id, value and extensions. The accessor "getDuration" gives direct access to the value
1007         */
1008        public DecimalType getDurationElement() { 
1009          if (this.duration == null)
1010            if (Configuration.errorOnAutoCreate())
1011              throw new Error("Attempt to auto-create TimingRepeatComponent.duration");
1012            else if (Configuration.doAutoCreate())
1013              this.duration = new DecimalType(); // bb
1014          return this.duration;
1015        }
1016
1017        public boolean hasDurationElement() { 
1018          return this.duration != null && !this.duration.isEmpty();
1019        }
1020
1021        public boolean hasDuration() { 
1022          return this.duration != null && !this.duration.isEmpty();
1023        }
1024
1025        /**
1026         * @param value {@link #duration} (How long this thing happens for when it happens. If durationMax is present, this element indicates the lower bound of the allowed range of the duration.). This is the underlying object with id, value and extensions. The accessor "getDuration" gives direct access to the value
1027         */
1028        public TimingRepeatComponent setDurationElement(DecimalType value) { 
1029          this.duration = value;
1030          return this;
1031        }
1032
1033        /**
1034         * @return How long this thing happens for when it happens. If durationMax is present, this element indicates the lower bound of the allowed range of the duration.
1035         */
1036        public BigDecimal getDuration() { 
1037          return this.duration == null ? null : this.duration.getValue();
1038        }
1039
1040        /**
1041         * @param value How long this thing happens for when it happens. If durationMax is present, this element indicates the lower bound of the allowed range of the duration.
1042         */
1043        public TimingRepeatComponent setDuration(BigDecimal value) { 
1044          if (value == null)
1045            this.duration = null;
1046          else {
1047            if (this.duration == null)
1048              this.duration = new DecimalType();
1049            this.duration.setValue(value);
1050          }
1051          return this;
1052        }
1053
1054        /**
1055         * @param value How long this thing happens for when it happens. If durationMax is present, this element indicates the lower bound of the allowed range of the duration.
1056         */
1057        public TimingRepeatComponent setDuration(long value) { 
1058              this.duration = new DecimalType();
1059            this.duration.setValue(value);
1060          return this;
1061        }
1062
1063        /**
1064         * @param value How long this thing happens for when it happens. If durationMax is present, this element indicates the lower bound of the allowed range of the duration.
1065         */
1066        public TimingRepeatComponent setDuration(double value) { 
1067              this.duration = new DecimalType();
1068            this.duration.setValue(value);
1069          return this;
1070        }
1071
1072        /**
1073         * @return {@link #durationMax} (If present, indicates that the duration is a range - so to perform the action between [duration] and [durationMax] time length.). This is the underlying object with id, value and extensions. The accessor "getDurationMax" gives direct access to the value
1074         */
1075        public DecimalType getDurationMaxElement() { 
1076          if (this.durationMax == null)
1077            if (Configuration.errorOnAutoCreate())
1078              throw new Error("Attempt to auto-create TimingRepeatComponent.durationMax");
1079            else if (Configuration.doAutoCreate())
1080              this.durationMax = new DecimalType(); // bb
1081          return this.durationMax;
1082        }
1083
1084        public boolean hasDurationMaxElement() { 
1085          return this.durationMax != null && !this.durationMax.isEmpty();
1086        }
1087
1088        public boolean hasDurationMax() { 
1089          return this.durationMax != null && !this.durationMax.isEmpty();
1090        }
1091
1092        /**
1093         * @param value {@link #durationMax} (If present, indicates that the duration is a range - so to perform the action between [duration] and [durationMax] time length.). This is the underlying object with id, value and extensions. The accessor "getDurationMax" gives direct access to the value
1094         */
1095        public TimingRepeatComponent setDurationMaxElement(DecimalType value) { 
1096          this.durationMax = value;
1097          return this;
1098        }
1099
1100        /**
1101         * @return If present, indicates that the duration is a range - so to perform the action between [duration] and [durationMax] time length.
1102         */
1103        public BigDecimal getDurationMax() { 
1104          return this.durationMax == null ? null : this.durationMax.getValue();
1105        }
1106
1107        /**
1108         * @param value If present, indicates that the duration is a range - so to perform the action between [duration] and [durationMax] time length.
1109         */
1110        public TimingRepeatComponent setDurationMax(BigDecimal value) { 
1111          if (value == null)
1112            this.durationMax = null;
1113          else {
1114            if (this.durationMax == null)
1115              this.durationMax = new DecimalType();
1116            this.durationMax.setValue(value);
1117          }
1118          return this;
1119        }
1120
1121        /**
1122         * @param value If present, indicates that the duration is a range - so to perform the action between [duration] and [durationMax] time length.
1123         */
1124        public TimingRepeatComponent setDurationMax(long value) { 
1125              this.durationMax = new DecimalType();
1126            this.durationMax.setValue(value);
1127          return this;
1128        }
1129
1130        /**
1131         * @param value If present, indicates that the duration is a range - so to perform the action between [duration] and [durationMax] time length.
1132         */
1133        public TimingRepeatComponent setDurationMax(double value) { 
1134              this.durationMax = new DecimalType();
1135            this.durationMax.setValue(value);
1136          return this;
1137        }
1138
1139        /**
1140         * @return {@link #durationUnit} (The units of time for the duration, in UCUM units
1141Normal practice is to use the 'mo' code as a calendar month when calculating the next occurrence.). This is the underlying object with id, value and extensions. The accessor "getDurationUnit" gives direct access to the value
1142         */
1143        public Enumeration<UnitsOfTime> getDurationUnitElement() { 
1144          if (this.durationUnit == null)
1145            if (Configuration.errorOnAutoCreate())
1146              throw new Error("Attempt to auto-create TimingRepeatComponent.durationUnit");
1147            else if (Configuration.doAutoCreate())
1148              this.durationUnit = new Enumeration<UnitsOfTime>(new UnitsOfTimeEnumFactory()); // bb
1149          return this.durationUnit;
1150        }
1151
1152        public boolean hasDurationUnitElement() { 
1153          return this.durationUnit != null && !this.durationUnit.isEmpty();
1154        }
1155
1156        public boolean hasDurationUnit() { 
1157          return this.durationUnit != null && !this.durationUnit.isEmpty();
1158        }
1159
1160        /**
1161         * @param value {@link #durationUnit} (The units of time for the duration, in UCUM units
1162Normal practice is to use the 'mo' code as a calendar month when calculating the next occurrence.). This is the underlying object with id, value and extensions. The accessor "getDurationUnit" gives direct access to the value
1163         */
1164        public TimingRepeatComponent setDurationUnitElement(Enumeration<UnitsOfTime> value) { 
1165          this.durationUnit = value;
1166          return this;
1167        }
1168
1169        /**
1170         * @return The units of time for the duration, in UCUM units
1171Normal practice is to use the 'mo' code as a calendar month when calculating the next occurrence.
1172         */
1173        public UnitsOfTime getDurationUnit() { 
1174          return this.durationUnit == null ? null : this.durationUnit.getValue();
1175        }
1176
1177        /**
1178         * @param value The units of time for the duration, in UCUM units
1179Normal practice is to use the 'mo' code as a calendar month when calculating the next occurrence.
1180         */
1181        public TimingRepeatComponent setDurationUnit(UnitsOfTime value) { 
1182          if (value == null)
1183            this.durationUnit = null;
1184          else {
1185            if (this.durationUnit == null)
1186              this.durationUnit = new Enumeration<UnitsOfTime>(new UnitsOfTimeEnumFactory());
1187            this.durationUnit.setValue(value);
1188          }
1189          return this;
1190        }
1191
1192        /**
1193         * @return {@link #frequency} (The number of times to repeat the action within the specified period. If frequencyMax is present, this element indicates the lower bound of the allowed range of the frequency.). This is the underlying object with id, value and extensions. The accessor "getFrequency" gives direct access to the value
1194         */
1195        public PositiveIntType getFrequencyElement() { 
1196          if (this.frequency == null)
1197            if (Configuration.errorOnAutoCreate())
1198              throw new Error("Attempt to auto-create TimingRepeatComponent.frequency");
1199            else if (Configuration.doAutoCreate())
1200              this.frequency = new PositiveIntType(); // bb
1201          return this.frequency;
1202        }
1203
1204        public boolean hasFrequencyElement() { 
1205          return this.frequency != null && !this.frequency.isEmpty();
1206        }
1207
1208        public boolean hasFrequency() { 
1209          return this.frequency != null && !this.frequency.isEmpty();
1210        }
1211
1212        /**
1213         * @param value {@link #frequency} (The number of times to repeat the action within the specified period. If frequencyMax is present, this element indicates the lower bound of the allowed range of the frequency.). This is the underlying object with id, value and extensions. The accessor "getFrequency" gives direct access to the value
1214         */
1215        public TimingRepeatComponent setFrequencyElement(PositiveIntType value) { 
1216          this.frequency = value;
1217          return this;
1218        }
1219
1220        /**
1221         * @return The number of times to repeat the action within the specified period. If frequencyMax is present, this element indicates the lower bound of the allowed range of the frequency.
1222         */
1223        public int getFrequency() { 
1224          return this.frequency == null || this.frequency.isEmpty() ? 0 : this.frequency.getValue();
1225        }
1226
1227        /**
1228         * @param value The number of times to repeat the action within the specified period. If frequencyMax is present, this element indicates the lower bound of the allowed range of the frequency.
1229         */
1230        public TimingRepeatComponent setFrequency(int value) { 
1231            if (this.frequency == null)
1232              this.frequency = new PositiveIntType();
1233            this.frequency.setValue(value);
1234          return this;
1235        }
1236
1237        /**
1238         * @return {@link #frequencyMax} (If present, indicates that the frequency is a range - so to 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
1239         */
1240        public PositiveIntType getFrequencyMaxElement() { 
1241          if (this.frequencyMax == null)
1242            if (Configuration.errorOnAutoCreate())
1243              throw new Error("Attempt to auto-create TimingRepeatComponent.frequencyMax");
1244            else if (Configuration.doAutoCreate())
1245              this.frequencyMax = new PositiveIntType(); // bb
1246          return this.frequencyMax;
1247        }
1248
1249        public boolean hasFrequencyMaxElement() { 
1250          return this.frequencyMax != null && !this.frequencyMax.isEmpty();
1251        }
1252
1253        public boolean hasFrequencyMax() { 
1254          return this.frequencyMax != null && !this.frequencyMax.isEmpty();
1255        }
1256
1257        /**
1258         * @param value {@link #frequencyMax} (If present, indicates that the frequency is a range - so to 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
1259         */
1260        public TimingRepeatComponent setFrequencyMaxElement(PositiveIntType value) { 
1261          this.frequencyMax = value;
1262          return this;
1263        }
1264
1265        /**
1266         * @return If present, indicates that the frequency is a range - so to repeat between [frequency] and [frequencyMax] times within the period or period range.
1267         */
1268        public int getFrequencyMax() { 
1269          return this.frequencyMax == null || this.frequencyMax.isEmpty() ? 0 : this.frequencyMax.getValue();
1270        }
1271
1272        /**
1273         * @param value If present, indicates that the frequency is a range - so to repeat between [frequency] and [frequencyMax] times within the period or period range.
1274         */
1275        public TimingRepeatComponent setFrequencyMax(int value) { 
1276            if (this.frequencyMax == null)
1277              this.frequencyMax = new PositiveIntType();
1278            this.frequencyMax.setValue(value);
1279          return this;
1280        }
1281
1282        /**
1283         * @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. If periodMax is present, this element indicates the lower bound of the allowed range of the period length.). This is the underlying object with id, value and extensions. The accessor "getPeriod" gives direct access to the value
1284         */
1285        public DecimalType getPeriodElement() { 
1286          if (this.period == null)
1287            if (Configuration.errorOnAutoCreate())
1288              throw new Error("Attempt to auto-create TimingRepeatComponent.period");
1289            else if (Configuration.doAutoCreate())
1290              this.period = new DecimalType(); // bb
1291          return this.period;
1292        }
1293
1294        public boolean hasPeriodElement() { 
1295          return this.period != null && !this.period.isEmpty();
1296        }
1297
1298        public boolean hasPeriod() { 
1299          return this.period != null && !this.period.isEmpty();
1300        }
1301
1302        /**
1303         * @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. If periodMax is present, this element indicates the lower bound of the allowed range of the period length.). This is the underlying object with id, value and extensions. The accessor "getPeriod" gives direct access to the value
1304         */
1305        public TimingRepeatComponent setPeriodElement(DecimalType value) { 
1306          this.period = value;
1307          return this;
1308        }
1309
1310        /**
1311         * @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. If periodMax is present, this element indicates the lower bound of the allowed range of the period length.
1312         */
1313        public BigDecimal getPeriod() { 
1314          return this.period == null ? null : this.period.getValue();
1315        }
1316
1317        /**
1318         * @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. If periodMax is present, this element indicates the lower bound of the allowed range of the period length.
1319         */
1320        public TimingRepeatComponent setPeriod(BigDecimal value) { 
1321          if (value == null)
1322            this.period = null;
1323          else {
1324            if (this.period == null)
1325              this.period = new DecimalType();
1326            this.period.setValue(value);
1327          }
1328          return this;
1329        }
1330
1331        /**
1332         * @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. If periodMax is present, this element indicates the lower bound of the allowed range of the period length.
1333         */
1334        public TimingRepeatComponent setPeriod(long value) { 
1335              this.period = new DecimalType();
1336            this.period.setValue(value);
1337          return this;
1338        }
1339
1340        /**
1341         * @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. If periodMax is present, this element indicates the lower bound of the allowed range of the period length.
1342         */
1343        public TimingRepeatComponent setPeriod(double value) { 
1344              this.period = new DecimalType();
1345            this.period.setValue(value);
1346          return this;
1347        }
1348
1349        /**
1350         * @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
1351         */
1352        public DecimalType getPeriodMaxElement() { 
1353          if (this.periodMax == null)
1354            if (Configuration.errorOnAutoCreate())
1355              throw new Error("Attempt to auto-create TimingRepeatComponent.periodMax");
1356            else if (Configuration.doAutoCreate())
1357              this.periodMax = new DecimalType(); // bb
1358          return this.periodMax;
1359        }
1360
1361        public boolean hasPeriodMaxElement() { 
1362          return this.periodMax != null && !this.periodMax.isEmpty();
1363        }
1364
1365        public boolean hasPeriodMax() { 
1366          return this.periodMax != null && !this.periodMax.isEmpty();
1367        }
1368
1369        /**
1370         * @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
1371         */
1372        public TimingRepeatComponent setPeriodMaxElement(DecimalType value) { 
1373          this.periodMax = value;
1374          return this;
1375        }
1376
1377        /**
1378         * @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.
1379         */
1380        public BigDecimal getPeriodMax() { 
1381          return this.periodMax == null ? null : this.periodMax.getValue();
1382        }
1383
1384        /**
1385         * @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.
1386         */
1387        public TimingRepeatComponent setPeriodMax(BigDecimal value) { 
1388          if (value == null)
1389            this.periodMax = null;
1390          else {
1391            if (this.periodMax == null)
1392              this.periodMax = new DecimalType();
1393            this.periodMax.setValue(value);
1394          }
1395          return this;
1396        }
1397
1398        /**
1399         * @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.
1400         */
1401        public TimingRepeatComponent setPeriodMax(long value) { 
1402              this.periodMax = new DecimalType();
1403            this.periodMax.setValue(value);
1404          return this;
1405        }
1406
1407        /**
1408         * @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.
1409         */
1410        public TimingRepeatComponent setPeriodMax(double value) { 
1411              this.periodMax = new DecimalType();
1412            this.periodMax.setValue(value);
1413          return this;
1414        }
1415
1416        /**
1417         * @return {@link #periodUnit} (The units of time for the period in UCUM units
1418Normal practice is to use the 'mo' code as a calendar month when calculating the next occurrence.). This is the underlying object with id, value and extensions. The accessor "getPeriodUnit" gives direct access to the value
1419         */
1420        public Enumeration<UnitsOfTime> getPeriodUnitElement() { 
1421          if (this.periodUnit == null)
1422            if (Configuration.errorOnAutoCreate())
1423              throw new Error("Attempt to auto-create TimingRepeatComponent.periodUnit");
1424            else if (Configuration.doAutoCreate())
1425              this.periodUnit = new Enumeration<UnitsOfTime>(new UnitsOfTimeEnumFactory()); // bb
1426          return this.periodUnit;
1427        }
1428
1429        public boolean hasPeriodUnitElement() { 
1430          return this.periodUnit != null && !this.periodUnit.isEmpty();
1431        }
1432
1433        public boolean hasPeriodUnit() { 
1434          return this.periodUnit != null && !this.periodUnit.isEmpty();
1435        }
1436
1437        /**
1438         * @param value {@link #periodUnit} (The units of time for the period in UCUM units
1439Normal practice is to use the 'mo' code as a calendar month when calculating the next occurrence.). This is the underlying object with id, value and extensions. The accessor "getPeriodUnit" gives direct access to the value
1440         */
1441        public TimingRepeatComponent setPeriodUnitElement(Enumeration<UnitsOfTime> value) { 
1442          this.periodUnit = value;
1443          return this;
1444        }
1445
1446        /**
1447         * @return The units of time for the period in UCUM units
1448Normal practice is to use the 'mo' code as a calendar month when calculating the next occurrence.
1449         */
1450        public UnitsOfTime getPeriodUnit() { 
1451          return this.periodUnit == null ? null : this.periodUnit.getValue();
1452        }
1453
1454        /**
1455         * @param value The units of time for the period in UCUM units
1456Normal practice is to use the 'mo' code as a calendar month when calculating the next occurrence.
1457         */
1458        public TimingRepeatComponent setPeriodUnit(UnitsOfTime value) { 
1459          if (value == null)
1460            this.periodUnit = null;
1461          else {
1462            if (this.periodUnit == null)
1463              this.periodUnit = new Enumeration<UnitsOfTime>(new UnitsOfTimeEnumFactory());
1464            this.periodUnit.setValue(value);
1465          }
1466          return this;
1467        }
1468
1469        /**
1470         * @return {@link #dayOfWeek} (If one or more days of week is provided, then the action happens only on the specified day(s).)
1471         */
1472        public List<Enumeration<DaysOfWeek>> getDayOfWeek() { 
1473          if (this.dayOfWeek == null)
1474            this.dayOfWeek = new ArrayList<Enumeration<DaysOfWeek>>();
1475          return this.dayOfWeek;
1476        }
1477
1478        /**
1479         * @return Returns a reference to <code>this</code> for easy method chaining
1480         */
1481        public TimingRepeatComponent setDayOfWeek(List<Enumeration<DaysOfWeek>> theDayOfWeek) { 
1482          this.dayOfWeek = theDayOfWeek;
1483          return this;
1484        }
1485
1486        public boolean hasDayOfWeek() { 
1487          if (this.dayOfWeek == null)
1488            return false;
1489          for (Enumeration<DaysOfWeek> item : this.dayOfWeek)
1490            if (!item.isEmpty())
1491              return true;
1492          return false;
1493        }
1494
1495        /**
1496         * @return {@link #dayOfWeek} (If one or more days of week is provided, then the action happens only on the specified day(s).)
1497         */
1498        public Enumeration<DaysOfWeek> addDayOfWeekElement() {//2 
1499          Enumeration<DaysOfWeek> t = new Enumeration<DaysOfWeek>(new DaysOfWeekEnumFactory());
1500          if (this.dayOfWeek == null)
1501            this.dayOfWeek = new ArrayList<Enumeration<DaysOfWeek>>();
1502          this.dayOfWeek.add(t);
1503          return t;
1504        }
1505
1506        /**
1507         * @param value {@link #dayOfWeek} (If one or more days of week is provided, then the action happens only on the specified day(s).)
1508         */
1509        public TimingRepeatComponent addDayOfWeek(DaysOfWeek value) { //1
1510          Enumeration<DaysOfWeek> t = new Enumeration<DaysOfWeek>(new DaysOfWeekEnumFactory());
1511          t.setValue(value);
1512          if (this.dayOfWeek == null)
1513            this.dayOfWeek = new ArrayList<Enumeration<DaysOfWeek>>();
1514          this.dayOfWeek.add(t);
1515          return this;
1516        }
1517
1518        /**
1519         * @param value {@link #dayOfWeek} (If one or more days of week is provided, then the action happens only on the specified day(s).)
1520         */
1521        public boolean hasDayOfWeek(DaysOfWeek value) { 
1522          if (this.dayOfWeek == null)
1523            return false;
1524          for (Enumeration<DaysOfWeek> v : this.dayOfWeek)
1525            if (v.getValue().equals(value)) // code
1526              return true;
1527          return false;
1528        }
1529
1530        /**
1531         * @return {@link #timeOfDay} (Specified time of day for action to take place.)
1532         */
1533        public List<TimeType> getTimeOfDay() { 
1534          if (this.timeOfDay == null)
1535            this.timeOfDay = new ArrayList<TimeType>();
1536          return this.timeOfDay;
1537        }
1538
1539        /**
1540         * @return Returns a reference to <code>this</code> for easy method chaining
1541         */
1542        public TimingRepeatComponent setTimeOfDay(List<TimeType> theTimeOfDay) { 
1543          this.timeOfDay = theTimeOfDay;
1544          return this;
1545        }
1546
1547        public boolean hasTimeOfDay() { 
1548          if (this.timeOfDay == null)
1549            return false;
1550          for (TimeType item : this.timeOfDay)
1551            if (!item.isEmpty())
1552              return true;
1553          return false;
1554        }
1555
1556        /**
1557         * @return {@link #timeOfDay} (Specified time of day for action to take place.)
1558         */
1559        public TimeType addTimeOfDayElement() {//2 
1560          TimeType t = new TimeType();
1561          if (this.timeOfDay == null)
1562            this.timeOfDay = new ArrayList<TimeType>();
1563          this.timeOfDay.add(t);
1564          return t;
1565        }
1566
1567        /**
1568         * @param value {@link #timeOfDay} (Specified time of day for action to take place.)
1569         */
1570        public TimingRepeatComponent addTimeOfDay(String value) { //1
1571          TimeType t = new TimeType();
1572          t.setValue(value);
1573          if (this.timeOfDay == null)
1574            this.timeOfDay = new ArrayList<TimeType>();
1575          this.timeOfDay.add(t);
1576          return this;
1577        }
1578
1579        /**
1580         * @param value {@link #timeOfDay} (Specified time of day for action to take place.)
1581         */
1582        public boolean hasTimeOfDay(String value) { 
1583          if (this.timeOfDay == null)
1584            return false;
1585          for (TimeType v : this.timeOfDay)
1586            if (v.getValue().equals(value)) // time
1587              return true;
1588          return false;
1589        }
1590
1591        /**
1592         * @return {@link #when} (An approximate time period during the day, potentially linked to an event of daily living that indicates when the action should occur.)
1593         */
1594        public List<Enumeration<EventTiming>> getWhen() { 
1595          if (this.when == null)
1596            this.when = new ArrayList<Enumeration<EventTiming>>();
1597          return this.when;
1598        }
1599
1600        /**
1601         * @return Returns a reference to <code>this</code> for easy method chaining
1602         */
1603        public TimingRepeatComponent setWhen(List<Enumeration<EventTiming>> theWhen) { 
1604          this.when = theWhen;
1605          return this;
1606        }
1607
1608        public boolean hasWhen() { 
1609          if (this.when == null)
1610            return false;
1611          for (Enumeration<EventTiming> item : this.when)
1612            if (!item.isEmpty())
1613              return true;
1614          return false;
1615        }
1616
1617        /**
1618         * @return {@link #when} (An approximate time period during the day, potentially linked to an event of daily living that indicates when the action should occur.)
1619         */
1620        public Enumeration<EventTiming> addWhenElement() {//2 
1621          Enumeration<EventTiming> t = new Enumeration<EventTiming>(new EventTimingEnumFactory());
1622          if (this.when == null)
1623            this.when = new ArrayList<Enumeration<EventTiming>>();
1624          this.when.add(t);
1625          return t;
1626        }
1627
1628        /**
1629         * @param value {@link #when} (An approximate time period during the day, potentially linked to an event of daily living that indicates when the action should occur.)
1630         */
1631        public TimingRepeatComponent addWhen(EventTiming value) { //1
1632          Enumeration<EventTiming> t = new Enumeration<EventTiming>(new EventTimingEnumFactory());
1633          t.setValue(value);
1634          if (this.when == null)
1635            this.when = new ArrayList<Enumeration<EventTiming>>();
1636          this.when.add(t);
1637          return this;
1638        }
1639
1640        /**
1641         * @param value {@link #when} (An approximate time period during the day, potentially linked to an event of daily living that indicates when the action should occur.)
1642         */
1643        public boolean hasWhen(EventTiming value) { 
1644          if (this.when == null)
1645            return false;
1646          for (Enumeration<EventTiming> v : this.when)
1647            if (v.getValue().equals(value)) // code
1648              return true;
1649          return false;
1650        }
1651
1652        /**
1653         * @return {@link #offset} (The number of minutes from the event. If the event code does not indicate whether the minutes is before or after the event, then the offset is assumed to be after the event.). This is the underlying object with id, value and extensions. The accessor "getOffset" gives direct access to the value
1654         */
1655        public UnsignedIntType getOffsetElement() { 
1656          if (this.offset == null)
1657            if (Configuration.errorOnAutoCreate())
1658              throw new Error("Attempt to auto-create TimingRepeatComponent.offset");
1659            else if (Configuration.doAutoCreate())
1660              this.offset = new UnsignedIntType(); // bb
1661          return this.offset;
1662        }
1663
1664        public boolean hasOffsetElement() { 
1665          return this.offset != null && !this.offset.isEmpty();
1666        }
1667
1668        public boolean hasOffset() { 
1669          return this.offset != null && !this.offset.isEmpty();
1670        }
1671
1672        /**
1673         * @param value {@link #offset} (The number of minutes from the event. If the event code does not indicate whether the minutes is before or after the event, then the offset is assumed to be after the event.). This is the underlying object with id, value and extensions. The accessor "getOffset" gives direct access to the value
1674         */
1675        public TimingRepeatComponent setOffsetElement(UnsignedIntType value) { 
1676          this.offset = value;
1677          return this;
1678        }
1679
1680        /**
1681         * @return The number of minutes from the event. If the event code does not indicate whether the minutes is before or after the event, then the offset is assumed to be after the event.
1682         */
1683        public int getOffset() { 
1684          return this.offset == null || this.offset.isEmpty() ? 0 : this.offset.getValue();
1685        }
1686
1687        /**
1688         * @param value The number of minutes from the event. If the event code does not indicate whether the minutes is before or after the event, then the offset is assumed to be after the event.
1689         */
1690        public TimingRepeatComponent setOffset(int value) { 
1691            if (this.offset == null)
1692              this.offset = new UnsignedIntType();
1693            this.offset.setValue(value);
1694          return this;
1695        }
1696
1697        protected void listChildren(List<Property> children) {
1698          super.listChildren(children);
1699          children.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, 1, bounds));
1700          children.add(new Property("count", "positiveInt", "A total count of the desired number of repetitions across the duration of the entire timing specification. If countMax is present, this element indicates the lower bound of the allowed range of count values.", 0, 1, count));
1701          children.add(new Property("countMax", "positiveInt", "If present, indicates that the count is a range - so to perform the action between [count] and [countMax] times.", 0, 1, countMax));
1702          children.add(new Property("duration", "decimal", "How long this thing happens for when it happens. If durationMax is present, this element indicates the lower bound of the allowed range of the duration.", 0, 1, duration));
1703          children.add(new Property("durationMax", "decimal", "If present, indicates that the duration is a range - so to perform the action between [duration] and [durationMax] time length.", 0, 1, durationMax));
1704          children.add(new Property("durationUnit", "code", "The units of time for the duration, in UCUM units\nNormal practice is to use the 'mo' code as a calendar month when calculating the next occurrence.", 0, 1, durationUnit));
1705          children.add(new Property("frequency", "positiveInt", "The number of times to repeat the action within the specified period. If frequencyMax is present, this element indicates the lower bound of the allowed range of the frequency.", 0, 1, frequency));
1706          children.add(new Property("frequencyMax", "positiveInt", "If present, indicates that the frequency is a range - so to repeat between [frequency] and [frequencyMax] times within the period or period range.", 0, 1, frequencyMax));
1707          children.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. If periodMax is present, this element indicates the lower bound of the allowed range of the period length.", 0, 1, period));
1708          children.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, 1, periodMax));
1709          children.add(new Property("periodUnit", "code", "The units of time for the period in UCUM units\nNormal practice is to use the 'mo' code as a calendar month when calculating the next occurrence.", 0, 1, periodUnit));
1710          children.add(new Property("dayOfWeek", "code", "If one or more days of week is provided, then the action happens only on the specified day(s).", 0, java.lang.Integer.MAX_VALUE, dayOfWeek));
1711          children.add(new Property("timeOfDay", "time", "Specified time of day for action to take place.", 0, java.lang.Integer.MAX_VALUE, timeOfDay));
1712          children.add(new Property("when", "code", "An approximate time period during the day, potentially linked to an event of daily living that indicates when the action should occur.", 0, java.lang.Integer.MAX_VALUE, when));
1713          children.add(new Property("offset", "unsignedInt", "The number of minutes from the event. If the event code does not indicate whether the minutes is before or after the event, then the offset is assumed to be after the event.", 0, 1, offset));
1714        }
1715
1716        @Override
1717        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1718          switch (_hash) {
1719          case -1149635157: /*bounds[x]*/  return 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, 1, bounds);
1720          case -1383205195: /*bounds*/  return 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, 1, bounds);
1721          case -189193367: /*boundsDuration*/  return new Property("bounds[x]", "Duration", "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, 1, bounds);
1722          case -1001768056: /*boundsRange*/  return new Property("bounds[x]", "Range", "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, 1, bounds);
1723          case -1043481386: /*boundsPeriod*/  return new Property("bounds[x]", "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, 1, bounds);
1724          case 94851343: /*count*/  return new Property("count", "positiveInt", "A total count of the desired number of repetitions across the duration of the entire timing specification. If countMax is present, this element indicates the lower bound of the allowed range of count values.", 0, 1, count);
1725          case -372044331: /*countMax*/  return new Property("countMax", "positiveInt", "If present, indicates that the count is a range - so to perform the action between [count] and [countMax] times.", 0, 1, countMax);
1726          case -1992012396: /*duration*/  return new Property("duration", "decimal", "How long this thing happens for when it happens. If durationMax is present, this element indicates the lower bound of the allowed range of the duration.", 0, 1, duration);
1727          case -478083280: /*durationMax*/  return new Property("durationMax", "decimal", "If present, indicates that the duration is a range - so to perform the action between [duration] and [durationMax] time length.", 0, 1, durationMax);
1728          case -1935429320: /*durationUnit*/  return new Property("durationUnit", "code", "The units of time for the duration, in UCUM units\nNormal practice is to use the 'mo' code as a calendar month when calculating the next occurrence.", 0, 1, durationUnit);
1729          case -70023844: /*frequency*/  return new Property("frequency", "positiveInt", "The number of times to repeat the action within the specified period. If frequencyMax is present, this element indicates the lower bound of the allowed range of the frequency.", 0, 1, frequency);
1730          case 1273846376: /*frequencyMax*/  return new Property("frequencyMax", "positiveInt", "If present, indicates that the frequency is a range - so to repeat between [frequency] and [frequencyMax] times within the period or period range.", 0, 1, frequencyMax);
1731          case -991726143: /*period*/  return 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. If periodMax is present, this element indicates the lower bound of the allowed range of the period length.", 0, 1, period);
1732          case 566580195: /*periodMax*/  return 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, 1, periodMax);
1733          case 384367333: /*periodUnit*/  return new Property("periodUnit", "code", "The units of time for the period in UCUM units\nNormal practice is to use the 'mo' code as a calendar month when calculating the next occurrence.", 0, 1, periodUnit);
1734          case -730552025: /*dayOfWeek*/  return new Property("dayOfWeek", "code", "If one or more days of week is provided, then the action happens only on the specified day(s).", 0, java.lang.Integer.MAX_VALUE, dayOfWeek);
1735          case 21434232: /*timeOfDay*/  return new Property("timeOfDay", "time", "Specified time of day for action to take place.", 0, java.lang.Integer.MAX_VALUE, timeOfDay);
1736          case 3648314: /*when*/  return new Property("when", "code", "An approximate time period during the day, potentially linked to an event of daily living that indicates when the action should occur.", 0, java.lang.Integer.MAX_VALUE, when);
1737          case -1019779949: /*offset*/  return new Property("offset", "unsignedInt", "The number of minutes from the event. If the event code does not indicate whether the minutes is before or after the event, then the offset is assumed to be after the event.", 0, 1, offset);
1738          default: return super.getNamedProperty(_hash, _name, _checkValid);
1739          }
1740
1741        }
1742
1743      @Override
1744      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1745        switch (hash) {
1746        case -1383205195: /*bounds*/ return this.bounds == null ? new Base[0] : new Base[] {this.bounds}; // DataType
1747        case 94851343: /*count*/ return this.count == null ? new Base[0] : new Base[] {this.count}; // PositiveIntType
1748        case -372044331: /*countMax*/ return this.countMax == null ? new Base[0] : new Base[] {this.countMax}; // PositiveIntType
1749        case -1992012396: /*duration*/ return this.duration == null ? new Base[0] : new Base[] {this.duration}; // DecimalType
1750        case -478083280: /*durationMax*/ return this.durationMax == null ? new Base[0] : new Base[] {this.durationMax}; // DecimalType
1751        case -1935429320: /*durationUnit*/ return this.durationUnit == null ? new Base[0] : new Base[] {this.durationUnit}; // Enumeration<UnitsOfTime>
1752        case -70023844: /*frequency*/ return this.frequency == null ? new Base[0] : new Base[] {this.frequency}; // PositiveIntType
1753        case 1273846376: /*frequencyMax*/ return this.frequencyMax == null ? new Base[0] : new Base[] {this.frequencyMax}; // PositiveIntType
1754        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // DecimalType
1755        case 566580195: /*periodMax*/ return this.periodMax == null ? new Base[0] : new Base[] {this.periodMax}; // DecimalType
1756        case 384367333: /*periodUnit*/ return this.periodUnit == null ? new Base[0] : new Base[] {this.periodUnit}; // Enumeration<UnitsOfTime>
1757        case -730552025: /*dayOfWeek*/ return this.dayOfWeek == null ? new Base[0] : this.dayOfWeek.toArray(new Base[this.dayOfWeek.size()]); // Enumeration<DaysOfWeek>
1758        case 21434232: /*timeOfDay*/ return this.timeOfDay == null ? new Base[0] : this.timeOfDay.toArray(new Base[this.timeOfDay.size()]); // TimeType
1759        case 3648314: /*when*/ return this.when == null ? new Base[0] : this.when.toArray(new Base[this.when.size()]); // Enumeration<EventTiming>
1760        case -1019779949: /*offset*/ return this.offset == null ? new Base[0] : new Base[] {this.offset}; // UnsignedIntType
1761        default: return super.getProperty(hash, name, checkValid);
1762        }
1763
1764      }
1765
1766      @Override
1767      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1768        switch (hash) {
1769        case -1383205195: // bounds
1770          this.bounds = TypeConvertor.castToType(value); // DataType
1771          return value;
1772        case 94851343: // count
1773          this.count = TypeConvertor.castToPositiveInt(value); // PositiveIntType
1774          return value;
1775        case -372044331: // countMax
1776          this.countMax = TypeConvertor.castToPositiveInt(value); // PositiveIntType
1777          return value;
1778        case -1992012396: // duration
1779          this.duration = TypeConvertor.castToDecimal(value); // DecimalType
1780          return value;
1781        case -478083280: // durationMax
1782          this.durationMax = TypeConvertor.castToDecimal(value); // DecimalType
1783          return value;
1784        case -1935429320: // durationUnit
1785          value = new UnitsOfTimeEnumFactory().fromType(TypeConvertor.castToCode(value));
1786          this.durationUnit = (Enumeration) value; // Enumeration<UnitsOfTime>
1787          return value;
1788        case -70023844: // frequency
1789          this.frequency = TypeConvertor.castToPositiveInt(value); // PositiveIntType
1790          return value;
1791        case 1273846376: // frequencyMax
1792          this.frequencyMax = TypeConvertor.castToPositiveInt(value); // PositiveIntType
1793          return value;
1794        case -991726143: // period
1795          this.period = TypeConvertor.castToDecimal(value); // DecimalType
1796          return value;
1797        case 566580195: // periodMax
1798          this.periodMax = TypeConvertor.castToDecimal(value); // DecimalType
1799          return value;
1800        case 384367333: // periodUnit
1801          value = new UnitsOfTimeEnumFactory().fromType(TypeConvertor.castToCode(value));
1802          this.periodUnit = (Enumeration) value; // Enumeration<UnitsOfTime>
1803          return value;
1804        case -730552025: // dayOfWeek
1805          value = new DaysOfWeekEnumFactory().fromType(TypeConvertor.castToCode(value));
1806          this.getDayOfWeek().add((Enumeration) value); // Enumeration<DaysOfWeek>
1807          return value;
1808        case 21434232: // timeOfDay
1809          this.getTimeOfDay().add(TypeConvertor.castToTime(value)); // TimeType
1810          return value;
1811        case 3648314: // when
1812          value = new EventTimingEnumFactory().fromType(TypeConvertor.castToCode(value));
1813          this.getWhen().add((Enumeration) value); // Enumeration<EventTiming>
1814          return value;
1815        case -1019779949: // offset
1816          this.offset = TypeConvertor.castToUnsignedInt(value); // UnsignedIntType
1817          return value;
1818        default: return super.setProperty(hash, name, value);
1819        }
1820
1821      }
1822
1823      @Override
1824      public Base setProperty(String name, Base value) throws FHIRException {
1825        if (name.equals("bounds[x]")) {
1826          this.bounds = TypeConvertor.castToType(value); // DataType
1827        } else if (name.equals("count")) {
1828          this.count = TypeConvertor.castToPositiveInt(value); // PositiveIntType
1829        } else if (name.equals("countMax")) {
1830          this.countMax = TypeConvertor.castToPositiveInt(value); // PositiveIntType
1831        } else if (name.equals("duration")) {
1832          this.duration = TypeConvertor.castToDecimal(value); // DecimalType
1833        } else if (name.equals("durationMax")) {
1834          this.durationMax = TypeConvertor.castToDecimal(value); // DecimalType
1835        } else if (name.equals("durationUnit")) {
1836          value = new UnitsOfTimeEnumFactory().fromType(TypeConvertor.castToCode(value));
1837          this.durationUnit = (Enumeration) value; // Enumeration<UnitsOfTime>
1838        } else if (name.equals("frequency")) {
1839          this.frequency = TypeConvertor.castToPositiveInt(value); // PositiveIntType
1840        } else if (name.equals("frequencyMax")) {
1841          this.frequencyMax = TypeConvertor.castToPositiveInt(value); // PositiveIntType
1842        } else if (name.equals("period")) {
1843          this.period = TypeConvertor.castToDecimal(value); // DecimalType
1844        } else if (name.equals("periodMax")) {
1845          this.periodMax = TypeConvertor.castToDecimal(value); // DecimalType
1846        } else if (name.equals("periodUnit")) {
1847          value = new UnitsOfTimeEnumFactory().fromType(TypeConvertor.castToCode(value));
1848          this.periodUnit = (Enumeration) value; // Enumeration<UnitsOfTime>
1849        } else if (name.equals("dayOfWeek")) {
1850          value = new DaysOfWeekEnumFactory().fromType(TypeConvertor.castToCode(value));
1851          this.getDayOfWeek().add((Enumeration) value);
1852        } else if (name.equals("timeOfDay")) {
1853          this.getTimeOfDay().add(TypeConvertor.castToTime(value));
1854        } else if (name.equals("when")) {
1855          value = new EventTimingEnumFactory().fromType(TypeConvertor.castToCode(value));
1856          this.getWhen().add((Enumeration) value);
1857        } else if (name.equals("offset")) {
1858          this.offset = TypeConvertor.castToUnsignedInt(value); // UnsignedIntType
1859        } else
1860          return super.setProperty(name, value);
1861        return value;
1862      }
1863
1864      @Override
1865      public Base makeProperty(int hash, String name) throws FHIRException {
1866        switch (hash) {
1867        case -1149635157:  return getBounds();
1868        case -1383205195:  return getBounds();
1869        case 94851343:  return getCountElement();
1870        case -372044331:  return getCountMaxElement();
1871        case -1992012396:  return getDurationElement();
1872        case -478083280:  return getDurationMaxElement();
1873        case -1935429320:  return getDurationUnitElement();
1874        case -70023844:  return getFrequencyElement();
1875        case 1273846376:  return getFrequencyMaxElement();
1876        case -991726143:  return getPeriodElement();
1877        case 566580195:  return getPeriodMaxElement();
1878        case 384367333:  return getPeriodUnitElement();
1879        case -730552025:  return addDayOfWeekElement();
1880        case 21434232:  return addTimeOfDayElement();
1881        case 3648314:  return addWhenElement();
1882        case -1019779949:  return getOffsetElement();
1883        default: return super.makeProperty(hash, name);
1884        }
1885
1886      }
1887
1888      @Override
1889      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1890        switch (hash) {
1891        case -1383205195: /*bounds*/ return new String[] {"Duration", "Range", "Period"};
1892        case 94851343: /*count*/ return new String[] {"positiveInt"};
1893        case -372044331: /*countMax*/ return new String[] {"positiveInt"};
1894        case -1992012396: /*duration*/ return new String[] {"decimal"};
1895        case -478083280: /*durationMax*/ return new String[] {"decimal"};
1896        case -1935429320: /*durationUnit*/ return new String[] {"code"};
1897        case -70023844: /*frequency*/ return new String[] {"positiveInt"};
1898        case 1273846376: /*frequencyMax*/ return new String[] {"positiveInt"};
1899        case -991726143: /*period*/ return new String[] {"decimal"};
1900        case 566580195: /*periodMax*/ return new String[] {"decimal"};
1901        case 384367333: /*periodUnit*/ return new String[] {"code"};
1902        case -730552025: /*dayOfWeek*/ return new String[] {"code"};
1903        case 21434232: /*timeOfDay*/ return new String[] {"time"};
1904        case 3648314: /*when*/ return new String[] {"code"};
1905        case -1019779949: /*offset*/ return new String[] {"unsignedInt"};
1906        default: return super.getTypesForProperty(hash, name);
1907        }
1908
1909      }
1910
1911      @Override
1912      public Base addChild(String name) throws FHIRException {
1913        if (name.equals("boundsDuration")) {
1914          this.bounds = new Duration();
1915          return this.bounds;
1916        }
1917        else if (name.equals("boundsRange")) {
1918          this.bounds = new Range();
1919          return this.bounds;
1920        }
1921        else if (name.equals("boundsPeriod")) {
1922          this.bounds = new Period();
1923          return this.bounds;
1924        }
1925        else if (name.equals("count")) {
1926          throw new FHIRException("Cannot call addChild on a singleton property Timing.repeat.count");
1927        }
1928        else if (name.equals("countMax")) {
1929          throw new FHIRException("Cannot call addChild on a singleton property Timing.repeat.countMax");
1930        }
1931        else if (name.equals("duration")) {
1932          throw new FHIRException("Cannot call addChild on a singleton property Timing.repeat.duration");
1933        }
1934        else if (name.equals("durationMax")) {
1935          throw new FHIRException("Cannot call addChild on a singleton property Timing.repeat.durationMax");
1936        }
1937        else if (name.equals("durationUnit")) {
1938          throw new FHIRException("Cannot call addChild on a singleton property Timing.repeat.durationUnit");
1939        }
1940        else if (name.equals("frequency")) {
1941          throw new FHIRException("Cannot call addChild on a singleton property Timing.repeat.frequency");
1942        }
1943        else if (name.equals("frequencyMax")) {
1944          throw new FHIRException("Cannot call addChild on a singleton property Timing.repeat.frequencyMax");
1945        }
1946        else if (name.equals("period")) {
1947          throw new FHIRException("Cannot call addChild on a singleton property Timing.repeat.period");
1948        }
1949        else if (name.equals("periodMax")) {
1950          throw new FHIRException("Cannot call addChild on a singleton property Timing.repeat.periodMax");
1951        }
1952        else if (name.equals("periodUnit")) {
1953          throw new FHIRException("Cannot call addChild on a singleton property Timing.repeat.periodUnit");
1954        }
1955        else if (name.equals("dayOfWeek")) {
1956          throw new FHIRException("Cannot call addChild on a singleton property Timing.repeat.dayOfWeek");
1957        }
1958        else if (name.equals("timeOfDay")) {
1959          throw new FHIRException("Cannot call addChild on a singleton property Timing.repeat.timeOfDay");
1960        }
1961        else if (name.equals("when")) {
1962          throw new FHIRException("Cannot call addChild on a singleton property Timing.repeat.when");
1963        }
1964        else if (name.equals("offset")) {
1965          throw new FHIRException("Cannot call addChild on a singleton property Timing.repeat.offset");
1966        }
1967        else
1968          return super.addChild(name);
1969      }
1970
1971      public TimingRepeatComponent copy() {
1972        TimingRepeatComponent dst = new TimingRepeatComponent();
1973        copyValues(dst);
1974        return dst;
1975      }
1976
1977      public void copyValues(TimingRepeatComponent dst) {
1978        super.copyValues(dst);
1979        dst.bounds = bounds == null ? null : bounds.copy();
1980        dst.count = count == null ? null : count.copy();
1981        dst.countMax = countMax == null ? null : countMax.copy();
1982        dst.duration = duration == null ? null : duration.copy();
1983        dst.durationMax = durationMax == null ? null : durationMax.copy();
1984        dst.durationUnit = durationUnit == null ? null : durationUnit.copy();
1985        dst.frequency = frequency == null ? null : frequency.copy();
1986        dst.frequencyMax = frequencyMax == null ? null : frequencyMax.copy();
1987        dst.period = period == null ? null : period.copy();
1988        dst.periodMax = periodMax == null ? null : periodMax.copy();
1989        dst.periodUnit = periodUnit == null ? null : periodUnit.copy();
1990        if (dayOfWeek != null) {
1991          dst.dayOfWeek = new ArrayList<Enumeration<DaysOfWeek>>();
1992          for (Enumeration<DaysOfWeek> i : dayOfWeek)
1993            dst.dayOfWeek.add(i.copy());
1994        };
1995        if (timeOfDay != null) {
1996          dst.timeOfDay = new ArrayList<TimeType>();
1997          for (TimeType i : timeOfDay)
1998            dst.timeOfDay.add(i.copy());
1999        };
2000        if (when != null) {
2001          dst.when = new ArrayList<Enumeration<EventTiming>>();
2002          for (Enumeration<EventTiming> i : when)
2003            dst.when.add(i.copy());
2004        };
2005        dst.offset = offset == null ? null : offset.copy();
2006      }
2007
2008      @Override
2009      public boolean equalsDeep(Base other_) {
2010        if (!super.equalsDeep(other_))
2011          return false;
2012        if (!(other_ instanceof TimingRepeatComponent))
2013          return false;
2014        TimingRepeatComponent o = (TimingRepeatComponent) other_;
2015        return compareDeep(bounds, o.bounds, true) && compareDeep(count, o.count, true) && compareDeep(countMax, o.countMax, true)
2016           && compareDeep(duration, o.duration, true) && compareDeep(durationMax, o.durationMax, true) && compareDeep(durationUnit, o.durationUnit, true)
2017           && compareDeep(frequency, o.frequency, true) && compareDeep(frequencyMax, o.frequencyMax, true)
2018           && compareDeep(period, o.period, true) && compareDeep(periodMax, o.periodMax, true) && compareDeep(periodUnit, o.periodUnit, true)
2019           && compareDeep(dayOfWeek, o.dayOfWeek, true) && compareDeep(timeOfDay, o.timeOfDay, true) && compareDeep(when, o.when, true)
2020           && compareDeep(offset, o.offset, true);
2021      }
2022
2023      @Override
2024      public boolean equalsShallow(Base other_) {
2025        if (!super.equalsShallow(other_))
2026          return false;
2027        if (!(other_ instanceof TimingRepeatComponent))
2028          return false;
2029        TimingRepeatComponent o = (TimingRepeatComponent) other_;
2030        return compareValues(count, o.count, true) && compareValues(countMax, o.countMax, true) && compareValues(duration, o.duration, true)
2031           && compareValues(durationMax, o.durationMax, true) && compareValues(durationUnit, o.durationUnit, true)
2032           && compareValues(frequency, o.frequency, true) && compareValues(frequencyMax, o.frequencyMax, true)
2033           && compareValues(period, o.period, true) && compareValues(periodMax, o.periodMax, true) && compareValues(periodUnit, o.periodUnit, true)
2034           && compareValues(dayOfWeek, o.dayOfWeek, true) && compareValues(timeOfDay, o.timeOfDay, true) && compareValues(when, o.when, true)
2035           && compareValues(offset, o.offset, true);
2036      }
2037
2038      public boolean isEmpty() {
2039        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(bounds, count, countMax
2040          , duration, durationMax, durationUnit, frequency, frequencyMax, period, periodMax
2041          , periodUnit, dayOfWeek, timeOfDay, when, offset);
2042      }
2043
2044  public String fhirType() {
2045    return "Timing.repeat";
2046
2047  }
2048
2049  }
2050
2051    /**
2052     * Identifies specific times when the event occurs.
2053     */
2054    @Child(name = "event", type = {DateTimeType.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2055    @Description(shortDefinition="When the event occurs", formalDefinition="Identifies specific times when the event occurs." )
2056    protected List<DateTimeType> event;
2057
2058    /**
2059     * A set of rules that describe when the event is scheduled.
2060     */
2061    @Child(name = "repeat", type = {}, order=1, min=0, max=1, modifier=false, summary=true)
2062    @Description(shortDefinition="When the event is to occur", formalDefinition="A set of rules that describe when the event is scheduled." )
2063    protected TimingRepeatComponent repeat;
2064
2065    /**
2066     * A code for the timing schedule (or just text in code.text). Some codes such as BID are ubiquitous, but many institutions define their own additional codes. If a code is provided, the code is understood to be a complete statement of whatever is specified in the structured timing data, and either the code or the data may be used to interpret the Timing, with the exception that .repeat.bounds still applies over the code (and is not contained in the code).
2067     */
2068    @Child(name = "code", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
2069    @Description(shortDefinition="C | BID | TID | QID | AM | PM | QD | QOD | +", formalDefinition="A code for the timing schedule (or just text in code.text). Some codes such as BID are ubiquitous, but many institutions define their own additional codes. If a code is provided, the code is understood to be a complete statement of whatever is specified in the structured timing data, and either the code or the data may be used to interpret the Timing, with the exception that .repeat.bounds still applies over the code (and is not contained in the code)." )
2070    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/timing-abbreviation")
2071    protected CodeableConcept code;
2072
2073    private static final long serialVersionUID = 791565112L;
2074
2075  /**
2076   * Constructor
2077   */
2078    public Timing() {
2079      super();
2080    }
2081
2082    /**
2083     * @return {@link #event} (Identifies specific times when the event occurs.)
2084     */
2085    public List<DateTimeType> getEvent() { 
2086      if (this.event == null)
2087        this.event = new ArrayList<DateTimeType>();
2088      return this.event;
2089    }
2090
2091    /**
2092     * @return Returns a reference to <code>this</code> for easy method chaining
2093     */
2094    public Timing setEvent(List<DateTimeType> theEvent) { 
2095      this.event = theEvent;
2096      return this;
2097    }
2098
2099    public boolean hasEvent() { 
2100      if (this.event == null)
2101        return false;
2102      for (DateTimeType item : this.event)
2103        if (!item.isEmpty())
2104          return true;
2105      return false;
2106    }
2107
2108    /**
2109     * @return {@link #event} (Identifies specific times when the event occurs.)
2110     */
2111    public DateTimeType addEventElement() {//2 
2112      DateTimeType t = new DateTimeType();
2113      if (this.event == null)
2114        this.event = new ArrayList<DateTimeType>();
2115      this.event.add(t);
2116      return t;
2117    }
2118
2119    /**
2120     * @param value {@link #event} (Identifies specific times when the event occurs.)
2121     */
2122    public Timing addEvent(Date value) { //1
2123      DateTimeType t = new DateTimeType();
2124      t.setValue(value);
2125      if (this.event == null)
2126        this.event = new ArrayList<DateTimeType>();
2127      this.event.add(t);
2128      return this;
2129    }
2130
2131    /**
2132     * @param value {@link #event} (Identifies specific times when the event occurs.)
2133     */
2134    public boolean hasEvent(Date value) { 
2135      if (this.event == null)
2136        return false;
2137      for (DateTimeType v : this.event)
2138        if (v.getValue().equals(value)) // dateTime
2139          return true;
2140      return false;
2141    }
2142
2143    /**
2144     * @return {@link #repeat} (A set of rules that describe when the event is scheduled.)
2145     */
2146    public TimingRepeatComponent getRepeat() { 
2147      if (this.repeat == null)
2148        if (Configuration.errorOnAutoCreate())
2149          throw new Error("Attempt to auto-create Timing.repeat");
2150        else if (Configuration.doAutoCreate())
2151          this.repeat = new TimingRepeatComponent(); // cc
2152      return this.repeat;
2153    }
2154
2155    public boolean hasRepeat() { 
2156      return this.repeat != null && !this.repeat.isEmpty();
2157    }
2158
2159    /**
2160     * @param value {@link #repeat} (A set of rules that describe when the event is scheduled.)
2161     */
2162    public Timing setRepeat(TimingRepeatComponent value) { 
2163      this.repeat = value;
2164      return this;
2165    }
2166
2167    /**
2168     * @return {@link #code} (A code for the timing schedule (or just text in code.text). Some codes such as BID are ubiquitous, but many institutions define their own additional codes. If a code is provided, the code is understood to be a complete statement of whatever is specified in the structured timing data, and either the code or the data may be used to interpret the Timing, with the exception that .repeat.bounds still applies over the code (and is not contained in the code).)
2169     */
2170    public CodeableConcept getCode() { 
2171      if (this.code == null)
2172        if (Configuration.errorOnAutoCreate())
2173          throw new Error("Attempt to auto-create Timing.code");
2174        else if (Configuration.doAutoCreate())
2175          this.code = new CodeableConcept(); // cc
2176      return this.code;
2177    }
2178
2179    public boolean hasCode() { 
2180      return this.code != null && !this.code.isEmpty();
2181    }
2182
2183    /**
2184     * @param value {@link #code} (A code for the timing schedule (or just text in code.text). Some codes such as BID are ubiquitous, but many institutions define their own additional codes. If a code is provided, the code is understood to be a complete statement of whatever is specified in the structured timing data, and either the code or the data may be used to interpret the Timing, with the exception that .repeat.bounds still applies over the code (and is not contained in the code).)
2185     */
2186    public Timing setCode(CodeableConcept value) { 
2187      this.code = value;
2188      return this;
2189    }
2190
2191      protected void listChildren(List<Property> children) {
2192        super.listChildren(children);
2193        children.add(new Property("event", "dateTime", "Identifies specific times when the event occurs.", 0, java.lang.Integer.MAX_VALUE, event));
2194        children.add(new Property("repeat", "", "A set of rules that describe when the event is scheduled.", 0, 1, repeat));
2195        children.add(new Property("code", "CodeableConcept", "A code for the timing schedule (or just text in code.text). Some codes such as BID are ubiquitous, but many institutions define their own additional codes. If a code is provided, the code is understood to be a complete statement of whatever is specified in the structured timing data, and either the code or the data may be used to interpret the Timing, with the exception that .repeat.bounds still applies over the code (and is not contained in the code).", 0, 1, code));
2196      }
2197
2198      @Override
2199      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2200        switch (_hash) {
2201        case 96891546: /*event*/  return new Property("event", "dateTime", "Identifies specific times when the event occurs.", 0, java.lang.Integer.MAX_VALUE, event);
2202        case -934531685: /*repeat*/  return new Property("repeat", "", "A set of rules that describe when the event is scheduled.", 0, 1, repeat);
2203        case 3059181: /*code*/  return new Property("code", "CodeableConcept", "A code for the timing schedule (or just text in code.text). Some codes such as BID are ubiquitous, but many institutions define their own additional codes. If a code is provided, the code is understood to be a complete statement of whatever is specified in the structured timing data, and either the code or the data may be used to interpret the Timing, with the exception that .repeat.bounds still applies over the code (and is not contained in the code).", 0, 1, code);
2204        default: return super.getNamedProperty(_hash, _name, _checkValid);
2205        }
2206
2207      }
2208
2209      @Override
2210      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2211        switch (hash) {
2212        case 96891546: /*event*/ return this.event == null ? new Base[0] : this.event.toArray(new Base[this.event.size()]); // DateTimeType
2213        case -934531685: /*repeat*/ return this.repeat == null ? new Base[0] : new Base[] {this.repeat}; // TimingRepeatComponent
2214        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept
2215        default: return super.getProperty(hash, name, checkValid);
2216        }
2217
2218      }
2219
2220      @Override
2221      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2222        switch (hash) {
2223        case 96891546: // event
2224          this.getEvent().add(TypeConvertor.castToDateTime(value)); // DateTimeType
2225          return value;
2226        case -934531685: // repeat
2227          this.repeat = (TimingRepeatComponent) value; // TimingRepeatComponent
2228          return value;
2229        case 3059181: // code
2230          this.code = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
2231          return value;
2232        default: return super.setProperty(hash, name, value);
2233        }
2234
2235      }
2236
2237      @Override
2238      public Base setProperty(String name, Base value) throws FHIRException {
2239        if (name.equals("event")) {
2240          this.getEvent().add(TypeConvertor.castToDateTime(value));
2241        } else if (name.equals("repeat")) {
2242          this.repeat = (TimingRepeatComponent) value; // TimingRepeatComponent
2243        } else if (name.equals("code")) {
2244          this.code = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
2245        } else
2246          return super.setProperty(name, value);
2247        return value;
2248      }
2249
2250      @Override
2251      public Base makeProperty(int hash, String name) throws FHIRException {
2252        switch (hash) {
2253        case 96891546:  return addEventElement();
2254        case -934531685:  return getRepeat();
2255        case 3059181:  return getCode();
2256        default: return super.makeProperty(hash, name);
2257        }
2258
2259      }
2260
2261      @Override
2262      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2263        switch (hash) {
2264        case 96891546: /*event*/ return new String[] {"dateTime"};
2265        case -934531685: /*repeat*/ return new String[] {};
2266        case 3059181: /*code*/ return new String[] {"CodeableConcept"};
2267        default: return super.getTypesForProperty(hash, name);
2268        }
2269
2270      }
2271
2272      @Override
2273      public Base addChild(String name) throws FHIRException {
2274        if (name.equals("event")) {
2275          throw new FHIRException("Cannot call addChild on a singleton property Timing.event");
2276        }
2277        else if (name.equals("repeat")) {
2278          this.repeat = new TimingRepeatComponent();
2279          return this.repeat;
2280        }
2281        else if (name.equals("code")) {
2282          this.code = new CodeableConcept();
2283          return this.code;
2284        }
2285        else
2286          return super.addChild(name);
2287      }
2288
2289  public String fhirType() {
2290    return "Timing";
2291
2292  }
2293
2294      public Timing copy() {
2295        Timing dst = new Timing();
2296        copyValues(dst);
2297        return dst;
2298      }
2299
2300      public void copyValues(Timing dst) {
2301        super.copyValues(dst);
2302        if (event != null) {
2303          dst.event = new ArrayList<DateTimeType>();
2304          for (DateTimeType i : event)
2305            dst.event.add(i.copy());
2306        };
2307        dst.repeat = repeat == null ? null : repeat.copy();
2308        dst.code = code == null ? null : code.copy();
2309      }
2310
2311      protected Timing typedCopy() {
2312        return copy();
2313      }
2314
2315      @Override
2316      public boolean equalsDeep(Base other_) {
2317        if (!super.equalsDeep(other_))
2318          return false;
2319        if (!(other_ instanceof Timing))
2320          return false;
2321        Timing o = (Timing) other_;
2322        return compareDeep(event, o.event, true) && compareDeep(repeat, o.repeat, true) && compareDeep(code, o.code, true)
2323          ;
2324      }
2325
2326      @Override
2327      public boolean equalsShallow(Base other_) {
2328        if (!super.equalsShallow(other_))
2329          return false;
2330        if (!(other_ instanceof Timing))
2331          return false;
2332        Timing o = (Timing) other_;
2333        return compareValues(event, o.event, true);
2334      }
2335
2336      public boolean isEmpty() {
2337        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(event, repeat, code);
2338      }
2339
2340
2341}
2342