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