001package org.hl7.fhir.r4.model; 002 003 004 005/* 006 Copyright (c) 2011+, HL7, Inc. 007 All rights reserved. 008 009 Redistribution and use in source and binary forms, with or without modification, 010 are permitted provided that the following conditions are met: 011 012 * Redistributions of source code must retain the above copyright notice, this 013 list of conditions and the following disclaimer. 014 * Redistributions in binary form must reproduce the above copyright notice, 015 this list of conditions and the following disclaimer in the documentation 016 and/or other materials provided with the distribution. 017 * Neither the name of HL7 nor the names of its contributors may be used to 018 endorse or promote products derived from this software without specific 019 prior written permission. 020 021 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 022 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 023 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 024 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 025 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 026 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 027 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 028 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 029 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 030 POSSIBILITY OF SUCH DAMAGE. 031 032*/ 033 034 035// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1 036 037import java.util.*; 038 039import org.hl7.fhir.utilities.Utilities; 040import ca.uhn.fhir.model.api.annotation.Child; 041import ca.uhn.fhir.model.api.annotation.ChildOrder; 042import ca.uhn.fhir.model.api.annotation.Description; 043import ca.uhn.fhir.model.api.annotation.DatatypeDef; 044import ca.uhn.fhir.model.api.annotation.Block; 045import org.hl7.fhir.instance.model.api.*; 046import org.hl7.fhir.exceptions.FHIRException; 047/** 048 * 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. 049 */ 050@DatatypeDef(name="SubstanceAmount") 051public class SubstanceAmount extends BackboneType implements ICompositeType { 052 053 @Block() 054 public static class SubstanceAmountReferenceRangeComponent extends Element implements IBaseDatatypeElement { 055 /** 056 * Lower limit possible or expected. 057 */ 058 @Child(name = "lowLimit", type = {Quantity.class}, order=1, min=0, max=1, modifier=false, summary=true) 059 @Description(shortDefinition="Lower limit possible or expected", formalDefinition="Lower limit possible or expected." ) 060 protected Quantity lowLimit; 061 062 /** 063 * Upper limit possible or expected. 064 */ 065 @Child(name = "highLimit", type = {Quantity.class}, order=2, min=0, max=1, modifier=false, summary=true) 066 @Description(shortDefinition="Upper limit possible or expected", formalDefinition="Upper limit possible or expected." ) 067 protected Quantity highLimit; 068 069 private static final long serialVersionUID = -193230412L; 070 071 /** 072 * Constructor 073 */ 074 public SubstanceAmountReferenceRangeComponent() { 075 super(); 076 } 077 078 /** 079 * @return {@link #lowLimit} (Lower limit possible or expected.) 080 */ 081 public Quantity getLowLimit() { 082 if (this.lowLimit == null) 083 if (Configuration.errorOnAutoCreate()) 084 throw new Error("Attempt to auto-create SubstanceAmountReferenceRangeComponent.lowLimit"); 085 else if (Configuration.doAutoCreate()) 086 this.lowLimit = new Quantity(); // cc 087 return this.lowLimit; 088 } 089 090 public boolean hasLowLimit() { 091 return this.lowLimit != null && !this.lowLimit.isEmpty(); 092 } 093 094 /** 095 * @param value {@link #lowLimit} (Lower limit possible or expected.) 096 */ 097 public SubstanceAmountReferenceRangeComponent setLowLimit(Quantity value) { 098 this.lowLimit = value; 099 return this; 100 } 101 102 /** 103 * @return {@link #highLimit} (Upper limit possible or expected.) 104 */ 105 public Quantity getHighLimit() { 106 if (this.highLimit == null) 107 if (Configuration.errorOnAutoCreate()) 108 throw new Error("Attempt to auto-create SubstanceAmountReferenceRangeComponent.highLimit"); 109 else if (Configuration.doAutoCreate()) 110 this.highLimit = new Quantity(); // cc 111 return this.highLimit; 112 } 113 114 public boolean hasHighLimit() { 115 return this.highLimit != null && !this.highLimit.isEmpty(); 116 } 117 118 /** 119 * @param value {@link #highLimit} (Upper limit possible or expected.) 120 */ 121 public SubstanceAmountReferenceRangeComponent setHighLimit(Quantity value) { 122 this.highLimit = value; 123 return this; 124 } 125 126 protected void listChildren(List<Property> children) { 127 super.listChildren(children); 128 children.add(new Property("lowLimit", "Quantity", "Lower limit possible or expected.", 0, 1, lowLimit)); 129 children.add(new Property("highLimit", "Quantity", "Upper limit possible or expected.", 0, 1, highLimit)); 130 } 131 132 @Override 133 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 134 switch (_hash) { 135 case -1841058617: /*lowLimit*/ return new Property("lowLimit", "Quantity", "Lower limit possible or expected.", 0, 1, lowLimit); 136 case -710757575: /*highLimit*/ return new Property("highLimit", "Quantity", "Upper limit possible or expected.", 0, 1, highLimit); 137 default: return super.getNamedProperty(_hash, _name, _checkValid); 138 } 139 140 } 141 142 @Override 143 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 144 switch (hash) { 145 case -1841058617: /*lowLimit*/ return this.lowLimit == null ? new Base[0] : new Base[] {this.lowLimit}; // Quantity 146 case -710757575: /*highLimit*/ return this.highLimit == null ? new Base[0] : new Base[] {this.highLimit}; // Quantity 147 default: return super.getProperty(hash, name, checkValid); 148 } 149 150 } 151 152 @Override 153 public Base setProperty(int hash, String name, Base value) throws FHIRException { 154 switch (hash) { 155 case -1841058617: // lowLimit 156 this.lowLimit = castToQuantity(value); // Quantity 157 return value; 158 case -710757575: // highLimit 159 this.highLimit = castToQuantity(value); // Quantity 160 return value; 161 default: return super.setProperty(hash, name, value); 162 } 163 164 } 165 166 @Override 167 public Base setProperty(String name, Base value) throws FHIRException { 168 if (name.equals("lowLimit")) { 169 this.lowLimit = castToQuantity(value); // Quantity 170 } else if (name.equals("highLimit")) { 171 this.highLimit = castToQuantity(value); // Quantity 172 } else 173 return super.setProperty(name, value); 174 return value; 175 } 176 177 @Override 178 public Base makeProperty(int hash, String name) throws FHIRException { 179 switch (hash) { 180 case -1841058617: return getLowLimit(); 181 case -710757575: return getHighLimit(); 182 default: return super.makeProperty(hash, name); 183 } 184 185 } 186 187 @Override 188 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 189 switch (hash) { 190 case -1841058617: /*lowLimit*/ return new String[] {"Quantity"}; 191 case -710757575: /*highLimit*/ return new String[] {"Quantity"}; 192 default: return super.getTypesForProperty(hash, name); 193 } 194 195 } 196 197 @Override 198 public Base addChild(String name) throws FHIRException { 199 if (name.equals("lowLimit")) { 200 this.lowLimit = new Quantity(); 201 return this.lowLimit; 202 } 203 else if (name.equals("highLimit")) { 204 this.highLimit = new Quantity(); 205 return this.highLimit; 206 } 207 else 208 return super.addChild(name); 209 } 210 211 public SubstanceAmountReferenceRangeComponent copy() { 212 SubstanceAmountReferenceRangeComponent dst = new SubstanceAmountReferenceRangeComponent(); 213 copyValues(dst); 214 return dst; 215 } 216 217 public void copyValues(SubstanceAmountReferenceRangeComponent dst) { 218 super.copyValues(dst); 219 dst.lowLimit = lowLimit == null ? null : lowLimit.copy(); 220 dst.highLimit = highLimit == null ? null : highLimit.copy(); 221 } 222 223 @Override 224 public boolean equalsDeep(Base other_) { 225 if (!super.equalsDeep(other_)) 226 return false; 227 if (!(other_ instanceof SubstanceAmountReferenceRangeComponent)) 228 return false; 229 SubstanceAmountReferenceRangeComponent o = (SubstanceAmountReferenceRangeComponent) other_; 230 return compareDeep(lowLimit, o.lowLimit, true) && compareDeep(highLimit, o.highLimit, true); 231 } 232 233 @Override 234 public boolean equalsShallow(Base other_) { 235 if (!super.equalsShallow(other_)) 236 return false; 237 if (!(other_ instanceof SubstanceAmountReferenceRangeComponent)) 238 return false; 239 SubstanceAmountReferenceRangeComponent o = (SubstanceAmountReferenceRangeComponent) other_; 240 return true; 241 } 242 243 public boolean isEmpty() { 244 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(lowLimit, highLimit); 245 } 246 247 public String fhirType() { 248 return "SubstanceAmount.referenceRange"; 249 250 } 251 252 } 253 254 /** 255 * 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. 256 */ 257 @Child(name = "amount", type = {Quantity.class, Range.class, StringType.class}, order=0, min=0, max=1, modifier=false, summary=true) 258 @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." ) 259 protected Type amount; 260 261 /** 262 * 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. 263 */ 264 @Child(name = "amountType", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true) 265 @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." ) 266 protected CodeableConcept amountType; 267 268 /** 269 * A textual comment on a numeric value. 270 */ 271 @Child(name = "amountText", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=true) 272 @Description(shortDefinition="A textual comment on a numeric value", formalDefinition="A textual comment on a numeric value." ) 273 protected StringType amountText; 274 275 /** 276 * Reference range of possible or expected values. 277 */ 278 @Child(name = "referenceRange", type = {}, order=3, min=0, max=1, modifier=false, summary=true) 279 @Description(shortDefinition="Reference range of possible or expected values", formalDefinition="Reference range of possible or expected values." ) 280 protected SubstanceAmountReferenceRangeComponent referenceRange; 281 282 private static final long serialVersionUID = -174997548L; 283 284 /** 285 * Constructor 286 */ 287 public SubstanceAmount() { 288 super(); 289 } 290 291 /** 292 * @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.) 293 */ 294 public Type getAmount() { 295 return this.amount; 296 } 297 298 /** 299 * @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.) 300 */ 301 public Quantity getAmountQuantity() throws FHIRException { 302 if (this.amount == null) 303 this.amount = new Quantity(); 304 if (!(this.amount instanceof Quantity)) 305 throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.amount.getClass().getName()+" was encountered"); 306 return (Quantity) this.amount; 307 } 308 309 public boolean hasAmountQuantity() { 310 return this != null && this.amount instanceof Quantity; 311 } 312 313 /** 314 * @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.) 315 */ 316 public Range getAmountRange() throws FHIRException { 317 if (this.amount == null) 318 this.amount = new Range(); 319 if (!(this.amount instanceof Range)) 320 throw new FHIRException("Type mismatch: the type Range was expected, but "+this.amount.getClass().getName()+" was encountered"); 321 return (Range) this.amount; 322 } 323 324 public boolean hasAmountRange() { 325 return this != null && this.amount instanceof Range; 326 } 327 328 /** 329 * @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.) 330 */ 331 public StringType getAmountStringType() throws FHIRException { 332 if (this.amount == null) 333 this.amount = new StringType(); 334 if (!(this.amount instanceof StringType)) 335 throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.amount.getClass().getName()+" was encountered"); 336 return (StringType) this.amount; 337 } 338 339 public boolean hasAmountStringType() { 340 return this != null && this.amount instanceof StringType; 341 } 342 343 public boolean hasAmount() { 344 return this.amount != null && !this.amount.isEmpty(); 345 } 346 347 /** 348 * @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.) 349 */ 350 public SubstanceAmount setAmount(Type value) { 351 if (value != null && !(value instanceof Quantity || value instanceof Range || value instanceof StringType)) 352 throw new Error("Not the right type for SubstanceAmount.amount[x]: "+value.fhirType()); 353 this.amount = value; 354 return this; 355 } 356 357 /** 358 * @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.) 359 */ 360 public CodeableConcept getAmountType() { 361 if (this.amountType == null) 362 if (Configuration.errorOnAutoCreate()) 363 throw new Error("Attempt to auto-create SubstanceAmount.amountType"); 364 else if (Configuration.doAutoCreate()) 365 this.amountType = new CodeableConcept(); // cc 366 return this.amountType; 367 } 368 369 public boolean hasAmountType() { 370 return this.amountType != null && !this.amountType.isEmpty(); 371 } 372 373 /** 374 * @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.) 375 */ 376 public SubstanceAmount setAmountType(CodeableConcept value) { 377 this.amountType = value; 378 return this; 379 } 380 381 /** 382 * @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 383 */ 384 public StringType getAmountTextElement() { 385 if (this.amountText == null) 386 if (Configuration.errorOnAutoCreate()) 387 throw new Error("Attempt to auto-create SubstanceAmount.amountText"); 388 else if (Configuration.doAutoCreate()) 389 this.amountText = new StringType(); // bb 390 return this.amountText; 391 } 392 393 public boolean hasAmountTextElement() { 394 return this.amountText != null && !this.amountText.isEmpty(); 395 } 396 397 public boolean hasAmountText() { 398 return this.amountText != null && !this.amountText.isEmpty(); 399 } 400 401 /** 402 * @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 403 */ 404 public SubstanceAmount setAmountTextElement(StringType value) { 405 this.amountText = value; 406 return this; 407 } 408 409 /** 410 * @return A textual comment on a numeric value. 411 */ 412 public String getAmountText() { 413 return this.amountText == null ? null : this.amountText.getValue(); 414 } 415 416 /** 417 * @param value A textual comment on a numeric value. 418 */ 419 public SubstanceAmount setAmountText(String value) { 420 if (Utilities.noString(value)) 421 this.amountText = null; 422 else { 423 if (this.amountText == null) 424 this.amountText = new StringType(); 425 this.amountText.setValue(value); 426 } 427 return this; 428 } 429 430 /** 431 * @return {@link #referenceRange} (Reference range of possible or expected values.) 432 */ 433 public SubstanceAmountReferenceRangeComponent getReferenceRange() { 434 if (this.referenceRange == null) 435 if (Configuration.errorOnAutoCreate()) 436 throw new Error("Attempt to auto-create SubstanceAmount.referenceRange"); 437 else if (Configuration.doAutoCreate()) 438 this.referenceRange = new SubstanceAmountReferenceRangeComponent(); // cc 439 return this.referenceRange; 440 } 441 442 public boolean hasReferenceRange() { 443 return this.referenceRange != null && !this.referenceRange.isEmpty(); 444 } 445 446 /** 447 * @param value {@link #referenceRange} (Reference range of possible or expected values.) 448 */ 449 public SubstanceAmount setReferenceRange(SubstanceAmountReferenceRangeComponent value) { 450 this.referenceRange = value; 451 return this; 452 } 453 454 protected void listChildren(List<Property> children) { 455 super.listChildren(children); 456 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)); 457 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)); 458 children.add(new Property("amountText", "string", "A textual comment on a numeric value.", 0, 1, amountText)); 459 children.add(new Property("referenceRange", "", "Reference range of possible or expected values.", 0, 1, referenceRange)); 460 } 461 462 @Override 463 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 464 switch (_hash) { 465 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); 466 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); 467 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); 468 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); 469 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); 470 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); 471 case -1424876123: /*amountText*/ return new Property("amountText", "string", "A textual comment on a numeric value.", 0, 1, amountText); 472 case -1912545102: /*referenceRange*/ return new Property("referenceRange", "", "Reference range of possible or expected values.", 0, 1, referenceRange); 473 default: return super.getNamedProperty(_hash, _name, _checkValid); 474 } 475 476 } 477 478 @Override 479 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 480 switch (hash) { 481 case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : new Base[] {this.amount}; // Type 482 case -1424857166: /*amountType*/ return this.amountType == null ? new Base[0] : new Base[] {this.amountType}; // CodeableConcept 483 case -1424876123: /*amountText*/ return this.amountText == null ? new Base[0] : new Base[] {this.amountText}; // StringType 484 case -1912545102: /*referenceRange*/ return this.referenceRange == null ? new Base[0] : new Base[] {this.referenceRange}; // SubstanceAmountReferenceRangeComponent 485 default: return super.getProperty(hash, name, checkValid); 486 } 487 488 } 489 490 @Override 491 public Base setProperty(int hash, String name, Base value) throws FHIRException { 492 switch (hash) { 493 case -1413853096: // amount 494 this.amount = castToType(value); // Type 495 return value; 496 case -1424857166: // amountType 497 this.amountType = castToCodeableConcept(value); // CodeableConcept 498 return value; 499 case -1424876123: // amountText 500 this.amountText = castToString(value); // StringType 501 return value; 502 case -1912545102: // referenceRange 503 this.referenceRange = (SubstanceAmountReferenceRangeComponent) value; // SubstanceAmountReferenceRangeComponent 504 return value; 505 default: return super.setProperty(hash, name, value); 506 } 507 508 } 509 510 @Override 511 public Base setProperty(String name, Base value) throws FHIRException { 512 if (name.equals("amount[x]")) { 513 this.amount = castToType(value); // Type 514 } else if (name.equals("amountType")) { 515 this.amountType = castToCodeableConcept(value); // CodeableConcept 516 } else if (name.equals("amountText")) { 517 this.amountText = castToString(value); // StringType 518 } else if (name.equals("referenceRange")) { 519 this.referenceRange = (SubstanceAmountReferenceRangeComponent) value; // SubstanceAmountReferenceRangeComponent 520 } else 521 return super.setProperty(name, value); 522 return value; 523 } 524 525 @Override 526 public Base makeProperty(int hash, String name) throws FHIRException { 527 switch (hash) { 528 case 646780200: return getAmount(); 529 case -1413853096: return getAmount(); 530 case -1424857166: return getAmountType(); 531 case -1424876123: return getAmountTextElement(); 532 case -1912545102: return getReferenceRange(); 533 default: return super.makeProperty(hash, name); 534 } 535 536 } 537 538 @Override 539 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 540 switch (hash) { 541 case -1413853096: /*amount*/ return new String[] {"Quantity", "Range", "string"}; 542 case -1424857166: /*amountType*/ return new String[] {"CodeableConcept"}; 543 case -1424876123: /*amountText*/ return new String[] {"string"}; 544 case -1912545102: /*referenceRange*/ return new String[] {}; 545 default: return super.getTypesForProperty(hash, name); 546 } 547 548 } 549 550 @Override 551 public Base addChild(String name) throws FHIRException { 552 if (name.equals("amountQuantity")) { 553 this.amount = new Quantity(); 554 return this.amount; 555 } 556 else if (name.equals("amountRange")) { 557 this.amount = new Range(); 558 return this.amount; 559 } 560 else if (name.equals("amountString")) { 561 this.amount = new StringType(); 562 return this.amount; 563 } 564 else if (name.equals("amountType")) { 565 this.amountType = new CodeableConcept(); 566 return this.amountType; 567 } 568 else if (name.equals("amountText")) { 569 throw new FHIRException("Cannot call addChild on a primitive type SubstanceAmount.amountText"); 570 } 571 else if (name.equals("referenceRange")) { 572 this.referenceRange = new SubstanceAmountReferenceRangeComponent(); 573 return this.referenceRange; 574 } 575 else 576 return super.addChild(name); 577 } 578 579 public String fhirType() { 580 return "SubstanceAmount"; 581 582 } 583 584 public SubstanceAmount copy() { 585 SubstanceAmount dst = new SubstanceAmount(); 586 copyValues(dst); 587 return dst; 588 } 589 590 public void copyValues(SubstanceAmount dst) { 591 super.copyValues(dst); 592 dst.amount = amount == null ? null : amount.copy(); 593 dst.amountType = amountType == null ? null : amountType.copy(); 594 dst.amountText = amountText == null ? null : amountText.copy(); 595 dst.referenceRange = referenceRange == null ? null : referenceRange.copy(); 596 } 597 598 protected SubstanceAmount typedCopy() { 599 return copy(); 600 } 601 602 @Override 603 public boolean equalsDeep(Base other_) { 604 if (!super.equalsDeep(other_)) 605 return false; 606 if (!(other_ instanceof SubstanceAmount)) 607 return false; 608 SubstanceAmount o = (SubstanceAmount) other_; 609 return compareDeep(amount, o.amount, true) && compareDeep(amountType, o.amountType, true) && compareDeep(amountText, o.amountText, true) 610 && compareDeep(referenceRange, o.referenceRange, true); 611 } 612 613 @Override 614 public boolean equalsShallow(Base other_) { 615 if (!super.equalsShallow(other_)) 616 return false; 617 if (!(other_ instanceof SubstanceAmount)) 618 return false; 619 SubstanceAmount o = (SubstanceAmount) other_; 620 return compareValues(amountText, o.amountText, true); 621 } 622 623 public boolean isEmpty() { 624 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(amount, amountType, amountText 625 , referenceRange); 626 } 627 628 629}