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 * Risk of harmful or undesirable, physiological response which is unique to an
049 * individual and associated with exposure to a substance.
050 */
051@ResourceDef(name = "AllergyIntolerance", profile = "http://hl7.org/fhir/StructureDefinition/AllergyIntolerance")
052public class AllergyIntolerance extends DomainResource {
053
054  public enum AllergyIntoleranceType {
055    /**
056     * A propensity for hypersensitive reaction(s) to a substance. These reactions
057     * are most typically type I hypersensitivity, plus other "allergy-like"
058     * reactions, including pseudoallergy.
059     */
060    ALLERGY,
061    /**
062     * A propensity for adverse reactions to a substance that is not judged to be
063     * allergic or "allergy-like". These reactions are typically (but not
064     * necessarily) non-immune. They are to some degree idiosyncratic and/or
065     * patient-specific (i.e. are not a reaction that is expected to occur with most
066     * or all patients given similar circumstances).
067     */
068    INTOLERANCE,
069    /**
070     * added to help the parsers with the generic types
071     */
072    NULL;
073
074    public static AllergyIntoleranceType fromCode(String codeString) throws FHIRException {
075      if (codeString == null || "".equals(codeString))
076        return null;
077      if ("allergy".equals(codeString))
078        return ALLERGY;
079      if ("intolerance".equals(codeString))
080        return INTOLERANCE;
081      if (Configuration.isAcceptInvalidEnums())
082        return null;
083      else
084        throw new FHIRException("Unknown AllergyIntoleranceType code '" + codeString + "'");
085    }
086
087    public String toCode() {
088      switch (this) {
089      case ALLERGY:
090        return "allergy";
091      case INTOLERANCE:
092        return "intolerance";
093      case NULL:
094        return null;
095      default:
096        return "?";
097      }
098    }
099
100    public String getSystem() {
101      switch (this) {
102      case ALLERGY:
103        return "http://hl7.org/fhir/allergy-intolerance-type";
104      case INTOLERANCE:
105        return "http://hl7.org/fhir/allergy-intolerance-type";
106      case NULL:
107        return null;
108      default:
109        return "?";
110      }
111    }
112
113    public String getDefinition() {
114      switch (this) {
115      case ALLERGY:
116        return "A propensity for hypersensitive reaction(s) to a substance.  These reactions are most typically type I hypersensitivity, plus other \"allergy-like\" reactions, including pseudoallergy.";
117      case INTOLERANCE:
118        return "A propensity for adverse reactions to a substance that is not judged to be allergic or \"allergy-like\".  These reactions are typically (but not necessarily) non-immune.  They are to some degree idiosyncratic and/or patient-specific (i.e. are not a reaction that is expected to occur with most or all patients given similar circumstances).";
119      case NULL:
120        return null;
121      default:
122        return "?";
123      }
124    }
125
126    public String getDisplay() {
127      switch (this) {
128      case ALLERGY:
129        return "Allergy";
130      case INTOLERANCE:
131        return "Intolerance";
132      case NULL:
133        return null;
134      default:
135        return "?";
136      }
137    }
138  }
139
140  public static class AllergyIntoleranceTypeEnumFactory implements EnumFactory<AllergyIntoleranceType> {
141    public AllergyIntoleranceType fromCode(String codeString) throws IllegalArgumentException {
142      if (codeString == null || "".equals(codeString))
143        if (codeString == null || "".equals(codeString))
144          return null;
145      if ("allergy".equals(codeString))
146        return AllergyIntoleranceType.ALLERGY;
147      if ("intolerance".equals(codeString))
148        return AllergyIntoleranceType.INTOLERANCE;
149      throw new IllegalArgumentException("Unknown AllergyIntoleranceType code '" + codeString + "'");
150    }
151
152    public Enumeration<AllergyIntoleranceType> fromType(PrimitiveType<?> code) throws FHIRException {
153      if (code == null)
154        return null;
155      if (code.isEmpty())
156        return new Enumeration<AllergyIntoleranceType>(this, AllergyIntoleranceType.NULL, code);
157      String codeString = code.asStringValue();
158      if (codeString == null || "".equals(codeString))
159        return new Enumeration<AllergyIntoleranceType>(this, AllergyIntoleranceType.NULL, code);
160      if ("allergy".equals(codeString))
161        return new Enumeration<AllergyIntoleranceType>(this, AllergyIntoleranceType.ALLERGY, code);
162      if ("intolerance".equals(codeString))
163        return new Enumeration<AllergyIntoleranceType>(this, AllergyIntoleranceType.INTOLERANCE, code);
164      throw new FHIRException("Unknown AllergyIntoleranceType code '" + codeString + "'");
165    }
166
167    public String toCode(AllergyIntoleranceType code) {
168      if (code == AllergyIntoleranceType.ALLERGY)
169        return "allergy";
170      if (code == AllergyIntoleranceType.INTOLERANCE)
171        return "intolerance";
172      return "?";
173    }
174
175    public String toSystem(AllergyIntoleranceType code) {
176      return code.getSystem();
177    }
178  }
179
180  public enum AllergyIntoleranceCategory {
181    /**
182     * Any substance consumed to provide nutritional support for the body.
183     */
184    FOOD,
185    /**
186     * Substances administered to achieve a physiological effect.
187     */
188    MEDICATION,
189    /**
190     * Any substances that are encountered in the environment, including any
191     * substance not already classified as food, medication, or biologic.
192     */
193    ENVIRONMENT,
194    /**
195     * A preparation that is synthesized from living organisms or their products,
196     * especially a human or animal protein, such as a hormone or antitoxin, that is
197     * used as a diagnostic, preventive, or therapeutic agent. Examples of biologic
198     * medications include: vaccines; allergenic extracts, which are used for both
199     * diagnosis and treatment (for example, allergy shots); gene therapies;
200     * cellular therapies. There are other biologic products, such as tissues, which
201     * are not typically associated with allergies.
202     */
203    BIOLOGIC,
204    /**
205     * added to help the parsers with the generic types
206     */
207    NULL;
208
209    public static AllergyIntoleranceCategory fromCode(String codeString) throws FHIRException {
210      if (codeString == null || "".equals(codeString))
211        return null;
212      if ("food".equals(codeString))
213        return FOOD;
214      if ("medication".equals(codeString))
215        return MEDICATION;
216      if ("environment".equals(codeString))
217        return ENVIRONMENT;
218      if ("biologic".equals(codeString))
219        return BIOLOGIC;
220      if (Configuration.isAcceptInvalidEnums())
221        return null;
222      else
223        throw new FHIRException("Unknown AllergyIntoleranceCategory code '" + codeString + "'");
224    }
225
226    public String toCode() {
227      switch (this) {
228      case FOOD:
229        return "food";
230      case MEDICATION:
231        return "medication";
232      case ENVIRONMENT:
233        return "environment";
234      case BIOLOGIC:
235        return "biologic";
236      case NULL:
237        return null;
238      default:
239        return "?";
240      }
241    }
242
243    public String getSystem() {
244      switch (this) {
245      case FOOD:
246        return "http://hl7.org/fhir/allergy-intolerance-category";
247      case MEDICATION:
248        return "http://hl7.org/fhir/allergy-intolerance-category";
249      case ENVIRONMENT:
250        return "http://hl7.org/fhir/allergy-intolerance-category";
251      case BIOLOGIC:
252        return "http://hl7.org/fhir/allergy-intolerance-category";
253      case NULL:
254        return null;
255      default:
256        return "?";
257      }
258    }
259
260    public String getDefinition() {
261      switch (this) {
262      case FOOD:
263        return "Any substance consumed to provide nutritional support for the body.";
264      case MEDICATION:
265        return "Substances administered to achieve a physiological effect.";
266      case ENVIRONMENT:
267        return "Any substances that are encountered in the environment, including any substance not already classified as food, medication, or biologic.";
268      case BIOLOGIC:
269        return "A preparation that is synthesized from living organisms or their products, especially a human or animal protein, such as a hormone or antitoxin, that is used as a diagnostic, preventive, or therapeutic agent. Examples of biologic medications include: vaccines; allergenic extracts, which are used for both diagnosis and treatment (for example, allergy shots); gene therapies; cellular therapies.  There are other biologic products, such as tissues, which are not typically associated with allergies.";
270      case NULL:
271        return null;
272      default:
273        return "?";
274      }
275    }
276
277    public String getDisplay() {
278      switch (this) {
279      case FOOD:
280        return "Food";
281      case MEDICATION:
282        return "Medication";
283      case ENVIRONMENT:
284        return "Environment";
285      case BIOLOGIC:
286        return "Biologic";
287      case NULL:
288        return null;
289      default:
290        return "?";
291      }
292    }
293  }
294
295  public static class AllergyIntoleranceCategoryEnumFactory implements EnumFactory<AllergyIntoleranceCategory> {
296    public AllergyIntoleranceCategory fromCode(String codeString) throws IllegalArgumentException {
297      if (codeString == null || "".equals(codeString))
298        if (codeString == null || "".equals(codeString))
299          return null;
300      if ("food".equals(codeString))
301        return AllergyIntoleranceCategory.FOOD;
302      if ("medication".equals(codeString))
303        return AllergyIntoleranceCategory.MEDICATION;
304      if ("environment".equals(codeString))
305        return AllergyIntoleranceCategory.ENVIRONMENT;
306      if ("biologic".equals(codeString))
307        return AllergyIntoleranceCategory.BIOLOGIC;
308      throw new IllegalArgumentException("Unknown AllergyIntoleranceCategory code '" + codeString + "'");
309    }
310
311    public Enumeration<AllergyIntoleranceCategory> fromType(PrimitiveType<?> code) throws FHIRException {
312      if (code == null)
313        return null;
314      if (code.isEmpty())
315        return new Enumeration<AllergyIntoleranceCategory>(this, AllergyIntoleranceCategory.NULL, code);
316      String codeString = code.asStringValue();
317      if (codeString == null || "".equals(codeString))
318        return new Enumeration<AllergyIntoleranceCategory>(this, AllergyIntoleranceCategory.NULL, code);
319      if ("food".equals(codeString))
320        return new Enumeration<AllergyIntoleranceCategory>(this, AllergyIntoleranceCategory.FOOD, code);
321      if ("medication".equals(codeString))
322        return new Enumeration<AllergyIntoleranceCategory>(this, AllergyIntoleranceCategory.MEDICATION, code);
323      if ("environment".equals(codeString))
324        return new Enumeration<AllergyIntoleranceCategory>(this, AllergyIntoleranceCategory.ENVIRONMENT, code);
325      if ("biologic".equals(codeString))
326        return new Enumeration<AllergyIntoleranceCategory>(this, AllergyIntoleranceCategory.BIOLOGIC, code);
327      throw new FHIRException("Unknown AllergyIntoleranceCategory code '" + codeString + "'");
328    }
329
330    public String toCode(AllergyIntoleranceCategory code) {
331      if (code == AllergyIntoleranceCategory.FOOD)
332        return "food";
333      if (code == AllergyIntoleranceCategory.MEDICATION)
334        return "medication";
335      if (code == AllergyIntoleranceCategory.ENVIRONMENT)
336        return "environment";
337      if (code == AllergyIntoleranceCategory.BIOLOGIC)
338        return "biologic";
339      return "?";
340    }
341
342    public String toSystem(AllergyIntoleranceCategory code) {
343      return code.getSystem();
344    }
345  }
346
347  public enum AllergyIntoleranceCriticality {
348    /**
349     * Worst case result of a future exposure is not assessed to be life-threatening
350     * or having high potential for organ system failure.
351     */
352    LOW,
353    /**
354     * Worst case result of a future exposure is assessed to be life-threatening or
355     * having high potential for organ system failure.
356     */
357    HIGH,
358    /**
359     * Unable to assess the worst case result of a future exposure.
360     */
361    UNABLETOASSESS,
362    /**
363     * added to help the parsers with the generic types
364     */
365    NULL;
366
367    public static AllergyIntoleranceCriticality fromCode(String codeString) throws FHIRException {
368      if (codeString == null || "".equals(codeString))
369        return null;
370      if ("low".equals(codeString))
371        return LOW;
372      if ("high".equals(codeString))
373        return HIGH;
374      if ("unable-to-assess".equals(codeString))
375        return UNABLETOASSESS;
376      if (Configuration.isAcceptInvalidEnums())
377        return null;
378      else
379        throw new FHIRException("Unknown AllergyIntoleranceCriticality code '" + codeString + "'");
380    }
381
382    public String toCode() {
383      switch (this) {
384      case LOW:
385        return "low";
386      case HIGH:
387        return "high";
388      case UNABLETOASSESS:
389        return "unable-to-assess";
390      case NULL:
391        return null;
392      default:
393        return "?";
394      }
395    }
396
397    public String getSystem() {
398      switch (this) {
399      case LOW:
400        return "http://hl7.org/fhir/allergy-intolerance-criticality";
401      case HIGH:
402        return "http://hl7.org/fhir/allergy-intolerance-criticality";
403      case UNABLETOASSESS:
404        return "http://hl7.org/fhir/allergy-intolerance-criticality";
405      case NULL:
406        return null;
407      default:
408        return "?";
409      }
410    }
411
412    public String getDefinition() {
413      switch (this) {
414      case LOW:
415        return "Worst case result of a future exposure is not assessed to be life-threatening or having high potential for organ system failure.";
416      case HIGH:
417        return "Worst case result of a future exposure is assessed to be life-threatening or having high potential for organ system failure.";
418      case UNABLETOASSESS:
419        return "Unable to assess the worst case result of a future exposure.";
420      case NULL:
421        return null;
422      default:
423        return "?";
424      }
425    }
426
427    public String getDisplay() {
428      switch (this) {
429      case LOW:
430        return "Low Risk";
431      case HIGH:
432        return "High Risk";
433      case UNABLETOASSESS:
434        return "Unable to Assess Risk";
435      case NULL:
436        return null;
437      default:
438        return "?";
439      }
440    }
441  }
442
443  public static class AllergyIntoleranceCriticalityEnumFactory implements EnumFactory<AllergyIntoleranceCriticality> {
444    public AllergyIntoleranceCriticality fromCode(String codeString) throws IllegalArgumentException {
445      if (codeString == null || "".equals(codeString))
446        if (codeString == null || "".equals(codeString))
447          return null;
448      if ("low".equals(codeString))
449        return AllergyIntoleranceCriticality.LOW;
450      if ("high".equals(codeString))
451        return AllergyIntoleranceCriticality.HIGH;
452      if ("unable-to-assess".equals(codeString))
453        return AllergyIntoleranceCriticality.UNABLETOASSESS;
454      throw new IllegalArgumentException("Unknown AllergyIntoleranceCriticality code '" + codeString + "'");
455    }
456
457    public Enumeration<AllergyIntoleranceCriticality> fromType(PrimitiveType<?> code) throws FHIRException {
458      if (code == null)
459        return null;
460      if (code.isEmpty())
461        return new Enumeration<AllergyIntoleranceCriticality>(this, AllergyIntoleranceCriticality.NULL, code);
462      String codeString = code.asStringValue();
463      if (codeString == null || "".equals(codeString))
464        return new Enumeration<AllergyIntoleranceCriticality>(this, AllergyIntoleranceCriticality.NULL, code);
465      if ("low".equals(codeString))
466        return new Enumeration<AllergyIntoleranceCriticality>(this, AllergyIntoleranceCriticality.LOW, code);
467      if ("high".equals(codeString))
468        return new Enumeration<AllergyIntoleranceCriticality>(this, AllergyIntoleranceCriticality.HIGH, code);
469      if ("unable-to-assess".equals(codeString))
470        return new Enumeration<AllergyIntoleranceCriticality>(this, AllergyIntoleranceCriticality.UNABLETOASSESS, code);
471      throw new FHIRException("Unknown AllergyIntoleranceCriticality code '" + codeString + "'");
472    }
473
474    public String toCode(AllergyIntoleranceCriticality code) {
475      if (code == AllergyIntoleranceCriticality.LOW)
476        return "low";
477      if (code == AllergyIntoleranceCriticality.HIGH)
478        return "high";
479      if (code == AllergyIntoleranceCriticality.UNABLETOASSESS)
480        return "unable-to-assess";
481      return "?";
482    }
483
484    public String toSystem(AllergyIntoleranceCriticality code) {
485      return code.getSystem();
486    }
487  }
488
489  public enum AllergyIntoleranceSeverity {
490    /**
491     * Causes mild physiological effects.
492     */
493    MILD,
494    /**
495     * Causes moderate physiological effects.
496     */
497    MODERATE,
498    /**
499     * Causes severe physiological effects.
500     */
501    SEVERE,
502    /**
503     * added to help the parsers with the generic types
504     */
505    NULL;
506
507    public static AllergyIntoleranceSeverity fromCode(String codeString) throws FHIRException {
508      if (codeString == null || "".equals(codeString))
509        return null;
510      if ("mild".equals(codeString))
511        return MILD;
512      if ("moderate".equals(codeString))
513        return MODERATE;
514      if ("severe".equals(codeString))
515        return SEVERE;
516      if (Configuration.isAcceptInvalidEnums())
517        return null;
518      else
519        throw new FHIRException("Unknown AllergyIntoleranceSeverity code '" + codeString + "'");
520    }
521
522    public String toCode() {
523      switch (this) {
524      case MILD:
525        return "mild";
526      case MODERATE:
527        return "moderate";
528      case SEVERE:
529        return "severe";
530      case NULL:
531        return null;
532      default:
533        return "?";
534      }
535    }
536
537    public String getSystem() {
538      switch (this) {
539      case MILD:
540        return "http://hl7.org/fhir/reaction-event-severity";
541      case MODERATE:
542        return "http://hl7.org/fhir/reaction-event-severity";
543      case SEVERE:
544        return "http://hl7.org/fhir/reaction-event-severity";
545      case NULL:
546        return null;
547      default:
548        return "?";
549      }
550    }
551
552    public String getDefinition() {
553      switch (this) {
554      case MILD:
555        return "Causes mild physiological effects.";
556      case MODERATE:
557        return "Causes moderate physiological effects.";
558      case SEVERE:
559        return "Causes severe physiological effects.";
560      case NULL:
561        return null;
562      default:
563        return "?";
564      }
565    }
566
567    public String getDisplay() {
568      switch (this) {
569      case MILD:
570        return "Mild";
571      case MODERATE:
572        return "Moderate";
573      case SEVERE:
574        return "Severe";
575      case NULL:
576        return null;
577      default:
578        return "?";
579      }
580    }
581  }
582
583  public static class AllergyIntoleranceSeverityEnumFactory implements EnumFactory<AllergyIntoleranceSeverity> {
584    public AllergyIntoleranceSeverity fromCode(String codeString) throws IllegalArgumentException {
585      if (codeString == null || "".equals(codeString))
586        if (codeString == null || "".equals(codeString))
587          return null;
588      if ("mild".equals(codeString))
589        return AllergyIntoleranceSeverity.MILD;
590      if ("moderate".equals(codeString))
591        return AllergyIntoleranceSeverity.MODERATE;
592      if ("severe".equals(codeString))
593        return AllergyIntoleranceSeverity.SEVERE;
594      throw new IllegalArgumentException("Unknown AllergyIntoleranceSeverity code '" + codeString + "'");
595    }
596
597    public Enumeration<AllergyIntoleranceSeverity> fromType(PrimitiveType<?> code) throws FHIRException {
598      if (code == null)
599        return null;
600      if (code.isEmpty())
601        return new Enumeration<AllergyIntoleranceSeverity>(this, AllergyIntoleranceSeverity.NULL, code);
602      String codeString = code.asStringValue();
603      if (codeString == null || "".equals(codeString))
604        return new Enumeration<AllergyIntoleranceSeverity>(this, AllergyIntoleranceSeverity.NULL, code);
605      if ("mild".equals(codeString))
606        return new Enumeration<AllergyIntoleranceSeverity>(this, AllergyIntoleranceSeverity.MILD, code);
607      if ("moderate".equals(codeString))
608        return new Enumeration<AllergyIntoleranceSeverity>(this, AllergyIntoleranceSeverity.MODERATE, code);
609      if ("severe".equals(codeString))
610        return new Enumeration<AllergyIntoleranceSeverity>(this, AllergyIntoleranceSeverity.SEVERE, code);
611      throw new FHIRException("Unknown AllergyIntoleranceSeverity code '" + codeString + "'");
612    }
613
614    public String toCode(AllergyIntoleranceSeverity code) {
615      if (code == AllergyIntoleranceSeverity.MILD)
616        return "mild";
617      if (code == AllergyIntoleranceSeverity.MODERATE)
618        return "moderate";
619      if (code == AllergyIntoleranceSeverity.SEVERE)
620        return "severe";
621      return "?";
622    }
623
624    public String toSystem(AllergyIntoleranceSeverity code) {
625      return code.getSystem();
626    }
627  }
628
629  @Block()
630  public static class AllergyIntoleranceReactionComponent extends BackboneElement implements IBaseBackboneElement {
631    /**
632     * Identification of the specific substance (or pharmaceutical product)
633     * considered to be responsible for the Adverse Reaction event. Note: the
634     * substance for a specific reaction may be different from the substance
635     * identified as the cause of the risk, but it must be consistent with it. For
636     * instance, it may be a more specific substance (e.g. a brand medication) or a
637     * composite product that includes the identified substance. It must be
638     * clinically safe to only process the 'code' and ignore the
639     * 'reaction.substance'. If a receiving system is unable to confirm that
640     * AllergyIntolerance.reaction.substance falls within the semantic scope of
641     * AllergyIntolerance.code, then the receiving system should ignore
642     * AllergyIntolerance.reaction.substance.
643     */
644    @Child(name = "substance", type = {
645        CodeableConcept.class }, order = 1, min = 0, max = 1, modifier = false, summary = false)
646    @Description(shortDefinition = "Specific substance or pharmaceutical product considered to be responsible for event", formalDefinition = "Identification of the specific substance (or pharmaceutical product) considered to be responsible for the Adverse Reaction event. Note: the substance for a specific reaction may be different from the substance identified as the cause of the risk, but it must be consistent with it. For instance, it may be a more specific substance (e.g. a brand medication) or a composite product that includes the identified substance. It must be clinically safe to only process the 'code' and ignore the 'reaction.substance'.  If a receiving system is unable to confirm that AllergyIntolerance.reaction.substance falls within the semantic scope of AllergyIntolerance.code, then the receiving system should ignore AllergyIntolerance.reaction.substance.")
647    @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/substance-code")
648    protected CodeableConcept substance;
649
650    /**
651     * Clinical symptoms and/or signs that are observed or associated with the
652     * adverse reaction event.
653     */
654    @Child(name = "manifestation", type = {
655        CodeableConcept.class }, order = 2, min = 1, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
656    @Description(shortDefinition = "Clinical symptoms/signs associated with the Event", formalDefinition = "Clinical symptoms and/or signs that are observed or associated with the adverse reaction event.")
657    @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/clinical-findings")
658    protected List<CodeableConcept> manifestation;
659
660    /**
661     * Text description about the reaction as a whole, including details of the
662     * manifestation if required.
663     */
664    @Child(name = "description", type = {
665        StringType.class }, order = 3, min = 0, max = 1, modifier = false, summary = false)
666    @Description(shortDefinition = "Description of the event as a whole", formalDefinition = "Text description about the reaction as a whole, including details of the manifestation if required.")
667    protected StringType description;
668
669    /**
670     * Record of the date and/or time of the onset of the Reaction.
671     */
672    @Child(name = "onset", type = {
673        DateTimeType.class }, order = 4, min = 0, max = 1, modifier = false, summary = false)
674    @Description(shortDefinition = "Date(/time) when manifestations showed", formalDefinition = "Record of the date and/or time of the onset of the Reaction.")
675    protected DateTimeType onset;
676
677    /**
678     * Clinical assessment of the severity of the reaction event as a whole,
679     * potentially considering multiple different manifestations.
680     */
681    @Child(name = "severity", type = { CodeType.class }, order = 5, min = 0, max = 1, modifier = false, summary = false)
682    @Description(shortDefinition = "mild | moderate | severe (of event as a whole)", formalDefinition = "Clinical assessment of the severity of the reaction event as a whole, potentially considering multiple different manifestations.")
683    @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/reaction-event-severity")
684    protected Enumeration<AllergyIntoleranceSeverity> severity;
685
686    /**
687     * Identification of the route by which the subject was exposed to the
688     * substance.
689     */
690    @Child(name = "exposureRoute", type = {
691        CodeableConcept.class }, order = 6, min = 0, max = 1, modifier = false, summary = false)
692    @Description(shortDefinition = "How the subject was exposed to the substance", formalDefinition = "Identification of the route by which the subject was exposed to the substance.")
693    @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/route-codes")
694    protected CodeableConcept exposureRoute;
695
696    /**
697     * Additional text about the adverse reaction event not captured in other
698     * fields.
699     */
700    @Child(name = "note", type = {
701        Annotation.class }, order = 7, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
702    @Description(shortDefinition = "Text about event not captured in other fields", formalDefinition = "Additional text about the adverse reaction event not captured in other fields.")
703    protected List<Annotation> note;
704
705    private static final long serialVersionUID = -752118516L;
706
707    /**
708     * Constructor
709     */
710    public AllergyIntoleranceReactionComponent() {
711      super();
712    }
713
714    /**
715     * @return {@link #substance} (Identification of the specific substance (or
716     *         pharmaceutical product) considered to be responsible for the Adverse
717     *         Reaction event. Note: the substance for a specific reaction may be
718     *         different from the substance identified as the cause of the risk, but
719     *         it must be consistent with it. For instance, it may be a more
720     *         specific substance (e.g. a brand medication) or a composite product
721     *         that includes the identified substance. It must be clinically safe to
722     *         only process the 'code' and ignore the 'reaction.substance'. If a
723     *         receiving system is unable to confirm that
724     *         AllergyIntolerance.reaction.substance falls within the semantic scope
725     *         of AllergyIntolerance.code, then the receiving system should ignore
726     *         AllergyIntolerance.reaction.substance.)
727     */
728    public CodeableConcept getSubstance() {
729      if (this.substance == null)
730        if (Configuration.errorOnAutoCreate())
731          throw new Error("Attempt to auto-create AllergyIntoleranceReactionComponent.substance");
732        else if (Configuration.doAutoCreate())
733          this.substance = new CodeableConcept(); // cc
734      return this.substance;
735    }
736
737    public boolean hasSubstance() {
738      return this.substance != null && !this.substance.isEmpty();
739    }
740
741    /**
742     * @param value {@link #substance} (Identification of the specific substance (or
743     *              pharmaceutical product) considered to be responsible for the
744     *              Adverse Reaction event. Note: the substance for a specific
745     *              reaction may be different from the substance identified as the
746     *              cause of the risk, but it must be consistent with it. For
747     *              instance, it may be a more specific substance (e.g. a brand
748     *              medication) or a composite product that includes the identified
749     *              substance. It must be clinically safe to only process the 'code'
750     *              and ignore the 'reaction.substance'. If a receiving system is
751     *              unable to confirm that AllergyIntolerance.reaction.substance
752     *              falls within the semantic scope of AllergyIntolerance.code, then
753     *              the receiving system should ignore
754     *              AllergyIntolerance.reaction.substance.)
755     */
756    public AllergyIntoleranceReactionComponent setSubstance(CodeableConcept value) {
757      this.substance = value;
758      return this;
759    }
760
761    /**
762     * @return {@link #manifestation} (Clinical symptoms and/or signs that are
763     *         observed or associated with the adverse reaction event.)
764     */
765    public List<CodeableConcept> getManifestation() {
766      if (this.manifestation == null)
767        this.manifestation = new ArrayList<CodeableConcept>();
768      return this.manifestation;
769    }
770
771    /**
772     * @return Returns a reference to <code>this</code> for easy method chaining
773     */
774    public AllergyIntoleranceReactionComponent setManifestation(List<CodeableConcept> theManifestation) {
775      this.manifestation = theManifestation;
776      return this;
777    }
778
779    public boolean hasManifestation() {
780      if (this.manifestation == null)
781        return false;
782      for (CodeableConcept item : this.manifestation)
783        if (!item.isEmpty())
784          return true;
785      return false;
786    }
787
788    public CodeableConcept addManifestation() { // 3
789      CodeableConcept t = new CodeableConcept();
790      if (this.manifestation == null)
791        this.manifestation = new ArrayList<CodeableConcept>();
792      this.manifestation.add(t);
793      return t;
794    }
795
796    public AllergyIntoleranceReactionComponent addManifestation(CodeableConcept t) { // 3
797      if (t == null)
798        return this;
799      if (this.manifestation == null)
800        this.manifestation = new ArrayList<CodeableConcept>();
801      this.manifestation.add(t);
802      return this;
803    }
804
805    /**
806     * @return The first repetition of repeating field {@link #manifestation},
807     *         creating it if it does not already exist
808     */
809    public CodeableConcept getManifestationFirstRep() {
810      if (getManifestation().isEmpty()) {
811        addManifestation();
812      }
813      return getManifestation().get(0);
814    }
815
816    /**
817     * @return {@link #description} (Text description about the reaction as a whole,
818     *         including details of the manifestation if required.). This is the
819     *         underlying object with id, value and extensions. The accessor
820     *         "getDescription" gives direct access to the value
821     */
822    public StringType getDescriptionElement() {
823      if (this.description == null)
824        if (Configuration.errorOnAutoCreate())
825          throw new Error("Attempt to auto-create AllergyIntoleranceReactionComponent.description");
826        else if (Configuration.doAutoCreate())
827          this.description = new StringType(); // bb
828      return this.description;
829    }
830
831    public boolean hasDescriptionElement() {
832      return this.description != null && !this.description.isEmpty();
833    }
834
835    public boolean hasDescription() {
836      return this.description != null && !this.description.isEmpty();
837    }
838
839    /**
840     * @param value {@link #description} (Text description about the reaction as a
841     *              whole, including details of the manifestation if required.).
842     *              This is the underlying object with id, value and extensions. The
843     *              accessor "getDescription" gives direct access to the value
844     */
845    public AllergyIntoleranceReactionComponent setDescriptionElement(StringType value) {
846      this.description = value;
847      return this;
848    }
849
850    /**
851     * @return Text description about the reaction as a whole, including details of
852     *         the manifestation if required.
853     */
854    public String getDescription() {
855      return this.description == null ? null : this.description.getValue();
856    }
857
858    /**
859     * @param value Text description about the reaction as a whole, including
860     *              details of the manifestation if required.
861     */
862    public AllergyIntoleranceReactionComponent setDescription(String value) {
863      if (Utilities.noString(value))
864        this.description = null;
865      else {
866        if (this.description == null)
867          this.description = new StringType();
868        this.description.setValue(value);
869      }
870      return this;
871    }
872
873    /**
874     * @return {@link #onset} (Record of the date and/or time of the onset of the
875     *         Reaction.). This is the underlying object with id, value and
876     *         extensions. The accessor "getOnset" gives direct access to the value
877     */
878    public DateTimeType getOnsetElement() {
879      if (this.onset == null)
880        if (Configuration.errorOnAutoCreate())
881          throw new Error("Attempt to auto-create AllergyIntoleranceReactionComponent.onset");
882        else if (Configuration.doAutoCreate())
883          this.onset = new DateTimeType(); // bb
884      return this.onset;
885    }
886
887    public boolean hasOnsetElement() {
888      return this.onset != null && !this.onset.isEmpty();
889    }
890
891    public boolean hasOnset() {
892      return this.onset != null && !this.onset.isEmpty();
893    }
894
895    /**
896     * @param value {@link #onset} (Record of the date and/or time of the onset of
897     *              the Reaction.). This is the underlying object with id, value and
898     *              extensions. The accessor "getOnset" gives direct access to the
899     *              value
900     */
901    public AllergyIntoleranceReactionComponent setOnsetElement(DateTimeType value) {
902      this.onset = value;
903      return this;
904    }
905
906    /**
907     * @return Record of the date and/or time of the onset of the Reaction.
908     */
909    public Date getOnset() {
910      return this.onset == null ? null : this.onset.getValue();
911    }
912
913    /**
914     * @param value Record of the date and/or time of the onset of the Reaction.
915     */
916    public AllergyIntoleranceReactionComponent setOnset(Date value) {
917      if (value == null)
918        this.onset = null;
919      else {
920        if (this.onset == null)
921          this.onset = new DateTimeType();
922        this.onset.setValue(value);
923      }
924      return this;
925    }
926
927    /**
928     * @return {@link #severity} (Clinical assessment of the severity of the
929     *         reaction event as a whole, potentially considering multiple different
930     *         manifestations.). This is the underlying object with id, value and
931     *         extensions. The accessor "getSeverity" gives direct access to the
932     *         value
933     */
934    public Enumeration<AllergyIntoleranceSeverity> getSeverityElement() {
935      if (this.severity == null)
936        if (Configuration.errorOnAutoCreate())
937          throw new Error("Attempt to auto-create AllergyIntoleranceReactionComponent.severity");
938        else if (Configuration.doAutoCreate())
939          this.severity = new Enumeration<AllergyIntoleranceSeverity>(new AllergyIntoleranceSeverityEnumFactory()); // bb
940      return this.severity;
941    }
942
943    public boolean hasSeverityElement() {
944      return this.severity != null && !this.severity.isEmpty();
945    }
946
947    public boolean hasSeverity() {
948      return this.severity != null && !this.severity.isEmpty();
949    }
950
951    /**
952     * @param value {@link #severity} (Clinical assessment of the severity of the
953     *              reaction event as a whole, potentially considering multiple
954     *              different manifestations.). This is the underlying object with
955     *              id, value and extensions. The accessor "getSeverity" gives
956     *              direct access to the value
957     */
958    public AllergyIntoleranceReactionComponent setSeverityElement(Enumeration<AllergyIntoleranceSeverity> value) {
959      this.severity = value;
960      return this;
961    }
962
963    /**
964     * @return Clinical assessment of the severity of the reaction event as a whole,
965     *         potentially considering multiple different manifestations.
966     */
967    public AllergyIntoleranceSeverity getSeverity() {
968      return this.severity == null ? null : this.severity.getValue();
969    }
970
971    /**
972     * @param value Clinical assessment of the severity of the reaction event as a
973     *              whole, potentially considering multiple different
974     *              manifestations.
975     */
976    public AllergyIntoleranceReactionComponent setSeverity(AllergyIntoleranceSeverity value) {
977      if (value == null)
978        this.severity = null;
979      else {
980        if (this.severity == null)
981          this.severity = new Enumeration<AllergyIntoleranceSeverity>(new AllergyIntoleranceSeverityEnumFactory());
982        this.severity.setValue(value);
983      }
984      return this;
985    }
986
987    /**
988     * @return {@link #exposureRoute} (Identification of the route by which the
989     *         subject was exposed to the substance.)
990     */
991    public CodeableConcept getExposureRoute() {
992      if (this.exposureRoute == null)
993        if (Configuration.errorOnAutoCreate())
994          throw new Error("Attempt to auto-create AllergyIntoleranceReactionComponent.exposureRoute");
995        else if (Configuration.doAutoCreate())
996          this.exposureRoute = new CodeableConcept(); // cc
997      return this.exposureRoute;
998    }
999
1000    public boolean hasExposureRoute() {
1001      return this.exposureRoute != null && !this.exposureRoute.isEmpty();
1002    }
1003
1004    /**
1005     * @param value {@link #exposureRoute} (Identification of the route by which the
1006     *              subject was exposed to the substance.)
1007     */
1008    public AllergyIntoleranceReactionComponent setExposureRoute(CodeableConcept value) {
1009      this.exposureRoute = value;
1010      return this;
1011    }
1012
1013    /**
1014     * @return {@link #note} (Additional text about the adverse reaction event not
1015     *         captured in other fields.)
1016     */
1017    public List<Annotation> getNote() {
1018      if (this.note == null)
1019        this.note = new ArrayList<Annotation>();
1020      return this.note;
1021    }
1022
1023    /**
1024     * @return Returns a reference to <code>this</code> for easy method chaining
1025     */
1026    public AllergyIntoleranceReactionComponent setNote(List<Annotation> theNote) {
1027      this.note = theNote;
1028      return this;
1029    }
1030
1031    public boolean hasNote() {
1032      if (this.note == null)
1033        return false;
1034      for (Annotation item : this.note)
1035        if (!item.isEmpty())
1036          return true;
1037      return false;
1038    }
1039
1040    public Annotation addNote() { // 3
1041      Annotation t = new Annotation();
1042      if (this.note == null)
1043        this.note = new ArrayList<Annotation>();
1044      this.note.add(t);
1045      return t;
1046    }
1047
1048    public AllergyIntoleranceReactionComponent addNote(Annotation t) { // 3
1049      if (t == null)
1050        return this;
1051      if (this.note == null)
1052        this.note = new ArrayList<Annotation>();
1053      this.note.add(t);
1054      return this;
1055    }
1056
1057    /**
1058     * @return The first repetition of repeating field {@link #note}, creating it if
1059     *         it does not already exist
1060     */
1061    public Annotation getNoteFirstRep() {
1062      if (getNote().isEmpty()) {
1063        addNote();
1064      }
1065      return getNote().get(0);
1066    }
1067
1068    protected void listChildren(List<Property> children) {
1069      super.listChildren(children);
1070      children.add(new Property("substance", "CodeableConcept",
1071          "Identification of the specific substance (or pharmaceutical product) considered to be responsible for the Adverse Reaction event. Note: the substance for a specific reaction may be different from the substance identified as the cause of the risk, but it must be consistent with it. For instance, it may be a more specific substance (e.g. a brand medication) or a composite product that includes the identified substance. It must be clinically safe to only process the 'code' and ignore the 'reaction.substance'.  If a receiving system is unable to confirm that AllergyIntolerance.reaction.substance falls within the semantic scope of AllergyIntolerance.code, then the receiving system should ignore AllergyIntolerance.reaction.substance.",
1072          0, 1, substance));
1073      children.add(new Property("manifestation", "CodeableConcept",
1074          "Clinical symptoms and/or signs that are observed or associated with the adverse reaction event.", 0,
1075          java.lang.Integer.MAX_VALUE, manifestation));
1076      children.add(new Property("description", "string",
1077          "Text description about the reaction as a whole, including details of the manifestation if required.", 0, 1,
1078          description));
1079      children.add(new Property("onset", "dateTime", "Record of the date and/or time of the onset of the Reaction.", 0,
1080          1, onset));
1081      children.add(new Property("severity", "code",
1082          "Clinical assessment of the severity of the reaction event as a whole, potentially considering multiple different manifestations.",
1083          0, 1, severity));
1084      children.add(new Property("exposureRoute", "CodeableConcept",
1085          "Identification of the route by which the subject was exposed to the substance.", 0, 1, exposureRoute));
1086      children.add(new Property("note", "Annotation",
1087          "Additional text about the adverse reaction event not captured in other fields.", 0,
1088          java.lang.Integer.MAX_VALUE, note));
1089    }
1090
1091    @Override
1092    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1093      switch (_hash) {
1094      case 530040176:
1095        /* substance */ return new Property("substance", "CodeableConcept",
1096            "Identification of the specific substance (or pharmaceutical product) considered to be responsible for the Adverse Reaction event. Note: the substance for a specific reaction may be different from the substance identified as the cause of the risk, but it must be consistent with it. For instance, it may be a more specific substance (e.g. a brand medication) or a composite product that includes the identified substance. It must be clinically safe to only process the 'code' and ignore the 'reaction.substance'.  If a receiving system is unable to confirm that AllergyIntolerance.reaction.substance falls within the semantic scope of AllergyIntolerance.code, then the receiving system should ignore AllergyIntolerance.reaction.substance.",
1097            0, 1, substance);
1098      case 1115984422:
1099        /* manifestation */ return new Property("manifestation", "CodeableConcept",
1100            "Clinical symptoms and/or signs that are observed or associated with the adverse reaction event.", 0,
1101            java.lang.Integer.MAX_VALUE, manifestation);
1102      case -1724546052:
1103        /* description */ return new Property("description", "string",
1104            "Text description about the reaction as a whole, including details of the manifestation if required.", 0, 1,
1105            description);
1106      case 105901603:
1107        /* onset */ return new Property("onset", "dateTime",
1108            "Record of the date and/or time of the onset of the Reaction.", 0, 1, onset);
1109      case 1478300413:
1110        /* severity */ return new Property("severity", "code",
1111            "Clinical assessment of the severity of the reaction event as a whole, potentially considering multiple different manifestations.",
1112            0, 1, severity);
1113      case 421286274:
1114        /* exposureRoute */ return new Property("exposureRoute", "CodeableConcept",
1115            "Identification of the route by which the subject was exposed to the substance.", 0, 1, exposureRoute);
1116      case 3387378:
1117        /* note */ return new Property("note", "Annotation",
1118            "Additional text about the adverse reaction event not captured in other fields.", 0,
1119            java.lang.Integer.MAX_VALUE, note);
1120      default:
1121        return super.getNamedProperty(_hash, _name, _checkValid);
1122      }
1123
1124    }
1125
1126    @Override
1127    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1128      switch (hash) {
1129      case 530040176:
1130        /* substance */ return this.substance == null ? new Base[0] : new Base[] { this.substance }; // CodeableConcept
1131      case 1115984422:
1132        /* manifestation */ return this.manifestation == null ? new Base[0]
1133            : this.manifestation.toArray(new Base[this.manifestation.size()]); // CodeableConcept
1134      case -1724546052:
1135        /* description */ return this.description == null ? new Base[0] : new Base[] { this.description }; // StringType
1136      case 105901603:
1137        /* onset */ return this.onset == null ? new Base[0] : new Base[] { this.onset }; // DateTimeType
1138      case 1478300413:
1139        /* severity */ return this.severity == null ? new Base[0] : new Base[] { this.severity }; // Enumeration<AllergyIntoleranceSeverity>
1140      case 421286274:
1141        /* exposureRoute */ return this.exposureRoute == null ? new Base[0] : new Base[] { this.exposureRoute }; // CodeableConcept
1142      case 3387378:
1143        /* note */ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
1144      default:
1145        return super.getProperty(hash, name, checkValid);
1146      }
1147
1148    }
1149
1150    @Override
1151    public Base setProperty(int hash, String name, Base value) throws FHIRException {
1152      switch (hash) {
1153      case 530040176: // substance
1154        this.substance = castToCodeableConcept(value); // CodeableConcept
1155        return value;
1156      case 1115984422: // manifestation
1157        this.getManifestation().add(castToCodeableConcept(value)); // CodeableConcept
1158        return value;
1159      case -1724546052: // description
1160        this.description = castToString(value); // StringType
1161        return value;
1162      case 105901603: // onset
1163        this.onset = castToDateTime(value); // DateTimeType
1164        return value;
1165      case 1478300413: // severity
1166        value = new AllergyIntoleranceSeverityEnumFactory().fromType(castToCode(value));
1167        this.severity = (Enumeration) value; // Enumeration<AllergyIntoleranceSeverity>
1168        return value;
1169      case 421286274: // exposureRoute
1170        this.exposureRoute = castToCodeableConcept(value); // CodeableConcept
1171        return value;
1172      case 3387378: // note
1173        this.getNote().add(castToAnnotation(value)); // Annotation
1174        return value;
1175      default:
1176        return super.setProperty(hash, name, value);
1177      }
1178
1179    }
1180
1181    @Override
1182    public Base setProperty(String name, Base value) throws FHIRException {
1183      if (name.equals("substance")) {
1184        this.substance = castToCodeableConcept(value); // CodeableConcept
1185      } else if (name.equals("manifestation")) {
1186        this.getManifestation().add(castToCodeableConcept(value));
1187      } else if (name.equals("description")) {
1188        this.description = castToString(value); // StringType
1189      } else if (name.equals("onset")) {
1190        this.onset = castToDateTime(value); // DateTimeType
1191      } else if (name.equals("severity")) {
1192        value = new AllergyIntoleranceSeverityEnumFactory().fromType(castToCode(value));
1193        this.severity = (Enumeration) value; // Enumeration<AllergyIntoleranceSeverity>
1194      } else if (name.equals("exposureRoute")) {
1195        this.exposureRoute = castToCodeableConcept(value); // CodeableConcept
1196      } else if (name.equals("note")) {
1197        this.getNote().add(castToAnnotation(value));
1198      } else
1199        return super.setProperty(name, value);
1200      return value;
1201    }
1202
1203  @Override
1204  public void removeChild(String name, Base value) throws FHIRException {
1205      if (name.equals("substance")) {
1206        this.substance = null;
1207      } else if (name.equals("manifestation")) {
1208        this.getManifestation().remove(castToCodeableConcept(value));
1209      } else if (name.equals("description")) {
1210        this.description = null;
1211      } else if (name.equals("onset")) {
1212        this.onset = null;
1213      } else if (name.equals("severity")) {
1214        this.severity = null;
1215      } else if (name.equals("exposureRoute")) {
1216        this.exposureRoute = null;
1217      } else if (name.equals("note")) {
1218        this.getNote().remove(castToAnnotation(value));
1219      } else
1220        super.removeChild(name, value);
1221      
1222    }
1223
1224    @Override
1225    public Base makeProperty(int hash, String name) throws FHIRException {
1226      switch (hash) {
1227      case 530040176:
1228        return getSubstance();
1229      case 1115984422:
1230        return addManifestation();
1231      case -1724546052:
1232        return getDescriptionElement();
1233      case 105901603:
1234        return getOnsetElement();
1235      case 1478300413:
1236        return getSeverityElement();
1237      case 421286274:
1238        return getExposureRoute();
1239      case 3387378:
1240        return addNote();
1241      default:
1242        return super.makeProperty(hash, name);
1243      }
1244
1245    }
1246
1247    @Override
1248    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1249      switch (hash) {
1250      case 530040176:
1251        /* substance */ return new String[] { "CodeableConcept" };
1252      case 1115984422:
1253        /* manifestation */ return new String[] { "CodeableConcept" };
1254      case -1724546052:
1255        /* description */ return new String[] { "string" };
1256      case 105901603:
1257        /* onset */ return new String[] { "dateTime" };
1258      case 1478300413:
1259        /* severity */ return new String[] { "code" };
1260      case 421286274:
1261        /* exposureRoute */ return new String[] { "CodeableConcept" };
1262      case 3387378:
1263        /* note */ return new String[] { "Annotation" };
1264      default:
1265        return super.getTypesForProperty(hash, name);
1266      }
1267
1268    }
1269
1270    @Override
1271    public Base addChild(String name) throws FHIRException {
1272      if (name.equals("substance")) {
1273        this.substance = new CodeableConcept();
1274        return this.substance;
1275      } else if (name.equals("manifestation")) {
1276        return addManifestation();
1277      } else if (name.equals("description")) {
1278        throw new FHIRException("Cannot call addChild on a singleton property AllergyIntolerance.description");
1279      } else if (name.equals("onset")) {
1280        throw new FHIRException("Cannot call addChild on a singleton property AllergyIntolerance.onset");
1281      } else if (name.equals("severity")) {
1282        throw new FHIRException("Cannot call addChild on a singleton property AllergyIntolerance.severity");
1283      } else if (name.equals("exposureRoute")) {
1284        this.exposureRoute = new CodeableConcept();
1285        return this.exposureRoute;
1286      } else if (name.equals("note")) {
1287        return addNote();
1288      } else
1289        return super.addChild(name);
1290    }
1291
1292    public AllergyIntoleranceReactionComponent copy() {
1293      AllergyIntoleranceReactionComponent dst = new AllergyIntoleranceReactionComponent();
1294      copyValues(dst);
1295      return dst;
1296    }
1297
1298    public void copyValues(AllergyIntoleranceReactionComponent dst) {
1299      super.copyValues(dst);
1300      dst.substance = substance == null ? null : substance.copy();
1301      if (manifestation != null) {
1302        dst.manifestation = new ArrayList<CodeableConcept>();
1303        for (CodeableConcept i : manifestation)
1304          dst.manifestation.add(i.copy());
1305      }
1306      ;
1307      dst.description = description == null ? null : description.copy();
1308      dst.onset = onset == null ? null : onset.copy();
1309      dst.severity = severity == null ? null : severity.copy();
1310      dst.exposureRoute = exposureRoute == null ? null : exposureRoute.copy();
1311      if (note != null) {
1312        dst.note = new ArrayList<Annotation>();
1313        for (Annotation i : note)
1314          dst.note.add(i.copy());
1315      }
1316      ;
1317    }
1318
1319    @Override
1320    public boolean equalsDeep(Base other_) {
1321      if (!super.equalsDeep(other_))
1322        return false;
1323      if (!(other_ instanceof AllergyIntoleranceReactionComponent))
1324        return false;
1325      AllergyIntoleranceReactionComponent o = (AllergyIntoleranceReactionComponent) other_;
1326      return compareDeep(substance, o.substance, true) && compareDeep(manifestation, o.manifestation, true)
1327          && compareDeep(description, o.description, true) && compareDeep(onset, o.onset, true)
1328          && compareDeep(severity, o.severity, true) && compareDeep(exposureRoute, o.exposureRoute, true)
1329          && compareDeep(note, o.note, true);
1330    }
1331
1332    @Override
1333    public boolean equalsShallow(Base other_) {
1334      if (!super.equalsShallow(other_))
1335        return false;
1336      if (!(other_ instanceof AllergyIntoleranceReactionComponent))
1337        return false;
1338      AllergyIntoleranceReactionComponent o = (AllergyIntoleranceReactionComponent) other_;
1339      return compareValues(description, o.description, true) && compareValues(onset, o.onset, true)
1340          && compareValues(severity, o.severity, true);
1341    }
1342
1343    public boolean isEmpty() {
1344      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(substance, manifestation, description, onset,
1345          severity, exposureRoute, note);
1346    }
1347
1348    public String fhirType() {
1349      return "AllergyIntolerance.reaction";
1350
1351    }
1352
1353  }
1354
1355  /**
1356   * Business identifiers assigned to this AllergyIntolerance by the performer or
1357   * other systems which remain constant as the resource is updated and propagates
1358   * from server to server.
1359   */
1360  @Child(name = "identifier", type = {
1361      Identifier.class }, order = 0, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
1362  @Description(shortDefinition = "External ids for this item", formalDefinition = "Business identifiers assigned to this AllergyIntolerance by the performer or other systems which remain constant as the resource is updated and propagates from server to server.")
1363  protected List<Identifier> identifier;
1364
1365  /**
1366   * The clinical status of the allergy or intolerance.
1367   */
1368  @Child(name = "clinicalStatus", type = {
1369      CodeableConcept.class }, order = 1, min = 0, max = 1, modifier = true, summary = true)
1370  @Description(shortDefinition = "active | inactive | resolved", formalDefinition = "The clinical status of the allergy or intolerance.")
1371  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/allergyintolerance-clinical")
1372  protected CodeableConcept clinicalStatus;
1373
1374  /**
1375   * Assertion about certainty associated with the propensity, or potential risk,
1376   * of a reaction to the identified substance (including pharmaceutical product).
1377   */
1378  @Child(name = "verificationStatus", type = {
1379      CodeableConcept.class }, order = 2, min = 0, max = 1, modifier = true, summary = true)
1380  @Description(shortDefinition = "unconfirmed | confirmed | refuted | entered-in-error", formalDefinition = "Assertion about certainty associated with the propensity, or potential risk, of a reaction to the identified substance (including pharmaceutical product).")
1381  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/allergyintolerance-verification")
1382  protected CodeableConcept verificationStatus;
1383
1384  /**
1385   * Identification of the underlying physiological mechanism for the reaction
1386   * risk.
1387   */
1388  @Child(name = "type", type = { CodeType.class }, order = 3, min = 0, max = 1, modifier = false, summary = true)
1389  @Description(shortDefinition = "allergy | intolerance - Underlying mechanism (if known)", formalDefinition = "Identification of the underlying physiological mechanism for the reaction risk.")
1390  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/allergy-intolerance-type")
1391  protected Enumeration<AllergyIntoleranceType> type;
1392
1393  /**
1394   * Category of the identified substance.
1395   */
1396  @Child(name = "category", type = {
1397      CodeType.class }, order = 4, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
1398  @Description(shortDefinition = "food | medication | environment | biologic", formalDefinition = "Category of the identified substance.")
1399  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/allergy-intolerance-category")
1400  protected List<Enumeration<AllergyIntoleranceCategory>> category;
1401
1402  /**
1403   * Estimate of the potential clinical harm, or seriousness, of the reaction to
1404   * the identified substance.
1405   */
1406  @Child(name = "criticality", type = { CodeType.class }, order = 5, min = 0, max = 1, modifier = false, summary = true)
1407  @Description(shortDefinition = "low | high | unable-to-assess", formalDefinition = "Estimate of the potential clinical harm, or seriousness, of the reaction to the identified substance.")
1408  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/allergy-intolerance-criticality")
1409  protected Enumeration<AllergyIntoleranceCriticality> criticality;
1410
1411  /**
1412   * Code for an allergy or intolerance statement (either a positive or a
1413   * negated/excluded statement). This may be a code for a substance or
1414   * pharmaceutical product that is considered to be responsible for the adverse
1415   * reaction risk (e.g., "Latex"), an allergy or intolerance condition (e.g.,
1416   * "Latex allergy"), or a negated/excluded code for a specific substance or
1417   * class (e.g., "No latex allergy") or a general or categorical negated
1418   * statement (e.g., "No known allergy", "No known drug allergies"). Note: the
1419   * substance for a specific reaction may be different from the substance
1420   * identified as the cause of the risk, but it must be consistent with it. For
1421   * instance, it may be a more specific substance (e.g. a brand medication) or a
1422   * composite product that includes the identified substance. It must be
1423   * clinically safe to only process the 'code' and ignore the
1424   * 'reaction.substance'. If a receiving system is unable to confirm that
1425   * AllergyIntolerance.reaction.substance falls within the semantic scope of
1426   * AllergyIntolerance.code, then the receiving system should ignore
1427   * AllergyIntolerance.reaction.substance.
1428   */
1429  @Child(name = "code", type = { CodeableConcept.class }, order = 6, min = 0, max = 1, modifier = false, summary = true)
1430  @Description(shortDefinition = "Code that identifies the allergy or intolerance", formalDefinition = "Code for an allergy or intolerance statement (either a positive or a negated/excluded statement).  This may be a code for a substance or pharmaceutical product that is considered to be responsible for the adverse reaction risk (e.g., \"Latex\"), an allergy or intolerance condition (e.g., \"Latex allergy\"), or a negated/excluded code for a specific substance or class (e.g., \"No latex allergy\") or a general or categorical negated statement (e.g.,  \"No known allergy\", \"No known drug allergies\").  Note: the substance for a specific reaction may be different from the substance identified as the cause of the risk, but it must be consistent with it. For instance, it may be a more specific substance (e.g. a brand medication) or a composite product that includes the identified substance. It must be clinically safe to only process the 'code' and ignore the 'reaction.substance'.  If a receiving system is unable to confirm that AllergyIntolerance.reaction.substance falls within the semantic scope of AllergyIntolerance.code, then the receiving system should ignore AllergyIntolerance.reaction.substance.")
1431  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/allergyintolerance-code")
1432  protected CodeableConcept code;
1433
1434  /**
1435   * The patient who has the allergy or intolerance.
1436   */
1437  @Child(name = "patient", type = { Patient.class }, order = 7, min = 1, max = 1, modifier = false, summary = true)
1438  @Description(shortDefinition = "Who the sensitivity is for", formalDefinition = "The patient who has the allergy or intolerance.")
1439  protected Reference patient;
1440
1441  /**
1442   * The actual object that is the target of the reference (The patient who has
1443   * the allergy or intolerance.)
1444   */
1445  protected Patient patientTarget;
1446
1447  /**
1448   * The encounter when the allergy or intolerance was asserted.
1449   */
1450  @Child(name = "encounter", type = { Encounter.class }, order = 8, min = 0, max = 1, modifier = false, summary = false)
1451  @Description(shortDefinition = "Encounter when the allergy or intolerance was asserted", formalDefinition = "The encounter when the allergy or intolerance was asserted.")
1452  protected Reference encounter;
1453
1454  /**
1455   * The actual object that is the target of the reference (The encounter when the
1456   * allergy or intolerance was asserted.)
1457   */
1458  protected Encounter encounterTarget;
1459
1460  /**
1461   * Estimated or actual date, date-time, or age when allergy or intolerance was
1462   * identified.
1463   */
1464  @Child(name = "onset", type = { DateTimeType.class, Age.class, Period.class, Range.class,
1465      StringType.class }, order = 9, min = 0, max = 1, modifier = false, summary = false)
1466  @Description(shortDefinition = "When allergy or intolerance was identified", formalDefinition = "Estimated or actual date,  date-time, or age when allergy or intolerance was identified.")
1467  protected Type onset;
1468
1469  /**
1470   * The recordedDate represents when this particular AllergyIntolerance record
1471   * was created in the system, which is often a system-generated date.
1472   */
1473  @Child(name = "recordedDate", type = {
1474      DateTimeType.class }, order = 10, min = 0, max = 1, modifier = false, summary = false)
1475  @Description(shortDefinition = "Date first version of the resource instance was recorded", formalDefinition = "The recordedDate represents when this particular AllergyIntolerance record was created in the system, which is often a system-generated date.")
1476  protected DateTimeType recordedDate;
1477
1478  /**
1479   * Individual who recorded the record and takes responsibility for its content.
1480   */
1481  @Child(name = "recorder", type = { Practitioner.class, PractitionerRole.class, Patient.class,
1482      RelatedPerson.class }, order = 11, min = 0, max = 1, modifier = false, summary = false)
1483  @Description(shortDefinition = "Who recorded the sensitivity", formalDefinition = "Individual who recorded the record and takes responsibility for its content.")
1484  protected Reference recorder;
1485
1486  /**
1487   * The actual object that is the target of the reference (Individual who
1488   * recorded the record and takes responsibility for its content.)
1489   */
1490  protected Resource recorderTarget;
1491
1492  /**
1493   * The source of the information about the allergy that is recorded.
1494   */
1495  @Child(name = "asserter", type = { Patient.class, RelatedPerson.class, Practitioner.class,
1496      PractitionerRole.class }, order = 12, min = 0, max = 1, modifier = false, summary = true)
1497  @Description(shortDefinition = "Source of the information about the allergy", formalDefinition = "The source of the information about the allergy that is recorded.")
1498  protected Reference asserter;
1499
1500  /**
1501   * The actual object that is the target of the reference (The source of the
1502   * information about the allergy that is recorded.)
1503   */
1504  protected Resource asserterTarget;
1505
1506  /**
1507   * Represents the date and/or time of the last known occurrence of a reaction
1508   * event.
1509   */
1510  @Child(name = "lastOccurrence", type = {
1511      DateTimeType.class }, order = 13, min = 0, max = 1, modifier = false, summary = false)
1512  @Description(shortDefinition = "Date(/time) of last known occurrence of a reaction", formalDefinition = "Represents the date and/or time of the last known occurrence of a reaction event.")
1513  protected DateTimeType lastOccurrence;
1514
1515  /**
1516   * Additional narrative about the propensity for the Adverse Reaction, not
1517   * captured in other fields.
1518   */
1519  @Child(name = "note", type = {
1520      Annotation.class }, order = 14, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
1521  @Description(shortDefinition = "Additional text not captured in other fields", formalDefinition = "Additional narrative about the propensity for the Adverse Reaction, not captured in other fields.")
1522  protected List<Annotation> note;
1523
1524  /**
1525   * Details about each adverse reaction event linked to exposure to the
1526   * identified substance.
1527   */
1528  @Child(name = "reaction", type = {}, order = 15, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
1529  @Description(shortDefinition = "Adverse Reaction Events linked to exposure to substance", formalDefinition = "Details about each adverse reaction event linked to exposure to the identified substance.")
1530  protected List<AllergyIntoleranceReactionComponent> reaction;
1531
1532  private static final long serialVersionUID = 393192289L;
1533
1534  /**
1535   * Constructor
1536   */
1537  public AllergyIntolerance() {
1538    super();
1539  }
1540
1541  /**
1542   * Constructor
1543   */
1544  public AllergyIntolerance(Reference patient) {
1545    super();
1546    this.patient = patient;
1547  }
1548
1549  /**
1550   * @return {@link #identifier} (Business identifiers assigned to this
1551   *         AllergyIntolerance by the performer or other systems which remain
1552   *         constant as the resource is updated and propagates from server to
1553   *         server.)
1554   */
1555  public List<Identifier> getIdentifier() {
1556    if (this.identifier == null)
1557      this.identifier = new ArrayList<Identifier>();
1558    return this.identifier;
1559  }
1560
1561  /**
1562   * @return Returns a reference to <code>this</code> for easy method chaining
1563   */
1564  public AllergyIntolerance setIdentifier(List<Identifier> theIdentifier) {
1565    this.identifier = theIdentifier;
1566    return this;
1567  }
1568
1569  public boolean hasIdentifier() {
1570    if (this.identifier == null)
1571      return false;
1572    for (Identifier item : this.identifier)
1573      if (!item.isEmpty())
1574        return true;
1575    return false;
1576  }
1577
1578  public Identifier addIdentifier() { // 3
1579    Identifier t = new Identifier();
1580    if (this.identifier == null)
1581      this.identifier = new ArrayList<Identifier>();
1582    this.identifier.add(t);
1583    return t;
1584  }
1585
1586  public AllergyIntolerance addIdentifier(Identifier t) { // 3
1587    if (t == null)
1588      return this;
1589    if (this.identifier == null)
1590      this.identifier = new ArrayList<Identifier>();
1591    this.identifier.add(t);
1592    return this;
1593  }
1594
1595  /**
1596   * @return The first repetition of repeating field {@link #identifier}, creating
1597   *         it if it does not already exist
1598   */
1599  public Identifier getIdentifierFirstRep() {
1600    if (getIdentifier().isEmpty()) {
1601      addIdentifier();
1602    }
1603    return getIdentifier().get(0);
1604  }
1605
1606  /**
1607   * @return {@link #clinicalStatus} (The clinical status of the allergy or
1608   *         intolerance.)
1609   */
1610  public CodeableConcept getClinicalStatus() {
1611    if (this.clinicalStatus == null)
1612      if (Configuration.errorOnAutoCreate())
1613        throw new Error("Attempt to auto-create AllergyIntolerance.clinicalStatus");
1614      else if (Configuration.doAutoCreate())
1615        this.clinicalStatus = new CodeableConcept(); // cc
1616    return this.clinicalStatus;
1617  }
1618
1619  public boolean hasClinicalStatus() {
1620    return this.clinicalStatus != null && !this.clinicalStatus.isEmpty();
1621  }
1622
1623  /**
1624   * @param value {@link #clinicalStatus} (The clinical status of the allergy or
1625   *              intolerance.)
1626   */
1627  public AllergyIntolerance setClinicalStatus(CodeableConcept value) {
1628    this.clinicalStatus = value;
1629    return this;
1630  }
1631
1632  /**
1633   * @return {@link #verificationStatus} (Assertion about certainty associated
1634   *         with the propensity, or potential risk, of a reaction to the
1635   *         identified substance (including pharmaceutical product).)
1636   */
1637  public CodeableConcept getVerificationStatus() {
1638    if (this.verificationStatus == null)
1639      if (Configuration.errorOnAutoCreate())
1640        throw new Error("Attempt to auto-create AllergyIntolerance.verificationStatus");
1641      else if (Configuration.doAutoCreate())
1642        this.verificationStatus = new CodeableConcept(); // cc
1643    return this.verificationStatus;
1644  }
1645
1646  public boolean hasVerificationStatus() {
1647    return this.verificationStatus != null && !this.verificationStatus.isEmpty();
1648  }
1649
1650  /**
1651   * @param value {@link #verificationStatus} (Assertion about certainty
1652   *              associated with the propensity, or potential risk, of a reaction
1653   *              to the identified substance (including pharmaceutical product).)
1654   */
1655  public AllergyIntolerance setVerificationStatus(CodeableConcept value) {
1656    this.verificationStatus = value;
1657    return this;
1658  }
1659
1660  /**
1661   * @return {@link #type} (Identification of the underlying physiological
1662   *         mechanism for the reaction risk.). This is the underlying object with
1663   *         id, value and extensions. The accessor "getType" gives direct access
1664   *         to the value
1665   */
1666  public Enumeration<AllergyIntoleranceType> getTypeElement() {
1667    if (this.type == null)
1668      if (Configuration.errorOnAutoCreate())
1669        throw new Error("Attempt to auto-create AllergyIntolerance.type");
1670      else if (Configuration.doAutoCreate())
1671        this.type = new Enumeration<AllergyIntoleranceType>(new AllergyIntoleranceTypeEnumFactory()); // bb
1672    return this.type;
1673  }
1674
1675  public boolean hasTypeElement() {
1676    return this.type != null && !this.type.isEmpty();
1677  }
1678
1679  public boolean hasType() {
1680    return this.type != null && !this.type.isEmpty();
1681  }
1682
1683  /**
1684   * @param value {@link #type} (Identification of the underlying physiological
1685   *              mechanism for the reaction risk.). This is the underlying object
1686   *              with id, value and extensions. The accessor "getType" gives
1687   *              direct access to the value
1688   */
1689  public AllergyIntolerance setTypeElement(Enumeration<AllergyIntoleranceType> value) {
1690    this.type = value;
1691    return this;
1692  }
1693
1694  /**
1695   * @return Identification of the underlying physiological mechanism for the
1696   *         reaction risk.
1697   */
1698  public AllergyIntoleranceType getType() {
1699    return this.type == null ? null : this.type.getValue();
1700  }
1701
1702  /**
1703   * @param value Identification of the underlying physiological mechanism for the
1704   *              reaction risk.
1705   */
1706  public AllergyIntolerance setType(AllergyIntoleranceType value) {
1707    if (value == null)
1708      this.type = null;
1709    else {
1710      if (this.type == null)
1711        this.type = new Enumeration<AllergyIntoleranceType>(new AllergyIntoleranceTypeEnumFactory());
1712      this.type.setValue(value);
1713    }
1714    return this;
1715  }
1716
1717  /**
1718   * @return {@link #category} (Category of the identified substance.)
1719   */
1720  public List<Enumeration<AllergyIntoleranceCategory>> getCategory() {
1721    if (this.category == null)
1722      this.category = new ArrayList<Enumeration<AllergyIntoleranceCategory>>();
1723    return this.category;
1724  }
1725
1726  /**
1727   * @return Returns a reference to <code>this</code> for easy method chaining
1728   */
1729  public AllergyIntolerance setCategory(List<Enumeration<AllergyIntoleranceCategory>> theCategory) {
1730    this.category = theCategory;
1731    return this;
1732  }
1733
1734  public boolean hasCategory() {
1735    if (this.category == null)
1736      return false;
1737    for (Enumeration<AllergyIntoleranceCategory> item : this.category)
1738      if (!item.isEmpty())
1739        return true;
1740    return false;
1741  }
1742
1743  /**
1744   * @return {@link #category} (Category of the identified substance.)
1745   */
1746  public Enumeration<AllergyIntoleranceCategory> addCategoryElement() {// 2
1747    Enumeration<AllergyIntoleranceCategory> t = new Enumeration<AllergyIntoleranceCategory>(
1748        new AllergyIntoleranceCategoryEnumFactory());
1749    if (this.category == null)
1750      this.category = new ArrayList<Enumeration<AllergyIntoleranceCategory>>();
1751    this.category.add(t);
1752    return t;
1753  }
1754
1755  /**
1756   * @param value {@link #category} (Category of the identified substance.)
1757   */
1758  public AllergyIntolerance addCategory(AllergyIntoleranceCategory value) { // 1
1759    Enumeration<AllergyIntoleranceCategory> t = new Enumeration<AllergyIntoleranceCategory>(
1760        new AllergyIntoleranceCategoryEnumFactory());
1761    t.setValue(value);
1762    if (this.category == null)
1763      this.category = new ArrayList<Enumeration<AllergyIntoleranceCategory>>();
1764    this.category.add(t);
1765    return this;
1766  }
1767
1768  /**
1769   * @param value {@link #category} (Category of the identified substance.)
1770   */
1771  public boolean hasCategory(AllergyIntoleranceCategory value) {
1772    if (this.category == null)
1773      return false;
1774    for (Enumeration<AllergyIntoleranceCategory> v : this.category)
1775      if (v.getValue().equals(value)) // code
1776        return true;
1777    return false;
1778  }
1779
1780  /**
1781   * @return {@link #criticality} (Estimate of the potential clinical harm, or
1782   *         seriousness, of the reaction to the identified substance.). This is
1783   *         the underlying object with id, value and extensions. The accessor
1784   *         "getCriticality" gives direct access to the value
1785   */
1786  public Enumeration<AllergyIntoleranceCriticality> getCriticalityElement() {
1787    if (this.criticality == null)
1788      if (Configuration.errorOnAutoCreate())
1789        throw new Error("Attempt to auto-create AllergyIntolerance.criticality");
1790      else if (Configuration.doAutoCreate())
1791        this.criticality = new Enumeration<AllergyIntoleranceCriticality>(
1792            new AllergyIntoleranceCriticalityEnumFactory()); // bb
1793    return this.criticality;
1794  }
1795
1796  public boolean hasCriticalityElement() {
1797    return this.criticality != null && !this.criticality.isEmpty();
1798  }
1799
1800  public boolean hasCriticality() {
1801    return this.criticality != null && !this.criticality.isEmpty();
1802  }
1803
1804  /**
1805   * @param value {@link #criticality} (Estimate of the potential clinical harm,
1806   *              or seriousness, of the reaction to the identified substance.).
1807   *              This is the underlying object with id, value and extensions. The
1808   *              accessor "getCriticality" gives direct access to the value
1809   */
1810  public AllergyIntolerance setCriticalityElement(Enumeration<AllergyIntoleranceCriticality> value) {
1811    this.criticality = value;
1812    return this;
1813  }
1814
1815  /**
1816   * @return Estimate of the potential clinical harm, or seriousness, of the
1817   *         reaction to the identified substance.
1818   */
1819  public AllergyIntoleranceCriticality getCriticality() {
1820    return this.criticality == null ? null : this.criticality.getValue();
1821  }
1822
1823  /**
1824   * @param value Estimate of the potential clinical harm, or seriousness, of the
1825   *              reaction to the identified substance.
1826   */
1827  public AllergyIntolerance setCriticality(AllergyIntoleranceCriticality value) {
1828    if (value == null)
1829      this.criticality = null;
1830    else {
1831      if (this.criticality == null)
1832        this.criticality = new Enumeration<AllergyIntoleranceCriticality>(
1833            new AllergyIntoleranceCriticalityEnumFactory());
1834      this.criticality.setValue(value);
1835    }
1836    return this;
1837  }
1838
1839  /**
1840   * @return {@link #code} (Code for an allergy or intolerance statement (either a
1841   *         positive or a negated/excluded statement). This may be a code for a
1842   *         substance or pharmaceutical product that is considered to be
1843   *         responsible for the adverse reaction risk (e.g., "Latex"), an allergy
1844   *         or intolerance condition (e.g., "Latex allergy"), or a
1845   *         negated/excluded code for a specific substance or class (e.g., "No
1846   *         latex allergy") or a general or categorical negated statement (e.g.,
1847   *         "No known allergy", "No known drug allergies"). Note: the substance
1848   *         for a specific reaction may be different from the substance
1849   *         identified as the cause of the risk, but it must be consistent with
1850   *         it. For instance, it may be a more specific substance (e.g. a brand
1851   *         medication) or a composite product that includes the identified
1852   *         substance. It must be clinically safe to only process the 'code' and
1853   *         ignore the 'reaction.substance'. If a receiving system is unable to
1854   *         confirm that AllergyIntolerance.reaction.substance falls within the
1855   *         semantic scope of AllergyIntolerance.code, then the receiving system
1856   *         should ignore AllergyIntolerance.reaction.substance.)
1857   */
1858  public CodeableConcept getCode() {
1859    if (this.code == null)
1860      if (Configuration.errorOnAutoCreate())
1861        throw new Error("Attempt to auto-create AllergyIntolerance.code");
1862      else if (Configuration.doAutoCreate())
1863        this.code = new CodeableConcept(); // cc
1864    return this.code;
1865  }
1866
1867  public boolean hasCode() {
1868    return this.code != null && !this.code.isEmpty();
1869  }
1870
1871  /**
1872   * @param value {@link #code} (Code for an allergy or intolerance statement
1873   *              (either a positive or a negated/excluded statement). This may be
1874   *              a code for a substance or pharmaceutical product that is
1875   *              considered to be responsible for the adverse reaction risk
1876   *              (e.g., "Latex"), an allergy or intolerance condition (e.g.,
1877   *              "Latex allergy"), or a negated/excluded code for a specific
1878   *              substance or class (e.g., "No latex allergy") or a general or
1879   *              categorical negated statement (e.g., "No known allergy", "No
1880   *              known drug allergies"). Note: the substance for a specific
1881   *              reaction may be different from the substance identified as the
1882   *              cause of the risk, but it must be consistent with it. For
1883   *              instance, it may be a more specific substance (e.g. a brand
1884   *              medication) or a composite product that includes the identified
1885   *              substance. It must be clinically safe to only process the 'code'
1886   *              and ignore the 'reaction.substance'. If a receiving system is
1887   *              unable to confirm that AllergyIntolerance.reaction.substance
1888   *              falls within the semantic scope of AllergyIntolerance.code, then
1889   *              the receiving system should ignore
1890   *              AllergyIntolerance.reaction.substance.)
1891   */
1892  public AllergyIntolerance setCode(CodeableConcept value) {
1893    this.code = value;
1894    return this;
1895  }
1896
1897  /**
1898   * @return {@link #patient} (The patient who has the allergy or intolerance.)
1899   */
1900  public Reference getPatient() {
1901    if (this.patient == null)
1902      if (Configuration.errorOnAutoCreate())
1903        throw new Error("Attempt to auto-create AllergyIntolerance.patient");
1904      else if (Configuration.doAutoCreate())
1905        this.patient = new Reference(); // cc
1906    return this.patient;
1907  }
1908
1909  public boolean hasPatient() {
1910    return this.patient != null && !this.patient.isEmpty();
1911  }
1912
1913  /**
1914   * @param value {@link #patient} (The patient who has the allergy or
1915   *              intolerance.)
1916   */
1917  public AllergyIntolerance setPatient(Reference value) {
1918    this.patient = value;
1919    return this;
1920  }
1921
1922  /**
1923   * @return {@link #patient} The actual object that is the target of the
1924   *         reference. The reference library doesn't populate this, but you can
1925   *         use it to hold the resource if you resolve it. (The patient who has
1926   *         the allergy or intolerance.)
1927   */
1928  public Patient getPatientTarget() {
1929    if (this.patientTarget == null)
1930      if (Configuration.errorOnAutoCreate())
1931        throw new Error("Attempt to auto-create AllergyIntolerance.patient");
1932      else if (Configuration.doAutoCreate())
1933        this.patientTarget = new Patient(); // aa
1934    return this.patientTarget;
1935  }
1936
1937  /**
1938   * @param value {@link #patient} The actual object that is the target of the
1939   *              reference. The reference library doesn't use these, but you can
1940   *              use it to hold the resource if you resolve it. (The patient who
1941   *              has the allergy or intolerance.)
1942   */
1943  public AllergyIntolerance setPatientTarget(Patient value) {
1944    this.patientTarget = value;
1945    return this;
1946  }
1947
1948  /**
1949   * @return {@link #encounter} (The encounter when the allergy or intolerance was
1950   *         asserted.)
1951   */
1952  public Reference getEncounter() {
1953    if (this.encounter == null)
1954      if (Configuration.errorOnAutoCreate())
1955        throw new Error("Attempt to auto-create AllergyIntolerance.encounter");
1956      else if (Configuration.doAutoCreate())
1957        this.encounter = new Reference(); // cc
1958    return this.encounter;
1959  }
1960
1961  public boolean hasEncounter() {
1962    return this.encounter != null && !this.encounter.isEmpty();
1963  }
1964
1965  /**
1966   * @param value {@link #encounter} (The encounter when the allergy or
1967   *              intolerance was asserted.)
1968   */
1969  public AllergyIntolerance setEncounter(Reference value) {
1970    this.encounter = value;
1971    return this;
1972  }
1973
1974  /**
1975   * @return {@link #encounter} The actual object that is the target of the
1976   *         reference. The reference library doesn't populate this, but you can
1977   *         use it to hold the resource if you resolve it. (The encounter when
1978   *         the allergy or intolerance was asserted.)
1979   */
1980  public Encounter getEncounterTarget() {
1981    if (this.encounterTarget == null)
1982      if (Configuration.errorOnAutoCreate())
1983        throw new Error("Attempt to auto-create AllergyIntolerance.encounter");
1984      else if (Configuration.doAutoCreate())
1985        this.encounterTarget = new Encounter(); // aa
1986    return this.encounterTarget;
1987  }
1988
1989  /**
1990   * @param value {@link #encounter} The actual object that is the target of the
1991   *              reference. The reference library doesn't use these, but you can
1992   *              use it to hold the resource if you resolve it. (The encounter
1993   *              when the allergy or intolerance was asserted.)
1994   */
1995  public AllergyIntolerance setEncounterTarget(Encounter value) {
1996    this.encounterTarget = value;
1997    return this;
1998  }
1999
2000  /**
2001   * @return {@link #onset} (Estimated or actual date, date-time, or age when
2002   *         allergy or intolerance was identified.)
2003   */
2004  public Type getOnset() {
2005    return this.onset;
2006  }
2007
2008  /**
2009   * @return {@link #onset} (Estimated or actual date, date-time, or age when
2010   *         allergy or intolerance was identified.)
2011   */
2012  public DateTimeType getOnsetDateTimeType() throws FHIRException {
2013    if (this.onset == null)
2014      this.onset = new DateTimeType();
2015    if (!(this.onset instanceof DateTimeType))
2016      throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "
2017          + this.onset.getClass().getName() + " was encountered");
2018    return (DateTimeType) this.onset;
2019  }
2020
2021  public boolean hasOnsetDateTimeType() {
2022    return this != null && this.onset instanceof DateTimeType;
2023  }
2024
2025  /**
2026   * @return {@link #onset} (Estimated or actual date, date-time, or age when
2027   *         allergy or intolerance was identified.)
2028   */
2029  public Age getOnsetAge() throws FHIRException {
2030    if (this.onset == null)
2031      this.onset = new Age();
2032    if (!(this.onset instanceof Age))
2033      throw new FHIRException(
2034          "Type mismatch: the type Age was expected, but " + this.onset.getClass().getName() + " was encountered");
2035    return (Age) this.onset;
2036  }
2037
2038  public boolean hasOnsetAge() {
2039    return this != null && this.onset instanceof Age;
2040  }
2041
2042  /**
2043   * @return {@link #onset} (Estimated or actual date, date-time, or age when
2044   *         allergy or intolerance was identified.)
2045   */
2046  public Period getOnsetPeriod() throws FHIRException {
2047    if (this.onset == null)
2048      this.onset = new Period();
2049    if (!(this.onset instanceof Period))
2050      throw new FHIRException(
2051          "Type mismatch: the type Period was expected, but " + this.onset.getClass().getName() + " was encountered");
2052    return (Period) this.onset;
2053  }
2054
2055  public boolean hasOnsetPeriod() {
2056    return this != null && this.onset instanceof Period;
2057  }
2058
2059  /**
2060   * @return {@link #onset} (Estimated or actual date, date-time, or age when
2061   *         allergy or intolerance was identified.)
2062   */
2063  public Range getOnsetRange() throws FHIRException {
2064    if (this.onset == null)
2065      this.onset = new Range();
2066    if (!(this.onset instanceof Range))
2067      throw new FHIRException(
2068          "Type mismatch: the type Range was expected, but " + this.onset.getClass().getName() + " was encountered");
2069    return (Range) this.onset;
2070  }
2071
2072  public boolean hasOnsetRange() {
2073    return this != null && this.onset instanceof Range;
2074  }
2075
2076  /**
2077   * @return {@link #onset} (Estimated or actual date, date-time, or age when
2078   *         allergy or intolerance was identified.)
2079   */
2080  public StringType getOnsetStringType() throws FHIRException {
2081    if (this.onset == null)
2082      this.onset = new StringType();
2083    if (!(this.onset instanceof StringType))
2084      throw new FHIRException("Type mismatch: the type StringType was expected, but " + this.onset.getClass().getName()
2085          + " was encountered");
2086    return (StringType) this.onset;
2087  }
2088
2089  public boolean hasOnsetStringType() {
2090    return this != null && this.onset instanceof StringType;
2091  }
2092
2093  public boolean hasOnset() {
2094    return this.onset != null && !this.onset.isEmpty();
2095  }
2096
2097  /**
2098   * @param value {@link #onset} (Estimated or actual date, date-time, or age when
2099   *              allergy or intolerance was identified.)
2100   */
2101  public AllergyIntolerance setOnset(Type value) {
2102    if (value != null && !(value instanceof DateTimeType || value instanceof Age || value instanceof Period
2103        || value instanceof Range || value instanceof StringType))
2104      throw new Error("Not the right type for AllergyIntolerance.onset[x]: " + value.fhirType());
2105    this.onset = value;
2106    return this;
2107  }
2108
2109  /**
2110   * @return {@link #recordedDate} (The recordedDate represents when this
2111   *         particular AllergyIntolerance record was created in the system, which
2112   *         is often a system-generated date.). This is the underlying object
2113   *         with id, value and extensions. The accessor "getRecordedDate" gives
2114   *         direct access to the value
2115   */
2116  public DateTimeType getRecordedDateElement() {
2117    if (this.recordedDate == null)
2118      if (Configuration.errorOnAutoCreate())
2119        throw new Error("Attempt to auto-create AllergyIntolerance.recordedDate");
2120      else if (Configuration.doAutoCreate())
2121        this.recordedDate = new DateTimeType(); // bb
2122    return this.recordedDate;
2123  }
2124
2125  public boolean hasRecordedDateElement() {
2126    return this.recordedDate != null && !this.recordedDate.isEmpty();
2127  }
2128
2129  public boolean hasRecordedDate() {
2130    return this.recordedDate != null && !this.recordedDate.isEmpty();
2131  }
2132
2133  /**
2134   * @param value {@link #recordedDate} (The recordedDate represents when this
2135   *              particular AllergyIntolerance record was created in the system,
2136   *              which is often a system-generated date.). This is the underlying
2137   *              object with id, value and extensions. The accessor
2138   *              "getRecordedDate" gives direct access to the value
2139   */
2140  public AllergyIntolerance setRecordedDateElement(DateTimeType value) {
2141    this.recordedDate = value;
2142    return this;
2143  }
2144
2145  /**
2146   * @return The recordedDate represents when this particular AllergyIntolerance
2147   *         record was created in the system, which is often a system-generated
2148   *         date.
2149   */
2150  public Date getRecordedDate() {
2151    return this.recordedDate == null ? null : this.recordedDate.getValue();
2152  }
2153
2154  /**
2155   * @param value The recordedDate represents when this particular
2156   *              AllergyIntolerance record was created in the system, which is
2157   *              often a system-generated date.
2158   */
2159  public AllergyIntolerance setRecordedDate(Date value) {
2160    if (value == null)
2161      this.recordedDate = null;
2162    else {
2163      if (this.recordedDate == null)
2164        this.recordedDate = new DateTimeType();
2165      this.recordedDate.setValue(value);
2166    }
2167    return this;
2168  }
2169
2170  /**
2171   * @return {@link #recorder} (Individual who recorded the record and takes
2172   *         responsibility for its content.)
2173   */
2174  public Reference getRecorder() {
2175    if (this.recorder == null)
2176      if (Configuration.errorOnAutoCreate())
2177        throw new Error("Attempt to auto-create AllergyIntolerance.recorder");
2178      else if (Configuration.doAutoCreate())
2179        this.recorder = new Reference(); // cc
2180    return this.recorder;
2181  }
2182
2183  public boolean hasRecorder() {
2184    return this.recorder != null && !this.recorder.isEmpty();
2185  }
2186
2187  /**
2188   * @param value {@link #recorder} (Individual who recorded the record and takes
2189   *              responsibility for its content.)
2190   */
2191  public AllergyIntolerance setRecorder(Reference value) {
2192    this.recorder = value;
2193    return this;
2194  }
2195
2196  /**
2197   * @return {@link #recorder} The actual object that is the target of the
2198   *         reference. The reference library doesn't populate this, but you can
2199   *         use it to hold the resource if you resolve it. (Individual who
2200   *         recorded the record and takes responsibility for its content.)
2201   */
2202  public Resource getRecorderTarget() {
2203    return this.recorderTarget;
2204  }
2205
2206  /**
2207   * @param value {@link #recorder} The actual object that is the target of the
2208   *              reference. The reference library doesn't use these, but you can
2209   *              use it to hold the resource if you resolve it. (Individual who
2210   *              recorded the record and takes responsibility for its content.)
2211   */
2212  public AllergyIntolerance setRecorderTarget(Resource value) {
2213    this.recorderTarget = value;
2214    return this;
2215  }
2216
2217  /**
2218   * @return {@link #asserter} (The source of the information about the allergy
2219   *         that is recorded.)
2220   */
2221  public Reference getAsserter() {
2222    if (this.asserter == null)
2223      if (Configuration.errorOnAutoCreate())
2224        throw new Error("Attempt to auto-create AllergyIntolerance.asserter");
2225      else if (Configuration.doAutoCreate())
2226        this.asserter = new Reference(); // cc
2227    return this.asserter;
2228  }
2229
2230  public boolean hasAsserter() {
2231    return this.asserter != null && !this.asserter.isEmpty();
2232  }
2233
2234  /**
2235   * @param value {@link #asserter} (The source of the information about the
2236   *              allergy that is recorded.)
2237   */
2238  public AllergyIntolerance setAsserter(Reference value) {
2239    this.asserter = value;
2240    return this;
2241  }
2242
2243  /**
2244   * @return {@link #asserter} The actual object that is the target of the
2245   *         reference. The reference library doesn't populate this, but you can
2246   *         use it to hold the resource if you resolve it. (The source of the
2247   *         information about the allergy that is recorded.)
2248   */
2249  public Resource getAsserterTarget() {
2250    return this.asserterTarget;
2251  }
2252
2253  /**
2254   * @param value {@link #asserter} The actual object that is the target of the
2255   *              reference. The reference library doesn't use these, but you can
2256   *              use it to hold the resource if you resolve it. (The source of
2257   *              the information about the allergy that is recorded.)
2258   */
2259  public AllergyIntolerance setAsserterTarget(Resource value) {
2260    this.asserterTarget = value;
2261    return this;
2262  }
2263
2264  /**
2265   * @return {@link #lastOccurrence} (Represents the date and/or time of the last
2266   *         known occurrence of a reaction event.). This is the underlying object
2267   *         with id, value and extensions. The accessor "getLastOccurrence" gives
2268   *         direct access to the value
2269   */
2270  public DateTimeType getLastOccurrenceElement() {
2271    if (this.lastOccurrence == null)
2272      if (Configuration.errorOnAutoCreate())
2273        throw new Error("Attempt to auto-create AllergyIntolerance.lastOccurrence");
2274      else if (Configuration.doAutoCreate())
2275        this.lastOccurrence = new DateTimeType(); // bb
2276    return this.lastOccurrence;
2277  }
2278
2279  public boolean hasLastOccurrenceElement() {
2280    return this.lastOccurrence != null && !this.lastOccurrence.isEmpty();
2281  }
2282
2283  public boolean hasLastOccurrence() {
2284    return this.lastOccurrence != null && !this.lastOccurrence.isEmpty();
2285  }
2286
2287  /**
2288   * @param value {@link #lastOccurrence} (Represents the date and/or time of the
2289   *              last known occurrence of a reaction event.). This is the
2290   *              underlying object with id, value and extensions. The accessor
2291   *              "getLastOccurrence" gives direct access to the value
2292   */
2293  public AllergyIntolerance setLastOccurrenceElement(DateTimeType value) {
2294    this.lastOccurrence = value;
2295    return this;
2296  }
2297
2298  /**
2299   * @return Represents the date and/or time of the last known occurrence of a
2300   *         reaction event.
2301   */
2302  public Date getLastOccurrence() {
2303    return this.lastOccurrence == null ? null : this.lastOccurrence.getValue();
2304  }
2305
2306  /**
2307   * @param value Represents the date and/or time of the last known occurrence of
2308   *              a reaction event.
2309   */
2310  public AllergyIntolerance setLastOccurrence(Date value) {
2311    if (value == null)
2312      this.lastOccurrence = null;
2313    else {
2314      if (this.lastOccurrence == null)
2315        this.lastOccurrence = new DateTimeType();
2316      this.lastOccurrence.setValue(value);
2317    }
2318    return this;
2319  }
2320
2321  /**
2322   * @return {@link #note} (Additional narrative about the propensity for the
2323   *         Adverse Reaction, not captured in other fields.)
2324   */
2325  public List<Annotation> getNote() {
2326    if (this.note == null)
2327      this.note = new ArrayList<Annotation>();
2328    return this.note;
2329  }
2330
2331  /**
2332   * @return Returns a reference to <code>this</code> for easy method chaining
2333   */
2334  public AllergyIntolerance setNote(List<Annotation> theNote) {
2335    this.note = theNote;
2336    return this;
2337  }
2338
2339  public boolean hasNote() {
2340    if (this.note == null)
2341      return false;
2342    for (Annotation item : this.note)
2343      if (!item.isEmpty())
2344        return true;
2345    return false;
2346  }
2347
2348  public Annotation addNote() { // 3
2349    Annotation t = new Annotation();
2350    if (this.note == null)
2351      this.note = new ArrayList<Annotation>();
2352    this.note.add(t);
2353    return t;
2354  }
2355
2356  public AllergyIntolerance addNote(Annotation t) { // 3
2357    if (t == null)
2358      return this;
2359    if (this.note == null)
2360      this.note = new ArrayList<Annotation>();
2361    this.note.add(t);
2362    return this;
2363  }
2364
2365  /**
2366   * @return The first repetition of repeating field {@link #note}, creating it if
2367   *         it does not already exist
2368   */
2369  public Annotation getNoteFirstRep() {
2370    if (getNote().isEmpty()) {
2371      addNote();
2372    }
2373    return getNote().get(0);
2374  }
2375
2376  /**
2377   * @return {@link #reaction} (Details about each adverse reaction event linked
2378   *         to exposure to the identified substance.)
2379   */
2380  public List<AllergyIntoleranceReactionComponent> getReaction() {
2381    if (this.reaction == null)
2382      this.reaction = new ArrayList<AllergyIntoleranceReactionComponent>();
2383    return this.reaction;
2384  }
2385
2386  /**
2387   * @return Returns a reference to <code>this</code> for easy method chaining
2388   */
2389  public AllergyIntolerance setReaction(List<AllergyIntoleranceReactionComponent> theReaction) {
2390    this.reaction = theReaction;
2391    return this;
2392  }
2393
2394  public boolean hasReaction() {
2395    if (this.reaction == null)
2396      return false;
2397    for (AllergyIntoleranceReactionComponent item : this.reaction)
2398      if (!item.isEmpty())
2399        return true;
2400    return false;
2401  }
2402
2403  public AllergyIntoleranceReactionComponent addReaction() { // 3
2404    AllergyIntoleranceReactionComponent t = new AllergyIntoleranceReactionComponent();
2405    if (this.reaction == null)
2406      this.reaction = new ArrayList<AllergyIntoleranceReactionComponent>();
2407    this.reaction.add(t);
2408    return t;
2409  }
2410
2411  public AllergyIntolerance addReaction(AllergyIntoleranceReactionComponent t) { // 3
2412    if (t == null)
2413      return this;
2414    if (this.reaction == null)
2415      this.reaction = new ArrayList<AllergyIntoleranceReactionComponent>();
2416    this.reaction.add(t);
2417    return this;
2418  }
2419
2420  /**
2421   * @return The first repetition of repeating field {@link #reaction}, creating
2422   *         it if it does not already exist
2423   */
2424  public AllergyIntoleranceReactionComponent getReactionFirstRep() {
2425    if (getReaction().isEmpty()) {
2426      addReaction();
2427    }
2428    return getReaction().get(0);
2429  }
2430
2431  protected void listChildren(List<Property> children) {
2432    super.listChildren(children);
2433    children.add(new Property("identifier", "Identifier",
2434        "Business identifiers assigned to this AllergyIntolerance by the performer or other systems which remain constant as the resource is updated and propagates from server to server.",
2435        0, java.lang.Integer.MAX_VALUE, identifier));
2436    children.add(new Property("clinicalStatus", "CodeableConcept", "The clinical status of the allergy or intolerance.",
2437        0, 1, clinicalStatus));
2438    children.add(new Property("verificationStatus", "CodeableConcept",
2439        "Assertion about certainty associated with the propensity, or potential risk, of a reaction to the identified substance (including pharmaceutical product).",
2440        0, 1, verificationStatus));
2441    children.add(new Property("type", "code",
2442        "Identification of the underlying physiological mechanism for the reaction risk.", 0, 1, type));
2443    children.add(new Property("category", "code", "Category of the identified substance.", 0,
2444        java.lang.Integer.MAX_VALUE, category));
2445    children.add(new Property("criticality", "code",
2446        "Estimate of the potential clinical harm, or seriousness, of the reaction to the identified substance.", 0, 1,
2447        criticality));
2448    children.add(new Property("code", "CodeableConcept",
2449        "Code for an allergy or intolerance statement (either a positive or a negated/excluded statement).  This may be a code for a substance or pharmaceutical product that is considered to be responsible for the adverse reaction risk (e.g., \"Latex\"), an allergy or intolerance condition (e.g., \"Latex allergy\"), or a negated/excluded code for a specific substance or class (e.g., \"No latex allergy\") or a general or categorical negated statement (e.g.,  \"No known allergy\", \"No known drug allergies\").  Note: the substance for a specific reaction may be different from the substance identified as the cause of the risk, but it must be consistent with it. For instance, it may be a more specific substance (e.g. a brand medication) or a composite product that includes the identified substance. It must be clinically safe to only process the 'code' and ignore the 'reaction.substance'.  If a receiving system is unable to confirm that AllergyIntolerance.reaction.substance falls within the semantic scope of AllergyIntolerance.code, then the receiving system should ignore AllergyIntolerance.reaction.substance.",
2450        0, 1, code));
2451    children.add(new Property("patient", "Reference(Patient)", "The patient who has the allergy or intolerance.", 0, 1,
2452        patient));
2453    children.add(new Property("encounter", "Reference(Encounter)",
2454        "The encounter when the allergy or intolerance was asserted.", 0, 1, encounter));
2455    children.add(new Property("onset[x]", "dateTime|Age|Period|Range|string",
2456        "Estimated or actual date,  date-time, or age when allergy or intolerance was identified.", 0, 1, onset));
2457    children.add(new Property("recordedDate", "dateTime",
2458        "The recordedDate represents when this particular AllergyIntolerance record was created in the system, which is often a system-generated date.",
2459        0, 1, recordedDate));
2460    children.add(new Property("recorder", "Reference(Practitioner|PractitionerRole|Patient|RelatedPerson)",
2461        "Individual who recorded the record and takes responsibility for its content.", 0, 1, recorder));
2462    children.add(new Property("asserter", "Reference(Patient|RelatedPerson|Practitioner|PractitionerRole)",
2463        "The source of the information about the allergy that is recorded.", 0, 1, asserter));
2464    children.add(new Property("lastOccurrence", "dateTime",
2465        "Represents the date and/or time of the last known occurrence of a reaction event.", 0, 1, lastOccurrence));
2466    children.add(new Property("note", "Annotation",
2467        "Additional narrative about the propensity for the Adverse Reaction, not captured in other fields.", 0,
2468        java.lang.Integer.MAX_VALUE, note));
2469    children.add(new Property("reaction", "",
2470        "Details about each adverse reaction event linked to exposure to the identified substance.", 0,
2471        java.lang.Integer.MAX_VALUE, reaction));
2472  }
2473
2474  @Override
2475  public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2476    switch (_hash) {
2477    case -1618432855:
2478      /* identifier */ return new Property("identifier", "Identifier",
2479          "Business identifiers assigned to this AllergyIntolerance by the performer or other systems which remain constant as the resource is updated and propagates from server to server.",
2480          0, java.lang.Integer.MAX_VALUE, identifier);
2481    case -462853915:
2482      /* clinicalStatus */ return new Property("clinicalStatus", "CodeableConcept",
2483          "The clinical status of the allergy or intolerance.", 0, 1, clinicalStatus);
2484    case -842509843:
2485      /* verificationStatus */ return new Property("verificationStatus", "CodeableConcept",
2486          "Assertion about certainty associated with the propensity, or potential risk, of a reaction to the identified substance (including pharmaceutical product).",
2487          0, 1, verificationStatus);
2488    case 3575610:
2489      /* type */ return new Property("type", "code",
2490          "Identification of the underlying physiological mechanism for the reaction risk.", 0, 1, type);
2491    case 50511102:
2492      /* category */ return new Property("category", "code", "Category of the identified substance.", 0,
2493          java.lang.Integer.MAX_VALUE, category);
2494    case -1608054609:
2495      /* criticality */ return new Property("criticality", "code",
2496          "Estimate of the potential clinical harm, or seriousness, of the reaction to the identified substance.", 0, 1,
2497          criticality);
2498    case 3059181:
2499      /* code */ return new Property("code", "CodeableConcept",
2500          "Code for an allergy or intolerance statement (either a positive or a negated/excluded statement).  This may be a code for a substance or pharmaceutical product that is considered to be responsible for the adverse reaction risk (e.g., \"Latex\"), an allergy or intolerance condition (e.g., \"Latex allergy\"), or a negated/excluded code for a specific substance or class (e.g., \"No latex allergy\") or a general or categorical negated statement (e.g.,  \"No known allergy\", \"No known drug allergies\").  Note: the substance for a specific reaction may be different from the substance identified as the cause of the risk, but it must be consistent with it. For instance, it may be a more specific substance (e.g. a brand medication) or a composite product that includes the identified substance. It must be clinically safe to only process the 'code' and ignore the 'reaction.substance'.  If a receiving system is unable to confirm that AllergyIntolerance.reaction.substance falls within the semantic scope of AllergyIntolerance.code, then the receiving system should ignore AllergyIntolerance.reaction.substance.",
2501          0, 1, code);
2502    case -791418107:
2503      /* patient */ return new Property("patient", "Reference(Patient)",
2504          "The patient who has the allergy or intolerance.", 0, 1, patient);
2505    case 1524132147:
2506      /* encounter */ return new Property("encounter", "Reference(Encounter)",
2507          "The encounter when the allergy or intolerance was asserted.", 0, 1, encounter);
2508    case -1886216323:
2509      /* onset[x] */ return new Property("onset[x]", "dateTime|Age|Period|Range|string",
2510          "Estimated or actual date,  date-time, or age when allergy or intolerance was identified.", 0, 1, onset);
2511    case 105901603:
2512      /* onset */ return new Property("onset[x]", "dateTime|Age|Period|Range|string",
2513          "Estimated or actual date,  date-time, or age when allergy or intolerance was identified.", 0, 1, onset);
2514    case -1701663010:
2515      /* onsetDateTime */ return new Property("onset[x]", "dateTime|Age|Period|Range|string",
2516          "Estimated or actual date,  date-time, or age when allergy or intolerance was identified.", 0, 1, onset);
2517    case -1886241828:
2518      /* onsetAge */ return new Property("onset[x]", "dateTime|Age|Period|Range|string",
2519          "Estimated or actual date,  date-time, or age when allergy or intolerance was identified.", 0, 1, onset);
2520    case -1545082428:
2521      /* onsetPeriod */ return new Property("onset[x]", "dateTime|Age|Period|Range|string",
2522          "Estimated or actual date,  date-time, or age when allergy or intolerance was identified.", 0, 1, onset);
2523    case -186664742:
2524      /* onsetRange */ return new Property("onset[x]", "dateTime|Age|Period|Range|string",
2525          "Estimated or actual date,  date-time, or age when allergy or intolerance was identified.", 0, 1, onset);
2526    case -1445342188:
2527      /* onsetString */ return new Property("onset[x]", "dateTime|Age|Period|Range|string",
2528          "Estimated or actual date,  date-time, or age when allergy or intolerance was identified.", 0, 1, onset);
2529    case -1952893826:
2530      /* recordedDate */ return new Property("recordedDate", "dateTime",
2531          "The recordedDate represents when this particular AllergyIntolerance record was created in the system, which is often a system-generated date.",
2532          0, 1, recordedDate);
2533    case -799233858:
2534      /* recorder */ return new Property("recorder", "Reference(Practitioner|PractitionerRole|Patient|RelatedPerson)",
2535          "Individual who recorded the record and takes responsibility for its content.", 0, 1, recorder);
2536    case -373242253:
2537      /* asserter */ return new Property("asserter", "Reference(Patient|RelatedPerson|Practitioner|PractitionerRole)",
2538          "The source of the information about the allergy that is recorded.", 0, 1, asserter);
2539    case 1896977671:
2540      /* lastOccurrence */ return new Property("lastOccurrence", "dateTime",
2541          "Represents the date and/or time of the last known occurrence of a reaction event.", 0, 1, lastOccurrence);
2542    case 3387378:
2543      /* note */ return new Property("note", "Annotation",
2544          "Additional narrative about the propensity for the Adverse Reaction, not captured in other fields.", 0,
2545          java.lang.Integer.MAX_VALUE, note);
2546    case -867509719:
2547      /* reaction */ return new Property("reaction", "",
2548          "Details about each adverse reaction event linked to exposure to the identified substance.", 0,
2549          java.lang.Integer.MAX_VALUE, reaction);
2550    default:
2551      return super.getNamedProperty(_hash, _name, _checkValid);
2552    }
2553
2554  }
2555
2556  @Override
2557  public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2558    switch (hash) {
2559    case -1618432855:
2560      /* identifier */ return this.identifier == null ? new Base[0]
2561          : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
2562    case -462853915:
2563      /* clinicalStatus */ return this.clinicalStatus == null ? new Base[0] : new Base[] { this.clinicalStatus }; // CodeableConcept
2564    case -842509843:
2565      /* verificationStatus */ return this.verificationStatus == null ? new Base[0]
2566          : new Base[] { this.verificationStatus }; // CodeableConcept
2567    case 3575610:
2568      /* type */ return this.type == null ? new Base[0] : new Base[] { this.type }; // Enumeration<AllergyIntoleranceType>
2569    case 50511102:
2570      /* category */ return this.category == null ? new Base[0] : this.category.toArray(new Base[this.category.size()]); // Enumeration<AllergyIntoleranceCategory>
2571    case -1608054609:
2572      /* criticality */ return this.criticality == null ? new Base[0] : new Base[] { this.criticality }; // Enumeration<AllergyIntoleranceCriticality>
2573    case 3059181:
2574      /* code */ return this.code == null ? new Base[0] : new Base[] { this.code }; // CodeableConcept
2575    case -791418107:
2576      /* patient */ return this.patient == null ? new Base[0] : new Base[] { this.patient }; // Reference
2577    case 1524132147:
2578      /* encounter */ return this.encounter == null ? new Base[0] : new Base[] { this.encounter }; // Reference
2579    case 105901603:
2580      /* onset */ return this.onset == null ? new Base[0] : new Base[] { this.onset }; // Type
2581    case -1952893826:
2582      /* recordedDate */ return this.recordedDate == null ? new Base[0] : new Base[] { this.recordedDate }; // DateTimeType
2583    case -799233858:
2584      /* recorder */ return this.recorder == null ? new Base[0] : new Base[] { this.recorder }; // Reference
2585    case -373242253:
2586      /* asserter */ return this.asserter == null ? new Base[0] : new Base[] { this.asserter }; // Reference
2587    case 1896977671:
2588      /* lastOccurrence */ return this.lastOccurrence == null ? new Base[0] : new Base[] { this.lastOccurrence }; // DateTimeType
2589    case 3387378:
2590      /* note */ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
2591    case -867509719:
2592      /* reaction */ return this.reaction == null ? new Base[0] : this.reaction.toArray(new Base[this.reaction.size()]); // AllergyIntoleranceReactionComponent
2593    default:
2594      return super.getProperty(hash, name, checkValid);
2595    }
2596
2597  }
2598
2599  @Override
2600  public Base setProperty(int hash, String name, Base value) throws FHIRException {
2601    switch (hash) {
2602    case -1618432855: // identifier
2603      this.getIdentifier().add(castToIdentifier(value)); // Identifier
2604      return value;
2605    case -462853915: // clinicalStatus
2606      this.clinicalStatus = castToCodeableConcept(value); // CodeableConcept
2607      return value;
2608    case -842509843: // verificationStatus
2609      this.verificationStatus = castToCodeableConcept(value); // CodeableConcept
2610      return value;
2611    case 3575610: // type
2612      value = new AllergyIntoleranceTypeEnumFactory().fromType(castToCode(value));
2613      this.type = (Enumeration) value; // Enumeration<AllergyIntoleranceType>
2614      return value;
2615    case 50511102: // category
2616      value = new AllergyIntoleranceCategoryEnumFactory().fromType(castToCode(value));
2617      this.getCategory().add((Enumeration) value); // Enumeration<AllergyIntoleranceCategory>
2618      return value;
2619    case -1608054609: // criticality
2620      value = new AllergyIntoleranceCriticalityEnumFactory().fromType(castToCode(value));
2621      this.criticality = (Enumeration) value; // Enumeration<AllergyIntoleranceCriticality>
2622      return value;
2623    case 3059181: // code
2624      this.code = castToCodeableConcept(value); // CodeableConcept
2625      return value;
2626    case -791418107: // patient
2627      this.patient = castToReference(value); // Reference
2628      return value;
2629    case 1524132147: // encounter
2630      this.encounter = castToReference(value); // Reference
2631      return value;
2632    case 105901603: // onset
2633      this.onset = castToType(value); // Type
2634      return value;
2635    case -1952893826: // recordedDate
2636      this.recordedDate = castToDateTime(value); // DateTimeType
2637      return value;
2638    case -799233858: // recorder
2639      this.recorder = castToReference(value); // Reference
2640      return value;
2641    case -373242253: // asserter
2642      this.asserter = castToReference(value); // Reference
2643      return value;
2644    case 1896977671: // lastOccurrence
2645      this.lastOccurrence = castToDateTime(value); // DateTimeType
2646      return value;
2647    case 3387378: // note
2648      this.getNote().add(castToAnnotation(value)); // Annotation
2649      return value;
2650    case -867509719: // reaction
2651      this.getReaction().add((AllergyIntoleranceReactionComponent) value); // AllergyIntoleranceReactionComponent
2652      return value;
2653    default:
2654      return super.setProperty(hash, name, value);
2655    }
2656
2657  }
2658
2659  @Override
2660  public Base setProperty(String name, Base value) throws FHIRException {
2661    if (name.equals("identifier")) {
2662      this.getIdentifier().add(castToIdentifier(value));
2663    } else if (name.equals("clinicalStatus")) {
2664      this.clinicalStatus = castToCodeableConcept(value); // CodeableConcept
2665    } else if (name.equals("verificationStatus")) {
2666      this.verificationStatus = castToCodeableConcept(value); // CodeableConcept
2667    } else if (name.equals("type")) {
2668      value = new AllergyIntoleranceTypeEnumFactory().fromType(castToCode(value));
2669      this.type = (Enumeration) value; // Enumeration<AllergyIntoleranceType>
2670    } else if (name.equals("category")) {
2671      value = new AllergyIntoleranceCategoryEnumFactory().fromType(castToCode(value));
2672      this.getCategory().add((Enumeration) value);
2673    } else if (name.equals("criticality")) {
2674      value = new AllergyIntoleranceCriticalityEnumFactory().fromType(castToCode(value));
2675      this.criticality = (Enumeration) value; // Enumeration<AllergyIntoleranceCriticality>
2676    } else if (name.equals("code")) {
2677      this.code = castToCodeableConcept(value); // CodeableConcept
2678    } else if (name.equals("patient")) {
2679      this.patient = castToReference(value); // Reference
2680    } else if (name.equals("encounter")) {
2681      this.encounter = castToReference(value); // Reference
2682    } else if (name.equals("onset[x]")) {
2683      this.onset = castToType(value); // Type
2684    } else if (name.equals("recordedDate")) {
2685      this.recordedDate = castToDateTime(value); // DateTimeType
2686    } else if (name.equals("recorder")) {
2687      this.recorder = castToReference(value); // Reference
2688    } else if (name.equals("asserter")) {
2689      this.asserter = castToReference(value); // Reference
2690    } else if (name.equals("lastOccurrence")) {
2691      this.lastOccurrence = castToDateTime(value); // DateTimeType
2692    } else if (name.equals("note")) {
2693      this.getNote().add(castToAnnotation(value));
2694    } else if (name.equals("reaction")) {
2695      this.getReaction().add((AllergyIntoleranceReactionComponent) value);
2696    } else
2697      return super.setProperty(name, value);
2698    return value;
2699  }
2700
2701  @Override
2702  public void removeChild(String name, Base value) throws FHIRException {
2703    if (name.equals("identifier")) {
2704      this.getIdentifier().remove(castToIdentifier(value));
2705    } else if (name.equals("clinicalStatus")) {
2706      this.clinicalStatus = null;
2707    } else if (name.equals("verificationStatus")) {
2708      this.verificationStatus = null;
2709    } else if (name.equals("type")) {
2710      this.type = null;
2711    } else if (name.equals("category")) {
2712      this.getCategory().remove((Enumeration) value);
2713    } else if (name.equals("criticality")) {
2714      value = null;
2715      this.criticality = (Enumeration) value; // Enumeration<AllergyIntoleranceCriticality>
2716    } else if (name.equals("code")) {
2717      this.code = null;
2718    } else if (name.equals("patient")) {
2719      this.patient = null;
2720    } else if (name.equals("encounter")) {
2721      this.encounter = null;
2722    } else if (name.equals("onset[x]")) {
2723      this.onset = null;
2724    } else if (name.equals("recordedDate")) {
2725      this.recordedDate = null;
2726    } else if (name.equals("recorder")) {
2727      this.recorder = null;
2728    } else if (name.equals("asserter")) {
2729      this.asserter = null;
2730    } else if (name.equals("lastOccurrence")) {
2731      this.lastOccurrence = null;
2732    } else if (name.equals("note")) {
2733      this.getNote().remove(castToAnnotation(value));
2734    } else if (name.equals("reaction")) {
2735      this.getReaction().remove((AllergyIntoleranceReactionComponent) value);
2736    } else
2737      super.removeChild(name, value);
2738    
2739  }
2740
2741  @Override
2742  public Base makeProperty(int hash, String name) throws FHIRException {
2743    switch (hash) {
2744    case -1618432855:
2745      return addIdentifier();
2746    case -462853915:
2747      return getClinicalStatus();
2748    case -842509843:
2749      return getVerificationStatus();
2750    case 3575610:
2751      return getTypeElement();
2752    case 50511102:
2753      return addCategoryElement();
2754    case -1608054609:
2755      return getCriticalityElement();
2756    case 3059181:
2757      return getCode();
2758    case -791418107:
2759      return getPatient();
2760    case 1524132147:
2761      return getEncounter();
2762    case -1886216323:
2763      return getOnset();
2764    case 105901603:
2765      return getOnset();
2766    case -1952893826:
2767      return getRecordedDateElement();
2768    case -799233858:
2769      return getRecorder();
2770    case -373242253:
2771      return getAsserter();
2772    case 1896977671:
2773      return getLastOccurrenceElement();
2774    case 3387378:
2775      return addNote();
2776    case -867509719:
2777      return addReaction();
2778    default:
2779      return super.makeProperty(hash, name);
2780    }
2781
2782  }
2783
2784  @Override
2785  public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2786    switch (hash) {
2787    case -1618432855:
2788      /* identifier */ return new String[] { "Identifier" };
2789    case -462853915:
2790      /* clinicalStatus */ return new String[] { "CodeableConcept" };
2791    case -842509843:
2792      /* verificationStatus */ return new String[] { "CodeableConcept" };
2793    case 3575610:
2794      /* type */ return new String[] { "code" };
2795    case 50511102:
2796      /* category */ return new String[] { "code" };
2797    case -1608054609:
2798      /* criticality */ return new String[] { "code" };
2799    case 3059181:
2800      /* code */ return new String[] { "CodeableConcept" };
2801    case -791418107:
2802      /* patient */ return new String[] { "Reference" };
2803    case 1524132147:
2804      /* encounter */ return new String[] { "Reference" };
2805    case 105901603:
2806      /* onset */ return new String[] { "dateTime", "Age", "Period", "Range", "string" };
2807    case -1952893826:
2808      /* recordedDate */ return new String[] { "dateTime" };
2809    case -799233858:
2810      /* recorder */ return new String[] { "Reference" };
2811    case -373242253:
2812      /* asserter */ return new String[] { "Reference" };
2813    case 1896977671:
2814      /* lastOccurrence */ return new String[] { "dateTime" };
2815    case 3387378:
2816      /* note */ return new String[] { "Annotation" };
2817    case -867509719:
2818      /* reaction */ return new String[] {};
2819    default:
2820      return super.getTypesForProperty(hash, name);
2821    }
2822
2823  }
2824
2825  @Override
2826  public Base addChild(String name) throws FHIRException {
2827    if (name.equals("identifier")) {
2828      return addIdentifier();
2829    } else if (name.equals("clinicalStatus")) {
2830      this.clinicalStatus = new CodeableConcept();
2831      return this.clinicalStatus;
2832    } else if (name.equals("verificationStatus")) {
2833      this.verificationStatus = new CodeableConcept();
2834      return this.verificationStatus;
2835    } else if (name.equals("type")) {
2836      throw new FHIRException("Cannot call addChild on a singleton property AllergyIntolerance.type");
2837    } else if (name.equals("category")) {
2838      throw new FHIRException("Cannot call addChild on a singleton property AllergyIntolerance.category");
2839    } else if (name.equals("criticality")) {
2840      throw new FHIRException("Cannot call addChild on a singleton property AllergyIntolerance.criticality");
2841    } else if (name.equals("code")) {
2842      this.code = new CodeableConcept();
2843      return this.code;
2844    } else if (name.equals("patient")) {
2845      this.patient = new Reference();
2846      return this.patient;
2847    } else if (name.equals("encounter")) {
2848      this.encounter = new Reference();
2849      return this.encounter;
2850    } else if (name.equals("onsetDateTime")) {
2851      this.onset = new DateTimeType();
2852      return this.onset;
2853    } else if (name.equals("onsetAge")) {
2854      this.onset = new Age();
2855      return this.onset;
2856    } else if (name.equals("onsetPeriod")) {
2857      this.onset = new Period();
2858      return this.onset;
2859    } else if (name.equals("onsetRange")) {
2860      this.onset = new Range();
2861      return this.onset;
2862    } else if (name.equals("onsetString")) {
2863      this.onset = new StringType();
2864      return this.onset;
2865    } else if (name.equals("recordedDate")) {
2866      throw new FHIRException("Cannot call addChild on a singleton property AllergyIntolerance.recordedDate");
2867    } else if (name.equals("recorder")) {
2868      this.recorder = new Reference();
2869      return this.recorder;
2870    } else if (name.equals("asserter")) {
2871      this.asserter = new Reference();
2872      return this.asserter;
2873    } else if (name.equals("lastOccurrence")) {
2874      throw new FHIRException("Cannot call addChild on a singleton property AllergyIntolerance.lastOccurrence");
2875    } else if (name.equals("note")) {
2876      return addNote();
2877    } else if (name.equals("reaction")) {
2878      return addReaction();
2879    } else
2880      return super.addChild(name);
2881  }
2882
2883  public String fhirType() {
2884    return "AllergyIntolerance";
2885
2886  }
2887
2888  public AllergyIntolerance copy() {
2889    AllergyIntolerance dst = new AllergyIntolerance();
2890    copyValues(dst);
2891    return dst;
2892  }
2893
2894  public void copyValues(AllergyIntolerance dst) {
2895    super.copyValues(dst);
2896    if (identifier != null) {
2897      dst.identifier = new ArrayList<Identifier>();
2898      for (Identifier i : identifier)
2899        dst.identifier.add(i.copy());
2900    }
2901    ;
2902    dst.clinicalStatus = clinicalStatus == null ? null : clinicalStatus.copy();
2903    dst.verificationStatus = verificationStatus == null ? null : verificationStatus.copy();
2904    dst.type = type == null ? null : type.copy();
2905    if (category != null) {
2906      dst.category = new ArrayList<Enumeration<AllergyIntoleranceCategory>>();
2907      for (Enumeration<AllergyIntoleranceCategory> i : category)
2908        dst.category.add(i.copy());
2909    }
2910    ;
2911    dst.criticality = criticality == null ? null : criticality.copy();
2912    dst.code = code == null ? null : code.copy();
2913    dst.patient = patient == null ? null : patient.copy();
2914    dst.encounter = encounter == null ? null : encounter.copy();
2915    dst.onset = onset == null ? null : onset.copy();
2916    dst.recordedDate = recordedDate == null ? null : recordedDate.copy();
2917    dst.recorder = recorder == null ? null : recorder.copy();
2918    dst.asserter = asserter == null ? null : asserter.copy();
2919    dst.lastOccurrence = lastOccurrence == null ? null : lastOccurrence.copy();
2920    if (note != null) {
2921      dst.note = new ArrayList<Annotation>();
2922      for (Annotation i : note)
2923        dst.note.add(i.copy());
2924    }
2925    ;
2926    if (reaction != null) {
2927      dst.reaction = new ArrayList<AllergyIntoleranceReactionComponent>();
2928      for (AllergyIntoleranceReactionComponent i : reaction)
2929        dst.reaction.add(i.copy());
2930    }
2931    ;
2932  }
2933
2934  protected AllergyIntolerance typedCopy() {
2935    return copy();
2936  }
2937
2938  @Override
2939  public boolean equalsDeep(Base other_) {
2940    if (!super.equalsDeep(other_))
2941      return false;
2942    if (!(other_ instanceof AllergyIntolerance))
2943      return false;
2944    AllergyIntolerance o = (AllergyIntolerance) other_;
2945    return compareDeep(identifier, o.identifier, true) && compareDeep(clinicalStatus, o.clinicalStatus, true)
2946        && compareDeep(verificationStatus, o.verificationStatus, true) && compareDeep(type, o.type, true)
2947        && compareDeep(category, o.category, true) && compareDeep(criticality, o.criticality, true)
2948        && compareDeep(code, o.code, true) && compareDeep(patient, o.patient, true)
2949        && compareDeep(encounter, o.encounter, true) && compareDeep(onset, o.onset, true)
2950        && compareDeep(recordedDate, o.recordedDate, true) && compareDeep(recorder, o.recorder, true)
2951        && compareDeep(asserter, o.asserter, true) && compareDeep(lastOccurrence, o.lastOccurrence, true)
2952        && compareDeep(note, o.note, true) && compareDeep(reaction, o.reaction, true);
2953  }
2954
2955  @Override
2956  public boolean equalsShallow(Base other_) {
2957    if (!super.equalsShallow(other_))
2958      return false;
2959    if (!(other_ instanceof AllergyIntolerance))
2960      return false;
2961    AllergyIntolerance o = (AllergyIntolerance) other_;
2962    return compareValues(type, o.type, true) && compareValues(category, o.category, true)
2963        && compareValues(criticality, o.criticality, true) && compareValues(recordedDate, o.recordedDate, true)
2964        && compareValues(lastOccurrence, o.lastOccurrence, true);
2965  }
2966
2967  public boolean isEmpty() {
2968    return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, clinicalStatus, verificationStatus, type,
2969        category, criticality, code, patient, encounter, onset, recordedDate, recorder, asserter, lastOccurrence, note,
2970        reaction);
2971  }
2972
2973  @Override
2974  public ResourceType getResourceType() {
2975    return ResourceType.AllergyIntolerance;
2976  }
2977
2978  /**
2979   * Search parameter: <b>severity</b>
2980   * <p>
2981   * Description: <b>mild | moderate | severe (of event as a whole)</b><br>
2982   * Type: <b>token</b><br>
2983   * Path: <b>AllergyIntolerance.reaction.severity</b><br>
2984   * </p>
2985   */
2986  @SearchParamDefinition(name = "severity", path = "AllergyIntolerance.reaction.severity", description = "mild | moderate | severe (of event as a whole)", type = "token")
2987  public static final String SP_SEVERITY = "severity";
2988  /**
2989   * <b>Fluent Client</b> search parameter constant for <b>severity</b>
2990   * <p>
2991   * Description: <b>mild | moderate | severe (of event as a whole)</b><br>
2992   * Type: <b>token</b><br>
2993   * Path: <b>AllergyIntolerance.reaction.severity</b><br>
2994   * </p>
2995   */
2996  public static final ca.uhn.fhir.rest.gclient.TokenClientParam SEVERITY = new ca.uhn.fhir.rest.gclient.TokenClientParam(
2997      SP_SEVERITY);
2998
2999  /**
3000   * Search parameter: <b>date</b>
3001   * <p>
3002   * Description: <b>Date first version of the resource instance was
3003   * recorded</b><br>
3004   * Type: <b>date</b><br>
3005   * Path: <b>AllergyIntolerance.recordedDate</b><br>
3006   * </p>
3007   */
3008  @SearchParamDefinition(name = "date", path = "AllergyIntolerance.recordedDate", description = "Date first version of the resource instance was recorded", type = "date")
3009  public static final String SP_DATE = "date";
3010  /**
3011   * <b>Fluent Client</b> search parameter constant for <b>date</b>
3012   * <p>
3013   * Description: <b>Date first version of the resource instance was
3014   * recorded</b><br>
3015   * Type: <b>date</b><br>
3016   * Path: <b>AllergyIntolerance.recordedDate</b><br>
3017   * </p>
3018   */
3019  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(
3020      SP_DATE);
3021
3022  /**
3023   * Search parameter: <b>identifier</b>
3024   * <p>
3025   * Description: <b>External ids for this item</b><br>
3026   * Type: <b>token</b><br>
3027   * Path: <b>AllergyIntolerance.identifier</b><br>
3028   * </p>
3029   */
3030  @SearchParamDefinition(name = "identifier", path = "AllergyIntolerance.identifier", description = "External ids for this item", type = "token")
3031  public static final String SP_IDENTIFIER = "identifier";
3032  /**
3033   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
3034   * <p>
3035   * Description: <b>External ids for this item</b><br>
3036   * Type: <b>token</b><br>
3037   * Path: <b>AllergyIntolerance.identifier</b><br>
3038   * </p>
3039   */
3040  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(
3041      SP_IDENTIFIER);
3042
3043  /**
3044   * Search parameter: <b>manifestation</b>
3045   * <p>
3046   * Description: <b>Clinical symptoms/signs associated with the Event</b><br>
3047   * Type: <b>token</b><br>
3048   * Path: <b>AllergyIntolerance.reaction.manifestation</b><br>
3049   * </p>
3050   */
3051  @SearchParamDefinition(name = "manifestation", path = "AllergyIntolerance.reaction.manifestation", description = "Clinical symptoms/signs associated with the Event", type = "token")
3052  public static final String SP_MANIFESTATION = "manifestation";
3053  /**
3054   * <b>Fluent Client</b> search parameter constant for <b>manifestation</b>
3055   * <p>
3056   * Description: <b>Clinical symptoms/signs associated with the Event</b><br>
3057   * Type: <b>token</b><br>
3058   * Path: <b>AllergyIntolerance.reaction.manifestation</b><br>
3059   * </p>
3060   */
3061  public static final ca.uhn.fhir.rest.gclient.TokenClientParam MANIFESTATION = new ca.uhn.fhir.rest.gclient.TokenClientParam(
3062      SP_MANIFESTATION);
3063
3064  /**
3065   * Search parameter: <b>recorder</b>
3066   * <p>
3067   * Description: <b>Who recorded the sensitivity</b><br>
3068   * Type: <b>reference</b><br>
3069   * Path: <b>AllergyIntolerance.recorder</b><br>
3070   * </p>
3071   */
3072  @SearchParamDefinition(name = "recorder", path = "AllergyIntolerance.recorder", description = "Who recorded the sensitivity", type = "reference", providesMembershipIn = {
3073      @ca.uhn.fhir.model.api.annotation.Compartment(name = "Patient"),
3074      @ca.uhn.fhir.model.api.annotation.Compartment(name = "Practitioner") }, target = { Patient.class,
3075          Practitioner.class, PractitionerRole.class, RelatedPerson.class })
3076  public static final String SP_RECORDER = "recorder";
3077  /**
3078   * <b>Fluent Client</b> search parameter constant for <b>recorder</b>
3079   * <p>
3080   * Description: <b>Who recorded the sensitivity</b><br>
3081   * Type: <b>reference</b><br>
3082   * Path: <b>AllergyIntolerance.recorder</b><br>
3083   * </p>
3084   */
3085  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam RECORDER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
3086      SP_RECORDER);
3087
3088  /**
3089   * Constant for fluent queries to be used to add include statements. Specifies
3090   * the path value of "<b>AllergyIntolerance:recorder</b>".
3091   */
3092  public static final ca.uhn.fhir.model.api.Include INCLUDE_RECORDER = new ca.uhn.fhir.model.api.Include(
3093      "AllergyIntolerance:recorder").toLocked();
3094
3095  /**
3096   * Search parameter: <b>code</b>
3097   * <p>
3098   * Description: <b>Code that identifies the allergy or intolerance</b><br>
3099   * Type: <b>token</b><br>
3100   * Path: <b>AllergyIntolerance.code,
3101   * AllergyIntolerance.reaction.substance</b><br>
3102   * </p>
3103   */
3104  @SearchParamDefinition(name = "code", path = "AllergyIntolerance.code | AllergyIntolerance.reaction.substance", description = "Code that identifies the allergy or intolerance", type = "token")
3105  public static final String SP_CODE = "code";
3106  /**
3107   * <b>Fluent Client</b> search parameter constant for <b>code</b>
3108   * <p>
3109   * Description: <b>Code that identifies the allergy or intolerance</b><br>
3110   * Type: <b>token</b><br>
3111   * Path: <b>AllergyIntolerance.code,
3112   * AllergyIntolerance.reaction.substance</b><br>
3113   * </p>
3114   */
3115  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(
3116      SP_CODE);
3117
3118  /**
3119   * Search parameter: <b>verification-status</b>
3120   * <p>
3121   * Description: <b>unconfirmed | confirmed | refuted | entered-in-error</b><br>
3122   * Type: <b>token</b><br>
3123   * Path: <b>AllergyIntolerance.verificationStatus</b><br>
3124   * </p>
3125   */
3126  @SearchParamDefinition(name = "verification-status", path = "AllergyIntolerance.verificationStatus", description = "unconfirmed | confirmed | refuted | entered-in-error", type = "token")
3127  public static final String SP_VERIFICATION_STATUS = "verification-status";
3128  /**
3129   * <b>Fluent Client</b> search parameter constant for <b>verification-status</b>
3130   * <p>
3131   * Description: <b>unconfirmed | confirmed | refuted | entered-in-error</b><br>
3132   * Type: <b>token</b><br>
3133   * Path: <b>AllergyIntolerance.verificationStatus</b><br>
3134   * </p>
3135   */
3136  public static final ca.uhn.fhir.rest.gclient.TokenClientParam VERIFICATION_STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(
3137      SP_VERIFICATION_STATUS);
3138
3139  /**
3140   * Search parameter: <b>criticality</b>
3141   * <p>
3142   * Description: <b>low | high | unable-to-assess</b><br>
3143   * Type: <b>token</b><br>
3144   * Path: <b>AllergyIntolerance.criticality</b><br>
3145   * </p>
3146   */
3147  @SearchParamDefinition(name = "criticality", path = "AllergyIntolerance.criticality", description = "low | high | unable-to-assess", type = "token")
3148  public static final String SP_CRITICALITY = "criticality";
3149  /**
3150   * <b>Fluent Client</b> search parameter constant for <b>criticality</b>
3151   * <p>
3152   * Description: <b>low | high | unable-to-assess</b><br>
3153   * Type: <b>token</b><br>
3154   * Path: <b>AllergyIntolerance.criticality</b><br>
3155   * </p>
3156   */
3157  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CRITICALITY = new ca.uhn.fhir.rest.gclient.TokenClientParam(
3158      SP_CRITICALITY);
3159
3160  /**
3161   * Search parameter: <b>clinical-status</b>
3162   * <p>
3163   * Description: <b>active | inactive | resolved</b><br>
3164   * Type: <b>token</b><br>
3165   * Path: <b>AllergyIntolerance.clinicalStatus</b><br>
3166   * </p>
3167   */
3168  @SearchParamDefinition(name = "clinical-status", path = "AllergyIntolerance.clinicalStatus", description = "active | inactive | resolved", type = "token")
3169  public static final String SP_CLINICAL_STATUS = "clinical-status";
3170  /**
3171   * <b>Fluent Client</b> search parameter constant for <b>clinical-status</b>
3172   * <p>
3173   * Description: <b>active | inactive | resolved</b><br>
3174   * Type: <b>token</b><br>
3175   * Path: <b>AllergyIntolerance.clinicalStatus</b><br>
3176   * </p>
3177   */
3178  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CLINICAL_STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(
3179      SP_CLINICAL_STATUS);
3180
3181  /**
3182   * Search parameter: <b>type</b>
3183   * <p>
3184   * Description: <b>allergy | intolerance - Underlying mechanism (if
3185   * known)</b><br>
3186   * Type: <b>token</b><br>
3187   * Path: <b>AllergyIntolerance.type</b><br>
3188   * </p>
3189   */
3190  @SearchParamDefinition(name = "type", path = "AllergyIntolerance.type", description = "allergy | intolerance - Underlying mechanism (if known)", type = "token")
3191  public static final String SP_TYPE = "type";
3192  /**
3193   * <b>Fluent Client</b> search parameter constant for <b>type</b>
3194   * <p>
3195   * Description: <b>allergy | intolerance - Underlying mechanism (if
3196   * known)</b><br>
3197   * Type: <b>token</b><br>
3198   * Path: <b>AllergyIntolerance.type</b><br>
3199   * </p>
3200   */
3201  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(
3202      SP_TYPE);
3203
3204  /**
3205   * Search parameter: <b>onset</b>
3206   * <p>
3207   * Description: <b>Date(/time) when manifestations showed</b><br>
3208   * Type: <b>date</b><br>
3209   * Path: <b>AllergyIntolerance.reaction.onset</b><br>
3210   * </p>
3211   */
3212  @SearchParamDefinition(name = "onset", path = "AllergyIntolerance.reaction.onset", description = "Date(/time) when manifestations showed", type = "date")
3213  public static final String SP_ONSET = "onset";
3214  /**
3215   * <b>Fluent Client</b> search parameter constant for <b>onset</b>
3216   * <p>
3217   * Description: <b>Date(/time) when manifestations showed</b><br>
3218   * Type: <b>date</b><br>
3219   * Path: <b>AllergyIntolerance.reaction.onset</b><br>
3220   * </p>
3221   */
3222  public static final ca.uhn.fhir.rest.gclient.DateClientParam ONSET = new ca.uhn.fhir.rest.gclient.DateClientParam(
3223      SP_ONSET);
3224
3225  /**
3226   * Search parameter: <b>route</b>
3227   * <p>
3228   * Description: <b>How the subject was exposed to the substance</b><br>
3229   * Type: <b>token</b><br>
3230   * Path: <b>AllergyIntolerance.reaction.exposureRoute</b><br>
3231   * </p>
3232   */
3233  @SearchParamDefinition(name = "route", path = "AllergyIntolerance.reaction.exposureRoute", description = "How the subject was exposed to the substance", type = "token")
3234  public static final String SP_ROUTE = "route";
3235  /**
3236   * <b>Fluent Client</b> search parameter constant for <b>route</b>
3237   * <p>
3238   * Description: <b>How the subject was exposed to the substance</b><br>
3239   * Type: <b>token</b><br>
3240   * Path: <b>AllergyIntolerance.reaction.exposureRoute</b><br>
3241   * </p>
3242   */
3243  public static final ca.uhn.fhir.rest.gclient.TokenClientParam ROUTE = new ca.uhn.fhir.rest.gclient.TokenClientParam(
3244      SP_ROUTE);
3245
3246  /**
3247   * Search parameter: <b>asserter</b>
3248   * <p>
3249   * Description: <b>Source of the information about the allergy</b><br>
3250   * Type: <b>reference</b><br>
3251   * Path: <b>AllergyIntolerance.asserter</b><br>
3252   * </p>
3253   */
3254  @SearchParamDefinition(name = "asserter", path = "AllergyIntolerance.asserter", description = "Source of the information about the allergy", type = "reference", providesMembershipIn = {
3255      @ca.uhn.fhir.model.api.annotation.Compartment(name = "Patient"),
3256      @ca.uhn.fhir.model.api.annotation.Compartment(name = "Practitioner"),
3257      @ca.uhn.fhir.model.api.annotation.Compartment(name = "RelatedPerson") }, target = { Patient.class,
3258          Practitioner.class, PractitionerRole.class, RelatedPerson.class })
3259  public static final String SP_ASSERTER = "asserter";
3260  /**
3261   * <b>Fluent Client</b> search parameter constant for <b>asserter</b>
3262   * <p>
3263   * Description: <b>Source of the information about the allergy</b><br>
3264   * Type: <b>reference</b><br>
3265   * Path: <b>AllergyIntolerance.asserter</b><br>
3266   * </p>
3267   */
3268  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ASSERTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
3269      SP_ASSERTER);
3270
3271  /**
3272   * Constant for fluent queries to be used to add include statements. Specifies
3273   * the path value of "<b>AllergyIntolerance:asserter</b>".
3274   */
3275  public static final ca.uhn.fhir.model.api.Include INCLUDE_ASSERTER = new ca.uhn.fhir.model.api.Include(
3276      "AllergyIntolerance:asserter").toLocked();
3277
3278  /**
3279   * Search parameter: <b>patient</b>
3280   * <p>
3281   * Description: <b>Who the sensitivity is for</b><br>
3282   * Type: <b>reference</b><br>
3283   * Path: <b>AllergyIntolerance.patient</b><br>
3284   * </p>
3285   */
3286  @SearchParamDefinition(name = "patient", path = "AllergyIntolerance.patient", description = "Who the sensitivity is for", type = "reference", providesMembershipIn = {
3287      @ca.uhn.fhir.model.api.annotation.Compartment(name = "Patient") }, target = { Patient.class })
3288  public static final String SP_PATIENT = "patient";
3289  /**
3290   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
3291   * <p>
3292   * Description: <b>Who the sensitivity is for</b><br>
3293   * Type: <b>reference</b><br>
3294   * Path: <b>AllergyIntolerance.patient</b><br>
3295   * </p>
3296   */
3297  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
3298      SP_PATIENT);
3299
3300  /**
3301   * Constant for fluent queries to be used to add include statements. Specifies
3302   * the path value of "<b>AllergyIntolerance:patient</b>".
3303   */
3304  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include(
3305      "AllergyIntolerance:patient").toLocked();
3306
3307  /**
3308   * Search parameter: <b>category</b>
3309   * <p>
3310   * Description: <b>food | medication | environment | biologic</b><br>
3311   * Type: <b>token</b><br>
3312   * Path: <b>AllergyIntolerance.category</b><br>
3313   * </p>
3314   */
3315  @SearchParamDefinition(name = "category", path = "AllergyIntolerance.category", description = "food | medication | environment | biologic", type = "token")
3316  public static final String SP_CATEGORY = "category";
3317  /**
3318   * <b>Fluent Client</b> search parameter constant for <b>category</b>
3319   * <p>
3320   * Description: <b>food | medication | environment | biologic</b><br>
3321   * Type: <b>token</b><br>
3322   * Path: <b>AllergyIntolerance.category</b><br>
3323   * </p>
3324   */
3325  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CATEGORY = new ca.uhn.fhir.rest.gclient.TokenClientParam(
3326      SP_CATEGORY);
3327
3328  /**
3329   * Search parameter: <b>last-date</b>
3330   * <p>
3331   * Description: <b>Date(/time) of last known occurrence of a reaction</b><br>
3332   * Type: <b>date</b><br>
3333   * Path: <b>AllergyIntolerance.lastOccurrence</b><br>
3334   * </p>
3335   */
3336  @SearchParamDefinition(name = "last-date", path = "AllergyIntolerance.lastOccurrence", description = "Date(/time) of last known occurrence of a reaction", type = "date")
3337  public static final String SP_LAST_DATE = "last-date";
3338  /**
3339   * <b>Fluent Client</b> search parameter constant for <b>last-date</b>
3340   * <p>
3341   * Description: <b>Date(/time) of last known occurrence of a reaction</b><br>
3342   * Type: <b>date</b><br>
3343   * Path: <b>AllergyIntolerance.lastOccurrence</b><br>
3344   * </p>
3345   */
3346  public static final ca.uhn.fhir.rest.gclient.DateClientParam LAST_DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(
3347      SP_LAST_DATE);
3348
3349}