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