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