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.Child; 038import ca.uhn.fhir.model.api.annotation.Description; 039import ca.uhn.fhir.model.api.annotation.ResourceDef; 040import ca.uhn.fhir.model.api.annotation.SearchParamDefinition; 041import org.hl7.fhir.exceptions.FHIRException; 042 043/** 044 * Record of delivery of what is supplied. 045 */ 046@ResourceDef(name = "SupplyDelivery", profile = "http://hl7.org/fhir/Profile/SupplyDelivery") 047public class SupplyDelivery extends DomainResource { 048 049 public enum SupplyDeliveryStatus { 050 /** 051 * Supply has been requested, but not delivered. 052 */ 053 INPROGRESS, 054 /** 055 * Supply has been delivered ("completed"). 056 */ 057 COMPLETED, 058 /** 059 * Dispensing was not completed. 060 */ 061 ABANDONED, 062 /** 063 * added to help the parsers 064 */ 065 NULL; 066 067 public static SupplyDeliveryStatus fromCode(String codeString) throws FHIRException { 068 if (codeString == null || "".equals(codeString)) 069 return null; 070 if ("in-progress".equals(codeString)) 071 return INPROGRESS; 072 if ("completed".equals(codeString)) 073 return COMPLETED; 074 if ("abandoned".equals(codeString)) 075 return ABANDONED; 076 throw new FHIRException("Unknown SupplyDeliveryStatus code '" + codeString + "'"); 077 } 078 079 public String toCode() { 080 switch (this) { 081 case INPROGRESS: 082 return "in-progress"; 083 case COMPLETED: 084 return "completed"; 085 case ABANDONED: 086 return "abandoned"; 087 case NULL: 088 return null; 089 default: 090 return "?"; 091 } 092 } 093 094 public String getSystem() { 095 switch (this) { 096 case INPROGRESS: 097 return "http://hl7.org/fhir/supplydelivery-status"; 098 case COMPLETED: 099 return "http://hl7.org/fhir/supplydelivery-status"; 100 case ABANDONED: 101 return "http://hl7.org/fhir/supplydelivery-status"; 102 case NULL: 103 return null; 104 default: 105 return "?"; 106 } 107 } 108 109 public String getDefinition() { 110 switch (this) { 111 case INPROGRESS: 112 return "Supply has been requested, but not delivered."; 113 case COMPLETED: 114 return "Supply has been delivered (\"completed\")."; 115 case ABANDONED: 116 return "Dispensing was not completed."; 117 case NULL: 118 return null; 119 default: 120 return "?"; 121 } 122 } 123 124 public String getDisplay() { 125 switch (this) { 126 case INPROGRESS: 127 return "In Progress"; 128 case COMPLETED: 129 return "Delivered"; 130 case ABANDONED: 131 return "Abandoned"; 132 case NULL: 133 return null; 134 default: 135 return "?"; 136 } 137 } 138 } 139 140 public static class SupplyDeliveryStatusEnumFactory implements EnumFactory<SupplyDeliveryStatus> { 141 public SupplyDeliveryStatus fromCode(String codeString) throws IllegalArgumentException { 142 if (codeString == null || "".equals(codeString)) 143 if (codeString == null || "".equals(codeString)) 144 return null; 145 if ("in-progress".equals(codeString)) 146 return SupplyDeliveryStatus.INPROGRESS; 147 if ("completed".equals(codeString)) 148 return SupplyDeliveryStatus.COMPLETED; 149 if ("abandoned".equals(codeString)) 150 return SupplyDeliveryStatus.ABANDONED; 151 throw new IllegalArgumentException("Unknown SupplyDeliveryStatus code '" + codeString + "'"); 152 } 153 154 public Enumeration<SupplyDeliveryStatus> fromType(Base code) throws FHIRException { 155 if (code == null || code.isEmpty()) 156 return null; 157 String codeString = ((PrimitiveType) code).asStringValue(); 158 if (codeString == null || "".equals(codeString)) 159 return null; 160 if ("in-progress".equals(codeString)) 161 return new Enumeration<SupplyDeliveryStatus>(this, SupplyDeliveryStatus.INPROGRESS); 162 if ("completed".equals(codeString)) 163 return new Enumeration<SupplyDeliveryStatus>(this, SupplyDeliveryStatus.COMPLETED); 164 if ("abandoned".equals(codeString)) 165 return new Enumeration<SupplyDeliveryStatus>(this, SupplyDeliveryStatus.ABANDONED); 166 throw new FHIRException("Unknown SupplyDeliveryStatus code '" + codeString + "'"); 167 } 168 169 public String toCode(SupplyDeliveryStatus code) { 170 if (code == SupplyDeliveryStatus.INPROGRESS) 171 return "in-progress"; 172 if (code == SupplyDeliveryStatus.COMPLETED) 173 return "completed"; 174 if (code == SupplyDeliveryStatus.ABANDONED) 175 return "abandoned"; 176 return "?"; 177 } 178 } 179 180 /** 181 * Identifier assigned by the dispensing facility when the item(s) is dispensed. 182 */ 183 @Child(name = "identifier", type = { 184 Identifier.class }, order = 0, min = 0, max = 1, modifier = false, summary = true) 185 @Description(shortDefinition = "External identifier", formalDefinition = "Identifier assigned by the dispensing facility when the item(s) is dispensed.") 186 protected Identifier identifier; 187 188 /** 189 * A code specifying the state of the dispense event. 190 */ 191 @Child(name = "status", type = { CodeType.class }, order = 1, min = 0, max = 1, modifier = true, summary = true) 192 @Description(shortDefinition = "in-progress | completed | abandoned", formalDefinition = "A code specifying the state of the dispense event.") 193 protected Enumeration<SupplyDeliveryStatus> status; 194 195 /** 196 * A link to a resource representing the person whom the delivered item is for. 197 */ 198 @Child(name = "patient", type = { Patient.class }, order = 2, min = 0, max = 1, modifier = false, summary = true) 199 @Description(shortDefinition = "Patient for whom the item is supplied", formalDefinition = "A link to a resource representing the person whom the delivered item is for.") 200 protected Reference patient; 201 202 /** 203 * The actual object that is the target of the reference (A link to a resource 204 * representing the person whom the delivered item is for.) 205 */ 206 protected Patient patientTarget; 207 208 /** 209 * Indicates the type of dispensing event that is performed. Examples include: 210 * Trial Fill, Completion of Trial, Partial Fill, Emergency Fill, Samples, etc. 211 */ 212 @Child(name = "type", type = { CodeableConcept.class }, order = 3, min = 0, max = 1, modifier = false, summary = true) 213 @Description(shortDefinition = "Category of dispense event", formalDefinition = "Indicates the type of dispensing event that is performed. Examples include: Trial Fill, Completion of Trial, Partial Fill, Emergency Fill, Samples, etc.") 214 protected CodeableConcept type; 215 216 /** 217 * The amount of supply that has been dispensed. Includes unit of measure. 218 */ 219 @Child(name = "quantity", type = { 220 SimpleQuantity.class }, order = 4, min = 0, max = 1, modifier = false, summary = true) 221 @Description(shortDefinition = "Amount dispensed", formalDefinition = "The amount of supply that has been dispensed. Includes unit of measure.") 222 protected SimpleQuantity quantity; 223 224 /** 225 * Identifies the medication, substance or device being dispensed. This is 226 * either a link to a resource representing the details of the item or a simple 227 * attribute carrying a code that identifies the item from a known list. 228 */ 229 @Child(name = "suppliedItem", type = { Medication.class, Substance.class, 230 Device.class }, order = 5, min = 0, max = 1, modifier = false, summary = true) 231 @Description(shortDefinition = "Medication, Substance, or Device supplied", formalDefinition = "Identifies the medication, substance or device being dispensed. This is either a link to a resource representing the details of the item or a simple attribute carrying a code that identifies the item from a known list.") 232 protected Reference suppliedItem; 233 234 /** 235 * The actual object that is the target of the reference (Identifies the 236 * medication, substance or device being dispensed. This is either a link to a 237 * resource representing the details of the item or a simple attribute carrying 238 * a code that identifies the item from a known list.) 239 */ 240 protected Resource suppliedItemTarget; 241 242 /** 243 * The individual responsible for dispensing the medication, supplier or device. 244 */ 245 @Child(name = "supplier", type = { 246 Practitioner.class }, order = 6, min = 0, max = 1, modifier = false, summary = true) 247 @Description(shortDefinition = "Dispenser", formalDefinition = "The individual responsible for dispensing the medication, supplier or device.") 248 protected Reference supplier; 249 250 /** 251 * The actual object that is the target of the reference (The individual 252 * responsible for dispensing the medication, supplier or device.) 253 */ 254 protected Practitioner supplierTarget; 255 256 /** 257 * The time the dispense event occurred. 258 */ 259 @Child(name = "whenPrepared", type = { Period.class }, order = 7, min = 0, max = 1, modifier = false, summary = true) 260 @Description(shortDefinition = "Dispensing time", formalDefinition = "The time the dispense event occurred.") 261 protected Period whenPrepared; 262 263 /** 264 * The time the dispensed item was sent or handed to the patient (or agent). 265 */ 266 @Child(name = "time", type = { DateTimeType.class }, order = 8, min = 0, max = 1, modifier = false, summary = true) 267 @Description(shortDefinition = "Handover time", formalDefinition = "The time the dispensed item was sent or handed to the patient (or agent).") 268 protected DateTimeType time; 269 270 /** 271 * Identification of the facility/location where the Supply was shipped to, as 272 * part of the dispense event. 273 */ 274 @Child(name = "destination", type = { Location.class }, order = 9, min = 0, max = 1, modifier = false, summary = true) 275 @Description(shortDefinition = "Where the Supply was sent", formalDefinition = "Identification of the facility/location where the Supply was shipped to, as part of the dispense event.") 276 protected Reference destination; 277 278 /** 279 * The actual object that is the target of the reference (Identification of the 280 * facility/location where the Supply was shipped to, as part of the dispense 281 * event.) 282 */ 283 protected Location destinationTarget; 284 285 /** 286 * Identifies the person who picked up the Supply. 287 */ 288 @Child(name = "receiver", type = { 289 Practitioner.class }, order = 10, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true) 290 @Description(shortDefinition = "Who collected the Supply", formalDefinition = "Identifies the person who picked up the Supply.") 291 protected List<Reference> receiver; 292 /** 293 * The actual objects that are the target of the reference (Identifies the 294 * person who picked up the Supply.) 295 */ 296 protected List<Practitioner> receiverTarget; 297 298 private static final long serialVersionUID = -1520129707L; 299 300 /* 301 * Constructor 302 */ 303 public SupplyDelivery() { 304 super(); 305 } 306 307 /** 308 * @return {@link #identifier} (Identifier assigned by the dispensing facility 309 * when the item(s) is dispensed.) 310 */ 311 public Identifier getIdentifier() { 312 if (this.identifier == null) 313 if (Configuration.errorOnAutoCreate()) 314 throw new Error("Attempt to auto-create SupplyDelivery.identifier"); 315 else if (Configuration.doAutoCreate()) 316 this.identifier = new Identifier(); // cc 317 return this.identifier; 318 } 319 320 public boolean hasIdentifier() { 321 return this.identifier != null && !this.identifier.isEmpty(); 322 } 323 324 /** 325 * @param value {@link #identifier} (Identifier assigned by the dispensing 326 * facility when the item(s) is dispensed.) 327 */ 328 public SupplyDelivery setIdentifier(Identifier value) { 329 this.identifier = value; 330 return this; 331 } 332 333 /** 334 * @return {@link #status} (A code specifying the state of the dispense event.). 335 * This is the underlying object with id, value and extensions. The 336 * accessor "getStatus" gives direct access to the value 337 */ 338 public Enumeration<SupplyDeliveryStatus> getStatusElement() { 339 if (this.status == null) 340 if (Configuration.errorOnAutoCreate()) 341 throw new Error("Attempt to auto-create SupplyDelivery.status"); 342 else if (Configuration.doAutoCreate()) 343 this.status = new Enumeration<SupplyDeliveryStatus>(new SupplyDeliveryStatusEnumFactory()); // bb 344 return this.status; 345 } 346 347 public boolean hasStatusElement() { 348 return this.status != null && !this.status.isEmpty(); 349 } 350 351 public boolean hasStatus() { 352 return this.status != null && !this.status.isEmpty(); 353 } 354 355 /** 356 * @param value {@link #status} (A code specifying the state of the dispense 357 * event.). This is the underlying object with id, value and 358 * extensions. The accessor "getStatus" gives direct access to the 359 * value 360 */ 361 public SupplyDelivery setStatusElement(Enumeration<SupplyDeliveryStatus> value) { 362 this.status = value; 363 return this; 364 } 365 366 /** 367 * @return A code specifying the state of the dispense event. 368 */ 369 public SupplyDeliveryStatus getStatus() { 370 return this.status == null ? null : this.status.getValue(); 371 } 372 373 /** 374 * @param value A code specifying the state of the dispense event. 375 */ 376 public SupplyDelivery setStatus(SupplyDeliveryStatus value) { 377 if (value == null) 378 this.status = null; 379 else { 380 if (this.status == null) 381 this.status = new Enumeration<SupplyDeliveryStatus>(new SupplyDeliveryStatusEnumFactory()); 382 this.status.setValue(value); 383 } 384 return this; 385 } 386 387 /** 388 * @return {@link #patient} (A link to a resource representing the person whom 389 * the delivered item is for.) 390 */ 391 public Reference getPatient() { 392 if (this.patient == null) 393 if (Configuration.errorOnAutoCreate()) 394 throw new Error("Attempt to auto-create SupplyDelivery.patient"); 395 else if (Configuration.doAutoCreate()) 396 this.patient = new Reference(); // cc 397 return this.patient; 398 } 399 400 public boolean hasPatient() { 401 return this.patient != null && !this.patient.isEmpty(); 402 } 403 404 /** 405 * @param value {@link #patient} (A link to a resource representing the person 406 * whom the delivered item is for.) 407 */ 408 public SupplyDelivery setPatient(Reference value) { 409 this.patient = value; 410 return this; 411 } 412 413 /** 414 * @return {@link #patient} The actual object that is the target of the 415 * reference. The reference library doesn't populate this, but you can 416 * use it to hold the resource if you resolve it. (A link to a resource 417 * representing the person whom the delivered item is for.) 418 */ 419 public Patient getPatientTarget() { 420 if (this.patientTarget == null) 421 if (Configuration.errorOnAutoCreate()) 422 throw new Error("Attempt to auto-create SupplyDelivery.patient"); 423 else if (Configuration.doAutoCreate()) 424 this.patientTarget = new Patient(); // aa 425 return this.patientTarget; 426 } 427 428 /** 429 * @param value {@link #patient} The actual object that is the target of the 430 * reference. The reference library doesn't use these, but you can 431 * use it to hold the resource if you resolve it. (A link to a 432 * resource representing the person whom the delivered item is 433 * for.) 434 */ 435 public SupplyDelivery setPatientTarget(Patient value) { 436 this.patientTarget = value; 437 return this; 438 } 439 440 /** 441 * @return {@link #type} (Indicates the type of dispensing event that is 442 * performed. Examples include: Trial Fill, Completion of Trial, Partial 443 * Fill, Emergency Fill, Samples, etc.) 444 */ 445 public CodeableConcept getType() { 446 if (this.type == null) 447 if (Configuration.errorOnAutoCreate()) 448 throw new Error("Attempt to auto-create SupplyDelivery.type"); 449 else if (Configuration.doAutoCreate()) 450 this.type = new CodeableConcept(); // cc 451 return this.type; 452 } 453 454 public boolean hasType() { 455 return this.type != null && !this.type.isEmpty(); 456 } 457 458 /** 459 * @param value {@link #type} (Indicates the type of dispensing event that is 460 * performed. Examples include: Trial Fill, Completion of Trial, 461 * Partial Fill, Emergency Fill, Samples, etc.) 462 */ 463 public SupplyDelivery setType(CodeableConcept value) { 464 this.type = value; 465 return this; 466 } 467 468 /** 469 * @return {@link #quantity} (The amount of supply that has been dispensed. 470 * Includes unit of measure.) 471 */ 472 public SimpleQuantity getQuantity() { 473 if (this.quantity == null) 474 if (Configuration.errorOnAutoCreate()) 475 throw new Error("Attempt to auto-create SupplyDelivery.quantity"); 476 else if (Configuration.doAutoCreate()) 477 this.quantity = new SimpleQuantity(); // cc 478 return this.quantity; 479 } 480 481 public boolean hasQuantity() { 482 return this.quantity != null && !this.quantity.isEmpty(); 483 } 484 485 /** 486 * @param value {@link #quantity} (The amount of supply that has been dispensed. 487 * Includes unit of measure.) 488 */ 489 public SupplyDelivery setQuantity(SimpleQuantity value) { 490 this.quantity = value; 491 return this; 492 } 493 494 /** 495 * @return {@link #suppliedItem} (Identifies the medication, substance or device 496 * being dispensed. This is either a link to a resource representing the 497 * details of the item or a simple attribute carrying a code that 498 * identifies the item from a known list.) 499 */ 500 public Reference getSuppliedItem() { 501 if (this.suppliedItem == null) 502 if (Configuration.errorOnAutoCreate()) 503 throw new Error("Attempt to auto-create SupplyDelivery.suppliedItem"); 504 else if (Configuration.doAutoCreate()) 505 this.suppliedItem = new Reference(); // cc 506 return this.suppliedItem; 507 } 508 509 public boolean hasSuppliedItem() { 510 return this.suppliedItem != null && !this.suppliedItem.isEmpty(); 511 } 512 513 /** 514 * @param value {@link #suppliedItem} (Identifies the medication, substance or 515 * device being dispensed. This is either a link to a resource 516 * representing the details of the item or a simple attribute 517 * carrying a code that identifies the item from a known list.) 518 */ 519 public SupplyDelivery setSuppliedItem(Reference value) { 520 this.suppliedItem = value; 521 return this; 522 } 523 524 /** 525 * @return {@link #suppliedItem} The actual object that is the target of the 526 * reference. The reference library doesn't populate this, but you can 527 * use it to hold the resource if you resolve it. (Identifies the 528 * medication, substance or device being dispensed. This is either a 529 * link to a resource representing the details of the item or a simple 530 * attribute carrying a code that identifies the item from a known 531 * list.) 532 */ 533 public Resource getSuppliedItemTarget() { 534 return this.suppliedItemTarget; 535 } 536 537 /** 538 * @param value {@link #suppliedItem} The actual object that is the target of 539 * the reference. The reference library doesn't use these, but you 540 * can use it to hold the resource if you resolve it. (Identifies 541 * the medication, substance or device being dispensed. This is 542 * either a link to a resource representing the details of the item 543 * or a simple attribute carrying a code that identifies the item 544 * from a known list.) 545 */ 546 public SupplyDelivery setSuppliedItemTarget(Resource value) { 547 this.suppliedItemTarget = value; 548 return this; 549 } 550 551 /** 552 * @return {@link #supplier} (The individual responsible for dispensing the 553 * medication, supplier or device.) 554 */ 555 public Reference getSupplier() { 556 if (this.supplier == null) 557 if (Configuration.errorOnAutoCreate()) 558 throw new Error("Attempt to auto-create SupplyDelivery.supplier"); 559 else if (Configuration.doAutoCreate()) 560 this.supplier = new Reference(); // cc 561 return this.supplier; 562 } 563 564 public boolean hasSupplier() { 565 return this.supplier != null && !this.supplier.isEmpty(); 566 } 567 568 /** 569 * @param value {@link #supplier} (The individual responsible for dispensing the 570 * medication, supplier or device.) 571 */ 572 public SupplyDelivery setSupplier(Reference value) { 573 this.supplier = value; 574 return this; 575 } 576 577 /** 578 * @return {@link #supplier} The actual object that is the target of the 579 * reference. The reference library doesn't populate this, but you can 580 * use it to hold the resource if you resolve it. (The individual 581 * responsible for dispensing the medication, supplier or device.) 582 */ 583 public Practitioner getSupplierTarget() { 584 if (this.supplierTarget == null) 585 if (Configuration.errorOnAutoCreate()) 586 throw new Error("Attempt to auto-create SupplyDelivery.supplier"); 587 else if (Configuration.doAutoCreate()) 588 this.supplierTarget = new Practitioner(); // aa 589 return this.supplierTarget; 590 } 591 592 /** 593 * @param value {@link #supplier} The actual object that is the target of the 594 * reference. The reference library doesn't use these, but you can 595 * use it to hold the resource if you resolve it. (The individual 596 * responsible for dispensing the medication, supplier or device.) 597 */ 598 public SupplyDelivery setSupplierTarget(Practitioner value) { 599 this.supplierTarget = value; 600 return this; 601 } 602 603 /** 604 * @return {@link #whenPrepared} (The time the dispense event occurred.) 605 */ 606 public Period getWhenPrepared() { 607 if (this.whenPrepared == null) 608 if (Configuration.errorOnAutoCreate()) 609 throw new Error("Attempt to auto-create SupplyDelivery.whenPrepared"); 610 else if (Configuration.doAutoCreate()) 611 this.whenPrepared = new Period(); // cc 612 return this.whenPrepared; 613 } 614 615 public boolean hasWhenPrepared() { 616 return this.whenPrepared != null && !this.whenPrepared.isEmpty(); 617 } 618 619 /** 620 * @param value {@link #whenPrepared} (The time the dispense event occurred.) 621 */ 622 public SupplyDelivery setWhenPrepared(Period value) { 623 this.whenPrepared = value; 624 return this; 625 } 626 627 /** 628 * @return {@link #time} (The time the dispensed item was sent or handed to the 629 * patient (or agent).). This is the underlying object with id, value 630 * and extensions. The accessor "getTime" gives direct access to the 631 * value 632 */ 633 public DateTimeType getTimeElement() { 634 if (this.time == null) 635 if (Configuration.errorOnAutoCreate()) 636 throw new Error("Attempt to auto-create SupplyDelivery.time"); 637 else if (Configuration.doAutoCreate()) 638 this.time = new DateTimeType(); // bb 639 return this.time; 640 } 641 642 public boolean hasTimeElement() { 643 return this.time != null && !this.time.isEmpty(); 644 } 645 646 public boolean hasTime() { 647 return this.time != null && !this.time.isEmpty(); 648 } 649 650 /** 651 * @param value {@link #time} (The time the dispensed item was sent or handed to 652 * the patient (or agent).). This is the underlying object with id, 653 * value and extensions. The accessor "getTime" gives direct access 654 * to the value 655 */ 656 public SupplyDelivery setTimeElement(DateTimeType value) { 657 this.time = value; 658 return this; 659 } 660 661 /** 662 * @return The time the dispensed item was sent or handed to the patient (or 663 * agent). 664 */ 665 public Date getTime() { 666 return this.time == null ? null : this.time.getValue(); 667 } 668 669 /** 670 * @param value The time the dispensed item was sent or handed to the patient 671 * (or agent). 672 */ 673 public SupplyDelivery setTime(Date value) { 674 if (value == null) 675 this.time = null; 676 else { 677 if (this.time == null) 678 this.time = new DateTimeType(); 679 this.time.setValue(value); 680 } 681 return this; 682 } 683 684 /** 685 * @return {@link #destination} (Identification of the facility/location where 686 * the Supply was shipped to, as part of the dispense event.) 687 */ 688 public Reference getDestination() { 689 if (this.destination == null) 690 if (Configuration.errorOnAutoCreate()) 691 throw new Error("Attempt to auto-create SupplyDelivery.destination"); 692 else if (Configuration.doAutoCreate()) 693 this.destination = new Reference(); // cc 694 return this.destination; 695 } 696 697 public boolean hasDestination() { 698 return this.destination != null && !this.destination.isEmpty(); 699 } 700 701 /** 702 * @param value {@link #destination} (Identification of the facility/location 703 * where the Supply was shipped to, as part of the dispense event.) 704 */ 705 public SupplyDelivery setDestination(Reference value) { 706 this.destination = value; 707 return this; 708 } 709 710 /** 711 * @return {@link #destination} The actual object that is the target of the 712 * reference. The reference library doesn't populate this, but you can 713 * use it to hold the resource if you resolve it. (Identification of the 714 * facility/location where the Supply was shipped to, as part of the 715 * dispense event.) 716 */ 717 public Location getDestinationTarget() { 718 if (this.destinationTarget == null) 719 if (Configuration.errorOnAutoCreate()) 720 throw new Error("Attempt to auto-create SupplyDelivery.destination"); 721 else if (Configuration.doAutoCreate()) 722 this.destinationTarget = new Location(); // aa 723 return this.destinationTarget; 724 } 725 726 /** 727 * @param value {@link #destination} The actual object that is the target of the 728 * reference. The reference library doesn't use these, but you can 729 * use it to hold the resource if you resolve it. (Identification 730 * of the facility/location where the Supply was shipped to, as 731 * part of the dispense event.) 732 */ 733 public SupplyDelivery setDestinationTarget(Location value) { 734 this.destinationTarget = value; 735 return this; 736 } 737 738 /** 739 * @return {@link #receiver} (Identifies the person who picked up the Supply.) 740 */ 741 public List<Reference> getReceiver() { 742 if (this.receiver == null) 743 this.receiver = new ArrayList<Reference>(); 744 return this.receiver; 745 } 746 747 public boolean hasReceiver() { 748 if (this.receiver == null) 749 return false; 750 for (Reference item : this.receiver) 751 if (!item.isEmpty()) 752 return true; 753 return false; 754 } 755 756 /** 757 * @return {@link #receiver} (Identifies the person who picked up the Supply.) 758 */ 759 // syntactic sugar 760 public Reference addReceiver() { // 3 761 Reference t = new Reference(); 762 if (this.receiver == null) 763 this.receiver = new ArrayList<Reference>(); 764 this.receiver.add(t); 765 return t; 766 } 767 768 // syntactic sugar 769 public SupplyDelivery addReceiver(Reference t) { // 3 770 if (t == null) 771 return this; 772 if (this.receiver == null) 773 this.receiver = new ArrayList<Reference>(); 774 this.receiver.add(t); 775 return this; 776 } 777 778 /** 779 * @return {@link #receiver} (The actual objects that are the target of the 780 * reference. The reference library doesn't populate this, but you can 781 * use this to hold the resources if you resolvethemt. Identifies the 782 * person who picked up the Supply.) 783 */ 784 public List<Practitioner> getReceiverTarget() { 785 if (this.receiverTarget == null) 786 this.receiverTarget = new ArrayList<Practitioner>(); 787 return this.receiverTarget; 788 } 789 790 // syntactic sugar 791 /** 792 * @return {@link #receiver} (Add an actual object that is the target of the 793 * reference. The reference library doesn't use these, but you can use 794 * this to hold the resources if you resolvethemt. Identifies the person 795 * who picked up the Supply.) 796 */ 797 public Practitioner addReceiverTarget() { 798 Practitioner r = new Practitioner(); 799 if (this.receiverTarget == null) 800 this.receiverTarget = new ArrayList<Practitioner>(); 801 this.receiverTarget.add(r); 802 return r; 803 } 804 805 protected void listChildren(List<Property> childrenList) { 806 super.listChildren(childrenList); 807 childrenList.add(new Property("identifier", "Identifier", 808 "Identifier assigned by the dispensing facility when the item(s) is dispensed.", 0, java.lang.Integer.MAX_VALUE, 809 identifier)); 810 childrenList.add(new Property("status", "code", "A code specifying the state of the dispense event.", 0, 811 java.lang.Integer.MAX_VALUE, status)); 812 childrenList.add(new Property("patient", "Reference(Patient)", 813 "A link to a resource representing the person whom the delivered item is for.", 0, java.lang.Integer.MAX_VALUE, 814 patient)); 815 childrenList.add(new Property("type", "CodeableConcept", 816 "Indicates the type of dispensing event that is performed. Examples include: Trial Fill, Completion of Trial, Partial Fill, Emergency Fill, Samples, etc.", 817 0, java.lang.Integer.MAX_VALUE, type)); 818 childrenList.add(new Property("quantity", "SimpleQuantity", 819 "The amount of supply that has been dispensed. Includes unit of measure.", 0, java.lang.Integer.MAX_VALUE, 820 quantity)); 821 childrenList.add(new Property("suppliedItem", "Reference(Medication|Substance|Device)", 822 "Identifies the medication, substance or device being dispensed. This is either a link to a resource representing the details of the item or a simple attribute carrying a code that identifies the item from a known list.", 823 0, java.lang.Integer.MAX_VALUE, suppliedItem)); 824 childrenList.add(new Property("supplier", "Reference(Practitioner)", 825 "The individual responsible for dispensing the medication, supplier or device.", 0, java.lang.Integer.MAX_VALUE, 826 supplier)); 827 childrenList.add(new Property("whenPrepared", "Period", "The time the dispense event occurred.", 0, 828 java.lang.Integer.MAX_VALUE, whenPrepared)); 829 childrenList.add( 830 new Property("time", "dateTime", "The time the dispensed item was sent or handed to the patient (or agent).", 0, 831 java.lang.Integer.MAX_VALUE, time)); 832 childrenList.add(new Property("destination", "Reference(Location)", 833 "Identification of the facility/location where the Supply was shipped to, as part of the dispense event.", 0, 834 java.lang.Integer.MAX_VALUE, destination)); 835 childrenList.add(new Property("receiver", "Reference(Practitioner)", 836 "Identifies the person who picked up the Supply.", 0, java.lang.Integer.MAX_VALUE, receiver)); 837 } 838 839 @Override 840 public void setProperty(String name, Base value) throws FHIRException { 841 if (name.equals("identifier")) 842 this.identifier = castToIdentifier(value); // Identifier 843 else if (name.equals("status")) 844 this.status = new SupplyDeliveryStatusEnumFactory().fromType(value); // Enumeration<SupplyDeliveryStatus> 845 else if (name.equals("patient")) 846 this.patient = castToReference(value); // Reference 847 else if (name.equals("type")) 848 this.type = castToCodeableConcept(value); // CodeableConcept 849 else if (name.equals("quantity")) 850 this.quantity = castToSimpleQuantity(value); // SimpleQuantity 851 else if (name.equals("suppliedItem")) 852 this.suppliedItem = castToReference(value); // Reference 853 else if (name.equals("supplier")) 854 this.supplier = castToReference(value); // Reference 855 else if (name.equals("whenPrepared")) 856 this.whenPrepared = castToPeriod(value); // Period 857 else if (name.equals("time")) 858 this.time = castToDateTime(value); // DateTimeType 859 else if (name.equals("destination")) 860 this.destination = castToReference(value); // Reference 861 else if (name.equals("receiver")) 862 this.getReceiver().add(castToReference(value)); 863 else 864 super.setProperty(name, value); 865 } 866 867 @Override 868 public Base addChild(String name) throws FHIRException { 869 if (name.equals("identifier")) { 870 this.identifier = new Identifier(); 871 return this.identifier; 872 } else if (name.equals("status")) { 873 throw new FHIRException("Cannot call addChild on a singleton property SupplyDelivery.status"); 874 } else if (name.equals("patient")) { 875 this.patient = new Reference(); 876 return this.patient; 877 } else if (name.equals("type")) { 878 this.type = new CodeableConcept(); 879 return this.type; 880 } else if (name.equals("quantity")) { 881 this.quantity = new SimpleQuantity(); 882 return this.quantity; 883 } else if (name.equals("suppliedItem")) { 884 this.suppliedItem = new Reference(); 885 return this.suppliedItem; 886 } else if (name.equals("supplier")) { 887 this.supplier = new Reference(); 888 return this.supplier; 889 } else if (name.equals("whenPrepared")) { 890 this.whenPrepared = new Period(); 891 return this.whenPrepared; 892 } else if (name.equals("time")) { 893 throw new FHIRException("Cannot call addChild on a singleton property SupplyDelivery.time"); 894 } else if (name.equals("destination")) { 895 this.destination = new Reference(); 896 return this.destination; 897 } else if (name.equals("receiver")) { 898 return addReceiver(); 899 } else 900 return super.addChild(name); 901 } 902 903 public String fhirType() { 904 return "SupplyDelivery"; 905 906 } 907 908 public SupplyDelivery copy() { 909 SupplyDelivery dst = new SupplyDelivery(); 910 copyValues(dst); 911 dst.identifier = identifier == null ? null : identifier.copy(); 912 dst.status = status == null ? null : status.copy(); 913 dst.patient = patient == null ? null : patient.copy(); 914 dst.type = type == null ? null : type.copy(); 915 dst.quantity = quantity == null ? null : quantity.copy(); 916 dst.suppliedItem = suppliedItem == null ? null : suppliedItem.copy(); 917 dst.supplier = supplier == null ? null : supplier.copy(); 918 dst.whenPrepared = whenPrepared == null ? null : whenPrepared.copy(); 919 dst.time = time == null ? null : time.copy(); 920 dst.destination = destination == null ? null : destination.copy(); 921 if (receiver != null) { 922 dst.receiver = new ArrayList<Reference>(); 923 for (Reference i : receiver) 924 dst.receiver.add(i.copy()); 925 } 926 ; 927 return dst; 928 } 929 930 protected SupplyDelivery typedCopy() { 931 return copy(); 932 } 933 934 @Override 935 public boolean equalsDeep(Base other) { 936 if (!super.equalsDeep(other)) 937 return false; 938 if (!(other instanceof SupplyDelivery)) 939 return false; 940 SupplyDelivery o = (SupplyDelivery) other; 941 return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) 942 && compareDeep(patient, o.patient, true) && compareDeep(type, o.type, true) 943 && compareDeep(quantity, o.quantity, true) && compareDeep(suppliedItem, o.suppliedItem, true) 944 && compareDeep(supplier, o.supplier, true) && compareDeep(whenPrepared, o.whenPrepared, true) 945 && compareDeep(time, o.time, true) && compareDeep(destination, o.destination, true) 946 && compareDeep(receiver, o.receiver, true); 947 } 948 949 @Override 950 public boolean equalsShallow(Base other) { 951 if (!super.equalsShallow(other)) 952 return false; 953 if (!(other instanceof SupplyDelivery)) 954 return false; 955 SupplyDelivery o = (SupplyDelivery) other; 956 return compareValues(status, o.status, true) && compareValues(time, o.time, true); 957 } 958 959 public boolean isEmpty() { 960 return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (status == null || status.isEmpty()) 961 && (patient == null || patient.isEmpty()) && (type == null || type.isEmpty()) 962 && (quantity == null || quantity.isEmpty()) && (suppliedItem == null || suppliedItem.isEmpty()) 963 && (supplier == null || supplier.isEmpty()) && (whenPrepared == null || whenPrepared.isEmpty()) 964 && (time == null || time.isEmpty()) && (destination == null || destination.isEmpty()) 965 && (receiver == null || receiver.isEmpty()); 966 } 967 968 @Override 969 public ResourceType getResourceType() { 970 return ResourceType.SupplyDelivery; 971 } 972 973 @SearchParamDefinition(name = "identifier", path = "SupplyDelivery.identifier", description = "External identifier", type = "token") 974 public static final String SP_IDENTIFIER = "identifier"; 975 @SearchParamDefinition(name = "receiver", path = "SupplyDelivery.receiver", description = "Who collected the Supply", type = "reference") 976 public static final String SP_RECEIVER = "receiver"; 977 @SearchParamDefinition(name = "patient", path = "SupplyDelivery.patient", description = "Patient for whom the item is supplied", type = "reference") 978 public static final String SP_PATIENT = "patient"; 979 @SearchParamDefinition(name = "supplier", path = "SupplyDelivery.supplier", description = "Dispenser", type = "reference") 980 public static final String SP_SUPPLIER = "supplier"; 981 @SearchParamDefinition(name = "status", path = "SupplyDelivery.status", description = "in-progress | completed | abandoned", type = "token") 982 public static final String SP_STATUS = "status"; 983 984}