001package org.hl7.fhir.dstu2.model; 002 003/* 004 Copyright (c) 2011+, HL7, Inc. 005 All rights reserved. 006 007 Redistribution and use in source and binary forms, with or without modification, 008 are permitted provided that the following conditions are met: 009 010 * Redistributions of source code must retain the above copyright notice, this 011 list of conditions and the following disclaimer. 012 * Redistributions in binary form must reproduce the above copyright notice, 013 this list of conditions and the following disclaimer in the documentation 014 and/or other materials provided with the distribution. 015 * Neither the name of HL7 nor the names of its contributors may be used to 016 endorse or promote products derived from this software without specific 017 prior written permission. 018 019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 020 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 021 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 022 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 023 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 024 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 025 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 026 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 027 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 028 POSSIBILITY OF SUCH DAMAGE. 029 030*/ 031 032// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2 033import java.util.ArrayList; 034import java.util.Date; 035import java.util.List; 036 037import ca.uhn.fhir.model.api.annotation.Block; 038import ca.uhn.fhir.model.api.annotation.Child; 039import ca.uhn.fhir.model.api.annotation.Description; 040import ca.uhn.fhir.model.api.annotation.ResourceDef; 041import ca.uhn.fhir.model.api.annotation.SearchParamDefinition; 042import org.hl7.fhir.instance.model.api.IBaseBackboneElement; 043import org.hl7.fhir.exceptions.FHIRException; 044import org.hl7.fhir.utilities.Utilities; 045 046/** 047 * An order for both supply of the medication and the instructions for 048 * administration of the medication to a patient. The resource is called 049 * "MedicationOrder" rather than "MedicationPrescription" to generalize the use 050 * across inpatient and outpatient settings as well as for care plans, etc. 051 */ 052@ResourceDef(name = "MedicationOrder", profile = "http://hl7.org/fhir/Profile/MedicationOrder") 053public class MedicationOrder extends DomainResource { 054 055 public enum MedicationOrderStatus { 056 /** 057 * The prescription is 'actionable', but not all actions that are implied by it 058 * have occurred yet. 059 */ 060 ACTIVE, 061 /** 062 * Actions implied by the prescription are to be temporarily halted, but are 063 * expected to continue later. May also be called "suspended". 064 */ 065 ONHOLD, 066 /** 067 * All actions that are implied by the prescription have occurred. 068 */ 069 COMPLETED, 070 /** 071 * The prescription was entered in error. 072 */ 073 ENTEREDINERROR, 074 /** 075 * Actions implied by the prescription are to be permanently halted, before all 076 * of them occurred. 077 */ 078 STOPPED, 079 /** 080 * The prescription is not yet 'actionable', i.e. it is a work in progress, 081 * requires sign-off or verification, and needs to be run through decision 082 * support process. 083 */ 084 DRAFT, 085 /** 086 * added to help the parsers 087 */ 088 NULL; 089 090 public static MedicationOrderStatus fromCode(String codeString) throws FHIRException { 091 if (codeString == null || "".equals(codeString)) 092 return null; 093 if ("active".equals(codeString)) 094 return ACTIVE; 095 if ("on-hold".equals(codeString)) 096 return ONHOLD; 097 if ("completed".equals(codeString)) 098 return COMPLETED; 099 if ("entered-in-error".equals(codeString)) 100 return ENTEREDINERROR; 101 if ("stopped".equals(codeString)) 102 return STOPPED; 103 if ("draft".equals(codeString)) 104 return DRAFT; 105 throw new FHIRException("Unknown MedicationOrderStatus code '" + codeString + "'"); 106 } 107 108 public String toCode() { 109 switch (this) { 110 case ACTIVE: 111 return "active"; 112 case ONHOLD: 113 return "on-hold"; 114 case COMPLETED: 115 return "completed"; 116 case ENTEREDINERROR: 117 return "entered-in-error"; 118 case STOPPED: 119 return "stopped"; 120 case DRAFT: 121 return "draft"; 122 case NULL: 123 return null; 124 default: 125 return "?"; 126 } 127 } 128 129 public String getSystem() { 130 switch (this) { 131 case ACTIVE: 132 return "http://hl7.org/fhir/medication-order-status"; 133 case ONHOLD: 134 return "http://hl7.org/fhir/medication-order-status"; 135 case COMPLETED: 136 return "http://hl7.org/fhir/medication-order-status"; 137 case ENTEREDINERROR: 138 return "http://hl7.org/fhir/medication-order-status"; 139 case STOPPED: 140 return "http://hl7.org/fhir/medication-order-status"; 141 case DRAFT: 142 return "http://hl7.org/fhir/medication-order-status"; 143 case NULL: 144 return null; 145 default: 146 return "?"; 147 } 148 } 149 150 public String getDefinition() { 151 switch (this) { 152 case ACTIVE: 153 return "The prescription is 'actionable', but not all actions that are implied by it have occurred yet."; 154 case ONHOLD: 155 return "Actions implied by the prescription are to be temporarily halted, but are expected to continue later. May also be called \"suspended\"."; 156 case COMPLETED: 157 return "All actions that are implied by the prescription have occurred."; 158 case ENTEREDINERROR: 159 return "The prescription was entered in error."; 160 case STOPPED: 161 return "Actions implied by the prescription are to be permanently halted, before all of them occurred."; 162 case DRAFT: 163 return "The prescription is not yet 'actionable', i.e. it is a work in progress, requires sign-off or verification, and needs to be run through decision support process."; 164 case NULL: 165 return null; 166 default: 167 return "?"; 168 } 169 } 170 171 public String getDisplay() { 172 switch (this) { 173 case ACTIVE: 174 return "Active"; 175 case ONHOLD: 176 return "On Hold"; 177 case COMPLETED: 178 return "Completed"; 179 case ENTEREDINERROR: 180 return "Entered In Error"; 181 case STOPPED: 182 return "Stopped"; 183 case DRAFT: 184 return "Draft"; 185 case NULL: 186 return null; 187 default: 188 return "?"; 189 } 190 } 191 } 192 193 public static class MedicationOrderStatusEnumFactory implements EnumFactory<MedicationOrderStatus> { 194 public MedicationOrderStatus fromCode(String codeString) throws IllegalArgumentException { 195 if (codeString == null || "".equals(codeString)) 196 if (codeString == null || "".equals(codeString)) 197 return null; 198 if ("active".equals(codeString)) 199 return MedicationOrderStatus.ACTIVE; 200 if ("on-hold".equals(codeString)) 201 return MedicationOrderStatus.ONHOLD; 202 if ("completed".equals(codeString)) 203 return MedicationOrderStatus.COMPLETED; 204 if ("entered-in-error".equals(codeString)) 205 return MedicationOrderStatus.ENTEREDINERROR; 206 if ("stopped".equals(codeString)) 207 return MedicationOrderStatus.STOPPED; 208 if ("draft".equals(codeString)) 209 return MedicationOrderStatus.DRAFT; 210 throw new IllegalArgumentException("Unknown MedicationOrderStatus code '" + codeString + "'"); 211 } 212 213 public Enumeration<MedicationOrderStatus> fromType(Base code) throws FHIRException { 214 if (code == null || code.isEmpty()) 215 return null; 216 String codeString = ((PrimitiveType) code).asStringValue(); 217 if (codeString == null || "".equals(codeString)) 218 return null; 219 if ("active".equals(codeString)) 220 return new Enumeration<MedicationOrderStatus>(this, MedicationOrderStatus.ACTIVE); 221 if ("on-hold".equals(codeString)) 222 return new Enumeration<MedicationOrderStatus>(this, MedicationOrderStatus.ONHOLD); 223 if ("completed".equals(codeString)) 224 return new Enumeration<MedicationOrderStatus>(this, MedicationOrderStatus.COMPLETED); 225 if ("entered-in-error".equals(codeString)) 226 return new Enumeration<MedicationOrderStatus>(this, MedicationOrderStatus.ENTEREDINERROR); 227 if ("stopped".equals(codeString)) 228 return new Enumeration<MedicationOrderStatus>(this, MedicationOrderStatus.STOPPED); 229 if ("draft".equals(codeString)) 230 return new Enumeration<MedicationOrderStatus>(this, MedicationOrderStatus.DRAFT); 231 throw new FHIRException("Unknown MedicationOrderStatus code '" + codeString + "'"); 232 } 233 234 public String toCode(MedicationOrderStatus code) { 235 if (code == MedicationOrderStatus.ACTIVE) 236 return "active"; 237 if (code == MedicationOrderStatus.ONHOLD) 238 return "on-hold"; 239 if (code == MedicationOrderStatus.COMPLETED) 240 return "completed"; 241 if (code == MedicationOrderStatus.ENTEREDINERROR) 242 return "entered-in-error"; 243 if (code == MedicationOrderStatus.STOPPED) 244 return "stopped"; 245 if (code == MedicationOrderStatus.DRAFT) 246 return "draft"; 247 return "?"; 248 } 249 } 250 251 @Block() 252 public static class MedicationOrderDosageInstructionComponent extends BackboneElement 253 implements IBaseBackboneElement { 254 /** 255 * Free text dosage instructions can be used for cases where the instructions 256 * are too complex to code. The content of this attribute does not include the 257 * name or description of the medication. When coded instructions are present, 258 * the free text instructions may still be present for display to humans taking 259 * or administering the medication. It is expected that the text instructions 260 * will always be populated. If the dosage.timing attribute is also populated, 261 * then the dosage.text should reflect the same information as the timing. 262 */ 263 @Child(name = "text", type = { StringType.class }, order = 1, min = 0, max = 1, modifier = false, summary = true) 264 @Description(shortDefinition = "Dosage instructions expressed as text", formalDefinition = "Free text dosage instructions can be used for cases where the instructions are too complex to code. The content of this attribute does not include the name or description of the medication. When coded instructions are present, the free text instructions may still be present for display to humans taking or administering the medication. It is expected that the text instructions will always be populated. If the dosage.timing attribute is also populated, then the dosage.text should reflect the same information as the timing.") 265 protected StringType text; 266 267 /** 268 * Additional instructions such as "Swallow with plenty of water" which may or 269 * may not be coded. 270 */ 271 @Child(name = "additionalInstructions", type = { 272 CodeableConcept.class }, order = 2, min = 0, max = 1, modifier = false, summary = true) 273 @Description(shortDefinition = "Supplemental instructions - e.g. \"with meals\"", formalDefinition = "Additional instructions such as \"Swallow with plenty of water\" which may or may not be coded.") 274 protected CodeableConcept additionalInstructions; 275 276 /** 277 * The timing schedule for giving the medication to the patient. The Schedule 278 * data type allows many different expressions. For example: "Every 8 hours"; 279 * "Three times a day"; "1/2 an hour before breakfast for 10 days from 23-Dec 280 * 2011:"; "15 Oct 2013, 17 Oct 2013 and 1 Nov 2013". 281 */ 282 @Child(name = "timing", type = { Timing.class }, order = 3, min = 0, max = 1, modifier = false, summary = true) 283 @Description(shortDefinition = "When medication should be administered", formalDefinition = "The timing schedule for giving the medication to the patient. The Schedule data type allows many different expressions. For example: \"Every 8 hours\"; \"Three times a day\"; \"1/2 an hour before breakfast for 10 days from 23-Dec 2011:\"; \"15 Oct 2013, 17 Oct 2013 and 1 Nov 2013\".") 284 protected Timing timing; 285 286 /** 287 * Indicates whether the Medication is only taken when needed within a specific 288 * dosing schedule (Boolean option), or it indicates the precondition for taking 289 * the Medication (CodeableConcept). 290 */ 291 @Child(name = "asNeeded", type = { BooleanType.class, 292 CodeableConcept.class }, order = 4, min = 0, max = 1, modifier = false, summary = true) 293 @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).") 294 protected Type asNeeded; 295 296 /** 297 * A coded specification of the anatomic site where the medication first enters 298 * the body. 299 */ 300 @Child(name = "site", type = { CodeableConcept.class, 301 BodySite.class }, order = 5, min = 0, max = 1, modifier = false, summary = true) 302 @Description(shortDefinition = "Body site to administer to", formalDefinition = "A coded specification of the anatomic site where the medication first enters the body.") 303 protected Type site; 304 305 /** 306 * A code specifying the route or physiological path of administration of a 307 * therapeutic agent into or onto a patient's body. 308 */ 309 @Child(name = "route", type = { 310 CodeableConcept.class }, order = 6, min = 0, max = 1, modifier = false, summary = true) 311 @Description(shortDefinition = "How drug should enter body", formalDefinition = "A code specifying the route or physiological path of administration of a therapeutic agent into or onto a patient's body.") 312 protected CodeableConcept route; 313 314 /** 315 * A coded value indicating the method by which the medication is introduced 316 * into or onto the body. Most commonly used for injections. For examples, Slow 317 * Push; Deep IV. 318 */ 319 @Child(name = "method", type = { 320 CodeableConcept.class }, order = 7, min = 0, max = 1, modifier = false, summary = true) 321 @Description(shortDefinition = "Technique for administering medication", formalDefinition = "A coded value indicating the method by which the medication is introduced into or onto the body. Most commonly used for injections. For examples, Slow Push; Deep IV.") 322 protected CodeableConcept method; 323 324 /** 325 * The amount of therapeutic or other substance given at one administration 326 * event. 327 */ 328 @Child(name = "dose", type = { Range.class, 329 SimpleQuantity.class }, order = 8, min = 0, max = 1, modifier = false, summary = true) 330 @Description(shortDefinition = "Amount of medication per dose", formalDefinition = "The amount of therapeutic or other substance given at one administration event.") 331 protected Type dose; 332 333 /** 334 * Identifies the speed with which the medication was or will be introduced into 335 * the patient. Typically the rate for an infusion e.g. 100 ml per 1 hour or 100 336 * ml/hr. May also be expressed as a rate per unit of time e.g. 500 ml per 2 337 * hours. Currently we do not specify a default of '1' in the denominator, but 338 * this is being discussed. Other examples: 200 mcg/min or 200 mcg/1 minute; 1 339 * liter/8 hours. 340 */ 341 @Child(name = "rate", type = { Ratio.class, 342 Range.class }, order = 9, min = 0, max = 1, modifier = false, summary = true) 343 @Description(shortDefinition = "Amount of medication per unit of time", formalDefinition = "Identifies the speed with which the medication was or will be introduced into the patient. Typically the rate for an infusion e.g. 100 ml per 1 hour or 100 ml/hr. May also be expressed as a rate per unit of time e.g. 500 ml per 2 hours. Currently we do not specify a default of '1' in the denominator, but this is being discussed. Other examples: 200 mcg/min or 200 mcg/1 minute; 1 liter/8 hours.") 344 protected Type rate; 345 346 /** 347 * The maximum total quantity of a therapeutic substance that may be 348 * administered to a subject over the period of time. For example, 1000mg in 24 349 * hours. 350 */ 351 @Child(name = "maxDosePerPeriod", type = { 352 Ratio.class }, order = 10, min = 0, max = 1, modifier = false, summary = true) 353 @Description(shortDefinition = "Upper limit on medication per unit of time", formalDefinition = "The maximum total quantity of a therapeutic substance that may be administered to a subject over the period of time. For example, 1000mg in 24 hours.") 354 protected Ratio maxDosePerPeriod; 355 356 private static final long serialVersionUID = -1470136646L; 357 358 /* 359 * Constructor 360 */ 361 public MedicationOrderDosageInstructionComponent() { 362 super(); 363 } 364 365 /** 366 * @return {@link #text} (Free text dosage instructions can be used for cases 367 * where the instructions are too complex to code. The content of this 368 * attribute does not include the name or description of the medication. 369 * When coded instructions are present, the free text instructions may 370 * still be present for display to humans taking or administering the 371 * medication. It is expected that the text instructions will always be 372 * populated. If the dosage.timing attribute is also populated, then the 373 * dosage.text should reflect the same information as the timing.). This 374 * is the underlying object with id, value and extensions. The accessor 375 * "getText" gives direct access to the value 376 */ 377 public StringType getTextElement() { 378 if (this.text == null) 379 if (Configuration.errorOnAutoCreate()) 380 throw new Error("Attempt to auto-create MedicationOrderDosageInstructionComponent.text"); 381 else if (Configuration.doAutoCreate()) 382 this.text = new StringType(); // bb 383 return this.text; 384 } 385 386 public boolean hasTextElement() { 387 return this.text != null && !this.text.isEmpty(); 388 } 389 390 public boolean hasText() { 391 return this.text != null && !this.text.isEmpty(); 392 } 393 394 /** 395 * @param value {@link #text} (Free text dosage instructions can be used for 396 * cases where the instructions are too complex to code. The 397 * content of this attribute does not include the name or 398 * description of the medication. When coded instructions are 399 * present, the free text instructions may still be present for 400 * display to humans taking or administering the medication. It is 401 * expected that the text instructions will always be populated. If 402 * the dosage.timing attribute is also populated, then the 403 * dosage.text should reflect the same information as the timing.). 404 * This is the underlying object with id, value and extensions. The 405 * accessor "getText" gives direct access to the value 406 */ 407 public MedicationOrderDosageInstructionComponent setTextElement(StringType value) { 408 this.text = value; 409 return this; 410 } 411 412 /** 413 * @return Free text dosage instructions can be used for cases where the 414 * instructions are too complex to code. The content of this attribute 415 * does not include the name or description of the medication. When 416 * coded instructions are present, the free text instructions may still 417 * be present for display to humans taking or administering the 418 * medication. It is expected that the text instructions will always be 419 * populated. If the dosage.timing attribute is also populated, then the 420 * dosage.text should reflect the same information as the timing. 421 */ 422 public String getText() { 423 return this.text == null ? null : this.text.getValue(); 424 } 425 426 /** 427 * @param value Free text dosage instructions can be used for cases where the 428 * instructions are too complex to code. The content of this 429 * attribute does not include the name or description of the 430 * medication. When coded instructions are present, the free text 431 * instructions may still be present for display to humans taking 432 * or administering the medication. It is expected that the text 433 * instructions will always be populated. If the dosage.timing 434 * attribute is also populated, then the dosage.text should reflect 435 * the same information as the timing. 436 */ 437 public MedicationOrderDosageInstructionComponent setText(String value) { 438 if (Utilities.noString(value)) 439 this.text = null; 440 else { 441 if (this.text == null) 442 this.text = new StringType(); 443 this.text.setValue(value); 444 } 445 return this; 446 } 447 448 /** 449 * @return {@link #additionalInstructions} (Additional instructions such as 450 * "Swallow with plenty of water" which may or may not be coded.) 451 */ 452 public CodeableConcept getAdditionalInstructions() { 453 if (this.additionalInstructions == null) 454 if (Configuration.errorOnAutoCreate()) 455 throw new Error("Attempt to auto-create MedicationOrderDosageInstructionComponent.additionalInstructions"); 456 else if (Configuration.doAutoCreate()) 457 this.additionalInstructions = new CodeableConcept(); // cc 458 return this.additionalInstructions; 459 } 460 461 public boolean hasAdditionalInstructions() { 462 return this.additionalInstructions != null && !this.additionalInstructions.isEmpty(); 463 } 464 465 /** 466 * @param value {@link #additionalInstructions} (Additional instructions such as 467 * "Swallow with plenty of water" which may or may not be coded.) 468 */ 469 public MedicationOrderDosageInstructionComponent setAdditionalInstructions(CodeableConcept value) { 470 this.additionalInstructions = value; 471 return this; 472 } 473 474 /** 475 * @return {@link #timing} (The timing schedule for giving the medication to the 476 * patient. The Schedule data type allows many different expressions. 477 * For example: "Every 8 hours"; "Three times a day"; "1/2 an hour 478 * before breakfast for 10 days from 23-Dec 2011:"; "15 Oct 2013, 17 Oct 479 * 2013 and 1 Nov 2013".) 480 */ 481 public Timing getTiming() { 482 if (this.timing == null) 483 if (Configuration.errorOnAutoCreate()) 484 throw new Error("Attempt to auto-create MedicationOrderDosageInstructionComponent.timing"); 485 else if (Configuration.doAutoCreate()) 486 this.timing = new Timing(); // cc 487 return this.timing; 488 } 489 490 public boolean hasTiming() { 491 return this.timing != null && !this.timing.isEmpty(); 492 } 493 494 /** 495 * @param value {@link #timing} (The timing schedule for giving the medication 496 * to the patient. The Schedule data type allows many different 497 * expressions. For example: "Every 8 hours"; "Three times a day"; 498 * "1/2 an hour before breakfast for 10 days from 23-Dec 2011:"; 499 * "15 Oct 2013, 17 Oct 2013 and 1 Nov 2013".) 500 */ 501 public MedicationOrderDosageInstructionComponent setTiming(Timing value) { 502 this.timing = value; 503 return this; 504 } 505 506 /** 507 * @return {@link #asNeeded} (Indicates whether the Medication is only taken 508 * when needed within a specific dosing schedule (Boolean option), or it 509 * indicates the precondition for taking the Medication 510 * (CodeableConcept).) 511 */ 512 public Type getAsNeeded() { 513 return this.asNeeded; 514 } 515 516 /** 517 * @return {@link #asNeeded} (Indicates whether the Medication is only taken 518 * when needed within a specific dosing schedule (Boolean option), or it 519 * indicates the precondition for taking the Medication 520 * (CodeableConcept).) 521 */ 522 public BooleanType getAsNeededBooleanType() throws FHIRException { 523 if (!(this.asNeeded instanceof BooleanType)) 524 throw new FHIRException("Type mismatch: the type BooleanType was expected, but " 525 + this.asNeeded.getClass().getName() + " was encountered"); 526 return (BooleanType) this.asNeeded; 527 } 528 529 public boolean hasAsNeededBooleanType() { 530 return this.asNeeded instanceof BooleanType; 531 } 532 533 /** 534 * @return {@link #asNeeded} (Indicates whether the Medication is only taken 535 * when needed within a specific dosing schedule (Boolean option), or it 536 * indicates the precondition for taking the Medication 537 * (CodeableConcept).) 538 */ 539 public CodeableConcept getAsNeededCodeableConcept() throws FHIRException { 540 if (!(this.asNeeded instanceof CodeableConcept)) 541 throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but " 542 + this.asNeeded.getClass().getName() + " was encountered"); 543 return (CodeableConcept) this.asNeeded; 544 } 545 546 public boolean hasAsNeededCodeableConcept() { 547 return this.asNeeded instanceof CodeableConcept; 548 } 549 550 public boolean hasAsNeeded() { 551 return this.asNeeded != null && !this.asNeeded.isEmpty(); 552 } 553 554 /** 555 * @param value {@link #asNeeded} (Indicates whether the Medication is only 556 * taken when needed within a specific dosing schedule (Boolean 557 * option), or it indicates the precondition for taking the 558 * Medication (CodeableConcept).) 559 */ 560 public MedicationOrderDosageInstructionComponent setAsNeeded(Type value) { 561 this.asNeeded = value; 562 return this; 563 } 564 565 /** 566 * @return {@link #site} (A coded specification of the anatomic site where the 567 * medication first enters the body.) 568 */ 569 public Type getSite() { 570 return this.site; 571 } 572 573 /** 574 * @return {@link #site} (A coded specification of the anatomic site where the 575 * medication first enters the body.) 576 */ 577 public CodeableConcept getSiteCodeableConcept() throws FHIRException { 578 if (!(this.site instanceof CodeableConcept)) 579 throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but " 580 + this.site.getClass().getName() + " was encountered"); 581 return (CodeableConcept) this.site; 582 } 583 584 public boolean hasSiteCodeableConcept() { 585 return this.site instanceof CodeableConcept; 586 } 587 588 /** 589 * @return {@link #site} (A coded specification of the anatomic site where the 590 * medication first enters the body.) 591 */ 592 public Reference getSiteReference() throws FHIRException { 593 if (!(this.site instanceof Reference)) 594 throw new FHIRException("Type mismatch: the type Reference was expected, but " + this.site.getClass().getName() 595 + " was encountered"); 596 return (Reference) this.site; 597 } 598 599 public boolean hasSiteReference() { 600 return this.site instanceof Reference; 601 } 602 603 public boolean hasSite() { 604 return this.site != null && !this.site.isEmpty(); 605 } 606 607 /** 608 * @param value {@link #site} (A coded specification of the anatomic site where 609 * the medication first enters the body.) 610 */ 611 public MedicationOrderDosageInstructionComponent setSite(Type value) { 612 this.site = value; 613 return this; 614 } 615 616 /** 617 * @return {@link #route} (A code specifying the route or physiological path of 618 * administration of a therapeutic agent into or onto a patient's body.) 619 */ 620 public CodeableConcept getRoute() { 621 if (this.route == null) 622 if (Configuration.errorOnAutoCreate()) 623 throw new Error("Attempt to auto-create MedicationOrderDosageInstructionComponent.route"); 624 else if (Configuration.doAutoCreate()) 625 this.route = new CodeableConcept(); // cc 626 return this.route; 627 } 628 629 public boolean hasRoute() { 630 return this.route != null && !this.route.isEmpty(); 631 } 632 633 /** 634 * @param value {@link #route} (A code specifying the route or physiological 635 * path of administration of a therapeutic agent into or onto a 636 * patient's body.) 637 */ 638 public MedicationOrderDosageInstructionComponent setRoute(CodeableConcept value) { 639 this.route = value; 640 return this; 641 } 642 643 /** 644 * @return {@link #method} (A coded value indicating the method by which the 645 * medication is introduced into or onto the body. Most commonly used 646 * for injections. For examples, Slow Push; Deep IV.) 647 */ 648 public CodeableConcept getMethod() { 649 if (this.method == null) 650 if (Configuration.errorOnAutoCreate()) 651 throw new Error("Attempt to auto-create MedicationOrderDosageInstructionComponent.method"); 652 else if (Configuration.doAutoCreate()) 653 this.method = new CodeableConcept(); // cc 654 return this.method; 655 } 656 657 public boolean hasMethod() { 658 return this.method != null && !this.method.isEmpty(); 659 } 660 661 /** 662 * @param value {@link #method} (A coded value indicating the method by which 663 * the medication is introduced into or onto the body. Most 664 * commonly used for injections. For examples, Slow Push; Deep IV.) 665 */ 666 public MedicationOrderDosageInstructionComponent setMethod(CodeableConcept value) { 667 this.method = value; 668 return this; 669 } 670 671 /** 672 * @return {@link #dose} (The amount of therapeutic or other substance given at 673 * one administration event.) 674 */ 675 public Type getDose() { 676 return this.dose; 677 } 678 679 /** 680 * @return {@link #dose} (The amount of therapeutic or other substance given at 681 * one administration event.) 682 */ 683 public Range getDoseRange() throws FHIRException { 684 if (!(this.dose instanceof Range)) 685 throw new FHIRException( 686 "Type mismatch: the type Range was expected, but " + this.dose.getClass().getName() + " was encountered"); 687 return (Range) this.dose; 688 } 689 690 public boolean hasDoseRange() { 691 return this.dose instanceof Range; 692 } 693 694 /** 695 * @return {@link #dose} (The amount of therapeutic or other substance given at 696 * one administration event.) 697 */ 698 public SimpleQuantity getDoseSimpleQuantity() throws FHIRException { 699 if (!(this.dose instanceof SimpleQuantity)) 700 throw new FHIRException("Type mismatch: the type SimpleQuantity was expected, but " 701 + this.dose.getClass().getName() + " was encountered"); 702 return (SimpleQuantity) this.dose; 703 } 704 705 public boolean hasDoseSimpleQuantity() { 706 return this.dose instanceof SimpleQuantity; 707 } 708 709 public boolean hasDose() { 710 return this.dose != null && !this.dose.isEmpty(); 711 } 712 713 /** 714 * @param value {@link #dose} (The amount of therapeutic or other substance 715 * given at one administration event.) 716 */ 717 public MedicationOrderDosageInstructionComponent setDose(Type value) { 718 this.dose = value; 719 return this; 720 } 721 722 /** 723 * @return {@link #rate} (Identifies the speed with which the medication was or 724 * will be introduced into the patient. Typically the rate for an 725 * infusion e.g. 100 ml per 1 hour or 100 ml/hr. May also be expressed 726 * as a rate per unit of time e.g. 500 ml per 2 hours. Currently we do 727 * not specify a default of '1' in the denominator, but this is being 728 * discussed. Other examples: 200 mcg/min or 200 mcg/1 minute; 1 liter/8 729 * hours.) 730 */ 731 public Type getRate() { 732 return this.rate; 733 } 734 735 /** 736 * @return {@link #rate} (Identifies the speed with which the medication was or 737 * will be introduced into the patient. Typically the rate for an 738 * infusion e.g. 100 ml per 1 hour or 100 ml/hr. May also be expressed 739 * as a rate per unit of time e.g. 500 ml per 2 hours. Currently we do 740 * not specify a default of '1' in the denominator, but this is being 741 * discussed. Other examples: 200 mcg/min or 200 mcg/1 minute; 1 liter/8 742 * hours.) 743 */ 744 public Ratio getRateRatio() throws FHIRException { 745 if (!(this.rate instanceof Ratio)) 746 throw new FHIRException( 747 "Type mismatch: the type Ratio was expected, but " + this.rate.getClass().getName() + " was encountered"); 748 return (Ratio) this.rate; 749 } 750 751 public boolean hasRateRatio() { 752 return this.rate instanceof Ratio; 753 } 754 755 /** 756 * @return {@link #rate} (Identifies the speed with which the medication was or 757 * will be introduced into the patient. Typically the rate for an 758 * infusion e.g. 100 ml per 1 hour or 100 ml/hr. May also be expressed 759 * as a rate per unit of time e.g. 500 ml per 2 hours. Currently we do 760 * not specify a default of '1' in the denominator, but this is being 761 * discussed. Other examples: 200 mcg/min or 200 mcg/1 minute; 1 liter/8 762 * hours.) 763 */ 764 public Range getRateRange() throws FHIRException { 765 if (!(this.rate instanceof Range)) 766 throw new FHIRException( 767 "Type mismatch: the type Range was expected, but " + this.rate.getClass().getName() + " was encountered"); 768 return (Range) this.rate; 769 } 770 771 public boolean hasRateRange() { 772 return this.rate instanceof Range; 773 } 774 775 public boolean hasRate() { 776 return this.rate != null && !this.rate.isEmpty(); 777 } 778 779 /** 780 * @param value {@link #rate} (Identifies the speed with which the medication 781 * was or will be introduced into the patient. Typically the rate 782 * for an infusion e.g. 100 ml per 1 hour or 100 ml/hr. May also be 783 * expressed as a rate per unit of time e.g. 500 ml per 2 hours. 784 * Currently we do not specify a default of '1' in the denominator, 785 * but this is being discussed. Other examples: 200 mcg/min or 200 786 * mcg/1 minute; 1 liter/8 hours.) 787 */ 788 public MedicationOrderDosageInstructionComponent setRate(Type value) { 789 this.rate = value; 790 return this; 791 } 792 793 /** 794 * @return {@link #maxDosePerPeriod} (The maximum total quantity of a 795 * therapeutic substance that may be administered to a subject over the 796 * period of time. For example, 1000mg in 24 hours.) 797 */ 798 public Ratio getMaxDosePerPeriod() { 799 if (this.maxDosePerPeriod == null) 800 if (Configuration.errorOnAutoCreate()) 801 throw new Error("Attempt to auto-create MedicationOrderDosageInstructionComponent.maxDosePerPeriod"); 802 else if (Configuration.doAutoCreate()) 803 this.maxDosePerPeriod = new Ratio(); // cc 804 return this.maxDosePerPeriod; 805 } 806 807 public boolean hasMaxDosePerPeriod() { 808 return this.maxDosePerPeriod != null && !this.maxDosePerPeriod.isEmpty(); 809 } 810 811 /** 812 * @param value {@link #maxDosePerPeriod} (The maximum total quantity of a 813 * therapeutic substance that may be administered to a subject over 814 * the period of time. For example, 1000mg in 24 hours.) 815 */ 816 public MedicationOrderDosageInstructionComponent setMaxDosePerPeriod(Ratio value) { 817 this.maxDosePerPeriod = value; 818 return this; 819 } 820 821 protected void listChildren(List<Property> childrenList) { 822 super.listChildren(childrenList); 823 childrenList.add(new Property("text", "string", 824 "Free text dosage instructions can be used for cases where the instructions are too complex to code. The content of this attribute does not include the name or description of the medication. When coded instructions are present, the free text instructions may still be present for display to humans taking or administering the medication. It is expected that the text instructions will always be populated. If the dosage.timing attribute is also populated, then the dosage.text should reflect the same information as the timing.", 825 0, java.lang.Integer.MAX_VALUE, text)); 826 childrenList.add(new Property("additionalInstructions", "CodeableConcept", 827 "Additional instructions such as \"Swallow with plenty of water\" which may or may not be coded.", 0, 828 java.lang.Integer.MAX_VALUE, additionalInstructions)); 829 childrenList.add(new Property("timing", "Timing", 830 "The timing schedule for giving the medication to the patient. The Schedule data type allows many different expressions. For example: \"Every 8 hours\"; \"Three times a day\"; \"1/2 an hour before breakfast for 10 days from 23-Dec 2011:\"; \"15 Oct 2013, 17 Oct 2013 and 1 Nov 2013\".", 831 0, java.lang.Integer.MAX_VALUE, timing)); 832 childrenList.add(new Property("asNeeded[x]", "boolean|CodeableConcept", 833 "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).", 834 0, java.lang.Integer.MAX_VALUE, asNeeded)); 835 childrenList.add(new Property("site[x]", "CodeableConcept|Reference(BodySite)", 836 "A coded specification of the anatomic site where the medication first enters the body.", 0, 837 java.lang.Integer.MAX_VALUE, site)); 838 childrenList.add(new Property("route", "CodeableConcept", 839 "A code specifying the route or physiological path of administration of a therapeutic agent into or onto a patient's body.", 840 0, java.lang.Integer.MAX_VALUE, route)); 841 childrenList.add(new Property("method", "CodeableConcept", 842 "A coded value indicating the method by which the medication is introduced into or onto the body. Most commonly used for injections. For examples, Slow Push; Deep IV.", 843 0, java.lang.Integer.MAX_VALUE, method)); 844 childrenList.add(new Property("dose[x]", "Range|SimpleQuantity", 845 "The amount of therapeutic or other substance given at one administration event.", 0, 846 java.lang.Integer.MAX_VALUE, dose)); 847 childrenList.add(new Property("rate[x]", "Ratio|Range", 848 "Identifies the speed with which the medication was or will be introduced into the patient. Typically the rate for an infusion e.g. 100 ml per 1 hour or 100 ml/hr. May also be expressed as a rate per unit of time e.g. 500 ml per 2 hours. Currently we do not specify a default of '1' in the denominator, but this is being discussed. Other examples: 200 mcg/min or 200 mcg/1 minute; 1 liter/8 hours.", 849 0, java.lang.Integer.MAX_VALUE, rate)); 850 childrenList.add(new Property("maxDosePerPeriod", "Ratio", 851 "The maximum total quantity of a therapeutic substance that may be administered to a subject over the period of time. For example, 1000mg in 24 hours.", 852 0, java.lang.Integer.MAX_VALUE, maxDosePerPeriod)); 853 } 854 855 @Override 856 public void setProperty(String name, Base value) throws FHIRException { 857 if (name.equals("text")) 858 this.text = castToString(value); // StringType 859 else if (name.equals("additionalInstructions")) 860 this.additionalInstructions = castToCodeableConcept(value); // CodeableConcept 861 else if (name.equals("timing")) 862 this.timing = castToTiming(value); // Timing 863 else if (name.equals("asNeeded[x]")) 864 this.asNeeded = (Type) value; // Type 865 else if (name.equals("site[x]")) 866 this.site = (Type) value; // Type 867 else if (name.equals("route")) 868 this.route = castToCodeableConcept(value); // CodeableConcept 869 else if (name.equals("method")) 870 this.method = castToCodeableConcept(value); // CodeableConcept 871 else if (name.equals("dose[x]")) 872 this.dose = (Type) value; // Type 873 else if (name.equals("rate[x]")) 874 this.rate = (Type) value; // Type 875 else if (name.equals("maxDosePerPeriod")) 876 this.maxDosePerPeriod = castToRatio(value); // Ratio 877 else 878 super.setProperty(name, value); 879 } 880 881 @Override 882 public Base addChild(String name) throws FHIRException { 883 if (name.equals("text")) { 884 throw new FHIRException("Cannot call addChild on a singleton property MedicationOrder.text"); 885 } else if (name.equals("additionalInstructions")) { 886 this.additionalInstructions = new CodeableConcept(); 887 return this.additionalInstructions; 888 } else if (name.equals("timing")) { 889 this.timing = new Timing(); 890 return this.timing; 891 } else if (name.equals("asNeededBoolean")) { 892 this.asNeeded = new BooleanType(); 893 return this.asNeeded; 894 } else if (name.equals("asNeededCodeableConcept")) { 895 this.asNeeded = new CodeableConcept(); 896 return this.asNeeded; 897 } else if (name.equals("siteCodeableConcept")) { 898 this.site = new CodeableConcept(); 899 return this.site; 900 } else if (name.equals("siteReference")) { 901 this.site = new Reference(); 902 return this.site; 903 } else if (name.equals("route")) { 904 this.route = new CodeableConcept(); 905 return this.route; 906 } else if (name.equals("method")) { 907 this.method = new CodeableConcept(); 908 return this.method; 909 } else if (name.equals("doseRange")) { 910 this.dose = new Range(); 911 return this.dose; 912 } else if (name.equals("doseSimpleQuantity")) { 913 this.dose = new SimpleQuantity(); 914 return this.dose; 915 } else if (name.equals("rateRatio")) { 916 this.rate = new Ratio(); 917 return this.rate; 918 } else if (name.equals("rateRange")) { 919 this.rate = new Range(); 920 return this.rate; 921 } else if (name.equals("maxDosePerPeriod")) { 922 this.maxDosePerPeriod = new Ratio(); 923 return this.maxDosePerPeriod; 924 } else 925 return super.addChild(name); 926 } 927 928 public MedicationOrderDosageInstructionComponent copy() { 929 MedicationOrderDosageInstructionComponent dst = new MedicationOrderDosageInstructionComponent(); 930 copyValues(dst); 931 dst.text = text == null ? null : text.copy(); 932 dst.additionalInstructions = additionalInstructions == null ? null : additionalInstructions.copy(); 933 dst.timing = timing == null ? null : timing.copy(); 934 dst.asNeeded = asNeeded == null ? null : asNeeded.copy(); 935 dst.site = site == null ? null : site.copy(); 936 dst.route = route == null ? null : route.copy(); 937 dst.method = method == null ? null : method.copy(); 938 dst.dose = dose == null ? null : dose.copy(); 939 dst.rate = rate == null ? null : rate.copy(); 940 dst.maxDosePerPeriod = maxDosePerPeriod == null ? null : maxDosePerPeriod.copy(); 941 return dst; 942 } 943 944 @Override 945 public boolean equalsDeep(Base other) { 946 if (!super.equalsDeep(other)) 947 return false; 948 if (!(other instanceof MedicationOrderDosageInstructionComponent)) 949 return false; 950 MedicationOrderDosageInstructionComponent o = (MedicationOrderDosageInstructionComponent) other; 951 return compareDeep(text, o.text, true) && compareDeep(additionalInstructions, o.additionalInstructions, true) 952 && compareDeep(timing, o.timing, true) && compareDeep(asNeeded, o.asNeeded, true) 953 && compareDeep(site, o.site, true) && compareDeep(route, o.route, true) && compareDeep(method, o.method, true) 954 && compareDeep(dose, o.dose, true) && compareDeep(rate, o.rate, true) 955 && compareDeep(maxDosePerPeriod, o.maxDosePerPeriod, true); 956 } 957 958 @Override 959 public boolean equalsShallow(Base other) { 960 if (!super.equalsShallow(other)) 961 return false; 962 if (!(other instanceof MedicationOrderDosageInstructionComponent)) 963 return false; 964 MedicationOrderDosageInstructionComponent o = (MedicationOrderDosageInstructionComponent) other; 965 return compareValues(text, o.text, true); 966 } 967 968 public boolean isEmpty() { 969 return super.isEmpty() && (text == null || text.isEmpty()) 970 && (additionalInstructions == null || additionalInstructions.isEmpty()) 971 && (timing == null || timing.isEmpty()) && (asNeeded == null || asNeeded.isEmpty()) 972 && (site == null || site.isEmpty()) && (route == null || route.isEmpty()) 973 && (method == null || method.isEmpty()) && (dose == null || dose.isEmpty()) 974 && (rate == null || rate.isEmpty()) && (maxDosePerPeriod == null || maxDosePerPeriod.isEmpty()); 975 } 976 977 public String fhirType() { 978 return "MedicationOrder.dosageInstruction"; 979 980 } 981 982 } 983 984 @Block() 985 public static class MedicationOrderDispenseRequestComponent extends BackboneElement implements IBaseBackboneElement { 986 /** 987 * Identifies the medication being administered. This is a link to a resource 988 * that represents the medication which may be the details of the medication or 989 * simply an attribute carrying a code that identifies the medication from a 990 * known list of medications. 991 */ 992 @Child(name = "medication", type = { CodeableConcept.class, 993 Medication.class }, order = 1, min = 0, max = 1, modifier = false, summary = true) 994 @Description(shortDefinition = "Product to be supplied", formalDefinition = "Identifies the medication being administered. This is a link to a resource that represents the medication which may be the details of the medication or simply an attribute carrying a code that identifies the medication from a known list of medications.") 995 protected Type medication; 996 997 /** 998 * This indicates the validity period of a prescription (stale dating the 999 * Prescription). 1000 */ 1001 @Child(name = "validityPeriod", type = { 1002 Period.class }, order = 2, min = 0, max = 1, modifier = false, summary = true) 1003 @Description(shortDefinition = "Time period supply is authorized for", formalDefinition = "This indicates the validity period of a prescription (stale dating the Prescription).") 1004 protected Period validityPeriod; 1005 1006 /** 1007 * An integer indicating the number of additional times (aka refills or repeats) 1008 * the patient can receive the prescribed medication. Usage Notes: This integer 1009 * does NOT include the original order dispense. This means that if an order 1010 * indicates dispense 30 tablets plus "3 repeats", then the order can be 1011 * dispensed a total of 4 times and the patient can receive a total of 120 1012 * tablets. 1013 */ 1014 @Child(name = "numberOfRepeatsAllowed", type = { 1015 PositiveIntType.class }, order = 3, min = 0, max = 1, modifier = false, summary = true) 1016 @Description(shortDefinition = "Number of refills authorized", formalDefinition = "An integer indicating the number of additional times (aka refills or repeats) the patient can receive the prescribed medication. Usage Notes: This integer does NOT include the original order dispense. This means that if an order indicates dispense 30 tablets plus \"3 repeats\", then the order can be dispensed a total of 4 times and the patient can receive a total of 120 tablets.") 1017 protected PositiveIntType numberOfRepeatsAllowed; 1018 1019 /** 1020 * The amount that is to be dispensed for one fill. 1021 */ 1022 @Child(name = "quantity", type = { 1023 SimpleQuantity.class }, order = 4, min = 0, max = 1, modifier = false, summary = true) 1024 @Description(shortDefinition = "Amount of medication to supply per dispense", formalDefinition = "The amount that is to be dispensed for one fill.") 1025 protected SimpleQuantity quantity; 1026 1027 /** 1028 * Identifies the period time over which the supplied product is expected to be 1029 * used, or the length of time the dispense is expected to last. 1030 */ 1031 @Child(name = "expectedSupplyDuration", type = { 1032 Duration.class }, order = 5, min = 0, max = 1, modifier = false, summary = true) 1033 @Description(shortDefinition = "Number of days supply per dispense", formalDefinition = "Identifies the period time over which the supplied product is expected to be used, or the length of time the dispense is expected to last.") 1034 protected Duration expectedSupplyDuration; 1035 1036 private static final long serialVersionUID = -1690502728L; 1037 1038 /* 1039 * Constructor 1040 */ 1041 public MedicationOrderDispenseRequestComponent() { 1042 super(); 1043 } 1044 1045 /** 1046 * @return {@link #medication} (Identifies the medication being administered. 1047 * This is a link to a resource that represents the medication which may 1048 * be the details of the medication or simply an attribute carrying a 1049 * code that identifies the medication from a known list of 1050 * medications.) 1051 */ 1052 public Type getMedication() { 1053 return this.medication; 1054 } 1055 1056 /** 1057 * @return {@link #medication} (Identifies the medication being administered. 1058 * This is a link to a resource that represents the medication which may 1059 * be the details of the medication or simply an attribute carrying a 1060 * code that identifies the medication from a known list of 1061 * medications.) 1062 */ 1063 public CodeableConcept getMedicationCodeableConcept() throws FHIRException { 1064 if (!(this.medication instanceof CodeableConcept)) 1065 throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but " 1066 + this.medication.getClass().getName() + " was encountered"); 1067 return (CodeableConcept) this.medication; 1068 } 1069 1070 public boolean hasMedicationCodeableConcept() { 1071 return this.medication instanceof CodeableConcept; 1072 } 1073 1074 /** 1075 * @return {@link #medication} (Identifies the medication being administered. 1076 * This is a link to a resource that represents the medication which may 1077 * be the details of the medication or simply an attribute carrying a 1078 * code that identifies the medication from a known list of 1079 * medications.) 1080 */ 1081 public Reference getMedicationReference() throws FHIRException { 1082 if (!(this.medication instanceof Reference)) 1083 throw new FHIRException("Type mismatch: the type Reference was expected, but " 1084 + this.medication.getClass().getName() + " was encountered"); 1085 return (Reference) this.medication; 1086 } 1087 1088 public boolean hasMedicationReference() { 1089 return this.medication instanceof Reference; 1090 } 1091 1092 public boolean hasMedication() { 1093 return this.medication != null && !this.medication.isEmpty(); 1094 } 1095 1096 /** 1097 * @param value {@link #medication} (Identifies the medication being 1098 * administered. This is a link to a resource that represents the 1099 * medication which may be the details of the medication or simply 1100 * an attribute carrying a code that identifies the medication from 1101 * a known list of medications.) 1102 */ 1103 public MedicationOrderDispenseRequestComponent setMedication(Type value) { 1104 this.medication = value; 1105 return this; 1106 } 1107 1108 /** 1109 * @return {@link #validityPeriod} (This indicates the validity period of a 1110 * prescription (stale dating the Prescription).) 1111 */ 1112 public Period getValidityPeriod() { 1113 if (this.validityPeriod == null) 1114 if (Configuration.errorOnAutoCreate()) 1115 throw new Error("Attempt to auto-create MedicationOrderDispenseRequestComponent.validityPeriod"); 1116 else if (Configuration.doAutoCreate()) 1117 this.validityPeriod = new Period(); // cc 1118 return this.validityPeriod; 1119 } 1120 1121 public boolean hasValidityPeriod() { 1122 return this.validityPeriod != null && !this.validityPeriod.isEmpty(); 1123 } 1124 1125 /** 1126 * @param value {@link #validityPeriod} (This indicates the validity period of a 1127 * prescription (stale dating the Prescription).) 1128 */ 1129 public MedicationOrderDispenseRequestComponent setValidityPeriod(Period value) { 1130 this.validityPeriod = value; 1131 return this; 1132 } 1133 1134 /** 1135 * @return {@link #numberOfRepeatsAllowed} (An integer indicating the number of 1136 * additional times (aka refills or repeats) the patient can receive the 1137 * prescribed medication. Usage Notes: This integer does NOT include the 1138 * original order dispense. This means that if an order indicates 1139 * dispense 30 tablets plus "3 repeats", then the order can be dispensed 1140 * a total of 4 times and the patient can receive a total of 120 1141 * tablets.). This is the underlying object with id, value and 1142 * extensions. The accessor "getNumberOfRepeatsAllowed" gives direct 1143 * access to the value 1144 */ 1145 public PositiveIntType getNumberOfRepeatsAllowedElement() { 1146 if (this.numberOfRepeatsAllowed == null) 1147 if (Configuration.errorOnAutoCreate()) 1148 throw new Error("Attempt to auto-create MedicationOrderDispenseRequestComponent.numberOfRepeatsAllowed"); 1149 else if (Configuration.doAutoCreate()) 1150 this.numberOfRepeatsAllowed = new PositiveIntType(); // bb 1151 return this.numberOfRepeatsAllowed; 1152 } 1153 1154 public boolean hasNumberOfRepeatsAllowedElement() { 1155 return this.numberOfRepeatsAllowed != null && !this.numberOfRepeatsAllowed.isEmpty(); 1156 } 1157 1158 public boolean hasNumberOfRepeatsAllowed() { 1159 return this.numberOfRepeatsAllowed != null && !this.numberOfRepeatsAllowed.isEmpty(); 1160 } 1161 1162 /** 1163 * @param value {@link #numberOfRepeatsAllowed} (An integer indicating the 1164 * number of additional times (aka refills or repeats) the patient 1165 * can receive the prescribed medication. Usage Notes: This integer 1166 * does NOT include the original order dispense. This means that if 1167 * an order indicates dispense 30 tablets plus "3 repeats", then 1168 * the order can be dispensed a total of 4 times and the patient 1169 * can receive a total of 120 tablets.). This is the underlying 1170 * object with id, value and extensions. The accessor 1171 * "getNumberOfRepeatsAllowed" gives direct access to the value 1172 */ 1173 public MedicationOrderDispenseRequestComponent setNumberOfRepeatsAllowedElement(PositiveIntType value) { 1174 this.numberOfRepeatsAllowed = value; 1175 return this; 1176 } 1177 1178 /** 1179 * @return An integer indicating the number of additional times (aka refills or 1180 * repeats) the patient can receive the prescribed medication. Usage 1181 * Notes: This integer does NOT include the original order dispense. 1182 * This means that if an order indicates dispense 30 tablets plus "3 1183 * repeats", then the order can be dispensed a total of 4 times and the 1184 * patient can receive a total of 120 tablets. 1185 */ 1186 public int getNumberOfRepeatsAllowed() { 1187 return this.numberOfRepeatsAllowed == null || this.numberOfRepeatsAllowed.isEmpty() ? 0 1188 : this.numberOfRepeatsAllowed.getValue(); 1189 } 1190 1191 /** 1192 * @param value An integer indicating the number of additional times (aka 1193 * refills or repeats) the patient can receive the prescribed 1194 * medication. Usage Notes: This integer does NOT include the 1195 * original order dispense. This means that if an order indicates 1196 * dispense 30 tablets plus "3 repeats", then the order can be 1197 * dispensed a total of 4 times and the patient can receive a total 1198 * of 120 tablets. 1199 */ 1200 public MedicationOrderDispenseRequestComponent setNumberOfRepeatsAllowed(int value) { 1201 if (this.numberOfRepeatsAllowed == null) 1202 this.numberOfRepeatsAllowed = new PositiveIntType(); 1203 this.numberOfRepeatsAllowed.setValue(value); 1204 return this; 1205 } 1206 1207 /** 1208 * @return {@link #quantity} (The amount that is to be dispensed for one fill.) 1209 */ 1210 public SimpleQuantity getQuantity() { 1211 if (this.quantity == null) 1212 if (Configuration.errorOnAutoCreate()) 1213 throw new Error("Attempt to auto-create MedicationOrderDispenseRequestComponent.quantity"); 1214 else if (Configuration.doAutoCreate()) 1215 this.quantity = new SimpleQuantity(); // cc 1216 return this.quantity; 1217 } 1218 1219 public boolean hasQuantity() { 1220 return this.quantity != null && !this.quantity.isEmpty(); 1221 } 1222 1223 /** 1224 * @param value {@link #quantity} (The amount that is to be dispensed for one 1225 * fill.) 1226 */ 1227 public MedicationOrderDispenseRequestComponent setQuantity(SimpleQuantity value) { 1228 this.quantity = value; 1229 return this; 1230 } 1231 1232 /** 1233 * @return {@link #expectedSupplyDuration} (Identifies the period time over 1234 * which the supplied product is expected to be used, or the length of 1235 * time the dispense is expected to last.) 1236 */ 1237 public Duration getExpectedSupplyDuration() { 1238 if (this.expectedSupplyDuration == null) 1239 if (Configuration.errorOnAutoCreate()) 1240 throw new Error("Attempt to auto-create MedicationOrderDispenseRequestComponent.expectedSupplyDuration"); 1241 else if (Configuration.doAutoCreate()) 1242 this.expectedSupplyDuration = new Duration(); // cc 1243 return this.expectedSupplyDuration; 1244 } 1245 1246 public boolean hasExpectedSupplyDuration() { 1247 return this.expectedSupplyDuration != null && !this.expectedSupplyDuration.isEmpty(); 1248 } 1249 1250 /** 1251 * @param value {@link #expectedSupplyDuration} (Identifies the period time over 1252 * which the supplied product is expected to be used, or the length 1253 * of time the dispense is expected to last.) 1254 */ 1255 public MedicationOrderDispenseRequestComponent setExpectedSupplyDuration(Duration value) { 1256 this.expectedSupplyDuration = value; 1257 return this; 1258 } 1259 1260 protected void listChildren(List<Property> childrenList) { 1261 super.listChildren(childrenList); 1262 childrenList.add(new Property("medication[x]", "CodeableConcept|Reference(Medication)", 1263 "Identifies the medication being administered. This is a link to a resource that represents the medication which may be the details of the medication or simply an attribute carrying a code that identifies the medication from a known list of medications.", 1264 0, java.lang.Integer.MAX_VALUE, medication)); 1265 childrenList.add(new Property("validityPeriod", "Period", 1266 "This indicates the validity period of a prescription (stale dating the Prescription).", 0, 1267 java.lang.Integer.MAX_VALUE, validityPeriod)); 1268 childrenList.add(new Property("numberOfRepeatsAllowed", "positiveInt", 1269 "An integer indicating the number of additional times (aka refills or repeats) the patient can receive the prescribed medication. Usage Notes: This integer does NOT include the original order dispense. This means that if an order indicates dispense 30 tablets plus \"3 repeats\", then the order can be dispensed a total of 4 times and the patient can receive a total of 120 tablets.", 1270 0, java.lang.Integer.MAX_VALUE, numberOfRepeatsAllowed)); 1271 childrenList.add(new Property("quantity", "SimpleQuantity", "The amount that is to be dispensed for one fill.", 0, 1272 java.lang.Integer.MAX_VALUE, quantity)); 1273 childrenList.add(new Property("expectedSupplyDuration", "Duration", 1274 "Identifies the period time over which the supplied product is expected to be used, or the length of time the dispense is expected to last.", 1275 0, java.lang.Integer.MAX_VALUE, expectedSupplyDuration)); 1276 } 1277 1278 @Override 1279 public void setProperty(String name, Base value) throws FHIRException { 1280 if (name.equals("medication[x]")) 1281 this.medication = (Type) value; // Type 1282 else if (name.equals("validityPeriod")) 1283 this.validityPeriod = castToPeriod(value); // Period 1284 else if (name.equals("numberOfRepeatsAllowed")) 1285 this.numberOfRepeatsAllowed = castToPositiveInt(value); // PositiveIntType 1286 else if (name.equals("quantity")) 1287 this.quantity = castToSimpleQuantity(value); // SimpleQuantity 1288 else if (name.equals("expectedSupplyDuration")) 1289 this.expectedSupplyDuration = castToDuration(value); // Duration 1290 else 1291 super.setProperty(name, value); 1292 } 1293 1294 @Override 1295 public Base addChild(String name) throws FHIRException { 1296 if (name.equals("medicationCodeableConcept")) { 1297 this.medication = new CodeableConcept(); 1298 return this.medication; 1299 } else if (name.equals("medicationReference")) { 1300 this.medication = new Reference(); 1301 return this.medication; 1302 } else if (name.equals("validityPeriod")) { 1303 this.validityPeriod = new Period(); 1304 return this.validityPeriod; 1305 } else if (name.equals("numberOfRepeatsAllowed")) { 1306 throw new FHIRException("Cannot call addChild on a singleton property MedicationOrder.numberOfRepeatsAllowed"); 1307 } else if (name.equals("quantity")) { 1308 this.quantity = new SimpleQuantity(); 1309 return this.quantity; 1310 } else if (name.equals("expectedSupplyDuration")) { 1311 this.expectedSupplyDuration = new Duration(); 1312 return this.expectedSupplyDuration; 1313 } else 1314 return super.addChild(name); 1315 } 1316 1317 public MedicationOrderDispenseRequestComponent copy() { 1318 MedicationOrderDispenseRequestComponent dst = new MedicationOrderDispenseRequestComponent(); 1319 copyValues(dst); 1320 dst.medication = medication == null ? null : medication.copy(); 1321 dst.validityPeriod = validityPeriod == null ? null : validityPeriod.copy(); 1322 dst.numberOfRepeatsAllowed = numberOfRepeatsAllowed == null ? null : numberOfRepeatsAllowed.copy(); 1323 dst.quantity = quantity == null ? null : quantity.copy(); 1324 dst.expectedSupplyDuration = expectedSupplyDuration == null ? null : expectedSupplyDuration.copy(); 1325 return dst; 1326 } 1327 1328 @Override 1329 public boolean equalsDeep(Base other) { 1330 if (!super.equalsDeep(other)) 1331 return false; 1332 if (!(other instanceof MedicationOrderDispenseRequestComponent)) 1333 return false; 1334 MedicationOrderDispenseRequestComponent o = (MedicationOrderDispenseRequestComponent) other; 1335 return compareDeep(medication, o.medication, true) && compareDeep(validityPeriod, o.validityPeriod, true) 1336 && compareDeep(numberOfRepeatsAllowed, o.numberOfRepeatsAllowed, true) 1337 && compareDeep(quantity, o.quantity, true) 1338 && compareDeep(expectedSupplyDuration, o.expectedSupplyDuration, true); 1339 } 1340 1341 @Override 1342 public boolean equalsShallow(Base other) { 1343 if (!super.equalsShallow(other)) 1344 return false; 1345 if (!(other instanceof MedicationOrderDispenseRequestComponent)) 1346 return false; 1347 MedicationOrderDispenseRequestComponent o = (MedicationOrderDispenseRequestComponent) other; 1348 return compareValues(numberOfRepeatsAllowed, o.numberOfRepeatsAllowed, true); 1349 } 1350 1351 public boolean isEmpty() { 1352 return super.isEmpty() && (medication == null || medication.isEmpty()) 1353 && (validityPeriod == null || validityPeriod.isEmpty()) 1354 && (numberOfRepeatsAllowed == null || numberOfRepeatsAllowed.isEmpty()) 1355 && (quantity == null || quantity.isEmpty()) 1356 && (expectedSupplyDuration == null || expectedSupplyDuration.isEmpty()); 1357 } 1358 1359 public String fhirType() { 1360 return "MedicationOrder.dispenseRequest"; 1361 1362 } 1363 1364 } 1365 1366 @Block() 1367 public static class MedicationOrderSubstitutionComponent extends BackboneElement implements IBaseBackboneElement { 1368 /** 1369 * A code signifying whether a different drug should be dispensed from what was 1370 * prescribed. 1371 */ 1372 @Child(name = "type", type = { 1373 CodeableConcept.class }, order = 1, min = 1, max = 1, modifier = false, summary = true) 1374 @Description(shortDefinition = "generic | formulary +", formalDefinition = "A code signifying whether a different drug should be dispensed from what was prescribed.") 1375 protected CodeableConcept type; 1376 1377 /** 1378 * Indicates the reason for the substitution, or why substitution must or must 1379 * not be performed. 1380 */ 1381 @Child(name = "reason", type = { 1382 CodeableConcept.class }, order = 2, min = 0, max = 1, modifier = false, summary = true) 1383 @Description(shortDefinition = "Why should (not) substitution be made", formalDefinition = "Indicates the reason for the substitution, or why substitution must or must not be performed.") 1384 protected CodeableConcept reason; 1385 1386 private static final long serialVersionUID = 1693602518L; 1387 1388 /* 1389 * Constructor 1390 */ 1391 public MedicationOrderSubstitutionComponent() { 1392 super(); 1393 } 1394 1395 /* 1396 * Constructor 1397 */ 1398 public MedicationOrderSubstitutionComponent(CodeableConcept type) { 1399 super(); 1400 this.type = type; 1401 } 1402 1403 /** 1404 * @return {@link #type} (A code signifying whether a different drug should be 1405 * dispensed from what was prescribed.) 1406 */ 1407 public CodeableConcept getType() { 1408 if (this.type == null) 1409 if (Configuration.errorOnAutoCreate()) 1410 throw new Error("Attempt to auto-create MedicationOrderSubstitutionComponent.type"); 1411 else if (Configuration.doAutoCreate()) 1412 this.type = new CodeableConcept(); // cc 1413 return this.type; 1414 } 1415 1416 public boolean hasType() { 1417 return this.type != null && !this.type.isEmpty(); 1418 } 1419 1420 /** 1421 * @param value {@link #type} (A code signifying whether a different drug should 1422 * be dispensed from what was prescribed.) 1423 */ 1424 public MedicationOrderSubstitutionComponent setType(CodeableConcept value) { 1425 this.type = value; 1426 return this; 1427 } 1428 1429 /** 1430 * @return {@link #reason} (Indicates the reason for the substitution, or why 1431 * substitution must or must not be performed.) 1432 */ 1433 public CodeableConcept getReason() { 1434 if (this.reason == null) 1435 if (Configuration.errorOnAutoCreate()) 1436 throw new Error("Attempt to auto-create MedicationOrderSubstitutionComponent.reason"); 1437 else if (Configuration.doAutoCreate()) 1438 this.reason = new CodeableConcept(); // cc 1439 return this.reason; 1440 } 1441 1442 public boolean hasReason() { 1443 return this.reason != null && !this.reason.isEmpty(); 1444 } 1445 1446 /** 1447 * @param value {@link #reason} (Indicates the reason for the substitution, or 1448 * why substitution must or must not be performed.) 1449 */ 1450 public MedicationOrderSubstitutionComponent setReason(CodeableConcept value) { 1451 this.reason = value; 1452 return this; 1453 } 1454 1455 protected void listChildren(List<Property> childrenList) { 1456 super.listChildren(childrenList); 1457 childrenList.add(new Property("type", "CodeableConcept", 1458 "A code signifying whether a different drug should be dispensed from what was prescribed.", 0, 1459 java.lang.Integer.MAX_VALUE, type)); 1460 childrenList.add(new Property("reason", "CodeableConcept", 1461 "Indicates the reason for the substitution, or why substitution must or must not be performed.", 0, 1462 java.lang.Integer.MAX_VALUE, reason)); 1463 } 1464 1465 @Override 1466 public void setProperty(String name, Base value) throws FHIRException { 1467 if (name.equals("type")) 1468 this.type = castToCodeableConcept(value); // CodeableConcept 1469 else if (name.equals("reason")) 1470 this.reason = castToCodeableConcept(value); // CodeableConcept 1471 else 1472 super.setProperty(name, value); 1473 } 1474 1475 @Override 1476 public Base addChild(String name) throws FHIRException { 1477 if (name.equals("type")) { 1478 this.type = new CodeableConcept(); 1479 return this.type; 1480 } else if (name.equals("reason")) { 1481 this.reason = new CodeableConcept(); 1482 return this.reason; 1483 } else 1484 return super.addChild(name); 1485 } 1486 1487 public MedicationOrderSubstitutionComponent copy() { 1488 MedicationOrderSubstitutionComponent dst = new MedicationOrderSubstitutionComponent(); 1489 copyValues(dst); 1490 dst.type = type == null ? null : type.copy(); 1491 dst.reason = reason == null ? null : reason.copy(); 1492 return dst; 1493 } 1494 1495 @Override 1496 public boolean equalsDeep(Base other) { 1497 if (!super.equalsDeep(other)) 1498 return false; 1499 if (!(other instanceof MedicationOrderSubstitutionComponent)) 1500 return false; 1501 MedicationOrderSubstitutionComponent o = (MedicationOrderSubstitutionComponent) other; 1502 return compareDeep(type, o.type, true) && compareDeep(reason, o.reason, true); 1503 } 1504 1505 @Override 1506 public boolean equalsShallow(Base other) { 1507 if (!super.equalsShallow(other)) 1508 return false; 1509 if (!(other instanceof MedicationOrderSubstitutionComponent)) 1510 return false; 1511 MedicationOrderSubstitutionComponent o = (MedicationOrderSubstitutionComponent) other; 1512 return true; 1513 } 1514 1515 public boolean isEmpty() { 1516 return super.isEmpty() && (type == null || type.isEmpty()) && (reason == null || reason.isEmpty()); 1517 } 1518 1519 public String fhirType() { 1520 return "MedicationOrder.substitution"; 1521 1522 } 1523 1524 } 1525 1526 /** 1527 * External identifier - one that would be used by another non-FHIR system - for 1528 * example a re-imbursement system might issue its own id for each prescription 1529 * that is created. This is particularly important where FHIR only provides part 1530 * of an entire workflow process where records have to be tracked through an 1531 * entire system. 1532 */ 1533 @Child(name = "identifier", type = { 1534 Identifier.class }, order = 0, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true) 1535 @Description(shortDefinition = "External identifier", formalDefinition = "External identifier - one that would be used by another non-FHIR system - for example a re-imbursement system might issue its own id for each prescription that is created. This is particularly important where FHIR only provides part of an entire workflow process where records have to be tracked through an entire system.") 1536 protected List<Identifier> identifier; 1537 1538 /** 1539 * The date (and perhaps time) when the prescription was written. 1540 */ 1541 @Child(name = "dateWritten", type = { 1542 DateTimeType.class }, order = 1, min = 0, max = 1, modifier = false, summary = true) 1543 @Description(shortDefinition = "When prescription was authorized", formalDefinition = "The date (and perhaps time) when the prescription was written.") 1544 protected DateTimeType dateWritten; 1545 1546 /** 1547 * A code specifying the state of the order. Generally this will be active or 1548 * completed state. 1549 */ 1550 @Child(name = "status", type = { CodeType.class }, order = 2, min = 0, max = 1, modifier = true, summary = true) 1551 @Description(shortDefinition = "active | on-hold | completed | entered-in-error | stopped | draft", formalDefinition = "A code specifying the state of the order. Generally this will be active or completed state.") 1552 protected Enumeration<MedicationOrderStatus> status; 1553 1554 /** 1555 * The date (and perhaps time) when the prescription was stopped. 1556 */ 1557 @Child(name = "dateEnded", type = { 1558 DateTimeType.class }, order = 3, min = 0, max = 1, modifier = false, summary = true) 1559 @Description(shortDefinition = "When prescription was stopped", formalDefinition = "The date (and perhaps time) when the prescription was stopped.") 1560 protected DateTimeType dateEnded; 1561 1562 /** 1563 * The reason why the prescription was stopped, if it was. 1564 */ 1565 @Child(name = "reasonEnded", type = { 1566 CodeableConcept.class }, order = 4, min = 0, max = 1, modifier = false, summary = true) 1567 @Description(shortDefinition = "Why prescription was stopped", formalDefinition = "The reason why the prescription was stopped, if it was.") 1568 protected CodeableConcept reasonEnded; 1569 1570 /** 1571 * A link to a resource representing the person to whom the medication will be 1572 * given. 1573 */ 1574 @Child(name = "patient", type = { Patient.class }, order = 5, min = 0, max = 1, modifier = false, summary = true) 1575 @Description(shortDefinition = "Who prescription is for", formalDefinition = "A link to a resource representing the person to whom the medication will be given.") 1576 protected Reference patient; 1577 1578 /** 1579 * The actual object that is the target of the reference (A link to a resource 1580 * representing the person to whom the medication will be given.) 1581 */ 1582 protected Patient patientTarget; 1583 1584 /** 1585 * The healthcare professional responsible for authorizing the prescription. 1586 */ 1587 @Child(name = "prescriber", type = { 1588 Practitioner.class }, order = 6, min = 0, max = 1, modifier = false, summary = true) 1589 @Description(shortDefinition = "Who ordered the medication(s)", formalDefinition = "The healthcare professional responsible for authorizing the prescription.") 1590 protected Reference prescriber; 1591 1592 /** 1593 * The actual object that is the target of the reference (The healthcare 1594 * professional responsible for authorizing the prescription.) 1595 */ 1596 protected Practitioner prescriberTarget; 1597 1598 /** 1599 * A link to a resource that identifies the particular occurrence of contact 1600 * between patient and health care provider. 1601 */ 1602 @Child(name = "encounter", type = { Encounter.class }, order = 7, min = 0, max = 1, modifier = false, summary = true) 1603 @Description(shortDefinition = "Created during encounter/admission/stay", formalDefinition = "A link to a resource that identifies the particular occurrence of contact between patient and health care provider.") 1604 protected Reference encounter; 1605 1606 /** 1607 * The actual object that is the target of the reference (A link to a resource 1608 * that identifies the particular occurrence of contact between patient and 1609 * health care provider.) 1610 */ 1611 protected Encounter encounterTarget; 1612 1613 /** 1614 * Can be the reason or the indication for writing the prescription. 1615 */ 1616 @Child(name = "reason", type = { CodeableConcept.class, 1617 Condition.class }, order = 8, min = 0, max = 1, modifier = false, summary = true) 1618 @Description(shortDefinition = "Reason or indication for writing the prescription", formalDefinition = "Can be the reason or the indication for writing the prescription.") 1619 protected Type reason; 1620 1621 /** 1622 * Extra information about the prescription that could not be conveyed by the 1623 * other attributes. 1624 */ 1625 @Child(name = "note", type = { StringType.class }, order = 9, min = 0, max = 1, modifier = false, summary = true) 1626 @Description(shortDefinition = "Information about the prescription", formalDefinition = "Extra information about the prescription that could not be conveyed by the other attributes.") 1627 protected StringType note; 1628 1629 /** 1630 * Identifies the medication being administered. This is a link to a resource 1631 * that represents the medication which may be the details of the medication or 1632 * simply an attribute carrying a code that identifies the medication from a 1633 * known list of medications. 1634 */ 1635 @Child(name = "medication", type = { CodeableConcept.class, 1636 Medication.class }, order = 10, min = 1, max = 1, modifier = false, summary = true) 1637 @Description(shortDefinition = "Medication to be taken", formalDefinition = "Identifies the medication being administered. This is a link to a resource that represents the medication which may be the details of the medication or simply an attribute carrying a code that identifies the medication from a known list of medications.") 1638 protected Type medication; 1639 1640 /** 1641 * Indicates how the medication is to be used by the patient. 1642 */ 1643 @Child(name = "dosageInstruction", type = {}, order = 11, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true) 1644 @Description(shortDefinition = "How medication should be taken", formalDefinition = "Indicates how the medication is to be used by the patient.") 1645 protected List<MedicationOrderDosageInstructionComponent> dosageInstruction; 1646 1647 /** 1648 * Indicates the specific details for the dispense or medication supply part of 1649 * a medication order (also known as a Medication Prescription). Note that this 1650 * information is NOT always sent with the order. There may be in some settings 1651 * (e.g. hospitals) institutional or system support for completing the dispense 1652 * details in the pharmacy department. 1653 */ 1654 @Child(name = "dispenseRequest", type = {}, order = 12, min = 0, max = 1, modifier = false, summary = true) 1655 @Description(shortDefinition = "Medication supply authorization", formalDefinition = "Indicates the specific details for the dispense or medication supply part of a medication order (also known as a Medication Prescription). Note that this information is NOT always sent with the order. There may be in some settings (e.g. hospitals) institutional or system support for completing the dispense details in the pharmacy department.") 1656 protected MedicationOrderDispenseRequestComponent dispenseRequest; 1657 1658 /** 1659 * Indicates whether or not substitution can or should be part of the dispense. 1660 * In some cases substitution must happen, in other cases substitution must not 1661 * happen, and in others it does not matter. This block explains the 1662 * prescriber's intent. If nothing is specified substitution may be done. 1663 */ 1664 @Child(name = "substitution", type = {}, order = 13, min = 0, max = 1, modifier = false, summary = true) 1665 @Description(shortDefinition = "Any restrictions on medication substitution", formalDefinition = "Indicates whether or not substitution can or should be part of the dispense. In some cases substitution must happen, in other cases substitution must not happen, and in others it does not matter. This block explains the prescriber's intent. If nothing is specified substitution may be done.") 1666 protected MedicationOrderSubstitutionComponent substitution; 1667 1668 /** 1669 * A link to a resource representing an earlier order or prescription that this 1670 * order supersedes. 1671 */ 1672 @Child(name = "priorPrescription", type = { 1673 MedicationOrder.class }, order = 14, min = 0, max = 1, modifier = false, summary = true) 1674 @Description(shortDefinition = "An order/prescription that this supersedes", formalDefinition = "A link to a resource representing an earlier order or prescription that this order supersedes.") 1675 protected Reference priorPrescription; 1676 1677 /** 1678 * The actual object that is the target of the reference (A link to a resource 1679 * representing an earlier order or prescription that this order supersedes.) 1680 */ 1681 protected MedicationOrder priorPrescriptionTarget; 1682 1683 private static final long serialVersionUID = 619326051L; 1684 1685 /* 1686 * Constructor 1687 */ 1688 public MedicationOrder() { 1689 super(); 1690 } 1691 1692 /* 1693 * Constructor 1694 */ 1695 public MedicationOrder(Type medication) { 1696 super(); 1697 this.medication = medication; 1698 } 1699 1700 /** 1701 * @return {@link #identifier} (External identifier - one that would be used by 1702 * another non-FHIR system - for example a re-imbursement system might 1703 * issue its own id for each prescription that is created. This is 1704 * particularly important where FHIR only provides part of an entire 1705 * workflow process where records have to be tracked through an entire 1706 * system.) 1707 */ 1708 public List<Identifier> getIdentifier() { 1709 if (this.identifier == null) 1710 this.identifier = new ArrayList<Identifier>(); 1711 return this.identifier; 1712 } 1713 1714 public boolean hasIdentifier() { 1715 if (this.identifier == null) 1716 return false; 1717 for (Identifier item : this.identifier) 1718 if (!item.isEmpty()) 1719 return true; 1720 return false; 1721 } 1722 1723 /** 1724 * @return {@link #identifier} (External identifier - one that would be used by 1725 * another non-FHIR system - for example a re-imbursement system might 1726 * issue its own id for each prescription that is created. This is 1727 * particularly important where FHIR only provides part of an entire 1728 * workflow process where records have to be tracked through an entire 1729 * system.) 1730 */ 1731 // syntactic sugar 1732 public Identifier addIdentifier() { // 3 1733 Identifier t = new Identifier(); 1734 if (this.identifier == null) 1735 this.identifier = new ArrayList<Identifier>(); 1736 this.identifier.add(t); 1737 return t; 1738 } 1739 1740 // syntactic sugar 1741 public MedicationOrder addIdentifier(Identifier t) { // 3 1742 if (t == null) 1743 return this; 1744 if (this.identifier == null) 1745 this.identifier = new ArrayList<Identifier>(); 1746 this.identifier.add(t); 1747 return this; 1748 } 1749 1750 /** 1751 * @return {@link #dateWritten} (The date (and perhaps time) when the 1752 * prescription was written.). This is the underlying object with id, 1753 * value and extensions. The accessor "getDateWritten" gives direct 1754 * access to the value 1755 */ 1756 public DateTimeType getDateWrittenElement() { 1757 if (this.dateWritten == null) 1758 if (Configuration.errorOnAutoCreate()) 1759 throw new Error("Attempt to auto-create MedicationOrder.dateWritten"); 1760 else if (Configuration.doAutoCreate()) 1761 this.dateWritten = new DateTimeType(); // bb 1762 return this.dateWritten; 1763 } 1764 1765 public boolean hasDateWrittenElement() { 1766 return this.dateWritten != null && !this.dateWritten.isEmpty(); 1767 } 1768 1769 public boolean hasDateWritten() { 1770 return this.dateWritten != null && !this.dateWritten.isEmpty(); 1771 } 1772 1773 /** 1774 * @param value {@link #dateWritten} (The date (and perhaps time) when the 1775 * prescription was written.). This is the underlying object with 1776 * id, value and extensions. The accessor "getDateWritten" gives 1777 * direct access to the value 1778 */ 1779 public MedicationOrder setDateWrittenElement(DateTimeType value) { 1780 this.dateWritten = value; 1781 return this; 1782 } 1783 1784 /** 1785 * @return The date (and perhaps time) when the prescription was written. 1786 */ 1787 public Date getDateWritten() { 1788 return this.dateWritten == null ? null : this.dateWritten.getValue(); 1789 } 1790 1791 /** 1792 * @param value The date (and perhaps time) when the prescription was written. 1793 */ 1794 public MedicationOrder setDateWritten(Date value) { 1795 if (value == null) 1796 this.dateWritten = null; 1797 else { 1798 if (this.dateWritten == null) 1799 this.dateWritten = new DateTimeType(); 1800 this.dateWritten.setValue(value); 1801 } 1802 return this; 1803 } 1804 1805 /** 1806 * @return {@link #status} (A code specifying the state of the order. Generally 1807 * this will be active or completed state.). This is the underlying 1808 * object with id, value and extensions. The accessor "getStatus" gives 1809 * direct access to the value 1810 */ 1811 public Enumeration<MedicationOrderStatus> getStatusElement() { 1812 if (this.status == null) 1813 if (Configuration.errorOnAutoCreate()) 1814 throw new Error("Attempt to auto-create MedicationOrder.status"); 1815 else if (Configuration.doAutoCreate()) 1816 this.status = new Enumeration<MedicationOrderStatus>(new MedicationOrderStatusEnumFactory()); // bb 1817 return this.status; 1818 } 1819 1820 public boolean hasStatusElement() { 1821 return this.status != null && !this.status.isEmpty(); 1822 } 1823 1824 public boolean hasStatus() { 1825 return this.status != null && !this.status.isEmpty(); 1826 } 1827 1828 /** 1829 * @param value {@link #status} (A code specifying the state of the order. 1830 * Generally this will be active or completed state.). This is the 1831 * underlying object with id, value and extensions. The accessor 1832 * "getStatus" gives direct access to the value 1833 */ 1834 public MedicationOrder setStatusElement(Enumeration<MedicationOrderStatus> value) { 1835 this.status = value; 1836 return this; 1837 } 1838 1839 /** 1840 * @return A code specifying the state of the order. Generally this will be 1841 * active or completed state. 1842 */ 1843 public MedicationOrderStatus getStatus() { 1844 return this.status == null ? null : this.status.getValue(); 1845 } 1846 1847 /** 1848 * @param value A code specifying the state of the order. Generally this will be 1849 * active or completed state. 1850 */ 1851 public MedicationOrder setStatus(MedicationOrderStatus value) { 1852 if (value == null) 1853 this.status = null; 1854 else { 1855 if (this.status == null) 1856 this.status = new Enumeration<MedicationOrderStatus>(new MedicationOrderStatusEnumFactory()); 1857 this.status.setValue(value); 1858 } 1859 return this; 1860 } 1861 1862 /** 1863 * @return {@link #dateEnded} (The date (and perhaps time) when the prescription 1864 * was stopped.). This is the underlying object with id, value and 1865 * extensions. The accessor "getDateEnded" gives direct access to the 1866 * value 1867 */ 1868 public DateTimeType getDateEndedElement() { 1869 if (this.dateEnded == null) 1870 if (Configuration.errorOnAutoCreate()) 1871 throw new Error("Attempt to auto-create MedicationOrder.dateEnded"); 1872 else if (Configuration.doAutoCreate()) 1873 this.dateEnded = new DateTimeType(); // bb 1874 return this.dateEnded; 1875 } 1876 1877 public boolean hasDateEndedElement() { 1878 return this.dateEnded != null && !this.dateEnded.isEmpty(); 1879 } 1880 1881 public boolean hasDateEnded() { 1882 return this.dateEnded != null && !this.dateEnded.isEmpty(); 1883 } 1884 1885 /** 1886 * @param value {@link #dateEnded} (The date (and perhaps time) when the 1887 * prescription was stopped.). This is the underlying object with 1888 * id, value and extensions. The accessor "getDateEnded" gives 1889 * direct access to the value 1890 */ 1891 public MedicationOrder setDateEndedElement(DateTimeType value) { 1892 this.dateEnded = value; 1893 return this; 1894 } 1895 1896 /** 1897 * @return The date (and perhaps time) when the prescription was stopped. 1898 */ 1899 public Date getDateEnded() { 1900 return this.dateEnded == null ? null : this.dateEnded.getValue(); 1901 } 1902 1903 /** 1904 * @param value The date (and perhaps time) when the prescription was stopped. 1905 */ 1906 public MedicationOrder setDateEnded(Date value) { 1907 if (value == null) 1908 this.dateEnded = null; 1909 else { 1910 if (this.dateEnded == null) 1911 this.dateEnded = new DateTimeType(); 1912 this.dateEnded.setValue(value); 1913 } 1914 return this; 1915 } 1916 1917 /** 1918 * @return {@link #reasonEnded} (The reason why the prescription was stopped, if 1919 * it was.) 1920 */ 1921 public CodeableConcept getReasonEnded() { 1922 if (this.reasonEnded == null) 1923 if (Configuration.errorOnAutoCreate()) 1924 throw new Error("Attempt to auto-create MedicationOrder.reasonEnded"); 1925 else if (Configuration.doAutoCreate()) 1926 this.reasonEnded = new CodeableConcept(); // cc 1927 return this.reasonEnded; 1928 } 1929 1930 public boolean hasReasonEnded() { 1931 return this.reasonEnded != null && !this.reasonEnded.isEmpty(); 1932 } 1933 1934 /** 1935 * @param value {@link #reasonEnded} (The reason why the prescription was 1936 * stopped, if it was.) 1937 */ 1938 public MedicationOrder setReasonEnded(CodeableConcept value) { 1939 this.reasonEnded = value; 1940 return this; 1941 } 1942 1943 /** 1944 * @return {@link #patient} (A link to a resource representing the person to 1945 * whom the medication will be given.) 1946 */ 1947 public Reference getPatient() { 1948 if (this.patient == null) 1949 if (Configuration.errorOnAutoCreate()) 1950 throw new Error("Attempt to auto-create MedicationOrder.patient"); 1951 else if (Configuration.doAutoCreate()) 1952 this.patient = new Reference(); // cc 1953 return this.patient; 1954 } 1955 1956 public boolean hasPatient() { 1957 return this.patient != null && !this.patient.isEmpty(); 1958 } 1959 1960 /** 1961 * @param value {@link #patient} (A link to a resource representing the person 1962 * to whom the medication will be given.) 1963 */ 1964 public MedicationOrder setPatient(Reference value) { 1965 this.patient = value; 1966 return this; 1967 } 1968 1969 /** 1970 * @return {@link #patient} The actual object that is the target of the 1971 * reference. The reference library doesn't populate this, but you can 1972 * use it to hold the resource if you resolve it. (A link to a resource 1973 * representing the person to whom the medication will be given.) 1974 */ 1975 public Patient getPatientTarget() { 1976 if (this.patientTarget == null) 1977 if (Configuration.errorOnAutoCreate()) 1978 throw new Error("Attempt to auto-create MedicationOrder.patient"); 1979 else if (Configuration.doAutoCreate()) 1980 this.patientTarget = new Patient(); // aa 1981 return this.patientTarget; 1982 } 1983 1984 /** 1985 * @param value {@link #patient} The actual object that is the target of the 1986 * reference. The reference library doesn't use these, but you can 1987 * use it to hold the resource if you resolve it. (A link to a 1988 * resource representing the person to whom the medication will be 1989 * given.) 1990 */ 1991 public MedicationOrder setPatientTarget(Patient value) { 1992 this.patientTarget = value; 1993 return this; 1994 } 1995 1996 /** 1997 * @return {@link #prescriber} (The healthcare professional responsible for 1998 * authorizing the prescription.) 1999 */ 2000 public Reference getPrescriber() { 2001 if (this.prescriber == null) 2002 if (Configuration.errorOnAutoCreate()) 2003 throw new Error("Attempt to auto-create MedicationOrder.prescriber"); 2004 else if (Configuration.doAutoCreate()) 2005 this.prescriber = new Reference(); // cc 2006 return this.prescriber; 2007 } 2008 2009 public boolean hasPrescriber() { 2010 return this.prescriber != null && !this.prescriber.isEmpty(); 2011 } 2012 2013 /** 2014 * @param value {@link #prescriber} (The healthcare professional responsible for 2015 * authorizing the prescription.) 2016 */ 2017 public MedicationOrder setPrescriber(Reference value) { 2018 this.prescriber = value; 2019 return this; 2020 } 2021 2022 /** 2023 * @return {@link #prescriber} The actual object that is the target of the 2024 * reference. The reference library doesn't populate this, but you can 2025 * use it to hold the resource if you resolve it. (The healthcare 2026 * professional responsible for authorizing the prescription.) 2027 */ 2028 public Practitioner getPrescriberTarget() { 2029 if (this.prescriberTarget == null) 2030 if (Configuration.errorOnAutoCreate()) 2031 throw new Error("Attempt to auto-create MedicationOrder.prescriber"); 2032 else if (Configuration.doAutoCreate()) 2033 this.prescriberTarget = new Practitioner(); // aa 2034 return this.prescriberTarget; 2035 } 2036 2037 /** 2038 * @param value {@link #prescriber} The actual object that is the target of the 2039 * reference. The reference library doesn't use these, but you can 2040 * use it to hold the resource if you resolve it. (The healthcare 2041 * professional responsible for authorizing the prescription.) 2042 */ 2043 public MedicationOrder setPrescriberTarget(Practitioner value) { 2044 this.prescriberTarget = value; 2045 return this; 2046 } 2047 2048 /** 2049 * @return {@link #encounter} (A link to a resource that identifies the 2050 * particular occurrence of contact between patient and health care 2051 * provider.) 2052 */ 2053 public Reference getEncounter() { 2054 if (this.encounter == null) 2055 if (Configuration.errorOnAutoCreate()) 2056 throw new Error("Attempt to auto-create MedicationOrder.encounter"); 2057 else if (Configuration.doAutoCreate()) 2058 this.encounter = new Reference(); // cc 2059 return this.encounter; 2060 } 2061 2062 public boolean hasEncounter() { 2063 return this.encounter != null && !this.encounter.isEmpty(); 2064 } 2065 2066 /** 2067 * @param value {@link #encounter} (A link to a resource that identifies the 2068 * particular occurrence of contact between patient and health care 2069 * provider.) 2070 */ 2071 public MedicationOrder setEncounter(Reference value) { 2072 this.encounter = value; 2073 return this; 2074 } 2075 2076 /** 2077 * @return {@link #encounter} The actual object that is the target of the 2078 * reference. The reference library doesn't populate this, but you can 2079 * use it to hold the resource if you resolve it. (A link to a resource 2080 * that identifies the particular occurrence of contact between patient 2081 * and health care provider.) 2082 */ 2083 public Encounter getEncounterTarget() { 2084 if (this.encounterTarget == null) 2085 if (Configuration.errorOnAutoCreate()) 2086 throw new Error("Attempt to auto-create MedicationOrder.encounter"); 2087 else if (Configuration.doAutoCreate()) 2088 this.encounterTarget = new Encounter(); // aa 2089 return this.encounterTarget; 2090 } 2091 2092 /** 2093 * @param value {@link #encounter} The actual object that is the target of the 2094 * reference. The reference library doesn't use these, but you can 2095 * use it to hold the resource if you resolve it. (A link to a 2096 * resource that identifies the particular occurrence of contact 2097 * between patient and health care provider.) 2098 */ 2099 public MedicationOrder setEncounterTarget(Encounter value) { 2100 this.encounterTarget = value; 2101 return this; 2102 } 2103 2104 /** 2105 * @return {@link #reason} (Can be the reason or the indication for writing the 2106 * prescription.) 2107 */ 2108 public Type getReason() { 2109 return this.reason; 2110 } 2111 2112 /** 2113 * @return {@link #reason} (Can be the reason or the indication for writing the 2114 * prescription.) 2115 */ 2116 public CodeableConcept getReasonCodeableConcept() throws FHIRException { 2117 if (!(this.reason instanceof CodeableConcept)) 2118 throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but " 2119 + this.reason.getClass().getName() + " was encountered"); 2120 return (CodeableConcept) this.reason; 2121 } 2122 2123 public boolean hasReasonCodeableConcept() { 2124 return this.reason instanceof CodeableConcept; 2125 } 2126 2127 /** 2128 * @return {@link #reason} (Can be the reason or the indication for writing the 2129 * prescription.) 2130 */ 2131 public Reference getReasonReference() throws FHIRException { 2132 if (!(this.reason instanceof Reference)) 2133 throw new FHIRException("Type mismatch: the type Reference was expected, but " + this.reason.getClass().getName() 2134 + " was encountered"); 2135 return (Reference) this.reason; 2136 } 2137 2138 public boolean hasReasonReference() { 2139 return this.reason instanceof Reference; 2140 } 2141 2142 public boolean hasReason() { 2143 return this.reason != null && !this.reason.isEmpty(); 2144 } 2145 2146 /** 2147 * @param value {@link #reason} (Can be the reason or the indication for writing 2148 * the prescription.) 2149 */ 2150 public MedicationOrder setReason(Type value) { 2151 this.reason = value; 2152 return this; 2153 } 2154 2155 /** 2156 * @return {@link #note} (Extra information about the prescription that could 2157 * not be conveyed by the other attributes.). This is the underlying 2158 * object with id, value and extensions. The accessor "getNote" gives 2159 * direct access to the value 2160 */ 2161 public StringType getNoteElement() { 2162 if (this.note == null) 2163 if (Configuration.errorOnAutoCreate()) 2164 throw new Error("Attempt to auto-create MedicationOrder.note"); 2165 else if (Configuration.doAutoCreate()) 2166 this.note = new StringType(); // bb 2167 return this.note; 2168 } 2169 2170 public boolean hasNoteElement() { 2171 return this.note != null && !this.note.isEmpty(); 2172 } 2173 2174 public boolean hasNote() { 2175 return this.note != null && !this.note.isEmpty(); 2176 } 2177 2178 /** 2179 * @param value {@link #note} (Extra information about the prescription that 2180 * could not be conveyed by the other attributes.). This is the 2181 * underlying object with id, value and extensions. The accessor 2182 * "getNote" gives direct access to the value 2183 */ 2184 public MedicationOrder setNoteElement(StringType value) { 2185 this.note = value; 2186 return this; 2187 } 2188 2189 /** 2190 * @return Extra information about the prescription that could not be conveyed 2191 * by the other attributes. 2192 */ 2193 public String getNote() { 2194 return this.note == null ? null : this.note.getValue(); 2195 } 2196 2197 /** 2198 * @param value Extra information about the prescription that could not be 2199 * conveyed by the other attributes. 2200 */ 2201 public MedicationOrder setNote(String value) { 2202 if (Utilities.noString(value)) 2203 this.note = null; 2204 else { 2205 if (this.note == null) 2206 this.note = new StringType(); 2207 this.note.setValue(value); 2208 } 2209 return this; 2210 } 2211 2212 /** 2213 * @return {@link #medication} (Identifies the medication being administered. 2214 * This is a link to a resource that represents the medication which may 2215 * be the details of the medication or simply an attribute carrying a 2216 * code that identifies the medication from a known list of 2217 * medications.) 2218 */ 2219 public Type getMedication() { 2220 return this.medication; 2221 } 2222 2223 /** 2224 * @return {@link #medication} (Identifies the medication being administered. 2225 * This is a link to a resource that represents the medication which may 2226 * be the details of the medication or simply an attribute carrying a 2227 * code that identifies the medication from a known list of 2228 * medications.) 2229 */ 2230 public CodeableConcept getMedicationCodeableConcept() throws FHIRException { 2231 if (!(this.medication instanceof CodeableConcept)) 2232 throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but " 2233 + this.medication.getClass().getName() + " was encountered"); 2234 return (CodeableConcept) this.medication; 2235 } 2236 2237 public boolean hasMedicationCodeableConcept() { 2238 return this.medication instanceof CodeableConcept; 2239 } 2240 2241 /** 2242 * @return {@link #medication} (Identifies the medication being administered. 2243 * This is a link to a resource that represents the medication which may 2244 * be the details of the medication or simply an attribute carrying a 2245 * code that identifies the medication from a known list of 2246 * medications.) 2247 */ 2248 public Reference getMedicationReference() throws FHIRException { 2249 if (!(this.medication instanceof Reference)) 2250 throw new FHIRException("Type mismatch: the type Reference was expected, but " 2251 + this.medication.getClass().getName() + " was encountered"); 2252 return (Reference) this.medication; 2253 } 2254 2255 public boolean hasMedicationReference() { 2256 return this.medication instanceof Reference; 2257 } 2258 2259 public boolean hasMedication() { 2260 return this.medication != null && !this.medication.isEmpty(); 2261 } 2262 2263 /** 2264 * @param value {@link #medication} (Identifies the medication being 2265 * administered. This is a link to a resource that represents the 2266 * medication which may be the details of the medication or simply 2267 * an attribute carrying a code that identifies the medication from 2268 * a known list of medications.) 2269 */ 2270 public MedicationOrder setMedication(Type value) { 2271 this.medication = value; 2272 return this; 2273 } 2274 2275 /** 2276 * @return {@link #dosageInstruction} (Indicates how the medication is to be 2277 * used by the patient.) 2278 */ 2279 public List<MedicationOrderDosageInstructionComponent> getDosageInstruction() { 2280 if (this.dosageInstruction == null) 2281 this.dosageInstruction = new ArrayList<MedicationOrderDosageInstructionComponent>(); 2282 return this.dosageInstruction; 2283 } 2284 2285 public boolean hasDosageInstruction() { 2286 if (this.dosageInstruction == null) 2287 return false; 2288 for (MedicationOrderDosageInstructionComponent item : this.dosageInstruction) 2289 if (!item.isEmpty()) 2290 return true; 2291 return false; 2292 } 2293 2294 /** 2295 * @return {@link #dosageInstruction} (Indicates how the medication is to be 2296 * used by the patient.) 2297 */ 2298 // syntactic sugar 2299 public MedicationOrderDosageInstructionComponent addDosageInstruction() { // 3 2300 MedicationOrderDosageInstructionComponent t = new MedicationOrderDosageInstructionComponent(); 2301 if (this.dosageInstruction == null) 2302 this.dosageInstruction = new ArrayList<MedicationOrderDosageInstructionComponent>(); 2303 this.dosageInstruction.add(t); 2304 return t; 2305 } 2306 2307 // syntactic sugar 2308 public MedicationOrder addDosageInstruction(MedicationOrderDosageInstructionComponent t) { // 3 2309 if (t == null) 2310 return this; 2311 if (this.dosageInstruction == null) 2312 this.dosageInstruction = new ArrayList<MedicationOrderDosageInstructionComponent>(); 2313 this.dosageInstruction.add(t); 2314 return this; 2315 } 2316 2317 /** 2318 * @return {@link #dispenseRequest} (Indicates the specific details for the 2319 * dispense or medication supply part of a medication order (also known 2320 * as a Medication Prescription). Note that this information is NOT 2321 * always sent with the order. There may be in some settings (e.g. 2322 * hospitals) institutional or system support for completing the 2323 * dispense details in the pharmacy department.) 2324 */ 2325 public MedicationOrderDispenseRequestComponent getDispenseRequest() { 2326 if (this.dispenseRequest == null) 2327 if (Configuration.errorOnAutoCreate()) 2328 throw new Error("Attempt to auto-create MedicationOrder.dispenseRequest"); 2329 else if (Configuration.doAutoCreate()) 2330 this.dispenseRequest = new MedicationOrderDispenseRequestComponent(); // cc 2331 return this.dispenseRequest; 2332 } 2333 2334 public boolean hasDispenseRequest() { 2335 return this.dispenseRequest != null && !this.dispenseRequest.isEmpty(); 2336 } 2337 2338 /** 2339 * @param value {@link #dispenseRequest} (Indicates the specific details for the 2340 * dispense or medication supply part of a medication order (also 2341 * known as a Medication Prescription). Note that this information 2342 * is NOT always sent with the order. There may be in some settings 2343 * (e.g. hospitals) institutional or system support for completing 2344 * the dispense details in the pharmacy department.) 2345 */ 2346 public MedicationOrder setDispenseRequest(MedicationOrderDispenseRequestComponent value) { 2347 this.dispenseRequest = value; 2348 return this; 2349 } 2350 2351 /** 2352 * @return {@link #substitution} (Indicates whether or not substitution can or 2353 * should be part of the dispense. In some cases substitution must 2354 * happen, in other cases substitution must not happen, and in others it 2355 * does not matter. This block explains the prescriber's intent. If 2356 * nothing is specified substitution may be done.) 2357 */ 2358 public MedicationOrderSubstitutionComponent getSubstitution() { 2359 if (this.substitution == null) 2360 if (Configuration.errorOnAutoCreate()) 2361 throw new Error("Attempt to auto-create MedicationOrder.substitution"); 2362 else if (Configuration.doAutoCreate()) 2363 this.substitution = new MedicationOrderSubstitutionComponent(); // cc 2364 return this.substitution; 2365 } 2366 2367 public boolean hasSubstitution() { 2368 return this.substitution != null && !this.substitution.isEmpty(); 2369 } 2370 2371 /** 2372 * @param value {@link #substitution} (Indicates whether or not substitution can 2373 * or should be part of the dispense. In some cases substitution 2374 * must happen, in other cases substitution must not happen, and in 2375 * others it does not matter. This block explains the prescriber's 2376 * intent. If nothing is specified substitution may be done.) 2377 */ 2378 public MedicationOrder setSubstitution(MedicationOrderSubstitutionComponent value) { 2379 this.substitution = value; 2380 return this; 2381 } 2382 2383 /** 2384 * @return {@link #priorPrescription} (A link to a resource representing an 2385 * earlier order or prescription that this order supersedes.) 2386 */ 2387 public Reference getPriorPrescription() { 2388 if (this.priorPrescription == null) 2389 if (Configuration.errorOnAutoCreate()) 2390 throw new Error("Attempt to auto-create MedicationOrder.priorPrescription"); 2391 else if (Configuration.doAutoCreate()) 2392 this.priorPrescription = new Reference(); // cc 2393 return this.priorPrescription; 2394 } 2395 2396 public boolean hasPriorPrescription() { 2397 return this.priorPrescription != null && !this.priorPrescription.isEmpty(); 2398 } 2399 2400 /** 2401 * @param value {@link #priorPrescription} (A link to a resource representing an 2402 * earlier order or prescription that this order supersedes.) 2403 */ 2404 public MedicationOrder setPriorPrescription(Reference value) { 2405 this.priorPrescription = value; 2406 return this; 2407 } 2408 2409 /** 2410 * @return {@link #priorPrescription} The actual object that is the target of 2411 * the reference. The reference library doesn't populate this, but you 2412 * can use it to hold the resource if you resolve it. (A link to a 2413 * resource representing an earlier order or prescription that this 2414 * order supersedes.) 2415 */ 2416 public MedicationOrder getPriorPrescriptionTarget() { 2417 if (this.priorPrescriptionTarget == null) 2418 if (Configuration.errorOnAutoCreate()) 2419 throw new Error("Attempt to auto-create MedicationOrder.priorPrescription"); 2420 else if (Configuration.doAutoCreate()) 2421 this.priorPrescriptionTarget = new MedicationOrder(); // aa 2422 return this.priorPrescriptionTarget; 2423 } 2424 2425 /** 2426 * @param value {@link #priorPrescription} The actual object that is the target 2427 * of the reference. The reference library doesn't use these, but 2428 * you can use it to hold the resource if you resolve it. (A link 2429 * to a resource representing an earlier order or prescription that 2430 * this order supersedes.) 2431 */ 2432 public MedicationOrder setPriorPrescriptionTarget(MedicationOrder value) { 2433 this.priorPrescriptionTarget = value; 2434 return this; 2435 } 2436 2437 protected void listChildren(List<Property> childrenList) { 2438 super.listChildren(childrenList); 2439 childrenList.add(new Property("identifier", "Identifier", 2440 "External identifier - one that would be used by another non-FHIR system - for example a re-imbursement system might issue its own id for each prescription that is created. This is particularly important where FHIR only provides part of an entire workflow process where records have to be tracked through an entire system.", 2441 0, java.lang.Integer.MAX_VALUE, identifier)); 2442 childrenList.add(new Property("dateWritten", "dateTime", 2443 "The date (and perhaps time) when the prescription was written.", 0, java.lang.Integer.MAX_VALUE, dateWritten)); 2444 childrenList.add(new Property("status", "code", 2445 "A code specifying the state of the order. Generally this will be active or completed state.", 0, 2446 java.lang.Integer.MAX_VALUE, status)); 2447 childrenList.add(new Property("dateEnded", "dateTime", 2448 "The date (and perhaps time) when the prescription was stopped.", 0, java.lang.Integer.MAX_VALUE, dateEnded)); 2449 childrenList.add(new Property("reasonEnded", "CodeableConcept", 2450 "The reason why the prescription was stopped, if it was.", 0, java.lang.Integer.MAX_VALUE, reasonEnded)); 2451 childrenList.add(new Property("patient", "Reference(Patient)", 2452 "A link to a resource representing the person to whom the medication will be given.", 0, 2453 java.lang.Integer.MAX_VALUE, patient)); 2454 childrenList.add(new Property("prescriber", "Reference(Practitioner)", 2455 "The healthcare professional responsible for authorizing the prescription.", 0, java.lang.Integer.MAX_VALUE, 2456 prescriber)); 2457 childrenList.add(new Property("encounter", "Reference(Encounter)", 2458 "A link to a resource that identifies the particular occurrence of contact between patient and health care provider.", 2459 0, java.lang.Integer.MAX_VALUE, encounter)); 2460 childrenList.add(new Property("reason[x]", "CodeableConcept|Reference(Condition)", 2461 "Can be the reason or the indication for writing the prescription.", 0, java.lang.Integer.MAX_VALUE, reason)); 2462 childrenList.add(new Property("note", "string", 2463 "Extra information about the prescription that could not be conveyed by the other attributes.", 0, 2464 java.lang.Integer.MAX_VALUE, note)); 2465 childrenList.add(new Property("medication[x]", "CodeableConcept|Reference(Medication)", 2466 "Identifies the medication being administered. This is a link to a resource that represents the medication which may be the details of the medication or simply an attribute carrying a code that identifies the medication from a known list of medications.", 2467 0, java.lang.Integer.MAX_VALUE, medication)); 2468 childrenList.add(new Property("dosageInstruction", "", "Indicates how the medication is to be used by the patient.", 2469 0, java.lang.Integer.MAX_VALUE, dosageInstruction)); 2470 childrenList.add(new Property("dispenseRequest", "", 2471 "Indicates the specific details for the dispense or medication supply part of a medication order (also known as a Medication Prescription). Note that this information is NOT always sent with the order. There may be in some settings (e.g. hospitals) institutional or system support for completing the dispense details in the pharmacy department.", 2472 0, java.lang.Integer.MAX_VALUE, dispenseRequest)); 2473 childrenList.add(new Property("substitution", "", 2474 "Indicates whether or not substitution can or should be part of the dispense. In some cases substitution must happen, in other cases substitution must not happen, and in others it does not matter. This block explains the prescriber's intent. If nothing is specified substitution may be done.", 2475 0, java.lang.Integer.MAX_VALUE, substitution)); 2476 childrenList.add(new Property("priorPrescription", "Reference(MedicationOrder)", 2477 "A link to a resource representing an earlier order or prescription that this order supersedes.", 0, 2478 java.lang.Integer.MAX_VALUE, priorPrescription)); 2479 } 2480 2481 @Override 2482 public void setProperty(String name, Base value) throws FHIRException { 2483 if (name.equals("identifier")) 2484 this.getIdentifier().add(castToIdentifier(value)); 2485 else if (name.equals("dateWritten")) 2486 this.dateWritten = castToDateTime(value); // DateTimeType 2487 else if (name.equals("status")) 2488 this.status = new MedicationOrderStatusEnumFactory().fromType(value); // Enumeration<MedicationOrderStatus> 2489 else if (name.equals("dateEnded")) 2490 this.dateEnded = castToDateTime(value); // DateTimeType 2491 else if (name.equals("reasonEnded")) 2492 this.reasonEnded = castToCodeableConcept(value); // CodeableConcept 2493 else if (name.equals("patient")) 2494 this.patient = castToReference(value); // Reference 2495 else if (name.equals("prescriber")) 2496 this.prescriber = castToReference(value); // Reference 2497 else if (name.equals("encounter")) 2498 this.encounter = castToReference(value); // Reference 2499 else if (name.equals("reason[x]")) 2500 this.reason = (Type) value; // Type 2501 else if (name.equals("note")) 2502 this.note = castToString(value); // StringType 2503 else if (name.equals("medication[x]")) 2504 this.medication = (Type) value; // Type 2505 else if (name.equals("dosageInstruction")) 2506 this.getDosageInstruction().add((MedicationOrderDosageInstructionComponent) value); 2507 else if (name.equals("dispenseRequest")) 2508 this.dispenseRequest = (MedicationOrderDispenseRequestComponent) value; // MedicationOrderDispenseRequestComponent 2509 else if (name.equals("substitution")) 2510 this.substitution = (MedicationOrderSubstitutionComponent) value; // MedicationOrderSubstitutionComponent 2511 else if (name.equals("priorPrescription")) 2512 this.priorPrescription = castToReference(value); // Reference 2513 else 2514 super.setProperty(name, value); 2515 } 2516 2517 @Override 2518 public Base addChild(String name) throws FHIRException { 2519 if (name.equals("identifier")) { 2520 return addIdentifier(); 2521 } else if (name.equals("dateWritten")) { 2522 throw new FHIRException("Cannot call addChild on a singleton property MedicationOrder.dateWritten"); 2523 } else if (name.equals("status")) { 2524 throw new FHIRException("Cannot call addChild on a singleton property MedicationOrder.status"); 2525 } else if (name.equals("dateEnded")) { 2526 throw new FHIRException("Cannot call addChild on a singleton property MedicationOrder.dateEnded"); 2527 } else if (name.equals("reasonEnded")) { 2528 this.reasonEnded = new CodeableConcept(); 2529 return this.reasonEnded; 2530 } else if (name.equals("patient")) { 2531 this.patient = new Reference(); 2532 return this.patient; 2533 } else if (name.equals("prescriber")) { 2534 this.prescriber = new Reference(); 2535 return this.prescriber; 2536 } else if (name.equals("encounter")) { 2537 this.encounter = new Reference(); 2538 return this.encounter; 2539 } else if (name.equals("reasonCodeableConcept")) { 2540 this.reason = new CodeableConcept(); 2541 return this.reason; 2542 } else if (name.equals("reasonReference")) { 2543 this.reason = new Reference(); 2544 return this.reason; 2545 } else if (name.equals("note")) { 2546 throw new FHIRException("Cannot call addChild on a singleton property MedicationOrder.note"); 2547 } else if (name.equals("medicationCodeableConcept")) { 2548 this.medication = new CodeableConcept(); 2549 return this.medication; 2550 } else if (name.equals("medicationReference")) { 2551 this.medication = new Reference(); 2552 return this.medication; 2553 } else if (name.equals("dosageInstruction")) { 2554 return addDosageInstruction(); 2555 } else if (name.equals("dispenseRequest")) { 2556 this.dispenseRequest = new MedicationOrderDispenseRequestComponent(); 2557 return this.dispenseRequest; 2558 } else if (name.equals("substitution")) { 2559 this.substitution = new MedicationOrderSubstitutionComponent(); 2560 return this.substitution; 2561 } else if (name.equals("priorPrescription")) { 2562 this.priorPrescription = new Reference(); 2563 return this.priorPrescription; 2564 } else 2565 return super.addChild(name); 2566 } 2567 2568 public String fhirType() { 2569 return "MedicationOrder"; 2570 2571 } 2572 2573 public MedicationOrder copy() { 2574 MedicationOrder dst = new MedicationOrder(); 2575 copyValues(dst); 2576 if (identifier != null) { 2577 dst.identifier = new ArrayList<Identifier>(); 2578 for (Identifier i : identifier) 2579 dst.identifier.add(i.copy()); 2580 } 2581 ; 2582 dst.dateWritten = dateWritten == null ? null : dateWritten.copy(); 2583 dst.status = status == null ? null : status.copy(); 2584 dst.dateEnded = dateEnded == null ? null : dateEnded.copy(); 2585 dst.reasonEnded = reasonEnded == null ? null : reasonEnded.copy(); 2586 dst.patient = patient == null ? null : patient.copy(); 2587 dst.prescriber = prescriber == null ? null : prescriber.copy(); 2588 dst.encounter = encounter == null ? null : encounter.copy(); 2589 dst.reason = reason == null ? null : reason.copy(); 2590 dst.note = note == null ? null : note.copy(); 2591 dst.medication = medication == null ? null : medication.copy(); 2592 if (dosageInstruction != null) { 2593 dst.dosageInstruction = new ArrayList<MedicationOrderDosageInstructionComponent>(); 2594 for (MedicationOrderDosageInstructionComponent i : dosageInstruction) 2595 dst.dosageInstruction.add(i.copy()); 2596 } 2597 ; 2598 dst.dispenseRequest = dispenseRequest == null ? null : dispenseRequest.copy(); 2599 dst.substitution = substitution == null ? null : substitution.copy(); 2600 dst.priorPrescription = priorPrescription == null ? null : priorPrescription.copy(); 2601 return dst; 2602 } 2603 2604 protected MedicationOrder typedCopy() { 2605 return copy(); 2606 } 2607 2608 @Override 2609 public boolean equalsDeep(Base other) { 2610 if (!super.equalsDeep(other)) 2611 return false; 2612 if (!(other instanceof MedicationOrder)) 2613 return false; 2614 MedicationOrder o = (MedicationOrder) other; 2615 return compareDeep(identifier, o.identifier, true) && compareDeep(dateWritten, o.dateWritten, true) 2616 && compareDeep(status, o.status, true) && compareDeep(dateEnded, o.dateEnded, true) 2617 && compareDeep(reasonEnded, o.reasonEnded, true) && compareDeep(patient, o.patient, true) 2618 && compareDeep(prescriber, o.prescriber, true) && compareDeep(encounter, o.encounter, true) 2619 && compareDeep(reason, o.reason, true) && compareDeep(note, o.note, true) 2620 && compareDeep(medication, o.medication, true) && compareDeep(dosageInstruction, o.dosageInstruction, true) 2621 && compareDeep(dispenseRequest, o.dispenseRequest, true) && compareDeep(substitution, o.substitution, true) 2622 && compareDeep(priorPrescription, o.priorPrescription, true); 2623 } 2624 2625 @Override 2626 public boolean equalsShallow(Base other) { 2627 if (!super.equalsShallow(other)) 2628 return false; 2629 if (!(other instanceof MedicationOrder)) 2630 return false; 2631 MedicationOrder o = (MedicationOrder) other; 2632 return compareValues(dateWritten, o.dateWritten, true) && compareValues(status, o.status, true) 2633 && compareValues(dateEnded, o.dateEnded, true) && compareValues(note, o.note, true); 2634 } 2635 2636 public boolean isEmpty() { 2637 return super.isEmpty() && (identifier == null || identifier.isEmpty()) 2638 && (dateWritten == null || dateWritten.isEmpty()) && (status == null || status.isEmpty()) 2639 && (dateEnded == null || dateEnded.isEmpty()) && (reasonEnded == null || reasonEnded.isEmpty()) 2640 && (patient == null || patient.isEmpty()) && (prescriber == null || prescriber.isEmpty()) 2641 && (encounter == null || encounter.isEmpty()) && (reason == null || reason.isEmpty()) 2642 && (note == null || note.isEmpty()) && (medication == null || medication.isEmpty()) 2643 && (dosageInstruction == null || dosageInstruction.isEmpty()) 2644 && (dispenseRequest == null || dispenseRequest.isEmpty()) && (substitution == null || substitution.isEmpty()) 2645 && (priorPrescription == null || priorPrescription.isEmpty()); 2646 } 2647 2648 @Override 2649 public ResourceType getResourceType() { 2650 return ResourceType.MedicationOrder; 2651 } 2652 2653 @SearchParamDefinition(name = "prescriber", path = "MedicationOrder.prescriber", description = "Who ordered the medication(s)", type = "reference") 2654 public static final String SP_PRESCRIBER = "prescriber"; 2655 @SearchParamDefinition(name = "identifier", path = "MedicationOrder.identifier", description = "Return prescriptions with this external identifier", type = "token") 2656 public static final String SP_IDENTIFIER = "identifier"; 2657 @SearchParamDefinition(name = "code", path = "MedicationOrder.medicationCodeableConcept", description = "Return administrations of this medication code", type = "token") 2658 public static final String SP_CODE = "code"; 2659 @SearchParamDefinition(name = "patient", path = "MedicationOrder.patient", description = "The identity of a patient to list orders for", type = "reference") 2660 public static final String SP_PATIENT = "patient"; 2661 @SearchParamDefinition(name = "datewritten", path = "MedicationOrder.dateWritten", description = "Return prescriptions written on this date", type = "date") 2662 public static final String SP_DATEWRITTEN = "datewritten"; 2663 @SearchParamDefinition(name = "medication", path = "MedicationOrder.medicationReference", description = "Return administrations of this medication reference", type = "reference") 2664 public static final String SP_MEDICATION = "medication"; 2665 @SearchParamDefinition(name = "encounter", path = "MedicationOrder.encounter", description = "Return prescriptions with this encounter identifier", type = "reference") 2666 public static final String SP_ENCOUNTER = "encounter"; 2667 @SearchParamDefinition(name = "status", path = "MedicationOrder.status", description = "Status of the prescription", type = "token") 2668 public static final String SP_STATUS = "status"; 2669 2670}