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