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