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