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