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 * Indicates how the medication is/was taken or should be taken by the patient. 049 */ 050@DatatypeDef(name="Dosage") 051public class Dosage extends BackboneType implements ICompositeType { 052 053 @Block() 054 public static class DosageDoseAndRateComponent extends Element implements IBaseDatatypeElement { 055 /** 056 * The kind of dose or rate specified, for example, ordered or calculated. 057 */ 058 @Child(name = "type", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true) 059 @Description(shortDefinition="The kind of dose or rate specified", formalDefinition="The kind of dose or rate specified, for example, ordered or calculated." ) 060 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/dose-rate-type") 061 protected CodeableConcept type; 062 063 /** 064 * Amount of medication per dose. 065 */ 066 @Child(name = "dose", type = {Range.class, Quantity.class}, order=2, min=0, max=1, modifier=false, summary=true) 067 @Description(shortDefinition="Amount of medication per dose", formalDefinition="Amount of medication per dose." ) 068 protected Type dose; 069 070 /** 071 * Amount of medication per unit of time. 072 */ 073 @Child(name = "rate", type = {Ratio.class, Range.class, Quantity.class}, order=3, min=0, max=1, modifier=false, summary=true) 074 @Description(shortDefinition="Amount of medication per unit of time", formalDefinition="Amount of medication per unit of time." ) 075 protected Type rate; 076 077 private static final long serialVersionUID = -2133698888L; 078 079 /** 080 * Constructor 081 */ 082 public DosageDoseAndRateComponent() { 083 super(); 084 } 085 086 /** 087 * @return {@link #type} (The kind of dose or rate specified, for example, ordered or calculated.) 088 */ 089 public CodeableConcept getType() { 090 if (this.type == null) 091 if (Configuration.errorOnAutoCreate()) 092 throw new Error("Attempt to auto-create DosageDoseAndRateComponent.type"); 093 else if (Configuration.doAutoCreate()) 094 this.type = new CodeableConcept(); // cc 095 return this.type; 096 } 097 098 public boolean hasType() { 099 return this.type != null && !this.type.isEmpty(); 100 } 101 102 /** 103 * @param value {@link #type} (The kind of dose or rate specified, for example, ordered or calculated.) 104 */ 105 public DosageDoseAndRateComponent setType(CodeableConcept value) { 106 this.type = value; 107 return this; 108 } 109 110 /** 111 * @return {@link #dose} (Amount of medication per dose.) 112 */ 113 public Type getDose() { 114 return this.dose; 115 } 116 117 /** 118 * @return {@link #dose} (Amount of medication per dose.) 119 */ 120 public Range getDoseRange() throws FHIRException { 121 if (this.dose == null) 122 this.dose = new Range(); 123 if (!(this.dose instanceof Range)) 124 throw new FHIRException("Type mismatch: the type Range was expected, but "+this.dose.getClass().getName()+" was encountered"); 125 return (Range) this.dose; 126 } 127 128 public boolean hasDoseRange() { 129 return this != null && this.dose instanceof Range; 130 } 131 132 /** 133 * @return {@link #dose} (Amount of medication per dose.) 134 */ 135 public Quantity getDoseQuantity() throws FHIRException { 136 if (this.dose == null) 137 this.dose = new Quantity(); 138 if (!(this.dose instanceof Quantity)) 139 throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.dose.getClass().getName()+" was encountered"); 140 return (Quantity) this.dose; 141 } 142 143 public boolean hasDoseQuantity() { 144 return this != null && this.dose instanceof Quantity; 145 } 146 147 public boolean hasDose() { 148 return this.dose != null && !this.dose.isEmpty(); 149 } 150 151 /** 152 * @param value {@link #dose} (Amount of medication per dose.) 153 */ 154 public DosageDoseAndRateComponent setDose(Type value) { 155 if (value != null && !(value instanceof Range || value instanceof Quantity)) 156 throw new Error("Not the right type for Dosage.doseAndRate.dose[x]: "+value.fhirType()); 157 this.dose = value; 158 return this; 159 } 160 161 /** 162 * @return {@link #rate} (Amount of medication per unit of time.) 163 */ 164 public Type getRate() { 165 return this.rate; 166 } 167 168 /** 169 * @return {@link #rate} (Amount of medication per unit of time.) 170 */ 171 public Ratio getRateRatio() throws FHIRException { 172 if (this.rate == null) 173 this.rate = new Ratio(); 174 if (!(this.rate instanceof Ratio)) 175 throw new FHIRException("Type mismatch: the type Ratio was expected, but "+this.rate.getClass().getName()+" was encountered"); 176 return (Ratio) this.rate; 177 } 178 179 public boolean hasRateRatio() { 180 return this != null && this.rate instanceof Ratio; 181 } 182 183 /** 184 * @return {@link #rate} (Amount of medication per unit of time.) 185 */ 186 public Range getRateRange() throws FHIRException { 187 if (this.rate == null) 188 this.rate = new Range(); 189 if (!(this.rate instanceof Range)) 190 throw new FHIRException("Type mismatch: the type Range was expected, but "+this.rate.getClass().getName()+" was encountered"); 191 return (Range) this.rate; 192 } 193 194 public boolean hasRateRange() { 195 return this != null && this.rate instanceof Range; 196 } 197 198 /** 199 * @return {@link #rate} (Amount of medication per unit of time.) 200 */ 201 public Quantity getRateQuantity() throws FHIRException { 202 if (this.rate == null) 203 this.rate = new Quantity(); 204 if (!(this.rate instanceof Quantity)) 205 throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.rate.getClass().getName()+" was encountered"); 206 return (Quantity) this.rate; 207 } 208 209 public boolean hasRateQuantity() { 210 return this != null && this.rate instanceof Quantity; 211 } 212 213 public boolean hasRate() { 214 return this.rate != null && !this.rate.isEmpty(); 215 } 216 217 /** 218 * @param value {@link #rate} (Amount of medication per unit of time.) 219 */ 220 public DosageDoseAndRateComponent setRate(Type value) { 221 if (value != null && !(value instanceof Ratio || value instanceof Range || value instanceof Quantity)) 222 throw new Error("Not the right type for Dosage.doseAndRate.rate[x]: "+value.fhirType()); 223 this.rate = value; 224 return this; 225 } 226 227 protected void listChildren(List<Property> children) { 228 super.listChildren(children); 229 children.add(new Property("type", "CodeableConcept", "The kind of dose or rate specified, for example, ordered or calculated.", 0, 1, type)); 230 children.add(new Property("dose[x]", "Range|SimpleQuantity", "Amount of medication per dose.", 0, 1, dose)); 231 children.add(new Property("rate[x]", "Ratio|Range|SimpleQuantity", "Amount of medication per unit of time.", 0, 1, rate)); 232 } 233 234 @Override 235 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 236 switch (_hash) { 237 case 3575610: /*type*/ return new Property("type", "CodeableConcept", "The kind of dose or rate specified, for example, ordered or calculated.", 0, 1, type); 238 case 1843195715: /*dose[x]*/ return new Property("dose[x]", "Range|SimpleQuantity", "Amount of medication per dose.", 0, 1, dose); 239 case 3089437: /*dose*/ return new Property("dose[x]", "Range|SimpleQuantity", "Amount of medication per dose.", 0, 1, dose); 240 case 1775578912: /*doseRange*/ return new Property("dose[x]", "Range|SimpleQuantity", "Amount of medication per dose.", 0, 1, dose); 241 case -2083618872: /*doseQuantity*/ return new Property("dose[x]", "Range|SimpleQuantity", "Amount of medication per dose.", 0, 1, dose); 242 case 983460768: /*rate[x]*/ return new Property("rate[x]", "Ratio|Range|SimpleQuantity", "Amount of medication per unit of time.", 0, 1, rate); 243 case 3493088: /*rate*/ return new Property("rate[x]", "Ratio|Range|SimpleQuantity", "Amount of medication per unit of time.", 0, 1, rate); 244 case 204021515: /*rateRatio*/ return new Property("rate[x]", "Ratio|Range|SimpleQuantity", "Amount of medication per unit of time.", 0, 1, rate); 245 case 204015677: /*rateRange*/ return new Property("rate[x]", "Ratio|Range|SimpleQuantity", "Amount of medication per unit of time.", 0, 1, rate); 246 case -1085459061: /*rateQuantity*/ return new Property("rate[x]", "Ratio|Range|SimpleQuantity", "Amount of medication per unit of time.", 0, 1, rate); 247 default: return super.getNamedProperty(_hash, _name, _checkValid); 248 } 249 250 } 251 252 @Override 253 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 254 switch (hash) { 255 case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept 256 case 3089437: /*dose*/ return this.dose == null ? new Base[0] : new Base[] {this.dose}; // Type 257 case 3493088: /*rate*/ return this.rate == null ? new Base[0] : new Base[] {this.rate}; // Type 258 default: return super.getProperty(hash, name, checkValid); 259 } 260 261 } 262 263 @Override 264 public Base setProperty(int hash, String name, Base value) throws FHIRException { 265 switch (hash) { 266 case 3575610: // type 267 this.type = castToCodeableConcept(value); // CodeableConcept 268 return value; 269 case 3089437: // dose 270 this.dose = castToType(value); // Type 271 return value; 272 case 3493088: // rate 273 this.rate = castToType(value); // Type 274 return value; 275 default: return super.setProperty(hash, name, value); 276 } 277 278 } 279 280 @Override 281 public Base setProperty(String name, Base value) throws FHIRException { 282 if (name.equals("type")) { 283 this.type = castToCodeableConcept(value); // CodeableConcept 284 } else if (name.equals("dose[x]")) { 285 this.dose = castToType(value); // Type 286 } else if (name.equals("rate[x]")) { 287 this.rate = castToType(value); // Type 288 } else 289 return super.setProperty(name, value); 290 return value; 291 } 292 293 @Override 294 public Base makeProperty(int hash, String name) throws FHIRException { 295 switch (hash) { 296 case 3575610: return getType(); 297 case 1843195715: return getDose(); 298 case 3089437: return getDose(); 299 case 983460768: return getRate(); 300 case 3493088: return getRate(); 301 default: return super.makeProperty(hash, name); 302 } 303 304 } 305 306 @Override 307 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 308 switch (hash) { 309 case 3575610: /*type*/ return new String[] {"CodeableConcept"}; 310 case 3089437: /*dose*/ return new String[] {"Range", "SimpleQuantity"}; 311 case 3493088: /*rate*/ return new String[] {"Ratio", "Range", "SimpleQuantity"}; 312 default: return super.getTypesForProperty(hash, name); 313 } 314 315 } 316 317 @Override 318 public Base addChild(String name) throws FHIRException { 319 if (name.equals("type")) { 320 this.type = new CodeableConcept(); 321 return this.type; 322 } 323 else if (name.equals("doseRange")) { 324 this.dose = new Range(); 325 return this.dose; 326 } 327 else if (name.equals("doseQuantity")) { 328 this.dose = new Quantity(); 329 return this.dose; 330 } 331 else if (name.equals("rateRatio")) { 332 this.rate = new Ratio(); 333 return this.rate; 334 } 335 else if (name.equals("rateRange")) { 336 this.rate = new Range(); 337 return this.rate; 338 } 339 else if (name.equals("rateQuantity")) { 340 this.rate = new Quantity(); 341 return this.rate; 342 } 343 else 344 return super.addChild(name); 345 } 346 347 public DosageDoseAndRateComponent copy() { 348 DosageDoseAndRateComponent dst = new DosageDoseAndRateComponent(); 349 copyValues(dst); 350 return dst; 351 } 352 353 public void copyValues(DosageDoseAndRateComponent dst) { 354 super.copyValues(dst); 355 dst.type = type == null ? null : type.copy(); 356 dst.dose = dose == null ? null : dose.copy(); 357 dst.rate = rate == null ? null : rate.copy(); 358 } 359 360 @Override 361 public boolean equalsDeep(Base other_) { 362 if (!super.equalsDeep(other_)) 363 return false; 364 if (!(other_ instanceof DosageDoseAndRateComponent)) 365 return false; 366 DosageDoseAndRateComponent o = (DosageDoseAndRateComponent) other_; 367 return compareDeep(type, o.type, true) && compareDeep(dose, o.dose, true) && compareDeep(rate, o.rate, true) 368 ; 369 } 370 371 @Override 372 public boolean equalsShallow(Base other_) { 373 if (!super.equalsShallow(other_)) 374 return false; 375 if (!(other_ instanceof DosageDoseAndRateComponent)) 376 return false; 377 DosageDoseAndRateComponent o = (DosageDoseAndRateComponent) other_; 378 return true; 379 } 380 381 public boolean isEmpty() { 382 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, dose, rate); 383 } 384 385 public String fhirType() { 386 return "Dosage.doseAndRate"; 387 388 } 389 390 } 391 392 /** 393 * Indicates the order in which the dosage instructions should be applied or interpreted. 394 */ 395 @Child(name = "sequence", type = {IntegerType.class}, order=0, min=0, max=1, modifier=false, summary=true) 396 @Description(shortDefinition="The order of the dosage instructions", formalDefinition="Indicates the order in which the dosage instructions should be applied or interpreted." ) 397 protected IntegerType sequence; 398 399 /** 400 * Free text dosage instructions e.g. SIG. 401 */ 402 @Child(name = "text", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true) 403 @Description(shortDefinition="Free text dosage instructions e.g. SIG", formalDefinition="Free text dosage instructions e.g. SIG." ) 404 protected StringType text; 405 406 /** 407 * Supplemental instructions to the patient on how to take the medication (e.g. "with meals" or"take half to one hour before food") or warnings for the patient about the medication (e.g. "may cause drowsiness" or "avoid exposure of skin to direct sunlight or sunlamps"). 408 */ 409 @Child(name = "additionalInstruction", type = {CodeableConcept.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 410 @Description(shortDefinition="Supplemental instruction or warnings to the patient - e.g. \"with meals\", \"may cause drowsiness\"", formalDefinition="Supplemental instructions to the patient on how to take the medication (e.g. \"with meals\" or\"take half to one hour before food\") or warnings for the patient about the medication (e.g. \"may cause drowsiness\" or \"avoid exposure of skin to direct sunlight or sunlamps\")." ) 411 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/additional-instruction-codes") 412 protected List<CodeableConcept> additionalInstruction; 413 414 /** 415 * Instructions in terms that are understood by the patient or consumer. 416 */ 417 @Child(name = "patientInstruction", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true) 418 @Description(shortDefinition="Patient or consumer oriented instructions", formalDefinition="Instructions in terms that are understood by the patient or consumer." ) 419 protected StringType patientInstruction; 420 421 /** 422 * When medication should be administered. 423 */ 424 @Child(name = "timing", type = {Timing.class}, order=4, min=0, max=1, modifier=false, summary=true) 425 @Description(shortDefinition="When medication should be administered", formalDefinition="When medication should be administered." ) 426 protected Timing timing; 427 428 /** 429 * Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept). 430 */ 431 @Child(name = "asNeeded", type = {BooleanType.class, CodeableConcept.class}, order=5, min=0, max=1, modifier=false, summary=true) 432 @Description(shortDefinition="Take \"as needed\" (for x)", formalDefinition="Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept)." ) 433 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-as-needed-reason") 434 protected Type asNeeded; 435 436 /** 437 * Body site to administer to. 438 */ 439 @Child(name = "site", type = {CodeableConcept.class}, order=6, min=0, max=1, modifier=false, summary=true) 440 @Description(shortDefinition="Body site to administer to", formalDefinition="Body site to administer to." ) 441 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/approach-site-codes") 442 protected CodeableConcept site; 443 444 /** 445 * How drug should enter body. 446 */ 447 @Child(name = "route", type = {CodeableConcept.class}, order=7, min=0, max=1, modifier=false, summary=true) 448 @Description(shortDefinition="How drug should enter body", formalDefinition="How drug should enter body." ) 449 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/route-codes") 450 protected CodeableConcept route; 451 452 /** 453 * Technique for administering medication. 454 */ 455 @Child(name = "method", type = {CodeableConcept.class}, order=8, min=0, max=1, modifier=false, summary=true) 456 @Description(shortDefinition="Technique for administering medication", formalDefinition="Technique for administering medication." ) 457 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/administration-method-codes") 458 protected CodeableConcept method; 459 460 /** 461 * The amount of medication administered. 462 */ 463 @Child(name = "doseAndRate", type = {}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 464 @Description(shortDefinition="Amount of medication administered", formalDefinition="The amount of medication administered." ) 465 protected List<DosageDoseAndRateComponent> doseAndRate; 466 467 /** 468 * Upper limit on medication per unit of time. 469 */ 470 @Child(name = "maxDosePerPeriod", type = {Ratio.class}, order=10, min=0, max=1, modifier=false, summary=true) 471 @Description(shortDefinition="Upper limit on medication per unit of time", formalDefinition="Upper limit on medication per unit of time." ) 472 protected Ratio maxDosePerPeriod; 473 474 /** 475 * Upper limit on medication per administration. 476 */ 477 @Child(name = "maxDosePerAdministration", type = {Quantity.class}, order=11, min=0, max=1, modifier=false, summary=true) 478 @Description(shortDefinition="Upper limit on medication per administration", formalDefinition="Upper limit on medication per administration." ) 479 protected Quantity maxDosePerAdministration; 480 481 /** 482 * Upper limit on medication per lifetime of the patient. 483 */ 484 @Child(name = "maxDosePerLifetime", type = {Quantity.class}, order=12, min=0, max=1, modifier=false, summary=true) 485 @Description(shortDefinition="Upper limit on medication per lifetime of the patient", formalDefinition="Upper limit on medication per lifetime of the patient." ) 486 protected Quantity maxDosePerLifetime; 487 488 private static final long serialVersionUID = -1095063329L; 489 490 /** 491 * Constructor 492 */ 493 public Dosage() { 494 super(); 495 } 496 497 /** 498 * @return {@link #sequence} (Indicates the order in which the dosage instructions should be applied or interpreted.). This is the underlying object with id, value and extensions. The accessor "getSequence" gives direct access to the value 499 */ 500 public IntegerType getSequenceElement() { 501 if (this.sequence == null) 502 if (Configuration.errorOnAutoCreate()) 503 throw new Error("Attempt to auto-create Dosage.sequence"); 504 else if (Configuration.doAutoCreate()) 505 this.sequence = new IntegerType(); // bb 506 return this.sequence; 507 } 508 509 public boolean hasSequenceElement() { 510 return this.sequence != null && !this.sequence.isEmpty(); 511 } 512 513 public boolean hasSequence() { 514 return this.sequence != null && !this.sequence.isEmpty(); 515 } 516 517 /** 518 * @param value {@link #sequence} (Indicates the order in which the dosage instructions should be applied or interpreted.). This is the underlying object with id, value and extensions. The accessor "getSequence" gives direct access to the value 519 */ 520 public Dosage setSequenceElement(IntegerType value) { 521 this.sequence = value; 522 return this; 523 } 524 525 /** 526 * @return Indicates the order in which the dosage instructions should be applied or interpreted. 527 */ 528 public int getSequence() { 529 return this.sequence == null || this.sequence.isEmpty() ? 0 : this.sequence.getValue(); 530 } 531 532 /** 533 * @param value Indicates the order in which the dosage instructions should be applied or interpreted. 534 */ 535 public Dosage setSequence(int value) { 536 if (this.sequence == null) 537 this.sequence = new IntegerType(); 538 this.sequence.setValue(value); 539 return this; 540 } 541 542 /** 543 * @return {@link #text} (Free text dosage instructions e.g. SIG.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value 544 */ 545 public StringType getTextElement() { 546 if (this.text == null) 547 if (Configuration.errorOnAutoCreate()) 548 throw new Error("Attempt to auto-create Dosage.text"); 549 else if (Configuration.doAutoCreate()) 550 this.text = new StringType(); // bb 551 return this.text; 552 } 553 554 public boolean hasTextElement() { 555 return this.text != null && !this.text.isEmpty(); 556 } 557 558 public boolean hasText() { 559 return this.text != null && !this.text.isEmpty(); 560 } 561 562 /** 563 * @param value {@link #text} (Free text dosage instructions e.g. SIG.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value 564 */ 565 public Dosage setTextElement(StringType value) { 566 this.text = value; 567 return this; 568 } 569 570 /** 571 * @return Free text dosage instructions e.g. SIG. 572 */ 573 public String getText() { 574 return this.text == null ? null : this.text.getValue(); 575 } 576 577 /** 578 * @param value Free text dosage instructions e.g. SIG. 579 */ 580 public Dosage setText(String value) { 581 if (Utilities.noString(value)) 582 this.text = null; 583 else { 584 if (this.text == null) 585 this.text = new StringType(); 586 this.text.setValue(value); 587 } 588 return this; 589 } 590 591 /** 592 * @return {@link #additionalInstruction} (Supplemental instructions to the patient on how to take the medication (e.g. "with meals" or"take half to one hour before food") or warnings for the patient about the medication (e.g. "may cause drowsiness" or "avoid exposure of skin to direct sunlight or sunlamps").) 593 */ 594 public List<CodeableConcept> getAdditionalInstruction() { 595 if (this.additionalInstruction == null) 596 this.additionalInstruction = new ArrayList<CodeableConcept>(); 597 return this.additionalInstruction; 598 } 599 600 /** 601 * @return Returns a reference to <code>this</code> for easy method chaining 602 */ 603 public Dosage setAdditionalInstruction(List<CodeableConcept> theAdditionalInstruction) { 604 this.additionalInstruction = theAdditionalInstruction; 605 return this; 606 } 607 608 public boolean hasAdditionalInstruction() { 609 if (this.additionalInstruction == null) 610 return false; 611 for (CodeableConcept item : this.additionalInstruction) 612 if (!item.isEmpty()) 613 return true; 614 return false; 615 } 616 617 public CodeableConcept addAdditionalInstruction() { //3 618 CodeableConcept t = new CodeableConcept(); 619 if (this.additionalInstruction == null) 620 this.additionalInstruction = new ArrayList<CodeableConcept>(); 621 this.additionalInstruction.add(t); 622 return t; 623 } 624 625 public Dosage addAdditionalInstruction(CodeableConcept t) { //3 626 if (t == null) 627 return this; 628 if (this.additionalInstruction == null) 629 this.additionalInstruction = new ArrayList<CodeableConcept>(); 630 this.additionalInstruction.add(t); 631 return this; 632 } 633 634 /** 635 * @return The first repetition of repeating field {@link #additionalInstruction}, creating it if it does not already exist 636 */ 637 public CodeableConcept getAdditionalInstructionFirstRep() { 638 if (getAdditionalInstruction().isEmpty()) { 639 addAdditionalInstruction(); 640 } 641 return getAdditionalInstruction().get(0); 642 } 643 644 /** 645 * @return {@link #patientInstruction} (Instructions in terms that are understood by the patient or consumer.). This is the underlying object with id, value and extensions. The accessor "getPatientInstruction" gives direct access to the value 646 */ 647 public StringType getPatientInstructionElement() { 648 if (this.patientInstruction == null) 649 if (Configuration.errorOnAutoCreate()) 650 throw new Error("Attempt to auto-create Dosage.patientInstruction"); 651 else if (Configuration.doAutoCreate()) 652 this.patientInstruction = new StringType(); // bb 653 return this.patientInstruction; 654 } 655 656 public boolean hasPatientInstructionElement() { 657 return this.patientInstruction != null && !this.patientInstruction.isEmpty(); 658 } 659 660 public boolean hasPatientInstruction() { 661 return this.patientInstruction != null && !this.patientInstruction.isEmpty(); 662 } 663 664 /** 665 * @param value {@link #patientInstruction} (Instructions in terms that are understood by the patient or consumer.). This is the underlying object with id, value and extensions. The accessor "getPatientInstruction" gives direct access to the value 666 */ 667 public Dosage setPatientInstructionElement(StringType value) { 668 this.patientInstruction = value; 669 return this; 670 } 671 672 /** 673 * @return Instructions in terms that are understood by the patient or consumer. 674 */ 675 public String getPatientInstruction() { 676 return this.patientInstruction == null ? null : this.patientInstruction.getValue(); 677 } 678 679 /** 680 * @param value Instructions in terms that are understood by the patient or consumer. 681 */ 682 public Dosage setPatientInstruction(String value) { 683 if (Utilities.noString(value)) 684 this.patientInstruction = null; 685 else { 686 if (this.patientInstruction == null) 687 this.patientInstruction = new StringType(); 688 this.patientInstruction.setValue(value); 689 } 690 return this; 691 } 692 693 /** 694 * @return {@link #timing} (When medication should be administered.) 695 */ 696 public Timing getTiming() { 697 if (this.timing == null) 698 if (Configuration.errorOnAutoCreate()) 699 throw new Error("Attempt to auto-create Dosage.timing"); 700 else if (Configuration.doAutoCreate()) 701 this.timing = new Timing(); // cc 702 return this.timing; 703 } 704 705 public boolean hasTiming() { 706 return this.timing != null && !this.timing.isEmpty(); 707 } 708 709 /** 710 * @param value {@link #timing} (When medication should be administered.) 711 */ 712 public Dosage setTiming(Timing value) { 713 this.timing = value; 714 return this; 715 } 716 717 /** 718 * @return {@link #asNeeded} (Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept).) 719 */ 720 public Type getAsNeeded() { 721 return this.asNeeded; 722 } 723 724 /** 725 * @return {@link #asNeeded} (Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept).) 726 */ 727 public BooleanType getAsNeededBooleanType() throws FHIRException { 728 if (this.asNeeded == null) 729 this.asNeeded = new BooleanType(); 730 if (!(this.asNeeded instanceof BooleanType)) 731 throw new FHIRException("Type mismatch: the type BooleanType was expected, but "+this.asNeeded.getClass().getName()+" was encountered"); 732 return (BooleanType) this.asNeeded; 733 } 734 735 public boolean hasAsNeededBooleanType() { 736 return this != null && this.asNeeded instanceof BooleanType; 737 } 738 739 /** 740 * @return {@link #asNeeded} (Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept).) 741 */ 742 public CodeableConcept getAsNeededCodeableConcept() throws FHIRException { 743 if (this.asNeeded == null) 744 this.asNeeded = new CodeableConcept(); 745 if (!(this.asNeeded instanceof CodeableConcept)) 746 throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.asNeeded.getClass().getName()+" was encountered"); 747 return (CodeableConcept) this.asNeeded; 748 } 749 750 public boolean hasAsNeededCodeableConcept() { 751 return this != null && this.asNeeded instanceof CodeableConcept; 752 } 753 754 public boolean hasAsNeeded() { 755 return this.asNeeded != null && !this.asNeeded.isEmpty(); 756 } 757 758 /** 759 * @param value {@link #asNeeded} (Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept).) 760 */ 761 public Dosage setAsNeeded(Type value) { 762 if (value != null && !(value instanceof BooleanType || value instanceof CodeableConcept)) 763 throw new Error("Not the right type for Dosage.asNeeded[x]: "+value.fhirType()); 764 this.asNeeded = value; 765 return this; 766 } 767 768 /** 769 * @return {@link #site} (Body site to administer to.) 770 */ 771 public CodeableConcept getSite() { 772 if (this.site == null) 773 if (Configuration.errorOnAutoCreate()) 774 throw new Error("Attempt to auto-create Dosage.site"); 775 else if (Configuration.doAutoCreate()) 776 this.site = new CodeableConcept(); // cc 777 return this.site; 778 } 779 780 public boolean hasSite() { 781 return this.site != null && !this.site.isEmpty(); 782 } 783 784 /** 785 * @param value {@link #site} (Body site to administer to.) 786 */ 787 public Dosage setSite(CodeableConcept value) { 788 this.site = value; 789 return this; 790 } 791 792 /** 793 * @return {@link #route} (How drug should enter body.) 794 */ 795 public CodeableConcept getRoute() { 796 if (this.route == null) 797 if (Configuration.errorOnAutoCreate()) 798 throw new Error("Attempt to auto-create Dosage.route"); 799 else if (Configuration.doAutoCreate()) 800 this.route = new CodeableConcept(); // cc 801 return this.route; 802 } 803 804 public boolean hasRoute() { 805 return this.route != null && !this.route.isEmpty(); 806 } 807 808 /** 809 * @param value {@link #route} (How drug should enter body.) 810 */ 811 public Dosage setRoute(CodeableConcept value) { 812 this.route = value; 813 return this; 814 } 815 816 /** 817 * @return {@link #method} (Technique for administering medication.) 818 */ 819 public CodeableConcept getMethod() { 820 if (this.method == null) 821 if (Configuration.errorOnAutoCreate()) 822 throw new Error("Attempt to auto-create Dosage.method"); 823 else if (Configuration.doAutoCreate()) 824 this.method = new CodeableConcept(); // cc 825 return this.method; 826 } 827 828 public boolean hasMethod() { 829 return this.method != null && !this.method.isEmpty(); 830 } 831 832 /** 833 * @param value {@link #method} (Technique for administering medication.) 834 */ 835 public Dosage setMethod(CodeableConcept value) { 836 this.method = value; 837 return this; 838 } 839 840 /** 841 * @return {@link #doseAndRate} (The amount of medication administered.) 842 */ 843 public List<DosageDoseAndRateComponent> getDoseAndRate() { 844 if (this.doseAndRate == null) 845 this.doseAndRate = new ArrayList<DosageDoseAndRateComponent>(); 846 return this.doseAndRate; 847 } 848 849 /** 850 * @return Returns a reference to <code>this</code> for easy method chaining 851 */ 852 public Dosage setDoseAndRate(List<DosageDoseAndRateComponent> theDoseAndRate) { 853 this.doseAndRate = theDoseAndRate; 854 return this; 855 } 856 857 public boolean hasDoseAndRate() { 858 if (this.doseAndRate == null) 859 return false; 860 for (DosageDoseAndRateComponent item : this.doseAndRate) 861 if (!item.isEmpty()) 862 return true; 863 return false; 864 } 865 866 public DosageDoseAndRateComponent addDoseAndRate() { //3 867 DosageDoseAndRateComponent t = new DosageDoseAndRateComponent(); 868 if (this.doseAndRate == null) 869 this.doseAndRate = new ArrayList<DosageDoseAndRateComponent>(); 870 this.doseAndRate.add(t); 871 return t; 872 } 873 874 public Dosage addDoseAndRate(DosageDoseAndRateComponent t) { //3 875 if (t == null) 876 return this; 877 if (this.doseAndRate == null) 878 this.doseAndRate = new ArrayList<DosageDoseAndRateComponent>(); 879 this.doseAndRate.add(t); 880 return this; 881 } 882 883 /** 884 * @return The first repetition of repeating field {@link #doseAndRate}, creating it if it does not already exist 885 */ 886 public DosageDoseAndRateComponent getDoseAndRateFirstRep() { 887 if (getDoseAndRate().isEmpty()) { 888 addDoseAndRate(); 889 } 890 return getDoseAndRate().get(0); 891 } 892 893 /** 894 * @return {@link #maxDosePerPeriod} (Upper limit on medication per unit of time.) 895 */ 896 public Ratio getMaxDosePerPeriod() { 897 if (this.maxDosePerPeriod == null) 898 if (Configuration.errorOnAutoCreate()) 899 throw new Error("Attempt to auto-create Dosage.maxDosePerPeriod"); 900 else if (Configuration.doAutoCreate()) 901 this.maxDosePerPeriod = new Ratio(); // cc 902 return this.maxDosePerPeriod; 903 } 904 905 public boolean hasMaxDosePerPeriod() { 906 return this.maxDosePerPeriod != null && !this.maxDosePerPeriod.isEmpty(); 907 } 908 909 /** 910 * @param value {@link #maxDosePerPeriod} (Upper limit on medication per unit of time.) 911 */ 912 public Dosage setMaxDosePerPeriod(Ratio value) { 913 this.maxDosePerPeriod = value; 914 return this; 915 } 916 917 /** 918 * @return {@link #maxDosePerAdministration} (Upper limit on medication per administration.) 919 */ 920 public Quantity getMaxDosePerAdministration() { 921 if (this.maxDosePerAdministration == null) 922 if (Configuration.errorOnAutoCreate()) 923 throw new Error("Attempt to auto-create Dosage.maxDosePerAdministration"); 924 else if (Configuration.doAutoCreate()) 925 this.maxDosePerAdministration = new Quantity(); // cc 926 return this.maxDosePerAdministration; 927 } 928 929 public boolean hasMaxDosePerAdministration() { 930 return this.maxDosePerAdministration != null && !this.maxDosePerAdministration.isEmpty(); 931 } 932 933 /** 934 * @param value {@link #maxDosePerAdministration} (Upper limit on medication per administration.) 935 */ 936 public Dosage setMaxDosePerAdministration(Quantity value) { 937 this.maxDosePerAdministration = value; 938 return this; 939 } 940 941 /** 942 * @return {@link #maxDosePerLifetime} (Upper limit on medication per lifetime of the patient.) 943 */ 944 public Quantity getMaxDosePerLifetime() { 945 if (this.maxDosePerLifetime == null) 946 if (Configuration.errorOnAutoCreate()) 947 throw new Error("Attempt to auto-create Dosage.maxDosePerLifetime"); 948 else if (Configuration.doAutoCreate()) 949 this.maxDosePerLifetime = new Quantity(); // cc 950 return this.maxDosePerLifetime; 951 } 952 953 public boolean hasMaxDosePerLifetime() { 954 return this.maxDosePerLifetime != null && !this.maxDosePerLifetime.isEmpty(); 955 } 956 957 /** 958 * @param value {@link #maxDosePerLifetime} (Upper limit on medication per lifetime of the patient.) 959 */ 960 public Dosage setMaxDosePerLifetime(Quantity value) { 961 this.maxDosePerLifetime = value; 962 return this; 963 } 964 965 protected void listChildren(List<Property> children) { 966 super.listChildren(children); 967 children.add(new Property("sequence", "integer", "Indicates the order in which the dosage instructions should be applied or interpreted.", 0, 1, sequence)); 968 children.add(new Property("text", "string", "Free text dosage instructions e.g. SIG.", 0, 1, text)); 969 children.add(new Property("additionalInstruction", "CodeableConcept", "Supplemental instructions to the patient on how to take the medication (e.g. \"with meals\" or\"take half to one hour before food\") or warnings for the patient about the medication (e.g. \"may cause drowsiness\" or \"avoid exposure of skin to direct sunlight or sunlamps\").", 0, java.lang.Integer.MAX_VALUE, additionalInstruction)); 970 children.add(new Property("patientInstruction", "string", "Instructions in terms that are understood by the patient or consumer.", 0, 1, patientInstruction)); 971 children.add(new Property("timing", "Timing", "When medication should be administered.", 0, 1, timing)); 972 children.add(new Property("asNeeded[x]", "boolean|CodeableConcept", "Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept).", 0, 1, asNeeded)); 973 children.add(new Property("site", "CodeableConcept", "Body site to administer to.", 0, 1, site)); 974 children.add(new Property("route", "CodeableConcept", "How drug should enter body.", 0, 1, route)); 975 children.add(new Property("method", "CodeableConcept", "Technique for administering medication.", 0, 1, method)); 976 children.add(new Property("doseAndRate", "", "The amount of medication administered.", 0, java.lang.Integer.MAX_VALUE, doseAndRate)); 977 children.add(new Property("maxDosePerPeriod", "Ratio", "Upper limit on medication per unit of time.", 0, 1, maxDosePerPeriod)); 978 children.add(new Property("maxDosePerAdministration", "SimpleQuantity", "Upper limit on medication per administration.", 0, 1, maxDosePerAdministration)); 979 children.add(new Property("maxDosePerLifetime", "SimpleQuantity", "Upper limit on medication per lifetime of the patient.", 0, 1, maxDosePerLifetime)); 980 } 981 982 @Override 983 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 984 switch (_hash) { 985 case 1349547969: /*sequence*/ return new Property("sequence", "integer", "Indicates the order in which the dosage instructions should be applied or interpreted.", 0, 1, sequence); 986 case 3556653: /*text*/ return new Property("text", "string", "Free text dosage instructions e.g. SIG.", 0, 1, text); 987 case 1623641575: /*additionalInstruction*/ return new Property("additionalInstruction", "CodeableConcept", "Supplemental instructions to the patient on how to take the medication (e.g. \"with meals\" or\"take half to one hour before food\") or warnings for the patient about the medication (e.g. \"may cause drowsiness\" or \"avoid exposure of skin to direct sunlight or sunlamps\").", 0, java.lang.Integer.MAX_VALUE, additionalInstruction); 988 case 737543241: /*patientInstruction*/ return new Property("patientInstruction", "string", "Instructions in terms that are understood by the patient or consumer.", 0, 1, patientInstruction); 989 case -873664438: /*timing*/ return new Property("timing", "Timing", "When medication should be administered.", 0, 1, timing); 990 case -544329575: /*asNeeded[x]*/ return new Property("asNeeded[x]", "boolean|CodeableConcept", "Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept).", 0, 1, asNeeded); 991 case -1432923513: /*asNeeded*/ return new Property("asNeeded[x]", "boolean|CodeableConcept", "Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept).", 0, 1, asNeeded); 992 case -591717471: /*asNeededBoolean*/ return new Property("asNeeded[x]", "boolean|CodeableConcept", "Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept).", 0, 1, asNeeded); 993 case 1556420122: /*asNeededCodeableConcept*/ return new Property("asNeeded[x]", "boolean|CodeableConcept", "Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept).", 0, 1, asNeeded); 994 case 3530567: /*site*/ return new Property("site", "CodeableConcept", "Body site to administer to.", 0, 1, site); 995 case 108704329: /*route*/ return new Property("route", "CodeableConcept", "How drug should enter body.", 0, 1, route); 996 case -1077554975: /*method*/ return new Property("method", "CodeableConcept", "Technique for administering medication.", 0, 1, method); 997 case -611024774: /*doseAndRate*/ return new Property("doseAndRate", "", "The amount of medication administered.", 0, java.lang.Integer.MAX_VALUE, doseAndRate); 998 case 1506263709: /*maxDosePerPeriod*/ return new Property("maxDosePerPeriod", "Ratio", "Upper limit on medication per unit of time.", 0, 1, maxDosePerPeriod); 999 case 2004889914: /*maxDosePerAdministration*/ return new Property("maxDosePerAdministration", "SimpleQuantity", "Upper limit on medication per administration.", 0, 1, maxDosePerAdministration); 1000 case 642099621: /*maxDosePerLifetime*/ return new Property("maxDosePerLifetime", "SimpleQuantity", "Upper limit on medication per lifetime of the patient.", 0, 1, maxDosePerLifetime); 1001 default: return super.getNamedProperty(_hash, _name, _checkValid); 1002 } 1003 1004 } 1005 1006 @Override 1007 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 1008 switch (hash) { 1009 case 1349547969: /*sequence*/ return this.sequence == null ? new Base[0] : new Base[] {this.sequence}; // IntegerType 1010 case 3556653: /*text*/ return this.text == null ? new Base[0] : new Base[] {this.text}; // StringType 1011 case 1623641575: /*additionalInstruction*/ return this.additionalInstruction == null ? new Base[0] : this.additionalInstruction.toArray(new Base[this.additionalInstruction.size()]); // CodeableConcept 1012 case 737543241: /*patientInstruction*/ return this.patientInstruction == null ? new Base[0] : new Base[] {this.patientInstruction}; // StringType 1013 case -873664438: /*timing*/ return this.timing == null ? new Base[0] : new Base[] {this.timing}; // Timing 1014 case -1432923513: /*asNeeded*/ return this.asNeeded == null ? new Base[0] : new Base[] {this.asNeeded}; // Type 1015 case 3530567: /*site*/ return this.site == null ? new Base[0] : new Base[] {this.site}; // CodeableConcept 1016 case 108704329: /*route*/ return this.route == null ? new Base[0] : new Base[] {this.route}; // CodeableConcept 1017 case -1077554975: /*method*/ return this.method == null ? new Base[0] : new Base[] {this.method}; // CodeableConcept 1018 case -611024774: /*doseAndRate*/ return this.doseAndRate == null ? new Base[0] : this.doseAndRate.toArray(new Base[this.doseAndRate.size()]); // DosageDoseAndRateComponent 1019 case 1506263709: /*maxDosePerPeriod*/ return this.maxDosePerPeriod == null ? new Base[0] : new Base[] {this.maxDosePerPeriod}; // Ratio 1020 case 2004889914: /*maxDosePerAdministration*/ return this.maxDosePerAdministration == null ? new Base[0] : new Base[] {this.maxDosePerAdministration}; // Quantity 1021 case 642099621: /*maxDosePerLifetime*/ return this.maxDosePerLifetime == null ? new Base[0] : new Base[] {this.maxDosePerLifetime}; // Quantity 1022 default: return super.getProperty(hash, name, checkValid); 1023 } 1024 1025 } 1026 1027 @Override 1028 public Base setProperty(int hash, String name, Base value) throws FHIRException { 1029 switch (hash) { 1030 case 1349547969: // sequence 1031 this.sequence = castToInteger(value); // IntegerType 1032 return value; 1033 case 3556653: // text 1034 this.text = castToString(value); // StringType 1035 return value; 1036 case 1623641575: // additionalInstruction 1037 this.getAdditionalInstruction().add(castToCodeableConcept(value)); // CodeableConcept 1038 return value; 1039 case 737543241: // patientInstruction 1040 this.patientInstruction = castToString(value); // StringType 1041 return value; 1042 case -873664438: // timing 1043 this.timing = castToTiming(value); // Timing 1044 return value; 1045 case -1432923513: // asNeeded 1046 this.asNeeded = castToType(value); // Type 1047 return value; 1048 case 3530567: // site 1049 this.site = castToCodeableConcept(value); // CodeableConcept 1050 return value; 1051 case 108704329: // route 1052 this.route = castToCodeableConcept(value); // CodeableConcept 1053 return value; 1054 case -1077554975: // method 1055 this.method = castToCodeableConcept(value); // CodeableConcept 1056 return value; 1057 case -611024774: // doseAndRate 1058 this.getDoseAndRate().add((DosageDoseAndRateComponent) value); // DosageDoseAndRateComponent 1059 return value; 1060 case 1506263709: // maxDosePerPeriod 1061 this.maxDosePerPeriod = castToRatio(value); // Ratio 1062 return value; 1063 case 2004889914: // maxDosePerAdministration 1064 this.maxDosePerAdministration = castToQuantity(value); // Quantity 1065 return value; 1066 case 642099621: // maxDosePerLifetime 1067 this.maxDosePerLifetime = castToQuantity(value); // Quantity 1068 return value; 1069 default: return super.setProperty(hash, name, value); 1070 } 1071 1072 } 1073 1074 @Override 1075 public Base setProperty(String name, Base value) throws FHIRException { 1076 if (name.equals("sequence")) { 1077 this.sequence = castToInteger(value); // IntegerType 1078 } else if (name.equals("text")) { 1079 this.text = castToString(value); // StringType 1080 } else if (name.equals("additionalInstruction")) { 1081 this.getAdditionalInstruction().add(castToCodeableConcept(value)); 1082 } else if (name.equals("patientInstruction")) { 1083 this.patientInstruction = castToString(value); // StringType 1084 } else if (name.equals("timing")) { 1085 this.timing = castToTiming(value); // Timing 1086 } else if (name.equals("asNeeded[x]")) { 1087 this.asNeeded = castToType(value); // Type 1088 } else if (name.equals("site")) { 1089 this.site = castToCodeableConcept(value); // CodeableConcept 1090 } else if (name.equals("route")) { 1091 this.route = castToCodeableConcept(value); // CodeableConcept 1092 } else if (name.equals("method")) { 1093 this.method = castToCodeableConcept(value); // CodeableConcept 1094 } else if (name.equals("doseAndRate")) { 1095 this.getDoseAndRate().add((DosageDoseAndRateComponent) value); 1096 } else if (name.equals("maxDosePerPeriod")) { 1097 this.maxDosePerPeriod = castToRatio(value); // Ratio 1098 } else if (name.equals("maxDosePerAdministration")) { 1099 this.maxDosePerAdministration = castToQuantity(value); // Quantity 1100 } else if (name.equals("maxDosePerLifetime")) { 1101 this.maxDosePerLifetime = castToQuantity(value); // Quantity 1102 } else 1103 return super.setProperty(name, value); 1104 return value; 1105 } 1106 1107 @Override 1108 public Base makeProperty(int hash, String name) throws FHIRException { 1109 switch (hash) { 1110 case 1349547969: return getSequenceElement(); 1111 case 3556653: return getTextElement(); 1112 case 1623641575: return addAdditionalInstruction(); 1113 case 737543241: return getPatientInstructionElement(); 1114 case -873664438: return getTiming(); 1115 case -544329575: return getAsNeeded(); 1116 case -1432923513: return getAsNeeded(); 1117 case 3530567: return getSite(); 1118 case 108704329: return getRoute(); 1119 case -1077554975: return getMethod(); 1120 case -611024774: return addDoseAndRate(); 1121 case 1506263709: return getMaxDosePerPeriod(); 1122 case 2004889914: return getMaxDosePerAdministration(); 1123 case 642099621: return getMaxDosePerLifetime(); 1124 default: return super.makeProperty(hash, name); 1125 } 1126 1127 } 1128 1129 @Override 1130 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 1131 switch (hash) { 1132 case 1349547969: /*sequence*/ return new String[] {"integer"}; 1133 case 3556653: /*text*/ return new String[] {"string"}; 1134 case 1623641575: /*additionalInstruction*/ return new String[] {"CodeableConcept"}; 1135 case 737543241: /*patientInstruction*/ return new String[] {"string"}; 1136 case -873664438: /*timing*/ return new String[] {"Timing"}; 1137 case -1432923513: /*asNeeded*/ return new String[] {"boolean", "CodeableConcept"}; 1138 case 3530567: /*site*/ return new String[] {"CodeableConcept"}; 1139 case 108704329: /*route*/ return new String[] {"CodeableConcept"}; 1140 case -1077554975: /*method*/ return new String[] {"CodeableConcept"}; 1141 case -611024774: /*doseAndRate*/ return new String[] {}; 1142 case 1506263709: /*maxDosePerPeriod*/ return new String[] {"Ratio"}; 1143 case 2004889914: /*maxDosePerAdministration*/ return new String[] {"SimpleQuantity"}; 1144 case 642099621: /*maxDosePerLifetime*/ return new String[] {"SimpleQuantity"}; 1145 default: return super.getTypesForProperty(hash, name); 1146 } 1147 1148 } 1149 1150 @Override 1151 public Base addChild(String name) throws FHIRException { 1152 if (name.equals("sequence")) { 1153 throw new FHIRException("Cannot call addChild on a primitive type Dosage.sequence"); 1154 } 1155 else if (name.equals("text")) { 1156 throw new FHIRException("Cannot call addChild on a primitive type Dosage.text"); 1157 } 1158 else if (name.equals("additionalInstruction")) { 1159 return addAdditionalInstruction(); 1160 } 1161 else if (name.equals("patientInstruction")) { 1162 throw new FHIRException("Cannot call addChild on a primitive type Dosage.patientInstruction"); 1163 } 1164 else if (name.equals("timing")) { 1165 this.timing = new Timing(); 1166 return this.timing; 1167 } 1168 else if (name.equals("asNeededBoolean")) { 1169 this.asNeeded = new BooleanType(); 1170 return this.asNeeded; 1171 } 1172 else if (name.equals("asNeededCodeableConcept")) { 1173 this.asNeeded = new CodeableConcept(); 1174 return this.asNeeded; 1175 } 1176 else if (name.equals("site")) { 1177 this.site = new CodeableConcept(); 1178 return this.site; 1179 } 1180 else if (name.equals("route")) { 1181 this.route = new CodeableConcept(); 1182 return this.route; 1183 } 1184 else if (name.equals("method")) { 1185 this.method = new CodeableConcept(); 1186 return this.method; 1187 } 1188 else if (name.equals("doseAndRate")) { 1189 return addDoseAndRate(); 1190 } 1191 else if (name.equals("maxDosePerPeriod")) { 1192 this.maxDosePerPeriod = new Ratio(); 1193 return this.maxDosePerPeriod; 1194 } 1195 else if (name.equals("maxDosePerAdministration")) { 1196 this.maxDosePerAdministration = new Quantity(); 1197 return this.maxDosePerAdministration; 1198 } 1199 else if (name.equals("maxDosePerLifetime")) { 1200 this.maxDosePerLifetime = new Quantity(); 1201 return this.maxDosePerLifetime; 1202 } 1203 else 1204 return super.addChild(name); 1205 } 1206 1207 public String fhirType() { 1208 return "Dosage"; 1209 1210 } 1211 1212 public Dosage copy() { 1213 Dosage dst = new Dosage(); 1214 copyValues(dst); 1215 return dst; 1216 } 1217 1218 public void copyValues(Dosage dst) { 1219 super.copyValues(dst); 1220 dst.sequence = sequence == null ? null : sequence.copy(); 1221 dst.text = text == null ? null : text.copy(); 1222 if (additionalInstruction != null) { 1223 dst.additionalInstruction = new ArrayList<CodeableConcept>(); 1224 for (CodeableConcept i : additionalInstruction) 1225 dst.additionalInstruction.add(i.copy()); 1226 }; 1227 dst.patientInstruction = patientInstruction == null ? null : patientInstruction.copy(); 1228 dst.timing = timing == null ? null : timing.copy(); 1229 dst.asNeeded = asNeeded == null ? null : asNeeded.copy(); 1230 dst.site = site == null ? null : site.copy(); 1231 dst.route = route == null ? null : route.copy(); 1232 dst.method = method == null ? null : method.copy(); 1233 if (doseAndRate != null) { 1234 dst.doseAndRate = new ArrayList<DosageDoseAndRateComponent>(); 1235 for (DosageDoseAndRateComponent i : doseAndRate) 1236 dst.doseAndRate.add(i.copy()); 1237 }; 1238 dst.maxDosePerPeriod = maxDosePerPeriod == null ? null : maxDosePerPeriod.copy(); 1239 dst.maxDosePerAdministration = maxDosePerAdministration == null ? null : maxDosePerAdministration.copy(); 1240 dst.maxDosePerLifetime = maxDosePerLifetime == null ? null : maxDosePerLifetime.copy(); 1241 } 1242 1243 protected Dosage typedCopy() { 1244 return copy(); 1245 } 1246 1247 @Override 1248 public boolean equalsDeep(Base other_) { 1249 if (!super.equalsDeep(other_)) 1250 return false; 1251 if (!(other_ instanceof Dosage)) 1252 return false; 1253 Dosage o = (Dosage) other_; 1254 return compareDeep(sequence, o.sequence, true) && compareDeep(text, o.text, true) && compareDeep(additionalInstruction, o.additionalInstruction, true) 1255 && compareDeep(patientInstruction, o.patientInstruction, true) && compareDeep(timing, o.timing, true) 1256 && compareDeep(asNeeded, o.asNeeded, true) && compareDeep(site, o.site, true) && compareDeep(route, o.route, true) 1257 && compareDeep(method, o.method, true) && compareDeep(doseAndRate, o.doseAndRate, true) && compareDeep(maxDosePerPeriod, o.maxDosePerPeriod, true) 1258 && compareDeep(maxDosePerAdministration, o.maxDosePerAdministration, true) && compareDeep(maxDosePerLifetime, o.maxDosePerLifetime, true) 1259 ; 1260 } 1261 1262 @Override 1263 public boolean equalsShallow(Base other_) { 1264 if (!super.equalsShallow(other_)) 1265 return false; 1266 if (!(other_ instanceof Dosage)) 1267 return false; 1268 Dosage o = (Dosage) other_; 1269 return compareValues(sequence, o.sequence, true) && compareValues(text, o.text, true) && compareValues(patientInstruction, o.patientInstruction, true) 1270 ; 1271 } 1272 1273 public boolean isEmpty() { 1274 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(sequence, text, additionalInstruction 1275 , patientInstruction, timing, asNeeded, site, route, method, doseAndRate, maxDosePerPeriod 1276 , maxDosePerAdministration, maxDosePerLifetime); 1277 } 1278 1279 1280}