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