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