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 Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1
033import java.util.ArrayList;
034import java.util.List;
035
036import org.hl7.fhir.exceptions.FHIRException;
037import org.hl7.fhir.instance.model.api.ICompositeType;
038import org.hl7.fhir.utilities.Utilities;
039
040import ca.uhn.fhir.model.api.annotation.Child;
041import ca.uhn.fhir.model.api.annotation.DatatypeDef;
042import ca.uhn.fhir.model.api.annotation.Description;
043
044/**
045 * A description of a triggering event. Triggering events can be named events,
046 * data events, or periodic, as determined by the type element.
047 */
048@DatatypeDef(name = "TriggerDefinition")
049public class TriggerDefinition extends Type implements ICompositeType {
050
051  public enum TriggerType {
052    /**
053     * The trigger occurs in response to a specific named event, and no other
054     * information about the trigger is specified. Named events are completely
055     * 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
060     * timing or schedule. A periodic event cannot have any data elements, but may
061     * have a name assigned as a shorthand for the event.
062     */
063    PERIODIC,
064    /**
065     * The trigger occurs whenever data of a particular type is changed in any way,
066     * either added, modified, or removed.
067     */
068    DATACHANGED,
069    /**
070     * The trigger occurs whenever data of a particular type is added.
071     */
072    DATAADDED,
073    /**
074     * The trigger occurs whenever data of a particular type is modified.
075     */
076    DATAMODIFIED,
077    /**
078     * The trigger occurs whenever data of a particular type is removed.
079     */
080    DATAREMOVED,
081    /**
082     * The trigger occurs whenever data of a particular type is accessed.
083     */
084    DATAACCESSED,
085    /**
086     * The trigger occurs whenever access to data of a particular type is completed.
087     */
088    DATAACCESSENDED,
089    /**
090     * added to help the parsers with the generic types
091     */
092    NULL;
093
094    public static TriggerType fromCode(String codeString) throws FHIRException {
095      if (codeString == null || "".equals(codeString))
096        return null;
097      if ("named-event".equals(codeString))
098        return NAMEDEVENT;
099      if ("periodic".equals(codeString))
100        return PERIODIC;
101      if ("data-changed".equals(codeString))
102        return DATACHANGED;
103      if ("data-added".equals(codeString))
104        return DATAADDED;
105      if ("data-modified".equals(codeString))
106        return DATAMODIFIED;
107      if ("data-removed".equals(codeString))
108        return DATAREMOVED;
109      if ("data-accessed".equals(codeString))
110        return DATAACCESSED;
111      if ("data-access-ended".equals(codeString))
112        return DATAACCESSENDED;
113      if (Configuration.isAcceptInvalidEnums())
114        return null;
115      else
116        throw new FHIRException("Unknown TriggerType code '" + codeString + "'");
117    }
118
119    public String toCode() {
120      switch (this) {
121      case NAMEDEVENT:
122        return "named-event";
123      case PERIODIC:
124        return "periodic";
125      case DATACHANGED:
126        return "data-changed";
127      case DATAADDED:
128        return "data-added";
129      case DATAMODIFIED:
130        return "data-modified";
131      case DATAREMOVED:
132        return "data-removed";
133      case DATAACCESSED:
134        return "data-accessed";
135      case DATAACCESSENDED:
136        return "data-access-ended";
137      case NULL:
138        return null;
139      default:
140        return "?";
141      }
142    }
143
144    public String getSystem() {
145      switch (this) {
146      case NAMEDEVENT:
147        return "http://hl7.org/fhir/trigger-type";
148      case PERIODIC:
149        return "http://hl7.org/fhir/trigger-type";
150      case DATACHANGED:
151        return "http://hl7.org/fhir/trigger-type";
152      case DATAADDED:
153        return "http://hl7.org/fhir/trigger-type";
154      case DATAMODIFIED:
155        return "http://hl7.org/fhir/trigger-type";
156      case DATAREMOVED:
157        return "http://hl7.org/fhir/trigger-type";
158      case DATAACCESSED:
159        return "http://hl7.org/fhir/trigger-type";
160      case DATAACCESSENDED:
161        return "http://hl7.org/fhir/trigger-type";
162      case NULL:
163        return null;
164      default:
165        return "?";
166      }
167    }
168
169    public String getDefinition() {
170      switch (this) {
171      case NAMEDEVENT:
172        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.";
173      case PERIODIC:
174        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.";
175      case DATACHANGED:
176        return "The trigger occurs whenever data of a particular type is changed in any way, either added, modified, or removed.";
177      case DATAADDED:
178        return "The trigger occurs whenever data of a particular type is added.";
179      case DATAMODIFIED:
180        return "The trigger occurs whenever data of a particular type is modified.";
181      case DATAREMOVED:
182        return "The trigger occurs whenever data of a particular type is removed.";
183      case DATAACCESSED:
184        return "The trigger occurs whenever data of a particular type is accessed.";
185      case DATAACCESSENDED:
186        return "The trigger occurs whenever access to data of a particular type is completed.";
187      case NULL:
188        return null;
189      default:
190        return "?";
191      }
192    }
193
194    public String getDisplay() {
195      switch (this) {
196      case NAMEDEVENT:
197        return "Named Event";
198      case PERIODIC:
199        return "Periodic";
200      case DATACHANGED:
201        return "Data Changed";
202      case DATAADDED:
203        return "Data Added";
204      case DATAMODIFIED:
205        return "Data Updated";
206      case DATAREMOVED:
207        return "Data Removed";
208      case DATAACCESSED:
209        return "Data Accessed";
210      case DATAACCESSENDED:
211        return "Data Access Ended";
212      case NULL:
213        return null;
214      default:
215        return "?";
216      }
217    }
218  }
219
220  public static class TriggerTypeEnumFactory implements EnumFactory<TriggerType> {
221    public TriggerType fromCode(String codeString) throws IllegalArgumentException {
222      if (codeString == null || "".equals(codeString))
223        if (codeString == null || "".equals(codeString))
224          return null;
225      if ("named-event".equals(codeString))
226        return TriggerType.NAMEDEVENT;
227      if ("periodic".equals(codeString))
228        return TriggerType.PERIODIC;
229      if ("data-changed".equals(codeString))
230        return TriggerType.DATACHANGED;
231      if ("data-added".equals(codeString))
232        return TriggerType.DATAADDED;
233      if ("data-modified".equals(codeString))
234        return TriggerType.DATAMODIFIED;
235      if ("data-removed".equals(codeString))
236        return TriggerType.DATAREMOVED;
237      if ("data-accessed".equals(codeString))
238        return TriggerType.DATAACCESSED;
239      if ("data-access-ended".equals(codeString))
240        return TriggerType.DATAACCESSENDED;
241      throw new IllegalArgumentException("Unknown TriggerType code '" + codeString + "'");
242    }
243
244    public Enumeration<TriggerType> fromType(PrimitiveType<?> code) throws FHIRException {
245      if (code == null)
246        return null;
247      if (code.isEmpty())
248        return new Enumeration<TriggerType>(this, TriggerType.NULL, code);
249      String codeString = code.asStringValue();
250      if (codeString == null || "".equals(codeString))
251        return new Enumeration<TriggerType>(this, TriggerType.NULL, code);
252      if ("named-event".equals(codeString))
253        return new Enumeration<TriggerType>(this, TriggerType.NAMEDEVENT, code);
254      if ("periodic".equals(codeString))
255        return new Enumeration<TriggerType>(this, TriggerType.PERIODIC, code);
256      if ("data-changed".equals(codeString))
257        return new Enumeration<TriggerType>(this, TriggerType.DATACHANGED, code);
258      if ("data-added".equals(codeString))
259        return new Enumeration<TriggerType>(this, TriggerType.DATAADDED, code);
260      if ("data-modified".equals(codeString))
261        return new Enumeration<TriggerType>(this, TriggerType.DATAMODIFIED, code);
262      if ("data-removed".equals(codeString))
263        return new Enumeration<TriggerType>(this, TriggerType.DATAREMOVED, code);
264      if ("data-accessed".equals(codeString))
265        return new Enumeration<TriggerType>(this, TriggerType.DATAACCESSED, code);
266      if ("data-access-ended".equals(codeString))
267        return new Enumeration<TriggerType>(this, TriggerType.DATAACCESSENDED, code);
268      throw new FHIRException("Unknown TriggerType code '" + codeString + "'");
269    }
270
271    public String toCode(TriggerType code) {
272      if (code == TriggerType.NAMEDEVENT)
273        return "named-event";
274      if (code == TriggerType.PERIODIC)
275        return "periodic";
276      if (code == TriggerType.DATACHANGED)
277        return "data-changed";
278      if (code == TriggerType.DATAADDED)
279        return "data-added";
280      if (code == TriggerType.DATAMODIFIED)
281        return "data-modified";
282      if (code == TriggerType.DATAREMOVED)
283        return "data-removed";
284      if (code == TriggerType.DATAACCESSED)
285        return "data-accessed";
286      if (code == TriggerType.DATAACCESSENDED)
287        return "data-access-ended";
288      return "?";
289    }
290
291    public String toSystem(TriggerType code) {
292      return code.getSystem();
293    }
294  }
295
296  /**
297   * The type of triggering event.
298   */
299  @Child(name = "type", type = { CodeType.class }, order = 0, min = 1, max = 1, modifier = false, summary = true)
300  @Description(shortDefinition = "named-event | periodic | data-changed | data-added | data-modified | data-removed | data-accessed | data-access-ended", formalDefinition = "The type of triggering event.")
301  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/trigger-type")
302  protected Enumeration<TriggerType> type;
303
304  /**
305   * A formal name for the event. This may be an absolute URI that identifies the
306   * event formally (e.g. from a trigger registry), or a simple relative URI that
307   * identifies the event in a local context.
308   */
309  @Child(name = "name", type = { StringType.class }, order = 1, min = 0, max = 1, modifier = false, summary = true)
310  @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.")
311  protected StringType name;
312
313  /**
314   * The timing of the event (if this is a periodic trigger).
315   */
316  @Child(name = "timing", type = { Timing.class, Schedule.class, DateType.class,
317      DateTimeType.class }, order = 2, min = 0, max = 1, modifier = false, summary = true)
318  @Description(shortDefinition = "Timing of the event", formalDefinition = "The timing of the event (if this is a periodic trigger).")
319  protected Type timing;
320
321  /**
322   * The triggering data of the event (if this is a data trigger). If more than
323   * one data is requirement is specified, then all the data requirements must be
324   * true.
325   */
326  @Child(name = "data", type = {
327      DataRequirement.class }, order = 3, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
328  @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.")
329  protected List<DataRequirement> data;
330
331  /**
332   * A boolean-valued expression that is evaluated in the context of the container
333   * of the trigger definition and returns whether or not the trigger fires.
334   */
335  @Child(name = "condition", type = { Expression.class }, order = 4, min = 0, max = 1, modifier = false, summary = true)
336  @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.")
337  protected Expression condition;
338
339  private static final long serialVersionUID = -1706033335L;
340
341  /**
342   * Constructor
343   */
344  public TriggerDefinition() {
345    super();
346  }
347
348  /**
349   * Constructor
350   */
351  public TriggerDefinition(Enumeration<TriggerType> type) {
352    super();
353    this.type = type;
354  }
355
356  /**
357   * @return {@link #type} (The type of triggering event.). This is the underlying
358   *         object with id, value and extensions. The accessor "getType" gives
359   *         direct access to the value
360   */
361  public Enumeration<TriggerType> getTypeElement() {
362    if (this.type == null)
363      if (Configuration.errorOnAutoCreate())
364        throw new Error("Attempt to auto-create TriggerDefinition.type");
365      else if (Configuration.doAutoCreate())
366        this.type = new Enumeration<TriggerType>(new TriggerTypeEnumFactory()); // bb
367    return this.type;
368  }
369
370  public boolean hasTypeElement() {
371    return this.type != null && !this.type.isEmpty();
372  }
373
374  public boolean hasType() {
375    return this.type != null && !this.type.isEmpty();
376  }
377
378  /**
379   * @param value {@link #type} (The type of triggering event.). This is the
380   *              underlying object with id, value and extensions. The accessor
381   *              "getType" gives direct access to the value
382   */
383  public TriggerDefinition setTypeElement(Enumeration<TriggerType> value) {
384    this.type = value;
385    return this;
386  }
387
388  /**
389   * @return The type of triggering event.
390   */
391  public TriggerType getType() {
392    return this.type == null ? null : this.type.getValue();
393  }
394
395  /**
396   * @param value The type of triggering event.
397   */
398  public TriggerDefinition setType(TriggerType value) {
399    if (this.type == null)
400      this.type = new Enumeration<TriggerType>(new TriggerTypeEnumFactory());
401    this.type.setValue(value);
402    return this;
403  }
404
405  /**
406   * @return {@link #name} (A formal name for the event. This may be an absolute
407   *         URI that identifies the event formally (e.g. from a trigger
408   *         registry), or a simple relative URI that identifies the event in a
409   *         local context.). This is the underlying object with id, value and
410   *         extensions. The accessor "getName" gives direct access to the value
411   */
412  public StringType getNameElement() {
413    if (this.name == null)
414      if (Configuration.errorOnAutoCreate())
415        throw new Error("Attempt to auto-create TriggerDefinition.name");
416      else if (Configuration.doAutoCreate())
417        this.name = new StringType(); // bb
418    return this.name;
419  }
420
421  public boolean hasNameElement() {
422    return this.name != null && !this.name.isEmpty();
423  }
424
425  public boolean hasName() {
426    return this.name != null && !this.name.isEmpty();
427  }
428
429  /**
430   * @param value {@link #name} (A formal name for the event. This may be an
431   *              absolute URI that identifies the event formally (e.g. from a
432   *              trigger registry), or a simple relative URI that identifies the
433   *              event in a local context.). This is the underlying object with
434   *              id, value and extensions. The accessor "getName" gives direct
435   *              access to the value
436   */
437  public TriggerDefinition setNameElement(StringType value) {
438    this.name = value;
439    return this;
440  }
441
442  /**
443   * @return A formal name for the event. This may be an absolute URI that
444   *         identifies the event formally (e.g. from a trigger registry), or a
445   *         simple relative URI that identifies the event in a local context.
446   */
447  public String getName() {
448    return this.name == null ? null : this.name.getValue();
449  }
450
451  /**
452   * @param value A formal name for the event. This may be an absolute URI that
453   *              identifies the event formally (e.g. from a trigger registry), or
454   *              a simple relative URI that identifies the event in a local
455   *              context.
456   */
457  public TriggerDefinition setName(String value) {
458    if (Utilities.noString(value))
459      this.name = null;
460    else {
461      if (this.name == null)
462        this.name = new StringType();
463      this.name.setValue(value);
464    }
465    return this;
466  }
467
468  /**
469   * @return {@link #timing} (The timing of the event (if this is a periodic
470   *         trigger).)
471   */
472  public Type getTiming() {
473    return this.timing;
474  }
475
476  /**
477   * @return {@link #timing} (The timing of the event (if this is a periodic
478   *         trigger).)
479   */
480  public Timing getTimingTiming() throws FHIRException {
481    if (this.timing == null)
482      this.timing = new Timing();
483    if (!(this.timing instanceof Timing))
484      throw new FHIRException(
485          "Type mismatch: the type Timing was expected, but " + this.timing.getClass().getName() + " was encountered");
486    return (Timing) this.timing;
487  }
488
489  public boolean hasTimingTiming() {
490    return this != null && this.timing instanceof Timing;
491  }
492
493  /**
494   * @return {@link #timing} (The timing of the event (if this is a periodic
495   *         trigger).)
496   */
497  public Reference getTimingReference() throws FHIRException {
498    if (this.timing == null)
499      this.timing = new Reference();
500    if (!(this.timing instanceof Reference))
501      throw new FHIRException("Type mismatch: the type Reference was expected, but " + this.timing.getClass().getName()
502          + " was encountered");
503    return (Reference) this.timing;
504  }
505
506  public boolean hasTimingReference() {
507    return this != null && this.timing instanceof Reference;
508  }
509
510  /**
511   * @return {@link #timing} (The timing of the event (if this is a periodic
512   *         trigger).)
513   */
514  public DateType getTimingDateType() throws FHIRException {
515    if (this.timing == null)
516      this.timing = new DateType();
517    if (!(this.timing instanceof DateType))
518      throw new FHIRException("Type mismatch: the type DateType was expected, but " + this.timing.getClass().getName()
519          + " was encountered");
520    return (DateType) this.timing;
521  }
522
523  public boolean hasTimingDateType() {
524    return this != null && this.timing instanceof DateType;
525  }
526
527  /**
528   * @return {@link #timing} (The timing of the event (if this is a periodic
529   *         trigger).)
530   */
531  public DateTimeType getTimingDateTimeType() throws FHIRException {
532    if (this.timing == null)
533      this.timing = new DateTimeType();
534    if (!(this.timing instanceof DateTimeType))
535      throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "
536          + this.timing.getClass().getName() + " was encountered");
537    return (DateTimeType) this.timing;
538  }
539
540  public boolean hasTimingDateTimeType() {
541    return this != null && this.timing instanceof DateTimeType;
542  }
543
544  public boolean hasTiming() {
545    return this.timing != null && !this.timing.isEmpty();
546  }
547
548  /**
549   * @param value {@link #timing} (The timing of the event (if this is a periodic
550   *              trigger).)
551   */
552  public TriggerDefinition setTiming(Type value) {
553    if (value != null && !(value instanceof Timing || value instanceof Reference || value instanceof DateType
554        || value instanceof DateTimeType))
555      throw new Error("Not the right type for TriggerDefinition.timing[x]: " + value.fhirType());
556    this.timing = value;
557    return this;
558  }
559
560  /**
561   * @return {@link #data} (The triggering data of the event (if this is a data
562   *         trigger). If more than one data is requirement is specified, then all
563   *         the data requirements must be true.)
564   */
565  public List<DataRequirement> getData() {
566    if (this.data == null)
567      this.data = new ArrayList<DataRequirement>();
568    return this.data;
569  }
570
571  /**
572   * @return Returns a reference to <code>this</code> for easy method chaining
573   */
574  public TriggerDefinition setData(List<DataRequirement> theData) {
575    this.data = theData;
576    return this;
577  }
578
579  public boolean hasData() {
580    if (this.data == null)
581      return false;
582    for (DataRequirement item : this.data)
583      if (!item.isEmpty())
584        return true;
585    return false;
586  }
587
588  public DataRequirement addData() { // 3
589    DataRequirement t = new DataRequirement();
590    if (this.data == null)
591      this.data = new ArrayList<DataRequirement>();
592    this.data.add(t);
593    return t;
594  }
595
596  public TriggerDefinition addData(DataRequirement t) { // 3
597    if (t == null)
598      return this;
599    if (this.data == null)
600      this.data = new ArrayList<DataRequirement>();
601    this.data.add(t);
602    return this;
603  }
604
605  /**
606   * @return The first repetition of repeating field {@link #data}, creating it if
607   *         it does not already exist
608   */
609  public DataRequirement getDataFirstRep() {
610    if (getData().isEmpty()) {
611      addData();
612    }
613    return getData().get(0);
614  }
615
616  /**
617   * @return {@link #condition} (A boolean-valued expression that is evaluated in
618   *         the context of the container of the trigger definition and returns
619   *         whether or not the trigger fires.)
620   */
621  public Expression getCondition() {
622    if (this.condition == null)
623      if (Configuration.errorOnAutoCreate())
624        throw new Error("Attempt to auto-create TriggerDefinition.condition");
625      else if (Configuration.doAutoCreate())
626        this.condition = new Expression(); // cc
627    return this.condition;
628  }
629
630  public boolean hasCondition() {
631    return this.condition != null && !this.condition.isEmpty();
632  }
633
634  /**
635   * @param value {@link #condition} (A boolean-valued expression that is
636   *              evaluated in the context of the container of the trigger
637   *              definition and returns whether or not the trigger fires.)
638   */
639  public TriggerDefinition setCondition(Expression value) {
640    this.condition = value;
641    return this;
642  }
643
644  protected void listChildren(List<Property> children) {
645    super.listChildren(children);
646    children.add(new Property("type", "code", "The type of triggering event.", 0, 1, type));
647    children.add(new Property("name", "string",
648        "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.",
649        0, 1, name));
650    children.add(new Property("timing[x]", "Timing|Reference(Schedule)|date|dateTime",
651        "The timing of the event (if this is a periodic trigger).", 0, 1, timing));
652    children.add(new Property("data", "DataRequirement",
653        "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.",
654        0, java.lang.Integer.MAX_VALUE, data));
655    children.add(new Property("condition", "Expression",
656        "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.",
657        0, 1, condition));
658  }
659
660  @Override
661  public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
662    switch (_hash) {
663    case 3575610:
664      /* type */ return new Property("type", "code", "The type of triggering event.", 0, 1, type);
665    case 3373707:
666      /* name */ return new Property("name", "string",
667          "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.",
668          0, 1, name);
669    case 164632566:
670      /* timing[x] */ return new Property("timing[x]", "Timing|Reference(Schedule)|date|dateTime",
671          "The timing of the event (if this is a periodic trigger).", 0, 1, timing);
672    case -873664438:
673      /* timing */ return new Property("timing[x]", "Timing|Reference(Schedule)|date|dateTime",
674          "The timing of the event (if this is a periodic trigger).", 0, 1, timing);
675    case -497554124:
676      /* timingTiming */ return new Property("timing[x]", "Timing|Reference(Schedule)|date|dateTime",
677          "The timing of the event (if this is a periodic trigger).", 0, 1, timing);
678    case -1792466399:
679      /* timingReference */ return new Property("timing[x]", "Timing|Reference(Schedule)|date|dateTime",
680          "The timing of the event (if this is a periodic trigger).", 0, 1, timing);
681    case 807935768:
682      /* timingDate */ return new Property("timing[x]", "Timing|Reference(Schedule)|date|dateTime",
683          "The timing of the event (if this is a periodic trigger).", 0, 1, timing);
684    case -1837458939:
685      /* timingDateTime */ return new Property("timing[x]", "Timing|Reference(Schedule)|date|dateTime",
686          "The timing of the event (if this is a periodic trigger).", 0, 1, timing);
687    case 3076010:
688      /* data */ return new Property("data", "DataRequirement",
689          "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.",
690          0, java.lang.Integer.MAX_VALUE, data);
691    case -861311717:
692      /* condition */ return new Property("condition", "Expression",
693          "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.",
694          0, 1, condition);
695    default:
696      return super.getNamedProperty(_hash, _name, _checkValid);
697    }
698
699  }
700
701  @Override
702  public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
703    switch (hash) {
704    case 3575610:
705      /* type */ return this.type == null ? new Base[0] : new Base[] { this.type }; // Enumeration<TriggerType>
706    case 3373707:
707      /* name */ return this.name == null ? new Base[0] : new Base[] { this.name }; // StringType
708    case -873664438:
709      /* timing */ return this.timing == null ? new Base[0] : new Base[] { this.timing }; // Type
710    case 3076010:
711      /* data */ return this.data == null ? new Base[0] : this.data.toArray(new Base[this.data.size()]); // DataRequirement
712    case -861311717:
713      /* condition */ return this.condition == null ? new Base[0] : new Base[] { this.condition }; // Expression
714    default:
715      return super.getProperty(hash, name, checkValid);
716    }
717
718  }
719
720  @Override
721  public Base setProperty(int hash, String name, Base value) throws FHIRException {
722    switch (hash) {
723    case 3575610: // type
724      value = new TriggerTypeEnumFactory().fromType(castToCode(value));
725      this.type = (Enumeration) value; // Enumeration<TriggerType>
726      return value;
727    case 3373707: // name
728      this.name = castToString(value); // StringType
729      return value;
730    case -873664438: // timing
731      this.timing = castToType(value); // Type
732      return value;
733    case 3076010: // data
734      this.getData().add(castToDataRequirement(value)); // DataRequirement
735      return value;
736    case -861311717: // condition
737      this.condition = castToExpression(value); // Expression
738      return value;
739    default:
740      return super.setProperty(hash, name, value);
741    }
742
743  }
744
745  @Override
746  public Base setProperty(String name, Base value) throws FHIRException {
747    if (name.equals("type")) {
748      value = new TriggerTypeEnumFactory().fromType(castToCode(value));
749      this.type = (Enumeration) value; // Enumeration<TriggerType>
750    } else if (name.equals("name")) {
751      this.name = castToString(value); // StringType
752    } else if (name.equals("timing[x]")) {
753      this.timing = castToType(value); // Type
754    } else if (name.equals("data")) {
755      this.getData().add(castToDataRequirement(value));
756    } else if (name.equals("condition")) {
757      this.condition = castToExpression(value); // Expression
758    } else
759      return super.setProperty(name, value);
760    return value;
761  }
762
763  @Override
764  public Base makeProperty(int hash, String name) throws FHIRException {
765    switch (hash) {
766    case 3575610:
767      return getTypeElement();
768    case 3373707:
769      return getNameElement();
770    case 164632566:
771      return getTiming();
772    case -873664438:
773      return getTiming();
774    case 3076010:
775      return addData();
776    case -861311717:
777      return getCondition();
778    default:
779      return super.makeProperty(hash, name);
780    }
781
782  }
783
784  @Override
785  public String[] getTypesForProperty(int hash, String name) throws FHIRException {
786    switch (hash) {
787    case 3575610:
788      /* type */ return new String[] { "code" };
789    case 3373707:
790      /* name */ return new String[] { "string" };
791    case -873664438:
792      /* timing */ return new String[] { "Timing", "Reference", "date", "dateTime" };
793    case 3076010:
794      /* data */ return new String[] { "DataRequirement" };
795    case -861311717:
796      /* condition */ return new String[] { "Expression" };
797    default:
798      return super.getTypesForProperty(hash, name);
799    }
800
801  }
802
803  @Override
804  public Base addChild(String name) throws FHIRException {
805    if (name.equals("type")) {
806      throw new FHIRException("Cannot call addChild on a singleton property TriggerDefinition.type");
807    } else if (name.equals("name")) {
808      throw new FHIRException("Cannot call addChild on a singleton property TriggerDefinition.name");
809    } else if (name.equals("timingTiming")) {
810      this.timing = new Timing();
811      return this.timing;
812    } else if (name.equals("timingReference")) {
813      this.timing = new Reference();
814      return this.timing;
815    } else if (name.equals("timingDate")) {
816      this.timing = new DateType();
817      return this.timing;
818    } else if (name.equals("timingDateTime")) {
819      this.timing = new DateTimeType();
820      return this.timing;
821    } else if (name.equals("data")) {
822      return addData();
823    } else if (name.equals("condition")) {
824      this.condition = new Expression();
825      return this.condition;
826    } else
827      return super.addChild(name);
828  }
829
830  public String fhirType() {
831    return "TriggerDefinition";
832
833  }
834
835  public TriggerDefinition copy() {
836    TriggerDefinition dst = new TriggerDefinition();
837    copyValues(dst);
838    return dst;
839  }
840
841  public void copyValues(TriggerDefinition dst) {
842    super.copyValues(dst);
843    dst.type = type == null ? null : type.copy();
844    dst.name = name == null ? null : name.copy();
845    dst.timing = timing == null ? null : timing.copy();
846    if (data != null) {
847      dst.data = new ArrayList<DataRequirement>();
848      for (DataRequirement i : data)
849        dst.data.add(i.copy());
850    }
851    ;
852    dst.condition = condition == null ? null : condition.copy();
853  }
854
855  protected TriggerDefinition typedCopy() {
856    return copy();
857  }
858
859  @Override
860  public boolean equalsDeep(Base other_) {
861    if (!super.equalsDeep(other_))
862      return false;
863    if (!(other_ instanceof TriggerDefinition))
864      return false;
865    TriggerDefinition o = (TriggerDefinition) other_;
866    return compareDeep(type, o.type, true) && compareDeep(name, o.name, true) && compareDeep(timing, o.timing, true)
867        && compareDeep(data, o.data, true) && compareDeep(condition, o.condition, true);
868  }
869
870  @Override
871  public boolean equalsShallow(Base other_) {
872    if (!super.equalsShallow(other_))
873      return false;
874    if (!(other_ instanceof TriggerDefinition))
875      return false;
876    TriggerDefinition o = (TriggerDefinition) other_;
877    return compareValues(type, o.type, true) && compareValues(name, o.name, true);
878  }
879
880  public boolean isEmpty() {
881    return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, name, timing, data, condition);
882  }
883
884}