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