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