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