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 org.hl7.fhir.utilities.Utilities; 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 * Chemical substances are a single substance type whose primary defining element is the molecular structure. Chemical substances shall be defined on the basis of their complete covalent molecular structure; the presence of a salt (counter-ion) and/or solvates (water, alcohols) is also captured. Purity, grade, physical form or particle size are not taken into account in the definition of a chemical substance or in the assignment of a Substance ID. 068 */ 069@DatatypeDef(name="SubstanceAmount") 070public class SubstanceAmount extends BackboneType implements ICompositeType { 071 072 @Block() 073 public static class SubstanceAmountReferenceRangeComponent extends Element implements IBaseDatatypeElement { 074 /** 075 * Lower limit possible or expected. 076 */ 077 @Child(name = "lowLimit", type = {Quantity.class}, order=1, min=0, max=1, modifier=false, summary=true) 078 @Description(shortDefinition="Lower limit possible or expected", formalDefinition="Lower limit possible or expected." ) 079 protected Quantity lowLimit; 080 081 /** 082 * Upper limit possible or expected. 083 */ 084 @Child(name = "highLimit", type = {Quantity.class}, order=2, min=0, max=1, modifier=false, summary=true) 085 @Description(shortDefinition="Upper limit possible or expected", formalDefinition="Upper limit possible or expected." ) 086 protected Quantity highLimit; 087 088 private static final long serialVersionUID = -193230412L; 089 090 /** 091 * Constructor 092 */ 093 public SubstanceAmountReferenceRangeComponent() { 094 super(); 095 } 096 097 /** 098 * @return {@link #lowLimit} (Lower limit possible or expected.) 099 */ 100 public Quantity getLowLimit() { 101 if (this.lowLimit == null) 102 if (Configuration.errorOnAutoCreate()) 103 throw new Error("Attempt to auto-create SubstanceAmountReferenceRangeComponent.lowLimit"); 104 else if (Configuration.doAutoCreate()) 105 this.lowLimit = new Quantity(); // cc 106 return this.lowLimit; 107 } 108 109 public boolean hasLowLimit() { 110 return this.lowLimit != null && !this.lowLimit.isEmpty(); 111 } 112 113 /** 114 * @param value {@link #lowLimit} (Lower limit possible or expected.) 115 */ 116 public SubstanceAmountReferenceRangeComponent setLowLimit(Quantity value) { 117 this.lowLimit = value; 118 return this; 119 } 120 121 /** 122 * @return {@link #highLimit} (Upper limit possible or expected.) 123 */ 124 public Quantity getHighLimit() { 125 if (this.highLimit == null) 126 if (Configuration.errorOnAutoCreate()) 127 throw new Error("Attempt to auto-create SubstanceAmountReferenceRangeComponent.highLimit"); 128 else if (Configuration.doAutoCreate()) 129 this.highLimit = new Quantity(); // cc 130 return this.highLimit; 131 } 132 133 public boolean hasHighLimit() { 134 return this.highLimit != null && !this.highLimit.isEmpty(); 135 } 136 137 /** 138 * @param value {@link #highLimit} (Upper limit possible or expected.) 139 */ 140 public SubstanceAmountReferenceRangeComponent setHighLimit(Quantity value) { 141 this.highLimit = value; 142 return this; 143 } 144 145 protected void listChildren(List<Property> children) { 146 super.listChildren(children); 147 children.add(new Property("lowLimit", "Quantity", "Lower limit possible or expected.", 0, 1, lowLimit)); 148 children.add(new Property("highLimit", "Quantity", "Upper limit possible or expected.", 0, 1, highLimit)); 149 } 150 151 @Override 152 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 153 switch (_hash) { 154 case -1841058617: /*lowLimit*/ return new Property("lowLimit", "Quantity", "Lower limit possible or expected.", 0, 1, lowLimit); 155 case -710757575: /*highLimit*/ return new Property("highLimit", "Quantity", "Upper limit possible or expected.", 0, 1, highLimit); 156 default: return super.getNamedProperty(_hash, _name, _checkValid); 157 } 158 159 } 160 161 @Override 162 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 163 switch (hash) { 164 case -1841058617: /*lowLimit*/ return this.lowLimit == null ? new Base[0] : new Base[] {this.lowLimit}; // Quantity 165 case -710757575: /*highLimit*/ return this.highLimit == null ? new Base[0] : new Base[] {this.highLimit}; // Quantity 166 default: return super.getProperty(hash, name, checkValid); 167 } 168 169 } 170 171 @Override 172 public Base setProperty(int hash, String name, Base value) throws FHIRException { 173 switch (hash) { 174 case -1841058617: // lowLimit 175 this.lowLimit = castToQuantity(value); // Quantity 176 return value; 177 case -710757575: // highLimit 178 this.highLimit = castToQuantity(value); // Quantity 179 return value; 180 default: return super.setProperty(hash, name, value); 181 } 182 183 } 184 185 @Override 186 public Base setProperty(String name, Base value) throws FHIRException { 187 if (name.equals("lowLimit")) { 188 this.lowLimit = castToQuantity(value); // Quantity 189 } else if (name.equals("highLimit")) { 190 this.highLimit = castToQuantity(value); // Quantity 191 } else 192 return super.setProperty(name, value); 193 return value; 194 } 195 196 @Override 197 public Base makeProperty(int hash, String name) throws FHIRException { 198 switch (hash) { 199 case -1841058617: return getLowLimit(); 200 case -710757575: return getHighLimit(); 201 default: return super.makeProperty(hash, name); 202 } 203 204 } 205 206 @Override 207 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 208 switch (hash) { 209 case -1841058617: /*lowLimit*/ return new String[] {"Quantity"}; 210 case -710757575: /*highLimit*/ return new String[] {"Quantity"}; 211 default: return super.getTypesForProperty(hash, name); 212 } 213 214 } 215 216 @Override 217 public Base addChild(String name) throws FHIRException { 218 if (name.equals("lowLimit")) { 219 this.lowLimit = new Quantity(); 220 return this.lowLimit; 221 } 222 else if (name.equals("highLimit")) { 223 this.highLimit = new Quantity(); 224 return this.highLimit; 225 } 226 else 227 return super.addChild(name); 228 } 229 230 public SubstanceAmountReferenceRangeComponent copy() { 231 SubstanceAmountReferenceRangeComponent dst = new SubstanceAmountReferenceRangeComponent(); 232 copyValues(dst); 233 return dst; 234 } 235 236 public void copyValues(SubstanceAmountReferenceRangeComponent dst) { 237 super.copyValues(dst); 238 dst.lowLimit = lowLimit == null ? null : lowLimit.copy(); 239 dst.highLimit = highLimit == null ? null : highLimit.copy(); 240 } 241 242 @Override 243 public boolean equalsDeep(Base other_) { 244 if (!super.equalsDeep(other_)) 245 return false; 246 if (!(other_ instanceof SubstanceAmountReferenceRangeComponent)) 247 return false; 248 SubstanceAmountReferenceRangeComponent o = (SubstanceAmountReferenceRangeComponent) other_; 249 return compareDeep(lowLimit, o.lowLimit, true) && compareDeep(highLimit, o.highLimit, true); 250 } 251 252 @Override 253 public boolean equalsShallow(Base other_) { 254 if (!super.equalsShallow(other_)) 255 return false; 256 if (!(other_ instanceof SubstanceAmountReferenceRangeComponent)) 257 return false; 258 SubstanceAmountReferenceRangeComponent o = (SubstanceAmountReferenceRangeComponent) other_; 259 return true; 260 } 261 262 public boolean isEmpty() { 263 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(lowLimit, highLimit); 264 } 265 266 public String fhirType() { 267 return "SubstanceAmount.referenceRange"; 268 269 } 270 271 } 272 273 /** 274 * Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field. 275 */ 276 @Child(name = "amount", type = {Quantity.class, Range.class, StringType.class}, order=0, min=0, max=1, modifier=false, summary=true) 277 @Description(shortDefinition="Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field", formalDefinition="Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field." ) 278 protected Type amount; 279 280 /** 281 * Most elements that require a quantitative value will also have a field called amount type. Amount type should always be specified because the actual value of the amount is often dependent on it. EXAMPLE: In capturing the actual relative amounts of substances or molecular fragments it is essential to indicate whether the amount refers to a mole ratio or weight ratio. For any given element an effort should be made to use same the amount type for all related definitional elements. 282 */ 283 @Child(name = "amountType", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true) 284 @Description(shortDefinition="Most elements that require a quantitative value will also have a field called amount type. Amount type should always be specified because the actual value of the amount is often dependent on it. EXAMPLE: In capturing the actual relative amounts of substances or molecular fragments it is essential to indicate whether the amount refers to a mole ratio or weight ratio. For any given element an effort should be made to use same the amount type for all related definitional elements", formalDefinition="Most elements that require a quantitative value will also have a field called amount type. Amount type should always be specified because the actual value of the amount is often dependent on it. EXAMPLE: In capturing the actual relative amounts of substances or molecular fragments it is essential to indicate whether the amount refers to a mole ratio or weight ratio. For any given element an effort should be made to use same the amount type for all related definitional elements." ) 285 protected CodeableConcept amountType; 286 287 /** 288 * A textual comment on a numeric value. 289 */ 290 @Child(name = "amountText", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=true) 291 @Description(shortDefinition="A textual comment on a numeric value", formalDefinition="A textual comment on a numeric value." ) 292 protected StringType amountText; 293 294 /** 295 * Reference range of possible or expected values. 296 */ 297 @Child(name = "referenceRange", type = {}, order=3, min=0, max=1, modifier=false, summary=true) 298 @Description(shortDefinition="Reference range of possible or expected values", formalDefinition="Reference range of possible or expected values." ) 299 protected SubstanceAmountReferenceRangeComponent referenceRange; 300 301 private static final long serialVersionUID = -174997548L; 302 303 /** 304 * Constructor 305 */ 306 public SubstanceAmount() { 307 super(); 308 } 309 310 /** 311 * @return {@link #amount} (Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.) 312 */ 313 public Type getAmount() { 314 return this.amount; 315 } 316 317 /** 318 * @return {@link #amount} (Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.) 319 */ 320 public Quantity getAmountQuantity() throws FHIRException { 321 if (this.amount == null) 322 this.amount = new Quantity(); 323 if (!(this.amount instanceof Quantity)) 324 throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.amount.getClass().getName()+" was encountered"); 325 return (Quantity) this.amount; 326 } 327 328 public boolean hasAmountQuantity() { 329 return this != null && this.amount instanceof Quantity; 330 } 331 332 /** 333 * @return {@link #amount} (Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.) 334 */ 335 public Range getAmountRange() throws FHIRException { 336 if (this.amount == null) 337 this.amount = new Range(); 338 if (!(this.amount instanceof Range)) 339 throw new FHIRException("Type mismatch: the type Range was expected, but "+this.amount.getClass().getName()+" was encountered"); 340 return (Range) this.amount; 341 } 342 343 public boolean hasAmountRange() { 344 return this != null && this.amount instanceof Range; 345 } 346 347 /** 348 * @return {@link #amount} (Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.) 349 */ 350 public StringType getAmountStringType() throws FHIRException { 351 if (this.amount == null) 352 this.amount = new StringType(); 353 if (!(this.amount instanceof StringType)) 354 throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.amount.getClass().getName()+" was encountered"); 355 return (StringType) this.amount; 356 } 357 358 public boolean hasAmountStringType() { 359 return this != null && this.amount instanceof StringType; 360 } 361 362 public boolean hasAmount() { 363 return this.amount != null && !this.amount.isEmpty(); 364 } 365 366 /** 367 * @param value {@link #amount} (Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.) 368 */ 369 public SubstanceAmount setAmount(Type value) { 370 if (value != null && !(value instanceof Quantity || value instanceof Range || value instanceof StringType)) 371 throw new Error("Not the right type for SubstanceAmount.amount[x]: "+value.fhirType()); 372 this.amount = value; 373 return this; 374 } 375 376 /** 377 * @return {@link #amountType} (Most elements that require a quantitative value will also have a field called amount type. Amount type should always be specified because the actual value of the amount is often dependent on it. EXAMPLE: In capturing the actual relative amounts of substances or molecular fragments it is essential to indicate whether the amount refers to a mole ratio or weight ratio. For any given element an effort should be made to use same the amount type for all related definitional elements.) 378 */ 379 public CodeableConcept getAmountType() { 380 if (this.amountType == null) 381 if (Configuration.errorOnAutoCreate()) 382 throw new Error("Attempt to auto-create SubstanceAmount.amountType"); 383 else if (Configuration.doAutoCreate()) 384 this.amountType = new CodeableConcept(); // cc 385 return this.amountType; 386 } 387 388 public boolean hasAmountType() { 389 return this.amountType != null && !this.amountType.isEmpty(); 390 } 391 392 /** 393 * @param value {@link #amountType} (Most elements that require a quantitative value will also have a field called amount type. Amount type should always be specified because the actual value of the amount is often dependent on it. EXAMPLE: In capturing the actual relative amounts of substances or molecular fragments it is essential to indicate whether the amount refers to a mole ratio or weight ratio. For any given element an effort should be made to use same the amount type for all related definitional elements.) 394 */ 395 public SubstanceAmount setAmountType(CodeableConcept value) { 396 this.amountType = value; 397 return this; 398 } 399 400 /** 401 * @return {@link #amountText} (A textual comment on a numeric value.). This is the underlying object with id, value and extensions. The accessor "getAmountText" gives direct access to the value 402 */ 403 public StringType getAmountTextElement() { 404 if (this.amountText == null) 405 if (Configuration.errorOnAutoCreate()) 406 throw new Error("Attempt to auto-create SubstanceAmount.amountText"); 407 else if (Configuration.doAutoCreate()) 408 this.amountText = new StringType(); // bb 409 return this.amountText; 410 } 411 412 public boolean hasAmountTextElement() { 413 return this.amountText != null && !this.amountText.isEmpty(); 414 } 415 416 public boolean hasAmountText() { 417 return this.amountText != null && !this.amountText.isEmpty(); 418 } 419 420 /** 421 * @param value {@link #amountText} (A textual comment on a numeric value.). This is the underlying object with id, value and extensions. The accessor "getAmountText" gives direct access to the value 422 */ 423 public SubstanceAmount setAmountTextElement(StringType value) { 424 this.amountText = value; 425 return this; 426 } 427 428 /** 429 * @return A textual comment on a numeric value. 430 */ 431 public String getAmountText() { 432 return this.amountText == null ? null : this.amountText.getValue(); 433 } 434 435 /** 436 * @param value A textual comment on a numeric value. 437 */ 438 public SubstanceAmount setAmountText(String value) { 439 if (Utilities.noString(value)) 440 this.amountText = null; 441 else { 442 if (this.amountText == null) 443 this.amountText = new StringType(); 444 this.amountText.setValue(value); 445 } 446 return this; 447 } 448 449 /** 450 * @return {@link #referenceRange} (Reference range of possible or expected values.) 451 */ 452 public SubstanceAmountReferenceRangeComponent getReferenceRange() { 453 if (this.referenceRange == null) 454 if (Configuration.errorOnAutoCreate()) 455 throw new Error("Attempt to auto-create SubstanceAmount.referenceRange"); 456 else if (Configuration.doAutoCreate()) 457 this.referenceRange = new SubstanceAmountReferenceRangeComponent(); // cc 458 return this.referenceRange; 459 } 460 461 public boolean hasReferenceRange() { 462 return this.referenceRange != null && !this.referenceRange.isEmpty(); 463 } 464 465 /** 466 * @param value {@link #referenceRange} (Reference range of possible or expected values.) 467 */ 468 public SubstanceAmount setReferenceRange(SubstanceAmountReferenceRangeComponent value) { 469 this.referenceRange = value; 470 return this; 471 } 472 473 protected void listChildren(List<Property> children) { 474 super.listChildren(children); 475 children.add(new Property("amount[x]", "Quantity|Range|string", "Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.", 0, 1, amount)); 476 children.add(new Property("amountType", "CodeableConcept", "Most elements that require a quantitative value will also have a field called amount type. Amount type should always be specified because the actual value of the amount is often dependent on it. EXAMPLE: In capturing the actual relative amounts of substances or molecular fragments it is essential to indicate whether the amount refers to a mole ratio or weight ratio. For any given element an effort should be made to use same the amount type for all related definitional elements.", 0, 1, amountType)); 477 children.add(new Property("amountText", "string", "A textual comment on a numeric value.", 0, 1, amountText)); 478 children.add(new Property("referenceRange", "", "Reference range of possible or expected values.", 0, 1, referenceRange)); 479 } 480 481 @Override 482 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 483 switch (_hash) { 484 case 646780200: /*amount[x]*/ return new Property("amount[x]", "Quantity|Range|string", "Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.", 0, 1, amount); 485 case -1413853096: /*amount*/ return new Property("amount[x]", "Quantity|Range|string", "Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.", 0, 1, amount); 486 case 1664303363: /*amountQuantity*/ return new Property("amount[x]", "Quantity|Range|string", "Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.", 0, 1, amount); 487 case -1223462971: /*amountRange*/ return new Property("amount[x]", "Quantity|Range|string", "Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.", 0, 1, amount); 488 case 773651081: /*amountString*/ return new Property("amount[x]", "Quantity|Range|string", "Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.", 0, 1, amount); 489 case -1424857166: /*amountType*/ return new Property("amountType", "CodeableConcept", "Most elements that require a quantitative value will also have a field called amount type. Amount type should always be specified because the actual value of the amount is often dependent on it. EXAMPLE: In capturing the actual relative amounts of substances or molecular fragments it is essential to indicate whether the amount refers to a mole ratio or weight ratio. For any given element an effort should be made to use same the amount type for all related definitional elements.", 0, 1, amountType); 490 case -1424876123: /*amountText*/ return new Property("amountText", "string", "A textual comment on a numeric value.", 0, 1, amountText); 491 case -1912545102: /*referenceRange*/ return new Property("referenceRange", "", "Reference range of possible or expected values.", 0, 1, referenceRange); 492 default: return super.getNamedProperty(_hash, _name, _checkValid); 493 } 494 495 } 496 497 @Override 498 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 499 switch (hash) { 500 case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : new Base[] {this.amount}; // Type 501 case -1424857166: /*amountType*/ return this.amountType == null ? new Base[0] : new Base[] {this.amountType}; // CodeableConcept 502 case -1424876123: /*amountText*/ return this.amountText == null ? new Base[0] : new Base[] {this.amountText}; // StringType 503 case -1912545102: /*referenceRange*/ return this.referenceRange == null ? new Base[0] : new Base[] {this.referenceRange}; // SubstanceAmountReferenceRangeComponent 504 default: return super.getProperty(hash, name, checkValid); 505 } 506 507 } 508 509 @Override 510 public Base setProperty(int hash, String name, Base value) throws FHIRException { 511 switch (hash) { 512 case -1413853096: // amount 513 this.amount = castToType(value); // Type 514 return value; 515 case -1424857166: // amountType 516 this.amountType = castToCodeableConcept(value); // CodeableConcept 517 return value; 518 case -1424876123: // amountText 519 this.amountText = castToString(value); // StringType 520 return value; 521 case -1912545102: // referenceRange 522 this.referenceRange = (SubstanceAmountReferenceRangeComponent) value; // SubstanceAmountReferenceRangeComponent 523 return value; 524 default: return super.setProperty(hash, name, value); 525 } 526 527 } 528 529 @Override 530 public Base setProperty(String name, Base value) throws FHIRException { 531 if (name.equals("amount[x]")) { 532 this.amount = castToType(value); // Type 533 } else if (name.equals("amountType")) { 534 this.amountType = castToCodeableConcept(value); // CodeableConcept 535 } else if (name.equals("amountText")) { 536 this.amountText = castToString(value); // StringType 537 } else if (name.equals("referenceRange")) { 538 this.referenceRange = (SubstanceAmountReferenceRangeComponent) value; // SubstanceAmountReferenceRangeComponent 539 } else 540 return super.setProperty(name, value); 541 return value; 542 } 543 544 @Override 545 public Base makeProperty(int hash, String name) throws FHIRException { 546 switch (hash) { 547 case 646780200: return getAmount(); 548 case -1413853096: return getAmount(); 549 case -1424857166: return getAmountType(); 550 case -1424876123: return getAmountTextElement(); 551 case -1912545102: return getReferenceRange(); 552 default: return super.makeProperty(hash, name); 553 } 554 555 } 556 557 @Override 558 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 559 switch (hash) { 560 case -1413853096: /*amount*/ return new String[] {"Quantity", "Range", "string"}; 561 case -1424857166: /*amountType*/ return new String[] {"CodeableConcept"}; 562 case -1424876123: /*amountText*/ return new String[] {"string"}; 563 case -1912545102: /*referenceRange*/ return new String[] {}; 564 default: return super.getTypesForProperty(hash, name); 565 } 566 567 } 568 569 @Override 570 public Base addChild(String name) throws FHIRException { 571 if (name.equals("amountQuantity")) { 572 this.amount = new Quantity(); 573 return this.amount; 574 } 575 else if (name.equals("amountRange")) { 576 this.amount = new Range(); 577 return this.amount; 578 } 579 else if (name.equals("amountString")) { 580 this.amount = new StringType(); 581 return this.amount; 582 } 583 else if (name.equals("amountType")) { 584 this.amountType = new CodeableConcept(); 585 return this.amountType; 586 } 587 else if (name.equals("amountText")) { 588 throw new FHIRException("Cannot call addChild on a primitive type SubstanceAmount.amountText"); 589 } 590 else if (name.equals("referenceRange")) { 591 this.referenceRange = new SubstanceAmountReferenceRangeComponent(); 592 return this.referenceRange; 593 } 594 else 595 return super.addChild(name); 596 } 597 598 public String fhirType() { 599 return "SubstanceAmount"; 600 601 } 602 603 public SubstanceAmount copy() { 604 SubstanceAmount dst = new SubstanceAmount(); 605 copyValues(dst); 606 return dst; 607 } 608 609 public void copyValues(SubstanceAmount dst) { 610 super.copyValues(dst); 611 dst.amount = amount == null ? null : amount.copy(); 612 dst.amountType = amountType == null ? null : amountType.copy(); 613 dst.amountText = amountText == null ? null : amountText.copy(); 614 dst.referenceRange = referenceRange == null ? null : referenceRange.copy(); 615 } 616 617 protected SubstanceAmount typedCopy() { 618 return copy(); 619 } 620 621 @Override 622 public boolean equalsDeep(Base other_) { 623 if (!super.equalsDeep(other_)) 624 return false; 625 if (!(other_ instanceof SubstanceAmount)) 626 return false; 627 SubstanceAmount o = (SubstanceAmount) other_; 628 return compareDeep(amount, o.amount, true) && compareDeep(amountType, o.amountType, true) && compareDeep(amountText, o.amountText, true) 629 && compareDeep(referenceRange, o.referenceRange, true); 630 } 631 632 @Override 633 public boolean equalsShallow(Base other_) { 634 if (!super.equalsShallow(other_)) 635 return false; 636 if (!(other_ instanceof SubstanceAmount)) 637 return false; 638 SubstanceAmount o = (SubstanceAmount) other_; 639 return compareValues(amountText, o.amountText, true); 640 } 641 642 public boolean isEmpty() { 643 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(amount, amountType, amountText 644 , referenceRange); 645 } 646 647 648} 649