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