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, Dec 27, 2018 10:06-0500 for FHIR v4.0.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). If more than one data is requirement is specified, then all the data requirements must be true.
262     */
263    @Child(name = "data", type = {DataRequirement.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
264    @Description(shortDefinition="Triggering data of the event (multiple = 'and')", formalDefinition="The triggering data of the event (if this is a data trigger). If more than one data is requirement is specified, then all the data requirements must be true." )
265    protected List<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 = -1706033335L;
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        this.timing = new Timing();
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        this.timing = new Reference();
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        this.timing = new DateType();
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        this.timing = new DateTimeType();
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). If more than one data is requirement is specified, then all the data requirements must be true.)
468     */
469    public List<DataRequirement> getData() { 
470      if (this.data == null)
471        this.data = new ArrayList<DataRequirement>();
472      return this.data;
473    }
474
475    /**
476     * @return Returns a reference to <code>this</code> for easy method chaining
477     */
478    public TriggerDefinition setData(List<DataRequirement> theData) { 
479      this.data = theData;
480      return this;
481    }
482
483    public boolean hasData() { 
484      if (this.data == null)
485        return false;
486      for (DataRequirement item : this.data)
487        if (!item.isEmpty())
488          return true;
489      return false;
490    }
491
492    public DataRequirement addData() { //3
493      DataRequirement t = new DataRequirement();
494      if (this.data == null)
495        this.data = new ArrayList<DataRequirement>();
496      this.data.add(t);
497      return t;
498    }
499
500    public TriggerDefinition addData(DataRequirement t) { //3
501      if (t == null)
502        return this;
503      if (this.data == null)
504        this.data = new ArrayList<DataRequirement>();
505      this.data.add(t);
506      return this;
507    }
508
509    /**
510     * @return The first repetition of repeating field {@link #data}, creating it if it does not already exist
511     */
512    public DataRequirement getDataFirstRep() { 
513      if (getData().isEmpty()) {
514        addData();
515      }
516      return getData().get(0);
517    }
518
519    /**
520     * @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.)
521     */
522    public Expression getCondition() { 
523      if (this.condition == null)
524        if (Configuration.errorOnAutoCreate())
525          throw new Error("Attempt to auto-create TriggerDefinition.condition");
526        else if (Configuration.doAutoCreate())
527          this.condition = new Expression(); // cc
528      return this.condition;
529    }
530
531    public boolean hasCondition() { 
532      return this.condition != null && !this.condition.isEmpty();
533    }
534
535    /**
536     * @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.)
537     */
538    public TriggerDefinition setCondition(Expression value) { 
539      this.condition = value;
540      return this;
541    }
542
543      protected void listChildren(List<Property> children) {
544        super.listChildren(children);
545        children.add(new Property("type", "code", "The type of triggering event.", 0, 1, type));
546        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));
547        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));
548        children.add(new Property("data", "DataRequirement", "The triggering data of the event (if this is a data trigger). If more than one data is requirement is specified, then all the data requirements must be true.", 0, java.lang.Integer.MAX_VALUE, data));
549        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));
550      }
551
552      @Override
553      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
554        switch (_hash) {
555        case 3575610: /*type*/  return new Property("type", "code", "The type of triggering event.", 0, 1, type);
556        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);
557        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);
558        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);
559        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);
560        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);
561        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);
562        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);
563        case 3076010: /*data*/  return new Property("data", "DataRequirement", "The triggering data of the event (if this is a data trigger). If more than one data is requirement is specified, then all the data requirements must be true.", 0, java.lang.Integer.MAX_VALUE, data);
564        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);
565        default: return super.getNamedProperty(_hash, _name, _checkValid);
566        }
567
568      }
569
570      @Override
571      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
572        switch (hash) {
573        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // Enumeration<TriggerType>
574        case 3373707: /*name*/ return this.name == null ? new Base[0] : new Base[] {this.name}; // StringType
575        case -873664438: /*timing*/ return this.timing == null ? new Base[0] : new Base[] {this.timing}; // Type
576        case 3076010: /*data*/ return this.data == null ? new Base[0] : this.data.toArray(new Base[this.data.size()]); // DataRequirement
577        case -861311717: /*condition*/ return this.condition == null ? new Base[0] : new Base[] {this.condition}; // Expression
578        default: return super.getProperty(hash, name, checkValid);
579        }
580
581      }
582
583      @Override
584      public Base setProperty(int hash, String name, Base value) throws FHIRException {
585        switch (hash) {
586        case 3575610: // type
587          value = new TriggerTypeEnumFactory().fromType(castToCode(value));
588          this.type = (Enumeration) value; // Enumeration<TriggerType>
589          return value;
590        case 3373707: // name
591          this.name = castToString(value); // StringType
592          return value;
593        case -873664438: // timing
594          this.timing = castToType(value); // Type
595          return value;
596        case 3076010: // data
597          this.getData().add(castToDataRequirement(value)); // DataRequirement
598          return value;
599        case -861311717: // condition
600          this.condition = castToExpression(value); // Expression
601          return value;
602        default: return super.setProperty(hash, name, value);
603        }
604
605      }
606
607      @Override
608      public Base setProperty(String name, Base value) throws FHIRException {
609        if (name.equals("type")) {
610          value = new TriggerTypeEnumFactory().fromType(castToCode(value));
611          this.type = (Enumeration) value; // Enumeration<TriggerType>
612        } else if (name.equals("name")) {
613          this.name = castToString(value); // StringType
614        } else if (name.equals("timing[x]")) {
615          this.timing = castToType(value); // Type
616        } else if (name.equals("data")) {
617          this.getData().add(castToDataRequirement(value));
618        } else if (name.equals("condition")) {
619          this.condition = castToExpression(value); // Expression
620        } else
621          return super.setProperty(name, value);
622        return value;
623      }
624
625      @Override
626      public Base makeProperty(int hash, String name) throws FHIRException {
627        switch (hash) {
628        case 3575610:  return getTypeElement();
629        case 3373707:  return getNameElement();
630        case 164632566:  return getTiming(); 
631        case -873664438:  return getTiming(); 
632        case 3076010:  return addData(); 
633        case -861311717:  return getCondition(); 
634        default: return super.makeProperty(hash, name);
635        }
636
637      }
638
639      @Override
640      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
641        switch (hash) {
642        case 3575610: /*type*/ return new String[] {"code"};
643        case 3373707: /*name*/ return new String[] {"string"};
644        case -873664438: /*timing*/ return new String[] {"Timing", "Reference", "date", "dateTime"};
645        case 3076010: /*data*/ return new String[] {"DataRequirement"};
646        case -861311717: /*condition*/ return new String[] {"Expression"};
647        default: return super.getTypesForProperty(hash, name);
648        }
649
650      }
651
652      @Override
653      public Base addChild(String name) throws FHIRException {
654        if (name.equals("type")) {
655          throw new FHIRException("Cannot call addChild on a primitive type TriggerDefinition.type");
656        }
657        else if (name.equals("name")) {
658          throw new FHIRException("Cannot call addChild on a primitive type TriggerDefinition.name");
659        }
660        else if (name.equals("timingTiming")) {
661          this.timing = new Timing();
662          return this.timing;
663        }
664        else if (name.equals("timingReference")) {
665          this.timing = new Reference();
666          return this.timing;
667        }
668        else if (name.equals("timingDate")) {
669          this.timing = new DateType();
670          return this.timing;
671        }
672        else if (name.equals("timingDateTime")) {
673          this.timing = new DateTimeType();
674          return this.timing;
675        }
676        else if (name.equals("data")) {
677          return addData();
678        }
679        else if (name.equals("condition")) {
680          this.condition = new Expression();
681          return this.condition;
682        }
683        else
684          return super.addChild(name);
685      }
686
687  public String fhirType() {
688    return "TriggerDefinition";
689
690  }
691
692      public TriggerDefinition copy() {
693        TriggerDefinition dst = new TriggerDefinition();
694        copyValues(dst);
695        dst.type = type == null ? null : type.copy();
696        dst.name = name == null ? null : name.copy();
697        dst.timing = timing == null ? null : timing.copy();
698        if (data != null) {
699          dst.data = new ArrayList<DataRequirement>();
700          for (DataRequirement i : data)
701            dst.data.add(i.copy());
702        };
703        dst.condition = condition == null ? null : condition.copy();
704        return dst;
705      }
706
707      protected TriggerDefinition typedCopy() {
708        return copy();
709      }
710
711      @Override
712      public boolean equalsDeep(Base other_) {
713        if (!super.equalsDeep(other_))
714          return false;
715        if (!(other_ instanceof TriggerDefinition))
716          return false;
717        TriggerDefinition o = (TriggerDefinition) other_;
718        return compareDeep(type, o.type, true) && compareDeep(name, o.name, true) && compareDeep(timing, o.timing, true)
719           && compareDeep(data, o.data, true) && compareDeep(condition, o.condition, true);
720      }
721
722      @Override
723      public boolean equalsShallow(Base other_) {
724        if (!super.equalsShallow(other_))
725          return false;
726        if (!(other_ instanceof TriggerDefinition))
727          return false;
728        TriggerDefinition o = (TriggerDefinition) other_;
729        return compareValues(type, o.type, true) && compareValues(name, o.name, true);
730      }
731
732      public boolean isEmpty() {
733        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, name, timing, data
734          , condition);
735      }
736
737
738}
739