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