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