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