001package org.hl7.fhir.r4.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Thu, Sep 13, 2018 09:04-0400 for FHIR v3.5.0
033
034import java.util.*;
035
036import org.hl7.fhir.utilities.Utilities;
037import ca.uhn.fhir.model.api.annotation.ResourceDef;
038import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.ChildOrder;
041import ca.uhn.fhir.model.api.annotation.Description;
042import ca.uhn.fhir.model.api.annotation.Block;
043import org.hl7.fhir.instance.model.api.*;
044import org.hl7.fhir.exceptions.FHIRException;
045/**
046 * A medicinal product in a container or package.
047 */
048@ResourceDef(name="MedicinalProductPackaged", profile="http://hl7.org/fhir/StructureDefinition/MedicinalProductPackaged")
049public class MedicinalProductPackaged extends DomainResource {
050
051    @Block()
052    public static class MedicinalProductPackagedBatchIdentifierComponent extends BackboneElement implements IBaseBackboneElement {
053        /**
054         * A number appearing on the outer packaging of a specific batch.
055         */
056        @Child(name = "outerPackaging", type = {Identifier.class}, order=1, min=1, max=1, modifier=false, summary=true)
057        @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." )
058        protected Identifier outerPackaging;
059
060        /**
061         * A number appearing on the immediate packaging (and not the outer packaging).
062         */
063        @Child(name = "immediatePackaging", type = {Identifier.class}, order=2, min=0, max=1, modifier=false, summary=true)
064        @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)." )
065        protected Identifier immediatePackaging;
066
067        private static final long serialVersionUID = 1187365068L;
068
069    /**
070     * Constructor
071     */
072      public MedicinalProductPackagedBatchIdentifierComponent() {
073        super();
074      }
075
076    /**
077     * Constructor
078     */
079      public MedicinalProductPackagedBatchIdentifierComponent(Identifier outerPackaging) {
080        super();
081        this.outerPackaging = outerPackaging;
082      }
083
084        /**
085         * @return {@link #outerPackaging} (A number appearing on the outer packaging of a specific batch.)
086         */
087        public Identifier getOuterPackaging() { 
088          if (this.outerPackaging == null)
089            if (Configuration.errorOnAutoCreate())
090              throw new Error("Attempt to auto-create MedicinalProductPackagedBatchIdentifierComponent.outerPackaging");
091            else if (Configuration.doAutoCreate())
092              this.outerPackaging = new Identifier(); // cc
093          return this.outerPackaging;
094        }
095
096        public boolean hasOuterPackaging() { 
097          return this.outerPackaging != null && !this.outerPackaging.isEmpty();
098        }
099
100        /**
101         * @param value {@link #outerPackaging} (A number appearing on the outer packaging of a specific batch.)
102         */
103        public MedicinalProductPackagedBatchIdentifierComponent setOuterPackaging(Identifier value) { 
104          this.outerPackaging = value;
105          return this;
106        }
107
108        /**
109         * @return {@link #immediatePackaging} (A number appearing on the immediate packaging (and not the outer packaging).)
110         */
111        public Identifier getImmediatePackaging() { 
112          if (this.immediatePackaging == null)
113            if (Configuration.errorOnAutoCreate())
114              throw new Error("Attempt to auto-create MedicinalProductPackagedBatchIdentifierComponent.immediatePackaging");
115            else if (Configuration.doAutoCreate())
116              this.immediatePackaging = new Identifier(); // cc
117          return this.immediatePackaging;
118        }
119
120        public boolean hasImmediatePackaging() { 
121          return this.immediatePackaging != null && !this.immediatePackaging.isEmpty();
122        }
123
124        /**
125         * @param value {@link #immediatePackaging} (A number appearing on the immediate packaging (and not the outer packaging).)
126         */
127        public MedicinalProductPackagedBatchIdentifierComponent setImmediatePackaging(Identifier value) { 
128          this.immediatePackaging = value;
129          return this;
130        }
131
132        protected void listChildren(List<Property> children) {
133          super.listChildren(children);
134          children.add(new Property("outerPackaging", "Identifier", "A number appearing on the outer packaging of a specific batch.", 0, 1, outerPackaging));
135          children.add(new Property("immediatePackaging", "Identifier", "A number appearing on the immediate packaging (and not the outer packaging).", 0, 1, immediatePackaging));
136        }
137
138        @Override
139        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
140          switch (_hash) {
141          case -682249912: /*outerPackaging*/  return new Property("outerPackaging", "Identifier", "A number appearing on the outer packaging of a specific batch.", 0, 1, outerPackaging);
142          case 721147602: /*immediatePackaging*/  return new Property("immediatePackaging", "Identifier", "A number appearing on the immediate packaging (and not the outer packaging).", 0, 1, immediatePackaging);
143          default: return super.getNamedProperty(_hash, _name, _checkValid);
144          }
145
146        }
147
148      @Override
149      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
150        switch (hash) {
151        case -682249912: /*outerPackaging*/ return this.outerPackaging == null ? new Base[0] : new Base[] {this.outerPackaging}; // Identifier
152        case 721147602: /*immediatePackaging*/ return this.immediatePackaging == null ? new Base[0] : new Base[] {this.immediatePackaging}; // Identifier
153        default: return super.getProperty(hash, name, checkValid);
154        }
155
156      }
157
158      @Override
159      public Base setProperty(int hash, String name, Base value) throws FHIRException {
160        switch (hash) {
161        case -682249912: // outerPackaging
162          this.outerPackaging = castToIdentifier(value); // Identifier
163          return value;
164        case 721147602: // immediatePackaging
165          this.immediatePackaging = castToIdentifier(value); // Identifier
166          return value;
167        default: return super.setProperty(hash, name, value);
168        }
169
170      }
171
172      @Override
173      public Base setProperty(String name, Base value) throws FHIRException {
174        if (name.equals("outerPackaging")) {
175          this.outerPackaging = castToIdentifier(value); // Identifier
176        } else if (name.equals("immediatePackaging")) {
177          this.immediatePackaging = castToIdentifier(value); // Identifier
178        } else
179          return super.setProperty(name, value);
180        return value;
181      }
182
183      @Override
184      public Base makeProperty(int hash, String name) throws FHIRException {
185        switch (hash) {
186        case -682249912:  return getOuterPackaging(); 
187        case 721147602:  return getImmediatePackaging(); 
188        default: return super.makeProperty(hash, name);
189        }
190
191      }
192
193      @Override
194      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
195        switch (hash) {
196        case -682249912: /*outerPackaging*/ return new String[] {"Identifier"};
197        case 721147602: /*immediatePackaging*/ return new String[] {"Identifier"};
198        default: return super.getTypesForProperty(hash, name);
199        }
200
201      }
202
203      @Override
204      public Base addChild(String name) throws FHIRException {
205        if (name.equals("outerPackaging")) {
206          this.outerPackaging = new Identifier();
207          return this.outerPackaging;
208        }
209        else if (name.equals("immediatePackaging")) {
210          this.immediatePackaging = new Identifier();
211          return this.immediatePackaging;
212        }
213        else
214          return super.addChild(name);
215      }
216
217      public MedicinalProductPackagedBatchIdentifierComponent copy() {
218        MedicinalProductPackagedBatchIdentifierComponent dst = new MedicinalProductPackagedBatchIdentifierComponent();
219        copyValues(dst);
220        dst.outerPackaging = outerPackaging == null ? null : outerPackaging.copy();
221        dst.immediatePackaging = immediatePackaging == null ? null : immediatePackaging.copy();
222        return dst;
223      }
224
225      @Override
226      public boolean equalsDeep(Base other_) {
227        if (!super.equalsDeep(other_))
228          return false;
229        if (!(other_ instanceof MedicinalProductPackagedBatchIdentifierComponent))
230          return false;
231        MedicinalProductPackagedBatchIdentifierComponent o = (MedicinalProductPackagedBatchIdentifierComponent) other_;
232        return compareDeep(outerPackaging, o.outerPackaging, true) && compareDeep(immediatePackaging, o.immediatePackaging, true)
233          ;
234      }
235
236      @Override
237      public boolean equalsShallow(Base other_) {
238        if (!super.equalsShallow(other_))
239          return false;
240        if (!(other_ instanceof MedicinalProductPackagedBatchIdentifierComponent))
241          return false;
242        MedicinalProductPackagedBatchIdentifierComponent o = (MedicinalProductPackagedBatchIdentifierComponent) other_;
243        return true;
244      }
245
246      public boolean isEmpty() {
247        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(outerPackaging, immediatePackaging
248          );
249      }
250
251  public String fhirType() {
252    return "MedicinalProductPackaged.batchIdentifier";
253
254  }
255
256  }
257
258    @Block()
259    public static class MedicinalProductPackagedPackageItemComponent extends BackboneElement implements IBaseBackboneElement {
260        /**
261         * Including possibly Data Carrier Identifier.
262         */
263        @Child(name = "identifier", type = {Identifier.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
264        @Description(shortDefinition="Including possibly Data Carrier Identifier", formalDefinition="Including possibly Data Carrier Identifier." )
265        protected List<Identifier> identifier;
266
267        /**
268         * The physical type of the container of the medicine.
269         */
270        @Child(name = "type", type = {CodeableConcept.class}, order=2, min=1, max=1, modifier=false, summary=true)
271        @Description(shortDefinition="The physical type of the container of the medicine", formalDefinition="The physical type of the container of the medicine." )
272        protected CodeableConcept type;
273
274        /**
275         * The quantity of this package in the medicinal product, at the current level of packaging. The outermost is always 1.
276         */
277        @Child(name = "quantity", type = {Quantity.class}, order=3, min=1, max=1, modifier=false, summary=true)
278        @Description(shortDefinition="The quantity of this package in the medicinal product, at the current level of packaging. The outermost is always 1", formalDefinition="The quantity of this package in the medicinal product, at the current level of packaging. The outermost is always 1." )
279        protected Quantity quantity;
280
281        /**
282         * Material type of the package item.
283         */
284        @Child(name = "material", type = {CodeableConcept.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
285        @Description(shortDefinition="Material type of the package item", formalDefinition="Material type of the package item." )
286        protected List<CodeableConcept> material;
287
288        /**
289         * A possible alternate material for the packaging.
290         */
291        @Child(name = "alternateMaterial", type = {CodeableConcept.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
292        @Description(shortDefinition="A possible alternate material for the packaging", formalDefinition="A possible alternate material for the packaging." )
293        protected List<CodeableConcept> alternateMaterial;
294
295        /**
296         * A device accompanying a medicinal product.
297         */
298        @Child(name = "device", type = {MedicinalProductDeviceSpec.class, DeviceDefinition.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
299        @Description(shortDefinition="A device accompanying a medicinal product", formalDefinition="A device accompanying a medicinal product." )
300        protected List<Reference> device;
301        /**
302         * The actual objects that are the target of the reference (A device accompanying a medicinal product.)
303         */
304        protected List<Resource> deviceTarget;
305
306
307        /**
308         * The manufactured item as contained in the packaged medicinal product.
309         */
310        @Child(name = "manufacturedItem", type = {MedicinalProductManufactured.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
311        @Description(shortDefinition="The manufactured item as contained in the packaged medicinal product", formalDefinition="The manufactured item as contained in the packaged medicinal product." )
312        protected List<Reference> manufacturedItem;
313        /**
314         * The actual objects that are the target of the reference (The manufactured item as contained in the packaged medicinal product.)
315         */
316        protected List<MedicinalProductManufactured> manufacturedItemTarget;
317
318
319        /**
320         * Allows containers within containers.
321         */
322        @Child(name = "packageItem", type = {MedicinalProductPackagedPackageItemComponent.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
323        @Description(shortDefinition="Allows containers within containers", formalDefinition="Allows containers within containers." )
324        protected List<MedicinalProductPackagedPackageItemComponent> packageItem;
325
326        /**
327         * Dimensions, color etc.
328         */
329        @Child(name = "physicalCharacteristics", type = {ProdCharacteristic.class}, order=9, min=0, max=1, modifier=false, summary=true)
330        @Description(shortDefinition="Dimensions, color etc.", formalDefinition="Dimensions, color etc." )
331        protected ProdCharacteristic physicalCharacteristics;
332
333        /**
334         * Other codeable characteristics.
335         */
336        @Child(name = "otherCharacteristics", type = {CodeableConcept.class}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
337        @Description(shortDefinition="Other codeable characteristics", formalDefinition="Other codeable characteristics." )
338        protected List<CodeableConcept> otherCharacteristics;
339
340        /**
341         * Shelf Life and storage information.
342         */
343        @Child(name = "shelfLifeStorage", type = {ProductShelfLife.class}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
344        @Description(shortDefinition="Shelf Life and storage information", formalDefinition="Shelf Life and storage information." )
345        protected List<ProductShelfLife> shelfLifeStorage;
346
347        /**
348         * Manufacturer of this Package Item.
349         */
350        @Child(name = "manufacturer", type = {Organization.class}, order=12, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
351        @Description(shortDefinition="Manufacturer of this Package Item", formalDefinition="Manufacturer of this Package Item." )
352        protected List<Reference> manufacturer;
353        /**
354         * The actual objects that are the target of the reference (Manufacturer of this Package Item.)
355         */
356        protected List<Organization> manufacturerTarget;
357
358
359        private static final long serialVersionUID = -712776950L;
360
361    /**
362     * Constructor
363     */
364      public MedicinalProductPackagedPackageItemComponent() {
365        super();
366      }
367
368    /**
369     * Constructor
370     */
371      public MedicinalProductPackagedPackageItemComponent(CodeableConcept type, Quantity quantity) {
372        super();
373        this.type = type;
374        this.quantity = quantity;
375      }
376
377        /**
378         * @return {@link #identifier} (Including possibly Data Carrier Identifier.)
379         */
380        public List<Identifier> getIdentifier() { 
381          if (this.identifier == null)
382            this.identifier = new ArrayList<Identifier>();
383          return this.identifier;
384        }
385
386        /**
387         * @return Returns a reference to <code>this</code> for easy method chaining
388         */
389        public MedicinalProductPackagedPackageItemComponent setIdentifier(List<Identifier> theIdentifier) { 
390          this.identifier = theIdentifier;
391          return this;
392        }
393
394        public boolean hasIdentifier() { 
395          if (this.identifier == null)
396            return false;
397          for (Identifier item : this.identifier)
398            if (!item.isEmpty())
399              return true;
400          return false;
401        }
402
403        public Identifier addIdentifier() { //3
404          Identifier t = new Identifier();
405          if (this.identifier == null)
406            this.identifier = new ArrayList<Identifier>();
407          this.identifier.add(t);
408          return t;
409        }
410
411        public MedicinalProductPackagedPackageItemComponent addIdentifier(Identifier t) { //3
412          if (t == null)
413            return this;
414          if (this.identifier == null)
415            this.identifier = new ArrayList<Identifier>();
416          this.identifier.add(t);
417          return this;
418        }
419
420        /**
421         * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
422         */
423        public Identifier getIdentifierFirstRep() { 
424          if (getIdentifier().isEmpty()) {
425            addIdentifier();
426          }
427          return getIdentifier().get(0);
428        }
429
430        /**
431         * @return {@link #type} (The physical type of the container of the medicine.)
432         */
433        public CodeableConcept getType() { 
434          if (this.type == null)
435            if (Configuration.errorOnAutoCreate())
436              throw new Error("Attempt to auto-create MedicinalProductPackagedPackageItemComponent.type");
437            else if (Configuration.doAutoCreate())
438              this.type = new CodeableConcept(); // cc
439          return this.type;
440        }
441
442        public boolean hasType() { 
443          return this.type != null && !this.type.isEmpty();
444        }
445
446        /**
447         * @param value {@link #type} (The physical type of the container of the medicine.)
448         */
449        public MedicinalProductPackagedPackageItemComponent setType(CodeableConcept value) { 
450          this.type = value;
451          return this;
452        }
453
454        /**
455         * @return {@link #quantity} (The quantity of this package in the medicinal product, at the current level of packaging. The outermost is always 1.)
456         */
457        public Quantity getQuantity() { 
458          if (this.quantity == null)
459            if (Configuration.errorOnAutoCreate())
460              throw new Error("Attempt to auto-create MedicinalProductPackagedPackageItemComponent.quantity");
461            else if (Configuration.doAutoCreate())
462              this.quantity = new Quantity(); // cc
463          return this.quantity;
464        }
465
466        public boolean hasQuantity() { 
467          return this.quantity != null && !this.quantity.isEmpty();
468        }
469
470        /**
471         * @param value {@link #quantity} (The quantity of this package in the medicinal product, at the current level of packaging. The outermost is always 1.)
472         */
473        public MedicinalProductPackagedPackageItemComponent setQuantity(Quantity value) { 
474          this.quantity = value;
475          return this;
476        }
477
478        /**
479         * @return {@link #material} (Material type of the package item.)
480         */
481        public List<CodeableConcept> getMaterial() { 
482          if (this.material == null)
483            this.material = new ArrayList<CodeableConcept>();
484          return this.material;
485        }
486
487        /**
488         * @return Returns a reference to <code>this</code> for easy method chaining
489         */
490        public MedicinalProductPackagedPackageItemComponent setMaterial(List<CodeableConcept> theMaterial) { 
491          this.material = theMaterial;
492          return this;
493        }
494
495        public boolean hasMaterial() { 
496          if (this.material == null)
497            return false;
498          for (CodeableConcept item : this.material)
499            if (!item.isEmpty())
500              return true;
501          return false;
502        }
503
504        public CodeableConcept addMaterial() { //3
505          CodeableConcept t = new CodeableConcept();
506          if (this.material == null)
507            this.material = new ArrayList<CodeableConcept>();
508          this.material.add(t);
509          return t;
510        }
511
512        public MedicinalProductPackagedPackageItemComponent addMaterial(CodeableConcept t) { //3
513          if (t == null)
514            return this;
515          if (this.material == null)
516            this.material = new ArrayList<CodeableConcept>();
517          this.material.add(t);
518          return this;
519        }
520
521        /**
522         * @return The first repetition of repeating field {@link #material}, creating it if it does not already exist
523         */
524        public CodeableConcept getMaterialFirstRep() { 
525          if (getMaterial().isEmpty()) {
526            addMaterial();
527          }
528          return getMaterial().get(0);
529        }
530
531        /**
532         * @return {@link #alternateMaterial} (A possible alternate material for the packaging.)
533         */
534        public List<CodeableConcept> getAlternateMaterial() { 
535          if (this.alternateMaterial == null)
536            this.alternateMaterial = new ArrayList<CodeableConcept>();
537          return this.alternateMaterial;
538        }
539
540        /**
541         * @return Returns a reference to <code>this</code> for easy method chaining
542         */
543        public MedicinalProductPackagedPackageItemComponent setAlternateMaterial(List<CodeableConcept> theAlternateMaterial) { 
544          this.alternateMaterial = theAlternateMaterial;
545          return this;
546        }
547
548        public boolean hasAlternateMaterial() { 
549          if (this.alternateMaterial == null)
550            return false;
551          for (CodeableConcept item : this.alternateMaterial)
552            if (!item.isEmpty())
553              return true;
554          return false;
555        }
556
557        public CodeableConcept addAlternateMaterial() { //3
558          CodeableConcept t = new CodeableConcept();
559          if (this.alternateMaterial == null)
560            this.alternateMaterial = new ArrayList<CodeableConcept>();
561          this.alternateMaterial.add(t);
562          return t;
563        }
564
565        public MedicinalProductPackagedPackageItemComponent addAlternateMaterial(CodeableConcept t) { //3
566          if (t == null)
567            return this;
568          if (this.alternateMaterial == null)
569            this.alternateMaterial = new ArrayList<CodeableConcept>();
570          this.alternateMaterial.add(t);
571          return this;
572        }
573
574        /**
575         * @return The first repetition of repeating field {@link #alternateMaterial}, creating it if it does not already exist
576         */
577        public CodeableConcept getAlternateMaterialFirstRep() { 
578          if (getAlternateMaterial().isEmpty()) {
579            addAlternateMaterial();
580          }
581          return getAlternateMaterial().get(0);
582        }
583
584        /**
585         * @return {@link #device} (A device accompanying a medicinal product.)
586         */
587        public List<Reference> getDevice() { 
588          if (this.device == null)
589            this.device = new ArrayList<Reference>();
590          return this.device;
591        }
592
593        /**
594         * @return Returns a reference to <code>this</code> for easy method chaining
595         */
596        public MedicinalProductPackagedPackageItemComponent setDevice(List<Reference> theDevice) { 
597          this.device = theDevice;
598          return this;
599        }
600
601        public boolean hasDevice() { 
602          if (this.device == null)
603            return false;
604          for (Reference item : this.device)
605            if (!item.isEmpty())
606              return true;
607          return false;
608        }
609
610        public Reference addDevice() { //3
611          Reference t = new Reference();
612          if (this.device == null)
613            this.device = new ArrayList<Reference>();
614          this.device.add(t);
615          return t;
616        }
617
618        public MedicinalProductPackagedPackageItemComponent addDevice(Reference t) { //3
619          if (t == null)
620            return this;
621          if (this.device == null)
622            this.device = new ArrayList<Reference>();
623          this.device.add(t);
624          return this;
625        }
626
627        /**
628         * @return The first repetition of repeating field {@link #device}, creating it if it does not already exist
629         */
630        public Reference getDeviceFirstRep() { 
631          if (getDevice().isEmpty()) {
632            addDevice();
633          }
634          return getDevice().get(0);
635        }
636
637        /**
638         * @deprecated Use Reference#setResource(IBaseResource) instead
639         */
640        @Deprecated
641        public List<Resource> getDeviceTarget() { 
642          if (this.deviceTarget == null)
643            this.deviceTarget = new ArrayList<Resource>();
644          return this.deviceTarget;
645        }
646
647        /**
648         * @return {@link #manufacturedItem} (The manufactured item as contained in the packaged medicinal product.)
649         */
650        public List<Reference> getManufacturedItem() { 
651          if (this.manufacturedItem == null)
652            this.manufacturedItem = new ArrayList<Reference>();
653          return this.manufacturedItem;
654        }
655
656        /**
657         * @return Returns a reference to <code>this</code> for easy method chaining
658         */
659        public MedicinalProductPackagedPackageItemComponent setManufacturedItem(List<Reference> theManufacturedItem) { 
660          this.manufacturedItem = theManufacturedItem;
661          return this;
662        }
663
664        public boolean hasManufacturedItem() { 
665          if (this.manufacturedItem == null)
666            return false;
667          for (Reference item : this.manufacturedItem)
668            if (!item.isEmpty())
669              return true;
670          return false;
671        }
672
673        public Reference addManufacturedItem() { //3
674          Reference t = new Reference();
675          if (this.manufacturedItem == null)
676            this.manufacturedItem = new ArrayList<Reference>();
677          this.manufacturedItem.add(t);
678          return t;
679        }
680
681        public MedicinalProductPackagedPackageItemComponent addManufacturedItem(Reference t) { //3
682          if (t == null)
683            return this;
684          if (this.manufacturedItem == null)
685            this.manufacturedItem = new ArrayList<Reference>();
686          this.manufacturedItem.add(t);
687          return this;
688        }
689
690        /**
691         * @return The first repetition of repeating field {@link #manufacturedItem}, creating it if it does not already exist
692         */
693        public Reference getManufacturedItemFirstRep() { 
694          if (getManufacturedItem().isEmpty()) {
695            addManufacturedItem();
696          }
697          return getManufacturedItem().get(0);
698        }
699
700        /**
701         * @deprecated Use Reference#setResource(IBaseResource) instead
702         */
703        @Deprecated
704        public List<MedicinalProductManufactured> getManufacturedItemTarget() { 
705          if (this.manufacturedItemTarget == null)
706            this.manufacturedItemTarget = new ArrayList<MedicinalProductManufactured>();
707          return this.manufacturedItemTarget;
708        }
709
710        /**
711         * @deprecated Use Reference#setResource(IBaseResource) instead
712         */
713        @Deprecated
714        public MedicinalProductManufactured addManufacturedItemTarget() { 
715          MedicinalProductManufactured r = new MedicinalProductManufactured();
716          if (this.manufacturedItemTarget == null)
717            this.manufacturedItemTarget = new ArrayList<MedicinalProductManufactured>();
718          this.manufacturedItemTarget.add(r);
719          return r;
720        }
721
722        /**
723         * @return {@link #packageItem} (Allows containers within containers.)
724         */
725        public List<MedicinalProductPackagedPackageItemComponent> getPackageItem() { 
726          if (this.packageItem == null)
727            this.packageItem = new ArrayList<MedicinalProductPackagedPackageItemComponent>();
728          return this.packageItem;
729        }
730
731        /**
732         * @return Returns a reference to <code>this</code> for easy method chaining
733         */
734        public MedicinalProductPackagedPackageItemComponent setPackageItem(List<MedicinalProductPackagedPackageItemComponent> thePackageItem) { 
735          this.packageItem = thePackageItem;
736          return this;
737        }
738
739        public boolean hasPackageItem() { 
740          if (this.packageItem == null)
741            return false;
742          for (MedicinalProductPackagedPackageItemComponent item : this.packageItem)
743            if (!item.isEmpty())
744              return true;
745          return false;
746        }
747
748        public MedicinalProductPackagedPackageItemComponent addPackageItem() { //3
749          MedicinalProductPackagedPackageItemComponent t = new MedicinalProductPackagedPackageItemComponent();
750          if (this.packageItem == null)
751            this.packageItem = new ArrayList<MedicinalProductPackagedPackageItemComponent>();
752          this.packageItem.add(t);
753          return t;
754        }
755
756        public MedicinalProductPackagedPackageItemComponent addPackageItem(MedicinalProductPackagedPackageItemComponent t) { //3
757          if (t == null)
758            return this;
759          if (this.packageItem == null)
760            this.packageItem = new ArrayList<MedicinalProductPackagedPackageItemComponent>();
761          this.packageItem.add(t);
762          return this;
763        }
764
765        /**
766         * @return The first repetition of repeating field {@link #packageItem}, creating it if it does not already exist
767         */
768        public MedicinalProductPackagedPackageItemComponent getPackageItemFirstRep() { 
769          if (getPackageItem().isEmpty()) {
770            addPackageItem();
771          }
772          return getPackageItem().get(0);
773        }
774
775        /**
776         * @return {@link #physicalCharacteristics} (Dimensions, color etc.)
777         */
778        public ProdCharacteristic getPhysicalCharacteristics() { 
779          if (this.physicalCharacteristics == null)
780            if (Configuration.errorOnAutoCreate())
781              throw new Error("Attempt to auto-create MedicinalProductPackagedPackageItemComponent.physicalCharacteristics");
782            else if (Configuration.doAutoCreate())
783              this.physicalCharacteristics = new ProdCharacteristic(); // cc
784          return this.physicalCharacteristics;
785        }
786
787        public boolean hasPhysicalCharacteristics() { 
788          return this.physicalCharacteristics != null && !this.physicalCharacteristics.isEmpty();
789        }
790
791        /**
792         * @param value {@link #physicalCharacteristics} (Dimensions, color etc.)
793         */
794        public MedicinalProductPackagedPackageItemComponent setPhysicalCharacteristics(ProdCharacteristic value) { 
795          this.physicalCharacteristics = value;
796          return this;
797        }
798
799        /**
800         * @return {@link #otherCharacteristics} (Other codeable characteristics.)
801         */
802        public List<CodeableConcept> getOtherCharacteristics() { 
803          if (this.otherCharacteristics == null)
804            this.otherCharacteristics = new ArrayList<CodeableConcept>();
805          return this.otherCharacteristics;
806        }
807
808        /**
809         * @return Returns a reference to <code>this</code> for easy method chaining
810         */
811        public MedicinalProductPackagedPackageItemComponent setOtherCharacteristics(List<CodeableConcept> theOtherCharacteristics) { 
812          this.otherCharacteristics = theOtherCharacteristics;
813          return this;
814        }
815
816        public boolean hasOtherCharacteristics() { 
817          if (this.otherCharacteristics == null)
818            return false;
819          for (CodeableConcept item : this.otherCharacteristics)
820            if (!item.isEmpty())
821              return true;
822          return false;
823        }
824
825        public CodeableConcept addOtherCharacteristics() { //3
826          CodeableConcept t = new CodeableConcept();
827          if (this.otherCharacteristics == null)
828            this.otherCharacteristics = new ArrayList<CodeableConcept>();
829          this.otherCharacteristics.add(t);
830          return t;
831        }
832
833        public MedicinalProductPackagedPackageItemComponent addOtherCharacteristics(CodeableConcept t) { //3
834          if (t == null)
835            return this;
836          if (this.otherCharacteristics == null)
837            this.otherCharacteristics = new ArrayList<CodeableConcept>();
838          this.otherCharacteristics.add(t);
839          return this;
840        }
841
842        /**
843         * @return The first repetition of repeating field {@link #otherCharacteristics}, creating it if it does not already exist
844         */
845        public CodeableConcept getOtherCharacteristicsFirstRep() { 
846          if (getOtherCharacteristics().isEmpty()) {
847            addOtherCharacteristics();
848          }
849          return getOtherCharacteristics().get(0);
850        }
851
852        /**
853         * @return {@link #shelfLifeStorage} (Shelf Life and storage information.)
854         */
855        public List<ProductShelfLife> getShelfLifeStorage() { 
856          if (this.shelfLifeStorage == null)
857            this.shelfLifeStorage = new ArrayList<ProductShelfLife>();
858          return this.shelfLifeStorage;
859        }
860
861        /**
862         * @return Returns a reference to <code>this</code> for easy method chaining
863         */
864        public MedicinalProductPackagedPackageItemComponent setShelfLifeStorage(List<ProductShelfLife> theShelfLifeStorage) { 
865          this.shelfLifeStorage = theShelfLifeStorage;
866          return this;
867        }
868
869        public boolean hasShelfLifeStorage() { 
870          if (this.shelfLifeStorage == null)
871            return false;
872          for (ProductShelfLife item : this.shelfLifeStorage)
873            if (!item.isEmpty())
874              return true;
875          return false;
876        }
877
878        public ProductShelfLife addShelfLifeStorage() { //3
879          ProductShelfLife t = new ProductShelfLife();
880          if (this.shelfLifeStorage == null)
881            this.shelfLifeStorage = new ArrayList<ProductShelfLife>();
882          this.shelfLifeStorage.add(t);
883          return t;
884        }
885
886        public MedicinalProductPackagedPackageItemComponent addShelfLifeStorage(ProductShelfLife t) { //3
887          if (t == null)
888            return this;
889          if (this.shelfLifeStorage == null)
890            this.shelfLifeStorage = new ArrayList<ProductShelfLife>();
891          this.shelfLifeStorage.add(t);
892          return this;
893        }
894
895        /**
896         * @return The first repetition of repeating field {@link #shelfLifeStorage}, creating it if it does not already exist
897         */
898        public ProductShelfLife getShelfLifeStorageFirstRep() { 
899          if (getShelfLifeStorage().isEmpty()) {
900            addShelfLifeStorage();
901          }
902          return getShelfLifeStorage().get(0);
903        }
904
905        /**
906         * @return {@link #manufacturer} (Manufacturer of this Package Item.)
907         */
908        public List<Reference> getManufacturer() { 
909          if (this.manufacturer == null)
910            this.manufacturer = new ArrayList<Reference>();
911          return this.manufacturer;
912        }
913
914        /**
915         * @return Returns a reference to <code>this</code> for easy method chaining
916         */
917        public MedicinalProductPackagedPackageItemComponent setManufacturer(List<Reference> theManufacturer) { 
918          this.manufacturer = theManufacturer;
919          return this;
920        }
921
922        public boolean hasManufacturer() { 
923          if (this.manufacturer == null)
924            return false;
925          for (Reference item : this.manufacturer)
926            if (!item.isEmpty())
927              return true;
928          return false;
929        }
930
931        public Reference addManufacturer() { //3
932          Reference t = new Reference();
933          if (this.manufacturer == null)
934            this.manufacturer = new ArrayList<Reference>();
935          this.manufacturer.add(t);
936          return t;
937        }
938
939        public MedicinalProductPackagedPackageItemComponent addManufacturer(Reference t) { //3
940          if (t == null)
941            return this;
942          if (this.manufacturer == null)
943            this.manufacturer = new ArrayList<Reference>();
944          this.manufacturer.add(t);
945          return this;
946        }
947
948        /**
949         * @return The first repetition of repeating field {@link #manufacturer}, creating it if it does not already exist
950         */
951        public Reference getManufacturerFirstRep() { 
952          if (getManufacturer().isEmpty()) {
953            addManufacturer();
954          }
955          return getManufacturer().get(0);
956        }
957
958        /**
959         * @deprecated Use Reference#setResource(IBaseResource) instead
960         */
961        @Deprecated
962        public List<Organization> getManufacturerTarget() { 
963          if (this.manufacturerTarget == null)
964            this.manufacturerTarget = new ArrayList<Organization>();
965          return this.manufacturerTarget;
966        }
967
968        /**
969         * @deprecated Use Reference#setResource(IBaseResource) instead
970         */
971        @Deprecated
972        public Organization addManufacturerTarget() { 
973          Organization r = new Organization();
974          if (this.manufacturerTarget == null)
975            this.manufacturerTarget = new ArrayList<Organization>();
976          this.manufacturerTarget.add(r);
977          return r;
978        }
979
980        protected void listChildren(List<Property> children) {
981          super.listChildren(children);
982          children.add(new Property("identifier", "Identifier", "Including possibly Data Carrier Identifier.", 0, java.lang.Integer.MAX_VALUE, identifier));
983          children.add(new Property("type", "CodeableConcept", "The physical type of the container of the medicine.", 0, 1, type));
984          children.add(new Property("quantity", "Quantity", "The quantity of this package in the medicinal product, at the current level of packaging. The outermost is always 1.", 0, 1, quantity));
985          children.add(new Property("material", "CodeableConcept", "Material type of the package item.", 0, java.lang.Integer.MAX_VALUE, material));
986          children.add(new Property("alternateMaterial", "CodeableConcept", "A possible alternate material for the packaging.", 0, java.lang.Integer.MAX_VALUE, alternateMaterial));
987          children.add(new Property("device", "Reference(MedicinalProductDeviceSpec|DeviceDefinition)", "A device accompanying a medicinal product.", 0, java.lang.Integer.MAX_VALUE, device));
988          children.add(new Property("manufacturedItem", "Reference(MedicinalProductManufactured)", "The manufactured item as contained in the packaged medicinal product.", 0, java.lang.Integer.MAX_VALUE, manufacturedItem));
989          children.add(new Property("packageItem", "@MedicinalProductPackaged.packageItem", "Allows containers within containers.", 0, java.lang.Integer.MAX_VALUE, packageItem));
990          children.add(new Property("physicalCharacteristics", "ProdCharacteristic", "Dimensions, color etc.", 0, 1, physicalCharacteristics));
991          children.add(new Property("otherCharacteristics", "CodeableConcept", "Other codeable characteristics.", 0, java.lang.Integer.MAX_VALUE, otherCharacteristics));
992          children.add(new Property("shelfLifeStorage", "ProductShelfLife", "Shelf Life and storage information.", 0, java.lang.Integer.MAX_VALUE, shelfLifeStorage));
993          children.add(new Property("manufacturer", "Reference(Organization)", "Manufacturer of this Package Item.", 0, java.lang.Integer.MAX_VALUE, manufacturer));
994        }
995
996        @Override
997        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
998          switch (_hash) {
999          case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Including possibly Data Carrier Identifier.", 0, java.lang.Integer.MAX_VALUE, identifier);
1000          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "The physical type of the container of the medicine.", 0, 1, type);
1001          case -1285004149: /*quantity*/  return new Property("quantity", "Quantity", "The quantity of this package in the medicinal product, at the current level of packaging. The outermost is always 1.", 0, 1, quantity);
1002          case 299066663: /*material*/  return new Property("material", "CodeableConcept", "Material type of the package item.", 0, java.lang.Integer.MAX_VALUE, material);
1003          case -1021448255: /*alternateMaterial*/  return new Property("alternateMaterial", "CodeableConcept", "A possible alternate material for the packaging.", 0, java.lang.Integer.MAX_VALUE, alternateMaterial);
1004          case -1335157162: /*device*/  return new Property("device", "Reference(MedicinalProductDeviceSpec|DeviceDefinition)", "A device accompanying a medicinal product.", 0, java.lang.Integer.MAX_VALUE, device);
1005          case 62093686: /*manufacturedItem*/  return new Property("manufacturedItem", "Reference(MedicinalProductManufactured)", "The manufactured item as contained in the packaged medicinal product.", 0, java.lang.Integer.MAX_VALUE, manufacturedItem);
1006          case 908628089: /*packageItem*/  return new Property("packageItem", "@MedicinalProductPackaged.packageItem", "Allows containers within containers.", 0, java.lang.Integer.MAX_VALUE, packageItem);
1007          case -1599676319: /*physicalCharacteristics*/  return new Property("physicalCharacteristics", "ProdCharacteristic", "Dimensions, color etc.", 0, 1, physicalCharacteristics);
1008          case 722135304: /*otherCharacteristics*/  return new Property("otherCharacteristics", "CodeableConcept", "Other codeable characteristics.", 0, java.lang.Integer.MAX_VALUE, otherCharacteristics);
1009          case 172049237: /*shelfLifeStorage*/  return new Property("shelfLifeStorage", "ProductShelfLife", "Shelf Life and storage information.", 0, java.lang.Integer.MAX_VALUE, shelfLifeStorage);
1010          case -1969347631: /*manufacturer*/  return new Property("manufacturer", "Reference(Organization)", "Manufacturer of this Package Item.", 0, java.lang.Integer.MAX_VALUE, manufacturer);
1011          default: return super.getNamedProperty(_hash, _name, _checkValid);
1012          }
1013
1014        }
1015
1016      @Override
1017      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1018        switch (hash) {
1019        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1020        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
1021        case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // Quantity
1022        case 299066663: /*material*/ return this.material == null ? new Base[0] : this.material.toArray(new Base[this.material.size()]); // CodeableConcept
1023        case -1021448255: /*alternateMaterial*/ return this.alternateMaterial == null ? new Base[0] : this.alternateMaterial.toArray(new Base[this.alternateMaterial.size()]); // CodeableConcept
1024        case -1335157162: /*device*/ return this.device == null ? new Base[0] : this.device.toArray(new Base[this.device.size()]); // Reference
1025        case 62093686: /*manufacturedItem*/ return this.manufacturedItem == null ? new Base[0] : this.manufacturedItem.toArray(new Base[this.manufacturedItem.size()]); // Reference
1026        case 908628089: /*packageItem*/ return this.packageItem == null ? new Base[0] : this.packageItem.toArray(new Base[this.packageItem.size()]); // MedicinalProductPackagedPackageItemComponent
1027        case -1599676319: /*physicalCharacteristics*/ return this.physicalCharacteristics == null ? new Base[0] : new Base[] {this.physicalCharacteristics}; // ProdCharacteristic
1028        case 722135304: /*otherCharacteristics*/ return this.otherCharacteristics == null ? new Base[0] : this.otherCharacteristics.toArray(new Base[this.otherCharacteristics.size()]); // CodeableConcept
1029        case 172049237: /*shelfLifeStorage*/ return this.shelfLifeStorage == null ? new Base[0] : this.shelfLifeStorage.toArray(new Base[this.shelfLifeStorage.size()]); // ProductShelfLife
1030        case -1969347631: /*manufacturer*/ return this.manufacturer == null ? new Base[0] : this.manufacturer.toArray(new Base[this.manufacturer.size()]); // Reference
1031        default: return super.getProperty(hash, name, checkValid);
1032        }
1033
1034      }
1035
1036      @Override
1037      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1038        switch (hash) {
1039        case -1618432855: // identifier
1040          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1041          return value;
1042        case 3575610: // type
1043          this.type = castToCodeableConcept(value); // CodeableConcept
1044          return value;
1045        case -1285004149: // quantity
1046          this.quantity = castToQuantity(value); // Quantity
1047          return value;
1048        case 299066663: // material
1049          this.getMaterial().add(castToCodeableConcept(value)); // CodeableConcept
1050          return value;
1051        case -1021448255: // alternateMaterial
1052          this.getAlternateMaterial().add(castToCodeableConcept(value)); // CodeableConcept
1053          return value;
1054        case -1335157162: // device
1055          this.getDevice().add(castToReference(value)); // Reference
1056          return value;
1057        case 62093686: // manufacturedItem
1058          this.getManufacturedItem().add(castToReference(value)); // Reference
1059          return value;
1060        case 908628089: // packageItem
1061          this.getPackageItem().add((MedicinalProductPackagedPackageItemComponent) value); // MedicinalProductPackagedPackageItemComponent
1062          return value;
1063        case -1599676319: // physicalCharacteristics
1064          this.physicalCharacteristics = castToProdCharacteristic(value); // ProdCharacteristic
1065          return value;
1066        case 722135304: // otherCharacteristics
1067          this.getOtherCharacteristics().add(castToCodeableConcept(value)); // CodeableConcept
1068          return value;
1069        case 172049237: // shelfLifeStorage
1070          this.getShelfLifeStorage().add(castToProductShelfLife(value)); // ProductShelfLife
1071          return value;
1072        case -1969347631: // manufacturer
1073          this.getManufacturer().add(castToReference(value)); // Reference
1074          return value;
1075        default: return super.setProperty(hash, name, value);
1076        }
1077
1078      }
1079
1080      @Override
1081      public Base setProperty(String name, Base value) throws FHIRException {
1082        if (name.equals("identifier")) {
1083          this.getIdentifier().add(castToIdentifier(value));
1084        } else if (name.equals("type")) {
1085          this.type = castToCodeableConcept(value); // CodeableConcept
1086        } else if (name.equals("quantity")) {
1087          this.quantity = castToQuantity(value); // Quantity
1088        } else if (name.equals("material")) {
1089          this.getMaterial().add(castToCodeableConcept(value));
1090        } else if (name.equals("alternateMaterial")) {
1091          this.getAlternateMaterial().add(castToCodeableConcept(value));
1092        } else if (name.equals("device")) {
1093          this.getDevice().add(castToReference(value));
1094        } else if (name.equals("manufacturedItem")) {
1095          this.getManufacturedItem().add(castToReference(value));
1096        } else if (name.equals("packageItem")) {
1097          this.getPackageItem().add((MedicinalProductPackagedPackageItemComponent) value);
1098        } else if (name.equals("physicalCharacteristics")) {
1099          this.physicalCharacteristics = castToProdCharacteristic(value); // ProdCharacteristic
1100        } else if (name.equals("otherCharacteristics")) {
1101          this.getOtherCharacteristics().add(castToCodeableConcept(value));
1102        } else if (name.equals("shelfLifeStorage")) {
1103          this.getShelfLifeStorage().add(castToProductShelfLife(value));
1104        } else if (name.equals("manufacturer")) {
1105          this.getManufacturer().add(castToReference(value));
1106        } else
1107          return super.setProperty(name, value);
1108        return value;
1109      }
1110
1111      @Override
1112      public Base makeProperty(int hash, String name) throws FHIRException {
1113        switch (hash) {
1114        case -1618432855:  return addIdentifier(); 
1115        case 3575610:  return getType(); 
1116        case -1285004149:  return getQuantity(); 
1117        case 299066663:  return addMaterial(); 
1118        case -1021448255:  return addAlternateMaterial(); 
1119        case -1335157162:  return addDevice(); 
1120        case 62093686:  return addManufacturedItem(); 
1121        case 908628089:  return addPackageItem(); 
1122        case -1599676319:  return getPhysicalCharacteristics(); 
1123        case 722135304:  return addOtherCharacteristics(); 
1124        case 172049237:  return addShelfLifeStorage(); 
1125        case -1969347631:  return addManufacturer(); 
1126        default: return super.makeProperty(hash, name);
1127        }
1128
1129      }
1130
1131      @Override
1132      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1133        switch (hash) {
1134        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
1135        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
1136        case -1285004149: /*quantity*/ return new String[] {"Quantity"};
1137        case 299066663: /*material*/ return new String[] {"CodeableConcept"};
1138        case -1021448255: /*alternateMaterial*/ return new String[] {"CodeableConcept"};
1139        case -1335157162: /*device*/ return new String[] {"Reference"};
1140        case 62093686: /*manufacturedItem*/ return new String[] {"Reference"};
1141        case 908628089: /*packageItem*/ return new String[] {"@MedicinalProductPackaged.packageItem"};
1142        case -1599676319: /*physicalCharacteristics*/ return new String[] {"ProdCharacteristic"};
1143        case 722135304: /*otherCharacteristics*/ return new String[] {"CodeableConcept"};
1144        case 172049237: /*shelfLifeStorage*/ return new String[] {"ProductShelfLife"};
1145        case -1969347631: /*manufacturer*/ return new String[] {"Reference"};
1146        default: return super.getTypesForProperty(hash, name);
1147        }
1148
1149      }
1150
1151      @Override
1152      public Base addChild(String name) throws FHIRException {
1153        if (name.equals("identifier")) {
1154          return addIdentifier();
1155        }
1156        else if (name.equals("type")) {
1157          this.type = new CodeableConcept();
1158          return this.type;
1159        }
1160        else if (name.equals("quantity")) {
1161          this.quantity = new Quantity();
1162          return this.quantity;
1163        }
1164        else if (name.equals("material")) {
1165          return addMaterial();
1166        }
1167        else if (name.equals("alternateMaterial")) {
1168          return addAlternateMaterial();
1169        }
1170        else if (name.equals("device")) {
1171          return addDevice();
1172        }
1173        else if (name.equals("manufacturedItem")) {
1174          return addManufacturedItem();
1175        }
1176        else if (name.equals("packageItem")) {
1177          return addPackageItem();
1178        }
1179        else if (name.equals("physicalCharacteristics")) {
1180          this.physicalCharacteristics = new ProdCharacteristic();
1181          return this.physicalCharacteristics;
1182        }
1183        else if (name.equals("otherCharacteristics")) {
1184          return addOtherCharacteristics();
1185        }
1186        else if (name.equals("shelfLifeStorage")) {
1187          return addShelfLifeStorage();
1188        }
1189        else if (name.equals("manufacturer")) {
1190          return addManufacturer();
1191        }
1192        else
1193          return super.addChild(name);
1194      }
1195
1196      public MedicinalProductPackagedPackageItemComponent copy() {
1197        MedicinalProductPackagedPackageItemComponent dst = new MedicinalProductPackagedPackageItemComponent();
1198        copyValues(dst);
1199        if (identifier != null) {
1200          dst.identifier = new ArrayList<Identifier>();
1201          for (Identifier i : identifier)
1202            dst.identifier.add(i.copy());
1203        };
1204        dst.type = type == null ? null : type.copy();
1205        dst.quantity = quantity == null ? null : quantity.copy();
1206        if (material != null) {
1207          dst.material = new ArrayList<CodeableConcept>();
1208          for (CodeableConcept i : material)
1209            dst.material.add(i.copy());
1210        };
1211        if (alternateMaterial != null) {
1212          dst.alternateMaterial = new ArrayList<CodeableConcept>();
1213          for (CodeableConcept i : alternateMaterial)
1214            dst.alternateMaterial.add(i.copy());
1215        };
1216        if (device != null) {
1217          dst.device = new ArrayList<Reference>();
1218          for (Reference i : device)
1219            dst.device.add(i.copy());
1220        };
1221        if (manufacturedItem != null) {
1222          dst.manufacturedItem = new ArrayList<Reference>();
1223          for (Reference i : manufacturedItem)
1224            dst.manufacturedItem.add(i.copy());
1225        };
1226        if (packageItem != null) {
1227          dst.packageItem = new ArrayList<MedicinalProductPackagedPackageItemComponent>();
1228          for (MedicinalProductPackagedPackageItemComponent i : packageItem)
1229            dst.packageItem.add(i.copy());
1230        };
1231        dst.physicalCharacteristics = physicalCharacteristics == null ? null : physicalCharacteristics.copy();
1232        if (otherCharacteristics != null) {
1233          dst.otherCharacteristics = new ArrayList<CodeableConcept>();
1234          for (CodeableConcept i : otherCharacteristics)
1235            dst.otherCharacteristics.add(i.copy());
1236        };
1237        if (shelfLifeStorage != null) {
1238          dst.shelfLifeStorage = new ArrayList<ProductShelfLife>();
1239          for (ProductShelfLife i : shelfLifeStorage)
1240            dst.shelfLifeStorage.add(i.copy());
1241        };
1242        if (manufacturer != null) {
1243          dst.manufacturer = new ArrayList<Reference>();
1244          for (Reference i : manufacturer)
1245            dst.manufacturer.add(i.copy());
1246        };
1247        return dst;
1248      }
1249
1250      @Override
1251      public boolean equalsDeep(Base other_) {
1252        if (!super.equalsDeep(other_))
1253          return false;
1254        if (!(other_ instanceof MedicinalProductPackagedPackageItemComponent))
1255          return false;
1256        MedicinalProductPackagedPackageItemComponent o = (MedicinalProductPackagedPackageItemComponent) other_;
1257        return compareDeep(identifier, o.identifier, true) && compareDeep(type, o.type, true) && compareDeep(quantity, o.quantity, true)
1258           && compareDeep(material, o.material, true) && compareDeep(alternateMaterial, o.alternateMaterial, true)
1259           && compareDeep(device, o.device, true) && compareDeep(manufacturedItem, o.manufacturedItem, true)
1260           && compareDeep(packageItem, o.packageItem, true) && compareDeep(physicalCharacteristics, o.physicalCharacteristics, true)
1261           && compareDeep(otherCharacteristics, o.otherCharacteristics, true) && compareDeep(shelfLifeStorage, o.shelfLifeStorage, true)
1262           && compareDeep(manufacturer, o.manufacturer, true);
1263      }
1264
1265      @Override
1266      public boolean equalsShallow(Base other_) {
1267        if (!super.equalsShallow(other_))
1268          return false;
1269        if (!(other_ instanceof MedicinalProductPackagedPackageItemComponent))
1270          return false;
1271        MedicinalProductPackagedPackageItemComponent o = (MedicinalProductPackagedPackageItemComponent) other_;
1272        return true;
1273      }
1274
1275      public boolean isEmpty() {
1276        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, type, quantity
1277          , material, alternateMaterial, device, manufacturedItem, packageItem, physicalCharacteristics
1278          , otherCharacteristics, shelfLifeStorage, manufacturer);
1279      }
1280
1281  public String fhirType() {
1282    return "MedicinalProductPackaged.packageItem";
1283
1284  }
1285
1286  }
1287
1288    /**
1289     * Unique identifier.
1290     */
1291    @Child(name = "identifier", type = {Identifier.class}, order=0, min=1, max=1, modifier=false, summary=true)
1292    @Description(shortDefinition="Unique identifier", formalDefinition="Unique identifier." )
1293    protected Identifier identifier;
1294
1295    /**
1296     * Textual description.
1297     */
1298    @Child(name = "description", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true)
1299    @Description(shortDefinition="Textual description", formalDefinition="Textual description." )
1300    protected StringType description;
1301
1302    /**
1303     * Marketing information.
1304     */
1305    @Child(name = "marketingStatus", type = {MarketingStatus.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1306    @Description(shortDefinition="Marketing information", formalDefinition="Marketing information." )
1307    protected List<MarketingStatus> marketingStatus;
1308
1309    /**
1310     * Manufacturer of this Package Item.
1311     */
1312    @Child(name = "marketingAuthorization", type = {MedicinalProductAuthorization.class}, order=3, min=0, max=1, modifier=false, summary=true)
1313    @Description(shortDefinition="Manufacturer of this Package Item", formalDefinition="Manufacturer of this Package Item." )
1314    protected Reference marketingAuthorization;
1315
1316    /**
1317     * The actual object that is the target of the reference (Manufacturer of this Package Item.)
1318     */
1319    protected MedicinalProductAuthorization marketingAuthorizationTarget;
1320
1321    /**
1322     * Manufacturer of this Package Item.
1323     */
1324    @Child(name = "manufacturer", type = {Organization.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1325    @Description(shortDefinition="Manufacturer of this Package Item", formalDefinition="Manufacturer of this Package Item." )
1326    protected List<Reference> manufacturer;
1327    /**
1328     * The actual objects that are the target of the reference (Manufacturer of this Package Item.)
1329     */
1330    protected List<Organization> manufacturerTarget;
1331
1332
1333    /**
1334     * Batch numbering.
1335     */
1336    @Child(name = "batchIdentifier", type = {}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1337    @Description(shortDefinition="Batch numbering", formalDefinition="Batch numbering." )
1338    protected List<MedicinalProductPackagedBatchIdentifierComponent> batchIdentifier;
1339
1340    /**
1341     * A packaging item, as a contained for medicine, possibly with other packaging items within.
1342     */
1343    @Child(name = "packageItem", type = {}, order=6, min=1, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1344    @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." )
1345    protected List<MedicinalProductPackagedPackageItemComponent> packageItem;
1346
1347    private static final long serialVersionUID = 1280861928L;
1348
1349  /**
1350   * Constructor
1351   */
1352    public MedicinalProductPackaged() {
1353      super();
1354    }
1355
1356  /**
1357   * Constructor
1358   */
1359    public MedicinalProductPackaged(Identifier identifier) {
1360      super();
1361      this.identifier = identifier;
1362    }
1363
1364    /**
1365     * @return {@link #identifier} (Unique identifier.)
1366     */
1367    public Identifier getIdentifier() { 
1368      if (this.identifier == null)
1369        if (Configuration.errorOnAutoCreate())
1370          throw new Error("Attempt to auto-create MedicinalProductPackaged.identifier");
1371        else if (Configuration.doAutoCreate())
1372          this.identifier = new Identifier(); // cc
1373      return this.identifier;
1374    }
1375
1376    public boolean hasIdentifier() { 
1377      return this.identifier != null && !this.identifier.isEmpty();
1378    }
1379
1380    /**
1381     * @param value {@link #identifier} (Unique identifier.)
1382     */
1383    public MedicinalProductPackaged setIdentifier(Identifier value) { 
1384      this.identifier = value;
1385      return this;
1386    }
1387
1388    /**
1389     * @return {@link #description} (Textual description.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
1390     */
1391    public StringType getDescriptionElement() { 
1392      if (this.description == null)
1393        if (Configuration.errorOnAutoCreate())
1394          throw new Error("Attempt to auto-create MedicinalProductPackaged.description");
1395        else if (Configuration.doAutoCreate())
1396          this.description = new StringType(); // bb
1397      return this.description;
1398    }
1399
1400    public boolean hasDescriptionElement() { 
1401      return this.description != null && !this.description.isEmpty();
1402    }
1403
1404    public boolean hasDescription() { 
1405      return this.description != null && !this.description.isEmpty();
1406    }
1407
1408    /**
1409     * @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
1410     */
1411    public MedicinalProductPackaged setDescriptionElement(StringType value) { 
1412      this.description = value;
1413      return this;
1414    }
1415
1416    /**
1417     * @return Textual description.
1418     */
1419    public String getDescription() { 
1420      return this.description == null ? null : this.description.getValue();
1421    }
1422
1423    /**
1424     * @param value Textual description.
1425     */
1426    public MedicinalProductPackaged setDescription(String value) { 
1427      if (Utilities.noString(value))
1428        this.description = null;
1429      else {
1430        if (this.description == null)
1431          this.description = new StringType();
1432        this.description.setValue(value);
1433      }
1434      return this;
1435    }
1436
1437    /**
1438     * @return {@link #marketingStatus} (Marketing information.)
1439     */
1440    public List<MarketingStatus> getMarketingStatus() { 
1441      if (this.marketingStatus == null)
1442        this.marketingStatus = new ArrayList<MarketingStatus>();
1443      return this.marketingStatus;
1444    }
1445
1446    /**
1447     * @return Returns a reference to <code>this</code> for easy method chaining
1448     */
1449    public MedicinalProductPackaged setMarketingStatus(List<MarketingStatus> theMarketingStatus) { 
1450      this.marketingStatus = theMarketingStatus;
1451      return this;
1452    }
1453
1454    public boolean hasMarketingStatus() { 
1455      if (this.marketingStatus == null)
1456        return false;
1457      for (MarketingStatus item : this.marketingStatus)
1458        if (!item.isEmpty())
1459          return true;
1460      return false;
1461    }
1462
1463    public MarketingStatus addMarketingStatus() { //3
1464      MarketingStatus t = new MarketingStatus();
1465      if (this.marketingStatus == null)
1466        this.marketingStatus = new ArrayList<MarketingStatus>();
1467      this.marketingStatus.add(t);
1468      return t;
1469    }
1470
1471    public MedicinalProductPackaged addMarketingStatus(MarketingStatus t) { //3
1472      if (t == null)
1473        return this;
1474      if (this.marketingStatus == null)
1475        this.marketingStatus = new ArrayList<MarketingStatus>();
1476      this.marketingStatus.add(t);
1477      return this;
1478    }
1479
1480    /**
1481     * @return The first repetition of repeating field {@link #marketingStatus}, creating it if it does not already exist
1482     */
1483    public MarketingStatus getMarketingStatusFirstRep() { 
1484      if (getMarketingStatus().isEmpty()) {
1485        addMarketingStatus();
1486      }
1487      return getMarketingStatus().get(0);
1488    }
1489
1490    /**
1491     * @return {@link #marketingAuthorization} (Manufacturer of this Package Item.)
1492     */
1493    public Reference getMarketingAuthorization() { 
1494      if (this.marketingAuthorization == null)
1495        if (Configuration.errorOnAutoCreate())
1496          throw new Error("Attempt to auto-create MedicinalProductPackaged.marketingAuthorization");
1497        else if (Configuration.doAutoCreate())
1498          this.marketingAuthorization = new Reference(); // cc
1499      return this.marketingAuthorization;
1500    }
1501
1502    public boolean hasMarketingAuthorization() { 
1503      return this.marketingAuthorization != null && !this.marketingAuthorization.isEmpty();
1504    }
1505
1506    /**
1507     * @param value {@link #marketingAuthorization} (Manufacturer of this Package Item.)
1508     */
1509    public MedicinalProductPackaged setMarketingAuthorization(Reference value) { 
1510      this.marketingAuthorization = value;
1511      return this;
1512    }
1513
1514    /**
1515     * @return {@link #marketingAuthorization} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Manufacturer of this Package Item.)
1516     */
1517    public MedicinalProductAuthorization getMarketingAuthorizationTarget() { 
1518      if (this.marketingAuthorizationTarget == null)
1519        if (Configuration.errorOnAutoCreate())
1520          throw new Error("Attempt to auto-create MedicinalProductPackaged.marketingAuthorization");
1521        else if (Configuration.doAutoCreate())
1522          this.marketingAuthorizationTarget = new MedicinalProductAuthorization(); // aa
1523      return this.marketingAuthorizationTarget;
1524    }
1525
1526    /**
1527     * @param value {@link #marketingAuthorization} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Manufacturer of this Package Item.)
1528     */
1529    public MedicinalProductPackaged setMarketingAuthorizationTarget(MedicinalProductAuthorization value) { 
1530      this.marketingAuthorizationTarget = value;
1531      return this;
1532    }
1533
1534    /**
1535     * @return {@link #manufacturer} (Manufacturer of this Package Item.)
1536     */
1537    public List<Reference> getManufacturer() { 
1538      if (this.manufacturer == null)
1539        this.manufacturer = new ArrayList<Reference>();
1540      return this.manufacturer;
1541    }
1542
1543    /**
1544     * @return Returns a reference to <code>this</code> for easy method chaining
1545     */
1546    public MedicinalProductPackaged setManufacturer(List<Reference> theManufacturer) { 
1547      this.manufacturer = theManufacturer;
1548      return this;
1549    }
1550
1551    public boolean hasManufacturer() { 
1552      if (this.manufacturer == null)
1553        return false;
1554      for (Reference item : this.manufacturer)
1555        if (!item.isEmpty())
1556          return true;
1557      return false;
1558    }
1559
1560    public Reference addManufacturer() { //3
1561      Reference t = new Reference();
1562      if (this.manufacturer == null)
1563        this.manufacturer = new ArrayList<Reference>();
1564      this.manufacturer.add(t);
1565      return t;
1566    }
1567
1568    public MedicinalProductPackaged addManufacturer(Reference t) { //3
1569      if (t == null)
1570        return this;
1571      if (this.manufacturer == null)
1572        this.manufacturer = new ArrayList<Reference>();
1573      this.manufacturer.add(t);
1574      return this;
1575    }
1576
1577    /**
1578     * @return The first repetition of repeating field {@link #manufacturer}, creating it if it does not already exist
1579     */
1580    public Reference getManufacturerFirstRep() { 
1581      if (getManufacturer().isEmpty()) {
1582        addManufacturer();
1583      }
1584      return getManufacturer().get(0);
1585    }
1586
1587    /**
1588     * @deprecated Use Reference#setResource(IBaseResource) instead
1589     */
1590    @Deprecated
1591    public List<Organization> getManufacturerTarget() { 
1592      if (this.manufacturerTarget == null)
1593        this.manufacturerTarget = new ArrayList<Organization>();
1594      return this.manufacturerTarget;
1595    }
1596
1597    /**
1598     * @deprecated Use Reference#setResource(IBaseResource) instead
1599     */
1600    @Deprecated
1601    public Organization addManufacturerTarget() { 
1602      Organization r = new Organization();
1603      if (this.manufacturerTarget == null)
1604        this.manufacturerTarget = new ArrayList<Organization>();
1605      this.manufacturerTarget.add(r);
1606      return r;
1607    }
1608
1609    /**
1610     * @return {@link #batchIdentifier} (Batch numbering.)
1611     */
1612    public List<MedicinalProductPackagedBatchIdentifierComponent> getBatchIdentifier() { 
1613      if (this.batchIdentifier == null)
1614        this.batchIdentifier = new ArrayList<MedicinalProductPackagedBatchIdentifierComponent>();
1615      return this.batchIdentifier;
1616    }
1617
1618    /**
1619     * @return Returns a reference to <code>this</code> for easy method chaining
1620     */
1621    public MedicinalProductPackaged setBatchIdentifier(List<MedicinalProductPackagedBatchIdentifierComponent> theBatchIdentifier) { 
1622      this.batchIdentifier = theBatchIdentifier;
1623      return this;
1624    }
1625
1626    public boolean hasBatchIdentifier() { 
1627      if (this.batchIdentifier == null)
1628        return false;
1629      for (MedicinalProductPackagedBatchIdentifierComponent item : this.batchIdentifier)
1630        if (!item.isEmpty())
1631          return true;
1632      return false;
1633    }
1634
1635    public MedicinalProductPackagedBatchIdentifierComponent addBatchIdentifier() { //3
1636      MedicinalProductPackagedBatchIdentifierComponent t = new MedicinalProductPackagedBatchIdentifierComponent();
1637      if (this.batchIdentifier == null)
1638        this.batchIdentifier = new ArrayList<MedicinalProductPackagedBatchIdentifierComponent>();
1639      this.batchIdentifier.add(t);
1640      return t;
1641    }
1642
1643    public MedicinalProductPackaged addBatchIdentifier(MedicinalProductPackagedBatchIdentifierComponent t) { //3
1644      if (t == null)
1645        return this;
1646      if (this.batchIdentifier == null)
1647        this.batchIdentifier = new ArrayList<MedicinalProductPackagedBatchIdentifierComponent>();
1648      this.batchIdentifier.add(t);
1649      return this;
1650    }
1651
1652    /**
1653     * @return The first repetition of repeating field {@link #batchIdentifier}, creating it if it does not already exist
1654     */
1655    public MedicinalProductPackagedBatchIdentifierComponent getBatchIdentifierFirstRep() { 
1656      if (getBatchIdentifier().isEmpty()) {
1657        addBatchIdentifier();
1658      }
1659      return getBatchIdentifier().get(0);
1660    }
1661
1662    /**
1663     * @return {@link #packageItem} (A packaging item, as a contained for medicine, possibly with other packaging items within.)
1664     */
1665    public List<MedicinalProductPackagedPackageItemComponent> getPackageItem() { 
1666      if (this.packageItem == null)
1667        this.packageItem = new ArrayList<MedicinalProductPackagedPackageItemComponent>();
1668      return this.packageItem;
1669    }
1670
1671    /**
1672     * @return Returns a reference to <code>this</code> for easy method chaining
1673     */
1674    public MedicinalProductPackaged setPackageItem(List<MedicinalProductPackagedPackageItemComponent> thePackageItem) { 
1675      this.packageItem = thePackageItem;
1676      return this;
1677    }
1678
1679    public boolean hasPackageItem() { 
1680      if (this.packageItem == null)
1681        return false;
1682      for (MedicinalProductPackagedPackageItemComponent item : this.packageItem)
1683        if (!item.isEmpty())
1684          return true;
1685      return false;
1686    }
1687
1688    public MedicinalProductPackagedPackageItemComponent addPackageItem() { //3
1689      MedicinalProductPackagedPackageItemComponent t = new MedicinalProductPackagedPackageItemComponent();
1690      if (this.packageItem == null)
1691        this.packageItem = new ArrayList<MedicinalProductPackagedPackageItemComponent>();
1692      this.packageItem.add(t);
1693      return t;
1694    }
1695
1696    public MedicinalProductPackaged addPackageItem(MedicinalProductPackagedPackageItemComponent t) { //3
1697      if (t == null)
1698        return this;
1699      if (this.packageItem == null)
1700        this.packageItem = new ArrayList<MedicinalProductPackagedPackageItemComponent>();
1701      this.packageItem.add(t);
1702      return this;
1703    }
1704
1705    /**
1706     * @return The first repetition of repeating field {@link #packageItem}, creating it if it does not already exist
1707     */
1708    public MedicinalProductPackagedPackageItemComponent getPackageItemFirstRep() { 
1709      if (getPackageItem().isEmpty()) {
1710        addPackageItem();
1711      }
1712      return getPackageItem().get(0);
1713    }
1714
1715      protected void listChildren(List<Property> children) {
1716        super.listChildren(children);
1717        children.add(new Property("identifier", "Identifier", "Unique identifier.", 0, 1, identifier));
1718        children.add(new Property("description", "string", "Textual description.", 0, 1, description));
1719        children.add(new Property("marketingStatus", "MarketingStatus", "Marketing information.", 0, java.lang.Integer.MAX_VALUE, marketingStatus));
1720        children.add(new Property("marketingAuthorization", "Reference(MedicinalProductAuthorization)", "Manufacturer of this Package Item.", 0, 1, marketingAuthorization));
1721        children.add(new Property("manufacturer", "Reference(Organization)", "Manufacturer of this Package Item.", 0, java.lang.Integer.MAX_VALUE, manufacturer));
1722        children.add(new Property("batchIdentifier", "", "Batch numbering.", 0, java.lang.Integer.MAX_VALUE, batchIdentifier));
1723        children.add(new Property("packageItem", "", "A packaging item, as a contained for medicine, possibly with other packaging items within.", 0, java.lang.Integer.MAX_VALUE, packageItem));
1724      }
1725
1726      @Override
1727      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1728        switch (_hash) {
1729        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Unique identifier.", 0, 1, identifier);
1730        case -1724546052: /*description*/  return new Property("description", "string", "Textual description.", 0, 1, description);
1731        case 70767032: /*marketingStatus*/  return new Property("marketingStatus", "MarketingStatus", "Marketing information.", 0, java.lang.Integer.MAX_VALUE, marketingStatus);
1732        case 571831283: /*marketingAuthorization*/  return new Property("marketingAuthorization", "Reference(MedicinalProductAuthorization)", "Manufacturer of this Package Item.", 0, 1, marketingAuthorization);
1733        case -1969347631: /*manufacturer*/  return new Property("manufacturer", "Reference(Organization)", "Manufacturer of this Package Item.", 0, java.lang.Integer.MAX_VALUE, manufacturer);
1734        case -1688395901: /*batchIdentifier*/  return new Property("batchIdentifier", "", "Batch numbering.", 0, java.lang.Integer.MAX_VALUE, batchIdentifier);
1735        case 908628089: /*packageItem*/  return new Property("packageItem", "", "A packaging item, as a contained for medicine, possibly with other packaging items within.", 0, java.lang.Integer.MAX_VALUE, packageItem);
1736        default: return super.getNamedProperty(_hash, _name, _checkValid);
1737        }
1738
1739      }
1740
1741      @Override
1742      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1743        switch (hash) {
1744        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : new Base[] {this.identifier}; // Identifier
1745        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // StringType
1746        case 70767032: /*marketingStatus*/ return this.marketingStatus == null ? new Base[0] : this.marketingStatus.toArray(new Base[this.marketingStatus.size()]); // MarketingStatus
1747        case 571831283: /*marketingAuthorization*/ return this.marketingAuthorization == null ? new Base[0] : new Base[] {this.marketingAuthorization}; // Reference
1748        case -1969347631: /*manufacturer*/ return this.manufacturer == null ? new Base[0] : this.manufacturer.toArray(new Base[this.manufacturer.size()]); // Reference
1749        case -1688395901: /*batchIdentifier*/ return this.batchIdentifier == null ? new Base[0] : this.batchIdentifier.toArray(new Base[this.batchIdentifier.size()]); // MedicinalProductPackagedBatchIdentifierComponent
1750        case 908628089: /*packageItem*/ return this.packageItem == null ? new Base[0] : this.packageItem.toArray(new Base[this.packageItem.size()]); // MedicinalProductPackagedPackageItemComponent
1751        default: return super.getProperty(hash, name, checkValid);
1752        }
1753
1754      }
1755
1756      @Override
1757      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1758        switch (hash) {
1759        case -1618432855: // identifier
1760          this.identifier = castToIdentifier(value); // Identifier
1761          return value;
1762        case -1724546052: // description
1763          this.description = castToString(value); // StringType
1764          return value;
1765        case 70767032: // marketingStatus
1766          this.getMarketingStatus().add(castToMarketingStatus(value)); // MarketingStatus
1767          return value;
1768        case 571831283: // marketingAuthorization
1769          this.marketingAuthorization = castToReference(value); // Reference
1770          return value;
1771        case -1969347631: // manufacturer
1772          this.getManufacturer().add(castToReference(value)); // Reference
1773          return value;
1774        case -1688395901: // batchIdentifier
1775          this.getBatchIdentifier().add((MedicinalProductPackagedBatchIdentifierComponent) value); // MedicinalProductPackagedBatchIdentifierComponent
1776          return value;
1777        case 908628089: // packageItem
1778          this.getPackageItem().add((MedicinalProductPackagedPackageItemComponent) value); // MedicinalProductPackagedPackageItemComponent
1779          return value;
1780        default: return super.setProperty(hash, name, value);
1781        }
1782
1783      }
1784
1785      @Override
1786      public Base setProperty(String name, Base value) throws FHIRException {
1787        if (name.equals("identifier")) {
1788          this.identifier = castToIdentifier(value); // Identifier
1789        } else if (name.equals("description")) {
1790          this.description = castToString(value); // StringType
1791        } else if (name.equals("marketingStatus")) {
1792          this.getMarketingStatus().add(castToMarketingStatus(value));
1793        } else if (name.equals("marketingAuthorization")) {
1794          this.marketingAuthorization = castToReference(value); // Reference
1795        } else if (name.equals("manufacturer")) {
1796          this.getManufacturer().add(castToReference(value));
1797        } else if (name.equals("batchIdentifier")) {
1798          this.getBatchIdentifier().add((MedicinalProductPackagedBatchIdentifierComponent) value);
1799        } else if (name.equals("packageItem")) {
1800          this.getPackageItem().add((MedicinalProductPackagedPackageItemComponent) value);
1801        } else
1802          return super.setProperty(name, value);
1803        return value;
1804      }
1805
1806      @Override
1807      public Base makeProperty(int hash, String name) throws FHIRException {
1808        switch (hash) {
1809        case -1618432855:  return getIdentifier(); 
1810        case -1724546052:  return getDescriptionElement();
1811        case 70767032:  return addMarketingStatus(); 
1812        case 571831283:  return getMarketingAuthorization(); 
1813        case -1969347631:  return addManufacturer(); 
1814        case -1688395901:  return addBatchIdentifier(); 
1815        case 908628089:  return addPackageItem(); 
1816        default: return super.makeProperty(hash, name);
1817        }
1818
1819      }
1820
1821      @Override
1822      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1823        switch (hash) {
1824        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
1825        case -1724546052: /*description*/ return new String[] {"string"};
1826        case 70767032: /*marketingStatus*/ return new String[] {"MarketingStatus"};
1827        case 571831283: /*marketingAuthorization*/ return new String[] {"Reference"};
1828        case -1969347631: /*manufacturer*/ return new String[] {"Reference"};
1829        case -1688395901: /*batchIdentifier*/ return new String[] {};
1830        case 908628089: /*packageItem*/ return new String[] {};
1831        default: return super.getTypesForProperty(hash, name);
1832        }
1833
1834      }
1835
1836      @Override
1837      public Base addChild(String name) throws FHIRException {
1838        if (name.equals("identifier")) {
1839          this.identifier = new Identifier();
1840          return this.identifier;
1841        }
1842        else if (name.equals("description")) {
1843          throw new FHIRException("Cannot call addChild on a primitive type MedicinalProductPackaged.description");
1844        }
1845        else if (name.equals("marketingStatus")) {
1846          return addMarketingStatus();
1847        }
1848        else if (name.equals("marketingAuthorization")) {
1849          this.marketingAuthorization = new Reference();
1850          return this.marketingAuthorization;
1851        }
1852        else if (name.equals("manufacturer")) {
1853          return addManufacturer();
1854        }
1855        else if (name.equals("batchIdentifier")) {
1856          return addBatchIdentifier();
1857        }
1858        else if (name.equals("packageItem")) {
1859          return addPackageItem();
1860        }
1861        else
1862          return super.addChild(name);
1863      }
1864
1865  public String fhirType() {
1866    return "MedicinalProductPackaged";
1867
1868  }
1869
1870      public MedicinalProductPackaged copy() {
1871        MedicinalProductPackaged dst = new MedicinalProductPackaged();
1872        copyValues(dst);
1873        dst.identifier = identifier == null ? null : identifier.copy();
1874        dst.description = description == null ? null : description.copy();
1875        if (marketingStatus != null) {
1876          dst.marketingStatus = new ArrayList<MarketingStatus>();
1877          for (MarketingStatus i : marketingStatus)
1878            dst.marketingStatus.add(i.copy());
1879        };
1880        dst.marketingAuthorization = marketingAuthorization == null ? null : marketingAuthorization.copy();
1881        if (manufacturer != null) {
1882          dst.manufacturer = new ArrayList<Reference>();
1883          for (Reference i : manufacturer)
1884            dst.manufacturer.add(i.copy());
1885        };
1886        if (batchIdentifier != null) {
1887          dst.batchIdentifier = new ArrayList<MedicinalProductPackagedBatchIdentifierComponent>();
1888          for (MedicinalProductPackagedBatchIdentifierComponent i : batchIdentifier)
1889            dst.batchIdentifier.add(i.copy());
1890        };
1891        if (packageItem != null) {
1892          dst.packageItem = new ArrayList<MedicinalProductPackagedPackageItemComponent>();
1893          for (MedicinalProductPackagedPackageItemComponent i : packageItem)
1894            dst.packageItem.add(i.copy());
1895        };
1896        return dst;
1897      }
1898
1899      protected MedicinalProductPackaged typedCopy() {
1900        return copy();
1901      }
1902
1903      @Override
1904      public boolean equalsDeep(Base other_) {
1905        if (!super.equalsDeep(other_))
1906          return false;
1907        if (!(other_ instanceof MedicinalProductPackaged))
1908          return false;
1909        MedicinalProductPackaged o = (MedicinalProductPackaged) other_;
1910        return compareDeep(identifier, o.identifier, true) && compareDeep(description, o.description, true)
1911           && compareDeep(marketingStatus, o.marketingStatus, true) && compareDeep(marketingAuthorization, o.marketingAuthorization, true)
1912           && compareDeep(manufacturer, o.manufacturer, true) && compareDeep(batchIdentifier, o.batchIdentifier, true)
1913           && compareDeep(packageItem, o.packageItem, true);
1914      }
1915
1916      @Override
1917      public boolean equalsShallow(Base other_) {
1918        if (!super.equalsShallow(other_))
1919          return false;
1920        if (!(other_ instanceof MedicinalProductPackaged))
1921          return false;
1922        MedicinalProductPackaged o = (MedicinalProductPackaged) other_;
1923        return compareValues(description, o.description, true);
1924      }
1925
1926      public boolean isEmpty() {
1927        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, description, marketingStatus
1928          , marketingAuthorization, manufacturer, batchIdentifier, packageItem);
1929      }
1930
1931  @Override
1932  public ResourceType getResourceType() {
1933    return ResourceType.MedicinalProductPackaged;
1934   }
1935
1936
1937}
1938