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