001package org.hl7.fhir.r4.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 6, 2018 17:51-0400 for FHIR v3.4.0
033
034import java.util.*;
035
036import org.hl7.fhir.utilities.Utilities;
037import ca.uhn.fhir.model.api.annotation.ResourceDef;
038import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.ChildOrder;
041import ca.uhn.fhir.model.api.annotation.Description;
042import ca.uhn.fhir.model.api.annotation.Block;
043import org.hl7.fhir.instance.model.api.*;
044import org.hl7.fhir.exceptions.FHIRException;
045/**
046 * Record of delivery of what is supplied.
047 */
048@ResourceDef(name="SupplyDelivery", profile="http://hl7.org/fhir/Profile/SupplyDelivery")
049public class SupplyDelivery extends DomainResource {
050
051    public enum SupplyDeliveryStatus {
052        /**
053         * Supply has been requested, but not delivered.
054         */
055        INPROGRESS, 
056        /**
057         * Supply has been delivered ("completed").
058         */
059        COMPLETED, 
060        /**
061         * Delivery was not completed.
062         */
063        ABANDONED, 
064        /**
065         * 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".)
066         */
067        ENTEREDINERROR, 
068        /**
069         * added to help the parsers with the generic types
070         */
071        NULL;
072        public static SupplyDeliveryStatus fromCode(String codeString) throws FHIRException {
073            if (codeString == null || "".equals(codeString))
074                return null;
075        if ("in-progress".equals(codeString))
076          return INPROGRESS;
077        if ("completed".equals(codeString))
078          return COMPLETED;
079        if ("abandoned".equals(codeString))
080          return ABANDONED;
081        if ("entered-in-error".equals(codeString))
082          return ENTEREDINERROR;
083        if (Configuration.isAcceptInvalidEnums())
084          return null;
085        else
086          throw new FHIRException("Unknown SupplyDeliveryStatus code '"+codeString+"'");
087        }
088        public String toCode() {
089          switch (this) {
090            case INPROGRESS: return "in-progress";
091            case COMPLETED: return "completed";
092            case ABANDONED: return "abandoned";
093            case ENTEREDINERROR: return "entered-in-error";
094            default: return "?";
095          }
096        }
097        public String getSystem() {
098          switch (this) {
099            case INPROGRESS: return "http://hl7.org/fhir/supplydelivery-status";
100            case COMPLETED: return "http://hl7.org/fhir/supplydelivery-status";
101            case ABANDONED: return "http://hl7.org/fhir/supplydelivery-status";
102            case ENTEREDINERROR: return "http://hl7.org/fhir/supplydelivery-status";
103            default: return "?";
104          }
105        }
106        public String getDefinition() {
107          switch (this) {
108            case INPROGRESS: return "Supply has been requested, but not delivered.";
109            case COMPLETED: return "Supply has been delivered (\"completed\").";
110            case ABANDONED: return "Delivery was not completed.";
111            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\".)";
112            default: return "?";
113          }
114        }
115        public String getDisplay() {
116          switch (this) {
117            case INPROGRESS: return "In Progress";
118            case COMPLETED: return "Delivered";
119            case ABANDONED: return "Abandoned";
120            case ENTEREDINERROR: return "Entered In Error";
121            default: return "?";
122          }
123        }
124    }
125
126  public static class SupplyDeliveryStatusEnumFactory implements EnumFactory<SupplyDeliveryStatus> {
127    public SupplyDeliveryStatus fromCode(String codeString) throws IllegalArgumentException {
128      if (codeString == null || "".equals(codeString))
129            if (codeString == null || "".equals(codeString))
130                return null;
131        if ("in-progress".equals(codeString))
132          return SupplyDeliveryStatus.INPROGRESS;
133        if ("completed".equals(codeString))
134          return SupplyDeliveryStatus.COMPLETED;
135        if ("abandoned".equals(codeString))
136          return SupplyDeliveryStatus.ABANDONED;
137        if ("entered-in-error".equals(codeString))
138          return SupplyDeliveryStatus.ENTEREDINERROR;
139        throw new IllegalArgumentException("Unknown SupplyDeliveryStatus code '"+codeString+"'");
140        }
141        public Enumeration<SupplyDeliveryStatus> fromType(Base code) throws FHIRException {
142          if (code == null)
143            return null;
144          if (code.isEmpty())
145            return new Enumeration<SupplyDeliveryStatus>(this);
146          String codeString = ((PrimitiveType) code).asStringValue();
147          if (codeString == null || "".equals(codeString))
148            return null;
149        if ("in-progress".equals(codeString))
150          return new Enumeration<SupplyDeliveryStatus>(this, SupplyDeliveryStatus.INPROGRESS);
151        if ("completed".equals(codeString))
152          return new Enumeration<SupplyDeliveryStatus>(this, SupplyDeliveryStatus.COMPLETED);
153        if ("abandoned".equals(codeString))
154          return new Enumeration<SupplyDeliveryStatus>(this, SupplyDeliveryStatus.ABANDONED);
155        if ("entered-in-error".equals(codeString))
156          return new Enumeration<SupplyDeliveryStatus>(this, SupplyDeliveryStatus.ENTEREDINERROR);
157        throw new FHIRException("Unknown SupplyDeliveryStatus code '"+codeString+"'");
158        }
159    public String toCode(SupplyDeliveryStatus code) {
160      if (code == SupplyDeliveryStatus.INPROGRESS)
161        return "in-progress";
162      if (code == SupplyDeliveryStatus.COMPLETED)
163        return "completed";
164      if (code == SupplyDeliveryStatus.ABANDONED)
165        return "abandoned";
166      if (code == SupplyDeliveryStatus.ENTEREDINERROR)
167        return "entered-in-error";
168      return "?";
169      }
170    public String toSystem(SupplyDeliveryStatus code) {
171      return code.getSystem();
172      }
173    }
174
175    @Block()
176    public static class SupplyDeliverySuppliedItemComponent extends BackboneElement implements IBaseBackboneElement {
177        /**
178         * The amount of supply that has been dispensed. Includes unit of measure.
179         */
180        @Child(name = "quantity", type = {SimpleQuantity.class}, order=1, min=0, max=1, modifier=false, summary=false)
181        @Description(shortDefinition="Amount dispensed", formalDefinition="The amount of supply that has been dispensed. Includes unit of measure." )
182        protected SimpleQuantity quantity;
183
184        /**
185         * Identifies the medication, substance or device being dispensed. 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.
186         */
187        @Child(name = "item", type = {CodeableConcept.class, Medication.class, Substance.class, Device.class}, order=2, min=0, max=1, modifier=false, summary=false)
188        @Description(shortDefinition="Medication, Substance, or Device supplied", formalDefinition="Identifies the medication, substance or device being dispensed. 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." )
189        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/supply-item")
190        protected Type item;
191
192        private static final long serialVersionUID = 80196045L;
193
194    /**
195     * Constructor
196     */
197      public SupplyDeliverySuppliedItemComponent() {
198        super();
199      }
200
201        /**
202         * @return {@link #quantity} (The amount of supply that has been dispensed. Includes unit of measure.)
203         */
204        public SimpleQuantity getQuantity() { 
205          if (this.quantity == null)
206            if (Configuration.errorOnAutoCreate())
207              throw new Error("Attempt to auto-create SupplyDeliverySuppliedItemComponent.quantity");
208            else if (Configuration.doAutoCreate())
209              this.quantity = new SimpleQuantity(); // cc
210          return this.quantity;
211        }
212
213        public boolean hasQuantity() { 
214          return this.quantity != null && !this.quantity.isEmpty();
215        }
216
217        /**
218         * @param value {@link #quantity} (The amount of supply that has been dispensed. Includes unit of measure.)
219         */
220        public SupplyDeliverySuppliedItemComponent setQuantity(SimpleQuantity value) { 
221          this.quantity = value;
222          return this;
223        }
224
225        /**
226         * @return {@link #item} (Identifies the medication, substance or device being dispensed. 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.)
227         */
228        public Type getItem() { 
229          return this.item;
230        }
231
232        /**
233         * @return {@link #item} (Identifies the medication, substance or device being dispensed. 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.)
234         */
235        public CodeableConcept getItemCodeableConcept() throws FHIRException { 
236          if (this.item == null)
237            return null;
238          if (!(this.item instanceof CodeableConcept))
239            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.item.getClass().getName()+" was encountered");
240          return (CodeableConcept) this.item;
241        }
242
243        public boolean hasItemCodeableConcept() { 
244          return this != null && this.item instanceof CodeableConcept;
245        }
246
247        /**
248         * @return {@link #item} (Identifies the medication, substance or device being dispensed. 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.)
249         */
250        public Reference getItemReference() throws FHIRException { 
251          if (this.item == null)
252            return null;
253          if (!(this.item instanceof Reference))
254            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.item.getClass().getName()+" was encountered");
255          return (Reference) this.item;
256        }
257
258        public boolean hasItemReference() { 
259          return this != null && this.item instanceof Reference;
260        }
261
262        public boolean hasItem() { 
263          return this.item != null && !this.item.isEmpty();
264        }
265
266        /**
267         * @param value {@link #item} (Identifies the medication, substance or device being dispensed. 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.)
268         */
269        public SupplyDeliverySuppliedItemComponent setItem(Type value) { 
270          if (value != null && !(value instanceof CodeableConcept || value instanceof Reference))
271            throw new Error("Not the right type for SupplyDelivery.suppliedItem.item[x]: "+value.fhirType());
272          this.item = value;
273          return this;
274        }
275
276        protected void listChildren(List<Property> children) {
277          super.listChildren(children);
278          children.add(new Property("quantity", "SimpleQuantity", "The amount of supply that has been dispensed. Includes unit of measure.", 0, 1, quantity));
279          children.add(new Property("item[x]", "CodeableConcept|Reference(Medication|Substance|Device)", "Identifies the medication, substance or device being dispensed. 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));
280        }
281
282        @Override
283        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
284          switch (_hash) {
285          case -1285004149: /*quantity*/  return new Property("quantity", "SimpleQuantity", "The amount of supply that has been dispensed. Includes unit of measure.", 0, 1, quantity);
286          case 2116201613: /*item[x]*/  return new Property("item[x]", "CodeableConcept|Reference(Medication|Substance|Device)", "Identifies the medication, substance or device being dispensed. 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);
287          case 3242771: /*item*/  return new Property("item[x]", "CodeableConcept|Reference(Medication|Substance|Device)", "Identifies the medication, substance or device being dispensed. 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);
288          case 106644494: /*itemCodeableConcept*/  return new Property("item[x]", "CodeableConcept|Reference(Medication|Substance|Device)", "Identifies the medication, substance or device being dispensed. 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);
289          case 1376364920: /*itemReference*/  return new Property("item[x]", "CodeableConcept|Reference(Medication|Substance|Device)", "Identifies the medication, substance or device being dispensed. 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);
290          default: return super.getNamedProperty(_hash, _name, _checkValid);
291          }
292
293        }
294
295      @Override
296      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
297        switch (hash) {
298        case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // SimpleQuantity
299        case 3242771: /*item*/ return this.item == null ? new Base[0] : new Base[] {this.item}; // Type
300        default: return super.getProperty(hash, name, checkValid);
301        }
302
303      }
304
305      @Override
306      public Base setProperty(int hash, String name, Base value) throws FHIRException {
307        switch (hash) {
308        case -1285004149: // quantity
309          this.quantity = castToSimpleQuantity(value); // SimpleQuantity
310          return value;
311        case 3242771: // item
312          this.item = castToType(value); // Type
313          return value;
314        default: return super.setProperty(hash, name, value);
315        }
316
317      }
318
319      @Override
320      public Base setProperty(String name, Base value) throws FHIRException {
321        if (name.equals("quantity")) {
322          this.quantity = castToSimpleQuantity(value); // SimpleQuantity
323        } else if (name.equals("item[x]")) {
324          this.item = castToType(value); // Type
325        } else
326          return super.setProperty(name, value);
327        return value;
328      }
329
330      @Override
331      public Base makeProperty(int hash, String name) throws FHIRException {
332        switch (hash) {
333        case -1285004149:  return getQuantity(); 
334        case 2116201613:  return getItem(); 
335        case 3242771:  return getItem(); 
336        default: return super.makeProperty(hash, name);
337        }
338
339      }
340
341      @Override
342      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
343        switch (hash) {
344        case -1285004149: /*quantity*/ return new String[] {"SimpleQuantity"};
345        case 3242771: /*item*/ return new String[] {"CodeableConcept", "Reference"};
346        default: return super.getTypesForProperty(hash, name);
347        }
348
349      }
350
351      @Override
352      public Base addChild(String name) throws FHIRException {
353        if (name.equals("quantity")) {
354          this.quantity = new SimpleQuantity();
355          return this.quantity;
356        }
357        else if (name.equals("itemCodeableConcept")) {
358          this.item = new CodeableConcept();
359          return this.item;
360        }
361        else if (name.equals("itemReference")) {
362          this.item = new Reference();
363          return this.item;
364        }
365        else
366          return super.addChild(name);
367      }
368
369      public SupplyDeliverySuppliedItemComponent copy() {
370        SupplyDeliverySuppliedItemComponent dst = new SupplyDeliverySuppliedItemComponent();
371        copyValues(dst);
372        dst.quantity = quantity == null ? null : quantity.copy();
373        dst.item = item == null ? null : item.copy();
374        return dst;
375      }
376
377      @Override
378      public boolean equalsDeep(Base other_) {
379        if (!super.equalsDeep(other_))
380          return false;
381        if (!(other_ instanceof SupplyDeliverySuppliedItemComponent))
382          return false;
383        SupplyDeliverySuppliedItemComponent o = (SupplyDeliverySuppliedItemComponent) other_;
384        return compareDeep(quantity, o.quantity, true) && compareDeep(item, o.item, true);
385      }
386
387      @Override
388      public boolean equalsShallow(Base other_) {
389        if (!super.equalsShallow(other_))
390          return false;
391        if (!(other_ instanceof SupplyDeliverySuppliedItemComponent))
392          return false;
393        SupplyDeliverySuppliedItemComponent o = (SupplyDeliverySuppliedItemComponent) other_;
394        return true;
395      }
396
397      public boolean isEmpty() {
398        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(quantity, item);
399      }
400
401  public String fhirType() {
402    return "SupplyDelivery.suppliedItem";
403
404  }
405
406  }
407
408    /**
409     * Identifier for the supply delivery event that is used to identify it across multiple disparate systems.
410     */
411    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
412    @Description(shortDefinition="External identifier", formalDefinition="Identifier for the supply delivery event that is used to identify it across multiple disparate systems." )
413    protected List<Identifier> identifier;
414
415    /**
416     * A plan, proposal or order that is fulfilled in whole or in part by this event.
417     */
418    @Child(name = "basedOn", type = {SupplyRequest.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
419    @Description(shortDefinition="Fulfills plan, proposal or order", formalDefinition="A plan, proposal or order that is fulfilled in whole or in part by this event." )
420    protected List<Reference> basedOn;
421    /**
422     * The actual objects that are the target of the reference (A plan, proposal or order that is fulfilled in whole or in part by this event.)
423     */
424    protected List<SupplyRequest> basedOnTarget;
425
426
427    /**
428     * A larger event of which this particular event is a component or step.
429     */
430    @Child(name = "partOf", type = {SupplyDelivery.class, Contract.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
431    @Description(shortDefinition="Part of referenced event", formalDefinition="A larger event of which this particular event is a component or step." )
432    protected List<Reference> partOf;
433    /**
434     * The actual objects that are the target of the reference (A larger event of which this particular event is a component or step.)
435     */
436    protected List<Resource> partOfTarget;
437
438
439    /**
440     * A code specifying the state of the dispense event.
441     */
442    @Child(name = "status", type = {CodeType.class}, order=3, min=0, max=1, modifier=true, summary=true)
443    @Description(shortDefinition="in-progress | completed | abandoned | entered-in-error", formalDefinition="A code specifying the state of the dispense event." )
444    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/supplydelivery-status")
445    protected Enumeration<SupplyDeliveryStatus> status;
446
447    /**
448     * A link to a resource representing the person whom the delivered item is for.
449     */
450    @Child(name = "patient", type = {Patient.class}, order=4, min=0, max=1, modifier=false, summary=false)
451    @Description(shortDefinition="Patient for whom the item is supplied", formalDefinition="A link to a resource representing the person whom the delivered item is for." )
452    protected Reference patient;
453
454    /**
455     * The actual object that is the target of the reference (A link to a resource representing the person whom the delivered item is for.)
456     */
457    protected Patient patientTarget;
458
459    /**
460     * Indicates the type of dispensing event that is performed. Examples include: Trial Fill, Completion of Trial, Partial Fill, Emergency Fill, Samples, etc.
461     */
462    @Child(name = "type", type = {CodeableConcept.class}, order=5, min=0, max=1, modifier=false, summary=false)
463    @Description(shortDefinition="Category of dispense event", formalDefinition="Indicates the type of dispensing event that is performed. Examples include: Trial Fill, Completion of Trial, Partial Fill, Emergency Fill, Samples, etc." )
464    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/supplydelivery-type")
465    protected CodeableConcept type;
466
467    /**
468     * The item that is being delivered or has been supplied.
469     */
470    @Child(name = "suppliedItem", type = {}, order=6, min=0, max=1, modifier=false, summary=false)
471    @Description(shortDefinition="The item that is delivered or supplied", formalDefinition="The item that is being delivered or has been supplied." )
472    protected SupplyDeliverySuppliedItemComponent suppliedItem;
473
474    /**
475     * The date or time(s) the activity occurred.
476     */
477    @Child(name = "occurrence", type = {DateTimeType.class, Period.class, Timing.class}, order=7, min=0, max=1, modifier=false, summary=true)
478    @Description(shortDefinition="When event occurred", formalDefinition="The date or time(s) the activity occurred." )
479    protected Type occurrence;
480
481    /**
482     * The individual responsible for dispensing the medication, supplier or device.
483     */
484    @Child(name = "supplier", type = {Practitioner.class, PractitionerRole.class, Organization.class}, order=8, min=0, max=1, modifier=false, summary=false)
485    @Description(shortDefinition="Dispenser", formalDefinition="The individual responsible for dispensing the medication, supplier or device." )
486    protected Reference supplier;
487
488    /**
489     * The actual object that is the target of the reference (The individual responsible for dispensing the medication, supplier or device.)
490     */
491    protected Resource supplierTarget;
492
493    /**
494     * Identification of the facility/location where the Supply was shipped to, as part of the dispense event.
495     */
496    @Child(name = "destination", type = {Location.class}, order=9, min=0, max=1, modifier=false, summary=false)
497    @Description(shortDefinition="Where the Supply was sent", formalDefinition="Identification of the facility/location where the Supply was shipped to, as part of the dispense event." )
498    protected Reference destination;
499
500    /**
501     * The actual object that is the target of the reference (Identification of the facility/location where the Supply was shipped to, as part of the dispense event.)
502     */
503    protected Location destinationTarget;
504
505    /**
506     * Identifies the person who picked up the Supply.
507     */
508    @Child(name = "receiver", type = {Practitioner.class}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
509    @Description(shortDefinition="Who collected the Supply", formalDefinition="Identifies the person who picked up the Supply." )
510    protected List<Reference> receiver;
511    /**
512     * The actual objects that are the target of the reference (Identifies the person who picked up the Supply.)
513     */
514    protected List<Practitioner> receiverTarget;
515
516
517    private static final long serialVersionUID = 630023750L;
518
519  /**
520   * Constructor
521   */
522    public SupplyDelivery() {
523      super();
524    }
525
526    /**
527     * @return {@link #identifier} (Identifier for the supply delivery event that is used to identify it across multiple disparate systems.)
528     */
529    public List<Identifier> getIdentifier() { 
530      if (this.identifier == null)
531        this.identifier = new ArrayList<Identifier>();
532      return this.identifier;
533    }
534
535    /**
536     * @return Returns a reference to <code>this</code> for easy method chaining
537     */
538    public SupplyDelivery setIdentifier(List<Identifier> theIdentifier) { 
539      this.identifier = theIdentifier;
540      return this;
541    }
542
543    public boolean hasIdentifier() { 
544      if (this.identifier == null)
545        return false;
546      for (Identifier item : this.identifier)
547        if (!item.isEmpty())
548          return true;
549      return false;
550    }
551
552    public Identifier addIdentifier() { //3
553      Identifier t = new Identifier();
554      if (this.identifier == null)
555        this.identifier = new ArrayList<Identifier>();
556      this.identifier.add(t);
557      return t;
558    }
559
560    public SupplyDelivery addIdentifier(Identifier t) { //3
561      if (t == null)
562        return this;
563      if (this.identifier == null)
564        this.identifier = new ArrayList<Identifier>();
565      this.identifier.add(t);
566      return this;
567    }
568
569    /**
570     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
571     */
572    public Identifier getIdentifierFirstRep() { 
573      if (getIdentifier().isEmpty()) {
574        addIdentifier();
575      }
576      return getIdentifier().get(0);
577    }
578
579    /**
580     * @return {@link #basedOn} (A plan, proposal or order that is fulfilled in whole or in part by this event.)
581     */
582    public List<Reference> getBasedOn() { 
583      if (this.basedOn == null)
584        this.basedOn = new ArrayList<Reference>();
585      return this.basedOn;
586    }
587
588    /**
589     * @return Returns a reference to <code>this</code> for easy method chaining
590     */
591    public SupplyDelivery setBasedOn(List<Reference> theBasedOn) { 
592      this.basedOn = theBasedOn;
593      return this;
594    }
595
596    public boolean hasBasedOn() { 
597      if (this.basedOn == null)
598        return false;
599      for (Reference item : this.basedOn)
600        if (!item.isEmpty())
601          return true;
602      return false;
603    }
604
605    public Reference addBasedOn() { //3
606      Reference t = new Reference();
607      if (this.basedOn == null)
608        this.basedOn = new ArrayList<Reference>();
609      this.basedOn.add(t);
610      return t;
611    }
612
613    public SupplyDelivery addBasedOn(Reference t) { //3
614      if (t == null)
615        return this;
616      if (this.basedOn == null)
617        this.basedOn = new ArrayList<Reference>();
618      this.basedOn.add(t);
619      return this;
620    }
621
622    /**
623     * @return The first repetition of repeating field {@link #basedOn}, creating it if it does not already exist
624     */
625    public Reference getBasedOnFirstRep() { 
626      if (getBasedOn().isEmpty()) {
627        addBasedOn();
628      }
629      return getBasedOn().get(0);
630    }
631
632    /**
633     * @deprecated Use Reference#setResource(IBaseResource) instead
634     */
635    @Deprecated
636    public List<SupplyRequest> getBasedOnTarget() { 
637      if (this.basedOnTarget == null)
638        this.basedOnTarget = new ArrayList<SupplyRequest>();
639      return this.basedOnTarget;
640    }
641
642    /**
643     * @deprecated Use Reference#setResource(IBaseResource) instead
644     */
645    @Deprecated
646    public SupplyRequest addBasedOnTarget() { 
647      SupplyRequest r = new SupplyRequest();
648      if (this.basedOnTarget == null)
649        this.basedOnTarget = new ArrayList<SupplyRequest>();
650      this.basedOnTarget.add(r);
651      return r;
652    }
653
654    /**
655     * @return {@link #partOf} (A larger event of which this particular event is a component or step.)
656     */
657    public List<Reference> getPartOf() { 
658      if (this.partOf == null)
659        this.partOf = new ArrayList<Reference>();
660      return this.partOf;
661    }
662
663    /**
664     * @return Returns a reference to <code>this</code> for easy method chaining
665     */
666    public SupplyDelivery setPartOf(List<Reference> thePartOf) { 
667      this.partOf = thePartOf;
668      return this;
669    }
670
671    public boolean hasPartOf() { 
672      if (this.partOf == null)
673        return false;
674      for (Reference item : this.partOf)
675        if (!item.isEmpty())
676          return true;
677      return false;
678    }
679
680    public Reference addPartOf() { //3
681      Reference t = new Reference();
682      if (this.partOf == null)
683        this.partOf = new ArrayList<Reference>();
684      this.partOf.add(t);
685      return t;
686    }
687
688    public SupplyDelivery addPartOf(Reference t) { //3
689      if (t == null)
690        return this;
691      if (this.partOf == null)
692        this.partOf = new ArrayList<Reference>();
693      this.partOf.add(t);
694      return this;
695    }
696
697    /**
698     * @return The first repetition of repeating field {@link #partOf}, creating it if it does not already exist
699     */
700    public Reference getPartOfFirstRep() { 
701      if (getPartOf().isEmpty()) {
702        addPartOf();
703      }
704      return getPartOf().get(0);
705    }
706
707    /**
708     * @deprecated Use Reference#setResource(IBaseResource) instead
709     */
710    @Deprecated
711    public List<Resource> getPartOfTarget() { 
712      if (this.partOfTarget == null)
713        this.partOfTarget = new ArrayList<Resource>();
714      return this.partOfTarget;
715    }
716
717    /**
718     * @return {@link #status} (A code specifying the state of the dispense event.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
719     */
720    public Enumeration<SupplyDeliveryStatus> getStatusElement() { 
721      if (this.status == null)
722        if (Configuration.errorOnAutoCreate())
723          throw new Error("Attempt to auto-create SupplyDelivery.status");
724        else if (Configuration.doAutoCreate())
725          this.status = new Enumeration<SupplyDeliveryStatus>(new SupplyDeliveryStatusEnumFactory()); // bb
726      return this.status;
727    }
728
729    public boolean hasStatusElement() { 
730      return this.status != null && !this.status.isEmpty();
731    }
732
733    public boolean hasStatus() { 
734      return this.status != null && !this.status.isEmpty();
735    }
736
737    /**
738     * @param value {@link #status} (A code specifying the state of the dispense event.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
739     */
740    public SupplyDelivery setStatusElement(Enumeration<SupplyDeliveryStatus> value) { 
741      this.status = value;
742      return this;
743    }
744
745    /**
746     * @return A code specifying the state of the dispense event.
747     */
748    public SupplyDeliveryStatus getStatus() { 
749      return this.status == null ? null : this.status.getValue();
750    }
751
752    /**
753     * @param value A code specifying the state of the dispense event.
754     */
755    public SupplyDelivery setStatus(SupplyDeliveryStatus value) { 
756      if (value == null)
757        this.status = null;
758      else {
759        if (this.status == null)
760          this.status = new Enumeration<SupplyDeliveryStatus>(new SupplyDeliveryStatusEnumFactory());
761        this.status.setValue(value);
762      }
763      return this;
764    }
765
766    /**
767     * @return {@link #patient} (A link to a resource representing the person whom the delivered item is for.)
768     */
769    public Reference getPatient() { 
770      if (this.patient == null)
771        if (Configuration.errorOnAutoCreate())
772          throw new Error("Attempt to auto-create SupplyDelivery.patient");
773        else if (Configuration.doAutoCreate())
774          this.patient = new Reference(); // cc
775      return this.patient;
776    }
777
778    public boolean hasPatient() { 
779      return this.patient != null && !this.patient.isEmpty();
780    }
781
782    /**
783     * @param value {@link #patient} (A link to a resource representing the person whom the delivered item is for.)
784     */
785    public SupplyDelivery setPatient(Reference value) { 
786      this.patient = value;
787      return this;
788    }
789
790    /**
791     * @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 delivered item is for.)
792     */
793    public Patient getPatientTarget() { 
794      if (this.patientTarget == null)
795        if (Configuration.errorOnAutoCreate())
796          throw new Error("Attempt to auto-create SupplyDelivery.patient");
797        else if (Configuration.doAutoCreate())
798          this.patientTarget = new Patient(); // aa
799      return this.patientTarget;
800    }
801
802    /**
803     * @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 delivered item is for.)
804     */
805    public SupplyDelivery setPatientTarget(Patient value) { 
806      this.patientTarget = value;
807      return this;
808    }
809
810    /**
811     * @return {@link #type} (Indicates the type of dispensing event that is performed. Examples include: Trial Fill, Completion of Trial, Partial Fill, Emergency Fill, Samples, etc.)
812     */
813    public CodeableConcept getType() { 
814      if (this.type == null)
815        if (Configuration.errorOnAutoCreate())
816          throw new Error("Attempt to auto-create SupplyDelivery.type");
817        else if (Configuration.doAutoCreate())
818          this.type = new CodeableConcept(); // cc
819      return this.type;
820    }
821
822    public boolean hasType() { 
823      return this.type != null && !this.type.isEmpty();
824    }
825
826    /**
827     * @param value {@link #type} (Indicates the type of dispensing event that is performed. Examples include: Trial Fill, Completion of Trial, Partial Fill, Emergency Fill, Samples, etc.)
828     */
829    public SupplyDelivery setType(CodeableConcept value) { 
830      this.type = value;
831      return this;
832    }
833
834    /**
835     * @return {@link #suppliedItem} (The item that is being delivered or has been supplied.)
836     */
837    public SupplyDeliverySuppliedItemComponent getSuppliedItem() { 
838      if (this.suppliedItem == null)
839        if (Configuration.errorOnAutoCreate())
840          throw new Error("Attempt to auto-create SupplyDelivery.suppliedItem");
841        else if (Configuration.doAutoCreate())
842          this.suppliedItem = new SupplyDeliverySuppliedItemComponent(); // cc
843      return this.suppliedItem;
844    }
845
846    public boolean hasSuppliedItem() { 
847      return this.suppliedItem != null && !this.suppliedItem.isEmpty();
848    }
849
850    /**
851     * @param value {@link #suppliedItem} (The item that is being delivered or has been supplied.)
852     */
853    public SupplyDelivery setSuppliedItem(SupplyDeliverySuppliedItemComponent value) { 
854      this.suppliedItem = value;
855      return this;
856    }
857
858    /**
859     * @return {@link #occurrence} (The date or time(s) the activity occurred.)
860     */
861    public Type getOccurrence() { 
862      return this.occurrence;
863    }
864
865    /**
866     * @return {@link #occurrence} (The date or time(s) the activity occurred.)
867     */
868    public DateTimeType getOccurrenceDateTimeType() throws FHIRException { 
869      if (this.occurrence == null)
870        return null;
871      if (!(this.occurrence instanceof DateTimeType))
872        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.occurrence.getClass().getName()+" was encountered");
873      return (DateTimeType) this.occurrence;
874    }
875
876    public boolean hasOccurrenceDateTimeType() { 
877      return this != null && this.occurrence instanceof DateTimeType;
878    }
879
880    /**
881     * @return {@link #occurrence} (The date or time(s) the activity occurred.)
882     */
883    public Period getOccurrencePeriod() throws FHIRException { 
884      if (this.occurrence == null)
885        return null;
886      if (!(this.occurrence instanceof Period))
887        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.occurrence.getClass().getName()+" was encountered");
888      return (Period) this.occurrence;
889    }
890
891    public boolean hasOccurrencePeriod() { 
892      return this != null && this.occurrence instanceof Period;
893    }
894
895    /**
896     * @return {@link #occurrence} (The date or time(s) the activity occurred.)
897     */
898    public Timing getOccurrenceTiming() throws FHIRException { 
899      if (this.occurrence == null)
900        return null;
901      if (!(this.occurrence instanceof Timing))
902        throw new FHIRException("Type mismatch: the type Timing was expected, but "+this.occurrence.getClass().getName()+" was encountered");
903      return (Timing) this.occurrence;
904    }
905
906    public boolean hasOccurrenceTiming() { 
907      return this != null && this.occurrence instanceof Timing;
908    }
909
910    public boolean hasOccurrence() { 
911      return this.occurrence != null && !this.occurrence.isEmpty();
912    }
913
914    /**
915     * @param value {@link #occurrence} (The date or time(s) the activity occurred.)
916     */
917    public SupplyDelivery setOccurrence(Type value) { 
918      if (value != null && !(value instanceof DateTimeType || value instanceof Period || value instanceof Timing))
919        throw new Error("Not the right type for SupplyDelivery.occurrence[x]: "+value.fhirType());
920      this.occurrence = value;
921      return this;
922    }
923
924    /**
925     * @return {@link #supplier} (The individual responsible for dispensing the medication, supplier or device.)
926     */
927    public Reference getSupplier() { 
928      if (this.supplier == null)
929        if (Configuration.errorOnAutoCreate())
930          throw new Error("Attempt to auto-create SupplyDelivery.supplier");
931        else if (Configuration.doAutoCreate())
932          this.supplier = new Reference(); // cc
933      return this.supplier;
934    }
935
936    public boolean hasSupplier() { 
937      return this.supplier != null && !this.supplier.isEmpty();
938    }
939
940    /**
941     * @param value {@link #supplier} (The individual responsible for dispensing the medication, supplier or device.)
942     */
943    public SupplyDelivery setSupplier(Reference value) { 
944      this.supplier = value;
945      return this;
946    }
947
948    /**
949     * @return {@link #supplier} 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 individual responsible for dispensing the medication, supplier or device.)
950     */
951    public Resource getSupplierTarget() { 
952      return this.supplierTarget;
953    }
954
955    /**
956     * @param value {@link #supplier} 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 individual responsible for dispensing the medication, supplier or device.)
957     */
958    public SupplyDelivery setSupplierTarget(Resource value) { 
959      this.supplierTarget = value;
960      return this;
961    }
962
963    /**
964     * @return {@link #destination} (Identification of the facility/location where the Supply was shipped to, as part of the dispense event.)
965     */
966    public Reference getDestination() { 
967      if (this.destination == null)
968        if (Configuration.errorOnAutoCreate())
969          throw new Error("Attempt to auto-create SupplyDelivery.destination");
970        else if (Configuration.doAutoCreate())
971          this.destination = new Reference(); // cc
972      return this.destination;
973    }
974
975    public boolean hasDestination() { 
976      return this.destination != null && !this.destination.isEmpty();
977    }
978
979    /**
980     * @param value {@link #destination} (Identification of the facility/location where the Supply was shipped to, as part of the dispense event.)
981     */
982    public SupplyDelivery setDestination(Reference value) { 
983      this.destination = value;
984      return this;
985    }
986
987    /**
988     * @return {@link #destination} 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. (Identification of the facility/location where the Supply was shipped to, as part of the dispense event.)
989     */
990    public Location getDestinationTarget() { 
991      if (this.destinationTarget == null)
992        if (Configuration.errorOnAutoCreate())
993          throw new Error("Attempt to auto-create SupplyDelivery.destination");
994        else if (Configuration.doAutoCreate())
995          this.destinationTarget = new Location(); // aa
996      return this.destinationTarget;
997    }
998
999    /**
1000     * @param value {@link #destination} 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. (Identification of the facility/location where the Supply was shipped to, as part of the dispense event.)
1001     */
1002    public SupplyDelivery setDestinationTarget(Location value) { 
1003      this.destinationTarget = value;
1004      return this;
1005    }
1006
1007    /**
1008     * @return {@link #receiver} (Identifies the person who picked up the Supply.)
1009     */
1010    public List<Reference> getReceiver() { 
1011      if (this.receiver == null)
1012        this.receiver = new ArrayList<Reference>();
1013      return this.receiver;
1014    }
1015
1016    /**
1017     * @return Returns a reference to <code>this</code> for easy method chaining
1018     */
1019    public SupplyDelivery setReceiver(List<Reference> theReceiver) { 
1020      this.receiver = theReceiver;
1021      return this;
1022    }
1023
1024    public boolean hasReceiver() { 
1025      if (this.receiver == null)
1026        return false;
1027      for (Reference item : this.receiver)
1028        if (!item.isEmpty())
1029          return true;
1030      return false;
1031    }
1032
1033    public Reference addReceiver() { //3
1034      Reference t = new Reference();
1035      if (this.receiver == null)
1036        this.receiver = new ArrayList<Reference>();
1037      this.receiver.add(t);
1038      return t;
1039    }
1040
1041    public SupplyDelivery addReceiver(Reference t) { //3
1042      if (t == null)
1043        return this;
1044      if (this.receiver == null)
1045        this.receiver = new ArrayList<Reference>();
1046      this.receiver.add(t);
1047      return this;
1048    }
1049
1050    /**
1051     * @return The first repetition of repeating field {@link #receiver}, creating it if it does not already exist
1052     */
1053    public Reference getReceiverFirstRep() { 
1054      if (getReceiver().isEmpty()) {
1055        addReceiver();
1056      }
1057      return getReceiver().get(0);
1058    }
1059
1060    /**
1061     * @deprecated Use Reference#setResource(IBaseResource) instead
1062     */
1063    @Deprecated
1064    public List<Practitioner> getReceiverTarget() { 
1065      if (this.receiverTarget == null)
1066        this.receiverTarget = new ArrayList<Practitioner>();
1067      return this.receiverTarget;
1068    }
1069
1070    /**
1071     * @deprecated Use Reference#setResource(IBaseResource) instead
1072     */
1073    @Deprecated
1074    public Practitioner addReceiverTarget() { 
1075      Practitioner r = new Practitioner();
1076      if (this.receiverTarget == null)
1077        this.receiverTarget = new ArrayList<Practitioner>();
1078      this.receiverTarget.add(r);
1079      return r;
1080    }
1081
1082      protected void listChildren(List<Property> children) {
1083        super.listChildren(children);
1084        children.add(new Property("identifier", "Identifier", "Identifier for the supply delivery event that is used to identify it across multiple disparate systems.", 0, java.lang.Integer.MAX_VALUE, identifier));
1085        children.add(new Property("basedOn", "Reference(SupplyRequest)", "A plan, proposal or order that is fulfilled in whole or in part by this event.", 0, java.lang.Integer.MAX_VALUE, basedOn));
1086        children.add(new Property("partOf", "Reference(SupplyDelivery|Contract)", "A larger event of which this particular event is a component or step.", 0, java.lang.Integer.MAX_VALUE, partOf));
1087        children.add(new Property("status", "code", "A code specifying the state of the dispense event.", 0, 1, status));
1088        children.add(new Property("patient", "Reference(Patient)", "A link to a resource representing the person whom the delivered item is for.", 0, 1, patient));
1089        children.add(new Property("type", "CodeableConcept", "Indicates the type of dispensing event that is performed. Examples include: Trial Fill, Completion of Trial, Partial Fill, Emergency Fill, Samples, etc.", 0, 1, type));
1090        children.add(new Property("suppliedItem", "", "The item that is being delivered or has been supplied.", 0, 1, suppliedItem));
1091        children.add(new Property("occurrence[x]", "dateTime|Period|Timing", "The date or time(s) the activity occurred.", 0, 1, occurrence));
1092        children.add(new Property("supplier", "Reference(Practitioner|PractitionerRole|Organization)", "The individual responsible for dispensing the medication, supplier or device.", 0, 1, supplier));
1093        children.add(new Property("destination", "Reference(Location)", "Identification of the facility/location where the Supply was shipped to, as part of the dispense event.", 0, 1, destination));
1094        children.add(new Property("receiver", "Reference(Practitioner)", "Identifies the person who picked up the Supply.", 0, java.lang.Integer.MAX_VALUE, receiver));
1095      }
1096
1097      @Override
1098      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1099        switch (_hash) {
1100        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Identifier for the supply delivery event that is used to identify it across multiple disparate systems.", 0, java.lang.Integer.MAX_VALUE, identifier);
1101        case -332612366: /*basedOn*/  return new Property("basedOn", "Reference(SupplyRequest)", "A plan, proposal or order that is fulfilled in whole or in part by this event.", 0, java.lang.Integer.MAX_VALUE, basedOn);
1102        case -995410646: /*partOf*/  return new Property("partOf", "Reference(SupplyDelivery|Contract)", "A larger event of which this particular event is a component or step.", 0, java.lang.Integer.MAX_VALUE, partOf);
1103        case -892481550: /*status*/  return new Property("status", "code", "A code specifying the state of the dispense event.", 0, 1, status);
1104        case -791418107: /*patient*/  return new Property("patient", "Reference(Patient)", "A link to a resource representing the person whom the delivered item is for.", 0, 1, patient);
1105        case 3575610: /*type*/  return new Property("type", "CodeableConcept", "Indicates the type of dispensing event that is performed. Examples include: Trial Fill, Completion of Trial, Partial Fill, Emergency Fill, Samples, etc.", 0, 1, type);
1106        case 1993333233: /*suppliedItem*/  return new Property("suppliedItem", "", "The item that is being delivered or has been supplied.", 0, 1, suppliedItem);
1107        case -2022646513: /*occurrence[x]*/  return new Property("occurrence[x]", "dateTime|Period|Timing", "The date or time(s) the activity occurred.", 0, 1, occurrence);
1108        case 1687874001: /*occurrence*/  return new Property("occurrence[x]", "dateTime|Period|Timing", "The date or time(s) the activity occurred.", 0, 1, occurrence);
1109        case -298443636: /*occurrenceDateTime*/  return new Property("occurrence[x]", "dateTime|Period|Timing", "The date or time(s) the activity occurred.", 0, 1, occurrence);
1110        case 1397156594: /*occurrencePeriod*/  return new Property("occurrence[x]", "dateTime|Period|Timing", "The date or time(s) the activity occurred.", 0, 1, occurrence);
1111        case 1515218299: /*occurrenceTiming*/  return new Property("occurrence[x]", "dateTime|Period|Timing", "The date or time(s) the activity occurred.", 0, 1, occurrence);
1112        case -1663305268: /*supplier*/  return new Property("supplier", "Reference(Practitioner|PractitionerRole|Organization)", "The individual responsible for dispensing the medication, supplier or device.", 0, 1, supplier);
1113        case -1429847026: /*destination*/  return new Property("destination", "Reference(Location)", "Identification of the facility/location where the Supply was shipped to, as part of the dispense event.", 0, 1, destination);
1114        case -808719889: /*receiver*/  return new Property("receiver", "Reference(Practitioner)", "Identifies the person who picked up the Supply.", 0, java.lang.Integer.MAX_VALUE, receiver);
1115        default: return super.getNamedProperty(_hash, _name, _checkValid);
1116        }
1117
1118      }
1119
1120      @Override
1121      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1122        switch (hash) {
1123        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1124        case -332612366: /*basedOn*/ return this.basedOn == null ? new Base[0] : this.basedOn.toArray(new Base[this.basedOn.size()]); // Reference
1125        case -995410646: /*partOf*/ return this.partOf == null ? new Base[0] : this.partOf.toArray(new Base[this.partOf.size()]); // Reference
1126        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<SupplyDeliveryStatus>
1127        case -791418107: /*patient*/ return this.patient == null ? new Base[0] : new Base[] {this.patient}; // Reference
1128        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
1129        case 1993333233: /*suppliedItem*/ return this.suppliedItem == null ? new Base[0] : new Base[] {this.suppliedItem}; // SupplyDeliverySuppliedItemComponent
1130        case 1687874001: /*occurrence*/ return this.occurrence == null ? new Base[0] : new Base[] {this.occurrence}; // Type
1131        case -1663305268: /*supplier*/ return this.supplier == null ? new Base[0] : new Base[] {this.supplier}; // Reference
1132        case -1429847026: /*destination*/ return this.destination == null ? new Base[0] : new Base[] {this.destination}; // Reference
1133        case -808719889: /*receiver*/ return this.receiver == null ? new Base[0] : this.receiver.toArray(new Base[this.receiver.size()]); // Reference
1134        default: return super.getProperty(hash, name, checkValid);
1135        }
1136
1137      }
1138
1139      @Override
1140      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1141        switch (hash) {
1142        case -1618432855: // identifier
1143          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1144          return value;
1145        case -332612366: // basedOn
1146          this.getBasedOn().add(castToReference(value)); // Reference
1147          return value;
1148        case -995410646: // partOf
1149          this.getPartOf().add(castToReference(value)); // Reference
1150          return value;
1151        case -892481550: // status
1152          value = new SupplyDeliveryStatusEnumFactory().fromType(castToCode(value));
1153          this.status = (Enumeration) value; // Enumeration<SupplyDeliveryStatus>
1154          return value;
1155        case -791418107: // patient
1156          this.patient = castToReference(value); // Reference
1157          return value;
1158        case 3575610: // type
1159          this.type = castToCodeableConcept(value); // CodeableConcept
1160          return value;
1161        case 1993333233: // suppliedItem
1162          this.suppliedItem = (SupplyDeliverySuppliedItemComponent) value; // SupplyDeliverySuppliedItemComponent
1163          return value;
1164        case 1687874001: // occurrence
1165          this.occurrence = castToType(value); // Type
1166          return value;
1167        case -1663305268: // supplier
1168          this.supplier = castToReference(value); // Reference
1169          return value;
1170        case -1429847026: // destination
1171          this.destination = castToReference(value); // Reference
1172          return value;
1173        case -808719889: // receiver
1174          this.getReceiver().add(castToReference(value)); // Reference
1175          return value;
1176        default: return super.setProperty(hash, name, value);
1177        }
1178
1179      }
1180
1181      @Override
1182      public Base setProperty(String name, Base value) throws FHIRException {
1183        if (name.equals("identifier")) {
1184          this.getIdentifier().add(castToIdentifier(value));
1185        } else if (name.equals("basedOn")) {
1186          this.getBasedOn().add(castToReference(value));
1187        } else if (name.equals("partOf")) {
1188          this.getPartOf().add(castToReference(value));
1189        } else if (name.equals("status")) {
1190          value = new SupplyDeliveryStatusEnumFactory().fromType(castToCode(value));
1191          this.status = (Enumeration) value; // Enumeration<SupplyDeliveryStatus>
1192        } else if (name.equals("patient")) {
1193          this.patient = castToReference(value); // Reference
1194        } else if (name.equals("type")) {
1195          this.type = castToCodeableConcept(value); // CodeableConcept
1196        } else if (name.equals("suppliedItem")) {
1197          this.suppliedItem = (SupplyDeliverySuppliedItemComponent) value; // SupplyDeliverySuppliedItemComponent
1198        } else if (name.equals("occurrence[x]")) {
1199          this.occurrence = castToType(value); // Type
1200        } else if (name.equals("supplier")) {
1201          this.supplier = castToReference(value); // Reference
1202        } else if (name.equals("destination")) {
1203          this.destination = castToReference(value); // Reference
1204        } else if (name.equals("receiver")) {
1205          this.getReceiver().add(castToReference(value));
1206        } else
1207          return super.setProperty(name, value);
1208        return value;
1209      }
1210
1211      @Override
1212      public Base makeProperty(int hash, String name) throws FHIRException {
1213        switch (hash) {
1214        case -1618432855:  return addIdentifier(); 
1215        case -332612366:  return addBasedOn(); 
1216        case -995410646:  return addPartOf(); 
1217        case -892481550:  return getStatusElement();
1218        case -791418107:  return getPatient(); 
1219        case 3575610:  return getType(); 
1220        case 1993333233:  return getSuppliedItem(); 
1221        case -2022646513:  return getOccurrence(); 
1222        case 1687874001:  return getOccurrence(); 
1223        case -1663305268:  return getSupplier(); 
1224        case -1429847026:  return getDestination(); 
1225        case -808719889:  return addReceiver(); 
1226        default: return super.makeProperty(hash, name);
1227        }
1228
1229      }
1230
1231      @Override
1232      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1233        switch (hash) {
1234        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
1235        case -332612366: /*basedOn*/ return new String[] {"Reference"};
1236        case -995410646: /*partOf*/ return new String[] {"Reference"};
1237        case -892481550: /*status*/ return new String[] {"code"};
1238        case -791418107: /*patient*/ return new String[] {"Reference"};
1239        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
1240        case 1993333233: /*suppliedItem*/ return new String[] {};
1241        case 1687874001: /*occurrence*/ return new String[] {"dateTime", "Period", "Timing"};
1242        case -1663305268: /*supplier*/ return new String[] {"Reference"};
1243        case -1429847026: /*destination*/ return new String[] {"Reference"};
1244        case -808719889: /*receiver*/ return new String[] {"Reference"};
1245        default: return super.getTypesForProperty(hash, name);
1246        }
1247
1248      }
1249
1250      @Override
1251      public Base addChild(String name) throws FHIRException {
1252        if (name.equals("identifier")) {
1253          return addIdentifier();
1254        }
1255        else if (name.equals("basedOn")) {
1256          return addBasedOn();
1257        }
1258        else if (name.equals("partOf")) {
1259          return addPartOf();
1260        }
1261        else if (name.equals("status")) {
1262          throw new FHIRException("Cannot call addChild on a primitive type SupplyDelivery.status");
1263        }
1264        else if (name.equals("patient")) {
1265          this.patient = new Reference();
1266          return this.patient;
1267        }
1268        else if (name.equals("type")) {
1269          this.type = new CodeableConcept();
1270          return this.type;
1271        }
1272        else if (name.equals("suppliedItem")) {
1273          this.suppliedItem = new SupplyDeliverySuppliedItemComponent();
1274          return this.suppliedItem;
1275        }
1276        else if (name.equals("occurrenceDateTime")) {
1277          this.occurrence = new DateTimeType();
1278          return this.occurrence;
1279        }
1280        else if (name.equals("occurrencePeriod")) {
1281          this.occurrence = new Period();
1282          return this.occurrence;
1283        }
1284        else if (name.equals("occurrenceTiming")) {
1285          this.occurrence = new Timing();
1286          return this.occurrence;
1287        }
1288        else if (name.equals("supplier")) {
1289          this.supplier = new Reference();
1290          return this.supplier;
1291        }
1292        else if (name.equals("destination")) {
1293          this.destination = new Reference();
1294          return this.destination;
1295        }
1296        else if (name.equals("receiver")) {
1297          return addReceiver();
1298        }
1299        else
1300          return super.addChild(name);
1301      }
1302
1303  public String fhirType() {
1304    return "SupplyDelivery";
1305
1306  }
1307
1308      public SupplyDelivery copy() {
1309        SupplyDelivery dst = new SupplyDelivery();
1310        copyValues(dst);
1311        if (identifier != null) {
1312          dst.identifier = new ArrayList<Identifier>();
1313          for (Identifier i : identifier)
1314            dst.identifier.add(i.copy());
1315        };
1316        if (basedOn != null) {
1317          dst.basedOn = new ArrayList<Reference>();
1318          for (Reference i : basedOn)
1319            dst.basedOn.add(i.copy());
1320        };
1321        if (partOf != null) {
1322          dst.partOf = new ArrayList<Reference>();
1323          for (Reference i : partOf)
1324            dst.partOf.add(i.copy());
1325        };
1326        dst.status = status == null ? null : status.copy();
1327        dst.patient = patient == null ? null : patient.copy();
1328        dst.type = type == null ? null : type.copy();
1329        dst.suppliedItem = suppliedItem == null ? null : suppliedItem.copy();
1330        dst.occurrence = occurrence == null ? null : occurrence.copy();
1331        dst.supplier = supplier == null ? null : supplier.copy();
1332        dst.destination = destination == null ? null : destination.copy();
1333        if (receiver != null) {
1334          dst.receiver = new ArrayList<Reference>();
1335          for (Reference i : receiver)
1336            dst.receiver.add(i.copy());
1337        };
1338        return dst;
1339      }
1340
1341      protected SupplyDelivery typedCopy() {
1342        return copy();
1343      }
1344
1345      @Override
1346      public boolean equalsDeep(Base other_) {
1347        if (!super.equalsDeep(other_))
1348          return false;
1349        if (!(other_ instanceof SupplyDelivery))
1350          return false;
1351        SupplyDelivery o = (SupplyDelivery) other_;
1352        return compareDeep(identifier, o.identifier, true) && compareDeep(basedOn, o.basedOn, true) && compareDeep(partOf, o.partOf, true)
1353           && compareDeep(status, o.status, true) && compareDeep(patient, o.patient, true) && compareDeep(type, o.type, true)
1354           && compareDeep(suppliedItem, o.suppliedItem, true) && compareDeep(occurrence, o.occurrence, true)
1355           && compareDeep(supplier, o.supplier, true) && compareDeep(destination, o.destination, true) && compareDeep(receiver, o.receiver, true)
1356          ;
1357      }
1358
1359      @Override
1360      public boolean equalsShallow(Base other_) {
1361        if (!super.equalsShallow(other_))
1362          return false;
1363        if (!(other_ instanceof SupplyDelivery))
1364          return false;
1365        SupplyDelivery o = (SupplyDelivery) other_;
1366        return compareValues(status, o.status, true);
1367      }
1368
1369      public boolean isEmpty() {
1370        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, basedOn, partOf
1371          , status, patient, type, suppliedItem, occurrence, supplier, destination, receiver
1372          );
1373      }
1374
1375  @Override
1376  public ResourceType getResourceType() {
1377    return ResourceType.SupplyDelivery;
1378   }
1379
1380 /**
1381   * Search parameter: <b>identifier</b>
1382   * <p>
1383   * Description: <b>External identifier</b><br>
1384   * Type: <b>token</b><br>
1385   * Path: <b>SupplyDelivery.identifier</b><br>
1386   * </p>
1387   */
1388  @SearchParamDefinition(name="identifier", path="SupplyDelivery.identifier", description="External identifier", type="token" )
1389  public static final String SP_IDENTIFIER = "identifier";
1390 /**
1391   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
1392   * <p>
1393   * Description: <b>External identifier</b><br>
1394   * Type: <b>token</b><br>
1395   * Path: <b>SupplyDelivery.identifier</b><br>
1396   * </p>
1397   */
1398  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
1399
1400 /**
1401   * Search parameter: <b>receiver</b>
1402   * <p>
1403   * Description: <b>Who collected the Supply</b><br>
1404   * Type: <b>reference</b><br>
1405   * Path: <b>SupplyDelivery.receiver</b><br>
1406   * </p>
1407   */
1408  @SearchParamDefinition(name="receiver", path="SupplyDelivery.receiver", description="Who collected the Supply", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner") }, target={Practitioner.class } )
1409  public static final String SP_RECEIVER = "receiver";
1410 /**
1411   * <b>Fluent Client</b> search parameter constant for <b>receiver</b>
1412   * <p>
1413   * Description: <b>Who collected the Supply</b><br>
1414   * Type: <b>reference</b><br>
1415   * Path: <b>SupplyDelivery.receiver</b><br>
1416   * </p>
1417   */
1418  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam RECEIVER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_RECEIVER);
1419
1420/**
1421   * Constant for fluent queries to be used to add include statements. Specifies
1422   * the path value of "<b>SupplyDelivery:receiver</b>".
1423   */
1424  public static final ca.uhn.fhir.model.api.Include INCLUDE_RECEIVER = new ca.uhn.fhir.model.api.Include("SupplyDelivery:receiver").toLocked();
1425
1426 /**
1427   * Search parameter: <b>patient</b>
1428   * <p>
1429   * Description: <b>Patient for whom the item is supplied</b><br>
1430   * Type: <b>reference</b><br>
1431   * Path: <b>SupplyDelivery.patient</b><br>
1432   * </p>
1433   */
1434  @SearchParamDefinition(name="patient", path="SupplyDelivery.patient", description="Patient for whom the item is supplied", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Patient.class } )
1435  public static final String SP_PATIENT = "patient";
1436 /**
1437   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
1438   * <p>
1439   * Description: <b>Patient for whom the item is supplied</b><br>
1440   * Type: <b>reference</b><br>
1441   * Path: <b>SupplyDelivery.patient</b><br>
1442   * </p>
1443   */
1444  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
1445
1446/**
1447   * Constant for fluent queries to be used to add include statements. Specifies
1448   * the path value of "<b>SupplyDelivery:patient</b>".
1449   */
1450  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("SupplyDelivery:patient").toLocked();
1451
1452 /**
1453   * Search parameter: <b>supplier</b>
1454   * <p>
1455   * Description: <b>Dispenser</b><br>
1456   * Type: <b>reference</b><br>
1457   * Path: <b>SupplyDelivery.supplier</b><br>
1458   * </p>
1459   */
1460  @SearchParamDefinition(name="supplier", path="SupplyDelivery.supplier", description="Dispenser", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner") }, target={Organization.class, Practitioner.class, PractitionerRole.class } )
1461  public static final String SP_SUPPLIER = "supplier";
1462 /**
1463   * <b>Fluent Client</b> search parameter constant for <b>supplier</b>
1464   * <p>
1465   * Description: <b>Dispenser</b><br>
1466   * Type: <b>reference</b><br>
1467   * Path: <b>SupplyDelivery.supplier</b><br>
1468   * </p>
1469   */
1470  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUPPLIER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUPPLIER);
1471
1472/**
1473   * Constant for fluent queries to be used to add include statements. Specifies
1474   * the path value of "<b>SupplyDelivery:supplier</b>".
1475   */
1476  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUPPLIER = new ca.uhn.fhir.model.api.Include("SupplyDelivery:supplier").toLocked();
1477
1478 /**
1479   * Search parameter: <b>status</b>
1480   * <p>
1481   * Description: <b>in-progress | completed | abandoned | entered-in-error</b><br>
1482   * Type: <b>token</b><br>
1483   * Path: <b>SupplyDelivery.status</b><br>
1484   * </p>
1485   */
1486  @SearchParamDefinition(name="status", path="SupplyDelivery.status", description="in-progress | completed | abandoned | entered-in-error", type="token" )
1487  public static final String SP_STATUS = "status";
1488 /**
1489   * <b>Fluent Client</b> search parameter constant for <b>status</b>
1490   * <p>
1491   * Description: <b>in-progress | completed | abandoned | entered-in-error</b><br>
1492   * Type: <b>token</b><br>
1493   * Path: <b>SupplyDelivery.status</b><br>
1494   * </p>
1495   */
1496  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
1497
1498
1499}
1500