001package org.hl7.fhir.dstu2.model; 002 003/*- 004 * #%L 005 * org.hl7.fhir.dstu2 006 * %% 007 * Copyright (C) 2014 - 2019 Health Level 7 008 * %% 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 * #L% 021 */ 022 023 024/* 025 Copyright (c) 2011+, HL7, Inc. 026 All rights reserved. 027 028 Redistribution and use in source and binary forms, with or without modification, 029 are permitted provided that the following conditions are met: 030 031 * Redistributions of source code must retain the above copyright notice, this 032 list of conditions and the following disclaimer. 033 * Redistributions in binary form must reproduce the above copyright notice, 034 this list of conditions and the following disclaimer in the documentation 035 and/or other materials provided with the distribution. 036 * Neither the name of HL7 nor the names of its contributors may be used to 037 endorse or promote products derived from this software without specific 038 prior written permission. 039 040 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 041 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 042 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 043 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 044 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 045 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 046 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 047 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 048 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 049 POSSIBILITY OF SUCH DAMAGE. 050 051*/ 052 053// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2 054import java.util.ArrayList; 055import java.util.List; 056 057import ca.uhn.fhir.model.api.annotation.Block; 058import ca.uhn.fhir.model.api.annotation.Child; 059import ca.uhn.fhir.model.api.annotation.Description; 060import ca.uhn.fhir.model.api.annotation.ResourceDef; 061import ca.uhn.fhir.model.api.annotation.SearchParamDefinition; 062import org.hl7.fhir.instance.model.api.IBaseBackboneElement; 063import org.hl7.fhir.exceptions.FHIRException; 064import org.hl7.fhir.utilities.Utilities; 065/** 066 * Describes the event of a patient consuming or otherwise being administered a medication. This may be as simple as swallowing a tablet or it may be a long running infusion. Related resources tie this event to the authorizing prescription, and the specific encounter between patient and health care practitioner. 067 */ 068@ResourceDef(name="MedicationAdministration", profile="http://hl7.org/fhir/Profile/MedicationAdministration") 069public class MedicationAdministration extends DomainResource { 070 071 public enum MedicationAdministrationStatus { 072 /** 073 * The administration has started but has not yet completed. 074 */ 075 INPROGRESS, 076 /** 077 * Actions implied by the administration have been temporarily halted, but are expected to continue later. May also be called "suspended". 078 */ 079 ONHOLD, 080 /** 081 * All actions that are implied by the administration have occurred. 082 */ 083 COMPLETED, 084 /** 085 * The administration was entered in error and therefore nullified. 086 */ 087 ENTEREDINERROR, 088 /** 089 * Actions implied by the administration have been permanently halted, before all of them occurred. 090 */ 091 STOPPED, 092 /** 093 * added to help the parsers 094 */ 095 NULL; 096 public static MedicationAdministrationStatus fromCode(String codeString) throws FHIRException { 097 if (codeString == null || "".equals(codeString)) 098 return null; 099 if ("in-progress".equals(codeString)) 100 return INPROGRESS; 101 if ("on-hold".equals(codeString)) 102 return ONHOLD; 103 if ("completed".equals(codeString)) 104 return COMPLETED; 105 if ("entered-in-error".equals(codeString)) 106 return ENTEREDINERROR; 107 if ("stopped".equals(codeString)) 108 return STOPPED; 109 throw new FHIRException("Unknown MedicationAdministrationStatus code '"+codeString+"'"); 110 } 111 public String toCode() { 112 switch (this) { 113 case INPROGRESS: return "in-progress"; 114 case ONHOLD: return "on-hold"; 115 case COMPLETED: return "completed"; 116 case ENTEREDINERROR: return "entered-in-error"; 117 case STOPPED: return "stopped"; 118 default: return "?"; 119 } 120 } 121 public String getSystem() { 122 switch (this) { 123 case INPROGRESS: return "http://hl7.org/fhir/medication-admin-status"; 124 case ONHOLD: return "http://hl7.org/fhir/medication-admin-status"; 125 case COMPLETED: return "http://hl7.org/fhir/medication-admin-status"; 126 case ENTEREDINERROR: return "http://hl7.org/fhir/medication-admin-status"; 127 case STOPPED: return "http://hl7.org/fhir/medication-admin-status"; 128 default: return "?"; 129 } 130 } 131 public String getDefinition() { 132 switch (this) { 133 case INPROGRESS: return "The administration has started but has not yet completed."; 134 case ONHOLD: return "Actions implied by the administration have been temporarily halted, but are expected to continue later. May also be called \"suspended\"."; 135 case COMPLETED: return "All actions that are implied by the administration have occurred."; 136 case ENTEREDINERROR: return "The administration was entered in error and therefore nullified."; 137 case STOPPED: return "Actions implied by the administration have been permanently halted, before all of them occurred."; 138 default: return "?"; 139 } 140 } 141 public String getDisplay() { 142 switch (this) { 143 case INPROGRESS: return "In Progress"; 144 case ONHOLD: return "On Hold"; 145 case COMPLETED: return "Completed"; 146 case ENTEREDINERROR: return "Entered in Error"; 147 case STOPPED: return "Stopped"; 148 default: return "?"; 149 } 150 } 151 } 152 153 public static class MedicationAdministrationStatusEnumFactory implements EnumFactory<MedicationAdministrationStatus> { 154 public MedicationAdministrationStatus fromCode(String codeString) throws IllegalArgumentException { 155 if (codeString == null || "".equals(codeString)) 156 if (codeString == null || "".equals(codeString)) 157 return null; 158 if ("in-progress".equals(codeString)) 159 return MedicationAdministrationStatus.INPROGRESS; 160 if ("on-hold".equals(codeString)) 161 return MedicationAdministrationStatus.ONHOLD; 162 if ("completed".equals(codeString)) 163 return MedicationAdministrationStatus.COMPLETED; 164 if ("entered-in-error".equals(codeString)) 165 return MedicationAdministrationStatus.ENTEREDINERROR; 166 if ("stopped".equals(codeString)) 167 return MedicationAdministrationStatus.STOPPED; 168 throw new IllegalArgumentException("Unknown MedicationAdministrationStatus code '"+codeString+"'"); 169 } 170 public Enumeration<MedicationAdministrationStatus> fromType(Base code) throws FHIRException { 171 if (code == null || code.isEmpty()) 172 return null; 173 String codeString = ((PrimitiveType) code).asStringValue(); 174 if (codeString == null || "".equals(codeString)) 175 return null; 176 if ("in-progress".equals(codeString)) 177 return new Enumeration<MedicationAdministrationStatus>(this, MedicationAdministrationStatus.INPROGRESS); 178 if ("on-hold".equals(codeString)) 179 return new Enumeration<MedicationAdministrationStatus>(this, MedicationAdministrationStatus.ONHOLD); 180 if ("completed".equals(codeString)) 181 return new Enumeration<MedicationAdministrationStatus>(this, MedicationAdministrationStatus.COMPLETED); 182 if ("entered-in-error".equals(codeString)) 183 return new Enumeration<MedicationAdministrationStatus>(this, MedicationAdministrationStatus.ENTEREDINERROR); 184 if ("stopped".equals(codeString)) 185 return new Enumeration<MedicationAdministrationStatus>(this, MedicationAdministrationStatus.STOPPED); 186 throw new FHIRException("Unknown MedicationAdministrationStatus code '"+codeString+"'"); 187 } 188 public String toCode(MedicationAdministrationStatus code) { 189 if (code == MedicationAdministrationStatus.INPROGRESS) 190 return "in-progress"; 191 if (code == MedicationAdministrationStatus.ONHOLD) 192 return "on-hold"; 193 if (code == MedicationAdministrationStatus.COMPLETED) 194 return "completed"; 195 if (code == MedicationAdministrationStatus.ENTEREDINERROR) 196 return "entered-in-error"; 197 if (code == MedicationAdministrationStatus.STOPPED) 198 return "stopped"; 199 return "?"; 200 } 201 } 202 203 @Block() 204 public static class MedicationAdministrationDosageComponent extends BackboneElement implements IBaseBackboneElement { 205 /** 206 * Free text dosage instructions can be used for cases where the instructions are too complex to code. When coded instructions are present, the free text instructions may still be present for display to humans taking or administering the medication. 207 */ 208 @Child(name = "text", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true) 209 @Description(shortDefinition="Dosage Instructions", formalDefinition="Free text dosage instructions can be used for cases where the instructions are too complex to code. When coded instructions are present, the free text instructions may still be present for display to humans taking or administering the medication." ) 210 protected StringType text; 211 212 /** 213 * A coded specification of the anatomic site where the medication first entered the body. For example, "left arm". 214 */ 215 @Child(name = "site", type = {CodeableConcept.class, BodySite.class}, order=2, min=0, max=1, modifier=false, summary=true) 216 @Description(shortDefinition="Body site administered to", formalDefinition="A coded specification of the anatomic site where the medication first entered the body. For example, \"left arm\"." ) 217 protected Type site; 218 219 /** 220 * A code specifying the route or physiological path of administration of a therapeutic agent into or onto the patient. For example, topical, intravenous, etc. 221 */ 222 @Child(name = "route", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true) 223 @Description(shortDefinition="Path of substance into body", formalDefinition="A code specifying the route or physiological path of administration of a therapeutic agent into or onto the patient. For example, topical, intravenous, etc." ) 224 protected CodeableConcept route; 225 226 /** 227 * A coded value indicating the method by which the medication is intended to be or was introduced into or on the body. This attribute will most often NOT be populated. It is most commonly used for injections. For example, Slow Push, Deep IV. 228 */ 229 @Child(name = "method", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=true) 230 @Description(shortDefinition="How drug was administered", formalDefinition="A coded value indicating the method by which the medication is intended to be or was introduced into or on the body. This attribute will most often NOT be populated. It is most commonly used for injections. For example, Slow Push, Deep IV." ) 231 protected CodeableConcept method; 232 233 /** 234 * The amount of the medication given at one administration event. Use this value when the administration is essentially an instantaneous event such as a swallowing a tablet or giving an injection. 235 */ 236 @Child(name = "quantity", type = {SimpleQuantity.class}, order=5, min=0, max=1, modifier=false, summary=true) 237 @Description(shortDefinition="Amount administered in one dose", formalDefinition="The amount of the medication given at one administration event. Use this value when the administration is essentially an instantaneous event such as a swallowing a tablet or giving an injection." ) 238 protected SimpleQuantity quantity; 239 240 /** 241 * 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. 242 */ 243 @Child(name = "rate", type = {Ratio.class, Range.class}, order=6, min=0, max=1, modifier=false, summary=true) 244 @Description(shortDefinition="Dose quantity 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." ) 245 protected Type rate; 246 247 private static final long serialVersionUID = -1772198879L; 248 249 /* 250 * Constructor 251 */ 252 public MedicationAdministrationDosageComponent() { 253 super(); 254 } 255 256 /** 257 * @return {@link #text} (Free text dosage instructions can be used for cases where the instructions are too complex to code. When coded instructions are present, the free text instructions may still be present for display to humans taking or administering the medication.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value 258 */ 259 public StringType getTextElement() { 260 if (this.text == null) 261 if (Configuration.errorOnAutoCreate()) 262 throw new Error("Attempt to auto-create MedicationAdministrationDosageComponent.text"); 263 else if (Configuration.doAutoCreate()) 264 this.text = new StringType(); // bb 265 return this.text; 266 } 267 268 public boolean hasTextElement() { 269 return this.text != null && !this.text.isEmpty(); 270 } 271 272 public boolean hasText() { 273 return this.text != null && !this.text.isEmpty(); 274 } 275 276 /** 277 * @param value {@link #text} (Free text dosage instructions can be used for cases where the instructions are too complex to code. When coded instructions are present, the free text instructions may still be present for display to humans taking or administering the medication.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value 278 */ 279 public MedicationAdministrationDosageComponent setTextElement(StringType value) { 280 this.text = value; 281 return this; 282 } 283 284 /** 285 * @return Free text dosage instructions can be used for cases where the instructions are too complex to code. When coded instructions are present, the free text instructions may still be present for display to humans taking or administering the medication. 286 */ 287 public String getText() { 288 return this.text == null ? null : this.text.getValue(); 289 } 290 291 /** 292 * @param value Free text dosage instructions can be used for cases where the instructions are too complex to code. When coded instructions are present, the free text instructions may still be present for display to humans taking or administering the medication. 293 */ 294 public MedicationAdministrationDosageComponent setText(String value) { 295 if (Utilities.noString(value)) 296 this.text = null; 297 else { 298 if (this.text == null) 299 this.text = new StringType(); 300 this.text.setValue(value); 301 } 302 return this; 303 } 304 305 /** 306 * @return {@link #site} (A coded specification of the anatomic site where the medication first entered the body. For example, "left arm".) 307 */ 308 public Type getSite() { 309 return this.site; 310 } 311 312 /** 313 * @return {@link #site} (A coded specification of the anatomic site where the medication first entered the body. For example, "left arm".) 314 */ 315 public CodeableConcept getSiteCodeableConcept() throws FHIRException { 316 if (!(this.site instanceof CodeableConcept)) 317 throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.site.getClass().getName()+" was encountered"); 318 return (CodeableConcept) this.site; 319 } 320 321 public boolean hasSiteCodeableConcept() { 322 return this.site instanceof CodeableConcept; 323 } 324 325 /** 326 * @return {@link #site} (A coded specification of the anatomic site where the medication first entered the body. For example, "left arm".) 327 */ 328 public Reference getSiteReference() throws FHIRException { 329 if (!(this.site instanceof Reference)) 330 throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.site.getClass().getName()+" was encountered"); 331 return (Reference) this.site; 332 } 333 334 public boolean hasSiteReference() { 335 return this.site instanceof Reference; 336 } 337 338 public boolean hasSite() { 339 return this.site != null && !this.site.isEmpty(); 340 } 341 342 /** 343 * @param value {@link #site} (A coded specification of the anatomic site where the medication first entered the body. For example, "left arm".) 344 */ 345 public MedicationAdministrationDosageComponent setSite(Type value) { 346 this.site = value; 347 return this; 348 } 349 350 /** 351 * @return {@link #route} (A code specifying the route or physiological path of administration of a therapeutic agent into or onto the patient. For example, topical, intravenous, etc.) 352 */ 353 public CodeableConcept getRoute() { 354 if (this.route == null) 355 if (Configuration.errorOnAutoCreate()) 356 throw new Error("Attempt to auto-create MedicationAdministrationDosageComponent.route"); 357 else if (Configuration.doAutoCreate()) 358 this.route = new CodeableConcept(); // cc 359 return this.route; 360 } 361 362 public boolean hasRoute() { 363 return this.route != null && !this.route.isEmpty(); 364 } 365 366 /** 367 * @param value {@link #route} (A code specifying the route or physiological path of administration of a therapeutic agent into or onto the patient. For example, topical, intravenous, etc.) 368 */ 369 public MedicationAdministrationDosageComponent setRoute(CodeableConcept value) { 370 this.route = value; 371 return this; 372 } 373 374 /** 375 * @return {@link #method} (A coded value indicating the method by which the medication is intended to be or was introduced into or on the body. This attribute will most often NOT be populated. It is most commonly used for injections. For example, Slow Push, Deep IV.) 376 */ 377 public CodeableConcept getMethod() { 378 if (this.method == null) 379 if (Configuration.errorOnAutoCreate()) 380 throw new Error("Attempt to auto-create MedicationAdministrationDosageComponent.method"); 381 else if (Configuration.doAutoCreate()) 382 this.method = new CodeableConcept(); // cc 383 return this.method; 384 } 385 386 public boolean hasMethod() { 387 return this.method != null && !this.method.isEmpty(); 388 } 389 390 /** 391 * @param value {@link #method} (A coded value indicating the method by which the medication is intended to be or was introduced into or on the body. This attribute will most often NOT be populated. It is most commonly used for injections. For example, Slow Push, Deep IV.) 392 */ 393 public MedicationAdministrationDosageComponent setMethod(CodeableConcept value) { 394 this.method = value; 395 return this; 396 } 397 398 /** 399 * @return {@link #quantity} (The amount of the medication given at one administration event. Use this value when the administration is essentially an instantaneous event such as a swallowing a tablet or giving an injection.) 400 */ 401 public SimpleQuantity getQuantity() { 402 if (this.quantity == null) 403 if (Configuration.errorOnAutoCreate()) 404 throw new Error("Attempt to auto-create MedicationAdministrationDosageComponent.quantity"); 405 else if (Configuration.doAutoCreate()) 406 this.quantity = new SimpleQuantity(); // cc 407 return this.quantity; 408 } 409 410 public boolean hasQuantity() { 411 return this.quantity != null && !this.quantity.isEmpty(); 412 } 413 414 /** 415 * @param value {@link #quantity} (The amount of the medication given at one administration event. Use this value when the administration is essentially an instantaneous event such as a swallowing a tablet or giving an injection.) 416 */ 417 public MedicationAdministrationDosageComponent setQuantity(SimpleQuantity value) { 418 this.quantity = value; 419 return this; 420 } 421 422 /** 423 * @return {@link #rate} (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.) 424 */ 425 public Type getRate() { 426 return this.rate; 427 } 428 429 /** 430 * @return {@link #rate} (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.) 431 */ 432 public Ratio getRateRatio() throws FHIRException { 433 if (!(this.rate instanceof Ratio)) 434 throw new FHIRException("Type mismatch: the type Ratio was expected, but "+this.rate.getClass().getName()+" was encountered"); 435 return (Ratio) this.rate; 436 } 437 438 public boolean hasRateRatio() { 439 return this.rate instanceof Ratio; 440 } 441 442 /** 443 * @return {@link #rate} (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.) 444 */ 445 public Range getRateRange() throws FHIRException { 446 if (!(this.rate instanceof Range)) 447 throw new FHIRException("Type mismatch: the type Range was expected, but "+this.rate.getClass().getName()+" was encountered"); 448 return (Range) this.rate; 449 } 450 451 public boolean hasRateRange() { 452 return this.rate instanceof Range; 453 } 454 455 public boolean hasRate() { 456 return this.rate != null && !this.rate.isEmpty(); 457 } 458 459 /** 460 * @param value {@link #rate} (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.) 461 */ 462 public MedicationAdministrationDosageComponent setRate(Type value) { 463 this.rate = value; 464 return this; 465 } 466 467 protected void listChildren(List<Property> childrenList) { 468 super.listChildren(childrenList); 469 childrenList.add(new Property("text", "string", "Free text dosage instructions can be used for cases where the instructions are too complex to code. When coded instructions are present, the free text instructions may still be present for display to humans taking or administering the medication.", 0, java.lang.Integer.MAX_VALUE, text)); 470 childrenList.add(new Property("site[x]", "CodeableConcept|Reference(BodySite)", "A coded specification of the anatomic site where the medication first entered the body. For example, \"left arm\".", 0, java.lang.Integer.MAX_VALUE, site)); 471 childrenList.add(new Property("route", "CodeableConcept", "A code specifying the route or physiological path of administration of a therapeutic agent into or onto the patient. For example, topical, intravenous, etc.", 0, java.lang.Integer.MAX_VALUE, route)); 472 childrenList.add(new Property("method", "CodeableConcept", "A coded value indicating the method by which the medication is intended to be or was introduced into or on the body. This attribute will most often NOT be populated. It is most commonly used for injections. For example, Slow Push, Deep IV.", 0, java.lang.Integer.MAX_VALUE, method)); 473 childrenList.add(new Property("quantity", "SimpleQuantity", "The amount of the medication given at one administration event. Use this value when the administration is essentially an instantaneous event such as a swallowing a tablet or giving an injection.", 0, java.lang.Integer.MAX_VALUE, quantity)); 474 childrenList.add(new Property("rate[x]", "Ratio|Range", "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.", 0, java.lang.Integer.MAX_VALUE, rate)); 475 } 476 477 @Override 478 public void setProperty(String name, Base value) throws FHIRException { 479 if (name.equals("text")) 480 this.text = castToString(value); // StringType 481 else if (name.equals("site[x]")) 482 this.site = (Type) value; // Type 483 else if (name.equals("route")) 484 this.route = castToCodeableConcept(value); // CodeableConcept 485 else if (name.equals("method")) 486 this.method = castToCodeableConcept(value); // CodeableConcept 487 else if (name.equals("quantity")) 488 this.quantity = castToSimpleQuantity(value); // SimpleQuantity 489 else if (name.equals("rate[x]")) 490 this.rate = (Type) value; // Type 491 else 492 super.setProperty(name, value); 493 } 494 495 @Override 496 public Base addChild(String name) throws FHIRException { 497 if (name.equals("text")) { 498 throw new FHIRException("Cannot call addChild on a primitive type MedicationAdministration.text"); 499 } 500 else if (name.equals("siteCodeableConcept")) { 501 this.site = new CodeableConcept(); 502 return this.site; 503 } 504 else if (name.equals("siteReference")) { 505 this.site = new Reference(); 506 return this.site; 507 } 508 else if (name.equals("route")) { 509 this.route = new CodeableConcept(); 510 return this.route; 511 } 512 else if (name.equals("method")) { 513 this.method = new CodeableConcept(); 514 return this.method; 515 } 516 else if (name.equals("quantity")) { 517 this.quantity = new SimpleQuantity(); 518 return this.quantity; 519 } 520 else if (name.equals("rateRatio")) { 521 this.rate = new Ratio(); 522 return this.rate; 523 } 524 else if (name.equals("rateRange")) { 525 this.rate = new Range(); 526 return this.rate; 527 } 528 else 529 return super.addChild(name); 530 } 531 532 public MedicationAdministrationDosageComponent copy() { 533 MedicationAdministrationDosageComponent dst = new MedicationAdministrationDosageComponent(); 534 copyValues(dst); 535 dst.text = text == null ? null : text.copy(); 536 dst.site = site == null ? null : site.copy(); 537 dst.route = route == null ? null : route.copy(); 538 dst.method = method == null ? null : method.copy(); 539 dst.quantity = quantity == null ? null : quantity.copy(); 540 dst.rate = rate == null ? null : rate.copy(); 541 return dst; 542 } 543 544 @Override 545 public boolean equalsDeep(Base other) { 546 if (!super.equalsDeep(other)) 547 return false; 548 if (!(other instanceof MedicationAdministrationDosageComponent)) 549 return false; 550 MedicationAdministrationDosageComponent o = (MedicationAdministrationDosageComponent) other; 551 return compareDeep(text, o.text, true) && compareDeep(site, o.site, true) && compareDeep(route, o.route, true) 552 && compareDeep(method, o.method, true) && compareDeep(quantity, o.quantity, true) && compareDeep(rate, o.rate, true) 553 ; 554 } 555 556 @Override 557 public boolean equalsShallow(Base other) { 558 if (!super.equalsShallow(other)) 559 return false; 560 if (!(other instanceof MedicationAdministrationDosageComponent)) 561 return false; 562 MedicationAdministrationDosageComponent o = (MedicationAdministrationDosageComponent) other; 563 return compareValues(text, o.text, true); 564 } 565 566 public boolean isEmpty() { 567 return super.isEmpty() && (text == null || text.isEmpty()) && (site == null || site.isEmpty()) 568 && (route == null || route.isEmpty()) && (method == null || method.isEmpty()) && (quantity == null || quantity.isEmpty()) 569 && (rate == null || rate.isEmpty()); 570 } 571 572 public String fhirType() { 573 return "MedicationAdministration.dosage"; 574 575 } 576 577 } 578 579 /** 580 * External identifier - FHIR will generate its own internal identifiers (probably URLs) which do not need to be explicitly managed by the resource. The identifier here is one that would be used by another non-FHIR system - for example an automated medication pump would provide a record each time it operated; an administration while the patient was off the ward might be made with a different system and entered after the event. Particularly important if these records have to be updated. 581 */ 582 @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 583 @Description(shortDefinition="External identifier", formalDefinition="External identifier - FHIR will generate its own internal identifiers (probably URLs) which do not need to be explicitly managed by the resource. The identifier here is one that would be used by another non-FHIR system - for example an automated medication pump would provide a record each time it operated; an administration while the patient was off the ward might be made with a different system and entered after the event. Particularly important if these records have to be updated." ) 584 protected List<Identifier> identifier; 585 586 /** 587 * Will generally be set to show that the administration has been completed. For some long running administrations such as infusions it is possible for an administration to be started but not completed or it may be paused while some other process is under way. 588 */ 589 @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true) 590 @Description(shortDefinition="in-progress | on-hold | completed | entered-in-error | stopped", formalDefinition="Will generally be set to show that the administration has been completed. For some long running administrations such as infusions it is possible for an administration to be started but not completed or it may be paused while some other process is under way." ) 591 protected Enumeration<MedicationAdministrationStatus> status; 592 593 /** 594 * The person or animal receiving the medication. 595 */ 596 @Child(name = "patient", type = {Patient.class}, order=2, min=1, max=1, modifier=false, summary=true) 597 @Description(shortDefinition="Who received medication", formalDefinition="The person or animal receiving the medication." ) 598 protected Reference patient; 599 600 /** 601 * The actual object that is the target of the reference (The person or animal receiving the medication.) 602 */ 603 protected Patient patientTarget; 604 605 /** 606 * The individual who was responsible for giving the medication to the patient. 607 */ 608 @Child(name = "practitioner", type = {Practitioner.class, Patient.class, RelatedPerson.class}, order=3, min=0, max=1, modifier=false, summary=true) 609 @Description(shortDefinition="Who administered substance", formalDefinition="The individual who was responsible for giving the medication to the patient." ) 610 protected Reference practitioner; 611 612 /** 613 * The actual object that is the target of the reference (The individual who was responsible for giving the medication to the patient.) 614 */ 615 protected Resource practitionerTarget; 616 617 /** 618 * The visit, admission or other contact between patient and health care provider the medication administration was performed as part of. 619 */ 620 @Child(name = "encounter", type = {Encounter.class}, order=4, min=0, max=1, modifier=false, summary=true) 621 @Description(shortDefinition="Encounter administered as part of", formalDefinition="The visit, admission or other contact between patient and health care provider the medication administration was performed as part of." ) 622 protected Reference encounter; 623 624 /** 625 * The actual object that is the target of the reference (The visit, admission or other contact between patient and health care provider the medication administration was performed as part of.) 626 */ 627 protected Encounter encounterTarget; 628 629 /** 630 * The original request, instruction or authority to perform the administration. 631 */ 632 @Child(name = "prescription", type = {MedicationOrder.class}, order=5, min=0, max=1, modifier=false, summary=true) 633 @Description(shortDefinition="Order administration performed against", formalDefinition="The original request, instruction or authority to perform the administration." ) 634 protected Reference prescription; 635 636 /** 637 * The actual object that is the target of the reference (The original request, instruction or authority to perform the administration.) 638 */ 639 protected MedicationOrder prescriptionTarget; 640 641 /** 642 * Set this to true if the record is saying that the medication was NOT administered. 643 */ 644 @Child(name = "wasNotGiven", type = {BooleanType.class}, order=6, min=0, max=1, modifier=true, summary=true) 645 @Description(shortDefinition="True if medication not administered", formalDefinition="Set this to true if the record is saying that the medication was NOT administered." ) 646 protected BooleanType wasNotGiven; 647 648 /** 649 * A code indicating why the administration was not performed. 650 */ 651 @Child(name = "reasonNotGiven", type = {CodeableConcept.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 652 @Description(shortDefinition="Reason administration not performed", formalDefinition="A code indicating why the administration was not performed." ) 653 protected List<CodeableConcept> reasonNotGiven; 654 655 /** 656 * A code indicating why the medication was given. 657 */ 658 @Child(name = "reasonGiven", type = {CodeableConcept.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 659 @Description(shortDefinition="Reason administration performed", formalDefinition="A code indicating why the medication was given." ) 660 protected List<CodeableConcept> reasonGiven; 661 662 /** 663 * A specific date/time or interval of time during which the administration took place (or did not take place, when the 'notGiven' attribute is true). For many administrations, such as swallowing a tablet the use of dateTime is more appropriate. 664 */ 665 @Child(name = "effectiveTime", type = {DateTimeType.class, Period.class}, order=9, min=1, max=1, modifier=false, summary=true) 666 @Description(shortDefinition="Start and end time of administration", formalDefinition="A specific date/time or interval of time during which the administration took place (or did not take place, when the 'notGiven' attribute is true). For many administrations, such as swallowing a tablet the use of dateTime is more appropriate." ) 667 protected Type effectiveTime; 668 669 /** 670 * Identifies the medication that was administered. This is either a link to a resource representing the details of the medication or a simple attribute carrying a code that identifies the medication from a known list of medications. 671 */ 672 @Child(name = "medication", type = {CodeableConcept.class, Medication.class}, order=10, min=1, max=1, modifier=false, summary=true) 673 @Description(shortDefinition="What was administered", formalDefinition="Identifies the medication that was administered. This is either a link to a resource representing the details of the medication or a simple attribute carrying a code that identifies the medication from a known list of medications." ) 674 protected Type medication; 675 676 /** 677 * The device used in administering the medication to the patient. For example, a particular infusion pump. 678 */ 679 @Child(name = "device", type = {Device.class}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 680 @Description(shortDefinition="Device used to administer", formalDefinition="The device used in administering the medication to the patient. For example, a particular infusion pump." ) 681 protected List<Reference> device; 682 /** 683 * The actual objects that are the target of the reference (The device used in administering the medication to the patient. For example, a particular infusion pump.) 684 */ 685 protected List<Device> deviceTarget; 686 687 688 /** 689 * Extra information about the medication administration that is not conveyed by the other attributes. 690 */ 691 @Child(name = "note", type = {StringType.class}, order=12, min=0, max=1, modifier=false, summary=true) 692 @Description(shortDefinition="Information about the administration", formalDefinition="Extra information about the medication administration that is not conveyed by the other attributes." ) 693 protected StringType note; 694 695 /** 696 * Describes the medication dosage information details e.g. dose, rate, site, route, etc. 697 */ 698 @Child(name = "dosage", type = {}, order=13, min=0, max=1, modifier=false, summary=true) 699 @Description(shortDefinition="Details of how medication was taken", formalDefinition="Describes the medication dosage information details e.g. dose, rate, site, route, etc." ) 700 protected MedicationAdministrationDosageComponent dosage; 701 702 private static final long serialVersionUID = -669616345L; 703 704 /* 705 * Constructor 706 */ 707 public MedicationAdministration() { 708 super(); 709 } 710 711 /* 712 * Constructor 713 */ 714 public MedicationAdministration(Enumeration<MedicationAdministrationStatus> status, Reference patient, Type effectiveTime, Type medication) { 715 super(); 716 this.status = status; 717 this.patient = patient; 718 this.effectiveTime = effectiveTime; 719 this.medication = medication; 720 } 721 722 /** 723 * @return {@link #identifier} (External identifier - FHIR will generate its own internal identifiers (probably URLs) which do not need to be explicitly managed by the resource. The identifier here is one that would be used by another non-FHIR system - for example an automated medication pump would provide a record each time it operated; an administration while the patient was off the ward might be made with a different system and entered after the event. Particularly important if these records have to be updated.) 724 */ 725 public List<Identifier> getIdentifier() { 726 if (this.identifier == null) 727 this.identifier = new ArrayList<Identifier>(); 728 return this.identifier; 729 } 730 731 public boolean hasIdentifier() { 732 if (this.identifier == null) 733 return false; 734 for (Identifier item : this.identifier) 735 if (!item.isEmpty()) 736 return true; 737 return false; 738 } 739 740 /** 741 * @return {@link #identifier} (External identifier - FHIR will generate its own internal identifiers (probably URLs) which do not need to be explicitly managed by the resource. The identifier here is one that would be used by another non-FHIR system - for example an automated medication pump would provide a record each time it operated; an administration while the patient was off the ward might be made with a different system and entered after the event. Particularly important if these records have to be updated.) 742 */ 743 // syntactic sugar 744 public Identifier addIdentifier() { //3 745 Identifier t = new Identifier(); 746 if (this.identifier == null) 747 this.identifier = new ArrayList<Identifier>(); 748 this.identifier.add(t); 749 return t; 750 } 751 752 // syntactic sugar 753 public MedicationAdministration addIdentifier(Identifier t) { //3 754 if (t == null) 755 return this; 756 if (this.identifier == null) 757 this.identifier = new ArrayList<Identifier>(); 758 this.identifier.add(t); 759 return this; 760 } 761 762 /** 763 * @return {@link #status} (Will generally be set to show that the administration has been completed. For some long running administrations such as infusions it is possible for an administration to be started but not completed or it may be paused while some other process is under way.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value 764 */ 765 public Enumeration<MedicationAdministrationStatus> getStatusElement() { 766 if (this.status == null) 767 if (Configuration.errorOnAutoCreate()) 768 throw new Error("Attempt to auto-create MedicationAdministration.status"); 769 else if (Configuration.doAutoCreate()) 770 this.status = new Enumeration<MedicationAdministrationStatus>(new MedicationAdministrationStatusEnumFactory()); // bb 771 return this.status; 772 } 773 774 public boolean hasStatusElement() { 775 return this.status != null && !this.status.isEmpty(); 776 } 777 778 public boolean hasStatus() { 779 return this.status != null && !this.status.isEmpty(); 780 } 781 782 /** 783 * @param value {@link #status} (Will generally be set to show that the administration has been completed. For some long running administrations such as infusions it is possible for an administration to be started but not completed or it may be paused while some other process is under way.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value 784 */ 785 public MedicationAdministration setStatusElement(Enumeration<MedicationAdministrationStatus> value) { 786 this.status = value; 787 return this; 788 } 789 790 /** 791 * @return Will generally be set to show that the administration has been completed. For some long running administrations such as infusions it is possible for an administration to be started but not completed or it may be paused while some other process is under way. 792 */ 793 public MedicationAdministrationStatus getStatus() { 794 return this.status == null ? null : this.status.getValue(); 795 } 796 797 /** 798 * @param value Will generally be set to show that the administration has been completed. For some long running administrations such as infusions it is possible for an administration to be started but not completed or it may be paused while some other process is under way. 799 */ 800 public MedicationAdministration setStatus(MedicationAdministrationStatus value) { 801 if (this.status == null) 802 this.status = new Enumeration<MedicationAdministrationStatus>(new MedicationAdministrationStatusEnumFactory()); 803 this.status.setValue(value); 804 return this; 805 } 806 807 /** 808 * @return {@link #patient} (The person or animal receiving the medication.) 809 */ 810 public Reference getPatient() { 811 if (this.patient == null) 812 if (Configuration.errorOnAutoCreate()) 813 throw new Error("Attempt to auto-create MedicationAdministration.patient"); 814 else if (Configuration.doAutoCreate()) 815 this.patient = new Reference(); // cc 816 return this.patient; 817 } 818 819 public boolean hasPatient() { 820 return this.patient != null && !this.patient.isEmpty(); 821 } 822 823 /** 824 * @param value {@link #patient} (The person or animal receiving the medication.) 825 */ 826 public MedicationAdministration setPatient(Reference value) { 827 this.patient = value; 828 return this; 829 } 830 831 /** 832 * @return {@link #patient} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The person or animal receiving the medication.) 833 */ 834 public Patient getPatientTarget() { 835 if (this.patientTarget == null) 836 if (Configuration.errorOnAutoCreate()) 837 throw new Error("Attempt to auto-create MedicationAdministration.patient"); 838 else if (Configuration.doAutoCreate()) 839 this.patientTarget = new Patient(); // aa 840 return this.patientTarget; 841 } 842 843 /** 844 * @param value {@link #patient} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The person or animal receiving the medication.) 845 */ 846 public MedicationAdministration setPatientTarget(Patient value) { 847 this.patientTarget = value; 848 return this; 849 } 850 851 /** 852 * @return {@link #practitioner} (The individual who was responsible for giving the medication to the patient.) 853 */ 854 public Reference getPractitioner() { 855 if (this.practitioner == null) 856 if (Configuration.errorOnAutoCreate()) 857 throw new Error("Attempt to auto-create MedicationAdministration.practitioner"); 858 else if (Configuration.doAutoCreate()) 859 this.practitioner = new Reference(); // cc 860 return this.practitioner; 861 } 862 863 public boolean hasPractitioner() { 864 return this.practitioner != null && !this.practitioner.isEmpty(); 865 } 866 867 /** 868 * @param value {@link #practitioner} (The individual who was responsible for giving the medication to the patient.) 869 */ 870 public MedicationAdministration setPractitioner(Reference value) { 871 this.practitioner = value; 872 return this; 873 } 874 875 /** 876 * @return {@link #practitioner} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The individual who was responsible for giving the medication to the patient.) 877 */ 878 public Resource getPractitionerTarget() { 879 return this.practitionerTarget; 880 } 881 882 /** 883 * @param value {@link #practitioner} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The individual who was responsible for giving the medication to the patient.) 884 */ 885 public MedicationAdministration setPractitionerTarget(Resource value) { 886 this.practitionerTarget = value; 887 return this; 888 } 889 890 /** 891 * @return {@link #encounter} (The visit, admission or other contact between patient and health care provider the medication administration was performed as part of.) 892 */ 893 public Reference getEncounter() { 894 if (this.encounter == null) 895 if (Configuration.errorOnAutoCreate()) 896 throw new Error("Attempt to auto-create MedicationAdministration.encounter"); 897 else if (Configuration.doAutoCreate()) 898 this.encounter = new Reference(); // cc 899 return this.encounter; 900 } 901 902 public boolean hasEncounter() { 903 return this.encounter != null && !this.encounter.isEmpty(); 904 } 905 906 /** 907 * @param value {@link #encounter} (The visit, admission or other contact between patient and health care provider the medication administration was performed as part of.) 908 */ 909 public MedicationAdministration setEncounter(Reference value) { 910 this.encounter = value; 911 return this; 912 } 913 914 /** 915 * @return {@link #encounter} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The visit, admission or other contact between patient and health care provider the medication administration was performed as part of.) 916 */ 917 public Encounter getEncounterTarget() { 918 if (this.encounterTarget == null) 919 if (Configuration.errorOnAutoCreate()) 920 throw new Error("Attempt to auto-create MedicationAdministration.encounter"); 921 else if (Configuration.doAutoCreate()) 922 this.encounterTarget = new Encounter(); // aa 923 return this.encounterTarget; 924 } 925 926 /** 927 * @param value {@link #encounter} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The visit, admission or other contact between patient and health care provider the medication administration was performed as part of.) 928 */ 929 public MedicationAdministration setEncounterTarget(Encounter value) { 930 this.encounterTarget = value; 931 return this; 932 } 933 934 /** 935 * @return {@link #prescription} (The original request, instruction or authority to perform the administration.) 936 */ 937 public Reference getPrescription() { 938 if (this.prescription == null) 939 if (Configuration.errorOnAutoCreate()) 940 throw new Error("Attempt to auto-create MedicationAdministration.prescription"); 941 else if (Configuration.doAutoCreate()) 942 this.prescription = new Reference(); // cc 943 return this.prescription; 944 } 945 946 public boolean hasPrescription() { 947 return this.prescription != null && !this.prescription.isEmpty(); 948 } 949 950 /** 951 * @param value {@link #prescription} (The original request, instruction or authority to perform the administration.) 952 */ 953 public MedicationAdministration setPrescription(Reference value) { 954 this.prescription = value; 955 return this; 956 } 957 958 /** 959 * @return {@link #prescription} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The original request, instruction or authority to perform the administration.) 960 */ 961 public MedicationOrder getPrescriptionTarget() { 962 if (this.prescriptionTarget == null) 963 if (Configuration.errorOnAutoCreate()) 964 throw new Error("Attempt to auto-create MedicationAdministration.prescription"); 965 else if (Configuration.doAutoCreate()) 966 this.prescriptionTarget = new MedicationOrder(); // aa 967 return this.prescriptionTarget; 968 } 969 970 /** 971 * @param value {@link #prescription} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The original request, instruction or authority to perform the administration.) 972 */ 973 public MedicationAdministration setPrescriptionTarget(MedicationOrder value) { 974 this.prescriptionTarget = value; 975 return this; 976 } 977 978 /** 979 * @return {@link #wasNotGiven} (Set this to true if the record is saying that the medication was NOT administered.). This is the underlying object with id, value and extensions. The accessor "getWasNotGiven" gives direct access to the value 980 */ 981 public BooleanType getWasNotGivenElement() { 982 if (this.wasNotGiven == null) 983 if (Configuration.errorOnAutoCreate()) 984 throw new Error("Attempt to auto-create MedicationAdministration.wasNotGiven"); 985 else if (Configuration.doAutoCreate()) 986 this.wasNotGiven = new BooleanType(); // bb 987 return this.wasNotGiven; 988 } 989 990 public boolean hasWasNotGivenElement() { 991 return this.wasNotGiven != null && !this.wasNotGiven.isEmpty(); 992 } 993 994 public boolean hasWasNotGiven() { 995 return this.wasNotGiven != null && !this.wasNotGiven.isEmpty(); 996 } 997 998 /** 999 * @param value {@link #wasNotGiven} (Set this to true if the record is saying that the medication was NOT administered.). This is the underlying object with id, value and extensions. The accessor "getWasNotGiven" gives direct access to the value 1000 */ 1001 public MedicationAdministration setWasNotGivenElement(BooleanType value) { 1002 this.wasNotGiven = value; 1003 return this; 1004 } 1005 1006 /** 1007 * @return Set this to true if the record is saying that the medication was NOT administered. 1008 */ 1009 public boolean getWasNotGiven() { 1010 return this.wasNotGiven == null || this.wasNotGiven.isEmpty() ? false : this.wasNotGiven.getValue(); 1011 } 1012 1013 /** 1014 * @param value Set this to true if the record is saying that the medication was NOT administered. 1015 */ 1016 public MedicationAdministration setWasNotGiven(boolean value) { 1017 if (this.wasNotGiven == null) 1018 this.wasNotGiven = new BooleanType(); 1019 this.wasNotGiven.setValue(value); 1020 return this; 1021 } 1022 1023 /** 1024 * @return {@link #reasonNotGiven} (A code indicating why the administration was not performed.) 1025 */ 1026 public List<CodeableConcept> getReasonNotGiven() { 1027 if (this.reasonNotGiven == null) 1028 this.reasonNotGiven = new ArrayList<CodeableConcept>(); 1029 return this.reasonNotGiven; 1030 } 1031 1032 public boolean hasReasonNotGiven() { 1033 if (this.reasonNotGiven == null) 1034 return false; 1035 for (CodeableConcept item : this.reasonNotGiven) 1036 if (!item.isEmpty()) 1037 return true; 1038 return false; 1039 } 1040 1041 /** 1042 * @return {@link #reasonNotGiven} (A code indicating why the administration was not performed.) 1043 */ 1044 // syntactic sugar 1045 public CodeableConcept addReasonNotGiven() { //3 1046 CodeableConcept t = new CodeableConcept(); 1047 if (this.reasonNotGiven == null) 1048 this.reasonNotGiven = new ArrayList<CodeableConcept>(); 1049 this.reasonNotGiven.add(t); 1050 return t; 1051 } 1052 1053 // syntactic sugar 1054 public MedicationAdministration addReasonNotGiven(CodeableConcept t) { //3 1055 if (t == null) 1056 return this; 1057 if (this.reasonNotGiven == null) 1058 this.reasonNotGiven = new ArrayList<CodeableConcept>(); 1059 this.reasonNotGiven.add(t); 1060 return this; 1061 } 1062 1063 /** 1064 * @return {@link #reasonGiven} (A code indicating why the medication was given.) 1065 */ 1066 public List<CodeableConcept> getReasonGiven() { 1067 if (this.reasonGiven == null) 1068 this.reasonGiven = new ArrayList<CodeableConcept>(); 1069 return this.reasonGiven; 1070 } 1071 1072 public boolean hasReasonGiven() { 1073 if (this.reasonGiven == null) 1074 return false; 1075 for (CodeableConcept item : this.reasonGiven) 1076 if (!item.isEmpty()) 1077 return true; 1078 return false; 1079 } 1080 1081 /** 1082 * @return {@link #reasonGiven} (A code indicating why the medication was given.) 1083 */ 1084 // syntactic sugar 1085 public CodeableConcept addReasonGiven() { //3 1086 CodeableConcept t = new CodeableConcept(); 1087 if (this.reasonGiven == null) 1088 this.reasonGiven = new ArrayList<CodeableConcept>(); 1089 this.reasonGiven.add(t); 1090 return t; 1091 } 1092 1093 // syntactic sugar 1094 public MedicationAdministration addReasonGiven(CodeableConcept t) { //3 1095 if (t == null) 1096 return this; 1097 if (this.reasonGiven == null) 1098 this.reasonGiven = new ArrayList<CodeableConcept>(); 1099 this.reasonGiven.add(t); 1100 return this; 1101 } 1102 1103 /** 1104 * @return {@link #effectiveTime} (A specific date/time or interval of time during which the administration took place (or did not take place, when the 'notGiven' attribute is true). For many administrations, such as swallowing a tablet the use of dateTime is more appropriate.) 1105 */ 1106 public Type getEffectiveTime() { 1107 return this.effectiveTime; 1108 } 1109 1110 /** 1111 * @return {@link #effectiveTime} (A specific date/time or interval of time during which the administration took place (or did not take place, when the 'notGiven' attribute is true). For many administrations, such as swallowing a tablet the use of dateTime is more appropriate.) 1112 */ 1113 public DateTimeType getEffectiveTimeDateTimeType() throws FHIRException { 1114 if (!(this.effectiveTime instanceof DateTimeType)) 1115 throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.effectiveTime.getClass().getName()+" was encountered"); 1116 return (DateTimeType) this.effectiveTime; 1117 } 1118 1119 public boolean hasEffectiveTimeDateTimeType() { 1120 return this.effectiveTime instanceof DateTimeType; 1121 } 1122 1123 /** 1124 * @return {@link #effectiveTime} (A specific date/time or interval of time during which the administration took place (or did not take place, when the 'notGiven' attribute is true). For many administrations, such as swallowing a tablet the use of dateTime is more appropriate.) 1125 */ 1126 public Period getEffectiveTimePeriod() throws FHIRException { 1127 if (!(this.effectiveTime instanceof Period)) 1128 throw new FHIRException("Type mismatch: the type Period was expected, but "+this.effectiveTime.getClass().getName()+" was encountered"); 1129 return (Period) this.effectiveTime; 1130 } 1131 1132 public boolean hasEffectiveTimePeriod() { 1133 return this.effectiveTime instanceof Period; 1134 } 1135 1136 public boolean hasEffectiveTime() { 1137 return this.effectiveTime != null && !this.effectiveTime.isEmpty(); 1138 } 1139 1140 /** 1141 * @param value {@link #effectiveTime} (A specific date/time or interval of time during which the administration took place (or did not take place, when the 'notGiven' attribute is true). For many administrations, such as swallowing a tablet the use of dateTime is more appropriate.) 1142 */ 1143 public MedicationAdministration setEffectiveTime(Type value) { 1144 this.effectiveTime = value; 1145 return this; 1146 } 1147 1148 /** 1149 * @return {@link #medication} (Identifies the medication that was administered. This is either a link to a resource representing the details of the medication or a simple attribute carrying a code that identifies the medication from a known list of medications.) 1150 */ 1151 public Type getMedication() { 1152 return this.medication; 1153 } 1154 1155 /** 1156 * @return {@link #medication} (Identifies the medication that was administered. This is either a link to a resource representing the details of the medication or a simple attribute carrying a code that identifies the medication from a known list of medications.) 1157 */ 1158 public CodeableConcept getMedicationCodeableConcept() throws FHIRException { 1159 if (!(this.medication instanceof CodeableConcept)) 1160 throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.medication.getClass().getName()+" was encountered"); 1161 return (CodeableConcept) this.medication; 1162 } 1163 1164 public boolean hasMedicationCodeableConcept() { 1165 return this.medication instanceof CodeableConcept; 1166 } 1167 1168 /** 1169 * @return {@link #medication} (Identifies the medication that was administered. This is either a link to a resource representing the details of the medication or a simple attribute carrying a code that identifies the medication from a known list of medications.) 1170 */ 1171 public Reference getMedicationReference() throws FHIRException { 1172 if (!(this.medication instanceof Reference)) 1173 throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.medication.getClass().getName()+" was encountered"); 1174 return (Reference) this.medication; 1175 } 1176 1177 public boolean hasMedicationReference() { 1178 return this.medication instanceof Reference; 1179 } 1180 1181 public boolean hasMedication() { 1182 return this.medication != null && !this.medication.isEmpty(); 1183 } 1184 1185 /** 1186 * @param value {@link #medication} (Identifies the medication that was administered. This is either a link to a resource representing the details of the medication or a simple attribute carrying a code that identifies the medication from a known list of medications.) 1187 */ 1188 public MedicationAdministration setMedication(Type value) { 1189 this.medication = value; 1190 return this; 1191 } 1192 1193 /** 1194 * @return {@link #device} (The device used in administering the medication to the patient. For example, a particular infusion pump.) 1195 */ 1196 public List<Reference> getDevice() { 1197 if (this.device == null) 1198 this.device = new ArrayList<Reference>(); 1199 return this.device; 1200 } 1201 1202 public boolean hasDevice() { 1203 if (this.device == null) 1204 return false; 1205 for (Reference item : this.device) 1206 if (!item.isEmpty()) 1207 return true; 1208 return false; 1209 } 1210 1211 /** 1212 * @return {@link #device} (The device used in administering the medication to the patient. For example, a particular infusion pump.) 1213 */ 1214 // syntactic sugar 1215 public Reference addDevice() { //3 1216 Reference t = new Reference(); 1217 if (this.device == null) 1218 this.device = new ArrayList<Reference>(); 1219 this.device.add(t); 1220 return t; 1221 } 1222 1223 // syntactic sugar 1224 public MedicationAdministration addDevice(Reference t) { //3 1225 if (t == null) 1226 return this; 1227 if (this.device == null) 1228 this.device = new ArrayList<Reference>(); 1229 this.device.add(t); 1230 return this; 1231 } 1232 1233 /** 1234 * @return {@link #device} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. The device used in administering the medication to the patient. For example, a particular infusion pump.) 1235 */ 1236 public List<Device> getDeviceTarget() { 1237 if (this.deviceTarget == null) 1238 this.deviceTarget = new ArrayList<Device>(); 1239 return this.deviceTarget; 1240 } 1241 1242 // syntactic sugar 1243 /** 1244 * @return {@link #device} (Add an actual object that is the target of the reference. The reference library doesn't use these, but you can use this to hold the resources if you resolvethemt. The device used in administering the medication to the patient. For example, a particular infusion pump.) 1245 */ 1246 public Device addDeviceTarget() { 1247 Device r = new Device(); 1248 if (this.deviceTarget == null) 1249 this.deviceTarget = new ArrayList<Device>(); 1250 this.deviceTarget.add(r); 1251 return r; 1252 } 1253 1254 /** 1255 * @return {@link #note} (Extra information about the medication administration that is not conveyed by the other attributes.). This is the underlying object with id, value and extensions. The accessor "getNote" gives direct access to the value 1256 */ 1257 public StringType getNoteElement() { 1258 if (this.note == null) 1259 if (Configuration.errorOnAutoCreate()) 1260 throw new Error("Attempt to auto-create MedicationAdministration.note"); 1261 else if (Configuration.doAutoCreate()) 1262 this.note = new StringType(); // bb 1263 return this.note; 1264 } 1265 1266 public boolean hasNoteElement() { 1267 return this.note != null && !this.note.isEmpty(); 1268 } 1269 1270 public boolean hasNote() { 1271 return this.note != null && !this.note.isEmpty(); 1272 } 1273 1274 /** 1275 * @param value {@link #note} (Extra information about the medication administration that is not conveyed by the other attributes.). This is the underlying object with id, value and extensions. The accessor "getNote" gives direct access to the value 1276 */ 1277 public MedicationAdministration setNoteElement(StringType value) { 1278 this.note = value; 1279 return this; 1280 } 1281 1282 /** 1283 * @return Extra information about the medication administration that is not conveyed by the other attributes. 1284 */ 1285 public String getNote() { 1286 return this.note == null ? null : this.note.getValue(); 1287 } 1288 1289 /** 1290 * @param value Extra information about the medication administration that is not conveyed by the other attributes. 1291 */ 1292 public MedicationAdministration setNote(String value) { 1293 if (Utilities.noString(value)) 1294 this.note = null; 1295 else { 1296 if (this.note == null) 1297 this.note = new StringType(); 1298 this.note.setValue(value); 1299 } 1300 return this; 1301 } 1302 1303 /** 1304 * @return {@link #dosage} (Describes the medication dosage information details e.g. dose, rate, site, route, etc.) 1305 */ 1306 public MedicationAdministrationDosageComponent getDosage() { 1307 if (this.dosage == null) 1308 if (Configuration.errorOnAutoCreate()) 1309 throw new Error("Attempt to auto-create MedicationAdministration.dosage"); 1310 else if (Configuration.doAutoCreate()) 1311 this.dosage = new MedicationAdministrationDosageComponent(); // cc 1312 return this.dosage; 1313 } 1314 1315 public boolean hasDosage() { 1316 return this.dosage != null && !this.dosage.isEmpty(); 1317 } 1318 1319 /** 1320 * @param value {@link #dosage} (Describes the medication dosage information details e.g. dose, rate, site, route, etc.) 1321 */ 1322 public MedicationAdministration setDosage(MedicationAdministrationDosageComponent value) { 1323 this.dosage = value; 1324 return this; 1325 } 1326 1327 protected void listChildren(List<Property> childrenList) { 1328 super.listChildren(childrenList); 1329 childrenList.add(new Property("identifier", "Identifier", "External identifier - FHIR will generate its own internal identifiers (probably URLs) which do not need to be explicitly managed by the resource. The identifier here is one that would be used by another non-FHIR system - for example an automated medication pump would provide a record each time it operated; an administration while the patient was off the ward might be made with a different system and entered after the event. Particularly important if these records have to be updated.", 0, java.lang.Integer.MAX_VALUE, identifier)); 1330 childrenList.add(new Property("status", "code", "Will generally be set to show that the administration has been completed. For some long running administrations such as infusions it is possible for an administration to be started but not completed or it may be paused while some other process is under way.", 0, java.lang.Integer.MAX_VALUE, status)); 1331 childrenList.add(new Property("patient", "Reference(Patient)", "The person or animal receiving the medication.", 0, java.lang.Integer.MAX_VALUE, patient)); 1332 childrenList.add(new Property("practitioner", "Reference(Practitioner|Patient|RelatedPerson)", "The individual who was responsible for giving the medication to the patient.", 0, java.lang.Integer.MAX_VALUE, practitioner)); 1333 childrenList.add(new Property("encounter", "Reference(Encounter)", "The visit, admission or other contact between patient and health care provider the medication administration was performed as part of.", 0, java.lang.Integer.MAX_VALUE, encounter)); 1334 childrenList.add(new Property("prescription", "Reference(MedicationOrder)", "The original request, instruction or authority to perform the administration.", 0, java.lang.Integer.MAX_VALUE, prescription)); 1335 childrenList.add(new Property("wasNotGiven", "boolean", "Set this to true if the record is saying that the medication was NOT administered.", 0, java.lang.Integer.MAX_VALUE, wasNotGiven)); 1336 childrenList.add(new Property("reasonNotGiven", "CodeableConcept", "A code indicating why the administration was not performed.", 0, java.lang.Integer.MAX_VALUE, reasonNotGiven)); 1337 childrenList.add(new Property("reasonGiven", "CodeableConcept", "A code indicating why the medication was given.", 0, java.lang.Integer.MAX_VALUE, reasonGiven)); 1338 childrenList.add(new Property("effectiveTime[x]", "dateTime|Period", "A specific date/time or interval of time during which the administration took place (or did not take place, when the 'notGiven' attribute is true). For many administrations, such as swallowing a tablet the use of dateTime is more appropriate.", 0, java.lang.Integer.MAX_VALUE, effectiveTime)); 1339 childrenList.add(new Property("medication[x]", "CodeableConcept|Reference(Medication)", "Identifies the medication that was administered. This is either a link to a resource representing the details of the medication or a simple attribute carrying a code that identifies the medication from a known list of medications.", 0, java.lang.Integer.MAX_VALUE, medication)); 1340 childrenList.add(new Property("device", "Reference(Device)", "The device used in administering the medication to the patient. For example, a particular infusion pump.", 0, java.lang.Integer.MAX_VALUE, device)); 1341 childrenList.add(new Property("note", "string", "Extra information about the medication administration that is not conveyed by the other attributes.", 0, java.lang.Integer.MAX_VALUE, note)); 1342 childrenList.add(new Property("dosage", "", "Describes the medication dosage information details e.g. dose, rate, site, route, etc.", 0, java.lang.Integer.MAX_VALUE, dosage)); 1343 } 1344 1345 @Override 1346 public void setProperty(String name, Base value) throws FHIRException { 1347 if (name.equals("identifier")) 1348 this.getIdentifier().add(castToIdentifier(value)); 1349 else if (name.equals("status")) 1350 this.status = new MedicationAdministrationStatusEnumFactory().fromType(value); // Enumeration<MedicationAdministrationStatus> 1351 else if (name.equals("patient")) 1352 this.patient = castToReference(value); // Reference 1353 else if (name.equals("practitioner")) 1354 this.practitioner = castToReference(value); // Reference 1355 else if (name.equals("encounter")) 1356 this.encounter = castToReference(value); // Reference 1357 else if (name.equals("prescription")) 1358 this.prescription = castToReference(value); // Reference 1359 else if (name.equals("wasNotGiven")) 1360 this.wasNotGiven = castToBoolean(value); // BooleanType 1361 else if (name.equals("reasonNotGiven")) 1362 this.getReasonNotGiven().add(castToCodeableConcept(value)); 1363 else if (name.equals("reasonGiven")) 1364 this.getReasonGiven().add(castToCodeableConcept(value)); 1365 else if (name.equals("effectiveTime[x]")) 1366 this.effectiveTime = (Type) value; // Type 1367 else if (name.equals("medication[x]")) 1368 this.medication = (Type) value; // Type 1369 else if (name.equals("device")) 1370 this.getDevice().add(castToReference(value)); 1371 else if (name.equals("note")) 1372 this.note = castToString(value); // StringType 1373 else if (name.equals("dosage")) 1374 this.dosage = (MedicationAdministrationDosageComponent) value; // MedicationAdministrationDosageComponent 1375 else 1376 super.setProperty(name, value); 1377 } 1378 1379 @Override 1380 public Base addChild(String name) throws FHIRException { 1381 if (name.equals("identifier")) { 1382 return addIdentifier(); 1383 } 1384 else if (name.equals("status")) { 1385 throw new FHIRException("Cannot call addChild on a primitive type MedicationAdministration.status"); 1386 } 1387 else if (name.equals("patient")) { 1388 this.patient = new Reference(); 1389 return this.patient; 1390 } 1391 else if (name.equals("practitioner")) { 1392 this.practitioner = new Reference(); 1393 return this.practitioner; 1394 } 1395 else if (name.equals("encounter")) { 1396 this.encounter = new Reference(); 1397 return this.encounter; 1398 } 1399 else if (name.equals("prescription")) { 1400 this.prescription = new Reference(); 1401 return this.prescription; 1402 } 1403 else if (name.equals("wasNotGiven")) { 1404 throw new FHIRException("Cannot call addChild on a primitive type MedicationAdministration.wasNotGiven"); 1405 } 1406 else if (name.equals("reasonNotGiven")) { 1407 return addReasonNotGiven(); 1408 } 1409 else if (name.equals("reasonGiven")) { 1410 return addReasonGiven(); 1411 } 1412 else if (name.equals("effectiveTimeDateTime")) { 1413 this.effectiveTime = new DateTimeType(); 1414 return this.effectiveTime; 1415 } 1416 else if (name.equals("effectiveTimePeriod")) { 1417 this.effectiveTime = new Period(); 1418 return this.effectiveTime; 1419 } 1420 else if (name.equals("medicationCodeableConcept")) { 1421 this.medication = new CodeableConcept(); 1422 return this.medication; 1423 } 1424 else if (name.equals("medicationReference")) { 1425 this.medication = new Reference(); 1426 return this.medication; 1427 } 1428 else if (name.equals("device")) { 1429 return addDevice(); 1430 } 1431 else if (name.equals("note")) { 1432 throw new FHIRException("Cannot call addChild on a primitive type MedicationAdministration.note"); 1433 } 1434 else if (name.equals("dosage")) { 1435 this.dosage = new MedicationAdministrationDosageComponent(); 1436 return this.dosage; 1437 } 1438 else 1439 return super.addChild(name); 1440 } 1441 1442 public String fhirType() { 1443 return "MedicationAdministration"; 1444 1445 } 1446 1447 public MedicationAdministration copy() { 1448 MedicationAdministration dst = new MedicationAdministration(); 1449 copyValues(dst); 1450 if (identifier != null) { 1451 dst.identifier = new ArrayList<Identifier>(); 1452 for (Identifier i : identifier) 1453 dst.identifier.add(i.copy()); 1454 }; 1455 dst.status = status == null ? null : status.copy(); 1456 dst.patient = patient == null ? null : patient.copy(); 1457 dst.practitioner = practitioner == null ? null : practitioner.copy(); 1458 dst.encounter = encounter == null ? null : encounter.copy(); 1459 dst.prescription = prescription == null ? null : prescription.copy(); 1460 dst.wasNotGiven = wasNotGiven == null ? null : wasNotGiven.copy(); 1461 if (reasonNotGiven != null) { 1462 dst.reasonNotGiven = new ArrayList<CodeableConcept>(); 1463 for (CodeableConcept i : reasonNotGiven) 1464 dst.reasonNotGiven.add(i.copy()); 1465 }; 1466 if (reasonGiven != null) { 1467 dst.reasonGiven = new ArrayList<CodeableConcept>(); 1468 for (CodeableConcept i : reasonGiven) 1469 dst.reasonGiven.add(i.copy()); 1470 }; 1471 dst.effectiveTime = effectiveTime == null ? null : effectiveTime.copy(); 1472 dst.medication = medication == null ? null : medication.copy(); 1473 if (device != null) { 1474 dst.device = new ArrayList<Reference>(); 1475 for (Reference i : device) 1476 dst.device.add(i.copy()); 1477 }; 1478 dst.note = note == null ? null : note.copy(); 1479 dst.dosage = dosage == null ? null : dosage.copy(); 1480 return dst; 1481 } 1482 1483 protected MedicationAdministration typedCopy() { 1484 return copy(); 1485 } 1486 1487 @Override 1488 public boolean equalsDeep(Base other) { 1489 if (!super.equalsDeep(other)) 1490 return false; 1491 if (!(other instanceof MedicationAdministration)) 1492 return false; 1493 MedicationAdministration o = (MedicationAdministration) other; 1494 return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(patient, o.patient, true) 1495 && compareDeep(practitioner, o.practitioner, true) && compareDeep(encounter, o.encounter, true) 1496 && compareDeep(prescription, o.prescription, true) && compareDeep(wasNotGiven, o.wasNotGiven, true) 1497 && compareDeep(reasonNotGiven, o.reasonNotGiven, true) && compareDeep(reasonGiven, o.reasonGiven, true) 1498 && compareDeep(effectiveTime, o.effectiveTime, true) && compareDeep(medication, o.medication, true) 1499 && compareDeep(device, o.device, true) && compareDeep(note, o.note, true) && compareDeep(dosage, o.dosage, true) 1500 ; 1501 } 1502 1503 @Override 1504 public boolean equalsShallow(Base other) { 1505 if (!super.equalsShallow(other)) 1506 return false; 1507 if (!(other instanceof MedicationAdministration)) 1508 return false; 1509 MedicationAdministration o = (MedicationAdministration) other; 1510 return compareValues(status, o.status, true) && compareValues(wasNotGiven, o.wasNotGiven, true) && compareValues(note, o.note, true) 1511 ; 1512 } 1513 1514 public boolean isEmpty() { 1515 return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (status == null || status.isEmpty()) 1516 && (patient == null || patient.isEmpty()) && (practitioner == null || practitioner.isEmpty()) 1517 && (encounter == null || encounter.isEmpty()) && (prescription == null || prescription.isEmpty()) 1518 && (wasNotGiven == null || wasNotGiven.isEmpty()) && (reasonNotGiven == null || reasonNotGiven.isEmpty()) 1519 && (reasonGiven == null || reasonGiven.isEmpty()) && (effectiveTime == null || effectiveTime.isEmpty()) 1520 && (medication == null || medication.isEmpty()) && (device == null || device.isEmpty()) && (note == null || note.isEmpty()) 1521 && (dosage == null || dosage.isEmpty()); 1522 } 1523 1524 @Override 1525 public ResourceType getResourceType() { 1526 return ResourceType.MedicationAdministration; 1527 } 1528 1529 @SearchParamDefinition(name="identifier", path="MedicationAdministration.identifier", description="Return administrations with this external identifier", type="token" ) 1530 public static final String SP_IDENTIFIER = "identifier"; 1531 @SearchParamDefinition(name="code", path="MedicationAdministration.medicationCodeableConcept", description="Return administrations of this medication code", type="token" ) 1532 public static final String SP_CODE = "code"; 1533 @SearchParamDefinition(name="prescription", path="MedicationAdministration.prescription", description="The identity of a prescription to list administrations from", type="reference" ) 1534 public static final String SP_PRESCRIPTION = "prescription"; 1535 @SearchParamDefinition(name="effectivetime", path="MedicationAdministration.effectiveTime[x]", description="Date administration happened (or did not happen)", type="date" ) 1536 public static final String SP_EFFECTIVETIME = "effectivetime"; 1537 @SearchParamDefinition(name="practitioner", path="MedicationAdministration.practitioner", description="Who administered substance", type="reference" ) 1538 public static final String SP_PRACTITIONER = "practitioner"; 1539 @SearchParamDefinition(name="patient", path="MedicationAdministration.patient", description="The identity of a patient to list administrations for", type="reference" ) 1540 public static final String SP_PATIENT = "patient"; 1541 @SearchParamDefinition(name="medication", path="MedicationAdministration.medicationReference", description="Return administrations of this medication resource", type="reference" ) 1542 public static final String SP_MEDICATION = "medication"; 1543 @SearchParamDefinition(name="encounter", path="MedicationAdministration.encounter", description="Return administrations that share this encounter", type="reference" ) 1544 public static final String SP_ENCOUNTER = "encounter"; 1545 @SearchParamDefinition(name="device", path="MedicationAdministration.device", description="Return administrations with this administration device identity", type="reference" ) 1546 public static final String SP_DEVICE = "device"; 1547 @SearchParamDefinition(name="notgiven", path="MedicationAdministration.wasNotGiven", description="Administrations that were not made", type="token" ) 1548 public static final String SP_NOTGIVEN = "notgiven"; 1549 @SearchParamDefinition(name="status", path="MedicationAdministration.status", description="MedicationAdministration event status (for example one of active/paused/completed/nullified)", type="token" ) 1550 public static final String SP_STATUS = "status"; 1551 1552} 1553