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