001package org.hl7.fhir.r5.model;
002
003
004/*
005  Copyright (c) 2011+, HL7, Inc.
006  All rights reserved.
007  
008  Redistribution and use in source and binary forms, with or without modification, \
009  are permitted provided that the following conditions are met:
010  
011   * Redistributions of source code must retain the above copyright notice, this \
012     list of conditions and the following disclaimer.
013   * Redistributions in binary form must reproduce the above copyright notice, \
014     this list of conditions and the following disclaimer in the documentation \
015     and/or other materials provided with the distribution.
016   * Neither the name of HL7 nor the names of its contributors may be used to 
017     endorse or promote products derived from this software without specific 
018     prior written permission.
019  
020  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
021  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
022  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
023  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
024  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
025  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
026  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
027  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
028  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
029  POSSIBILITY OF SUCH DAMAGE.
030  */
031
032// Generated on Tue, Dec 28, 2021 07:16+1100 for FHIR v5.0.0-snapshot1
033
034import java.util.ArrayList;
035import java.util.Date;
036import java.util.List;
037import org.hl7.fhir.utilities.Utilities;
038import org.hl7.fhir.r5.model.Enumerations.*;
039import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
040import org.hl7.fhir.exceptions.FHIRException;
041import org.hl7.fhir.instance.model.api.ICompositeType;
042import ca.uhn.fhir.model.api.annotation.ResourceDef;
043import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
044import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
045import ca.uhn.fhir.model.api.annotation.Child;
046import ca.uhn.fhir.model.api.annotation.ChildOrder;
047import ca.uhn.fhir.model.api.annotation.Description;
048import ca.uhn.fhir.model.api.annotation.Block;
049
050/**
051 * A medically related item or items, in a container or package.
052 */
053@ResourceDef(name="PackagedProductDefinition", profile="http://hl7.org/fhir/StructureDefinition/PackagedProductDefinition")
054public class PackagedProductDefinition extends DomainResource {
055
056    @Block()
057    public static class PackagedProductDefinitionLegalStatusOfSupplyComponent extends BackboneElement implements IBaseBackboneElement {
058        /**
059         * The actual status of supply. In what situation this package type may be supplied for use.
060         */
061        @Child(name = "code", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
062        @Description(shortDefinition="The actual status of supply. In what situation this package type may be supplied for use", formalDefinition="The actual status of supply. In what situation this package type may be supplied for use." )
063        protected CodeableConcept code;
064
065        /**
066         * The place where the legal status of supply applies. When not specified, this indicates it is unknown in this context.
067         */
068        @Child(name = "jurisdiction", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
069        @Description(shortDefinition="The place where the legal status of supply applies. When not specified, this indicates it is unknown in this context", formalDefinition="The place where the legal status of supply applies. When not specified, this indicates it is unknown in this context." )
070        protected CodeableConcept jurisdiction;
071
072        private static final long serialVersionUID = 1072410156L;
073
074    /**
075     * Constructor
076     */
077      public PackagedProductDefinitionLegalStatusOfSupplyComponent() {
078        super();
079      }
080
081        /**
082         * @return {@link #code} (The actual status of supply. In what situation this package type may be supplied for use.)
083         */
084        public CodeableConcept getCode() { 
085          if (this.code == null)
086            if (Configuration.errorOnAutoCreate())
087              throw new Error("Attempt to auto-create PackagedProductDefinitionLegalStatusOfSupplyComponent.code");
088            else if (Configuration.doAutoCreate())
089              this.code = new CodeableConcept(); // cc
090          return this.code;
091        }
092
093        public boolean hasCode() { 
094          return this.code != null && !this.code.isEmpty();
095        }
096
097        /**
098         * @param value {@link #code} (The actual status of supply. In what situation this package type may be supplied for use.)
099         */
100        public PackagedProductDefinitionLegalStatusOfSupplyComponent setCode(CodeableConcept value) { 
101          this.code = value;
102          return this;
103        }
104
105        /**
106         * @return {@link #jurisdiction} (The place where the legal status of supply applies. When not specified, this indicates it is unknown in this context.)
107         */
108        public CodeableConcept getJurisdiction() { 
109          if (this.jurisdiction == null)
110            if (Configuration.errorOnAutoCreate())
111              throw new Error("Attempt to auto-create PackagedProductDefinitionLegalStatusOfSupplyComponent.jurisdiction");
112            else if (Configuration.doAutoCreate())
113              this.jurisdiction = new CodeableConcept(); // cc
114          return this.jurisdiction;
115        }
116
117        public boolean hasJurisdiction() { 
118          return this.jurisdiction != null && !this.jurisdiction.isEmpty();
119        }
120
121        /**
122         * @param value {@link #jurisdiction} (The place where the legal status of supply applies. When not specified, this indicates it is unknown in this context.)
123         */
124        public PackagedProductDefinitionLegalStatusOfSupplyComponent setJurisdiction(CodeableConcept value) { 
125          this.jurisdiction = value;
126          return this;
127        }
128
129        protected void listChildren(List<Property> children) {
130          super.listChildren(children);
131          children.add(new Property("code", "CodeableConcept", "The actual status of supply. In what situation this package type may be supplied for use.", 0, 1, code));
132          children.add(new Property("jurisdiction", "CodeableConcept", "The place where the legal status of supply applies. When not specified, this indicates it is unknown in this context.", 0, 1, jurisdiction));
133        }
134
135        @Override
136        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
137          switch (_hash) {
138          case 3059181: /*code*/  return new Property("code", "CodeableConcept", "The actual status of supply. In what situation this package type may be supplied for use.", 0, 1, code);
139          case -507075711: /*jurisdiction*/  return new Property("jurisdiction", "CodeableConcept", "The place where the legal status of supply applies. When not specified, this indicates it is unknown in this context.", 0, 1, jurisdiction);
140          default: return super.getNamedProperty(_hash, _name, _checkValid);
141          }
142
143        }
144
145      @Override
146      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
147        switch (hash) {
148        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept
149        case -507075711: /*jurisdiction*/ return this.jurisdiction == null ? new Base[0] : new Base[] {this.jurisdiction}; // CodeableConcept
150        default: return super.getProperty(hash, name, checkValid);
151        }
152
153      }
154
155      @Override
156      public Base setProperty(int hash, String name, Base value) throws FHIRException {
157        switch (hash) {
158        case 3059181: // code
159          this.code = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
160          return value;
161        case -507075711: // jurisdiction
162          this.jurisdiction = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
163          return value;
164        default: return super.setProperty(hash, name, value);
165        }
166
167      }
168
169      @Override
170      public Base setProperty(String name, Base value) throws FHIRException {
171        if (name.equals("code")) {
172          this.code = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
173        } else if (name.equals("jurisdiction")) {
174          this.jurisdiction = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
175        } else
176          return super.setProperty(name, value);
177        return value;
178      }
179
180      @Override
181      public Base makeProperty(int hash, String name) throws FHIRException {
182        switch (hash) {
183        case 3059181:  return getCode();
184        case -507075711:  return getJurisdiction();
185        default: return super.makeProperty(hash, name);
186        }
187
188      }
189
190      @Override
191      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
192        switch (hash) {
193        case 3059181: /*code*/ return new String[] {"CodeableConcept"};
194        case -507075711: /*jurisdiction*/ return new String[] {"CodeableConcept"};
195        default: return super.getTypesForProperty(hash, name);
196        }
197
198      }
199
200      @Override
201      public Base addChild(String name) throws FHIRException {
202        if (name.equals("code")) {
203          this.code = new CodeableConcept();
204          return this.code;
205        }
206        else if (name.equals("jurisdiction")) {
207          this.jurisdiction = new CodeableConcept();
208          return this.jurisdiction;
209        }
210        else
211          return super.addChild(name);
212      }
213
214      public PackagedProductDefinitionLegalStatusOfSupplyComponent copy() {
215        PackagedProductDefinitionLegalStatusOfSupplyComponent dst = new PackagedProductDefinitionLegalStatusOfSupplyComponent();
216        copyValues(dst);
217        return dst;
218      }
219
220      public void copyValues(PackagedProductDefinitionLegalStatusOfSupplyComponent dst) {
221        super.copyValues(dst);
222        dst.code = code == null ? null : code.copy();
223        dst.jurisdiction = jurisdiction == null ? null : jurisdiction.copy();
224      }
225
226      @Override
227      public boolean equalsDeep(Base other_) {
228        if (!super.equalsDeep(other_))
229          return false;
230        if (!(other_ instanceof PackagedProductDefinitionLegalStatusOfSupplyComponent))
231          return false;
232        PackagedProductDefinitionLegalStatusOfSupplyComponent o = (PackagedProductDefinitionLegalStatusOfSupplyComponent) other_;
233        return compareDeep(code, o.code, true) && compareDeep(jurisdiction, o.jurisdiction, true);
234      }
235
236      @Override
237      public boolean equalsShallow(Base other_) {
238        if (!super.equalsShallow(other_))
239          return false;
240        if (!(other_ instanceof PackagedProductDefinitionLegalStatusOfSupplyComponent))
241          return false;
242        PackagedProductDefinitionLegalStatusOfSupplyComponent o = (PackagedProductDefinitionLegalStatusOfSupplyComponent) other_;
243        return true;
244      }
245
246      public boolean isEmpty() {
247        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(code, jurisdiction);
248      }
249
250  public String fhirType() {
251    return "PackagedProductDefinition.legalStatusOfSupply";
252
253  }
254
255  }
256
257    @Block()
258    public static class PackagedProductDefinitionPackageComponent extends BackboneElement implements IBaseBackboneElement {
259        /**
260         * Including possibly Data Carrier Identifier.
261         */
262        @Child(name = "identifier", type = {Identifier.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
263        @Description(shortDefinition="Including possibly Data Carrier Identifier", formalDefinition="Including possibly Data Carrier Identifier." )
264        protected List<Identifier> identifier;
265
266        /**
267         * The physical type of the container of the items.
268         */
269        @Child(name = "type", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
270        @Description(shortDefinition="The physical type of the container of the items", formalDefinition="The physical type of the container of the items." )
271        protected CodeableConcept type;
272
273        /**
274         * The quantity of this level of packaging in the package that contains it. If specified, the outermost level is always 1.
275         */
276        @Child(name = "quantity", type = {IntegerType.class}, order=3, min=0, max=1, modifier=false, summary=true)
277        @Description(shortDefinition="The quantity of this level of packaging in the package that contains it. If specified, the outermost level is always 1", formalDefinition="The quantity of this level of packaging in the package that contains it. If specified, the outermost level is always 1." )
278        protected IntegerType quantity;
279
280        /**
281         * Material type of the package item.
282         */
283        @Child(name = "material", type = {CodeableConcept.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
284        @Description(shortDefinition="Material type of the package item", formalDefinition="Material type of the package item." )
285        protected List<CodeableConcept> material;
286
287        /**
288         * A possible alternate material for the packaging.
289         */
290        @Child(name = "alternateMaterial", type = {CodeableConcept.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
291        @Description(shortDefinition="A possible alternate material for the packaging", formalDefinition="A possible alternate material for the packaging." )
292        protected List<CodeableConcept> alternateMaterial;
293
294        /**
295         * Shelf Life and storage information.
296         */
297        @Child(name = "shelfLifeStorage", type = {ProductShelfLife.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
298        @Description(shortDefinition="Shelf Life and storage information", formalDefinition="Shelf Life and storage information." )
299        protected List<ProductShelfLife> shelfLifeStorage;
300
301        /**
302         * Manufacturer of this package Item. When there are multiple it means these are all possible manufacturers.
303         */
304        @Child(name = "manufacturer", type = {Organization.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
305        @Description(shortDefinition="Manufacturer of this package Item. When there are multiple it means these are all possible manufacturers", formalDefinition="Manufacturer of this package Item. When there are multiple it means these are all possible manufacturers." )
306        protected List<Reference> manufacturer;
307
308        /**
309         * General characteristics of this item.
310         */
311        @Child(name = "property", type = {}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
312        @Description(shortDefinition="General characteristics of this item", formalDefinition="General characteristics of this item." )
313        protected List<PackagedProductDefinitionPackagePropertyComponent> property;
314
315        /**
316         * The item(s) within the packaging.
317         */
318        @Child(name = "containedItem", type = {}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
319        @Description(shortDefinition="The item(s) within the packaging", formalDefinition="The item(s) within the packaging." )
320        protected List<PackagedProductDefinitionPackageContainedItemComponent> containedItem;
321
322        /**
323         * Allows containers (and parts of containers) parwithin containers, still a single packaged product.  See also PackagedProductDefinition.package.containedItem.item(PackagedProductDefinition).
324         */
325        @Child(name = "package", type = {PackagedProductDefinitionPackageComponent.class}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
326        @Description(shortDefinition="Allows containers (and parts of containers) within containers, still a single packaged product. See also PackagedProductDefinition.package.containedItem.item(PackagedProductDefinition)", formalDefinition="Allows containers (and parts of containers) parwithin containers, still a single packaged product.  See also PackagedProductDefinition.package.containedItem.item(PackagedProductDefinition)." )
327        protected List<PackagedProductDefinitionPackageComponent> package_;
328
329        private static final long serialVersionUID = 387482302L;
330
331    /**
332     * Constructor
333     */
334      public PackagedProductDefinitionPackageComponent() {
335        super();
336      }
337
338        /**
339         * @return {@link #identifier} (Including possibly Data Carrier Identifier.)
340         */
341        public List<Identifier> getIdentifier() { 
342          if (this.identifier == null)
343            this.identifier = new ArrayList<Identifier>();
344          return this.identifier;
345        }
346
347        /**
348         * @return Returns a reference to <code>this</code> for easy method chaining
349         */
350        public PackagedProductDefinitionPackageComponent setIdentifier(List<Identifier> theIdentifier) { 
351          this.identifier = theIdentifier;
352          return this;
353        }
354
355        public boolean hasIdentifier() { 
356          if (this.identifier == null)
357            return false;
358          for (Identifier item : this.identifier)
359            if (!item.isEmpty())
360              return true;
361          return false;
362        }
363
364        public Identifier addIdentifier() { //3
365          Identifier t = new Identifier();
366          if (this.identifier == null)
367            this.identifier = new ArrayList<Identifier>();
368          this.identifier.add(t);
369          return t;
370        }
371
372        public PackagedProductDefinitionPackageComponent addIdentifier(Identifier t) { //3
373          if (t == null)
374            return this;
375          if (this.identifier == null)
376            this.identifier = new ArrayList<Identifier>();
377          this.identifier.add(t);
378          return this;
379        }
380
381        /**
382         * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist {3}
383         */
384        public Identifier getIdentifierFirstRep() { 
385          if (getIdentifier().isEmpty()) {
386            addIdentifier();
387          }
388          return getIdentifier().get(0);
389        }
390
391        /**
392         * @return {@link #type} (The physical type of the container of the items.)
393         */
394        public CodeableConcept getType() { 
395          if (this.type == null)
396            if (Configuration.errorOnAutoCreate())
397              throw new Error("Attempt to auto-create PackagedProductDefinitionPackageComponent.type");
398            else if (Configuration.doAutoCreate())
399              this.type = new CodeableConcept(); // cc
400          return this.type;
401        }
402
403        public boolean hasType() { 
404          return this.type != null && !this.type.isEmpty();
405        }
406
407        /**
408         * @param value {@link #type} (The physical type of the container of the items.)
409         */
410        public PackagedProductDefinitionPackageComponent setType(CodeableConcept value) { 
411          this.type = value;
412          return this;
413        }
414
415        /**
416         * @return {@link #quantity} (The quantity of this level of packaging in the package that contains it. If specified, the outermost level is always 1.). This is the underlying object with id, value and extensions. The accessor "getQuantity" gives direct access to the value
417         */
418        public IntegerType getQuantityElement() { 
419          if (this.quantity == null)
420            if (Configuration.errorOnAutoCreate())
421              throw new Error("Attempt to auto-create PackagedProductDefinitionPackageComponent.quantity");
422            else if (Configuration.doAutoCreate())
423              this.quantity = new IntegerType(); // bb
424          return this.quantity;
425        }
426
427        public boolean hasQuantityElement() { 
428          return this.quantity != null && !this.quantity.isEmpty();
429        }
430
431        public boolean hasQuantity() { 
432          return this.quantity != null && !this.quantity.isEmpty();
433        }
434
435        /**
436         * @param value {@link #quantity} (The quantity of this level of packaging in the package that contains it. If specified, the outermost level is always 1.). This is the underlying object with id, value and extensions. The accessor "getQuantity" gives direct access to the value
437         */
438        public PackagedProductDefinitionPackageComponent setQuantityElement(IntegerType value) { 
439          this.quantity = value;
440          return this;
441        }
442
443        /**
444         * @return The quantity of this level of packaging in the package that contains it. If specified, the outermost level is always 1.
445         */
446        public int getQuantity() { 
447          return this.quantity == null || this.quantity.isEmpty() ? 0 : this.quantity.getValue();
448        }
449
450        /**
451         * @param value The quantity of this level of packaging in the package that contains it. If specified, the outermost level is always 1.
452         */
453        public PackagedProductDefinitionPackageComponent setQuantity(int value) { 
454            if (this.quantity == null)
455              this.quantity = new IntegerType();
456            this.quantity.setValue(value);
457          return this;
458        }
459
460        /**
461         * @return {@link #material} (Material type of the package item.)
462         */
463        public List<CodeableConcept> getMaterial() { 
464          if (this.material == null)
465            this.material = new ArrayList<CodeableConcept>();
466          return this.material;
467        }
468
469        /**
470         * @return Returns a reference to <code>this</code> for easy method chaining
471         */
472        public PackagedProductDefinitionPackageComponent setMaterial(List<CodeableConcept> theMaterial) { 
473          this.material = theMaterial;
474          return this;
475        }
476
477        public boolean hasMaterial() { 
478          if (this.material == null)
479            return false;
480          for (CodeableConcept item : this.material)
481            if (!item.isEmpty())
482              return true;
483          return false;
484        }
485
486        public CodeableConcept addMaterial() { //3
487          CodeableConcept t = new CodeableConcept();
488          if (this.material == null)
489            this.material = new ArrayList<CodeableConcept>();
490          this.material.add(t);
491          return t;
492        }
493
494        public PackagedProductDefinitionPackageComponent addMaterial(CodeableConcept t) { //3
495          if (t == null)
496            return this;
497          if (this.material == null)
498            this.material = new ArrayList<CodeableConcept>();
499          this.material.add(t);
500          return this;
501        }
502
503        /**
504         * @return The first repetition of repeating field {@link #material}, creating it if it does not already exist {3}
505         */
506        public CodeableConcept getMaterialFirstRep() { 
507          if (getMaterial().isEmpty()) {
508            addMaterial();
509          }
510          return getMaterial().get(0);
511        }
512
513        /**
514         * @return {@link #alternateMaterial} (A possible alternate material for the packaging.)
515         */
516        public List<CodeableConcept> getAlternateMaterial() { 
517          if (this.alternateMaterial == null)
518            this.alternateMaterial = new ArrayList<CodeableConcept>();
519          return this.alternateMaterial;
520        }
521
522        /**
523         * @return Returns a reference to <code>this</code> for easy method chaining
524         */
525        public PackagedProductDefinitionPackageComponent setAlternateMaterial(List<CodeableConcept> theAlternateMaterial) { 
526          this.alternateMaterial = theAlternateMaterial;
527          return this;
528        }
529
530        public boolean hasAlternateMaterial() { 
531          if (this.alternateMaterial == null)
532            return false;
533          for (CodeableConcept item : this.alternateMaterial)
534            if (!item.isEmpty())
535              return true;
536          return false;
537        }
538
539        public CodeableConcept addAlternateMaterial() { //3
540          CodeableConcept t = new CodeableConcept();
541          if (this.alternateMaterial == null)
542            this.alternateMaterial = new ArrayList<CodeableConcept>();
543          this.alternateMaterial.add(t);
544          return t;
545        }
546
547        public PackagedProductDefinitionPackageComponent addAlternateMaterial(CodeableConcept t) { //3
548          if (t == null)
549            return this;
550          if (this.alternateMaterial == null)
551            this.alternateMaterial = new ArrayList<CodeableConcept>();
552          this.alternateMaterial.add(t);
553          return this;
554        }
555
556        /**
557         * @return The first repetition of repeating field {@link #alternateMaterial}, creating it if it does not already exist {3}
558         */
559        public CodeableConcept getAlternateMaterialFirstRep() { 
560          if (getAlternateMaterial().isEmpty()) {
561            addAlternateMaterial();
562          }
563          return getAlternateMaterial().get(0);
564        }
565
566        /**
567         * @return {@link #shelfLifeStorage} (Shelf Life and storage information.)
568         */
569        public List<ProductShelfLife> getShelfLifeStorage() { 
570          if (this.shelfLifeStorage == null)
571            this.shelfLifeStorage = new ArrayList<ProductShelfLife>();
572          return this.shelfLifeStorage;
573        }
574
575        /**
576         * @return Returns a reference to <code>this</code> for easy method chaining
577         */
578        public PackagedProductDefinitionPackageComponent setShelfLifeStorage(List<ProductShelfLife> theShelfLifeStorage) { 
579          this.shelfLifeStorage = theShelfLifeStorage;
580          return this;
581        }
582
583        public boolean hasShelfLifeStorage() { 
584          if (this.shelfLifeStorage == null)
585            return false;
586          for (ProductShelfLife item : this.shelfLifeStorage)
587            if (!item.isEmpty())
588              return true;
589          return false;
590        }
591
592        public ProductShelfLife addShelfLifeStorage() { //3
593          ProductShelfLife t = new ProductShelfLife();
594          if (this.shelfLifeStorage == null)
595            this.shelfLifeStorage = new ArrayList<ProductShelfLife>();
596          this.shelfLifeStorage.add(t);
597          return t;
598        }
599
600        public PackagedProductDefinitionPackageComponent addShelfLifeStorage(ProductShelfLife t) { //3
601          if (t == null)
602            return this;
603          if (this.shelfLifeStorage == null)
604            this.shelfLifeStorage = new ArrayList<ProductShelfLife>();
605          this.shelfLifeStorage.add(t);
606          return this;
607        }
608
609        /**
610         * @return The first repetition of repeating field {@link #shelfLifeStorage}, creating it if it does not already exist {3}
611         */
612        public ProductShelfLife getShelfLifeStorageFirstRep() { 
613          if (getShelfLifeStorage().isEmpty()) {
614            addShelfLifeStorage();
615          }
616          return getShelfLifeStorage().get(0);
617        }
618
619        /**
620         * @return {@link #manufacturer} (Manufacturer of this package Item. When there are multiple it means these are all possible manufacturers.)
621         */
622        public List<Reference> getManufacturer() { 
623          if (this.manufacturer == null)
624            this.manufacturer = new ArrayList<Reference>();
625          return this.manufacturer;
626        }
627
628        /**
629         * @return Returns a reference to <code>this</code> for easy method chaining
630         */
631        public PackagedProductDefinitionPackageComponent setManufacturer(List<Reference> theManufacturer) { 
632          this.manufacturer = theManufacturer;
633          return this;
634        }
635
636        public boolean hasManufacturer() { 
637          if (this.manufacturer == null)
638            return false;
639          for (Reference item : this.manufacturer)
640            if (!item.isEmpty())
641              return true;
642          return false;
643        }
644
645        public Reference addManufacturer() { //3
646          Reference t = new Reference();
647          if (this.manufacturer == null)
648            this.manufacturer = new ArrayList<Reference>();
649          this.manufacturer.add(t);
650          return t;
651        }
652
653        public PackagedProductDefinitionPackageComponent addManufacturer(Reference t) { //3
654          if (t == null)
655            return this;
656          if (this.manufacturer == null)
657            this.manufacturer = new ArrayList<Reference>();
658          this.manufacturer.add(t);
659          return this;
660        }
661
662        /**
663         * @return The first repetition of repeating field {@link #manufacturer}, creating it if it does not already exist {3}
664         */
665        public Reference getManufacturerFirstRep() { 
666          if (getManufacturer().isEmpty()) {
667            addManufacturer();
668          }
669          return getManufacturer().get(0);
670        }
671
672        /**
673         * @return {@link #property} (General characteristics of this item.)
674         */
675        public List<PackagedProductDefinitionPackagePropertyComponent> getProperty() { 
676          if (this.property == null)
677            this.property = new ArrayList<PackagedProductDefinitionPackagePropertyComponent>();
678          return this.property;
679        }
680
681        /**
682         * @return Returns a reference to <code>this</code> for easy method chaining
683         */
684        public PackagedProductDefinitionPackageComponent setProperty(List<PackagedProductDefinitionPackagePropertyComponent> theProperty) { 
685          this.property = theProperty;
686          return this;
687        }
688
689        public boolean hasProperty() { 
690          if (this.property == null)
691            return false;
692          for (PackagedProductDefinitionPackagePropertyComponent item : this.property)
693            if (!item.isEmpty())
694              return true;
695          return false;
696        }
697
698        public PackagedProductDefinitionPackagePropertyComponent addProperty() { //3
699          PackagedProductDefinitionPackagePropertyComponent t = new PackagedProductDefinitionPackagePropertyComponent();
700          if (this.property == null)
701            this.property = new ArrayList<PackagedProductDefinitionPackagePropertyComponent>();
702          this.property.add(t);
703          return t;
704        }
705
706        public PackagedProductDefinitionPackageComponent addProperty(PackagedProductDefinitionPackagePropertyComponent t) { //3
707          if (t == null)
708            return this;
709          if (this.property == null)
710            this.property = new ArrayList<PackagedProductDefinitionPackagePropertyComponent>();
711          this.property.add(t);
712          return this;
713        }
714
715        /**
716         * @return The first repetition of repeating field {@link #property}, creating it if it does not already exist {3}
717         */
718        public PackagedProductDefinitionPackagePropertyComponent getPropertyFirstRep() { 
719          if (getProperty().isEmpty()) {
720            addProperty();
721          }
722          return getProperty().get(0);
723        }
724
725        /**
726         * @return {@link #containedItem} (The item(s) within the packaging.)
727         */
728        public List<PackagedProductDefinitionPackageContainedItemComponent> getContainedItem() { 
729          if (this.containedItem == null)
730            this.containedItem = new ArrayList<PackagedProductDefinitionPackageContainedItemComponent>();
731          return this.containedItem;
732        }
733
734        /**
735         * @return Returns a reference to <code>this</code> for easy method chaining
736         */
737        public PackagedProductDefinitionPackageComponent setContainedItem(List<PackagedProductDefinitionPackageContainedItemComponent> theContainedItem) { 
738          this.containedItem = theContainedItem;
739          return this;
740        }
741
742        public boolean hasContainedItem() { 
743          if (this.containedItem == null)
744            return false;
745          for (PackagedProductDefinitionPackageContainedItemComponent item : this.containedItem)
746            if (!item.isEmpty())
747              return true;
748          return false;
749        }
750
751        public PackagedProductDefinitionPackageContainedItemComponent addContainedItem() { //3
752          PackagedProductDefinitionPackageContainedItemComponent t = new PackagedProductDefinitionPackageContainedItemComponent();
753          if (this.containedItem == null)
754            this.containedItem = new ArrayList<PackagedProductDefinitionPackageContainedItemComponent>();
755          this.containedItem.add(t);
756          return t;
757        }
758
759        public PackagedProductDefinitionPackageComponent addContainedItem(PackagedProductDefinitionPackageContainedItemComponent t) { //3
760          if (t == null)
761            return this;
762          if (this.containedItem == null)
763            this.containedItem = new ArrayList<PackagedProductDefinitionPackageContainedItemComponent>();
764          this.containedItem.add(t);
765          return this;
766        }
767
768        /**
769         * @return The first repetition of repeating field {@link #containedItem}, creating it if it does not already exist {3}
770         */
771        public PackagedProductDefinitionPackageContainedItemComponent getContainedItemFirstRep() { 
772          if (getContainedItem().isEmpty()) {
773            addContainedItem();
774          }
775          return getContainedItem().get(0);
776        }
777
778        /**
779         * @return {@link #package_} (Allows containers (and parts of containers) parwithin containers, still a single packaged product.  See also PackagedProductDefinition.package.containedItem.item(PackagedProductDefinition).)
780         */
781        public List<PackagedProductDefinitionPackageComponent> getPackage() { 
782          if (this.package_ == null)
783            this.package_ = new ArrayList<PackagedProductDefinitionPackageComponent>();
784          return this.package_;
785        }
786
787        /**
788         * @return Returns a reference to <code>this</code> for easy method chaining
789         */
790        public PackagedProductDefinitionPackageComponent setPackage(List<PackagedProductDefinitionPackageComponent> thePackage) { 
791          this.package_ = thePackage;
792          return this;
793        }
794
795        public boolean hasPackage() { 
796          if (this.package_ == null)
797            return false;
798          for (PackagedProductDefinitionPackageComponent item : this.package_)
799            if (!item.isEmpty())
800              return true;
801          return false;
802        }
803
804        public PackagedProductDefinitionPackageComponent addPackage() { //3
805          PackagedProductDefinitionPackageComponent t = new PackagedProductDefinitionPackageComponent();
806          if (this.package_ == null)
807            this.package_ = new ArrayList<PackagedProductDefinitionPackageComponent>();
808          this.package_.add(t);
809          return t;
810        }
811
812        public PackagedProductDefinitionPackageComponent addPackage(PackagedProductDefinitionPackageComponent t) { //3
813          if (t == null)
814            return this;
815          if (this.package_ == null)
816            this.package_ = new ArrayList<PackagedProductDefinitionPackageComponent>();
817          this.package_.add(t);
818          return this;
819        }
820
821        /**
822         * @return The first repetition of repeating field {@link #package_}, creating it if it does not already exist {3}
823         */
824        public PackagedProductDefinitionPackageComponent getPackageFirstRep() { 
825          if (getPackage().isEmpty()) {
826            addPackage();
827          }
828          return getPackage().get(0);
829        }
830
831        protected void listChildren(List<Property> children) {
832          super.listChildren(children);
833          children.add(new Property("identifier", "Identifier", "Including possibly Data Carrier Identifier.", 0, java.lang.Integer.MAX_VALUE, identifier));
834          children.add(new Property("type", "CodeableConcept", "The physical type of the container of the items.", 0, 1, type));
835          children.add(new Property("quantity", "integer", "The quantity of this level of packaging in the package that contains it. If specified, the outermost level is always 1.", 0, 1, quantity));
836          children.add(new Property("material", "CodeableConcept", "Material type of the package item.", 0, java.lang.Integer.MAX_VALUE, material));
837          children.add(new Property("alternateMaterial", "CodeableConcept", "A possible alternate material for the packaging.", 0, java.lang.Integer.MAX_VALUE, alternateMaterial));
838          children.add(new Property("shelfLifeStorage", "ProductShelfLife", "Shelf Life and storage information.", 0, java.lang.Integer.MAX_VALUE, shelfLifeStorage));
839          children.add(new Property("manufacturer", "Reference(Organization)", "Manufacturer of this package Item. When there are multiple it means these are all possible manufacturers.", 0, java.lang.Integer.MAX_VALUE, manufacturer));
840          children.add(new Property("property", "", "General characteristics of this item.", 0, java.lang.Integer.MAX_VALUE, property));
841          children.add(new Property("containedItem", "", "The item(s) within the packaging.", 0, java.lang.Integer.MAX_VALUE, containedItem));
842          children.add(new Property("package", "@PackagedProductDefinition.package", "Allows containers (and parts of containers) parwithin containers, still a single packaged product.  See also PackagedProductDefinition.package.containedItem.item(PackagedProductDefinition).", 0, java.lang.Integer.MAX_VALUE, package_));
843        }
844
845        @Override
846        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
847          switch (_hash) {
848          case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Including possibly Data Carrier Identifier.", 0, java.lang.Integer.MAX_VALUE, identifier);
849          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "The physical type of the container of the items.", 0, 1, type);
850          case -1285004149: /*quantity*/  return new Property("quantity", "integer", "The quantity of this level of packaging in the package that contains it. If specified, the outermost level is always 1.", 0, 1, quantity);
851          case 299066663: /*material*/  return new Property("material", "CodeableConcept", "Material type of the package item.", 0, java.lang.Integer.MAX_VALUE, material);
852          case -1021448255: /*alternateMaterial*/  return new Property("alternateMaterial", "CodeableConcept", "A possible alternate material for the packaging.", 0, java.lang.Integer.MAX_VALUE, alternateMaterial);
853          case 172049237: /*shelfLifeStorage*/  return new Property("shelfLifeStorage", "ProductShelfLife", "Shelf Life and storage information.", 0, java.lang.Integer.MAX_VALUE, shelfLifeStorage);
854          case -1969347631: /*manufacturer*/  return new Property("manufacturer", "Reference(Organization)", "Manufacturer of this package Item. When there are multiple it means these are all possible manufacturers.", 0, java.lang.Integer.MAX_VALUE, manufacturer);
855          case -993141291: /*property*/  return new Property("property", "", "General characteristics of this item.", 0, java.lang.Integer.MAX_VALUE, property);
856          case 1953679910: /*containedItem*/  return new Property("containedItem", "", "The item(s) within the packaging.", 0, java.lang.Integer.MAX_VALUE, containedItem);
857          case -807062458: /*package*/  return new Property("package", "@PackagedProductDefinition.package", "Allows containers (and parts of containers) parwithin containers, still a single packaged product.  See also PackagedProductDefinition.package.containedItem.item(PackagedProductDefinition).", 0, java.lang.Integer.MAX_VALUE, package_);
858          default: return super.getNamedProperty(_hash, _name, _checkValid);
859          }
860
861        }
862
863      @Override
864      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
865        switch (hash) {
866        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
867        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
868        case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // IntegerType
869        case 299066663: /*material*/ return this.material == null ? new Base[0] : this.material.toArray(new Base[this.material.size()]); // CodeableConcept
870        case -1021448255: /*alternateMaterial*/ return this.alternateMaterial == null ? new Base[0] : this.alternateMaterial.toArray(new Base[this.alternateMaterial.size()]); // CodeableConcept
871        case 172049237: /*shelfLifeStorage*/ return this.shelfLifeStorage == null ? new Base[0] : this.shelfLifeStorage.toArray(new Base[this.shelfLifeStorage.size()]); // ProductShelfLife
872        case -1969347631: /*manufacturer*/ return this.manufacturer == null ? new Base[0] : this.manufacturer.toArray(new Base[this.manufacturer.size()]); // Reference
873        case -993141291: /*property*/ return this.property == null ? new Base[0] : this.property.toArray(new Base[this.property.size()]); // PackagedProductDefinitionPackagePropertyComponent
874        case 1953679910: /*containedItem*/ return this.containedItem == null ? new Base[0] : this.containedItem.toArray(new Base[this.containedItem.size()]); // PackagedProductDefinitionPackageContainedItemComponent
875        case -807062458: /*package*/ return this.package_ == null ? new Base[0] : this.package_.toArray(new Base[this.package_.size()]); // PackagedProductDefinitionPackageComponent
876        default: return super.getProperty(hash, name, checkValid);
877        }
878
879      }
880
881      @Override
882      public Base setProperty(int hash, String name, Base value) throws FHIRException {
883        switch (hash) {
884        case -1618432855: // identifier
885          this.getIdentifier().add(TypeConvertor.castToIdentifier(value)); // Identifier
886          return value;
887        case 3575610: // type
888          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
889          return value;
890        case -1285004149: // quantity
891          this.quantity = TypeConvertor.castToInteger(value); // IntegerType
892          return value;
893        case 299066663: // material
894          this.getMaterial().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
895          return value;
896        case -1021448255: // alternateMaterial
897          this.getAlternateMaterial().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
898          return value;
899        case 172049237: // shelfLifeStorage
900          this.getShelfLifeStorage().add(TypeConvertor.castToProductShelfLife(value)); // ProductShelfLife
901          return value;
902        case -1969347631: // manufacturer
903          this.getManufacturer().add(TypeConvertor.castToReference(value)); // Reference
904          return value;
905        case -993141291: // property
906          this.getProperty().add((PackagedProductDefinitionPackagePropertyComponent) value); // PackagedProductDefinitionPackagePropertyComponent
907          return value;
908        case 1953679910: // containedItem
909          this.getContainedItem().add((PackagedProductDefinitionPackageContainedItemComponent) value); // PackagedProductDefinitionPackageContainedItemComponent
910          return value;
911        case -807062458: // package
912          this.getPackage().add((PackagedProductDefinitionPackageComponent) value); // PackagedProductDefinitionPackageComponent
913          return value;
914        default: return super.setProperty(hash, name, value);
915        }
916
917      }
918
919      @Override
920      public Base setProperty(String name, Base value) throws FHIRException {
921        if (name.equals("identifier")) {
922          this.getIdentifier().add(TypeConvertor.castToIdentifier(value));
923        } else if (name.equals("type")) {
924          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
925        } else if (name.equals("quantity")) {
926          this.quantity = TypeConvertor.castToInteger(value); // IntegerType
927        } else if (name.equals("material")) {
928          this.getMaterial().add(TypeConvertor.castToCodeableConcept(value));
929        } else if (name.equals("alternateMaterial")) {
930          this.getAlternateMaterial().add(TypeConvertor.castToCodeableConcept(value));
931        } else if (name.equals("shelfLifeStorage")) {
932          this.getShelfLifeStorage().add(TypeConvertor.castToProductShelfLife(value));
933        } else if (name.equals("manufacturer")) {
934          this.getManufacturer().add(TypeConvertor.castToReference(value));
935        } else if (name.equals("property")) {
936          this.getProperty().add((PackagedProductDefinitionPackagePropertyComponent) value);
937        } else if (name.equals("containedItem")) {
938          this.getContainedItem().add((PackagedProductDefinitionPackageContainedItemComponent) value);
939        } else if (name.equals("package")) {
940          this.getPackage().add((PackagedProductDefinitionPackageComponent) value);
941        } else
942          return super.setProperty(name, value);
943        return value;
944      }
945
946      @Override
947      public Base makeProperty(int hash, String name) throws FHIRException {
948        switch (hash) {
949        case -1618432855:  return addIdentifier(); 
950        case 3575610:  return getType();
951        case -1285004149:  return getQuantityElement();
952        case 299066663:  return addMaterial(); 
953        case -1021448255:  return addAlternateMaterial(); 
954        case 172049237:  return addShelfLifeStorage(); 
955        case -1969347631:  return addManufacturer(); 
956        case -993141291:  return addProperty(); 
957        case 1953679910:  return addContainedItem(); 
958        case -807062458:  return addPackage(); 
959        default: return super.makeProperty(hash, name);
960        }
961
962      }
963
964      @Override
965      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
966        switch (hash) {
967        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
968        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
969        case -1285004149: /*quantity*/ return new String[] {"integer"};
970        case 299066663: /*material*/ return new String[] {"CodeableConcept"};
971        case -1021448255: /*alternateMaterial*/ return new String[] {"CodeableConcept"};
972        case 172049237: /*shelfLifeStorage*/ return new String[] {"ProductShelfLife"};
973        case -1969347631: /*manufacturer*/ return new String[] {"Reference"};
974        case -993141291: /*property*/ return new String[] {};
975        case 1953679910: /*containedItem*/ return new String[] {};
976        case -807062458: /*package*/ return new String[] {"@PackagedProductDefinition.package"};
977        default: return super.getTypesForProperty(hash, name);
978        }
979
980      }
981
982      @Override
983      public Base addChild(String name) throws FHIRException {
984        if (name.equals("identifier")) {
985          return addIdentifier();
986        }
987        else if (name.equals("type")) {
988          this.type = new CodeableConcept();
989          return this.type;
990        }
991        else if (name.equals("quantity")) {
992          throw new FHIRException("Cannot call addChild on a primitive type PackagedProductDefinition.package.quantity");
993        }
994        else if (name.equals("material")) {
995          return addMaterial();
996        }
997        else if (name.equals("alternateMaterial")) {
998          return addAlternateMaterial();
999        }
1000        else if (name.equals("shelfLifeStorage")) {
1001          return addShelfLifeStorage();
1002        }
1003        else if (name.equals("manufacturer")) {
1004          return addManufacturer();
1005        }
1006        else if (name.equals("property")) {
1007          return addProperty();
1008        }
1009        else if (name.equals("containedItem")) {
1010          return addContainedItem();
1011        }
1012        else if (name.equals("package")) {
1013          return addPackage();
1014        }
1015        else
1016          return super.addChild(name);
1017      }
1018
1019      public PackagedProductDefinitionPackageComponent copy() {
1020        PackagedProductDefinitionPackageComponent dst = new PackagedProductDefinitionPackageComponent();
1021        copyValues(dst);
1022        return dst;
1023      }
1024
1025      public void copyValues(PackagedProductDefinitionPackageComponent dst) {
1026        super.copyValues(dst);
1027        if (identifier != null) {
1028          dst.identifier = new ArrayList<Identifier>();
1029          for (Identifier i : identifier)
1030            dst.identifier.add(i.copy());
1031        };
1032        dst.type = type == null ? null : type.copy();
1033        dst.quantity = quantity == null ? null : quantity.copy();
1034        if (material != null) {
1035          dst.material = new ArrayList<CodeableConcept>();
1036          for (CodeableConcept i : material)
1037            dst.material.add(i.copy());
1038        };
1039        if (alternateMaterial != null) {
1040          dst.alternateMaterial = new ArrayList<CodeableConcept>();
1041          for (CodeableConcept i : alternateMaterial)
1042            dst.alternateMaterial.add(i.copy());
1043        };
1044        if (shelfLifeStorage != null) {
1045          dst.shelfLifeStorage = new ArrayList<ProductShelfLife>();
1046          for (ProductShelfLife i : shelfLifeStorage)
1047            dst.shelfLifeStorage.add(i.copy());
1048        };
1049        if (manufacturer != null) {
1050          dst.manufacturer = new ArrayList<Reference>();
1051          for (Reference i : manufacturer)
1052            dst.manufacturer.add(i.copy());
1053        };
1054        if (property != null) {
1055          dst.property = new ArrayList<PackagedProductDefinitionPackagePropertyComponent>();
1056          for (PackagedProductDefinitionPackagePropertyComponent i : property)
1057            dst.property.add(i.copy());
1058        };
1059        if (containedItem != null) {
1060          dst.containedItem = new ArrayList<PackagedProductDefinitionPackageContainedItemComponent>();
1061          for (PackagedProductDefinitionPackageContainedItemComponent i : containedItem)
1062            dst.containedItem.add(i.copy());
1063        };
1064        if (package_ != null) {
1065          dst.package_ = new ArrayList<PackagedProductDefinitionPackageComponent>();
1066          for (PackagedProductDefinitionPackageComponent i : package_)
1067            dst.package_.add(i.copy());
1068        };
1069      }
1070
1071      @Override
1072      public boolean equalsDeep(Base other_) {
1073        if (!super.equalsDeep(other_))
1074          return false;
1075        if (!(other_ instanceof PackagedProductDefinitionPackageComponent))
1076          return false;
1077        PackagedProductDefinitionPackageComponent o = (PackagedProductDefinitionPackageComponent) other_;
1078        return compareDeep(identifier, o.identifier, true) && compareDeep(type, o.type, true) && compareDeep(quantity, o.quantity, true)
1079           && compareDeep(material, o.material, true) && compareDeep(alternateMaterial, o.alternateMaterial, true)
1080           && compareDeep(shelfLifeStorage, o.shelfLifeStorage, true) && compareDeep(manufacturer, o.manufacturer, true)
1081           && compareDeep(property, o.property, true) && compareDeep(containedItem, o.containedItem, true)
1082           && compareDeep(package_, o.package_, true);
1083      }
1084
1085      @Override
1086      public boolean equalsShallow(Base other_) {
1087        if (!super.equalsShallow(other_))
1088          return false;
1089        if (!(other_ instanceof PackagedProductDefinitionPackageComponent))
1090          return false;
1091        PackagedProductDefinitionPackageComponent o = (PackagedProductDefinitionPackageComponent) other_;
1092        return compareValues(quantity, o.quantity, true);
1093      }
1094
1095      public boolean isEmpty() {
1096        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, type, quantity
1097          , material, alternateMaterial, shelfLifeStorage, manufacturer, property, containedItem
1098          , package_);
1099      }
1100
1101  public String fhirType() {
1102    return "PackagedProductDefinition.package";
1103
1104  }
1105
1106  }
1107
1108    @Block()
1109    public static class PackagedProductDefinitionPackagePropertyComponent extends BackboneElement implements IBaseBackboneElement {
1110        /**
1111         * A code expressing the type of characteristic.
1112         */
1113        @Child(name = "type", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=true)
1114        @Description(shortDefinition="A code expressing the type of characteristic", formalDefinition="A code expressing the type of characteristic." )
1115        protected CodeableConcept type;
1116
1117        /**
1118         * A value for the characteristic.
1119         */
1120        @Child(name = "value", type = {CodeableConcept.class, Quantity.class, DateType.class, BooleanType.class, Attachment.class}, order=2, min=0, max=1, modifier=false, summary=true)
1121        @Description(shortDefinition="A value for the characteristic", formalDefinition="A value for the characteristic." )
1122        protected DataType value;
1123
1124        private static final long serialVersionUID = -1659186716L;
1125
1126    /**
1127     * Constructor
1128     */
1129      public PackagedProductDefinitionPackagePropertyComponent() {
1130        super();
1131      }
1132
1133    /**
1134     * Constructor
1135     */
1136      public PackagedProductDefinitionPackagePropertyComponent(CodeableConcept type) {
1137        super();
1138        this.setType(type);
1139      }
1140
1141        /**
1142         * @return {@link #type} (A code expressing the type of characteristic.)
1143         */
1144        public CodeableConcept getType() { 
1145          if (this.type == null)
1146            if (Configuration.errorOnAutoCreate())
1147              throw new Error("Attempt to auto-create PackagedProductDefinitionPackagePropertyComponent.type");
1148            else if (Configuration.doAutoCreate())
1149              this.type = new CodeableConcept(); // cc
1150          return this.type;
1151        }
1152
1153        public boolean hasType() { 
1154          return this.type != null && !this.type.isEmpty();
1155        }
1156
1157        /**
1158         * @param value {@link #type} (A code expressing the type of characteristic.)
1159         */
1160        public PackagedProductDefinitionPackagePropertyComponent setType(CodeableConcept value) { 
1161          this.type = value;
1162          return this;
1163        }
1164
1165        /**
1166         * @return {@link #value} (A value for the characteristic.)
1167         */
1168        public DataType getValue() { 
1169          return this.value;
1170        }
1171
1172        /**
1173         * @return {@link #value} (A value for the characteristic.)
1174         */
1175        public CodeableConcept getValueCodeableConcept() throws FHIRException { 
1176          if (this.value == null)
1177            this.value = new CodeableConcept();
1178          if (!(this.value instanceof CodeableConcept))
1179            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.value.getClass().getName()+" was encountered");
1180          return (CodeableConcept) this.value;
1181        }
1182
1183        public boolean hasValueCodeableConcept() { 
1184          return this != null && this.value instanceof CodeableConcept;
1185        }
1186
1187        /**
1188         * @return {@link #value} (A value for the characteristic.)
1189         */
1190        public Quantity getValueQuantity() throws FHIRException { 
1191          if (this.value == null)
1192            this.value = new Quantity();
1193          if (!(this.value instanceof Quantity))
1194            throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.value.getClass().getName()+" was encountered");
1195          return (Quantity) this.value;
1196        }
1197
1198        public boolean hasValueQuantity() { 
1199          return this != null && this.value instanceof Quantity;
1200        }
1201
1202        /**
1203         * @return {@link #value} (A value for the characteristic.)
1204         */
1205        public DateType getValueDateType() throws FHIRException { 
1206          if (this.value == null)
1207            this.value = new DateType();
1208          if (!(this.value instanceof DateType))
1209            throw new FHIRException("Type mismatch: the type DateType was expected, but "+this.value.getClass().getName()+" was encountered");
1210          return (DateType) this.value;
1211        }
1212
1213        public boolean hasValueDateType() { 
1214          return this != null && this.value instanceof DateType;
1215        }
1216
1217        /**
1218         * @return {@link #value} (A value for the characteristic.)
1219         */
1220        public BooleanType getValueBooleanType() throws FHIRException { 
1221          if (this.value == null)
1222            this.value = new BooleanType();
1223          if (!(this.value instanceof BooleanType))
1224            throw new FHIRException("Type mismatch: the type BooleanType was expected, but "+this.value.getClass().getName()+" was encountered");
1225          return (BooleanType) this.value;
1226        }
1227
1228        public boolean hasValueBooleanType() { 
1229          return this != null && this.value instanceof BooleanType;
1230        }
1231
1232        /**
1233         * @return {@link #value} (A value for the characteristic.)
1234         */
1235        public Attachment getValueAttachment() throws FHIRException { 
1236          if (this.value == null)
1237            this.value = new Attachment();
1238          if (!(this.value instanceof Attachment))
1239            throw new FHIRException("Type mismatch: the type Attachment was expected, but "+this.value.getClass().getName()+" was encountered");
1240          return (Attachment) this.value;
1241        }
1242
1243        public boolean hasValueAttachment() { 
1244          return this != null && this.value instanceof Attachment;
1245        }
1246
1247        public boolean hasValue() { 
1248          return this.value != null && !this.value.isEmpty();
1249        }
1250
1251        /**
1252         * @param value {@link #value} (A value for the characteristic.)
1253         */
1254        public PackagedProductDefinitionPackagePropertyComponent setValue(DataType value) { 
1255          if (value != null && !(value instanceof CodeableConcept || value instanceof Quantity || value instanceof DateType || value instanceof BooleanType || value instanceof Attachment))
1256            throw new Error("Not the right type for PackagedProductDefinition.package.property.value[x]: "+value.fhirType());
1257          this.value = value;
1258          return this;
1259        }
1260
1261        protected void listChildren(List<Property> children) {
1262          super.listChildren(children);
1263          children.add(new Property("type", "CodeableConcept", "A code expressing the type of characteristic.", 0, 1, type));
1264          children.add(new Property("value[x]", "CodeableConcept|Quantity|date|boolean|Attachment", "A value for the characteristic.", 0, 1, value));
1265        }
1266
1267        @Override
1268        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1269          switch (_hash) {
1270          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "A code expressing the type of characteristic.", 0, 1, type);
1271          case -1410166417: /*value[x]*/  return new Property("value[x]", "CodeableConcept|Quantity|date|boolean|Attachment", "A value for the characteristic.", 0, 1, value);
1272          case 111972721: /*value*/  return new Property("value[x]", "CodeableConcept|Quantity|date|boolean|Attachment", "A value for the characteristic.", 0, 1, value);
1273          case 924902896: /*valueCodeableConcept*/  return new Property("value[x]", "CodeableConcept", "A value for the characteristic.", 0, 1, value);
1274          case -2029823716: /*valueQuantity*/  return new Property("value[x]", "Quantity", "A value for the characteristic.", 0, 1, value);
1275          case -766192449: /*valueDate*/  return new Property("value[x]", "date", "A value for the characteristic.", 0, 1, value);
1276          case 733421943: /*valueBoolean*/  return new Property("value[x]", "boolean", "A value for the characteristic.", 0, 1, value);
1277          case -475566732: /*valueAttachment*/  return new Property("value[x]", "Attachment", "A value for the characteristic.", 0, 1, value);
1278          default: return super.getNamedProperty(_hash, _name, _checkValid);
1279          }
1280
1281        }
1282
1283      @Override
1284      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1285        switch (hash) {
1286        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
1287        case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // DataType
1288        default: return super.getProperty(hash, name, checkValid);
1289        }
1290
1291      }
1292
1293      @Override
1294      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1295        switch (hash) {
1296        case 3575610: // type
1297          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1298          return value;
1299        case 111972721: // value
1300          this.value = TypeConvertor.castToType(value); // DataType
1301          return value;
1302        default: return super.setProperty(hash, name, value);
1303        }
1304
1305      }
1306
1307      @Override
1308      public Base setProperty(String name, Base value) throws FHIRException {
1309        if (name.equals("type")) {
1310          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1311        } else if (name.equals("value[x]")) {
1312          this.value = TypeConvertor.castToType(value); // DataType
1313        } else
1314          return super.setProperty(name, value);
1315        return value;
1316      }
1317
1318      @Override
1319      public Base makeProperty(int hash, String name) throws FHIRException {
1320        switch (hash) {
1321        case 3575610:  return getType();
1322        case -1410166417:  return getValue();
1323        case 111972721:  return getValue();
1324        default: return super.makeProperty(hash, name);
1325        }
1326
1327      }
1328
1329      @Override
1330      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1331        switch (hash) {
1332        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
1333        case 111972721: /*value*/ return new String[] {"CodeableConcept", "Quantity", "date", "boolean", "Attachment"};
1334        default: return super.getTypesForProperty(hash, name);
1335        }
1336
1337      }
1338
1339      @Override
1340      public Base addChild(String name) throws FHIRException {
1341        if (name.equals("type")) {
1342          this.type = new CodeableConcept();
1343          return this.type;
1344        }
1345        else if (name.equals("valueCodeableConcept")) {
1346          this.value = new CodeableConcept();
1347          return this.value;
1348        }
1349        else if (name.equals("valueQuantity")) {
1350          this.value = new Quantity();
1351          return this.value;
1352        }
1353        else if (name.equals("valueDate")) {
1354          this.value = new DateType();
1355          return this.value;
1356        }
1357        else if (name.equals("valueBoolean")) {
1358          this.value = new BooleanType();
1359          return this.value;
1360        }
1361        else if (name.equals("valueAttachment")) {
1362          this.value = new Attachment();
1363          return this.value;
1364        }
1365        else
1366          return super.addChild(name);
1367      }
1368
1369      public PackagedProductDefinitionPackagePropertyComponent copy() {
1370        PackagedProductDefinitionPackagePropertyComponent dst = new PackagedProductDefinitionPackagePropertyComponent();
1371        copyValues(dst);
1372        return dst;
1373      }
1374
1375      public void copyValues(PackagedProductDefinitionPackagePropertyComponent dst) {
1376        super.copyValues(dst);
1377        dst.type = type == null ? null : type.copy();
1378        dst.value = value == null ? null : value.copy();
1379      }
1380
1381      @Override
1382      public boolean equalsDeep(Base other_) {
1383        if (!super.equalsDeep(other_))
1384          return false;
1385        if (!(other_ instanceof PackagedProductDefinitionPackagePropertyComponent))
1386          return false;
1387        PackagedProductDefinitionPackagePropertyComponent o = (PackagedProductDefinitionPackagePropertyComponent) other_;
1388        return compareDeep(type, o.type, true) && compareDeep(value, o.value, true);
1389      }
1390
1391      @Override
1392      public boolean equalsShallow(Base other_) {
1393        if (!super.equalsShallow(other_))
1394          return false;
1395        if (!(other_ instanceof PackagedProductDefinitionPackagePropertyComponent))
1396          return false;
1397        PackagedProductDefinitionPackagePropertyComponent o = (PackagedProductDefinitionPackagePropertyComponent) other_;
1398        return true;
1399      }
1400
1401      public boolean isEmpty() {
1402        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, value);
1403      }
1404
1405  public String fhirType() {
1406    return "PackagedProductDefinition.package.property";
1407
1408  }
1409
1410  }
1411
1412    @Block()
1413    public static class PackagedProductDefinitionPackageContainedItemComponent extends BackboneElement implements IBaseBackboneElement {
1414        /**
1415         * The actual item(s) of medication, as manufactured, or a device (typically, but not necessarily, a co-packaged one), or other medically related item (such as food, biologicals, raw materials, medical fluids, gases etc.), as contained in the package. This also allows another whole packaged product to be included, which is solely for the case where a package of other entire packages is wanted - such as a wholesale or distribution pack (for layers within one package, use PackagedProductDefinition.package.package).
1416         */
1417        @Child(name = "item", type = {CodeableReference.class}, order=1, min=1, max=1, modifier=false, summary=true)
1418        @Description(shortDefinition="The actual item(s) of medication, as manufactured, or a device (typically, but not necessarily, a co-packaged one), or other medically related item (such as food, biologicals, raw materials, medical fluids, gases etc.), as contained in the package. This also allows another whole packaged product to be included, which is solely for the case where a package of other entire packages is wanted - such as a wholesale or distribution pack (for layers within one package, use PackagedProductDefinition.package.package)", formalDefinition="The actual item(s) of medication, as manufactured, or a device (typically, but not necessarily, a co-packaged one), or other medically related item (such as food, biologicals, raw materials, medical fluids, gases etc.), as contained in the package. This also allows another whole packaged product to be included, which is solely for the case where a package of other entire packages is wanted - such as a wholesale or distribution pack (for layers within one package, use PackagedProductDefinition.package.package)." )
1419        protected CodeableReference item;
1420
1421        /**
1422         * The number of this type of item within this packaging.
1423         */
1424        @Child(name = "amount", type = {Quantity.class}, order=2, min=0, max=1, modifier=false, summary=true)
1425        @Description(shortDefinition="The number of this type of item within this packaging", formalDefinition="The number of this type of item within this packaging." )
1426        protected Quantity amount;
1427
1428        private static final long serialVersionUID = 443863028L;
1429
1430    /**
1431     * Constructor
1432     */
1433      public PackagedProductDefinitionPackageContainedItemComponent() {
1434        super();
1435      }
1436
1437    /**
1438     * Constructor
1439     */
1440      public PackagedProductDefinitionPackageContainedItemComponent(CodeableReference item) {
1441        super();
1442        this.setItem(item);
1443      }
1444
1445        /**
1446         * @return {@link #item} (The actual item(s) of medication, as manufactured, or a device (typically, but not necessarily, a co-packaged one), or other medically related item (such as food, biologicals, raw materials, medical fluids, gases etc.), as contained in the package. This also allows another whole packaged product to be included, which is solely for the case where a package of other entire packages is wanted - such as a wholesale or distribution pack (for layers within one package, use PackagedProductDefinition.package.package).)
1447         */
1448        public CodeableReference getItem() { 
1449          if (this.item == null)
1450            if (Configuration.errorOnAutoCreate())
1451              throw new Error("Attempt to auto-create PackagedProductDefinitionPackageContainedItemComponent.item");
1452            else if (Configuration.doAutoCreate())
1453              this.item = new CodeableReference(); // cc
1454          return this.item;
1455        }
1456
1457        public boolean hasItem() { 
1458          return this.item != null && !this.item.isEmpty();
1459        }
1460
1461        /**
1462         * @param value {@link #item} (The actual item(s) of medication, as manufactured, or a device (typically, but not necessarily, a co-packaged one), or other medically related item (such as food, biologicals, raw materials, medical fluids, gases etc.), as contained in the package. This also allows another whole packaged product to be included, which is solely for the case where a package of other entire packages is wanted - such as a wholesale or distribution pack (for layers within one package, use PackagedProductDefinition.package.package).)
1463         */
1464        public PackagedProductDefinitionPackageContainedItemComponent setItem(CodeableReference value) { 
1465          this.item = value;
1466          return this;
1467        }
1468
1469        /**
1470         * @return {@link #amount} (The number of this type of item within this packaging.)
1471         */
1472        public Quantity getAmount() { 
1473          if (this.amount == null)
1474            if (Configuration.errorOnAutoCreate())
1475              throw new Error("Attempt to auto-create PackagedProductDefinitionPackageContainedItemComponent.amount");
1476            else if (Configuration.doAutoCreate())
1477              this.amount = new Quantity(); // cc
1478          return this.amount;
1479        }
1480
1481        public boolean hasAmount() { 
1482          return this.amount != null && !this.amount.isEmpty();
1483        }
1484
1485        /**
1486         * @param value {@link #amount} (The number of this type of item within this packaging.)
1487         */
1488        public PackagedProductDefinitionPackageContainedItemComponent setAmount(Quantity value) { 
1489          this.amount = value;
1490          return this;
1491        }
1492
1493        protected void listChildren(List<Property> children) {
1494          super.listChildren(children);
1495          children.add(new Property("item", "CodeableReference(ManufacturedItemDefinition|DeviceDefinition|PackagedProductDefinition|BiologicallyDerivedProduct|NutritionProduct)", "The actual item(s) of medication, as manufactured, or a device (typically, but not necessarily, a co-packaged one), or other medically related item (such as food, biologicals, raw materials, medical fluids, gases etc.), as contained in the package. This also allows another whole packaged product to be included, which is solely for the case where a package of other entire packages is wanted - such as a wholesale or distribution pack (for layers within one package, use PackagedProductDefinition.package.package).", 0, 1, item));
1496          children.add(new Property("amount", "Quantity", "The number of this type of item within this packaging.", 0, 1, amount));
1497        }
1498
1499        @Override
1500        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1501          switch (_hash) {
1502          case 3242771: /*item*/  return new Property("item", "CodeableReference(ManufacturedItemDefinition|DeviceDefinition|PackagedProductDefinition|BiologicallyDerivedProduct|NutritionProduct)", "The actual item(s) of medication, as manufactured, or a device (typically, but not necessarily, a co-packaged one), or other medically related item (such as food, biologicals, raw materials, medical fluids, gases etc.), as contained in the package. This also allows another whole packaged product to be included, which is solely for the case where a package of other entire packages is wanted - such as a wholesale or distribution pack (for layers within one package, use PackagedProductDefinition.package.package).", 0, 1, item);
1503          case -1413853096: /*amount*/  return new Property("amount", "Quantity", "The number of this type of item within this packaging.", 0, 1, amount);
1504          default: return super.getNamedProperty(_hash, _name, _checkValid);
1505          }
1506
1507        }
1508
1509      @Override
1510      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1511        switch (hash) {
1512        case 3242771: /*item*/ return this.item == null ? new Base[0] : new Base[] {this.item}; // CodeableReference
1513        case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : new Base[] {this.amount}; // Quantity
1514        default: return super.getProperty(hash, name, checkValid);
1515        }
1516
1517      }
1518
1519      @Override
1520      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1521        switch (hash) {
1522        case 3242771: // item
1523          this.item = TypeConvertor.castToCodeableReference(value); // CodeableReference
1524          return value;
1525        case -1413853096: // amount
1526          this.amount = TypeConvertor.castToQuantity(value); // Quantity
1527          return value;
1528        default: return super.setProperty(hash, name, value);
1529        }
1530
1531      }
1532
1533      @Override
1534      public Base setProperty(String name, Base value) throws FHIRException {
1535        if (name.equals("item")) {
1536          this.item = TypeConvertor.castToCodeableReference(value); // CodeableReference
1537        } else if (name.equals("amount")) {
1538          this.amount = TypeConvertor.castToQuantity(value); // Quantity
1539        } else
1540          return super.setProperty(name, value);
1541        return value;
1542      }
1543
1544      @Override
1545      public Base makeProperty(int hash, String name) throws FHIRException {
1546        switch (hash) {
1547        case 3242771:  return getItem();
1548        case -1413853096:  return getAmount();
1549        default: return super.makeProperty(hash, name);
1550        }
1551
1552      }
1553
1554      @Override
1555      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1556        switch (hash) {
1557        case 3242771: /*item*/ return new String[] {"CodeableReference"};
1558        case -1413853096: /*amount*/ return new String[] {"Quantity"};
1559        default: return super.getTypesForProperty(hash, name);
1560        }
1561
1562      }
1563
1564      @Override
1565      public Base addChild(String name) throws FHIRException {
1566        if (name.equals("item")) {
1567          this.item = new CodeableReference();
1568          return this.item;
1569        }
1570        else if (name.equals("amount")) {
1571          this.amount = new Quantity();
1572          return this.amount;
1573        }
1574        else
1575          return super.addChild(name);
1576      }
1577
1578      public PackagedProductDefinitionPackageContainedItemComponent copy() {
1579        PackagedProductDefinitionPackageContainedItemComponent dst = new PackagedProductDefinitionPackageContainedItemComponent();
1580        copyValues(dst);
1581        return dst;
1582      }
1583
1584      public void copyValues(PackagedProductDefinitionPackageContainedItemComponent dst) {
1585        super.copyValues(dst);
1586        dst.item = item == null ? null : item.copy();
1587        dst.amount = amount == null ? null : amount.copy();
1588      }
1589
1590      @Override
1591      public boolean equalsDeep(Base other_) {
1592        if (!super.equalsDeep(other_))
1593          return false;
1594        if (!(other_ instanceof PackagedProductDefinitionPackageContainedItemComponent))
1595          return false;
1596        PackagedProductDefinitionPackageContainedItemComponent o = (PackagedProductDefinitionPackageContainedItemComponent) other_;
1597        return compareDeep(item, o.item, true) && compareDeep(amount, o.amount, true);
1598      }
1599
1600      @Override
1601      public boolean equalsShallow(Base other_) {
1602        if (!super.equalsShallow(other_))
1603          return false;
1604        if (!(other_ instanceof PackagedProductDefinitionPackageContainedItemComponent))
1605          return false;
1606        PackagedProductDefinitionPackageContainedItemComponent o = (PackagedProductDefinitionPackageContainedItemComponent) other_;
1607        return true;
1608      }
1609
1610      public boolean isEmpty() {
1611        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(item, amount);
1612      }
1613
1614  public String fhirType() {
1615    return "PackagedProductDefinition.package.containedItem";
1616
1617  }
1618
1619  }
1620
1621    /**
1622     * Unique identifier.
1623     */
1624    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1625    @Description(shortDefinition="Unique identifier", formalDefinition="Unique identifier." )
1626    protected List<Identifier> identifier;
1627
1628    /**
1629     * A name for this package. Typically what it would be listed as in a drug formulary or catalogue, inventory etc.
1630     */
1631    @Child(name = "name", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true)
1632    @Description(shortDefinition="A name for this package. Typically what it would be listed as in a drug formulary or catalogue, inventory etc", formalDefinition="A name for this package. Typically what it would be listed as in a drug formulary or catalogue, inventory etc." )
1633    protected StringType name;
1634
1635    /**
1636     * A high level category e.g. medicinal product, raw material, shipping/transport container, etc.
1637     */
1638    @Child(name = "type", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
1639    @Description(shortDefinition="A high level category e.g. medicinal product, raw material, shipping/transport container, etc", formalDefinition="A high level category e.g. medicinal product, raw material, shipping/transport container, etc." )
1640    protected CodeableConcept type;
1641
1642    /**
1643     * The product that this is a pack for.
1644     */
1645    @Child(name = "packageFor", type = {MedicinalProductDefinition.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1646    @Description(shortDefinition="The product that this is a pack for", formalDefinition="The product that this is a pack for." )
1647    protected List<Reference> packageFor;
1648
1649    /**
1650     * The status within the lifecycle of this item. A high level status, this is not intended to duplicate details carried elsewhere such as legal status, or authorization or marketing status.
1651     */
1652    @Child(name = "status", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=true, summary=true)
1653    @Description(shortDefinition="The status within the lifecycle of this item. A high level status, this is not intended to duplicate details carried elsewhere such as legal status, or authorization or marketing status", formalDefinition="The status within the lifecycle of this item. A high level status, this is not intended to duplicate details carried elsewhere such as legal status, or authorization or marketing status." )
1654    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/publication-status")
1655    protected CodeableConcept status;
1656
1657    /**
1658     * The date at which the given status became applicable.
1659     */
1660    @Child(name = "statusDate", type = {DateTimeType.class}, order=5, min=0, max=1, modifier=false, summary=true)
1661    @Description(shortDefinition="The date at which the given status became applicable", formalDefinition="The date at which the given status became applicable." )
1662    protected DateTimeType statusDate;
1663
1664    /**
1665     * A total of the amount of items in the package, per item type. This can be considered as the pack size. This attribute differs from containedItem.amount in that it can give a single aggregated count of all tablet types in a pack, even when these are different manufactured items. For example a pill pack of 21 tablets plus 7 sugar tablets, can be denoted here as '28 tablets'. This attribute is repeatable so that the different item types in one pack type can be counted (e.g. a count of vials and count of syringes). Each repeat must have different units, so that it is clear what the different sets of counted items are, and it is not intended to allow different counts of similar items (e.g. not '2 tubes and 3 tubes'). Repeats are not to be used to represent different pack sizes (e.g. 20 pack vs. 50 pack) - which would be different instances of this resource.
1666     */
1667    @Child(name = "containedItemQuantity", type = {Quantity.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1668    @Description(shortDefinition="A total of the amount of items in the package, per item type. This can be considered as the pack size. This attribute differs from containedItem.amount in that it can give a single aggregated count of all tablet types in a pack, even when these are different manufactured items. For example a pill pack of 21 tablets plus 7 sugar tablets, can be denoted here as '28 tablets'. This attribute is repeatable so that the different item types in one pack type can be counted (e.g. a count of vials and count of syringes). Each repeat must have different units, so that it is clear what the different sets of counted items are, and it is not intended to allow different counts of similar items (e.g. not '2 tubes and 3 tubes'). Repeats are not to be used to represent different pack sizes (e.g. 20 pack vs. 50 pack) - which would be different instances of this resource", formalDefinition="A total of the amount of items in the package, per item type. This can be considered as the pack size. This attribute differs from containedItem.amount in that it can give a single aggregated count of all tablet types in a pack, even when these are different manufactured items. For example a pill pack of 21 tablets plus 7 sugar tablets, can be denoted here as '28 tablets'. This attribute is repeatable so that the different item types in one pack type can be counted (e.g. a count of vials and count of syringes). Each repeat must have different units, so that it is clear what the different sets of counted items are, and it is not intended to allow different counts of similar items (e.g. not '2 tubes and 3 tubes'). Repeats are not to be used to represent different pack sizes (e.g. 20 pack vs. 50 pack) - which would be different instances of this resource." )
1669    protected List<Quantity> containedItemQuantity;
1670
1671    /**
1672     * Textual description. Note that this is not the name of the package or product.
1673     */
1674    @Child(name = "description", type = {MarkdownType.class}, order=7, min=0, max=1, modifier=false, summary=true)
1675    @Description(shortDefinition="Textual description. Note that this is not the name of the package or product", formalDefinition="Textual description. Note that this is not the name of the package or product." )
1676    protected MarkdownType description;
1677
1678    /**
1679     * The legal status of supply of the packaged item as classified by the regulator.
1680     */
1681    @Child(name = "legalStatusOfSupply", type = {}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1682    @Description(shortDefinition="The legal status of supply of the packaged item as classified by the regulator", formalDefinition="The legal status of supply of the packaged item as classified by the regulator." )
1683    protected List<PackagedProductDefinitionLegalStatusOfSupplyComponent> legalStatusOfSupply;
1684
1685    /**
1686     * Marketing information.
1687     */
1688    @Child(name = "marketingStatus", type = {MarketingStatus.class}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1689    @Description(shortDefinition="Marketing information", formalDefinition="Marketing information." )
1690    protected List<MarketingStatus> marketingStatus;
1691
1692    /**
1693     * Allows the key features to be recorded, such as "hospital pack", "nurse prescribable", "calendar pack".
1694     */
1695    @Child(name = "characteristic", type = {CodeableConcept.class}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1696    @Description(shortDefinition="Allows the key features to be recorded, such as \"hospital pack\", \"nurse prescribable\", \"calendar pack\"", formalDefinition="Allows the key features to be recorded, such as \"hospital pack\", \"nurse prescribable\", \"calendar pack\"." )
1697    protected List<CodeableConcept> characteristic;
1698
1699    /**
1700     * States whether a drug product is supplied with another item such as a diluent or adjuvant.
1701     */
1702    @Child(name = "copackagedIndicator", type = {BooleanType.class}, order=11, min=0, max=1, modifier=false, summary=true)
1703    @Description(shortDefinition="States whether a drug product is supplied with another item such as a diluent or adjuvant", formalDefinition="States whether a drug product is supplied with another item such as a diluent or adjuvant." )
1704    protected BooleanType copackagedIndicator;
1705
1706    /**
1707     * Manufacturer of this package type. When there are multiple it means these are all possible manufacturers.
1708     */
1709    @Child(name = "manufacturer", type = {Organization.class}, order=12, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1710    @Description(shortDefinition="Manufacturer of this package type. When there are multiple it means these are all possible manufacturers", formalDefinition="Manufacturer of this package type. When there are multiple it means these are all possible manufacturers." )
1711    protected List<Reference> manufacturer;
1712
1713    /**
1714     * Additional information or supporting documentation about the packaged product.
1715     */
1716    @Child(name = "attachedDocument", type = {DocumentReference.class}, order=13, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1717    @Description(shortDefinition="Additional information or supporting documentation about the packaged product", formalDefinition="Additional information or supporting documentation about the packaged product." )
1718    protected List<Reference> attachedDocument;
1719
1720    /**
1721     * A packaging item, as a container for medically related items, possibly with other packaging items within, or a packaging component, such as bottle cap (which is not a device or a medication manufactured item).
1722     */
1723    @Child(name = "package", type = {}, order=14, min=0, max=1, modifier=false, summary=true)
1724    @Description(shortDefinition="A packaging item, as a container for medically related items, possibly with other packaging items within, or a packaging component, such as bottle cap (which is not a device or a medication manufactured item)", formalDefinition="A packaging item, as a container for medically related items, possibly with other packaging items within, or a packaging component, such as bottle cap (which is not a device or a medication manufactured item)." )
1725    protected PackagedProductDefinitionPackageComponent package_;
1726
1727    private static final long serialVersionUID = -575424428L;
1728
1729  /**
1730   * Constructor
1731   */
1732    public PackagedProductDefinition() {
1733      super();
1734    }
1735
1736    /**
1737     * @return {@link #identifier} (Unique identifier.)
1738     */
1739    public List<Identifier> getIdentifier() { 
1740      if (this.identifier == null)
1741        this.identifier = new ArrayList<Identifier>();
1742      return this.identifier;
1743    }
1744
1745    /**
1746     * @return Returns a reference to <code>this</code> for easy method chaining
1747     */
1748    public PackagedProductDefinition setIdentifier(List<Identifier> theIdentifier) { 
1749      this.identifier = theIdentifier;
1750      return this;
1751    }
1752
1753    public boolean hasIdentifier() { 
1754      if (this.identifier == null)
1755        return false;
1756      for (Identifier item : this.identifier)
1757        if (!item.isEmpty())
1758          return true;
1759      return false;
1760    }
1761
1762    public Identifier addIdentifier() { //3
1763      Identifier t = new Identifier();
1764      if (this.identifier == null)
1765        this.identifier = new ArrayList<Identifier>();
1766      this.identifier.add(t);
1767      return t;
1768    }
1769
1770    public PackagedProductDefinition addIdentifier(Identifier t) { //3
1771      if (t == null)
1772        return this;
1773      if (this.identifier == null)
1774        this.identifier = new ArrayList<Identifier>();
1775      this.identifier.add(t);
1776      return this;
1777    }
1778
1779    /**
1780     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist {3}
1781     */
1782    public Identifier getIdentifierFirstRep() { 
1783      if (getIdentifier().isEmpty()) {
1784        addIdentifier();
1785      }
1786      return getIdentifier().get(0);
1787    }
1788
1789    /**
1790     * @return {@link #name} (A name for this package. Typically what it would be listed as in a drug formulary or catalogue, inventory etc.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
1791     */
1792    public StringType getNameElement() { 
1793      if (this.name == null)
1794        if (Configuration.errorOnAutoCreate())
1795          throw new Error("Attempt to auto-create PackagedProductDefinition.name");
1796        else if (Configuration.doAutoCreate())
1797          this.name = new StringType(); // bb
1798      return this.name;
1799    }
1800
1801    public boolean hasNameElement() { 
1802      return this.name != null && !this.name.isEmpty();
1803    }
1804
1805    public boolean hasName() { 
1806      return this.name != null && !this.name.isEmpty();
1807    }
1808
1809    /**
1810     * @param value {@link #name} (A name for this package. Typically what it would be listed as in a drug formulary or catalogue, inventory etc.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
1811     */
1812    public PackagedProductDefinition setNameElement(StringType value) { 
1813      this.name = value;
1814      return this;
1815    }
1816
1817    /**
1818     * @return A name for this package. Typically what it would be listed as in a drug formulary or catalogue, inventory etc.
1819     */
1820    public String getName() { 
1821      return this.name == null ? null : this.name.getValue();
1822    }
1823
1824    /**
1825     * @param value A name for this package. Typically what it would be listed as in a drug formulary or catalogue, inventory etc.
1826     */
1827    public PackagedProductDefinition setName(String value) { 
1828      if (Utilities.noString(value))
1829        this.name = null;
1830      else {
1831        if (this.name == null)
1832          this.name = new StringType();
1833        this.name.setValue(value);
1834      }
1835      return this;
1836    }
1837
1838    /**
1839     * @return {@link #type} (A high level category e.g. medicinal product, raw material, shipping/transport container, etc.)
1840     */
1841    public CodeableConcept getType() { 
1842      if (this.type == null)
1843        if (Configuration.errorOnAutoCreate())
1844          throw new Error("Attempt to auto-create PackagedProductDefinition.type");
1845        else if (Configuration.doAutoCreate())
1846          this.type = new CodeableConcept(); // cc
1847      return this.type;
1848    }
1849
1850    public boolean hasType() { 
1851      return this.type != null && !this.type.isEmpty();
1852    }
1853
1854    /**
1855     * @param value {@link #type} (A high level category e.g. medicinal product, raw material, shipping/transport container, etc.)
1856     */
1857    public PackagedProductDefinition setType(CodeableConcept value) { 
1858      this.type = value;
1859      return this;
1860    }
1861
1862    /**
1863     * @return {@link #packageFor} (The product that this is a pack for.)
1864     */
1865    public List<Reference> getPackageFor() { 
1866      if (this.packageFor == null)
1867        this.packageFor = new ArrayList<Reference>();
1868      return this.packageFor;
1869    }
1870
1871    /**
1872     * @return Returns a reference to <code>this</code> for easy method chaining
1873     */
1874    public PackagedProductDefinition setPackageFor(List<Reference> thePackageFor) { 
1875      this.packageFor = thePackageFor;
1876      return this;
1877    }
1878
1879    public boolean hasPackageFor() { 
1880      if (this.packageFor == null)
1881        return false;
1882      for (Reference item : this.packageFor)
1883        if (!item.isEmpty())
1884          return true;
1885      return false;
1886    }
1887
1888    public Reference addPackageFor() { //3
1889      Reference t = new Reference();
1890      if (this.packageFor == null)
1891        this.packageFor = new ArrayList<Reference>();
1892      this.packageFor.add(t);
1893      return t;
1894    }
1895
1896    public PackagedProductDefinition addPackageFor(Reference t) { //3
1897      if (t == null)
1898        return this;
1899      if (this.packageFor == null)
1900        this.packageFor = new ArrayList<Reference>();
1901      this.packageFor.add(t);
1902      return this;
1903    }
1904
1905    /**
1906     * @return The first repetition of repeating field {@link #packageFor}, creating it if it does not already exist {3}
1907     */
1908    public Reference getPackageForFirstRep() { 
1909      if (getPackageFor().isEmpty()) {
1910        addPackageFor();
1911      }
1912      return getPackageFor().get(0);
1913    }
1914
1915    /**
1916     * @return {@link #status} (The status within the lifecycle of this item. A high level status, this is not intended to duplicate details carried elsewhere such as legal status, or authorization or marketing status.)
1917     */
1918    public CodeableConcept getStatus() { 
1919      if (this.status == null)
1920        if (Configuration.errorOnAutoCreate())
1921          throw new Error("Attempt to auto-create PackagedProductDefinition.status");
1922        else if (Configuration.doAutoCreate())
1923          this.status = new CodeableConcept(); // cc
1924      return this.status;
1925    }
1926
1927    public boolean hasStatus() { 
1928      return this.status != null && !this.status.isEmpty();
1929    }
1930
1931    /**
1932     * @param value {@link #status} (The status within the lifecycle of this item. A high level status, this is not intended to duplicate details carried elsewhere such as legal status, or authorization or marketing status.)
1933     */
1934    public PackagedProductDefinition setStatus(CodeableConcept value) { 
1935      this.status = value;
1936      return this;
1937    }
1938
1939    /**
1940     * @return {@link #statusDate} (The date at which the given status became applicable.). This is the underlying object with id, value and extensions. The accessor "getStatusDate" gives direct access to the value
1941     */
1942    public DateTimeType getStatusDateElement() { 
1943      if (this.statusDate == null)
1944        if (Configuration.errorOnAutoCreate())
1945          throw new Error("Attempt to auto-create PackagedProductDefinition.statusDate");
1946        else if (Configuration.doAutoCreate())
1947          this.statusDate = new DateTimeType(); // bb
1948      return this.statusDate;
1949    }
1950
1951    public boolean hasStatusDateElement() { 
1952      return this.statusDate != null && !this.statusDate.isEmpty();
1953    }
1954
1955    public boolean hasStatusDate() { 
1956      return this.statusDate != null && !this.statusDate.isEmpty();
1957    }
1958
1959    /**
1960     * @param value {@link #statusDate} (The date at which the given status became applicable.). This is the underlying object with id, value and extensions. The accessor "getStatusDate" gives direct access to the value
1961     */
1962    public PackagedProductDefinition setStatusDateElement(DateTimeType value) { 
1963      this.statusDate = value;
1964      return this;
1965    }
1966
1967    /**
1968     * @return The date at which the given status became applicable.
1969     */
1970    public Date getStatusDate() { 
1971      return this.statusDate == null ? null : this.statusDate.getValue();
1972    }
1973
1974    /**
1975     * @param value The date at which the given status became applicable.
1976     */
1977    public PackagedProductDefinition setStatusDate(Date value) { 
1978      if (value == null)
1979        this.statusDate = null;
1980      else {
1981        if (this.statusDate == null)
1982          this.statusDate = new DateTimeType();
1983        this.statusDate.setValue(value);
1984      }
1985      return this;
1986    }
1987
1988    /**
1989     * @return {@link #containedItemQuantity} (A total of the amount of items in the package, per item type. This can be considered as the pack size. This attribute differs from containedItem.amount in that it can give a single aggregated count of all tablet types in a pack, even when these are different manufactured items. For example a pill pack of 21 tablets plus 7 sugar tablets, can be denoted here as '28 tablets'. This attribute is repeatable so that the different item types in one pack type can be counted (e.g. a count of vials and count of syringes). Each repeat must have different units, so that it is clear what the different sets of counted items are, and it is not intended to allow different counts of similar items (e.g. not '2 tubes and 3 tubes'). Repeats are not to be used to represent different pack sizes (e.g. 20 pack vs. 50 pack) - which would be different instances of this resource.)
1990     */
1991    public List<Quantity> getContainedItemQuantity() { 
1992      if (this.containedItemQuantity == null)
1993        this.containedItemQuantity = new ArrayList<Quantity>();
1994      return this.containedItemQuantity;
1995    }
1996
1997    /**
1998     * @return Returns a reference to <code>this</code> for easy method chaining
1999     */
2000    public PackagedProductDefinition setContainedItemQuantity(List<Quantity> theContainedItemQuantity) { 
2001      this.containedItemQuantity = theContainedItemQuantity;
2002      return this;
2003    }
2004
2005    public boolean hasContainedItemQuantity() { 
2006      if (this.containedItemQuantity == null)
2007        return false;
2008      for (Quantity item : this.containedItemQuantity)
2009        if (!item.isEmpty())
2010          return true;
2011      return false;
2012    }
2013
2014    public Quantity addContainedItemQuantity() { //3
2015      Quantity t = new Quantity();
2016      if (this.containedItemQuantity == null)
2017        this.containedItemQuantity = new ArrayList<Quantity>();
2018      this.containedItemQuantity.add(t);
2019      return t;
2020    }
2021
2022    public PackagedProductDefinition addContainedItemQuantity(Quantity t) { //3
2023      if (t == null)
2024        return this;
2025      if (this.containedItemQuantity == null)
2026        this.containedItemQuantity = new ArrayList<Quantity>();
2027      this.containedItemQuantity.add(t);
2028      return this;
2029    }
2030
2031    /**
2032     * @return The first repetition of repeating field {@link #containedItemQuantity}, creating it if it does not already exist {3}
2033     */
2034    public Quantity getContainedItemQuantityFirstRep() { 
2035      if (getContainedItemQuantity().isEmpty()) {
2036        addContainedItemQuantity();
2037      }
2038      return getContainedItemQuantity().get(0);
2039    }
2040
2041    /**
2042     * @return {@link #description} (Textual description. Note that this is not the name of the package or product.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
2043     */
2044    public MarkdownType getDescriptionElement() { 
2045      if (this.description == null)
2046        if (Configuration.errorOnAutoCreate())
2047          throw new Error("Attempt to auto-create PackagedProductDefinition.description");
2048        else if (Configuration.doAutoCreate())
2049          this.description = new MarkdownType(); // bb
2050      return this.description;
2051    }
2052
2053    public boolean hasDescriptionElement() { 
2054      return this.description != null && !this.description.isEmpty();
2055    }
2056
2057    public boolean hasDescription() { 
2058      return this.description != null && !this.description.isEmpty();
2059    }
2060
2061    /**
2062     * @param value {@link #description} (Textual description. Note that this is not the name of the package or product.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
2063     */
2064    public PackagedProductDefinition setDescriptionElement(MarkdownType value) { 
2065      this.description = value;
2066      return this;
2067    }
2068
2069    /**
2070     * @return Textual description. Note that this is not the name of the package or product.
2071     */
2072    public String getDescription() { 
2073      return this.description == null ? null : this.description.getValue();
2074    }
2075
2076    /**
2077     * @param value Textual description. Note that this is not the name of the package or product.
2078     */
2079    public PackagedProductDefinition setDescription(String value) { 
2080      if (value == null)
2081        this.description = null;
2082      else {
2083        if (this.description == null)
2084          this.description = new MarkdownType();
2085        this.description.setValue(value);
2086      }
2087      return this;
2088    }
2089
2090    /**
2091     * @return {@link #legalStatusOfSupply} (The legal status of supply of the packaged item as classified by the regulator.)
2092     */
2093    public List<PackagedProductDefinitionLegalStatusOfSupplyComponent> getLegalStatusOfSupply() { 
2094      if (this.legalStatusOfSupply == null)
2095        this.legalStatusOfSupply = new ArrayList<PackagedProductDefinitionLegalStatusOfSupplyComponent>();
2096      return this.legalStatusOfSupply;
2097    }
2098
2099    /**
2100     * @return Returns a reference to <code>this</code> for easy method chaining
2101     */
2102    public PackagedProductDefinition setLegalStatusOfSupply(List<PackagedProductDefinitionLegalStatusOfSupplyComponent> theLegalStatusOfSupply) { 
2103      this.legalStatusOfSupply = theLegalStatusOfSupply;
2104      return this;
2105    }
2106
2107    public boolean hasLegalStatusOfSupply() { 
2108      if (this.legalStatusOfSupply == null)
2109        return false;
2110      for (PackagedProductDefinitionLegalStatusOfSupplyComponent item : this.legalStatusOfSupply)
2111        if (!item.isEmpty())
2112          return true;
2113      return false;
2114    }
2115
2116    public PackagedProductDefinitionLegalStatusOfSupplyComponent addLegalStatusOfSupply() { //3
2117      PackagedProductDefinitionLegalStatusOfSupplyComponent t = new PackagedProductDefinitionLegalStatusOfSupplyComponent();
2118      if (this.legalStatusOfSupply == null)
2119        this.legalStatusOfSupply = new ArrayList<PackagedProductDefinitionLegalStatusOfSupplyComponent>();
2120      this.legalStatusOfSupply.add(t);
2121      return t;
2122    }
2123
2124    public PackagedProductDefinition addLegalStatusOfSupply(PackagedProductDefinitionLegalStatusOfSupplyComponent t) { //3
2125      if (t == null)
2126        return this;
2127      if (this.legalStatusOfSupply == null)
2128        this.legalStatusOfSupply = new ArrayList<PackagedProductDefinitionLegalStatusOfSupplyComponent>();
2129      this.legalStatusOfSupply.add(t);
2130      return this;
2131    }
2132
2133    /**
2134     * @return The first repetition of repeating field {@link #legalStatusOfSupply}, creating it if it does not already exist {3}
2135     */
2136    public PackagedProductDefinitionLegalStatusOfSupplyComponent getLegalStatusOfSupplyFirstRep() { 
2137      if (getLegalStatusOfSupply().isEmpty()) {
2138        addLegalStatusOfSupply();
2139      }
2140      return getLegalStatusOfSupply().get(0);
2141    }
2142
2143    /**
2144     * @return {@link #marketingStatus} (Marketing information.)
2145     */
2146    public List<MarketingStatus> getMarketingStatus() { 
2147      if (this.marketingStatus == null)
2148        this.marketingStatus = new ArrayList<MarketingStatus>();
2149      return this.marketingStatus;
2150    }
2151
2152    /**
2153     * @return Returns a reference to <code>this</code> for easy method chaining
2154     */
2155    public PackagedProductDefinition setMarketingStatus(List<MarketingStatus> theMarketingStatus) { 
2156      this.marketingStatus = theMarketingStatus;
2157      return this;
2158    }
2159
2160    public boolean hasMarketingStatus() { 
2161      if (this.marketingStatus == null)
2162        return false;
2163      for (MarketingStatus item : this.marketingStatus)
2164        if (!item.isEmpty())
2165          return true;
2166      return false;
2167    }
2168
2169    public MarketingStatus addMarketingStatus() { //3
2170      MarketingStatus t = new MarketingStatus();
2171      if (this.marketingStatus == null)
2172        this.marketingStatus = new ArrayList<MarketingStatus>();
2173      this.marketingStatus.add(t);
2174      return t;
2175    }
2176
2177    public PackagedProductDefinition addMarketingStatus(MarketingStatus t) { //3
2178      if (t == null)
2179        return this;
2180      if (this.marketingStatus == null)
2181        this.marketingStatus = new ArrayList<MarketingStatus>();
2182      this.marketingStatus.add(t);
2183      return this;
2184    }
2185
2186    /**
2187     * @return The first repetition of repeating field {@link #marketingStatus}, creating it if it does not already exist {3}
2188     */
2189    public MarketingStatus getMarketingStatusFirstRep() { 
2190      if (getMarketingStatus().isEmpty()) {
2191        addMarketingStatus();
2192      }
2193      return getMarketingStatus().get(0);
2194    }
2195
2196    /**
2197     * @return {@link #characteristic} (Allows the key features to be recorded, such as "hospital pack", "nurse prescribable", "calendar pack".)
2198     */
2199    public List<CodeableConcept> getCharacteristic() { 
2200      if (this.characteristic == null)
2201        this.characteristic = new ArrayList<CodeableConcept>();
2202      return this.characteristic;
2203    }
2204
2205    /**
2206     * @return Returns a reference to <code>this</code> for easy method chaining
2207     */
2208    public PackagedProductDefinition setCharacteristic(List<CodeableConcept> theCharacteristic) { 
2209      this.characteristic = theCharacteristic;
2210      return this;
2211    }
2212
2213    public boolean hasCharacteristic() { 
2214      if (this.characteristic == null)
2215        return false;
2216      for (CodeableConcept item : this.characteristic)
2217        if (!item.isEmpty())
2218          return true;
2219      return false;
2220    }
2221
2222    public CodeableConcept addCharacteristic() { //3
2223      CodeableConcept t = new CodeableConcept();
2224      if (this.characteristic == null)
2225        this.characteristic = new ArrayList<CodeableConcept>();
2226      this.characteristic.add(t);
2227      return t;
2228    }
2229
2230    public PackagedProductDefinition addCharacteristic(CodeableConcept t) { //3
2231      if (t == null)
2232        return this;
2233      if (this.characteristic == null)
2234        this.characteristic = new ArrayList<CodeableConcept>();
2235      this.characteristic.add(t);
2236      return this;
2237    }
2238
2239    /**
2240     * @return The first repetition of repeating field {@link #characteristic}, creating it if it does not already exist {3}
2241     */
2242    public CodeableConcept getCharacteristicFirstRep() { 
2243      if (getCharacteristic().isEmpty()) {
2244        addCharacteristic();
2245      }
2246      return getCharacteristic().get(0);
2247    }
2248
2249    /**
2250     * @return {@link #copackagedIndicator} (States whether a drug product is supplied with another item such as a diluent or adjuvant.). This is the underlying object with id, value and extensions. The accessor "getCopackagedIndicator" gives direct access to the value
2251     */
2252    public BooleanType getCopackagedIndicatorElement() { 
2253      if (this.copackagedIndicator == null)
2254        if (Configuration.errorOnAutoCreate())
2255          throw new Error("Attempt to auto-create PackagedProductDefinition.copackagedIndicator");
2256        else if (Configuration.doAutoCreate())
2257          this.copackagedIndicator = new BooleanType(); // bb
2258      return this.copackagedIndicator;
2259    }
2260
2261    public boolean hasCopackagedIndicatorElement() { 
2262      return this.copackagedIndicator != null && !this.copackagedIndicator.isEmpty();
2263    }
2264
2265    public boolean hasCopackagedIndicator() { 
2266      return this.copackagedIndicator != null && !this.copackagedIndicator.isEmpty();
2267    }
2268
2269    /**
2270     * @param value {@link #copackagedIndicator} (States whether a drug product is supplied with another item such as a diluent or adjuvant.). This is the underlying object with id, value and extensions. The accessor "getCopackagedIndicator" gives direct access to the value
2271     */
2272    public PackagedProductDefinition setCopackagedIndicatorElement(BooleanType value) { 
2273      this.copackagedIndicator = value;
2274      return this;
2275    }
2276
2277    /**
2278     * @return States whether a drug product is supplied with another item such as a diluent or adjuvant.
2279     */
2280    public boolean getCopackagedIndicator() { 
2281      return this.copackagedIndicator == null || this.copackagedIndicator.isEmpty() ? false : this.copackagedIndicator.getValue();
2282    }
2283
2284    /**
2285     * @param value States whether a drug product is supplied with another item such as a diluent or adjuvant.
2286     */
2287    public PackagedProductDefinition setCopackagedIndicator(boolean value) { 
2288        if (this.copackagedIndicator == null)
2289          this.copackagedIndicator = new BooleanType();
2290        this.copackagedIndicator.setValue(value);
2291      return this;
2292    }
2293
2294    /**
2295     * @return {@link #manufacturer} (Manufacturer of this package type. When there are multiple it means these are all possible manufacturers.)
2296     */
2297    public List<Reference> getManufacturer() { 
2298      if (this.manufacturer == null)
2299        this.manufacturer = new ArrayList<Reference>();
2300      return this.manufacturer;
2301    }
2302
2303    /**
2304     * @return Returns a reference to <code>this</code> for easy method chaining
2305     */
2306    public PackagedProductDefinition setManufacturer(List<Reference> theManufacturer) { 
2307      this.manufacturer = theManufacturer;
2308      return this;
2309    }
2310
2311    public boolean hasManufacturer() { 
2312      if (this.manufacturer == null)
2313        return false;
2314      for (Reference item : this.manufacturer)
2315        if (!item.isEmpty())
2316          return true;
2317      return false;
2318    }
2319
2320    public Reference addManufacturer() { //3
2321      Reference t = new Reference();
2322      if (this.manufacturer == null)
2323        this.manufacturer = new ArrayList<Reference>();
2324      this.manufacturer.add(t);
2325      return t;
2326    }
2327
2328    public PackagedProductDefinition addManufacturer(Reference t) { //3
2329      if (t == null)
2330        return this;
2331      if (this.manufacturer == null)
2332        this.manufacturer = new ArrayList<Reference>();
2333      this.manufacturer.add(t);
2334      return this;
2335    }
2336
2337    /**
2338     * @return The first repetition of repeating field {@link #manufacturer}, creating it if it does not already exist {3}
2339     */
2340    public Reference getManufacturerFirstRep() { 
2341      if (getManufacturer().isEmpty()) {
2342        addManufacturer();
2343      }
2344      return getManufacturer().get(0);
2345    }
2346
2347    /**
2348     * @return {@link #attachedDocument} (Additional information or supporting documentation about the packaged product.)
2349     */
2350    public List<Reference> getAttachedDocument() { 
2351      if (this.attachedDocument == null)
2352        this.attachedDocument = new ArrayList<Reference>();
2353      return this.attachedDocument;
2354    }
2355
2356    /**
2357     * @return Returns a reference to <code>this</code> for easy method chaining
2358     */
2359    public PackagedProductDefinition setAttachedDocument(List<Reference> theAttachedDocument) { 
2360      this.attachedDocument = theAttachedDocument;
2361      return this;
2362    }
2363
2364    public boolean hasAttachedDocument() { 
2365      if (this.attachedDocument == null)
2366        return false;
2367      for (Reference item : this.attachedDocument)
2368        if (!item.isEmpty())
2369          return true;
2370      return false;
2371    }
2372
2373    public Reference addAttachedDocument() { //3
2374      Reference t = new Reference();
2375      if (this.attachedDocument == null)
2376        this.attachedDocument = new ArrayList<Reference>();
2377      this.attachedDocument.add(t);
2378      return t;
2379    }
2380
2381    public PackagedProductDefinition addAttachedDocument(Reference t) { //3
2382      if (t == null)
2383        return this;
2384      if (this.attachedDocument == null)
2385        this.attachedDocument = new ArrayList<Reference>();
2386      this.attachedDocument.add(t);
2387      return this;
2388    }
2389
2390    /**
2391     * @return The first repetition of repeating field {@link #attachedDocument}, creating it if it does not already exist {3}
2392     */
2393    public Reference getAttachedDocumentFirstRep() { 
2394      if (getAttachedDocument().isEmpty()) {
2395        addAttachedDocument();
2396      }
2397      return getAttachedDocument().get(0);
2398    }
2399
2400    /**
2401     * @return {@link #package_} (A packaging item, as a container for medically related items, possibly with other packaging items within, or a packaging component, such as bottle cap (which is not a device or a medication manufactured item).)
2402     */
2403    public PackagedProductDefinitionPackageComponent getPackage() { 
2404      if (this.package_ == null)
2405        if (Configuration.errorOnAutoCreate())
2406          throw new Error("Attempt to auto-create PackagedProductDefinition.package_");
2407        else if (Configuration.doAutoCreate())
2408          this.package_ = new PackagedProductDefinitionPackageComponent(); // cc
2409      return this.package_;
2410    }
2411
2412    public boolean hasPackage() { 
2413      return this.package_ != null && !this.package_.isEmpty();
2414    }
2415
2416    /**
2417     * @param value {@link #package_} (A packaging item, as a container for medically related items, possibly with other packaging items within, or a packaging component, such as bottle cap (which is not a device or a medication manufactured item).)
2418     */
2419    public PackagedProductDefinition setPackage(PackagedProductDefinitionPackageComponent value) { 
2420      this.package_ = value;
2421      return this;
2422    }
2423
2424      protected void listChildren(List<Property> children) {
2425        super.listChildren(children);
2426        children.add(new Property("identifier", "Identifier", "Unique identifier.", 0, java.lang.Integer.MAX_VALUE, identifier));
2427        children.add(new Property("name", "string", "A name for this package. Typically what it would be listed as in a drug formulary or catalogue, inventory etc.", 0, 1, name));
2428        children.add(new Property("type", "CodeableConcept", "A high level category e.g. medicinal product, raw material, shipping/transport container, etc.", 0, 1, type));
2429        children.add(new Property("packageFor", "Reference(MedicinalProductDefinition)", "The product that this is a pack for.", 0, java.lang.Integer.MAX_VALUE, packageFor));
2430        children.add(new Property("status", "CodeableConcept", "The status within the lifecycle of this item. A high level status, this is not intended to duplicate details carried elsewhere such as legal status, or authorization or marketing status.", 0, 1, status));
2431        children.add(new Property("statusDate", "dateTime", "The date at which the given status became applicable.", 0, 1, statusDate));
2432        children.add(new Property("containedItemQuantity", "Quantity", "A total of the amount of items in the package, per item type. This can be considered as the pack size. This attribute differs from containedItem.amount in that it can give a single aggregated count of all tablet types in a pack, even when these are different manufactured items. For example a pill pack of 21 tablets plus 7 sugar tablets, can be denoted here as '28 tablets'. This attribute is repeatable so that the different item types in one pack type can be counted (e.g. a count of vials and count of syringes). Each repeat must have different units, so that it is clear what the different sets of counted items are, and it is not intended to allow different counts of similar items (e.g. not '2 tubes and 3 tubes'). Repeats are not to be used to represent different pack sizes (e.g. 20 pack vs. 50 pack) - which would be different instances of this resource.", 0, java.lang.Integer.MAX_VALUE, containedItemQuantity));
2433        children.add(new Property("description", "markdown", "Textual description. Note that this is not the name of the package or product.", 0, 1, description));
2434        children.add(new Property("legalStatusOfSupply", "", "The legal status of supply of the packaged item as classified by the regulator.", 0, java.lang.Integer.MAX_VALUE, legalStatusOfSupply));
2435        children.add(new Property("marketingStatus", "MarketingStatus", "Marketing information.", 0, java.lang.Integer.MAX_VALUE, marketingStatus));
2436        children.add(new Property("characteristic", "CodeableConcept", "Allows the key features to be recorded, such as \"hospital pack\", \"nurse prescribable\", \"calendar pack\".", 0, java.lang.Integer.MAX_VALUE, characteristic));
2437        children.add(new Property("copackagedIndicator", "boolean", "States whether a drug product is supplied with another item such as a diluent or adjuvant.", 0, 1, copackagedIndicator));
2438        children.add(new Property("manufacturer", "Reference(Organization)", "Manufacturer of this package type. When there are multiple it means these are all possible manufacturers.", 0, java.lang.Integer.MAX_VALUE, manufacturer));
2439        children.add(new Property("attachedDocument", "Reference(DocumentReference)", "Additional information or supporting documentation about the packaged product.", 0, java.lang.Integer.MAX_VALUE, attachedDocument));
2440        children.add(new Property("package", "", "A packaging item, as a container for medically related items, possibly with other packaging items within, or a packaging component, such as bottle cap (which is not a device or a medication manufactured item).", 0, 1, package_));
2441      }
2442
2443      @Override
2444      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2445        switch (_hash) {
2446        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Unique identifier.", 0, java.lang.Integer.MAX_VALUE, identifier);
2447        case 3373707: /*name*/  return new Property("name", "string", "A name for this package. Typically what it would be listed as in a drug formulary or catalogue, inventory etc.", 0, 1, name);
2448        case 3575610: /*type*/  return new Property("type", "CodeableConcept", "A high level category e.g. medicinal product, raw material, shipping/transport container, etc.", 0, 1, type);
2449        case 29307555: /*packageFor*/  return new Property("packageFor", "Reference(MedicinalProductDefinition)", "The product that this is a pack for.", 0, java.lang.Integer.MAX_VALUE, packageFor);
2450        case -892481550: /*status*/  return new Property("status", "CodeableConcept", "The status within the lifecycle of this item. A high level status, this is not intended to duplicate details carried elsewhere such as legal status, or authorization or marketing status.", 0, 1, status);
2451        case 247524032: /*statusDate*/  return new Property("statusDate", "dateTime", "The date at which the given status became applicable.", 0, 1, statusDate);
2452        case -1686893359: /*containedItemQuantity*/  return new Property("containedItemQuantity", "Quantity", "A total of the amount of items in the package, per item type. This can be considered as the pack size. This attribute differs from containedItem.amount in that it can give a single aggregated count of all tablet types in a pack, even when these are different manufactured items. For example a pill pack of 21 tablets plus 7 sugar tablets, can be denoted here as '28 tablets'. This attribute is repeatable so that the different item types in one pack type can be counted (e.g. a count of vials and count of syringes). Each repeat must have different units, so that it is clear what the different sets of counted items are, and it is not intended to allow different counts of similar items (e.g. not '2 tubes and 3 tubes'). Repeats are not to be used to represent different pack sizes (e.g. 20 pack vs. 50 pack) - which would be different instances of this resource.", 0, java.lang.Integer.MAX_VALUE, containedItemQuantity);
2453        case -1724546052: /*description*/  return new Property("description", "markdown", "Textual description. Note that this is not the name of the package or product.", 0, 1, description);
2454        case -844874031: /*legalStatusOfSupply*/  return new Property("legalStatusOfSupply", "", "The legal status of supply of the packaged item as classified by the regulator.", 0, java.lang.Integer.MAX_VALUE, legalStatusOfSupply);
2455        case 70767032: /*marketingStatus*/  return new Property("marketingStatus", "MarketingStatus", "Marketing information.", 0, java.lang.Integer.MAX_VALUE, marketingStatus);
2456        case 366313883: /*characteristic*/  return new Property("characteristic", "CodeableConcept", "Allows the key features to be recorded, such as \"hospital pack\", \"nurse prescribable\", \"calendar pack\".", 0, java.lang.Integer.MAX_VALUE, characteristic);
2457        case -1638663195: /*copackagedIndicator*/  return new Property("copackagedIndicator", "boolean", "States whether a drug product is supplied with another item such as a diluent or adjuvant.", 0, 1, copackagedIndicator);
2458        case -1969347631: /*manufacturer*/  return new Property("manufacturer", "Reference(Organization)", "Manufacturer of this package type. When there are multiple it means these are all possible manufacturers.", 0, java.lang.Integer.MAX_VALUE, manufacturer);
2459        case -513945889: /*attachedDocument*/  return new Property("attachedDocument", "Reference(DocumentReference)", "Additional information or supporting documentation about the packaged product.", 0, java.lang.Integer.MAX_VALUE, attachedDocument);
2460        case -807062458: /*package*/  return new Property("package", "", "A packaging item, as a container for medically related items, possibly with other packaging items within, or a packaging component, such as bottle cap (which is not a device or a medication manufactured item).", 0, 1, package_);
2461        default: return super.getNamedProperty(_hash, _name, _checkValid);
2462        }
2463
2464      }
2465
2466      @Override
2467      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2468        switch (hash) {
2469        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
2470        case 3373707: /*name*/ return this.name == null ? new Base[0] : new Base[] {this.name}; // StringType
2471        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
2472        case 29307555: /*packageFor*/ return this.packageFor == null ? new Base[0] : this.packageFor.toArray(new Base[this.packageFor.size()]); // Reference
2473        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // CodeableConcept
2474        case 247524032: /*statusDate*/ return this.statusDate == null ? new Base[0] : new Base[] {this.statusDate}; // DateTimeType
2475        case -1686893359: /*containedItemQuantity*/ return this.containedItemQuantity == null ? new Base[0] : this.containedItemQuantity.toArray(new Base[this.containedItemQuantity.size()]); // Quantity
2476        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // MarkdownType
2477        case -844874031: /*legalStatusOfSupply*/ return this.legalStatusOfSupply == null ? new Base[0] : this.legalStatusOfSupply.toArray(new Base[this.legalStatusOfSupply.size()]); // PackagedProductDefinitionLegalStatusOfSupplyComponent
2478        case 70767032: /*marketingStatus*/ return this.marketingStatus == null ? new Base[0] : this.marketingStatus.toArray(new Base[this.marketingStatus.size()]); // MarketingStatus
2479        case 366313883: /*characteristic*/ return this.characteristic == null ? new Base[0] : this.characteristic.toArray(new Base[this.characteristic.size()]); // CodeableConcept
2480        case -1638663195: /*copackagedIndicator*/ return this.copackagedIndicator == null ? new Base[0] : new Base[] {this.copackagedIndicator}; // BooleanType
2481        case -1969347631: /*manufacturer*/ return this.manufacturer == null ? new Base[0] : this.manufacturer.toArray(new Base[this.manufacturer.size()]); // Reference
2482        case -513945889: /*attachedDocument*/ return this.attachedDocument == null ? new Base[0] : this.attachedDocument.toArray(new Base[this.attachedDocument.size()]); // Reference
2483        case -807062458: /*package*/ return this.package_ == null ? new Base[0] : new Base[] {this.package_}; // PackagedProductDefinitionPackageComponent
2484        default: return super.getProperty(hash, name, checkValid);
2485        }
2486
2487      }
2488
2489      @Override
2490      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2491        switch (hash) {
2492        case -1618432855: // identifier
2493          this.getIdentifier().add(TypeConvertor.castToIdentifier(value)); // Identifier
2494          return value;
2495        case 3373707: // name
2496          this.name = TypeConvertor.castToString(value); // StringType
2497          return value;
2498        case 3575610: // type
2499          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
2500          return value;
2501        case 29307555: // packageFor
2502          this.getPackageFor().add(TypeConvertor.castToReference(value)); // Reference
2503          return value;
2504        case -892481550: // status
2505          this.status = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
2506          return value;
2507        case 247524032: // statusDate
2508          this.statusDate = TypeConvertor.castToDateTime(value); // DateTimeType
2509          return value;
2510        case -1686893359: // containedItemQuantity
2511          this.getContainedItemQuantity().add(TypeConvertor.castToQuantity(value)); // Quantity
2512          return value;
2513        case -1724546052: // description
2514          this.description = TypeConvertor.castToMarkdown(value); // MarkdownType
2515          return value;
2516        case -844874031: // legalStatusOfSupply
2517          this.getLegalStatusOfSupply().add((PackagedProductDefinitionLegalStatusOfSupplyComponent) value); // PackagedProductDefinitionLegalStatusOfSupplyComponent
2518          return value;
2519        case 70767032: // marketingStatus
2520          this.getMarketingStatus().add(TypeConvertor.castToMarketingStatus(value)); // MarketingStatus
2521          return value;
2522        case 366313883: // characteristic
2523          this.getCharacteristic().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
2524          return value;
2525        case -1638663195: // copackagedIndicator
2526          this.copackagedIndicator = TypeConvertor.castToBoolean(value); // BooleanType
2527          return value;
2528        case -1969347631: // manufacturer
2529          this.getManufacturer().add(TypeConvertor.castToReference(value)); // Reference
2530          return value;
2531        case -513945889: // attachedDocument
2532          this.getAttachedDocument().add(TypeConvertor.castToReference(value)); // Reference
2533          return value;
2534        case -807062458: // package
2535          this.package_ = (PackagedProductDefinitionPackageComponent) value; // PackagedProductDefinitionPackageComponent
2536          return value;
2537        default: return super.setProperty(hash, name, value);
2538        }
2539
2540      }
2541
2542      @Override
2543      public Base setProperty(String name, Base value) throws FHIRException {
2544        if (name.equals("identifier")) {
2545          this.getIdentifier().add(TypeConvertor.castToIdentifier(value));
2546        } else if (name.equals("name")) {
2547          this.name = TypeConvertor.castToString(value); // StringType
2548        } else if (name.equals("type")) {
2549          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
2550        } else if (name.equals("packageFor")) {
2551          this.getPackageFor().add(TypeConvertor.castToReference(value));
2552        } else if (name.equals("status")) {
2553          this.status = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
2554        } else if (name.equals("statusDate")) {
2555          this.statusDate = TypeConvertor.castToDateTime(value); // DateTimeType
2556        } else if (name.equals("containedItemQuantity")) {
2557          this.getContainedItemQuantity().add(TypeConvertor.castToQuantity(value));
2558        } else if (name.equals("description")) {
2559          this.description = TypeConvertor.castToMarkdown(value); // MarkdownType
2560        } else if (name.equals("legalStatusOfSupply")) {
2561          this.getLegalStatusOfSupply().add((PackagedProductDefinitionLegalStatusOfSupplyComponent) value);
2562        } else if (name.equals("marketingStatus")) {
2563          this.getMarketingStatus().add(TypeConvertor.castToMarketingStatus(value));
2564        } else if (name.equals("characteristic")) {
2565          this.getCharacteristic().add(TypeConvertor.castToCodeableConcept(value));
2566        } else if (name.equals("copackagedIndicator")) {
2567          this.copackagedIndicator = TypeConvertor.castToBoolean(value); // BooleanType
2568        } else if (name.equals("manufacturer")) {
2569          this.getManufacturer().add(TypeConvertor.castToReference(value));
2570        } else if (name.equals("attachedDocument")) {
2571          this.getAttachedDocument().add(TypeConvertor.castToReference(value));
2572        } else if (name.equals("package")) {
2573          this.package_ = (PackagedProductDefinitionPackageComponent) value; // PackagedProductDefinitionPackageComponent
2574        } else
2575          return super.setProperty(name, value);
2576        return value;
2577      }
2578
2579      @Override
2580      public Base makeProperty(int hash, String name) throws FHIRException {
2581        switch (hash) {
2582        case -1618432855:  return addIdentifier(); 
2583        case 3373707:  return getNameElement();
2584        case 3575610:  return getType();
2585        case 29307555:  return addPackageFor(); 
2586        case -892481550:  return getStatus();
2587        case 247524032:  return getStatusDateElement();
2588        case -1686893359:  return addContainedItemQuantity(); 
2589        case -1724546052:  return getDescriptionElement();
2590        case -844874031:  return addLegalStatusOfSupply(); 
2591        case 70767032:  return addMarketingStatus(); 
2592        case 366313883:  return addCharacteristic(); 
2593        case -1638663195:  return getCopackagedIndicatorElement();
2594        case -1969347631:  return addManufacturer(); 
2595        case -513945889:  return addAttachedDocument(); 
2596        case -807062458:  return getPackage();
2597        default: return super.makeProperty(hash, name);
2598        }
2599
2600      }
2601
2602      @Override
2603      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2604        switch (hash) {
2605        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
2606        case 3373707: /*name*/ return new String[] {"string"};
2607        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
2608        case 29307555: /*packageFor*/ return new String[] {"Reference"};
2609        case -892481550: /*status*/ return new String[] {"CodeableConcept"};
2610        case 247524032: /*statusDate*/ return new String[] {"dateTime"};
2611        case -1686893359: /*containedItemQuantity*/ return new String[] {"Quantity"};
2612        case -1724546052: /*description*/ return new String[] {"markdown"};
2613        case -844874031: /*legalStatusOfSupply*/ return new String[] {};
2614        case 70767032: /*marketingStatus*/ return new String[] {"MarketingStatus"};
2615        case 366313883: /*characteristic*/ return new String[] {"CodeableConcept"};
2616        case -1638663195: /*copackagedIndicator*/ return new String[] {"boolean"};
2617        case -1969347631: /*manufacturer*/ return new String[] {"Reference"};
2618        case -513945889: /*attachedDocument*/ return new String[] {"Reference"};
2619        case -807062458: /*package*/ return new String[] {};
2620        default: return super.getTypesForProperty(hash, name);
2621        }
2622
2623      }
2624
2625      @Override
2626      public Base addChild(String name) throws FHIRException {
2627        if (name.equals("identifier")) {
2628          return addIdentifier();
2629        }
2630        else if (name.equals("name")) {
2631          throw new FHIRException("Cannot call addChild on a primitive type PackagedProductDefinition.name");
2632        }
2633        else if (name.equals("type")) {
2634          this.type = new CodeableConcept();
2635          return this.type;
2636        }
2637        else if (name.equals("packageFor")) {
2638          return addPackageFor();
2639        }
2640        else if (name.equals("status")) {
2641          this.status = new CodeableConcept();
2642          return this.status;
2643        }
2644        else if (name.equals("statusDate")) {
2645          throw new FHIRException("Cannot call addChild on a primitive type PackagedProductDefinition.statusDate");
2646        }
2647        else if (name.equals("containedItemQuantity")) {
2648          return addContainedItemQuantity();
2649        }
2650        else if (name.equals("description")) {
2651          throw new FHIRException("Cannot call addChild on a primitive type PackagedProductDefinition.description");
2652        }
2653        else if (name.equals("legalStatusOfSupply")) {
2654          return addLegalStatusOfSupply();
2655        }
2656        else if (name.equals("marketingStatus")) {
2657          return addMarketingStatus();
2658        }
2659        else if (name.equals("characteristic")) {
2660          return addCharacteristic();
2661        }
2662        else if (name.equals("copackagedIndicator")) {
2663          throw new FHIRException("Cannot call addChild on a primitive type PackagedProductDefinition.copackagedIndicator");
2664        }
2665        else if (name.equals("manufacturer")) {
2666          return addManufacturer();
2667        }
2668        else if (name.equals("attachedDocument")) {
2669          return addAttachedDocument();
2670        }
2671        else if (name.equals("package")) {
2672          this.package_ = new PackagedProductDefinitionPackageComponent();
2673          return this.package_;
2674        }
2675        else
2676          return super.addChild(name);
2677      }
2678
2679  public String fhirType() {
2680    return "PackagedProductDefinition";
2681
2682  }
2683
2684      public PackagedProductDefinition copy() {
2685        PackagedProductDefinition dst = new PackagedProductDefinition();
2686        copyValues(dst);
2687        return dst;
2688      }
2689
2690      public void copyValues(PackagedProductDefinition dst) {
2691        super.copyValues(dst);
2692        if (identifier != null) {
2693          dst.identifier = new ArrayList<Identifier>();
2694          for (Identifier i : identifier)
2695            dst.identifier.add(i.copy());
2696        };
2697        dst.name = name == null ? null : name.copy();
2698        dst.type = type == null ? null : type.copy();
2699        if (packageFor != null) {
2700          dst.packageFor = new ArrayList<Reference>();
2701          for (Reference i : packageFor)
2702            dst.packageFor.add(i.copy());
2703        };
2704        dst.status = status == null ? null : status.copy();
2705        dst.statusDate = statusDate == null ? null : statusDate.copy();
2706        if (containedItemQuantity != null) {
2707          dst.containedItemQuantity = new ArrayList<Quantity>();
2708          for (Quantity i : containedItemQuantity)
2709            dst.containedItemQuantity.add(i.copy());
2710        };
2711        dst.description = description == null ? null : description.copy();
2712        if (legalStatusOfSupply != null) {
2713          dst.legalStatusOfSupply = new ArrayList<PackagedProductDefinitionLegalStatusOfSupplyComponent>();
2714          for (PackagedProductDefinitionLegalStatusOfSupplyComponent i : legalStatusOfSupply)
2715            dst.legalStatusOfSupply.add(i.copy());
2716        };
2717        if (marketingStatus != null) {
2718          dst.marketingStatus = new ArrayList<MarketingStatus>();
2719          for (MarketingStatus i : marketingStatus)
2720            dst.marketingStatus.add(i.copy());
2721        };
2722        if (characteristic != null) {
2723          dst.characteristic = new ArrayList<CodeableConcept>();
2724          for (CodeableConcept i : characteristic)
2725            dst.characteristic.add(i.copy());
2726        };
2727        dst.copackagedIndicator = copackagedIndicator == null ? null : copackagedIndicator.copy();
2728        if (manufacturer != null) {
2729          dst.manufacturer = new ArrayList<Reference>();
2730          for (Reference i : manufacturer)
2731            dst.manufacturer.add(i.copy());
2732        };
2733        if (attachedDocument != null) {
2734          dst.attachedDocument = new ArrayList<Reference>();
2735          for (Reference i : attachedDocument)
2736            dst.attachedDocument.add(i.copy());
2737        };
2738        dst.package_ = package_ == null ? null : package_.copy();
2739      }
2740
2741      protected PackagedProductDefinition typedCopy() {
2742        return copy();
2743      }
2744
2745      @Override
2746      public boolean equalsDeep(Base other_) {
2747        if (!super.equalsDeep(other_))
2748          return false;
2749        if (!(other_ instanceof PackagedProductDefinition))
2750          return false;
2751        PackagedProductDefinition o = (PackagedProductDefinition) other_;
2752        return compareDeep(identifier, o.identifier, true) && compareDeep(name, o.name, true) && compareDeep(type, o.type, true)
2753           && compareDeep(packageFor, o.packageFor, true) && compareDeep(status, o.status, true) && compareDeep(statusDate, o.statusDate, true)
2754           && compareDeep(containedItemQuantity, o.containedItemQuantity, true) && compareDeep(description, o.description, true)
2755           && compareDeep(legalStatusOfSupply, o.legalStatusOfSupply, true) && compareDeep(marketingStatus, o.marketingStatus, true)
2756           && compareDeep(characteristic, o.characteristic, true) && compareDeep(copackagedIndicator, o.copackagedIndicator, true)
2757           && compareDeep(manufacturer, o.manufacturer, true) && compareDeep(attachedDocument, o.attachedDocument, true)
2758           && compareDeep(package_, o.package_, true);
2759      }
2760
2761      @Override
2762      public boolean equalsShallow(Base other_) {
2763        if (!super.equalsShallow(other_))
2764          return false;
2765        if (!(other_ instanceof PackagedProductDefinition))
2766          return false;
2767        PackagedProductDefinition o = (PackagedProductDefinition) other_;
2768        return compareValues(name, o.name, true) && compareValues(statusDate, o.statusDate, true) && compareValues(description, o.description, true)
2769           && compareValues(copackagedIndicator, o.copackagedIndicator, true);
2770      }
2771
2772      public boolean isEmpty() {
2773        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, name, type, packageFor
2774          , status, statusDate, containedItemQuantity, description, legalStatusOfSupply, marketingStatus
2775          , characteristic, copackagedIndicator, manufacturer, attachedDocument, package_);
2776      }
2777
2778  @Override
2779  public ResourceType getResourceType() {
2780    return ResourceType.PackagedProductDefinition;
2781   }
2782
2783 /**
2784   * Search parameter: <b>biological</b>
2785   * <p>
2786   * Description: <b>A biologically derived product within this packaged product</b><br>
2787   * Type: <b>reference</b><br>
2788   * Path: <b>PackagedProductDefinition.package.containedItem.item.reference</b><br>
2789   * </p>
2790   */
2791  @SearchParamDefinition(name="biological", path="PackagedProductDefinition.package.containedItem.item.reference", description="A biologically derived product within this packaged product", type="reference" )
2792  public static final String SP_BIOLOGICAL = "biological";
2793 /**
2794   * <b>Fluent Client</b> search parameter constant for <b>biological</b>
2795   * <p>
2796   * Description: <b>A biologically derived product within this packaged product</b><br>
2797   * Type: <b>reference</b><br>
2798   * Path: <b>PackagedProductDefinition.package.containedItem.item.reference</b><br>
2799   * </p>
2800   */
2801  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam BIOLOGICAL = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_BIOLOGICAL);
2802
2803/**
2804   * Constant for fluent queries to be used to add include statements. Specifies
2805   * the path value of "<b>PackagedProductDefinition:biological</b>".
2806   */
2807  public static final ca.uhn.fhir.model.api.Include INCLUDE_BIOLOGICAL = new ca.uhn.fhir.model.api.Include("PackagedProductDefinition:biological").toLocked();
2808
2809 /**
2810   * Search parameter: <b>contained-item</b>
2811   * <p>
2812   * Description: <b>Any of the contained items within this packaged product</b><br>
2813   * Type: <b>reference</b><br>
2814   * Path: <b>PackagedProductDefinition.package.containedItem.item.reference</b><br>
2815   * </p>
2816   */
2817  @SearchParamDefinition(name="contained-item", path="PackagedProductDefinition.package.containedItem.item.reference", description="Any of the contained items within this packaged product", type="reference" )
2818  public static final String SP_CONTAINED_ITEM = "contained-item";
2819 /**
2820   * <b>Fluent Client</b> search parameter constant for <b>contained-item</b>
2821   * <p>
2822   * Description: <b>Any of the contained items within this packaged product</b><br>
2823   * Type: <b>reference</b><br>
2824   * Path: <b>PackagedProductDefinition.package.containedItem.item.reference</b><br>
2825   * </p>
2826   */
2827  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam CONTAINED_ITEM = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_CONTAINED_ITEM);
2828
2829/**
2830   * Constant for fluent queries to be used to add include statements. Specifies
2831   * the path value of "<b>PackagedProductDefinition:contained-item</b>".
2832   */
2833  public static final ca.uhn.fhir.model.api.Include INCLUDE_CONTAINED_ITEM = new ca.uhn.fhir.model.api.Include("PackagedProductDefinition:contained-item").toLocked();
2834
2835 /**
2836   * Search parameter: <b>device</b>
2837   * <p>
2838   * Description: <b>A device within this packaged product</b><br>
2839   * Type: <b>reference</b><br>
2840   * Path: <b>PackagedProductDefinition.package.containedItem.item.reference</b><br>
2841   * </p>
2842   */
2843  @SearchParamDefinition(name="device", path="PackagedProductDefinition.package.containedItem.item.reference", description="A device within this packaged product", type="reference" )
2844  public static final String SP_DEVICE = "device";
2845 /**
2846   * <b>Fluent Client</b> search parameter constant for <b>device</b>
2847   * <p>
2848   * Description: <b>A device within this packaged product</b><br>
2849   * Type: <b>reference</b><br>
2850   * Path: <b>PackagedProductDefinition.package.containedItem.item.reference</b><br>
2851   * </p>
2852   */
2853  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam DEVICE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_DEVICE);
2854
2855/**
2856   * Constant for fluent queries to be used to add include statements. Specifies
2857   * the path value of "<b>PackagedProductDefinition:device</b>".
2858   */
2859  public static final ca.uhn.fhir.model.api.Include INCLUDE_DEVICE = new ca.uhn.fhir.model.api.Include("PackagedProductDefinition:device").toLocked();
2860
2861 /**
2862   * Search parameter: <b>identifier</b>
2863   * <p>
2864   * Description: <b>Unique identifier</b><br>
2865   * Type: <b>token</b><br>
2866   * Path: <b>PackagedProductDefinition.identifier</b><br>
2867   * </p>
2868   */
2869  @SearchParamDefinition(name="identifier", path="PackagedProductDefinition.identifier", description="Unique identifier", type="token" )
2870  public static final String SP_IDENTIFIER = "identifier";
2871 /**
2872   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2873   * <p>
2874   * Description: <b>Unique identifier</b><br>
2875   * Type: <b>token</b><br>
2876   * Path: <b>PackagedProductDefinition.identifier</b><br>
2877   * </p>
2878   */
2879  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
2880
2881 /**
2882   * Search parameter: <b>manufactured-item</b>
2883   * <p>
2884   * Description: <b>A manufactured item of medication within this packaged product</b><br>
2885   * Type: <b>reference</b><br>
2886   * Path: <b>PackagedProductDefinition.package.containedItem.item.reference</b><br>
2887   * </p>
2888   */
2889  @SearchParamDefinition(name="manufactured-item", path="PackagedProductDefinition.package.containedItem.item.reference", description="A manufactured item of medication within this packaged product", type="reference" )
2890  public static final String SP_MANUFACTURED_ITEM = "manufactured-item";
2891 /**
2892   * <b>Fluent Client</b> search parameter constant for <b>manufactured-item</b>
2893   * <p>
2894   * Description: <b>A manufactured item of medication within this packaged product</b><br>
2895   * Type: <b>reference</b><br>
2896   * Path: <b>PackagedProductDefinition.package.containedItem.item.reference</b><br>
2897   * </p>
2898   */
2899  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam MANUFACTURED_ITEM = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_MANUFACTURED_ITEM);
2900
2901/**
2902   * Constant for fluent queries to be used to add include statements. Specifies
2903   * the path value of "<b>PackagedProductDefinition:manufactured-item</b>".
2904   */
2905  public static final ca.uhn.fhir.model.api.Include INCLUDE_MANUFACTURED_ITEM = new ca.uhn.fhir.model.api.Include("PackagedProductDefinition:manufactured-item").toLocked();
2906
2907 /**
2908   * Search parameter: <b>medication</b>
2909   * <p>
2910   * Description: <b>A manufactured item of medication within this packaged product</b><br>
2911   * Type: <b>reference</b><br>
2912   * Path: <b>PackagedProductDefinition.package.containedItem.item.reference</b><br>
2913   * </p>
2914   */
2915  @SearchParamDefinition(name="medication", path="PackagedProductDefinition.package.containedItem.item.reference", description="A manufactured item of medication within this packaged product", type="reference" )
2916  public static final String SP_MEDICATION = "medication";
2917 /**
2918   * <b>Fluent Client</b> search parameter constant for <b>medication</b>
2919   * <p>
2920   * Description: <b>A manufactured item of medication within this packaged product</b><br>
2921   * Type: <b>reference</b><br>
2922   * Path: <b>PackagedProductDefinition.package.containedItem.item.reference</b><br>
2923   * </p>
2924   */
2925  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam MEDICATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_MEDICATION);
2926
2927/**
2928   * Constant for fluent queries to be used to add include statements. Specifies
2929   * the path value of "<b>PackagedProductDefinition:medication</b>".
2930   */
2931  public static final ca.uhn.fhir.model.api.Include INCLUDE_MEDICATION = new ca.uhn.fhir.model.api.Include("PackagedProductDefinition:medication").toLocked();
2932
2933 /**
2934   * Search parameter: <b>name</b>
2935   * <p>
2936   * Description: <b>A name for this package. Typically what it would be listed as in a drug formulary or catalogue, inventory etc</b><br>
2937   * Type: <b>token</b><br>
2938   * Path: <b>PackagedProductDefinition.name</b><br>
2939   * </p>
2940   */
2941  @SearchParamDefinition(name="name", path="PackagedProductDefinition.name", description="A name for this package. Typically what it would be listed as in a drug formulary or catalogue, inventory etc", type="token" )
2942  public static final String SP_NAME = "name";
2943 /**
2944   * <b>Fluent Client</b> search parameter constant for <b>name</b>
2945   * <p>
2946   * Description: <b>A name for this package. Typically what it would be listed as in a drug formulary or catalogue, inventory etc</b><br>
2947   * Type: <b>token</b><br>
2948   * Path: <b>PackagedProductDefinition.name</b><br>
2949   * </p>
2950   */
2951  public static final ca.uhn.fhir.rest.gclient.TokenClientParam NAME = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_NAME);
2952
2953 /**
2954   * Search parameter: <b>nutrition</b>
2955   * <p>
2956   * Description: <b>A nutrition product within this packaged product</b><br>
2957   * Type: <b>reference</b><br>
2958   * Path: <b>PackagedProductDefinition.package.containedItem.item.reference</b><br>
2959   * </p>
2960   */
2961  @SearchParamDefinition(name="nutrition", path="PackagedProductDefinition.package.containedItem.item.reference", description="A nutrition product within this packaged product", type="reference" )
2962  public static final String SP_NUTRITION = "nutrition";
2963 /**
2964   * <b>Fluent Client</b> search parameter constant for <b>nutrition</b>
2965   * <p>
2966   * Description: <b>A nutrition product within this packaged product</b><br>
2967   * Type: <b>reference</b><br>
2968   * Path: <b>PackagedProductDefinition.package.containedItem.item.reference</b><br>
2969   * </p>
2970   */
2971  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam NUTRITION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_NUTRITION);
2972
2973/**
2974   * Constant for fluent queries to be used to add include statements. Specifies
2975   * the path value of "<b>PackagedProductDefinition:nutrition</b>".
2976   */
2977  public static final ca.uhn.fhir.model.api.Include INCLUDE_NUTRITION = new ca.uhn.fhir.model.api.Include("PackagedProductDefinition:nutrition").toLocked();
2978
2979 /**
2980   * Search parameter: <b>package-for</b>
2981   * <p>
2982   * Description: <b>The product that this is a pack for</b><br>
2983   * Type: <b>reference</b><br>
2984   * Path: <b>PackagedProductDefinition.packageFor</b><br>
2985   * </p>
2986   */
2987  @SearchParamDefinition(name="package-for", path="PackagedProductDefinition.packageFor", description="The product that this is a pack for", type="reference", target={MedicinalProductDefinition.class } )
2988  public static final String SP_PACKAGE_FOR = "package-for";
2989 /**
2990   * <b>Fluent Client</b> search parameter constant for <b>package-for</b>
2991   * <p>
2992   * Description: <b>The product that this is a pack for</b><br>
2993   * Type: <b>reference</b><br>
2994   * Path: <b>PackagedProductDefinition.packageFor</b><br>
2995   * </p>
2996   */
2997  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PACKAGE_FOR = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PACKAGE_FOR);
2998
2999/**
3000   * Constant for fluent queries to be used to add include statements. Specifies
3001   * the path value of "<b>PackagedProductDefinition:package-for</b>".
3002   */
3003  public static final ca.uhn.fhir.model.api.Include INCLUDE_PACKAGE_FOR = new ca.uhn.fhir.model.api.Include("PackagedProductDefinition:package-for").toLocked();
3004
3005 /**
3006   * Search parameter: <b>package</b>
3007   * <p>
3008   * Description: <b>A complete packaged product within this packaged product</b><br>
3009   * Type: <b>reference</b><br>
3010   * Path: <b>PackagedProductDefinition.package.containedItem.item.reference</b><br>
3011   * </p>
3012   */
3013  @SearchParamDefinition(name="package", path="PackagedProductDefinition.package.containedItem.item.reference", description="A complete packaged product within this packaged product", type="reference" )
3014  public static final String SP_PACKAGE = "package";
3015 /**
3016   * <b>Fluent Client</b> search parameter constant for <b>package</b>
3017   * <p>
3018   * Description: <b>A complete packaged product within this packaged product</b><br>
3019   * Type: <b>reference</b><br>
3020   * Path: <b>PackagedProductDefinition.package.containedItem.item.reference</b><br>
3021   * </p>
3022   */
3023  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PACKAGE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PACKAGE);
3024
3025/**
3026   * Constant for fluent queries to be used to add include statements. Specifies
3027   * the path value of "<b>PackagedProductDefinition:package</b>".
3028   */
3029  public static final ca.uhn.fhir.model.api.Include INCLUDE_PACKAGE = new ca.uhn.fhir.model.api.Include("PackagedProductDefinition:package").toLocked();
3030
3031 /**
3032   * Search parameter: <b>status</b>
3033   * <p>
3034   * Description: <b>The status within the lifecycle of this item. A high level status, this is not intended to duplicate details carried elsewhere such as legal status, or authorization or marketing status</b><br>
3035   * Type: <b>token</b><br>
3036   * Path: <b>PackagedProductDefinition.status</b><br>
3037   * </p>
3038   */
3039  @SearchParamDefinition(name="status", path="PackagedProductDefinition.status", description="The status within the lifecycle of this item. A high level status, this is not intended to duplicate details carried elsewhere such as legal status, or authorization or marketing status", type="token" )
3040  public static final String SP_STATUS = "status";
3041 /**
3042   * <b>Fluent Client</b> search parameter constant for <b>status</b>
3043   * <p>
3044   * Description: <b>The status within the lifecycle of this item. A high level status, this is not intended to duplicate details carried elsewhere such as legal status, or authorization or marketing status</b><br>
3045   * Type: <b>token</b><br>
3046   * Path: <b>PackagedProductDefinition.status</b><br>
3047   * </p>
3048   */
3049  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
3050
3051
3052}
3053