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