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 Sun, May 6, 2018 17:51-0400 for FHIR v3.4.0 033 034import java.util.*; 035 036import ca.uhn.fhir.model.api.annotation.Child; 037import ca.uhn.fhir.model.api.annotation.ChildOrder; 038import ca.uhn.fhir.model.api.annotation.Description; 039import ca.uhn.fhir.model.api.annotation.DatatypeDef; 040import ca.uhn.fhir.model.api.annotation.Block; 041import org.hl7.fhir.instance.model.api.*; 042import org.hl7.fhir.exceptions.FHIRException; 043/** 044 * The shelf-life and storage information for a medicinal product item or container can be described using this class. 045 */ 046@DatatypeDef(name="ProductShelfLife") 047public class ProductShelfLife extends BackboneElement implements ICompositeType { 048 049 /** 050 * Unique identifier for the packaged Medicinal Product. 051 */ 052 @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=1, modifier=false, summary=true) 053 @Description(shortDefinition="Unique identifier for the packaged Medicinal Product", formalDefinition="Unique identifier for the packaged Medicinal Product." ) 054 protected Identifier identifier; 055 056 /** 057 * 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. 058 */ 059 @Child(name = "type", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=true) 060 @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." ) 061 protected CodeableConcept type; 062 063 /** 064 * 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. 065 */ 066 @Child(name = "period", type = {Quantity.class}, order=2, min=1, max=1, modifier=false, summary=true) 067 @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." ) 068 protected Quantity period; 069 070 /** 071 * 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. 072 */ 073 @Child(name = "specialPrecautionsForStorage", type = {CodeableConcept.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 074 @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." ) 075 protected List<CodeableConcept> specialPrecautionsForStorage; 076 077 private static final long serialVersionUID = -1561196410L; 078 079 /** 080 * Constructor 081 */ 082 public ProductShelfLife() { 083 super(); 084 } 085 086 /** 087 * Constructor 088 */ 089 public ProductShelfLife(CodeableConcept type, Quantity period) { 090 super(); 091 this.type = type; 092 this.period = period; 093 } 094 095 /** 096 * @return {@link #identifier} (Unique identifier for the packaged Medicinal Product.) 097 */ 098 public Identifier getIdentifier() { 099 if (this.identifier == null) 100 if (Configuration.errorOnAutoCreate()) 101 throw new Error("Attempt to auto-create ProductShelfLife.identifier"); 102 else if (Configuration.doAutoCreate()) 103 this.identifier = new Identifier(); // cc 104 return this.identifier; 105 } 106 107 public boolean hasIdentifier() { 108 return this.identifier != null && !this.identifier.isEmpty(); 109 } 110 111 /** 112 * @param value {@link #identifier} (Unique identifier for the packaged Medicinal Product.) 113 */ 114 public ProductShelfLife setIdentifier(Identifier value) { 115 this.identifier = value; 116 return this; 117 } 118 119 /** 120 * @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.) 121 */ 122 public CodeableConcept getType() { 123 if (this.type == null) 124 if (Configuration.errorOnAutoCreate()) 125 throw new Error("Attempt to auto-create ProductShelfLife.type"); 126 else if (Configuration.doAutoCreate()) 127 this.type = new CodeableConcept(); // cc 128 return this.type; 129 } 130 131 public boolean hasType() { 132 return this.type != null && !this.type.isEmpty(); 133 } 134 135 /** 136 * @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.) 137 */ 138 public ProductShelfLife setType(CodeableConcept value) { 139 this.type = value; 140 return this; 141 } 142 143 /** 144 * @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.) 145 */ 146 public Quantity getPeriod() { 147 if (this.period == null) 148 if (Configuration.errorOnAutoCreate()) 149 throw new Error("Attempt to auto-create ProductShelfLife.period"); 150 else if (Configuration.doAutoCreate()) 151 this.period = new Quantity(); // cc 152 return this.period; 153 } 154 155 public boolean hasPeriod() { 156 return this.period != null && !this.period.isEmpty(); 157 } 158 159 /** 160 * @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.) 161 */ 162 public ProductShelfLife setPeriod(Quantity value) { 163 this.period = value; 164 return this; 165 } 166 167 /** 168 * @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.) 169 */ 170 public List<CodeableConcept> getSpecialPrecautionsForStorage() { 171 if (this.specialPrecautionsForStorage == null) 172 this.specialPrecautionsForStorage = new ArrayList<CodeableConcept>(); 173 return this.specialPrecautionsForStorage; 174 } 175 176 /** 177 * @return Returns a reference to <code>this</code> for easy method chaining 178 */ 179 public ProductShelfLife setSpecialPrecautionsForStorage(List<CodeableConcept> theSpecialPrecautionsForStorage) { 180 this.specialPrecautionsForStorage = theSpecialPrecautionsForStorage; 181 return this; 182 } 183 184 public boolean hasSpecialPrecautionsForStorage() { 185 if (this.specialPrecautionsForStorage == null) 186 return false; 187 for (CodeableConcept item : this.specialPrecautionsForStorage) 188 if (!item.isEmpty()) 189 return true; 190 return false; 191 } 192 193 public CodeableConcept addSpecialPrecautionsForStorage() { //3 194 CodeableConcept t = new CodeableConcept(); 195 if (this.specialPrecautionsForStorage == null) 196 this.specialPrecautionsForStorage = new ArrayList<CodeableConcept>(); 197 this.specialPrecautionsForStorage.add(t); 198 return t; 199 } 200 201 public ProductShelfLife addSpecialPrecautionsForStorage(CodeableConcept t) { //3 202 if (t == null) 203 return this; 204 if (this.specialPrecautionsForStorage == null) 205 this.specialPrecautionsForStorage = new ArrayList<CodeableConcept>(); 206 this.specialPrecautionsForStorage.add(t); 207 return this; 208 } 209 210 /** 211 * @return The first repetition of repeating field {@link #specialPrecautionsForStorage}, creating it if it does not already exist 212 */ 213 public CodeableConcept getSpecialPrecautionsForStorageFirstRep() { 214 if (getSpecialPrecautionsForStorage().isEmpty()) { 215 addSpecialPrecautionsForStorage(); 216 } 217 return getSpecialPrecautionsForStorage().get(0); 218 } 219 220 protected void listChildren(List<Property> children) { 221 super.listChildren(children); 222 children.add(new Property("identifier", "Identifier", "Unique identifier for the packaged Medicinal Product.", 0, 1, identifier)); 223 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)); 224 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)); 225 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)); 226 } 227 228 @Override 229 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 230 switch (_hash) { 231 case -1618432855: /*identifier*/ return new Property("identifier", "Identifier", "Unique identifier for the packaged Medicinal Product.", 0, 1, identifier); 232 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); 233 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); 234 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); 235 default: return super.getNamedProperty(_hash, _name, _checkValid); 236 } 237 238 } 239 240 @Override 241 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 242 switch (hash) { 243 case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : new Base[] {this.identifier}; // Identifier 244 case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept 245 case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Quantity 246 case 2103459492: /*specialPrecautionsForStorage*/ return this.specialPrecautionsForStorage == null ? new Base[0] : this.specialPrecautionsForStorage.toArray(new Base[this.specialPrecautionsForStorage.size()]); // CodeableConcept 247 default: return super.getProperty(hash, name, checkValid); 248 } 249 250 } 251 252 @Override 253 public Base setProperty(int hash, String name, Base value) throws FHIRException { 254 switch (hash) { 255 case -1618432855: // identifier 256 this.identifier = castToIdentifier(value); // Identifier 257 return value; 258 case 3575610: // type 259 this.type = castToCodeableConcept(value); // CodeableConcept 260 return value; 261 case -991726143: // period 262 this.period = castToQuantity(value); // Quantity 263 return value; 264 case 2103459492: // specialPrecautionsForStorage 265 this.getSpecialPrecautionsForStorage().add(castToCodeableConcept(value)); // CodeableConcept 266 return value; 267 default: return super.setProperty(hash, name, value); 268 } 269 270 } 271 272 @Override 273 public Base setProperty(String name, Base value) throws FHIRException { 274 if (name.equals("identifier")) { 275 this.identifier = castToIdentifier(value); // Identifier 276 } else if (name.equals("type")) { 277 this.type = castToCodeableConcept(value); // CodeableConcept 278 } else if (name.equals("period")) { 279 this.period = castToQuantity(value); // Quantity 280 } else if (name.equals("specialPrecautionsForStorage")) { 281 this.getSpecialPrecautionsForStorage().add(castToCodeableConcept(value)); 282 } else 283 return super.setProperty(name, value); 284 return value; 285 } 286 287 @Override 288 public Base makeProperty(int hash, String name) throws FHIRException { 289 switch (hash) { 290 case -1618432855: return getIdentifier(); 291 case 3575610: return getType(); 292 case -991726143: return getPeriod(); 293 case 2103459492: return addSpecialPrecautionsForStorage(); 294 default: return super.makeProperty(hash, name); 295 } 296 297 } 298 299 @Override 300 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 301 switch (hash) { 302 case -1618432855: /*identifier*/ return new String[] {"Identifier"}; 303 case 3575610: /*type*/ return new String[] {"CodeableConcept"}; 304 case -991726143: /*period*/ return new String[] {"Quantity"}; 305 case 2103459492: /*specialPrecautionsForStorage*/ return new String[] {"CodeableConcept"}; 306 default: return super.getTypesForProperty(hash, name); 307 } 308 309 } 310 311 @Override 312 public Base addChild(String name) throws FHIRException { 313 if (name.equals("identifier")) { 314 this.identifier = new Identifier(); 315 return this.identifier; 316 } 317 else if (name.equals("type")) { 318 this.type = new CodeableConcept(); 319 return this.type; 320 } 321 else if (name.equals("period")) { 322 this.period = new Quantity(); 323 return this.period; 324 } 325 else if (name.equals("specialPrecautionsForStorage")) { 326 return addSpecialPrecautionsForStorage(); 327 } 328 else 329 return super.addChild(name); 330 } 331 332 public String fhirType() { 333 return "ProductShelfLife"; 334 335 } 336 337 public ProductShelfLife copy() { 338 ProductShelfLife dst = new ProductShelfLife(); 339 copyValues(dst); 340 dst.identifier = identifier == null ? null : identifier.copy(); 341 dst.type = type == null ? null : type.copy(); 342 dst.period = period == null ? null : period.copy(); 343 if (specialPrecautionsForStorage != null) { 344 dst.specialPrecautionsForStorage = new ArrayList<CodeableConcept>(); 345 for (CodeableConcept i : specialPrecautionsForStorage) 346 dst.specialPrecautionsForStorage.add(i.copy()); 347 }; 348 return dst; 349 } 350 351 protected ProductShelfLife typedCopy() { 352 return copy(); 353 } 354 355 @Override 356 public boolean equalsDeep(Base other_) { 357 if (!super.equalsDeep(other_)) 358 return false; 359 if (!(other_ instanceof ProductShelfLife)) 360 return false; 361 ProductShelfLife o = (ProductShelfLife) other_; 362 return compareDeep(identifier, o.identifier, true) && compareDeep(type, o.type, true) && compareDeep(period, o.period, true) 363 && compareDeep(specialPrecautionsForStorage, o.specialPrecautionsForStorage, true); 364 } 365 366 @Override 367 public boolean equalsShallow(Base other_) { 368 if (!super.equalsShallow(other_)) 369 return false; 370 if (!(other_ instanceof ProductShelfLife)) 371 return false; 372 ProductShelfLife o = (ProductShelfLife) other_; 373 return true; 374 } 375 376 public boolean isEmpty() { 377 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, type, period 378 , specialPrecautionsForStorage); 379 } 380 381 382} 383