001package org.hl7.fhir.r5.model;
002
003/*-
004 * #%L
005 * org.hl7.fhir.r5
006 * %%
007 * Copyright (C) 2014 - 2019 Health Level 7
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 * 
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 * 
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023/*
024  Copyright (c) 2011+, HL7, Inc.
025  All rights reserved.
026  
027  Redistribution and use in source and binary forms, with or without modification, 
028  are permitted provided that the following conditions are met:
029  
030   * Redistributions of source code must retain the above copyright notice, this 
031     list of conditions and the following disclaimer.
032   * Redistributions in binary form must reproduce the above copyright notice, 
033     this list of conditions and the following disclaimer in the documentation 
034     and/or other materials provided with the distribution.
035   * Neither the name of HL7 nor the names of its contributors may be used to 
036     endorse or promote products derived from this software without specific 
037     prior written permission.
038  
039  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
040  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
041  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
042  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
043  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
044  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
045  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
046  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
047  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
048  POSSIBILITY OF SUCH DAMAGE.
049  
050*/
051
052// Generated on Thu, Dec 13, 2018 14:07+1100 for FHIR v4.0.0
053import java.util.ArrayList;
054import java.util.Date;
055import java.util.List;
056import org.hl7.fhir.exceptions.FHIRException;
057import org.hl7.fhir.instance.model.api.ICompositeType;
058
059import org.hl7.fhir.instance.model.api.IBaseDatatypeElement;
060import org.hl7.fhir.utilities.Utilities;
061import ca.uhn.fhir.model.api.annotation.ResourceDef;
062import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
063import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
064import ca.uhn.fhir.model.api.annotation.Child;
065import ca.uhn.fhir.model.api.annotation.ChildOrder;
066import ca.uhn.fhir.model.api.annotation.Description;
067import ca.uhn.fhir.model.api.annotation.Block;
068/**
069 * A medicinal product in a container or package.
070 */
071@ResourceDef(name="PackagedProductDefinition", profile="http://hl7.org/fhir/StructureDefinition/PackagedProductDefinition")
072public class PackagedProductDefinition extends DomainResource {
073
074    @Block()
075    public static class PackagedProductDefinitionBatchIdentifierComponent extends BackboneElement implements IBaseBackboneElement {
076        /**
077         * A number appearing on the outer packaging of a specific batch.
078         */
079        @Child(name = "outerPackaging", type = {Identifier.class}, order=1, min=1, max=1, modifier=false, summary=true)
080        @Description(shortDefinition="A number appearing on the outer packaging of a specific batch", formalDefinition="A number appearing on the outer packaging of a specific batch." )
081        protected Identifier outerPackaging;
082
083        /**
084         * A number appearing on the immediate packaging (and not the outer packaging).
085         */
086        @Child(name = "immediatePackaging", type = {Identifier.class}, order=2, min=0, max=1, modifier=false, summary=true)
087        @Description(shortDefinition="A number appearing on the immediate packaging (and not the outer packaging)", formalDefinition="A number appearing on the immediate packaging (and not the outer packaging)." )
088        protected Identifier immediatePackaging;
089
090        private static final long serialVersionUID = 1187365068L;
091
092    /**
093     * Constructor
094     */
095      public PackagedProductDefinitionBatchIdentifierComponent() {
096        super();
097      }
098
099    /**
100     * Constructor
101     */
102      public PackagedProductDefinitionBatchIdentifierComponent(Identifier outerPackaging) {
103        super();
104        this.outerPackaging = outerPackaging;
105      }
106
107        /**
108         * @return {@link #outerPackaging} (A number appearing on the outer packaging of a specific batch.)
109         */
110        public Identifier getOuterPackaging() { 
111          if (this.outerPackaging == null)
112            if (Configuration.errorOnAutoCreate())
113              throw new Error("Attempt to auto-create PackagedProductDefinitionBatchIdentifierComponent.outerPackaging");
114            else if (Configuration.doAutoCreate())
115              this.outerPackaging = new Identifier(); // cc
116          return this.outerPackaging;
117        }
118
119        public boolean hasOuterPackaging() { 
120          return this.outerPackaging != null && !this.outerPackaging.isEmpty();
121        }
122
123        /**
124         * @param value {@link #outerPackaging} (A number appearing on the outer packaging of a specific batch.)
125         */
126        public PackagedProductDefinitionBatchIdentifierComponent setOuterPackaging(Identifier value) { 
127          this.outerPackaging = value;
128          return this;
129        }
130
131        /**
132         * @return {@link #immediatePackaging} (A number appearing on the immediate packaging (and not the outer packaging).)
133         */
134        public Identifier getImmediatePackaging() { 
135          if (this.immediatePackaging == null)
136            if (Configuration.errorOnAutoCreate())
137              throw new Error("Attempt to auto-create PackagedProductDefinitionBatchIdentifierComponent.immediatePackaging");
138            else if (Configuration.doAutoCreate())
139              this.immediatePackaging = new Identifier(); // cc
140          return this.immediatePackaging;
141        }
142
143        public boolean hasImmediatePackaging() { 
144          return this.immediatePackaging != null && !this.immediatePackaging.isEmpty();
145        }
146
147        /**
148         * @param value {@link #immediatePackaging} (A number appearing on the immediate packaging (and not the outer packaging).)
149         */
150        public PackagedProductDefinitionBatchIdentifierComponent setImmediatePackaging(Identifier value) { 
151          this.immediatePackaging = value;
152          return this;
153        }
154
155        protected void listChildren(List<Property> children) {
156          super.listChildren(children);
157          children.add(new Property("outerPackaging", "Identifier", "A number appearing on the outer packaging of a specific batch.", 0, 1, outerPackaging));
158          children.add(new Property("immediatePackaging", "Identifier", "A number appearing on the immediate packaging (and not the outer packaging).", 0, 1, immediatePackaging));
159        }
160
161        @Override
162        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
163          switch (_hash) {
164          case -682249912: /*outerPackaging*/  return new Property("outerPackaging", "Identifier", "A number appearing on the outer packaging of a specific batch.", 0, 1, outerPackaging);
165          case 721147602: /*immediatePackaging*/  return new Property("immediatePackaging", "Identifier", "A number appearing on the immediate packaging (and not the outer packaging).", 0, 1, immediatePackaging);
166          default: return super.getNamedProperty(_hash, _name, _checkValid);
167          }
168
169        }
170
171      @Override
172      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
173        switch (hash) {
174        case -682249912: /*outerPackaging*/ return this.outerPackaging == null ? new Base[0] : new Base[] {this.outerPackaging}; // Identifier
175        case 721147602: /*immediatePackaging*/ return this.immediatePackaging == null ? new Base[0] : new Base[] {this.immediatePackaging}; // Identifier
176        default: return super.getProperty(hash, name, checkValid);
177        }
178
179      }
180
181      @Override
182      public Base setProperty(int hash, String name, Base value) throws FHIRException {
183        switch (hash) {
184        case -682249912: // outerPackaging
185          this.outerPackaging = castToIdentifier(value); // Identifier
186          return value;
187        case 721147602: // immediatePackaging
188          this.immediatePackaging = castToIdentifier(value); // Identifier
189          return value;
190        default: return super.setProperty(hash, name, value);
191        }
192
193      }
194
195      @Override
196      public Base setProperty(String name, Base value) throws FHIRException {
197        if (name.equals("outerPackaging")) {
198          this.outerPackaging = castToIdentifier(value); // Identifier
199        } else if (name.equals("immediatePackaging")) {
200          this.immediatePackaging = castToIdentifier(value); // Identifier
201        } else
202          return super.setProperty(name, value);
203        return value;
204      }
205
206      @Override
207      public Base makeProperty(int hash, String name) throws FHIRException {
208        switch (hash) {
209        case -682249912:  return getOuterPackaging();
210        case 721147602:  return getImmediatePackaging();
211        default: return super.makeProperty(hash, name);
212        }
213
214      }
215
216      @Override
217      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
218        switch (hash) {
219        case -682249912: /*outerPackaging*/ return new String[] {"Identifier"};
220        case 721147602: /*immediatePackaging*/ return new String[] {"Identifier"};
221        default: return super.getTypesForProperty(hash, name);
222        }
223
224      }
225
226      @Override
227      public Base addChild(String name) throws FHIRException {
228        if (name.equals("outerPackaging")) {
229          this.outerPackaging = new Identifier();
230          return this.outerPackaging;
231        }
232        else if (name.equals("immediatePackaging")) {
233          this.immediatePackaging = new Identifier();
234          return this.immediatePackaging;
235        }
236        else
237          return super.addChild(name);
238      }
239
240      public PackagedProductDefinitionBatchIdentifierComponent copy() {
241        PackagedProductDefinitionBatchIdentifierComponent dst = new PackagedProductDefinitionBatchIdentifierComponent();
242        copyValues(dst);
243        return dst;
244      }
245
246      public void copyValues(PackagedProductDefinitionBatchIdentifierComponent dst) {
247        super.copyValues(dst);
248        dst.outerPackaging = outerPackaging == null ? null : outerPackaging.copy();
249        dst.immediatePackaging = immediatePackaging == null ? null : immediatePackaging.copy();
250      }
251
252      @Override
253      public boolean equalsDeep(Base other_) {
254        if (!super.equalsDeep(other_))
255          return false;
256        if (!(other_ instanceof PackagedProductDefinitionBatchIdentifierComponent))
257          return false;
258        PackagedProductDefinitionBatchIdentifierComponent o = (PackagedProductDefinitionBatchIdentifierComponent) other_;
259        return compareDeep(outerPackaging, o.outerPackaging, true) && compareDeep(immediatePackaging, o.immediatePackaging, true)
260          ;
261      }
262
263      @Override
264      public boolean equalsShallow(Base other_) {
265        if (!super.equalsShallow(other_))
266          return false;
267        if (!(other_ instanceof PackagedProductDefinitionBatchIdentifierComponent))
268          return false;
269        PackagedProductDefinitionBatchIdentifierComponent o = (PackagedProductDefinitionBatchIdentifierComponent) other_;
270        return true;
271      }
272
273      public boolean isEmpty() {
274        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(outerPackaging, immediatePackaging
275          );
276      }
277
278  public String fhirType() {
279    return "PackagedProductDefinition.batchIdentifier";
280
281  }
282
283  }
284
285    @Block()
286    public static class PackagedProductDefinitionPackageComponent extends BackboneElement implements IBaseBackboneElement {
287        /**
288         * Including possibly Data Carrier Identifier.
289         */
290        @Child(name = "identifier", type = {Identifier.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
291        @Description(shortDefinition="Including possibly Data Carrier Identifier", formalDefinition="Including possibly Data Carrier Identifier." )
292        protected List<Identifier> identifier;
293
294        /**
295         * The physical type of the container of the medicine.
296         */
297        @Child(name = "type", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
298        @Description(shortDefinition="The physical type of the container of the medicine", formalDefinition="The physical type of the container of the medicine." )
299        protected CodeableConcept type;
300
301        /**
302         * The quantity of this package in the medicinal product, at the current level of packaging. If specified, the outermost level is always 1.
303         */
304        @Child(name = "quantity", type = {Quantity.class}, order=3, min=0, max=1, modifier=false, summary=true)
305        @Description(shortDefinition="The quantity of this package in the medicinal product, at the current level of packaging. If specified, the outermost level is always 1", formalDefinition="The quantity of this package in the medicinal product, at the current level of packaging. If specified, the outermost level is always 1." )
306        protected Quantity quantity;
307
308        /**
309         * Material type of the package item.
310         */
311        @Child(name = "material", type = {CodeableConcept.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
312        @Description(shortDefinition="Material type of the package item", formalDefinition="Material type of the package item." )
313        protected List<CodeableConcept> material;
314
315        /**
316         * A possible alternate material for the packaging.
317         */
318        @Child(name = "alternateMaterial", type = {CodeableConcept.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
319        @Description(shortDefinition="A possible alternate material for the packaging", formalDefinition="A possible alternate material for the packaging." )
320        protected List<CodeableConcept> alternateMaterial;
321
322        /**
323         * Shelf Life and storage information.
324         */
325        @Child(name = "shelfLifeStorage", type = {ProductShelfLife.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
326        @Description(shortDefinition="Shelf Life and storage information", formalDefinition="Shelf Life and storage information." )
327        protected List<ProductShelfLife> shelfLifeStorage;
328
329        /**
330         * Manufacturer of this Package Item.
331         */
332        @Child(name = "manufacturer", type = {Organization.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
333        @Description(shortDefinition="Manufacturer of this Package Item", formalDefinition="Manufacturer of this Package Item." )
334        protected List<Reference> manufacturer;
335
336        /**
337         * General characteristics of this item.
338         */
339        @Child(name = "characteristic", type = {}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
340        @Description(shortDefinition="General characteristics of this item", formalDefinition="General characteristics of this item." )
341        protected List<PackagedProductDefinitionPackageCharacteristicComponent> characteristic;
342
343        /**
344         * The item(s) within the packaging).
345         */
346        @Child(name = "containedItem", type = {}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
347        @Description(shortDefinition="The item(s) within the packaging)", formalDefinition="The item(s) within the packaging)." )
348        protected List<PackagedProductDefinitionPackageContainedItemComponent> containedItem;
349
350        /**
351         * Allows containers within containers.
352         */
353        @Child(name = "package", type = {PackagedProductDefinitionPackageComponent.class}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
354        @Description(shortDefinition="Allows containers within containers", formalDefinition="Allows containers within containers." )
355        protected List<PackagedProductDefinitionPackageComponent> package_;
356
357        private static final long serialVersionUID = 8053245L;
358
359    /**
360     * Constructor
361     */
362      public PackagedProductDefinitionPackageComponent() {
363        super();
364      }
365
366        /**
367         * @return {@link #identifier} (Including possibly Data Carrier Identifier.)
368         */
369        public List<Identifier> getIdentifier() { 
370          if (this.identifier == null)
371            this.identifier = new ArrayList<Identifier>();
372          return this.identifier;
373        }
374
375        /**
376         * @return Returns a reference to <code>this</code> for easy method chaining
377         */
378        public PackagedProductDefinitionPackageComponent setIdentifier(List<Identifier> theIdentifier) { 
379          this.identifier = theIdentifier;
380          return this;
381        }
382
383        public boolean hasIdentifier() { 
384          if (this.identifier == null)
385            return false;
386          for (Identifier item : this.identifier)
387            if (!item.isEmpty())
388              return true;
389          return false;
390        }
391
392        public Identifier addIdentifier() { //3
393          Identifier t = new Identifier();
394          if (this.identifier == null)
395            this.identifier = new ArrayList<Identifier>();
396          this.identifier.add(t);
397          return t;
398        }
399
400        public PackagedProductDefinitionPackageComponent addIdentifier(Identifier t) { //3
401          if (t == null)
402            return this;
403          if (this.identifier == null)
404            this.identifier = new ArrayList<Identifier>();
405          this.identifier.add(t);
406          return this;
407        }
408
409        /**
410         * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
411         */
412        public Identifier getIdentifierFirstRep() { 
413          if (getIdentifier().isEmpty()) {
414            addIdentifier();
415          }
416          return getIdentifier().get(0);
417        }
418
419        /**
420         * @return {@link #type} (The physical type of the container of the medicine.)
421         */
422        public CodeableConcept getType() { 
423          if (this.type == null)
424            if (Configuration.errorOnAutoCreate())
425              throw new Error("Attempt to auto-create PackagedProductDefinitionPackageComponent.type");
426            else if (Configuration.doAutoCreate())
427              this.type = new CodeableConcept(); // cc
428          return this.type;
429        }
430
431        public boolean hasType() { 
432          return this.type != null && !this.type.isEmpty();
433        }
434
435        /**
436         * @param value {@link #type} (The physical type of the container of the medicine.)
437         */
438        public PackagedProductDefinitionPackageComponent setType(CodeableConcept value) { 
439          this.type = value;
440          return this;
441        }
442
443        /**
444         * @return {@link #quantity} (The quantity of this package in the medicinal product, at the current level of packaging. If specified, the outermost level is always 1.)
445         */
446        public Quantity getQuantity() { 
447          if (this.quantity == null)
448            if (Configuration.errorOnAutoCreate())
449              throw new Error("Attempt to auto-create PackagedProductDefinitionPackageComponent.quantity");
450            else if (Configuration.doAutoCreate())
451              this.quantity = new Quantity(); // cc
452          return this.quantity;
453        }
454
455        public boolean hasQuantity() { 
456          return this.quantity != null && !this.quantity.isEmpty();
457        }
458
459        /**
460         * @param value {@link #quantity} (The quantity of this package in the medicinal product, at the current level of packaging. If specified, the outermost level is always 1.)
461         */
462        public PackagedProductDefinitionPackageComponent setQuantity(Quantity value) { 
463          this.quantity = value;
464          return this;
465        }
466
467        /**
468         * @return {@link #material} (Material type of the package item.)
469         */
470        public List<CodeableConcept> getMaterial() { 
471          if (this.material == null)
472            this.material = new ArrayList<CodeableConcept>();
473          return this.material;
474        }
475
476        /**
477         * @return Returns a reference to <code>this</code> for easy method chaining
478         */
479        public PackagedProductDefinitionPackageComponent setMaterial(List<CodeableConcept> theMaterial) { 
480          this.material = theMaterial;
481          return this;
482        }
483
484        public boolean hasMaterial() { 
485          if (this.material == null)
486            return false;
487          for (CodeableConcept item : this.material)
488            if (!item.isEmpty())
489              return true;
490          return false;
491        }
492
493        public CodeableConcept addMaterial() { //3
494          CodeableConcept t = new CodeableConcept();
495          if (this.material == null)
496            this.material = new ArrayList<CodeableConcept>();
497          this.material.add(t);
498          return t;
499        }
500
501        public PackagedProductDefinitionPackageComponent addMaterial(CodeableConcept t) { //3
502          if (t == null)
503            return this;
504          if (this.material == null)
505            this.material = new ArrayList<CodeableConcept>();
506          this.material.add(t);
507          return this;
508        }
509
510        /**
511         * @return The first repetition of repeating field {@link #material}, creating it if it does not already exist
512         */
513        public CodeableConcept getMaterialFirstRep() { 
514          if (getMaterial().isEmpty()) {
515            addMaterial();
516          }
517          return getMaterial().get(0);
518        }
519
520        /**
521         * @return {@link #alternateMaterial} (A possible alternate material for the packaging.)
522         */
523        public List<CodeableConcept> getAlternateMaterial() { 
524          if (this.alternateMaterial == null)
525            this.alternateMaterial = new ArrayList<CodeableConcept>();
526          return this.alternateMaterial;
527        }
528
529        /**
530         * @return Returns a reference to <code>this</code> for easy method chaining
531         */
532        public PackagedProductDefinitionPackageComponent setAlternateMaterial(List<CodeableConcept> theAlternateMaterial) { 
533          this.alternateMaterial = theAlternateMaterial;
534          return this;
535        }
536
537        public boolean hasAlternateMaterial() { 
538          if (this.alternateMaterial == null)
539            return false;
540          for (CodeableConcept item : this.alternateMaterial)
541            if (!item.isEmpty())
542              return true;
543          return false;
544        }
545
546        public CodeableConcept addAlternateMaterial() { //3
547          CodeableConcept t = new CodeableConcept();
548          if (this.alternateMaterial == null)
549            this.alternateMaterial = new ArrayList<CodeableConcept>();
550          this.alternateMaterial.add(t);
551          return t;
552        }
553
554        public PackagedProductDefinitionPackageComponent addAlternateMaterial(CodeableConcept t) { //3
555          if (t == null)
556            return this;
557          if (this.alternateMaterial == null)
558            this.alternateMaterial = new ArrayList<CodeableConcept>();
559          this.alternateMaterial.add(t);
560          return this;
561        }
562
563        /**
564         * @return The first repetition of repeating field {@link #alternateMaterial}, creating it if it does not already exist
565         */
566        public CodeableConcept getAlternateMaterialFirstRep() { 
567          if (getAlternateMaterial().isEmpty()) {
568            addAlternateMaterial();
569          }
570          return getAlternateMaterial().get(0);
571        }
572
573        /**
574         * @return {@link #shelfLifeStorage} (Shelf Life and storage information.)
575         */
576        public List<ProductShelfLife> getShelfLifeStorage() { 
577          if (this.shelfLifeStorage == null)
578            this.shelfLifeStorage = new ArrayList<ProductShelfLife>();
579          return this.shelfLifeStorage;
580        }
581
582        /**
583         * @return Returns a reference to <code>this</code> for easy method chaining
584         */
585        public PackagedProductDefinitionPackageComponent setShelfLifeStorage(List<ProductShelfLife> theShelfLifeStorage) { 
586          this.shelfLifeStorage = theShelfLifeStorage;
587          return this;
588        }
589
590        public boolean hasShelfLifeStorage() { 
591          if (this.shelfLifeStorage == null)
592            return false;
593          for (ProductShelfLife item : this.shelfLifeStorage)
594            if (!item.isEmpty())
595              return true;
596          return false;
597        }
598
599        public ProductShelfLife addShelfLifeStorage() { //3
600          ProductShelfLife t = new ProductShelfLife();
601          if (this.shelfLifeStorage == null)
602            this.shelfLifeStorage = new ArrayList<ProductShelfLife>();
603          this.shelfLifeStorage.add(t);
604          return t;
605        }
606
607        public PackagedProductDefinitionPackageComponent addShelfLifeStorage(ProductShelfLife t) { //3
608          if (t == null)
609            return this;
610          if (this.shelfLifeStorage == null)
611            this.shelfLifeStorage = new ArrayList<ProductShelfLife>();
612          this.shelfLifeStorage.add(t);
613          return this;
614        }
615
616        /**
617         * @return The first repetition of repeating field {@link #shelfLifeStorage}, creating it if it does not already exist
618         */
619        public ProductShelfLife getShelfLifeStorageFirstRep() { 
620          if (getShelfLifeStorage().isEmpty()) {
621            addShelfLifeStorage();
622          }
623          return getShelfLifeStorage().get(0);
624        }
625
626        /**
627         * @return {@link #manufacturer} (Manufacturer of this Package Item.)
628         */
629        public List<Reference> getManufacturer() { 
630          if (this.manufacturer == null)
631            this.manufacturer = new ArrayList<Reference>();
632          return this.manufacturer;
633        }
634
635        /**
636         * @return Returns a reference to <code>this</code> for easy method chaining
637         */
638        public PackagedProductDefinitionPackageComponent setManufacturer(List<Reference> theManufacturer) { 
639          this.manufacturer = theManufacturer;
640          return this;
641        }
642
643        public boolean hasManufacturer() { 
644          if (this.manufacturer == null)
645            return false;
646          for (Reference item : this.manufacturer)
647            if (!item.isEmpty())
648              return true;
649          return false;
650        }
651
652        public Reference addManufacturer() { //3
653          Reference t = new Reference();
654          if (this.manufacturer == null)
655            this.manufacturer = new ArrayList<Reference>();
656          this.manufacturer.add(t);
657          return t;
658        }
659
660        public PackagedProductDefinitionPackageComponent addManufacturer(Reference t) { //3
661          if (t == null)
662            return this;
663          if (this.manufacturer == null)
664            this.manufacturer = new ArrayList<Reference>();
665          this.manufacturer.add(t);
666          return this;
667        }
668
669        /**
670         * @return The first repetition of repeating field {@link #manufacturer}, creating it if it does not already exist
671         */
672        public Reference getManufacturerFirstRep() { 
673          if (getManufacturer().isEmpty()) {
674            addManufacturer();
675          }
676          return getManufacturer().get(0);
677        }
678
679        /**
680         * @return {@link #characteristic} (General characteristics of this item.)
681         */
682        public List<PackagedProductDefinitionPackageCharacteristicComponent> getCharacteristic() { 
683          if (this.characteristic == null)
684            this.characteristic = new ArrayList<PackagedProductDefinitionPackageCharacteristicComponent>();
685          return this.characteristic;
686        }
687
688        /**
689         * @return Returns a reference to <code>this</code> for easy method chaining
690         */
691        public PackagedProductDefinitionPackageComponent setCharacteristic(List<PackagedProductDefinitionPackageCharacteristicComponent> theCharacteristic) { 
692          this.characteristic = theCharacteristic;
693          return this;
694        }
695
696        public boolean hasCharacteristic() { 
697          if (this.characteristic == null)
698            return false;
699          for (PackagedProductDefinitionPackageCharacteristicComponent item : this.characteristic)
700            if (!item.isEmpty())
701              return true;
702          return false;
703        }
704
705        public PackagedProductDefinitionPackageCharacteristicComponent addCharacteristic() { //3
706          PackagedProductDefinitionPackageCharacteristicComponent t = new PackagedProductDefinitionPackageCharacteristicComponent();
707          if (this.characteristic == null)
708            this.characteristic = new ArrayList<PackagedProductDefinitionPackageCharacteristicComponent>();
709          this.characteristic.add(t);
710          return t;
711        }
712
713        public PackagedProductDefinitionPackageComponent addCharacteristic(PackagedProductDefinitionPackageCharacteristicComponent t) { //3
714          if (t == null)
715            return this;
716          if (this.characteristic == null)
717            this.characteristic = new ArrayList<PackagedProductDefinitionPackageCharacteristicComponent>();
718          this.characteristic.add(t);
719          return this;
720        }
721
722        /**
723         * @return The first repetition of repeating field {@link #characteristic}, creating it if it does not already exist
724         */
725        public PackagedProductDefinitionPackageCharacteristicComponent getCharacteristicFirstRep() { 
726          if (getCharacteristic().isEmpty()) {
727            addCharacteristic();
728          }
729          return getCharacteristic().get(0);
730        }
731
732        /**
733         * @return {@link #containedItem} (The item(s) within the packaging).)
734         */
735        public List<PackagedProductDefinitionPackageContainedItemComponent> getContainedItem() { 
736          if (this.containedItem == null)
737            this.containedItem = new ArrayList<PackagedProductDefinitionPackageContainedItemComponent>();
738          return this.containedItem;
739        }
740
741        /**
742         * @return Returns a reference to <code>this</code> for easy method chaining
743         */
744        public PackagedProductDefinitionPackageComponent setContainedItem(List<PackagedProductDefinitionPackageContainedItemComponent> theContainedItem) { 
745          this.containedItem = theContainedItem;
746          return this;
747        }
748
749        public boolean hasContainedItem() { 
750          if (this.containedItem == null)
751            return false;
752          for (PackagedProductDefinitionPackageContainedItemComponent item : this.containedItem)
753            if (!item.isEmpty())
754              return true;
755          return false;
756        }
757
758        public PackagedProductDefinitionPackageContainedItemComponent addContainedItem() { //3
759          PackagedProductDefinitionPackageContainedItemComponent t = new PackagedProductDefinitionPackageContainedItemComponent();
760          if (this.containedItem == null)
761            this.containedItem = new ArrayList<PackagedProductDefinitionPackageContainedItemComponent>();
762          this.containedItem.add(t);
763          return t;
764        }
765
766        public PackagedProductDefinitionPackageComponent addContainedItem(PackagedProductDefinitionPackageContainedItemComponent t) { //3
767          if (t == null)
768            return this;
769          if (this.containedItem == null)
770            this.containedItem = new ArrayList<PackagedProductDefinitionPackageContainedItemComponent>();
771          this.containedItem.add(t);
772          return this;
773        }
774
775        /**
776         * @return The first repetition of repeating field {@link #containedItem}, creating it if it does not already exist
777         */
778        public PackagedProductDefinitionPackageContainedItemComponent getContainedItemFirstRep() { 
779          if (getContainedItem().isEmpty()) {
780            addContainedItem();
781          }
782          return getContainedItem().get(0);
783        }
784
785        /**
786         * @return {@link #package_} (Allows containers within containers.)
787         */
788        public List<PackagedProductDefinitionPackageComponent> getPackage() { 
789          if (this.package_ == null)
790            this.package_ = new ArrayList<PackagedProductDefinitionPackageComponent>();
791          return this.package_;
792        }
793
794        /**
795         * @return Returns a reference to <code>this</code> for easy method chaining
796         */
797        public PackagedProductDefinitionPackageComponent setPackage(List<PackagedProductDefinitionPackageComponent> thePackage) { 
798          this.package_ = thePackage;
799          return this;
800        }
801
802        public boolean hasPackage() { 
803          if (this.package_ == null)
804            return false;
805          for (PackagedProductDefinitionPackageComponent item : this.package_)
806            if (!item.isEmpty())
807              return true;
808          return false;
809        }
810
811        public PackagedProductDefinitionPackageComponent addPackage() { //3
812          PackagedProductDefinitionPackageComponent t = new PackagedProductDefinitionPackageComponent();
813          if (this.package_ == null)
814            this.package_ = new ArrayList<PackagedProductDefinitionPackageComponent>();
815          this.package_.add(t);
816          return t;
817        }
818
819        public PackagedProductDefinitionPackageComponent addPackage(PackagedProductDefinitionPackageComponent t) { //3
820          if (t == null)
821            return this;
822          if (this.package_ == null)
823            this.package_ = new ArrayList<PackagedProductDefinitionPackageComponent>();
824          this.package_.add(t);
825          return this;
826        }
827
828        /**
829         * @return The first repetition of repeating field {@link #package_}, creating it if it does not already exist
830         */
831        public PackagedProductDefinitionPackageComponent getPackageFirstRep() { 
832          if (getPackage().isEmpty()) {
833            addPackage();
834          }
835          return getPackage().get(0);
836        }
837
838        protected void listChildren(List<Property> children) {
839          super.listChildren(children);
840          children.add(new Property("identifier", "Identifier", "Including possibly Data Carrier Identifier.", 0, java.lang.Integer.MAX_VALUE, identifier));
841          children.add(new Property("type", "CodeableConcept", "The physical type of the container of the medicine.", 0, 1, type));
842          children.add(new Property("quantity", "Quantity", "The quantity of this package in the medicinal product, at the current level of packaging. If specified, the outermost level is always 1.", 0, 1, quantity));
843          children.add(new Property("material", "CodeableConcept", "Material type of the package item.", 0, java.lang.Integer.MAX_VALUE, material));
844          children.add(new Property("alternateMaterial", "CodeableConcept", "A possible alternate material for the packaging.", 0, java.lang.Integer.MAX_VALUE, alternateMaterial));
845          children.add(new Property("shelfLifeStorage", "ProductShelfLife", "Shelf Life and storage information.", 0, java.lang.Integer.MAX_VALUE, shelfLifeStorage));
846          children.add(new Property("manufacturer", "Reference(Organization)", "Manufacturer of this Package Item.", 0, java.lang.Integer.MAX_VALUE, manufacturer));
847          children.add(new Property("characteristic", "", "General characteristics of this item.", 0, java.lang.Integer.MAX_VALUE, characteristic));
848          children.add(new Property("containedItem", "", "The item(s) within the packaging).", 0, java.lang.Integer.MAX_VALUE, containedItem));
849          children.add(new Property("package", "@PackagedProductDefinition.package", "Allows containers within containers.", 0, java.lang.Integer.MAX_VALUE, package_));
850        }
851
852        @Override
853        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
854          switch (_hash) {
855          case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Including possibly Data Carrier Identifier.", 0, java.lang.Integer.MAX_VALUE, identifier);
856          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "The physical type of the container of the medicine.", 0, 1, type);
857          case -1285004149: /*quantity*/  return new Property("quantity", "Quantity", "The quantity of this package in the medicinal product, at the current level of packaging. If specified, the outermost level is always 1.", 0, 1, quantity);
858          case 299066663: /*material*/  return new Property("material", "CodeableConcept", "Material type of the package item.", 0, java.lang.Integer.MAX_VALUE, material);
859          case -1021448255: /*alternateMaterial*/  return new Property("alternateMaterial", "CodeableConcept", "A possible alternate material for the packaging.", 0, java.lang.Integer.MAX_VALUE, alternateMaterial);
860          case 172049237: /*shelfLifeStorage*/  return new Property("shelfLifeStorage", "ProductShelfLife", "Shelf Life and storage information.", 0, java.lang.Integer.MAX_VALUE, shelfLifeStorage);
861          case -1969347631: /*manufacturer*/  return new Property("manufacturer", "Reference(Organization)", "Manufacturer of this Package Item.", 0, java.lang.Integer.MAX_VALUE, manufacturer);
862          case 366313883: /*characteristic*/  return new Property("characteristic", "", "General characteristics of this item.", 0, java.lang.Integer.MAX_VALUE, characteristic);
863          case 1953679910: /*containedItem*/  return new Property("containedItem", "", "The item(s) within the packaging).", 0, java.lang.Integer.MAX_VALUE, containedItem);
864          case -807062458: /*package*/  return new Property("package", "@PackagedProductDefinition.package", "Allows containers within containers.", 0, java.lang.Integer.MAX_VALUE, package_);
865          default: return super.getNamedProperty(_hash, _name, _checkValid);
866          }
867
868        }
869
870      @Override
871      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
872        switch (hash) {
873        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
874        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
875        case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // Quantity
876        case 299066663: /*material*/ return this.material == null ? new Base[0] : this.material.toArray(new Base[this.material.size()]); // CodeableConcept
877        case -1021448255: /*alternateMaterial*/ return this.alternateMaterial == null ? new Base[0] : this.alternateMaterial.toArray(new Base[this.alternateMaterial.size()]); // CodeableConcept
878        case 172049237: /*shelfLifeStorage*/ return this.shelfLifeStorage == null ? new Base[0] : this.shelfLifeStorage.toArray(new Base[this.shelfLifeStorage.size()]); // ProductShelfLife
879        case -1969347631: /*manufacturer*/ return this.manufacturer == null ? new Base[0] : this.manufacturer.toArray(new Base[this.manufacturer.size()]); // Reference
880        case 366313883: /*characteristic*/ return this.characteristic == null ? new Base[0] : this.characteristic.toArray(new Base[this.characteristic.size()]); // PackagedProductDefinitionPackageCharacteristicComponent
881        case 1953679910: /*containedItem*/ return this.containedItem == null ? new Base[0] : this.containedItem.toArray(new Base[this.containedItem.size()]); // PackagedProductDefinitionPackageContainedItemComponent
882        case -807062458: /*package*/ return this.package_ == null ? new Base[0] : this.package_.toArray(new Base[this.package_.size()]); // PackagedProductDefinitionPackageComponent
883        default: return super.getProperty(hash, name, checkValid);
884        }
885
886      }
887
888      @Override
889      public Base setProperty(int hash, String name, Base value) throws FHIRException {
890        switch (hash) {
891        case -1618432855: // identifier
892          this.getIdentifier().add(castToIdentifier(value)); // Identifier
893          return value;
894        case 3575610: // type
895          this.type = castToCodeableConcept(value); // CodeableConcept
896          return value;
897        case -1285004149: // quantity
898          this.quantity = castToQuantity(value); // Quantity
899          return value;
900        case 299066663: // material
901          this.getMaterial().add(castToCodeableConcept(value)); // CodeableConcept
902          return value;
903        case -1021448255: // alternateMaterial
904          this.getAlternateMaterial().add(castToCodeableConcept(value)); // CodeableConcept
905          return value;
906        case 172049237: // shelfLifeStorage
907          this.getShelfLifeStorage().add(castToProductShelfLife(value)); // ProductShelfLife
908          return value;
909        case -1969347631: // manufacturer
910          this.getManufacturer().add(castToReference(value)); // Reference
911          return value;
912        case 366313883: // characteristic
913          this.getCharacteristic().add((PackagedProductDefinitionPackageCharacteristicComponent) value); // PackagedProductDefinitionPackageCharacteristicComponent
914          return value;
915        case 1953679910: // containedItem
916          this.getContainedItem().add((PackagedProductDefinitionPackageContainedItemComponent) value); // PackagedProductDefinitionPackageContainedItemComponent
917          return value;
918        case -807062458: // package
919          this.getPackage().add((PackagedProductDefinitionPackageComponent) value); // PackagedProductDefinitionPackageComponent
920          return value;
921        default: return super.setProperty(hash, name, value);
922        }
923
924      }
925
926      @Override
927      public Base setProperty(String name, Base value) throws FHIRException {
928        if (name.equals("identifier")) {
929          this.getIdentifier().add(castToIdentifier(value));
930        } else if (name.equals("type")) {
931          this.type = castToCodeableConcept(value); // CodeableConcept
932        } else if (name.equals("quantity")) {
933          this.quantity = castToQuantity(value); // Quantity
934        } else if (name.equals("material")) {
935          this.getMaterial().add(castToCodeableConcept(value));
936        } else if (name.equals("alternateMaterial")) {
937          this.getAlternateMaterial().add(castToCodeableConcept(value));
938        } else if (name.equals("shelfLifeStorage")) {
939          this.getShelfLifeStorage().add(castToProductShelfLife(value));
940        } else if (name.equals("manufacturer")) {
941          this.getManufacturer().add(castToReference(value));
942        } else if (name.equals("characteristic")) {
943          this.getCharacteristic().add((PackagedProductDefinitionPackageCharacteristicComponent) value);
944        } else if (name.equals("containedItem")) {
945          this.getContainedItem().add((PackagedProductDefinitionPackageContainedItemComponent) value);
946        } else if (name.equals("package")) {
947          this.getPackage().add((PackagedProductDefinitionPackageComponent) value);
948        } else
949          return super.setProperty(name, value);
950        return value;
951      }
952
953      @Override
954      public Base makeProperty(int hash, String name) throws FHIRException {
955        switch (hash) {
956        case -1618432855:  return addIdentifier(); 
957        case 3575610:  return getType();
958        case -1285004149:  return getQuantity();
959        case 299066663:  return addMaterial(); 
960        case -1021448255:  return addAlternateMaterial(); 
961        case 172049237:  return addShelfLifeStorage(); 
962        case -1969347631:  return addManufacturer(); 
963        case 366313883:  return addCharacteristic(); 
964        case 1953679910:  return addContainedItem(); 
965        case -807062458:  return addPackage(); 
966        default: return super.makeProperty(hash, name);
967        }
968
969      }
970
971      @Override
972      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
973        switch (hash) {
974        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
975        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
976        case -1285004149: /*quantity*/ return new String[] {"Quantity"};
977        case 299066663: /*material*/ return new String[] {"CodeableConcept"};
978        case -1021448255: /*alternateMaterial*/ return new String[] {"CodeableConcept"};
979        case 172049237: /*shelfLifeStorage*/ return new String[] {"ProductShelfLife"};
980        case -1969347631: /*manufacturer*/ return new String[] {"Reference"};
981        case 366313883: /*characteristic*/ return new String[] {};
982        case 1953679910: /*containedItem*/ return new String[] {};
983        case -807062458: /*package*/ return new String[] {"@PackagedProductDefinition.package"};
984        default: return super.getTypesForProperty(hash, name);
985        }
986
987      }
988
989      @Override
990      public Base addChild(String name) throws FHIRException {
991        if (name.equals("identifier")) {
992          return addIdentifier();
993        }
994        else if (name.equals("type")) {
995          this.type = new CodeableConcept();
996          return this.type;
997        }
998        else if (name.equals("quantity")) {
999          this.quantity = new Quantity();
1000          return this.quantity;
1001        }
1002        else if (name.equals("material")) {
1003          return addMaterial();
1004        }
1005        else if (name.equals("alternateMaterial")) {
1006          return addAlternateMaterial();
1007        }
1008        else if (name.equals("shelfLifeStorage")) {
1009          return addShelfLifeStorage();
1010        }
1011        else if (name.equals("manufacturer")) {
1012          return addManufacturer();
1013        }
1014        else if (name.equals("characteristic")) {
1015          return addCharacteristic();
1016        }
1017        else if (name.equals("containedItem")) {
1018          return addContainedItem();
1019        }
1020        else if (name.equals("package")) {
1021          return addPackage();
1022        }
1023        else
1024          return super.addChild(name);
1025      }
1026
1027      public PackagedProductDefinitionPackageComponent copy() {
1028        PackagedProductDefinitionPackageComponent dst = new PackagedProductDefinitionPackageComponent();
1029        copyValues(dst);
1030        return dst;
1031      }
1032
1033      public void copyValues(PackagedProductDefinitionPackageComponent dst) {
1034        super.copyValues(dst);
1035        if (identifier != null) {
1036          dst.identifier = new ArrayList<Identifier>();
1037          for (Identifier i : identifier)
1038            dst.identifier.add(i.copy());
1039        };
1040        dst.type = type == null ? null : type.copy();
1041        dst.quantity = quantity == null ? null : quantity.copy();
1042        if (material != null) {
1043          dst.material = new ArrayList<CodeableConcept>();
1044          for (CodeableConcept i : material)
1045            dst.material.add(i.copy());
1046        };
1047        if (alternateMaterial != null) {
1048          dst.alternateMaterial = new ArrayList<CodeableConcept>();
1049          for (CodeableConcept i : alternateMaterial)
1050            dst.alternateMaterial.add(i.copy());
1051        };
1052        if (shelfLifeStorage != null) {
1053          dst.shelfLifeStorage = new ArrayList<ProductShelfLife>();
1054          for (ProductShelfLife i : shelfLifeStorage)
1055            dst.shelfLifeStorage.add(i.copy());
1056        };
1057        if (manufacturer != null) {
1058          dst.manufacturer = new ArrayList<Reference>();
1059          for (Reference i : manufacturer)
1060            dst.manufacturer.add(i.copy());
1061        };
1062        if (characteristic != null) {
1063          dst.characteristic = new ArrayList<PackagedProductDefinitionPackageCharacteristicComponent>();
1064          for (PackagedProductDefinitionPackageCharacteristicComponent i : characteristic)
1065            dst.characteristic.add(i.copy());
1066        };
1067        if (containedItem != null) {
1068          dst.containedItem = new ArrayList<PackagedProductDefinitionPackageContainedItemComponent>();
1069          for (PackagedProductDefinitionPackageContainedItemComponent i : containedItem)
1070            dst.containedItem.add(i.copy());
1071        };
1072        if (package_ != null) {
1073          dst.package_ = new ArrayList<PackagedProductDefinitionPackageComponent>();
1074          for (PackagedProductDefinitionPackageComponent i : package_)
1075            dst.package_.add(i.copy());
1076        };
1077      }
1078
1079      @Override
1080      public boolean equalsDeep(Base other_) {
1081        if (!super.equalsDeep(other_))
1082          return false;
1083        if (!(other_ instanceof PackagedProductDefinitionPackageComponent))
1084          return false;
1085        PackagedProductDefinitionPackageComponent o = (PackagedProductDefinitionPackageComponent) other_;
1086        return compareDeep(identifier, o.identifier, true) && compareDeep(type, o.type, true) && compareDeep(quantity, o.quantity, true)
1087           && compareDeep(material, o.material, true) && compareDeep(alternateMaterial, o.alternateMaterial, true)
1088           && compareDeep(shelfLifeStorage, o.shelfLifeStorage, true) && compareDeep(manufacturer, o.manufacturer, true)
1089           && compareDeep(characteristic, o.characteristic, true) && compareDeep(containedItem, o.containedItem, true)
1090           && compareDeep(package_, o.package_, true);
1091      }
1092
1093      @Override
1094      public boolean equalsShallow(Base other_) {
1095        if (!super.equalsShallow(other_))
1096          return false;
1097        if (!(other_ instanceof PackagedProductDefinitionPackageComponent))
1098          return false;
1099        PackagedProductDefinitionPackageComponent o = (PackagedProductDefinitionPackageComponent) other_;
1100        return true;
1101      }
1102
1103      public boolean isEmpty() {
1104        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, type, quantity
1105          , material, alternateMaterial, shelfLifeStorage, manufacturer, characteristic, containedItem
1106          , package_);
1107      }
1108
1109  public String fhirType() {
1110    return "PackagedProductDefinition.package";
1111
1112  }
1113
1114  }
1115
1116    @Block()
1117    public static class PackagedProductDefinitionPackageCharacteristicComponent extends BackboneElement implements IBaseBackboneElement {
1118        /**
1119         * A code expressing the type of characteristic.
1120         */
1121        @Child(name = "code", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=true)
1122        @Description(shortDefinition="A code expressing the type of characteristic", formalDefinition="A code expressing the type of characteristic." )
1123        protected CodeableConcept code;
1124
1125        /**
1126         * A value for the characteristic.
1127         */
1128        @Child(name = "value", type = {Coding.class, Quantity.class, StringType.class, DateType.class, BooleanType.class, Attachment.class}, order=2, min=0, max=1, modifier=false, summary=true)
1129        @Description(shortDefinition="A value for the characteristic", formalDefinition="A value for the characteristic." )
1130        protected Type value;
1131
1132        private static final long serialVersionUID = 884525025L;
1133
1134    /**
1135     * Constructor
1136     */
1137      public PackagedProductDefinitionPackageCharacteristicComponent() {
1138        super();
1139      }
1140
1141    /**
1142     * Constructor
1143     */
1144      public PackagedProductDefinitionPackageCharacteristicComponent(CodeableConcept code) {
1145        super();
1146        this.code = code;
1147      }
1148
1149        /**
1150         * @return {@link #code} (A code expressing the type of characteristic.)
1151         */
1152        public CodeableConcept getCode() { 
1153          if (this.code == null)
1154            if (Configuration.errorOnAutoCreate())
1155              throw new Error("Attempt to auto-create PackagedProductDefinitionPackageCharacteristicComponent.code");
1156            else if (Configuration.doAutoCreate())
1157              this.code = new CodeableConcept(); // cc
1158          return this.code;
1159        }
1160
1161        public boolean hasCode() { 
1162          return this.code != null && !this.code.isEmpty();
1163        }
1164
1165        /**
1166         * @param value {@link #code} (A code expressing the type of characteristic.)
1167         */
1168        public PackagedProductDefinitionPackageCharacteristicComponent setCode(CodeableConcept value) { 
1169          this.code = value;
1170          return this;
1171        }
1172
1173        /**
1174         * @return {@link #value} (A value for the characteristic.)
1175         */
1176        public Type getValue() { 
1177          return this.value;
1178        }
1179
1180        /**
1181         * @return {@link #value} (A value for the characteristic.)
1182         */
1183        public Coding getValueCoding() throws FHIRException { 
1184          if (this.value == null)
1185            this.value = new Coding();
1186          if (!(this.value instanceof Coding))
1187            throw new FHIRException("Type mismatch: the type Coding was expected, but "+this.value.getClass().getName()+" was encountered");
1188          return (Coding) this.value;
1189        }
1190
1191        public boolean hasValueCoding() { 
1192          return this != null && this.value instanceof Coding;
1193        }
1194
1195        /**
1196         * @return {@link #value} (A value for the characteristic.)
1197         */
1198        public Quantity getValueQuantity() throws FHIRException { 
1199          if (this.value == null)
1200            this.value = new Quantity();
1201          if (!(this.value instanceof Quantity))
1202            throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.value.getClass().getName()+" was encountered");
1203          return (Quantity) this.value;
1204        }
1205
1206        public boolean hasValueQuantity() { 
1207          return this != null && this.value instanceof Quantity;
1208        }
1209
1210        /**
1211         * @return {@link #value} (A value for the characteristic.)
1212         */
1213        public StringType getValueStringType() throws FHIRException { 
1214          if (this.value == null)
1215            this.value = new StringType();
1216          if (!(this.value instanceof StringType))
1217            throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.value.getClass().getName()+" was encountered");
1218          return (StringType) this.value;
1219        }
1220
1221        public boolean hasValueStringType() { 
1222          return this != null && this.value instanceof StringType;
1223        }
1224
1225        /**
1226         * @return {@link #value} (A value for the characteristic.)
1227         */
1228        public DateType getValueDateType() throws FHIRException { 
1229          if (this.value == null)
1230            this.value = new DateType();
1231          if (!(this.value instanceof DateType))
1232            throw new FHIRException("Type mismatch: the type DateType was expected, but "+this.value.getClass().getName()+" was encountered");
1233          return (DateType) this.value;
1234        }
1235
1236        public boolean hasValueDateType() { 
1237          return this != null && this.value instanceof DateType;
1238        }
1239
1240        /**
1241         * @return {@link #value} (A value for the characteristic.)
1242         */
1243        public BooleanType getValueBooleanType() throws FHIRException { 
1244          if (this.value == null)
1245            this.value = new BooleanType();
1246          if (!(this.value instanceof BooleanType))
1247            throw new FHIRException("Type mismatch: the type BooleanType was expected, but "+this.value.getClass().getName()+" was encountered");
1248          return (BooleanType) this.value;
1249        }
1250
1251        public boolean hasValueBooleanType() { 
1252          return this != null && this.value instanceof BooleanType;
1253        }
1254
1255        /**
1256         * @return {@link #value} (A value for the characteristic.)
1257         */
1258        public Attachment getValueAttachment() throws FHIRException { 
1259          if (this.value == null)
1260            this.value = new Attachment();
1261          if (!(this.value instanceof Attachment))
1262            throw new FHIRException("Type mismatch: the type Attachment was expected, but "+this.value.getClass().getName()+" was encountered");
1263          return (Attachment) this.value;
1264        }
1265
1266        public boolean hasValueAttachment() { 
1267          return this != null && this.value instanceof Attachment;
1268        }
1269
1270        public boolean hasValue() { 
1271          return this.value != null && !this.value.isEmpty();
1272        }
1273
1274        /**
1275         * @param value {@link #value} (A value for the characteristic.)
1276         */
1277        public PackagedProductDefinitionPackageCharacteristicComponent setValue(Type value) { 
1278          if (value != null && !(value instanceof Coding || value instanceof Quantity || value instanceof StringType || value instanceof DateType || value instanceof BooleanType || value instanceof Attachment))
1279            throw new Error("Not the right type for PackagedProductDefinition.package.characteristic.value[x]: "+value.fhirType());
1280          this.value = value;
1281          return this;
1282        }
1283
1284        protected void listChildren(List<Property> children) {
1285          super.listChildren(children);
1286          children.add(new Property("code", "CodeableConcept", "A code expressing the type of characteristic.", 0, 1, code));
1287          children.add(new Property("value[x]", "Coding|Quantity|string|date|boolean|Attachment", "A value for the characteristic.", 0, 1, value));
1288        }
1289
1290        @Override
1291        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1292          switch (_hash) {
1293          case 3059181: /*code*/  return new Property("code", "CodeableConcept", "A code expressing the type of characteristic.", 0, 1, code);
1294          case -1410166417: /*value[x]*/  return new Property("value[x]", "Coding|Quantity|string|date|boolean|Attachment", "A value for the characteristic.", 0, 1, value);
1295          case 111972721: /*value*/  return new Property("value[x]", "Coding|Quantity|string|date|boolean|Attachment", "A value for the characteristic.", 0, 1, value);
1296          case -1887705029: /*valueCoding*/  return new Property("value[x]", "Coding|Quantity|string|date|boolean|Attachment", "A value for the characteristic.", 0, 1, value);
1297          case -2029823716: /*valueQuantity*/  return new Property("value[x]", "Coding|Quantity|string|date|boolean|Attachment", "A value for the characteristic.", 0, 1, value);
1298          case -1424603934: /*valueString*/  return new Property("value[x]", "Coding|Quantity|string|date|boolean|Attachment", "A value for the characteristic.", 0, 1, value);
1299          case -766192449: /*valueDate*/  return new Property("value[x]", "Coding|Quantity|string|date|boolean|Attachment", "A value for the characteristic.", 0, 1, value);
1300          case 733421943: /*valueBoolean*/  return new Property("value[x]", "Coding|Quantity|string|date|boolean|Attachment", "A value for the characteristic.", 0, 1, value);
1301          case -475566732: /*valueAttachment*/  return new Property("value[x]", "Coding|Quantity|string|date|boolean|Attachment", "A value for the characteristic.", 0, 1, value);
1302          default: return super.getNamedProperty(_hash, _name, _checkValid);
1303          }
1304
1305        }
1306
1307      @Override
1308      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1309        switch (hash) {
1310        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept
1311        case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // Type
1312        default: return super.getProperty(hash, name, checkValid);
1313        }
1314
1315      }
1316
1317      @Override
1318      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1319        switch (hash) {
1320        case 3059181: // code
1321          this.code = castToCodeableConcept(value); // CodeableConcept
1322          return value;
1323        case 111972721: // value
1324          this.value = castToType(value); // Type
1325          return value;
1326        default: return super.setProperty(hash, name, value);
1327        }
1328
1329      }
1330
1331      @Override
1332      public Base setProperty(String name, Base value) throws FHIRException {
1333        if (name.equals("code")) {
1334          this.code = castToCodeableConcept(value); // CodeableConcept
1335        } else if (name.equals("value[x]")) {
1336          this.value = castToType(value); // Type
1337        } else
1338          return super.setProperty(name, value);
1339        return value;
1340      }
1341
1342      @Override
1343      public Base makeProperty(int hash, String name) throws FHIRException {
1344        switch (hash) {
1345        case 3059181:  return getCode();
1346        case -1410166417:  return getValue();
1347        case 111972721:  return getValue();
1348        default: return super.makeProperty(hash, name);
1349        }
1350
1351      }
1352
1353      @Override
1354      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1355        switch (hash) {
1356        case 3059181: /*code*/ return new String[] {"CodeableConcept"};
1357        case 111972721: /*value*/ return new String[] {"Coding", "Quantity", "string", "date", "boolean", "Attachment"};
1358        default: return super.getTypesForProperty(hash, name);
1359        }
1360
1361      }
1362
1363      @Override
1364      public Base addChild(String name) throws FHIRException {
1365        if (name.equals("code")) {
1366          this.code = new CodeableConcept();
1367          return this.code;
1368        }
1369        else if (name.equals("valueCoding")) {
1370          this.value = new Coding();
1371          return this.value;
1372        }
1373        else if (name.equals("valueQuantity")) {
1374          this.value = new Quantity();
1375          return this.value;
1376        }
1377        else if (name.equals("valueString")) {
1378          this.value = new StringType();
1379          return this.value;
1380        }
1381        else if (name.equals("valueDate")) {
1382          this.value = new DateType();
1383          return this.value;
1384        }
1385        else if (name.equals("valueBoolean")) {
1386          this.value = new BooleanType();
1387          return this.value;
1388        }
1389        else if (name.equals("valueAttachment")) {
1390          this.value = new Attachment();
1391          return this.value;
1392        }
1393        else
1394          return super.addChild(name);
1395      }
1396
1397      public PackagedProductDefinitionPackageCharacteristicComponent copy() {
1398        PackagedProductDefinitionPackageCharacteristicComponent dst = new PackagedProductDefinitionPackageCharacteristicComponent();
1399        copyValues(dst);
1400        return dst;
1401      }
1402
1403      public void copyValues(PackagedProductDefinitionPackageCharacteristicComponent dst) {
1404        super.copyValues(dst);
1405        dst.code = code == null ? null : code.copy();
1406        dst.value = value == null ? null : value.copy();
1407      }
1408
1409      @Override
1410      public boolean equalsDeep(Base other_) {
1411        if (!super.equalsDeep(other_))
1412          return false;
1413        if (!(other_ instanceof PackagedProductDefinitionPackageCharacteristicComponent))
1414          return false;
1415        PackagedProductDefinitionPackageCharacteristicComponent o = (PackagedProductDefinitionPackageCharacteristicComponent) other_;
1416        return compareDeep(code, o.code, true) && compareDeep(value, o.value, true);
1417      }
1418
1419      @Override
1420      public boolean equalsShallow(Base other_) {
1421        if (!super.equalsShallow(other_))
1422          return false;
1423        if (!(other_ instanceof PackagedProductDefinitionPackageCharacteristicComponent))
1424          return false;
1425        PackagedProductDefinitionPackageCharacteristicComponent o = (PackagedProductDefinitionPackageCharacteristicComponent) other_;
1426        return true;
1427      }
1428
1429      public boolean isEmpty() {
1430        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(code, value);
1431      }
1432
1433  public String fhirType() {
1434    return "PackagedProductDefinition.package.characteristic";
1435
1436  }
1437
1438  }
1439
1440    @Block()
1441    public static class PackagedProductDefinitionPackageContainedItemComponent extends BackboneElement implements IBaseBackboneElement {
1442        /**
1443         * The manufactured item or device as contained in the packaged medicinal product.
1444         */
1445        @Child(name = "item", type = {ManufacturedItemDefinition.class, DeviceDefinition.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1446        @Description(shortDefinition="The manufactured item or device as contained in the packaged medicinal product", formalDefinition="The manufactured item or device as contained in the packaged medicinal product." )
1447        protected List<Reference> item;
1448
1449        /**
1450         * The number of this type of item within this packaging.
1451         */
1452        @Child(name = "amount", type = {Quantity.class, IntegerType.class}, order=2, min=0, max=1, modifier=false, summary=true)
1453        @Description(shortDefinition="The number of this type of item within this packaging", formalDefinition="The number of this type of item within this packaging." )
1454        protected Type amount;
1455
1456        private static final long serialVersionUID = 656616688L;
1457
1458    /**
1459     * Constructor
1460     */
1461      public PackagedProductDefinitionPackageContainedItemComponent() {
1462        super();
1463      }
1464
1465        /**
1466         * @return {@link #item} (The manufactured item or device as contained in the packaged medicinal product.)
1467         */
1468        public List<Reference> getItem() { 
1469          if (this.item == null)
1470            this.item = new ArrayList<Reference>();
1471          return this.item;
1472        }
1473
1474        /**
1475         * @return Returns a reference to <code>this</code> for easy method chaining
1476         */
1477        public PackagedProductDefinitionPackageContainedItemComponent setItem(List<Reference> theItem) { 
1478          this.item = theItem;
1479          return this;
1480        }
1481
1482        public boolean hasItem() { 
1483          if (this.item == null)
1484            return false;
1485          for (Reference item : this.item)
1486            if (!item.isEmpty())
1487              return true;
1488          return false;
1489        }
1490
1491        public Reference addItem() { //3
1492          Reference t = new Reference();
1493          if (this.item == null)
1494            this.item = new ArrayList<Reference>();
1495          this.item.add(t);
1496          return t;
1497        }
1498
1499        public PackagedProductDefinitionPackageContainedItemComponent addItem(Reference t) { //3
1500          if (t == null)
1501            return this;
1502          if (this.item == null)
1503            this.item = new ArrayList<Reference>();
1504          this.item.add(t);
1505          return this;
1506        }
1507
1508        /**
1509         * @return The first repetition of repeating field {@link #item}, creating it if it does not already exist
1510         */
1511        public Reference getItemFirstRep() { 
1512          if (getItem().isEmpty()) {
1513            addItem();
1514          }
1515          return getItem().get(0);
1516        }
1517
1518        /**
1519         * @return {@link #amount} (The number of this type of item within this packaging.)
1520         */
1521        public Type getAmount() { 
1522          return this.amount;
1523        }
1524
1525        /**
1526         * @return {@link #amount} (The number of this type of item within this packaging.)
1527         */
1528        public Quantity getAmountQuantity() throws FHIRException { 
1529          if (this.amount == null)
1530            this.amount = new Quantity();
1531          if (!(this.amount instanceof Quantity))
1532            throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.amount.getClass().getName()+" was encountered");
1533          return (Quantity) this.amount;
1534        }
1535
1536        public boolean hasAmountQuantity() { 
1537          return this != null && this.amount instanceof Quantity;
1538        }
1539
1540        /**
1541         * @return {@link #amount} (The number of this type of item within this packaging.)
1542         */
1543        public IntegerType getAmountIntegerType() throws FHIRException { 
1544          if (this.amount == null)
1545            this.amount = new IntegerType();
1546          if (!(this.amount instanceof IntegerType))
1547            throw new FHIRException("Type mismatch: the type IntegerType was expected, but "+this.amount.getClass().getName()+" was encountered");
1548          return (IntegerType) this.amount;
1549        }
1550
1551        public boolean hasAmountIntegerType() { 
1552          return this != null && this.amount instanceof IntegerType;
1553        }
1554
1555        public boolean hasAmount() { 
1556          return this.amount != null && !this.amount.isEmpty();
1557        }
1558
1559        /**
1560         * @param value {@link #amount} (The number of this type of item within this packaging.)
1561         */
1562        public PackagedProductDefinitionPackageContainedItemComponent setAmount(Type value) { 
1563          if (value != null && !(value instanceof Quantity || value instanceof IntegerType))
1564            throw new Error("Not the right type for PackagedProductDefinition.package.containedItem.amount[x]: "+value.fhirType());
1565          this.amount = value;
1566          return this;
1567        }
1568
1569        protected void listChildren(List<Property> children) {
1570          super.listChildren(children);
1571          children.add(new Property("item", "Reference(ManufacturedItemDefinition|DeviceDefinition)", "The manufactured item or device as contained in the packaged medicinal product.", 0, java.lang.Integer.MAX_VALUE, item));
1572          children.add(new Property("amount[x]", "Quantity|integer", "The number of this type of item within this packaging.", 0, 1, amount));
1573        }
1574
1575        @Override
1576        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1577          switch (_hash) {
1578          case 3242771: /*item*/  return new Property("item", "Reference(ManufacturedItemDefinition|DeviceDefinition)", "The manufactured item or device as contained in the packaged medicinal product.", 0, java.lang.Integer.MAX_VALUE, item);
1579          case 646780200: /*amount[x]*/  return new Property("amount[x]", "Quantity|integer", "The number of this type of item within this packaging.", 0, 1, amount);
1580          case -1413853096: /*amount*/  return new Property("amount[x]", "Quantity|integer", "The number of this type of item within this packaging.", 0, 1, amount);
1581          case 1664303363: /*amountQuantity*/  return new Property("amount[x]", "Quantity|integer", "The number of this type of item within this packaging.", 0, 1, amount);
1582          case 2053191110: /*amountInteger*/  return new Property("amount[x]", "Quantity|integer", "The number of this type of item within this packaging.", 0, 1, amount);
1583          default: return super.getNamedProperty(_hash, _name, _checkValid);
1584          }
1585
1586        }
1587
1588      @Override
1589      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1590        switch (hash) {
1591        case 3242771: /*item*/ return this.item == null ? new Base[0] : this.item.toArray(new Base[this.item.size()]); // Reference
1592        case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : new Base[] {this.amount}; // Type
1593        default: return super.getProperty(hash, name, checkValid);
1594        }
1595
1596      }
1597
1598      @Override
1599      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1600        switch (hash) {
1601        case 3242771: // item
1602          this.getItem().add(castToReference(value)); // Reference
1603          return value;
1604        case -1413853096: // amount
1605          this.amount = castToType(value); // Type
1606          return value;
1607        default: return super.setProperty(hash, name, value);
1608        }
1609
1610      }
1611
1612      @Override
1613      public Base setProperty(String name, Base value) throws FHIRException {
1614        if (name.equals("item")) {
1615          this.getItem().add(castToReference(value));
1616        } else if (name.equals("amount[x]")) {
1617          this.amount = castToType(value); // Type
1618        } else
1619          return super.setProperty(name, value);
1620        return value;
1621      }
1622
1623      @Override
1624      public Base makeProperty(int hash, String name) throws FHIRException {
1625        switch (hash) {
1626        case 3242771:  return addItem(); 
1627        case 646780200:  return getAmount();
1628        case -1413853096:  return getAmount();
1629        default: return super.makeProperty(hash, name);
1630        }
1631
1632      }
1633
1634      @Override
1635      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1636        switch (hash) {
1637        case 3242771: /*item*/ return new String[] {"Reference"};
1638        case -1413853096: /*amount*/ return new String[] {"Quantity", "integer"};
1639        default: return super.getTypesForProperty(hash, name);
1640        }
1641
1642      }
1643
1644      @Override
1645      public Base addChild(String name) throws FHIRException {
1646        if (name.equals("item")) {
1647          return addItem();
1648        }
1649        else if (name.equals("amountQuantity")) {
1650          this.amount = new Quantity();
1651          return this.amount;
1652        }
1653        else if (name.equals("amountInteger")) {
1654          this.amount = new IntegerType();
1655          return this.amount;
1656        }
1657        else
1658          return super.addChild(name);
1659      }
1660
1661      public PackagedProductDefinitionPackageContainedItemComponent copy() {
1662        PackagedProductDefinitionPackageContainedItemComponent dst = new PackagedProductDefinitionPackageContainedItemComponent();
1663        copyValues(dst);
1664        return dst;
1665      }
1666
1667      public void copyValues(PackagedProductDefinitionPackageContainedItemComponent dst) {
1668        super.copyValues(dst);
1669        if (item != null) {
1670          dst.item = new ArrayList<Reference>();
1671          for (Reference i : item)
1672            dst.item.add(i.copy());
1673        };
1674        dst.amount = amount == null ? null : amount.copy();
1675      }
1676
1677      @Override
1678      public boolean equalsDeep(Base other_) {
1679        if (!super.equalsDeep(other_))
1680          return false;
1681        if (!(other_ instanceof PackagedProductDefinitionPackageContainedItemComponent))
1682          return false;
1683        PackagedProductDefinitionPackageContainedItemComponent o = (PackagedProductDefinitionPackageContainedItemComponent) other_;
1684        return compareDeep(item, o.item, true) && compareDeep(amount, o.amount, true);
1685      }
1686
1687      @Override
1688      public boolean equalsShallow(Base other_) {
1689        if (!super.equalsShallow(other_))
1690          return false;
1691        if (!(other_ instanceof PackagedProductDefinitionPackageContainedItemComponent))
1692          return false;
1693        PackagedProductDefinitionPackageContainedItemComponent o = (PackagedProductDefinitionPackageContainedItemComponent) other_;
1694        return true;
1695      }
1696
1697      public boolean isEmpty() {
1698        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(item, amount);
1699      }
1700
1701  public String fhirType() {
1702    return "PackagedProductDefinition.package.containedItem";
1703
1704  }
1705
1706  }
1707
1708    /**
1709     * Unique identifier.
1710     */
1711    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1712    @Description(shortDefinition="Unique identifier", formalDefinition="Unique identifier." )
1713    protected List<Identifier> identifier;
1714
1715    /**
1716     * The product that this is a pack for.
1717     */
1718    @Child(name = "subject", type = {MedicinalProductDefinition.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1719    @Description(shortDefinition="The product that this is a pack for", formalDefinition="The product that this is a pack for." )
1720    protected List<Reference> subject;
1721
1722    /**
1723     * Textual description.
1724     */
1725    @Child(name = "description", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=true)
1726    @Description(shortDefinition="Textual description", formalDefinition="Textual description." )
1727    protected StringType description;
1728
1729    /**
1730     * The legal status of supply of the medicinal product as classified by the regulator.
1731     */
1732    @Child(name = "legalStatusOfSupply", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true)
1733    @Description(shortDefinition="The legal status of supply of the medicinal product as classified by the regulator", formalDefinition="The legal status of supply of the medicinal product as classified by the regulator." )
1734    protected CodeableConcept legalStatusOfSupply;
1735
1736    /**
1737     * Marketing information.
1738     */
1739    @Child(name = "marketingStatus", type = {MarketingStatus.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1740    @Description(shortDefinition="Marketing information", formalDefinition="Marketing information." )
1741    protected List<MarketingStatus> marketingStatus;
1742
1743    /**
1744     * Manufacturer of this Package Item.
1745     */
1746    @Child(name = "marketingAuthorization", type = {RegulatedAuthorization.class}, order=5, min=0, max=1, modifier=false, summary=true)
1747    @Description(shortDefinition="Manufacturer of this Package Item", formalDefinition="Manufacturer of this Package Item." )
1748    protected Reference marketingAuthorization;
1749
1750    /**
1751     * Manufacturer of this Package Item.
1752     */
1753    @Child(name = "manufacturer", type = {Organization.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1754    @Description(shortDefinition="Manufacturer of this Package Item", formalDefinition="Manufacturer of this Package Item." )
1755    protected List<Reference> manufacturer;
1756
1757    /**
1758     * Batch numbering.
1759     */
1760    @Child(name = "batchIdentifier", type = {}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1761    @Description(shortDefinition="Batch numbering", formalDefinition="Batch numbering." )
1762    protected List<PackagedProductDefinitionBatchIdentifierComponent> batchIdentifier;
1763
1764    /**
1765     * A packaging item, as a contained for medicine, possibly with other packaging items within.
1766     */
1767    @Child(name = "package", type = {}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1768    @Description(shortDefinition="A packaging item, as a contained for medicine, possibly with other packaging items within", formalDefinition="A packaging item, as a contained for medicine, possibly with other packaging items within." )
1769    protected List<PackagedProductDefinitionPackageComponent> package_;
1770
1771    private static final long serialVersionUID = -1124177667L;
1772
1773  /**
1774   * Constructor
1775   */
1776    public PackagedProductDefinition() {
1777      super();
1778    }
1779
1780    /**
1781     * @return {@link #identifier} (Unique identifier.)
1782     */
1783    public List<Identifier> getIdentifier() { 
1784      if (this.identifier == null)
1785        this.identifier = new ArrayList<Identifier>();
1786      return this.identifier;
1787    }
1788
1789    /**
1790     * @return Returns a reference to <code>this</code> for easy method chaining
1791     */
1792    public PackagedProductDefinition setIdentifier(List<Identifier> theIdentifier) { 
1793      this.identifier = theIdentifier;
1794      return this;
1795    }
1796
1797    public boolean hasIdentifier() { 
1798      if (this.identifier == null)
1799        return false;
1800      for (Identifier item : this.identifier)
1801        if (!item.isEmpty())
1802          return true;
1803      return false;
1804    }
1805
1806    public Identifier addIdentifier() { //3
1807      Identifier t = new Identifier();
1808      if (this.identifier == null)
1809        this.identifier = new ArrayList<Identifier>();
1810      this.identifier.add(t);
1811      return t;
1812    }
1813
1814    public PackagedProductDefinition addIdentifier(Identifier t) { //3
1815      if (t == null)
1816        return this;
1817      if (this.identifier == null)
1818        this.identifier = new ArrayList<Identifier>();
1819      this.identifier.add(t);
1820      return this;
1821    }
1822
1823    /**
1824     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
1825     */
1826    public Identifier getIdentifierFirstRep() { 
1827      if (getIdentifier().isEmpty()) {
1828        addIdentifier();
1829      }
1830      return getIdentifier().get(0);
1831    }
1832
1833    /**
1834     * @return {@link #subject} (The product that this is a pack for.)
1835     */
1836    public List<Reference> getSubject() { 
1837      if (this.subject == null)
1838        this.subject = new ArrayList<Reference>();
1839      return this.subject;
1840    }
1841
1842    /**
1843     * @return Returns a reference to <code>this</code> for easy method chaining
1844     */
1845    public PackagedProductDefinition setSubject(List<Reference> theSubject) { 
1846      this.subject = theSubject;
1847      return this;
1848    }
1849
1850    public boolean hasSubject() { 
1851      if (this.subject == null)
1852        return false;
1853      for (Reference item : this.subject)
1854        if (!item.isEmpty())
1855          return true;
1856      return false;
1857    }
1858
1859    public Reference addSubject() { //3
1860      Reference t = new Reference();
1861      if (this.subject == null)
1862        this.subject = new ArrayList<Reference>();
1863      this.subject.add(t);
1864      return t;
1865    }
1866
1867    public PackagedProductDefinition addSubject(Reference t) { //3
1868      if (t == null)
1869        return this;
1870      if (this.subject == null)
1871        this.subject = new ArrayList<Reference>();
1872      this.subject.add(t);
1873      return this;
1874    }
1875
1876    /**
1877     * @return The first repetition of repeating field {@link #subject}, creating it if it does not already exist
1878     */
1879    public Reference getSubjectFirstRep() { 
1880      if (getSubject().isEmpty()) {
1881        addSubject();
1882      }
1883      return getSubject().get(0);
1884    }
1885
1886    /**
1887     * @return {@link #description} (Textual description.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
1888     */
1889    public StringType getDescriptionElement() { 
1890      if (this.description == null)
1891        if (Configuration.errorOnAutoCreate())
1892          throw new Error("Attempt to auto-create PackagedProductDefinition.description");
1893        else if (Configuration.doAutoCreate())
1894          this.description = new StringType(); // bb
1895      return this.description;
1896    }
1897
1898    public boolean hasDescriptionElement() { 
1899      return this.description != null && !this.description.isEmpty();
1900    }
1901
1902    public boolean hasDescription() { 
1903      return this.description != null && !this.description.isEmpty();
1904    }
1905
1906    /**
1907     * @param value {@link #description} (Textual description.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
1908     */
1909    public PackagedProductDefinition setDescriptionElement(StringType value) { 
1910      this.description = value;
1911      return this;
1912    }
1913
1914    /**
1915     * @return Textual description.
1916     */
1917    public String getDescription() { 
1918      return this.description == null ? null : this.description.getValue();
1919    }
1920
1921    /**
1922     * @param value Textual description.
1923     */
1924    public PackagedProductDefinition setDescription(String value) { 
1925      if (Utilities.noString(value))
1926        this.description = null;
1927      else {
1928        if (this.description == null)
1929          this.description = new StringType();
1930        this.description.setValue(value);
1931      }
1932      return this;
1933    }
1934
1935    /**
1936     * @return {@link #legalStatusOfSupply} (The legal status of supply of the medicinal product as classified by the regulator.)
1937     */
1938    public CodeableConcept getLegalStatusOfSupply() { 
1939      if (this.legalStatusOfSupply == null)
1940        if (Configuration.errorOnAutoCreate())
1941          throw new Error("Attempt to auto-create PackagedProductDefinition.legalStatusOfSupply");
1942        else if (Configuration.doAutoCreate())
1943          this.legalStatusOfSupply = new CodeableConcept(); // cc
1944      return this.legalStatusOfSupply;
1945    }
1946
1947    public boolean hasLegalStatusOfSupply() { 
1948      return this.legalStatusOfSupply != null && !this.legalStatusOfSupply.isEmpty();
1949    }
1950
1951    /**
1952     * @param value {@link #legalStatusOfSupply} (The legal status of supply of the medicinal product as classified by the regulator.)
1953     */
1954    public PackagedProductDefinition setLegalStatusOfSupply(CodeableConcept value) { 
1955      this.legalStatusOfSupply = value;
1956      return this;
1957    }
1958
1959    /**
1960     * @return {@link #marketingStatus} (Marketing information.)
1961     */
1962    public List<MarketingStatus> getMarketingStatus() { 
1963      if (this.marketingStatus == null)
1964        this.marketingStatus = new ArrayList<MarketingStatus>();
1965      return this.marketingStatus;
1966    }
1967
1968    /**
1969     * @return Returns a reference to <code>this</code> for easy method chaining
1970     */
1971    public PackagedProductDefinition setMarketingStatus(List<MarketingStatus> theMarketingStatus) { 
1972      this.marketingStatus = theMarketingStatus;
1973      return this;
1974    }
1975
1976    public boolean hasMarketingStatus() { 
1977      if (this.marketingStatus == null)
1978        return false;
1979      for (MarketingStatus item : this.marketingStatus)
1980        if (!item.isEmpty())
1981          return true;
1982      return false;
1983    }
1984
1985    public MarketingStatus addMarketingStatus() { //3
1986      MarketingStatus t = new MarketingStatus();
1987      if (this.marketingStatus == null)
1988        this.marketingStatus = new ArrayList<MarketingStatus>();
1989      this.marketingStatus.add(t);
1990      return t;
1991    }
1992
1993    public PackagedProductDefinition addMarketingStatus(MarketingStatus t) { //3
1994      if (t == null)
1995        return this;
1996      if (this.marketingStatus == null)
1997        this.marketingStatus = new ArrayList<MarketingStatus>();
1998      this.marketingStatus.add(t);
1999      return this;
2000    }
2001
2002    /**
2003     * @return The first repetition of repeating field {@link #marketingStatus}, creating it if it does not already exist
2004     */
2005    public MarketingStatus getMarketingStatusFirstRep() { 
2006      if (getMarketingStatus().isEmpty()) {
2007        addMarketingStatus();
2008      }
2009      return getMarketingStatus().get(0);
2010    }
2011
2012    /**
2013     * @return {@link #marketingAuthorization} (Manufacturer of this Package Item.)
2014     */
2015    public Reference getMarketingAuthorization() { 
2016      if (this.marketingAuthorization == null)
2017        if (Configuration.errorOnAutoCreate())
2018          throw new Error("Attempt to auto-create PackagedProductDefinition.marketingAuthorization");
2019        else if (Configuration.doAutoCreate())
2020          this.marketingAuthorization = new Reference(); // cc
2021      return this.marketingAuthorization;
2022    }
2023
2024    public boolean hasMarketingAuthorization() { 
2025      return this.marketingAuthorization != null && !this.marketingAuthorization.isEmpty();
2026    }
2027
2028    /**
2029     * @param value {@link #marketingAuthorization} (Manufacturer of this Package Item.)
2030     */
2031    public PackagedProductDefinition setMarketingAuthorization(Reference value) { 
2032      this.marketingAuthorization = value;
2033      return this;
2034    }
2035
2036    /**
2037     * @return {@link #manufacturer} (Manufacturer of this Package Item.)
2038     */
2039    public List<Reference> getManufacturer() { 
2040      if (this.manufacturer == null)
2041        this.manufacturer = new ArrayList<Reference>();
2042      return this.manufacturer;
2043    }
2044
2045    /**
2046     * @return Returns a reference to <code>this</code> for easy method chaining
2047     */
2048    public PackagedProductDefinition setManufacturer(List<Reference> theManufacturer) { 
2049      this.manufacturer = theManufacturer;
2050      return this;
2051    }
2052
2053    public boolean hasManufacturer() { 
2054      if (this.manufacturer == null)
2055        return false;
2056      for (Reference item : this.manufacturer)
2057        if (!item.isEmpty())
2058          return true;
2059      return false;
2060    }
2061
2062    public Reference addManufacturer() { //3
2063      Reference t = new Reference();
2064      if (this.manufacturer == null)
2065        this.manufacturer = new ArrayList<Reference>();
2066      this.manufacturer.add(t);
2067      return t;
2068    }
2069
2070    public PackagedProductDefinition addManufacturer(Reference t) { //3
2071      if (t == null)
2072        return this;
2073      if (this.manufacturer == null)
2074        this.manufacturer = new ArrayList<Reference>();
2075      this.manufacturer.add(t);
2076      return this;
2077    }
2078
2079    /**
2080     * @return The first repetition of repeating field {@link #manufacturer}, creating it if it does not already exist
2081     */
2082    public Reference getManufacturerFirstRep() { 
2083      if (getManufacturer().isEmpty()) {
2084        addManufacturer();
2085      }
2086      return getManufacturer().get(0);
2087    }
2088
2089    /**
2090     * @return {@link #batchIdentifier} (Batch numbering.)
2091     */
2092    public List<PackagedProductDefinitionBatchIdentifierComponent> getBatchIdentifier() { 
2093      if (this.batchIdentifier == null)
2094        this.batchIdentifier = new ArrayList<PackagedProductDefinitionBatchIdentifierComponent>();
2095      return this.batchIdentifier;
2096    }
2097
2098    /**
2099     * @return Returns a reference to <code>this</code> for easy method chaining
2100     */
2101    public PackagedProductDefinition setBatchIdentifier(List<PackagedProductDefinitionBatchIdentifierComponent> theBatchIdentifier) { 
2102      this.batchIdentifier = theBatchIdentifier;
2103      return this;
2104    }
2105
2106    public boolean hasBatchIdentifier() { 
2107      if (this.batchIdentifier == null)
2108        return false;
2109      for (PackagedProductDefinitionBatchIdentifierComponent item : this.batchIdentifier)
2110        if (!item.isEmpty())
2111          return true;
2112      return false;
2113    }
2114
2115    public PackagedProductDefinitionBatchIdentifierComponent addBatchIdentifier() { //3
2116      PackagedProductDefinitionBatchIdentifierComponent t = new PackagedProductDefinitionBatchIdentifierComponent();
2117      if (this.batchIdentifier == null)
2118        this.batchIdentifier = new ArrayList<PackagedProductDefinitionBatchIdentifierComponent>();
2119      this.batchIdentifier.add(t);
2120      return t;
2121    }
2122
2123    public PackagedProductDefinition addBatchIdentifier(PackagedProductDefinitionBatchIdentifierComponent t) { //3
2124      if (t == null)
2125        return this;
2126      if (this.batchIdentifier == null)
2127        this.batchIdentifier = new ArrayList<PackagedProductDefinitionBatchIdentifierComponent>();
2128      this.batchIdentifier.add(t);
2129      return this;
2130    }
2131
2132    /**
2133     * @return The first repetition of repeating field {@link #batchIdentifier}, creating it if it does not already exist
2134     */
2135    public PackagedProductDefinitionBatchIdentifierComponent getBatchIdentifierFirstRep() { 
2136      if (getBatchIdentifier().isEmpty()) {
2137        addBatchIdentifier();
2138      }
2139      return getBatchIdentifier().get(0);
2140    }
2141
2142    /**
2143     * @return {@link #package_} (A packaging item, as a contained for medicine, possibly with other packaging items within.)
2144     */
2145    public List<PackagedProductDefinitionPackageComponent> getPackage() { 
2146      if (this.package_ == null)
2147        this.package_ = new ArrayList<PackagedProductDefinitionPackageComponent>();
2148      return this.package_;
2149    }
2150
2151    /**
2152     * @return Returns a reference to <code>this</code> for easy method chaining
2153     */
2154    public PackagedProductDefinition setPackage(List<PackagedProductDefinitionPackageComponent> thePackage) { 
2155      this.package_ = thePackage;
2156      return this;
2157    }
2158
2159    public boolean hasPackage() { 
2160      if (this.package_ == null)
2161        return false;
2162      for (PackagedProductDefinitionPackageComponent item : this.package_)
2163        if (!item.isEmpty())
2164          return true;
2165      return false;
2166    }
2167
2168    public PackagedProductDefinitionPackageComponent addPackage() { //3
2169      PackagedProductDefinitionPackageComponent t = new PackagedProductDefinitionPackageComponent();
2170      if (this.package_ == null)
2171        this.package_ = new ArrayList<PackagedProductDefinitionPackageComponent>();
2172      this.package_.add(t);
2173      return t;
2174    }
2175
2176    public PackagedProductDefinition addPackage(PackagedProductDefinitionPackageComponent t) { //3
2177      if (t == null)
2178        return this;
2179      if (this.package_ == null)
2180        this.package_ = new ArrayList<PackagedProductDefinitionPackageComponent>();
2181      this.package_.add(t);
2182      return this;
2183    }
2184
2185    /**
2186     * @return The first repetition of repeating field {@link #package_}, creating it if it does not already exist
2187     */
2188    public PackagedProductDefinitionPackageComponent getPackageFirstRep() { 
2189      if (getPackage().isEmpty()) {
2190        addPackage();
2191      }
2192      return getPackage().get(0);
2193    }
2194
2195      protected void listChildren(List<Property> children) {
2196        super.listChildren(children);
2197        children.add(new Property("identifier", "Identifier", "Unique identifier.", 0, java.lang.Integer.MAX_VALUE, identifier));
2198        children.add(new Property("subject", "Reference(MedicinalProductDefinition)", "The product that this is a pack for.", 0, java.lang.Integer.MAX_VALUE, subject));
2199        children.add(new Property("description", "string", "Textual description.", 0, 1, description));
2200        children.add(new Property("legalStatusOfSupply", "CodeableConcept", "The legal status of supply of the medicinal product as classified by the regulator.", 0, 1, legalStatusOfSupply));
2201        children.add(new Property("marketingStatus", "MarketingStatus", "Marketing information.", 0, java.lang.Integer.MAX_VALUE, marketingStatus));
2202        children.add(new Property("marketingAuthorization", "Reference(RegulatedAuthorization)", "Manufacturer of this Package Item.", 0, 1, marketingAuthorization));
2203        children.add(new Property("manufacturer", "Reference(Organization)", "Manufacturer of this Package Item.", 0, java.lang.Integer.MAX_VALUE, manufacturer));
2204        children.add(new Property("batchIdentifier", "", "Batch numbering.", 0, java.lang.Integer.MAX_VALUE, batchIdentifier));
2205        children.add(new Property("package", "", "A packaging item, as a contained for medicine, possibly with other packaging items within.", 0, java.lang.Integer.MAX_VALUE, package_));
2206      }
2207
2208      @Override
2209      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2210        switch (_hash) {
2211        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Unique identifier.", 0, java.lang.Integer.MAX_VALUE, identifier);
2212        case -1867885268: /*subject*/  return new Property("subject", "Reference(MedicinalProductDefinition)", "The product that this is a pack for.", 0, java.lang.Integer.MAX_VALUE, subject);
2213        case -1724546052: /*description*/  return new Property("description", "string", "Textual description.", 0, 1, description);
2214        case -844874031: /*legalStatusOfSupply*/  return new Property("legalStatusOfSupply", "CodeableConcept", "The legal status of supply of the medicinal product as classified by the regulator.", 0, 1, legalStatusOfSupply);
2215        case 70767032: /*marketingStatus*/  return new Property("marketingStatus", "MarketingStatus", "Marketing information.", 0, java.lang.Integer.MAX_VALUE, marketingStatus);
2216        case 571831283: /*marketingAuthorization*/  return new Property("marketingAuthorization", "Reference(RegulatedAuthorization)", "Manufacturer of this Package Item.", 0, 1, marketingAuthorization);
2217        case -1969347631: /*manufacturer*/  return new Property("manufacturer", "Reference(Organization)", "Manufacturer of this Package Item.", 0, java.lang.Integer.MAX_VALUE, manufacturer);
2218        case -1688395901: /*batchIdentifier*/  return new Property("batchIdentifier", "", "Batch numbering.", 0, java.lang.Integer.MAX_VALUE, batchIdentifier);
2219        case -807062458: /*package*/  return new Property("package", "", "A packaging item, as a contained for medicine, possibly with other packaging items within.", 0, java.lang.Integer.MAX_VALUE, package_);
2220        default: return super.getNamedProperty(_hash, _name, _checkValid);
2221        }
2222
2223      }
2224
2225      @Override
2226      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2227        switch (hash) {
2228        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
2229        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : this.subject.toArray(new Base[this.subject.size()]); // Reference
2230        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // StringType
2231        case -844874031: /*legalStatusOfSupply*/ return this.legalStatusOfSupply == null ? new Base[0] : new Base[] {this.legalStatusOfSupply}; // CodeableConcept
2232        case 70767032: /*marketingStatus*/ return this.marketingStatus == null ? new Base[0] : this.marketingStatus.toArray(new Base[this.marketingStatus.size()]); // MarketingStatus
2233        case 571831283: /*marketingAuthorization*/ return this.marketingAuthorization == null ? new Base[0] : new Base[] {this.marketingAuthorization}; // Reference
2234        case -1969347631: /*manufacturer*/ return this.manufacturer == null ? new Base[0] : this.manufacturer.toArray(new Base[this.manufacturer.size()]); // Reference
2235        case -1688395901: /*batchIdentifier*/ return this.batchIdentifier == null ? new Base[0] : this.batchIdentifier.toArray(new Base[this.batchIdentifier.size()]); // PackagedProductDefinitionBatchIdentifierComponent
2236        case -807062458: /*package*/ return this.package_ == null ? new Base[0] : this.package_.toArray(new Base[this.package_.size()]); // PackagedProductDefinitionPackageComponent
2237        default: return super.getProperty(hash, name, checkValid);
2238        }
2239
2240      }
2241
2242      @Override
2243      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2244        switch (hash) {
2245        case -1618432855: // identifier
2246          this.getIdentifier().add(castToIdentifier(value)); // Identifier
2247          return value;
2248        case -1867885268: // subject
2249          this.getSubject().add(castToReference(value)); // Reference
2250          return value;
2251        case -1724546052: // description
2252          this.description = castToString(value); // StringType
2253          return value;
2254        case -844874031: // legalStatusOfSupply
2255          this.legalStatusOfSupply = castToCodeableConcept(value); // CodeableConcept
2256          return value;
2257        case 70767032: // marketingStatus
2258          this.getMarketingStatus().add(castToMarketingStatus(value)); // MarketingStatus
2259          return value;
2260        case 571831283: // marketingAuthorization
2261          this.marketingAuthorization = castToReference(value); // Reference
2262          return value;
2263        case -1969347631: // manufacturer
2264          this.getManufacturer().add(castToReference(value)); // Reference
2265          return value;
2266        case -1688395901: // batchIdentifier
2267          this.getBatchIdentifier().add((PackagedProductDefinitionBatchIdentifierComponent) value); // PackagedProductDefinitionBatchIdentifierComponent
2268          return value;
2269        case -807062458: // package
2270          this.getPackage().add((PackagedProductDefinitionPackageComponent) value); // PackagedProductDefinitionPackageComponent
2271          return value;
2272        default: return super.setProperty(hash, name, value);
2273        }
2274
2275      }
2276
2277      @Override
2278      public Base setProperty(String name, Base value) throws FHIRException {
2279        if (name.equals("identifier")) {
2280          this.getIdentifier().add(castToIdentifier(value));
2281        } else if (name.equals("subject")) {
2282          this.getSubject().add(castToReference(value));
2283        } else if (name.equals("description")) {
2284          this.description = castToString(value); // StringType
2285        } else if (name.equals("legalStatusOfSupply")) {
2286          this.legalStatusOfSupply = castToCodeableConcept(value); // CodeableConcept
2287        } else if (name.equals("marketingStatus")) {
2288          this.getMarketingStatus().add(castToMarketingStatus(value));
2289        } else if (name.equals("marketingAuthorization")) {
2290          this.marketingAuthorization = castToReference(value); // Reference
2291        } else if (name.equals("manufacturer")) {
2292          this.getManufacturer().add(castToReference(value));
2293        } else if (name.equals("batchIdentifier")) {
2294          this.getBatchIdentifier().add((PackagedProductDefinitionBatchIdentifierComponent) value);
2295        } else if (name.equals("package")) {
2296          this.getPackage().add((PackagedProductDefinitionPackageComponent) value);
2297        } else
2298          return super.setProperty(name, value);
2299        return value;
2300      }
2301
2302      @Override
2303      public Base makeProperty(int hash, String name) throws FHIRException {
2304        switch (hash) {
2305        case -1618432855:  return addIdentifier(); 
2306        case -1867885268:  return addSubject(); 
2307        case -1724546052:  return getDescriptionElement();
2308        case -844874031:  return getLegalStatusOfSupply();
2309        case 70767032:  return addMarketingStatus(); 
2310        case 571831283:  return getMarketingAuthorization();
2311        case -1969347631:  return addManufacturer(); 
2312        case -1688395901:  return addBatchIdentifier(); 
2313        case -807062458:  return addPackage(); 
2314        default: return super.makeProperty(hash, name);
2315        }
2316
2317      }
2318
2319      @Override
2320      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2321        switch (hash) {
2322        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
2323        case -1867885268: /*subject*/ return new String[] {"Reference"};
2324        case -1724546052: /*description*/ return new String[] {"string"};
2325        case -844874031: /*legalStatusOfSupply*/ return new String[] {"CodeableConcept"};
2326        case 70767032: /*marketingStatus*/ return new String[] {"MarketingStatus"};
2327        case 571831283: /*marketingAuthorization*/ return new String[] {"Reference"};
2328        case -1969347631: /*manufacturer*/ return new String[] {"Reference"};
2329        case -1688395901: /*batchIdentifier*/ return new String[] {};
2330        case -807062458: /*package*/ return new String[] {};
2331        default: return super.getTypesForProperty(hash, name);
2332        }
2333
2334      }
2335
2336      @Override
2337      public Base addChild(String name) throws FHIRException {
2338        if (name.equals("identifier")) {
2339          return addIdentifier();
2340        }
2341        else if (name.equals("subject")) {
2342          return addSubject();
2343        }
2344        else if (name.equals("description")) {
2345          throw new FHIRException("Cannot call addChild on a primitive type PackagedProductDefinition.description");
2346        }
2347        else if (name.equals("legalStatusOfSupply")) {
2348          this.legalStatusOfSupply = new CodeableConcept();
2349          return this.legalStatusOfSupply;
2350        }
2351        else if (name.equals("marketingStatus")) {
2352          return addMarketingStatus();
2353        }
2354        else if (name.equals("marketingAuthorization")) {
2355          this.marketingAuthorization = new Reference();
2356          return this.marketingAuthorization;
2357        }
2358        else if (name.equals("manufacturer")) {
2359          return addManufacturer();
2360        }
2361        else if (name.equals("batchIdentifier")) {
2362          return addBatchIdentifier();
2363        }
2364        else if (name.equals("package")) {
2365          return addPackage();
2366        }
2367        else
2368          return super.addChild(name);
2369      }
2370
2371  public String fhirType() {
2372    return "PackagedProductDefinition";
2373
2374  }
2375
2376      public PackagedProductDefinition copy() {
2377        PackagedProductDefinition dst = new PackagedProductDefinition();
2378        copyValues(dst);
2379        return dst;
2380      }
2381
2382      public void copyValues(PackagedProductDefinition dst) {
2383        super.copyValues(dst);
2384        if (identifier != null) {
2385          dst.identifier = new ArrayList<Identifier>();
2386          for (Identifier i : identifier)
2387            dst.identifier.add(i.copy());
2388        };
2389        if (subject != null) {
2390          dst.subject = new ArrayList<Reference>();
2391          for (Reference i : subject)
2392            dst.subject.add(i.copy());
2393        };
2394        dst.description = description == null ? null : description.copy();
2395        dst.legalStatusOfSupply = legalStatusOfSupply == null ? null : legalStatusOfSupply.copy();
2396        if (marketingStatus != null) {
2397          dst.marketingStatus = new ArrayList<MarketingStatus>();
2398          for (MarketingStatus i : marketingStatus)
2399            dst.marketingStatus.add(i.copy());
2400        };
2401        dst.marketingAuthorization = marketingAuthorization == null ? null : marketingAuthorization.copy();
2402        if (manufacturer != null) {
2403          dst.manufacturer = new ArrayList<Reference>();
2404          for (Reference i : manufacturer)
2405            dst.manufacturer.add(i.copy());
2406        };
2407        if (batchIdentifier != null) {
2408          dst.batchIdentifier = new ArrayList<PackagedProductDefinitionBatchIdentifierComponent>();
2409          for (PackagedProductDefinitionBatchIdentifierComponent i : batchIdentifier)
2410            dst.batchIdentifier.add(i.copy());
2411        };
2412        if (package_ != null) {
2413          dst.package_ = new ArrayList<PackagedProductDefinitionPackageComponent>();
2414          for (PackagedProductDefinitionPackageComponent i : package_)
2415            dst.package_.add(i.copy());
2416        };
2417      }
2418
2419      protected PackagedProductDefinition typedCopy() {
2420        return copy();
2421      }
2422
2423      @Override
2424      public boolean equalsDeep(Base other_) {
2425        if (!super.equalsDeep(other_))
2426          return false;
2427        if (!(other_ instanceof PackagedProductDefinition))
2428          return false;
2429        PackagedProductDefinition o = (PackagedProductDefinition) other_;
2430        return compareDeep(identifier, o.identifier, true) && compareDeep(subject, o.subject, true) && compareDeep(description, o.description, true)
2431           && compareDeep(legalStatusOfSupply, o.legalStatusOfSupply, true) && compareDeep(marketingStatus, o.marketingStatus, true)
2432           && compareDeep(marketingAuthorization, o.marketingAuthorization, true) && compareDeep(manufacturer, o.manufacturer, true)
2433           && compareDeep(batchIdentifier, o.batchIdentifier, true) && compareDeep(package_, o.package_, true)
2434          ;
2435      }
2436
2437      @Override
2438      public boolean equalsShallow(Base other_) {
2439        if (!super.equalsShallow(other_))
2440          return false;
2441        if (!(other_ instanceof PackagedProductDefinition))
2442          return false;
2443        PackagedProductDefinition o = (PackagedProductDefinition) other_;
2444        return compareValues(description, o.description, true);
2445      }
2446
2447      public boolean isEmpty() {
2448        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, subject, description
2449          , legalStatusOfSupply, marketingStatus, marketingAuthorization, manufacturer, batchIdentifier
2450          , package_);
2451      }
2452
2453  @Override
2454  public ResourceType getResourceType() {
2455    return ResourceType.PackagedProductDefinition;
2456   }
2457
2458 /**
2459   * Search parameter: <b>identifier</b>
2460   * <p>
2461   * Description: <b>Unique identifier</b><br>
2462   * Type: <b>token</b><br>
2463   * Path: <b>PackagedProductDefinition.identifier</b><br>
2464   * </p>
2465   */
2466  @SearchParamDefinition(name="identifier", path="PackagedProductDefinition.identifier", description="Unique identifier", type="token" )
2467  public static final String SP_IDENTIFIER = "identifier";
2468 /**
2469   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2470   * <p>
2471   * Description: <b>Unique identifier</b><br>
2472   * Type: <b>token</b><br>
2473   * Path: <b>PackagedProductDefinition.identifier</b><br>
2474   * </p>
2475   */
2476  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
2477
2478 /**
2479   * Search parameter: <b>subject</b>
2480   * <p>
2481   * Description: <b>The product that this is a pack for</b><br>
2482   * Type: <b>reference</b><br>
2483   * Path: <b>PackagedProductDefinition.subject</b><br>
2484   * </p>
2485   */
2486  @SearchParamDefinition(name="subject", path="PackagedProductDefinition.subject", description="The product that this is a pack for", type="reference", target={MedicinalProductDefinition.class } )
2487  public static final String SP_SUBJECT = "subject";
2488 /**
2489   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
2490   * <p>
2491   * Description: <b>The product that this is a pack for</b><br>
2492   * Type: <b>reference</b><br>
2493   * Path: <b>PackagedProductDefinition.subject</b><br>
2494   * </p>
2495   */
2496  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
2497
2498/**
2499   * Constant for fluent queries to be used to add include statements. Specifies
2500   * the path value of "<b>PackagedProductDefinition:subject</b>".
2501   */
2502  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("PackagedProductDefinition:subject").toLocked();
2503
2504
2505}
2506