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