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