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