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