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