001package org.hl7.fhir.dstu2016may.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 Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
033import java.util.ArrayList;
034import java.util.Date;
035import java.util.List;
036
037import org.hl7.fhir.exceptions.FHIRException;
038
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.Description;
041import ca.uhn.fhir.model.api.annotation.ResourceDef;
042import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
043/**
044 * Record of delivery of what is supplied.
045 */
046@ResourceDef(name="SupplyDelivery", profile="http://hl7.org/fhir/Profile/SupplyDelivery")
047public class SupplyDelivery extends DomainResource {
048
049    public enum SupplyDeliveryStatus {
050        /**
051         * Supply has been requested, but not delivered.
052         */
053        INPROGRESS, 
054        /**
055         * Supply has been delivered ("completed").
056         */
057        COMPLETED, 
058        /**
059         * Dispensing was not completed.
060         */
061        ABANDONED, 
062        /**
063         * added to help the parsers
064         */
065        NULL;
066        public static SupplyDeliveryStatus fromCode(String codeString) throws FHIRException {
067            if (codeString == null || "".equals(codeString))
068                return null;
069        if ("in-progress".equals(codeString))
070          return INPROGRESS;
071        if ("completed".equals(codeString))
072          return COMPLETED;
073        if ("abandoned".equals(codeString))
074          return ABANDONED;
075        throw new FHIRException("Unknown SupplyDeliveryStatus code '"+codeString+"'");
076        }
077        public String toCode() {
078          switch (this) {
079            case INPROGRESS: return "in-progress";
080            case COMPLETED: return "completed";
081            case ABANDONED: return "abandoned";
082            default: return "?";
083          }
084        }
085        public String getSystem() {
086          switch (this) {
087            case INPROGRESS: return "http://hl7.org/fhir/supplydelivery-status";
088            case COMPLETED: return "http://hl7.org/fhir/supplydelivery-status";
089            case ABANDONED: return "http://hl7.org/fhir/supplydelivery-status";
090            default: return "?";
091          }
092        }
093        public String getDefinition() {
094          switch (this) {
095            case INPROGRESS: return "Supply has been requested, but not delivered.";
096            case COMPLETED: return "Supply has been delivered (\"completed\").";
097            case ABANDONED: return "Dispensing was not completed.";
098            default: return "?";
099          }
100        }
101        public String getDisplay() {
102          switch (this) {
103            case INPROGRESS: return "In Progress";
104            case COMPLETED: return "Delivered";
105            case ABANDONED: return "Abandoned";
106            default: return "?";
107          }
108        }
109    }
110
111  public static class SupplyDeliveryStatusEnumFactory implements EnumFactory<SupplyDeliveryStatus> {
112    public SupplyDeliveryStatus fromCode(String codeString) throws IllegalArgumentException {
113      if (codeString == null || "".equals(codeString))
114            if (codeString == null || "".equals(codeString))
115                return null;
116        if ("in-progress".equals(codeString))
117          return SupplyDeliveryStatus.INPROGRESS;
118        if ("completed".equals(codeString))
119          return SupplyDeliveryStatus.COMPLETED;
120        if ("abandoned".equals(codeString))
121          return SupplyDeliveryStatus.ABANDONED;
122        throw new IllegalArgumentException("Unknown SupplyDeliveryStatus code '"+codeString+"'");
123        }
124        public Enumeration<SupplyDeliveryStatus> fromType(Base code) throws FHIRException {
125          if (code == null || code.isEmpty())
126            return null;
127          String codeString = ((PrimitiveType) code).asStringValue();
128          if (codeString == null || "".equals(codeString))
129            return null;
130        if ("in-progress".equals(codeString))
131          return new Enumeration<SupplyDeliveryStatus>(this, SupplyDeliveryStatus.INPROGRESS);
132        if ("completed".equals(codeString))
133          return new Enumeration<SupplyDeliveryStatus>(this, SupplyDeliveryStatus.COMPLETED);
134        if ("abandoned".equals(codeString))
135          return new Enumeration<SupplyDeliveryStatus>(this, SupplyDeliveryStatus.ABANDONED);
136        throw new FHIRException("Unknown SupplyDeliveryStatus code '"+codeString+"'");
137        }
138    public String toCode(SupplyDeliveryStatus code) {
139      if (code == SupplyDeliveryStatus.INPROGRESS)
140        return "in-progress";
141      if (code == SupplyDeliveryStatus.COMPLETED)
142        return "completed";
143      if (code == SupplyDeliveryStatus.ABANDONED)
144        return "abandoned";
145      return "?";
146      }
147    public String toSystem(SupplyDeliveryStatus code) {
148      return code.getSystem();
149      }
150    }
151
152    /**
153     * Identifier assigned by the dispensing facility when the item(s) is dispensed.
154     */
155    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=1, modifier=false, summary=true)
156    @Description(shortDefinition="External identifier", formalDefinition="Identifier assigned by the dispensing facility when the item(s) is dispensed." )
157    protected Identifier identifier;
158
159    /**
160     * A code specifying the state of the dispense event.
161     */
162    @Child(name = "status", type = {CodeType.class}, order=1, min=0, max=1, modifier=true, summary=true)
163    @Description(shortDefinition="in-progress | completed | abandoned", formalDefinition="A code specifying the state of the dispense event." )
164    protected Enumeration<SupplyDeliveryStatus> status;
165
166    /**
167     * A link to a resource representing the person whom the delivered item is for.
168     */
169    @Child(name = "patient", type = {Patient.class}, order=2, min=0, max=1, modifier=false, summary=true)
170    @Description(shortDefinition="Patient for whom the item is supplied", formalDefinition="A link to a resource representing the person whom the delivered item is for." )
171    protected Reference patient;
172
173    /**
174     * The actual object that is the target of the reference (A link to a resource representing the person whom the delivered item is for.)
175     */
176    protected Patient patientTarget;
177
178    /**
179     * Indicates the type of dispensing event that is performed. Examples include: Trial Fill, Completion of Trial, Partial Fill, Emergency Fill, Samples, etc.
180     */
181    @Child(name = "type", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true)
182    @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." )
183    protected CodeableConcept type;
184
185    /**
186     * The amount of supply that has been dispensed. Includes unit of measure.
187     */
188    @Child(name = "quantity", type = {SimpleQuantity.class}, order=4, min=0, max=1, modifier=false, summary=true)
189    @Description(shortDefinition="Amount dispensed", formalDefinition="The amount of supply that has been dispensed. Includes unit of measure." )
190    protected SimpleQuantity quantity;
191
192    /**
193     * Identifies the medication, substance or device being dispensed. This is either a link to a resource representing the details of the item or a simple attribute carrying a code that identifies the item from a known list.
194     */
195    @Child(name = "suppliedItem", type = {Medication.class, Substance.class, Device.class}, order=5, min=0, max=1, modifier=false, summary=true)
196    @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 simple attribute carrying a code that identifies the item from a known list." )
197    protected Reference suppliedItem;
198
199    /**
200     * The actual object that is the target of the reference (Identifies the medication, substance or device being dispensed. This is either a link to a resource representing the details of the item or a simple attribute carrying a code that identifies the item from a known list.)
201     */
202    protected Resource suppliedItemTarget;
203
204    /**
205     * The individual responsible for dispensing the medication, supplier or device.
206     */
207    @Child(name = "supplier", type = {Practitioner.class}, order=6, min=0, max=1, modifier=false, summary=true)
208    @Description(shortDefinition="Dispenser", formalDefinition="The individual responsible for dispensing the medication, supplier or device." )
209    protected Reference supplier;
210
211    /**
212     * The actual object that is the target of the reference (The individual responsible for dispensing the medication, supplier or device.)
213     */
214    protected Practitioner supplierTarget;
215
216    /**
217     * The time the dispense event occurred.
218     */
219    @Child(name = "whenPrepared", type = {Period.class}, order=7, min=0, max=1, modifier=false, summary=true)
220    @Description(shortDefinition="Dispensing time", formalDefinition="The time the dispense event occurred." )
221    protected Period whenPrepared;
222
223    /**
224     * The time the dispensed item was sent or handed to the patient (or agent).
225     */
226    @Child(name = "time", type = {DateTimeType.class}, order=8, min=0, max=1, modifier=false, summary=true)
227    @Description(shortDefinition="Handover time", formalDefinition="The time the dispensed item was sent or handed to the patient (or agent)." )
228    protected DateTimeType time;
229
230    /**
231     * Identification of the facility/location where the Supply was shipped to, as part of the dispense event.
232     */
233    @Child(name = "destination", type = {Location.class}, order=9, min=0, max=1, modifier=false, summary=true)
234    @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." )
235    protected Reference destination;
236
237    /**
238     * The actual object that is the target of the reference (Identification of the facility/location where the Supply was shipped to, as part of the dispense event.)
239     */
240    protected Location destinationTarget;
241
242    /**
243     * Identifies the person who picked up the Supply.
244     */
245    @Child(name = "receiver", type = {Practitioner.class}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
246    @Description(shortDefinition="Who collected the Supply", formalDefinition="Identifies the person who picked up the Supply." )
247    protected List<Reference> receiver;
248    /**
249     * The actual objects that are the target of the reference (Identifies the person who picked up the Supply.)
250     */
251    protected List<Practitioner> receiverTarget;
252
253
254    private static final long serialVersionUID = -1520129707L;
255
256  /**
257   * Constructor
258   */
259    public SupplyDelivery() {
260      super();
261    }
262
263    /**
264     * @return {@link #identifier} (Identifier assigned by the dispensing facility when the item(s) is dispensed.)
265     */
266    public Identifier getIdentifier() { 
267      if (this.identifier == null)
268        if (Configuration.errorOnAutoCreate())
269          throw new Error("Attempt to auto-create SupplyDelivery.identifier");
270        else if (Configuration.doAutoCreate())
271          this.identifier = new Identifier(); // cc
272      return this.identifier;
273    }
274
275    public boolean hasIdentifier() { 
276      return this.identifier != null && !this.identifier.isEmpty();
277    }
278
279    /**
280     * @param value {@link #identifier} (Identifier assigned by the dispensing facility when the item(s) is dispensed.)
281     */
282    public SupplyDelivery setIdentifier(Identifier value) { 
283      this.identifier = value;
284      return this;
285    }
286
287    /**
288     * @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
289     */
290    public Enumeration<SupplyDeliveryStatus> getStatusElement() { 
291      if (this.status == null)
292        if (Configuration.errorOnAutoCreate())
293          throw new Error("Attempt to auto-create SupplyDelivery.status");
294        else if (Configuration.doAutoCreate())
295          this.status = new Enumeration<SupplyDeliveryStatus>(new SupplyDeliveryStatusEnumFactory()); // bb
296      return this.status;
297    }
298
299    public boolean hasStatusElement() { 
300      return this.status != null && !this.status.isEmpty();
301    }
302
303    public boolean hasStatus() { 
304      return this.status != null && !this.status.isEmpty();
305    }
306
307    /**
308     * @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
309     */
310    public SupplyDelivery setStatusElement(Enumeration<SupplyDeliveryStatus> value) { 
311      this.status = value;
312      return this;
313    }
314
315    /**
316     * @return A code specifying the state of the dispense event.
317     */
318    public SupplyDeliveryStatus getStatus() { 
319      return this.status == null ? null : this.status.getValue();
320    }
321
322    /**
323     * @param value A code specifying the state of the dispense event.
324     */
325    public SupplyDelivery setStatus(SupplyDeliveryStatus value) { 
326      if (value == null)
327        this.status = null;
328      else {
329        if (this.status == null)
330          this.status = new Enumeration<SupplyDeliveryStatus>(new SupplyDeliveryStatusEnumFactory());
331        this.status.setValue(value);
332      }
333      return this;
334    }
335
336    /**
337     * @return {@link #patient} (A link to a resource representing the person whom the delivered item is for.)
338     */
339    public Reference getPatient() { 
340      if (this.patient == null)
341        if (Configuration.errorOnAutoCreate())
342          throw new Error("Attempt to auto-create SupplyDelivery.patient");
343        else if (Configuration.doAutoCreate())
344          this.patient = new Reference(); // cc
345      return this.patient;
346    }
347
348    public boolean hasPatient() { 
349      return this.patient != null && !this.patient.isEmpty();
350    }
351
352    /**
353     * @param value {@link #patient} (A link to a resource representing the person whom the delivered item is for.)
354     */
355    public SupplyDelivery setPatient(Reference value) { 
356      this.patient = value;
357      return this;
358    }
359
360    /**
361     * @return {@link #patient} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (A link to a resource representing the person whom the delivered item is for.)
362     */
363    public Patient getPatientTarget() { 
364      if (this.patientTarget == null)
365        if (Configuration.errorOnAutoCreate())
366          throw new Error("Attempt to auto-create SupplyDelivery.patient");
367        else if (Configuration.doAutoCreate())
368          this.patientTarget = new Patient(); // aa
369      return this.patientTarget;
370    }
371
372    /**
373     * @param value {@link #patient} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (A link to a resource representing the person whom the delivered item is for.)
374     */
375    public SupplyDelivery setPatientTarget(Patient value) { 
376      this.patientTarget = value;
377      return this;
378    }
379
380    /**
381     * @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.)
382     */
383    public CodeableConcept getType() { 
384      if (this.type == null)
385        if (Configuration.errorOnAutoCreate())
386          throw new Error("Attempt to auto-create SupplyDelivery.type");
387        else if (Configuration.doAutoCreate())
388          this.type = new CodeableConcept(); // cc
389      return this.type;
390    }
391
392    public boolean hasType() { 
393      return this.type != null && !this.type.isEmpty();
394    }
395
396    /**
397     * @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.)
398     */
399    public SupplyDelivery setType(CodeableConcept value) { 
400      this.type = value;
401      return this;
402    }
403
404    /**
405     * @return {@link #quantity} (The amount of supply that has been dispensed. Includes unit of measure.)
406     */
407    public SimpleQuantity getQuantity() { 
408      if (this.quantity == null)
409        if (Configuration.errorOnAutoCreate())
410          throw new Error("Attempt to auto-create SupplyDelivery.quantity");
411        else if (Configuration.doAutoCreate())
412          this.quantity = new SimpleQuantity(); // cc
413      return this.quantity;
414    }
415
416    public boolean hasQuantity() { 
417      return this.quantity != null && !this.quantity.isEmpty();
418    }
419
420    /**
421     * @param value {@link #quantity} (The amount of supply that has been dispensed. Includes unit of measure.)
422     */
423    public SupplyDelivery setQuantity(SimpleQuantity value) { 
424      this.quantity = value;
425      return this;
426    }
427
428    /**
429     * @return {@link #suppliedItem} (Identifies the medication, substance or device being dispensed. This is either a link to a resource representing the details of the item or a simple attribute carrying a code that identifies the item from a known list.)
430     */
431    public Reference getSuppliedItem() { 
432      if (this.suppliedItem == null)
433        if (Configuration.errorOnAutoCreate())
434          throw new Error("Attempt to auto-create SupplyDelivery.suppliedItem");
435        else if (Configuration.doAutoCreate())
436          this.suppliedItem = new Reference(); // cc
437      return this.suppliedItem;
438    }
439
440    public boolean hasSuppliedItem() { 
441      return this.suppliedItem != null && !this.suppliedItem.isEmpty();
442    }
443
444    /**
445     * @param value {@link #suppliedItem} (Identifies the medication, substance or device being dispensed. This is either a link to a resource representing the details of the item or a simple attribute carrying a code that identifies the item from a known list.)
446     */
447    public SupplyDelivery setSuppliedItem(Reference value) { 
448      this.suppliedItem = value;
449      return this;
450    }
451
452    /**
453     * @return {@link #suppliedItem} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Identifies the medication, substance or device being dispensed. This is either a link to a resource representing the details of the item or a simple attribute carrying a code that identifies the item from a known list.)
454     */
455    public Resource getSuppliedItemTarget() { 
456      return this.suppliedItemTarget;
457    }
458
459    /**
460     * @param value {@link #suppliedItem} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Identifies the medication, substance or device being dispensed. This is either a link to a resource representing the details of the item or a simple attribute carrying a code that identifies the item from a known list.)
461     */
462    public SupplyDelivery setSuppliedItemTarget(Resource value) { 
463      this.suppliedItemTarget = value;
464      return this;
465    }
466
467    /**
468     * @return {@link #supplier} (The individual responsible for dispensing the medication, supplier or device.)
469     */
470    public Reference getSupplier() { 
471      if (this.supplier == null)
472        if (Configuration.errorOnAutoCreate())
473          throw new Error("Attempt to auto-create SupplyDelivery.supplier");
474        else if (Configuration.doAutoCreate())
475          this.supplier = new Reference(); // cc
476      return this.supplier;
477    }
478
479    public boolean hasSupplier() { 
480      return this.supplier != null && !this.supplier.isEmpty();
481    }
482
483    /**
484     * @param value {@link #supplier} (The individual responsible for dispensing the medication, supplier or device.)
485     */
486    public SupplyDelivery setSupplier(Reference value) { 
487      this.supplier = value;
488      return this;
489    }
490
491    /**
492     * @return {@link #supplier} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The individual responsible for dispensing the medication, supplier or device.)
493     */
494    public Practitioner getSupplierTarget() { 
495      if (this.supplierTarget == null)
496        if (Configuration.errorOnAutoCreate())
497          throw new Error("Attempt to auto-create SupplyDelivery.supplier");
498        else if (Configuration.doAutoCreate())
499          this.supplierTarget = new Practitioner(); // aa
500      return this.supplierTarget;
501    }
502
503    /**
504     * @param value {@link #supplier} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The individual responsible for dispensing the medication, supplier or device.)
505     */
506    public SupplyDelivery setSupplierTarget(Practitioner value) { 
507      this.supplierTarget = value;
508      return this;
509    }
510
511    /**
512     * @return {@link #whenPrepared} (The time the dispense event occurred.)
513     */
514    public Period getWhenPrepared() { 
515      if (this.whenPrepared == null)
516        if (Configuration.errorOnAutoCreate())
517          throw new Error("Attempt to auto-create SupplyDelivery.whenPrepared");
518        else if (Configuration.doAutoCreate())
519          this.whenPrepared = new Period(); // cc
520      return this.whenPrepared;
521    }
522
523    public boolean hasWhenPrepared() { 
524      return this.whenPrepared != null && !this.whenPrepared.isEmpty();
525    }
526
527    /**
528     * @param value {@link #whenPrepared} (The time the dispense event occurred.)
529     */
530    public SupplyDelivery setWhenPrepared(Period value) { 
531      this.whenPrepared = value;
532      return this;
533    }
534
535    /**
536     * @return {@link #time} (The time the dispensed item was sent or handed to the patient (or agent).). This is the underlying object with id, value and extensions. The accessor "getTime" gives direct access to the value
537     */
538    public DateTimeType getTimeElement() { 
539      if (this.time == null)
540        if (Configuration.errorOnAutoCreate())
541          throw new Error("Attempt to auto-create SupplyDelivery.time");
542        else if (Configuration.doAutoCreate())
543          this.time = new DateTimeType(); // bb
544      return this.time;
545    }
546
547    public boolean hasTimeElement() { 
548      return this.time != null && !this.time.isEmpty();
549    }
550
551    public boolean hasTime() { 
552      return this.time != null && !this.time.isEmpty();
553    }
554
555    /**
556     * @param value {@link #time} (The time the dispensed item was sent or handed to the patient (or agent).). This is the underlying object with id, value and extensions. The accessor "getTime" gives direct access to the value
557     */
558    public SupplyDelivery setTimeElement(DateTimeType value) { 
559      this.time = value;
560      return this;
561    }
562
563    /**
564     * @return The time the dispensed item was sent or handed to the patient (or agent).
565     */
566    public Date getTime() { 
567      return this.time == null ? null : this.time.getValue();
568    }
569
570    /**
571     * @param value The time the dispensed item was sent or handed to the patient (or agent).
572     */
573    public SupplyDelivery setTime(Date value) { 
574      if (value == null)
575        this.time = null;
576      else {
577        if (this.time == null)
578          this.time = new DateTimeType();
579        this.time.setValue(value);
580      }
581      return this;
582    }
583
584    /**
585     * @return {@link #destination} (Identification of the facility/location where the Supply was shipped to, as part of the dispense event.)
586     */
587    public Reference getDestination() { 
588      if (this.destination == null)
589        if (Configuration.errorOnAutoCreate())
590          throw new Error("Attempt to auto-create SupplyDelivery.destination");
591        else if (Configuration.doAutoCreate())
592          this.destination = new Reference(); // cc
593      return this.destination;
594    }
595
596    public boolean hasDestination() { 
597      return this.destination != null && !this.destination.isEmpty();
598    }
599
600    /**
601     * @param value {@link #destination} (Identification of the facility/location where the Supply was shipped to, as part of the dispense event.)
602     */
603    public SupplyDelivery setDestination(Reference value) { 
604      this.destination = value;
605      return this;
606    }
607
608    /**
609     * @return {@link #destination} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Identification of the facility/location where the Supply was shipped to, as part of the dispense event.)
610     */
611    public Location getDestinationTarget() { 
612      if (this.destinationTarget == null)
613        if (Configuration.errorOnAutoCreate())
614          throw new Error("Attempt to auto-create SupplyDelivery.destination");
615        else if (Configuration.doAutoCreate())
616          this.destinationTarget = new Location(); // aa
617      return this.destinationTarget;
618    }
619
620    /**
621     * @param value {@link #destination} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Identification of the facility/location where the Supply was shipped to, as part of the dispense event.)
622     */
623    public SupplyDelivery setDestinationTarget(Location value) { 
624      this.destinationTarget = value;
625      return this;
626    }
627
628    /**
629     * @return {@link #receiver} (Identifies the person who picked up the Supply.)
630     */
631    public List<Reference> getReceiver() { 
632      if (this.receiver == null)
633        this.receiver = new ArrayList<Reference>();
634      return this.receiver;
635    }
636
637    public boolean hasReceiver() { 
638      if (this.receiver == null)
639        return false;
640      for (Reference item : this.receiver)
641        if (!item.isEmpty())
642          return true;
643      return false;
644    }
645
646    /**
647     * @return {@link #receiver} (Identifies the person who picked up the Supply.)
648     */
649    // syntactic sugar
650    public Reference addReceiver() { //3
651      Reference t = new Reference();
652      if (this.receiver == null)
653        this.receiver = new ArrayList<Reference>();
654      this.receiver.add(t);
655      return t;
656    }
657
658    // syntactic sugar
659    public SupplyDelivery addReceiver(Reference t) { //3
660      if (t == null)
661        return this;
662      if (this.receiver == null)
663        this.receiver = new ArrayList<Reference>();
664      this.receiver.add(t);
665      return this;
666    }
667
668    /**
669     * @return {@link #receiver} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. Identifies the person who picked up the Supply.)
670     */
671    public List<Practitioner> getReceiverTarget() { 
672      if (this.receiverTarget == null)
673        this.receiverTarget = new ArrayList<Practitioner>();
674      return this.receiverTarget;
675    }
676
677    // syntactic sugar
678    /**
679     * @return {@link #receiver} (Add an actual object that is the target of the reference. The reference library doesn't use these, but you can use this to hold the resources if you resolvethemt. Identifies the person who picked up the Supply.)
680     */
681    public Practitioner addReceiverTarget() { 
682      Practitioner r = new Practitioner();
683      if (this.receiverTarget == null)
684        this.receiverTarget = new ArrayList<Practitioner>();
685      this.receiverTarget.add(r);
686      return r;
687    }
688
689      protected void listChildren(List<Property> childrenList) {
690        super.listChildren(childrenList);
691        childrenList.add(new Property("identifier", "Identifier", "Identifier assigned by the dispensing facility when the item(s) is dispensed.", 0, java.lang.Integer.MAX_VALUE, identifier));
692        childrenList.add(new Property("status", "code", "A code specifying the state of the dispense event.", 0, java.lang.Integer.MAX_VALUE, status));
693        childrenList.add(new Property("patient", "Reference(Patient)", "A link to a resource representing the person whom the delivered item is for.", 0, java.lang.Integer.MAX_VALUE, patient));
694        childrenList.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, java.lang.Integer.MAX_VALUE, type));
695        childrenList.add(new Property("quantity", "SimpleQuantity", "The amount of supply that has been dispensed. Includes unit of measure.", 0, java.lang.Integer.MAX_VALUE, quantity));
696        childrenList.add(new Property("suppliedItem", "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 simple attribute carrying a code that identifies the item from a known list.", 0, java.lang.Integer.MAX_VALUE, suppliedItem));
697        childrenList.add(new Property("supplier", "Reference(Practitioner)", "The individual responsible for dispensing the medication, supplier or device.", 0, java.lang.Integer.MAX_VALUE, supplier));
698        childrenList.add(new Property("whenPrepared", "Period", "The time the dispense event occurred.", 0, java.lang.Integer.MAX_VALUE, whenPrepared));
699        childrenList.add(new Property("time", "dateTime", "The time the dispensed item was sent or handed to the patient (or agent).", 0, java.lang.Integer.MAX_VALUE, time));
700        childrenList.add(new Property("destination", "Reference(Location)", "Identification of the facility/location where the Supply was shipped to, as part of the dispense event.", 0, java.lang.Integer.MAX_VALUE, destination));
701        childrenList.add(new Property("receiver", "Reference(Practitioner)", "Identifies the person who picked up the Supply.", 0, java.lang.Integer.MAX_VALUE, receiver));
702      }
703
704      @Override
705      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
706        switch (hash) {
707        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : new Base[] {this.identifier}; // Identifier
708        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<SupplyDeliveryStatus>
709        case -791418107: /*patient*/ return this.patient == null ? new Base[0] : new Base[] {this.patient}; // Reference
710        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
711        case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // SimpleQuantity
712        case 1993333233: /*suppliedItem*/ return this.suppliedItem == null ? new Base[0] : new Base[] {this.suppliedItem}; // Reference
713        case -1663305268: /*supplier*/ return this.supplier == null ? new Base[0] : new Base[] {this.supplier}; // Reference
714        case -562837097: /*whenPrepared*/ return this.whenPrepared == null ? new Base[0] : new Base[] {this.whenPrepared}; // Period
715        case 3560141: /*time*/ return this.time == null ? new Base[0] : new Base[] {this.time}; // DateTimeType
716        case -1429847026: /*destination*/ return this.destination == null ? new Base[0] : new Base[] {this.destination}; // Reference
717        case -808719889: /*receiver*/ return this.receiver == null ? new Base[0] : this.receiver.toArray(new Base[this.receiver.size()]); // Reference
718        default: return super.getProperty(hash, name, checkValid);
719        }
720
721      }
722
723      @Override
724      public void setProperty(int hash, String name, Base value) throws FHIRException {
725        switch (hash) {
726        case -1618432855: // identifier
727          this.identifier = castToIdentifier(value); // Identifier
728          break;
729        case -892481550: // status
730          this.status = new SupplyDeliveryStatusEnumFactory().fromType(value); // Enumeration<SupplyDeliveryStatus>
731          break;
732        case -791418107: // patient
733          this.patient = castToReference(value); // Reference
734          break;
735        case 3575610: // type
736          this.type = castToCodeableConcept(value); // CodeableConcept
737          break;
738        case -1285004149: // quantity
739          this.quantity = castToSimpleQuantity(value); // SimpleQuantity
740          break;
741        case 1993333233: // suppliedItem
742          this.suppliedItem = castToReference(value); // Reference
743          break;
744        case -1663305268: // supplier
745          this.supplier = castToReference(value); // Reference
746          break;
747        case -562837097: // whenPrepared
748          this.whenPrepared = castToPeriod(value); // Period
749          break;
750        case 3560141: // time
751          this.time = castToDateTime(value); // DateTimeType
752          break;
753        case -1429847026: // destination
754          this.destination = castToReference(value); // Reference
755          break;
756        case -808719889: // receiver
757          this.getReceiver().add(castToReference(value)); // Reference
758          break;
759        default: super.setProperty(hash, name, value);
760        }
761
762      }
763
764      @Override
765      public void setProperty(String name, Base value) throws FHIRException {
766        if (name.equals("identifier"))
767          this.identifier = castToIdentifier(value); // Identifier
768        else if (name.equals("status"))
769          this.status = new SupplyDeliveryStatusEnumFactory().fromType(value); // Enumeration<SupplyDeliveryStatus>
770        else if (name.equals("patient"))
771          this.patient = castToReference(value); // Reference
772        else if (name.equals("type"))
773          this.type = castToCodeableConcept(value); // CodeableConcept
774        else if (name.equals("quantity"))
775          this.quantity = castToSimpleQuantity(value); // SimpleQuantity
776        else if (name.equals("suppliedItem"))
777          this.suppliedItem = castToReference(value); // Reference
778        else if (name.equals("supplier"))
779          this.supplier = castToReference(value); // Reference
780        else if (name.equals("whenPrepared"))
781          this.whenPrepared = castToPeriod(value); // Period
782        else if (name.equals("time"))
783          this.time = castToDateTime(value); // DateTimeType
784        else if (name.equals("destination"))
785          this.destination = castToReference(value); // Reference
786        else if (name.equals("receiver"))
787          this.getReceiver().add(castToReference(value));
788        else
789          super.setProperty(name, value);
790      }
791
792      @Override
793      public Base makeProperty(int hash, String name) throws FHIRException {
794        switch (hash) {
795        case -1618432855:  return getIdentifier(); // Identifier
796        case -892481550: throw new FHIRException("Cannot make property status as it is not a complex type"); // Enumeration<SupplyDeliveryStatus>
797        case -791418107:  return getPatient(); // Reference
798        case 3575610:  return getType(); // CodeableConcept
799        case -1285004149:  return getQuantity(); // SimpleQuantity
800        case 1993333233:  return getSuppliedItem(); // Reference
801        case -1663305268:  return getSupplier(); // Reference
802        case -562837097:  return getWhenPrepared(); // Period
803        case 3560141: throw new FHIRException("Cannot make property time as it is not a complex type"); // DateTimeType
804        case -1429847026:  return getDestination(); // Reference
805        case -808719889:  return addReceiver(); // Reference
806        default: return super.makeProperty(hash, name);
807        }
808
809      }
810
811      @Override
812      public Base addChild(String name) throws FHIRException {
813        if (name.equals("identifier")) {
814          this.identifier = new Identifier();
815          return this.identifier;
816        }
817        else if (name.equals("status")) {
818          throw new FHIRException("Cannot call addChild on a primitive type SupplyDelivery.status");
819        }
820        else if (name.equals("patient")) {
821          this.patient = new Reference();
822          return this.patient;
823        }
824        else if (name.equals("type")) {
825          this.type = new CodeableConcept();
826          return this.type;
827        }
828        else if (name.equals("quantity")) {
829          this.quantity = new SimpleQuantity();
830          return this.quantity;
831        }
832        else if (name.equals("suppliedItem")) {
833          this.suppliedItem = new Reference();
834          return this.suppliedItem;
835        }
836        else if (name.equals("supplier")) {
837          this.supplier = new Reference();
838          return this.supplier;
839        }
840        else if (name.equals("whenPrepared")) {
841          this.whenPrepared = new Period();
842          return this.whenPrepared;
843        }
844        else if (name.equals("time")) {
845          throw new FHIRException("Cannot call addChild on a primitive type SupplyDelivery.time");
846        }
847        else if (name.equals("destination")) {
848          this.destination = new Reference();
849          return this.destination;
850        }
851        else if (name.equals("receiver")) {
852          return addReceiver();
853        }
854        else
855          return super.addChild(name);
856      }
857
858  public String fhirType() {
859    return "SupplyDelivery";
860
861  }
862
863      public SupplyDelivery copy() {
864        SupplyDelivery dst = new SupplyDelivery();
865        copyValues(dst);
866        dst.identifier = identifier == null ? null : identifier.copy();
867        dst.status = status == null ? null : status.copy();
868        dst.patient = patient == null ? null : patient.copy();
869        dst.type = type == null ? null : type.copy();
870        dst.quantity = quantity == null ? null : quantity.copy();
871        dst.suppliedItem = suppliedItem == null ? null : suppliedItem.copy();
872        dst.supplier = supplier == null ? null : supplier.copy();
873        dst.whenPrepared = whenPrepared == null ? null : whenPrepared.copy();
874        dst.time = time == null ? null : time.copy();
875        dst.destination = destination == null ? null : destination.copy();
876        if (receiver != null) {
877          dst.receiver = new ArrayList<Reference>();
878          for (Reference i : receiver)
879            dst.receiver.add(i.copy());
880        };
881        return dst;
882      }
883
884      protected SupplyDelivery typedCopy() {
885        return copy();
886      }
887
888      @Override
889      public boolean equalsDeep(Base other) {
890        if (!super.equalsDeep(other))
891          return false;
892        if (!(other instanceof SupplyDelivery))
893          return false;
894        SupplyDelivery o = (SupplyDelivery) other;
895        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(patient, o.patient, true)
896           && compareDeep(type, o.type, true) && compareDeep(quantity, o.quantity, true) && compareDeep(suppliedItem, o.suppliedItem, true)
897           && compareDeep(supplier, o.supplier, true) && compareDeep(whenPrepared, o.whenPrepared, true) && compareDeep(time, o.time, true)
898           && compareDeep(destination, o.destination, true) && compareDeep(receiver, o.receiver, true);
899      }
900
901      @Override
902      public boolean equalsShallow(Base other) {
903        if (!super.equalsShallow(other))
904          return false;
905        if (!(other instanceof SupplyDelivery))
906          return false;
907        SupplyDelivery o = (SupplyDelivery) other;
908        return compareValues(status, o.status, true) && compareValues(time, o.time, true);
909      }
910
911      public boolean isEmpty() {
912        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (status == null || status.isEmpty())
913           && (patient == null || patient.isEmpty()) && (type == null || type.isEmpty()) && (quantity == null || quantity.isEmpty())
914           && (suppliedItem == null || suppliedItem.isEmpty()) && (supplier == null || supplier.isEmpty())
915           && (whenPrepared == null || whenPrepared.isEmpty()) && (time == null || time.isEmpty()) && (destination == null || destination.isEmpty())
916           && (receiver == null || receiver.isEmpty());
917      }
918
919  @Override
920  public ResourceType getResourceType() {
921    return ResourceType.SupplyDelivery;
922   }
923
924 /**
925   * Search parameter: <b>patient</b>
926   * <p>
927   * Description: <b>Patient for whom the item is supplied</b><br>
928   * Type: <b>reference</b><br>
929   * Path: <b>SupplyDelivery.patient</b><br>
930   * </p>
931   */
932  @SearchParamDefinition(name="patient", path="SupplyDelivery.patient", description="Patient for whom the item is supplied", type="reference" )
933  public static final String SP_PATIENT = "patient";
934 /**
935   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
936   * <p>
937   * Description: <b>Patient for whom the item is supplied</b><br>
938   * Type: <b>reference</b><br>
939   * Path: <b>SupplyDelivery.patient</b><br>
940   * </p>
941   */
942  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
943
944/**
945   * Constant for fluent queries to be used to add include statements. Specifies
946   * the path value of "<b>SupplyDelivery:patient</b>".
947   */
948  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("SupplyDelivery:patient").toLocked();
949
950 /**
951   * Search parameter: <b>receiver</b>
952   * <p>
953   * Description: <b>Who collected the Supply</b><br>
954   * Type: <b>reference</b><br>
955   * Path: <b>SupplyDelivery.receiver</b><br>
956   * </p>
957   */
958  @SearchParamDefinition(name="receiver", path="SupplyDelivery.receiver", description="Who collected the Supply", type="reference" )
959  public static final String SP_RECEIVER = "receiver";
960 /**
961   * <b>Fluent Client</b> search parameter constant for <b>receiver</b>
962   * <p>
963   * Description: <b>Who collected the Supply</b><br>
964   * Type: <b>reference</b><br>
965   * Path: <b>SupplyDelivery.receiver</b><br>
966   * </p>
967   */
968  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam RECEIVER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_RECEIVER);
969
970/**
971   * Constant for fluent queries to be used to add include statements. Specifies
972   * the path value of "<b>SupplyDelivery:receiver</b>".
973   */
974  public static final ca.uhn.fhir.model.api.Include INCLUDE_RECEIVER = new ca.uhn.fhir.model.api.Include("SupplyDelivery:receiver").toLocked();
975
976 /**
977   * Search parameter: <b>status</b>
978   * <p>
979   * Description: <b>in-progress | completed | abandoned</b><br>
980   * Type: <b>token</b><br>
981   * Path: <b>SupplyDelivery.status</b><br>
982   * </p>
983   */
984  @SearchParamDefinition(name="status", path="SupplyDelivery.status", description="in-progress | completed | abandoned", type="token" )
985  public static final String SP_STATUS = "status";
986 /**
987   * <b>Fluent Client</b> search parameter constant for <b>status</b>
988   * <p>
989   * Description: <b>in-progress | completed | abandoned</b><br>
990   * Type: <b>token</b><br>
991   * Path: <b>SupplyDelivery.status</b><br>
992   * </p>
993   */
994  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
995
996 /**
997   * Search parameter: <b>identifier</b>
998   * <p>
999   * Description: <b>External identifier</b><br>
1000   * Type: <b>token</b><br>
1001   * Path: <b>SupplyDelivery.identifier</b><br>
1002   * </p>
1003   */
1004  @SearchParamDefinition(name="identifier", path="SupplyDelivery.identifier", description="External identifier", type="token" )
1005  public static final String SP_IDENTIFIER = "identifier";
1006 /**
1007   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
1008   * <p>
1009   * Description: <b>External identifier</b><br>
1010   * Type: <b>token</b><br>
1011   * Path: <b>SupplyDelivery.identifier</b><br>
1012   * </p>
1013   */
1014  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
1015
1016 /**
1017   * Search parameter: <b>supplier</b>
1018   * <p>
1019   * Description: <b>Dispenser</b><br>
1020   * Type: <b>reference</b><br>
1021   * Path: <b>SupplyDelivery.supplier</b><br>
1022   * </p>
1023   */
1024  @SearchParamDefinition(name="supplier", path="SupplyDelivery.supplier", description="Dispenser", type="reference" )
1025  public static final String SP_SUPPLIER = "supplier";
1026 /**
1027   * <b>Fluent Client</b> search parameter constant for <b>supplier</b>
1028   * <p>
1029   * Description: <b>Dispenser</b><br>
1030   * Type: <b>reference</b><br>
1031   * Path: <b>SupplyDelivery.supplier</b><br>
1032   * </p>
1033   */
1034  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUPPLIER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUPPLIER);
1035
1036/**
1037   * Constant for fluent queries to be used to add include statements. Specifies
1038   * the path value of "<b>SupplyDelivery:supplier</b>".
1039   */
1040  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUPPLIER = new ca.uhn.fhir.model.api.Include("SupplyDelivery:supplier").toLocked();
1041
1042
1043}
1044