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, Dec 27, 2018 10:06-0500 for FHIR v4.0.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 = {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<DeviceDefinition> 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 = 1454286533L;
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<DeviceDefinition> getDeviceTarget() { 
642          if (this.deviceTarget == null)
643            this.deviceTarget = new ArrayList<DeviceDefinition>();
644          return this.deviceTarget;
645        }
646
647        /**
648         * @deprecated Use Reference#setResource(IBaseResource) instead
649         */
650        @Deprecated
651        public DeviceDefinition addDeviceTarget() { 
652          DeviceDefinition r = new DeviceDefinition();
653          if (this.deviceTarget == null)
654            this.deviceTarget = new ArrayList<DeviceDefinition>();
655          this.deviceTarget.add(r);
656          return r;
657        }
658
659        /**
660         * @return {@link #manufacturedItem} (The manufactured item as contained in the packaged medicinal product.)
661         */
662        public List<Reference> getManufacturedItem() { 
663          if (this.manufacturedItem == null)
664            this.manufacturedItem = new ArrayList<Reference>();
665          return this.manufacturedItem;
666        }
667
668        /**
669         * @return Returns a reference to <code>this</code> for easy method chaining
670         */
671        public MedicinalProductPackagedPackageItemComponent setManufacturedItem(List<Reference> theManufacturedItem) { 
672          this.manufacturedItem = theManufacturedItem;
673          return this;
674        }
675
676        public boolean hasManufacturedItem() { 
677          if (this.manufacturedItem == null)
678            return false;
679          for (Reference item : this.manufacturedItem)
680            if (!item.isEmpty())
681              return true;
682          return false;
683        }
684
685        public Reference addManufacturedItem() { //3
686          Reference t = new Reference();
687          if (this.manufacturedItem == null)
688            this.manufacturedItem = new ArrayList<Reference>();
689          this.manufacturedItem.add(t);
690          return t;
691        }
692
693        public MedicinalProductPackagedPackageItemComponent addManufacturedItem(Reference t) { //3
694          if (t == null)
695            return this;
696          if (this.manufacturedItem == null)
697            this.manufacturedItem = new ArrayList<Reference>();
698          this.manufacturedItem.add(t);
699          return this;
700        }
701
702        /**
703         * @return The first repetition of repeating field {@link #manufacturedItem}, creating it if it does not already exist
704         */
705        public Reference getManufacturedItemFirstRep() { 
706          if (getManufacturedItem().isEmpty()) {
707            addManufacturedItem();
708          }
709          return getManufacturedItem().get(0);
710        }
711
712        /**
713         * @deprecated Use Reference#setResource(IBaseResource) instead
714         */
715        @Deprecated
716        public List<MedicinalProductManufactured> getManufacturedItemTarget() { 
717          if (this.manufacturedItemTarget == null)
718            this.manufacturedItemTarget = new ArrayList<MedicinalProductManufactured>();
719          return this.manufacturedItemTarget;
720        }
721
722        /**
723         * @deprecated Use Reference#setResource(IBaseResource) instead
724         */
725        @Deprecated
726        public MedicinalProductManufactured addManufacturedItemTarget() { 
727          MedicinalProductManufactured r = new MedicinalProductManufactured();
728          if (this.manufacturedItemTarget == null)
729            this.manufacturedItemTarget = new ArrayList<MedicinalProductManufactured>();
730          this.manufacturedItemTarget.add(r);
731          return r;
732        }
733
734        /**
735         * @return {@link #packageItem} (Allows containers within containers.)
736         */
737        public List<MedicinalProductPackagedPackageItemComponent> getPackageItem() { 
738          if (this.packageItem == null)
739            this.packageItem = new ArrayList<MedicinalProductPackagedPackageItemComponent>();
740          return this.packageItem;
741        }
742
743        /**
744         * @return Returns a reference to <code>this</code> for easy method chaining
745         */
746        public MedicinalProductPackagedPackageItemComponent setPackageItem(List<MedicinalProductPackagedPackageItemComponent> thePackageItem) { 
747          this.packageItem = thePackageItem;
748          return this;
749        }
750
751        public boolean hasPackageItem() { 
752          if (this.packageItem == null)
753            return false;
754          for (MedicinalProductPackagedPackageItemComponent item : this.packageItem)
755            if (!item.isEmpty())
756              return true;
757          return false;
758        }
759
760        public MedicinalProductPackagedPackageItemComponent addPackageItem() { //3
761          MedicinalProductPackagedPackageItemComponent t = new MedicinalProductPackagedPackageItemComponent();
762          if (this.packageItem == null)
763            this.packageItem = new ArrayList<MedicinalProductPackagedPackageItemComponent>();
764          this.packageItem.add(t);
765          return t;
766        }
767
768        public MedicinalProductPackagedPackageItemComponent addPackageItem(MedicinalProductPackagedPackageItemComponent t) { //3
769          if (t == null)
770            return this;
771          if (this.packageItem == null)
772            this.packageItem = new ArrayList<MedicinalProductPackagedPackageItemComponent>();
773          this.packageItem.add(t);
774          return this;
775        }
776
777        /**
778         * @return The first repetition of repeating field {@link #packageItem}, creating it if it does not already exist
779         */
780        public MedicinalProductPackagedPackageItemComponent getPackageItemFirstRep() { 
781          if (getPackageItem().isEmpty()) {
782            addPackageItem();
783          }
784          return getPackageItem().get(0);
785        }
786
787        /**
788         * @return {@link #physicalCharacteristics} (Dimensions, color etc.)
789         */
790        public ProdCharacteristic getPhysicalCharacteristics() { 
791          if (this.physicalCharacteristics == null)
792            if (Configuration.errorOnAutoCreate())
793              throw new Error("Attempt to auto-create MedicinalProductPackagedPackageItemComponent.physicalCharacteristics");
794            else if (Configuration.doAutoCreate())
795              this.physicalCharacteristics = new ProdCharacteristic(); // cc
796          return this.physicalCharacteristics;
797        }
798
799        public boolean hasPhysicalCharacteristics() { 
800          return this.physicalCharacteristics != null && !this.physicalCharacteristics.isEmpty();
801        }
802
803        /**
804         * @param value {@link #physicalCharacteristics} (Dimensions, color etc.)
805         */
806        public MedicinalProductPackagedPackageItemComponent setPhysicalCharacteristics(ProdCharacteristic value) { 
807          this.physicalCharacteristics = value;
808          return this;
809        }
810
811        /**
812         * @return {@link #otherCharacteristics} (Other codeable characteristics.)
813         */
814        public List<CodeableConcept> getOtherCharacteristics() { 
815          if (this.otherCharacteristics == null)
816            this.otherCharacteristics = new ArrayList<CodeableConcept>();
817          return this.otherCharacteristics;
818        }
819
820        /**
821         * @return Returns a reference to <code>this</code> for easy method chaining
822         */
823        public MedicinalProductPackagedPackageItemComponent setOtherCharacteristics(List<CodeableConcept> theOtherCharacteristics) { 
824          this.otherCharacteristics = theOtherCharacteristics;
825          return this;
826        }
827
828        public boolean hasOtherCharacteristics() { 
829          if (this.otherCharacteristics == null)
830            return false;
831          for (CodeableConcept item : this.otherCharacteristics)
832            if (!item.isEmpty())
833              return true;
834          return false;
835        }
836
837        public CodeableConcept addOtherCharacteristics() { //3
838          CodeableConcept t = new CodeableConcept();
839          if (this.otherCharacteristics == null)
840            this.otherCharacteristics = new ArrayList<CodeableConcept>();
841          this.otherCharacteristics.add(t);
842          return t;
843        }
844
845        public MedicinalProductPackagedPackageItemComponent addOtherCharacteristics(CodeableConcept t) { //3
846          if (t == null)
847            return this;
848          if (this.otherCharacteristics == null)
849            this.otherCharacteristics = new ArrayList<CodeableConcept>();
850          this.otherCharacteristics.add(t);
851          return this;
852        }
853
854        /**
855         * @return The first repetition of repeating field {@link #otherCharacteristics}, creating it if it does not already exist
856         */
857        public CodeableConcept getOtherCharacteristicsFirstRep() { 
858          if (getOtherCharacteristics().isEmpty()) {
859            addOtherCharacteristics();
860          }
861          return getOtherCharacteristics().get(0);
862        }
863
864        /**
865         * @return {@link #shelfLifeStorage} (Shelf Life and storage information.)
866         */
867        public List<ProductShelfLife> getShelfLifeStorage() { 
868          if (this.shelfLifeStorage == null)
869            this.shelfLifeStorage = new ArrayList<ProductShelfLife>();
870          return this.shelfLifeStorage;
871        }
872
873        /**
874         * @return Returns a reference to <code>this</code> for easy method chaining
875         */
876        public MedicinalProductPackagedPackageItemComponent setShelfLifeStorage(List<ProductShelfLife> theShelfLifeStorage) { 
877          this.shelfLifeStorage = theShelfLifeStorage;
878          return this;
879        }
880
881        public boolean hasShelfLifeStorage() { 
882          if (this.shelfLifeStorage == null)
883            return false;
884          for (ProductShelfLife item : this.shelfLifeStorage)
885            if (!item.isEmpty())
886              return true;
887          return false;
888        }
889
890        public ProductShelfLife addShelfLifeStorage() { //3
891          ProductShelfLife t = new ProductShelfLife();
892          if (this.shelfLifeStorage == null)
893            this.shelfLifeStorage = new ArrayList<ProductShelfLife>();
894          this.shelfLifeStorage.add(t);
895          return t;
896        }
897
898        public MedicinalProductPackagedPackageItemComponent addShelfLifeStorage(ProductShelfLife t) { //3
899          if (t == null)
900            return this;
901          if (this.shelfLifeStorage == null)
902            this.shelfLifeStorage = new ArrayList<ProductShelfLife>();
903          this.shelfLifeStorage.add(t);
904          return this;
905        }
906
907        /**
908         * @return The first repetition of repeating field {@link #shelfLifeStorage}, creating it if it does not already exist
909         */
910        public ProductShelfLife getShelfLifeStorageFirstRep() { 
911          if (getShelfLifeStorage().isEmpty()) {
912            addShelfLifeStorage();
913          }
914          return getShelfLifeStorage().get(0);
915        }
916
917        /**
918         * @return {@link #manufacturer} (Manufacturer of this Package Item.)
919         */
920        public List<Reference> getManufacturer() { 
921          if (this.manufacturer == null)
922            this.manufacturer = new ArrayList<Reference>();
923          return this.manufacturer;
924        }
925
926        /**
927         * @return Returns a reference to <code>this</code> for easy method chaining
928         */
929        public MedicinalProductPackagedPackageItemComponent setManufacturer(List<Reference> theManufacturer) { 
930          this.manufacturer = theManufacturer;
931          return this;
932        }
933
934        public boolean hasManufacturer() { 
935          if (this.manufacturer == null)
936            return false;
937          for (Reference item : this.manufacturer)
938            if (!item.isEmpty())
939              return true;
940          return false;
941        }
942
943        public Reference addManufacturer() { //3
944          Reference t = new Reference();
945          if (this.manufacturer == null)
946            this.manufacturer = new ArrayList<Reference>();
947          this.manufacturer.add(t);
948          return t;
949        }
950
951        public MedicinalProductPackagedPackageItemComponent addManufacturer(Reference t) { //3
952          if (t == null)
953            return this;
954          if (this.manufacturer == null)
955            this.manufacturer = new ArrayList<Reference>();
956          this.manufacturer.add(t);
957          return this;
958        }
959
960        /**
961         * @return The first repetition of repeating field {@link #manufacturer}, creating it if it does not already exist
962         */
963        public Reference getManufacturerFirstRep() { 
964          if (getManufacturer().isEmpty()) {
965            addManufacturer();
966          }
967          return getManufacturer().get(0);
968        }
969
970        /**
971         * @deprecated Use Reference#setResource(IBaseResource) instead
972         */
973        @Deprecated
974        public List<Organization> getManufacturerTarget() { 
975          if (this.manufacturerTarget == null)
976            this.manufacturerTarget = new ArrayList<Organization>();
977          return this.manufacturerTarget;
978        }
979
980        /**
981         * @deprecated Use Reference#setResource(IBaseResource) instead
982         */
983        @Deprecated
984        public Organization addManufacturerTarget() { 
985          Organization r = new Organization();
986          if (this.manufacturerTarget == null)
987            this.manufacturerTarget = new ArrayList<Organization>();
988          this.manufacturerTarget.add(r);
989          return r;
990        }
991
992        protected void listChildren(List<Property> children) {
993          super.listChildren(children);
994          children.add(new Property("identifier", "Identifier", "Including possibly Data Carrier Identifier.", 0, java.lang.Integer.MAX_VALUE, identifier));
995          children.add(new Property("type", "CodeableConcept", "The physical type of the container of the medicine.", 0, 1, type));
996          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));
997          children.add(new Property("material", "CodeableConcept", "Material type of the package item.", 0, java.lang.Integer.MAX_VALUE, material));
998          children.add(new Property("alternateMaterial", "CodeableConcept", "A possible alternate material for the packaging.", 0, java.lang.Integer.MAX_VALUE, alternateMaterial));
999          children.add(new Property("device", "Reference(DeviceDefinition)", "A device accompanying a medicinal product.", 0, java.lang.Integer.MAX_VALUE, device));
1000          children.add(new Property("manufacturedItem", "Reference(MedicinalProductManufactured)", "The manufactured item as contained in the packaged medicinal product.", 0, java.lang.Integer.MAX_VALUE, manufacturedItem));
1001          children.add(new Property("packageItem", "@MedicinalProductPackaged.packageItem", "Allows containers within containers.", 0, java.lang.Integer.MAX_VALUE, packageItem));
1002          children.add(new Property("physicalCharacteristics", "ProdCharacteristic", "Dimensions, color etc.", 0, 1, physicalCharacteristics));
1003          children.add(new Property("otherCharacteristics", "CodeableConcept", "Other codeable characteristics.", 0, java.lang.Integer.MAX_VALUE, otherCharacteristics));
1004          children.add(new Property("shelfLifeStorage", "ProductShelfLife", "Shelf Life and storage information.", 0, java.lang.Integer.MAX_VALUE, shelfLifeStorage));
1005          children.add(new Property("manufacturer", "Reference(Organization)", "Manufacturer of this Package Item.", 0, java.lang.Integer.MAX_VALUE, manufacturer));
1006        }
1007
1008        @Override
1009        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1010          switch (_hash) {
1011          case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Including possibly Data Carrier Identifier.", 0, java.lang.Integer.MAX_VALUE, identifier);
1012          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "The physical type of the container of the medicine.", 0, 1, type);
1013          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);
1014          case 299066663: /*material*/  return new Property("material", "CodeableConcept", "Material type of the package item.", 0, java.lang.Integer.MAX_VALUE, material);
1015          case -1021448255: /*alternateMaterial*/  return new Property("alternateMaterial", "CodeableConcept", "A possible alternate material for the packaging.", 0, java.lang.Integer.MAX_VALUE, alternateMaterial);
1016          case -1335157162: /*device*/  return new Property("device", "Reference(DeviceDefinition)", "A device accompanying a medicinal product.", 0, java.lang.Integer.MAX_VALUE, device);
1017          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);
1018          case 908628089: /*packageItem*/  return new Property("packageItem", "@MedicinalProductPackaged.packageItem", "Allows containers within containers.", 0, java.lang.Integer.MAX_VALUE, packageItem);
1019          case -1599676319: /*physicalCharacteristics*/  return new Property("physicalCharacteristics", "ProdCharacteristic", "Dimensions, color etc.", 0, 1, physicalCharacteristics);
1020          case 722135304: /*otherCharacteristics*/  return new Property("otherCharacteristics", "CodeableConcept", "Other codeable characteristics.", 0, java.lang.Integer.MAX_VALUE, otherCharacteristics);
1021          case 172049237: /*shelfLifeStorage*/  return new Property("shelfLifeStorage", "ProductShelfLife", "Shelf Life and storage information.", 0, java.lang.Integer.MAX_VALUE, shelfLifeStorage);
1022          case -1969347631: /*manufacturer*/  return new Property("manufacturer", "Reference(Organization)", "Manufacturer of this Package Item.", 0, java.lang.Integer.MAX_VALUE, manufacturer);
1023          default: return super.getNamedProperty(_hash, _name, _checkValid);
1024          }
1025
1026        }
1027
1028      @Override
1029      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1030        switch (hash) {
1031        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1032        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
1033        case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // Quantity
1034        case 299066663: /*material*/ return this.material == null ? new Base[0] : this.material.toArray(new Base[this.material.size()]); // CodeableConcept
1035        case -1021448255: /*alternateMaterial*/ return this.alternateMaterial == null ? new Base[0] : this.alternateMaterial.toArray(new Base[this.alternateMaterial.size()]); // CodeableConcept
1036        case -1335157162: /*device*/ return this.device == null ? new Base[0] : this.device.toArray(new Base[this.device.size()]); // Reference
1037        case 62093686: /*manufacturedItem*/ return this.manufacturedItem == null ? new Base[0] : this.manufacturedItem.toArray(new Base[this.manufacturedItem.size()]); // Reference
1038        case 908628089: /*packageItem*/ return this.packageItem == null ? new Base[0] : this.packageItem.toArray(new Base[this.packageItem.size()]); // MedicinalProductPackagedPackageItemComponent
1039        case -1599676319: /*physicalCharacteristics*/ return this.physicalCharacteristics == null ? new Base[0] : new Base[] {this.physicalCharacteristics}; // ProdCharacteristic
1040        case 722135304: /*otherCharacteristics*/ return this.otherCharacteristics == null ? new Base[0] : this.otherCharacteristics.toArray(new Base[this.otherCharacteristics.size()]); // CodeableConcept
1041        case 172049237: /*shelfLifeStorage*/ return this.shelfLifeStorage == null ? new Base[0] : this.shelfLifeStorage.toArray(new Base[this.shelfLifeStorage.size()]); // ProductShelfLife
1042        case -1969347631: /*manufacturer*/ return this.manufacturer == null ? new Base[0] : this.manufacturer.toArray(new Base[this.manufacturer.size()]); // Reference
1043        default: return super.getProperty(hash, name, checkValid);
1044        }
1045
1046      }
1047
1048      @Override
1049      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1050        switch (hash) {
1051        case -1618432855: // identifier
1052          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1053          return value;
1054        case 3575610: // type
1055          this.type = castToCodeableConcept(value); // CodeableConcept
1056          return value;
1057        case -1285004149: // quantity
1058          this.quantity = castToQuantity(value); // Quantity
1059          return value;
1060        case 299066663: // material
1061          this.getMaterial().add(castToCodeableConcept(value)); // CodeableConcept
1062          return value;
1063        case -1021448255: // alternateMaterial
1064          this.getAlternateMaterial().add(castToCodeableConcept(value)); // CodeableConcept
1065          return value;
1066        case -1335157162: // device
1067          this.getDevice().add(castToReference(value)); // Reference
1068          return value;
1069        case 62093686: // manufacturedItem
1070          this.getManufacturedItem().add(castToReference(value)); // Reference
1071          return value;
1072        case 908628089: // packageItem
1073          this.getPackageItem().add((MedicinalProductPackagedPackageItemComponent) value); // MedicinalProductPackagedPackageItemComponent
1074          return value;
1075        case -1599676319: // physicalCharacteristics
1076          this.physicalCharacteristics = castToProdCharacteristic(value); // ProdCharacteristic
1077          return value;
1078        case 722135304: // otherCharacteristics
1079          this.getOtherCharacteristics().add(castToCodeableConcept(value)); // CodeableConcept
1080          return value;
1081        case 172049237: // shelfLifeStorage
1082          this.getShelfLifeStorage().add(castToProductShelfLife(value)); // ProductShelfLife
1083          return value;
1084        case -1969347631: // manufacturer
1085          this.getManufacturer().add(castToReference(value)); // Reference
1086          return value;
1087        default: return super.setProperty(hash, name, value);
1088        }
1089
1090      }
1091
1092      @Override
1093      public Base setProperty(String name, Base value) throws FHIRException {
1094        if (name.equals("identifier")) {
1095          this.getIdentifier().add(castToIdentifier(value));
1096        } else if (name.equals("type")) {
1097          this.type = castToCodeableConcept(value); // CodeableConcept
1098        } else if (name.equals("quantity")) {
1099          this.quantity = castToQuantity(value); // Quantity
1100        } else if (name.equals("material")) {
1101          this.getMaterial().add(castToCodeableConcept(value));
1102        } else if (name.equals("alternateMaterial")) {
1103          this.getAlternateMaterial().add(castToCodeableConcept(value));
1104        } else if (name.equals("device")) {
1105          this.getDevice().add(castToReference(value));
1106        } else if (name.equals("manufacturedItem")) {
1107          this.getManufacturedItem().add(castToReference(value));
1108        } else if (name.equals("packageItem")) {
1109          this.getPackageItem().add((MedicinalProductPackagedPackageItemComponent) value);
1110        } else if (name.equals("physicalCharacteristics")) {
1111          this.physicalCharacteristics = castToProdCharacteristic(value); // ProdCharacteristic
1112        } else if (name.equals("otherCharacteristics")) {
1113          this.getOtherCharacteristics().add(castToCodeableConcept(value));
1114        } else if (name.equals("shelfLifeStorage")) {
1115          this.getShelfLifeStorage().add(castToProductShelfLife(value));
1116        } else if (name.equals("manufacturer")) {
1117          this.getManufacturer().add(castToReference(value));
1118        } else
1119          return super.setProperty(name, value);
1120        return value;
1121      }
1122
1123      @Override
1124      public Base makeProperty(int hash, String name) throws FHIRException {
1125        switch (hash) {
1126        case -1618432855:  return addIdentifier(); 
1127        case 3575610:  return getType(); 
1128        case -1285004149:  return getQuantity(); 
1129        case 299066663:  return addMaterial(); 
1130        case -1021448255:  return addAlternateMaterial(); 
1131        case -1335157162:  return addDevice(); 
1132        case 62093686:  return addManufacturedItem(); 
1133        case 908628089:  return addPackageItem(); 
1134        case -1599676319:  return getPhysicalCharacteristics(); 
1135        case 722135304:  return addOtherCharacteristics(); 
1136        case 172049237:  return addShelfLifeStorage(); 
1137        case -1969347631:  return addManufacturer(); 
1138        default: return super.makeProperty(hash, name);
1139        }
1140
1141      }
1142
1143      @Override
1144      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1145        switch (hash) {
1146        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
1147        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
1148        case -1285004149: /*quantity*/ return new String[] {"Quantity"};
1149        case 299066663: /*material*/ return new String[] {"CodeableConcept"};
1150        case -1021448255: /*alternateMaterial*/ return new String[] {"CodeableConcept"};
1151        case -1335157162: /*device*/ return new String[] {"Reference"};
1152        case 62093686: /*manufacturedItem*/ return new String[] {"Reference"};
1153        case 908628089: /*packageItem*/ return new String[] {"@MedicinalProductPackaged.packageItem"};
1154        case -1599676319: /*physicalCharacteristics*/ return new String[] {"ProdCharacteristic"};
1155        case 722135304: /*otherCharacteristics*/ return new String[] {"CodeableConcept"};
1156        case 172049237: /*shelfLifeStorage*/ return new String[] {"ProductShelfLife"};
1157        case -1969347631: /*manufacturer*/ return new String[] {"Reference"};
1158        default: return super.getTypesForProperty(hash, name);
1159        }
1160
1161      }
1162
1163      @Override
1164      public Base addChild(String name) throws FHIRException {
1165        if (name.equals("identifier")) {
1166          return addIdentifier();
1167        }
1168        else if (name.equals("type")) {
1169          this.type = new CodeableConcept();
1170          return this.type;
1171        }
1172        else if (name.equals("quantity")) {
1173          this.quantity = new Quantity();
1174          return this.quantity;
1175        }
1176        else if (name.equals("material")) {
1177          return addMaterial();
1178        }
1179        else if (name.equals("alternateMaterial")) {
1180          return addAlternateMaterial();
1181        }
1182        else if (name.equals("device")) {
1183          return addDevice();
1184        }
1185        else if (name.equals("manufacturedItem")) {
1186          return addManufacturedItem();
1187        }
1188        else if (name.equals("packageItem")) {
1189          return addPackageItem();
1190        }
1191        else if (name.equals("physicalCharacteristics")) {
1192          this.physicalCharacteristics = new ProdCharacteristic();
1193          return this.physicalCharacteristics;
1194        }
1195        else if (name.equals("otherCharacteristics")) {
1196          return addOtherCharacteristics();
1197        }
1198        else if (name.equals("shelfLifeStorage")) {
1199          return addShelfLifeStorage();
1200        }
1201        else if (name.equals("manufacturer")) {
1202          return addManufacturer();
1203        }
1204        else
1205          return super.addChild(name);
1206      }
1207
1208      public MedicinalProductPackagedPackageItemComponent copy() {
1209        MedicinalProductPackagedPackageItemComponent dst = new MedicinalProductPackagedPackageItemComponent();
1210        copyValues(dst);
1211        if (identifier != null) {
1212          dst.identifier = new ArrayList<Identifier>();
1213          for (Identifier i : identifier)
1214            dst.identifier.add(i.copy());
1215        };
1216        dst.type = type == null ? null : type.copy();
1217        dst.quantity = quantity == null ? null : quantity.copy();
1218        if (material != null) {
1219          dst.material = new ArrayList<CodeableConcept>();
1220          for (CodeableConcept i : material)
1221            dst.material.add(i.copy());
1222        };
1223        if (alternateMaterial != null) {
1224          dst.alternateMaterial = new ArrayList<CodeableConcept>();
1225          for (CodeableConcept i : alternateMaterial)
1226            dst.alternateMaterial.add(i.copy());
1227        };
1228        if (device != null) {
1229          dst.device = new ArrayList<Reference>();
1230          for (Reference i : device)
1231            dst.device.add(i.copy());
1232        };
1233        if (manufacturedItem != null) {
1234          dst.manufacturedItem = new ArrayList<Reference>();
1235          for (Reference i : manufacturedItem)
1236            dst.manufacturedItem.add(i.copy());
1237        };
1238        if (packageItem != null) {
1239          dst.packageItem = new ArrayList<MedicinalProductPackagedPackageItemComponent>();
1240          for (MedicinalProductPackagedPackageItemComponent i : packageItem)
1241            dst.packageItem.add(i.copy());
1242        };
1243        dst.physicalCharacteristics = physicalCharacteristics == null ? null : physicalCharacteristics.copy();
1244        if (otherCharacteristics != null) {
1245          dst.otherCharacteristics = new ArrayList<CodeableConcept>();
1246          for (CodeableConcept i : otherCharacteristics)
1247            dst.otherCharacteristics.add(i.copy());
1248        };
1249        if (shelfLifeStorage != null) {
1250          dst.shelfLifeStorage = new ArrayList<ProductShelfLife>();
1251          for (ProductShelfLife i : shelfLifeStorage)
1252            dst.shelfLifeStorage.add(i.copy());
1253        };
1254        if (manufacturer != null) {
1255          dst.manufacturer = new ArrayList<Reference>();
1256          for (Reference i : manufacturer)
1257            dst.manufacturer.add(i.copy());
1258        };
1259        return dst;
1260      }
1261
1262      @Override
1263      public boolean equalsDeep(Base other_) {
1264        if (!super.equalsDeep(other_))
1265          return false;
1266        if (!(other_ instanceof MedicinalProductPackagedPackageItemComponent))
1267          return false;
1268        MedicinalProductPackagedPackageItemComponent o = (MedicinalProductPackagedPackageItemComponent) other_;
1269        return compareDeep(identifier, o.identifier, true) && compareDeep(type, o.type, true) && compareDeep(quantity, o.quantity, true)
1270           && compareDeep(material, o.material, true) && compareDeep(alternateMaterial, o.alternateMaterial, true)
1271           && compareDeep(device, o.device, true) && compareDeep(manufacturedItem, o.manufacturedItem, true)
1272           && compareDeep(packageItem, o.packageItem, true) && compareDeep(physicalCharacteristics, o.physicalCharacteristics, true)
1273           && compareDeep(otherCharacteristics, o.otherCharacteristics, true) && compareDeep(shelfLifeStorage, o.shelfLifeStorage, true)
1274           && compareDeep(manufacturer, o.manufacturer, true);
1275      }
1276
1277      @Override
1278      public boolean equalsShallow(Base other_) {
1279        if (!super.equalsShallow(other_))
1280          return false;
1281        if (!(other_ instanceof MedicinalProductPackagedPackageItemComponent))
1282          return false;
1283        MedicinalProductPackagedPackageItemComponent o = (MedicinalProductPackagedPackageItemComponent) other_;
1284        return true;
1285      }
1286
1287      public boolean isEmpty() {
1288        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, type, quantity
1289          , material, alternateMaterial, device, manufacturedItem, packageItem, physicalCharacteristics
1290          , otherCharacteristics, shelfLifeStorage, manufacturer);
1291      }
1292
1293  public String fhirType() {
1294    return "MedicinalProductPackaged.packageItem";
1295
1296  }
1297
1298  }
1299
1300    /**
1301     * Unique identifier.
1302     */
1303    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1304    @Description(shortDefinition="Unique identifier", formalDefinition="Unique identifier." )
1305    protected List<Identifier> identifier;
1306
1307    /**
1308     * The product with this is a pack for.
1309     */
1310    @Child(name = "subject", type = {MedicinalProduct.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1311    @Description(shortDefinition="The product with this is a pack for", formalDefinition="The product with this is a pack for." )
1312    protected List<Reference> subject;
1313    /**
1314     * The actual objects that are the target of the reference (The product with this is a pack for.)
1315     */
1316    protected List<MedicinalProduct> subjectTarget;
1317
1318
1319    /**
1320     * Textual description.
1321     */
1322    @Child(name = "description", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=true)
1323    @Description(shortDefinition="Textual description", formalDefinition="Textual description." )
1324    protected StringType description;
1325
1326    /**
1327     * The legal status of supply of the medicinal product as classified by the regulator.
1328     */
1329    @Child(name = "legalStatusOfSupply", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true)
1330    @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." )
1331    protected CodeableConcept legalStatusOfSupply;
1332
1333    /**
1334     * Marketing information.
1335     */
1336    @Child(name = "marketingStatus", type = {MarketingStatus.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1337    @Description(shortDefinition="Marketing information", formalDefinition="Marketing information." )
1338    protected List<MarketingStatus> marketingStatus;
1339
1340    /**
1341     * Manufacturer of this Package Item.
1342     */
1343    @Child(name = "marketingAuthorization", type = {MedicinalProductAuthorization.class}, order=5, min=0, max=1, modifier=false, summary=true)
1344    @Description(shortDefinition="Manufacturer of this Package Item", formalDefinition="Manufacturer of this Package Item." )
1345    protected Reference marketingAuthorization;
1346
1347    /**
1348     * The actual object that is the target of the reference (Manufacturer of this Package Item.)
1349     */
1350    protected MedicinalProductAuthorization marketingAuthorizationTarget;
1351
1352    /**
1353     * Manufacturer of this Package Item.
1354     */
1355    @Child(name = "manufacturer", type = {Organization.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1356    @Description(shortDefinition="Manufacturer of this Package Item", formalDefinition="Manufacturer of this Package Item." )
1357    protected List<Reference> manufacturer;
1358    /**
1359     * The actual objects that are the target of the reference (Manufacturer of this Package Item.)
1360     */
1361    protected List<Organization> manufacturerTarget;
1362
1363
1364    /**
1365     * Batch numbering.
1366     */
1367    @Child(name = "batchIdentifier", type = {}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1368    @Description(shortDefinition="Batch numbering", formalDefinition="Batch numbering." )
1369    protected List<MedicinalProductPackagedBatchIdentifierComponent> batchIdentifier;
1370
1371    /**
1372     * A packaging item, as a contained for medicine, possibly with other packaging items within.
1373     */
1374    @Child(name = "packageItem", type = {}, order=8, min=1, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1375    @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." )
1376    protected List<MedicinalProductPackagedPackageItemComponent> packageItem;
1377
1378    private static final long serialVersionUID = -1530863773L;
1379
1380  /**
1381   * Constructor
1382   */
1383    public MedicinalProductPackaged() {
1384      super();
1385    }
1386
1387    /**
1388     * @return {@link #identifier} (Unique identifier.)
1389     */
1390    public List<Identifier> getIdentifier() { 
1391      if (this.identifier == null)
1392        this.identifier = new ArrayList<Identifier>();
1393      return this.identifier;
1394    }
1395
1396    /**
1397     * @return Returns a reference to <code>this</code> for easy method chaining
1398     */
1399    public MedicinalProductPackaged setIdentifier(List<Identifier> theIdentifier) { 
1400      this.identifier = theIdentifier;
1401      return this;
1402    }
1403
1404    public boolean hasIdentifier() { 
1405      if (this.identifier == null)
1406        return false;
1407      for (Identifier item : this.identifier)
1408        if (!item.isEmpty())
1409          return true;
1410      return false;
1411    }
1412
1413    public Identifier addIdentifier() { //3
1414      Identifier t = new Identifier();
1415      if (this.identifier == null)
1416        this.identifier = new ArrayList<Identifier>();
1417      this.identifier.add(t);
1418      return t;
1419    }
1420
1421    public MedicinalProductPackaged addIdentifier(Identifier t) { //3
1422      if (t == null)
1423        return this;
1424      if (this.identifier == null)
1425        this.identifier = new ArrayList<Identifier>();
1426      this.identifier.add(t);
1427      return this;
1428    }
1429
1430    /**
1431     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
1432     */
1433    public Identifier getIdentifierFirstRep() { 
1434      if (getIdentifier().isEmpty()) {
1435        addIdentifier();
1436      }
1437      return getIdentifier().get(0);
1438    }
1439
1440    /**
1441     * @return {@link #subject} (The product with this is a pack for.)
1442     */
1443    public List<Reference> getSubject() { 
1444      if (this.subject == null)
1445        this.subject = new ArrayList<Reference>();
1446      return this.subject;
1447    }
1448
1449    /**
1450     * @return Returns a reference to <code>this</code> for easy method chaining
1451     */
1452    public MedicinalProductPackaged setSubject(List<Reference> theSubject) { 
1453      this.subject = theSubject;
1454      return this;
1455    }
1456
1457    public boolean hasSubject() { 
1458      if (this.subject == null)
1459        return false;
1460      for (Reference item : this.subject)
1461        if (!item.isEmpty())
1462          return true;
1463      return false;
1464    }
1465
1466    public Reference addSubject() { //3
1467      Reference t = new Reference();
1468      if (this.subject == null)
1469        this.subject = new ArrayList<Reference>();
1470      this.subject.add(t);
1471      return t;
1472    }
1473
1474    public MedicinalProductPackaged addSubject(Reference t) { //3
1475      if (t == null)
1476        return this;
1477      if (this.subject == null)
1478        this.subject = new ArrayList<Reference>();
1479      this.subject.add(t);
1480      return this;
1481    }
1482
1483    /**
1484     * @return The first repetition of repeating field {@link #subject}, creating it if it does not already exist
1485     */
1486    public Reference getSubjectFirstRep() { 
1487      if (getSubject().isEmpty()) {
1488        addSubject();
1489      }
1490      return getSubject().get(0);
1491    }
1492
1493    /**
1494     * @deprecated Use Reference#setResource(IBaseResource) instead
1495     */
1496    @Deprecated
1497    public List<MedicinalProduct> getSubjectTarget() { 
1498      if (this.subjectTarget == null)
1499        this.subjectTarget = new ArrayList<MedicinalProduct>();
1500      return this.subjectTarget;
1501    }
1502
1503    /**
1504     * @deprecated Use Reference#setResource(IBaseResource) instead
1505     */
1506    @Deprecated
1507    public MedicinalProduct addSubjectTarget() { 
1508      MedicinalProduct r = new MedicinalProduct();
1509      if (this.subjectTarget == null)
1510        this.subjectTarget = new ArrayList<MedicinalProduct>();
1511      this.subjectTarget.add(r);
1512      return r;
1513    }
1514
1515    /**
1516     * @return {@link #description} (Textual description.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
1517     */
1518    public StringType getDescriptionElement() { 
1519      if (this.description == null)
1520        if (Configuration.errorOnAutoCreate())
1521          throw new Error("Attempt to auto-create MedicinalProductPackaged.description");
1522        else if (Configuration.doAutoCreate())
1523          this.description = new StringType(); // bb
1524      return this.description;
1525    }
1526
1527    public boolean hasDescriptionElement() { 
1528      return this.description != null && !this.description.isEmpty();
1529    }
1530
1531    public boolean hasDescription() { 
1532      return this.description != null && !this.description.isEmpty();
1533    }
1534
1535    /**
1536     * @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
1537     */
1538    public MedicinalProductPackaged setDescriptionElement(StringType value) { 
1539      this.description = value;
1540      return this;
1541    }
1542
1543    /**
1544     * @return Textual description.
1545     */
1546    public String getDescription() { 
1547      return this.description == null ? null : this.description.getValue();
1548    }
1549
1550    /**
1551     * @param value Textual description.
1552     */
1553    public MedicinalProductPackaged setDescription(String value) { 
1554      if (Utilities.noString(value))
1555        this.description = null;
1556      else {
1557        if (this.description == null)
1558          this.description = new StringType();
1559        this.description.setValue(value);
1560      }
1561      return this;
1562    }
1563
1564    /**
1565     * @return {@link #legalStatusOfSupply} (The legal status of supply of the medicinal product as classified by the regulator.)
1566     */
1567    public CodeableConcept getLegalStatusOfSupply() { 
1568      if (this.legalStatusOfSupply == null)
1569        if (Configuration.errorOnAutoCreate())
1570          throw new Error("Attempt to auto-create MedicinalProductPackaged.legalStatusOfSupply");
1571        else if (Configuration.doAutoCreate())
1572          this.legalStatusOfSupply = new CodeableConcept(); // cc
1573      return this.legalStatusOfSupply;
1574    }
1575
1576    public boolean hasLegalStatusOfSupply() { 
1577      return this.legalStatusOfSupply != null && !this.legalStatusOfSupply.isEmpty();
1578    }
1579
1580    /**
1581     * @param value {@link #legalStatusOfSupply} (The legal status of supply of the medicinal product as classified by the regulator.)
1582     */
1583    public MedicinalProductPackaged setLegalStatusOfSupply(CodeableConcept value) { 
1584      this.legalStatusOfSupply = value;
1585      return this;
1586    }
1587
1588    /**
1589     * @return {@link #marketingStatus} (Marketing information.)
1590     */
1591    public List<MarketingStatus> getMarketingStatus() { 
1592      if (this.marketingStatus == null)
1593        this.marketingStatus = new ArrayList<MarketingStatus>();
1594      return this.marketingStatus;
1595    }
1596
1597    /**
1598     * @return Returns a reference to <code>this</code> for easy method chaining
1599     */
1600    public MedicinalProductPackaged setMarketingStatus(List<MarketingStatus> theMarketingStatus) { 
1601      this.marketingStatus = theMarketingStatus;
1602      return this;
1603    }
1604
1605    public boolean hasMarketingStatus() { 
1606      if (this.marketingStatus == null)
1607        return false;
1608      for (MarketingStatus item : this.marketingStatus)
1609        if (!item.isEmpty())
1610          return true;
1611      return false;
1612    }
1613
1614    public MarketingStatus addMarketingStatus() { //3
1615      MarketingStatus t = new MarketingStatus();
1616      if (this.marketingStatus == null)
1617        this.marketingStatus = new ArrayList<MarketingStatus>();
1618      this.marketingStatus.add(t);
1619      return t;
1620    }
1621
1622    public MedicinalProductPackaged addMarketingStatus(MarketingStatus t) { //3
1623      if (t == null)
1624        return this;
1625      if (this.marketingStatus == null)
1626        this.marketingStatus = new ArrayList<MarketingStatus>();
1627      this.marketingStatus.add(t);
1628      return this;
1629    }
1630
1631    /**
1632     * @return The first repetition of repeating field {@link #marketingStatus}, creating it if it does not already exist
1633     */
1634    public MarketingStatus getMarketingStatusFirstRep() { 
1635      if (getMarketingStatus().isEmpty()) {
1636        addMarketingStatus();
1637      }
1638      return getMarketingStatus().get(0);
1639    }
1640
1641    /**
1642     * @return {@link #marketingAuthorization} (Manufacturer of this Package Item.)
1643     */
1644    public Reference getMarketingAuthorization() { 
1645      if (this.marketingAuthorization == null)
1646        if (Configuration.errorOnAutoCreate())
1647          throw new Error("Attempt to auto-create MedicinalProductPackaged.marketingAuthorization");
1648        else if (Configuration.doAutoCreate())
1649          this.marketingAuthorization = new Reference(); // cc
1650      return this.marketingAuthorization;
1651    }
1652
1653    public boolean hasMarketingAuthorization() { 
1654      return this.marketingAuthorization != null && !this.marketingAuthorization.isEmpty();
1655    }
1656
1657    /**
1658     * @param value {@link #marketingAuthorization} (Manufacturer of this Package Item.)
1659     */
1660    public MedicinalProductPackaged setMarketingAuthorization(Reference value) { 
1661      this.marketingAuthorization = value;
1662      return this;
1663    }
1664
1665    /**
1666     * @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.)
1667     */
1668    public MedicinalProductAuthorization getMarketingAuthorizationTarget() { 
1669      if (this.marketingAuthorizationTarget == null)
1670        if (Configuration.errorOnAutoCreate())
1671          throw new Error("Attempt to auto-create MedicinalProductPackaged.marketingAuthorization");
1672        else if (Configuration.doAutoCreate())
1673          this.marketingAuthorizationTarget = new MedicinalProductAuthorization(); // aa
1674      return this.marketingAuthorizationTarget;
1675    }
1676
1677    /**
1678     * @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.)
1679     */
1680    public MedicinalProductPackaged setMarketingAuthorizationTarget(MedicinalProductAuthorization value) { 
1681      this.marketingAuthorizationTarget = value;
1682      return this;
1683    }
1684
1685    /**
1686     * @return {@link #manufacturer} (Manufacturer of this Package Item.)
1687     */
1688    public List<Reference> getManufacturer() { 
1689      if (this.manufacturer == null)
1690        this.manufacturer = new ArrayList<Reference>();
1691      return this.manufacturer;
1692    }
1693
1694    /**
1695     * @return Returns a reference to <code>this</code> for easy method chaining
1696     */
1697    public MedicinalProductPackaged setManufacturer(List<Reference> theManufacturer) { 
1698      this.manufacturer = theManufacturer;
1699      return this;
1700    }
1701
1702    public boolean hasManufacturer() { 
1703      if (this.manufacturer == null)
1704        return false;
1705      for (Reference item : this.manufacturer)
1706        if (!item.isEmpty())
1707          return true;
1708      return false;
1709    }
1710
1711    public Reference addManufacturer() { //3
1712      Reference t = new Reference();
1713      if (this.manufacturer == null)
1714        this.manufacturer = new ArrayList<Reference>();
1715      this.manufacturer.add(t);
1716      return t;
1717    }
1718
1719    public MedicinalProductPackaged addManufacturer(Reference t) { //3
1720      if (t == null)
1721        return this;
1722      if (this.manufacturer == null)
1723        this.manufacturer = new ArrayList<Reference>();
1724      this.manufacturer.add(t);
1725      return this;
1726    }
1727
1728    /**
1729     * @return The first repetition of repeating field {@link #manufacturer}, creating it if it does not already exist
1730     */
1731    public Reference getManufacturerFirstRep() { 
1732      if (getManufacturer().isEmpty()) {
1733        addManufacturer();
1734      }
1735      return getManufacturer().get(0);
1736    }
1737
1738    /**
1739     * @deprecated Use Reference#setResource(IBaseResource) instead
1740     */
1741    @Deprecated
1742    public List<Organization> getManufacturerTarget() { 
1743      if (this.manufacturerTarget == null)
1744        this.manufacturerTarget = new ArrayList<Organization>();
1745      return this.manufacturerTarget;
1746    }
1747
1748    /**
1749     * @deprecated Use Reference#setResource(IBaseResource) instead
1750     */
1751    @Deprecated
1752    public Organization addManufacturerTarget() { 
1753      Organization r = new Organization();
1754      if (this.manufacturerTarget == null)
1755        this.manufacturerTarget = new ArrayList<Organization>();
1756      this.manufacturerTarget.add(r);
1757      return r;
1758    }
1759
1760    /**
1761     * @return {@link #batchIdentifier} (Batch numbering.)
1762     */
1763    public List<MedicinalProductPackagedBatchIdentifierComponent> getBatchIdentifier() { 
1764      if (this.batchIdentifier == null)
1765        this.batchIdentifier = new ArrayList<MedicinalProductPackagedBatchIdentifierComponent>();
1766      return this.batchIdentifier;
1767    }
1768
1769    /**
1770     * @return Returns a reference to <code>this</code> for easy method chaining
1771     */
1772    public MedicinalProductPackaged setBatchIdentifier(List<MedicinalProductPackagedBatchIdentifierComponent> theBatchIdentifier) { 
1773      this.batchIdentifier = theBatchIdentifier;
1774      return this;
1775    }
1776
1777    public boolean hasBatchIdentifier() { 
1778      if (this.batchIdentifier == null)
1779        return false;
1780      for (MedicinalProductPackagedBatchIdentifierComponent item : this.batchIdentifier)
1781        if (!item.isEmpty())
1782          return true;
1783      return false;
1784    }
1785
1786    public MedicinalProductPackagedBatchIdentifierComponent addBatchIdentifier() { //3
1787      MedicinalProductPackagedBatchIdentifierComponent t = new MedicinalProductPackagedBatchIdentifierComponent();
1788      if (this.batchIdentifier == null)
1789        this.batchIdentifier = new ArrayList<MedicinalProductPackagedBatchIdentifierComponent>();
1790      this.batchIdentifier.add(t);
1791      return t;
1792    }
1793
1794    public MedicinalProductPackaged addBatchIdentifier(MedicinalProductPackagedBatchIdentifierComponent t) { //3
1795      if (t == null)
1796        return this;
1797      if (this.batchIdentifier == null)
1798        this.batchIdentifier = new ArrayList<MedicinalProductPackagedBatchIdentifierComponent>();
1799      this.batchIdentifier.add(t);
1800      return this;
1801    }
1802
1803    /**
1804     * @return The first repetition of repeating field {@link #batchIdentifier}, creating it if it does not already exist
1805     */
1806    public MedicinalProductPackagedBatchIdentifierComponent getBatchIdentifierFirstRep() { 
1807      if (getBatchIdentifier().isEmpty()) {
1808        addBatchIdentifier();
1809      }
1810      return getBatchIdentifier().get(0);
1811    }
1812
1813    /**
1814     * @return {@link #packageItem} (A packaging item, as a contained for medicine, possibly with other packaging items within.)
1815     */
1816    public List<MedicinalProductPackagedPackageItemComponent> getPackageItem() { 
1817      if (this.packageItem == null)
1818        this.packageItem = new ArrayList<MedicinalProductPackagedPackageItemComponent>();
1819      return this.packageItem;
1820    }
1821
1822    /**
1823     * @return Returns a reference to <code>this</code> for easy method chaining
1824     */
1825    public MedicinalProductPackaged setPackageItem(List<MedicinalProductPackagedPackageItemComponent> thePackageItem) { 
1826      this.packageItem = thePackageItem;
1827      return this;
1828    }
1829
1830    public boolean hasPackageItem() { 
1831      if (this.packageItem == null)
1832        return false;
1833      for (MedicinalProductPackagedPackageItemComponent item : this.packageItem)
1834        if (!item.isEmpty())
1835          return true;
1836      return false;
1837    }
1838
1839    public MedicinalProductPackagedPackageItemComponent addPackageItem() { //3
1840      MedicinalProductPackagedPackageItemComponent t = new MedicinalProductPackagedPackageItemComponent();
1841      if (this.packageItem == null)
1842        this.packageItem = new ArrayList<MedicinalProductPackagedPackageItemComponent>();
1843      this.packageItem.add(t);
1844      return t;
1845    }
1846
1847    public MedicinalProductPackaged addPackageItem(MedicinalProductPackagedPackageItemComponent t) { //3
1848      if (t == null)
1849        return this;
1850      if (this.packageItem == null)
1851        this.packageItem = new ArrayList<MedicinalProductPackagedPackageItemComponent>();
1852      this.packageItem.add(t);
1853      return this;
1854    }
1855
1856    /**
1857     * @return The first repetition of repeating field {@link #packageItem}, creating it if it does not already exist
1858     */
1859    public MedicinalProductPackagedPackageItemComponent getPackageItemFirstRep() { 
1860      if (getPackageItem().isEmpty()) {
1861        addPackageItem();
1862      }
1863      return getPackageItem().get(0);
1864    }
1865
1866      protected void listChildren(List<Property> children) {
1867        super.listChildren(children);
1868        children.add(new Property("identifier", "Identifier", "Unique identifier.", 0, java.lang.Integer.MAX_VALUE, identifier));
1869        children.add(new Property("subject", "Reference(MedicinalProduct)", "The product with this is a pack for.", 0, java.lang.Integer.MAX_VALUE, subject));
1870        children.add(new Property("description", "string", "Textual description.", 0, 1, description));
1871        children.add(new Property("legalStatusOfSupply", "CodeableConcept", "The legal status of supply of the medicinal product as classified by the regulator.", 0, 1, legalStatusOfSupply));
1872        children.add(new Property("marketingStatus", "MarketingStatus", "Marketing information.", 0, java.lang.Integer.MAX_VALUE, marketingStatus));
1873        children.add(new Property("marketingAuthorization", "Reference(MedicinalProductAuthorization)", "Manufacturer of this Package Item.", 0, 1, marketingAuthorization));
1874        children.add(new Property("manufacturer", "Reference(Organization)", "Manufacturer of this Package Item.", 0, java.lang.Integer.MAX_VALUE, manufacturer));
1875        children.add(new Property("batchIdentifier", "", "Batch numbering.", 0, java.lang.Integer.MAX_VALUE, batchIdentifier));
1876        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));
1877      }
1878
1879      @Override
1880      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1881        switch (_hash) {
1882        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Unique identifier.", 0, java.lang.Integer.MAX_VALUE, identifier);
1883        case -1867885268: /*subject*/  return new Property("subject", "Reference(MedicinalProduct)", "The product with this is a pack for.", 0, java.lang.Integer.MAX_VALUE, subject);
1884        case -1724546052: /*description*/  return new Property("description", "string", "Textual description.", 0, 1, description);
1885        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);
1886        case 70767032: /*marketingStatus*/  return new Property("marketingStatus", "MarketingStatus", "Marketing information.", 0, java.lang.Integer.MAX_VALUE, marketingStatus);
1887        case 571831283: /*marketingAuthorization*/  return new Property("marketingAuthorization", "Reference(MedicinalProductAuthorization)", "Manufacturer of this Package Item.", 0, 1, marketingAuthorization);
1888        case -1969347631: /*manufacturer*/  return new Property("manufacturer", "Reference(Organization)", "Manufacturer of this Package Item.", 0, java.lang.Integer.MAX_VALUE, manufacturer);
1889        case -1688395901: /*batchIdentifier*/  return new Property("batchIdentifier", "", "Batch numbering.", 0, java.lang.Integer.MAX_VALUE, batchIdentifier);
1890        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);
1891        default: return super.getNamedProperty(_hash, _name, _checkValid);
1892        }
1893
1894      }
1895
1896      @Override
1897      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1898        switch (hash) {
1899        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1900        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : this.subject.toArray(new Base[this.subject.size()]); // Reference
1901        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // StringType
1902        case -844874031: /*legalStatusOfSupply*/ return this.legalStatusOfSupply == null ? new Base[0] : new Base[] {this.legalStatusOfSupply}; // CodeableConcept
1903        case 70767032: /*marketingStatus*/ return this.marketingStatus == null ? new Base[0] : this.marketingStatus.toArray(new Base[this.marketingStatus.size()]); // MarketingStatus
1904        case 571831283: /*marketingAuthorization*/ return this.marketingAuthorization == null ? new Base[0] : new Base[] {this.marketingAuthorization}; // Reference
1905        case -1969347631: /*manufacturer*/ return this.manufacturer == null ? new Base[0] : this.manufacturer.toArray(new Base[this.manufacturer.size()]); // Reference
1906        case -1688395901: /*batchIdentifier*/ return this.batchIdentifier == null ? new Base[0] : this.batchIdentifier.toArray(new Base[this.batchIdentifier.size()]); // MedicinalProductPackagedBatchIdentifierComponent
1907        case 908628089: /*packageItem*/ return this.packageItem == null ? new Base[0] : this.packageItem.toArray(new Base[this.packageItem.size()]); // MedicinalProductPackagedPackageItemComponent
1908        default: return super.getProperty(hash, name, checkValid);
1909        }
1910
1911      }
1912
1913      @Override
1914      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1915        switch (hash) {
1916        case -1618432855: // identifier
1917          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1918          return value;
1919        case -1867885268: // subject
1920          this.getSubject().add(castToReference(value)); // Reference
1921          return value;
1922        case -1724546052: // description
1923          this.description = castToString(value); // StringType
1924          return value;
1925        case -844874031: // legalStatusOfSupply
1926          this.legalStatusOfSupply = castToCodeableConcept(value); // CodeableConcept
1927          return value;
1928        case 70767032: // marketingStatus
1929          this.getMarketingStatus().add(castToMarketingStatus(value)); // MarketingStatus
1930          return value;
1931        case 571831283: // marketingAuthorization
1932          this.marketingAuthorization = castToReference(value); // Reference
1933          return value;
1934        case -1969347631: // manufacturer
1935          this.getManufacturer().add(castToReference(value)); // Reference
1936          return value;
1937        case -1688395901: // batchIdentifier
1938          this.getBatchIdentifier().add((MedicinalProductPackagedBatchIdentifierComponent) value); // MedicinalProductPackagedBatchIdentifierComponent
1939          return value;
1940        case 908628089: // packageItem
1941          this.getPackageItem().add((MedicinalProductPackagedPackageItemComponent) value); // MedicinalProductPackagedPackageItemComponent
1942          return value;
1943        default: return super.setProperty(hash, name, value);
1944        }
1945
1946      }
1947
1948      @Override
1949      public Base setProperty(String name, Base value) throws FHIRException {
1950        if (name.equals("identifier")) {
1951          this.getIdentifier().add(castToIdentifier(value));
1952        } else if (name.equals("subject")) {
1953          this.getSubject().add(castToReference(value));
1954        } else if (name.equals("description")) {
1955          this.description = castToString(value); // StringType
1956        } else if (name.equals("legalStatusOfSupply")) {
1957          this.legalStatusOfSupply = castToCodeableConcept(value); // CodeableConcept
1958        } else if (name.equals("marketingStatus")) {
1959          this.getMarketingStatus().add(castToMarketingStatus(value));
1960        } else if (name.equals("marketingAuthorization")) {
1961          this.marketingAuthorization = castToReference(value); // Reference
1962        } else if (name.equals("manufacturer")) {
1963          this.getManufacturer().add(castToReference(value));
1964        } else if (name.equals("batchIdentifier")) {
1965          this.getBatchIdentifier().add((MedicinalProductPackagedBatchIdentifierComponent) value);
1966        } else if (name.equals("packageItem")) {
1967          this.getPackageItem().add((MedicinalProductPackagedPackageItemComponent) value);
1968        } else
1969          return super.setProperty(name, value);
1970        return value;
1971      }
1972
1973      @Override
1974      public Base makeProperty(int hash, String name) throws FHIRException {
1975        switch (hash) {
1976        case -1618432855:  return addIdentifier(); 
1977        case -1867885268:  return addSubject(); 
1978        case -1724546052:  return getDescriptionElement();
1979        case -844874031:  return getLegalStatusOfSupply(); 
1980        case 70767032:  return addMarketingStatus(); 
1981        case 571831283:  return getMarketingAuthorization(); 
1982        case -1969347631:  return addManufacturer(); 
1983        case -1688395901:  return addBatchIdentifier(); 
1984        case 908628089:  return addPackageItem(); 
1985        default: return super.makeProperty(hash, name);
1986        }
1987
1988      }
1989
1990      @Override
1991      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1992        switch (hash) {
1993        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
1994        case -1867885268: /*subject*/ return new String[] {"Reference"};
1995        case -1724546052: /*description*/ return new String[] {"string"};
1996        case -844874031: /*legalStatusOfSupply*/ return new String[] {"CodeableConcept"};
1997        case 70767032: /*marketingStatus*/ return new String[] {"MarketingStatus"};
1998        case 571831283: /*marketingAuthorization*/ return new String[] {"Reference"};
1999        case -1969347631: /*manufacturer*/ return new String[] {"Reference"};
2000        case -1688395901: /*batchIdentifier*/ return new String[] {};
2001        case 908628089: /*packageItem*/ return new String[] {};
2002        default: return super.getTypesForProperty(hash, name);
2003        }
2004
2005      }
2006
2007      @Override
2008      public Base addChild(String name) throws FHIRException {
2009        if (name.equals("identifier")) {
2010          return addIdentifier();
2011        }
2012        else if (name.equals("subject")) {
2013          return addSubject();
2014        }
2015        else if (name.equals("description")) {
2016          throw new FHIRException("Cannot call addChild on a primitive type MedicinalProductPackaged.description");
2017        }
2018        else if (name.equals("legalStatusOfSupply")) {
2019          this.legalStatusOfSupply = new CodeableConcept();
2020          return this.legalStatusOfSupply;
2021        }
2022        else if (name.equals("marketingStatus")) {
2023          return addMarketingStatus();
2024        }
2025        else if (name.equals("marketingAuthorization")) {
2026          this.marketingAuthorization = new Reference();
2027          return this.marketingAuthorization;
2028        }
2029        else if (name.equals("manufacturer")) {
2030          return addManufacturer();
2031        }
2032        else if (name.equals("batchIdentifier")) {
2033          return addBatchIdentifier();
2034        }
2035        else if (name.equals("packageItem")) {
2036          return addPackageItem();
2037        }
2038        else
2039          return super.addChild(name);
2040      }
2041
2042  public String fhirType() {
2043    return "MedicinalProductPackaged";
2044
2045  }
2046
2047      public MedicinalProductPackaged copy() {
2048        MedicinalProductPackaged dst = new MedicinalProductPackaged();
2049        copyValues(dst);
2050        if (identifier != null) {
2051          dst.identifier = new ArrayList<Identifier>();
2052          for (Identifier i : identifier)
2053            dst.identifier.add(i.copy());
2054        };
2055        if (subject != null) {
2056          dst.subject = new ArrayList<Reference>();
2057          for (Reference i : subject)
2058            dst.subject.add(i.copy());
2059        };
2060        dst.description = description == null ? null : description.copy();
2061        dst.legalStatusOfSupply = legalStatusOfSupply == null ? null : legalStatusOfSupply.copy();
2062        if (marketingStatus != null) {
2063          dst.marketingStatus = new ArrayList<MarketingStatus>();
2064          for (MarketingStatus i : marketingStatus)
2065            dst.marketingStatus.add(i.copy());
2066        };
2067        dst.marketingAuthorization = marketingAuthorization == null ? null : marketingAuthorization.copy();
2068        if (manufacturer != null) {
2069          dst.manufacturer = new ArrayList<Reference>();
2070          for (Reference i : manufacturer)
2071            dst.manufacturer.add(i.copy());
2072        };
2073        if (batchIdentifier != null) {
2074          dst.batchIdentifier = new ArrayList<MedicinalProductPackagedBatchIdentifierComponent>();
2075          for (MedicinalProductPackagedBatchIdentifierComponent i : batchIdentifier)
2076            dst.batchIdentifier.add(i.copy());
2077        };
2078        if (packageItem != null) {
2079          dst.packageItem = new ArrayList<MedicinalProductPackagedPackageItemComponent>();
2080          for (MedicinalProductPackagedPackageItemComponent i : packageItem)
2081            dst.packageItem.add(i.copy());
2082        };
2083        return dst;
2084      }
2085
2086      protected MedicinalProductPackaged typedCopy() {
2087        return copy();
2088      }
2089
2090      @Override
2091      public boolean equalsDeep(Base other_) {
2092        if (!super.equalsDeep(other_))
2093          return false;
2094        if (!(other_ instanceof MedicinalProductPackaged))
2095          return false;
2096        MedicinalProductPackaged o = (MedicinalProductPackaged) other_;
2097        return compareDeep(identifier, o.identifier, true) && compareDeep(subject, o.subject, true) && compareDeep(description, o.description, true)
2098           && compareDeep(legalStatusOfSupply, o.legalStatusOfSupply, true) && compareDeep(marketingStatus, o.marketingStatus, true)
2099           && compareDeep(marketingAuthorization, o.marketingAuthorization, true) && compareDeep(manufacturer, o.manufacturer, true)
2100           && compareDeep(batchIdentifier, o.batchIdentifier, true) && compareDeep(packageItem, o.packageItem, true)
2101          ;
2102      }
2103
2104      @Override
2105      public boolean equalsShallow(Base other_) {
2106        if (!super.equalsShallow(other_))
2107          return false;
2108        if (!(other_ instanceof MedicinalProductPackaged))
2109          return false;
2110        MedicinalProductPackaged o = (MedicinalProductPackaged) other_;
2111        return compareValues(description, o.description, true);
2112      }
2113
2114      public boolean isEmpty() {
2115        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, subject, description
2116          , legalStatusOfSupply, marketingStatus, marketingAuthorization, manufacturer, batchIdentifier
2117          , packageItem);
2118      }
2119
2120  @Override
2121  public ResourceType getResourceType() {
2122    return ResourceType.MedicinalProductPackaged;
2123   }
2124
2125 /**
2126   * Search parameter: <b>identifier</b>
2127   * <p>
2128   * Description: <b>Unique identifier</b><br>
2129   * Type: <b>token</b><br>
2130   * Path: <b>MedicinalProductPackaged.identifier</b><br>
2131   * </p>
2132   */
2133  @SearchParamDefinition(name="identifier", path="MedicinalProductPackaged.identifier", description="Unique identifier", type="token" )
2134  public static final String SP_IDENTIFIER = "identifier";
2135 /**
2136   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2137   * <p>
2138   * Description: <b>Unique identifier</b><br>
2139   * Type: <b>token</b><br>
2140   * Path: <b>MedicinalProductPackaged.identifier</b><br>
2141   * </p>
2142   */
2143  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
2144
2145 /**
2146   * Search parameter: <b>subject</b>
2147   * <p>
2148   * Description: <b>The product with this is a pack for</b><br>
2149   * Type: <b>reference</b><br>
2150   * Path: <b>MedicinalProductPackaged.subject</b><br>
2151   * </p>
2152   */
2153  @SearchParamDefinition(name="subject", path="MedicinalProductPackaged.subject", description="The product with this is a pack for", type="reference", target={MedicinalProduct.class } )
2154  public static final String SP_SUBJECT = "subject";
2155 /**
2156   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
2157   * <p>
2158   * Description: <b>The product with this is a pack for</b><br>
2159   * Type: <b>reference</b><br>
2160   * Path: <b>MedicinalProductPackaged.subject</b><br>
2161   * </p>
2162   */
2163  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
2164
2165/**
2166   * Constant for fluent queries to be used to add include statements. Specifies
2167   * the path value of "<b>MedicinalProductPackaged:subject</b>".
2168   */
2169  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("MedicinalProductPackaged:subject").toLocked();
2170
2171
2172}
2173