001package org.hl7.fhir.dstu2.model; 002 003/* 004 Copyright (c) 2011+, HL7, Inc. 005 All rights reserved. 006 007 Redistribution and use in source and binary forms, with or without modification, 008 are permitted provided that the following conditions are met: 009 010 * Redistributions of source code must retain the above copyright notice, this 011 list of conditions and the following disclaimer. 012 * Redistributions in binary form must reproduce the above copyright notice, 013 this list of conditions and the following disclaimer in the documentation 014 and/or other materials provided with the distribution. 015 * Neither the name of HL7 nor the names of its contributors may be used to 016 endorse or promote products derived from this software without specific 017 prior written permission. 018 019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 020 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 021 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 022 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 023 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 024 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 025 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 026 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 027 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 028 POSSIBILITY OF SUCH DAMAGE. 029 030*/ 031 032// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2 033import java.util.ArrayList; 034import java.util.Date; 035import java.util.List; 036 037import ca.uhn.fhir.model.api.annotation.Block; 038import ca.uhn.fhir.model.api.annotation.Child; 039import ca.uhn.fhir.model.api.annotation.Description; 040import ca.uhn.fhir.model.api.annotation.ResourceDef; 041import ca.uhn.fhir.model.api.annotation.SearchParamDefinition; 042import org.hl7.fhir.instance.model.api.IBaseBackboneElement; 043import org.hl7.fhir.exceptions.FHIRException; 044 045/** 046 * A record of a request for a medication, substance or device used in the 047 * healthcare setting. 048 */ 049@ResourceDef(name = "SupplyRequest", profile = "http://hl7.org/fhir/Profile/SupplyRequest") 050public class SupplyRequest extends DomainResource { 051 052 public enum SupplyRequestStatus { 053 /** 054 * Supply has been requested, but not dispensed. 055 */ 056 REQUESTED, 057 /** 058 * Supply has been received by the requestor. 059 */ 060 COMPLETED, 061 /** 062 * The supply will not be completed because the supplier was unable or unwilling 063 * to supply the item. 064 */ 065 FAILED, 066 /** 067 * The orderer of the supply cancelled the request. 068 */ 069 CANCELLED, 070 /** 071 * added to help the parsers 072 */ 073 NULL; 074 075 public static SupplyRequestStatus fromCode(String codeString) throws FHIRException { 076 if (codeString == null || "".equals(codeString)) 077 return null; 078 if ("requested".equals(codeString)) 079 return REQUESTED; 080 if ("completed".equals(codeString)) 081 return COMPLETED; 082 if ("failed".equals(codeString)) 083 return FAILED; 084 if ("cancelled".equals(codeString)) 085 return CANCELLED; 086 throw new FHIRException("Unknown SupplyRequestStatus code '" + codeString + "'"); 087 } 088 089 public String toCode() { 090 switch (this) { 091 case REQUESTED: 092 return "requested"; 093 case COMPLETED: 094 return "completed"; 095 case FAILED: 096 return "failed"; 097 case CANCELLED: 098 return "cancelled"; 099 case NULL: 100 return null; 101 default: 102 return "?"; 103 } 104 } 105 106 public String getSystem() { 107 switch (this) { 108 case REQUESTED: 109 return "http://hl7.org/fhir/supplyrequest-status"; 110 case COMPLETED: 111 return "http://hl7.org/fhir/supplyrequest-status"; 112 case FAILED: 113 return "http://hl7.org/fhir/supplyrequest-status"; 114 case CANCELLED: 115 return "http://hl7.org/fhir/supplyrequest-status"; 116 case NULL: 117 return null; 118 default: 119 return "?"; 120 } 121 } 122 123 public String getDefinition() { 124 switch (this) { 125 case REQUESTED: 126 return "Supply has been requested, but not dispensed."; 127 case COMPLETED: 128 return "Supply has been received by the requestor."; 129 case FAILED: 130 return "The supply will not be completed because the supplier was unable or unwilling to supply the item."; 131 case CANCELLED: 132 return "The orderer of the supply cancelled the request."; 133 case NULL: 134 return null; 135 default: 136 return "?"; 137 } 138 } 139 140 public String getDisplay() { 141 switch (this) { 142 case REQUESTED: 143 return "Requested"; 144 case COMPLETED: 145 return "Received"; 146 case FAILED: 147 return "Failed"; 148 case CANCELLED: 149 return "Cancelled"; 150 case NULL: 151 return null; 152 default: 153 return "?"; 154 } 155 } 156 } 157 158 public static class SupplyRequestStatusEnumFactory implements EnumFactory<SupplyRequestStatus> { 159 public SupplyRequestStatus fromCode(String codeString) throws IllegalArgumentException { 160 if (codeString == null || "".equals(codeString)) 161 if (codeString == null || "".equals(codeString)) 162 return null; 163 if ("requested".equals(codeString)) 164 return SupplyRequestStatus.REQUESTED; 165 if ("completed".equals(codeString)) 166 return SupplyRequestStatus.COMPLETED; 167 if ("failed".equals(codeString)) 168 return SupplyRequestStatus.FAILED; 169 if ("cancelled".equals(codeString)) 170 return SupplyRequestStatus.CANCELLED; 171 throw new IllegalArgumentException("Unknown SupplyRequestStatus code '" + codeString + "'"); 172 } 173 174 public Enumeration<SupplyRequestStatus> fromType(Base code) throws FHIRException { 175 if (code == null || code.isEmpty()) 176 return null; 177 String codeString = ((PrimitiveType) code).asStringValue(); 178 if (codeString == null || "".equals(codeString)) 179 return null; 180 if ("requested".equals(codeString)) 181 return new Enumeration<SupplyRequestStatus>(this, SupplyRequestStatus.REQUESTED); 182 if ("completed".equals(codeString)) 183 return new Enumeration<SupplyRequestStatus>(this, SupplyRequestStatus.COMPLETED); 184 if ("failed".equals(codeString)) 185 return new Enumeration<SupplyRequestStatus>(this, SupplyRequestStatus.FAILED); 186 if ("cancelled".equals(codeString)) 187 return new Enumeration<SupplyRequestStatus>(this, SupplyRequestStatus.CANCELLED); 188 throw new FHIRException("Unknown SupplyRequestStatus code '" + codeString + "'"); 189 } 190 191 public String toCode(SupplyRequestStatus code) { 192 if (code == SupplyRequestStatus.REQUESTED) 193 return "requested"; 194 if (code == SupplyRequestStatus.COMPLETED) 195 return "completed"; 196 if (code == SupplyRequestStatus.FAILED) 197 return "failed"; 198 if (code == SupplyRequestStatus.CANCELLED) 199 return "cancelled"; 200 return "?"; 201 } 202 } 203 204 @Block() 205 public static class SupplyRequestWhenComponent extends BackboneElement implements IBaseBackboneElement { 206 /** 207 * Code indicating when the request should be fulfilled. 208 */ 209 @Child(name = "code", type = { 210 CodeableConcept.class }, order = 1, min = 0, max = 1, modifier = false, summary = true) 211 @Description(shortDefinition = "Fulfilment code", formalDefinition = "Code indicating when the request should be fulfilled.") 212 protected CodeableConcept code; 213 214 /** 215 * Formal fulfillment schedule. 216 */ 217 @Child(name = "schedule", type = { Timing.class }, order = 2, min = 0, max = 1, modifier = false, summary = true) 218 @Description(shortDefinition = "Formal fulfillment schedule", formalDefinition = "Formal fulfillment schedule.") 219 protected Timing schedule; 220 221 private static final long serialVersionUID = 307115287L; 222 223 /* 224 * Constructor 225 */ 226 public SupplyRequestWhenComponent() { 227 super(); 228 } 229 230 /** 231 * @return {@link #code} (Code indicating when the request should be fulfilled.) 232 */ 233 public CodeableConcept getCode() { 234 if (this.code == null) 235 if (Configuration.errorOnAutoCreate()) 236 throw new Error("Attempt to auto-create SupplyRequestWhenComponent.code"); 237 else if (Configuration.doAutoCreate()) 238 this.code = new CodeableConcept(); // cc 239 return this.code; 240 } 241 242 public boolean hasCode() { 243 return this.code != null && !this.code.isEmpty(); 244 } 245 246 /** 247 * @param value {@link #code} (Code indicating when the request should be 248 * fulfilled.) 249 */ 250 public SupplyRequestWhenComponent setCode(CodeableConcept value) { 251 this.code = value; 252 return this; 253 } 254 255 /** 256 * @return {@link #schedule} (Formal fulfillment schedule.) 257 */ 258 public Timing getSchedule() { 259 if (this.schedule == null) 260 if (Configuration.errorOnAutoCreate()) 261 throw new Error("Attempt to auto-create SupplyRequestWhenComponent.schedule"); 262 else if (Configuration.doAutoCreate()) 263 this.schedule = new Timing(); // cc 264 return this.schedule; 265 } 266 267 public boolean hasSchedule() { 268 return this.schedule != null && !this.schedule.isEmpty(); 269 } 270 271 /** 272 * @param value {@link #schedule} (Formal fulfillment schedule.) 273 */ 274 public SupplyRequestWhenComponent setSchedule(Timing value) { 275 this.schedule = value; 276 return this; 277 } 278 279 protected void listChildren(List<Property> childrenList) { 280 super.listChildren(childrenList); 281 childrenList.add(new Property("code", "CodeableConcept", "Code indicating when the request should be fulfilled.", 282 0, java.lang.Integer.MAX_VALUE, code)); 283 childrenList.add( 284 new Property("schedule", "Timing", "Formal fulfillment schedule.", 0, java.lang.Integer.MAX_VALUE, schedule)); 285 } 286 287 @Override 288 public void setProperty(String name, Base value) throws FHIRException { 289 if (name.equals("code")) 290 this.code = castToCodeableConcept(value); // CodeableConcept 291 else if (name.equals("schedule")) 292 this.schedule = castToTiming(value); // Timing 293 else 294 super.setProperty(name, value); 295 } 296 297 @Override 298 public Base addChild(String name) throws FHIRException { 299 if (name.equals("code")) { 300 this.code = new CodeableConcept(); 301 return this.code; 302 } else if (name.equals("schedule")) { 303 this.schedule = new Timing(); 304 return this.schedule; 305 } else 306 return super.addChild(name); 307 } 308 309 public SupplyRequestWhenComponent copy() { 310 SupplyRequestWhenComponent dst = new SupplyRequestWhenComponent(); 311 copyValues(dst); 312 dst.code = code == null ? null : code.copy(); 313 dst.schedule = schedule == null ? null : schedule.copy(); 314 return dst; 315 } 316 317 @Override 318 public boolean equalsDeep(Base other) { 319 if (!super.equalsDeep(other)) 320 return false; 321 if (!(other instanceof SupplyRequestWhenComponent)) 322 return false; 323 SupplyRequestWhenComponent o = (SupplyRequestWhenComponent) other; 324 return compareDeep(code, o.code, true) && compareDeep(schedule, o.schedule, true); 325 } 326 327 @Override 328 public boolean equalsShallow(Base other) { 329 if (!super.equalsShallow(other)) 330 return false; 331 if (!(other instanceof SupplyRequestWhenComponent)) 332 return false; 333 SupplyRequestWhenComponent o = (SupplyRequestWhenComponent) other; 334 return true; 335 } 336 337 public boolean isEmpty() { 338 return super.isEmpty() && (code == null || code.isEmpty()) && (schedule == null || schedule.isEmpty()); 339 } 340 341 public String fhirType() { 342 return "SupplyRequest.when"; 343 344 } 345 346 } 347 348 /** 349 * A link to a resource representing the person whom the ordered item is for. 350 */ 351 @Child(name = "patient", type = { Patient.class }, order = 0, min = 0, max = 1, modifier = false, summary = true) 352 @Description(shortDefinition = "Patient for whom the item is supplied", formalDefinition = "A link to a resource representing the person whom the ordered item is for.") 353 protected Reference patient; 354 355 /** 356 * The actual object that is the target of the reference (A link to a resource 357 * representing the person whom the ordered item is for.) 358 */ 359 protected Patient patientTarget; 360 361 /** 362 * The Practitioner , Organization or Patient who initiated this order for the 363 * supply. 364 */ 365 @Child(name = "source", type = { Practitioner.class, Organization.class, 366 Patient.class }, order = 1, min = 0, max = 1, modifier = false, summary = true) 367 @Description(shortDefinition = "Who initiated this order", formalDefinition = "The Practitioner , Organization or Patient who initiated this order for the supply.") 368 protected Reference source; 369 370 /** 371 * The actual object that is the target of the reference (The Practitioner , 372 * Organization or Patient who initiated this order for the supply.) 373 */ 374 protected Resource sourceTarget; 375 376 /** 377 * When the request was made. 378 */ 379 @Child(name = "date", type = { DateTimeType.class }, order = 2, min = 0, max = 1, modifier = false, summary = true) 380 @Description(shortDefinition = "When the request was made", formalDefinition = "When the request was made.") 381 protected DateTimeType date; 382 383 /** 384 * Unique identifier for this supply request. 385 */ 386 @Child(name = "identifier", type = { 387 Identifier.class }, order = 3, min = 0, max = 1, modifier = false, summary = true) 388 @Description(shortDefinition = "Unique identifier", formalDefinition = "Unique identifier for this supply request.") 389 protected Identifier identifier; 390 391 /** 392 * Status of the supply request. 393 */ 394 @Child(name = "status", type = { CodeType.class }, order = 4, min = 0, max = 1, modifier = true, summary = true) 395 @Description(shortDefinition = "requested | completed | failed | cancelled", formalDefinition = "Status of the supply request.") 396 protected Enumeration<SupplyRequestStatus> status; 397 398 /** 399 * Category of supply, e.g. central, non-stock, etc. This is used to support 400 * work flows associated with the supply process. 401 */ 402 @Child(name = "kind", type = { CodeableConcept.class }, order = 5, min = 0, max = 1, modifier = false, summary = true) 403 @Description(shortDefinition = "The kind of supply (central, non-stock, etc.)", formalDefinition = "Category of supply, e.g. central, non-stock, etc. This is used to support work flows associated with the supply process.") 404 protected CodeableConcept kind; 405 406 /** 407 * The item that is requested to be supplied. 408 */ 409 @Child(name = "orderedItem", type = { Medication.class, Substance.class, 410 Device.class }, order = 6, min = 0, max = 1, modifier = false, summary = true) 411 @Description(shortDefinition = "Medication, Substance, or Device requested to be supplied", formalDefinition = "The item that is requested to be supplied.") 412 protected Reference orderedItem; 413 414 /** 415 * The actual object that is the target of the reference (The item that is 416 * requested to be supplied.) 417 */ 418 protected Resource orderedItemTarget; 419 420 /** 421 * Who is intended to fulfill the request. 422 */ 423 @Child(name = "supplier", type = { 424 Organization.class }, order = 7, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true) 425 @Description(shortDefinition = "Who is intended to fulfill the request", formalDefinition = "Who is intended to fulfill the request.") 426 protected List<Reference> supplier; 427 /** 428 * The actual objects that are the target of the reference (Who is intended to 429 * fulfill the request.) 430 */ 431 protected List<Organization> supplierTarget; 432 433 /** 434 * Why the supply item was requested. 435 */ 436 @Child(name = "reason", type = { 437 CodeableConcept.class }, order = 8, min = 0, max = 1, modifier = false, summary = true) 438 @Description(shortDefinition = "Why the supply item was requested", formalDefinition = "Why the supply item was requested.") 439 protected Type reason; 440 441 /** 442 * When the request should be fulfilled. 443 */ 444 @Child(name = "when", type = {}, order = 9, min = 0, max = 1, modifier = false, summary = true) 445 @Description(shortDefinition = "When the request should be fulfilled", formalDefinition = "When the request should be fulfilled.") 446 protected SupplyRequestWhenComponent when; 447 448 private static final long serialVersionUID = 1649766198L; 449 450 /* 451 * Constructor 452 */ 453 public SupplyRequest() { 454 super(); 455 } 456 457 /** 458 * @return {@link #patient} (A link to a resource representing the person whom 459 * the ordered item is for.) 460 */ 461 public Reference getPatient() { 462 if (this.patient == null) 463 if (Configuration.errorOnAutoCreate()) 464 throw new Error("Attempt to auto-create SupplyRequest.patient"); 465 else if (Configuration.doAutoCreate()) 466 this.patient = new Reference(); // cc 467 return this.patient; 468 } 469 470 public boolean hasPatient() { 471 return this.patient != null && !this.patient.isEmpty(); 472 } 473 474 /** 475 * @param value {@link #patient} (A link to a resource representing the person 476 * whom the ordered item is for.) 477 */ 478 public SupplyRequest setPatient(Reference value) { 479 this.patient = value; 480 return this; 481 } 482 483 /** 484 * @return {@link #patient} The actual object that is the target of the 485 * reference. The reference library doesn't populate this, but you can 486 * use it to hold the resource if you resolve it. (A link to a resource 487 * representing the person whom the ordered item is for.) 488 */ 489 public Patient getPatientTarget() { 490 if (this.patientTarget == null) 491 if (Configuration.errorOnAutoCreate()) 492 throw new Error("Attempt to auto-create SupplyRequest.patient"); 493 else if (Configuration.doAutoCreate()) 494 this.patientTarget = new Patient(); // aa 495 return this.patientTarget; 496 } 497 498 /** 499 * @param value {@link #patient} The actual object that is the target of the 500 * reference. The reference library doesn't use these, but you can 501 * use it to hold the resource if you resolve it. (A link to a 502 * resource representing the person whom the ordered item is for.) 503 */ 504 public SupplyRequest setPatientTarget(Patient value) { 505 this.patientTarget = value; 506 return this; 507 } 508 509 /** 510 * @return {@link #source} (The Practitioner , Organization or Patient who 511 * initiated this order for the supply.) 512 */ 513 public Reference getSource() { 514 if (this.source == null) 515 if (Configuration.errorOnAutoCreate()) 516 throw new Error("Attempt to auto-create SupplyRequest.source"); 517 else if (Configuration.doAutoCreate()) 518 this.source = new Reference(); // cc 519 return this.source; 520 } 521 522 public boolean hasSource() { 523 return this.source != null && !this.source.isEmpty(); 524 } 525 526 /** 527 * @param value {@link #source} (The Practitioner , Organization or Patient who 528 * initiated this order for the supply.) 529 */ 530 public SupplyRequest setSource(Reference value) { 531 this.source = value; 532 return this; 533 } 534 535 /** 536 * @return {@link #source} The actual object that is the target of the 537 * reference. The reference library doesn't populate this, but you can 538 * use it to hold the resource if you resolve it. (The Practitioner , 539 * Organization or Patient who initiated this order for the supply.) 540 */ 541 public Resource getSourceTarget() { 542 return this.sourceTarget; 543 } 544 545 /** 546 * @param value {@link #source} The actual object that is the target of the 547 * reference. The reference library doesn't use these, but you can 548 * use it to hold the resource if you resolve it. (The Practitioner 549 * , Organization or Patient who initiated this order for the 550 * supply.) 551 */ 552 public SupplyRequest setSourceTarget(Resource value) { 553 this.sourceTarget = value; 554 return this; 555 } 556 557 /** 558 * @return {@link #date} (When the request was made.). This is the underlying 559 * object with id, value and extensions. The accessor "getDate" gives 560 * direct access to the value 561 */ 562 public DateTimeType getDateElement() { 563 if (this.date == null) 564 if (Configuration.errorOnAutoCreate()) 565 throw new Error("Attempt to auto-create SupplyRequest.date"); 566 else if (Configuration.doAutoCreate()) 567 this.date = new DateTimeType(); // bb 568 return this.date; 569 } 570 571 public boolean hasDateElement() { 572 return this.date != null && !this.date.isEmpty(); 573 } 574 575 public boolean hasDate() { 576 return this.date != null && !this.date.isEmpty(); 577 } 578 579 /** 580 * @param value {@link #date} (When the request was made.). This is the 581 * underlying object with id, value and extensions. The accessor 582 * "getDate" gives direct access to the value 583 */ 584 public SupplyRequest setDateElement(DateTimeType value) { 585 this.date = value; 586 return this; 587 } 588 589 /** 590 * @return When the request was made. 591 */ 592 public Date getDate() { 593 return this.date == null ? null : this.date.getValue(); 594 } 595 596 /** 597 * @param value When the request was made. 598 */ 599 public SupplyRequest setDate(Date value) { 600 if (value == null) 601 this.date = null; 602 else { 603 if (this.date == null) 604 this.date = new DateTimeType(); 605 this.date.setValue(value); 606 } 607 return this; 608 } 609 610 /** 611 * @return {@link #identifier} (Unique identifier for this supply request.) 612 */ 613 public Identifier getIdentifier() { 614 if (this.identifier == null) 615 if (Configuration.errorOnAutoCreate()) 616 throw new Error("Attempt to auto-create SupplyRequest.identifier"); 617 else if (Configuration.doAutoCreate()) 618 this.identifier = new Identifier(); // cc 619 return this.identifier; 620 } 621 622 public boolean hasIdentifier() { 623 return this.identifier != null && !this.identifier.isEmpty(); 624 } 625 626 /** 627 * @param value {@link #identifier} (Unique identifier for this supply request.) 628 */ 629 public SupplyRequest setIdentifier(Identifier value) { 630 this.identifier = value; 631 return this; 632 } 633 634 /** 635 * @return {@link #status} (Status of the supply request.). This is the 636 * underlying object with id, value and extensions. The accessor 637 * "getStatus" gives direct access to the value 638 */ 639 public Enumeration<SupplyRequestStatus> getStatusElement() { 640 if (this.status == null) 641 if (Configuration.errorOnAutoCreate()) 642 throw new Error("Attempt to auto-create SupplyRequest.status"); 643 else if (Configuration.doAutoCreate()) 644 this.status = new Enumeration<SupplyRequestStatus>(new SupplyRequestStatusEnumFactory()); // bb 645 return this.status; 646 } 647 648 public boolean hasStatusElement() { 649 return this.status != null && !this.status.isEmpty(); 650 } 651 652 public boolean hasStatus() { 653 return this.status != null && !this.status.isEmpty(); 654 } 655 656 /** 657 * @param value {@link #status} (Status of the supply request.). This is the 658 * underlying object with id, value and extensions. The accessor 659 * "getStatus" gives direct access to the value 660 */ 661 public SupplyRequest setStatusElement(Enumeration<SupplyRequestStatus> value) { 662 this.status = value; 663 return this; 664 } 665 666 /** 667 * @return Status of the supply request. 668 */ 669 public SupplyRequestStatus getStatus() { 670 return this.status == null ? null : this.status.getValue(); 671 } 672 673 /** 674 * @param value Status of the supply request. 675 */ 676 public SupplyRequest setStatus(SupplyRequestStatus value) { 677 if (value == null) 678 this.status = null; 679 else { 680 if (this.status == null) 681 this.status = new Enumeration<SupplyRequestStatus>(new SupplyRequestStatusEnumFactory()); 682 this.status.setValue(value); 683 } 684 return this; 685 } 686 687 /** 688 * @return {@link #kind} (Category of supply, e.g. central, non-stock, etc. This 689 * is used to support work flows associated with the supply process.) 690 */ 691 public CodeableConcept getKind() { 692 if (this.kind == null) 693 if (Configuration.errorOnAutoCreate()) 694 throw new Error("Attempt to auto-create SupplyRequest.kind"); 695 else if (Configuration.doAutoCreate()) 696 this.kind = new CodeableConcept(); // cc 697 return this.kind; 698 } 699 700 public boolean hasKind() { 701 return this.kind != null && !this.kind.isEmpty(); 702 } 703 704 /** 705 * @param value {@link #kind} (Category of supply, e.g. central, non-stock, etc. 706 * This is used to support work flows associated with the supply 707 * process.) 708 */ 709 public SupplyRequest setKind(CodeableConcept value) { 710 this.kind = value; 711 return this; 712 } 713 714 /** 715 * @return {@link #orderedItem} (The item that is requested to be supplied.) 716 */ 717 public Reference getOrderedItem() { 718 if (this.orderedItem == null) 719 if (Configuration.errorOnAutoCreate()) 720 throw new Error("Attempt to auto-create SupplyRequest.orderedItem"); 721 else if (Configuration.doAutoCreate()) 722 this.orderedItem = new Reference(); // cc 723 return this.orderedItem; 724 } 725 726 public boolean hasOrderedItem() { 727 return this.orderedItem != null && !this.orderedItem.isEmpty(); 728 } 729 730 /** 731 * @param value {@link #orderedItem} (The item that is requested to be 732 * supplied.) 733 */ 734 public SupplyRequest setOrderedItem(Reference value) { 735 this.orderedItem = value; 736 return this; 737 } 738 739 /** 740 * @return {@link #orderedItem} The actual object that is the target of the 741 * reference. The reference library doesn't populate this, but you can 742 * use it to hold the resource if you resolve it. (The item that is 743 * requested to be supplied.) 744 */ 745 public Resource getOrderedItemTarget() { 746 return this.orderedItemTarget; 747 } 748 749 /** 750 * @param value {@link #orderedItem} The actual object that is the target of the 751 * reference. The reference library doesn't use these, but you can 752 * use it to hold the resource if you resolve it. (The item that is 753 * requested to be supplied.) 754 */ 755 public SupplyRequest setOrderedItemTarget(Resource value) { 756 this.orderedItemTarget = value; 757 return this; 758 } 759 760 /** 761 * @return {@link #supplier} (Who is intended to fulfill the request.) 762 */ 763 public List<Reference> getSupplier() { 764 if (this.supplier == null) 765 this.supplier = new ArrayList<Reference>(); 766 return this.supplier; 767 } 768 769 public boolean hasSupplier() { 770 if (this.supplier == null) 771 return false; 772 for (Reference item : this.supplier) 773 if (!item.isEmpty()) 774 return true; 775 return false; 776 } 777 778 /** 779 * @return {@link #supplier} (Who is intended to fulfill the request.) 780 */ 781 // syntactic sugar 782 public Reference addSupplier() { // 3 783 Reference t = new Reference(); 784 if (this.supplier == null) 785 this.supplier = new ArrayList<Reference>(); 786 this.supplier.add(t); 787 return t; 788 } 789 790 // syntactic sugar 791 public SupplyRequest addSupplier(Reference t) { // 3 792 if (t == null) 793 return this; 794 if (this.supplier == null) 795 this.supplier = new ArrayList<Reference>(); 796 this.supplier.add(t); 797 return this; 798 } 799 800 /** 801 * @return {@link #supplier} (The actual objects that are the target of the 802 * reference. The reference library doesn't populate this, but you can 803 * use this to hold the resources if you resolvethemt. Who is intended 804 * to fulfill the request.) 805 */ 806 public List<Organization> getSupplierTarget() { 807 if (this.supplierTarget == null) 808 this.supplierTarget = new ArrayList<Organization>(); 809 return this.supplierTarget; 810 } 811 812 // syntactic sugar 813 /** 814 * @return {@link #supplier} (Add an actual object that is the target of the 815 * reference. The reference library doesn't use these, but you can use 816 * this to hold the resources if you resolvethemt. Who is intended to 817 * fulfill the request.) 818 */ 819 public Organization addSupplierTarget() { 820 Organization r = new Organization(); 821 if (this.supplierTarget == null) 822 this.supplierTarget = new ArrayList<Organization>(); 823 this.supplierTarget.add(r); 824 return r; 825 } 826 827 /** 828 * @return {@link #reason} (Why the supply item was requested.) 829 */ 830 public Type getReason() { 831 return this.reason; 832 } 833 834 /** 835 * @return {@link #reason} (Why the supply item was requested.) 836 */ 837 public CodeableConcept getReasonCodeableConcept() throws FHIRException { 838 if (!(this.reason instanceof CodeableConcept)) 839 throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but " 840 + this.reason.getClass().getName() + " was encountered"); 841 return (CodeableConcept) this.reason; 842 } 843 844 public boolean hasReasonCodeableConcept() { 845 return this.reason instanceof CodeableConcept; 846 } 847 848 /** 849 * @return {@link #reason} (Why the supply item was requested.) 850 */ 851 public Reference getReasonReference() throws FHIRException { 852 if (!(this.reason instanceof Reference)) 853 throw new FHIRException("Type mismatch: the type Reference was expected, but " + this.reason.getClass().getName() 854 + " was encountered"); 855 return (Reference) this.reason; 856 } 857 858 public boolean hasReasonReference() { 859 return this.reason instanceof Reference; 860 } 861 862 public boolean hasReason() { 863 return this.reason != null && !this.reason.isEmpty(); 864 } 865 866 /** 867 * @param value {@link #reason} (Why the supply item was requested.) 868 */ 869 public SupplyRequest setReason(Type value) { 870 this.reason = value; 871 return this; 872 } 873 874 /** 875 * @return {@link #when} (When the request should be fulfilled.) 876 */ 877 public SupplyRequestWhenComponent getWhen() { 878 if (this.when == null) 879 if (Configuration.errorOnAutoCreate()) 880 throw new Error("Attempt to auto-create SupplyRequest.when"); 881 else if (Configuration.doAutoCreate()) 882 this.when = new SupplyRequestWhenComponent(); // cc 883 return this.when; 884 } 885 886 public boolean hasWhen() { 887 return this.when != null && !this.when.isEmpty(); 888 } 889 890 /** 891 * @param value {@link #when} (When the request should be fulfilled.) 892 */ 893 public SupplyRequest setWhen(SupplyRequestWhenComponent value) { 894 this.when = value; 895 return this; 896 } 897 898 protected void listChildren(List<Property> childrenList) { 899 super.listChildren(childrenList); 900 childrenList.add(new Property("patient", "Reference(Patient)", 901 "A link to a resource representing the person whom the ordered item is for.", 0, java.lang.Integer.MAX_VALUE, 902 patient)); 903 childrenList.add(new Property("source", "Reference(Practitioner|Organization|Patient)", 904 "The Practitioner , Organization or Patient who initiated this order for the supply.", 0, 905 java.lang.Integer.MAX_VALUE, source)); 906 childrenList 907 .add(new Property("date", "dateTime", "When the request was made.", 0, java.lang.Integer.MAX_VALUE, date)); 908 childrenList.add(new Property("identifier", "Identifier", "Unique identifier for this supply request.", 0, 909 java.lang.Integer.MAX_VALUE, identifier)); 910 childrenList 911 .add(new Property("status", "code", "Status of the supply request.", 0, java.lang.Integer.MAX_VALUE, status)); 912 childrenList.add(new Property("kind", "CodeableConcept", 913 "Category of supply, e.g. central, non-stock, etc. This is used to support work flows associated with the supply process.", 914 0, java.lang.Integer.MAX_VALUE, kind)); 915 childrenList.add(new Property("orderedItem", "Reference(Medication|Substance|Device)", 916 "The item that is requested to be supplied.", 0, java.lang.Integer.MAX_VALUE, orderedItem)); 917 childrenList.add(new Property("supplier", "Reference(Organization)", "Who is intended to fulfill the request.", 0, 918 java.lang.Integer.MAX_VALUE, supplier)); 919 childrenList.add(new Property("reason[x]", "CodeableConcept|Reference(Any)", "Why the supply item was requested.", 920 0, java.lang.Integer.MAX_VALUE, reason)); 921 childrenList 922 .add(new Property("when", "", "When the request should be fulfilled.", 0, java.lang.Integer.MAX_VALUE, when)); 923 } 924 925 @Override 926 public void setProperty(String name, Base value) throws FHIRException { 927 if (name.equals("patient")) 928 this.patient = castToReference(value); // Reference 929 else if (name.equals("source")) 930 this.source = castToReference(value); // Reference 931 else if (name.equals("date")) 932 this.date = castToDateTime(value); // DateTimeType 933 else if (name.equals("identifier")) 934 this.identifier = castToIdentifier(value); // Identifier 935 else if (name.equals("status")) 936 this.status = new SupplyRequestStatusEnumFactory().fromType(value); // Enumeration<SupplyRequestStatus> 937 else if (name.equals("kind")) 938 this.kind = castToCodeableConcept(value); // CodeableConcept 939 else if (name.equals("orderedItem")) 940 this.orderedItem = castToReference(value); // Reference 941 else if (name.equals("supplier")) 942 this.getSupplier().add(castToReference(value)); 943 else if (name.equals("reason[x]")) 944 this.reason = (Type) value; // Type 945 else if (name.equals("when")) 946 this.when = (SupplyRequestWhenComponent) value; // SupplyRequestWhenComponent 947 else 948 super.setProperty(name, value); 949 } 950 951 @Override 952 public Base addChild(String name) throws FHIRException { 953 if (name.equals("patient")) { 954 this.patient = new Reference(); 955 return this.patient; 956 } else if (name.equals("source")) { 957 this.source = new Reference(); 958 return this.source; 959 } else if (name.equals("date")) { 960 throw new FHIRException("Cannot call addChild on a singleton property SupplyRequest.date"); 961 } else if (name.equals("identifier")) { 962 this.identifier = new Identifier(); 963 return this.identifier; 964 } else if (name.equals("status")) { 965 throw new FHIRException("Cannot call addChild on a singleton property SupplyRequest.status"); 966 } else if (name.equals("kind")) { 967 this.kind = new CodeableConcept(); 968 return this.kind; 969 } else if (name.equals("orderedItem")) { 970 this.orderedItem = new Reference(); 971 return this.orderedItem; 972 } else if (name.equals("supplier")) { 973 return addSupplier(); 974 } else if (name.equals("reasonCodeableConcept")) { 975 this.reason = new CodeableConcept(); 976 return this.reason; 977 } else if (name.equals("reasonReference")) { 978 this.reason = new Reference(); 979 return this.reason; 980 } else if (name.equals("when")) { 981 this.when = new SupplyRequestWhenComponent(); 982 return this.when; 983 } else 984 return super.addChild(name); 985 } 986 987 public String fhirType() { 988 return "SupplyRequest"; 989 990 } 991 992 public SupplyRequest copy() { 993 SupplyRequest dst = new SupplyRequest(); 994 copyValues(dst); 995 dst.patient = patient == null ? null : patient.copy(); 996 dst.source = source == null ? null : source.copy(); 997 dst.date = date == null ? null : date.copy(); 998 dst.identifier = identifier == null ? null : identifier.copy(); 999 dst.status = status == null ? null : status.copy(); 1000 dst.kind = kind == null ? null : kind.copy(); 1001 dst.orderedItem = orderedItem == null ? null : orderedItem.copy(); 1002 if (supplier != null) { 1003 dst.supplier = new ArrayList<Reference>(); 1004 for (Reference i : supplier) 1005 dst.supplier.add(i.copy()); 1006 } 1007 ; 1008 dst.reason = reason == null ? null : reason.copy(); 1009 dst.when = when == null ? null : when.copy(); 1010 return dst; 1011 } 1012 1013 protected SupplyRequest typedCopy() { 1014 return copy(); 1015 } 1016 1017 @Override 1018 public boolean equalsDeep(Base other) { 1019 if (!super.equalsDeep(other)) 1020 return false; 1021 if (!(other instanceof SupplyRequest)) 1022 return false; 1023 SupplyRequest o = (SupplyRequest) other; 1024 return compareDeep(patient, o.patient, true) && compareDeep(source, o.source, true) 1025 && compareDeep(date, o.date, true) && compareDeep(identifier, o.identifier, true) 1026 && compareDeep(status, o.status, true) && compareDeep(kind, o.kind, true) 1027 && compareDeep(orderedItem, o.orderedItem, true) && compareDeep(supplier, o.supplier, true) 1028 && compareDeep(reason, o.reason, true) && compareDeep(when, o.when, true); 1029 } 1030 1031 @Override 1032 public boolean equalsShallow(Base other) { 1033 if (!super.equalsShallow(other)) 1034 return false; 1035 if (!(other instanceof SupplyRequest)) 1036 return false; 1037 SupplyRequest o = (SupplyRequest) other; 1038 return compareValues(date, o.date, true) && compareValues(status, o.status, true); 1039 } 1040 1041 public boolean isEmpty() { 1042 return super.isEmpty() && (patient == null || patient.isEmpty()) && (source == null || source.isEmpty()) 1043 && (date == null || date.isEmpty()) && (identifier == null || identifier.isEmpty()) 1044 && (status == null || status.isEmpty()) && (kind == null || kind.isEmpty()) 1045 && (orderedItem == null || orderedItem.isEmpty()) && (supplier == null || supplier.isEmpty()) 1046 && (reason == null || reason.isEmpty()) && (when == null || when.isEmpty()); 1047 } 1048 1049 @Override 1050 public ResourceType getResourceType() { 1051 return ResourceType.SupplyRequest; 1052 } 1053 1054 @SearchParamDefinition(name = "date", path = "SupplyRequest.date", description = "When the request was made", type = "date") 1055 public static final String SP_DATE = "date"; 1056 @SearchParamDefinition(name = "identifier", path = "SupplyRequest.identifier", description = "Unique identifier", type = "token") 1057 public static final String SP_IDENTIFIER = "identifier"; 1058 @SearchParamDefinition(name = "kind", path = "SupplyRequest.kind", description = "The kind of supply (central, non-stock, etc.)", type = "token") 1059 public static final String SP_KIND = "kind"; 1060 @SearchParamDefinition(name = "patient", path = "SupplyRequest.patient", description = "Patient for whom the item is supplied", type = "reference") 1061 public static final String SP_PATIENT = "patient"; 1062 @SearchParamDefinition(name = "supplier", path = "SupplyRequest.supplier", description = "Who is intended to fulfill the request", type = "reference") 1063 public static final String SP_SUPPLIER = "supplier"; 1064 @SearchParamDefinition(name = "source", path = "SupplyRequest.source", description = "Who initiated this order", type = "reference") 1065 public static final String SP_SOURCE = "source"; 1066 @SearchParamDefinition(name = "status", path = "SupplyRequest.status", description = "requested | completed | failed | cancelled", type = "token") 1067 public static final String SP_STATUS = "status"; 1068 1069}