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