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 Thu, Dec 27, 2018 10:06-0500 for FHIR v4.0.0
033
034import java.util.*;
035
036import org.hl7.fhir.utilities.Utilities;
037import ca.uhn.fhir.model.api.annotation.ResourceDef;
038import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.ChildOrder;
041import ca.uhn.fhir.model.api.annotation.Description;
042import ca.uhn.fhir.model.api.annotation.Block;
043import org.hl7.fhir.instance.model.api.*;
044import org.hl7.fhir.exceptions.FHIRException;
045/**
046 * Actual or  potential/avoided event causing unintended physical injury resulting from or contributed to by medical care, a research study or other healthcare setting factors that requires additional monitoring, treatment, or hospitalization, or that results in death.
047 */
048@ResourceDef(name="AdverseEvent", profile="http://hl7.org/fhir/StructureDefinition/AdverseEvent")
049public class AdverseEvent extends DomainResource {
050
051    public enum AdverseEventActuality {
052        /**
053         * The adverse event actually happened regardless of whether anyone was affected or harmed.
054         */
055        ACTUAL, 
056        /**
057         * A potential adverse event.
058         */
059        POTENTIAL, 
060        /**
061         * added to help the parsers with the generic types
062         */
063        NULL;
064        public static AdverseEventActuality fromCode(String codeString) throws FHIRException {
065            if (codeString == null || "".equals(codeString))
066                return null;
067        if ("actual".equals(codeString))
068          return ACTUAL;
069        if ("potential".equals(codeString))
070          return POTENTIAL;
071        if (Configuration.isAcceptInvalidEnums())
072          return null;
073        else
074          throw new FHIRException("Unknown AdverseEventActuality code '"+codeString+"'");
075        }
076        public String toCode() {
077          switch (this) {
078            case ACTUAL: return "actual";
079            case POTENTIAL: return "potential";
080            default: return "?";
081          }
082        }
083        public String getSystem() {
084          switch (this) {
085            case ACTUAL: return "http://hl7.org/fhir/adverse-event-actuality";
086            case POTENTIAL: return "http://hl7.org/fhir/adverse-event-actuality";
087            default: return "?";
088          }
089        }
090        public String getDefinition() {
091          switch (this) {
092            case ACTUAL: return "The adverse event actually happened regardless of whether anyone was affected or harmed.";
093            case POTENTIAL: return "A potential adverse event.";
094            default: return "?";
095          }
096        }
097        public String getDisplay() {
098          switch (this) {
099            case ACTUAL: return "Adverse Event";
100            case POTENTIAL: return "Potential Adverse Event";
101            default: return "?";
102          }
103        }
104    }
105
106  public static class AdverseEventActualityEnumFactory implements EnumFactory<AdverseEventActuality> {
107    public AdverseEventActuality fromCode(String codeString) throws IllegalArgumentException {
108      if (codeString == null || "".equals(codeString))
109            if (codeString == null || "".equals(codeString))
110                return null;
111        if ("actual".equals(codeString))
112          return AdverseEventActuality.ACTUAL;
113        if ("potential".equals(codeString))
114          return AdverseEventActuality.POTENTIAL;
115        throw new IllegalArgumentException("Unknown AdverseEventActuality code '"+codeString+"'");
116        }
117        public Enumeration<AdverseEventActuality> fromType(Base code) throws FHIRException {
118          if (code == null)
119            return null;
120          if (code.isEmpty())
121            return new Enumeration<AdverseEventActuality>(this);
122          String codeString = ((PrimitiveType) code).asStringValue();
123          if (codeString == null || "".equals(codeString))
124            return null;
125        if ("actual".equals(codeString))
126          return new Enumeration<AdverseEventActuality>(this, AdverseEventActuality.ACTUAL);
127        if ("potential".equals(codeString))
128          return new Enumeration<AdverseEventActuality>(this, AdverseEventActuality.POTENTIAL);
129        throw new FHIRException("Unknown AdverseEventActuality code '"+codeString+"'");
130        }
131    public String toCode(AdverseEventActuality code) {
132      if (code == AdverseEventActuality.ACTUAL)
133        return "actual";
134      if (code == AdverseEventActuality.POTENTIAL)
135        return "potential";
136      return "?";
137      }
138    public String toSystem(AdverseEventActuality code) {
139      return code.getSystem();
140      }
141    }
142
143    @Block()
144    public static class AdverseEventSuspectEntityComponent extends BackboneElement implements IBaseBackboneElement {
145        /**
146         * Identifies the actual instance of what caused the adverse event.  May be a substance, medication, medication administration, medication statement or a device.
147         */
148        @Child(name = "instance", type = {Immunization.class, Procedure.class, Substance.class, Medication.class, MedicationAdministration.class, MedicationStatement.class, Device.class}, order=1, min=1, max=1, modifier=false, summary=true)
149        @Description(shortDefinition="Refers to the specific entity that caused the adverse event", formalDefinition="Identifies the actual instance of what caused the adverse event.  May be a substance, medication, medication administration, medication statement or a device." )
150        protected Reference instance;
151
152        /**
153         * The actual object that is the target of the reference (Identifies the actual instance of what caused the adverse event.  May be a substance, medication, medication administration, medication statement or a device.)
154         */
155        protected Resource instanceTarget;
156
157        /**
158         * Information on the possible cause of the event.
159         */
160        @Child(name = "causality", type = {}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
161        @Description(shortDefinition="Information on the possible cause of the event", formalDefinition="Information on the possible cause of the event." )
162        protected List<AdverseEventSuspectEntityCausalityComponent> causality;
163
164        private static final long serialVersionUID = 1245759325L;
165
166    /**
167     * Constructor
168     */
169      public AdverseEventSuspectEntityComponent() {
170        super();
171      }
172
173    /**
174     * Constructor
175     */
176      public AdverseEventSuspectEntityComponent(Reference instance) {
177        super();
178        this.instance = instance;
179      }
180
181        /**
182         * @return {@link #instance} (Identifies the actual instance of what caused the adverse event.  May be a substance, medication, medication administration, medication statement or a device.)
183         */
184        public Reference getInstance() { 
185          if (this.instance == null)
186            if (Configuration.errorOnAutoCreate())
187              throw new Error("Attempt to auto-create AdverseEventSuspectEntityComponent.instance");
188            else if (Configuration.doAutoCreate())
189              this.instance = new Reference(); // cc
190          return this.instance;
191        }
192
193        public boolean hasInstance() { 
194          return this.instance != null && !this.instance.isEmpty();
195        }
196
197        /**
198         * @param value {@link #instance} (Identifies the actual instance of what caused the adverse event.  May be a substance, medication, medication administration, medication statement or a device.)
199         */
200        public AdverseEventSuspectEntityComponent setInstance(Reference value) { 
201          this.instance = value;
202          return this;
203        }
204
205        /**
206         * @return {@link #instance} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Identifies the actual instance of what caused the adverse event.  May be a substance, medication, medication administration, medication statement or a device.)
207         */
208        public Resource getInstanceTarget() { 
209          return this.instanceTarget;
210        }
211
212        /**
213         * @param value {@link #instance} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Identifies the actual instance of what caused the adverse event.  May be a substance, medication, medication administration, medication statement or a device.)
214         */
215        public AdverseEventSuspectEntityComponent setInstanceTarget(Resource value) { 
216          this.instanceTarget = value;
217          return this;
218        }
219
220        /**
221         * @return {@link #causality} (Information on the possible cause of the event.)
222         */
223        public List<AdverseEventSuspectEntityCausalityComponent> getCausality() { 
224          if (this.causality == null)
225            this.causality = new ArrayList<AdverseEventSuspectEntityCausalityComponent>();
226          return this.causality;
227        }
228
229        /**
230         * @return Returns a reference to <code>this</code> for easy method chaining
231         */
232        public AdverseEventSuspectEntityComponent setCausality(List<AdverseEventSuspectEntityCausalityComponent> theCausality) { 
233          this.causality = theCausality;
234          return this;
235        }
236
237        public boolean hasCausality() { 
238          if (this.causality == null)
239            return false;
240          for (AdverseEventSuspectEntityCausalityComponent item : this.causality)
241            if (!item.isEmpty())
242              return true;
243          return false;
244        }
245
246        public AdverseEventSuspectEntityCausalityComponent addCausality() { //3
247          AdverseEventSuspectEntityCausalityComponent t = new AdverseEventSuspectEntityCausalityComponent();
248          if (this.causality == null)
249            this.causality = new ArrayList<AdverseEventSuspectEntityCausalityComponent>();
250          this.causality.add(t);
251          return t;
252        }
253
254        public AdverseEventSuspectEntityComponent addCausality(AdverseEventSuspectEntityCausalityComponent t) { //3
255          if (t == null)
256            return this;
257          if (this.causality == null)
258            this.causality = new ArrayList<AdverseEventSuspectEntityCausalityComponent>();
259          this.causality.add(t);
260          return this;
261        }
262
263        /**
264         * @return The first repetition of repeating field {@link #causality}, creating it if it does not already exist
265         */
266        public AdverseEventSuspectEntityCausalityComponent getCausalityFirstRep() { 
267          if (getCausality().isEmpty()) {
268            addCausality();
269          }
270          return getCausality().get(0);
271        }
272
273        protected void listChildren(List<Property> children) {
274          super.listChildren(children);
275          children.add(new Property("instance", "Reference(Immunization|Procedure|Substance|Medication|MedicationAdministration|MedicationStatement|Device)", "Identifies the actual instance of what caused the adverse event.  May be a substance, medication, medication administration, medication statement or a device.", 0, 1, instance));
276          children.add(new Property("causality", "", "Information on the possible cause of the event.", 0, java.lang.Integer.MAX_VALUE, causality));
277        }
278
279        @Override
280        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
281          switch (_hash) {
282          case 555127957: /*instance*/  return new Property("instance", "Reference(Immunization|Procedure|Substance|Medication|MedicationAdministration|MedicationStatement|Device)", "Identifies the actual instance of what caused the adverse event.  May be a substance, medication, medication administration, medication statement or a device.", 0, 1, instance);
283          case -1446450521: /*causality*/  return new Property("causality", "", "Information on the possible cause of the event.", 0, java.lang.Integer.MAX_VALUE, causality);
284          default: return super.getNamedProperty(_hash, _name, _checkValid);
285          }
286
287        }
288
289      @Override
290      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
291        switch (hash) {
292        case 555127957: /*instance*/ return this.instance == null ? new Base[0] : new Base[] {this.instance}; // Reference
293        case -1446450521: /*causality*/ return this.causality == null ? new Base[0] : this.causality.toArray(new Base[this.causality.size()]); // AdverseEventSuspectEntityCausalityComponent
294        default: return super.getProperty(hash, name, checkValid);
295        }
296
297      }
298
299      @Override
300      public Base setProperty(int hash, String name, Base value) throws FHIRException {
301        switch (hash) {
302        case 555127957: // instance
303          this.instance = castToReference(value); // Reference
304          return value;
305        case -1446450521: // causality
306          this.getCausality().add((AdverseEventSuspectEntityCausalityComponent) value); // AdverseEventSuspectEntityCausalityComponent
307          return value;
308        default: return super.setProperty(hash, name, value);
309        }
310
311      }
312
313      @Override
314      public Base setProperty(String name, Base value) throws FHIRException {
315        if (name.equals("instance")) {
316          this.instance = castToReference(value); // Reference
317        } else if (name.equals("causality")) {
318          this.getCausality().add((AdverseEventSuspectEntityCausalityComponent) value);
319        } else
320          return super.setProperty(name, value);
321        return value;
322      }
323
324      @Override
325      public Base makeProperty(int hash, String name) throws FHIRException {
326        switch (hash) {
327        case 555127957:  return getInstance(); 
328        case -1446450521:  return addCausality(); 
329        default: return super.makeProperty(hash, name);
330        }
331
332      }
333
334      @Override
335      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
336        switch (hash) {
337        case 555127957: /*instance*/ return new String[] {"Reference"};
338        case -1446450521: /*causality*/ return new String[] {};
339        default: return super.getTypesForProperty(hash, name);
340        }
341
342      }
343
344      @Override
345      public Base addChild(String name) throws FHIRException {
346        if (name.equals("instance")) {
347          this.instance = new Reference();
348          return this.instance;
349        }
350        else if (name.equals("causality")) {
351          return addCausality();
352        }
353        else
354          return super.addChild(name);
355      }
356
357      public AdverseEventSuspectEntityComponent copy() {
358        AdverseEventSuspectEntityComponent dst = new AdverseEventSuspectEntityComponent();
359        copyValues(dst);
360        dst.instance = instance == null ? null : instance.copy();
361        if (causality != null) {
362          dst.causality = new ArrayList<AdverseEventSuspectEntityCausalityComponent>();
363          for (AdverseEventSuspectEntityCausalityComponent i : causality)
364            dst.causality.add(i.copy());
365        };
366        return dst;
367      }
368
369      @Override
370      public boolean equalsDeep(Base other_) {
371        if (!super.equalsDeep(other_))
372          return false;
373        if (!(other_ instanceof AdverseEventSuspectEntityComponent))
374          return false;
375        AdverseEventSuspectEntityComponent o = (AdverseEventSuspectEntityComponent) other_;
376        return compareDeep(instance, o.instance, true) && compareDeep(causality, o.causality, true);
377      }
378
379      @Override
380      public boolean equalsShallow(Base other_) {
381        if (!super.equalsShallow(other_))
382          return false;
383        if (!(other_ instanceof AdverseEventSuspectEntityComponent))
384          return false;
385        AdverseEventSuspectEntityComponent o = (AdverseEventSuspectEntityComponent) other_;
386        return true;
387      }
388
389      public boolean isEmpty() {
390        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(instance, causality);
391      }
392
393  public String fhirType() {
394    return "AdverseEvent.suspectEntity";
395
396  }
397
398  }
399
400    @Block()
401    public static class AdverseEventSuspectEntityCausalityComponent extends BackboneElement implements IBaseBackboneElement {
402        /**
403         * Assessment of if the entity caused the event.
404         */
405        @Child(name = "assessment", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
406        @Description(shortDefinition="Assessment of if the entity caused the event", formalDefinition="Assessment of if the entity caused the event." )
407        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/adverse-event-causality-assess")
408        protected CodeableConcept assessment;
409
410        /**
411         * AdverseEvent.suspectEntity.causalityProductRelatedness.
412         */
413        @Child(name = "productRelatedness", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=true)
414        @Description(shortDefinition="AdverseEvent.suspectEntity.causalityProductRelatedness", formalDefinition="AdverseEvent.suspectEntity.causalityProductRelatedness." )
415        protected StringType productRelatedness;
416
417        /**
418         * AdverseEvent.suspectEntity.causalityAuthor.
419         */
420        @Child(name = "author", type = {Practitioner.class, PractitionerRole.class}, order=3, min=0, max=1, modifier=false, summary=true)
421        @Description(shortDefinition="AdverseEvent.suspectEntity.causalityAuthor", formalDefinition="AdverseEvent.suspectEntity.causalityAuthor." )
422        protected Reference author;
423
424        /**
425         * The actual object that is the target of the reference (AdverseEvent.suspectEntity.causalityAuthor.)
426         */
427        protected Resource authorTarget;
428
429        /**
430         * ProbabilityScale | Bayesian | Checklist.
431         */
432        @Child(name = "method", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=true)
433        @Description(shortDefinition="ProbabilityScale | Bayesian | Checklist", formalDefinition="ProbabilityScale | Bayesian | Checklist." )
434        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/adverse-event-causality-method")
435        protected CodeableConcept method;
436
437        private static final long serialVersionUID = -1847234837L;
438
439    /**
440     * Constructor
441     */
442      public AdverseEventSuspectEntityCausalityComponent() {
443        super();
444      }
445
446        /**
447         * @return {@link #assessment} (Assessment of if the entity caused the event.)
448         */
449        public CodeableConcept getAssessment() { 
450          if (this.assessment == null)
451            if (Configuration.errorOnAutoCreate())
452              throw new Error("Attempt to auto-create AdverseEventSuspectEntityCausalityComponent.assessment");
453            else if (Configuration.doAutoCreate())
454              this.assessment = new CodeableConcept(); // cc
455          return this.assessment;
456        }
457
458        public boolean hasAssessment() { 
459          return this.assessment != null && !this.assessment.isEmpty();
460        }
461
462        /**
463         * @param value {@link #assessment} (Assessment of if the entity caused the event.)
464         */
465        public AdverseEventSuspectEntityCausalityComponent setAssessment(CodeableConcept value) { 
466          this.assessment = value;
467          return this;
468        }
469
470        /**
471         * @return {@link #productRelatedness} (AdverseEvent.suspectEntity.causalityProductRelatedness.). This is the underlying object with id, value and extensions. The accessor "getProductRelatedness" gives direct access to the value
472         */
473        public StringType getProductRelatednessElement() { 
474          if (this.productRelatedness == null)
475            if (Configuration.errorOnAutoCreate())
476              throw new Error("Attempt to auto-create AdverseEventSuspectEntityCausalityComponent.productRelatedness");
477            else if (Configuration.doAutoCreate())
478              this.productRelatedness = new StringType(); // bb
479          return this.productRelatedness;
480        }
481
482        public boolean hasProductRelatednessElement() { 
483          return this.productRelatedness != null && !this.productRelatedness.isEmpty();
484        }
485
486        public boolean hasProductRelatedness() { 
487          return this.productRelatedness != null && !this.productRelatedness.isEmpty();
488        }
489
490        /**
491         * @param value {@link #productRelatedness} (AdverseEvent.suspectEntity.causalityProductRelatedness.). This is the underlying object with id, value and extensions. The accessor "getProductRelatedness" gives direct access to the value
492         */
493        public AdverseEventSuspectEntityCausalityComponent setProductRelatednessElement(StringType value) { 
494          this.productRelatedness = value;
495          return this;
496        }
497
498        /**
499         * @return AdverseEvent.suspectEntity.causalityProductRelatedness.
500         */
501        public String getProductRelatedness() { 
502          return this.productRelatedness == null ? null : this.productRelatedness.getValue();
503        }
504
505        /**
506         * @param value AdverseEvent.suspectEntity.causalityProductRelatedness.
507         */
508        public AdverseEventSuspectEntityCausalityComponent setProductRelatedness(String value) { 
509          if (Utilities.noString(value))
510            this.productRelatedness = null;
511          else {
512            if (this.productRelatedness == null)
513              this.productRelatedness = new StringType();
514            this.productRelatedness.setValue(value);
515          }
516          return this;
517        }
518
519        /**
520         * @return {@link #author} (AdverseEvent.suspectEntity.causalityAuthor.)
521         */
522        public Reference getAuthor() { 
523          if (this.author == null)
524            if (Configuration.errorOnAutoCreate())
525              throw new Error("Attempt to auto-create AdverseEventSuspectEntityCausalityComponent.author");
526            else if (Configuration.doAutoCreate())
527              this.author = new Reference(); // cc
528          return this.author;
529        }
530
531        public boolean hasAuthor() { 
532          return this.author != null && !this.author.isEmpty();
533        }
534
535        /**
536         * @param value {@link #author} (AdverseEvent.suspectEntity.causalityAuthor.)
537         */
538        public AdverseEventSuspectEntityCausalityComponent setAuthor(Reference value) { 
539          this.author = value;
540          return this;
541        }
542
543        /**
544         * @return {@link #author} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (AdverseEvent.suspectEntity.causalityAuthor.)
545         */
546        public Resource getAuthorTarget() { 
547          return this.authorTarget;
548        }
549
550        /**
551         * @param value {@link #author} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (AdverseEvent.suspectEntity.causalityAuthor.)
552         */
553        public AdverseEventSuspectEntityCausalityComponent setAuthorTarget(Resource value) { 
554          this.authorTarget = value;
555          return this;
556        }
557
558        /**
559         * @return {@link #method} (ProbabilityScale | Bayesian | Checklist.)
560         */
561        public CodeableConcept getMethod() { 
562          if (this.method == null)
563            if (Configuration.errorOnAutoCreate())
564              throw new Error("Attempt to auto-create AdverseEventSuspectEntityCausalityComponent.method");
565            else if (Configuration.doAutoCreate())
566              this.method = new CodeableConcept(); // cc
567          return this.method;
568        }
569
570        public boolean hasMethod() { 
571          return this.method != null && !this.method.isEmpty();
572        }
573
574        /**
575         * @param value {@link #method} (ProbabilityScale | Bayesian | Checklist.)
576         */
577        public AdverseEventSuspectEntityCausalityComponent setMethod(CodeableConcept value) { 
578          this.method = value;
579          return this;
580        }
581
582        protected void listChildren(List<Property> children) {
583          super.listChildren(children);
584          children.add(new Property("assessment", "CodeableConcept", "Assessment of if the entity caused the event.", 0, 1, assessment));
585          children.add(new Property("productRelatedness", "string", "AdverseEvent.suspectEntity.causalityProductRelatedness.", 0, 1, productRelatedness));
586          children.add(new Property("author", "Reference(Practitioner|PractitionerRole)", "AdverseEvent.suspectEntity.causalityAuthor.", 0, 1, author));
587          children.add(new Property("method", "CodeableConcept", "ProbabilityScale | Bayesian | Checklist.", 0, 1, method));
588        }
589
590        @Override
591        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
592          switch (_hash) {
593          case 2119382722: /*assessment*/  return new Property("assessment", "CodeableConcept", "Assessment of if the entity caused the event.", 0, 1, assessment);
594          case 1824577683: /*productRelatedness*/  return new Property("productRelatedness", "string", "AdverseEvent.suspectEntity.causalityProductRelatedness.", 0, 1, productRelatedness);
595          case -1406328437: /*author*/  return new Property("author", "Reference(Practitioner|PractitionerRole)", "AdverseEvent.suspectEntity.causalityAuthor.", 0, 1, author);
596          case -1077554975: /*method*/  return new Property("method", "CodeableConcept", "ProbabilityScale | Bayesian | Checklist.", 0, 1, method);
597          default: return super.getNamedProperty(_hash, _name, _checkValid);
598          }
599
600        }
601
602      @Override
603      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
604        switch (hash) {
605        case 2119382722: /*assessment*/ return this.assessment == null ? new Base[0] : new Base[] {this.assessment}; // CodeableConcept
606        case 1824577683: /*productRelatedness*/ return this.productRelatedness == null ? new Base[0] : new Base[] {this.productRelatedness}; // StringType
607        case -1406328437: /*author*/ return this.author == null ? new Base[0] : new Base[] {this.author}; // Reference
608        case -1077554975: /*method*/ return this.method == null ? new Base[0] : new Base[] {this.method}; // CodeableConcept
609        default: return super.getProperty(hash, name, checkValid);
610        }
611
612      }
613
614      @Override
615      public Base setProperty(int hash, String name, Base value) throws FHIRException {
616        switch (hash) {
617        case 2119382722: // assessment
618          this.assessment = castToCodeableConcept(value); // CodeableConcept
619          return value;
620        case 1824577683: // productRelatedness
621          this.productRelatedness = castToString(value); // StringType
622          return value;
623        case -1406328437: // author
624          this.author = castToReference(value); // Reference
625          return value;
626        case -1077554975: // method
627          this.method = castToCodeableConcept(value); // CodeableConcept
628          return value;
629        default: return super.setProperty(hash, name, value);
630        }
631
632      }
633
634      @Override
635      public Base setProperty(String name, Base value) throws FHIRException {
636        if (name.equals("assessment")) {
637          this.assessment = castToCodeableConcept(value); // CodeableConcept
638        } else if (name.equals("productRelatedness")) {
639          this.productRelatedness = castToString(value); // StringType
640        } else if (name.equals("author")) {
641          this.author = castToReference(value); // Reference
642        } else if (name.equals("method")) {
643          this.method = castToCodeableConcept(value); // CodeableConcept
644        } else
645          return super.setProperty(name, value);
646        return value;
647      }
648
649      @Override
650      public Base makeProperty(int hash, String name) throws FHIRException {
651        switch (hash) {
652        case 2119382722:  return getAssessment(); 
653        case 1824577683:  return getProductRelatednessElement();
654        case -1406328437:  return getAuthor(); 
655        case -1077554975:  return getMethod(); 
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 2119382722: /*assessment*/ return new String[] {"CodeableConcept"};
665        case 1824577683: /*productRelatedness*/ return new String[] {"string"};
666        case -1406328437: /*author*/ return new String[] {"Reference"};
667        case -1077554975: /*method*/ return new String[] {"CodeableConcept"};
668        default: return super.getTypesForProperty(hash, name);
669        }
670
671      }
672
673      @Override
674      public Base addChild(String name) throws FHIRException {
675        if (name.equals("assessment")) {
676          this.assessment = new CodeableConcept();
677          return this.assessment;
678        }
679        else if (name.equals("productRelatedness")) {
680          throw new FHIRException("Cannot call addChild on a primitive type AdverseEvent.productRelatedness");
681        }
682        else if (name.equals("author")) {
683          this.author = new Reference();
684          return this.author;
685        }
686        else if (name.equals("method")) {
687          this.method = new CodeableConcept();
688          return this.method;
689        }
690        else
691          return super.addChild(name);
692      }
693
694      public AdverseEventSuspectEntityCausalityComponent copy() {
695        AdverseEventSuspectEntityCausalityComponent dst = new AdverseEventSuspectEntityCausalityComponent();
696        copyValues(dst);
697        dst.assessment = assessment == null ? null : assessment.copy();
698        dst.productRelatedness = productRelatedness == null ? null : productRelatedness.copy();
699        dst.author = author == null ? null : author.copy();
700        dst.method = method == null ? null : method.copy();
701        return dst;
702      }
703
704      @Override
705      public boolean equalsDeep(Base other_) {
706        if (!super.equalsDeep(other_))
707          return false;
708        if (!(other_ instanceof AdverseEventSuspectEntityCausalityComponent))
709          return false;
710        AdverseEventSuspectEntityCausalityComponent o = (AdverseEventSuspectEntityCausalityComponent) other_;
711        return compareDeep(assessment, o.assessment, true) && compareDeep(productRelatedness, o.productRelatedness, true)
712           && compareDeep(author, o.author, true) && compareDeep(method, o.method, true);
713      }
714
715      @Override
716      public boolean equalsShallow(Base other_) {
717        if (!super.equalsShallow(other_))
718          return false;
719        if (!(other_ instanceof AdverseEventSuspectEntityCausalityComponent))
720          return false;
721        AdverseEventSuspectEntityCausalityComponent o = (AdverseEventSuspectEntityCausalityComponent) other_;
722        return compareValues(productRelatedness, o.productRelatedness, true);
723      }
724
725      public boolean isEmpty() {
726        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(assessment, productRelatedness
727          , author, method);
728      }
729
730  public String fhirType() {
731    return "AdverseEvent.suspectEntity.causality";
732
733  }
734
735  }
736
737    /**
738     * Business identifiers assigned to this adverse event by the performer or other systems which remain constant as the resource is updated and propagates from server to server.
739     */
740    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=1, modifier=false, summary=true)
741    @Description(shortDefinition="Business identifier for the event", formalDefinition="Business identifiers assigned to this adverse event by the performer or other systems which remain constant as the resource is updated and propagates from server to server." )
742    protected Identifier identifier;
743
744    /**
745     * Whether the event actually happened, or just had the potential to. Note that this is independent of whether anyone was affected or harmed or how severely.
746     */
747    @Child(name = "actuality", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
748    @Description(shortDefinition="actual | potential", formalDefinition="Whether the event actually happened, or just had the potential to. Note that this is independent of whether anyone was affected or harmed or how severely." )
749    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/adverse-event-actuality")
750    protected Enumeration<AdverseEventActuality> actuality;
751
752    /**
753     * The overall type of event, intended for search and filtering purposes.
754     */
755    @Child(name = "category", type = {CodeableConcept.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
756    @Description(shortDefinition="product-problem | product-quality | product-use-error | wrong-dose | incorrect-prescribing-information | wrong-technique | wrong-route-of-administration | wrong-rate | wrong-duration | wrong-time | expired-drug | medical-device-use-error | problem-different-manufacturer | unsafe-physical-environment", formalDefinition="The overall type of event, intended for search and filtering purposes." )
757    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/adverse-event-category")
758    protected List<CodeableConcept> category;
759
760    /**
761     * This element defines the specific type of event that occurred or that was prevented from occurring.
762     */
763    @Child(name = "event", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true)
764    @Description(shortDefinition="Type of the event itself in relation to the subject", formalDefinition="This element defines the specific type of event that occurred or that was prevented from occurring." )
765    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/adverse-event-type")
766    protected CodeableConcept event;
767
768    /**
769     * This subject or group impacted by the event.
770     */
771    @Child(name = "subject", type = {Patient.class, Group.class, Practitioner.class, RelatedPerson.class}, order=4, min=1, max=1, modifier=false, summary=true)
772    @Description(shortDefinition="Subject impacted by event", formalDefinition="This subject or group impacted by the event." )
773    protected Reference subject;
774
775    /**
776     * The actual object that is the target of the reference (This subject or group impacted by the event.)
777     */
778    protected Resource subjectTarget;
779
780    /**
781     * The Encounter during which AdverseEvent was created or to which the creation of this record is tightly associated.
782     */
783    @Child(name = "encounter", type = {Encounter.class}, order=5, min=0, max=1, modifier=false, summary=true)
784    @Description(shortDefinition="Encounter created as part of", formalDefinition="The Encounter during which AdverseEvent was created or to which the creation of this record is tightly associated." )
785    protected Reference encounter;
786
787    /**
788     * The actual object that is the target of the reference (The Encounter during which AdverseEvent was created or to which the creation of this record is tightly associated.)
789     */
790    protected Encounter encounterTarget;
791
792    /**
793     * The date (and perhaps time) when the adverse event occurred.
794     */
795    @Child(name = "date", type = {DateTimeType.class}, order=6, min=0, max=1, modifier=false, summary=true)
796    @Description(shortDefinition="When the event occurred", formalDefinition="The date (and perhaps time) when the adverse event occurred." )
797    protected DateTimeType date;
798
799    /**
800     * Estimated or actual date the AdverseEvent began, in the opinion of the reporter.
801     */
802    @Child(name = "detected", type = {DateTimeType.class}, order=7, min=0, max=1, modifier=false, summary=true)
803    @Description(shortDefinition="When the event was detected", formalDefinition="Estimated or actual date the AdverseEvent began, in the opinion of the reporter." )
804    protected DateTimeType detected;
805
806    /**
807     * The date on which the existence of the AdverseEvent was first recorded.
808     */
809    @Child(name = "recordedDate", type = {DateTimeType.class}, order=8, min=0, max=1, modifier=false, summary=true)
810    @Description(shortDefinition="When the event was recorded", formalDefinition="The date on which the existence of the AdverseEvent was first recorded." )
811    protected DateTimeType recordedDate;
812
813    /**
814     * Includes information about the reaction that occurred as a result of exposure to a substance (for example, a drug or a chemical).
815     */
816    @Child(name = "resultingCondition", type = {Condition.class}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
817    @Description(shortDefinition="Effect on the subject due to this event", formalDefinition="Includes information about the reaction that occurred as a result of exposure to a substance (for example, a drug or a chemical)." )
818    protected List<Reference> resultingCondition;
819    /**
820     * The actual objects that are the target of the reference (Includes information about the reaction that occurred as a result of exposure to a substance (for example, a drug or a chemical).)
821     */
822    protected List<Condition> resultingConditionTarget;
823
824
825    /**
826     * The information about where the adverse event occurred.
827     */
828    @Child(name = "location", type = {Location.class}, order=10, min=0, max=1, modifier=false, summary=true)
829    @Description(shortDefinition="Location where adverse event occurred", formalDefinition="The information about where the adverse event occurred." )
830    protected Reference location;
831
832    /**
833     * The actual object that is the target of the reference (The information about where the adverse event occurred.)
834     */
835    protected Location locationTarget;
836
837    /**
838     * Assessment whether this event was of real importance.
839     */
840    @Child(name = "seriousness", type = {CodeableConcept.class}, order=11, min=0, max=1, modifier=false, summary=true)
841    @Description(shortDefinition="Seriousness of the event", formalDefinition="Assessment whether this event was of real importance." )
842    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/adverse-event-seriousness")
843    protected CodeableConcept seriousness;
844
845    /**
846     * Describes the severity of the adverse event, in relation to the subject. Contrast to AdverseEvent.seriousness - a severe rash might not be serious, but a mild heart problem is.
847     */
848    @Child(name = "severity", type = {CodeableConcept.class}, order=12, min=0, max=1, modifier=false, summary=true)
849    @Description(shortDefinition="mild | moderate | severe", formalDefinition="Describes the severity of the adverse event, in relation to the subject. Contrast to AdverseEvent.seriousness - a severe rash might not be serious, but a mild heart problem is." )
850    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/adverse-event-severity")
851    protected CodeableConcept severity;
852
853    /**
854     * Describes the type of outcome from the adverse event.
855     */
856    @Child(name = "outcome", type = {CodeableConcept.class}, order=13, min=0, max=1, modifier=false, summary=true)
857    @Description(shortDefinition="resolved | recovering | ongoing | resolvedWithSequelae | fatal | unknown", formalDefinition="Describes the type of outcome from the adverse event." )
858    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/adverse-event-outcome")
859    protected CodeableConcept outcome;
860
861    /**
862     * Information on who recorded the adverse event.  May be the patient or a practitioner.
863     */
864    @Child(name = "recorder", type = {Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class}, order=14, min=0, max=1, modifier=false, summary=true)
865    @Description(shortDefinition="Who recorded the adverse event", formalDefinition="Information on who recorded the adverse event.  May be the patient or a practitioner." )
866    protected Reference recorder;
867
868    /**
869     * The actual object that is the target of the reference (Information on who recorded the adverse event.  May be the patient or a practitioner.)
870     */
871    protected Resource recorderTarget;
872
873    /**
874     * Parties that may or should contribute or have contributed information to the adverse event, which can consist of one or more activities.  Such information includes information leading to the decision to perform the activity and how to perform the activity (e.g. consultant), information that the activity itself seeks to reveal (e.g. informant of clinical history), or information about what activity was performed (e.g. informant witness).
875     */
876    @Child(name = "contributor", type = {Practitioner.class, PractitionerRole.class, Device.class}, order=15, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
877    @Description(shortDefinition="Who  was involved in the adverse event or the potential adverse event", formalDefinition="Parties that may or should contribute or have contributed information to the adverse event, which can consist of one or more activities.  Such information includes information leading to the decision to perform the activity and how to perform the activity (e.g. consultant), information that the activity itself seeks to reveal (e.g. informant of clinical history), or information about what activity was performed (e.g. informant witness)." )
878    protected List<Reference> contributor;
879    /**
880     * The actual objects that are the target of the reference (Parties that may or should contribute or have contributed information to the adverse event, which can consist of one or more activities.  Such information includes information leading to the decision to perform the activity and how to perform the activity (e.g. consultant), information that the activity itself seeks to reveal (e.g. informant of clinical history), or information about what activity was performed (e.g. informant witness).)
881     */
882    protected List<Resource> contributorTarget;
883
884
885    /**
886     * Describes the entity that is suspected to have caused the adverse event.
887     */
888    @Child(name = "suspectEntity", type = {}, order=16, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
889    @Description(shortDefinition="The suspected agent causing the adverse event", formalDefinition="Describes the entity that is suspected to have caused the adverse event." )
890    protected List<AdverseEventSuspectEntityComponent> suspectEntity;
891
892    /**
893     * AdverseEvent.subjectMedicalHistory.
894     */
895    @Child(name = "subjectMedicalHistory", type = {Condition.class, Observation.class, AllergyIntolerance.class, FamilyMemberHistory.class, Immunization.class, Procedure.class, Media.class, DocumentReference.class}, order=17, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
896    @Description(shortDefinition="AdverseEvent.subjectMedicalHistory", formalDefinition="AdverseEvent.subjectMedicalHistory." )
897    protected List<Reference> subjectMedicalHistory;
898    /**
899     * The actual objects that are the target of the reference (AdverseEvent.subjectMedicalHistory.)
900     */
901    protected List<Resource> subjectMedicalHistoryTarget;
902
903
904    /**
905     * AdverseEvent.referenceDocument.
906     */
907    @Child(name = "referenceDocument", type = {DocumentReference.class}, order=18, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
908    @Description(shortDefinition="AdverseEvent.referenceDocument", formalDefinition="AdverseEvent.referenceDocument." )
909    protected List<Reference> referenceDocument;
910    /**
911     * The actual objects that are the target of the reference (AdverseEvent.referenceDocument.)
912     */
913    protected List<DocumentReference> referenceDocumentTarget;
914
915
916    /**
917     * AdverseEvent.study.
918     */
919    @Child(name = "study", type = {ResearchStudy.class}, order=19, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
920    @Description(shortDefinition="AdverseEvent.study", formalDefinition="AdverseEvent.study." )
921    protected List<Reference> study;
922    /**
923     * The actual objects that are the target of the reference (AdverseEvent.study.)
924     */
925    protected List<ResearchStudy> studyTarget;
926
927
928    private static final long serialVersionUID = -2055195281L;
929
930  /**
931   * Constructor
932   */
933    public AdverseEvent() {
934      super();
935    }
936
937  /**
938   * Constructor
939   */
940    public AdverseEvent(Enumeration<AdverseEventActuality> actuality, Reference subject) {
941      super();
942      this.actuality = actuality;
943      this.subject = subject;
944    }
945
946    /**
947     * @return {@link #identifier} (Business identifiers assigned to this adverse event by the performer or other systems which remain constant as the resource is updated and propagates from server to server.)
948     */
949    public Identifier getIdentifier() { 
950      if (this.identifier == null)
951        if (Configuration.errorOnAutoCreate())
952          throw new Error("Attempt to auto-create AdverseEvent.identifier");
953        else if (Configuration.doAutoCreate())
954          this.identifier = new Identifier(); // cc
955      return this.identifier;
956    }
957
958    public boolean hasIdentifier() { 
959      return this.identifier != null && !this.identifier.isEmpty();
960    }
961
962    /**
963     * @param value {@link #identifier} (Business identifiers assigned to this adverse event by the performer or other systems which remain constant as the resource is updated and propagates from server to server.)
964     */
965    public AdverseEvent setIdentifier(Identifier value) { 
966      this.identifier = value;
967      return this;
968    }
969
970    /**
971     * @return {@link #actuality} (Whether the event actually happened, or just had the potential to. Note that this is independent of whether anyone was affected or harmed or how severely.). This is the underlying object with id, value and extensions. The accessor "getActuality" gives direct access to the value
972     */
973    public Enumeration<AdverseEventActuality> getActualityElement() { 
974      if (this.actuality == null)
975        if (Configuration.errorOnAutoCreate())
976          throw new Error("Attempt to auto-create AdverseEvent.actuality");
977        else if (Configuration.doAutoCreate())
978          this.actuality = new Enumeration<AdverseEventActuality>(new AdverseEventActualityEnumFactory()); // bb
979      return this.actuality;
980    }
981
982    public boolean hasActualityElement() { 
983      return this.actuality != null && !this.actuality.isEmpty();
984    }
985
986    public boolean hasActuality() { 
987      return this.actuality != null && !this.actuality.isEmpty();
988    }
989
990    /**
991     * @param value {@link #actuality} (Whether the event actually happened, or just had the potential to. Note that this is independent of whether anyone was affected or harmed or how severely.). This is the underlying object with id, value and extensions. The accessor "getActuality" gives direct access to the value
992     */
993    public AdverseEvent setActualityElement(Enumeration<AdverseEventActuality> value) { 
994      this.actuality = value;
995      return this;
996    }
997
998    /**
999     * @return Whether the event actually happened, or just had the potential to. Note that this is independent of whether anyone was affected or harmed or how severely.
1000     */
1001    public AdverseEventActuality getActuality() { 
1002      return this.actuality == null ? null : this.actuality.getValue();
1003    }
1004
1005    /**
1006     * @param value Whether the event actually happened, or just had the potential to. Note that this is independent of whether anyone was affected or harmed or how severely.
1007     */
1008    public AdverseEvent setActuality(AdverseEventActuality value) { 
1009        if (this.actuality == null)
1010          this.actuality = new Enumeration<AdverseEventActuality>(new AdverseEventActualityEnumFactory());
1011        this.actuality.setValue(value);
1012      return this;
1013    }
1014
1015    /**
1016     * @return {@link #category} (The overall type of event, intended for search and filtering purposes.)
1017     */
1018    public List<CodeableConcept> getCategory() { 
1019      if (this.category == null)
1020        this.category = new ArrayList<CodeableConcept>();
1021      return this.category;
1022    }
1023
1024    /**
1025     * @return Returns a reference to <code>this</code> for easy method chaining
1026     */
1027    public AdverseEvent setCategory(List<CodeableConcept> theCategory) { 
1028      this.category = theCategory;
1029      return this;
1030    }
1031
1032    public boolean hasCategory() { 
1033      if (this.category == null)
1034        return false;
1035      for (CodeableConcept item : this.category)
1036        if (!item.isEmpty())
1037          return true;
1038      return false;
1039    }
1040
1041    public CodeableConcept addCategory() { //3
1042      CodeableConcept t = new CodeableConcept();
1043      if (this.category == null)
1044        this.category = new ArrayList<CodeableConcept>();
1045      this.category.add(t);
1046      return t;
1047    }
1048
1049    public AdverseEvent addCategory(CodeableConcept t) { //3
1050      if (t == null)
1051        return this;
1052      if (this.category == null)
1053        this.category = new ArrayList<CodeableConcept>();
1054      this.category.add(t);
1055      return this;
1056    }
1057
1058    /**
1059     * @return The first repetition of repeating field {@link #category}, creating it if it does not already exist
1060     */
1061    public CodeableConcept getCategoryFirstRep() { 
1062      if (getCategory().isEmpty()) {
1063        addCategory();
1064      }
1065      return getCategory().get(0);
1066    }
1067
1068    /**
1069     * @return {@link #event} (This element defines the specific type of event that occurred or that was prevented from occurring.)
1070     */
1071    public CodeableConcept getEvent() { 
1072      if (this.event == null)
1073        if (Configuration.errorOnAutoCreate())
1074          throw new Error("Attempt to auto-create AdverseEvent.event");
1075        else if (Configuration.doAutoCreate())
1076          this.event = new CodeableConcept(); // cc
1077      return this.event;
1078    }
1079
1080    public boolean hasEvent() { 
1081      return this.event != null && !this.event.isEmpty();
1082    }
1083
1084    /**
1085     * @param value {@link #event} (This element defines the specific type of event that occurred or that was prevented from occurring.)
1086     */
1087    public AdverseEvent setEvent(CodeableConcept value) { 
1088      this.event = value;
1089      return this;
1090    }
1091
1092    /**
1093     * @return {@link #subject} (This subject or group impacted by the event.)
1094     */
1095    public Reference getSubject() { 
1096      if (this.subject == null)
1097        if (Configuration.errorOnAutoCreate())
1098          throw new Error("Attempt to auto-create AdverseEvent.subject");
1099        else if (Configuration.doAutoCreate())
1100          this.subject = new Reference(); // cc
1101      return this.subject;
1102    }
1103
1104    public boolean hasSubject() { 
1105      return this.subject != null && !this.subject.isEmpty();
1106    }
1107
1108    /**
1109     * @param value {@link #subject} (This subject or group impacted by the event.)
1110     */
1111    public AdverseEvent setSubject(Reference value) { 
1112      this.subject = value;
1113      return this;
1114    }
1115
1116    /**
1117     * @return {@link #subject} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (This subject or group impacted by the event.)
1118     */
1119    public Resource getSubjectTarget() { 
1120      return this.subjectTarget;
1121    }
1122
1123    /**
1124     * @param value {@link #subject} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (This subject or group impacted by the event.)
1125     */
1126    public AdverseEvent setSubjectTarget(Resource value) { 
1127      this.subjectTarget = value;
1128      return this;
1129    }
1130
1131    /**
1132     * @return {@link #encounter} (The Encounter during which AdverseEvent was created or to which the creation of this record is tightly associated.)
1133     */
1134    public Reference getEncounter() { 
1135      if (this.encounter == null)
1136        if (Configuration.errorOnAutoCreate())
1137          throw new Error("Attempt to auto-create AdverseEvent.encounter");
1138        else if (Configuration.doAutoCreate())
1139          this.encounter = new Reference(); // cc
1140      return this.encounter;
1141    }
1142
1143    public boolean hasEncounter() { 
1144      return this.encounter != null && !this.encounter.isEmpty();
1145    }
1146
1147    /**
1148     * @param value {@link #encounter} (The Encounter during which AdverseEvent was created or to which the creation of this record is tightly associated.)
1149     */
1150    public AdverseEvent setEncounter(Reference value) { 
1151      this.encounter = value;
1152      return this;
1153    }
1154
1155    /**
1156     * @return {@link #encounter} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The Encounter during which AdverseEvent was created or to which the creation of this record is tightly associated.)
1157     */
1158    public Encounter getEncounterTarget() { 
1159      if (this.encounterTarget == null)
1160        if (Configuration.errorOnAutoCreate())
1161          throw new Error("Attempt to auto-create AdverseEvent.encounter");
1162        else if (Configuration.doAutoCreate())
1163          this.encounterTarget = new Encounter(); // aa
1164      return this.encounterTarget;
1165    }
1166
1167    /**
1168     * @param value {@link #encounter} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The Encounter during which AdverseEvent was created or to which the creation of this record is tightly associated.)
1169     */
1170    public AdverseEvent setEncounterTarget(Encounter value) { 
1171      this.encounterTarget = value;
1172      return this;
1173    }
1174
1175    /**
1176     * @return {@link #date} (The date (and perhaps time) when the adverse event occurred.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
1177     */
1178    public DateTimeType getDateElement() { 
1179      if (this.date == null)
1180        if (Configuration.errorOnAutoCreate())
1181          throw new Error("Attempt to auto-create AdverseEvent.date");
1182        else if (Configuration.doAutoCreate())
1183          this.date = new DateTimeType(); // bb
1184      return this.date;
1185    }
1186
1187    public boolean hasDateElement() { 
1188      return this.date != null && !this.date.isEmpty();
1189    }
1190
1191    public boolean hasDate() { 
1192      return this.date != null && !this.date.isEmpty();
1193    }
1194
1195    /**
1196     * @param value {@link #date} (The date (and perhaps time) when the adverse event occurred.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
1197     */
1198    public AdverseEvent setDateElement(DateTimeType value) { 
1199      this.date = value;
1200      return this;
1201    }
1202
1203    /**
1204     * @return The date (and perhaps time) when the adverse event occurred.
1205     */
1206    public Date getDate() { 
1207      return this.date == null ? null : this.date.getValue();
1208    }
1209
1210    /**
1211     * @param value The date (and perhaps time) when the adverse event occurred.
1212     */
1213    public AdverseEvent setDate(Date value) { 
1214      if (value == null)
1215        this.date = null;
1216      else {
1217        if (this.date == null)
1218          this.date = new DateTimeType();
1219        this.date.setValue(value);
1220      }
1221      return this;
1222    }
1223
1224    /**
1225     * @return {@link #detected} (Estimated or actual date the AdverseEvent began, in the opinion of the reporter.). This is the underlying object with id, value and extensions. The accessor "getDetected" gives direct access to the value
1226     */
1227    public DateTimeType getDetectedElement() { 
1228      if (this.detected == null)
1229        if (Configuration.errorOnAutoCreate())
1230          throw new Error("Attempt to auto-create AdverseEvent.detected");
1231        else if (Configuration.doAutoCreate())
1232          this.detected = new DateTimeType(); // bb
1233      return this.detected;
1234    }
1235
1236    public boolean hasDetectedElement() { 
1237      return this.detected != null && !this.detected.isEmpty();
1238    }
1239
1240    public boolean hasDetected() { 
1241      return this.detected != null && !this.detected.isEmpty();
1242    }
1243
1244    /**
1245     * @param value {@link #detected} (Estimated or actual date the AdverseEvent began, in the opinion of the reporter.). This is the underlying object with id, value and extensions. The accessor "getDetected" gives direct access to the value
1246     */
1247    public AdverseEvent setDetectedElement(DateTimeType value) { 
1248      this.detected = value;
1249      return this;
1250    }
1251
1252    /**
1253     * @return Estimated or actual date the AdverseEvent began, in the opinion of the reporter.
1254     */
1255    public Date getDetected() { 
1256      return this.detected == null ? null : this.detected.getValue();
1257    }
1258
1259    /**
1260     * @param value Estimated or actual date the AdverseEvent began, in the opinion of the reporter.
1261     */
1262    public AdverseEvent setDetected(Date value) { 
1263      if (value == null)
1264        this.detected = null;
1265      else {
1266        if (this.detected == null)
1267          this.detected = new DateTimeType();
1268        this.detected.setValue(value);
1269      }
1270      return this;
1271    }
1272
1273    /**
1274     * @return {@link #recordedDate} (The date on which the existence of the AdverseEvent was first recorded.). This is the underlying object with id, value and extensions. The accessor "getRecordedDate" gives direct access to the value
1275     */
1276    public DateTimeType getRecordedDateElement() { 
1277      if (this.recordedDate == null)
1278        if (Configuration.errorOnAutoCreate())
1279          throw new Error("Attempt to auto-create AdverseEvent.recordedDate");
1280        else if (Configuration.doAutoCreate())
1281          this.recordedDate = new DateTimeType(); // bb
1282      return this.recordedDate;
1283    }
1284
1285    public boolean hasRecordedDateElement() { 
1286      return this.recordedDate != null && !this.recordedDate.isEmpty();
1287    }
1288
1289    public boolean hasRecordedDate() { 
1290      return this.recordedDate != null && !this.recordedDate.isEmpty();
1291    }
1292
1293    /**
1294     * @param value {@link #recordedDate} (The date on which the existence of the AdverseEvent was first recorded.). This is the underlying object with id, value and extensions. The accessor "getRecordedDate" gives direct access to the value
1295     */
1296    public AdverseEvent setRecordedDateElement(DateTimeType value) { 
1297      this.recordedDate = value;
1298      return this;
1299    }
1300
1301    /**
1302     * @return The date on which the existence of the AdverseEvent was first recorded.
1303     */
1304    public Date getRecordedDate() { 
1305      return this.recordedDate == null ? null : this.recordedDate.getValue();
1306    }
1307
1308    /**
1309     * @param value The date on which the existence of the AdverseEvent was first recorded.
1310     */
1311    public AdverseEvent setRecordedDate(Date value) { 
1312      if (value == null)
1313        this.recordedDate = null;
1314      else {
1315        if (this.recordedDate == null)
1316          this.recordedDate = new DateTimeType();
1317        this.recordedDate.setValue(value);
1318      }
1319      return this;
1320    }
1321
1322    /**
1323     * @return {@link #resultingCondition} (Includes information about the reaction that occurred as a result of exposure to a substance (for example, a drug or a chemical).)
1324     */
1325    public List<Reference> getResultingCondition() { 
1326      if (this.resultingCondition == null)
1327        this.resultingCondition = new ArrayList<Reference>();
1328      return this.resultingCondition;
1329    }
1330
1331    /**
1332     * @return Returns a reference to <code>this</code> for easy method chaining
1333     */
1334    public AdverseEvent setResultingCondition(List<Reference> theResultingCondition) { 
1335      this.resultingCondition = theResultingCondition;
1336      return this;
1337    }
1338
1339    public boolean hasResultingCondition() { 
1340      if (this.resultingCondition == null)
1341        return false;
1342      for (Reference item : this.resultingCondition)
1343        if (!item.isEmpty())
1344          return true;
1345      return false;
1346    }
1347
1348    public Reference addResultingCondition() { //3
1349      Reference t = new Reference();
1350      if (this.resultingCondition == null)
1351        this.resultingCondition = new ArrayList<Reference>();
1352      this.resultingCondition.add(t);
1353      return t;
1354    }
1355
1356    public AdverseEvent addResultingCondition(Reference t) { //3
1357      if (t == null)
1358        return this;
1359      if (this.resultingCondition == null)
1360        this.resultingCondition = new ArrayList<Reference>();
1361      this.resultingCondition.add(t);
1362      return this;
1363    }
1364
1365    /**
1366     * @return The first repetition of repeating field {@link #resultingCondition}, creating it if it does not already exist
1367     */
1368    public Reference getResultingConditionFirstRep() { 
1369      if (getResultingCondition().isEmpty()) {
1370        addResultingCondition();
1371      }
1372      return getResultingCondition().get(0);
1373    }
1374
1375    /**
1376     * @deprecated Use Reference#setResource(IBaseResource) instead
1377     */
1378    @Deprecated
1379    public List<Condition> getResultingConditionTarget() { 
1380      if (this.resultingConditionTarget == null)
1381        this.resultingConditionTarget = new ArrayList<Condition>();
1382      return this.resultingConditionTarget;
1383    }
1384
1385    /**
1386     * @deprecated Use Reference#setResource(IBaseResource) instead
1387     */
1388    @Deprecated
1389    public Condition addResultingConditionTarget() { 
1390      Condition r = new Condition();
1391      if (this.resultingConditionTarget == null)
1392        this.resultingConditionTarget = new ArrayList<Condition>();
1393      this.resultingConditionTarget.add(r);
1394      return r;
1395    }
1396
1397    /**
1398     * @return {@link #location} (The information about where the adverse event occurred.)
1399     */
1400    public Reference getLocation() { 
1401      if (this.location == null)
1402        if (Configuration.errorOnAutoCreate())
1403          throw new Error("Attempt to auto-create AdverseEvent.location");
1404        else if (Configuration.doAutoCreate())
1405          this.location = new Reference(); // cc
1406      return this.location;
1407    }
1408
1409    public boolean hasLocation() { 
1410      return this.location != null && !this.location.isEmpty();
1411    }
1412
1413    /**
1414     * @param value {@link #location} (The information about where the adverse event occurred.)
1415     */
1416    public AdverseEvent setLocation(Reference value) { 
1417      this.location = value;
1418      return this;
1419    }
1420
1421    /**
1422     * @return {@link #location} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The information about where the adverse event occurred.)
1423     */
1424    public Location getLocationTarget() { 
1425      if (this.locationTarget == null)
1426        if (Configuration.errorOnAutoCreate())
1427          throw new Error("Attempt to auto-create AdverseEvent.location");
1428        else if (Configuration.doAutoCreate())
1429          this.locationTarget = new Location(); // aa
1430      return this.locationTarget;
1431    }
1432
1433    /**
1434     * @param value {@link #location} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The information about where the adverse event occurred.)
1435     */
1436    public AdverseEvent setLocationTarget(Location value) { 
1437      this.locationTarget = value;
1438      return this;
1439    }
1440
1441    /**
1442     * @return {@link #seriousness} (Assessment whether this event was of real importance.)
1443     */
1444    public CodeableConcept getSeriousness() { 
1445      if (this.seriousness == null)
1446        if (Configuration.errorOnAutoCreate())
1447          throw new Error("Attempt to auto-create AdverseEvent.seriousness");
1448        else if (Configuration.doAutoCreate())
1449          this.seriousness = new CodeableConcept(); // cc
1450      return this.seriousness;
1451    }
1452
1453    public boolean hasSeriousness() { 
1454      return this.seriousness != null && !this.seriousness.isEmpty();
1455    }
1456
1457    /**
1458     * @param value {@link #seriousness} (Assessment whether this event was of real importance.)
1459     */
1460    public AdverseEvent setSeriousness(CodeableConcept value) { 
1461      this.seriousness = value;
1462      return this;
1463    }
1464
1465    /**
1466     * @return {@link #severity} (Describes the severity of the adverse event, in relation to the subject. Contrast to AdverseEvent.seriousness - a severe rash might not be serious, but a mild heart problem is.)
1467     */
1468    public CodeableConcept getSeverity() { 
1469      if (this.severity == null)
1470        if (Configuration.errorOnAutoCreate())
1471          throw new Error("Attempt to auto-create AdverseEvent.severity");
1472        else if (Configuration.doAutoCreate())
1473          this.severity = new CodeableConcept(); // cc
1474      return this.severity;
1475    }
1476
1477    public boolean hasSeverity() { 
1478      return this.severity != null && !this.severity.isEmpty();
1479    }
1480
1481    /**
1482     * @param value {@link #severity} (Describes the severity of the adverse event, in relation to the subject. Contrast to AdverseEvent.seriousness - a severe rash might not be serious, but a mild heart problem is.)
1483     */
1484    public AdverseEvent setSeverity(CodeableConcept value) { 
1485      this.severity = value;
1486      return this;
1487    }
1488
1489    /**
1490     * @return {@link #outcome} (Describes the type of outcome from the adverse event.)
1491     */
1492    public CodeableConcept getOutcome() { 
1493      if (this.outcome == null)
1494        if (Configuration.errorOnAutoCreate())
1495          throw new Error("Attempt to auto-create AdverseEvent.outcome");
1496        else if (Configuration.doAutoCreate())
1497          this.outcome = new CodeableConcept(); // cc
1498      return this.outcome;
1499    }
1500
1501    public boolean hasOutcome() { 
1502      return this.outcome != null && !this.outcome.isEmpty();
1503    }
1504
1505    /**
1506     * @param value {@link #outcome} (Describes the type of outcome from the adverse event.)
1507     */
1508    public AdverseEvent setOutcome(CodeableConcept value) { 
1509      this.outcome = value;
1510      return this;
1511    }
1512
1513    /**
1514     * @return {@link #recorder} (Information on who recorded the adverse event.  May be the patient or a practitioner.)
1515     */
1516    public Reference getRecorder() { 
1517      if (this.recorder == null)
1518        if (Configuration.errorOnAutoCreate())
1519          throw new Error("Attempt to auto-create AdverseEvent.recorder");
1520        else if (Configuration.doAutoCreate())
1521          this.recorder = new Reference(); // cc
1522      return this.recorder;
1523    }
1524
1525    public boolean hasRecorder() { 
1526      return this.recorder != null && !this.recorder.isEmpty();
1527    }
1528
1529    /**
1530     * @param value {@link #recorder} (Information on who recorded the adverse event.  May be the patient or a practitioner.)
1531     */
1532    public AdverseEvent setRecorder(Reference value) { 
1533      this.recorder = value;
1534      return this;
1535    }
1536
1537    /**
1538     * @return {@link #recorder} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Information on who recorded the adverse event.  May be the patient or a practitioner.)
1539     */
1540    public Resource getRecorderTarget() { 
1541      return this.recorderTarget;
1542    }
1543
1544    /**
1545     * @param value {@link #recorder} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Information on who recorded the adverse event.  May be the patient or a practitioner.)
1546     */
1547    public AdverseEvent setRecorderTarget(Resource value) { 
1548      this.recorderTarget = value;
1549      return this;
1550    }
1551
1552    /**
1553     * @return {@link #contributor} (Parties that may or should contribute or have contributed information to the adverse event, which can consist of one or more activities.  Such information includes information leading to the decision to perform the activity and how to perform the activity (e.g. consultant), information that the activity itself seeks to reveal (e.g. informant of clinical history), or information about what activity was performed (e.g. informant witness).)
1554     */
1555    public List<Reference> getContributor() { 
1556      if (this.contributor == null)
1557        this.contributor = new ArrayList<Reference>();
1558      return this.contributor;
1559    }
1560
1561    /**
1562     * @return Returns a reference to <code>this</code> for easy method chaining
1563     */
1564    public AdverseEvent setContributor(List<Reference> theContributor) { 
1565      this.contributor = theContributor;
1566      return this;
1567    }
1568
1569    public boolean hasContributor() { 
1570      if (this.contributor == null)
1571        return false;
1572      for (Reference item : this.contributor)
1573        if (!item.isEmpty())
1574          return true;
1575      return false;
1576    }
1577
1578    public Reference addContributor() { //3
1579      Reference t = new Reference();
1580      if (this.contributor == null)
1581        this.contributor = new ArrayList<Reference>();
1582      this.contributor.add(t);
1583      return t;
1584    }
1585
1586    public AdverseEvent addContributor(Reference t) { //3
1587      if (t == null)
1588        return this;
1589      if (this.contributor == null)
1590        this.contributor = new ArrayList<Reference>();
1591      this.contributor.add(t);
1592      return this;
1593    }
1594
1595    /**
1596     * @return The first repetition of repeating field {@link #contributor}, creating it if it does not already exist
1597     */
1598    public Reference getContributorFirstRep() { 
1599      if (getContributor().isEmpty()) {
1600        addContributor();
1601      }
1602      return getContributor().get(0);
1603    }
1604
1605    /**
1606     * @deprecated Use Reference#setResource(IBaseResource) instead
1607     */
1608    @Deprecated
1609    public List<Resource> getContributorTarget() { 
1610      if (this.contributorTarget == null)
1611        this.contributorTarget = new ArrayList<Resource>();
1612      return this.contributorTarget;
1613    }
1614
1615    /**
1616     * @return {@link #suspectEntity} (Describes the entity that is suspected to have caused the adverse event.)
1617     */
1618    public List<AdverseEventSuspectEntityComponent> getSuspectEntity() { 
1619      if (this.suspectEntity == null)
1620        this.suspectEntity = new ArrayList<AdverseEventSuspectEntityComponent>();
1621      return this.suspectEntity;
1622    }
1623
1624    /**
1625     * @return Returns a reference to <code>this</code> for easy method chaining
1626     */
1627    public AdverseEvent setSuspectEntity(List<AdverseEventSuspectEntityComponent> theSuspectEntity) { 
1628      this.suspectEntity = theSuspectEntity;
1629      return this;
1630    }
1631
1632    public boolean hasSuspectEntity() { 
1633      if (this.suspectEntity == null)
1634        return false;
1635      for (AdverseEventSuspectEntityComponent item : this.suspectEntity)
1636        if (!item.isEmpty())
1637          return true;
1638      return false;
1639    }
1640
1641    public AdverseEventSuspectEntityComponent addSuspectEntity() { //3
1642      AdverseEventSuspectEntityComponent t = new AdverseEventSuspectEntityComponent();
1643      if (this.suspectEntity == null)
1644        this.suspectEntity = new ArrayList<AdverseEventSuspectEntityComponent>();
1645      this.suspectEntity.add(t);
1646      return t;
1647    }
1648
1649    public AdverseEvent addSuspectEntity(AdverseEventSuspectEntityComponent t) { //3
1650      if (t == null)
1651        return this;
1652      if (this.suspectEntity == null)
1653        this.suspectEntity = new ArrayList<AdverseEventSuspectEntityComponent>();
1654      this.suspectEntity.add(t);
1655      return this;
1656    }
1657
1658    /**
1659     * @return The first repetition of repeating field {@link #suspectEntity}, creating it if it does not already exist
1660     */
1661    public AdverseEventSuspectEntityComponent getSuspectEntityFirstRep() { 
1662      if (getSuspectEntity().isEmpty()) {
1663        addSuspectEntity();
1664      }
1665      return getSuspectEntity().get(0);
1666    }
1667
1668    /**
1669     * @return {@link #subjectMedicalHistory} (AdverseEvent.subjectMedicalHistory.)
1670     */
1671    public List<Reference> getSubjectMedicalHistory() { 
1672      if (this.subjectMedicalHistory == null)
1673        this.subjectMedicalHistory = new ArrayList<Reference>();
1674      return this.subjectMedicalHistory;
1675    }
1676
1677    /**
1678     * @return Returns a reference to <code>this</code> for easy method chaining
1679     */
1680    public AdverseEvent setSubjectMedicalHistory(List<Reference> theSubjectMedicalHistory) { 
1681      this.subjectMedicalHistory = theSubjectMedicalHistory;
1682      return this;
1683    }
1684
1685    public boolean hasSubjectMedicalHistory() { 
1686      if (this.subjectMedicalHistory == null)
1687        return false;
1688      for (Reference item : this.subjectMedicalHistory)
1689        if (!item.isEmpty())
1690          return true;
1691      return false;
1692    }
1693
1694    public Reference addSubjectMedicalHistory() { //3
1695      Reference t = new Reference();
1696      if (this.subjectMedicalHistory == null)
1697        this.subjectMedicalHistory = new ArrayList<Reference>();
1698      this.subjectMedicalHistory.add(t);
1699      return t;
1700    }
1701
1702    public AdverseEvent addSubjectMedicalHistory(Reference t) { //3
1703      if (t == null)
1704        return this;
1705      if (this.subjectMedicalHistory == null)
1706        this.subjectMedicalHistory = new ArrayList<Reference>();
1707      this.subjectMedicalHistory.add(t);
1708      return this;
1709    }
1710
1711    /**
1712     * @return The first repetition of repeating field {@link #subjectMedicalHistory}, creating it if it does not already exist
1713     */
1714    public Reference getSubjectMedicalHistoryFirstRep() { 
1715      if (getSubjectMedicalHistory().isEmpty()) {
1716        addSubjectMedicalHistory();
1717      }
1718      return getSubjectMedicalHistory().get(0);
1719    }
1720
1721    /**
1722     * @deprecated Use Reference#setResource(IBaseResource) instead
1723     */
1724    @Deprecated
1725    public List<Resource> getSubjectMedicalHistoryTarget() { 
1726      if (this.subjectMedicalHistoryTarget == null)
1727        this.subjectMedicalHistoryTarget = new ArrayList<Resource>();
1728      return this.subjectMedicalHistoryTarget;
1729    }
1730
1731    /**
1732     * @return {@link #referenceDocument} (AdverseEvent.referenceDocument.)
1733     */
1734    public List<Reference> getReferenceDocument() { 
1735      if (this.referenceDocument == null)
1736        this.referenceDocument = new ArrayList<Reference>();
1737      return this.referenceDocument;
1738    }
1739
1740    /**
1741     * @return Returns a reference to <code>this</code> for easy method chaining
1742     */
1743    public AdverseEvent setReferenceDocument(List<Reference> theReferenceDocument) { 
1744      this.referenceDocument = theReferenceDocument;
1745      return this;
1746    }
1747
1748    public boolean hasReferenceDocument() { 
1749      if (this.referenceDocument == null)
1750        return false;
1751      for (Reference item : this.referenceDocument)
1752        if (!item.isEmpty())
1753          return true;
1754      return false;
1755    }
1756
1757    public Reference addReferenceDocument() { //3
1758      Reference t = new Reference();
1759      if (this.referenceDocument == null)
1760        this.referenceDocument = new ArrayList<Reference>();
1761      this.referenceDocument.add(t);
1762      return t;
1763    }
1764
1765    public AdverseEvent addReferenceDocument(Reference t) { //3
1766      if (t == null)
1767        return this;
1768      if (this.referenceDocument == null)
1769        this.referenceDocument = new ArrayList<Reference>();
1770      this.referenceDocument.add(t);
1771      return this;
1772    }
1773
1774    /**
1775     * @return The first repetition of repeating field {@link #referenceDocument}, creating it if it does not already exist
1776     */
1777    public Reference getReferenceDocumentFirstRep() { 
1778      if (getReferenceDocument().isEmpty()) {
1779        addReferenceDocument();
1780      }
1781      return getReferenceDocument().get(0);
1782    }
1783
1784    /**
1785     * @deprecated Use Reference#setResource(IBaseResource) instead
1786     */
1787    @Deprecated
1788    public List<DocumentReference> getReferenceDocumentTarget() { 
1789      if (this.referenceDocumentTarget == null)
1790        this.referenceDocumentTarget = new ArrayList<DocumentReference>();
1791      return this.referenceDocumentTarget;
1792    }
1793
1794    /**
1795     * @deprecated Use Reference#setResource(IBaseResource) instead
1796     */
1797    @Deprecated
1798    public DocumentReference addReferenceDocumentTarget() { 
1799      DocumentReference r = new DocumentReference();
1800      if (this.referenceDocumentTarget == null)
1801        this.referenceDocumentTarget = new ArrayList<DocumentReference>();
1802      this.referenceDocumentTarget.add(r);
1803      return r;
1804    }
1805
1806    /**
1807     * @return {@link #study} (AdverseEvent.study.)
1808     */
1809    public List<Reference> getStudy() { 
1810      if (this.study == null)
1811        this.study = new ArrayList<Reference>();
1812      return this.study;
1813    }
1814
1815    /**
1816     * @return Returns a reference to <code>this</code> for easy method chaining
1817     */
1818    public AdverseEvent setStudy(List<Reference> theStudy) { 
1819      this.study = theStudy;
1820      return this;
1821    }
1822
1823    public boolean hasStudy() { 
1824      if (this.study == null)
1825        return false;
1826      for (Reference item : this.study)
1827        if (!item.isEmpty())
1828          return true;
1829      return false;
1830    }
1831
1832    public Reference addStudy() { //3
1833      Reference t = new Reference();
1834      if (this.study == null)
1835        this.study = new ArrayList<Reference>();
1836      this.study.add(t);
1837      return t;
1838    }
1839
1840    public AdverseEvent addStudy(Reference t) { //3
1841      if (t == null)
1842        return this;
1843      if (this.study == null)
1844        this.study = new ArrayList<Reference>();
1845      this.study.add(t);
1846      return this;
1847    }
1848
1849    /**
1850     * @return The first repetition of repeating field {@link #study}, creating it if it does not already exist
1851     */
1852    public Reference getStudyFirstRep() { 
1853      if (getStudy().isEmpty()) {
1854        addStudy();
1855      }
1856      return getStudy().get(0);
1857    }
1858
1859    /**
1860     * @deprecated Use Reference#setResource(IBaseResource) instead
1861     */
1862    @Deprecated
1863    public List<ResearchStudy> getStudyTarget() { 
1864      if (this.studyTarget == null)
1865        this.studyTarget = new ArrayList<ResearchStudy>();
1866      return this.studyTarget;
1867    }
1868
1869    /**
1870     * @deprecated Use Reference#setResource(IBaseResource) instead
1871     */
1872    @Deprecated
1873    public ResearchStudy addStudyTarget() { 
1874      ResearchStudy r = new ResearchStudy();
1875      if (this.studyTarget == null)
1876        this.studyTarget = new ArrayList<ResearchStudy>();
1877      this.studyTarget.add(r);
1878      return r;
1879    }
1880
1881      protected void listChildren(List<Property> children) {
1882        super.listChildren(children);
1883        children.add(new Property("identifier", "Identifier", "Business identifiers assigned to this adverse event by the performer or other systems which remain constant as the resource is updated and propagates from server to server.", 0, 1, identifier));
1884        children.add(new Property("actuality", "code", "Whether the event actually happened, or just had the potential to. Note that this is independent of whether anyone was affected or harmed or how severely.", 0, 1, actuality));
1885        children.add(new Property("category", "CodeableConcept", "The overall type of event, intended for search and filtering purposes.", 0, java.lang.Integer.MAX_VALUE, category));
1886        children.add(new Property("event", "CodeableConcept", "This element defines the specific type of event that occurred or that was prevented from occurring.", 0, 1, event));
1887        children.add(new Property("subject", "Reference(Patient|Group|Practitioner|RelatedPerson)", "This subject or group impacted by the event.", 0, 1, subject));
1888        children.add(new Property("encounter", "Reference(Encounter)", "The Encounter during which AdverseEvent was created or to which the creation of this record is tightly associated.", 0, 1, encounter));
1889        children.add(new Property("date", "dateTime", "The date (and perhaps time) when the adverse event occurred.", 0, 1, date));
1890        children.add(new Property("detected", "dateTime", "Estimated or actual date the AdverseEvent began, in the opinion of the reporter.", 0, 1, detected));
1891        children.add(new Property("recordedDate", "dateTime", "The date on which the existence of the AdverseEvent was first recorded.", 0, 1, recordedDate));
1892        children.add(new Property("resultingCondition", "Reference(Condition)", "Includes information about the reaction that occurred as a result of exposure to a substance (for example, a drug or a chemical).", 0, java.lang.Integer.MAX_VALUE, resultingCondition));
1893        children.add(new Property("location", "Reference(Location)", "The information about where the adverse event occurred.", 0, 1, location));
1894        children.add(new Property("seriousness", "CodeableConcept", "Assessment whether this event was of real importance.", 0, 1, seriousness));
1895        children.add(new Property("severity", "CodeableConcept", "Describes the severity of the adverse event, in relation to the subject. Contrast to AdverseEvent.seriousness - a severe rash might not be serious, but a mild heart problem is.", 0, 1, severity));
1896        children.add(new Property("outcome", "CodeableConcept", "Describes the type of outcome from the adverse event.", 0, 1, outcome));
1897        children.add(new Property("recorder", "Reference(Patient|Practitioner|PractitionerRole|RelatedPerson)", "Information on who recorded the adverse event.  May be the patient or a practitioner.", 0, 1, recorder));
1898        children.add(new Property("contributor", "Reference(Practitioner|PractitionerRole|Device)", "Parties that may or should contribute or have contributed information to the adverse event, which can consist of one or more activities.  Such information includes information leading to the decision to perform the activity and how to perform the activity (e.g. consultant), information that the activity itself seeks to reveal (e.g. informant of clinical history), or information about what activity was performed (e.g. informant witness).", 0, java.lang.Integer.MAX_VALUE, contributor));
1899        children.add(new Property("suspectEntity", "", "Describes the entity that is suspected to have caused the adverse event.", 0, java.lang.Integer.MAX_VALUE, suspectEntity));
1900        children.add(new Property("subjectMedicalHistory", "Reference(Condition|Observation|AllergyIntolerance|FamilyMemberHistory|Immunization|Procedure|Media|DocumentReference)", "AdverseEvent.subjectMedicalHistory.", 0, java.lang.Integer.MAX_VALUE, subjectMedicalHistory));
1901        children.add(new Property("referenceDocument", "Reference(DocumentReference)", "AdverseEvent.referenceDocument.", 0, java.lang.Integer.MAX_VALUE, referenceDocument));
1902        children.add(new Property("study", "Reference(ResearchStudy)", "AdverseEvent.study.", 0, java.lang.Integer.MAX_VALUE, study));
1903      }
1904
1905      @Override
1906      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1907        switch (_hash) {
1908        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Business identifiers assigned to this adverse event by the performer or other systems which remain constant as the resource is updated and propagates from server to server.", 0, 1, identifier);
1909        case 528866400: /*actuality*/  return new Property("actuality", "code", "Whether the event actually happened, or just had the potential to. Note that this is independent of whether anyone was affected or harmed or how severely.", 0, 1, actuality);
1910        case 50511102: /*category*/  return new Property("category", "CodeableConcept", "The overall type of event, intended for search and filtering purposes.", 0, java.lang.Integer.MAX_VALUE, category);
1911        case 96891546: /*event*/  return new Property("event", "CodeableConcept", "This element defines the specific type of event that occurred or that was prevented from occurring.", 0, 1, event);
1912        case -1867885268: /*subject*/  return new Property("subject", "Reference(Patient|Group|Practitioner|RelatedPerson)", "This subject or group impacted by the event.", 0, 1, subject);
1913        case 1524132147: /*encounter*/  return new Property("encounter", "Reference(Encounter)", "The Encounter during which AdverseEvent was created or to which the creation of this record is tightly associated.", 0, 1, encounter);
1914        case 3076014: /*date*/  return new Property("date", "dateTime", "The date (and perhaps time) when the adverse event occurred.", 0, 1, date);
1915        case 1048254082: /*detected*/  return new Property("detected", "dateTime", "Estimated or actual date the AdverseEvent began, in the opinion of the reporter.", 0, 1, detected);
1916        case -1952893826: /*recordedDate*/  return new Property("recordedDate", "dateTime", "The date on which the existence of the AdverseEvent was first recorded.", 0, 1, recordedDate);
1917        case -830261258: /*resultingCondition*/  return new Property("resultingCondition", "Reference(Condition)", "Includes information about the reaction that occurred as a result of exposure to a substance (for example, a drug or a chemical).", 0, java.lang.Integer.MAX_VALUE, resultingCondition);
1918        case 1901043637: /*location*/  return new Property("location", "Reference(Location)", "The information about where the adverse event occurred.", 0, 1, location);
1919        case -1551003909: /*seriousness*/  return new Property("seriousness", "CodeableConcept", "Assessment whether this event was of real importance.", 0, 1, seriousness);
1920        case 1478300413: /*severity*/  return new Property("severity", "CodeableConcept", "Describes the severity of the adverse event, in relation to the subject. Contrast to AdverseEvent.seriousness - a severe rash might not be serious, but a mild heart problem is.", 0, 1, severity);
1921        case -1106507950: /*outcome*/  return new Property("outcome", "CodeableConcept", "Describes the type of outcome from the adverse event.", 0, 1, outcome);
1922        case -799233858: /*recorder*/  return new Property("recorder", "Reference(Patient|Practitioner|PractitionerRole|RelatedPerson)", "Information on who recorded the adverse event.  May be the patient or a practitioner.", 0, 1, recorder);
1923        case -1895276325: /*contributor*/  return new Property("contributor", "Reference(Practitioner|PractitionerRole|Device)", "Parties that may or should contribute or have contributed information to the adverse event, which can consist of one or more activities.  Such information includes information leading to the decision to perform the activity and how to perform the activity (e.g. consultant), information that the activity itself seeks to reveal (e.g. informant of clinical history), or information about what activity was performed (e.g. informant witness).", 0, java.lang.Integer.MAX_VALUE, contributor);
1924        case -1957422662: /*suspectEntity*/  return new Property("suspectEntity", "", "Describes the entity that is suspected to have caused the adverse event.", 0, java.lang.Integer.MAX_VALUE, suspectEntity);
1925        case -1685245681: /*subjectMedicalHistory*/  return new Property("subjectMedicalHistory", "Reference(Condition|Observation|AllergyIntolerance|FamilyMemberHistory|Immunization|Procedure|Media|DocumentReference)", "AdverseEvent.subjectMedicalHistory.", 0, java.lang.Integer.MAX_VALUE, subjectMedicalHistory);
1926        case 1013971334: /*referenceDocument*/  return new Property("referenceDocument", "Reference(DocumentReference)", "AdverseEvent.referenceDocument.", 0, java.lang.Integer.MAX_VALUE, referenceDocument);
1927        case 109776329: /*study*/  return new Property("study", "Reference(ResearchStudy)", "AdverseEvent.study.", 0, java.lang.Integer.MAX_VALUE, study);
1928        default: return super.getNamedProperty(_hash, _name, _checkValid);
1929        }
1930
1931      }
1932
1933      @Override
1934      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1935        switch (hash) {
1936        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : new Base[] {this.identifier}; // Identifier
1937        case 528866400: /*actuality*/ return this.actuality == null ? new Base[0] : new Base[] {this.actuality}; // Enumeration<AdverseEventActuality>
1938        case 50511102: /*category*/ return this.category == null ? new Base[0] : this.category.toArray(new Base[this.category.size()]); // CodeableConcept
1939        case 96891546: /*event*/ return this.event == null ? new Base[0] : new Base[] {this.event}; // CodeableConcept
1940        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
1941        case 1524132147: /*encounter*/ return this.encounter == null ? new Base[0] : new Base[] {this.encounter}; // Reference
1942        case 3076014: /*date*/ return this.date == null ? new Base[0] : new Base[] {this.date}; // DateTimeType
1943        case 1048254082: /*detected*/ return this.detected == null ? new Base[0] : new Base[] {this.detected}; // DateTimeType
1944        case -1952893826: /*recordedDate*/ return this.recordedDate == null ? new Base[0] : new Base[] {this.recordedDate}; // DateTimeType
1945        case -830261258: /*resultingCondition*/ return this.resultingCondition == null ? new Base[0] : this.resultingCondition.toArray(new Base[this.resultingCondition.size()]); // Reference
1946        case 1901043637: /*location*/ return this.location == null ? new Base[0] : new Base[] {this.location}; // Reference
1947        case -1551003909: /*seriousness*/ return this.seriousness == null ? new Base[0] : new Base[] {this.seriousness}; // CodeableConcept
1948        case 1478300413: /*severity*/ return this.severity == null ? new Base[0] : new Base[] {this.severity}; // CodeableConcept
1949        case -1106507950: /*outcome*/ return this.outcome == null ? new Base[0] : new Base[] {this.outcome}; // CodeableConcept
1950        case -799233858: /*recorder*/ return this.recorder == null ? new Base[0] : new Base[] {this.recorder}; // Reference
1951        case -1895276325: /*contributor*/ return this.contributor == null ? new Base[0] : this.contributor.toArray(new Base[this.contributor.size()]); // Reference
1952        case -1957422662: /*suspectEntity*/ return this.suspectEntity == null ? new Base[0] : this.suspectEntity.toArray(new Base[this.suspectEntity.size()]); // AdverseEventSuspectEntityComponent
1953        case -1685245681: /*subjectMedicalHistory*/ return this.subjectMedicalHistory == null ? new Base[0] : this.subjectMedicalHistory.toArray(new Base[this.subjectMedicalHistory.size()]); // Reference
1954        case 1013971334: /*referenceDocument*/ return this.referenceDocument == null ? new Base[0] : this.referenceDocument.toArray(new Base[this.referenceDocument.size()]); // Reference
1955        case 109776329: /*study*/ return this.study == null ? new Base[0] : this.study.toArray(new Base[this.study.size()]); // Reference
1956        default: return super.getProperty(hash, name, checkValid);
1957        }
1958
1959      }
1960
1961      @Override
1962      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1963        switch (hash) {
1964        case -1618432855: // identifier
1965          this.identifier = castToIdentifier(value); // Identifier
1966          return value;
1967        case 528866400: // actuality
1968          value = new AdverseEventActualityEnumFactory().fromType(castToCode(value));
1969          this.actuality = (Enumeration) value; // Enumeration<AdverseEventActuality>
1970          return value;
1971        case 50511102: // category
1972          this.getCategory().add(castToCodeableConcept(value)); // CodeableConcept
1973          return value;
1974        case 96891546: // event
1975          this.event = castToCodeableConcept(value); // CodeableConcept
1976          return value;
1977        case -1867885268: // subject
1978          this.subject = castToReference(value); // Reference
1979          return value;
1980        case 1524132147: // encounter
1981          this.encounter = castToReference(value); // Reference
1982          return value;
1983        case 3076014: // date
1984          this.date = castToDateTime(value); // DateTimeType
1985          return value;
1986        case 1048254082: // detected
1987          this.detected = castToDateTime(value); // DateTimeType
1988          return value;
1989        case -1952893826: // recordedDate
1990          this.recordedDate = castToDateTime(value); // DateTimeType
1991          return value;
1992        case -830261258: // resultingCondition
1993          this.getResultingCondition().add(castToReference(value)); // Reference
1994          return value;
1995        case 1901043637: // location
1996          this.location = castToReference(value); // Reference
1997          return value;
1998        case -1551003909: // seriousness
1999          this.seriousness = castToCodeableConcept(value); // CodeableConcept
2000          return value;
2001        case 1478300413: // severity
2002          this.severity = castToCodeableConcept(value); // CodeableConcept
2003          return value;
2004        case -1106507950: // outcome
2005          this.outcome = castToCodeableConcept(value); // CodeableConcept
2006          return value;
2007        case -799233858: // recorder
2008          this.recorder = castToReference(value); // Reference
2009          return value;
2010        case -1895276325: // contributor
2011          this.getContributor().add(castToReference(value)); // Reference
2012          return value;
2013        case -1957422662: // suspectEntity
2014          this.getSuspectEntity().add((AdverseEventSuspectEntityComponent) value); // AdverseEventSuspectEntityComponent
2015          return value;
2016        case -1685245681: // subjectMedicalHistory
2017          this.getSubjectMedicalHistory().add(castToReference(value)); // Reference
2018          return value;
2019        case 1013971334: // referenceDocument
2020          this.getReferenceDocument().add(castToReference(value)); // Reference
2021          return value;
2022        case 109776329: // study
2023          this.getStudy().add(castToReference(value)); // Reference
2024          return value;
2025        default: return super.setProperty(hash, name, value);
2026        }
2027
2028      }
2029
2030      @Override
2031      public Base setProperty(String name, Base value) throws FHIRException {
2032        if (name.equals("identifier")) {
2033          this.identifier = castToIdentifier(value); // Identifier
2034        } else if (name.equals("actuality")) {
2035          value = new AdverseEventActualityEnumFactory().fromType(castToCode(value));
2036          this.actuality = (Enumeration) value; // Enumeration<AdverseEventActuality>
2037        } else if (name.equals("category")) {
2038          this.getCategory().add(castToCodeableConcept(value));
2039        } else if (name.equals("event")) {
2040          this.event = castToCodeableConcept(value); // CodeableConcept
2041        } else if (name.equals("subject")) {
2042          this.subject = castToReference(value); // Reference
2043        } else if (name.equals("encounter")) {
2044          this.encounter = castToReference(value); // Reference
2045        } else if (name.equals("date")) {
2046          this.date = castToDateTime(value); // DateTimeType
2047        } else if (name.equals("detected")) {
2048          this.detected = castToDateTime(value); // DateTimeType
2049        } else if (name.equals("recordedDate")) {
2050          this.recordedDate = castToDateTime(value); // DateTimeType
2051        } else if (name.equals("resultingCondition")) {
2052          this.getResultingCondition().add(castToReference(value));
2053        } else if (name.equals("location")) {
2054          this.location = castToReference(value); // Reference
2055        } else if (name.equals("seriousness")) {
2056          this.seriousness = castToCodeableConcept(value); // CodeableConcept
2057        } else if (name.equals("severity")) {
2058          this.severity = castToCodeableConcept(value); // CodeableConcept
2059        } else if (name.equals("outcome")) {
2060          this.outcome = castToCodeableConcept(value); // CodeableConcept
2061        } else if (name.equals("recorder")) {
2062          this.recorder = castToReference(value); // Reference
2063        } else if (name.equals("contributor")) {
2064          this.getContributor().add(castToReference(value));
2065        } else if (name.equals("suspectEntity")) {
2066          this.getSuspectEntity().add((AdverseEventSuspectEntityComponent) value);
2067        } else if (name.equals("subjectMedicalHistory")) {
2068          this.getSubjectMedicalHistory().add(castToReference(value));
2069        } else if (name.equals("referenceDocument")) {
2070          this.getReferenceDocument().add(castToReference(value));
2071        } else if (name.equals("study")) {
2072          this.getStudy().add(castToReference(value));
2073        } else
2074          return super.setProperty(name, value);
2075        return value;
2076      }
2077
2078      @Override
2079      public Base makeProperty(int hash, String name) throws FHIRException {
2080        switch (hash) {
2081        case -1618432855:  return getIdentifier(); 
2082        case 528866400:  return getActualityElement();
2083        case 50511102:  return addCategory(); 
2084        case 96891546:  return getEvent(); 
2085        case -1867885268:  return getSubject(); 
2086        case 1524132147:  return getEncounter(); 
2087        case 3076014:  return getDateElement();
2088        case 1048254082:  return getDetectedElement();
2089        case -1952893826:  return getRecordedDateElement();
2090        case -830261258:  return addResultingCondition(); 
2091        case 1901043637:  return getLocation(); 
2092        case -1551003909:  return getSeriousness(); 
2093        case 1478300413:  return getSeverity(); 
2094        case -1106507950:  return getOutcome(); 
2095        case -799233858:  return getRecorder(); 
2096        case -1895276325:  return addContributor(); 
2097        case -1957422662:  return addSuspectEntity(); 
2098        case -1685245681:  return addSubjectMedicalHistory(); 
2099        case 1013971334:  return addReferenceDocument(); 
2100        case 109776329:  return addStudy(); 
2101        default: return super.makeProperty(hash, name);
2102        }
2103
2104      }
2105
2106      @Override
2107      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2108        switch (hash) {
2109        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
2110        case 528866400: /*actuality*/ return new String[] {"code"};
2111        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
2112        case 96891546: /*event*/ return new String[] {"CodeableConcept"};
2113        case -1867885268: /*subject*/ return new String[] {"Reference"};
2114        case 1524132147: /*encounter*/ return new String[] {"Reference"};
2115        case 3076014: /*date*/ return new String[] {"dateTime"};
2116        case 1048254082: /*detected*/ return new String[] {"dateTime"};
2117        case -1952893826: /*recordedDate*/ return new String[] {"dateTime"};
2118        case -830261258: /*resultingCondition*/ return new String[] {"Reference"};
2119        case 1901043637: /*location*/ return new String[] {"Reference"};
2120        case -1551003909: /*seriousness*/ return new String[] {"CodeableConcept"};
2121        case 1478300413: /*severity*/ return new String[] {"CodeableConcept"};
2122        case -1106507950: /*outcome*/ return new String[] {"CodeableConcept"};
2123        case -799233858: /*recorder*/ return new String[] {"Reference"};
2124        case -1895276325: /*contributor*/ return new String[] {"Reference"};
2125        case -1957422662: /*suspectEntity*/ return new String[] {};
2126        case -1685245681: /*subjectMedicalHistory*/ return new String[] {"Reference"};
2127        case 1013971334: /*referenceDocument*/ return new String[] {"Reference"};
2128        case 109776329: /*study*/ return new String[] {"Reference"};
2129        default: return super.getTypesForProperty(hash, name);
2130        }
2131
2132      }
2133
2134      @Override
2135      public Base addChild(String name) throws FHIRException {
2136        if (name.equals("identifier")) {
2137          this.identifier = new Identifier();
2138          return this.identifier;
2139        }
2140        else if (name.equals("actuality")) {
2141          throw new FHIRException("Cannot call addChild on a primitive type AdverseEvent.actuality");
2142        }
2143        else if (name.equals("category")) {
2144          return addCategory();
2145        }
2146        else if (name.equals("event")) {
2147          this.event = new CodeableConcept();
2148          return this.event;
2149        }
2150        else if (name.equals("subject")) {
2151          this.subject = new Reference();
2152          return this.subject;
2153        }
2154        else if (name.equals("encounter")) {
2155          this.encounter = new Reference();
2156          return this.encounter;
2157        }
2158        else if (name.equals("date")) {
2159          throw new FHIRException("Cannot call addChild on a primitive type AdverseEvent.date");
2160        }
2161        else if (name.equals("detected")) {
2162          throw new FHIRException("Cannot call addChild on a primitive type AdverseEvent.detected");
2163        }
2164        else if (name.equals("recordedDate")) {
2165          throw new FHIRException("Cannot call addChild on a primitive type AdverseEvent.recordedDate");
2166        }
2167        else if (name.equals("resultingCondition")) {
2168          return addResultingCondition();
2169        }
2170        else if (name.equals("location")) {
2171          this.location = new Reference();
2172          return this.location;
2173        }
2174        else if (name.equals("seriousness")) {
2175          this.seriousness = new CodeableConcept();
2176          return this.seriousness;
2177        }
2178        else if (name.equals("severity")) {
2179          this.severity = new CodeableConcept();
2180          return this.severity;
2181        }
2182        else if (name.equals("outcome")) {
2183          this.outcome = new CodeableConcept();
2184          return this.outcome;
2185        }
2186        else if (name.equals("recorder")) {
2187          this.recorder = new Reference();
2188          return this.recorder;
2189        }
2190        else if (name.equals("contributor")) {
2191          return addContributor();
2192        }
2193        else if (name.equals("suspectEntity")) {
2194          return addSuspectEntity();
2195        }
2196        else if (name.equals("subjectMedicalHistory")) {
2197          return addSubjectMedicalHistory();
2198        }
2199        else if (name.equals("referenceDocument")) {
2200          return addReferenceDocument();
2201        }
2202        else if (name.equals("study")) {
2203          return addStudy();
2204        }
2205        else
2206          return super.addChild(name);
2207      }
2208
2209  public String fhirType() {
2210    return "AdverseEvent";
2211
2212  }
2213
2214      public AdverseEvent copy() {
2215        AdverseEvent dst = new AdverseEvent();
2216        copyValues(dst);
2217        dst.identifier = identifier == null ? null : identifier.copy();
2218        dst.actuality = actuality == null ? null : actuality.copy();
2219        if (category != null) {
2220          dst.category = new ArrayList<CodeableConcept>();
2221          for (CodeableConcept i : category)
2222            dst.category.add(i.copy());
2223        };
2224        dst.event = event == null ? null : event.copy();
2225        dst.subject = subject == null ? null : subject.copy();
2226        dst.encounter = encounter == null ? null : encounter.copy();
2227        dst.date = date == null ? null : date.copy();
2228        dst.detected = detected == null ? null : detected.copy();
2229        dst.recordedDate = recordedDate == null ? null : recordedDate.copy();
2230        if (resultingCondition != null) {
2231          dst.resultingCondition = new ArrayList<Reference>();
2232          for (Reference i : resultingCondition)
2233            dst.resultingCondition.add(i.copy());
2234        };
2235        dst.location = location == null ? null : location.copy();
2236        dst.seriousness = seriousness == null ? null : seriousness.copy();
2237        dst.severity = severity == null ? null : severity.copy();
2238        dst.outcome = outcome == null ? null : outcome.copy();
2239        dst.recorder = recorder == null ? null : recorder.copy();
2240        if (contributor != null) {
2241          dst.contributor = new ArrayList<Reference>();
2242          for (Reference i : contributor)
2243            dst.contributor.add(i.copy());
2244        };
2245        if (suspectEntity != null) {
2246          dst.suspectEntity = new ArrayList<AdverseEventSuspectEntityComponent>();
2247          for (AdverseEventSuspectEntityComponent i : suspectEntity)
2248            dst.suspectEntity.add(i.copy());
2249        };
2250        if (subjectMedicalHistory != null) {
2251          dst.subjectMedicalHistory = new ArrayList<Reference>();
2252          for (Reference i : subjectMedicalHistory)
2253            dst.subjectMedicalHistory.add(i.copy());
2254        };
2255        if (referenceDocument != null) {
2256          dst.referenceDocument = new ArrayList<Reference>();
2257          for (Reference i : referenceDocument)
2258            dst.referenceDocument.add(i.copy());
2259        };
2260        if (study != null) {
2261          dst.study = new ArrayList<Reference>();
2262          for (Reference i : study)
2263            dst.study.add(i.copy());
2264        };
2265        return dst;
2266      }
2267
2268      protected AdverseEvent typedCopy() {
2269        return copy();
2270      }
2271
2272      @Override
2273      public boolean equalsDeep(Base other_) {
2274        if (!super.equalsDeep(other_))
2275          return false;
2276        if (!(other_ instanceof AdverseEvent))
2277          return false;
2278        AdverseEvent o = (AdverseEvent) other_;
2279        return compareDeep(identifier, o.identifier, true) && compareDeep(actuality, o.actuality, true)
2280           && compareDeep(category, o.category, true) && compareDeep(event, o.event, true) && compareDeep(subject, o.subject, true)
2281           && compareDeep(encounter, o.encounter, true) && compareDeep(date, o.date, true) && compareDeep(detected, o.detected, true)
2282           && compareDeep(recordedDate, o.recordedDate, true) && compareDeep(resultingCondition, o.resultingCondition, true)
2283           && compareDeep(location, o.location, true) && compareDeep(seriousness, o.seriousness, true) && compareDeep(severity, o.severity, true)
2284           && compareDeep(outcome, o.outcome, true) && compareDeep(recorder, o.recorder, true) && compareDeep(contributor, o.contributor, true)
2285           && compareDeep(suspectEntity, o.suspectEntity, true) && compareDeep(subjectMedicalHistory, o.subjectMedicalHistory, true)
2286           && compareDeep(referenceDocument, o.referenceDocument, true) && compareDeep(study, o.study, true)
2287          ;
2288      }
2289
2290      @Override
2291      public boolean equalsShallow(Base other_) {
2292        if (!super.equalsShallow(other_))
2293          return false;
2294        if (!(other_ instanceof AdverseEvent))
2295          return false;
2296        AdverseEvent o = (AdverseEvent) other_;
2297        return compareValues(actuality, o.actuality, true) && compareValues(date, o.date, true) && compareValues(detected, o.detected, true)
2298           && compareValues(recordedDate, o.recordedDate, true);
2299      }
2300
2301      public boolean isEmpty() {
2302        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, actuality, category
2303          , event, subject, encounter, date, detected, recordedDate, resultingCondition
2304          , location, seriousness, severity, outcome, recorder, contributor, suspectEntity
2305          , subjectMedicalHistory, referenceDocument, study);
2306      }
2307
2308  @Override
2309  public ResourceType getResourceType() {
2310    return ResourceType.AdverseEvent;
2311   }
2312
2313 /**
2314   * Search parameter: <b>date</b>
2315   * <p>
2316   * Description: <b>When the event occurred</b><br>
2317   * Type: <b>date</b><br>
2318   * Path: <b>AdverseEvent.date</b><br>
2319   * </p>
2320   */
2321  @SearchParamDefinition(name="date", path="AdverseEvent.date", description="When the event occurred", type="date" )
2322  public static final String SP_DATE = "date";
2323 /**
2324   * <b>Fluent Client</b> search parameter constant for <b>date</b>
2325   * <p>
2326   * Description: <b>When the event occurred</b><br>
2327   * Type: <b>date</b><br>
2328   * Path: <b>AdverseEvent.date</b><br>
2329   * </p>
2330   */
2331  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
2332
2333 /**
2334   * Search parameter: <b>severity</b>
2335   * <p>
2336   * Description: <b>mild | moderate | severe</b><br>
2337   * Type: <b>token</b><br>
2338   * Path: <b>AdverseEvent.severity</b><br>
2339   * </p>
2340   */
2341  @SearchParamDefinition(name="severity", path="AdverseEvent.severity", description="mild | moderate | severe", type="token" )
2342  public static final String SP_SEVERITY = "severity";
2343 /**
2344   * <b>Fluent Client</b> search parameter constant for <b>severity</b>
2345   * <p>
2346   * Description: <b>mild | moderate | severe</b><br>
2347   * Type: <b>token</b><br>
2348   * Path: <b>AdverseEvent.severity</b><br>
2349   * </p>
2350   */
2351  public static final ca.uhn.fhir.rest.gclient.TokenClientParam SEVERITY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_SEVERITY);
2352
2353 /**
2354   * Search parameter: <b>recorder</b>
2355   * <p>
2356   * Description: <b>Who recorded the adverse event</b><br>
2357   * Type: <b>reference</b><br>
2358   * Path: <b>AdverseEvent.recorder</b><br>
2359   * </p>
2360   */
2361  @SearchParamDefinition(name="recorder", path="AdverseEvent.recorder", description="Who recorded the adverse event", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner"), @ca.uhn.fhir.model.api.annotation.Compartment(name="RelatedPerson") }, target={Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class } )
2362  public static final String SP_RECORDER = "recorder";
2363 /**
2364   * <b>Fluent Client</b> search parameter constant for <b>recorder</b>
2365   * <p>
2366   * Description: <b>Who recorded the adverse event</b><br>
2367   * Type: <b>reference</b><br>
2368   * Path: <b>AdverseEvent.recorder</b><br>
2369   * </p>
2370   */
2371  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam RECORDER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_RECORDER);
2372
2373/**
2374   * Constant for fluent queries to be used to add include statements. Specifies
2375   * the path value of "<b>AdverseEvent:recorder</b>".
2376   */
2377  public static final ca.uhn.fhir.model.api.Include INCLUDE_RECORDER = new ca.uhn.fhir.model.api.Include("AdverseEvent:recorder").toLocked();
2378
2379 /**
2380   * Search parameter: <b>study</b>
2381   * <p>
2382   * Description: <b>AdverseEvent.study</b><br>
2383   * Type: <b>reference</b><br>
2384   * Path: <b>AdverseEvent.study</b><br>
2385   * </p>
2386   */
2387  @SearchParamDefinition(name="study", path="AdverseEvent.study", description="AdverseEvent.study", type="reference", target={ResearchStudy.class } )
2388  public static final String SP_STUDY = "study";
2389 /**
2390   * <b>Fluent Client</b> search parameter constant for <b>study</b>
2391   * <p>
2392   * Description: <b>AdverseEvent.study</b><br>
2393   * Type: <b>reference</b><br>
2394   * Path: <b>AdverseEvent.study</b><br>
2395   * </p>
2396   */
2397  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam STUDY = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_STUDY);
2398
2399/**
2400   * Constant for fluent queries to be used to add include statements. Specifies
2401   * the path value of "<b>AdverseEvent:study</b>".
2402   */
2403  public static final ca.uhn.fhir.model.api.Include INCLUDE_STUDY = new ca.uhn.fhir.model.api.Include("AdverseEvent:study").toLocked();
2404
2405 /**
2406   * Search parameter: <b>actuality</b>
2407   * <p>
2408   * Description: <b>actual | potential</b><br>
2409   * Type: <b>token</b><br>
2410   * Path: <b>AdverseEvent.actuality</b><br>
2411   * </p>
2412   */
2413  @SearchParamDefinition(name="actuality", path="AdverseEvent.actuality", description="actual | potential", type="token" )
2414  public static final String SP_ACTUALITY = "actuality";
2415 /**
2416   * <b>Fluent Client</b> search parameter constant for <b>actuality</b>
2417   * <p>
2418   * Description: <b>actual | potential</b><br>
2419   * Type: <b>token</b><br>
2420   * Path: <b>AdverseEvent.actuality</b><br>
2421   * </p>
2422   */
2423  public static final ca.uhn.fhir.rest.gclient.TokenClientParam ACTUALITY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_ACTUALITY);
2424
2425 /**
2426   * Search parameter: <b>seriousness</b>
2427   * <p>
2428   * Description: <b>Seriousness of the event</b><br>
2429   * Type: <b>token</b><br>
2430   * Path: <b>AdverseEvent.seriousness</b><br>
2431   * </p>
2432   */
2433  @SearchParamDefinition(name="seriousness", path="AdverseEvent.seriousness", description="Seriousness of the event", type="token" )
2434  public static final String SP_SERIOUSNESS = "seriousness";
2435 /**
2436   * <b>Fluent Client</b> search parameter constant for <b>seriousness</b>
2437   * <p>
2438   * Description: <b>Seriousness of the event</b><br>
2439   * Type: <b>token</b><br>
2440   * Path: <b>AdverseEvent.seriousness</b><br>
2441   * </p>
2442   */
2443  public static final ca.uhn.fhir.rest.gclient.TokenClientParam SERIOUSNESS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_SERIOUSNESS);
2444
2445 /**
2446   * Search parameter: <b>subject</b>
2447   * <p>
2448   * Description: <b>Subject impacted by event</b><br>
2449   * Type: <b>reference</b><br>
2450   * Path: <b>AdverseEvent.subject</b><br>
2451   * </p>
2452   */
2453  @SearchParamDefinition(name="subject", path="AdverseEvent.subject", description="Subject impacted by event", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Group.class, Patient.class, Practitioner.class, RelatedPerson.class } )
2454  public static final String SP_SUBJECT = "subject";
2455 /**
2456   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
2457   * <p>
2458   * Description: <b>Subject impacted by event</b><br>
2459   * Type: <b>reference</b><br>
2460   * Path: <b>AdverseEvent.subject</b><br>
2461   * </p>
2462   */
2463  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
2464
2465/**
2466   * Constant for fluent queries to be used to add include statements. Specifies
2467   * the path value of "<b>AdverseEvent:subject</b>".
2468   */
2469  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("AdverseEvent:subject").toLocked();
2470
2471 /**
2472   * Search parameter: <b>resultingcondition</b>
2473   * <p>
2474   * Description: <b>Effect on the subject due to this event</b><br>
2475   * Type: <b>reference</b><br>
2476   * Path: <b>AdverseEvent.resultingCondition</b><br>
2477   * </p>
2478   */
2479  @SearchParamDefinition(name="resultingcondition", path="AdverseEvent.resultingCondition", description="Effect on the subject due to this event", type="reference", target={Condition.class } )
2480  public static final String SP_RESULTINGCONDITION = "resultingcondition";
2481 /**
2482   * <b>Fluent Client</b> search parameter constant for <b>resultingcondition</b>
2483   * <p>
2484   * Description: <b>Effect on the subject due to this event</b><br>
2485   * Type: <b>reference</b><br>
2486   * Path: <b>AdverseEvent.resultingCondition</b><br>
2487   * </p>
2488   */
2489  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam RESULTINGCONDITION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_RESULTINGCONDITION);
2490
2491/**
2492   * Constant for fluent queries to be used to add include statements. Specifies
2493   * the path value of "<b>AdverseEvent:resultingcondition</b>".
2494   */
2495  public static final ca.uhn.fhir.model.api.Include INCLUDE_RESULTINGCONDITION = new ca.uhn.fhir.model.api.Include("AdverseEvent:resultingcondition").toLocked();
2496
2497 /**
2498   * Search parameter: <b>substance</b>
2499   * <p>
2500   * Description: <b>Refers to the specific entity that caused the adverse event</b><br>
2501   * Type: <b>reference</b><br>
2502   * Path: <b>AdverseEvent.suspectEntity.instance</b><br>
2503   * </p>
2504   */
2505  @SearchParamDefinition(name="substance", path="AdverseEvent.suspectEntity.instance", description="Refers to the specific entity that caused the adverse event", type="reference", target={Device.class, Immunization.class, Medication.class, MedicationAdministration.class, MedicationStatement.class, Procedure.class, Substance.class } )
2506  public static final String SP_SUBSTANCE = "substance";
2507 /**
2508   * <b>Fluent Client</b> search parameter constant for <b>substance</b>
2509   * <p>
2510   * Description: <b>Refers to the specific entity that caused the adverse event</b><br>
2511   * Type: <b>reference</b><br>
2512   * Path: <b>AdverseEvent.suspectEntity.instance</b><br>
2513   * </p>
2514   */
2515  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBSTANCE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBSTANCE);
2516
2517/**
2518   * Constant for fluent queries to be used to add include statements. Specifies
2519   * the path value of "<b>AdverseEvent:substance</b>".
2520   */
2521  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBSTANCE = new ca.uhn.fhir.model.api.Include("AdverseEvent:substance").toLocked();
2522
2523 /**
2524   * Search parameter: <b>location</b>
2525   * <p>
2526   * Description: <b>Location where adverse event occurred</b><br>
2527   * Type: <b>reference</b><br>
2528   * Path: <b>AdverseEvent.location</b><br>
2529   * </p>
2530   */
2531  @SearchParamDefinition(name="location", path="AdverseEvent.location", description="Location where adverse event occurred", type="reference", target={Location.class } )
2532  public static final String SP_LOCATION = "location";
2533 /**
2534   * <b>Fluent Client</b> search parameter constant for <b>location</b>
2535   * <p>
2536   * Description: <b>Location where adverse event occurred</b><br>
2537   * Type: <b>reference</b><br>
2538   * Path: <b>AdverseEvent.location</b><br>
2539   * </p>
2540   */
2541  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam LOCATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_LOCATION);
2542
2543/**
2544   * Constant for fluent queries to be used to add include statements. Specifies
2545   * the path value of "<b>AdverseEvent:location</b>".
2546   */
2547  public static final ca.uhn.fhir.model.api.Include INCLUDE_LOCATION = new ca.uhn.fhir.model.api.Include("AdverseEvent:location").toLocked();
2548
2549 /**
2550   * Search parameter: <b>category</b>
2551   * <p>
2552   * Description: <b>product-problem | product-quality | product-use-error | wrong-dose | incorrect-prescribing-information | wrong-technique | wrong-route-of-administration | wrong-rate | wrong-duration | wrong-time | expired-drug | medical-device-use-error | problem-different-manufacturer | unsafe-physical-environment</b><br>
2553   * Type: <b>token</b><br>
2554   * Path: <b>AdverseEvent.category</b><br>
2555   * </p>
2556   */
2557  @SearchParamDefinition(name="category", path="AdverseEvent.category", description="product-problem | product-quality | product-use-error | wrong-dose | incorrect-prescribing-information | wrong-technique | wrong-route-of-administration | wrong-rate | wrong-duration | wrong-time | expired-drug | medical-device-use-error | problem-different-manufacturer | unsafe-physical-environment", type="token" )
2558  public static final String SP_CATEGORY = "category";
2559 /**
2560   * <b>Fluent Client</b> search parameter constant for <b>category</b>
2561   * <p>
2562   * Description: <b>product-problem | product-quality | product-use-error | wrong-dose | incorrect-prescribing-information | wrong-technique | wrong-route-of-administration | wrong-rate | wrong-duration | wrong-time | expired-drug | medical-device-use-error | problem-different-manufacturer | unsafe-physical-environment</b><br>
2563   * Type: <b>token</b><br>
2564   * Path: <b>AdverseEvent.category</b><br>
2565   * </p>
2566   */
2567  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CATEGORY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CATEGORY);
2568
2569 /**
2570   * Search parameter: <b>event</b>
2571   * <p>
2572   * Description: <b>Type of the event itself in relation to the subject</b><br>
2573   * Type: <b>token</b><br>
2574   * Path: <b>AdverseEvent.event</b><br>
2575   * </p>
2576   */
2577  @SearchParamDefinition(name="event", path="AdverseEvent.event", description="Type of the event itself in relation to the subject", type="token" )
2578  public static final String SP_EVENT = "event";
2579 /**
2580   * <b>Fluent Client</b> search parameter constant for <b>event</b>
2581   * <p>
2582   * Description: <b>Type of the event itself in relation to the subject</b><br>
2583   * Type: <b>token</b><br>
2584   * Path: <b>AdverseEvent.event</b><br>
2585   * </p>
2586   */
2587  public static final ca.uhn.fhir.rest.gclient.TokenClientParam EVENT = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_EVENT);
2588
2589
2590}
2591