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