001package org.hl7.fhir.instance.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
033import java.util.*;
034
035import org.hl7.fhir.exceptions.FHIRException;
036import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
037import org.hl7.fhir.utilities.Utilities;
038
039import ca.uhn.fhir.model.api.annotation.*;
040/**
041 * Describes the event of a patient being administered a vaccination or a record of a vaccination as reported by a patient, a clinician or another party and may include vaccine reaction information and what vaccination protocol was followed.
042 */
043@ResourceDef(name="Immunization", profile="http://hl7.org/fhir/Profile/Immunization")
044public class Immunization extends DomainResource {
045
046    @Block()
047    public static class ImmunizationExplanationComponent extends BackboneElement implements IBaseBackboneElement {
048        /**
049         * Reasons why a vaccine was administered.
050         */
051        @Child(name = "reason", type = {CodeableConcept.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
052        @Description(shortDefinition="Why immunization occurred", formalDefinition="Reasons why a vaccine was administered." )
053        protected List<CodeableConcept> reason;
054
055        /**
056         * Reason why a vaccine was not administered.
057         */
058        @Child(name = "reasonNotGiven", type = {CodeableConcept.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
059        @Description(shortDefinition="Why immunization did not occur", formalDefinition="Reason why a vaccine was not administered." )
060        protected List<CodeableConcept> reasonNotGiven;
061
062        private static final long serialVersionUID = -539821866L;
063
064    /*
065     * Constructor
066     */
067      public ImmunizationExplanationComponent() {
068        super();
069      }
070
071        /**
072         * @return {@link #reason} (Reasons why a vaccine was administered.)
073         */
074        public List<CodeableConcept> getReason() { 
075          if (this.reason == null)
076            this.reason = new ArrayList<CodeableConcept>();
077          return this.reason;
078        }
079
080        public boolean hasReason() { 
081          if (this.reason == null)
082            return false;
083          for (CodeableConcept item : this.reason)
084            if (!item.isEmpty())
085              return true;
086          return false;
087        }
088
089        /**
090         * @return {@link #reason} (Reasons why a vaccine was administered.)
091         */
092    // syntactic sugar
093        public CodeableConcept addReason() { //3
094          CodeableConcept t = new CodeableConcept();
095          if (this.reason == null)
096            this.reason = new ArrayList<CodeableConcept>();
097          this.reason.add(t);
098          return t;
099        }
100
101    // syntactic sugar
102        public ImmunizationExplanationComponent addReason(CodeableConcept t) { //3
103          if (t == null)
104            return this;
105          if (this.reason == null)
106            this.reason = new ArrayList<CodeableConcept>();
107          this.reason.add(t);
108          return this;
109        }
110
111        /**
112         * @return {@link #reasonNotGiven} (Reason why a vaccine was not administered.)
113         */
114        public List<CodeableConcept> getReasonNotGiven() { 
115          if (this.reasonNotGiven == null)
116            this.reasonNotGiven = new ArrayList<CodeableConcept>();
117          return this.reasonNotGiven;
118        }
119
120        public boolean hasReasonNotGiven() { 
121          if (this.reasonNotGiven == null)
122            return false;
123          for (CodeableConcept item : this.reasonNotGiven)
124            if (!item.isEmpty())
125              return true;
126          return false;
127        }
128
129        /**
130         * @return {@link #reasonNotGiven} (Reason why a vaccine was not administered.)
131         */
132    // syntactic sugar
133        public CodeableConcept addReasonNotGiven() { //3
134          CodeableConcept t = new CodeableConcept();
135          if (this.reasonNotGiven == null)
136            this.reasonNotGiven = new ArrayList<CodeableConcept>();
137          this.reasonNotGiven.add(t);
138          return t;
139        }
140
141    // syntactic sugar
142        public ImmunizationExplanationComponent addReasonNotGiven(CodeableConcept t) { //3
143          if (t == null)
144            return this;
145          if (this.reasonNotGiven == null)
146            this.reasonNotGiven = new ArrayList<CodeableConcept>();
147          this.reasonNotGiven.add(t);
148          return this;
149        }
150
151        protected void listChildren(List<Property> childrenList) {
152          super.listChildren(childrenList);
153          childrenList.add(new Property("reason", "CodeableConcept", "Reasons why a vaccine was administered.", 0, java.lang.Integer.MAX_VALUE, reason));
154          childrenList.add(new Property("reasonNotGiven", "CodeableConcept", "Reason why a vaccine was not administered.", 0, java.lang.Integer.MAX_VALUE, reasonNotGiven));
155        }
156
157      @Override
158      public void setProperty(String name, Base value) throws FHIRException {
159        if (name.equals("reason"))
160          this.getReason().add(castToCodeableConcept(value));
161        else if (name.equals("reasonNotGiven"))
162          this.getReasonNotGiven().add(castToCodeableConcept(value));
163        else
164          super.setProperty(name, value);
165      }
166
167      @Override
168      public Base addChild(String name) throws FHIRException {
169        if (name.equals("reason")) {
170          return addReason();
171        }
172        else if (name.equals("reasonNotGiven")) {
173          return addReasonNotGiven();
174        }
175        else
176          return super.addChild(name);
177      }
178
179      public ImmunizationExplanationComponent copy() {
180        ImmunizationExplanationComponent dst = new ImmunizationExplanationComponent();
181        copyValues(dst);
182        if (reason != null) {
183          dst.reason = new ArrayList<CodeableConcept>();
184          for (CodeableConcept i : reason)
185            dst.reason.add(i.copy());
186        };
187        if (reasonNotGiven != null) {
188          dst.reasonNotGiven = new ArrayList<CodeableConcept>();
189          for (CodeableConcept i : reasonNotGiven)
190            dst.reasonNotGiven.add(i.copy());
191        };
192        return dst;
193      }
194
195      @Override
196      public boolean equalsDeep(Base other) {
197        if (!super.equalsDeep(other))
198          return false;
199        if (!(other instanceof ImmunizationExplanationComponent))
200          return false;
201        ImmunizationExplanationComponent o = (ImmunizationExplanationComponent) other;
202        return compareDeep(reason, o.reason, true) && compareDeep(reasonNotGiven, o.reasonNotGiven, true)
203          ;
204      }
205
206      @Override
207      public boolean equalsShallow(Base other) {
208        if (!super.equalsShallow(other))
209          return false;
210        if (!(other instanceof ImmunizationExplanationComponent))
211          return false;
212        ImmunizationExplanationComponent o = (ImmunizationExplanationComponent) other;
213        return true;
214      }
215
216      public boolean isEmpty() {
217        return super.isEmpty() && (reason == null || reason.isEmpty()) && (reasonNotGiven == null || reasonNotGiven.isEmpty())
218          ;
219      }
220
221  public String fhirType() {
222    return "Immunization.explanation";
223
224  }
225
226  }
227
228    @Block()
229    public static class ImmunizationReactionComponent extends BackboneElement implements IBaseBackboneElement {
230        /**
231         * Date of reaction to the immunization.
232         */
233        @Child(name = "date", type = {DateTimeType.class}, order=1, min=0, max=1, modifier=false, summary=false)
234        @Description(shortDefinition="When reaction started", formalDefinition="Date of reaction to the immunization." )
235        protected DateTimeType date;
236
237        /**
238         * Details of the reaction.
239         */
240        @Child(name = "detail", type = {Observation.class}, order=2, min=0, max=1, modifier=false, summary=false)
241        @Description(shortDefinition="Additional information on reaction", formalDefinition="Details of the reaction." )
242        protected Reference detail;
243
244        /**
245         * The actual object that is the target of the reference (Details of the reaction.)
246         */
247        protected Observation detailTarget;
248
249        /**
250         * Self-reported indicator.
251         */
252        @Child(name = "reported", type = {BooleanType.class}, order=3, min=0, max=1, modifier=false, summary=false)
253        @Description(shortDefinition="Indicates self-reported reaction", formalDefinition="Self-reported indicator." )
254        protected BooleanType reported;
255
256        private static final long serialVersionUID = -1297668556L;
257
258    /*
259     * Constructor
260     */
261      public ImmunizationReactionComponent() {
262        super();
263      }
264
265        /**
266         * @return {@link #date} (Date of reaction to the immunization.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
267         */
268        public DateTimeType getDateElement() { 
269          if (this.date == null)
270            if (Configuration.errorOnAutoCreate())
271              throw new Error("Attempt to auto-create ImmunizationReactionComponent.date");
272            else if (Configuration.doAutoCreate())
273              this.date = new DateTimeType(); // bb
274          return this.date;
275        }
276
277        public boolean hasDateElement() { 
278          return this.date != null && !this.date.isEmpty();
279        }
280
281        public boolean hasDate() { 
282          return this.date != null && !this.date.isEmpty();
283        }
284
285        /**
286         * @param value {@link #date} (Date of reaction to the immunization.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
287         */
288        public ImmunizationReactionComponent setDateElement(DateTimeType value) { 
289          this.date = value;
290          return this;
291        }
292
293        /**
294         * @return Date of reaction to the immunization.
295         */
296        public Date getDate() { 
297          return this.date == null ? null : this.date.getValue();
298        }
299
300        /**
301         * @param value Date of reaction to the immunization.
302         */
303        public ImmunizationReactionComponent setDate(Date value) { 
304          if (value == null)
305            this.date = null;
306          else {
307            if (this.date == null)
308              this.date = new DateTimeType();
309            this.date.setValue(value);
310          }
311          return this;
312        }
313
314        /**
315         * @return {@link #detail} (Details of the reaction.)
316         */
317        public Reference getDetail() { 
318          if (this.detail == null)
319            if (Configuration.errorOnAutoCreate())
320              throw new Error("Attempt to auto-create ImmunizationReactionComponent.detail");
321            else if (Configuration.doAutoCreate())
322              this.detail = new Reference(); // cc
323          return this.detail;
324        }
325
326        public boolean hasDetail() { 
327          return this.detail != null && !this.detail.isEmpty();
328        }
329
330        /**
331         * @param value {@link #detail} (Details of the reaction.)
332         */
333        public ImmunizationReactionComponent setDetail(Reference value) { 
334          this.detail = value;
335          return this;
336        }
337
338        /**
339         * @return {@link #detail} 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. (Details of the reaction.)
340         */
341        public Observation getDetailTarget() { 
342          if (this.detailTarget == null)
343            if (Configuration.errorOnAutoCreate())
344              throw new Error("Attempt to auto-create ImmunizationReactionComponent.detail");
345            else if (Configuration.doAutoCreate())
346              this.detailTarget = new Observation(); // aa
347          return this.detailTarget;
348        }
349
350        /**
351         * @param value {@link #detail} 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. (Details of the reaction.)
352         */
353        public ImmunizationReactionComponent setDetailTarget(Observation value) { 
354          this.detailTarget = value;
355          return this;
356        }
357
358        /**
359         * @return {@link #reported} (Self-reported indicator.). This is the underlying object with id, value and extensions. The accessor "getReported" gives direct access to the value
360         */
361        public BooleanType getReportedElement() { 
362          if (this.reported == null)
363            if (Configuration.errorOnAutoCreate())
364              throw new Error("Attempt to auto-create ImmunizationReactionComponent.reported");
365            else if (Configuration.doAutoCreate())
366              this.reported = new BooleanType(); // bb
367          return this.reported;
368        }
369
370        public boolean hasReportedElement() { 
371          return this.reported != null && !this.reported.isEmpty();
372        }
373
374        public boolean hasReported() { 
375          return this.reported != null && !this.reported.isEmpty();
376        }
377
378        /**
379         * @param value {@link #reported} (Self-reported indicator.). This is the underlying object with id, value and extensions. The accessor "getReported" gives direct access to the value
380         */
381        public ImmunizationReactionComponent setReportedElement(BooleanType value) { 
382          this.reported = value;
383          return this;
384        }
385
386        /**
387         * @return Self-reported indicator.
388         */
389        public boolean getReported() { 
390          return this.reported == null || this.reported.isEmpty() ? false : this.reported.getValue();
391        }
392
393        /**
394         * @param value Self-reported indicator.
395         */
396        public ImmunizationReactionComponent setReported(boolean value) { 
397            if (this.reported == null)
398              this.reported = new BooleanType();
399            this.reported.setValue(value);
400          return this;
401        }
402
403        protected void listChildren(List<Property> childrenList) {
404          super.listChildren(childrenList);
405          childrenList.add(new Property("date", "dateTime", "Date of reaction to the immunization.", 0, java.lang.Integer.MAX_VALUE, date));
406          childrenList.add(new Property("detail", "Reference(Observation)", "Details of the reaction.", 0, java.lang.Integer.MAX_VALUE, detail));
407          childrenList.add(new Property("reported", "boolean", "Self-reported indicator.", 0, java.lang.Integer.MAX_VALUE, reported));
408        }
409
410      @Override
411      public void setProperty(String name, Base value) throws FHIRException {
412        if (name.equals("date"))
413          this.date = castToDateTime(value); // DateTimeType
414        else if (name.equals("detail"))
415          this.detail = castToReference(value); // Reference
416        else if (name.equals("reported"))
417          this.reported = castToBoolean(value); // BooleanType
418        else
419          super.setProperty(name, value);
420      }
421
422      @Override
423      public Base addChild(String name) throws FHIRException {
424        if (name.equals("date")) {
425          throw new FHIRException("Cannot call addChild on a primitive type Immunization.date");
426        }
427        else if (name.equals("detail")) {
428          this.detail = new Reference();
429          return this.detail;
430        }
431        else if (name.equals("reported")) {
432          throw new FHIRException("Cannot call addChild on a primitive type Immunization.reported");
433        }
434        else
435          return super.addChild(name);
436      }
437
438      public ImmunizationReactionComponent copy() {
439        ImmunizationReactionComponent dst = new ImmunizationReactionComponent();
440        copyValues(dst);
441        dst.date = date == null ? null : date.copy();
442        dst.detail = detail == null ? null : detail.copy();
443        dst.reported = reported == null ? null : reported.copy();
444        return dst;
445      }
446
447      @Override
448      public boolean equalsDeep(Base other) {
449        if (!super.equalsDeep(other))
450          return false;
451        if (!(other instanceof ImmunizationReactionComponent))
452          return false;
453        ImmunizationReactionComponent o = (ImmunizationReactionComponent) other;
454        return compareDeep(date, o.date, true) && compareDeep(detail, o.detail, true) && compareDeep(reported, o.reported, true)
455          ;
456      }
457
458      @Override
459      public boolean equalsShallow(Base other) {
460        if (!super.equalsShallow(other))
461          return false;
462        if (!(other instanceof ImmunizationReactionComponent))
463          return false;
464        ImmunizationReactionComponent o = (ImmunizationReactionComponent) other;
465        return compareValues(date, o.date, true) && compareValues(reported, o.reported, true);
466      }
467
468      public boolean isEmpty() {
469        return super.isEmpty() && (date == null || date.isEmpty()) && (detail == null || detail.isEmpty())
470           && (reported == null || reported.isEmpty());
471      }
472
473  public String fhirType() {
474    return "Immunization.reaction";
475
476  }
477
478  }
479
480    @Block()
481    public static class ImmunizationVaccinationProtocolComponent extends BackboneElement implements IBaseBackboneElement {
482        /**
483         * Nominal position in a series.
484         */
485        @Child(name = "doseSequence", type = {PositiveIntType.class}, order=1, min=1, max=1, modifier=false, summary=false)
486        @Description(shortDefinition="Dose number within series", formalDefinition="Nominal position in a series." )
487        protected PositiveIntType doseSequence;
488
489        /**
490         * Contains the description about the protocol under which the vaccine was administered.
491         */
492        @Child(name = "description", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=false)
493        @Description(shortDefinition="Details of vaccine protocol", formalDefinition="Contains the description about the protocol under which the vaccine was administered." )
494        protected StringType description;
495
496        /**
497         * Indicates the authority who published the protocol.  E.g. ACIP.
498         */
499        @Child(name = "authority", type = {Organization.class}, order=3, min=0, max=1, modifier=false, summary=false)
500        @Description(shortDefinition="Who is responsible for protocol", formalDefinition="Indicates the authority who published the protocol.  E.g. ACIP." )
501        protected Reference authority;
502
503        /**
504         * The actual object that is the target of the reference (Indicates the authority who published the protocol.  E.g. ACIP.)
505         */
506        protected Organization authorityTarget;
507
508        /**
509         * One possible path to achieve presumed immunity against a disease - within the context of an authority.
510         */
511        @Child(name = "series", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=false)
512        @Description(shortDefinition="Name of vaccine series", formalDefinition="One possible path to achieve presumed immunity against a disease - within the context of an authority." )
513        protected StringType series;
514
515        /**
516         * The recommended number of doses to achieve immunity.
517         */
518        @Child(name = "seriesDoses", type = {PositiveIntType.class}, order=5, min=0, max=1, modifier=false, summary=false)
519        @Description(shortDefinition="Recommended number of doses for immunity", formalDefinition="The recommended number of doses to achieve immunity." )
520        protected PositiveIntType seriesDoses;
521
522        /**
523         * The targeted disease.
524         */
525        @Child(name = "targetDisease", type = {CodeableConcept.class}, order=6, min=1, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
526        @Description(shortDefinition="Disease immunized against", formalDefinition="The targeted disease." )
527        protected List<CodeableConcept> targetDisease;
528
529        /**
530         * Indicates if the immunization event should "count" against  the protocol.
531         */
532        @Child(name = "doseStatus", type = {CodeableConcept.class}, order=7, min=1, max=1, modifier=false, summary=false)
533        @Description(shortDefinition="Indicates if dose counts towards immunity", formalDefinition="Indicates if the immunization event should \"count\" against  the protocol." )
534        protected CodeableConcept doseStatus;
535
536        /**
537         * Provides an explanation as to why an immunization event should or should not count against the protocol.
538         */
539        @Child(name = "doseStatusReason", type = {CodeableConcept.class}, order=8, min=0, max=1, modifier=false, summary=false)
540        @Description(shortDefinition="Why dose does (not) count", formalDefinition="Provides an explanation as to why an immunization event should or should not count against the protocol." )
541        protected CodeableConcept doseStatusReason;
542
543        private static final long serialVersionUID = 386814037L;
544
545    /*
546     * Constructor
547     */
548      public ImmunizationVaccinationProtocolComponent() {
549        super();
550      }
551
552    /*
553     * Constructor
554     */
555      public ImmunizationVaccinationProtocolComponent(PositiveIntType doseSequence, CodeableConcept doseStatus) {
556        super();
557        this.doseSequence = doseSequence;
558        this.doseStatus = doseStatus;
559      }
560
561        /**
562         * @return {@link #doseSequence} (Nominal position in a series.). This is the underlying object with id, value and extensions. The accessor "getDoseSequence" gives direct access to the value
563         */
564        public PositiveIntType getDoseSequenceElement() { 
565          if (this.doseSequence == null)
566            if (Configuration.errorOnAutoCreate())
567              throw new Error("Attempt to auto-create ImmunizationVaccinationProtocolComponent.doseSequence");
568            else if (Configuration.doAutoCreate())
569              this.doseSequence = new PositiveIntType(); // bb
570          return this.doseSequence;
571        }
572
573        public boolean hasDoseSequenceElement() { 
574          return this.doseSequence != null && !this.doseSequence.isEmpty();
575        }
576
577        public boolean hasDoseSequence() { 
578          return this.doseSequence != null && !this.doseSequence.isEmpty();
579        }
580
581        /**
582         * @param value {@link #doseSequence} (Nominal position in a series.). This is the underlying object with id, value and extensions. The accessor "getDoseSequence" gives direct access to the value
583         */
584        public ImmunizationVaccinationProtocolComponent setDoseSequenceElement(PositiveIntType value) { 
585          this.doseSequence = value;
586          return this;
587        }
588
589        /**
590         * @return Nominal position in a series.
591         */
592        public int getDoseSequence() { 
593          return this.doseSequence == null || this.doseSequence.isEmpty() ? 0 : this.doseSequence.getValue();
594        }
595
596        /**
597         * @param value Nominal position in a series.
598         */
599        public ImmunizationVaccinationProtocolComponent setDoseSequence(int value) { 
600            if (this.doseSequence == null)
601              this.doseSequence = new PositiveIntType();
602            this.doseSequence.setValue(value);
603          return this;
604        }
605
606        /**
607         * @return {@link #description} (Contains the description about the protocol under which the vaccine was administered.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
608         */
609        public StringType getDescriptionElement() { 
610          if (this.description == null)
611            if (Configuration.errorOnAutoCreate())
612              throw new Error("Attempt to auto-create ImmunizationVaccinationProtocolComponent.description");
613            else if (Configuration.doAutoCreate())
614              this.description = new StringType(); // bb
615          return this.description;
616        }
617
618        public boolean hasDescriptionElement() { 
619          return this.description != null && !this.description.isEmpty();
620        }
621
622        public boolean hasDescription() { 
623          return this.description != null && !this.description.isEmpty();
624        }
625
626        /**
627         * @param value {@link #description} (Contains the description about the protocol under which the vaccine was administered.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
628         */
629        public ImmunizationVaccinationProtocolComponent setDescriptionElement(StringType value) { 
630          this.description = value;
631          return this;
632        }
633
634        /**
635         * @return Contains the description about the protocol under which the vaccine was administered.
636         */
637        public String getDescription() { 
638          return this.description == null ? null : this.description.getValue();
639        }
640
641        /**
642         * @param value Contains the description about the protocol under which the vaccine was administered.
643         */
644        public ImmunizationVaccinationProtocolComponent setDescription(String value) { 
645          if (Utilities.noString(value))
646            this.description = null;
647          else {
648            if (this.description == null)
649              this.description = new StringType();
650            this.description.setValue(value);
651          }
652          return this;
653        }
654
655        /**
656         * @return {@link #authority} (Indicates the authority who published the protocol.  E.g. ACIP.)
657         */
658        public Reference getAuthority() { 
659          if (this.authority == null)
660            if (Configuration.errorOnAutoCreate())
661              throw new Error("Attempt to auto-create ImmunizationVaccinationProtocolComponent.authority");
662            else if (Configuration.doAutoCreate())
663              this.authority = new Reference(); // cc
664          return this.authority;
665        }
666
667        public boolean hasAuthority() { 
668          return this.authority != null && !this.authority.isEmpty();
669        }
670
671        /**
672         * @param value {@link #authority} (Indicates the authority who published the protocol.  E.g. ACIP.)
673         */
674        public ImmunizationVaccinationProtocolComponent setAuthority(Reference value) { 
675          this.authority = value;
676          return this;
677        }
678
679        /**
680         * @return {@link #authority} 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. (Indicates the authority who published the protocol.  E.g. ACIP.)
681         */
682        public Organization getAuthorityTarget() { 
683          if (this.authorityTarget == null)
684            if (Configuration.errorOnAutoCreate())
685              throw new Error("Attempt to auto-create ImmunizationVaccinationProtocolComponent.authority");
686            else if (Configuration.doAutoCreate())
687              this.authorityTarget = new Organization(); // aa
688          return this.authorityTarget;
689        }
690
691        /**
692         * @param value {@link #authority} 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. (Indicates the authority who published the protocol.  E.g. ACIP.)
693         */
694        public ImmunizationVaccinationProtocolComponent setAuthorityTarget(Organization value) { 
695          this.authorityTarget = value;
696          return this;
697        }
698
699        /**
700         * @return {@link #series} (One possible path to achieve presumed immunity against a disease - within the context of an authority.). This is the underlying object with id, value and extensions. The accessor "getSeries" gives direct access to the value
701         */
702        public StringType getSeriesElement() { 
703          if (this.series == null)
704            if (Configuration.errorOnAutoCreate())
705              throw new Error("Attempt to auto-create ImmunizationVaccinationProtocolComponent.series");
706            else if (Configuration.doAutoCreate())
707              this.series = new StringType(); // bb
708          return this.series;
709        }
710
711        public boolean hasSeriesElement() { 
712          return this.series != null && !this.series.isEmpty();
713        }
714
715        public boolean hasSeries() { 
716          return this.series != null && !this.series.isEmpty();
717        }
718
719        /**
720         * @param value {@link #series} (One possible path to achieve presumed immunity against a disease - within the context of an authority.). This is the underlying object with id, value and extensions. The accessor "getSeries" gives direct access to the value
721         */
722        public ImmunizationVaccinationProtocolComponent setSeriesElement(StringType value) { 
723          this.series = value;
724          return this;
725        }
726
727        /**
728         * @return One possible path to achieve presumed immunity against a disease - within the context of an authority.
729         */
730        public String getSeries() { 
731          return this.series == null ? null : this.series.getValue();
732        }
733
734        /**
735         * @param value One possible path to achieve presumed immunity against a disease - within the context of an authority.
736         */
737        public ImmunizationVaccinationProtocolComponent setSeries(String value) { 
738          if (Utilities.noString(value))
739            this.series = null;
740          else {
741            if (this.series == null)
742              this.series = new StringType();
743            this.series.setValue(value);
744          }
745          return this;
746        }
747
748        /**
749         * @return {@link #seriesDoses} (The recommended number of doses to achieve immunity.). This is the underlying object with id, value and extensions. The accessor "getSeriesDoses" gives direct access to the value
750         */
751        public PositiveIntType getSeriesDosesElement() { 
752          if (this.seriesDoses == null)
753            if (Configuration.errorOnAutoCreate())
754              throw new Error("Attempt to auto-create ImmunizationVaccinationProtocolComponent.seriesDoses");
755            else if (Configuration.doAutoCreate())
756              this.seriesDoses = new PositiveIntType(); // bb
757          return this.seriesDoses;
758        }
759
760        public boolean hasSeriesDosesElement() { 
761          return this.seriesDoses != null && !this.seriesDoses.isEmpty();
762        }
763
764        public boolean hasSeriesDoses() { 
765          return this.seriesDoses != null && !this.seriesDoses.isEmpty();
766        }
767
768        /**
769         * @param value {@link #seriesDoses} (The recommended number of doses to achieve immunity.). This is the underlying object with id, value and extensions. The accessor "getSeriesDoses" gives direct access to the value
770         */
771        public ImmunizationVaccinationProtocolComponent setSeriesDosesElement(PositiveIntType value) { 
772          this.seriesDoses = value;
773          return this;
774        }
775
776        /**
777         * @return The recommended number of doses to achieve immunity.
778         */
779        public int getSeriesDoses() { 
780          return this.seriesDoses == null || this.seriesDoses.isEmpty() ? 0 : this.seriesDoses.getValue();
781        }
782
783        /**
784         * @param value The recommended number of doses to achieve immunity.
785         */
786        public ImmunizationVaccinationProtocolComponent setSeriesDoses(int value) { 
787            if (this.seriesDoses == null)
788              this.seriesDoses = new PositiveIntType();
789            this.seriesDoses.setValue(value);
790          return this;
791        }
792
793        /**
794         * @return {@link #targetDisease} (The targeted disease.)
795         */
796        public List<CodeableConcept> getTargetDisease() { 
797          if (this.targetDisease == null)
798            this.targetDisease = new ArrayList<CodeableConcept>();
799          return this.targetDisease;
800        }
801
802        public boolean hasTargetDisease() { 
803          if (this.targetDisease == null)
804            return false;
805          for (CodeableConcept item : this.targetDisease)
806            if (!item.isEmpty())
807              return true;
808          return false;
809        }
810
811        /**
812         * @return {@link #targetDisease} (The targeted disease.)
813         */
814    // syntactic sugar
815        public CodeableConcept addTargetDisease() { //3
816          CodeableConcept t = new CodeableConcept();
817          if (this.targetDisease == null)
818            this.targetDisease = new ArrayList<CodeableConcept>();
819          this.targetDisease.add(t);
820          return t;
821        }
822
823    // syntactic sugar
824        public ImmunizationVaccinationProtocolComponent addTargetDisease(CodeableConcept t) { //3
825          if (t == null)
826            return this;
827          if (this.targetDisease == null)
828            this.targetDisease = new ArrayList<CodeableConcept>();
829          this.targetDisease.add(t);
830          return this;
831        }
832
833        /**
834         * @return {@link #doseStatus} (Indicates if the immunization event should "count" against  the protocol.)
835         */
836        public CodeableConcept getDoseStatus() { 
837          if (this.doseStatus == null)
838            if (Configuration.errorOnAutoCreate())
839              throw new Error("Attempt to auto-create ImmunizationVaccinationProtocolComponent.doseStatus");
840            else if (Configuration.doAutoCreate())
841              this.doseStatus = new CodeableConcept(); // cc
842          return this.doseStatus;
843        }
844
845        public boolean hasDoseStatus() { 
846          return this.doseStatus != null && !this.doseStatus.isEmpty();
847        }
848
849        /**
850         * @param value {@link #doseStatus} (Indicates if the immunization event should "count" against  the protocol.)
851         */
852        public ImmunizationVaccinationProtocolComponent setDoseStatus(CodeableConcept value) { 
853          this.doseStatus = value;
854          return this;
855        }
856
857        /**
858         * @return {@link #doseStatusReason} (Provides an explanation as to why an immunization event should or should not count against the protocol.)
859         */
860        public CodeableConcept getDoseStatusReason() { 
861          if (this.doseStatusReason == null)
862            if (Configuration.errorOnAutoCreate())
863              throw new Error("Attempt to auto-create ImmunizationVaccinationProtocolComponent.doseStatusReason");
864            else if (Configuration.doAutoCreate())
865              this.doseStatusReason = new CodeableConcept(); // cc
866          return this.doseStatusReason;
867        }
868
869        public boolean hasDoseStatusReason() { 
870          return this.doseStatusReason != null && !this.doseStatusReason.isEmpty();
871        }
872
873        /**
874         * @param value {@link #doseStatusReason} (Provides an explanation as to why an immunization event should or should not count against the protocol.)
875         */
876        public ImmunizationVaccinationProtocolComponent setDoseStatusReason(CodeableConcept value) { 
877          this.doseStatusReason = value;
878          return this;
879        }
880
881        protected void listChildren(List<Property> childrenList) {
882          super.listChildren(childrenList);
883          childrenList.add(new Property("doseSequence", "positiveInt", "Nominal position in a series.", 0, java.lang.Integer.MAX_VALUE, doseSequence));
884          childrenList.add(new Property("description", "string", "Contains the description about the protocol under which the vaccine was administered.", 0, java.lang.Integer.MAX_VALUE, description));
885          childrenList.add(new Property("authority", "Reference(Organization)", "Indicates the authority who published the protocol.  E.g. ACIP.", 0, java.lang.Integer.MAX_VALUE, authority));
886          childrenList.add(new Property("series", "string", "One possible path to achieve presumed immunity against a disease - within the context of an authority.", 0, java.lang.Integer.MAX_VALUE, series));
887          childrenList.add(new Property("seriesDoses", "positiveInt", "The recommended number of doses to achieve immunity.", 0, java.lang.Integer.MAX_VALUE, seriesDoses));
888          childrenList.add(new Property("targetDisease", "CodeableConcept", "The targeted disease.", 0, java.lang.Integer.MAX_VALUE, targetDisease));
889          childrenList.add(new Property("doseStatus", "CodeableConcept", "Indicates if the immunization event should \"count\" against  the protocol.", 0, java.lang.Integer.MAX_VALUE, doseStatus));
890          childrenList.add(new Property("doseStatusReason", "CodeableConcept", "Provides an explanation as to why an immunization event should or should not count against the protocol.", 0, java.lang.Integer.MAX_VALUE, doseStatusReason));
891        }
892
893      @Override
894      public void setProperty(String name, Base value) throws FHIRException {
895        if (name.equals("doseSequence"))
896          this.doseSequence = castToPositiveInt(value); // PositiveIntType
897        else if (name.equals("description"))
898          this.description = castToString(value); // StringType
899        else if (name.equals("authority"))
900          this.authority = castToReference(value); // Reference
901        else if (name.equals("series"))
902          this.series = castToString(value); // StringType
903        else if (name.equals("seriesDoses"))
904          this.seriesDoses = castToPositiveInt(value); // PositiveIntType
905        else if (name.equals("targetDisease"))
906          this.getTargetDisease().add(castToCodeableConcept(value));
907        else if (name.equals("doseStatus"))
908          this.doseStatus = castToCodeableConcept(value); // CodeableConcept
909        else if (name.equals("doseStatusReason"))
910          this.doseStatusReason = castToCodeableConcept(value); // CodeableConcept
911        else
912          super.setProperty(name, value);
913      }
914
915      @Override
916      public Base addChild(String name) throws FHIRException {
917        if (name.equals("doseSequence")) {
918          throw new FHIRException("Cannot call addChild on a primitive type Immunization.doseSequence");
919        }
920        else if (name.equals("description")) {
921          throw new FHIRException("Cannot call addChild on a primitive type Immunization.description");
922        }
923        else if (name.equals("authority")) {
924          this.authority = new Reference();
925          return this.authority;
926        }
927        else if (name.equals("series")) {
928          throw new FHIRException("Cannot call addChild on a primitive type Immunization.series");
929        }
930        else if (name.equals("seriesDoses")) {
931          throw new FHIRException("Cannot call addChild on a primitive type Immunization.seriesDoses");
932        }
933        else if (name.equals("targetDisease")) {
934          return addTargetDisease();
935        }
936        else if (name.equals("doseStatus")) {
937          this.doseStatus = new CodeableConcept();
938          return this.doseStatus;
939        }
940        else if (name.equals("doseStatusReason")) {
941          this.doseStatusReason = new CodeableConcept();
942          return this.doseStatusReason;
943        }
944        else
945          return super.addChild(name);
946      }
947
948      public ImmunizationVaccinationProtocolComponent copy() {
949        ImmunizationVaccinationProtocolComponent dst = new ImmunizationVaccinationProtocolComponent();
950        copyValues(dst);
951        dst.doseSequence = doseSequence == null ? null : doseSequence.copy();
952        dst.description = description == null ? null : description.copy();
953        dst.authority = authority == null ? null : authority.copy();
954        dst.series = series == null ? null : series.copy();
955        dst.seriesDoses = seriesDoses == null ? null : seriesDoses.copy();
956        if (targetDisease != null) {
957          dst.targetDisease = new ArrayList<CodeableConcept>();
958          for (CodeableConcept i : targetDisease)
959            dst.targetDisease.add(i.copy());
960        };
961        dst.doseStatus = doseStatus == null ? null : doseStatus.copy();
962        dst.doseStatusReason = doseStatusReason == null ? null : doseStatusReason.copy();
963        return dst;
964      }
965
966      @Override
967      public boolean equalsDeep(Base other) {
968        if (!super.equalsDeep(other))
969          return false;
970        if (!(other instanceof ImmunizationVaccinationProtocolComponent))
971          return false;
972        ImmunizationVaccinationProtocolComponent o = (ImmunizationVaccinationProtocolComponent) other;
973        return compareDeep(doseSequence, o.doseSequence, true) && compareDeep(description, o.description, true)
974           && compareDeep(authority, o.authority, true) && compareDeep(series, o.series, true) && compareDeep(seriesDoses, o.seriesDoses, true)
975           && compareDeep(targetDisease, o.targetDisease, true) && compareDeep(doseStatus, o.doseStatus, true)
976           && compareDeep(doseStatusReason, o.doseStatusReason, true);
977      }
978
979      @Override
980      public boolean equalsShallow(Base other) {
981        if (!super.equalsShallow(other))
982          return false;
983        if (!(other instanceof ImmunizationVaccinationProtocolComponent))
984          return false;
985        ImmunizationVaccinationProtocolComponent o = (ImmunizationVaccinationProtocolComponent) other;
986        return compareValues(doseSequence, o.doseSequence, true) && compareValues(description, o.description, true)
987           && compareValues(series, o.series, true) && compareValues(seriesDoses, o.seriesDoses, true);
988      }
989
990      public boolean isEmpty() {
991        return super.isEmpty() && (doseSequence == null || doseSequence.isEmpty()) && (description == null || description.isEmpty())
992           && (authority == null || authority.isEmpty()) && (series == null || series.isEmpty()) && (seriesDoses == null || seriesDoses.isEmpty())
993           && (targetDisease == null || targetDisease.isEmpty()) && (doseStatus == null || doseStatus.isEmpty())
994           && (doseStatusReason == null || doseStatusReason.isEmpty());
995      }
996
997  public String fhirType() {
998    return "Immunization.vaccinationProtocol";
999
1000  }
1001
1002  }
1003
1004    /**
1005     * A unique identifier assigned to this immunization record.
1006     */
1007    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1008    @Description(shortDefinition="Business identifier", formalDefinition="A unique identifier assigned to this immunization record." )
1009    protected List<Identifier> identifier;
1010
1011    /**
1012     * Indicates the current status of the vaccination event.
1013     */
1014    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
1015    @Description(shortDefinition="in-progress | on-hold | completed | entered-in-error | stopped", formalDefinition="Indicates the current status of the vaccination event." )
1016    protected CodeType status;
1017
1018    /**
1019     * Date vaccine administered or was to be administered.
1020     */
1021    @Child(name = "date", type = {DateTimeType.class}, order=2, min=0, max=1, modifier=false, summary=false)
1022    @Description(shortDefinition="Vaccination administration date", formalDefinition="Date vaccine administered or was to be administered." )
1023    protected DateTimeType date;
1024
1025    /**
1026     * Vaccine that was administered or was to be administered.
1027     */
1028    @Child(name = "vaccineCode", type = {CodeableConcept.class}, order=3, min=1, max=1, modifier=false, summary=false)
1029    @Description(shortDefinition="Vaccine product administered", formalDefinition="Vaccine that was administered or was to be administered." )
1030    protected CodeableConcept vaccineCode;
1031
1032    /**
1033     * The patient who either received or did not receive the immunization.
1034     */
1035    @Child(name = "patient", type = {Patient.class}, order=4, min=1, max=1, modifier=false, summary=false)
1036    @Description(shortDefinition="Who was immunized", formalDefinition="The patient who either received or did not receive the immunization." )
1037    protected Reference patient;
1038
1039    /**
1040     * The actual object that is the target of the reference (The patient who either received or did not receive the immunization.)
1041     */
1042    protected Patient patientTarget;
1043
1044    /**
1045     * Indicates if the vaccination was or was not given.
1046     */
1047    @Child(name = "wasNotGiven", type = {BooleanType.class}, order=5, min=1, max=1, modifier=true, summary=false)
1048    @Description(shortDefinition="Flag for whether immunization was given", formalDefinition="Indicates if the vaccination was or was not given." )
1049    protected BooleanType wasNotGiven;
1050
1051    /**
1052     * True if this administration was reported rather than directly administered.
1053     */
1054    @Child(name = "reported", type = {BooleanType.class}, order=6, min=1, max=1, modifier=false, summary=false)
1055    @Description(shortDefinition="Indicates a self-reported record", formalDefinition="True if this administration was reported rather than directly administered." )
1056    protected BooleanType reported;
1057
1058    /**
1059     * Clinician who administered the vaccine.
1060     */
1061    @Child(name = "performer", type = {Practitioner.class}, order=7, min=0, max=1, modifier=false, summary=false)
1062    @Description(shortDefinition="Who administered vaccine", formalDefinition="Clinician who administered the vaccine." )
1063    protected Reference performer;
1064
1065    /**
1066     * The actual object that is the target of the reference (Clinician who administered the vaccine.)
1067     */
1068    protected Practitioner performerTarget;
1069
1070    /**
1071     * Clinician who ordered the vaccination.
1072     */
1073    @Child(name = "requester", type = {Practitioner.class}, order=8, min=0, max=1, modifier=false, summary=false)
1074    @Description(shortDefinition="Who ordered vaccination", formalDefinition="Clinician who ordered the vaccination." )
1075    protected Reference requester;
1076
1077    /**
1078     * The actual object that is the target of the reference (Clinician who ordered the vaccination.)
1079     */
1080    protected Practitioner requesterTarget;
1081
1082    /**
1083     * The visit or admission or other contact between patient and health care provider the immunization was performed as part of.
1084     */
1085    @Child(name = "encounter", type = {Encounter.class}, order=9, min=0, max=1, modifier=false, summary=false)
1086    @Description(shortDefinition="Encounter administered as part of", formalDefinition="The visit or admission or other contact between patient and health care provider the immunization was performed as part of." )
1087    protected Reference encounter;
1088
1089    /**
1090     * The actual object that is the target of the reference (The visit or admission or other contact between patient and health care provider the immunization was performed as part of.)
1091     */
1092    protected Encounter encounterTarget;
1093
1094    /**
1095     * Name of vaccine manufacturer.
1096     */
1097    @Child(name = "manufacturer", type = {Organization.class}, order=10, min=0, max=1, modifier=false, summary=false)
1098    @Description(shortDefinition="Vaccine manufacturer", formalDefinition="Name of vaccine manufacturer." )
1099    protected Reference manufacturer;
1100
1101    /**
1102     * The actual object that is the target of the reference (Name of vaccine manufacturer.)
1103     */
1104    protected Organization manufacturerTarget;
1105
1106    /**
1107     * The service delivery location where the vaccine administration occurred.
1108     */
1109    @Child(name = "location", type = {Location.class}, order=11, min=0, max=1, modifier=false, summary=false)
1110    @Description(shortDefinition="Where vaccination occurred", formalDefinition="The service delivery location where the vaccine administration occurred." )
1111    protected Reference location;
1112
1113    /**
1114     * The actual object that is the target of the reference (The service delivery location where the vaccine administration occurred.)
1115     */
1116    protected Location locationTarget;
1117
1118    /**
1119     * Lot number of the  vaccine product.
1120     */
1121    @Child(name = "lotNumber", type = {StringType.class}, order=12, min=0, max=1, modifier=false, summary=false)
1122    @Description(shortDefinition="Vaccine lot number", formalDefinition="Lot number of the  vaccine product." )
1123    protected StringType lotNumber;
1124
1125    /**
1126     * Date vaccine batch expires.
1127     */
1128    @Child(name = "expirationDate", type = {DateType.class}, order=13, min=0, max=1, modifier=false, summary=false)
1129    @Description(shortDefinition="Vaccine expiration date", formalDefinition="Date vaccine batch expires." )
1130    protected DateType expirationDate;
1131
1132    /**
1133     * Body site where vaccine was administered.
1134     */
1135    @Child(name = "site", type = {CodeableConcept.class}, order=14, min=0, max=1, modifier=false, summary=false)
1136    @Description(shortDefinition="Body site vaccine  was administered", formalDefinition="Body site where vaccine was administered." )
1137    protected CodeableConcept site;
1138
1139    /**
1140     * The path by which the vaccine product is taken into the body.
1141     */
1142    @Child(name = "route", type = {CodeableConcept.class}, order=15, min=0, max=1, modifier=false, summary=false)
1143    @Description(shortDefinition="How vaccine entered body", formalDefinition="The path by which the vaccine product is taken into the body." )
1144    protected CodeableConcept route;
1145
1146    /**
1147     * The quantity of vaccine product that was administered.
1148     */
1149    @Child(name = "doseQuantity", type = {SimpleQuantity.class}, order=16, min=0, max=1, modifier=false, summary=false)
1150    @Description(shortDefinition="Amount of vaccine administered", formalDefinition="The quantity of vaccine product that was administered." )
1151    protected SimpleQuantity doseQuantity;
1152
1153    /**
1154     * Extra information about the immunization that is not conveyed by the other attributes.
1155     */
1156    @Child(name = "note", type = {Annotation.class}, order=17, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1157    @Description(shortDefinition="Vaccination notes", formalDefinition="Extra information about the immunization that is not conveyed by the other attributes." )
1158    protected List<Annotation> note;
1159
1160    /**
1161     * Reasons why a vaccine was or was not administered.
1162     */
1163    @Child(name = "explanation", type = {}, order=18, min=0, max=1, modifier=false, summary=false)
1164    @Description(shortDefinition="Administration/non-administration reasons", formalDefinition="Reasons why a vaccine was or was not administered." )
1165    protected ImmunizationExplanationComponent explanation;
1166
1167    /**
1168     * Categorical data indicating that an adverse event is associated in time to an immunization.
1169     */
1170    @Child(name = "reaction", type = {}, order=19, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1171    @Description(shortDefinition="Details of a reaction that follows immunization", formalDefinition="Categorical data indicating that an adverse event is associated in time to an immunization." )
1172    protected List<ImmunizationReactionComponent> reaction;
1173
1174    /**
1175     * Contains information about the protocol(s) under which the vaccine was administered.
1176     */
1177    @Child(name = "vaccinationProtocol", type = {}, order=20, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1178    @Description(shortDefinition="What protocol was followed", formalDefinition="Contains information about the protocol(s) under which the vaccine was administered." )
1179    protected List<ImmunizationVaccinationProtocolComponent> vaccinationProtocol;
1180
1181    private static final long serialVersionUID = 898786200L;
1182
1183  /*
1184   * Constructor
1185   */
1186    public Immunization() {
1187      super();
1188    }
1189
1190  /*
1191   * Constructor
1192   */
1193    public Immunization(CodeType status, CodeableConcept vaccineCode, Reference patient, BooleanType wasNotGiven, BooleanType reported) {
1194      super();
1195      this.status = status;
1196      this.vaccineCode = vaccineCode;
1197      this.patient = patient;
1198      this.wasNotGiven = wasNotGiven;
1199      this.reported = reported;
1200    }
1201
1202    /**
1203     * @return {@link #identifier} (A unique identifier assigned to this immunization record.)
1204     */
1205    public List<Identifier> getIdentifier() { 
1206      if (this.identifier == null)
1207        this.identifier = new ArrayList<Identifier>();
1208      return this.identifier;
1209    }
1210
1211    public boolean hasIdentifier() { 
1212      if (this.identifier == null)
1213        return false;
1214      for (Identifier item : this.identifier)
1215        if (!item.isEmpty())
1216          return true;
1217      return false;
1218    }
1219
1220    /**
1221     * @return {@link #identifier} (A unique identifier assigned to this immunization record.)
1222     */
1223    // syntactic sugar
1224    public Identifier addIdentifier() { //3
1225      Identifier t = new Identifier();
1226      if (this.identifier == null)
1227        this.identifier = new ArrayList<Identifier>();
1228      this.identifier.add(t);
1229      return t;
1230    }
1231
1232    // syntactic sugar
1233    public Immunization addIdentifier(Identifier t) { //3
1234      if (t == null)
1235        return this;
1236      if (this.identifier == null)
1237        this.identifier = new ArrayList<Identifier>();
1238      this.identifier.add(t);
1239      return this;
1240    }
1241
1242    /**
1243     * @return {@link #status} (Indicates the current status of the vaccination event.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1244     */
1245    public CodeType getStatusElement() { 
1246      if (this.status == null)
1247        if (Configuration.errorOnAutoCreate())
1248          throw new Error("Attempt to auto-create Immunization.status");
1249        else if (Configuration.doAutoCreate())
1250          this.status = new CodeType(); // bb
1251      return this.status;
1252    }
1253
1254    public boolean hasStatusElement() { 
1255      return this.status != null && !this.status.isEmpty();
1256    }
1257
1258    public boolean hasStatus() { 
1259      return this.status != null && !this.status.isEmpty();
1260    }
1261
1262    /**
1263     * @param value {@link #status} (Indicates the current status of the vaccination event.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1264     */
1265    public Immunization setStatusElement(CodeType value) { 
1266      this.status = value;
1267      return this;
1268    }
1269
1270    /**
1271     * @return Indicates the current status of the vaccination event.
1272     */
1273    public String getStatus() { 
1274      return this.status == null ? null : this.status.getValue();
1275    }
1276
1277    /**
1278     * @param value Indicates the current status of the vaccination event.
1279     */
1280    public Immunization setStatus(String value) { 
1281        if (this.status == null)
1282          this.status = new CodeType();
1283        this.status.setValue(value);
1284      return this;
1285    }
1286
1287    /**
1288     * @return {@link #date} (Date vaccine administered or was to be administered.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
1289     */
1290    public DateTimeType getDateElement() { 
1291      if (this.date == null)
1292        if (Configuration.errorOnAutoCreate())
1293          throw new Error("Attempt to auto-create Immunization.date");
1294        else if (Configuration.doAutoCreate())
1295          this.date = new DateTimeType(); // bb
1296      return this.date;
1297    }
1298
1299    public boolean hasDateElement() { 
1300      return this.date != null && !this.date.isEmpty();
1301    }
1302
1303    public boolean hasDate() { 
1304      return this.date != null && !this.date.isEmpty();
1305    }
1306
1307    /**
1308     * @param value {@link #date} (Date vaccine administered or was to be administered.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
1309     */
1310    public Immunization setDateElement(DateTimeType value) { 
1311      this.date = value;
1312      return this;
1313    }
1314
1315    /**
1316     * @return Date vaccine administered or was to be administered.
1317     */
1318    public Date getDate() { 
1319      return this.date == null ? null : this.date.getValue();
1320    }
1321
1322    /**
1323     * @param value Date vaccine administered or was to be administered.
1324     */
1325    public Immunization setDate(Date value) { 
1326      if (value == null)
1327        this.date = null;
1328      else {
1329        if (this.date == null)
1330          this.date = new DateTimeType();
1331        this.date.setValue(value);
1332      }
1333      return this;
1334    }
1335
1336    /**
1337     * @return {@link #vaccineCode} (Vaccine that was administered or was to be administered.)
1338     */
1339    public CodeableConcept getVaccineCode() { 
1340      if (this.vaccineCode == null)
1341        if (Configuration.errorOnAutoCreate())
1342          throw new Error("Attempt to auto-create Immunization.vaccineCode");
1343        else if (Configuration.doAutoCreate())
1344          this.vaccineCode = new CodeableConcept(); // cc
1345      return this.vaccineCode;
1346    }
1347
1348    public boolean hasVaccineCode() { 
1349      return this.vaccineCode != null && !this.vaccineCode.isEmpty();
1350    }
1351
1352    /**
1353     * @param value {@link #vaccineCode} (Vaccine that was administered or was to be administered.)
1354     */
1355    public Immunization setVaccineCode(CodeableConcept value) { 
1356      this.vaccineCode = value;
1357      return this;
1358    }
1359
1360    /**
1361     * @return {@link #patient} (The patient who either received or did not receive the immunization.)
1362     */
1363    public Reference getPatient() { 
1364      if (this.patient == null)
1365        if (Configuration.errorOnAutoCreate())
1366          throw new Error("Attempt to auto-create Immunization.patient");
1367        else if (Configuration.doAutoCreate())
1368          this.patient = new Reference(); // cc
1369      return this.patient;
1370    }
1371
1372    public boolean hasPatient() { 
1373      return this.patient != null && !this.patient.isEmpty();
1374    }
1375
1376    /**
1377     * @param value {@link #patient} (The patient who either received or did not receive the immunization.)
1378     */
1379    public Immunization setPatient(Reference value) { 
1380      this.patient = value;
1381      return this;
1382    }
1383
1384    /**
1385     * @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 either received or did not receive the immunization.)
1386     */
1387    public Patient getPatientTarget() { 
1388      if (this.patientTarget == null)
1389        if (Configuration.errorOnAutoCreate())
1390          throw new Error("Attempt to auto-create Immunization.patient");
1391        else if (Configuration.doAutoCreate())
1392          this.patientTarget = new Patient(); // aa
1393      return this.patientTarget;
1394    }
1395
1396    /**
1397     * @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 either received or did not receive the immunization.)
1398     */
1399    public Immunization setPatientTarget(Patient value) { 
1400      this.patientTarget = value;
1401      return this;
1402    }
1403
1404    /**
1405     * @return {@link #wasNotGiven} (Indicates if the vaccination was or was not given.). This is the underlying object with id, value and extensions. The accessor "getWasNotGiven" gives direct access to the value
1406     */
1407    public BooleanType getWasNotGivenElement() { 
1408      if (this.wasNotGiven == null)
1409        if (Configuration.errorOnAutoCreate())
1410          throw new Error("Attempt to auto-create Immunization.wasNotGiven");
1411        else if (Configuration.doAutoCreate())
1412          this.wasNotGiven = new BooleanType(); // bb
1413      return this.wasNotGiven;
1414    }
1415
1416    public boolean hasWasNotGivenElement() { 
1417      return this.wasNotGiven != null && !this.wasNotGiven.isEmpty();
1418    }
1419
1420    public boolean hasWasNotGiven() { 
1421      return this.wasNotGiven != null && !this.wasNotGiven.isEmpty();
1422    }
1423
1424    /**
1425     * @param value {@link #wasNotGiven} (Indicates if the vaccination was or was not given.). This is the underlying object with id, value and extensions. The accessor "getWasNotGiven" gives direct access to the value
1426     */
1427    public Immunization setWasNotGivenElement(BooleanType value) { 
1428      this.wasNotGiven = value;
1429      return this;
1430    }
1431
1432    /**
1433     * @return Indicates if the vaccination was or was not given.
1434     */
1435    public boolean getWasNotGiven() { 
1436      return this.wasNotGiven == null || this.wasNotGiven.isEmpty() ? false : this.wasNotGiven.getValue();
1437    }
1438
1439    /**
1440     * @param value Indicates if the vaccination was or was not given.
1441     */
1442    public Immunization setWasNotGiven(boolean value) { 
1443        if (this.wasNotGiven == null)
1444          this.wasNotGiven = new BooleanType();
1445        this.wasNotGiven.setValue(value);
1446      return this;
1447    }
1448
1449    /**
1450     * @return {@link #reported} (True if this administration was reported rather than directly administered.). This is the underlying object with id, value and extensions. The accessor "getReported" gives direct access to the value
1451     */
1452    public BooleanType getReportedElement() { 
1453      if (this.reported == null)
1454        if (Configuration.errorOnAutoCreate())
1455          throw new Error("Attempt to auto-create Immunization.reported");
1456        else if (Configuration.doAutoCreate())
1457          this.reported = new BooleanType(); // bb
1458      return this.reported;
1459    }
1460
1461    public boolean hasReportedElement() { 
1462      return this.reported != null && !this.reported.isEmpty();
1463    }
1464
1465    public boolean hasReported() { 
1466      return this.reported != null && !this.reported.isEmpty();
1467    }
1468
1469    /**
1470     * @param value {@link #reported} (True if this administration was reported rather than directly administered.). This is the underlying object with id, value and extensions. The accessor "getReported" gives direct access to the value
1471     */
1472    public Immunization setReportedElement(BooleanType value) { 
1473      this.reported = value;
1474      return this;
1475    }
1476
1477    /**
1478     * @return True if this administration was reported rather than directly administered.
1479     */
1480    public boolean getReported() { 
1481      return this.reported == null || this.reported.isEmpty() ? false : this.reported.getValue();
1482    }
1483
1484    /**
1485     * @param value True if this administration was reported rather than directly administered.
1486     */
1487    public Immunization setReported(boolean value) { 
1488        if (this.reported == null)
1489          this.reported = new BooleanType();
1490        this.reported.setValue(value);
1491      return this;
1492    }
1493
1494    /**
1495     * @return {@link #performer} (Clinician who administered the vaccine.)
1496     */
1497    public Reference getPerformer() { 
1498      if (this.performer == null)
1499        if (Configuration.errorOnAutoCreate())
1500          throw new Error("Attempt to auto-create Immunization.performer");
1501        else if (Configuration.doAutoCreate())
1502          this.performer = new Reference(); // cc
1503      return this.performer;
1504    }
1505
1506    public boolean hasPerformer() { 
1507      return this.performer != null && !this.performer.isEmpty();
1508    }
1509
1510    /**
1511     * @param value {@link #performer} (Clinician who administered the vaccine.)
1512     */
1513    public Immunization setPerformer(Reference value) { 
1514      this.performer = value;
1515      return this;
1516    }
1517
1518    /**
1519     * @return {@link #performer} 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. (Clinician who administered the vaccine.)
1520     */
1521    public Practitioner getPerformerTarget() { 
1522      if (this.performerTarget == null)
1523        if (Configuration.errorOnAutoCreate())
1524          throw new Error("Attempt to auto-create Immunization.performer");
1525        else if (Configuration.doAutoCreate())
1526          this.performerTarget = new Practitioner(); // aa
1527      return this.performerTarget;
1528    }
1529
1530    /**
1531     * @param value {@link #performer} 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. (Clinician who administered the vaccine.)
1532     */
1533    public Immunization setPerformerTarget(Practitioner value) { 
1534      this.performerTarget = value;
1535      return this;
1536    }
1537
1538    /**
1539     * @return {@link #requester} (Clinician who ordered the vaccination.)
1540     */
1541    public Reference getRequester() { 
1542      if (this.requester == null)
1543        if (Configuration.errorOnAutoCreate())
1544          throw new Error("Attempt to auto-create Immunization.requester");
1545        else if (Configuration.doAutoCreate())
1546          this.requester = new Reference(); // cc
1547      return this.requester;
1548    }
1549
1550    public boolean hasRequester() { 
1551      return this.requester != null && !this.requester.isEmpty();
1552    }
1553
1554    /**
1555     * @param value {@link #requester} (Clinician who ordered the vaccination.)
1556     */
1557    public Immunization setRequester(Reference value) { 
1558      this.requester = value;
1559      return this;
1560    }
1561
1562    /**
1563     * @return {@link #requester} 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. (Clinician who ordered the vaccination.)
1564     */
1565    public Practitioner getRequesterTarget() { 
1566      if (this.requesterTarget == null)
1567        if (Configuration.errorOnAutoCreate())
1568          throw new Error("Attempt to auto-create Immunization.requester");
1569        else if (Configuration.doAutoCreate())
1570          this.requesterTarget = new Practitioner(); // aa
1571      return this.requesterTarget;
1572    }
1573
1574    /**
1575     * @param value {@link #requester} 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. (Clinician who ordered the vaccination.)
1576     */
1577    public Immunization setRequesterTarget(Practitioner value) { 
1578      this.requesterTarget = value;
1579      return this;
1580    }
1581
1582    /**
1583     * @return {@link #encounter} (The visit or admission or other contact between patient and health care provider the immunization was performed as part of.)
1584     */
1585    public Reference getEncounter() { 
1586      if (this.encounter == null)
1587        if (Configuration.errorOnAutoCreate())
1588          throw new Error("Attempt to auto-create Immunization.encounter");
1589        else if (Configuration.doAutoCreate())
1590          this.encounter = new Reference(); // cc
1591      return this.encounter;
1592    }
1593
1594    public boolean hasEncounter() { 
1595      return this.encounter != null && !this.encounter.isEmpty();
1596    }
1597
1598    /**
1599     * @param value {@link #encounter} (The visit or admission or other contact between patient and health care provider the immunization was performed as part of.)
1600     */
1601    public Immunization setEncounter(Reference value) { 
1602      this.encounter = value;
1603      return this;
1604    }
1605
1606    /**
1607     * @return {@link #encounter} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The visit or admission or other contact between patient and health care provider the immunization was performed as part of.)
1608     */
1609    public Encounter getEncounterTarget() { 
1610      if (this.encounterTarget == null)
1611        if (Configuration.errorOnAutoCreate())
1612          throw new Error("Attempt to auto-create Immunization.encounter");
1613        else if (Configuration.doAutoCreate())
1614          this.encounterTarget = new Encounter(); // aa
1615      return this.encounterTarget;
1616    }
1617
1618    /**
1619     * @param value {@link #encounter} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The visit or admission or other contact between patient and health care provider the immunization was performed as part of.)
1620     */
1621    public Immunization setEncounterTarget(Encounter value) { 
1622      this.encounterTarget = value;
1623      return this;
1624    }
1625
1626    /**
1627     * @return {@link #manufacturer} (Name of vaccine manufacturer.)
1628     */
1629    public Reference getManufacturer() { 
1630      if (this.manufacturer == null)
1631        if (Configuration.errorOnAutoCreate())
1632          throw new Error("Attempt to auto-create Immunization.manufacturer");
1633        else if (Configuration.doAutoCreate())
1634          this.manufacturer = new Reference(); // cc
1635      return this.manufacturer;
1636    }
1637
1638    public boolean hasManufacturer() { 
1639      return this.manufacturer != null && !this.manufacturer.isEmpty();
1640    }
1641
1642    /**
1643     * @param value {@link #manufacturer} (Name of vaccine manufacturer.)
1644     */
1645    public Immunization setManufacturer(Reference value) { 
1646      this.manufacturer = value;
1647      return this;
1648    }
1649
1650    /**
1651     * @return {@link #manufacturer} 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. (Name of vaccine manufacturer.)
1652     */
1653    public Organization getManufacturerTarget() { 
1654      if (this.manufacturerTarget == null)
1655        if (Configuration.errorOnAutoCreate())
1656          throw new Error("Attempt to auto-create Immunization.manufacturer");
1657        else if (Configuration.doAutoCreate())
1658          this.manufacturerTarget = new Organization(); // aa
1659      return this.manufacturerTarget;
1660    }
1661
1662    /**
1663     * @param value {@link #manufacturer} 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. (Name of vaccine manufacturer.)
1664     */
1665    public Immunization setManufacturerTarget(Organization value) { 
1666      this.manufacturerTarget = value;
1667      return this;
1668    }
1669
1670    /**
1671     * @return {@link #location} (The service delivery location where the vaccine administration occurred.)
1672     */
1673    public Reference getLocation() { 
1674      if (this.location == null)
1675        if (Configuration.errorOnAutoCreate())
1676          throw new Error("Attempt to auto-create Immunization.location");
1677        else if (Configuration.doAutoCreate())
1678          this.location = new Reference(); // cc
1679      return this.location;
1680    }
1681
1682    public boolean hasLocation() { 
1683      return this.location != null && !this.location.isEmpty();
1684    }
1685
1686    /**
1687     * @param value {@link #location} (The service delivery location where the vaccine administration occurred.)
1688     */
1689    public Immunization setLocation(Reference value) { 
1690      this.location = value;
1691      return this;
1692    }
1693
1694    /**
1695     * @return {@link #location} 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 service delivery location where the vaccine administration occurred.)
1696     */
1697    public Location getLocationTarget() { 
1698      if (this.locationTarget == null)
1699        if (Configuration.errorOnAutoCreate())
1700          throw new Error("Attempt to auto-create Immunization.location");
1701        else if (Configuration.doAutoCreate())
1702          this.locationTarget = new Location(); // aa
1703      return this.locationTarget;
1704    }
1705
1706    /**
1707     * @param value {@link #location} 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 service delivery location where the vaccine administration occurred.)
1708     */
1709    public Immunization setLocationTarget(Location value) { 
1710      this.locationTarget = value;
1711      return this;
1712    }
1713
1714    /**
1715     * @return {@link #lotNumber} (Lot number of the  vaccine product.). This is the underlying object with id, value and extensions. The accessor "getLotNumber" gives direct access to the value
1716     */
1717    public StringType getLotNumberElement() { 
1718      if (this.lotNumber == null)
1719        if (Configuration.errorOnAutoCreate())
1720          throw new Error("Attempt to auto-create Immunization.lotNumber");
1721        else if (Configuration.doAutoCreate())
1722          this.lotNumber = new StringType(); // bb
1723      return this.lotNumber;
1724    }
1725
1726    public boolean hasLotNumberElement() { 
1727      return this.lotNumber != null && !this.lotNumber.isEmpty();
1728    }
1729
1730    public boolean hasLotNumber() { 
1731      return this.lotNumber != null && !this.lotNumber.isEmpty();
1732    }
1733
1734    /**
1735     * @param value {@link #lotNumber} (Lot number of the  vaccine product.). This is the underlying object with id, value and extensions. The accessor "getLotNumber" gives direct access to the value
1736     */
1737    public Immunization setLotNumberElement(StringType value) { 
1738      this.lotNumber = value;
1739      return this;
1740    }
1741
1742    /**
1743     * @return Lot number of the  vaccine product.
1744     */
1745    public String getLotNumber() { 
1746      return this.lotNumber == null ? null : this.lotNumber.getValue();
1747    }
1748
1749    /**
1750     * @param value Lot number of the  vaccine product.
1751     */
1752    public Immunization setLotNumber(String value) { 
1753      if (Utilities.noString(value))
1754        this.lotNumber = null;
1755      else {
1756        if (this.lotNumber == null)
1757          this.lotNumber = new StringType();
1758        this.lotNumber.setValue(value);
1759      }
1760      return this;
1761    }
1762
1763    /**
1764     * @return {@link #expirationDate} (Date vaccine batch expires.). This is the underlying object with id, value and extensions. The accessor "getExpirationDate" gives direct access to the value
1765     */
1766    public DateType getExpirationDateElement() { 
1767      if (this.expirationDate == null)
1768        if (Configuration.errorOnAutoCreate())
1769          throw new Error("Attempt to auto-create Immunization.expirationDate");
1770        else if (Configuration.doAutoCreate())
1771          this.expirationDate = new DateType(); // bb
1772      return this.expirationDate;
1773    }
1774
1775    public boolean hasExpirationDateElement() { 
1776      return this.expirationDate != null && !this.expirationDate.isEmpty();
1777    }
1778
1779    public boolean hasExpirationDate() { 
1780      return this.expirationDate != null && !this.expirationDate.isEmpty();
1781    }
1782
1783    /**
1784     * @param value {@link #expirationDate} (Date vaccine batch expires.). This is the underlying object with id, value and extensions. The accessor "getExpirationDate" gives direct access to the value
1785     */
1786    public Immunization setExpirationDateElement(DateType value) { 
1787      this.expirationDate = value;
1788      return this;
1789    }
1790
1791    /**
1792     * @return Date vaccine batch expires.
1793     */
1794    public Date getExpirationDate() { 
1795      return this.expirationDate == null ? null : this.expirationDate.getValue();
1796    }
1797
1798    /**
1799     * @param value Date vaccine batch expires.
1800     */
1801    public Immunization setExpirationDate(Date value) { 
1802      if (value == null)
1803        this.expirationDate = null;
1804      else {
1805        if (this.expirationDate == null)
1806          this.expirationDate = new DateType();
1807        this.expirationDate.setValue(value);
1808      }
1809      return this;
1810    }
1811
1812    /**
1813     * @return {@link #site} (Body site where vaccine was administered.)
1814     */
1815    public CodeableConcept getSite() { 
1816      if (this.site == null)
1817        if (Configuration.errorOnAutoCreate())
1818          throw new Error("Attempt to auto-create Immunization.site");
1819        else if (Configuration.doAutoCreate())
1820          this.site = new CodeableConcept(); // cc
1821      return this.site;
1822    }
1823
1824    public boolean hasSite() { 
1825      return this.site != null && !this.site.isEmpty();
1826    }
1827
1828    /**
1829     * @param value {@link #site} (Body site where vaccine was administered.)
1830     */
1831    public Immunization setSite(CodeableConcept value) { 
1832      this.site = value;
1833      return this;
1834    }
1835
1836    /**
1837     * @return {@link #route} (The path by which the vaccine product is taken into the body.)
1838     */
1839    public CodeableConcept getRoute() { 
1840      if (this.route == null)
1841        if (Configuration.errorOnAutoCreate())
1842          throw new Error("Attempt to auto-create Immunization.route");
1843        else if (Configuration.doAutoCreate())
1844          this.route = new CodeableConcept(); // cc
1845      return this.route;
1846    }
1847
1848    public boolean hasRoute() { 
1849      return this.route != null && !this.route.isEmpty();
1850    }
1851
1852    /**
1853     * @param value {@link #route} (The path by which the vaccine product is taken into the body.)
1854     */
1855    public Immunization setRoute(CodeableConcept value) { 
1856      this.route = value;
1857      return this;
1858    }
1859
1860    /**
1861     * @return {@link #doseQuantity} (The quantity of vaccine product that was administered.)
1862     */
1863    public SimpleQuantity getDoseQuantity() { 
1864      if (this.doseQuantity == null)
1865        if (Configuration.errorOnAutoCreate())
1866          throw new Error("Attempt to auto-create Immunization.doseQuantity");
1867        else if (Configuration.doAutoCreate())
1868          this.doseQuantity = new SimpleQuantity(); // cc
1869      return this.doseQuantity;
1870    }
1871
1872    public boolean hasDoseQuantity() { 
1873      return this.doseQuantity != null && !this.doseQuantity.isEmpty();
1874    }
1875
1876    /**
1877     * @param value {@link #doseQuantity} (The quantity of vaccine product that was administered.)
1878     */
1879    public Immunization setDoseQuantity(SimpleQuantity value) { 
1880      this.doseQuantity = value;
1881      return this;
1882    }
1883
1884    /**
1885     * @return {@link #note} (Extra information about the immunization that is not conveyed by the other attributes.)
1886     */
1887    public List<Annotation> getNote() { 
1888      if (this.note == null)
1889        this.note = new ArrayList<Annotation>();
1890      return this.note;
1891    }
1892
1893    public boolean hasNote() { 
1894      if (this.note == null)
1895        return false;
1896      for (Annotation item : this.note)
1897        if (!item.isEmpty())
1898          return true;
1899      return false;
1900    }
1901
1902    /**
1903     * @return {@link #note} (Extra information about the immunization that is not conveyed by the other attributes.)
1904     */
1905    // syntactic sugar
1906    public Annotation addNote() { //3
1907      Annotation t = new Annotation();
1908      if (this.note == null)
1909        this.note = new ArrayList<Annotation>();
1910      this.note.add(t);
1911      return t;
1912    }
1913
1914    // syntactic sugar
1915    public Immunization addNote(Annotation t) { //3
1916      if (t == null)
1917        return this;
1918      if (this.note == null)
1919        this.note = new ArrayList<Annotation>();
1920      this.note.add(t);
1921      return this;
1922    }
1923
1924    /**
1925     * @return {@link #explanation} (Reasons why a vaccine was or was not administered.)
1926     */
1927    public ImmunizationExplanationComponent getExplanation() { 
1928      if (this.explanation == null)
1929        if (Configuration.errorOnAutoCreate())
1930          throw new Error("Attempt to auto-create Immunization.explanation");
1931        else if (Configuration.doAutoCreate())
1932          this.explanation = new ImmunizationExplanationComponent(); // cc
1933      return this.explanation;
1934    }
1935
1936    public boolean hasExplanation() { 
1937      return this.explanation != null && !this.explanation.isEmpty();
1938    }
1939
1940    /**
1941     * @param value {@link #explanation} (Reasons why a vaccine was or was not administered.)
1942     */
1943    public Immunization setExplanation(ImmunizationExplanationComponent value) { 
1944      this.explanation = value;
1945      return this;
1946    }
1947
1948    /**
1949     * @return {@link #reaction} (Categorical data indicating that an adverse event is associated in time to an immunization.)
1950     */
1951    public List<ImmunizationReactionComponent> getReaction() { 
1952      if (this.reaction == null)
1953        this.reaction = new ArrayList<ImmunizationReactionComponent>();
1954      return this.reaction;
1955    }
1956
1957    public boolean hasReaction() { 
1958      if (this.reaction == null)
1959        return false;
1960      for (ImmunizationReactionComponent item : this.reaction)
1961        if (!item.isEmpty())
1962          return true;
1963      return false;
1964    }
1965
1966    /**
1967     * @return {@link #reaction} (Categorical data indicating that an adverse event is associated in time to an immunization.)
1968     */
1969    // syntactic sugar
1970    public ImmunizationReactionComponent addReaction() { //3
1971      ImmunizationReactionComponent t = new ImmunizationReactionComponent();
1972      if (this.reaction == null)
1973        this.reaction = new ArrayList<ImmunizationReactionComponent>();
1974      this.reaction.add(t);
1975      return t;
1976    }
1977
1978    // syntactic sugar
1979    public Immunization addReaction(ImmunizationReactionComponent t) { //3
1980      if (t == null)
1981        return this;
1982      if (this.reaction == null)
1983        this.reaction = new ArrayList<ImmunizationReactionComponent>();
1984      this.reaction.add(t);
1985      return this;
1986    }
1987
1988    /**
1989     * @return {@link #vaccinationProtocol} (Contains information about the protocol(s) under which the vaccine was administered.)
1990     */
1991    public List<ImmunizationVaccinationProtocolComponent> getVaccinationProtocol() { 
1992      if (this.vaccinationProtocol == null)
1993        this.vaccinationProtocol = new ArrayList<ImmunizationVaccinationProtocolComponent>();
1994      return this.vaccinationProtocol;
1995    }
1996
1997    public boolean hasVaccinationProtocol() { 
1998      if (this.vaccinationProtocol == null)
1999        return false;
2000      for (ImmunizationVaccinationProtocolComponent item : this.vaccinationProtocol)
2001        if (!item.isEmpty())
2002          return true;
2003      return false;
2004    }
2005
2006    /**
2007     * @return {@link #vaccinationProtocol} (Contains information about the protocol(s) under which the vaccine was administered.)
2008     */
2009    // syntactic sugar
2010    public ImmunizationVaccinationProtocolComponent addVaccinationProtocol() { //3
2011      ImmunizationVaccinationProtocolComponent t = new ImmunizationVaccinationProtocolComponent();
2012      if (this.vaccinationProtocol == null)
2013        this.vaccinationProtocol = new ArrayList<ImmunizationVaccinationProtocolComponent>();
2014      this.vaccinationProtocol.add(t);
2015      return t;
2016    }
2017
2018    // syntactic sugar
2019    public Immunization addVaccinationProtocol(ImmunizationVaccinationProtocolComponent t) { //3
2020      if (t == null)
2021        return this;
2022      if (this.vaccinationProtocol == null)
2023        this.vaccinationProtocol = new ArrayList<ImmunizationVaccinationProtocolComponent>();
2024      this.vaccinationProtocol.add(t);
2025      return this;
2026    }
2027
2028      protected void listChildren(List<Property> childrenList) {
2029        super.listChildren(childrenList);
2030        childrenList.add(new Property("identifier", "Identifier", "A unique identifier assigned to this immunization record.", 0, java.lang.Integer.MAX_VALUE, identifier));
2031        childrenList.add(new Property("status", "code", "Indicates the current status of the vaccination event.", 0, java.lang.Integer.MAX_VALUE, status));
2032        childrenList.add(new Property("date", "dateTime", "Date vaccine administered or was to be administered.", 0, java.lang.Integer.MAX_VALUE, date));
2033        childrenList.add(new Property("vaccineCode", "CodeableConcept", "Vaccine that was administered or was to be administered.", 0, java.lang.Integer.MAX_VALUE, vaccineCode));
2034        childrenList.add(new Property("patient", "Reference(Patient)", "The patient who either received or did not receive the immunization.", 0, java.lang.Integer.MAX_VALUE, patient));
2035        childrenList.add(new Property("wasNotGiven", "boolean", "Indicates if the vaccination was or was not given.", 0, java.lang.Integer.MAX_VALUE, wasNotGiven));
2036        childrenList.add(new Property("reported", "boolean", "True if this administration was reported rather than directly administered.", 0, java.lang.Integer.MAX_VALUE, reported));
2037        childrenList.add(new Property("performer", "Reference(Practitioner)", "Clinician who administered the vaccine.", 0, java.lang.Integer.MAX_VALUE, performer));
2038        childrenList.add(new Property("requester", "Reference(Practitioner)", "Clinician who ordered the vaccination.", 0, java.lang.Integer.MAX_VALUE, requester));
2039        childrenList.add(new Property("encounter", "Reference(Encounter)", "The visit or admission or other contact between patient and health care provider the immunization was performed as part of.", 0, java.lang.Integer.MAX_VALUE, encounter));
2040        childrenList.add(new Property("manufacturer", "Reference(Organization)", "Name of vaccine manufacturer.", 0, java.lang.Integer.MAX_VALUE, manufacturer));
2041        childrenList.add(new Property("location", "Reference(Location)", "The service delivery location where the vaccine administration occurred.", 0, java.lang.Integer.MAX_VALUE, location));
2042        childrenList.add(new Property("lotNumber", "string", "Lot number of the  vaccine product.", 0, java.lang.Integer.MAX_VALUE, lotNumber));
2043        childrenList.add(new Property("expirationDate", "date", "Date vaccine batch expires.", 0, java.lang.Integer.MAX_VALUE, expirationDate));
2044        childrenList.add(new Property("site", "CodeableConcept", "Body site where vaccine was administered.", 0, java.lang.Integer.MAX_VALUE, site));
2045        childrenList.add(new Property("route", "CodeableConcept", "The path by which the vaccine product is taken into the body.", 0, java.lang.Integer.MAX_VALUE, route));
2046        childrenList.add(new Property("doseQuantity", "SimpleQuantity", "The quantity of vaccine product that was administered.", 0, java.lang.Integer.MAX_VALUE, doseQuantity));
2047        childrenList.add(new Property("note", "Annotation", "Extra information about the immunization that is not conveyed by the other attributes.", 0, java.lang.Integer.MAX_VALUE, note));
2048        childrenList.add(new Property("explanation", "", "Reasons why a vaccine was or was not administered.", 0, java.lang.Integer.MAX_VALUE, explanation));
2049        childrenList.add(new Property("reaction", "", "Categorical data indicating that an adverse event is associated in time to an immunization.", 0, java.lang.Integer.MAX_VALUE, reaction));
2050        childrenList.add(new Property("vaccinationProtocol", "", "Contains information about the protocol(s) under which the vaccine was administered.", 0, java.lang.Integer.MAX_VALUE, vaccinationProtocol));
2051      }
2052
2053      @Override
2054      public void setProperty(String name, Base value) throws FHIRException {
2055        if (name.equals("identifier"))
2056          this.getIdentifier().add(castToIdentifier(value));
2057        else if (name.equals("status"))
2058          this.status = castToCode(value); // CodeType
2059        else if (name.equals("date"))
2060          this.date = castToDateTime(value); // DateTimeType
2061        else if (name.equals("vaccineCode"))
2062          this.vaccineCode = castToCodeableConcept(value); // CodeableConcept
2063        else if (name.equals("patient"))
2064          this.patient = castToReference(value); // Reference
2065        else if (name.equals("wasNotGiven"))
2066          this.wasNotGiven = castToBoolean(value); // BooleanType
2067        else if (name.equals("reported"))
2068          this.reported = castToBoolean(value); // BooleanType
2069        else if (name.equals("performer"))
2070          this.performer = castToReference(value); // Reference
2071        else if (name.equals("requester"))
2072          this.requester = castToReference(value); // Reference
2073        else if (name.equals("encounter"))
2074          this.encounter = castToReference(value); // Reference
2075        else if (name.equals("manufacturer"))
2076          this.manufacturer = castToReference(value); // Reference
2077        else if (name.equals("location"))
2078          this.location = castToReference(value); // Reference
2079        else if (name.equals("lotNumber"))
2080          this.lotNumber = castToString(value); // StringType
2081        else if (name.equals("expirationDate"))
2082          this.expirationDate = castToDate(value); // DateType
2083        else if (name.equals("site"))
2084          this.site = castToCodeableConcept(value); // CodeableConcept
2085        else if (name.equals("route"))
2086          this.route = castToCodeableConcept(value); // CodeableConcept
2087        else if (name.equals("doseQuantity"))
2088          this.doseQuantity = castToSimpleQuantity(value); // SimpleQuantity
2089        else if (name.equals("note"))
2090          this.getNote().add(castToAnnotation(value));
2091        else if (name.equals("explanation"))
2092          this.explanation = (ImmunizationExplanationComponent) value; // ImmunizationExplanationComponent
2093        else if (name.equals("reaction"))
2094          this.getReaction().add((ImmunizationReactionComponent) value);
2095        else if (name.equals("vaccinationProtocol"))
2096          this.getVaccinationProtocol().add((ImmunizationVaccinationProtocolComponent) value);
2097        else
2098          super.setProperty(name, value);
2099      }
2100
2101      @Override
2102      public Base addChild(String name) throws FHIRException {
2103        if (name.equals("identifier")) {
2104          return addIdentifier();
2105        }
2106        else if (name.equals("status")) {
2107          throw new FHIRException("Cannot call addChild on a primitive type Immunization.status");
2108        }
2109        else if (name.equals("date")) {
2110          throw new FHIRException("Cannot call addChild on a primitive type Immunization.date");
2111        }
2112        else if (name.equals("vaccineCode")) {
2113          this.vaccineCode = new CodeableConcept();
2114          return this.vaccineCode;
2115        }
2116        else if (name.equals("patient")) {
2117          this.patient = new Reference();
2118          return this.patient;
2119        }
2120        else if (name.equals("wasNotGiven")) {
2121          throw new FHIRException("Cannot call addChild on a primitive type Immunization.wasNotGiven");
2122        }
2123        else if (name.equals("reported")) {
2124          throw new FHIRException("Cannot call addChild on a primitive type Immunization.reported");
2125        }
2126        else if (name.equals("performer")) {
2127          this.performer = new Reference();
2128          return this.performer;
2129        }
2130        else if (name.equals("requester")) {
2131          this.requester = new Reference();
2132          return this.requester;
2133        }
2134        else if (name.equals("encounter")) {
2135          this.encounter = new Reference();
2136          return this.encounter;
2137        }
2138        else if (name.equals("manufacturer")) {
2139          this.manufacturer = new Reference();
2140          return this.manufacturer;
2141        }
2142        else if (name.equals("location")) {
2143          this.location = new Reference();
2144          return this.location;
2145        }
2146        else if (name.equals("lotNumber")) {
2147          throw new FHIRException("Cannot call addChild on a primitive type Immunization.lotNumber");
2148        }
2149        else if (name.equals("expirationDate")) {
2150          throw new FHIRException("Cannot call addChild on a primitive type Immunization.expirationDate");
2151        }
2152        else if (name.equals("site")) {
2153          this.site = new CodeableConcept();
2154          return this.site;
2155        }
2156        else if (name.equals("route")) {
2157          this.route = new CodeableConcept();
2158          return this.route;
2159        }
2160        else if (name.equals("doseQuantity")) {
2161          this.doseQuantity = new SimpleQuantity();
2162          return this.doseQuantity;
2163        }
2164        else if (name.equals("note")) {
2165          return addNote();
2166        }
2167        else if (name.equals("explanation")) {
2168          this.explanation = new ImmunizationExplanationComponent();
2169          return this.explanation;
2170        }
2171        else if (name.equals("reaction")) {
2172          return addReaction();
2173        }
2174        else if (name.equals("vaccinationProtocol")) {
2175          return addVaccinationProtocol();
2176        }
2177        else
2178          return super.addChild(name);
2179      }
2180
2181  public String fhirType() {
2182    return "Immunization";
2183
2184  }
2185
2186      public Immunization copy() {
2187        Immunization dst = new Immunization();
2188        copyValues(dst);
2189        if (identifier != null) {
2190          dst.identifier = new ArrayList<Identifier>();
2191          for (Identifier i : identifier)
2192            dst.identifier.add(i.copy());
2193        };
2194        dst.status = status == null ? null : status.copy();
2195        dst.date = date == null ? null : date.copy();
2196        dst.vaccineCode = vaccineCode == null ? null : vaccineCode.copy();
2197        dst.patient = patient == null ? null : patient.copy();
2198        dst.wasNotGiven = wasNotGiven == null ? null : wasNotGiven.copy();
2199        dst.reported = reported == null ? null : reported.copy();
2200        dst.performer = performer == null ? null : performer.copy();
2201        dst.requester = requester == null ? null : requester.copy();
2202        dst.encounter = encounter == null ? null : encounter.copy();
2203        dst.manufacturer = manufacturer == null ? null : manufacturer.copy();
2204        dst.location = location == null ? null : location.copy();
2205        dst.lotNumber = lotNumber == null ? null : lotNumber.copy();
2206        dst.expirationDate = expirationDate == null ? null : expirationDate.copy();
2207        dst.site = site == null ? null : site.copy();
2208        dst.route = route == null ? null : route.copy();
2209        dst.doseQuantity = doseQuantity == null ? null : doseQuantity.copy();
2210        if (note != null) {
2211          dst.note = new ArrayList<Annotation>();
2212          for (Annotation i : note)
2213            dst.note.add(i.copy());
2214        };
2215        dst.explanation = explanation == null ? null : explanation.copy();
2216        if (reaction != null) {
2217          dst.reaction = new ArrayList<ImmunizationReactionComponent>();
2218          for (ImmunizationReactionComponent i : reaction)
2219            dst.reaction.add(i.copy());
2220        };
2221        if (vaccinationProtocol != null) {
2222          dst.vaccinationProtocol = new ArrayList<ImmunizationVaccinationProtocolComponent>();
2223          for (ImmunizationVaccinationProtocolComponent i : vaccinationProtocol)
2224            dst.vaccinationProtocol.add(i.copy());
2225        };
2226        return dst;
2227      }
2228
2229      protected Immunization typedCopy() {
2230        return copy();
2231      }
2232
2233      @Override
2234      public boolean equalsDeep(Base other) {
2235        if (!super.equalsDeep(other))
2236          return false;
2237        if (!(other instanceof Immunization))
2238          return false;
2239        Immunization o = (Immunization) other;
2240        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(date, o.date, true)
2241           && compareDeep(vaccineCode, o.vaccineCode, true) && compareDeep(patient, o.patient, true) && compareDeep(wasNotGiven, o.wasNotGiven, true)
2242           && compareDeep(reported, o.reported, true) && compareDeep(performer, o.performer, true) && compareDeep(requester, o.requester, true)
2243           && compareDeep(encounter, o.encounter, true) && compareDeep(manufacturer, o.manufacturer, true)
2244           && compareDeep(location, o.location, true) && compareDeep(lotNumber, o.lotNumber, true) && compareDeep(expirationDate, o.expirationDate, true)
2245           && compareDeep(site, o.site, true) && compareDeep(route, o.route, true) && compareDeep(doseQuantity, o.doseQuantity, true)
2246           && compareDeep(note, o.note, true) && compareDeep(explanation, o.explanation, true) && compareDeep(reaction, o.reaction, true)
2247           && compareDeep(vaccinationProtocol, o.vaccinationProtocol, true);
2248      }
2249
2250      @Override
2251      public boolean equalsShallow(Base other) {
2252        if (!super.equalsShallow(other))
2253          return false;
2254        if (!(other instanceof Immunization))
2255          return false;
2256        Immunization o = (Immunization) other;
2257        return compareValues(status, o.status, true) && compareValues(date, o.date, true) && compareValues(wasNotGiven, o.wasNotGiven, true)
2258           && compareValues(reported, o.reported, true) && compareValues(lotNumber, o.lotNumber, true) && compareValues(expirationDate, o.expirationDate, true)
2259          ;
2260      }
2261
2262      public boolean isEmpty() {
2263        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (status == null || status.isEmpty())
2264           && (date == null || date.isEmpty()) && (vaccineCode == null || vaccineCode.isEmpty()) && (patient == null || patient.isEmpty())
2265           && (wasNotGiven == null || wasNotGiven.isEmpty()) && (reported == null || reported.isEmpty())
2266           && (performer == null || performer.isEmpty()) && (requester == null || requester.isEmpty())
2267           && (encounter == null || encounter.isEmpty()) && (manufacturer == null || manufacturer.isEmpty())
2268           && (location == null || location.isEmpty()) && (lotNumber == null || lotNumber.isEmpty())
2269           && (expirationDate == null || expirationDate.isEmpty()) && (site == null || site.isEmpty())
2270           && (route == null || route.isEmpty()) && (doseQuantity == null || doseQuantity.isEmpty())
2271           && (note == null || note.isEmpty()) && (explanation == null || explanation.isEmpty()) && (reaction == null || reaction.isEmpty())
2272           && (vaccinationProtocol == null || vaccinationProtocol.isEmpty());
2273      }
2274
2275  @Override
2276  public ResourceType getResourceType() {
2277    return ResourceType.Immunization;
2278   }
2279
2280  @SearchParamDefinition(name="date", path="Immunization.date", description="Vaccination  (non)-Administration Date", type="date" )
2281  public static final String SP_DATE = "date";
2282  @SearchParamDefinition(name="requester", path="Immunization.requester", description="The practitioner who ordered the vaccination", type="reference" )
2283  public static final String SP_REQUESTER = "requester";
2284  @SearchParamDefinition(name="identifier", path="Immunization.identifier", description="Business identifier", type="token" )
2285  public static final String SP_IDENTIFIER = "identifier";
2286  @SearchParamDefinition(name="reason", path="Immunization.explanation.reason", description="Why immunization occurred", type="token" )
2287  public static final String SP_REASON = "reason";
2288  @SearchParamDefinition(name="performer", path="Immunization.performer", description="The practitioner who administered the vaccination", type="reference" )
2289  public static final String SP_PERFORMER = "performer";
2290  @SearchParamDefinition(name="reaction", path="Immunization.reaction.detail", description="Additional information on reaction", type="reference" )
2291  public static final String SP_REACTION = "reaction";
2292  @SearchParamDefinition(name="lot-number", path="Immunization.lotNumber", description="Vaccine Lot Number", type="string" )
2293  public static final String SP_LOTNUMBER = "lot-number";
2294  @SearchParamDefinition(name="notgiven", path="Immunization.wasNotGiven", description="Administrations which were not given", type="token" )
2295  public static final String SP_NOTGIVEN = "notgiven";
2296  @SearchParamDefinition(name="manufacturer", path="Immunization.manufacturer", description="Vaccine Manufacturer", type="reference" )
2297  public static final String SP_MANUFACTURER = "manufacturer";
2298  @SearchParamDefinition(name="dose-sequence", path="Immunization.vaccinationProtocol.doseSequence", description="Dose number within series", type="number" )
2299  public static final String SP_DOSESEQUENCE = "dose-sequence";
2300  @SearchParamDefinition(name="patient", path="Immunization.patient", description="The patient for the vaccination record", type="reference" )
2301  public static final String SP_PATIENT = "patient";
2302  @SearchParamDefinition(name="vaccine-code", path="Immunization.vaccineCode", description="Vaccine Product Administered", type="token" )
2303  public static final String SP_VACCINECODE = "vaccine-code";
2304  @SearchParamDefinition(name="reason-not-given", path="Immunization.explanation.reasonNotGiven", description="Explanation of reason vaccination was not administered", type="token" )
2305  public static final String SP_REASONNOTGIVEN = "reason-not-given";
2306  @SearchParamDefinition(name="location", path="Immunization.location", description="The service delivery location or facility in which the vaccine was / was to be administered", type="reference" )
2307  public static final String SP_LOCATION = "location";
2308  @SearchParamDefinition(name="reaction-date", path="Immunization.reaction.date", description="When reaction started", type="date" )
2309  public static final String SP_REACTIONDATE = "reaction-date";
2310  @SearchParamDefinition(name="status", path="Immunization.status", description="Immunization event status", type="token" )
2311  public static final String SP_STATUS = "status";
2312
2313}
2314