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