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