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