001package org.hl7.fhir.r4.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Thu, Sep 13, 2018 09:04-0400 for FHIR v3.5.0
033
034import java.util.*;
035
036import org.hl7.fhir.utilities.Utilities;
037import ca.uhn.fhir.model.api.annotation.Child;
038import ca.uhn.fhir.model.api.annotation.ChildOrder;
039import ca.uhn.fhir.model.api.annotation.Description;
040import ca.uhn.fhir.model.api.annotation.DatatypeDef;
041import ca.uhn.fhir.model.api.annotation.Block;
042import org.hl7.fhir.instance.model.api.*;
043import org.hl7.fhir.exceptions.FHIRException;
044/**
045 * A description of a triggering event. Triggering events can be named events, data events, or periodic, as determined by the type element.
046 */
047@DatatypeDef(name="TriggerDefinition")
048public class TriggerDefinition extends Type implements ICompositeType {
049
050    public enum TriggerType {
051        /**
052         * The trigger occurs in response to a specific named event, and no other information about the trigger is specified. Named events are completely pre-coordinated, and the formal semantics of the trigger are not provided.
053         */
054        NAMEDEVENT, 
055        /**
056         * The trigger occurs at a specific time or periodically as described by a timing or schedule. A periodic event cannot have any data elements, but may have a name assigned as a shorthand for the event.
057         */
058        PERIODIC, 
059        /**
060         * The trigger occurs whenever data of a particular type is changed in any way, either added, modified, or removed.
061         */
062        DATACHANGED, 
063        /**
064         * The trigger occurs whenever data of a particular type is added.
065         */
066        DATAADDED, 
067        /**
068         * The trigger occurs whenever data of a particular type is modified.
069         */
070        DATAMODIFIED, 
071        /**
072         * The trigger occurs whenever data of a particular type is removed.
073         */
074        DATAREMOVED, 
075        /**
076         * The trigger occurs whenever data of a particular type is accessed.
077         */
078        DATAACCESSED, 
079        /**
080         * The trigger occurs whenever access to data of a particular type is completed.
081         */
082        DATAACCESSENDED, 
083        /**
084         * added to help the parsers with the generic types
085         */
086        NULL;
087        public static TriggerType fromCode(String codeString) throws FHIRException {
088            if (codeString == null || "".equals(codeString))
089                return null;
090        if ("named-event".equals(codeString))
091          return NAMEDEVENT;
092        if ("periodic".equals(codeString))
093          return PERIODIC;
094        if ("data-changed".equals(codeString))
095          return DATACHANGED;
096        if ("data-added".equals(codeString))
097          return DATAADDED;
098        if ("data-modified".equals(codeString))
099          return DATAMODIFIED;
100        if ("data-removed".equals(codeString))
101          return DATAREMOVED;
102        if ("data-accessed".equals(codeString))
103          return DATAACCESSED;
104        if ("data-access-ended".equals(codeString))
105          return DATAACCESSENDED;
106        if (Configuration.isAcceptInvalidEnums())
107          return null;
108        else
109          throw new FHIRException("Unknown TriggerType code '"+codeString+"'");
110        }
111        public String toCode() {
112          switch (this) {
113            case NAMEDEVENT: return "named-event";
114            case PERIODIC: return "periodic";
115            case DATACHANGED: return "data-changed";
116            case DATAADDED: return "data-added";
117            case DATAMODIFIED: return "data-modified";
118            case DATAREMOVED: return "data-removed";
119            case DATAACCESSED: return "data-accessed";
120            case DATAACCESSENDED: return "data-access-ended";
121            default: return "?";
122          }
123        }
124        public String getSystem() {
125          switch (this) {
126            case NAMEDEVENT: return "http://hl7.org/fhir/trigger-type";
127            case PERIODIC: return "http://hl7.org/fhir/trigger-type";
128            case DATACHANGED: return "http://hl7.org/fhir/trigger-type";
129            case DATAADDED: return "http://hl7.org/fhir/trigger-type";
130            case DATAMODIFIED: return "http://hl7.org/fhir/trigger-type";
131            case DATAREMOVED: return "http://hl7.org/fhir/trigger-type";
132            case DATAACCESSED: return "http://hl7.org/fhir/trigger-type";
133            case DATAACCESSENDED: return "http://hl7.org/fhir/trigger-type";
134            default: return "?";
135          }
136        }
137        public String getDefinition() {
138          switch (this) {
139            case NAMEDEVENT: return "The trigger occurs in response to a specific named event, and no other information about the trigger is specified. Named events are completely pre-coordinated, and the formal semantics of the trigger are not provided.";
140            case PERIODIC: return "The trigger occurs at a specific time or periodically as described by a timing or schedule. A periodic event cannot have any data elements, but may have a name assigned as a shorthand for the event.";
141            case DATACHANGED: return "The trigger occurs whenever data of a particular type is changed in any way, either added, modified, or removed.";
142            case DATAADDED: return "The trigger occurs whenever data of a particular type is added.";
143            case DATAMODIFIED: return "The trigger occurs whenever data of a particular type is modified.";
144            case DATAREMOVED: return "The trigger occurs whenever data of a particular type is removed.";
145            case DATAACCESSED: return "The trigger occurs whenever data of a particular type is accessed.";
146            case DATAACCESSENDED: return "The trigger occurs whenever access to data of a particular type is completed.";
147            default: return "?";
148          }
149        }
150        public String getDisplay() {
151          switch (this) {
152            case NAMEDEVENT: return "Named Event";
153            case PERIODIC: return "Periodic";
154            case DATACHANGED: return "Data Changed";
155            case DATAADDED: return "Data Added";
156            case DATAMODIFIED: return "Data Updated";
157            case DATAREMOVED: return "Data Removed";
158            case DATAACCESSED: return "Data Accessed";
159            case DATAACCESSENDED: return "Data Access Ended";
160            default: return "?";
161          }
162        }
163    }
164
165  public static class TriggerTypeEnumFactory implements EnumFactory<TriggerType> {
166    public TriggerType fromCode(String codeString) throws IllegalArgumentException {
167      if (codeString == null || "".equals(codeString))
168            if (codeString == null || "".equals(codeString))
169                return null;
170        if ("named-event".equals(codeString))
171          return TriggerType.NAMEDEVENT;
172        if ("periodic".equals(codeString))
173          return TriggerType.PERIODIC;
174        if ("data-changed".equals(codeString))
175          return TriggerType.DATACHANGED;
176        if ("data-added".equals(codeString))
177          return TriggerType.DATAADDED;
178        if ("data-modified".equals(codeString))
179          return TriggerType.DATAMODIFIED;
180        if ("data-removed".equals(codeString))
181          return TriggerType.DATAREMOVED;
182        if ("data-accessed".equals(codeString))
183          return TriggerType.DATAACCESSED;
184        if ("data-access-ended".equals(codeString))
185          return TriggerType.DATAACCESSENDED;
186        throw new IllegalArgumentException("Unknown TriggerType code '"+codeString+"'");
187        }
188        public Enumeration<TriggerType> fromType(Base code) throws FHIRException {
189          if (code == null)
190            return null;
191          if (code.isEmpty())
192            return new Enumeration<TriggerType>(this);
193          String codeString = ((PrimitiveType) code).asStringValue();
194          if (codeString == null || "".equals(codeString))
195            return null;
196        if ("named-event".equals(codeString))
197          return new Enumeration<TriggerType>(this, TriggerType.NAMEDEVENT);
198        if ("periodic".equals(codeString))
199          return new Enumeration<TriggerType>(this, TriggerType.PERIODIC);
200        if ("data-changed".equals(codeString))
201          return new Enumeration<TriggerType>(this, TriggerType.DATACHANGED);
202        if ("data-added".equals(codeString))
203          return new Enumeration<TriggerType>(this, TriggerType.DATAADDED);
204        if ("data-modified".equals(codeString))
205          return new Enumeration<TriggerType>(this, TriggerType.DATAMODIFIED);
206        if ("data-removed".equals(codeString))
207          return new Enumeration<TriggerType>(this, TriggerType.DATAREMOVED);
208        if ("data-accessed".equals(codeString))
209          return new Enumeration<TriggerType>(this, TriggerType.DATAACCESSED);
210        if ("data-access-ended".equals(codeString))
211          return new Enumeration<TriggerType>(this, TriggerType.DATAACCESSENDED);
212        throw new FHIRException("Unknown TriggerType code '"+codeString+"'");
213        }
214    public String toCode(TriggerType code) {
215      if (code == TriggerType.NAMEDEVENT)
216        return "named-event";
217      if (code == TriggerType.PERIODIC)
218        return "periodic";
219      if (code == TriggerType.DATACHANGED)
220        return "data-changed";
221      if (code == TriggerType.DATAADDED)
222        return "data-added";
223      if (code == TriggerType.DATAMODIFIED)
224        return "data-modified";
225      if (code == TriggerType.DATAREMOVED)
226        return "data-removed";
227      if (code == TriggerType.DATAACCESSED)
228        return "data-accessed";
229      if (code == TriggerType.DATAACCESSENDED)
230        return "data-access-ended";
231      return "?";
232      }
233    public String toSystem(TriggerType code) {
234      return code.getSystem();
235      }
236    }
237
238    /**
239     * The type of triggering event.
240     */
241    @Child(name = "type", type = {CodeType.class}, order=0, min=1, max=1, modifier=false, summary=true)
242    @Description(shortDefinition="named-event | periodic | data-changed | data-added | data-modified | data-removed | data-accessed | data-access-ended", formalDefinition="The type of triggering event." )
243    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/trigger-type")
244    protected Enumeration<TriggerType> type;
245
246    /**
247     * A formal name for the event. This may be an absolute URI that identifies the event formally (e.g. from a trigger registry), or a simple relative URI that identifies the event in a local context.
248     */
249    @Child(name = "name", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true)
250    @Description(shortDefinition="Name or URI that identifies the event", formalDefinition="A formal name for the event. This may be an absolute URI that identifies the event formally (e.g. from a trigger registry), or a simple relative URI that identifies the event in a local context." )
251    protected StringType name;
252
253    /**
254     * The timing of the event (if this is a periodic trigger).
255     */
256    @Child(name = "timing", type = {Timing.class, Schedule.class, DateType.class, DateTimeType.class}, order=2, min=0, max=1, modifier=false, summary=true)
257    @Description(shortDefinition="Timing of the event", formalDefinition="The timing of the event (if this is a periodic trigger)." )
258    protected Type timing;
259
260    /**
261     * The triggering data of the event (if this is a data trigger).
262     */
263    @Child(name = "data", type = {DataRequirement.class}, order=3, min=0, max=1, modifier=false, summary=true)
264    @Description(shortDefinition="Triggering data of the event", formalDefinition="The triggering data of the event (if this is a data trigger)." )
265    protected DataRequirement data;
266
267    /**
268     * A boolean-valued expression that is evaluated in the context of the container of the trigger definition and returns whether or not the trigger fires.
269     */
270    @Child(name = "condition", type = {Expression.class}, order=4, min=0, max=1, modifier=false, summary=true)
271    @Description(shortDefinition="Whether the event triggers (boolean expression)", formalDefinition="A boolean-valued expression that is evaluated in the context of the container of the trigger definition and returns whether or not the trigger fires." )
272    protected Expression condition;
273
274    private static final long serialVersionUID = -396344653L;
275
276  /**
277   * Constructor
278   */
279    public TriggerDefinition() {
280      super();
281    }
282
283  /**
284   * Constructor
285   */
286    public TriggerDefinition(Enumeration<TriggerType> type) {
287      super();
288      this.type = type;
289    }
290
291    /**
292     * @return {@link #type} (The type of triggering event.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
293     */
294    public Enumeration<TriggerType> getTypeElement() { 
295      if (this.type == null)
296        if (Configuration.errorOnAutoCreate())
297          throw new Error("Attempt to auto-create TriggerDefinition.type");
298        else if (Configuration.doAutoCreate())
299          this.type = new Enumeration<TriggerType>(new TriggerTypeEnumFactory()); // bb
300      return this.type;
301    }
302
303    public boolean hasTypeElement() { 
304      return this.type != null && !this.type.isEmpty();
305    }
306
307    public boolean hasType() { 
308      return this.type != null && !this.type.isEmpty();
309    }
310
311    /**
312     * @param value {@link #type} (The type of triggering event.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
313     */
314    public TriggerDefinition setTypeElement(Enumeration<TriggerType> value) { 
315      this.type = value;
316      return this;
317    }
318
319    /**
320     * @return The type of triggering event.
321     */
322    public TriggerType getType() { 
323      return this.type == null ? null : this.type.getValue();
324    }
325
326    /**
327     * @param value The type of triggering event.
328     */
329    public TriggerDefinition setType(TriggerType value) { 
330        if (this.type == null)
331          this.type = new Enumeration<TriggerType>(new TriggerTypeEnumFactory());
332        this.type.setValue(value);
333      return this;
334    }
335
336    /**
337     * @return {@link #name} (A formal name for the event. This may be an absolute URI that identifies the event formally (e.g. from a trigger registry), or a simple relative URI that identifies the event in a local context.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
338     */
339    public StringType getNameElement() { 
340      if (this.name == null)
341        if (Configuration.errorOnAutoCreate())
342          throw new Error("Attempt to auto-create TriggerDefinition.name");
343        else if (Configuration.doAutoCreate())
344          this.name = new StringType(); // bb
345      return this.name;
346    }
347
348    public boolean hasNameElement() { 
349      return this.name != null && !this.name.isEmpty();
350    }
351
352    public boolean hasName() { 
353      return this.name != null && !this.name.isEmpty();
354    }
355
356    /**
357     * @param value {@link #name} (A formal name for the event. This may be an absolute URI that identifies the event formally (e.g. from a trigger registry), or a simple relative URI that identifies the event in a local context.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
358     */
359    public TriggerDefinition setNameElement(StringType value) { 
360      this.name = value;
361      return this;
362    }
363
364    /**
365     * @return A formal name for the event. This may be an absolute URI that identifies the event formally (e.g. from a trigger registry), or a simple relative URI that identifies the event in a local context.
366     */
367    public String getName() { 
368      return this.name == null ? null : this.name.getValue();
369    }
370
371    /**
372     * @param value A formal name for the event. This may be an absolute URI that identifies the event formally (e.g. from a trigger registry), or a simple relative URI that identifies the event in a local context.
373     */
374    public TriggerDefinition setName(String value) { 
375      if (Utilities.noString(value))
376        this.name = null;
377      else {
378        if (this.name == null)
379          this.name = new StringType();
380        this.name.setValue(value);
381      }
382      return this;
383    }
384
385    /**
386     * @return {@link #timing} (The timing of the event (if this is a periodic trigger).)
387     */
388    public Type getTiming() { 
389      return this.timing;
390    }
391
392    /**
393     * @return {@link #timing} (The timing of the event (if this is a periodic trigger).)
394     */
395    public Timing getTimingTiming() throws FHIRException { 
396      if (this.timing == null)
397        return null;
398      if (!(this.timing instanceof Timing))
399        throw new FHIRException("Type mismatch: the type Timing was expected, but "+this.timing.getClass().getName()+" was encountered");
400      return (Timing) this.timing;
401    }
402
403    public boolean hasTimingTiming() { 
404      return this != null && this.timing instanceof Timing;
405    }
406
407    /**
408     * @return {@link #timing} (The timing of the event (if this is a periodic trigger).)
409     */
410    public Reference getTimingReference() throws FHIRException { 
411      if (this.timing == null)
412        return null;
413      if (!(this.timing instanceof Reference))
414        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.timing.getClass().getName()+" was encountered");
415      return (Reference) this.timing;
416    }
417
418    public boolean hasTimingReference() { 
419      return this != null && this.timing instanceof Reference;
420    }
421
422    /**
423     * @return {@link #timing} (The timing of the event (if this is a periodic trigger).)
424     */
425    public DateType getTimingDateType() throws FHIRException { 
426      if (this.timing == null)
427        return null;
428      if (!(this.timing instanceof DateType))
429        throw new FHIRException("Type mismatch: the type DateType was expected, but "+this.timing.getClass().getName()+" was encountered");
430      return (DateType) this.timing;
431    }
432
433    public boolean hasTimingDateType() { 
434      return this != null && this.timing instanceof DateType;
435    }
436
437    /**
438     * @return {@link #timing} (The timing of the event (if this is a periodic trigger).)
439     */
440    public DateTimeType getTimingDateTimeType() throws FHIRException { 
441      if (this.timing == null)
442        return null;
443      if (!(this.timing instanceof DateTimeType))
444        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.timing.getClass().getName()+" was encountered");
445      return (DateTimeType) this.timing;
446    }
447
448    public boolean hasTimingDateTimeType() { 
449      return this != null && this.timing instanceof DateTimeType;
450    }
451
452    public boolean hasTiming() { 
453      return this.timing != null && !this.timing.isEmpty();
454    }
455
456    /**
457     * @param value {@link #timing} (The timing of the event (if this is a periodic trigger).)
458     */
459    public TriggerDefinition setTiming(Type value) { 
460      if (value != null && !(value instanceof Timing || value instanceof Reference || value instanceof DateType || value instanceof DateTimeType))
461        throw new Error("Not the right type for TriggerDefinition.timing[x]: "+value.fhirType());
462      this.timing = value;
463      return this;
464    }
465
466    /**
467     * @return {@link #data} (The triggering data of the event (if this is a data trigger).)
468     */
469    public DataRequirement getData() { 
470      if (this.data == null)
471        if (Configuration.errorOnAutoCreate())
472          throw new Error("Attempt to auto-create TriggerDefinition.data");
473        else if (Configuration.doAutoCreate())
474          this.data = new DataRequirement(); // cc
475      return this.data;
476    }
477
478    public boolean hasData() { 
479      return this.data != null && !this.data.isEmpty();
480    }
481
482    /**
483     * @param value {@link #data} (The triggering data of the event (if this is a data trigger).)
484     */
485    public TriggerDefinition setData(DataRequirement value) { 
486      this.data = value;
487      return this;
488    }
489
490    /**
491     * @return {@link #condition} (A boolean-valued expression that is evaluated in the context of the container of the trigger definition and returns whether or not the trigger fires.)
492     */
493    public Expression getCondition() { 
494      if (this.condition == null)
495        if (Configuration.errorOnAutoCreate())
496          throw new Error("Attempt to auto-create TriggerDefinition.condition");
497        else if (Configuration.doAutoCreate())
498          this.condition = new Expression(); // cc
499      return this.condition;
500    }
501
502    public boolean hasCondition() { 
503      return this.condition != null && !this.condition.isEmpty();
504    }
505
506    /**
507     * @param value {@link #condition} (A boolean-valued expression that is evaluated in the context of the container of the trigger definition and returns whether or not the trigger fires.)
508     */
509    public TriggerDefinition setCondition(Expression value) { 
510      this.condition = value;
511      return this;
512    }
513
514      protected void listChildren(List<Property> children) {
515        super.listChildren(children);
516        children.add(new Property("type", "code", "The type of triggering event.", 0, 1, type));
517        children.add(new Property("name", "string", "A formal name for the event. This may be an absolute URI that identifies the event formally (e.g. from a trigger registry), or a simple relative URI that identifies the event in a local context.", 0, 1, name));
518        children.add(new Property("timing[x]", "Timing|Reference(Schedule)|date|dateTime", "The timing of the event (if this is a periodic trigger).", 0, 1, timing));
519        children.add(new Property("data", "DataRequirement", "The triggering data of the event (if this is a data trigger).", 0, 1, data));
520        children.add(new Property("condition", "Expression", "A boolean-valued expression that is evaluated in the context of the container of the trigger definition and returns whether or not the trigger fires.", 0, 1, condition));
521      }
522
523      @Override
524      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
525        switch (_hash) {
526        case 3575610: /*type*/  return new Property("type", "code", "The type of triggering event.", 0, 1, type);
527        case 3373707: /*name*/  return new Property("name", "string", "A formal name for the event. This may be an absolute URI that identifies the event formally (e.g. from a trigger registry), or a simple relative URI that identifies the event in a local context.", 0, 1, name);
528        case 164632566: /*timing[x]*/  return new Property("timing[x]", "Timing|Reference(Schedule)|date|dateTime", "The timing of the event (if this is a periodic trigger).", 0, 1, timing);
529        case -873664438: /*timing*/  return new Property("timing[x]", "Timing|Reference(Schedule)|date|dateTime", "The timing of the event (if this is a periodic trigger).", 0, 1, timing);
530        case -497554124: /*timingTiming*/  return new Property("timing[x]", "Timing|Reference(Schedule)|date|dateTime", "The timing of the event (if this is a periodic trigger).", 0, 1, timing);
531        case -1792466399: /*timingReference*/  return new Property("timing[x]", "Timing|Reference(Schedule)|date|dateTime", "The timing of the event (if this is a periodic trigger).", 0, 1, timing);
532        case 807935768: /*timingDate*/  return new Property("timing[x]", "Timing|Reference(Schedule)|date|dateTime", "The timing of the event (if this is a periodic trigger).", 0, 1, timing);
533        case -1837458939: /*timingDateTime*/  return new Property("timing[x]", "Timing|Reference(Schedule)|date|dateTime", "The timing of the event (if this is a periodic trigger).", 0, 1, timing);
534        case 3076010: /*data*/  return new Property("data", "DataRequirement", "The triggering data of the event (if this is a data trigger).", 0, 1, data);
535        case -861311717: /*condition*/  return new Property("condition", "Expression", "A boolean-valued expression that is evaluated in the context of the container of the trigger definition and returns whether or not the trigger fires.", 0, 1, condition);
536        default: return super.getNamedProperty(_hash, _name, _checkValid);
537        }
538
539      }
540
541      @Override
542      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
543        switch (hash) {
544        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // Enumeration<TriggerType>
545        case 3373707: /*name*/ return this.name == null ? new Base[0] : new Base[] {this.name}; // StringType
546        case -873664438: /*timing*/ return this.timing == null ? new Base[0] : new Base[] {this.timing}; // Type
547        case 3076010: /*data*/ return this.data == null ? new Base[0] : new Base[] {this.data}; // DataRequirement
548        case -861311717: /*condition*/ return this.condition == null ? new Base[0] : new Base[] {this.condition}; // Expression
549        default: return super.getProperty(hash, name, checkValid);
550        }
551
552      }
553
554      @Override
555      public Base setProperty(int hash, String name, Base value) throws FHIRException {
556        switch (hash) {
557        case 3575610: // type
558          value = new TriggerTypeEnumFactory().fromType(castToCode(value));
559          this.type = (Enumeration) value; // Enumeration<TriggerType>
560          return value;
561        case 3373707: // name
562          this.name = castToString(value); // StringType
563          return value;
564        case -873664438: // timing
565          this.timing = castToType(value); // Type
566          return value;
567        case 3076010: // data
568          this.data = castToDataRequirement(value); // DataRequirement
569          return value;
570        case -861311717: // condition
571          this.condition = castToExpression(value); // Expression
572          return value;
573        default: return super.setProperty(hash, name, value);
574        }
575
576      }
577
578      @Override
579      public Base setProperty(String name, Base value) throws FHIRException {
580        if (name.equals("type")) {
581          value = new TriggerTypeEnumFactory().fromType(castToCode(value));
582          this.type = (Enumeration) value; // Enumeration<TriggerType>
583        } else if (name.equals("name")) {
584          this.name = castToString(value); // StringType
585        } else if (name.equals("timing[x]")) {
586          this.timing = castToType(value); // Type
587        } else if (name.equals("data")) {
588          this.data = castToDataRequirement(value); // DataRequirement
589        } else if (name.equals("condition")) {
590          this.condition = castToExpression(value); // Expression
591        } else
592          return super.setProperty(name, value);
593        return value;
594      }
595
596      @Override
597      public Base makeProperty(int hash, String name) throws FHIRException {
598        switch (hash) {
599        case 3575610:  return getTypeElement();
600        case 3373707:  return getNameElement();
601        case 164632566:  return getTiming(); 
602        case -873664438:  return getTiming(); 
603        case 3076010:  return getData(); 
604        case -861311717:  return getCondition(); 
605        default: return super.makeProperty(hash, name);
606        }
607
608      }
609
610      @Override
611      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
612        switch (hash) {
613        case 3575610: /*type*/ return new String[] {"code"};
614        case 3373707: /*name*/ return new String[] {"string"};
615        case -873664438: /*timing*/ return new String[] {"Timing", "Reference", "date", "dateTime"};
616        case 3076010: /*data*/ return new String[] {"DataRequirement"};
617        case -861311717: /*condition*/ return new String[] {"Expression"};
618        default: return super.getTypesForProperty(hash, name);
619        }
620
621      }
622
623      @Override
624      public Base addChild(String name) throws FHIRException {
625        if (name.equals("type")) {
626          throw new FHIRException("Cannot call addChild on a primitive type TriggerDefinition.type");
627        }
628        else if (name.equals("name")) {
629          throw new FHIRException("Cannot call addChild on a primitive type TriggerDefinition.name");
630        }
631        else if (name.equals("timingTiming")) {
632          this.timing = new Timing();
633          return this.timing;
634        }
635        else if (name.equals("timingReference")) {
636          this.timing = new Reference();
637          return this.timing;
638        }
639        else if (name.equals("timingDate")) {
640          this.timing = new DateType();
641          return this.timing;
642        }
643        else if (name.equals("timingDateTime")) {
644          this.timing = new DateTimeType();
645          return this.timing;
646        }
647        else if (name.equals("data")) {
648          this.data = new DataRequirement();
649          return this.data;
650        }
651        else if (name.equals("condition")) {
652          this.condition = new Expression();
653          return this.condition;
654        }
655        else
656          return super.addChild(name);
657      }
658
659  public String fhirType() {
660    return "TriggerDefinition";
661
662  }
663
664      public TriggerDefinition copy() {
665        TriggerDefinition dst = new TriggerDefinition();
666        copyValues(dst);
667        dst.type = type == null ? null : type.copy();
668        dst.name = name == null ? null : name.copy();
669        dst.timing = timing == null ? null : timing.copy();
670        dst.data = data == null ? null : data.copy();
671        dst.condition = condition == null ? null : condition.copy();
672        return dst;
673      }
674
675      protected TriggerDefinition typedCopy() {
676        return copy();
677      }
678
679      @Override
680      public boolean equalsDeep(Base other_) {
681        if (!super.equalsDeep(other_))
682          return false;
683        if (!(other_ instanceof TriggerDefinition))
684          return false;
685        TriggerDefinition o = (TriggerDefinition) other_;
686        return compareDeep(type, o.type, true) && compareDeep(name, o.name, true) && compareDeep(timing, o.timing, true)
687           && compareDeep(data, o.data, true) && compareDeep(condition, o.condition, true);
688      }
689
690      @Override
691      public boolean equalsShallow(Base other_) {
692        if (!super.equalsShallow(other_))
693          return false;
694        if (!(other_ instanceof TriggerDefinition))
695          return false;
696        TriggerDefinition o = (TriggerDefinition) other_;
697        return compareValues(type, o.type, true) && compareValues(name, o.name, true);
698      }
699
700      public boolean isEmpty() {
701        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, name, timing, data
702          , condition);
703      }
704
705
706}
707