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