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