001package org.hl7.fhir.dstu3.model;
002
003/*-
004 * #%L
005 * org.hl7.fhir.dstu3
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 Fri, Mar 16, 2018 15:21+1100 for FHIR v3.0.x
054import java.util.ArrayList;
055import java.util.Date;
056import java.util.List;
057
058import org.hl7.fhir.exceptions.FHIRException;
059import org.hl7.fhir.exceptions.FHIRFormatError;
060import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
061
062import ca.uhn.fhir.model.api.annotation.Block;
063import ca.uhn.fhir.model.api.annotation.Child;
064import ca.uhn.fhir.model.api.annotation.Description;
065import ca.uhn.fhir.model.api.annotation.ResourceDef;
066import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
067/**
068 * A record of a request for a medication, substance or device used in the healthcare setting.
069 */
070@ResourceDef(name="SupplyRequest", profile="http://hl7.org/fhir/Profile/SupplyRequest")
071public class SupplyRequest extends DomainResource {
072
073    public enum SupplyRequestStatus {
074        /**
075         * The request has been created but is not yet complete or ready for action
076         */
077        DRAFT, 
078        /**
079         * The request is ready to be acted upon
080         */
081        ACTIVE, 
082        /**
083         * The authorization/request to act has been temporarily withdrawn but is expected to resume in the future
084         */
085        SUSPENDED, 
086        /**
087         * The authorization/request to act has been terminated prior to the full completion of the intended actions.  No further activity should occur.
088         */
089        CANCELLED, 
090        /**
091         * Activity against the request has been sufficiently completed to the satisfaction of the requester
092         */
093        COMPLETED, 
094        /**
095         * This electronic record should never have existed, though it is possible that real-world decisions were based on it.  (If real-world activity has occurred, the status should be "cancelled" rather than "entered-in-error".)
096         */
097        ENTEREDINERROR, 
098        /**
099         * The authoring system does not know which of the status values currently applies for this request.  Note: This concept is not to be used for "other" - one of the listed statuses is presumed to apply, it's just not known which one.
100         */
101        UNKNOWN, 
102        /**
103         * added to help the parsers with the generic types
104         */
105        NULL;
106        public static SupplyRequestStatus fromCode(String codeString) throws FHIRException {
107            if (codeString == null || "".equals(codeString))
108                return null;
109        if ("draft".equals(codeString))
110          return DRAFT;
111        if ("active".equals(codeString))
112          return ACTIVE;
113        if ("suspended".equals(codeString))
114          return SUSPENDED;
115        if ("cancelled".equals(codeString))
116          return CANCELLED;
117        if ("completed".equals(codeString))
118          return COMPLETED;
119        if ("entered-in-error".equals(codeString))
120          return ENTEREDINERROR;
121        if ("unknown".equals(codeString))
122          return UNKNOWN;
123        if (Configuration.isAcceptInvalidEnums())
124          return null;
125        else
126          throw new FHIRException("Unknown SupplyRequestStatus code '"+codeString+"'");
127        }
128        public String toCode() {
129          switch (this) {
130            case DRAFT: return "draft";
131            case ACTIVE: return "active";
132            case SUSPENDED: return "suspended";
133            case CANCELLED: return "cancelled";
134            case COMPLETED: return "completed";
135            case ENTEREDINERROR: return "entered-in-error";
136            case UNKNOWN: return "unknown";
137            default: return "?";
138          }
139        }
140        public String getSystem() {
141          switch (this) {
142            case DRAFT: return "http://hl7.org/fhir/supplyrequest-status";
143            case ACTIVE: return "http://hl7.org/fhir/supplyrequest-status";
144            case SUSPENDED: return "http://hl7.org/fhir/supplyrequest-status";
145            case CANCELLED: return "http://hl7.org/fhir/supplyrequest-status";
146            case COMPLETED: return "http://hl7.org/fhir/supplyrequest-status";
147            case ENTEREDINERROR: return "http://hl7.org/fhir/supplyrequest-status";
148            case UNKNOWN: return "http://hl7.org/fhir/supplyrequest-status";
149            default: return "?";
150          }
151        }
152        public String getDefinition() {
153          switch (this) {
154            case DRAFT: return "The request has been created but is not yet complete or ready for action";
155            case ACTIVE: return "The request is ready to be acted upon";
156            case SUSPENDED: return "The authorization/request to act has been temporarily withdrawn but is expected to resume in the future";
157            case CANCELLED: return "The authorization/request to act has been terminated prior to the full completion of the intended actions.  No further activity should occur.";
158            case COMPLETED: return "Activity against the request has been sufficiently completed to the satisfaction of the requester";
159            case ENTEREDINERROR: return "This electronic record should never have existed, though it is possible that real-world decisions were based on it.  (If real-world activity has occurred, the status should be \"cancelled\" rather than \"entered-in-error\".)";
160            case UNKNOWN: return "The authoring system does not know which of the status values currently applies for this request.  Note: This concept is not to be used for \"other\" - one of the listed statuses is presumed to apply, it's just not known which one.";
161            default: return "?";
162          }
163        }
164        public String getDisplay() {
165          switch (this) {
166            case DRAFT: return "Draft";
167            case ACTIVE: return "Active";
168            case SUSPENDED: return "Suspended";
169            case CANCELLED: return "Cancelled";
170            case COMPLETED: return "Completed";
171            case ENTEREDINERROR: return "Entered in Error";
172            case UNKNOWN: return "Unknown";
173            default: return "?";
174          }
175        }
176    }
177
178  public static class SupplyRequestStatusEnumFactory implements EnumFactory<SupplyRequestStatus> {
179    public SupplyRequestStatus fromCode(String codeString) throws IllegalArgumentException {
180      if (codeString == null || "".equals(codeString))
181            if (codeString == null || "".equals(codeString))
182                return null;
183        if ("draft".equals(codeString))
184          return SupplyRequestStatus.DRAFT;
185        if ("active".equals(codeString))
186          return SupplyRequestStatus.ACTIVE;
187        if ("suspended".equals(codeString))
188          return SupplyRequestStatus.SUSPENDED;
189        if ("cancelled".equals(codeString))
190          return SupplyRequestStatus.CANCELLED;
191        if ("completed".equals(codeString))
192          return SupplyRequestStatus.COMPLETED;
193        if ("entered-in-error".equals(codeString))
194          return SupplyRequestStatus.ENTEREDINERROR;
195        if ("unknown".equals(codeString))
196          return SupplyRequestStatus.UNKNOWN;
197        throw new IllegalArgumentException("Unknown SupplyRequestStatus code '"+codeString+"'");
198        }
199        public Enumeration<SupplyRequestStatus> fromType(Base code) throws FHIRException {
200          if (code == null)
201            return null;
202          if (code.isEmpty())
203            return new Enumeration<SupplyRequestStatus>(this);
204          String codeString = ((PrimitiveType) code).asStringValue();
205          if (codeString == null || "".equals(codeString))
206            return null;
207        if ("draft".equals(codeString))
208          return new Enumeration<SupplyRequestStatus>(this, SupplyRequestStatus.DRAFT);
209        if ("active".equals(codeString))
210          return new Enumeration<SupplyRequestStatus>(this, SupplyRequestStatus.ACTIVE);
211        if ("suspended".equals(codeString))
212          return new Enumeration<SupplyRequestStatus>(this, SupplyRequestStatus.SUSPENDED);
213        if ("cancelled".equals(codeString))
214          return new Enumeration<SupplyRequestStatus>(this, SupplyRequestStatus.CANCELLED);
215        if ("completed".equals(codeString))
216          return new Enumeration<SupplyRequestStatus>(this, SupplyRequestStatus.COMPLETED);
217        if ("entered-in-error".equals(codeString))
218          return new Enumeration<SupplyRequestStatus>(this, SupplyRequestStatus.ENTEREDINERROR);
219        if ("unknown".equals(codeString))
220          return new Enumeration<SupplyRequestStatus>(this, SupplyRequestStatus.UNKNOWN);
221        throw new FHIRException("Unknown SupplyRequestStatus code '"+codeString+"'");
222        }
223    public String toCode(SupplyRequestStatus code) {
224      if (code == SupplyRequestStatus.DRAFT)
225        return "draft";
226      if (code == SupplyRequestStatus.ACTIVE)
227        return "active";
228      if (code == SupplyRequestStatus.SUSPENDED)
229        return "suspended";
230      if (code == SupplyRequestStatus.CANCELLED)
231        return "cancelled";
232      if (code == SupplyRequestStatus.COMPLETED)
233        return "completed";
234      if (code == SupplyRequestStatus.ENTEREDINERROR)
235        return "entered-in-error";
236      if (code == SupplyRequestStatus.UNKNOWN)
237        return "unknown";
238      return "?";
239      }
240    public String toSystem(SupplyRequestStatus code) {
241      return code.getSystem();
242      }
243    }
244
245    public enum RequestPriority {
246        /**
247         * The request has normal priority
248         */
249        ROUTINE, 
250        /**
251         * The request should be actioned promptly - higher priority than routine
252         */
253        URGENT, 
254        /**
255         * The request should be actioned as soon as possible - higher priority than urgent
256         */
257        ASAP, 
258        /**
259         * The request should be actioned immediately - highest possible priority.  E.g. an emergency
260         */
261        STAT, 
262        /**
263         * added to help the parsers with the generic types
264         */
265        NULL;
266        public static RequestPriority fromCode(String codeString) throws FHIRException {
267            if (codeString == null || "".equals(codeString))
268                return null;
269        if ("routine".equals(codeString))
270          return ROUTINE;
271        if ("urgent".equals(codeString))
272          return URGENT;
273        if ("asap".equals(codeString))
274          return ASAP;
275        if ("stat".equals(codeString))
276          return STAT;
277        if (Configuration.isAcceptInvalidEnums())
278          return null;
279        else
280          throw new FHIRException("Unknown RequestPriority code '"+codeString+"'");
281        }
282        public String toCode() {
283          switch (this) {
284            case ROUTINE: return "routine";
285            case URGENT: return "urgent";
286            case ASAP: return "asap";
287            case STAT: return "stat";
288            default: return "?";
289          }
290        }
291        public String getSystem() {
292          switch (this) {
293            case ROUTINE: return "http://hl7.org/fhir/request-priority";
294            case URGENT: return "http://hl7.org/fhir/request-priority";
295            case ASAP: return "http://hl7.org/fhir/request-priority";
296            case STAT: return "http://hl7.org/fhir/request-priority";
297            default: return "?";
298          }
299        }
300        public String getDefinition() {
301          switch (this) {
302            case ROUTINE: return "The request has normal priority";
303            case URGENT: return "The request should be actioned promptly - higher priority than routine";
304            case ASAP: return "The request should be actioned as soon as possible - higher priority than urgent";
305            case STAT: return "The request should be actioned immediately - highest possible priority.  E.g. an emergency";
306            default: return "?";
307          }
308        }
309        public String getDisplay() {
310          switch (this) {
311            case ROUTINE: return "Routine";
312            case URGENT: return "Urgent";
313            case ASAP: return "ASAP";
314            case STAT: return "STAT";
315            default: return "?";
316          }
317        }
318    }
319
320  public static class RequestPriorityEnumFactory implements EnumFactory<RequestPriority> {
321    public RequestPriority fromCode(String codeString) throws IllegalArgumentException {
322      if (codeString == null || "".equals(codeString))
323            if (codeString == null || "".equals(codeString))
324                return null;
325        if ("routine".equals(codeString))
326          return RequestPriority.ROUTINE;
327        if ("urgent".equals(codeString))
328          return RequestPriority.URGENT;
329        if ("asap".equals(codeString))
330          return RequestPriority.ASAP;
331        if ("stat".equals(codeString))
332          return RequestPriority.STAT;
333        throw new IllegalArgumentException("Unknown RequestPriority code '"+codeString+"'");
334        }
335        public Enumeration<RequestPriority> fromType(Base code) throws FHIRException {
336          if (code == null)
337            return null;
338          if (code.isEmpty())
339            return new Enumeration<RequestPriority>(this);
340          String codeString = ((PrimitiveType) code).asStringValue();
341          if (codeString == null || "".equals(codeString))
342            return null;
343        if ("routine".equals(codeString))
344          return new Enumeration<RequestPriority>(this, RequestPriority.ROUTINE);
345        if ("urgent".equals(codeString))
346          return new Enumeration<RequestPriority>(this, RequestPriority.URGENT);
347        if ("asap".equals(codeString))
348          return new Enumeration<RequestPriority>(this, RequestPriority.ASAP);
349        if ("stat".equals(codeString))
350          return new Enumeration<RequestPriority>(this, RequestPriority.STAT);
351        throw new FHIRException("Unknown RequestPriority code '"+codeString+"'");
352        }
353    public String toCode(RequestPriority code) {
354      if (code == RequestPriority.ROUTINE)
355        return "routine";
356      if (code == RequestPriority.URGENT)
357        return "urgent";
358      if (code == RequestPriority.ASAP)
359        return "asap";
360      if (code == RequestPriority.STAT)
361        return "stat";
362      return "?";
363      }
364    public String toSystem(RequestPriority code) {
365      return code.getSystem();
366      }
367    }
368
369    @Block()
370    public static class SupplyRequestOrderedItemComponent extends BackboneElement implements IBaseBackboneElement {
371        /**
372         * The amount that is being ordered of the indicated item.
373         */
374        @Child(name = "quantity", type = {Quantity.class}, order=1, min=1, max=1, modifier=false, summary=true)
375        @Description(shortDefinition="The requested amount of the item indicated", formalDefinition="The amount that is being ordered of the indicated item." )
376        protected Quantity quantity;
377
378        /**
379         * The item that is requested to be supplied. This is either a link to a resource representing the details of the item or a code that identifies the item from a known list.
380         */
381        @Child(name = "item", type = {CodeableConcept.class, Medication.class, Substance.class, Device.class}, order=2, min=0, max=1, modifier=false, summary=true)
382        @Description(shortDefinition="Medication, Substance, or Device requested to be supplied", formalDefinition="The item that is requested to be supplied. This is either a link to a resource representing the details of the item or a code that identifies the item from a known list." )
383        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/supply-item")
384        protected Type item;
385
386        private static final long serialVersionUID = 1628109307L;
387
388    /**
389     * Constructor
390     */
391      public SupplyRequestOrderedItemComponent() {
392        super();
393      }
394
395    /**
396     * Constructor
397     */
398      public SupplyRequestOrderedItemComponent(Quantity quantity) {
399        super();
400        this.quantity = quantity;
401      }
402
403        /**
404         * @return {@link #quantity} (The amount that is being ordered of the indicated item.)
405         */
406        public Quantity getQuantity() { 
407          if (this.quantity == null)
408            if (Configuration.errorOnAutoCreate())
409              throw new Error("Attempt to auto-create SupplyRequestOrderedItemComponent.quantity");
410            else if (Configuration.doAutoCreate())
411              this.quantity = new Quantity(); // cc
412          return this.quantity;
413        }
414
415        public boolean hasQuantity() { 
416          return this.quantity != null && !this.quantity.isEmpty();
417        }
418
419        /**
420         * @param value {@link #quantity} (The amount that is being ordered of the indicated item.)
421         */
422        public SupplyRequestOrderedItemComponent setQuantity(Quantity value)  { 
423          this.quantity = value;
424          return this;
425        }
426
427        /**
428         * @return {@link #item} (The item that is requested to be supplied. This is either a link to a resource representing the details of the item or a code that identifies the item from a known list.)
429         */
430        public Type getItem() { 
431          return this.item;
432        }
433
434        /**
435         * @return {@link #item} (The item that is requested to be supplied. This is either a link to a resource representing the details of the item or a code that identifies the item from a known list.)
436         */
437        public CodeableConcept getItemCodeableConcept() throws FHIRException { 
438          if (this.item == null)
439            return null;
440          if (!(this.item instanceof CodeableConcept))
441            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.item.getClass().getName()+" was encountered");
442          return (CodeableConcept) this.item;
443        }
444
445        public boolean hasItemCodeableConcept() { 
446          return this != null && this.item instanceof CodeableConcept;
447        }
448
449        /**
450         * @return {@link #item} (The item that is requested to be supplied. This is either a link to a resource representing the details of the item or a code that identifies the item from a known list.)
451         */
452        public Reference getItemReference() throws FHIRException { 
453          if (this.item == null)
454            return null;
455          if (!(this.item instanceof Reference))
456            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.item.getClass().getName()+" was encountered");
457          return (Reference) this.item;
458        }
459
460        public boolean hasItemReference() { 
461          return this != null && this.item instanceof Reference;
462        }
463
464        public boolean hasItem() { 
465          return this.item != null && !this.item.isEmpty();
466        }
467
468        /**
469         * @param value {@link #item} (The item that is requested to be supplied. This is either a link to a resource representing the details of the item or a code that identifies the item from a known list.)
470         */
471        public SupplyRequestOrderedItemComponent setItem(Type value) throws FHIRFormatError { 
472          if (value != null && !(value instanceof CodeableConcept || value instanceof Reference))
473            throw new FHIRFormatError("Not the right type for SupplyRequest.orderedItem.item[x]: "+value.fhirType());
474          this.item = value;
475          return this;
476        }
477
478        protected void listChildren(List<Property> children) {
479          super.listChildren(children);
480          children.add(new Property("quantity", "Quantity", "The amount that is being ordered of the indicated item.", 0, 1, quantity));
481          children.add(new Property("item[x]", "CodeableConcept|Reference(Medication|Substance|Device)", "The item that is requested to be supplied. This is either a link to a resource representing the details of the item or a code that identifies the item from a known list.", 0, 1, item));
482        }
483
484        @Override
485        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
486          switch (_hash) {
487          case -1285004149: /*quantity*/  return new Property("quantity", "Quantity", "The amount that is being ordered of the indicated item.", 0, 1, quantity);
488          case 2116201613: /*item[x]*/  return new Property("item[x]", "CodeableConcept|Reference(Medication|Substance|Device)", "The item that is requested to be supplied. This is either a link to a resource representing the details of the item or a code that identifies the item from a known list.", 0, 1, item);
489          case 3242771: /*item*/  return new Property("item[x]", "CodeableConcept|Reference(Medication|Substance|Device)", "The item that is requested to be supplied. This is either a link to a resource representing the details of the item or a code that identifies the item from a known list.", 0, 1, item);
490          case 106644494: /*itemCodeableConcept*/  return new Property("item[x]", "CodeableConcept|Reference(Medication|Substance|Device)", "The item that is requested to be supplied. This is either a link to a resource representing the details of the item or a code that identifies the item from a known list.", 0, 1, item);
491          case 1376364920: /*itemReference*/  return new Property("item[x]", "CodeableConcept|Reference(Medication|Substance|Device)", "The item that is requested to be supplied. This is either a link to a resource representing the details of the item or a code that identifies the item from a known list.", 0, 1, item);
492          default: return super.getNamedProperty(_hash, _name, _checkValid);
493          }
494
495        }
496
497      @Override
498      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
499        switch (hash) {
500        case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // Quantity
501        case 3242771: /*item*/ return this.item == null ? new Base[0] : new Base[] {this.item}; // Type
502        default: return super.getProperty(hash, name, checkValid);
503        }
504
505      }
506
507      @Override
508      public Base setProperty(int hash, String name, Base value) throws FHIRException {
509        switch (hash) {
510        case -1285004149: // quantity
511          this.quantity = castToQuantity(value); // Quantity
512          return value;
513        case 3242771: // item
514          this.item = castToType(value); // Type
515          return value;
516        default: return super.setProperty(hash, name, value);
517        }
518
519      }
520
521      @Override
522      public Base setProperty(String name, Base value) throws FHIRException {
523        if (name.equals("quantity")) {
524          this.quantity = castToQuantity(value); // Quantity
525        } else if (name.equals("item[x]")) {
526          this.item = castToType(value); // Type
527        } else
528          return super.setProperty(name, value);
529        return value;
530      }
531
532      @Override
533      public Base makeProperty(int hash, String name) throws FHIRException {
534        switch (hash) {
535        case -1285004149:  return getQuantity(); 
536        case 2116201613:  return getItem(); 
537        case 3242771:  return getItem(); 
538        default: return super.makeProperty(hash, name);
539        }
540
541      }
542
543      @Override
544      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
545        switch (hash) {
546        case -1285004149: /*quantity*/ return new String[] {"Quantity"};
547        case 3242771: /*item*/ return new String[] {"CodeableConcept", "Reference"};
548        default: return super.getTypesForProperty(hash, name);
549        }
550
551      }
552
553      @Override
554      public Base addChild(String name) throws FHIRException {
555        if (name.equals("quantity")) {
556          this.quantity = new Quantity();
557          return this.quantity;
558        }
559        else if (name.equals("itemCodeableConcept")) {
560          this.item = new CodeableConcept();
561          return this.item;
562        }
563        else if (name.equals("itemReference")) {
564          this.item = new Reference();
565          return this.item;
566        }
567        else
568          return super.addChild(name);
569      }
570
571      public SupplyRequestOrderedItemComponent copy() {
572        SupplyRequestOrderedItemComponent dst = new SupplyRequestOrderedItemComponent();
573        copyValues(dst);
574        dst.quantity = quantity == null ? null : quantity.copy();
575        dst.item = item == null ? null : item.copy();
576        return dst;
577      }
578
579      @Override
580      public boolean equalsDeep(Base other_) {
581        if (!super.equalsDeep(other_))
582          return false;
583        if (!(other_ instanceof SupplyRequestOrderedItemComponent))
584          return false;
585        SupplyRequestOrderedItemComponent o = (SupplyRequestOrderedItemComponent) other_;
586        return compareDeep(quantity, o.quantity, true) && compareDeep(item, o.item, true);
587      }
588
589      @Override
590      public boolean equalsShallow(Base other_) {
591        if (!super.equalsShallow(other_))
592          return false;
593        if (!(other_ instanceof SupplyRequestOrderedItemComponent))
594          return false;
595        SupplyRequestOrderedItemComponent o = (SupplyRequestOrderedItemComponent) other_;
596        return true;
597      }
598
599      public boolean isEmpty() {
600        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(quantity, item);
601      }
602
603  public String fhirType() {
604    return "SupplyRequest.orderedItem";
605
606  }
607
608  }
609
610    @Block()
611    public static class SupplyRequestRequesterComponent extends BackboneElement implements IBaseBackboneElement {
612        /**
613         * The device, practitioner, etc. who initiated the request.
614         */
615        @Child(name = "agent", type = {Practitioner.class, Organization.class, Patient.class, RelatedPerson.class, Device.class}, order=1, min=1, max=1, modifier=false, summary=true)
616        @Description(shortDefinition="Individual making the request", formalDefinition="The device, practitioner, etc. who initiated the request." )
617        protected Reference agent;
618
619        /**
620         * The actual object that is the target of the reference (The device, practitioner, etc. who initiated the request.)
621         */
622        protected Resource agentTarget;
623
624        /**
625         * The organization the device or practitioner was acting on behalf of.
626         */
627        @Child(name = "onBehalfOf", type = {Organization.class}, order=2, min=0, max=1, modifier=false, summary=false)
628        @Description(shortDefinition="Organization agent is acting for", formalDefinition="The organization the device or practitioner was acting on behalf of." )
629        protected Reference onBehalfOf;
630
631        /**
632         * The actual object that is the target of the reference (The organization the device or practitioner was acting on behalf of.)
633         */
634        protected Organization onBehalfOfTarget;
635
636        private static final long serialVersionUID = -71453027L;
637
638    /**
639     * Constructor
640     */
641      public SupplyRequestRequesterComponent() {
642        super();
643      }
644
645    /**
646     * Constructor
647     */
648      public SupplyRequestRequesterComponent(Reference agent) {
649        super();
650        this.agent = agent;
651      }
652
653        /**
654         * @return {@link #agent} (The device, practitioner, etc. who initiated the request.)
655         */
656        public Reference getAgent() { 
657          if (this.agent == null)
658            if (Configuration.errorOnAutoCreate())
659              throw new Error("Attempt to auto-create SupplyRequestRequesterComponent.agent");
660            else if (Configuration.doAutoCreate())
661              this.agent = new Reference(); // cc
662          return this.agent;
663        }
664
665        public boolean hasAgent() { 
666          return this.agent != null && !this.agent.isEmpty();
667        }
668
669        /**
670         * @param value {@link #agent} (The device, practitioner, etc. who initiated the request.)
671         */
672        public SupplyRequestRequesterComponent setAgent(Reference value)  { 
673          this.agent = value;
674          return this;
675        }
676
677        /**
678         * @return {@link #agent} 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 device, practitioner, etc. who initiated the request.)
679         */
680        public Resource getAgentTarget() { 
681          return this.agentTarget;
682        }
683
684        /**
685         * @param value {@link #agent} 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 device, practitioner, etc. who initiated the request.)
686         */
687        public SupplyRequestRequesterComponent setAgentTarget(Resource value) { 
688          this.agentTarget = value;
689          return this;
690        }
691
692        /**
693         * @return {@link #onBehalfOf} (The organization the device or practitioner was acting on behalf of.)
694         */
695        public Reference getOnBehalfOf() { 
696          if (this.onBehalfOf == null)
697            if (Configuration.errorOnAutoCreate())
698              throw new Error("Attempt to auto-create SupplyRequestRequesterComponent.onBehalfOf");
699            else if (Configuration.doAutoCreate())
700              this.onBehalfOf = new Reference(); // cc
701          return this.onBehalfOf;
702        }
703
704        public boolean hasOnBehalfOf() { 
705          return this.onBehalfOf != null && !this.onBehalfOf.isEmpty();
706        }
707
708        /**
709         * @param value {@link #onBehalfOf} (The organization the device or practitioner was acting on behalf of.)
710         */
711        public SupplyRequestRequesterComponent setOnBehalfOf(Reference value)  { 
712          this.onBehalfOf = value;
713          return this;
714        }
715
716        /**
717         * @return {@link #onBehalfOf} 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 organization the device or practitioner was acting on behalf of.)
718         */
719        public Organization getOnBehalfOfTarget() { 
720          if (this.onBehalfOfTarget == null)
721            if (Configuration.errorOnAutoCreate())
722              throw new Error("Attempt to auto-create SupplyRequestRequesterComponent.onBehalfOf");
723            else if (Configuration.doAutoCreate())
724              this.onBehalfOfTarget = new Organization(); // aa
725          return this.onBehalfOfTarget;
726        }
727
728        /**
729         * @param value {@link #onBehalfOf} 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 organization the device or practitioner was acting on behalf of.)
730         */
731        public SupplyRequestRequesterComponent setOnBehalfOfTarget(Organization value) { 
732          this.onBehalfOfTarget = value;
733          return this;
734        }
735
736        protected void listChildren(List<Property> children) {
737          super.listChildren(children);
738          children.add(new Property("agent", "Reference(Practitioner|Organization|Patient|RelatedPerson|Device)", "The device, practitioner, etc. who initiated the request.", 0, 1, agent));
739          children.add(new Property("onBehalfOf", "Reference(Organization)", "The organization the device or practitioner was acting on behalf of.", 0, 1, onBehalfOf));
740        }
741
742        @Override
743        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
744          switch (_hash) {
745          case 92750597: /*agent*/  return new Property("agent", "Reference(Practitioner|Organization|Patient|RelatedPerson|Device)", "The device, practitioner, etc. who initiated the request.", 0, 1, agent);
746          case -14402964: /*onBehalfOf*/  return new Property("onBehalfOf", "Reference(Organization)", "The organization the device or practitioner was acting on behalf of.", 0, 1, onBehalfOf);
747          default: return super.getNamedProperty(_hash, _name, _checkValid);
748          }
749
750        }
751
752      @Override
753      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
754        switch (hash) {
755        case 92750597: /*agent*/ return this.agent == null ? new Base[0] : new Base[] {this.agent}; // Reference
756        case -14402964: /*onBehalfOf*/ return this.onBehalfOf == null ? new Base[0] : new Base[] {this.onBehalfOf}; // Reference
757        default: return super.getProperty(hash, name, checkValid);
758        }
759
760      }
761
762      @Override
763      public Base setProperty(int hash, String name, Base value) throws FHIRException {
764        switch (hash) {
765        case 92750597: // agent
766          this.agent = castToReference(value); // Reference
767          return value;
768        case -14402964: // onBehalfOf
769          this.onBehalfOf = castToReference(value); // Reference
770          return value;
771        default: return super.setProperty(hash, name, value);
772        }
773
774      }
775
776      @Override
777      public Base setProperty(String name, Base value) throws FHIRException {
778        if (name.equals("agent")) {
779          this.agent = castToReference(value); // Reference
780        } else if (name.equals("onBehalfOf")) {
781          this.onBehalfOf = castToReference(value); // Reference
782        } else
783          return super.setProperty(name, value);
784        return value;
785      }
786
787      @Override
788      public Base makeProperty(int hash, String name) throws FHIRException {
789        switch (hash) {
790        case 92750597:  return getAgent(); 
791        case -14402964:  return getOnBehalfOf(); 
792        default: return super.makeProperty(hash, name);
793        }
794
795      }
796
797      @Override
798      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
799        switch (hash) {
800        case 92750597: /*agent*/ return new String[] {"Reference"};
801        case -14402964: /*onBehalfOf*/ return new String[] {"Reference"};
802        default: return super.getTypesForProperty(hash, name);
803        }
804
805      }
806
807      @Override
808      public Base addChild(String name) throws FHIRException {
809        if (name.equals("agent")) {
810          this.agent = new Reference();
811          return this.agent;
812        }
813        else if (name.equals("onBehalfOf")) {
814          this.onBehalfOf = new Reference();
815          return this.onBehalfOf;
816        }
817        else
818          return super.addChild(name);
819      }
820
821      public SupplyRequestRequesterComponent copy() {
822        SupplyRequestRequesterComponent dst = new SupplyRequestRequesterComponent();
823        copyValues(dst);
824        dst.agent = agent == null ? null : agent.copy();
825        dst.onBehalfOf = onBehalfOf == null ? null : onBehalfOf.copy();
826        return dst;
827      }
828
829      @Override
830      public boolean equalsDeep(Base other_) {
831        if (!super.equalsDeep(other_))
832          return false;
833        if (!(other_ instanceof SupplyRequestRequesterComponent))
834          return false;
835        SupplyRequestRequesterComponent o = (SupplyRequestRequesterComponent) other_;
836        return compareDeep(agent, o.agent, true) && compareDeep(onBehalfOf, o.onBehalfOf, true);
837      }
838
839      @Override
840      public boolean equalsShallow(Base other_) {
841        if (!super.equalsShallow(other_))
842          return false;
843        if (!(other_ instanceof SupplyRequestRequesterComponent))
844          return false;
845        SupplyRequestRequesterComponent o = (SupplyRequestRequesterComponent) other_;
846        return true;
847      }
848
849      public boolean isEmpty() {
850        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(agent, onBehalfOf);
851      }
852
853  public String fhirType() {
854    return "SupplyRequest.requester";
855
856  }
857
858  }
859
860    /**
861     * Unique identifier for this supply request.
862     */
863    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=1, modifier=false, summary=true)
864    @Description(shortDefinition="Unique identifier", formalDefinition="Unique identifier for this supply request." )
865    protected Identifier identifier;
866
867    /**
868     * Status of the supply request.
869     */
870    @Child(name = "status", type = {CodeType.class}, order=1, min=0, max=1, modifier=true, summary=true)
871    @Description(shortDefinition="draft | active | suspended +", formalDefinition="Status of the supply request." )
872    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/supplyrequest-status")
873    protected Enumeration<SupplyRequestStatus> status;
874
875    /**
876     * Category of supply, e.g.  central, non-stock, etc. This is used to support work flows associated with the supply process.
877     */
878    @Child(name = "category", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
879    @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." )
880    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/supplyrequest-kind")
881    protected CodeableConcept category;
882
883    /**
884     * Indicates how quickly this SupplyRequest should be addressed with respect to other requests.
885     */
886    @Child(name = "priority", type = {CodeType.class}, order=3, min=0, max=1, modifier=false, summary=true)
887    @Description(shortDefinition="routine | urgent | asap | stat", formalDefinition="Indicates how quickly this SupplyRequest should be addressed with respect to other requests." )
888    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/request-priority")
889    protected Enumeration<RequestPriority> priority;
890
891    /**
892     * The item being requested.
893     */
894    @Child(name = "orderedItem", type = {}, order=4, min=0, max=1, modifier=false, summary=true)
895    @Description(shortDefinition="The item being requested", formalDefinition="The item being requested." )
896    protected SupplyRequestOrderedItemComponent orderedItem;
897
898    /**
899     * When the request should be fulfilled.
900     */
901    @Child(name = "occurrence", type = {DateTimeType.class, Period.class, Timing.class}, order=5, min=0, max=1, modifier=false, summary=true)
902    @Description(shortDefinition="When the request should be fulfilled", formalDefinition="When the request should be fulfilled." )
903    protected Type occurrence;
904
905    /**
906     * When the request was made.
907     */
908    @Child(name = "authoredOn", type = {DateTimeType.class}, order=6, min=0, max=1, modifier=false, summary=true)
909    @Description(shortDefinition="When the request was made", formalDefinition="When the request was made." )
910    protected DateTimeType authoredOn;
911
912    /**
913     * The individual who initiated the request and has responsibility for its activation.
914     */
915    @Child(name = "requester", type = {}, order=7, min=0, max=1, modifier=false, summary=true)
916    @Description(shortDefinition="Who/what is requesting service", formalDefinition="The individual who initiated the request and has responsibility for its activation." )
917    protected SupplyRequestRequesterComponent requester;
918
919    /**
920     * Who is intended to fulfill the request.
921     */
922    @Child(name = "supplier", type = {Organization.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
923    @Description(shortDefinition="Who is intended to fulfill the request", formalDefinition="Who is intended to fulfill the request." )
924    protected List<Reference> supplier;
925    /**
926     * The actual objects that are the target of the reference (Who is intended to fulfill the request.)
927     */
928    protected List<Organization> supplierTarget;
929
930
931    /**
932     * Why the supply item was requested.
933     */
934    @Child(name = "reason", type = {CodeableConcept.class, Reference.class}, order=9, min=0, max=1, modifier=false, summary=false)
935    @Description(shortDefinition="Why the supply item was requested", formalDefinition="Why the supply item was requested." )
936    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/supplyrequest-reason")
937    protected Type reason;
938
939    /**
940     * Where the supply is expected to come from.
941     */
942    @Child(name = "deliverFrom", type = {Organization.class, Location.class}, order=10, min=0, max=1, modifier=false, summary=false)
943    @Description(shortDefinition="The origin of the supply", formalDefinition="Where the supply is expected to come from." )
944    protected Reference deliverFrom;
945
946    /**
947     * The actual object that is the target of the reference (Where the supply is expected to come from.)
948     */
949    protected Resource deliverFromTarget;
950
951    /**
952     * Where the supply is destined to go.
953     */
954    @Child(name = "deliverTo", type = {Organization.class, Location.class, Patient.class}, order=11, min=0, max=1, modifier=false, summary=false)
955    @Description(shortDefinition="The destination of the supply", formalDefinition="Where the supply is destined to go." )
956    protected Reference deliverTo;
957
958    /**
959     * The actual object that is the target of the reference (Where the supply is destined to go.)
960     */
961    protected Resource deliverToTarget;
962
963    private static final long serialVersionUID = 43957782L;
964
965  /**
966   * Constructor
967   */
968    public SupplyRequest() {
969      super();
970    }
971
972    /**
973     * @return {@link #identifier} (Unique identifier for this supply request.)
974     */
975    public Identifier getIdentifier() { 
976      if (this.identifier == null)
977        if (Configuration.errorOnAutoCreate())
978          throw new Error("Attempt to auto-create SupplyRequest.identifier");
979        else if (Configuration.doAutoCreate())
980          this.identifier = new Identifier(); // cc
981      return this.identifier;
982    }
983
984    public boolean hasIdentifier() { 
985      return this.identifier != null && !this.identifier.isEmpty();
986    }
987
988    /**
989     * @param value {@link #identifier} (Unique identifier for this supply request.)
990     */
991    public SupplyRequest setIdentifier(Identifier value)  { 
992      this.identifier = value;
993      return this;
994    }
995
996    /**
997     * @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
998     */
999    public Enumeration<SupplyRequestStatus> getStatusElement() { 
1000      if (this.status == null)
1001        if (Configuration.errorOnAutoCreate())
1002          throw new Error("Attempt to auto-create SupplyRequest.status");
1003        else if (Configuration.doAutoCreate())
1004          this.status = new Enumeration<SupplyRequestStatus>(new SupplyRequestStatusEnumFactory()); // bb
1005      return this.status;
1006    }
1007
1008    public boolean hasStatusElement() { 
1009      return this.status != null && !this.status.isEmpty();
1010    }
1011
1012    public boolean hasStatus() { 
1013      return this.status != null && !this.status.isEmpty();
1014    }
1015
1016    /**
1017     * @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
1018     */
1019    public SupplyRequest setStatusElement(Enumeration<SupplyRequestStatus> value) { 
1020      this.status = value;
1021      return this;
1022    }
1023
1024    /**
1025     * @return Status of the supply request.
1026     */
1027    public SupplyRequestStatus getStatus() { 
1028      return this.status == null ? null : this.status.getValue();
1029    }
1030
1031    /**
1032     * @param value Status of the supply request.
1033     */
1034    public SupplyRequest setStatus(SupplyRequestStatus value) { 
1035      if (value == null)
1036        this.status = null;
1037      else {
1038        if (this.status == null)
1039          this.status = new Enumeration<SupplyRequestStatus>(new SupplyRequestStatusEnumFactory());
1040        this.status.setValue(value);
1041      }
1042      return this;
1043    }
1044
1045    /**
1046     * @return {@link #category} (Category of supply, e.g.  central, non-stock, etc. This is used to support work flows associated with the supply process.)
1047     */
1048    public CodeableConcept getCategory() { 
1049      if (this.category == null)
1050        if (Configuration.errorOnAutoCreate())
1051          throw new Error("Attempt to auto-create SupplyRequest.category");
1052        else if (Configuration.doAutoCreate())
1053          this.category = new CodeableConcept(); // cc
1054      return this.category;
1055    }
1056
1057    public boolean hasCategory() { 
1058      return this.category != null && !this.category.isEmpty();
1059    }
1060
1061    /**
1062     * @param value {@link #category} (Category of supply, e.g.  central, non-stock, etc. This is used to support work flows associated with the supply process.)
1063     */
1064    public SupplyRequest setCategory(CodeableConcept value)  { 
1065      this.category = value;
1066      return this;
1067    }
1068
1069    /**
1070     * @return {@link #priority} (Indicates how quickly this SupplyRequest should be addressed with respect to other requests.). This is the underlying object with id, value and extensions. The accessor "getPriority" gives direct access to the value
1071     */
1072    public Enumeration<RequestPriority> getPriorityElement() { 
1073      if (this.priority == null)
1074        if (Configuration.errorOnAutoCreate())
1075          throw new Error("Attempt to auto-create SupplyRequest.priority");
1076        else if (Configuration.doAutoCreate())
1077          this.priority = new Enumeration<RequestPriority>(new RequestPriorityEnumFactory()); // bb
1078      return this.priority;
1079    }
1080
1081    public boolean hasPriorityElement() { 
1082      return this.priority != null && !this.priority.isEmpty();
1083    }
1084
1085    public boolean hasPriority() { 
1086      return this.priority != null && !this.priority.isEmpty();
1087    }
1088
1089    /**
1090     * @param value {@link #priority} (Indicates how quickly this SupplyRequest should be addressed with respect to other requests.). This is the underlying object with id, value and extensions. The accessor "getPriority" gives direct access to the value
1091     */
1092    public SupplyRequest setPriorityElement(Enumeration<RequestPriority> value) { 
1093      this.priority = value;
1094      return this;
1095    }
1096
1097    /**
1098     * @return Indicates how quickly this SupplyRequest should be addressed with respect to other requests.
1099     */
1100    public RequestPriority getPriority() { 
1101      return this.priority == null ? null : this.priority.getValue();
1102    }
1103
1104    /**
1105     * @param value Indicates how quickly this SupplyRequest should be addressed with respect to other requests.
1106     */
1107    public SupplyRequest setPriority(RequestPriority value) { 
1108      if (value == null)
1109        this.priority = null;
1110      else {
1111        if (this.priority == null)
1112          this.priority = new Enumeration<RequestPriority>(new RequestPriorityEnumFactory());
1113        this.priority.setValue(value);
1114      }
1115      return this;
1116    }
1117
1118    /**
1119     * @return {@link #orderedItem} (The item being requested.)
1120     */
1121    public SupplyRequestOrderedItemComponent getOrderedItem() { 
1122      if (this.orderedItem == null)
1123        if (Configuration.errorOnAutoCreate())
1124          throw new Error("Attempt to auto-create SupplyRequest.orderedItem");
1125        else if (Configuration.doAutoCreate())
1126          this.orderedItem = new SupplyRequestOrderedItemComponent(); // cc
1127      return this.orderedItem;
1128    }
1129
1130    public boolean hasOrderedItem() { 
1131      return this.orderedItem != null && !this.orderedItem.isEmpty();
1132    }
1133
1134    /**
1135     * @param value {@link #orderedItem} (The item being requested.)
1136     */
1137    public SupplyRequest setOrderedItem(SupplyRequestOrderedItemComponent value)  { 
1138      this.orderedItem = value;
1139      return this;
1140    }
1141
1142    /**
1143     * @return {@link #occurrence} (When the request should be fulfilled.)
1144     */
1145    public Type getOccurrence() { 
1146      return this.occurrence;
1147    }
1148
1149    /**
1150     * @return {@link #occurrence} (When the request should be fulfilled.)
1151     */
1152    public DateTimeType getOccurrenceDateTimeType() throws FHIRException { 
1153      if (this.occurrence == null)
1154        return null;
1155      if (!(this.occurrence instanceof DateTimeType))
1156        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.occurrence.getClass().getName()+" was encountered");
1157      return (DateTimeType) this.occurrence;
1158    }
1159
1160    public boolean hasOccurrenceDateTimeType() { 
1161      return this != null && this.occurrence instanceof DateTimeType;
1162    }
1163
1164    /**
1165     * @return {@link #occurrence} (When the request should be fulfilled.)
1166     */
1167    public Period getOccurrencePeriod() throws FHIRException { 
1168      if (this.occurrence == null)
1169        return null;
1170      if (!(this.occurrence instanceof Period))
1171        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.occurrence.getClass().getName()+" was encountered");
1172      return (Period) this.occurrence;
1173    }
1174
1175    public boolean hasOccurrencePeriod() { 
1176      return this != null && this.occurrence instanceof Period;
1177    }
1178
1179    /**
1180     * @return {@link #occurrence} (When the request should be fulfilled.)
1181     */
1182    public Timing getOccurrenceTiming() throws FHIRException { 
1183      if (this.occurrence == null)
1184        return null;
1185      if (!(this.occurrence instanceof Timing))
1186        throw new FHIRException("Type mismatch: the type Timing was expected, but "+this.occurrence.getClass().getName()+" was encountered");
1187      return (Timing) this.occurrence;
1188    }
1189
1190    public boolean hasOccurrenceTiming() { 
1191      return this != null && this.occurrence instanceof Timing;
1192    }
1193
1194    public boolean hasOccurrence() { 
1195      return this.occurrence != null && !this.occurrence.isEmpty();
1196    }
1197
1198    /**
1199     * @param value {@link #occurrence} (When the request should be fulfilled.)
1200     */
1201    public SupplyRequest setOccurrence(Type value) throws FHIRFormatError { 
1202      if (value != null && !(value instanceof DateTimeType || value instanceof Period || value instanceof Timing))
1203        throw new FHIRFormatError("Not the right type for SupplyRequest.occurrence[x]: "+value.fhirType());
1204      this.occurrence = value;
1205      return this;
1206    }
1207
1208    /**
1209     * @return {@link #authoredOn} (When the request was made.). This is the underlying object with id, value and extensions. The accessor "getAuthoredOn" gives direct access to the value
1210     */
1211    public DateTimeType getAuthoredOnElement() { 
1212      if (this.authoredOn == null)
1213        if (Configuration.errorOnAutoCreate())
1214          throw new Error("Attempt to auto-create SupplyRequest.authoredOn");
1215        else if (Configuration.doAutoCreate())
1216          this.authoredOn = new DateTimeType(); // bb
1217      return this.authoredOn;
1218    }
1219
1220    public boolean hasAuthoredOnElement() { 
1221      return this.authoredOn != null && !this.authoredOn.isEmpty();
1222    }
1223
1224    public boolean hasAuthoredOn() { 
1225      return this.authoredOn != null && !this.authoredOn.isEmpty();
1226    }
1227
1228    /**
1229     * @param value {@link #authoredOn} (When the request was made.). This is the underlying object with id, value and extensions. The accessor "getAuthoredOn" gives direct access to the value
1230     */
1231    public SupplyRequest setAuthoredOnElement(DateTimeType value) { 
1232      this.authoredOn = value;
1233      return this;
1234    }
1235
1236    /**
1237     * @return When the request was made.
1238     */
1239    public Date getAuthoredOn() { 
1240      return this.authoredOn == null ? null : this.authoredOn.getValue();
1241    }
1242
1243    /**
1244     * @param value When the request was made.
1245     */
1246    public SupplyRequest setAuthoredOn(Date value) { 
1247      if (value == null)
1248        this.authoredOn = null;
1249      else {
1250        if (this.authoredOn == null)
1251          this.authoredOn = new DateTimeType();
1252        this.authoredOn.setValue(value);
1253      }
1254      return this;
1255    }
1256
1257    /**
1258     * @return {@link #requester} (The individual who initiated the request and has responsibility for its activation.)
1259     */
1260    public SupplyRequestRequesterComponent getRequester() { 
1261      if (this.requester == null)
1262        if (Configuration.errorOnAutoCreate())
1263          throw new Error("Attempt to auto-create SupplyRequest.requester");
1264        else if (Configuration.doAutoCreate())
1265          this.requester = new SupplyRequestRequesterComponent(); // cc
1266      return this.requester;
1267    }
1268
1269    public boolean hasRequester() { 
1270      return this.requester != null && !this.requester.isEmpty();
1271    }
1272
1273    /**
1274     * @param value {@link #requester} (The individual who initiated the request and has responsibility for its activation.)
1275     */
1276    public SupplyRequest setRequester(SupplyRequestRequesterComponent value)  { 
1277      this.requester = value;
1278      return this;
1279    }
1280
1281    /**
1282     * @return {@link #supplier} (Who is intended to fulfill the request.)
1283     */
1284    public List<Reference> getSupplier() { 
1285      if (this.supplier == null)
1286        this.supplier = new ArrayList<Reference>();
1287      return this.supplier;
1288    }
1289
1290    /**
1291     * @return Returns a reference to <code>this</code> for easy method chaining
1292     */
1293    public SupplyRequest setSupplier(List<Reference> theSupplier) { 
1294      this.supplier = theSupplier;
1295      return this;
1296    }
1297
1298    public boolean hasSupplier() { 
1299      if (this.supplier == null)
1300        return false;
1301      for (Reference item : this.supplier)
1302        if (!item.isEmpty())
1303          return true;
1304      return false;
1305    }
1306
1307    public Reference addSupplier() { //3
1308      Reference t = new Reference();
1309      if (this.supplier == null)
1310        this.supplier = new ArrayList<Reference>();
1311      this.supplier.add(t);
1312      return t;
1313    }
1314
1315    public SupplyRequest addSupplier(Reference t) { //3
1316      if (t == null)
1317        return this;
1318      if (this.supplier == null)
1319        this.supplier = new ArrayList<Reference>();
1320      this.supplier.add(t);
1321      return this;
1322    }
1323
1324    /**
1325     * @return The first repetition of repeating field {@link #supplier}, creating it if it does not already exist
1326     */
1327    public Reference getSupplierFirstRep() { 
1328      if (getSupplier().isEmpty()) {
1329        addSupplier();
1330      }
1331      return getSupplier().get(0);
1332    }
1333
1334    /**
1335     * @deprecated Use Reference#setResource(IBaseResource) instead
1336     */
1337    @Deprecated
1338    public List<Organization> getSupplierTarget() { 
1339      if (this.supplierTarget == null)
1340        this.supplierTarget = new ArrayList<Organization>();
1341      return this.supplierTarget;
1342    }
1343
1344    /**
1345     * @deprecated Use Reference#setResource(IBaseResource) instead
1346     */
1347    @Deprecated
1348    public Organization addSupplierTarget() { 
1349      Organization r = new Organization();
1350      if (this.supplierTarget == null)
1351        this.supplierTarget = new ArrayList<Organization>();
1352      this.supplierTarget.add(r);
1353      return r;
1354    }
1355
1356    /**
1357     * @return {@link #reason} (Why the supply item was requested.)
1358     */
1359    public Type getReason() { 
1360      return this.reason;
1361    }
1362
1363    /**
1364     * @return {@link #reason} (Why the supply item was requested.)
1365     */
1366    public CodeableConcept getReasonCodeableConcept() throws FHIRException { 
1367      if (this.reason == null)
1368        return null;
1369      if (!(this.reason instanceof CodeableConcept))
1370        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.reason.getClass().getName()+" was encountered");
1371      return (CodeableConcept) this.reason;
1372    }
1373
1374    public boolean hasReasonCodeableConcept() { 
1375      return this != null && this.reason instanceof CodeableConcept;
1376    }
1377
1378    /**
1379     * @return {@link #reason} (Why the supply item was requested.)
1380     */
1381    public Reference getReasonReference() throws FHIRException { 
1382      if (this.reason == null)
1383        return null;
1384      if (!(this.reason instanceof Reference))
1385        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.reason.getClass().getName()+" was encountered");
1386      return (Reference) this.reason;
1387    }
1388
1389    public boolean hasReasonReference() { 
1390      return this != null && this.reason instanceof Reference;
1391    }
1392
1393    public boolean hasReason() { 
1394      return this.reason != null && !this.reason.isEmpty();
1395    }
1396
1397    /**
1398     * @param value {@link #reason} (Why the supply item was requested.)
1399     */
1400    public SupplyRequest setReason(Type value) throws FHIRFormatError { 
1401      if (value != null && !(value instanceof CodeableConcept || value instanceof Reference))
1402        throw new FHIRFormatError("Not the right type for SupplyRequest.reason[x]: "+value.fhirType());
1403      this.reason = value;
1404      return this;
1405    }
1406
1407    /**
1408     * @return {@link #deliverFrom} (Where the supply is expected to come from.)
1409     */
1410    public Reference getDeliverFrom() { 
1411      if (this.deliverFrom == null)
1412        if (Configuration.errorOnAutoCreate())
1413          throw new Error("Attempt to auto-create SupplyRequest.deliverFrom");
1414        else if (Configuration.doAutoCreate())
1415          this.deliverFrom = new Reference(); // cc
1416      return this.deliverFrom;
1417    }
1418
1419    public boolean hasDeliverFrom() { 
1420      return this.deliverFrom != null && !this.deliverFrom.isEmpty();
1421    }
1422
1423    /**
1424     * @param value {@link #deliverFrom} (Where the supply is expected to come from.)
1425     */
1426    public SupplyRequest setDeliverFrom(Reference value)  { 
1427      this.deliverFrom = value;
1428      return this;
1429    }
1430
1431    /**
1432     * @return {@link #deliverFrom} 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. (Where the supply is expected to come from.)
1433     */
1434    public Resource getDeliverFromTarget() { 
1435      return this.deliverFromTarget;
1436    }
1437
1438    /**
1439     * @param value {@link #deliverFrom} 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. (Where the supply is expected to come from.)
1440     */
1441    public SupplyRequest setDeliverFromTarget(Resource value) { 
1442      this.deliverFromTarget = value;
1443      return this;
1444    }
1445
1446    /**
1447     * @return {@link #deliverTo} (Where the supply is destined to go.)
1448     */
1449    public Reference getDeliverTo() { 
1450      if (this.deliverTo == null)
1451        if (Configuration.errorOnAutoCreate())
1452          throw new Error("Attempt to auto-create SupplyRequest.deliverTo");
1453        else if (Configuration.doAutoCreate())
1454          this.deliverTo = new Reference(); // cc
1455      return this.deliverTo;
1456    }
1457
1458    public boolean hasDeliverTo() { 
1459      return this.deliverTo != null && !this.deliverTo.isEmpty();
1460    }
1461
1462    /**
1463     * @param value {@link #deliverTo} (Where the supply is destined to go.)
1464     */
1465    public SupplyRequest setDeliverTo(Reference value)  { 
1466      this.deliverTo = value;
1467      return this;
1468    }
1469
1470    /**
1471     * @return {@link #deliverTo} 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. (Where the supply is destined to go.)
1472     */
1473    public Resource getDeliverToTarget() { 
1474      return this.deliverToTarget;
1475    }
1476
1477    /**
1478     * @param value {@link #deliverTo} 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. (Where the supply is destined to go.)
1479     */
1480    public SupplyRequest setDeliverToTarget(Resource value) { 
1481      this.deliverToTarget = value;
1482      return this;
1483    }
1484
1485      protected void listChildren(List<Property> children) {
1486        super.listChildren(children);
1487        children.add(new Property("identifier", "Identifier", "Unique identifier for this supply request.", 0, 1, identifier));
1488        children.add(new Property("status", "code", "Status of the supply request.", 0, 1, status));
1489        children.add(new Property("category", "CodeableConcept", "Category of supply, e.g.  central, non-stock, etc. This is used to support work flows associated with the supply process.", 0, 1, category));
1490        children.add(new Property("priority", "code", "Indicates how quickly this SupplyRequest should be addressed with respect to other requests.", 0, 1, priority));
1491        children.add(new Property("orderedItem", "", "The item being requested.", 0, 1, orderedItem));
1492        children.add(new Property("occurrence[x]", "dateTime|Period|Timing", "When the request should be fulfilled.", 0, 1, occurrence));
1493        children.add(new Property("authoredOn", "dateTime", "When the request was made.", 0, 1, authoredOn));
1494        children.add(new Property("requester", "", "The individual who initiated the request and has responsibility for its activation.", 0, 1, requester));
1495        children.add(new Property("supplier", "Reference(Organization)", "Who is intended to fulfill the request.", 0, java.lang.Integer.MAX_VALUE, supplier));
1496        children.add(new Property("reason[x]", "CodeableConcept|Reference(Any)", "Why the supply item was requested.", 0, 1, reason));
1497        children.add(new Property("deliverFrom", "Reference(Organization|Location)", "Where the supply is expected to come from.", 0, 1, deliverFrom));
1498        children.add(new Property("deliverTo", "Reference(Organization|Location|Patient)", "Where the supply is destined to go.", 0, 1, deliverTo));
1499      }
1500
1501      @Override
1502      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1503        switch (_hash) {
1504        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Unique identifier for this supply request.", 0, 1, identifier);
1505        case -892481550: /*status*/  return new Property("status", "code", "Status of the supply request.", 0, 1, status);
1506        case 50511102: /*category*/  return new Property("category", "CodeableConcept", "Category of supply, e.g.  central, non-stock, etc. This is used to support work flows associated with the supply process.", 0, 1, category);
1507        case -1165461084: /*priority*/  return new Property("priority", "code", "Indicates how quickly this SupplyRequest should be addressed with respect to other requests.", 0, 1, priority);
1508        case 2129914144: /*orderedItem*/  return new Property("orderedItem", "", "The item being requested.", 0, 1, orderedItem);
1509        case -2022646513: /*occurrence[x]*/  return new Property("occurrence[x]", "dateTime|Period|Timing", "When the request should be fulfilled.", 0, 1, occurrence);
1510        case 1687874001: /*occurrence*/  return new Property("occurrence[x]", "dateTime|Period|Timing", "When the request should be fulfilled.", 0, 1, occurrence);
1511        case -298443636: /*occurrenceDateTime*/  return new Property("occurrence[x]", "dateTime|Period|Timing", "When the request should be fulfilled.", 0, 1, occurrence);
1512        case 1397156594: /*occurrencePeriod*/  return new Property("occurrence[x]", "dateTime|Period|Timing", "When the request should be fulfilled.", 0, 1, occurrence);
1513        case 1515218299: /*occurrenceTiming*/  return new Property("occurrence[x]", "dateTime|Period|Timing", "When the request should be fulfilled.", 0, 1, occurrence);
1514        case -1500852503: /*authoredOn*/  return new Property("authoredOn", "dateTime", "When the request was made.", 0, 1, authoredOn);
1515        case 693933948: /*requester*/  return new Property("requester", "", "The individual who initiated the request and has responsibility for its activation.", 0, 1, requester);
1516        case -1663305268: /*supplier*/  return new Property("supplier", "Reference(Organization)", "Who is intended to fulfill the request.", 0, java.lang.Integer.MAX_VALUE, supplier);
1517        case -669418564: /*reason[x]*/  return new Property("reason[x]", "CodeableConcept|Reference(Any)", "Why the supply item was requested.", 0, 1, reason);
1518        case -934964668: /*reason*/  return new Property("reason[x]", "CodeableConcept|Reference(Any)", "Why the supply item was requested.", 0, 1, reason);
1519        case -610155331: /*reasonCodeableConcept*/  return new Property("reason[x]", "CodeableConcept|Reference(Any)", "Why the supply item was requested.", 0, 1, reason);
1520        case -1146218137: /*reasonReference*/  return new Property("reason[x]", "CodeableConcept|Reference(Any)", "Why the supply item was requested.", 0, 1, reason);
1521        case -949323153: /*deliverFrom*/  return new Property("deliverFrom", "Reference(Organization|Location)", "Where the supply is expected to come from.", 0, 1, deliverFrom);
1522        case -242327936: /*deliverTo*/  return new Property("deliverTo", "Reference(Organization|Location|Patient)", "Where the supply is destined to go.", 0, 1, deliverTo);
1523        default: return super.getNamedProperty(_hash, _name, _checkValid);
1524        }
1525
1526      }
1527
1528      @Override
1529      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1530        switch (hash) {
1531        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : new Base[] {this.identifier}; // Identifier
1532        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<SupplyRequestStatus>
1533        case 50511102: /*category*/ return this.category == null ? new Base[0] : new Base[] {this.category}; // CodeableConcept
1534        case -1165461084: /*priority*/ return this.priority == null ? new Base[0] : new Base[] {this.priority}; // Enumeration<RequestPriority>
1535        case 2129914144: /*orderedItem*/ return this.orderedItem == null ? new Base[0] : new Base[] {this.orderedItem}; // SupplyRequestOrderedItemComponent
1536        case 1687874001: /*occurrence*/ return this.occurrence == null ? new Base[0] : new Base[] {this.occurrence}; // Type
1537        case -1500852503: /*authoredOn*/ return this.authoredOn == null ? new Base[0] : new Base[] {this.authoredOn}; // DateTimeType
1538        case 693933948: /*requester*/ return this.requester == null ? new Base[0] : new Base[] {this.requester}; // SupplyRequestRequesterComponent
1539        case -1663305268: /*supplier*/ return this.supplier == null ? new Base[0] : this.supplier.toArray(new Base[this.supplier.size()]); // Reference
1540        case -934964668: /*reason*/ return this.reason == null ? new Base[0] : new Base[] {this.reason}; // Type
1541        case -949323153: /*deliverFrom*/ return this.deliverFrom == null ? new Base[0] : new Base[] {this.deliverFrom}; // Reference
1542        case -242327936: /*deliverTo*/ return this.deliverTo == null ? new Base[0] : new Base[] {this.deliverTo}; // Reference
1543        default: return super.getProperty(hash, name, checkValid);
1544        }
1545
1546      }
1547
1548      @Override
1549      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1550        switch (hash) {
1551        case -1618432855: // identifier
1552          this.identifier = castToIdentifier(value); // Identifier
1553          return value;
1554        case -892481550: // status
1555          value = new SupplyRequestStatusEnumFactory().fromType(castToCode(value));
1556          this.status = (Enumeration) value; // Enumeration<SupplyRequestStatus>
1557          return value;
1558        case 50511102: // category
1559          this.category = castToCodeableConcept(value); // CodeableConcept
1560          return value;
1561        case -1165461084: // priority
1562          value = new RequestPriorityEnumFactory().fromType(castToCode(value));
1563          this.priority = (Enumeration) value; // Enumeration<RequestPriority>
1564          return value;
1565        case 2129914144: // orderedItem
1566          this.orderedItem = (SupplyRequestOrderedItemComponent) value; // SupplyRequestOrderedItemComponent
1567          return value;
1568        case 1687874001: // occurrence
1569          this.occurrence = castToType(value); // Type
1570          return value;
1571        case -1500852503: // authoredOn
1572          this.authoredOn = castToDateTime(value); // DateTimeType
1573          return value;
1574        case 693933948: // requester
1575          this.requester = (SupplyRequestRequesterComponent) value; // SupplyRequestRequesterComponent
1576          return value;
1577        case -1663305268: // supplier
1578          this.getSupplier().add(castToReference(value)); // Reference
1579          return value;
1580        case -934964668: // reason
1581          this.reason = castToType(value); // Type
1582          return value;
1583        case -949323153: // deliverFrom
1584          this.deliverFrom = castToReference(value); // Reference
1585          return value;
1586        case -242327936: // deliverTo
1587          this.deliverTo = castToReference(value); // Reference
1588          return value;
1589        default: return super.setProperty(hash, name, value);
1590        }
1591
1592      }
1593
1594      @Override
1595      public Base setProperty(String name, Base value) throws FHIRException {
1596        if (name.equals("identifier")) {
1597          this.identifier = castToIdentifier(value); // Identifier
1598        } else if (name.equals("status")) {
1599          value = new SupplyRequestStatusEnumFactory().fromType(castToCode(value));
1600          this.status = (Enumeration) value; // Enumeration<SupplyRequestStatus>
1601        } else if (name.equals("category")) {
1602          this.category = castToCodeableConcept(value); // CodeableConcept
1603        } else if (name.equals("priority")) {
1604          value = new RequestPriorityEnumFactory().fromType(castToCode(value));
1605          this.priority = (Enumeration) value; // Enumeration<RequestPriority>
1606        } else if (name.equals("orderedItem")) {
1607          this.orderedItem = (SupplyRequestOrderedItemComponent) value; // SupplyRequestOrderedItemComponent
1608        } else if (name.equals("occurrence[x]")) {
1609          this.occurrence = castToType(value); // Type
1610        } else if (name.equals("authoredOn")) {
1611          this.authoredOn = castToDateTime(value); // DateTimeType
1612        } else if (name.equals("requester")) {
1613          this.requester = (SupplyRequestRequesterComponent) value; // SupplyRequestRequesterComponent
1614        } else if (name.equals("supplier")) {
1615          this.getSupplier().add(castToReference(value));
1616        } else if (name.equals("reason[x]")) {
1617          this.reason = castToType(value); // Type
1618        } else if (name.equals("deliverFrom")) {
1619          this.deliverFrom = castToReference(value); // Reference
1620        } else if (name.equals("deliverTo")) {
1621          this.deliverTo = castToReference(value); // Reference
1622        } else
1623          return super.setProperty(name, value);
1624        return value;
1625      }
1626
1627      @Override
1628      public Base makeProperty(int hash, String name) throws FHIRException {
1629        switch (hash) {
1630        case -1618432855:  return getIdentifier(); 
1631        case -892481550:  return getStatusElement();
1632        case 50511102:  return getCategory(); 
1633        case -1165461084:  return getPriorityElement();
1634        case 2129914144:  return getOrderedItem(); 
1635        case -2022646513:  return getOccurrence(); 
1636        case 1687874001:  return getOccurrence(); 
1637        case -1500852503:  return getAuthoredOnElement();
1638        case 693933948:  return getRequester(); 
1639        case -1663305268:  return addSupplier(); 
1640        case -669418564:  return getReason(); 
1641        case -934964668:  return getReason(); 
1642        case -949323153:  return getDeliverFrom(); 
1643        case -242327936:  return getDeliverTo(); 
1644        default: return super.makeProperty(hash, name);
1645        }
1646
1647      }
1648
1649      @Override
1650      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1651        switch (hash) {
1652        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
1653        case -892481550: /*status*/ return new String[] {"code"};
1654        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
1655        case -1165461084: /*priority*/ return new String[] {"code"};
1656        case 2129914144: /*orderedItem*/ return new String[] {};
1657        case 1687874001: /*occurrence*/ return new String[] {"dateTime", "Period", "Timing"};
1658        case -1500852503: /*authoredOn*/ return new String[] {"dateTime"};
1659        case 693933948: /*requester*/ return new String[] {};
1660        case -1663305268: /*supplier*/ return new String[] {"Reference"};
1661        case -934964668: /*reason*/ return new String[] {"CodeableConcept", "Reference"};
1662        case -949323153: /*deliverFrom*/ return new String[] {"Reference"};
1663        case -242327936: /*deliverTo*/ return new String[] {"Reference"};
1664        default: return super.getTypesForProperty(hash, name);
1665        }
1666
1667      }
1668
1669      @Override
1670      public Base addChild(String name) throws FHIRException {
1671        if (name.equals("identifier")) {
1672          this.identifier = new Identifier();
1673          return this.identifier;
1674        }
1675        else if (name.equals("status")) {
1676          throw new FHIRException("Cannot call addChild on a primitive type SupplyRequest.status");
1677        }
1678        else if (name.equals("category")) {
1679          this.category = new CodeableConcept();
1680          return this.category;
1681        }
1682        else if (name.equals("priority")) {
1683          throw new FHIRException("Cannot call addChild on a primitive type SupplyRequest.priority");
1684        }
1685        else if (name.equals("orderedItem")) {
1686          this.orderedItem = new SupplyRequestOrderedItemComponent();
1687          return this.orderedItem;
1688        }
1689        else if (name.equals("occurrenceDateTime")) {
1690          this.occurrence = new DateTimeType();
1691          return this.occurrence;
1692        }
1693        else if (name.equals("occurrencePeriod")) {
1694          this.occurrence = new Period();
1695          return this.occurrence;
1696        }
1697        else if (name.equals("occurrenceTiming")) {
1698          this.occurrence = new Timing();
1699          return this.occurrence;
1700        }
1701        else if (name.equals("authoredOn")) {
1702          throw new FHIRException("Cannot call addChild on a primitive type SupplyRequest.authoredOn");
1703        }
1704        else if (name.equals("requester")) {
1705          this.requester = new SupplyRequestRequesterComponent();
1706          return this.requester;
1707        }
1708        else if (name.equals("supplier")) {
1709          return addSupplier();
1710        }
1711        else if (name.equals("reasonCodeableConcept")) {
1712          this.reason = new CodeableConcept();
1713          return this.reason;
1714        }
1715        else if (name.equals("reasonReference")) {
1716          this.reason = new Reference();
1717          return this.reason;
1718        }
1719        else if (name.equals("deliverFrom")) {
1720          this.deliverFrom = new Reference();
1721          return this.deliverFrom;
1722        }
1723        else if (name.equals("deliverTo")) {
1724          this.deliverTo = new Reference();
1725          return this.deliverTo;
1726        }
1727        else
1728          return super.addChild(name);
1729      }
1730
1731  public String fhirType() {
1732    return "SupplyRequest";
1733
1734  }
1735
1736      public SupplyRequest copy() {
1737        SupplyRequest dst = new SupplyRequest();
1738        copyValues(dst);
1739        dst.identifier = identifier == null ? null : identifier.copy();
1740        dst.status = status == null ? null : status.copy();
1741        dst.category = category == null ? null : category.copy();
1742        dst.priority = priority == null ? null : priority.copy();
1743        dst.orderedItem = orderedItem == null ? null : orderedItem.copy();
1744        dst.occurrence = occurrence == null ? null : occurrence.copy();
1745        dst.authoredOn = authoredOn == null ? null : authoredOn.copy();
1746        dst.requester = requester == null ? null : requester.copy();
1747        if (supplier != null) {
1748          dst.supplier = new ArrayList<Reference>();
1749          for (Reference i : supplier)
1750            dst.supplier.add(i.copy());
1751        };
1752        dst.reason = reason == null ? null : reason.copy();
1753        dst.deliverFrom = deliverFrom == null ? null : deliverFrom.copy();
1754        dst.deliverTo = deliverTo == null ? null : deliverTo.copy();
1755        return dst;
1756      }
1757
1758      protected SupplyRequest typedCopy() {
1759        return copy();
1760      }
1761
1762      @Override
1763      public boolean equalsDeep(Base other_) {
1764        if (!super.equalsDeep(other_))
1765          return false;
1766        if (!(other_ instanceof SupplyRequest))
1767          return false;
1768        SupplyRequest o = (SupplyRequest) other_;
1769        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(category, o.category, true)
1770           && compareDeep(priority, o.priority, true) && compareDeep(orderedItem, o.orderedItem, true) && compareDeep(occurrence, o.occurrence, true)
1771           && compareDeep(authoredOn, o.authoredOn, true) && compareDeep(requester, o.requester, true) && compareDeep(supplier, o.supplier, true)
1772           && compareDeep(reason, o.reason, true) && compareDeep(deliverFrom, o.deliverFrom, true) && compareDeep(deliverTo, o.deliverTo, true)
1773          ;
1774      }
1775
1776      @Override
1777      public boolean equalsShallow(Base other_) {
1778        if (!super.equalsShallow(other_))
1779          return false;
1780        if (!(other_ instanceof SupplyRequest))
1781          return false;
1782        SupplyRequest o = (SupplyRequest) other_;
1783        return compareValues(status, o.status, true) && compareValues(priority, o.priority, true) && compareValues(authoredOn, o.authoredOn, true)
1784          ;
1785      }
1786
1787      public boolean isEmpty() {
1788        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, category
1789          , priority, orderedItem, occurrence, authoredOn, requester, supplier, reason, deliverFrom
1790          , deliverTo);
1791      }
1792
1793  @Override
1794  public ResourceType getResourceType() {
1795    return ResourceType.SupplyRequest;
1796   }
1797
1798 /**
1799   * Search parameter: <b>requester</b>
1800   * <p>
1801   * Description: <b>Individual making the request</b><br>
1802   * Type: <b>reference</b><br>
1803   * Path: <b>SupplyRequest.requester.agent</b><br>
1804   * </p>
1805   */
1806  @SearchParamDefinition(name="requester", path="SupplyRequest.requester.agent", description="Individual making the request", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Device"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner"), @ca.uhn.fhir.model.api.annotation.Compartment(name="RelatedPerson") }, target={Device.class, Organization.class, Patient.class, Practitioner.class, RelatedPerson.class } )
1807  public static final String SP_REQUESTER = "requester";
1808 /**
1809   * <b>Fluent Client</b> search parameter constant for <b>requester</b>
1810   * <p>
1811   * Description: <b>Individual making the request</b><br>
1812   * Type: <b>reference</b><br>
1813   * Path: <b>SupplyRequest.requester.agent</b><br>
1814   * </p>
1815   */
1816  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam REQUESTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_REQUESTER);
1817
1818/**
1819   * Constant for fluent queries to be used to add include statements. Specifies
1820   * the path value of "<b>SupplyRequest:requester</b>".
1821   */
1822  public static final ca.uhn.fhir.model.api.Include INCLUDE_REQUESTER = new ca.uhn.fhir.model.api.Include("SupplyRequest:requester").toLocked();
1823
1824 /**
1825   * Search parameter: <b>date</b>
1826   * <p>
1827   * Description: <b>When the request was made</b><br>
1828   * Type: <b>date</b><br>
1829   * Path: <b>SupplyRequest.authoredOn</b><br>
1830   * </p>
1831   */
1832  @SearchParamDefinition(name="date", path="SupplyRequest.authoredOn", description="When the request was made", type="date" )
1833  public static final String SP_DATE = "date";
1834 /**
1835   * <b>Fluent Client</b> search parameter constant for <b>date</b>
1836   * <p>
1837   * Description: <b>When the request was made</b><br>
1838   * Type: <b>date</b><br>
1839   * Path: <b>SupplyRequest.authoredOn</b><br>
1840   * </p>
1841   */
1842  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
1843
1844 /**
1845   * Search parameter: <b>identifier</b>
1846   * <p>
1847   * Description: <b>Unique identifier</b><br>
1848   * Type: <b>token</b><br>
1849   * Path: <b>SupplyRequest.identifier</b><br>
1850   * </p>
1851   */
1852  @SearchParamDefinition(name="identifier", path="SupplyRequest.identifier", description="Unique identifier", type="token" )
1853  public static final String SP_IDENTIFIER = "identifier";
1854 /**
1855   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
1856   * <p>
1857   * Description: <b>Unique identifier</b><br>
1858   * Type: <b>token</b><br>
1859   * Path: <b>SupplyRequest.identifier</b><br>
1860   * </p>
1861   */
1862  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
1863
1864 /**
1865   * Search parameter: <b>supplier</b>
1866   * <p>
1867   * Description: <b>Who is intended to fulfill the request</b><br>
1868   * Type: <b>reference</b><br>
1869   * Path: <b>SupplyRequest.supplier</b><br>
1870   * </p>
1871   */
1872  @SearchParamDefinition(name="supplier", path="SupplyRequest.supplier", description="Who is intended to fulfill the request", type="reference", target={Organization.class } )
1873  public static final String SP_SUPPLIER = "supplier";
1874 /**
1875   * <b>Fluent Client</b> search parameter constant for <b>supplier</b>
1876   * <p>
1877   * Description: <b>Who is intended to fulfill the request</b><br>
1878   * Type: <b>reference</b><br>
1879   * Path: <b>SupplyRequest.supplier</b><br>
1880   * </p>
1881   */
1882  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUPPLIER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUPPLIER);
1883
1884/**
1885   * Constant for fluent queries to be used to add include statements. Specifies
1886   * the path value of "<b>SupplyRequest:supplier</b>".
1887   */
1888  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUPPLIER = new ca.uhn.fhir.model.api.Include("SupplyRequest:supplier").toLocked();
1889
1890 /**
1891   * Search parameter: <b>category</b>
1892   * <p>
1893   * Description: <b>The kind of supply (central, non-stock, etc.)</b><br>
1894   * Type: <b>token</b><br>
1895   * Path: <b>SupplyRequest.category</b><br>
1896   * </p>
1897   */
1898  @SearchParamDefinition(name="category", path="SupplyRequest.category", description="The kind of supply (central, non-stock, etc.)", type="token" )
1899  public static final String SP_CATEGORY = "category";
1900 /**
1901   * <b>Fluent Client</b> search parameter constant for <b>category</b>
1902   * <p>
1903   * Description: <b>The kind of supply (central, non-stock, etc.)</b><br>
1904   * Type: <b>token</b><br>
1905   * Path: <b>SupplyRequest.category</b><br>
1906   * </p>
1907   */
1908  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CATEGORY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CATEGORY);
1909
1910 /**
1911   * Search parameter: <b>status</b>
1912   * <p>
1913   * Description: <b>draft | active | suspended +</b><br>
1914   * Type: <b>token</b><br>
1915   * Path: <b>SupplyRequest.status</b><br>
1916   * </p>
1917   */
1918  @SearchParamDefinition(name="status", path="SupplyRequest.status", description="draft | active | suspended +", type="token" )
1919  public static final String SP_STATUS = "status";
1920 /**
1921   * <b>Fluent Client</b> search parameter constant for <b>status</b>
1922   * <p>
1923   * Description: <b>draft | active | suspended +</b><br>
1924   * Type: <b>token</b><br>
1925   * Path: <b>SupplyRequest.status</b><br>
1926   * </p>
1927   */
1928  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
1929
1930
1931}
1932