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 Sun, May 6, 2018 17:51-0400 for FHIR v3.4.0
033
034import java.util.*;
035
036import org.hl7.fhir.utilities.Utilities;
037import ca.uhn.fhir.model.api.annotation.Child;
038import ca.uhn.fhir.model.api.annotation.ChildOrder;
039import ca.uhn.fhir.model.api.annotation.Description;
040import ca.uhn.fhir.model.api.annotation.DatatypeDef;
041import ca.uhn.fhir.model.api.annotation.Block;
042import org.hl7.fhir.instance.model.api.*;
043import org.hl7.fhir.exceptions.FHIRException;
044/**
045 * A description of a triggering event. Triggering events can be named events, data events, or periodic, as determined by the type element.
046 */
047@DatatypeDef(name="TriggerDefinition")
048public class TriggerDefinition extends Type implements ICompositeType {
049
050    public enum TriggerType {
051        /**
052         * The trigger occurs in response to a specific named event, and no other information about the trigger is specified. Named events are completely pre-coordinated, and the formal semantics of the trigger are not provided
053         */
054        NAMEDEVENT, 
055        /**
056         * The trigger occurs at a specific time or periodically as described by a timing or schedule. A periodic event cannot have any data elements, but may have a name assigned as a shorthand for the event
057         */
058        PERIODIC, 
059        /**
060         * The trigger occurs whenever data of a particular type is changed in any way, either added, modified, or removed
061         */
062        DATACHANGED, 
063        /**
064         * The trigger occurs whenever data of a particular type is added
065         */
066        DATAADDED, 
067        /**
068         * The trigger occurs whenever data of a particular type is modified
069         */
070        DATAMODIFIED, 
071        /**
072         * The trigger occurs whenever data of a particular type is removed
073         */
074        DATAREMOVED, 
075        /**
076         * The trigger occurs whenever data of a particular type is accessed
077         */
078        DATAACCESSED, 
079        /**
080         * The trigger occurs whenever access to data of a particular type is completed
081         */
082        DATAACCESSENDED, 
083        /**
084         * added to help the parsers with the generic types
085         */
086        NULL;
087        public static TriggerType fromCode(String codeString) throws FHIRException {
088            if (codeString == null || "".equals(codeString))
089                return null;
090        if ("named-event".equals(codeString))
091          return NAMEDEVENT;
092        if ("periodic".equals(codeString))
093          return PERIODIC;
094        if ("data-changed".equals(codeString))
095          return DATACHANGED;
096        if ("data-added".equals(codeString))
097          return DATAADDED;
098        if ("data-modified".equals(codeString))
099          return DATAMODIFIED;
100        if ("data-removed".equals(codeString))
101          return DATAREMOVED;
102        if ("data-accessed".equals(codeString))
103          return DATAACCESSED;
104        if ("data-access-ended".equals(codeString))
105          return DATAACCESSENDED;
106        if (Configuration.isAcceptInvalidEnums())
107          return null;
108        else
109          throw new FHIRException("Unknown TriggerType code '"+codeString+"'");
110        }
111        public String toCode() {
112          switch (this) {
113            case NAMEDEVENT: return "named-event";
114            case PERIODIC: return "periodic";
115            case DATACHANGED: return "data-changed";
116            case DATAADDED: return "data-added";
117            case DATAMODIFIED: return "data-modified";
118            case DATAREMOVED: return "data-removed";
119            case DATAACCESSED: return "data-accessed";
120            case DATAACCESSENDED: return "data-access-ended";
121            default: return "?";
122          }
123        }
124        public String getSystem() {
125          switch (this) {
126            case NAMEDEVENT: return "http://hl7.org/fhir/trigger-type";
127            case PERIODIC: return "http://hl7.org/fhir/trigger-type";
128            case DATACHANGED: return "http://hl7.org/fhir/trigger-type";
129            case DATAADDED: return "http://hl7.org/fhir/trigger-type";
130            case DATAMODIFIED: return "http://hl7.org/fhir/trigger-type";
131            case DATAREMOVED: return "http://hl7.org/fhir/trigger-type";
132            case DATAACCESSED: return "http://hl7.org/fhir/trigger-type";
133            case DATAACCESSENDED: return "http://hl7.org/fhir/trigger-type";
134            default: return "?";
135          }
136        }
137        public String getDefinition() {
138          switch (this) {
139            case NAMEDEVENT: return "The trigger occurs in response to a specific named event, and no other information about the trigger is specified. Named events are completely pre-coordinated, and the formal semantics of the trigger are not provided";
140            case PERIODIC: return "The trigger occurs at a specific time or periodically as described by a timing or schedule. A periodic event cannot have any data elements, but may have a name assigned as a shorthand for the event";
141            case DATACHANGED: return "The trigger occurs whenever data of a particular type is changed in any way, either added, modified, or removed";
142            case DATAADDED: return "The trigger occurs whenever data of a particular type is added";
143            case DATAMODIFIED: return "The trigger occurs whenever data of a particular type is modified";
144            case DATAREMOVED: return "The trigger occurs whenever data of a particular type is removed";
145            case DATAACCESSED: return "The trigger occurs whenever data of a particular type is accessed";
146            case DATAACCESSENDED: return "The trigger occurs whenever access to data of a particular type is completed";
147            default: return "?";
148          }
149        }
150        public String getDisplay() {
151          switch (this) {
152            case NAMEDEVENT: return "Named Event";
153            case PERIODIC: return "Periodic";
154            case DATACHANGED: return "Data Changed";
155            case DATAADDED: return "Data Added";
156            case DATAMODIFIED: return "Data Updated";
157            case DATAREMOVED: return "Data Removed";
158            case DATAACCESSED: return "Data Accessed";
159            case DATAACCESSENDED: return "Data Access Ended";
160            default: return "?";
161          }
162        }
163    }
164
165  public static class TriggerTypeEnumFactory implements EnumFactory<TriggerType> {
166    public TriggerType fromCode(String codeString) throws IllegalArgumentException {
167      if (codeString == null || "".equals(codeString))
168            if (codeString == null || "".equals(codeString))
169                return null;
170        if ("named-event".equals(codeString))
171          return TriggerType.NAMEDEVENT;
172        if ("periodic".equals(codeString))
173          return TriggerType.PERIODIC;
174        if ("data-changed".equals(codeString))
175          return TriggerType.DATACHANGED;
176        if ("data-added".equals(codeString))
177          return TriggerType.DATAADDED;
178        if ("data-modified".equals(codeString))
179          return TriggerType.DATAMODIFIED;
180        if ("data-removed".equals(codeString))
181          return TriggerType.DATAREMOVED;
182        if ("data-accessed".equals(codeString))
183          return TriggerType.DATAACCESSED;
184        if ("data-access-ended".equals(codeString))
185          return TriggerType.DATAACCESSENDED;
186        throw new IllegalArgumentException("Unknown TriggerType code '"+codeString+"'");
187        }
188        public Enumeration<TriggerType> fromType(Base code) throws FHIRException {
189          if (code == null)
190            return null;
191          if (code.isEmpty())
192            return new Enumeration<TriggerType>(this);
193          String codeString = ((PrimitiveType) code).asStringValue();
194          if (codeString == null || "".equals(codeString))
195            return null;
196        if ("named-event".equals(codeString))
197          return new Enumeration<TriggerType>(this, TriggerType.NAMEDEVENT);
198        if ("periodic".equals(codeString))
199          return new Enumeration<TriggerType>(this, TriggerType.PERIODIC);
200        if ("data-changed".equals(codeString))
201          return new Enumeration<TriggerType>(this, TriggerType.DATACHANGED);
202        if ("data-added".equals(codeString))
203          return new Enumeration<TriggerType>(this, TriggerType.DATAADDED);
204        if ("data-modified".equals(codeString))
205          return new Enumeration<TriggerType>(this, TriggerType.DATAMODIFIED);
206        if ("data-removed".equals(codeString))
207          return new Enumeration<TriggerType>(this, TriggerType.DATAREMOVED);
208        if ("data-accessed".equals(codeString))
209          return new Enumeration<TriggerType>(this, TriggerType.DATAACCESSED);
210        if ("data-access-ended".equals(codeString))
211          return new Enumeration<TriggerType>(this, TriggerType.DATAACCESSENDED);
212        throw new FHIRException("Unknown TriggerType code '"+codeString+"'");
213        }
214    public String toCode(TriggerType code) {
215      if (code == TriggerType.NAMEDEVENT)
216        return "named-event";
217      if (code == TriggerType.PERIODIC)
218        return "periodic";
219      if (code == TriggerType.DATACHANGED)
220        return "data-changed";
221      if (code == TriggerType.DATAADDED)
222        return "data-added";
223      if (code == TriggerType.DATAMODIFIED)
224        return "data-modified";
225      if (code == TriggerType.DATAREMOVED)
226        return "data-removed";
227      if (code == TriggerType.DATAACCESSED)
228        return "data-accessed";
229      if (code == TriggerType.DATAACCESSENDED)
230        return "data-access-ended";
231      return "?";
232      }
233    public String toSystem(TriggerType code) {
234      return code.getSystem();
235      }
236    }
237
238    public enum ExpressionLanguage {
239        /**
240         * Clinical Quality Language
241         */
242        TEXT_CQL, 
243        /**
244         * FHIRPath
245         */
246        TEXT_FHIRPATH, 
247        /**
248         * added to help the parsers with the generic types
249         */
250        NULL;
251        public static ExpressionLanguage fromCode(String codeString) throws FHIRException {
252            if (codeString == null || "".equals(codeString))
253                return null;
254        if ("text/cql".equals(codeString))
255          return TEXT_CQL;
256        if ("text/fhirpath".equals(codeString))
257          return TEXT_FHIRPATH;
258        if (Configuration.isAcceptInvalidEnums())
259          return null;
260        else
261          throw new FHIRException("Unknown ExpressionLanguage code '"+codeString+"'");
262        }
263        public String toCode() {
264          switch (this) {
265            case TEXT_CQL: return "text/cql";
266            case TEXT_FHIRPATH: return "text/fhirpath";
267            default: return "?";
268          }
269        }
270        public String getSystem() {
271          switch (this) {
272            case TEXT_CQL: return "http://hl7.org/fhir/expression-language";
273            case TEXT_FHIRPATH: return "http://hl7.org/fhir/expression-language";
274            default: return "?";
275          }
276        }
277        public String getDefinition() {
278          switch (this) {
279            case TEXT_CQL: return "Clinical Quality Language";
280            case TEXT_FHIRPATH: return "FHIRPath";
281            default: return "?";
282          }
283        }
284        public String getDisplay() {
285          switch (this) {
286            case TEXT_CQL: return "CQL";
287            case TEXT_FHIRPATH: return "FHIRPath";
288            default: return "?";
289          }
290        }
291    }
292
293  public static class ExpressionLanguageEnumFactory implements EnumFactory<ExpressionLanguage> {
294    public ExpressionLanguage fromCode(String codeString) throws IllegalArgumentException {
295      if (codeString == null || "".equals(codeString))
296            if (codeString == null || "".equals(codeString))
297                return null;
298        if ("text/cql".equals(codeString))
299          return ExpressionLanguage.TEXT_CQL;
300        if ("text/fhirpath".equals(codeString))
301          return ExpressionLanguage.TEXT_FHIRPATH;
302        throw new IllegalArgumentException("Unknown ExpressionLanguage code '"+codeString+"'");
303        }
304        public Enumeration<ExpressionLanguage> fromType(Base code) throws FHIRException {
305          if (code == null)
306            return null;
307          if (code.isEmpty())
308            return new Enumeration<ExpressionLanguage>(this);
309          String codeString = ((PrimitiveType) code).asStringValue();
310          if (codeString == null || "".equals(codeString))
311            return null;
312        if ("text/cql".equals(codeString))
313          return new Enumeration<ExpressionLanguage>(this, ExpressionLanguage.TEXT_CQL);
314        if ("text/fhirpath".equals(codeString))
315          return new Enumeration<ExpressionLanguage>(this, ExpressionLanguage.TEXT_FHIRPATH);
316        throw new FHIRException("Unknown ExpressionLanguage code '"+codeString+"'");
317        }
318    public String toCode(ExpressionLanguage code) {
319      if (code == ExpressionLanguage.TEXT_CQL)
320        return "text/cql";
321      if (code == ExpressionLanguage.TEXT_FHIRPATH)
322        return "text/fhirpath";
323      return "?";
324      }
325    public String toSystem(ExpressionLanguage code) {
326      return code.getSystem();
327      }
328    }
329
330    @Block()
331    public static class TriggerDefinitionConditionComponent extends Element implements IBaseDatatypeElement {
332        /**
333         * A brief, natural language description of the condition that effectively communicates the intended semantics.
334         */
335        @Child(name = "description", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true)
336        @Description(shortDefinition="Natural language description of the condition", formalDefinition="A brief, natural language description of the condition that effectively communicates the intended semantics." )
337        protected StringType description;
338
339        /**
340         * The media type of the language for the expression.
341         */
342        @Child(name = "language", type = {CodeType.class}, order=2, min=1, max=1, modifier=false, summary=true)
343        @Description(shortDefinition="text/cql | text/fhirpath | etc.", formalDefinition="The media type of the language for the expression." )
344        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/expression-language")
345        protected Enumeration<ExpressionLanguage> language;
346
347        /**
348         * An expression that returns true or false, indicating whether or not the condition is satisfied.
349         */
350        @Child(name = "expression", type = {StringType.class}, order=3, min=1, max=1, modifier=false, summary=true)
351        @Description(shortDefinition="Boolean-valued expression", formalDefinition="An expression that returns true or false, indicating whether or not the condition is satisfied." )
352        protected StringType expression;
353
354        private static final long serialVersionUID = -1280303355L;
355
356    /**
357     * Constructor
358     */
359      public TriggerDefinitionConditionComponent() {
360        super();
361      }
362
363    /**
364     * Constructor
365     */
366      public TriggerDefinitionConditionComponent(Enumeration<ExpressionLanguage> language, StringType expression) {
367        super();
368        this.language = language;
369        this.expression = expression;
370      }
371
372        /**
373         * @return {@link #description} (A brief, natural language description of the condition that effectively communicates the intended semantics.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
374         */
375        public StringType getDescriptionElement() { 
376          if (this.description == null)
377            if (Configuration.errorOnAutoCreate())
378              throw new Error("Attempt to auto-create TriggerDefinitionConditionComponent.description");
379            else if (Configuration.doAutoCreate())
380              this.description = new StringType(); // bb
381          return this.description;
382        }
383
384        public boolean hasDescriptionElement() { 
385          return this.description != null && !this.description.isEmpty();
386        }
387
388        public boolean hasDescription() { 
389          return this.description != null && !this.description.isEmpty();
390        }
391
392        /**
393         * @param value {@link #description} (A brief, natural language description of the condition that effectively communicates the intended semantics.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
394         */
395        public TriggerDefinitionConditionComponent setDescriptionElement(StringType value) { 
396          this.description = value;
397          return this;
398        }
399
400        /**
401         * @return A brief, natural language description of the condition that effectively communicates the intended semantics.
402         */
403        public String getDescription() { 
404          return this.description == null ? null : this.description.getValue();
405        }
406
407        /**
408         * @param value A brief, natural language description of the condition that effectively communicates the intended semantics.
409         */
410        public TriggerDefinitionConditionComponent setDescription(String value) { 
411          if (Utilities.noString(value))
412            this.description = null;
413          else {
414            if (this.description == null)
415              this.description = new StringType();
416            this.description.setValue(value);
417          }
418          return this;
419        }
420
421        /**
422         * @return {@link #language} (The media type of the language for the expression.). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value
423         */
424        public Enumeration<ExpressionLanguage> getLanguageElement() { 
425          if (this.language == null)
426            if (Configuration.errorOnAutoCreate())
427              throw new Error("Attempt to auto-create TriggerDefinitionConditionComponent.language");
428            else if (Configuration.doAutoCreate())
429              this.language = new Enumeration<ExpressionLanguage>(new ExpressionLanguageEnumFactory()); // bb
430          return this.language;
431        }
432
433        public boolean hasLanguageElement() { 
434          return this.language != null && !this.language.isEmpty();
435        }
436
437        public boolean hasLanguage() { 
438          return this.language != null && !this.language.isEmpty();
439        }
440
441        /**
442         * @param value {@link #language} (The media type of the language for the expression.). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value
443         */
444        public TriggerDefinitionConditionComponent setLanguageElement(Enumeration<ExpressionLanguage> value) { 
445          this.language = value;
446          return this;
447        }
448
449        /**
450         * @return The media type of the language for the expression.
451         */
452        public ExpressionLanguage getLanguage() { 
453          return this.language == null ? null : this.language.getValue();
454        }
455
456        /**
457         * @param value The media type of the language for the expression.
458         */
459        public TriggerDefinitionConditionComponent setLanguage(ExpressionLanguage value) { 
460            if (this.language == null)
461              this.language = new Enumeration<ExpressionLanguage>(new ExpressionLanguageEnumFactory());
462            this.language.setValue(value);
463          return this;
464        }
465
466        /**
467         * @return {@link #expression} (An expression that returns true or false, indicating whether or not the condition is satisfied.). This is the underlying object with id, value and extensions. The accessor "getExpression" gives direct access to the value
468         */
469        public StringType getExpressionElement() { 
470          if (this.expression == null)
471            if (Configuration.errorOnAutoCreate())
472              throw new Error("Attempt to auto-create TriggerDefinitionConditionComponent.expression");
473            else if (Configuration.doAutoCreate())
474              this.expression = new StringType(); // bb
475          return this.expression;
476        }
477
478        public boolean hasExpressionElement() { 
479          return this.expression != null && !this.expression.isEmpty();
480        }
481
482        public boolean hasExpression() { 
483          return this.expression != null && !this.expression.isEmpty();
484        }
485
486        /**
487         * @param value {@link #expression} (An expression that returns true or false, indicating whether or not the condition is satisfied.). This is the underlying object with id, value and extensions. The accessor "getExpression" gives direct access to the value
488         */
489        public TriggerDefinitionConditionComponent setExpressionElement(StringType value) { 
490          this.expression = value;
491          return this;
492        }
493
494        /**
495         * @return An expression that returns true or false, indicating whether or not the condition is satisfied.
496         */
497        public String getExpression() { 
498          return this.expression == null ? null : this.expression.getValue();
499        }
500
501        /**
502         * @param value An expression that returns true or false, indicating whether or not the condition is satisfied.
503         */
504        public TriggerDefinitionConditionComponent setExpression(String value) { 
505            if (this.expression == null)
506              this.expression = new StringType();
507            this.expression.setValue(value);
508          return this;
509        }
510
511        protected void listChildren(List<Property> children) {
512          super.listChildren(children);
513          children.add(new Property("description", "string", "A brief, natural language description of the condition that effectively communicates the intended semantics.", 0, 1, description));
514          children.add(new Property("language", "code", "The media type of the language for the expression.", 0, 1, language));
515          children.add(new Property("expression", "string", "An expression that returns true or false, indicating whether or not the condition is satisfied.", 0, 1, expression));
516        }
517
518        @Override
519        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
520          switch (_hash) {
521          case -1724546052: /*description*/  return new Property("description", "string", "A brief, natural language description of the condition that effectively communicates the intended semantics.", 0, 1, description);
522          case -1613589672: /*language*/  return new Property("language", "code", "The media type of the language for the expression.", 0, 1, language);
523          case -1795452264: /*expression*/  return new Property("expression", "string", "An expression that returns true or false, indicating whether or not the condition is satisfied.", 0, 1, expression);
524          default: return super.getNamedProperty(_hash, _name, _checkValid);
525          }
526
527        }
528
529      @Override
530      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
531        switch (hash) {
532        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // StringType
533        case -1613589672: /*language*/ return this.language == null ? new Base[0] : new Base[] {this.language}; // Enumeration<ExpressionLanguage>
534        case -1795452264: /*expression*/ return this.expression == null ? new Base[0] : new Base[] {this.expression}; // StringType
535        default: return super.getProperty(hash, name, checkValid);
536        }
537
538      }
539
540      @Override
541      public Base setProperty(int hash, String name, Base value) throws FHIRException {
542        switch (hash) {
543        case -1724546052: // description
544          this.description = castToString(value); // StringType
545          return value;
546        case -1613589672: // language
547          value = new ExpressionLanguageEnumFactory().fromType(castToCode(value));
548          this.language = (Enumeration) value; // Enumeration<ExpressionLanguage>
549          return value;
550        case -1795452264: // expression
551          this.expression = castToString(value); // StringType
552          return value;
553        default: return super.setProperty(hash, name, value);
554        }
555
556      }
557
558      @Override
559      public Base setProperty(String name, Base value) throws FHIRException {
560        if (name.equals("description")) {
561          this.description = castToString(value); // StringType
562        } else if (name.equals("language")) {
563          value = new ExpressionLanguageEnumFactory().fromType(castToCode(value));
564          this.language = (Enumeration) value; // Enumeration<ExpressionLanguage>
565        } else if (name.equals("expression")) {
566          this.expression = castToString(value); // StringType
567        } else
568          return super.setProperty(name, value);
569        return value;
570      }
571
572      @Override
573      public Base makeProperty(int hash, String name) throws FHIRException {
574        switch (hash) {
575        case -1724546052:  return getDescriptionElement();
576        case -1613589672:  return getLanguageElement();
577        case -1795452264:  return getExpressionElement();
578        default: return super.makeProperty(hash, name);
579        }
580
581      }
582
583      @Override
584      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
585        switch (hash) {
586        case -1724546052: /*description*/ return new String[] {"string"};
587        case -1613589672: /*language*/ return new String[] {"code"};
588        case -1795452264: /*expression*/ return new String[] {"string"};
589        default: return super.getTypesForProperty(hash, name);
590        }
591
592      }
593
594      @Override
595      public Base addChild(String name) throws FHIRException {
596        if (name.equals("description")) {
597          throw new FHIRException("Cannot call addChild on a primitive type TriggerDefinition.description");
598        }
599        else if (name.equals("language")) {
600          throw new FHIRException("Cannot call addChild on a primitive type TriggerDefinition.language");
601        }
602        else if (name.equals("expression")) {
603          throw new FHIRException("Cannot call addChild on a primitive type TriggerDefinition.expression");
604        }
605        else
606          return super.addChild(name);
607      }
608
609      public TriggerDefinitionConditionComponent copy() {
610        TriggerDefinitionConditionComponent dst = new TriggerDefinitionConditionComponent();
611        copyValues(dst);
612        dst.description = description == null ? null : description.copy();
613        dst.language = language == null ? null : language.copy();
614        dst.expression = expression == null ? null : expression.copy();
615        return dst;
616      }
617
618      @Override
619      public boolean equalsDeep(Base other_) {
620        if (!super.equalsDeep(other_))
621          return false;
622        if (!(other_ instanceof TriggerDefinitionConditionComponent))
623          return false;
624        TriggerDefinitionConditionComponent o = (TriggerDefinitionConditionComponent) other_;
625        return compareDeep(description, o.description, true) && compareDeep(language, o.language, true)
626           && compareDeep(expression, o.expression, true);
627      }
628
629      @Override
630      public boolean equalsShallow(Base other_) {
631        if (!super.equalsShallow(other_))
632          return false;
633        if (!(other_ instanceof TriggerDefinitionConditionComponent))
634          return false;
635        TriggerDefinitionConditionComponent o = (TriggerDefinitionConditionComponent) other_;
636        return compareValues(description, o.description, true) && compareValues(language, o.language, true)
637           && compareValues(expression, o.expression, true);
638      }
639
640      public boolean isEmpty() {
641        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(description, language, expression
642          );
643      }
644
645  public String fhirType() {
646    return "TriggerDefinition.condition";
647
648  }
649
650  }
651
652    /**
653     * The type of triggering event.
654     */
655    @Child(name = "type", type = {CodeType.class}, order=0, min=1, max=1, modifier=false, summary=true)
656    @Description(shortDefinition="named-event | periodic | data-changed | data-added | data-modified | data-removed | data-accessed | data-access-ended", formalDefinition="The type of triggering event." )
657    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/trigger-type")
658    protected Enumeration<TriggerType> type;
659
660    /**
661     * 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.
662     */
663    @Child(name = "name", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true)
664    @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." )
665    protected StringType name;
666
667    /**
668     * The timing of the event (if this is a periodic trigger).
669     */
670    @Child(name = "timing", type = {Timing.class, Schedule.class, DateType.class, DateTimeType.class}, order=2, min=0, max=1, modifier=false, summary=true)
671    @Description(shortDefinition="Timing of the event", formalDefinition="The timing of the event (if this is a periodic trigger)." )
672    protected Type timing;
673
674    /**
675     * The triggering data of the event (if this is a data trigger).
676     */
677    @Child(name = "data", type = {DataRequirement.class}, order=3, min=0, max=1, modifier=false, summary=true)
678    @Description(shortDefinition="Triggering data of the event", formalDefinition="The triggering data of the event (if this is a data trigger)." )
679    protected DataRequirement data;
680
681    /**
682     * 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.
683     */
684    @Child(name = "condition", type = {}, order=4, min=0, max=1, modifier=false, summary=true)
685    @Description(shortDefinition="Whether the event triggers", 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." )
686    protected TriggerDefinitionConditionComponent condition;
687
688    private static final long serialVersionUID = -2027399070L;
689
690  /**
691   * Constructor
692   */
693    public TriggerDefinition() {
694      super();
695    }
696
697  /**
698   * Constructor
699   */
700    public TriggerDefinition(Enumeration<TriggerType> type) {
701      super();
702      this.type = type;
703    }
704
705    /**
706     * @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
707     */
708    public Enumeration<TriggerType> getTypeElement() { 
709      if (this.type == null)
710        if (Configuration.errorOnAutoCreate())
711          throw new Error("Attempt to auto-create TriggerDefinition.type");
712        else if (Configuration.doAutoCreate())
713          this.type = new Enumeration<TriggerType>(new TriggerTypeEnumFactory()); // bb
714      return this.type;
715    }
716
717    public boolean hasTypeElement() { 
718      return this.type != null && !this.type.isEmpty();
719    }
720
721    public boolean hasType() { 
722      return this.type != null && !this.type.isEmpty();
723    }
724
725    /**
726     * @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
727     */
728    public TriggerDefinition setTypeElement(Enumeration<TriggerType> value) { 
729      this.type = value;
730      return this;
731    }
732
733    /**
734     * @return The type of triggering event.
735     */
736    public TriggerType getType() { 
737      return this.type == null ? null : this.type.getValue();
738    }
739
740    /**
741     * @param value The type of triggering event.
742     */
743    public TriggerDefinition setType(TriggerType value) { 
744        if (this.type == null)
745          this.type = new Enumeration<TriggerType>(new TriggerTypeEnumFactory());
746        this.type.setValue(value);
747      return this;
748    }
749
750    /**
751     * @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
752     */
753    public StringType getNameElement() { 
754      if (this.name == null)
755        if (Configuration.errorOnAutoCreate())
756          throw new Error("Attempt to auto-create TriggerDefinition.name");
757        else if (Configuration.doAutoCreate())
758          this.name = new StringType(); // bb
759      return this.name;
760    }
761
762    public boolean hasNameElement() { 
763      return this.name != null && !this.name.isEmpty();
764    }
765
766    public boolean hasName() { 
767      return this.name != null && !this.name.isEmpty();
768    }
769
770    /**
771     * @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
772     */
773    public TriggerDefinition setNameElement(StringType value) { 
774      this.name = value;
775      return this;
776    }
777
778    /**
779     * @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.
780     */
781    public String getName() { 
782      return this.name == null ? null : this.name.getValue();
783    }
784
785    /**
786     * @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.
787     */
788    public TriggerDefinition setName(String value) { 
789      if (Utilities.noString(value))
790        this.name = null;
791      else {
792        if (this.name == null)
793          this.name = new StringType();
794        this.name.setValue(value);
795      }
796      return this;
797    }
798
799    /**
800     * @return {@link #timing} (The timing of the event (if this is a periodic trigger).)
801     */
802    public Type getTiming() { 
803      return this.timing;
804    }
805
806    /**
807     * @return {@link #timing} (The timing of the event (if this is a periodic trigger).)
808     */
809    public Timing getTimingTiming() throws FHIRException { 
810      if (this.timing == null)
811        return null;
812      if (!(this.timing instanceof Timing))
813        throw new FHIRException("Type mismatch: the type Timing was expected, but "+this.timing.getClass().getName()+" was encountered");
814      return (Timing) this.timing;
815    }
816
817    public boolean hasTimingTiming() { 
818      return this != null && this.timing instanceof Timing;
819    }
820
821    /**
822     * @return {@link #timing} (The timing of the event (if this is a periodic trigger).)
823     */
824    public Reference getTimingReference() throws FHIRException { 
825      if (this.timing == null)
826        return null;
827      if (!(this.timing instanceof Reference))
828        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.timing.getClass().getName()+" was encountered");
829      return (Reference) this.timing;
830    }
831
832    public boolean hasTimingReference() { 
833      return this != null && this.timing instanceof Reference;
834    }
835
836    /**
837     * @return {@link #timing} (The timing of the event (if this is a periodic trigger).)
838     */
839    public DateType getTimingDateType() throws FHIRException { 
840      if (this.timing == null)
841        return null;
842      if (!(this.timing instanceof DateType))
843        throw new FHIRException("Type mismatch: the type DateType was expected, but "+this.timing.getClass().getName()+" was encountered");
844      return (DateType) this.timing;
845    }
846
847    public boolean hasTimingDateType() { 
848      return this != null && this.timing instanceof DateType;
849    }
850
851    /**
852     * @return {@link #timing} (The timing of the event (if this is a periodic trigger).)
853     */
854    public DateTimeType getTimingDateTimeType() throws FHIRException { 
855      if (this.timing == null)
856        return null;
857      if (!(this.timing instanceof DateTimeType))
858        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.timing.getClass().getName()+" was encountered");
859      return (DateTimeType) this.timing;
860    }
861
862    public boolean hasTimingDateTimeType() { 
863      return this != null && this.timing instanceof DateTimeType;
864    }
865
866    public boolean hasTiming() { 
867      return this.timing != null && !this.timing.isEmpty();
868    }
869
870    /**
871     * @param value {@link #timing} (The timing of the event (if this is a periodic trigger).)
872     */
873    public TriggerDefinition setTiming(Type value) { 
874      if (value != null && !(value instanceof Timing || value instanceof Reference || value instanceof DateType || value instanceof DateTimeType))
875        throw new Error("Not the right type for TriggerDefinition.timing[x]: "+value.fhirType());
876      this.timing = value;
877      return this;
878    }
879
880    /**
881     * @return {@link #data} (The triggering data of the event (if this is a data trigger).)
882     */
883    public DataRequirement getData() { 
884      if (this.data == null)
885        if (Configuration.errorOnAutoCreate())
886          throw new Error("Attempt to auto-create TriggerDefinition.data");
887        else if (Configuration.doAutoCreate())
888          this.data = new DataRequirement(); // cc
889      return this.data;
890    }
891
892    public boolean hasData() { 
893      return this.data != null && !this.data.isEmpty();
894    }
895
896    /**
897     * @param value {@link #data} (The triggering data of the event (if this is a data trigger).)
898     */
899    public TriggerDefinition setData(DataRequirement value) { 
900      this.data = value;
901      return this;
902    }
903
904    /**
905     * @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.)
906     */
907    public TriggerDefinitionConditionComponent getCondition() { 
908      if (this.condition == null)
909        if (Configuration.errorOnAutoCreate())
910          throw new Error("Attempt to auto-create TriggerDefinition.condition");
911        else if (Configuration.doAutoCreate())
912          this.condition = new TriggerDefinitionConditionComponent(); // cc
913      return this.condition;
914    }
915
916    public boolean hasCondition() { 
917      return this.condition != null && !this.condition.isEmpty();
918    }
919
920    /**
921     * @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.)
922     */
923    public TriggerDefinition setCondition(TriggerDefinitionConditionComponent value) { 
924      this.condition = value;
925      return this;
926    }
927
928      protected void listChildren(List<Property> children) {
929        super.listChildren(children);
930        children.add(new Property("type", "code", "The type of triggering event.", 0, 1, type));
931        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));
932        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));
933        children.add(new Property("data", "DataRequirement", "The triggering data of the event (if this is a data trigger).", 0, 1, data));
934        children.add(new Property("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.", 0, 1, condition));
935      }
936
937      @Override
938      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
939        switch (_hash) {
940        case 3575610: /*type*/  return new Property("type", "code", "The type of triggering event.", 0, 1, type);
941        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);
942        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);
943        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);
944        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);
945        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);
946        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);
947        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);
948        case 3076010: /*data*/  return new Property("data", "DataRequirement", "The triggering data of the event (if this is a data trigger).", 0, 1, data);
949        case -861311717: /*condition*/  return new Property("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.", 0, 1, condition);
950        default: return super.getNamedProperty(_hash, _name, _checkValid);
951        }
952
953      }
954
955      @Override
956      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
957        switch (hash) {
958        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // Enumeration<TriggerType>
959        case 3373707: /*name*/ return this.name == null ? new Base[0] : new Base[] {this.name}; // StringType
960        case -873664438: /*timing*/ return this.timing == null ? new Base[0] : new Base[] {this.timing}; // Type
961        case 3076010: /*data*/ return this.data == null ? new Base[0] : new Base[] {this.data}; // DataRequirement
962        case -861311717: /*condition*/ return this.condition == null ? new Base[0] : new Base[] {this.condition}; // TriggerDefinitionConditionComponent
963        default: return super.getProperty(hash, name, checkValid);
964        }
965
966      }
967
968      @Override
969      public Base setProperty(int hash, String name, Base value) throws FHIRException {
970        switch (hash) {
971        case 3575610: // type
972          value = new TriggerTypeEnumFactory().fromType(castToCode(value));
973          this.type = (Enumeration) value; // Enumeration<TriggerType>
974          return value;
975        case 3373707: // name
976          this.name = castToString(value); // StringType
977          return value;
978        case -873664438: // timing
979          this.timing = castToType(value); // Type
980          return value;
981        case 3076010: // data
982          this.data = castToDataRequirement(value); // DataRequirement
983          return value;
984        case -861311717: // condition
985          this.condition = (TriggerDefinitionConditionComponent) value; // TriggerDefinitionConditionComponent
986          return value;
987        default: return super.setProperty(hash, name, value);
988        }
989
990      }
991
992      @Override
993      public Base setProperty(String name, Base value) throws FHIRException {
994        if (name.equals("type")) {
995          value = new TriggerTypeEnumFactory().fromType(castToCode(value));
996          this.type = (Enumeration) value; // Enumeration<TriggerType>
997        } else if (name.equals("name")) {
998          this.name = castToString(value); // StringType
999        } else if (name.equals("timing[x]")) {
1000          this.timing = castToType(value); // Type
1001        } else if (name.equals("data")) {
1002          this.data = castToDataRequirement(value); // DataRequirement
1003        } else if (name.equals("condition")) {
1004          this.condition = (TriggerDefinitionConditionComponent) value; // TriggerDefinitionConditionComponent
1005        } else
1006          return super.setProperty(name, value);
1007        return value;
1008      }
1009
1010      @Override
1011      public Base makeProperty(int hash, String name) throws FHIRException {
1012        switch (hash) {
1013        case 3575610:  return getTypeElement();
1014        case 3373707:  return getNameElement();
1015        case 164632566:  return getTiming(); 
1016        case -873664438:  return getTiming(); 
1017        case 3076010:  return getData(); 
1018        case -861311717:  return getCondition(); 
1019        default: return super.makeProperty(hash, name);
1020        }
1021
1022      }
1023
1024      @Override
1025      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1026        switch (hash) {
1027        case 3575610: /*type*/ return new String[] {"code"};
1028        case 3373707: /*name*/ return new String[] {"string"};
1029        case -873664438: /*timing*/ return new String[] {"Timing", "Reference", "date", "dateTime"};
1030        case 3076010: /*data*/ return new String[] {"DataRequirement"};
1031        case -861311717: /*condition*/ return new String[] {};
1032        default: return super.getTypesForProperty(hash, name);
1033        }
1034
1035      }
1036
1037      @Override
1038      public Base addChild(String name) throws FHIRException {
1039        if (name.equals("type")) {
1040          throw new FHIRException("Cannot call addChild on a primitive type TriggerDefinition.type");
1041        }
1042        else if (name.equals("name")) {
1043          throw new FHIRException("Cannot call addChild on a primitive type TriggerDefinition.name");
1044        }
1045        else if (name.equals("timingTiming")) {
1046          this.timing = new Timing();
1047          return this.timing;
1048        }
1049        else if (name.equals("timingReference")) {
1050          this.timing = new Reference();
1051          return this.timing;
1052        }
1053        else if (name.equals("timingDate")) {
1054          this.timing = new DateType();
1055          return this.timing;
1056        }
1057        else if (name.equals("timingDateTime")) {
1058          this.timing = new DateTimeType();
1059          return this.timing;
1060        }
1061        else if (name.equals("data")) {
1062          this.data = new DataRequirement();
1063          return this.data;
1064        }
1065        else if (name.equals("condition")) {
1066          this.condition = new TriggerDefinitionConditionComponent();
1067          return this.condition;
1068        }
1069        else
1070          return super.addChild(name);
1071      }
1072
1073  public String fhirType() {
1074    return "TriggerDefinition";
1075
1076  }
1077
1078      public TriggerDefinition copy() {
1079        TriggerDefinition dst = new TriggerDefinition();
1080        copyValues(dst);
1081        dst.type = type == null ? null : type.copy();
1082        dst.name = name == null ? null : name.copy();
1083        dst.timing = timing == null ? null : timing.copy();
1084        dst.data = data == null ? null : data.copy();
1085        dst.condition = condition == null ? null : condition.copy();
1086        return dst;
1087      }
1088
1089      protected TriggerDefinition typedCopy() {
1090        return copy();
1091      }
1092
1093      @Override
1094      public boolean equalsDeep(Base other_) {
1095        if (!super.equalsDeep(other_))
1096          return false;
1097        if (!(other_ instanceof TriggerDefinition))
1098          return false;
1099        TriggerDefinition o = (TriggerDefinition) other_;
1100        return compareDeep(type, o.type, true) && compareDeep(name, o.name, true) && compareDeep(timing, o.timing, true)
1101           && compareDeep(data, o.data, true) && compareDeep(condition, o.condition, true);
1102      }
1103
1104      @Override
1105      public boolean equalsShallow(Base other_) {
1106        if (!super.equalsShallow(other_))
1107          return false;
1108        if (!(other_ instanceof TriggerDefinition))
1109          return false;
1110        TriggerDefinition o = (TriggerDefinition) other_;
1111        return compareValues(type, o.type, true) && compareValues(name, o.name, true);
1112      }
1113
1114      public boolean isEmpty() {
1115        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, name, timing, data
1116          , condition);
1117      }
1118
1119
1120}
1121