001package org.hl7.fhir.instance.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 Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
033import java.util.*;
034
035import org.hl7.fhir.exceptions.FHIRException;
036import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
037import org.hl7.fhir.utilities.Utilities;
038
039import ca.uhn.fhir.model.api.annotation.*;
040/**
041 * Risk of harmful or undesirable, physiological response which is unique to an individual and associated with exposure to a substance.
042 */
043@ResourceDef(name="AllergyIntolerance", profile="http://hl7.org/fhir/Profile/AllergyIntolerance")
044public class AllergyIntolerance extends DomainResource {
045
046    public enum AllergyIntoleranceStatus {
047        /**
048         * An active record of a reaction to the identified Substance.
049         */
050        ACTIVE, 
051        /**
052         * A low level of certainty about the propensity for a reaction to the identified Substance.
053         */
054        UNCONFIRMED, 
055        /**
056         * A high level of certainty about the propensity for a reaction to the identified Substance, which may include clinical evidence by testing or rechallenge.
057         */
058        CONFIRMED, 
059        /**
060         * An inactive record of a reaction to the identified Substance.
061         */
062        INACTIVE, 
063        /**
064         * A reaction to the identified Substance has been clinically reassessed by testing or rechallenge and considered to be resolved.
065         */
066        RESOLVED, 
067        /**
068         * A propensity for a reaction to the identified Substance has been disproven with a high level of clinical certainty, which may include testing or rechallenge, and is refuted.
069         */
070        REFUTED, 
071        /**
072         * The statement was entered in error and is not valid.
073         */
074        ENTEREDINERROR, 
075        /**
076         * added to help the parsers
077         */
078        NULL;
079        public static AllergyIntoleranceStatus fromCode(String codeString) throws FHIRException {
080            if (codeString == null || "".equals(codeString))
081                return null;
082        if ("active".equals(codeString))
083          return ACTIVE;
084        if ("unconfirmed".equals(codeString))
085          return UNCONFIRMED;
086        if ("confirmed".equals(codeString))
087          return CONFIRMED;
088        if ("inactive".equals(codeString))
089          return INACTIVE;
090        if ("resolved".equals(codeString))
091          return RESOLVED;
092        if ("refuted".equals(codeString))
093          return REFUTED;
094        if ("entered-in-error".equals(codeString))
095          return ENTEREDINERROR;
096        throw new FHIRException("Unknown AllergyIntoleranceStatus code '"+codeString+"'");
097        }
098        public String toCode() {
099          switch (this) {
100            case ACTIVE: return "active";
101            case UNCONFIRMED: return "unconfirmed";
102            case CONFIRMED: return "confirmed";
103            case INACTIVE: return "inactive";
104            case RESOLVED: return "resolved";
105            case REFUTED: return "refuted";
106            case ENTEREDINERROR: return "entered-in-error";
107            default: return "?";
108          }
109        }
110        public String getSystem() {
111          switch (this) {
112            case ACTIVE: return "http://hl7.org/fhir/allergy-intolerance-status";
113            case UNCONFIRMED: return "http://hl7.org/fhir/allergy-intolerance-status";
114            case CONFIRMED: return "http://hl7.org/fhir/allergy-intolerance-status";
115            case INACTIVE: return "http://hl7.org/fhir/allergy-intolerance-status";
116            case RESOLVED: return "http://hl7.org/fhir/allergy-intolerance-status";
117            case REFUTED: return "http://hl7.org/fhir/allergy-intolerance-status";
118            case ENTEREDINERROR: return "http://hl7.org/fhir/allergy-intolerance-status";
119            default: return "?";
120          }
121        }
122        public String getDefinition() {
123          switch (this) {
124            case ACTIVE: return "An active record of a reaction to the identified Substance.";
125            case UNCONFIRMED: return "A low level of certainty about the propensity for a reaction to the identified Substance.";
126            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.";
127            case INACTIVE: return "An inactive record of a reaction to the identified Substance.";
128            case RESOLVED: return "A reaction to the identified Substance has been clinically reassessed by testing or rechallenge and considered to be resolved.";
129            case REFUTED: return "A propensity for a reaction to the identified Substance has been disproven with a high level of clinical certainty, which may include testing or rechallenge, and is refuted.";
130            case ENTEREDINERROR: return "The statement was entered in error and is not valid.";
131            default: return "?";
132          }
133        }
134        public String getDisplay() {
135          switch (this) {
136            case ACTIVE: return "Active";
137            case UNCONFIRMED: return "Unconfirmed";
138            case CONFIRMED: return "Confirmed";
139            case INACTIVE: return "Inactive";
140            case RESOLVED: return "Resolved";
141            case REFUTED: return "Refuted";
142            case ENTEREDINERROR: return "Entered In Error";
143            default: return "?";
144          }
145        }
146    }
147
148  public static class AllergyIntoleranceStatusEnumFactory implements EnumFactory<AllergyIntoleranceStatus> {
149    public AllergyIntoleranceStatus fromCode(String codeString) throws IllegalArgumentException {
150      if (codeString == null || "".equals(codeString))
151            if (codeString == null || "".equals(codeString))
152                return null;
153        if ("active".equals(codeString))
154          return AllergyIntoleranceStatus.ACTIVE;
155        if ("unconfirmed".equals(codeString))
156          return AllergyIntoleranceStatus.UNCONFIRMED;
157        if ("confirmed".equals(codeString))
158          return AllergyIntoleranceStatus.CONFIRMED;
159        if ("inactive".equals(codeString))
160          return AllergyIntoleranceStatus.INACTIVE;
161        if ("resolved".equals(codeString))
162          return AllergyIntoleranceStatus.RESOLVED;
163        if ("refuted".equals(codeString))
164          return AllergyIntoleranceStatus.REFUTED;
165        if ("entered-in-error".equals(codeString))
166          return AllergyIntoleranceStatus.ENTEREDINERROR;
167        throw new IllegalArgumentException("Unknown AllergyIntoleranceStatus code '"+codeString+"'");
168        }
169        public Enumeration<AllergyIntoleranceStatus> fromType(Base code) throws FHIRException {
170          if (code == null || code.isEmpty())
171            return null;
172          String codeString = ((PrimitiveType) code).asStringValue();
173          if (codeString == null || "".equals(codeString))
174            return null;
175        if ("active".equals(codeString))
176          return new Enumeration<AllergyIntoleranceStatus>(this, AllergyIntoleranceStatus.ACTIVE);
177        if ("unconfirmed".equals(codeString))
178          return new Enumeration<AllergyIntoleranceStatus>(this, AllergyIntoleranceStatus.UNCONFIRMED);
179        if ("confirmed".equals(codeString))
180          return new Enumeration<AllergyIntoleranceStatus>(this, AllergyIntoleranceStatus.CONFIRMED);
181        if ("inactive".equals(codeString))
182          return new Enumeration<AllergyIntoleranceStatus>(this, AllergyIntoleranceStatus.INACTIVE);
183        if ("resolved".equals(codeString))
184          return new Enumeration<AllergyIntoleranceStatus>(this, AllergyIntoleranceStatus.RESOLVED);
185        if ("refuted".equals(codeString))
186          return new Enumeration<AllergyIntoleranceStatus>(this, AllergyIntoleranceStatus.REFUTED);
187        if ("entered-in-error".equals(codeString))
188          return new Enumeration<AllergyIntoleranceStatus>(this, AllergyIntoleranceStatus.ENTEREDINERROR);
189        throw new FHIRException("Unknown AllergyIntoleranceStatus code '"+codeString+"'");
190        }
191    public String toCode(AllergyIntoleranceStatus code) {
192      if (code == AllergyIntoleranceStatus.ACTIVE)
193        return "active";
194      if (code == AllergyIntoleranceStatus.UNCONFIRMED)
195        return "unconfirmed";
196      if (code == AllergyIntoleranceStatus.CONFIRMED)
197        return "confirmed";
198      if (code == AllergyIntoleranceStatus.INACTIVE)
199        return "inactive";
200      if (code == AllergyIntoleranceStatus.RESOLVED)
201        return "resolved";
202      if (code == AllergyIntoleranceStatus.REFUTED)
203        return "refuted";
204      if (code == AllergyIntoleranceStatus.ENTEREDINERROR)
205        return "entered-in-error";
206      return "?";
207      }
208    }
209
210    public enum AllergyIntoleranceCriticality {
211        /**
212         * The potential clinical impact of a future reaction is estimated as low risk: exposure to substance is unlikely to result in a life threatening or organ system threatening outcome. Future exposure to the Substance is considered a relative contra-indication.
213         */
214        CRITL, 
215        /**
216         * The potential clinical impact of a future reaction is estimated as high risk: exposure to substance may result in a life threatening or organ system threatening outcome. Future exposure to the Substance may be considered an absolute contra-indication.
217         */
218        CRITH, 
219        /**
220         * Unable to assess the potential clinical impact with the information available.
221         */
222        CRITU, 
223        /**
224         * added to help the parsers
225         */
226        NULL;
227        public static AllergyIntoleranceCriticality fromCode(String codeString) throws FHIRException {
228            if (codeString == null || "".equals(codeString))
229                return null;
230        if ("CRITL".equals(codeString))
231          return CRITL;
232        if ("CRITH".equals(codeString))
233          return CRITH;
234        if ("CRITU".equals(codeString))
235          return CRITU;
236        throw new FHIRException("Unknown AllergyIntoleranceCriticality code '"+codeString+"'");
237        }
238        public String toCode() {
239          switch (this) {
240            case CRITL: return "CRITL";
241            case CRITH: return "CRITH";
242            case CRITU: return "CRITU";
243            default: return "?";
244          }
245        }
246        public String getSystem() {
247          switch (this) {
248            case CRITL: return "http://hl7.org/fhir/allergy-intolerance-criticality";
249            case CRITH: return "http://hl7.org/fhir/allergy-intolerance-criticality";
250            case CRITU: return "http://hl7.org/fhir/allergy-intolerance-criticality";
251            default: return "?";
252          }
253        }
254        public String getDefinition() {
255          switch (this) {
256            case CRITL: return "The potential clinical impact of a future reaction is estimated as low risk: exposure to substance is unlikely to result in a life threatening or organ system threatening outcome. Future exposure to the Substance is considered a relative contra-indication.";
257            case CRITH: return "The potential clinical impact of a future reaction is estimated as high risk: exposure to substance may result in a life threatening or organ system threatening outcome. Future exposure to the Substance may be considered an absolute contra-indication.";
258            case CRITU: return "Unable to assess the potential clinical impact with the information available.";
259            default: return "?";
260          }
261        }
262        public String getDisplay() {
263          switch (this) {
264            case CRITL: return "Low Risk";
265            case CRITH: return "High Risk";
266            case CRITU: return "Unable to determine";
267            default: return "?";
268          }
269        }
270    }
271
272  public static class AllergyIntoleranceCriticalityEnumFactory implements EnumFactory<AllergyIntoleranceCriticality> {
273    public AllergyIntoleranceCriticality fromCode(String codeString) throws IllegalArgumentException {
274      if (codeString == null || "".equals(codeString))
275            if (codeString == null || "".equals(codeString))
276                return null;
277        if ("CRITL".equals(codeString))
278          return AllergyIntoleranceCriticality.CRITL;
279        if ("CRITH".equals(codeString))
280          return AllergyIntoleranceCriticality.CRITH;
281        if ("CRITU".equals(codeString))
282          return AllergyIntoleranceCriticality.CRITU;
283        throw new IllegalArgumentException("Unknown AllergyIntoleranceCriticality code '"+codeString+"'");
284        }
285        public Enumeration<AllergyIntoleranceCriticality> fromType(Base code) throws FHIRException {
286          if (code == null || code.isEmpty())
287            return null;
288          String codeString = ((PrimitiveType) code).asStringValue();
289          if (codeString == null || "".equals(codeString))
290            return null;
291        if ("CRITL".equals(codeString))
292          return new Enumeration<AllergyIntoleranceCriticality>(this, AllergyIntoleranceCriticality.CRITL);
293        if ("CRITH".equals(codeString))
294          return new Enumeration<AllergyIntoleranceCriticality>(this, AllergyIntoleranceCriticality.CRITH);
295        if ("CRITU".equals(codeString))
296          return new Enumeration<AllergyIntoleranceCriticality>(this, AllergyIntoleranceCriticality.CRITU);
297        throw new FHIRException("Unknown AllergyIntoleranceCriticality code '"+codeString+"'");
298        }
299    public String toCode(AllergyIntoleranceCriticality code) {
300      if (code == AllergyIntoleranceCriticality.CRITL)
301        return "CRITL";
302      if (code == AllergyIntoleranceCriticality.CRITH)
303        return "CRITH";
304      if (code == AllergyIntoleranceCriticality.CRITU)
305        return "CRITU";
306      return "?";
307      }
308    }
309
310    public enum AllergyIntoleranceType {
311        /**
312         * A propensity for hypersensitivity reaction(s) to a substance.  These reactions are most typically type I hypersensitivity, plus other "allergy-like" reactions, including pseudoallergy.
313         */
314        ALLERGY, 
315        /**
316         * 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).
317         */
318        INTOLERANCE, 
319        /**
320         * added to help the parsers
321         */
322        NULL;
323        public static AllergyIntoleranceType fromCode(String codeString) throws FHIRException {
324            if (codeString == null || "".equals(codeString))
325                return null;
326        if ("allergy".equals(codeString))
327          return ALLERGY;
328        if ("intolerance".equals(codeString))
329          return INTOLERANCE;
330        throw new FHIRException("Unknown AllergyIntoleranceType code '"+codeString+"'");
331        }
332        public String toCode() {
333          switch (this) {
334            case ALLERGY: return "allergy";
335            case INTOLERANCE: return "intolerance";
336            default: return "?";
337          }
338        }
339        public String getSystem() {
340          switch (this) {
341            case ALLERGY: return "http://hl7.org/fhir/allergy-intolerance-type";
342            case INTOLERANCE: return "http://hl7.org/fhir/allergy-intolerance-type";
343            default: return "?";
344          }
345        }
346        public String getDefinition() {
347          switch (this) {
348            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.";
349            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).";
350            default: return "?";
351          }
352        }
353        public String getDisplay() {
354          switch (this) {
355            case ALLERGY: return "Allergy";
356            case INTOLERANCE: return "Intolerance";
357            default: return "?";
358          }
359        }
360    }
361
362  public static class AllergyIntoleranceTypeEnumFactory implements EnumFactory<AllergyIntoleranceType> {
363    public AllergyIntoleranceType fromCode(String codeString) throws IllegalArgumentException {
364      if (codeString == null || "".equals(codeString))
365            if (codeString == null || "".equals(codeString))
366                return null;
367        if ("allergy".equals(codeString))
368          return AllergyIntoleranceType.ALLERGY;
369        if ("intolerance".equals(codeString))
370          return AllergyIntoleranceType.INTOLERANCE;
371        throw new IllegalArgumentException("Unknown AllergyIntoleranceType code '"+codeString+"'");
372        }
373        public Enumeration<AllergyIntoleranceType> fromType(Base code) throws FHIRException {
374          if (code == null || code.isEmpty())
375            return null;
376          String codeString = ((PrimitiveType) code).asStringValue();
377          if (codeString == null || "".equals(codeString))
378            return null;
379        if ("allergy".equals(codeString))
380          return new Enumeration<AllergyIntoleranceType>(this, AllergyIntoleranceType.ALLERGY);
381        if ("intolerance".equals(codeString))
382          return new Enumeration<AllergyIntoleranceType>(this, AllergyIntoleranceType.INTOLERANCE);
383        throw new FHIRException("Unknown AllergyIntoleranceType code '"+codeString+"'");
384        }
385    public String toCode(AllergyIntoleranceType code) {
386      if (code == AllergyIntoleranceType.ALLERGY)
387        return "allergy";
388      if (code == AllergyIntoleranceType.INTOLERANCE)
389        return "intolerance";
390      return "?";
391      }
392    }
393
394    public enum AllergyIntoleranceCategory {
395        /**
396         * Any substance consumed to provide nutritional support for the body.
397         */
398        FOOD, 
399        /**
400         * Substances administered to achieve a physiological effect.
401         */
402        MEDICATION, 
403        /**
404         * Substances that are encountered in the environment.
405         */
406        ENVIRONMENT, 
407        /**
408         * Other substances that are not covered by any other category.
409         */
410        OTHER, 
411        /**
412         * added to help the parsers
413         */
414        NULL;
415        public static AllergyIntoleranceCategory fromCode(String codeString) throws FHIRException {
416            if (codeString == null || "".equals(codeString))
417                return null;
418        if ("food".equals(codeString))
419          return FOOD;
420        if ("medication".equals(codeString))
421          return MEDICATION;
422        if ("environment".equals(codeString))
423          return ENVIRONMENT;
424        if ("other".equals(codeString))
425          return OTHER;
426        throw new FHIRException("Unknown AllergyIntoleranceCategory code '"+codeString+"'");
427        }
428        public String toCode() {
429          switch (this) {
430            case FOOD: return "food";
431            case MEDICATION: return "medication";
432            case ENVIRONMENT: return "environment";
433            case OTHER: return "other";
434            default: return "?";
435          }
436        }
437        public String getSystem() {
438          switch (this) {
439            case FOOD: return "http://hl7.org/fhir/allergy-intolerance-category";
440            case MEDICATION: return "http://hl7.org/fhir/allergy-intolerance-category";
441            case ENVIRONMENT: return "http://hl7.org/fhir/allergy-intolerance-category";
442            case OTHER: return "http://hl7.org/fhir/allergy-intolerance-category";
443            default: return "?";
444          }
445        }
446        public String getDefinition() {
447          switch (this) {
448            case FOOD: return "Any substance consumed to provide nutritional support for the body.";
449            case MEDICATION: return "Substances administered to achieve a physiological effect.";
450            case ENVIRONMENT: return "Substances that are encountered in the environment.";
451            case OTHER: return "Other substances that are not covered by any other category.";
452            default: return "?";
453          }
454        }
455        public String getDisplay() {
456          switch (this) {
457            case FOOD: return "Food";
458            case MEDICATION: return "Medication";
459            case ENVIRONMENT: return "Environment";
460            case OTHER: return "Other";
461            default: return "?";
462          }
463        }
464    }
465
466  public static class AllergyIntoleranceCategoryEnumFactory implements EnumFactory<AllergyIntoleranceCategory> {
467    public AllergyIntoleranceCategory fromCode(String codeString) throws IllegalArgumentException {
468      if (codeString == null || "".equals(codeString))
469            if (codeString == null || "".equals(codeString))
470                return null;
471        if ("food".equals(codeString))
472          return AllergyIntoleranceCategory.FOOD;
473        if ("medication".equals(codeString))
474          return AllergyIntoleranceCategory.MEDICATION;
475        if ("environment".equals(codeString))
476          return AllergyIntoleranceCategory.ENVIRONMENT;
477        if ("other".equals(codeString))
478          return AllergyIntoleranceCategory.OTHER;
479        throw new IllegalArgumentException("Unknown AllergyIntoleranceCategory code '"+codeString+"'");
480        }
481        public Enumeration<AllergyIntoleranceCategory> fromType(Base code) throws FHIRException {
482          if (code == null || code.isEmpty())
483            return null;
484          String codeString = ((PrimitiveType) code).asStringValue();
485          if (codeString == null || "".equals(codeString))
486            return null;
487        if ("food".equals(codeString))
488          return new Enumeration<AllergyIntoleranceCategory>(this, AllergyIntoleranceCategory.FOOD);
489        if ("medication".equals(codeString))
490          return new Enumeration<AllergyIntoleranceCategory>(this, AllergyIntoleranceCategory.MEDICATION);
491        if ("environment".equals(codeString))
492          return new Enumeration<AllergyIntoleranceCategory>(this, AllergyIntoleranceCategory.ENVIRONMENT);
493        if ("other".equals(codeString))
494          return new Enumeration<AllergyIntoleranceCategory>(this, AllergyIntoleranceCategory.OTHER);
495        throw new FHIRException("Unknown AllergyIntoleranceCategory code '"+codeString+"'");
496        }
497    public String toCode(AllergyIntoleranceCategory code) {
498      if (code == AllergyIntoleranceCategory.FOOD)
499        return "food";
500      if (code == AllergyIntoleranceCategory.MEDICATION)
501        return "medication";
502      if (code == AllergyIntoleranceCategory.ENVIRONMENT)
503        return "environment";
504      if (code == AllergyIntoleranceCategory.OTHER)
505        return "other";
506      return "?";
507      }
508    }
509
510    public enum AllergyIntoleranceCertainty {
511        /**
512         * There is a low level of clinical certainty that the reaction was caused by the identified Substance.
513         */
514        UNLIKELY, 
515        /**
516         * There is a high level of clinical certainty that the reaction was caused by the identified Substance.
517         */
518        LIKELY, 
519        /**
520         * There is a very high level of clinical certainty that the reaction was due to the identified Substance, which may include clinical evidence by testing or rechallenge.
521         */
522        CONFIRMED, 
523        /**
524         * added to help the parsers
525         */
526        NULL;
527        public static AllergyIntoleranceCertainty fromCode(String codeString) throws FHIRException {
528            if (codeString == null || "".equals(codeString))
529                return null;
530        if ("unlikely".equals(codeString))
531          return UNLIKELY;
532        if ("likely".equals(codeString))
533          return LIKELY;
534        if ("confirmed".equals(codeString))
535          return CONFIRMED;
536        throw new FHIRException("Unknown AllergyIntoleranceCertainty code '"+codeString+"'");
537        }
538        public String toCode() {
539          switch (this) {
540            case UNLIKELY: return "unlikely";
541            case LIKELY: return "likely";
542            case CONFIRMED: return "confirmed";
543            default: return "?";
544          }
545        }
546        public String getSystem() {
547          switch (this) {
548            case UNLIKELY: return "http://hl7.org/fhir/reaction-event-certainty";
549            case LIKELY: return "http://hl7.org/fhir/reaction-event-certainty";
550            case CONFIRMED: return "http://hl7.org/fhir/reaction-event-certainty";
551            default: return "?";
552          }
553        }
554        public String getDefinition() {
555          switch (this) {
556            case UNLIKELY: return "There is a low level of clinical certainty that the reaction was caused by the identified Substance.";
557            case LIKELY: return "There is a high level of clinical certainty that the reaction was caused by the identified Substance.";
558            case CONFIRMED: return "There is a very high level of clinical certainty that the reaction was due to the identified Substance, which may include clinical evidence by testing or rechallenge.";
559            default: return "?";
560          }
561        }
562        public String getDisplay() {
563          switch (this) {
564            case UNLIKELY: return "Unlikely";
565            case LIKELY: return "Likely";
566            case CONFIRMED: return "Confirmed";
567            default: return "?";
568          }
569        }
570    }
571
572  public static class AllergyIntoleranceCertaintyEnumFactory implements EnumFactory<AllergyIntoleranceCertainty> {
573    public AllergyIntoleranceCertainty fromCode(String codeString) throws IllegalArgumentException {
574      if (codeString == null || "".equals(codeString))
575            if (codeString == null || "".equals(codeString))
576                return null;
577        if ("unlikely".equals(codeString))
578          return AllergyIntoleranceCertainty.UNLIKELY;
579        if ("likely".equals(codeString))
580          return AllergyIntoleranceCertainty.LIKELY;
581        if ("confirmed".equals(codeString))
582          return AllergyIntoleranceCertainty.CONFIRMED;
583        throw new IllegalArgumentException("Unknown AllergyIntoleranceCertainty code '"+codeString+"'");
584        }
585        public Enumeration<AllergyIntoleranceCertainty> fromType(Base code) throws FHIRException {
586          if (code == null || code.isEmpty())
587            return null;
588          String codeString = ((PrimitiveType) code).asStringValue();
589          if (codeString == null || "".equals(codeString))
590            return null;
591        if ("unlikely".equals(codeString))
592          return new Enumeration<AllergyIntoleranceCertainty>(this, AllergyIntoleranceCertainty.UNLIKELY);
593        if ("likely".equals(codeString))
594          return new Enumeration<AllergyIntoleranceCertainty>(this, AllergyIntoleranceCertainty.LIKELY);
595        if ("confirmed".equals(codeString))
596          return new Enumeration<AllergyIntoleranceCertainty>(this, AllergyIntoleranceCertainty.CONFIRMED);
597        throw new FHIRException("Unknown AllergyIntoleranceCertainty code '"+codeString+"'");
598        }
599    public String toCode(AllergyIntoleranceCertainty code) {
600      if (code == AllergyIntoleranceCertainty.UNLIKELY)
601        return "unlikely";
602      if (code == AllergyIntoleranceCertainty.LIKELY)
603        return "likely";
604      if (code == AllergyIntoleranceCertainty.CONFIRMED)
605        return "confirmed";
606      return "?";
607      }
608    }
609
610    public enum AllergyIntoleranceSeverity {
611        /**
612         * Causes mild physiological effects.
613         */
614        MILD, 
615        /**
616         * Causes moderate physiological effects.
617         */
618        MODERATE, 
619        /**
620         * Causes severe physiological effects.
621         */
622        SEVERE, 
623        /**
624         * added to help the parsers
625         */
626        NULL;
627        public static AllergyIntoleranceSeverity fromCode(String codeString) throws FHIRException {
628            if (codeString == null || "".equals(codeString))
629                return null;
630        if ("mild".equals(codeString))
631          return MILD;
632        if ("moderate".equals(codeString))
633          return MODERATE;
634        if ("severe".equals(codeString))
635          return SEVERE;
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 || code.isEmpty())
687            return null;
688          String codeString = ((PrimitiveType) code).asStringValue();
689          if (codeString == null || "".equals(codeString))
690            return null;
691        if ("mild".equals(codeString))
692          return new Enumeration<AllergyIntoleranceSeverity>(this, AllergyIntoleranceSeverity.MILD);
693        if ("moderate".equals(codeString))
694          return new Enumeration<AllergyIntoleranceSeverity>(this, AllergyIntoleranceSeverity.MODERATE);
695        if ("severe".equals(codeString))
696          return new Enumeration<AllergyIntoleranceSeverity>(this, AllergyIntoleranceSeverity.SEVERE);
697        throw new FHIRException("Unknown AllergyIntoleranceSeverity code '"+codeString+"'");
698        }
699    public String toCode(AllergyIntoleranceSeverity code) {
700      if (code == AllergyIntoleranceSeverity.MILD)
701        return "mild";
702      if (code == AllergyIntoleranceSeverity.MODERATE)
703        return "moderate";
704      if (code == AllergyIntoleranceSeverity.SEVERE)
705        return "severe";
706      return "?";
707      }
708    }
709
710    @Block()
711    public static class AllergyIntoleranceReactionComponent extends BackboneElement implements IBaseBackboneElement {
712        /**
713         * Identification of the specific substance considered to be responsible for the Adverse Reaction event. Note: the substance for a specific reaction may be different to the substance identified as the cause of the risk, but must be consistent with it. For instance, it may be a more specific substance (e.g. a brand medication) or a composite substance that includes the identified substance. It must be clinically safe to only process the AllergyIntolerance.substance and ignore the AllergyIntolerance.event.substance.
714         */
715        @Child(name = "substance", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
716        @Description(shortDefinition="Specific substance considered to be responsible for event", formalDefinition="Identification of the specific substance considered to be responsible for the Adverse Reaction event. Note: the substance for a specific reaction may be different to the substance identified as the cause of the risk, but must be consistent with it. For instance, it may be a more specific substance (e.g. a brand medication) or a composite substance that includes the identified substance. It must be clinically safe to only process the AllergyIntolerance.substance and ignore the AllergyIntolerance.event.substance." )
717        protected CodeableConcept substance;
718
719        /**
720         * Statement about the degree of clinical certainty that the specific substance was the cause of the manifestation in this reaction event.
721         */
722        @Child(name = "certainty", type = {CodeType.class}, order=2, min=0, max=1, modifier=false, summary=true)
723        @Description(shortDefinition="unlikely | likely | confirmed - clinical certainty about the specific substance", formalDefinition="Statement about the degree of clinical certainty that the specific substance was the cause of the manifestation in this reaction event." )
724        protected Enumeration<AllergyIntoleranceCertainty> certainty;
725
726        /**
727         * Clinical symptoms and/or signs that are observed or associated with the adverse reaction event.
728         */
729        @Child(name = "manifestation", type = {CodeableConcept.class}, order=3, min=1, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
730        @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." )
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=4, 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=5, min=0, max=1, modifier=false, summary=true)
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=6, min=0, max=1, modifier=false, summary=true)
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        protected Enumeration<AllergyIntoleranceSeverity> severity;
753
754        /**
755         * Identification of the route by which the subject was exposed to the substance.
756         */
757        @Child(name = "exposureRoute", type = {CodeableConcept.class}, order=7, min=0, max=1, modifier=false, summary=true)
758        @Description(shortDefinition="How the subject was exposed to the substance", formalDefinition="Identification of the route by which the subject was exposed to the substance." )
759        protected CodeableConcept exposureRoute;
760
761        /**
762         * Additional text about the adverse reaction event not captured in other fields.
763         */
764        @Child(name = "note", type = {Annotation.class}, order=8, min=0, max=1, modifier=false, summary=false)
765        @Description(shortDefinition="Text about event not captured in other fields", formalDefinition="Additional text about the adverse reaction event not captured in other fields." )
766        protected Annotation note;
767
768        private static final long serialVersionUID = -765664367L;
769
770    /*
771     * Constructor
772     */
773      public AllergyIntoleranceReactionComponent() {
774        super();
775      }
776
777        /**
778         * @return {@link #substance} (Identification of the specific substance considered to be responsible for the Adverse Reaction event. Note: the substance for a specific reaction may be different to the substance identified as the cause of the risk, but must be consistent with it. For instance, it may be a more specific substance (e.g. a brand medication) or a composite substance that includes the identified substance. It must be clinically safe to only process the AllergyIntolerance.substance and ignore the AllergyIntolerance.event.substance.)
779         */
780        public CodeableConcept getSubstance() { 
781          if (this.substance == null)
782            if (Configuration.errorOnAutoCreate())
783              throw new Error("Attempt to auto-create AllergyIntoleranceReactionComponent.substance");
784            else if (Configuration.doAutoCreate())
785              this.substance = new CodeableConcept(); // cc
786          return this.substance;
787        }
788
789        public boolean hasSubstance() { 
790          return this.substance != null && !this.substance.isEmpty();
791        }
792
793        /**
794         * @param value {@link #substance} (Identification of the specific substance considered to be responsible for the Adverse Reaction event. Note: the substance for a specific reaction may be different to the substance identified as the cause of the risk, but must be consistent with it. For instance, it may be a more specific substance (e.g. a brand medication) or a composite substance that includes the identified substance. It must be clinically safe to only process the AllergyIntolerance.substance and ignore the AllergyIntolerance.event.substance.)
795         */
796        public AllergyIntoleranceReactionComponent setSubstance(CodeableConcept value) { 
797          this.substance = value;
798          return this;
799        }
800
801        /**
802         * @return {@link #certainty} (Statement about the degree of clinical certainty that the specific substance was the cause of the manifestation in this reaction event.). This is the underlying object with id, value and extensions. The accessor "getCertainty" gives direct access to the value
803         */
804        public Enumeration<AllergyIntoleranceCertainty> getCertaintyElement() { 
805          if (this.certainty == null)
806            if (Configuration.errorOnAutoCreate())
807              throw new Error("Attempt to auto-create AllergyIntoleranceReactionComponent.certainty");
808            else if (Configuration.doAutoCreate())
809              this.certainty = new Enumeration<AllergyIntoleranceCertainty>(new AllergyIntoleranceCertaintyEnumFactory()); // bb
810          return this.certainty;
811        }
812
813        public boolean hasCertaintyElement() { 
814          return this.certainty != null && !this.certainty.isEmpty();
815        }
816
817        public boolean hasCertainty() { 
818          return this.certainty != null && !this.certainty.isEmpty();
819        }
820
821        /**
822         * @param value {@link #certainty} (Statement about the degree of clinical certainty that the specific substance was the cause of the manifestation in this reaction event.). This is the underlying object with id, value and extensions. The accessor "getCertainty" gives direct access to the value
823         */
824        public AllergyIntoleranceReactionComponent setCertaintyElement(Enumeration<AllergyIntoleranceCertainty> value) { 
825          this.certainty = value;
826          return this;
827        }
828
829        /**
830         * @return Statement about the degree of clinical certainty that the specific substance was the cause of the manifestation in this reaction event.
831         */
832        public AllergyIntoleranceCertainty getCertainty() { 
833          return this.certainty == null ? null : this.certainty.getValue();
834        }
835
836        /**
837         * @param value Statement about the degree of clinical certainty that the specific substance was the cause of the manifestation in this reaction event.
838         */
839        public AllergyIntoleranceReactionComponent setCertainty(AllergyIntoleranceCertainty value) { 
840          if (value == null)
841            this.certainty = null;
842          else {
843            if (this.certainty == null)
844              this.certainty = new Enumeration<AllergyIntoleranceCertainty>(new AllergyIntoleranceCertaintyEnumFactory());
845            this.certainty.setValue(value);
846          }
847          return this;
848        }
849
850        /**
851         * @return {@link #manifestation} (Clinical symptoms and/or signs that are observed or associated with the adverse reaction event.)
852         */
853        public List<CodeableConcept> getManifestation() { 
854          if (this.manifestation == null)
855            this.manifestation = new ArrayList<CodeableConcept>();
856          return this.manifestation;
857        }
858
859        public boolean hasManifestation() { 
860          if (this.manifestation == null)
861            return false;
862          for (CodeableConcept item : this.manifestation)
863            if (!item.isEmpty())
864              return true;
865          return false;
866        }
867
868        /**
869         * @return {@link #manifestation} (Clinical symptoms and/or signs that are observed or associated with the adverse reaction event.)
870         */
871    // syntactic sugar
872        public CodeableConcept addManifestation() { //3
873          CodeableConcept t = new CodeableConcept();
874          if (this.manifestation == null)
875            this.manifestation = new ArrayList<CodeableConcept>();
876          this.manifestation.add(t);
877          return t;
878        }
879
880    // syntactic sugar
881        public AllergyIntoleranceReactionComponent addManifestation(CodeableConcept t) { //3
882          if (t == null)
883            return this;
884          if (this.manifestation == null)
885            this.manifestation = new ArrayList<CodeableConcept>();
886          this.manifestation.add(t);
887          return this;
888        }
889
890        /**
891         * @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
892         */
893        public StringType getDescriptionElement() { 
894          if (this.description == null)
895            if (Configuration.errorOnAutoCreate())
896              throw new Error("Attempt to auto-create AllergyIntoleranceReactionComponent.description");
897            else if (Configuration.doAutoCreate())
898              this.description = new StringType(); // bb
899          return this.description;
900        }
901
902        public boolean hasDescriptionElement() { 
903          return this.description != null && !this.description.isEmpty();
904        }
905
906        public boolean hasDescription() { 
907          return this.description != null && !this.description.isEmpty();
908        }
909
910        /**
911         * @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
912         */
913        public AllergyIntoleranceReactionComponent setDescriptionElement(StringType value) { 
914          this.description = value;
915          return this;
916        }
917
918        /**
919         * @return Text description about the reaction as a whole, including details of the manifestation if required.
920         */
921        public String getDescription() { 
922          return this.description == null ? null : this.description.getValue();
923        }
924
925        /**
926         * @param value Text description about the reaction as a whole, including details of the manifestation if required.
927         */
928        public AllergyIntoleranceReactionComponent setDescription(String value) { 
929          if (Utilities.noString(value))
930            this.description = null;
931          else {
932            if (this.description == null)
933              this.description = new StringType();
934            this.description.setValue(value);
935          }
936          return this;
937        }
938
939        /**
940         * @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
941         */
942        public DateTimeType getOnsetElement() { 
943          if (this.onset == null)
944            if (Configuration.errorOnAutoCreate())
945              throw new Error("Attempt to auto-create AllergyIntoleranceReactionComponent.onset");
946            else if (Configuration.doAutoCreate())
947              this.onset = new DateTimeType(); // bb
948          return this.onset;
949        }
950
951        public boolean hasOnsetElement() { 
952          return this.onset != null && !this.onset.isEmpty();
953        }
954
955        public boolean hasOnset() { 
956          return this.onset != null && !this.onset.isEmpty();
957        }
958
959        /**
960         * @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
961         */
962        public AllergyIntoleranceReactionComponent setOnsetElement(DateTimeType value) { 
963          this.onset = value;
964          return this;
965        }
966
967        /**
968         * @return Record of the date and/or time of the onset of the Reaction.
969         */
970        public Date getOnset() { 
971          return this.onset == null ? null : this.onset.getValue();
972        }
973
974        /**
975         * @param value Record of the date and/or time of the onset of the Reaction.
976         */
977        public AllergyIntoleranceReactionComponent setOnset(Date value) { 
978          if (value == null)
979            this.onset = null;
980          else {
981            if (this.onset == null)
982              this.onset = new DateTimeType();
983            this.onset.setValue(value);
984          }
985          return this;
986        }
987
988        /**
989         * @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
990         */
991        public Enumeration<AllergyIntoleranceSeverity> getSeverityElement() { 
992          if (this.severity == null)
993            if (Configuration.errorOnAutoCreate())
994              throw new Error("Attempt to auto-create AllergyIntoleranceReactionComponent.severity");
995            else if (Configuration.doAutoCreate())
996              this.severity = new Enumeration<AllergyIntoleranceSeverity>(new AllergyIntoleranceSeverityEnumFactory()); // bb
997          return this.severity;
998        }
999
1000        public boolean hasSeverityElement() { 
1001          return this.severity != null && !this.severity.isEmpty();
1002        }
1003
1004        public boolean hasSeverity() { 
1005          return this.severity != null && !this.severity.isEmpty();
1006        }
1007
1008        /**
1009         * @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
1010         */
1011        public AllergyIntoleranceReactionComponent setSeverityElement(Enumeration<AllergyIntoleranceSeverity> value) { 
1012          this.severity = value;
1013          return this;
1014        }
1015
1016        /**
1017         * @return Clinical assessment of the severity of the reaction event as a whole, potentially considering multiple different manifestations.
1018         */
1019        public AllergyIntoleranceSeverity getSeverity() { 
1020          return this.severity == null ? null : this.severity.getValue();
1021        }
1022
1023        /**
1024         * @param value Clinical assessment of the severity of the reaction event as a whole, potentially considering multiple different manifestations.
1025         */
1026        public AllergyIntoleranceReactionComponent setSeverity(AllergyIntoleranceSeverity value) { 
1027          if (value == null)
1028            this.severity = null;
1029          else {
1030            if (this.severity == null)
1031              this.severity = new Enumeration<AllergyIntoleranceSeverity>(new AllergyIntoleranceSeverityEnumFactory());
1032            this.severity.setValue(value);
1033          }
1034          return this;
1035        }
1036
1037        /**
1038         * @return {@link #exposureRoute} (Identification of the route by which the subject was exposed to the substance.)
1039         */
1040        public CodeableConcept getExposureRoute() { 
1041          if (this.exposureRoute == null)
1042            if (Configuration.errorOnAutoCreate())
1043              throw new Error("Attempt to auto-create AllergyIntoleranceReactionComponent.exposureRoute");
1044            else if (Configuration.doAutoCreate())
1045              this.exposureRoute = new CodeableConcept(); // cc
1046          return this.exposureRoute;
1047        }
1048
1049        public boolean hasExposureRoute() { 
1050          return this.exposureRoute != null && !this.exposureRoute.isEmpty();
1051        }
1052
1053        /**
1054         * @param value {@link #exposureRoute} (Identification of the route by which the subject was exposed to the substance.)
1055         */
1056        public AllergyIntoleranceReactionComponent setExposureRoute(CodeableConcept value) { 
1057          this.exposureRoute = value;
1058          return this;
1059        }
1060
1061        /**
1062         * @return {@link #note} (Additional text about the adverse reaction event not captured in other fields.)
1063         */
1064        public Annotation getNote() { 
1065          if (this.note == null)
1066            if (Configuration.errorOnAutoCreate())
1067              throw new Error("Attempt to auto-create AllergyIntoleranceReactionComponent.note");
1068            else if (Configuration.doAutoCreate())
1069              this.note = new Annotation(); // cc
1070          return this.note;
1071        }
1072
1073        public boolean hasNote() { 
1074          return this.note != null && !this.note.isEmpty();
1075        }
1076
1077        /**
1078         * @param value {@link #note} (Additional text about the adverse reaction event not captured in other fields.)
1079         */
1080        public AllergyIntoleranceReactionComponent setNote(Annotation value) { 
1081          this.note = value;
1082          return this;
1083        }
1084
1085        protected void listChildren(List<Property> childrenList) {
1086          super.listChildren(childrenList);
1087          childrenList.add(new Property("substance", "CodeableConcept", "Identification of the specific substance considered to be responsible for the Adverse Reaction event. Note: the substance for a specific reaction may be different to the substance identified as the cause of the risk, but must be consistent with it. For instance, it may be a more specific substance (e.g. a brand medication) or a composite substance that includes the identified substance. It must be clinically safe to only process the AllergyIntolerance.substance and ignore the AllergyIntolerance.event.substance.", 0, java.lang.Integer.MAX_VALUE, substance));
1088          childrenList.add(new Property("certainty", "code", "Statement about the degree of clinical certainty that the specific substance was the cause of the manifestation in this reaction event.", 0, java.lang.Integer.MAX_VALUE, certainty));
1089          childrenList.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));
1090          childrenList.add(new Property("description", "string", "Text description about the reaction as a whole, including details of the manifestation if required.", 0, java.lang.Integer.MAX_VALUE, description));
1091          childrenList.add(new Property("onset", "dateTime", "Record of the date and/or time of the onset of the Reaction.", 0, java.lang.Integer.MAX_VALUE, onset));
1092          childrenList.add(new Property("severity", "code", "Clinical assessment of the severity of the reaction event as a whole, potentially considering multiple different manifestations.", 0, java.lang.Integer.MAX_VALUE, severity));
1093          childrenList.add(new Property("exposureRoute", "CodeableConcept", "Identification of the route by which the subject was exposed to the substance.", 0, java.lang.Integer.MAX_VALUE, exposureRoute));
1094          childrenList.add(new Property("note", "Annotation", "Additional text about the adverse reaction event not captured in other fields.", 0, java.lang.Integer.MAX_VALUE, note));
1095        }
1096
1097      @Override
1098      public void setProperty(String name, Base value) throws FHIRException {
1099        if (name.equals("substance"))
1100          this.substance = castToCodeableConcept(value); // CodeableConcept
1101        else if (name.equals("certainty"))
1102          this.certainty = new AllergyIntoleranceCertaintyEnumFactory().fromType(value); // Enumeration<AllergyIntoleranceCertainty>
1103        else if (name.equals("manifestation"))
1104          this.getManifestation().add(castToCodeableConcept(value));
1105        else if (name.equals("description"))
1106          this.description = castToString(value); // StringType
1107        else if (name.equals("onset"))
1108          this.onset = castToDateTime(value); // DateTimeType
1109        else if (name.equals("severity"))
1110          this.severity = new AllergyIntoleranceSeverityEnumFactory().fromType(value); // Enumeration<AllergyIntoleranceSeverity>
1111        else if (name.equals("exposureRoute"))
1112          this.exposureRoute = castToCodeableConcept(value); // CodeableConcept
1113        else if (name.equals("note"))
1114          this.note = castToAnnotation(value); // Annotation
1115        else
1116          super.setProperty(name, value);
1117      }
1118
1119      @Override
1120      public Base addChild(String name) throws FHIRException {
1121        if (name.equals("substance")) {
1122          this.substance = new CodeableConcept();
1123          return this.substance;
1124        }
1125        else if (name.equals("certainty")) {
1126          throw new FHIRException("Cannot call addChild on a primitive type AllergyIntolerance.certainty");
1127        }
1128        else if (name.equals("manifestation")) {
1129          return addManifestation();
1130        }
1131        else if (name.equals("description")) {
1132          throw new FHIRException("Cannot call addChild on a primitive type AllergyIntolerance.description");
1133        }
1134        else if (name.equals("onset")) {
1135          throw new FHIRException("Cannot call addChild on a primitive type AllergyIntolerance.onset");
1136        }
1137        else if (name.equals("severity")) {
1138          throw new FHIRException("Cannot call addChild on a primitive type AllergyIntolerance.severity");
1139        }
1140        else if (name.equals("exposureRoute")) {
1141          this.exposureRoute = new CodeableConcept();
1142          return this.exposureRoute;
1143        }
1144        else if (name.equals("note")) {
1145          this.note = new Annotation();
1146          return this.note;
1147        }
1148        else
1149          return super.addChild(name);
1150      }
1151
1152      public AllergyIntoleranceReactionComponent copy() {
1153        AllergyIntoleranceReactionComponent dst = new AllergyIntoleranceReactionComponent();
1154        copyValues(dst);
1155        dst.substance = substance == null ? null : substance.copy();
1156        dst.certainty = certainty == null ? null : certainty.copy();
1157        if (manifestation != null) {
1158          dst.manifestation = new ArrayList<CodeableConcept>();
1159          for (CodeableConcept i : manifestation)
1160            dst.manifestation.add(i.copy());
1161        };
1162        dst.description = description == null ? null : description.copy();
1163        dst.onset = onset == null ? null : onset.copy();
1164        dst.severity = severity == null ? null : severity.copy();
1165        dst.exposureRoute = exposureRoute == null ? null : exposureRoute.copy();
1166        dst.note = note == null ? null : note.copy();
1167        return dst;
1168      }
1169
1170      @Override
1171      public boolean equalsDeep(Base other) {
1172        if (!super.equalsDeep(other))
1173          return false;
1174        if (!(other instanceof AllergyIntoleranceReactionComponent))
1175          return false;
1176        AllergyIntoleranceReactionComponent o = (AllergyIntoleranceReactionComponent) other;
1177        return compareDeep(substance, o.substance, true) && compareDeep(certainty, o.certainty, true) && compareDeep(manifestation, o.manifestation, true)
1178           && compareDeep(description, o.description, true) && compareDeep(onset, o.onset, true) && compareDeep(severity, o.severity, true)
1179           && compareDeep(exposureRoute, o.exposureRoute, true) && compareDeep(note, o.note, true);
1180      }
1181
1182      @Override
1183      public boolean equalsShallow(Base other) {
1184        if (!super.equalsShallow(other))
1185          return false;
1186        if (!(other instanceof AllergyIntoleranceReactionComponent))
1187          return false;
1188        AllergyIntoleranceReactionComponent o = (AllergyIntoleranceReactionComponent) other;
1189        return compareValues(certainty, o.certainty, true) && compareValues(description, o.description, true)
1190           && compareValues(onset, o.onset, true) && compareValues(severity, o.severity, true);
1191      }
1192
1193      public boolean isEmpty() {
1194        return super.isEmpty() && (substance == null || substance.isEmpty()) && (certainty == null || certainty.isEmpty())
1195           && (manifestation == null || manifestation.isEmpty()) && (description == null || description.isEmpty())
1196           && (onset == null || onset.isEmpty()) && (severity == null || severity.isEmpty()) && (exposureRoute == null || exposureRoute.isEmpty())
1197           && (note == null || note.isEmpty());
1198      }
1199
1200  public String fhirType() {
1201    return "AllergyIntolerance.reaction";
1202
1203  }
1204
1205  }
1206
1207    /**
1208     * This records identifiers associated with this allergy/intolerance concern that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).
1209     */
1210    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1211    @Description(shortDefinition="External ids for this item", formalDefinition="This records identifiers associated with this allergy/intolerance concern that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation)." )
1212    protected List<Identifier> identifier;
1213
1214    /**
1215     * Record of the date and/or time of the onset of the Allergy or Intolerance.
1216     */
1217    @Child(name = "onset", type = {DateTimeType.class}, order=1, min=0, max=1, modifier=false, summary=true)
1218    @Description(shortDefinition="Date(/time) when manifestations showed", formalDefinition="Record of the date and/or time of the onset of the Allergy or Intolerance." )
1219    protected DateTimeType onset;
1220
1221    /**
1222     * Date when the sensitivity was recorded.
1223     */
1224    @Child(name = "recordedDate", type = {DateTimeType.class}, order=2, min=0, max=1, modifier=false, summary=true)
1225    @Description(shortDefinition="When recorded", formalDefinition="Date when the sensitivity was recorded." )
1226    protected DateTimeType recordedDate;
1227
1228    /**
1229     * Individual who recorded the record and takes responsibility for its conten.
1230     */
1231    @Child(name = "recorder", type = {Practitioner.class, Patient.class}, order=3, min=0, max=1, modifier=false, summary=true)
1232    @Description(shortDefinition="Who recorded the sensitivity", formalDefinition="Individual who recorded the record and takes responsibility for its conten." )
1233    protected Reference recorder;
1234
1235    /**
1236     * The actual object that is the target of the reference (Individual who recorded the record and takes responsibility for its conten.)
1237     */
1238    protected Resource recorderTarget;
1239
1240    /**
1241     * The patient who has the allergy or intolerance.
1242     */
1243    @Child(name = "patient", type = {Patient.class}, order=4, min=1, max=1, modifier=false, summary=true)
1244    @Description(shortDefinition="Who the sensitivity is for", formalDefinition="The patient who has the allergy or intolerance." )
1245    protected Reference patient;
1246
1247    /**
1248     * The actual object that is the target of the reference (The patient who has the allergy or intolerance.)
1249     */
1250    protected Patient patientTarget;
1251
1252    /**
1253     * The source of the information about the allergy that is recorded.
1254     */
1255    @Child(name = "reporter", type = {Patient.class, RelatedPerson.class, Practitioner.class}, order=5, min=0, max=1, modifier=false, summary=true)
1256    @Description(shortDefinition="Source of the information about the allergy", formalDefinition="The source of the information about the allergy that is recorded." )
1257    protected Reference reporter;
1258
1259    /**
1260     * The actual object that is the target of the reference (The source of the information about the allergy that is recorded.)
1261     */
1262    protected Resource reporterTarget;
1263
1264    /**
1265     * Identification of a substance, or a class of substances, that is considered to be responsible for the adverse reaction risk.
1266     */
1267    @Child(name = "substance", type = {CodeableConcept.class}, order=6, min=1, max=1, modifier=false, summary=true)
1268    @Description(shortDefinition="Substance, (or class) considered to be responsible for risk", formalDefinition="Identification of a substance, or a class of substances, that is considered to be responsible for the adverse reaction risk." )
1269    protected CodeableConcept substance;
1270
1271    /**
1272     * Assertion about certainty associated with the propensity, or potential risk, of a reaction to the identified Substance.
1273     */
1274    @Child(name = "status", type = {CodeType.class}, order=7, min=0, max=1, modifier=true, summary=true)
1275    @Description(shortDefinition="active | unconfirmed | confirmed | inactive | resolved | refuted | entered-in-error", formalDefinition="Assertion about certainty associated with the propensity, or potential risk, of a reaction to the identified Substance." )
1276    protected Enumeration<AllergyIntoleranceStatus> status;
1277
1278    /**
1279     * Estimate of the potential clinical harm, or seriousness, of the reaction to the identified Substance.
1280     */
1281    @Child(name = "criticality", type = {CodeType.class}, order=8, min=0, max=1, modifier=false, summary=true)
1282    @Description(shortDefinition="CRITL | CRITH | CRITU", formalDefinition="Estimate of the potential clinical harm, or seriousness, of the reaction to the identified Substance." )
1283    protected Enumeration<AllergyIntoleranceCriticality> criticality;
1284
1285    /**
1286     * Identification of the underlying physiological mechanism for the reaction risk.
1287     */
1288    @Child(name = "type", type = {CodeType.class}, order=9, min=0, max=1, modifier=false, summary=true)
1289    @Description(shortDefinition="allergy | intolerance - Underlying mechanism (if known)", formalDefinition="Identification of the underlying physiological mechanism for the reaction risk." )
1290    protected Enumeration<AllergyIntoleranceType> type;
1291
1292    /**
1293     * Category of the identified Substance.
1294     */
1295    @Child(name = "category", type = {CodeType.class}, order=10, min=0, max=1, modifier=false, summary=true)
1296    @Description(shortDefinition="food | medication | environment | other - Category of Substance", formalDefinition="Category of the identified Substance." )
1297    protected Enumeration<AllergyIntoleranceCategory> category;
1298
1299    /**
1300     * Represents the date and/or time of the last known occurrence of a reaction event.
1301     */
1302    @Child(name = "lastOccurence", type = {DateTimeType.class}, order=11, min=0, max=1, modifier=false, summary=true)
1303    @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." )
1304    protected DateTimeType lastOccurence;
1305
1306    /**
1307     * Additional narrative about the propensity for the Adverse Reaction, not captured in other fields.
1308     */
1309    @Child(name = "note", type = {Annotation.class}, order=12, min=0, max=1, modifier=false, summary=false)
1310    @Description(shortDefinition="Additional text not captured in other fields", formalDefinition="Additional narrative about the propensity for the Adverse Reaction, not captured in other fields." )
1311    protected Annotation note;
1312
1313    /**
1314     * Details about each adverse reaction event linked to exposure to the identified Substance.
1315     */
1316    @Child(name = "reaction", type = {}, order=13, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1317    @Description(shortDefinition="Adverse Reaction Events linked to exposure to substance", formalDefinition="Details about each adverse reaction event linked to exposure to the identified Substance." )
1318    protected List<AllergyIntoleranceReactionComponent> reaction;
1319
1320    private static final long serialVersionUID = -1657522921L;
1321
1322  /*
1323   * Constructor
1324   */
1325    public AllergyIntolerance() {
1326      super();
1327    }
1328
1329  /*
1330   * Constructor
1331   */
1332    public AllergyIntolerance(Reference patient, CodeableConcept substance) {
1333      super();
1334      this.patient = patient;
1335      this.substance = substance;
1336    }
1337
1338    /**
1339     * @return {@link #identifier} (This records identifiers associated with this allergy/intolerance concern that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).)
1340     */
1341    public List<Identifier> getIdentifier() { 
1342      if (this.identifier == null)
1343        this.identifier = new ArrayList<Identifier>();
1344      return this.identifier;
1345    }
1346
1347    public boolean hasIdentifier() { 
1348      if (this.identifier == null)
1349        return false;
1350      for (Identifier item : this.identifier)
1351        if (!item.isEmpty())
1352          return true;
1353      return false;
1354    }
1355
1356    /**
1357     * @return {@link #identifier} (This records identifiers associated with this allergy/intolerance concern that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).)
1358     */
1359    // syntactic sugar
1360    public Identifier addIdentifier() { //3
1361      Identifier t = new Identifier();
1362      if (this.identifier == null)
1363        this.identifier = new ArrayList<Identifier>();
1364      this.identifier.add(t);
1365      return t;
1366    }
1367
1368    // syntactic sugar
1369    public AllergyIntolerance addIdentifier(Identifier t) { //3
1370      if (t == null)
1371        return this;
1372      if (this.identifier == null)
1373        this.identifier = new ArrayList<Identifier>();
1374      this.identifier.add(t);
1375      return this;
1376    }
1377
1378    /**
1379     * @return {@link #onset} (Record of the date and/or time of the onset of the Allergy or Intolerance.). This is the underlying object with id, value and extensions. The accessor "getOnset" gives direct access to the value
1380     */
1381    public DateTimeType getOnsetElement() { 
1382      if (this.onset == null)
1383        if (Configuration.errorOnAutoCreate())
1384          throw new Error("Attempt to auto-create AllergyIntolerance.onset");
1385        else if (Configuration.doAutoCreate())
1386          this.onset = new DateTimeType(); // bb
1387      return this.onset;
1388    }
1389
1390    public boolean hasOnsetElement() { 
1391      return this.onset != null && !this.onset.isEmpty();
1392    }
1393
1394    public boolean hasOnset() { 
1395      return this.onset != null && !this.onset.isEmpty();
1396    }
1397
1398    /**
1399     * @param value {@link #onset} (Record of the date and/or time of the onset of the Allergy or Intolerance.). This is the underlying object with id, value and extensions. The accessor "getOnset" gives direct access to the value
1400     */
1401    public AllergyIntolerance setOnsetElement(DateTimeType value) { 
1402      this.onset = value;
1403      return this;
1404    }
1405
1406    /**
1407     * @return Record of the date and/or time of the onset of the Allergy or Intolerance.
1408     */
1409    public Date getOnset() { 
1410      return this.onset == null ? null : this.onset.getValue();
1411    }
1412
1413    /**
1414     * @param value Record of the date and/or time of the onset of the Allergy or Intolerance.
1415     */
1416    public AllergyIntolerance setOnset(Date value) { 
1417      if (value == null)
1418        this.onset = null;
1419      else {
1420        if (this.onset == null)
1421          this.onset = new DateTimeType();
1422        this.onset.setValue(value);
1423      }
1424      return this;
1425    }
1426
1427    /**
1428     * @return {@link #recordedDate} (Date when the sensitivity was recorded.). This is the underlying object with id, value and extensions. The accessor "getRecordedDate" gives direct access to the value
1429     */
1430    public DateTimeType getRecordedDateElement() { 
1431      if (this.recordedDate == null)
1432        if (Configuration.errorOnAutoCreate())
1433          throw new Error("Attempt to auto-create AllergyIntolerance.recordedDate");
1434        else if (Configuration.doAutoCreate())
1435          this.recordedDate = new DateTimeType(); // bb
1436      return this.recordedDate;
1437    }
1438
1439    public boolean hasRecordedDateElement() { 
1440      return this.recordedDate != null && !this.recordedDate.isEmpty();
1441    }
1442
1443    public boolean hasRecordedDate() { 
1444      return this.recordedDate != null && !this.recordedDate.isEmpty();
1445    }
1446
1447    /**
1448     * @param value {@link #recordedDate} (Date when the sensitivity was recorded.). This is the underlying object with id, value and extensions. The accessor "getRecordedDate" gives direct access to the value
1449     */
1450    public AllergyIntolerance setRecordedDateElement(DateTimeType value) { 
1451      this.recordedDate = value;
1452      return this;
1453    }
1454
1455    /**
1456     * @return Date when the sensitivity was recorded.
1457     */
1458    public Date getRecordedDate() { 
1459      return this.recordedDate == null ? null : this.recordedDate.getValue();
1460    }
1461
1462    /**
1463     * @param value Date when the sensitivity was recorded.
1464     */
1465    public AllergyIntolerance setRecordedDate(Date value) { 
1466      if (value == null)
1467        this.recordedDate = null;
1468      else {
1469        if (this.recordedDate == null)
1470          this.recordedDate = new DateTimeType();
1471        this.recordedDate.setValue(value);
1472      }
1473      return this;
1474    }
1475
1476    /**
1477     * @return {@link #recorder} (Individual who recorded the record and takes responsibility for its conten.)
1478     */
1479    public Reference getRecorder() { 
1480      if (this.recorder == null)
1481        if (Configuration.errorOnAutoCreate())
1482          throw new Error("Attempt to auto-create AllergyIntolerance.recorder");
1483        else if (Configuration.doAutoCreate())
1484          this.recorder = new Reference(); // cc
1485      return this.recorder;
1486    }
1487
1488    public boolean hasRecorder() { 
1489      return this.recorder != null && !this.recorder.isEmpty();
1490    }
1491
1492    /**
1493     * @param value {@link #recorder} (Individual who recorded the record and takes responsibility for its conten.)
1494     */
1495    public AllergyIntolerance setRecorder(Reference value) { 
1496      this.recorder = value;
1497      return this;
1498    }
1499
1500    /**
1501     * @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 conten.)
1502     */
1503    public Resource getRecorderTarget() { 
1504      return this.recorderTarget;
1505    }
1506
1507    /**
1508     * @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 conten.)
1509     */
1510    public AllergyIntolerance setRecorderTarget(Resource value) { 
1511      this.recorderTarget = value;
1512      return this;
1513    }
1514
1515    /**
1516     * @return {@link #patient} (The patient who has the allergy or intolerance.)
1517     */
1518    public Reference getPatient() { 
1519      if (this.patient == null)
1520        if (Configuration.errorOnAutoCreate())
1521          throw new Error("Attempt to auto-create AllergyIntolerance.patient");
1522        else if (Configuration.doAutoCreate())
1523          this.patient = new Reference(); // cc
1524      return this.patient;
1525    }
1526
1527    public boolean hasPatient() { 
1528      return this.patient != null && !this.patient.isEmpty();
1529    }
1530
1531    /**
1532     * @param value {@link #patient} (The patient who has the allergy or intolerance.)
1533     */
1534    public AllergyIntolerance setPatient(Reference value) { 
1535      this.patient = value;
1536      return this;
1537    }
1538
1539    /**
1540     * @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.)
1541     */
1542    public Patient getPatientTarget() { 
1543      if (this.patientTarget == null)
1544        if (Configuration.errorOnAutoCreate())
1545          throw new Error("Attempt to auto-create AllergyIntolerance.patient");
1546        else if (Configuration.doAutoCreate())
1547          this.patientTarget = new Patient(); // aa
1548      return this.patientTarget;
1549    }
1550
1551    /**
1552     * @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.)
1553     */
1554    public AllergyIntolerance setPatientTarget(Patient value) { 
1555      this.patientTarget = value;
1556      return this;
1557    }
1558
1559    /**
1560     * @return {@link #reporter} (The source of the information about the allergy that is recorded.)
1561     */
1562    public Reference getReporter() { 
1563      if (this.reporter == null)
1564        if (Configuration.errorOnAutoCreate())
1565          throw new Error("Attempt to auto-create AllergyIntolerance.reporter");
1566        else if (Configuration.doAutoCreate())
1567          this.reporter = new Reference(); // cc
1568      return this.reporter;
1569    }
1570
1571    public boolean hasReporter() { 
1572      return this.reporter != null && !this.reporter.isEmpty();
1573    }
1574
1575    /**
1576     * @param value {@link #reporter} (The source of the information about the allergy that is recorded.)
1577     */
1578    public AllergyIntolerance setReporter(Reference value) { 
1579      this.reporter = value;
1580      return this;
1581    }
1582
1583    /**
1584     * @return {@link #reporter} 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.)
1585     */
1586    public Resource getReporterTarget() { 
1587      return this.reporterTarget;
1588    }
1589
1590    /**
1591     * @param value {@link #reporter} 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.)
1592     */
1593    public AllergyIntolerance setReporterTarget(Resource value) { 
1594      this.reporterTarget = value;
1595      return this;
1596    }
1597
1598    /**
1599     * @return {@link #substance} (Identification of a substance, or a class of substances, that is considered to be responsible for the adverse reaction risk.)
1600     */
1601    public CodeableConcept getSubstance() { 
1602      if (this.substance == null)
1603        if (Configuration.errorOnAutoCreate())
1604          throw new Error("Attempt to auto-create AllergyIntolerance.substance");
1605        else if (Configuration.doAutoCreate())
1606          this.substance = new CodeableConcept(); // cc
1607      return this.substance;
1608    }
1609
1610    public boolean hasSubstance() { 
1611      return this.substance != null && !this.substance.isEmpty();
1612    }
1613
1614    /**
1615     * @param value {@link #substance} (Identification of a substance, or a class of substances, that is considered to be responsible for the adverse reaction risk.)
1616     */
1617    public AllergyIntolerance setSubstance(CodeableConcept value) { 
1618      this.substance = value;
1619      return this;
1620    }
1621
1622    /**
1623     * @return {@link #status} (Assertion about certainty associated with the propensity, or potential risk, of a reaction to the identified Substance.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1624     */
1625    public Enumeration<AllergyIntoleranceStatus> getStatusElement() { 
1626      if (this.status == null)
1627        if (Configuration.errorOnAutoCreate())
1628          throw new Error("Attempt to auto-create AllergyIntolerance.status");
1629        else if (Configuration.doAutoCreate())
1630          this.status = new Enumeration<AllergyIntoleranceStatus>(new AllergyIntoleranceStatusEnumFactory()); // bb
1631      return this.status;
1632    }
1633
1634    public boolean hasStatusElement() { 
1635      return this.status != null && !this.status.isEmpty();
1636    }
1637
1638    public boolean hasStatus() { 
1639      return this.status != null && !this.status.isEmpty();
1640    }
1641
1642    /**
1643     * @param value {@link #status} (Assertion about certainty associated with the propensity, or potential risk, of a reaction to the identified Substance.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1644     */
1645    public AllergyIntolerance setStatusElement(Enumeration<AllergyIntoleranceStatus> value) { 
1646      this.status = value;
1647      return this;
1648    }
1649
1650    /**
1651     * @return Assertion about certainty associated with the propensity, or potential risk, of a reaction to the identified Substance.
1652     */
1653    public AllergyIntoleranceStatus getStatus() { 
1654      return this.status == null ? null : this.status.getValue();
1655    }
1656
1657    /**
1658     * @param value Assertion about certainty associated with the propensity, or potential risk, of a reaction to the identified Substance.
1659     */
1660    public AllergyIntolerance setStatus(AllergyIntoleranceStatus value) { 
1661      if (value == null)
1662        this.status = null;
1663      else {
1664        if (this.status == null)
1665          this.status = new Enumeration<AllergyIntoleranceStatus>(new AllergyIntoleranceStatusEnumFactory());
1666        this.status.setValue(value);
1667      }
1668      return this;
1669    }
1670
1671    /**
1672     * @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
1673     */
1674    public Enumeration<AllergyIntoleranceCriticality> getCriticalityElement() { 
1675      if (this.criticality == null)
1676        if (Configuration.errorOnAutoCreate())
1677          throw new Error("Attempt to auto-create AllergyIntolerance.criticality");
1678        else if (Configuration.doAutoCreate())
1679          this.criticality = new Enumeration<AllergyIntoleranceCriticality>(new AllergyIntoleranceCriticalityEnumFactory()); // bb
1680      return this.criticality;
1681    }
1682
1683    public boolean hasCriticalityElement() { 
1684      return this.criticality != null && !this.criticality.isEmpty();
1685    }
1686
1687    public boolean hasCriticality() { 
1688      return this.criticality != null && !this.criticality.isEmpty();
1689    }
1690
1691    /**
1692     * @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
1693     */
1694    public AllergyIntolerance setCriticalityElement(Enumeration<AllergyIntoleranceCriticality> value) { 
1695      this.criticality = value;
1696      return this;
1697    }
1698
1699    /**
1700     * @return Estimate of the potential clinical harm, or seriousness, of the reaction to the identified Substance.
1701     */
1702    public AllergyIntoleranceCriticality getCriticality() { 
1703      return this.criticality == null ? null : this.criticality.getValue();
1704    }
1705
1706    /**
1707     * @param value Estimate of the potential clinical harm, or seriousness, of the reaction to the identified Substance.
1708     */
1709    public AllergyIntolerance setCriticality(AllergyIntoleranceCriticality value) { 
1710      if (value == null)
1711        this.criticality = null;
1712      else {
1713        if (this.criticality == null)
1714          this.criticality = new Enumeration<AllergyIntoleranceCriticality>(new AllergyIntoleranceCriticalityEnumFactory());
1715        this.criticality.setValue(value);
1716      }
1717      return this;
1718    }
1719
1720    /**
1721     * @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
1722     */
1723    public Enumeration<AllergyIntoleranceType> getTypeElement() { 
1724      if (this.type == null)
1725        if (Configuration.errorOnAutoCreate())
1726          throw new Error("Attempt to auto-create AllergyIntolerance.type");
1727        else if (Configuration.doAutoCreate())
1728          this.type = new Enumeration<AllergyIntoleranceType>(new AllergyIntoleranceTypeEnumFactory()); // bb
1729      return this.type;
1730    }
1731
1732    public boolean hasTypeElement() { 
1733      return this.type != null && !this.type.isEmpty();
1734    }
1735
1736    public boolean hasType() { 
1737      return this.type != null && !this.type.isEmpty();
1738    }
1739
1740    /**
1741     * @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
1742     */
1743    public AllergyIntolerance setTypeElement(Enumeration<AllergyIntoleranceType> value) { 
1744      this.type = value;
1745      return this;
1746    }
1747
1748    /**
1749     * @return Identification of the underlying physiological mechanism for the reaction risk.
1750     */
1751    public AllergyIntoleranceType getType() { 
1752      return this.type == null ? null : this.type.getValue();
1753    }
1754
1755    /**
1756     * @param value Identification of the underlying physiological mechanism for the reaction risk.
1757     */
1758    public AllergyIntolerance setType(AllergyIntoleranceType value) { 
1759      if (value == null)
1760        this.type = null;
1761      else {
1762        if (this.type == null)
1763          this.type = new Enumeration<AllergyIntoleranceType>(new AllergyIntoleranceTypeEnumFactory());
1764        this.type.setValue(value);
1765      }
1766      return this;
1767    }
1768
1769    /**
1770     * @return {@link #category} (Category of the identified Substance.). This is the underlying object with id, value and extensions. The accessor "getCategory" gives direct access to the value
1771     */
1772    public Enumeration<AllergyIntoleranceCategory> getCategoryElement() { 
1773      if (this.category == null)
1774        if (Configuration.errorOnAutoCreate())
1775          throw new Error("Attempt to auto-create AllergyIntolerance.category");
1776        else if (Configuration.doAutoCreate())
1777          this.category = new Enumeration<AllergyIntoleranceCategory>(new AllergyIntoleranceCategoryEnumFactory()); // bb
1778      return this.category;
1779    }
1780
1781    public boolean hasCategoryElement() { 
1782      return this.category != null && !this.category.isEmpty();
1783    }
1784
1785    public boolean hasCategory() { 
1786      return this.category != null && !this.category.isEmpty();
1787    }
1788
1789    /**
1790     * @param value {@link #category} (Category of the identified Substance.). This is the underlying object with id, value and extensions. The accessor "getCategory" gives direct access to the value
1791     */
1792    public AllergyIntolerance setCategoryElement(Enumeration<AllergyIntoleranceCategory> value) { 
1793      this.category = value;
1794      return this;
1795    }
1796
1797    /**
1798     * @return Category of the identified Substance.
1799     */
1800    public AllergyIntoleranceCategory getCategory() { 
1801      return this.category == null ? null : this.category.getValue();
1802    }
1803
1804    /**
1805     * @param value Category of the identified Substance.
1806     */
1807    public AllergyIntolerance setCategory(AllergyIntoleranceCategory value) { 
1808      if (value == null)
1809        this.category = null;
1810      else {
1811        if (this.category == null)
1812          this.category = new Enumeration<AllergyIntoleranceCategory>(new AllergyIntoleranceCategoryEnumFactory());
1813        this.category.setValue(value);
1814      }
1815      return this;
1816    }
1817
1818    /**
1819     * @return {@link #lastOccurence} (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 "getLastOccurence" gives direct access to the value
1820     */
1821    public DateTimeType getLastOccurenceElement() { 
1822      if (this.lastOccurence == null)
1823        if (Configuration.errorOnAutoCreate())
1824          throw new Error("Attempt to auto-create AllergyIntolerance.lastOccurence");
1825        else if (Configuration.doAutoCreate())
1826          this.lastOccurence = new DateTimeType(); // bb
1827      return this.lastOccurence;
1828    }
1829
1830    public boolean hasLastOccurenceElement() { 
1831      return this.lastOccurence != null && !this.lastOccurence.isEmpty();
1832    }
1833
1834    public boolean hasLastOccurence() { 
1835      return this.lastOccurence != null && !this.lastOccurence.isEmpty();
1836    }
1837
1838    /**
1839     * @param value {@link #lastOccurence} (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 "getLastOccurence" gives direct access to the value
1840     */
1841    public AllergyIntolerance setLastOccurenceElement(DateTimeType value) { 
1842      this.lastOccurence = value;
1843      return this;
1844    }
1845
1846    /**
1847     * @return Represents the date and/or time of the last known occurrence of a reaction event.
1848     */
1849    public Date getLastOccurence() { 
1850      return this.lastOccurence == null ? null : this.lastOccurence.getValue();
1851    }
1852
1853    /**
1854     * @param value Represents the date and/or time of the last known occurrence of a reaction event.
1855     */
1856    public AllergyIntolerance setLastOccurence(Date value) { 
1857      if (value == null)
1858        this.lastOccurence = null;
1859      else {
1860        if (this.lastOccurence == null)
1861          this.lastOccurence = new DateTimeType();
1862        this.lastOccurence.setValue(value);
1863      }
1864      return this;
1865    }
1866
1867    /**
1868     * @return {@link #note} (Additional narrative about the propensity for the Adverse Reaction, not captured in other fields.)
1869     */
1870    public Annotation getNote() { 
1871      if (this.note == null)
1872        if (Configuration.errorOnAutoCreate())
1873          throw new Error("Attempt to auto-create AllergyIntolerance.note");
1874        else if (Configuration.doAutoCreate())
1875          this.note = new Annotation(); // cc
1876      return this.note;
1877    }
1878
1879    public boolean hasNote() { 
1880      return this.note != null && !this.note.isEmpty();
1881    }
1882
1883    /**
1884     * @param value {@link #note} (Additional narrative about the propensity for the Adverse Reaction, not captured in other fields.)
1885     */
1886    public AllergyIntolerance setNote(Annotation value) { 
1887      this.note = value;
1888      return this;
1889    }
1890
1891    /**
1892     * @return {@link #reaction} (Details about each adverse reaction event linked to exposure to the identified Substance.)
1893     */
1894    public List<AllergyIntoleranceReactionComponent> getReaction() { 
1895      if (this.reaction == null)
1896        this.reaction = new ArrayList<AllergyIntoleranceReactionComponent>();
1897      return this.reaction;
1898    }
1899
1900    public boolean hasReaction() { 
1901      if (this.reaction == null)
1902        return false;
1903      for (AllergyIntoleranceReactionComponent item : this.reaction)
1904        if (!item.isEmpty())
1905          return true;
1906      return false;
1907    }
1908
1909    /**
1910     * @return {@link #reaction} (Details about each adverse reaction event linked to exposure to the identified Substance.)
1911     */
1912    // syntactic sugar
1913    public AllergyIntoleranceReactionComponent addReaction() { //3
1914      AllergyIntoleranceReactionComponent t = new AllergyIntoleranceReactionComponent();
1915      if (this.reaction == null)
1916        this.reaction = new ArrayList<AllergyIntoleranceReactionComponent>();
1917      this.reaction.add(t);
1918      return t;
1919    }
1920
1921    // syntactic sugar
1922    public AllergyIntolerance addReaction(AllergyIntoleranceReactionComponent t) { //3
1923      if (t == null)
1924        return this;
1925      if (this.reaction == null)
1926        this.reaction = new ArrayList<AllergyIntoleranceReactionComponent>();
1927      this.reaction.add(t);
1928      return this;
1929    }
1930
1931      protected void listChildren(List<Property> childrenList) {
1932        super.listChildren(childrenList);
1933        childrenList.add(new Property("identifier", "Identifier", "This records identifiers associated with this allergy/intolerance concern that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).", 0, java.lang.Integer.MAX_VALUE, identifier));
1934        childrenList.add(new Property("onset", "dateTime", "Record of the date and/or time of the onset of the Allergy or Intolerance.", 0, java.lang.Integer.MAX_VALUE, onset));
1935        childrenList.add(new Property("recordedDate", "dateTime", "Date when the sensitivity was recorded.", 0, java.lang.Integer.MAX_VALUE, recordedDate));
1936        childrenList.add(new Property("recorder", "Reference(Practitioner|Patient)", "Individual who recorded the record and takes responsibility for its conten.", 0, java.lang.Integer.MAX_VALUE, recorder));
1937        childrenList.add(new Property("patient", "Reference(Patient)", "The patient who has the allergy or intolerance.", 0, java.lang.Integer.MAX_VALUE, patient));
1938        childrenList.add(new Property("reporter", "Reference(Patient|RelatedPerson|Practitioner)", "The source of the information about the allergy that is recorded.", 0, java.lang.Integer.MAX_VALUE, reporter));
1939        childrenList.add(new Property("substance", "CodeableConcept", "Identification of a substance, or a class of substances, that is considered to be responsible for the adverse reaction risk.", 0, java.lang.Integer.MAX_VALUE, substance));
1940        childrenList.add(new Property("status", "code", "Assertion about certainty associated with the propensity, or potential risk, of a reaction to the identified Substance.", 0, java.lang.Integer.MAX_VALUE, status));
1941        childrenList.add(new Property("criticality", "code", "Estimate of the potential clinical harm, or seriousness, of the reaction to the identified Substance.", 0, java.lang.Integer.MAX_VALUE, criticality));
1942        childrenList.add(new Property("type", "code", "Identification of the underlying physiological mechanism for the reaction risk.", 0, java.lang.Integer.MAX_VALUE, type));
1943        childrenList.add(new Property("category", "code", "Category of the identified Substance.", 0, java.lang.Integer.MAX_VALUE, category));
1944        childrenList.add(new Property("lastOccurence", "dateTime", "Represents the date and/or time of the last known occurrence of a reaction event.", 0, java.lang.Integer.MAX_VALUE, lastOccurence));
1945        childrenList.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));
1946        childrenList.add(new Property("reaction", "", "Details about each adverse reaction event linked to exposure to the identified Substance.", 0, java.lang.Integer.MAX_VALUE, reaction));
1947      }
1948
1949      @Override
1950      public void setProperty(String name, Base value) throws FHIRException {
1951        if (name.equals("identifier"))
1952          this.getIdentifier().add(castToIdentifier(value));
1953        else if (name.equals("onset"))
1954          this.onset = castToDateTime(value); // DateTimeType
1955        else if (name.equals("recordedDate"))
1956          this.recordedDate = castToDateTime(value); // DateTimeType
1957        else if (name.equals("recorder"))
1958          this.recorder = castToReference(value); // Reference
1959        else if (name.equals("patient"))
1960          this.patient = castToReference(value); // Reference
1961        else if (name.equals("reporter"))
1962          this.reporter = castToReference(value); // Reference
1963        else if (name.equals("substance"))
1964          this.substance = castToCodeableConcept(value); // CodeableConcept
1965        else if (name.equals("status"))
1966          this.status = new AllergyIntoleranceStatusEnumFactory().fromType(value); // Enumeration<AllergyIntoleranceStatus>
1967        else if (name.equals("criticality"))
1968          this.criticality = new AllergyIntoleranceCriticalityEnumFactory().fromType(value); // Enumeration<AllergyIntoleranceCriticality>
1969        else if (name.equals("type"))
1970          this.type = new AllergyIntoleranceTypeEnumFactory().fromType(value); // Enumeration<AllergyIntoleranceType>
1971        else if (name.equals("category"))
1972          this.category = new AllergyIntoleranceCategoryEnumFactory().fromType(value); // Enumeration<AllergyIntoleranceCategory>
1973        else if (name.equals("lastOccurence"))
1974          this.lastOccurence = castToDateTime(value); // DateTimeType
1975        else if (name.equals("note"))
1976          this.note = castToAnnotation(value); // Annotation
1977        else if (name.equals("reaction"))
1978          this.getReaction().add((AllergyIntoleranceReactionComponent) value);
1979        else
1980          super.setProperty(name, value);
1981      }
1982
1983      @Override
1984      public Base addChild(String name) throws FHIRException {
1985        if (name.equals("identifier")) {
1986          return addIdentifier();
1987        }
1988        else if (name.equals("onset")) {
1989          throw new FHIRException("Cannot call addChild on a primitive type AllergyIntolerance.onset");
1990        }
1991        else if (name.equals("recordedDate")) {
1992          throw new FHIRException("Cannot call addChild on a primitive type AllergyIntolerance.recordedDate");
1993        }
1994        else if (name.equals("recorder")) {
1995          this.recorder = new Reference();
1996          return this.recorder;
1997        }
1998        else if (name.equals("patient")) {
1999          this.patient = new Reference();
2000          return this.patient;
2001        }
2002        else if (name.equals("reporter")) {
2003          this.reporter = new Reference();
2004          return this.reporter;
2005        }
2006        else if (name.equals("substance")) {
2007          this.substance = new CodeableConcept();
2008          return this.substance;
2009        }
2010        else if (name.equals("status")) {
2011          throw new FHIRException("Cannot call addChild on a primitive type AllergyIntolerance.status");
2012        }
2013        else if (name.equals("criticality")) {
2014          throw new FHIRException("Cannot call addChild on a primitive type AllergyIntolerance.criticality");
2015        }
2016        else if (name.equals("type")) {
2017          throw new FHIRException("Cannot call addChild on a primitive type AllergyIntolerance.type");
2018        }
2019        else if (name.equals("category")) {
2020          throw new FHIRException("Cannot call addChild on a primitive type AllergyIntolerance.category");
2021        }
2022        else if (name.equals("lastOccurence")) {
2023          throw new FHIRException("Cannot call addChild on a primitive type AllergyIntolerance.lastOccurence");
2024        }
2025        else if (name.equals("note")) {
2026          this.note = new Annotation();
2027          return this.note;
2028        }
2029        else if (name.equals("reaction")) {
2030          return addReaction();
2031        }
2032        else
2033          return super.addChild(name);
2034      }
2035
2036  public String fhirType() {
2037    return "AllergyIntolerance";
2038
2039  }
2040
2041      public AllergyIntolerance copy() {
2042        AllergyIntolerance dst = new AllergyIntolerance();
2043        copyValues(dst);
2044        if (identifier != null) {
2045          dst.identifier = new ArrayList<Identifier>();
2046          for (Identifier i : identifier)
2047            dst.identifier.add(i.copy());
2048        };
2049        dst.onset = onset == null ? null : onset.copy();
2050        dst.recordedDate = recordedDate == null ? null : recordedDate.copy();
2051        dst.recorder = recorder == null ? null : recorder.copy();
2052        dst.patient = patient == null ? null : patient.copy();
2053        dst.reporter = reporter == null ? null : reporter.copy();
2054        dst.substance = substance == null ? null : substance.copy();
2055        dst.status = status == null ? null : status.copy();
2056        dst.criticality = criticality == null ? null : criticality.copy();
2057        dst.type = type == null ? null : type.copy();
2058        dst.category = category == null ? null : category.copy();
2059        dst.lastOccurence = lastOccurence == null ? null : lastOccurence.copy();
2060        dst.note = note == null ? null : note.copy();
2061        if (reaction != null) {
2062          dst.reaction = new ArrayList<AllergyIntoleranceReactionComponent>();
2063          for (AllergyIntoleranceReactionComponent i : reaction)
2064            dst.reaction.add(i.copy());
2065        };
2066        return dst;
2067      }
2068
2069      protected AllergyIntolerance typedCopy() {
2070        return copy();
2071      }
2072
2073      @Override
2074      public boolean equalsDeep(Base other) {
2075        if (!super.equalsDeep(other))
2076          return false;
2077        if (!(other instanceof AllergyIntolerance))
2078          return false;
2079        AllergyIntolerance o = (AllergyIntolerance) other;
2080        return compareDeep(identifier, o.identifier, true) && compareDeep(onset, o.onset, true) && compareDeep(recordedDate, o.recordedDate, true)
2081           && compareDeep(recorder, o.recorder, true) && compareDeep(patient, o.patient, true) && compareDeep(reporter, o.reporter, true)
2082           && compareDeep(substance, o.substance, true) && compareDeep(status, o.status, true) && compareDeep(criticality, o.criticality, true)
2083           && compareDeep(type, o.type, true) && compareDeep(category, o.category, true) && compareDeep(lastOccurence, o.lastOccurence, true)
2084           && compareDeep(note, o.note, true) && compareDeep(reaction, o.reaction, true);
2085      }
2086
2087      @Override
2088      public boolean equalsShallow(Base other) {
2089        if (!super.equalsShallow(other))
2090          return false;
2091        if (!(other instanceof AllergyIntolerance))
2092          return false;
2093        AllergyIntolerance o = (AllergyIntolerance) other;
2094        return compareValues(onset, o.onset, true) && compareValues(recordedDate, o.recordedDate, true) && compareValues(status, o.status, true)
2095           && compareValues(criticality, o.criticality, true) && compareValues(type, o.type, true) && compareValues(category, o.category, true)
2096           && compareValues(lastOccurence, o.lastOccurence, true);
2097      }
2098
2099      public boolean isEmpty() {
2100        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (onset == null || onset.isEmpty())
2101           && (recordedDate == null || recordedDate.isEmpty()) && (recorder == null || recorder.isEmpty())
2102           && (patient == null || patient.isEmpty()) && (reporter == null || reporter.isEmpty()) && (substance == null || substance.isEmpty())
2103           && (status == null || status.isEmpty()) && (criticality == null || criticality.isEmpty())
2104           && (type == null || type.isEmpty()) && (category == null || category.isEmpty()) && (lastOccurence == null || lastOccurence.isEmpty())
2105           && (note == null || note.isEmpty()) && (reaction == null || reaction.isEmpty());
2106      }
2107
2108  @Override
2109  public ResourceType getResourceType() {
2110    return ResourceType.AllergyIntolerance;
2111   }
2112
2113  @SearchParamDefinition(name="severity", path="AllergyIntolerance.reaction.severity", description="mild | moderate | severe (of event as a whole)", type="token" )
2114  public static final String SP_SEVERITY = "severity";
2115  @SearchParamDefinition(name="date", path="AllergyIntolerance.recordedDate", description="When recorded", type="date" )
2116  public static final String SP_DATE = "date";
2117  @SearchParamDefinition(name="identifier", path="AllergyIntolerance.identifier", description="External ids for this item", type="token" )
2118  public static final String SP_IDENTIFIER = "identifier";
2119  @SearchParamDefinition(name="manifestation", path="AllergyIntolerance.reaction.manifestation", description="Clinical symptoms/signs associated with the Event", type="token" )
2120  public static final String SP_MANIFESTATION = "manifestation";
2121  @SearchParamDefinition(name="recorder", path="AllergyIntolerance.recorder", description="Who recorded the sensitivity", type="reference" )
2122  public static final String SP_RECORDER = "recorder";
2123  @SearchParamDefinition(name="substance", path="AllergyIntolerance.substance | AllergyIntolerance.reaction.substance", description="Substance, (or class) considered to be responsible for risk", type="token" )
2124  public static final String SP_SUBSTANCE = "substance";
2125  @SearchParamDefinition(name="criticality", path="AllergyIntolerance.criticality", description="CRITL | CRITH | CRITU", type="token" )
2126  public static final String SP_CRITICALITY = "criticality";
2127  @SearchParamDefinition(name="reporter", path="AllergyIntolerance.reporter", description="Source of the information about the allergy", type="reference" )
2128  public static final String SP_REPORTER = "reporter";
2129  @SearchParamDefinition(name="type", path="AllergyIntolerance.type", description="allergy | intolerance - Underlying mechanism (if known)", type="token" )
2130  public static final String SP_TYPE = "type";
2131  @SearchParamDefinition(name="onset", path="AllergyIntolerance.reaction.onset", description="Date(/time) when manifestations showed", type="date" )
2132  public static final String SP_ONSET = "onset";
2133  @SearchParamDefinition(name="route", path="AllergyIntolerance.reaction.exposureRoute", description="How the subject was exposed to the substance", type="token" )
2134  public static final String SP_ROUTE = "route";
2135  @SearchParamDefinition(name="patient", path="AllergyIntolerance.patient", description="Who the sensitivity is for", type="reference" )
2136  public static final String SP_PATIENT = "patient";
2137  @SearchParamDefinition(name="category", path="AllergyIntolerance.category", description="food | medication | environment | other - Category of Substance", type="token" )
2138  public static final String SP_CATEGORY = "category";
2139  @SearchParamDefinition(name="last-date", path="AllergyIntolerance.lastOccurence", description="Date(/time) of last known occurrence of a reaction", type="date" )
2140  public static final String SP_LASTDATE = "last-date";
2141  @SearchParamDefinition(name="status", path="AllergyIntolerance.status", description="active | unconfirmed | confirmed | inactive | resolved | refuted | entered-in-error", type="token" )
2142  public static final String SP_STATUS = "status";
2143
2144}
2145