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