001package org.hl7.fhir.r5.model;
002
003
004/*
005  Copyright (c) 2011+, HL7, Inc.
006  All rights reserved.
007  
008  Redistribution and use in source and binary forms, with or without modification, \
009  are permitted provided that the following conditions are met:
010  
011   * Redistributions of source code must retain the above copyright notice, this \
012     list of conditions and the following disclaimer.
013   * Redistributions in binary form must reproduce the above copyright notice, \
014     this list of conditions and the following disclaimer in the documentation \
015     and/or other materials provided with the distribution.
016   * Neither the name of HL7 nor the names of its contributors may be used to 
017     endorse or promote products derived from this software without specific 
018     prior written permission.
019  
020  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
021  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
022  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
023  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
024  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
025  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
026  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
027  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
028  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
029  POSSIBILITY OF SUCH DAMAGE.
030  */
031
032// Generated on Tue, Dec 28, 2021 07:16+1100 for FHIR v5.0.0-snapshot1
033
034import java.util.ArrayList;
035import java.util.Date;
036import java.util.List;
037import org.hl7.fhir.utilities.Utilities;
038import org.hl7.fhir.r5.model.Enumerations.*;
039import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
040import org.hl7.fhir.exceptions.FHIRException;
041import org.hl7.fhir.instance.model.api.ICompositeType;
042import ca.uhn.fhir.model.api.annotation.ResourceDef;
043import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
044import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
045import ca.uhn.fhir.model.api.annotation.Child;
046import ca.uhn.fhir.model.api.annotation.ChildOrder;
047import ca.uhn.fhir.model.api.annotation.Description;
048import ca.uhn.fhir.model.api.annotation.Block;
049
050/**
051 * The definition and characteristics of a medicinal manufactured item, such as a tablet or capsule, as contained in a packaged medicinal product.
052 */
053@ResourceDef(name="ManufacturedItemDefinition", profile="http://hl7.org/fhir/StructureDefinition/ManufacturedItemDefinition")
054public class ManufacturedItemDefinition extends DomainResource {
055
056    @Block()
057    public static class ManufacturedItemDefinitionPropertyComponent extends BackboneElement implements IBaseBackboneElement {
058        /**
059         * A code expressing the type of characteristic.
060         */
061        @Child(name = "type", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=true)
062        @Description(shortDefinition="A code expressing the type of characteristic", formalDefinition="A code expressing the type of characteristic." )
063        protected CodeableConcept type;
064
065        /**
066         * A value for the characteristic.
067         */
068        @Child(name = "value", type = {CodeableConcept.class, Quantity.class, DateType.class, BooleanType.class, Attachment.class}, order=2, min=0, max=1, modifier=false, summary=true)
069        @Description(shortDefinition="A value for the characteristic", formalDefinition="A value for the characteristic." )
070        protected DataType value;
071
072        private static final long serialVersionUID = -1659186716L;
073
074    /**
075     * Constructor
076     */
077      public ManufacturedItemDefinitionPropertyComponent() {
078        super();
079      }
080
081    /**
082     * Constructor
083     */
084      public ManufacturedItemDefinitionPropertyComponent(CodeableConcept type) {
085        super();
086        this.setType(type);
087      }
088
089        /**
090         * @return {@link #type} (A code expressing the type of characteristic.)
091         */
092        public CodeableConcept getType() { 
093          if (this.type == null)
094            if (Configuration.errorOnAutoCreate())
095              throw new Error("Attempt to auto-create ManufacturedItemDefinitionPropertyComponent.type");
096            else if (Configuration.doAutoCreate())
097              this.type = new CodeableConcept(); // cc
098          return this.type;
099        }
100
101        public boolean hasType() { 
102          return this.type != null && !this.type.isEmpty();
103        }
104
105        /**
106         * @param value {@link #type} (A code expressing the type of characteristic.)
107         */
108        public ManufacturedItemDefinitionPropertyComponent setType(CodeableConcept value) { 
109          this.type = value;
110          return this;
111        }
112
113        /**
114         * @return {@link #value} (A value for the characteristic.)
115         */
116        public DataType getValue() { 
117          return this.value;
118        }
119
120        /**
121         * @return {@link #value} (A value for the characteristic.)
122         */
123        public CodeableConcept getValueCodeableConcept() throws FHIRException { 
124          if (this.value == null)
125            this.value = new CodeableConcept();
126          if (!(this.value instanceof CodeableConcept))
127            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.value.getClass().getName()+" was encountered");
128          return (CodeableConcept) this.value;
129        }
130
131        public boolean hasValueCodeableConcept() { 
132          return this != null && this.value instanceof CodeableConcept;
133        }
134
135        /**
136         * @return {@link #value} (A value for the characteristic.)
137         */
138        public Quantity getValueQuantity() throws FHIRException { 
139          if (this.value == null)
140            this.value = new Quantity();
141          if (!(this.value instanceof Quantity))
142            throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.value.getClass().getName()+" was encountered");
143          return (Quantity) this.value;
144        }
145
146        public boolean hasValueQuantity() { 
147          return this != null && this.value instanceof Quantity;
148        }
149
150        /**
151         * @return {@link #value} (A value for the characteristic.)
152         */
153        public DateType getValueDateType() throws FHIRException { 
154          if (this.value == null)
155            this.value = new DateType();
156          if (!(this.value instanceof DateType))
157            throw new FHIRException("Type mismatch: the type DateType was expected, but "+this.value.getClass().getName()+" was encountered");
158          return (DateType) this.value;
159        }
160
161        public boolean hasValueDateType() { 
162          return this != null && this.value instanceof DateType;
163        }
164
165        /**
166         * @return {@link #value} (A value for the characteristic.)
167         */
168        public BooleanType getValueBooleanType() throws FHIRException { 
169          if (this.value == null)
170            this.value = new BooleanType();
171          if (!(this.value instanceof BooleanType))
172            throw new FHIRException("Type mismatch: the type BooleanType was expected, but "+this.value.getClass().getName()+" was encountered");
173          return (BooleanType) this.value;
174        }
175
176        public boolean hasValueBooleanType() { 
177          return this != null && this.value instanceof BooleanType;
178        }
179
180        /**
181         * @return {@link #value} (A value for the characteristic.)
182         */
183        public Attachment getValueAttachment() throws FHIRException { 
184          if (this.value == null)
185            this.value = new Attachment();
186          if (!(this.value instanceof Attachment))
187            throw new FHIRException("Type mismatch: the type Attachment was expected, but "+this.value.getClass().getName()+" was encountered");
188          return (Attachment) this.value;
189        }
190
191        public boolean hasValueAttachment() { 
192          return this != null && this.value instanceof Attachment;
193        }
194
195        public boolean hasValue() { 
196          return this.value != null && !this.value.isEmpty();
197        }
198
199        /**
200         * @param value {@link #value} (A value for the characteristic.)
201         */
202        public ManufacturedItemDefinitionPropertyComponent setValue(DataType value) { 
203          if (value != null && !(value instanceof CodeableConcept || value instanceof Quantity || value instanceof DateType || value instanceof BooleanType || value instanceof Attachment))
204            throw new Error("Not the right type for ManufacturedItemDefinition.property.value[x]: "+value.fhirType());
205          this.value = value;
206          return this;
207        }
208
209        protected void listChildren(List<Property> children) {
210          super.listChildren(children);
211          children.add(new Property("type", "CodeableConcept", "A code expressing the type of characteristic.", 0, 1, type));
212          children.add(new Property("value[x]", "CodeableConcept|Quantity|date|boolean|Attachment", "A value for the characteristic.", 0, 1, value));
213        }
214
215        @Override
216        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
217          switch (_hash) {
218          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "A code expressing the type of characteristic.", 0, 1, type);
219          case -1410166417: /*value[x]*/  return new Property("value[x]", "CodeableConcept|Quantity|date|boolean|Attachment", "A value for the characteristic.", 0, 1, value);
220          case 111972721: /*value*/  return new Property("value[x]", "CodeableConcept|Quantity|date|boolean|Attachment", "A value for the characteristic.", 0, 1, value);
221          case 924902896: /*valueCodeableConcept*/  return new Property("value[x]", "CodeableConcept", "A value for the characteristic.", 0, 1, value);
222          case -2029823716: /*valueQuantity*/  return new Property("value[x]", "Quantity", "A value for the characteristic.", 0, 1, value);
223          case -766192449: /*valueDate*/  return new Property("value[x]", "date", "A value for the characteristic.", 0, 1, value);
224          case 733421943: /*valueBoolean*/  return new Property("value[x]", "boolean", "A value for the characteristic.", 0, 1, value);
225          case -475566732: /*valueAttachment*/  return new Property("value[x]", "Attachment", "A value for the characteristic.", 0, 1, value);
226          default: return super.getNamedProperty(_hash, _name, _checkValid);
227          }
228
229        }
230
231      @Override
232      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
233        switch (hash) {
234        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
235        case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // DataType
236        default: return super.getProperty(hash, name, checkValid);
237        }
238
239      }
240
241      @Override
242      public Base setProperty(int hash, String name, Base value) throws FHIRException {
243        switch (hash) {
244        case 3575610: // type
245          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
246          return value;
247        case 111972721: // value
248          this.value = TypeConvertor.castToType(value); // DataType
249          return value;
250        default: return super.setProperty(hash, name, value);
251        }
252
253      }
254
255      @Override
256      public Base setProperty(String name, Base value) throws FHIRException {
257        if (name.equals("type")) {
258          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
259        } else if (name.equals("value[x]")) {
260          this.value = TypeConvertor.castToType(value); // DataType
261        } else
262          return super.setProperty(name, value);
263        return value;
264      }
265
266      @Override
267      public Base makeProperty(int hash, String name) throws FHIRException {
268        switch (hash) {
269        case 3575610:  return getType();
270        case -1410166417:  return getValue();
271        case 111972721:  return getValue();
272        default: return super.makeProperty(hash, name);
273        }
274
275      }
276
277      @Override
278      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
279        switch (hash) {
280        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
281        case 111972721: /*value*/ return new String[] {"CodeableConcept", "Quantity", "date", "boolean", "Attachment"};
282        default: return super.getTypesForProperty(hash, name);
283        }
284
285      }
286
287      @Override
288      public Base addChild(String name) throws FHIRException {
289        if (name.equals("type")) {
290          this.type = new CodeableConcept();
291          return this.type;
292        }
293        else if (name.equals("valueCodeableConcept")) {
294          this.value = new CodeableConcept();
295          return this.value;
296        }
297        else if (name.equals("valueQuantity")) {
298          this.value = new Quantity();
299          return this.value;
300        }
301        else if (name.equals("valueDate")) {
302          this.value = new DateType();
303          return this.value;
304        }
305        else if (name.equals("valueBoolean")) {
306          this.value = new BooleanType();
307          return this.value;
308        }
309        else if (name.equals("valueAttachment")) {
310          this.value = new Attachment();
311          return this.value;
312        }
313        else
314          return super.addChild(name);
315      }
316
317      public ManufacturedItemDefinitionPropertyComponent copy() {
318        ManufacturedItemDefinitionPropertyComponent dst = new ManufacturedItemDefinitionPropertyComponent();
319        copyValues(dst);
320        return dst;
321      }
322
323      public void copyValues(ManufacturedItemDefinitionPropertyComponent dst) {
324        super.copyValues(dst);
325        dst.type = type == null ? null : type.copy();
326        dst.value = value == null ? null : value.copy();
327      }
328
329      @Override
330      public boolean equalsDeep(Base other_) {
331        if (!super.equalsDeep(other_))
332          return false;
333        if (!(other_ instanceof ManufacturedItemDefinitionPropertyComponent))
334          return false;
335        ManufacturedItemDefinitionPropertyComponent o = (ManufacturedItemDefinitionPropertyComponent) other_;
336        return compareDeep(type, o.type, true) && compareDeep(value, o.value, true);
337      }
338
339      @Override
340      public boolean equalsShallow(Base other_) {
341        if (!super.equalsShallow(other_))
342          return false;
343        if (!(other_ instanceof ManufacturedItemDefinitionPropertyComponent))
344          return false;
345        ManufacturedItemDefinitionPropertyComponent o = (ManufacturedItemDefinitionPropertyComponent) other_;
346        return true;
347      }
348
349      public boolean isEmpty() {
350        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, value);
351      }
352
353  public String fhirType() {
354    return "ManufacturedItemDefinition.property";
355
356  }
357
358  }
359
360    /**
361     * Unique identifier.
362     */
363    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
364    @Description(shortDefinition="Unique identifier", formalDefinition="Unique identifier." )
365    protected List<Identifier> identifier;
366
367    /**
368     * The status of this item. Enables tracking the life-cycle of the content.
369     */
370    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
371    @Description(shortDefinition="draft | active | retired | unknown", formalDefinition="The status of this item. Enables tracking the life-cycle of the content." )
372    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/publication-status")
373    protected Enumeration<PublicationStatus> status;
374
375    /**
376     * Dose form as manufactured and before any transformation into the pharmaceutical product.
377     */
378    @Child(name = "manufacturedDoseForm", type = {CodeableConcept.class}, order=2, min=1, max=1, modifier=false, summary=true)
379    @Description(shortDefinition="Dose form as manufactured and before any transformation into the pharmaceutical product", formalDefinition="Dose form as manufactured and before any transformation into the pharmaceutical product." )
380    protected CodeableConcept manufacturedDoseForm;
381
382    /**
383     * The “real world” units in which the quantity of the manufactured item is described.
384     */
385    @Child(name = "unitOfPresentation", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true)
386    @Description(shortDefinition="The “real world” units in which the quantity of the manufactured item is described", formalDefinition="The “real world” units in which the quantity of the manufactured item is described." )
387    protected CodeableConcept unitOfPresentation;
388
389    /**
390     * Manufacturer of the item (Note that this should be named "manufacturer" but it currently causes technical issues).
391     */
392    @Child(name = "manufacturer", type = {Organization.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
393    @Description(shortDefinition="Manufacturer of the item (Note that this should be named \"manufacturer\" but it currently causes technical issues)", formalDefinition="Manufacturer of the item (Note that this should be named \"manufacturer\" but it currently causes technical issues)." )
394    protected List<Reference> manufacturer;
395
396    /**
397     * The ingredients of this manufactured item. This is only needed if the ingredients are not specified by incoming references from the Ingredient resource.
398     */
399    @Child(name = "ingredient", type = {CodeableConcept.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
400    @Description(shortDefinition="The ingredients of this manufactured item. This is only needed if the ingredients are not specified by incoming references from the Ingredient resource", formalDefinition="The ingredients of this manufactured item. This is only needed if the ingredients are not specified by incoming references from the Ingredient resource." )
401    protected List<CodeableConcept> ingredient;
402
403    /**
404     * General characteristics of this item.
405     */
406    @Child(name = "property", type = {}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
407    @Description(shortDefinition="General characteristics of this item", formalDefinition="General characteristics of this item." )
408    protected List<ManufacturedItemDefinitionPropertyComponent> property;
409
410    private static final long serialVersionUID = 1578434864L;
411
412  /**
413   * Constructor
414   */
415    public ManufacturedItemDefinition() {
416      super();
417    }
418
419  /**
420   * Constructor
421   */
422    public ManufacturedItemDefinition(PublicationStatus status, CodeableConcept manufacturedDoseForm) {
423      super();
424      this.setStatus(status);
425      this.setManufacturedDoseForm(manufacturedDoseForm);
426    }
427
428    /**
429     * @return {@link #identifier} (Unique identifier.)
430     */
431    public List<Identifier> getIdentifier() { 
432      if (this.identifier == null)
433        this.identifier = new ArrayList<Identifier>();
434      return this.identifier;
435    }
436
437    /**
438     * @return Returns a reference to <code>this</code> for easy method chaining
439     */
440    public ManufacturedItemDefinition setIdentifier(List<Identifier> theIdentifier) { 
441      this.identifier = theIdentifier;
442      return this;
443    }
444
445    public boolean hasIdentifier() { 
446      if (this.identifier == null)
447        return false;
448      for (Identifier item : this.identifier)
449        if (!item.isEmpty())
450          return true;
451      return false;
452    }
453
454    public Identifier addIdentifier() { //3
455      Identifier t = new Identifier();
456      if (this.identifier == null)
457        this.identifier = new ArrayList<Identifier>();
458      this.identifier.add(t);
459      return t;
460    }
461
462    public ManufacturedItemDefinition addIdentifier(Identifier t) { //3
463      if (t == null)
464        return this;
465      if (this.identifier == null)
466        this.identifier = new ArrayList<Identifier>();
467      this.identifier.add(t);
468      return this;
469    }
470
471    /**
472     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist {3}
473     */
474    public Identifier getIdentifierFirstRep() { 
475      if (getIdentifier().isEmpty()) {
476        addIdentifier();
477      }
478      return getIdentifier().get(0);
479    }
480
481    /**
482     * @return {@link #status} (The status of this item. Enables tracking the life-cycle of the content.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
483     */
484    public Enumeration<PublicationStatus> getStatusElement() { 
485      if (this.status == null)
486        if (Configuration.errorOnAutoCreate())
487          throw new Error("Attempt to auto-create ManufacturedItemDefinition.status");
488        else if (Configuration.doAutoCreate())
489          this.status = new Enumeration<PublicationStatus>(new PublicationStatusEnumFactory()); // bb
490      return this.status;
491    }
492
493    public boolean hasStatusElement() { 
494      return this.status != null && !this.status.isEmpty();
495    }
496
497    public boolean hasStatus() { 
498      return this.status != null && !this.status.isEmpty();
499    }
500
501    /**
502     * @param value {@link #status} (The status of this item. Enables tracking the life-cycle of the content.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
503     */
504    public ManufacturedItemDefinition setStatusElement(Enumeration<PublicationStatus> value) { 
505      this.status = value;
506      return this;
507    }
508
509    /**
510     * @return The status of this item. Enables tracking the life-cycle of the content.
511     */
512    public PublicationStatus getStatus() { 
513      return this.status == null ? null : this.status.getValue();
514    }
515
516    /**
517     * @param value The status of this item. Enables tracking the life-cycle of the content.
518     */
519    public ManufacturedItemDefinition setStatus(PublicationStatus value) { 
520        if (this.status == null)
521          this.status = new Enumeration<PublicationStatus>(new PublicationStatusEnumFactory());
522        this.status.setValue(value);
523      return this;
524    }
525
526    /**
527     * @return {@link #manufacturedDoseForm} (Dose form as manufactured and before any transformation into the pharmaceutical product.)
528     */
529    public CodeableConcept getManufacturedDoseForm() { 
530      if (this.manufacturedDoseForm == null)
531        if (Configuration.errorOnAutoCreate())
532          throw new Error("Attempt to auto-create ManufacturedItemDefinition.manufacturedDoseForm");
533        else if (Configuration.doAutoCreate())
534          this.manufacturedDoseForm = new CodeableConcept(); // cc
535      return this.manufacturedDoseForm;
536    }
537
538    public boolean hasManufacturedDoseForm() { 
539      return this.manufacturedDoseForm != null && !this.manufacturedDoseForm.isEmpty();
540    }
541
542    /**
543     * @param value {@link #manufacturedDoseForm} (Dose form as manufactured and before any transformation into the pharmaceutical product.)
544     */
545    public ManufacturedItemDefinition setManufacturedDoseForm(CodeableConcept value) { 
546      this.manufacturedDoseForm = value;
547      return this;
548    }
549
550    /**
551     * @return {@link #unitOfPresentation} (The “real world” units in which the quantity of the manufactured item is described.)
552     */
553    public CodeableConcept getUnitOfPresentation() { 
554      if (this.unitOfPresentation == null)
555        if (Configuration.errorOnAutoCreate())
556          throw new Error("Attempt to auto-create ManufacturedItemDefinition.unitOfPresentation");
557        else if (Configuration.doAutoCreate())
558          this.unitOfPresentation = new CodeableConcept(); // cc
559      return this.unitOfPresentation;
560    }
561
562    public boolean hasUnitOfPresentation() { 
563      return this.unitOfPresentation != null && !this.unitOfPresentation.isEmpty();
564    }
565
566    /**
567     * @param value {@link #unitOfPresentation} (The “real world” units in which the quantity of the manufactured item is described.)
568     */
569    public ManufacturedItemDefinition setUnitOfPresentation(CodeableConcept value) { 
570      this.unitOfPresentation = value;
571      return this;
572    }
573
574    /**
575     * @return {@link #manufacturer} (Manufacturer of the item (Note that this should be named "manufacturer" but it currently causes technical issues).)
576     */
577    public List<Reference> getManufacturer() { 
578      if (this.manufacturer == null)
579        this.manufacturer = new ArrayList<Reference>();
580      return this.manufacturer;
581    }
582
583    /**
584     * @return Returns a reference to <code>this</code> for easy method chaining
585     */
586    public ManufacturedItemDefinition setManufacturer(List<Reference> theManufacturer) { 
587      this.manufacturer = theManufacturer;
588      return this;
589    }
590
591    public boolean hasManufacturer() { 
592      if (this.manufacturer == null)
593        return false;
594      for (Reference item : this.manufacturer)
595        if (!item.isEmpty())
596          return true;
597      return false;
598    }
599
600    public Reference addManufacturer() { //3
601      Reference t = new Reference();
602      if (this.manufacturer == null)
603        this.manufacturer = new ArrayList<Reference>();
604      this.manufacturer.add(t);
605      return t;
606    }
607
608    public ManufacturedItemDefinition addManufacturer(Reference t) { //3
609      if (t == null)
610        return this;
611      if (this.manufacturer == null)
612        this.manufacturer = new ArrayList<Reference>();
613      this.manufacturer.add(t);
614      return this;
615    }
616
617    /**
618     * @return The first repetition of repeating field {@link #manufacturer}, creating it if it does not already exist {3}
619     */
620    public Reference getManufacturerFirstRep() { 
621      if (getManufacturer().isEmpty()) {
622        addManufacturer();
623      }
624      return getManufacturer().get(0);
625    }
626
627    /**
628     * @return {@link #ingredient} (The ingredients of this manufactured item. This is only needed if the ingredients are not specified by incoming references from the Ingredient resource.)
629     */
630    public List<CodeableConcept> getIngredient() { 
631      if (this.ingredient == null)
632        this.ingredient = new ArrayList<CodeableConcept>();
633      return this.ingredient;
634    }
635
636    /**
637     * @return Returns a reference to <code>this</code> for easy method chaining
638     */
639    public ManufacturedItemDefinition setIngredient(List<CodeableConcept> theIngredient) { 
640      this.ingredient = theIngredient;
641      return this;
642    }
643
644    public boolean hasIngredient() { 
645      if (this.ingredient == null)
646        return false;
647      for (CodeableConcept item : this.ingredient)
648        if (!item.isEmpty())
649          return true;
650      return false;
651    }
652
653    public CodeableConcept addIngredient() { //3
654      CodeableConcept t = new CodeableConcept();
655      if (this.ingredient == null)
656        this.ingredient = new ArrayList<CodeableConcept>();
657      this.ingredient.add(t);
658      return t;
659    }
660
661    public ManufacturedItemDefinition addIngredient(CodeableConcept t) { //3
662      if (t == null)
663        return this;
664      if (this.ingredient == null)
665        this.ingredient = new ArrayList<CodeableConcept>();
666      this.ingredient.add(t);
667      return this;
668    }
669
670    /**
671     * @return The first repetition of repeating field {@link #ingredient}, creating it if it does not already exist {3}
672     */
673    public CodeableConcept getIngredientFirstRep() { 
674      if (getIngredient().isEmpty()) {
675        addIngredient();
676      }
677      return getIngredient().get(0);
678    }
679
680    /**
681     * @return {@link #property} (General characteristics of this item.)
682     */
683    public List<ManufacturedItemDefinitionPropertyComponent> getProperty() { 
684      if (this.property == null)
685        this.property = new ArrayList<ManufacturedItemDefinitionPropertyComponent>();
686      return this.property;
687    }
688
689    /**
690     * @return Returns a reference to <code>this</code> for easy method chaining
691     */
692    public ManufacturedItemDefinition setProperty(List<ManufacturedItemDefinitionPropertyComponent> theProperty) { 
693      this.property = theProperty;
694      return this;
695    }
696
697    public boolean hasProperty() { 
698      if (this.property == null)
699        return false;
700      for (ManufacturedItemDefinitionPropertyComponent item : this.property)
701        if (!item.isEmpty())
702          return true;
703      return false;
704    }
705
706    public ManufacturedItemDefinitionPropertyComponent addProperty() { //3
707      ManufacturedItemDefinitionPropertyComponent t = new ManufacturedItemDefinitionPropertyComponent();
708      if (this.property == null)
709        this.property = new ArrayList<ManufacturedItemDefinitionPropertyComponent>();
710      this.property.add(t);
711      return t;
712    }
713
714    public ManufacturedItemDefinition addProperty(ManufacturedItemDefinitionPropertyComponent t) { //3
715      if (t == null)
716        return this;
717      if (this.property == null)
718        this.property = new ArrayList<ManufacturedItemDefinitionPropertyComponent>();
719      this.property.add(t);
720      return this;
721    }
722
723    /**
724     * @return The first repetition of repeating field {@link #property}, creating it if it does not already exist {3}
725     */
726    public ManufacturedItemDefinitionPropertyComponent getPropertyFirstRep() { 
727      if (getProperty().isEmpty()) {
728        addProperty();
729      }
730      return getProperty().get(0);
731    }
732
733      protected void listChildren(List<Property> children) {
734        super.listChildren(children);
735        children.add(new Property("identifier", "Identifier", "Unique identifier.", 0, java.lang.Integer.MAX_VALUE, identifier));
736        children.add(new Property("status", "code", "The status of this item. Enables tracking the life-cycle of the content.", 0, 1, status));
737        children.add(new Property("manufacturedDoseForm", "CodeableConcept", "Dose form as manufactured and before any transformation into the pharmaceutical product.", 0, 1, manufacturedDoseForm));
738        children.add(new Property("unitOfPresentation", "CodeableConcept", "The “real world” units in which the quantity of the manufactured item is described.", 0, 1, unitOfPresentation));
739        children.add(new Property("manufacturer", "Reference(Organization)", "Manufacturer of the item (Note that this should be named \"manufacturer\" but it currently causes technical issues).", 0, java.lang.Integer.MAX_VALUE, manufacturer));
740        children.add(new Property("ingredient", "CodeableConcept", "The ingredients of this manufactured item. This is only needed if the ingredients are not specified by incoming references from the Ingredient resource.", 0, java.lang.Integer.MAX_VALUE, ingredient));
741        children.add(new Property("property", "", "General characteristics of this item.", 0, java.lang.Integer.MAX_VALUE, property));
742      }
743
744      @Override
745      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
746        switch (_hash) {
747        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Unique identifier.", 0, java.lang.Integer.MAX_VALUE, identifier);
748        case -892481550: /*status*/  return new Property("status", "code", "The status of this item. Enables tracking the life-cycle of the content.", 0, 1, status);
749        case -1451400348: /*manufacturedDoseForm*/  return new Property("manufacturedDoseForm", "CodeableConcept", "Dose form as manufactured and before any transformation into the pharmaceutical product.", 0, 1, manufacturedDoseForm);
750        case -1427765963: /*unitOfPresentation*/  return new Property("unitOfPresentation", "CodeableConcept", "The “real world” units in which the quantity of the manufactured item is described.", 0, 1, unitOfPresentation);
751        case -1969347631: /*manufacturer*/  return new Property("manufacturer", "Reference(Organization)", "Manufacturer of the item (Note that this should be named \"manufacturer\" but it currently causes technical issues).", 0, java.lang.Integer.MAX_VALUE, manufacturer);
752        case -206409263: /*ingredient*/  return new Property("ingredient", "CodeableConcept", "The ingredients of this manufactured item. This is only needed if the ingredients are not specified by incoming references from the Ingredient resource.", 0, java.lang.Integer.MAX_VALUE, ingredient);
753        case -993141291: /*property*/  return new Property("property", "", "General characteristics of this item.", 0, java.lang.Integer.MAX_VALUE, property);
754        default: return super.getNamedProperty(_hash, _name, _checkValid);
755        }
756
757      }
758
759      @Override
760      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
761        switch (hash) {
762        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
763        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<PublicationStatus>
764        case -1451400348: /*manufacturedDoseForm*/ return this.manufacturedDoseForm == null ? new Base[0] : new Base[] {this.manufacturedDoseForm}; // CodeableConcept
765        case -1427765963: /*unitOfPresentation*/ return this.unitOfPresentation == null ? new Base[0] : new Base[] {this.unitOfPresentation}; // CodeableConcept
766        case -1969347631: /*manufacturer*/ return this.manufacturer == null ? new Base[0] : this.manufacturer.toArray(new Base[this.manufacturer.size()]); // Reference
767        case -206409263: /*ingredient*/ return this.ingredient == null ? new Base[0] : this.ingredient.toArray(new Base[this.ingredient.size()]); // CodeableConcept
768        case -993141291: /*property*/ return this.property == null ? new Base[0] : this.property.toArray(new Base[this.property.size()]); // ManufacturedItemDefinitionPropertyComponent
769        default: return super.getProperty(hash, name, checkValid);
770        }
771
772      }
773
774      @Override
775      public Base setProperty(int hash, String name, Base value) throws FHIRException {
776        switch (hash) {
777        case -1618432855: // identifier
778          this.getIdentifier().add(TypeConvertor.castToIdentifier(value)); // Identifier
779          return value;
780        case -892481550: // status
781          value = new PublicationStatusEnumFactory().fromType(TypeConvertor.castToCode(value));
782          this.status = (Enumeration) value; // Enumeration<PublicationStatus>
783          return value;
784        case -1451400348: // manufacturedDoseForm
785          this.manufacturedDoseForm = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
786          return value;
787        case -1427765963: // unitOfPresentation
788          this.unitOfPresentation = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
789          return value;
790        case -1969347631: // manufacturer
791          this.getManufacturer().add(TypeConvertor.castToReference(value)); // Reference
792          return value;
793        case -206409263: // ingredient
794          this.getIngredient().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
795          return value;
796        case -993141291: // property
797          this.getProperty().add((ManufacturedItemDefinitionPropertyComponent) value); // ManufacturedItemDefinitionPropertyComponent
798          return value;
799        default: return super.setProperty(hash, name, value);
800        }
801
802      }
803
804      @Override
805      public Base setProperty(String name, Base value) throws FHIRException {
806        if (name.equals("identifier")) {
807          this.getIdentifier().add(TypeConvertor.castToIdentifier(value));
808        } else if (name.equals("status")) {
809          value = new PublicationStatusEnumFactory().fromType(TypeConvertor.castToCode(value));
810          this.status = (Enumeration) value; // Enumeration<PublicationStatus>
811        } else if (name.equals("manufacturedDoseForm")) {
812          this.manufacturedDoseForm = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
813        } else if (name.equals("unitOfPresentation")) {
814          this.unitOfPresentation = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
815        } else if (name.equals("manufacturer")) {
816          this.getManufacturer().add(TypeConvertor.castToReference(value));
817        } else if (name.equals("ingredient")) {
818          this.getIngredient().add(TypeConvertor.castToCodeableConcept(value));
819        } else if (name.equals("property")) {
820          this.getProperty().add((ManufacturedItemDefinitionPropertyComponent) value);
821        } else
822          return super.setProperty(name, value);
823        return value;
824      }
825
826      @Override
827      public Base makeProperty(int hash, String name) throws FHIRException {
828        switch (hash) {
829        case -1618432855:  return addIdentifier(); 
830        case -892481550:  return getStatusElement();
831        case -1451400348:  return getManufacturedDoseForm();
832        case -1427765963:  return getUnitOfPresentation();
833        case -1969347631:  return addManufacturer(); 
834        case -206409263:  return addIngredient(); 
835        case -993141291:  return addProperty(); 
836        default: return super.makeProperty(hash, name);
837        }
838
839      }
840
841      @Override
842      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
843        switch (hash) {
844        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
845        case -892481550: /*status*/ return new String[] {"code"};
846        case -1451400348: /*manufacturedDoseForm*/ return new String[] {"CodeableConcept"};
847        case -1427765963: /*unitOfPresentation*/ return new String[] {"CodeableConcept"};
848        case -1969347631: /*manufacturer*/ return new String[] {"Reference"};
849        case -206409263: /*ingredient*/ return new String[] {"CodeableConcept"};
850        case -993141291: /*property*/ return new String[] {};
851        default: return super.getTypesForProperty(hash, name);
852        }
853
854      }
855
856      @Override
857      public Base addChild(String name) throws FHIRException {
858        if (name.equals("identifier")) {
859          return addIdentifier();
860        }
861        else if (name.equals("status")) {
862          throw new FHIRException("Cannot call addChild on a primitive type ManufacturedItemDefinition.status");
863        }
864        else if (name.equals("manufacturedDoseForm")) {
865          this.manufacturedDoseForm = new CodeableConcept();
866          return this.manufacturedDoseForm;
867        }
868        else if (name.equals("unitOfPresentation")) {
869          this.unitOfPresentation = new CodeableConcept();
870          return this.unitOfPresentation;
871        }
872        else if (name.equals("manufacturer")) {
873          return addManufacturer();
874        }
875        else if (name.equals("ingredient")) {
876          return addIngredient();
877        }
878        else if (name.equals("property")) {
879          return addProperty();
880        }
881        else
882          return super.addChild(name);
883      }
884
885  public String fhirType() {
886    return "ManufacturedItemDefinition";
887
888  }
889
890      public ManufacturedItemDefinition copy() {
891        ManufacturedItemDefinition dst = new ManufacturedItemDefinition();
892        copyValues(dst);
893        return dst;
894      }
895
896      public void copyValues(ManufacturedItemDefinition dst) {
897        super.copyValues(dst);
898        if (identifier != null) {
899          dst.identifier = new ArrayList<Identifier>();
900          for (Identifier i : identifier)
901            dst.identifier.add(i.copy());
902        };
903        dst.status = status == null ? null : status.copy();
904        dst.manufacturedDoseForm = manufacturedDoseForm == null ? null : manufacturedDoseForm.copy();
905        dst.unitOfPresentation = unitOfPresentation == null ? null : unitOfPresentation.copy();
906        if (manufacturer != null) {
907          dst.manufacturer = new ArrayList<Reference>();
908          for (Reference i : manufacturer)
909            dst.manufacturer.add(i.copy());
910        };
911        if (ingredient != null) {
912          dst.ingredient = new ArrayList<CodeableConcept>();
913          for (CodeableConcept i : ingredient)
914            dst.ingredient.add(i.copy());
915        };
916        if (property != null) {
917          dst.property = new ArrayList<ManufacturedItemDefinitionPropertyComponent>();
918          for (ManufacturedItemDefinitionPropertyComponent i : property)
919            dst.property.add(i.copy());
920        };
921      }
922
923      protected ManufacturedItemDefinition typedCopy() {
924        return copy();
925      }
926
927      @Override
928      public boolean equalsDeep(Base other_) {
929        if (!super.equalsDeep(other_))
930          return false;
931        if (!(other_ instanceof ManufacturedItemDefinition))
932          return false;
933        ManufacturedItemDefinition o = (ManufacturedItemDefinition) other_;
934        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(manufacturedDoseForm, o.manufacturedDoseForm, true)
935           && compareDeep(unitOfPresentation, o.unitOfPresentation, true) && compareDeep(manufacturer, o.manufacturer, true)
936           && compareDeep(ingredient, o.ingredient, true) && compareDeep(property, o.property, true);
937      }
938
939      @Override
940      public boolean equalsShallow(Base other_) {
941        if (!super.equalsShallow(other_))
942          return false;
943        if (!(other_ instanceof ManufacturedItemDefinition))
944          return false;
945        ManufacturedItemDefinition o = (ManufacturedItemDefinition) other_;
946        return compareValues(status, o.status, true);
947      }
948
949      public boolean isEmpty() {
950        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, manufacturedDoseForm
951          , unitOfPresentation, manufacturer, ingredient, property);
952      }
953
954  @Override
955  public ResourceType getResourceType() {
956    return ResourceType.ManufacturedItemDefinition;
957   }
958
959 /**
960   * Search parameter: <b>dose-form</b>
961   * <p>
962   * Description: <b>Dose form as manufactured and before any transformation into the pharmaceutical product</b><br>
963   * Type: <b>token</b><br>
964   * Path: <b>ManufacturedItemDefinition.manufacturedDoseForm</b><br>
965   * </p>
966   */
967  @SearchParamDefinition(name="dose-form", path="ManufacturedItemDefinition.manufacturedDoseForm", description="Dose form as manufactured and before any transformation into the pharmaceutical product", type="token" )
968  public static final String SP_DOSE_FORM = "dose-form";
969 /**
970   * <b>Fluent Client</b> search parameter constant for <b>dose-form</b>
971   * <p>
972   * Description: <b>Dose form as manufactured and before any transformation into the pharmaceutical product</b><br>
973   * Type: <b>token</b><br>
974   * Path: <b>ManufacturedItemDefinition.manufacturedDoseForm</b><br>
975   * </p>
976   */
977  public static final ca.uhn.fhir.rest.gclient.TokenClientParam DOSE_FORM = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_DOSE_FORM);
978
979 /**
980   * Search parameter: <b>identifier</b>
981   * <p>
982   * Description: <b>Unique identifier</b><br>
983   * Type: <b>token</b><br>
984   * Path: <b>ManufacturedItemDefinition.identifier</b><br>
985   * </p>
986   */
987  @SearchParamDefinition(name="identifier", path="ManufacturedItemDefinition.identifier", description="Unique identifier", type="token" )
988  public static final String SP_IDENTIFIER = "identifier";
989 /**
990   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
991   * <p>
992   * Description: <b>Unique identifier</b><br>
993   * Type: <b>token</b><br>
994   * Path: <b>ManufacturedItemDefinition.identifier</b><br>
995   * </p>
996   */
997  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
998
999 /**
1000   * Search parameter: <b>ingredient</b>
1001   * <p>
1002   * Description: <b>An ingredient of this item</b><br>
1003   * Type: <b>token</b><br>
1004   * Path: <b>ManufacturedItemDefinition.ingredient</b><br>
1005   * </p>
1006   */
1007  @SearchParamDefinition(name="ingredient", path="ManufacturedItemDefinition.ingredient", description="An ingredient of this item", type="token" )
1008  public static final String SP_INGREDIENT = "ingredient";
1009 /**
1010   * <b>Fluent Client</b> search parameter constant for <b>ingredient</b>
1011   * <p>
1012   * Description: <b>An ingredient of this item</b><br>
1013   * Type: <b>token</b><br>
1014   * Path: <b>ManufacturedItemDefinition.ingredient</b><br>
1015   * </p>
1016   */
1017  public static final ca.uhn.fhir.rest.gclient.TokenClientParam INGREDIENT = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_INGREDIENT);
1018
1019
1020}
1021