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