001package org.hl7.fhir.r4.model;
002
003
004
005/*
006  Copyright (c) 2011+, HL7, Inc.
007  All rights reserved.
008  
009  Redistribution and use in source and binary forms, with or without modification, 
010  are permitted provided that the following conditions are met:
011  
012   * Redistributions of source code must retain the above copyright notice, this 
013     list of conditions and the following disclaimer.
014   * Redistributions in binary form must reproduce the above copyright notice, 
015     this list of conditions and the following disclaimer in the documentation 
016     and/or other materials provided with the distribution.
017   * Neither the name of HL7 nor the names of its contributors may be used to 
018     endorse or promote products derived from this software without specific 
019     prior written permission.
020  
021  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
022  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
023  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
024  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
025  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
026  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
027  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
028  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
029  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
030  POSSIBILITY OF SUCH DAMAGE.
031  
032*/
033
034
035// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1
036
037import java.util.*;
038
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.ChildOrder;
041import ca.uhn.fhir.model.api.annotation.Description;
042import ca.uhn.fhir.model.api.annotation.DatatypeDef;
043import ca.uhn.fhir.model.api.annotation.Block;
044import org.hl7.fhir.instance.model.api.*;
045import org.hl7.fhir.exceptions.FHIRException;
046/**
047 * The shelf-life and storage information for a medicinal product item or container can be described using this class.
048 */
049@DatatypeDef(name="ProductShelfLife")
050public class ProductShelfLife extends BackboneType implements ICompositeType {
051
052    /**
053     * Unique identifier for the packaged Medicinal Product.
054     */
055    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=1, modifier=false, summary=true)
056    @Description(shortDefinition="Unique identifier for the packaged Medicinal Product", formalDefinition="Unique identifier for the packaged Medicinal Product." )
057    protected Identifier identifier;
058
059    /**
060     * This describes the shelf life, taking into account various scenarios such as shelf life of the packaged Medicinal Product itself, shelf life after transformation where necessary and shelf life after the first opening of a bottle, etc. The shelf life type shall be specified using an appropriate controlled vocabulary The controlled term and the controlled term identifier shall be specified.
061     */
062    @Child(name = "type", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=true)
063    @Description(shortDefinition="This describes the shelf life, taking into account various scenarios such as shelf life of the packaged Medicinal Product itself, shelf life after transformation where necessary and shelf life after the first opening of a bottle, etc. The shelf life type shall be specified using an appropriate controlled vocabulary The controlled term and the controlled term identifier shall be specified", formalDefinition="This describes the shelf life, taking into account various scenarios such as shelf life of the packaged Medicinal Product itself, shelf life after transformation where necessary and shelf life after the first opening of a bottle, etc. The shelf life type shall be specified using an appropriate controlled vocabulary The controlled term and the controlled term identifier shall be specified." )
064    protected CodeableConcept type;
065
066    /**
067     * The shelf life time period can be specified using a numerical value for the period of time and its unit of time measurement The unit of measurement shall be specified in accordance with ISO 11240 and the resulting terminology The symbol and the symbol identifier shall be used.
068     */
069    @Child(name = "period", type = {Quantity.class}, order=2, min=1, max=1, modifier=false, summary=true)
070    @Description(shortDefinition="The shelf life time period can be specified using a numerical value for the period of time and its unit of time measurement The unit of measurement shall be specified in accordance with ISO 11240 and the resulting terminology The symbol and the symbol identifier shall be used", formalDefinition="The shelf life time period can be specified using a numerical value for the period of time and its unit of time measurement The unit of measurement shall be specified in accordance with ISO 11240 and the resulting terminology The symbol and the symbol identifier shall be used." )
071    protected Quantity period;
072
073    /**
074     * Special precautions for storage, if any, can be specified using an appropriate controlled vocabulary The controlled term and the controlled term identifier shall be specified.
075     */
076    @Child(name = "specialPrecautionsForStorage", type = {CodeableConcept.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
077    @Description(shortDefinition="Special precautions for storage, if any, can be specified using an appropriate controlled vocabulary The controlled term and the controlled term identifier shall be specified", formalDefinition="Special precautions for storage, if any, can be specified using an appropriate controlled vocabulary The controlled term and the controlled term identifier shall be specified." )
078    protected List<CodeableConcept> specialPrecautionsForStorage;
079
080    private static final long serialVersionUID = -1561196410L;
081
082  /**
083   * Constructor
084   */
085    public ProductShelfLife() {
086      super();
087    }
088
089  /**
090   * Constructor
091   */
092    public ProductShelfLife(CodeableConcept type, Quantity period) {
093      super();
094      this.type = type;
095      this.period = period;
096    }
097
098    /**
099     * @return {@link #identifier} (Unique identifier for the packaged Medicinal Product.)
100     */
101    public Identifier getIdentifier() { 
102      if (this.identifier == null)
103        if (Configuration.errorOnAutoCreate())
104          throw new Error("Attempt to auto-create ProductShelfLife.identifier");
105        else if (Configuration.doAutoCreate())
106          this.identifier = new Identifier(); // cc
107      return this.identifier;
108    }
109
110    public boolean hasIdentifier() { 
111      return this.identifier != null && !this.identifier.isEmpty();
112    }
113
114    /**
115     * @param value {@link #identifier} (Unique identifier for the packaged Medicinal Product.)
116     */
117    public ProductShelfLife setIdentifier(Identifier value) { 
118      this.identifier = value;
119      return this;
120    }
121
122    /**
123     * @return {@link #type} (This describes the shelf life, taking into account various scenarios such as shelf life of the packaged Medicinal Product itself, shelf life after transformation where necessary and shelf life after the first opening of a bottle, etc. The shelf life type shall be specified using an appropriate controlled vocabulary The controlled term and the controlled term identifier shall be specified.)
124     */
125    public CodeableConcept getType() { 
126      if (this.type == null)
127        if (Configuration.errorOnAutoCreate())
128          throw new Error("Attempt to auto-create ProductShelfLife.type");
129        else if (Configuration.doAutoCreate())
130          this.type = new CodeableConcept(); // cc
131      return this.type;
132    }
133
134    public boolean hasType() { 
135      return this.type != null && !this.type.isEmpty();
136    }
137
138    /**
139     * @param value {@link #type} (This describes the shelf life, taking into account various scenarios such as shelf life of the packaged Medicinal Product itself, shelf life after transformation where necessary and shelf life after the first opening of a bottle, etc. The shelf life type shall be specified using an appropriate controlled vocabulary The controlled term and the controlled term identifier shall be specified.)
140     */
141    public ProductShelfLife setType(CodeableConcept value) { 
142      this.type = value;
143      return this;
144    }
145
146    /**
147     * @return {@link #period} (The shelf life time period can be specified using a numerical value for the period of time and its unit of time measurement The unit of measurement shall be specified in accordance with ISO 11240 and the resulting terminology The symbol and the symbol identifier shall be used.)
148     */
149    public Quantity getPeriod() { 
150      if (this.period == null)
151        if (Configuration.errorOnAutoCreate())
152          throw new Error("Attempt to auto-create ProductShelfLife.period");
153        else if (Configuration.doAutoCreate())
154          this.period = new Quantity(); // cc
155      return this.period;
156    }
157
158    public boolean hasPeriod() { 
159      return this.period != null && !this.period.isEmpty();
160    }
161
162    /**
163     * @param value {@link #period} (The shelf life time period can be specified using a numerical value for the period of time and its unit of time measurement The unit of measurement shall be specified in accordance with ISO 11240 and the resulting terminology The symbol and the symbol identifier shall be used.)
164     */
165    public ProductShelfLife setPeriod(Quantity value) { 
166      this.period = value;
167      return this;
168    }
169
170    /**
171     * @return {@link #specialPrecautionsForStorage} (Special precautions for storage, if any, can be specified using an appropriate controlled vocabulary The controlled term and the controlled term identifier shall be specified.)
172     */
173    public List<CodeableConcept> getSpecialPrecautionsForStorage() { 
174      if (this.specialPrecautionsForStorage == null)
175        this.specialPrecautionsForStorage = new ArrayList<CodeableConcept>();
176      return this.specialPrecautionsForStorage;
177    }
178
179    /**
180     * @return Returns a reference to <code>this</code> for easy method chaining
181     */
182    public ProductShelfLife setSpecialPrecautionsForStorage(List<CodeableConcept> theSpecialPrecautionsForStorage) { 
183      this.specialPrecautionsForStorage = theSpecialPrecautionsForStorage;
184      return this;
185    }
186
187    public boolean hasSpecialPrecautionsForStorage() { 
188      if (this.specialPrecautionsForStorage == null)
189        return false;
190      for (CodeableConcept item : this.specialPrecautionsForStorage)
191        if (!item.isEmpty())
192          return true;
193      return false;
194    }
195
196    public CodeableConcept addSpecialPrecautionsForStorage() { //3
197      CodeableConcept t = new CodeableConcept();
198      if (this.specialPrecautionsForStorage == null)
199        this.specialPrecautionsForStorage = new ArrayList<CodeableConcept>();
200      this.specialPrecautionsForStorage.add(t);
201      return t;
202    }
203
204    public ProductShelfLife addSpecialPrecautionsForStorage(CodeableConcept t) { //3
205      if (t == null)
206        return this;
207      if (this.specialPrecautionsForStorage == null)
208        this.specialPrecautionsForStorage = new ArrayList<CodeableConcept>();
209      this.specialPrecautionsForStorage.add(t);
210      return this;
211    }
212
213    /**
214     * @return The first repetition of repeating field {@link #specialPrecautionsForStorage}, creating it if it does not already exist
215     */
216    public CodeableConcept getSpecialPrecautionsForStorageFirstRep() { 
217      if (getSpecialPrecautionsForStorage().isEmpty()) {
218        addSpecialPrecautionsForStorage();
219      }
220      return getSpecialPrecautionsForStorage().get(0);
221    }
222
223      protected void listChildren(List<Property> children) {
224        super.listChildren(children);
225        children.add(new Property("identifier", "Identifier", "Unique identifier for the packaged Medicinal Product.", 0, 1, identifier));
226        children.add(new Property("type", "CodeableConcept", "This describes the shelf life, taking into account various scenarios such as shelf life of the packaged Medicinal Product itself, shelf life after transformation where necessary and shelf life after the first opening of a bottle, etc. The shelf life type shall be specified using an appropriate controlled vocabulary The controlled term and the controlled term identifier shall be specified.", 0, 1, type));
227        children.add(new Property("period", "Quantity", "The shelf life time period can be specified using a numerical value for the period of time and its unit of time measurement The unit of measurement shall be specified in accordance with ISO 11240 and the resulting terminology The symbol and the symbol identifier shall be used.", 0, 1, period));
228        children.add(new Property("specialPrecautionsForStorage", "CodeableConcept", "Special precautions for storage, if any, can be specified using an appropriate controlled vocabulary The controlled term and the controlled term identifier shall be specified.", 0, java.lang.Integer.MAX_VALUE, specialPrecautionsForStorage));
229      }
230
231      @Override
232      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
233        switch (_hash) {
234        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Unique identifier for the packaged Medicinal Product.", 0, 1, identifier);
235        case 3575610: /*type*/  return new Property("type", "CodeableConcept", "This describes the shelf life, taking into account various scenarios such as shelf life of the packaged Medicinal Product itself, shelf life after transformation where necessary and shelf life after the first opening of a bottle, etc. The shelf life type shall be specified using an appropriate controlled vocabulary The controlled term and the controlled term identifier shall be specified.", 0, 1, type);
236        case -991726143: /*period*/  return new Property("period", "Quantity", "The shelf life time period can be specified using a numerical value for the period of time and its unit of time measurement The unit of measurement shall be specified in accordance with ISO 11240 and the resulting terminology The symbol and the symbol identifier shall be used.", 0, 1, period);
237        case 2103459492: /*specialPrecautionsForStorage*/  return new Property("specialPrecautionsForStorage", "CodeableConcept", "Special precautions for storage, if any, can be specified using an appropriate controlled vocabulary The controlled term and the controlled term identifier shall be specified.", 0, java.lang.Integer.MAX_VALUE, specialPrecautionsForStorage);
238        default: return super.getNamedProperty(_hash, _name, _checkValid);
239        }
240
241      }
242
243      @Override
244      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
245        switch (hash) {
246        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : new Base[] {this.identifier}; // Identifier
247        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
248        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Quantity
249        case 2103459492: /*specialPrecautionsForStorage*/ return this.specialPrecautionsForStorage == null ? new Base[0] : this.specialPrecautionsForStorage.toArray(new Base[this.specialPrecautionsForStorage.size()]); // CodeableConcept
250        default: return super.getProperty(hash, name, checkValid);
251        }
252
253      }
254
255      @Override
256      public Base setProperty(int hash, String name, Base value) throws FHIRException {
257        switch (hash) {
258        case -1618432855: // identifier
259          this.identifier = castToIdentifier(value); // Identifier
260          return value;
261        case 3575610: // type
262          this.type = castToCodeableConcept(value); // CodeableConcept
263          return value;
264        case -991726143: // period
265          this.period = castToQuantity(value); // Quantity
266          return value;
267        case 2103459492: // specialPrecautionsForStorage
268          this.getSpecialPrecautionsForStorage().add(castToCodeableConcept(value)); // CodeableConcept
269          return value;
270        default: return super.setProperty(hash, name, value);
271        }
272
273      }
274
275      @Override
276      public Base setProperty(String name, Base value) throws FHIRException {
277        if (name.equals("identifier")) {
278          this.identifier = castToIdentifier(value); // Identifier
279        } else if (name.equals("type")) {
280          this.type = castToCodeableConcept(value); // CodeableConcept
281        } else if (name.equals("period")) {
282          this.period = castToQuantity(value); // Quantity
283        } else if (name.equals("specialPrecautionsForStorage")) {
284          this.getSpecialPrecautionsForStorage().add(castToCodeableConcept(value));
285        } else
286          return super.setProperty(name, value);
287        return value;
288      }
289
290      @Override
291      public Base makeProperty(int hash, String name) throws FHIRException {
292        switch (hash) {
293        case -1618432855:  return getIdentifier(); 
294        case 3575610:  return getType(); 
295        case -991726143:  return getPeriod(); 
296        case 2103459492:  return addSpecialPrecautionsForStorage(); 
297        default: return super.makeProperty(hash, name);
298        }
299
300      }
301
302      @Override
303      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
304        switch (hash) {
305        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
306        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
307        case -991726143: /*period*/ return new String[] {"Quantity"};
308        case 2103459492: /*specialPrecautionsForStorage*/ return new String[] {"CodeableConcept"};
309        default: return super.getTypesForProperty(hash, name);
310        }
311
312      }
313
314      @Override
315      public Base addChild(String name) throws FHIRException {
316        if (name.equals("identifier")) {
317          this.identifier = new Identifier();
318          return this.identifier;
319        }
320        else if (name.equals("type")) {
321          this.type = new CodeableConcept();
322          return this.type;
323        }
324        else if (name.equals("period")) {
325          this.period = new Quantity();
326          return this.period;
327        }
328        else if (name.equals("specialPrecautionsForStorage")) {
329          return addSpecialPrecautionsForStorage();
330        }
331        else
332          return super.addChild(name);
333      }
334
335  public String fhirType() {
336    return "ProductShelfLife";
337
338  }
339
340      public ProductShelfLife copy() {
341        ProductShelfLife dst = new ProductShelfLife();
342        copyValues(dst);
343        return dst;
344      }
345
346      public void copyValues(ProductShelfLife dst) {
347        super.copyValues(dst);
348        dst.identifier = identifier == null ? null : identifier.copy();
349        dst.type = type == null ? null : type.copy();
350        dst.period = period == null ? null : period.copy();
351        if (specialPrecautionsForStorage != null) {
352          dst.specialPrecautionsForStorage = new ArrayList<CodeableConcept>();
353          for (CodeableConcept i : specialPrecautionsForStorage)
354            dst.specialPrecautionsForStorage.add(i.copy());
355        };
356      }
357
358      protected ProductShelfLife typedCopy() {
359        return copy();
360      }
361
362      @Override
363      public boolean equalsDeep(Base other_) {
364        if (!super.equalsDeep(other_))
365          return false;
366        if (!(other_ instanceof ProductShelfLife))
367          return false;
368        ProductShelfLife o = (ProductShelfLife) other_;
369        return compareDeep(identifier, o.identifier, true) && compareDeep(type, o.type, true) && compareDeep(period, o.period, true)
370           && compareDeep(specialPrecautionsForStorage, o.specialPrecautionsForStorage, true);
371      }
372
373      @Override
374      public boolean equalsShallow(Base other_) {
375        if (!super.equalsShallow(other_))
376          return false;
377        if (!(other_ instanceof ProductShelfLife))
378          return false;
379        ProductShelfLife o = (ProductShelfLife) other_;
380        return true;
381      }
382
383      public boolean isEmpty() {
384        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, type, period
385          , specialPrecautionsForStorage);
386      }
387
388
389}