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