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