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