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.Date;
035import java.util.List;
036
037import org.hl7.fhir.exceptions.FHIRException;
038import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
039
040import ca.uhn.fhir.model.api.annotation.Block;
041import ca.uhn.fhir.model.api.annotation.Child;
042import ca.uhn.fhir.model.api.annotation.Description;
043import ca.uhn.fhir.model.api.annotation.ResourceDef;
044import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
045
046/**
047 * Indicates that a medication product is to be or has been dispensed for a
048 * named person/patient. This includes a description of the medication product
049 * (supply) provided and the instructions for administering the medication. The
050 * medication dispense is the result of a pharmacy system responding to a
051 * medication order.
052 */
053@ResourceDef(name = "MedicationDispense", profile = "http://hl7.org/fhir/StructureDefinition/MedicationDispense")
054public class MedicationDispense extends DomainResource {
055
056  public enum MedicationDispenseStatus {
057    /**
058     * The core event has not started yet, but some staging activities have begun
059     * (e.g. initial compounding or packaging of medication). Preparation stages may
060     * be tracked for billing purposes.
061     */
062    PREPARATION,
063    /**
064     * The dispensed product is ready for pickup.
065     */
066    INPROGRESS,
067    /**
068     * The dispensed product was not and will never be picked up by the patient.
069     */
070    CANCELLED,
071    /**
072     * The dispense process is paused while waiting for an external event to
073     * reactivate the dispense. For example, new stock has arrived or the prescriber
074     * has called.
075     */
076    ONHOLD,
077    /**
078     * The dispensed product has been picked up.
079     */
080    COMPLETED,
081    /**
082     * The dispense was entered in error and therefore nullified.
083     */
084    ENTEREDINERROR,
085    /**
086     * Actions implied by the dispense have been permanently halted, before all of
087     * them occurred.
088     */
089    STOPPED,
090    /**
091     * The dispense was declined and not performed.
092     */
093    DECLINED,
094    /**
095     * The authoring system does not know which of the status values applies for
096     * this medication dispense. Note: this concept is not to be used for other -
097     * one of the listed statuses is presumed to apply, it's just now known which
098     * one.
099     */
100    UNKNOWN,
101    /**
102     * added to help the parsers with the generic types
103     */
104    NULL;
105
106    public static MedicationDispenseStatus fromCode(String codeString) throws FHIRException {
107      if (codeString == null || "".equals(codeString))
108        return null;
109      if ("preparation".equals(codeString))
110        return PREPARATION;
111      if ("in-progress".equals(codeString))
112        return INPROGRESS;
113      if ("cancelled".equals(codeString))
114        return CANCELLED;
115      if ("on-hold".equals(codeString))
116        return ONHOLD;
117      if ("completed".equals(codeString))
118        return COMPLETED;
119      if ("entered-in-error".equals(codeString))
120        return ENTEREDINERROR;
121      if ("stopped".equals(codeString))
122        return STOPPED;
123      if ("declined".equals(codeString))
124        return DECLINED;
125      if ("unknown".equals(codeString))
126        return UNKNOWN;
127      if (Configuration.isAcceptInvalidEnums())
128        return null;
129      else
130        throw new FHIRException("Unknown MedicationDispenseStatus code '" + codeString + "'");
131    }
132
133    public String toCode() {
134      switch (this) {
135      case PREPARATION:
136        return "preparation";
137      case INPROGRESS:
138        return "in-progress";
139      case CANCELLED:
140        return "cancelled";
141      case ONHOLD:
142        return "on-hold";
143      case COMPLETED:
144        return "completed";
145      case ENTEREDINERROR:
146        return "entered-in-error";
147      case STOPPED:
148        return "stopped";
149      case DECLINED:
150        return "declined";
151      case UNKNOWN:
152        return "unknown";
153      case NULL:
154        return null;
155      default:
156        return "?";
157      }
158    }
159
160    public String getSystem() {
161      switch (this) {
162      case PREPARATION:
163        return "http://terminology.hl7.org/CodeSystem/medicationdispense-status";
164      case INPROGRESS:
165        return "http://terminology.hl7.org/CodeSystem/medicationdispense-status";
166      case CANCELLED:
167        return "http://terminology.hl7.org/CodeSystem/medicationdispense-status";
168      case ONHOLD:
169        return "http://terminology.hl7.org/CodeSystem/medicationdispense-status";
170      case COMPLETED:
171        return "http://terminology.hl7.org/CodeSystem/medicationdispense-status";
172      case ENTEREDINERROR:
173        return "http://terminology.hl7.org/CodeSystem/medicationdispense-status";
174      case STOPPED:
175        return "http://terminology.hl7.org/CodeSystem/medicationdispense-status";
176      case DECLINED:
177        return "http://terminology.hl7.org/CodeSystem/medicationdispense-status";
178      case UNKNOWN:
179        return "http://terminology.hl7.org/CodeSystem/medicationdispense-status";
180      case NULL:
181        return null;
182      default:
183        return "?";
184      }
185    }
186
187    public String getDefinition() {
188      switch (this) {
189      case PREPARATION:
190        return "The core event has not started yet, but some staging activities have begun (e.g. initial compounding or packaging of medication). Preparation stages may be tracked for billing purposes.";
191      case INPROGRESS:
192        return "The dispensed product is ready for pickup.";
193      case CANCELLED:
194        return "The dispensed product was not and will never be picked up by the patient.";
195      case ONHOLD:
196        return "The dispense process is paused while waiting for an external event to reactivate the dispense.  For example, new stock has arrived or the prescriber has called.";
197      case COMPLETED:
198        return "The dispensed product has been picked up.";
199      case ENTEREDINERROR:
200        return "The dispense was entered in error and therefore nullified.";
201      case STOPPED:
202        return "Actions implied by the dispense have been permanently halted, before all of them occurred.";
203      case DECLINED:
204        return "The dispense was declined and not performed.";
205      case UNKNOWN:
206        return "The authoring system does not know which of the status values applies for this medication dispense.  Note: this concept is not to be used for other - one of the listed statuses is presumed to apply, it's just now known which one.";
207      case NULL:
208        return null;
209      default:
210        return "?";
211      }
212    }
213
214    public String getDisplay() {
215      switch (this) {
216      case PREPARATION:
217        return "Preparation";
218      case INPROGRESS:
219        return "In Progress";
220      case CANCELLED:
221        return "Cancelled";
222      case ONHOLD:
223        return "On Hold";
224      case COMPLETED:
225        return "Completed";
226      case ENTEREDINERROR:
227        return "Entered in Error";
228      case STOPPED:
229        return "Stopped";
230      case DECLINED:
231        return "Declined";
232      case UNKNOWN:
233        return "Unknown";
234      case NULL:
235        return null;
236      default:
237        return "?";
238      }
239    }
240  }
241
242  public static class MedicationDispenseStatusEnumFactory implements EnumFactory<MedicationDispenseStatus> {
243    public MedicationDispenseStatus fromCode(String codeString) throws IllegalArgumentException {
244      if (codeString == null || "".equals(codeString))
245        if (codeString == null || "".equals(codeString))
246          return null;
247      if ("preparation".equals(codeString))
248        return MedicationDispenseStatus.PREPARATION;
249      if ("in-progress".equals(codeString))
250        return MedicationDispenseStatus.INPROGRESS;
251      if ("cancelled".equals(codeString))
252        return MedicationDispenseStatus.CANCELLED;
253      if ("on-hold".equals(codeString))
254        return MedicationDispenseStatus.ONHOLD;
255      if ("completed".equals(codeString))
256        return MedicationDispenseStatus.COMPLETED;
257      if ("entered-in-error".equals(codeString))
258        return MedicationDispenseStatus.ENTEREDINERROR;
259      if ("stopped".equals(codeString))
260        return MedicationDispenseStatus.STOPPED;
261      if ("declined".equals(codeString))
262        return MedicationDispenseStatus.DECLINED;
263      if ("unknown".equals(codeString))
264        return MedicationDispenseStatus.UNKNOWN;
265      throw new IllegalArgumentException("Unknown MedicationDispenseStatus code '" + codeString + "'");
266    }
267
268    public Enumeration<MedicationDispenseStatus> fromType(PrimitiveType<?> code) throws FHIRException {
269      if (code == null)
270        return null;
271      if (code.isEmpty())
272        return new Enumeration<MedicationDispenseStatus>(this, MedicationDispenseStatus.NULL, code);
273      String codeString = code.asStringValue();
274      if (codeString == null || "".equals(codeString))
275        return new Enumeration<MedicationDispenseStatus>(this, MedicationDispenseStatus.NULL, code);
276      if ("preparation".equals(codeString))
277        return new Enumeration<MedicationDispenseStatus>(this, MedicationDispenseStatus.PREPARATION, code);
278      if ("in-progress".equals(codeString))
279        return new Enumeration<MedicationDispenseStatus>(this, MedicationDispenseStatus.INPROGRESS, code);
280      if ("cancelled".equals(codeString))
281        return new Enumeration<MedicationDispenseStatus>(this, MedicationDispenseStatus.CANCELLED, code);
282      if ("on-hold".equals(codeString))
283        return new Enumeration<MedicationDispenseStatus>(this, MedicationDispenseStatus.ONHOLD, code);
284      if ("completed".equals(codeString))
285        return new Enumeration<MedicationDispenseStatus>(this, MedicationDispenseStatus.COMPLETED, code);
286      if ("entered-in-error".equals(codeString))
287        return new Enumeration<MedicationDispenseStatus>(this, MedicationDispenseStatus.ENTEREDINERROR, code);
288      if ("stopped".equals(codeString))
289        return new Enumeration<MedicationDispenseStatus>(this, MedicationDispenseStatus.STOPPED, code);
290      if ("declined".equals(codeString))
291        return new Enumeration<MedicationDispenseStatus>(this, MedicationDispenseStatus.DECLINED, code);
292      if ("unknown".equals(codeString))
293        return new Enumeration<MedicationDispenseStatus>(this, MedicationDispenseStatus.UNKNOWN, code);
294      throw new FHIRException("Unknown MedicationDispenseStatus code '" + codeString + "'");
295    }
296
297    public String toCode(MedicationDispenseStatus code) {
298       if (code == MedicationDispenseStatus.NULL)
299           return null;
300       if (code == MedicationDispenseStatus.PREPARATION)
301        return "preparation";
302      if (code == MedicationDispenseStatus.INPROGRESS)
303        return "in-progress";
304      if (code == MedicationDispenseStatus.CANCELLED)
305        return "cancelled";
306      if (code == MedicationDispenseStatus.ONHOLD)
307        return "on-hold";
308      if (code == MedicationDispenseStatus.COMPLETED)
309        return "completed";
310      if (code == MedicationDispenseStatus.ENTEREDINERROR)
311        return "entered-in-error";
312      if (code == MedicationDispenseStatus.STOPPED)
313        return "stopped";
314      if (code == MedicationDispenseStatus.DECLINED)
315        return "declined";
316      if (code == MedicationDispenseStatus.UNKNOWN)
317        return "unknown";
318      return "?";
319   }
320
321    public String toSystem(MedicationDispenseStatus code) {
322      return code.getSystem();
323    }
324  }
325
326  @Block()
327  public static class MedicationDispensePerformerComponent extends BackboneElement implements IBaseBackboneElement {
328    /**
329     * Distinguishes the type of performer in the dispense. For example, date
330     * enterer, packager, final checker.
331     */
332    @Child(name = "function", type = {
333        CodeableConcept.class }, order = 1, min = 0, max = 1, modifier = false, summary = false)
334    @Description(shortDefinition = "Who performed the dispense and what they did", formalDefinition = "Distinguishes the type of performer in the dispense.  For example, date enterer, packager, final checker.")
335    @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/medicationdispense-performer-function")
336    protected CodeableConcept function;
337
338    /**
339     * The device, practitioner, etc. who performed the action. It should be assumed
340     * that the actor is the dispenser of the medication.
341     */
342    @Child(name = "actor", type = { Practitioner.class, PractitionerRole.class, Organization.class, Patient.class,
343        Device.class, RelatedPerson.class }, order = 2, min = 1, max = 1, modifier = false, summary = false)
344    @Description(shortDefinition = "Individual who was performing", formalDefinition = "The device, practitioner, etc. who performed the action.  It should be assumed that the actor is the dispenser of the medication.")
345    protected Reference actor;
346
347    /**
348     * The actual object that is the target of the reference (The device,
349     * practitioner, etc. who performed the action. It should be assumed that the
350     * actor is the dispenser of the medication.)
351     */
352    protected Resource actorTarget;
353
354    private static final long serialVersionUID = 1424001049L;
355
356    /**
357     * Constructor
358     */
359    public MedicationDispensePerformerComponent() {
360      super();
361    }
362
363    /**
364     * Constructor
365     */
366    public MedicationDispensePerformerComponent(Reference actor) {
367      super();
368      this.actor = actor;
369    }
370
371    /**
372     * @return {@link #function} (Distinguishes the type of performer in the
373     *         dispense. For example, date enterer, packager, final checker.)
374     */
375    public CodeableConcept getFunction() {
376      if (this.function == null)
377        if (Configuration.errorOnAutoCreate())
378          throw new Error("Attempt to auto-create MedicationDispensePerformerComponent.function");
379        else if (Configuration.doAutoCreate())
380          this.function = new CodeableConcept(); // cc
381      return this.function;
382    }
383
384    public boolean hasFunction() {
385      return this.function != null && !this.function.isEmpty();
386    }
387
388    /**
389     * @param value {@link #function} (Distinguishes the type of performer in the
390     *              dispense. For example, date enterer, packager, final checker.)
391     */
392    public MedicationDispensePerformerComponent setFunction(CodeableConcept value) {
393      this.function = value;
394      return this;
395    }
396
397    /**
398     * @return {@link #actor} (The device, practitioner, etc. who performed the
399     *         action. It should be assumed that the actor is the dispenser of the
400     *         medication.)
401     */
402    public Reference getActor() {
403      if (this.actor == null)
404        if (Configuration.errorOnAutoCreate())
405          throw new Error("Attempt to auto-create MedicationDispensePerformerComponent.actor");
406        else if (Configuration.doAutoCreate())
407          this.actor = new Reference(); // cc
408      return this.actor;
409    }
410
411    public boolean hasActor() {
412      return this.actor != null && !this.actor.isEmpty();
413    }
414
415    /**
416     * @param value {@link #actor} (The device, practitioner, etc. who performed the
417     *              action. It should be assumed that the actor is the dispenser of
418     *              the medication.)
419     */
420    public MedicationDispensePerformerComponent setActor(Reference value) {
421      this.actor = value;
422      return this;
423    }
424
425    /**
426     * @return {@link #actor} The actual object that is the target of the reference.
427     *         The reference library doesn't populate this, but you can use it to
428     *         hold the resource if you resolve it. (The device, practitioner, etc.
429     *         who performed the action. It should be assumed that the actor is the
430     *         dispenser of the medication.)
431     */
432    public Resource getActorTarget() {
433      return this.actorTarget;
434    }
435
436    /**
437     * @param value {@link #actor} The actual object that is the target of the
438     *              reference. The reference library doesn't use these, but you can
439     *              use it to hold the resource if you resolve it. (The device,
440     *              practitioner, etc. who performed the action. It should be
441     *              assumed that the actor is the dispenser of the medication.)
442     */
443    public MedicationDispensePerformerComponent setActorTarget(Resource value) {
444      this.actorTarget = value;
445      return this;
446    }
447
448    protected void listChildren(List<Property> children) {
449      super.listChildren(children);
450      children.add(new Property("function", "CodeableConcept",
451          "Distinguishes the type of performer in the dispense.  For example, date enterer, packager, final checker.",
452          0, 1, function));
453      children.add(new Property("actor",
454          "Reference(Practitioner|PractitionerRole|Organization|Patient|Device|RelatedPerson)",
455          "The device, practitioner, etc. who performed the action.  It should be assumed that the actor is the dispenser of the medication.",
456          0, 1, actor));
457    }
458
459    @Override
460    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
461      switch (_hash) {
462      case 1380938712:
463        /* function */ return new Property("function", "CodeableConcept",
464            "Distinguishes the type of performer in the dispense.  For example, date enterer, packager, final checker.",
465            0, 1, function);
466      case 92645877:
467        /* actor */ return new Property("actor",
468            "Reference(Practitioner|PractitionerRole|Organization|Patient|Device|RelatedPerson)",
469            "The device, practitioner, etc. who performed the action.  It should be assumed that the actor is the dispenser of the medication.",
470            0, 1, actor);
471      default:
472        return super.getNamedProperty(_hash, _name, _checkValid);
473      }
474
475    }
476
477    @Override
478    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
479      switch (hash) {
480      case 1380938712:
481        /* function */ return this.function == null ? new Base[0] : new Base[] { this.function }; // CodeableConcept
482      case 92645877:
483        /* actor */ return this.actor == null ? new Base[0] : new Base[] { this.actor }; // Reference
484      default:
485        return super.getProperty(hash, name, checkValid);
486      }
487
488    }
489
490    @Override
491    public Base setProperty(int hash, String name, Base value) throws FHIRException {
492      switch (hash) {
493      case 1380938712: // function
494        this.function = castToCodeableConcept(value); // CodeableConcept
495        return value;
496      case 92645877: // actor
497        this.actor = castToReference(value); // Reference
498        return value;
499      default:
500        return super.setProperty(hash, name, value);
501      }
502
503    }
504
505    @Override
506    public Base setProperty(String name, Base value) throws FHIRException {
507      if (name.equals("function")) {
508        this.function = castToCodeableConcept(value); // CodeableConcept
509      } else if (name.equals("actor")) {
510        this.actor = castToReference(value); // Reference
511      } else
512        return super.setProperty(name, value);
513      return value;
514    }
515
516  @Override
517  public void removeChild(String name, Base value) throws FHIRException {
518      if (name.equals("function")) {
519        this.function = null;
520      } else if (name.equals("actor")) {
521        this.actor = null;
522      } else
523        super.removeChild(name, value);
524      
525    }
526
527    @Override
528    public Base makeProperty(int hash, String name) throws FHIRException {
529      switch (hash) {
530      case 1380938712:
531        return getFunction();
532      case 92645877:
533        return getActor();
534      default:
535        return super.makeProperty(hash, name);
536      }
537
538    }
539
540    @Override
541    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
542      switch (hash) {
543      case 1380938712:
544        /* function */ return new String[] { "CodeableConcept" };
545      case 92645877:
546        /* actor */ return new String[] { "Reference" };
547      default:
548        return super.getTypesForProperty(hash, name);
549      }
550
551    }
552
553    @Override
554    public Base addChild(String name) throws FHIRException {
555      if (name.equals("function")) {
556        this.function = new CodeableConcept();
557        return this.function;
558      } else if (name.equals("actor")) {
559        this.actor = new Reference();
560        return this.actor;
561      } else
562        return super.addChild(name);
563    }
564
565    public MedicationDispensePerformerComponent copy() {
566      MedicationDispensePerformerComponent dst = new MedicationDispensePerformerComponent();
567      copyValues(dst);
568      return dst;
569    }
570
571    public void copyValues(MedicationDispensePerformerComponent dst) {
572      super.copyValues(dst);
573      dst.function = function == null ? null : function.copy();
574      dst.actor = actor == null ? null : actor.copy();
575    }
576
577    @Override
578    public boolean equalsDeep(Base other_) {
579      if (!super.equalsDeep(other_))
580        return false;
581      if (!(other_ instanceof MedicationDispensePerformerComponent))
582        return false;
583      MedicationDispensePerformerComponent o = (MedicationDispensePerformerComponent) other_;
584      return compareDeep(function, o.function, true) && compareDeep(actor, o.actor, true);
585    }
586
587    @Override
588    public boolean equalsShallow(Base other_) {
589      if (!super.equalsShallow(other_))
590        return false;
591      if (!(other_ instanceof MedicationDispensePerformerComponent))
592        return false;
593      MedicationDispensePerformerComponent o = (MedicationDispensePerformerComponent) other_;
594      return true;
595    }
596
597    public boolean isEmpty() {
598      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(function, actor);
599    }
600
601    public String fhirType() {
602      return "MedicationDispense.performer";
603
604    }
605
606  }
607
608  @Block()
609  public static class MedicationDispenseSubstitutionComponent extends BackboneElement implements IBaseBackboneElement {
610    /**
611     * True if the dispenser dispensed a different drug or product from what was
612     * prescribed.
613     */
614    @Child(name = "wasSubstituted", type = {
615        BooleanType.class }, order = 1, min = 1, max = 1, modifier = false, summary = false)
616    @Description(shortDefinition = "Whether a substitution was or was not performed on the dispense", formalDefinition = "True if the dispenser dispensed a different drug or product from what was prescribed.")
617    protected BooleanType wasSubstituted;
618
619    /**
620     * A code signifying whether a different drug was dispensed from what was
621     * prescribed.
622     */
623    @Child(name = "type", type = {
624        CodeableConcept.class }, order = 2, min = 0, max = 1, modifier = false, summary = false)
625    @Description(shortDefinition = "Code signifying whether a different drug was dispensed from what was prescribed", formalDefinition = "A code signifying whether a different drug was dispensed from what was prescribed.")
626    @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://terminology.hl7.org/ValueSet/v3-ActSubstanceAdminSubstitutionCode")
627    protected CodeableConcept type;
628
629    /**
630     * Indicates the reason for the substitution (or lack of substitution) from what
631     * was prescribed.
632     */
633    @Child(name = "reason", type = {
634        CodeableConcept.class }, order = 3, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
635    @Description(shortDefinition = "Why was substitution made", formalDefinition = "Indicates the reason for the substitution (or lack of substitution) from what was prescribed.")
636    @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://terminology.hl7.org/ValueSet/v3-SubstanceAdminSubstitutionReason")
637    protected List<CodeableConcept> reason;
638
639    /**
640     * The person or organization that has primary responsibility for the
641     * substitution.
642     */
643    @Child(name = "responsibleParty", type = { Practitioner.class,
644        PractitionerRole.class }, order = 4, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
645    @Description(shortDefinition = "Who is responsible for the substitution", formalDefinition = "The person or organization that has primary responsibility for the substitution.")
646    protected List<Reference> responsibleParty;
647    /**
648     * The actual objects that are the target of the reference (The person or
649     * organization that has primary responsibility for the substitution.)
650     */
651    protected List<Resource> responsiblePartyTarget;
652
653    private static final long serialVersionUID = 357914571L;
654
655    /**
656     * Constructor
657     */
658    public MedicationDispenseSubstitutionComponent() {
659      super();
660    }
661
662    /**
663     * Constructor
664     */
665    public MedicationDispenseSubstitutionComponent(BooleanType wasSubstituted) {
666      super();
667      this.wasSubstituted = wasSubstituted;
668    }
669
670    /**
671     * @return {@link #wasSubstituted} (True if the dispenser dispensed a different
672     *         drug or product from what was prescribed.). This is the underlying
673     *         object with id, value and extensions. The accessor
674     *         "getWasSubstituted" gives direct access to the value
675     */
676    public BooleanType getWasSubstitutedElement() {
677      if (this.wasSubstituted == null)
678        if (Configuration.errorOnAutoCreate())
679          throw new Error("Attempt to auto-create MedicationDispenseSubstitutionComponent.wasSubstituted");
680        else if (Configuration.doAutoCreate())
681          this.wasSubstituted = new BooleanType(); // bb
682      return this.wasSubstituted;
683    }
684
685    public boolean hasWasSubstitutedElement() {
686      return this.wasSubstituted != null && !this.wasSubstituted.isEmpty();
687    }
688
689    public boolean hasWasSubstituted() {
690      return this.wasSubstituted != null && !this.wasSubstituted.isEmpty();
691    }
692
693    /**
694     * @param value {@link #wasSubstituted} (True if the dispenser dispensed a
695     *              different drug or product from what was prescribed.). This is
696     *              the underlying object with id, value and extensions. The
697     *              accessor "getWasSubstituted" gives direct access to the value
698     */
699    public MedicationDispenseSubstitutionComponent setWasSubstitutedElement(BooleanType value) {
700      this.wasSubstituted = value;
701      return this;
702    }
703
704    /**
705     * @return True if the dispenser dispensed a different drug or product from what
706     *         was prescribed.
707     */
708    public boolean getWasSubstituted() {
709      return this.wasSubstituted == null || this.wasSubstituted.isEmpty() ? false : this.wasSubstituted.getValue();
710    }
711
712    /**
713     * @param value True if the dispenser dispensed a different drug or product from
714     *              what was prescribed.
715     */
716    public MedicationDispenseSubstitutionComponent setWasSubstituted(boolean value) {
717      if (this.wasSubstituted == null)
718        this.wasSubstituted = new BooleanType();
719      this.wasSubstituted.setValue(value);
720      return this;
721    }
722
723    /**
724     * @return {@link #type} (A code signifying whether a different drug was
725     *         dispensed from what was prescribed.)
726     */
727    public CodeableConcept getType() {
728      if (this.type == null)
729        if (Configuration.errorOnAutoCreate())
730          throw new Error("Attempt to auto-create MedicationDispenseSubstitutionComponent.type");
731        else if (Configuration.doAutoCreate())
732          this.type = new CodeableConcept(); // cc
733      return this.type;
734    }
735
736    public boolean hasType() {
737      return this.type != null && !this.type.isEmpty();
738    }
739
740    /**
741     * @param value {@link #type} (A code signifying whether a different drug was
742     *              dispensed from what was prescribed.)
743     */
744    public MedicationDispenseSubstitutionComponent setType(CodeableConcept value) {
745      this.type = value;
746      return this;
747    }
748
749    /**
750     * @return {@link #reason} (Indicates the reason for the substitution (or lack
751     *         of substitution) from what was prescribed.)
752     */
753    public List<CodeableConcept> getReason() {
754      if (this.reason == null)
755        this.reason = new ArrayList<CodeableConcept>();
756      return this.reason;
757    }
758
759    /**
760     * @return Returns a reference to <code>this</code> for easy method chaining
761     */
762    public MedicationDispenseSubstitutionComponent setReason(List<CodeableConcept> theReason) {
763      this.reason = theReason;
764      return this;
765    }
766
767    public boolean hasReason() {
768      if (this.reason == null)
769        return false;
770      for (CodeableConcept item : this.reason)
771        if (!item.isEmpty())
772          return true;
773      return false;
774    }
775
776    public CodeableConcept addReason() { // 3
777      CodeableConcept t = new CodeableConcept();
778      if (this.reason == null)
779        this.reason = new ArrayList<CodeableConcept>();
780      this.reason.add(t);
781      return t;
782    }
783
784    public MedicationDispenseSubstitutionComponent addReason(CodeableConcept t) { // 3
785      if (t == null)
786        return this;
787      if (this.reason == null)
788        this.reason = new ArrayList<CodeableConcept>();
789      this.reason.add(t);
790      return this;
791    }
792
793    /**
794     * @return The first repetition of repeating field {@link #reason}, creating it
795     *         if it does not already exist
796     */
797    public CodeableConcept getReasonFirstRep() {
798      if (getReason().isEmpty()) {
799        addReason();
800      }
801      return getReason().get(0);
802    }
803
804    /**
805     * @return {@link #responsibleParty} (The person or organization that has
806     *         primary responsibility for the substitution.)
807     */
808    public List<Reference> getResponsibleParty() {
809      if (this.responsibleParty == null)
810        this.responsibleParty = new ArrayList<Reference>();
811      return this.responsibleParty;
812    }
813
814    /**
815     * @return Returns a reference to <code>this</code> for easy method chaining
816     */
817    public MedicationDispenseSubstitutionComponent setResponsibleParty(List<Reference> theResponsibleParty) {
818      this.responsibleParty = theResponsibleParty;
819      return this;
820    }
821
822    public boolean hasResponsibleParty() {
823      if (this.responsibleParty == null)
824        return false;
825      for (Reference item : this.responsibleParty)
826        if (!item.isEmpty())
827          return true;
828      return false;
829    }
830
831    public Reference addResponsibleParty() { // 3
832      Reference t = new Reference();
833      if (this.responsibleParty == null)
834        this.responsibleParty = new ArrayList<Reference>();
835      this.responsibleParty.add(t);
836      return t;
837    }
838
839    public MedicationDispenseSubstitutionComponent addResponsibleParty(Reference t) { // 3
840      if (t == null)
841        return this;
842      if (this.responsibleParty == null)
843        this.responsibleParty = new ArrayList<Reference>();
844      this.responsibleParty.add(t);
845      return this;
846    }
847
848    /**
849     * @return The first repetition of repeating field {@link #responsibleParty},
850     *         creating it if it does not already exist
851     */
852    public Reference getResponsiblePartyFirstRep() {
853      if (getResponsibleParty().isEmpty()) {
854        addResponsibleParty();
855      }
856      return getResponsibleParty().get(0);
857    }
858
859    protected void listChildren(List<Property> children) {
860      super.listChildren(children);
861      children.add(new Property("wasSubstituted", "boolean",
862          "True if the dispenser dispensed a different drug or product from what was prescribed.", 0, 1,
863          wasSubstituted));
864      children.add(new Property("type", "CodeableConcept",
865          "A code signifying whether a different drug was dispensed from what was prescribed.", 0, 1, type));
866      children.add(new Property("reason", "CodeableConcept",
867          "Indicates the reason for the substitution (or lack of substitution) from what was prescribed.", 0,
868          java.lang.Integer.MAX_VALUE, reason));
869      children.add(new Property("responsibleParty", "Reference(Practitioner|PractitionerRole)",
870          "The person or organization that has primary responsibility for the substitution.", 0,
871          java.lang.Integer.MAX_VALUE, responsibleParty));
872    }
873
874    @Override
875    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
876      switch (_hash) {
877      case -592113567:
878        /* wasSubstituted */ return new Property("wasSubstituted", "boolean",
879            "True if the dispenser dispensed a different drug or product from what was prescribed.", 0, 1,
880            wasSubstituted);
881      case 3575610:
882        /* type */ return new Property("type", "CodeableConcept",
883            "A code signifying whether a different drug was dispensed from what was prescribed.", 0, 1, type);
884      case -934964668:
885        /* reason */ return new Property("reason", "CodeableConcept",
886            "Indicates the reason for the substitution (or lack of substitution) from what was prescribed.", 0,
887            java.lang.Integer.MAX_VALUE, reason);
888      case 1511509392:
889        /* responsibleParty */ return new Property("responsibleParty", "Reference(Practitioner|PractitionerRole)",
890            "The person or organization that has primary responsibility for the substitution.", 0,
891            java.lang.Integer.MAX_VALUE, responsibleParty);
892      default:
893        return super.getNamedProperty(_hash, _name, _checkValid);
894      }
895
896    }
897
898    @Override
899    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
900      switch (hash) {
901      case -592113567:
902        /* wasSubstituted */ return this.wasSubstituted == null ? new Base[0] : new Base[] { this.wasSubstituted }; // BooleanType
903      case 3575610:
904        /* type */ return this.type == null ? new Base[0] : new Base[] { this.type }; // CodeableConcept
905      case -934964668:
906        /* reason */ return this.reason == null ? new Base[0] : this.reason.toArray(new Base[this.reason.size()]); // CodeableConcept
907      case 1511509392:
908        /* responsibleParty */ return this.responsibleParty == null ? new Base[0]
909            : this.responsibleParty.toArray(new Base[this.responsibleParty.size()]); // Reference
910      default:
911        return super.getProperty(hash, name, checkValid);
912      }
913
914    }
915
916    @Override
917    public Base setProperty(int hash, String name, Base value) throws FHIRException {
918      switch (hash) {
919      case -592113567: // wasSubstituted
920        this.wasSubstituted = castToBoolean(value); // BooleanType
921        return value;
922      case 3575610: // type
923        this.type = castToCodeableConcept(value); // CodeableConcept
924        return value;
925      case -934964668: // reason
926        this.getReason().add(castToCodeableConcept(value)); // CodeableConcept
927        return value;
928      case 1511509392: // responsibleParty
929        this.getResponsibleParty().add(castToReference(value)); // Reference
930        return value;
931      default:
932        return super.setProperty(hash, name, value);
933      }
934
935    }
936
937    @Override
938    public Base setProperty(String name, Base value) throws FHIRException {
939      if (name.equals("wasSubstituted")) {
940        this.wasSubstituted = castToBoolean(value); // BooleanType
941      } else if (name.equals("type")) {
942        this.type = castToCodeableConcept(value); // CodeableConcept
943      } else if (name.equals("reason")) {
944        this.getReason().add(castToCodeableConcept(value));
945      } else if (name.equals("responsibleParty")) {
946        this.getResponsibleParty().add(castToReference(value));
947      } else
948        return super.setProperty(name, value);
949      return value;
950    }
951
952  @Override
953  public void removeChild(String name, Base value) throws FHIRException {
954      if (name.equals("wasSubstituted")) {
955        this.wasSubstituted = null;
956      } else if (name.equals("type")) {
957        this.type = null;
958      } else if (name.equals("reason")) {
959        this.getReason().remove(castToCodeableConcept(value));
960      } else if (name.equals("responsibleParty")) {
961        this.getResponsibleParty().remove(castToReference(value));
962      } else
963        super.removeChild(name, value);
964      
965    }
966
967    @Override
968    public Base makeProperty(int hash, String name) throws FHIRException {
969      switch (hash) {
970      case -592113567:
971        return getWasSubstitutedElement();
972      case 3575610:
973        return getType();
974      case -934964668:
975        return addReason();
976      case 1511509392:
977        return addResponsibleParty();
978      default:
979        return super.makeProperty(hash, name);
980      }
981
982    }
983
984    @Override
985    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
986      switch (hash) {
987      case -592113567:
988        /* wasSubstituted */ return new String[] { "boolean" };
989      case 3575610:
990        /* type */ return new String[] { "CodeableConcept" };
991      case -934964668:
992        /* reason */ return new String[] { "CodeableConcept" };
993      case 1511509392:
994        /* responsibleParty */ return new String[] { "Reference" };
995      default:
996        return super.getTypesForProperty(hash, name);
997      }
998
999    }
1000
1001    @Override
1002    public Base addChild(String name) throws FHIRException {
1003      if (name.equals("wasSubstituted")) {
1004        throw new FHIRException("Cannot call addChild on a singleton property MedicationDispense.wasSubstituted");
1005      } else if (name.equals("type")) {
1006        this.type = new CodeableConcept();
1007        return this.type;
1008      } else if (name.equals("reason")) {
1009        return addReason();
1010      } else if (name.equals("responsibleParty")) {
1011        return addResponsibleParty();
1012      } else
1013        return super.addChild(name);
1014    }
1015
1016    public MedicationDispenseSubstitutionComponent copy() {
1017      MedicationDispenseSubstitutionComponent dst = new MedicationDispenseSubstitutionComponent();
1018      copyValues(dst);
1019      return dst;
1020    }
1021
1022    public void copyValues(MedicationDispenseSubstitutionComponent dst) {
1023      super.copyValues(dst);
1024      dst.wasSubstituted = wasSubstituted == null ? null : wasSubstituted.copy();
1025      dst.type = type == null ? null : type.copy();
1026      if (reason != null) {
1027        dst.reason = new ArrayList<CodeableConcept>();
1028        for (CodeableConcept i : reason)
1029          dst.reason.add(i.copy());
1030      }
1031      ;
1032      if (responsibleParty != null) {
1033        dst.responsibleParty = new ArrayList<Reference>();
1034        for (Reference i : responsibleParty)
1035          dst.responsibleParty.add(i.copy());
1036      }
1037      ;
1038    }
1039
1040    @Override
1041    public boolean equalsDeep(Base other_) {
1042      if (!super.equalsDeep(other_))
1043        return false;
1044      if (!(other_ instanceof MedicationDispenseSubstitutionComponent))
1045        return false;
1046      MedicationDispenseSubstitutionComponent o = (MedicationDispenseSubstitutionComponent) other_;
1047      return compareDeep(wasSubstituted, o.wasSubstituted, true) && compareDeep(type, o.type, true)
1048          && compareDeep(reason, o.reason, true) && compareDeep(responsibleParty, o.responsibleParty, true);
1049    }
1050
1051    @Override
1052    public boolean equalsShallow(Base other_) {
1053      if (!super.equalsShallow(other_))
1054        return false;
1055      if (!(other_ instanceof MedicationDispenseSubstitutionComponent))
1056        return false;
1057      MedicationDispenseSubstitutionComponent o = (MedicationDispenseSubstitutionComponent) other_;
1058      return compareValues(wasSubstituted, o.wasSubstituted, true);
1059    }
1060
1061    public boolean isEmpty() {
1062      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(wasSubstituted, type, reason, responsibleParty);
1063    }
1064
1065    public String fhirType() {
1066      return "MedicationDispense.substitution";
1067
1068    }
1069
1070  }
1071
1072  /**
1073   * Identifiers associated with this Medication Dispense that are defined by
1074   * business processes and/or used to refer to it when a direct URL reference to
1075   * the resource itself is not appropriate. They are business identifiers
1076   * assigned to this resource by the performer or other systems and remain
1077   * constant as the resource is updated and propagates from server to server.
1078   */
1079  @Child(name = "identifier", type = {
1080      Identifier.class }, order = 0, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
1081  @Description(shortDefinition = "External identifier", formalDefinition = "Identifiers associated with this Medication Dispense that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate. They are business identifiers assigned to this resource by the performer or other systems and remain constant as the resource is updated and propagates from server to server.")
1082  protected List<Identifier> identifier;
1083
1084  /**
1085   * The procedure that trigger the dispense.
1086   */
1087  @Child(name = "partOf", type = {
1088      Procedure.class }, order = 1, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
1089  @Description(shortDefinition = "Event that dispense is part of", formalDefinition = "The procedure that trigger the dispense.")
1090  protected List<Reference> partOf;
1091  /**
1092   * The actual objects that are the target of the reference (The procedure that
1093   * trigger the dispense.)
1094   */
1095  protected List<Procedure> partOfTarget;
1096
1097  /**
1098   * A code specifying the state of the set of dispense events.
1099   */
1100  @Child(name = "status", type = { CodeType.class }, order = 2, min = 1, max = 1, modifier = true, summary = true)
1101  @Description(shortDefinition = "preparation | in-progress | cancelled | on-hold | completed | entered-in-error | stopped | declined | unknown", formalDefinition = "A code specifying the state of the set of dispense events.")
1102  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/medicationdispense-status")
1103  protected Enumeration<MedicationDispenseStatus> status;
1104
1105  /**
1106   * Indicates the reason why a dispense was not performed.
1107   */
1108  @Child(name = "statusReason", type = { CodeableConcept.class,
1109      DetectedIssue.class }, order = 3, min = 0, max = 1, modifier = false, summary = false)
1110  @Description(shortDefinition = "Why a dispense was not performed", formalDefinition = "Indicates the reason why a dispense was not performed.")
1111  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/medicationdispense-status-reason")
1112  protected Type statusReason;
1113
1114  /**
1115   * Indicates the type of medication dispense (for example, where the medication
1116   * is expected to be consumed or administered (i.e. inpatient or outpatient)).
1117   */
1118  @Child(name = "category", type = {
1119      CodeableConcept.class }, order = 4, min = 0, max = 1, modifier = false, summary = false)
1120  @Description(shortDefinition = "Type of medication dispense", formalDefinition = "Indicates the type of medication dispense (for example, where the medication is expected to be consumed or administered (i.e. inpatient or outpatient)).")
1121  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/medicationdispense-category")
1122  protected CodeableConcept category;
1123
1124  /**
1125   * Identifies the medication being administered. This is either a link to a
1126   * resource representing the details of the medication or a simple attribute
1127   * carrying a code that identifies the medication from a known list of
1128   * medications.
1129   */
1130  @Child(name = "medication", type = { CodeableConcept.class,
1131      Medication.class }, order = 5, min = 1, max = 1, modifier = false, summary = true)
1132  @Description(shortDefinition = "What medication was supplied", formalDefinition = "Identifies the medication being administered. This is either a link to a resource representing the details of the medication or a simple attribute carrying a code that identifies the medication from a known list of medications.")
1133  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/medication-codes")
1134  protected Type medication;
1135
1136  /**
1137   * A link to a resource representing the person or the group to whom the
1138   * medication will be given.
1139   */
1140  @Child(name = "subject", type = { Patient.class,
1141      Group.class }, order = 6, min = 0, max = 1, modifier = false, summary = true)
1142  @Description(shortDefinition = "Who the dispense is for", formalDefinition = "A link to a resource representing the person or the group to whom the medication will be given.")
1143  protected Reference subject;
1144
1145  /**
1146   * The actual object that is the target of the reference (A link to a resource
1147   * representing the person or the group to whom the medication will be given.)
1148   */
1149  protected Resource subjectTarget;
1150
1151  /**
1152   * The encounter or episode of care that establishes the context for this event.
1153   */
1154  @Child(name = "context", type = { Encounter.class,
1155      EpisodeOfCare.class }, order = 7, min = 0, max = 1, modifier = false, summary = false)
1156  @Description(shortDefinition = "Encounter / Episode associated with event", formalDefinition = "The encounter or episode of care that establishes the context for this event.")
1157  protected Reference context;
1158
1159  /**
1160   * The actual object that is the target of the reference (The encounter or
1161   * episode of care that establishes the context for this event.)
1162   */
1163  protected Resource contextTarget;
1164
1165  /**
1166   * Additional information that supports the medication being dispensed.
1167   */
1168  @Child(name = "supportingInformation", type = {
1169      Reference.class }, order = 8, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
1170  @Description(shortDefinition = "Information that supports the dispensing of the medication", formalDefinition = "Additional information that supports the medication being dispensed.")
1171  protected List<Reference> supportingInformation;
1172  /**
1173   * The actual objects that are the target of the reference (Additional
1174   * information that supports the medication being dispensed.)
1175   */
1176  protected List<Resource> supportingInformationTarget;
1177
1178  /**
1179   * Indicates who or what performed the event.
1180   */
1181  @Child(name = "performer", type = {}, order = 9, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
1182  @Description(shortDefinition = "Who performed event", formalDefinition = "Indicates who or what performed the event.")
1183  protected List<MedicationDispensePerformerComponent> performer;
1184
1185  /**
1186   * The principal physical location where the dispense was performed.
1187   */
1188  @Child(name = "location", type = { Location.class }, order = 10, min = 0, max = 1, modifier = false, summary = false)
1189  @Description(shortDefinition = "Where the dispense occurred", formalDefinition = "The principal physical location where the dispense was performed.")
1190  protected Reference location;
1191
1192  /**
1193   * The actual object that is the target of the reference (The principal physical
1194   * location where the dispense was performed.)
1195   */
1196  protected Location locationTarget;
1197
1198  /**
1199   * Indicates the medication order that is being dispensed against.
1200   */
1201  @Child(name = "authorizingPrescription", type = {
1202      MedicationRequest.class }, order = 11, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
1203  @Description(shortDefinition = "Medication order that authorizes the dispense", formalDefinition = "Indicates the medication order that is being dispensed against.")
1204  protected List<Reference> authorizingPrescription;
1205  /**
1206   * The actual objects that are the target of the reference (Indicates the
1207   * medication order that is being dispensed against.)
1208   */
1209  protected List<MedicationRequest> authorizingPrescriptionTarget;
1210
1211  /**
1212   * Indicates the type of dispensing event that is performed. For example, Trial
1213   * Fill, Completion of Trial, Partial Fill, Emergency Fill, Samples, etc.
1214   */
1215  @Child(name = "type", type = {
1216      CodeableConcept.class }, order = 12, min = 0, max = 1, modifier = false, summary = false)
1217  @Description(shortDefinition = "Trial fill, partial fill, emergency fill, etc.", formalDefinition = "Indicates the type of dispensing event that is performed. For example, Trial Fill, Completion of Trial, Partial Fill, Emergency Fill, Samples, etc.")
1218  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://terminology.hl7.org/ValueSet/v3-ActPharmacySupplyType")
1219  protected CodeableConcept type;
1220
1221  /**
1222   * The amount of medication that has been dispensed. Includes unit of measure.
1223   */
1224  @Child(name = "quantity", type = { Quantity.class }, order = 13, min = 0, max = 1, modifier = false, summary = false)
1225  @Description(shortDefinition = "Amount dispensed", formalDefinition = "The amount of medication that has been dispensed. Includes unit of measure.")
1226  protected Quantity quantity;
1227
1228  /**
1229   * The amount of medication expressed as a timing amount.
1230   */
1231  @Child(name = "daysSupply", type = {
1232      Quantity.class }, order = 14, min = 0, max = 1, modifier = false, summary = false)
1233  @Description(shortDefinition = "Amount of medication expressed as a timing amount", formalDefinition = "The amount of medication expressed as a timing amount.")
1234  protected Quantity daysSupply;
1235
1236  /**
1237   * The time when the dispensed product was packaged and reviewed.
1238   */
1239  @Child(name = "whenPrepared", type = {
1240      DateTimeType.class }, order = 15, min = 0, max = 1, modifier = false, summary = true)
1241  @Description(shortDefinition = "When product was packaged and reviewed", formalDefinition = "The time when the dispensed product was packaged and reviewed.")
1242  protected DateTimeType whenPrepared;
1243
1244  /**
1245   * The time the dispensed product was provided to the patient or their
1246   * representative.
1247   */
1248  @Child(name = "whenHandedOver", type = {
1249      DateTimeType.class }, order = 16, min = 0, max = 1, modifier = false, summary = false)
1250  @Description(shortDefinition = "When product was given out", formalDefinition = "The time the dispensed product was provided to the patient or their representative.")
1251  protected DateTimeType whenHandedOver;
1252
1253  /**
1254   * Identification of the facility/location where the medication was shipped to,
1255   * as part of the dispense event.
1256   */
1257  @Child(name = "destination", type = {
1258      Location.class }, order = 17, min = 0, max = 1, modifier = false, summary = false)
1259  @Description(shortDefinition = "Where the medication was sent", formalDefinition = "Identification of the facility/location where the medication was shipped to, as part of the dispense event.")
1260  protected Reference destination;
1261
1262  /**
1263   * The actual object that is the target of the reference (Identification of the
1264   * facility/location where the medication was shipped to, as part of the
1265   * dispense event.)
1266   */
1267  protected Location destinationTarget;
1268
1269  /**
1270   * Identifies the person who picked up the medication. This will usually be a
1271   * patient or their caregiver, but some cases exist where it can be a healthcare
1272   * professional.
1273   */
1274  @Child(name = "receiver", type = { Patient.class,
1275      Practitioner.class }, order = 18, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
1276  @Description(shortDefinition = "Who collected the medication", formalDefinition = "Identifies the person who picked up the medication.  This will usually be a patient or their caregiver, but some cases exist where it can be a healthcare professional.")
1277  protected List<Reference> receiver;
1278  /**
1279   * The actual objects that are the target of the reference (Identifies the
1280   * person who picked up the medication. This will usually be a patient or their
1281   * caregiver, but some cases exist where it can be a healthcare professional.)
1282   */
1283  protected List<Resource> receiverTarget;
1284
1285  /**
1286   * Extra information about the dispense that could not be conveyed in the other
1287   * attributes.
1288   */
1289  @Child(name = "note", type = {
1290      Annotation.class }, order = 19, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
1291  @Description(shortDefinition = "Information about the dispense", formalDefinition = "Extra information about the dispense that could not be conveyed in the other attributes.")
1292  protected List<Annotation> note;
1293
1294  /**
1295   * Indicates how the medication is to be used by the patient.
1296   */
1297  @Child(name = "dosageInstruction", type = {
1298      Dosage.class }, order = 20, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
1299  @Description(shortDefinition = "How the medication is to be used by the patient or administered by the caregiver", formalDefinition = "Indicates how the medication is to be used by the patient.")
1300  protected List<Dosage> dosageInstruction;
1301
1302  /**
1303   * Indicates whether or not substitution was made as part of the dispense. In
1304   * some cases, substitution will be expected but does not happen, in other cases
1305   * substitution is not expected but does happen. This block explains what
1306   * substitution did or did not happen and why. If nothing is specified,
1307   * substitution was not done.
1308   */
1309  @Child(name = "substitution", type = {}, order = 21, min = 0, max = 1, modifier = false, summary = false)
1310  @Description(shortDefinition = "Whether a substitution was performed on the dispense", formalDefinition = "Indicates whether or not substitution was made as part of the dispense.  In some cases, substitution will be expected but does not happen, in other cases substitution is not expected but does happen.  This block explains what substitution did or did not happen and why.  If nothing is specified, substitution was not done.")
1311  protected MedicationDispenseSubstitutionComponent substitution;
1312
1313  /**
1314   * Indicates an actual or potential clinical issue with or between one or more
1315   * active or proposed clinical actions for a patient; e.g. drug-drug
1316   * interaction, duplicate therapy, dosage alert etc.
1317   */
1318  @Child(name = "detectedIssue", type = {
1319      DetectedIssue.class }, order = 22, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
1320  @Description(shortDefinition = "Clinical issue with action", formalDefinition = "Indicates an actual or potential clinical issue with or between one or more active or proposed clinical actions for a patient; e.g. drug-drug interaction, duplicate therapy, dosage alert etc.")
1321  protected List<Reference> detectedIssue;
1322  /**
1323   * The actual objects that are the target of the reference (Indicates an actual
1324   * or potential clinical issue with or between one or more active or proposed
1325   * clinical actions for a patient; e.g. drug-drug interaction, duplicate
1326   * therapy, dosage alert etc.)
1327   */
1328  protected List<DetectedIssue> detectedIssueTarget;
1329
1330  /**
1331   * A summary of the events of interest that have occurred, such as when the
1332   * dispense was verified.
1333   */
1334  @Child(name = "eventHistory", type = {
1335      Provenance.class }, order = 23, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
1336  @Description(shortDefinition = "A list of relevant lifecycle events", formalDefinition = "A summary of the events of interest that have occurred, such as when the dispense was verified.")
1337  protected List<Reference> eventHistory;
1338  /**
1339   * The actual objects that are the target of the reference (A summary of the
1340   * events of interest that have occurred, such as when the dispense was
1341   * verified.)
1342   */
1343  protected List<Provenance> eventHistoryTarget;
1344
1345  private static final long serialVersionUID = -976967238L;
1346
1347  /**
1348   * Constructor
1349   */
1350  public MedicationDispense() {
1351    super();
1352  }
1353
1354  /**
1355   * Constructor
1356   */
1357  public MedicationDispense(Enumeration<MedicationDispenseStatus> status, Type medication) {
1358    super();
1359    this.status = status;
1360    this.medication = medication;
1361  }
1362
1363  /**
1364   * @return {@link #identifier} (Identifiers associated with this Medication
1365   *         Dispense that are defined by business processes and/or used to refer
1366   *         to it when a direct URL reference to the resource itself is not
1367   *         appropriate. They are business identifiers assigned to this resource
1368   *         by the performer or other systems and remain constant as the resource
1369   *         is updated and propagates from server to server.)
1370   */
1371  public List<Identifier> getIdentifier() {
1372    if (this.identifier == null)
1373      this.identifier = new ArrayList<Identifier>();
1374    return this.identifier;
1375  }
1376
1377  /**
1378   * @return Returns a reference to <code>this</code> for easy method chaining
1379   */
1380  public MedicationDispense setIdentifier(List<Identifier> theIdentifier) {
1381    this.identifier = theIdentifier;
1382    return this;
1383  }
1384
1385  public boolean hasIdentifier() {
1386    if (this.identifier == null)
1387      return false;
1388    for (Identifier item : this.identifier)
1389      if (!item.isEmpty())
1390        return true;
1391    return false;
1392  }
1393
1394  public Identifier addIdentifier() { // 3
1395    Identifier t = new Identifier();
1396    if (this.identifier == null)
1397      this.identifier = new ArrayList<Identifier>();
1398    this.identifier.add(t);
1399    return t;
1400  }
1401
1402  public MedicationDispense addIdentifier(Identifier t) { // 3
1403    if (t == null)
1404      return this;
1405    if (this.identifier == null)
1406      this.identifier = new ArrayList<Identifier>();
1407    this.identifier.add(t);
1408    return this;
1409  }
1410
1411  /**
1412   * @return The first repetition of repeating field {@link #identifier}, creating
1413   *         it if it does not already exist
1414   */
1415  public Identifier getIdentifierFirstRep() {
1416    if (getIdentifier().isEmpty()) {
1417      addIdentifier();
1418    }
1419    return getIdentifier().get(0);
1420  }
1421
1422  /**
1423   * @return {@link #partOf} (The procedure that trigger the dispense.)
1424   */
1425  public List<Reference> getPartOf() {
1426    if (this.partOf == null)
1427      this.partOf = new ArrayList<Reference>();
1428    return this.partOf;
1429  }
1430
1431  /**
1432   * @return Returns a reference to <code>this</code> for easy method chaining
1433   */
1434  public MedicationDispense setPartOf(List<Reference> thePartOf) {
1435    this.partOf = thePartOf;
1436    return this;
1437  }
1438
1439  public boolean hasPartOf() {
1440    if (this.partOf == null)
1441      return false;
1442    for (Reference item : this.partOf)
1443      if (!item.isEmpty())
1444        return true;
1445    return false;
1446  }
1447
1448  public Reference addPartOf() { // 3
1449    Reference t = new Reference();
1450    if (this.partOf == null)
1451      this.partOf = new ArrayList<Reference>();
1452    this.partOf.add(t);
1453    return t;
1454  }
1455
1456  public MedicationDispense addPartOf(Reference t) { // 3
1457    if (t == null)
1458      return this;
1459    if (this.partOf == null)
1460      this.partOf = new ArrayList<Reference>();
1461    this.partOf.add(t);
1462    return this;
1463  }
1464
1465  /**
1466   * @return The first repetition of repeating field {@link #partOf}, creating it
1467   *         if it does not already exist
1468   */
1469  public Reference getPartOfFirstRep() {
1470    if (getPartOf().isEmpty()) {
1471      addPartOf();
1472    }
1473    return getPartOf().get(0);
1474  }
1475
1476  /**
1477   * @return {@link #status} (A code specifying the state of the set of dispense
1478   *         events.). This is the underlying object with id, value and
1479   *         extensions. The accessor "getStatus" gives direct access to the value
1480   */
1481  public Enumeration<MedicationDispenseStatus> getStatusElement() {
1482    if (this.status == null)
1483      if (Configuration.errorOnAutoCreate())
1484        throw new Error("Attempt to auto-create MedicationDispense.status");
1485      else if (Configuration.doAutoCreate())
1486        this.status = new Enumeration<MedicationDispenseStatus>(new MedicationDispenseStatusEnumFactory()); // bb
1487    return this.status;
1488  }
1489
1490  public boolean hasStatusElement() {
1491    return this.status != null && !this.status.isEmpty();
1492  }
1493
1494  public boolean hasStatus() {
1495    return this.status != null && !this.status.isEmpty();
1496  }
1497
1498  /**
1499   * @param value {@link #status} (A code specifying the state of the set of
1500   *              dispense events.). This is the underlying object with id, value
1501   *              and extensions. The accessor "getStatus" gives direct access to
1502   *              the value
1503   */
1504  public MedicationDispense setStatusElement(Enumeration<MedicationDispenseStatus> value) {
1505    this.status = value;
1506    return this;
1507  }
1508
1509  /**
1510   * @return A code specifying the state of the set of dispense events.
1511   */
1512  public MedicationDispenseStatus getStatus() {
1513    return this.status == null ? null : this.status.getValue();
1514  }
1515
1516  /**
1517   * @param value A code specifying the state of the set of dispense events.
1518   */
1519  public MedicationDispense setStatus(MedicationDispenseStatus value) {
1520    if (this.status == null)
1521      this.status = new Enumeration<MedicationDispenseStatus>(new MedicationDispenseStatusEnumFactory());
1522    this.status.setValue(value);
1523    return this;
1524  }
1525
1526  /**
1527   * @return {@link #statusReason} (Indicates the reason why a dispense was not
1528   *         performed.)
1529   */
1530  public Type getStatusReason() {
1531    return this.statusReason;
1532  }
1533
1534  /**
1535   * @return {@link #statusReason} (Indicates the reason why a dispense was not
1536   *         performed.)
1537   */
1538  public CodeableConcept getStatusReasonCodeableConcept() throws FHIRException {
1539    if (this.statusReason == null)
1540      this.statusReason = new CodeableConcept();
1541    if (!(this.statusReason instanceof CodeableConcept))
1542      throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "
1543          + this.statusReason.getClass().getName() + " was encountered");
1544    return (CodeableConcept) this.statusReason;
1545  }
1546
1547  public boolean hasStatusReasonCodeableConcept() {
1548      return this.statusReason instanceof CodeableConcept;
1549  }
1550
1551  /**
1552   * @return {@link #statusReason} (Indicates the reason why a dispense was not
1553   *         performed.)
1554   */
1555  public Reference getStatusReasonReference() throws FHIRException {
1556    if (this.statusReason == null)
1557      this.statusReason = new Reference();
1558    if (!(this.statusReason instanceof Reference))
1559      throw new FHIRException("Type mismatch: the type Reference was expected, but "
1560          + this.statusReason.getClass().getName() + " was encountered");
1561    return (Reference) this.statusReason;
1562  }
1563
1564  public boolean hasStatusReasonReference() {
1565      return this.statusReason instanceof Reference;
1566  }
1567
1568  public boolean hasStatusReason() {
1569    return this.statusReason != null && !this.statusReason.isEmpty();
1570  }
1571
1572  /**
1573   * @param value {@link #statusReason} (Indicates the reason why a dispense was
1574   *              not performed.)
1575   */
1576  public MedicationDispense setStatusReason(Type value) {
1577    if (value != null && !(value instanceof CodeableConcept || value instanceof Reference))
1578      throw new Error("Not the right type for MedicationDispense.statusReason[x]: " + value.fhirType());
1579    this.statusReason = value;
1580    return this;
1581  }
1582
1583  /**
1584   * @return {@link #category} (Indicates the type of medication dispense (for
1585   *         example, where the medication is expected to be consumed or
1586   *         administered (i.e. inpatient or outpatient)).)
1587   */
1588  public CodeableConcept getCategory() {
1589    if (this.category == null)
1590      if (Configuration.errorOnAutoCreate())
1591        throw new Error("Attempt to auto-create MedicationDispense.category");
1592      else if (Configuration.doAutoCreate())
1593        this.category = new CodeableConcept(); // cc
1594    return this.category;
1595  }
1596
1597  public boolean hasCategory() {
1598    return this.category != null && !this.category.isEmpty();
1599  }
1600
1601  /**
1602   * @param value {@link #category} (Indicates the type of medication dispense
1603   *              (for example, where the medication is expected to be consumed or
1604   *              administered (i.e. inpatient or outpatient)).)
1605   */
1606  public MedicationDispense setCategory(CodeableConcept value) {
1607    this.category = value;
1608    return this;
1609  }
1610
1611  /**
1612   * @return {@link #medication} (Identifies the medication being administered.
1613   *         This is either a link to a resource representing the details of the
1614   *         medication or a simple attribute carrying a code that identifies the
1615   *         medication from a known list of medications.)
1616   */
1617  public Type getMedication() {
1618    return this.medication;
1619  }
1620
1621  /**
1622   * @return {@link #medication} (Identifies the medication being administered.
1623   *         This is either a link to a resource representing the details of the
1624   *         medication or a simple attribute carrying a code that identifies the
1625   *         medication from a known list of medications.)
1626   */
1627  public CodeableConcept getMedicationCodeableConcept() throws FHIRException {
1628    if (this.medication == null)
1629      this.medication = new CodeableConcept();
1630    if (!(this.medication instanceof CodeableConcept))
1631      throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "
1632          + this.medication.getClass().getName() + " was encountered");
1633    return (CodeableConcept) this.medication;
1634  }
1635
1636  public boolean hasMedicationCodeableConcept() {
1637      return this.medication instanceof CodeableConcept;
1638  }
1639
1640  /**
1641   * @return {@link #medication} (Identifies the medication being administered.
1642   *         This is either a link to a resource representing the details of the
1643   *         medication or a simple attribute carrying a code that identifies the
1644   *         medication from a known list of medications.)
1645   */
1646  public Reference getMedicationReference() throws FHIRException {
1647    if (this.medication == null)
1648      this.medication = new Reference();
1649    if (!(this.medication instanceof Reference))
1650      throw new FHIRException("Type mismatch: the type Reference was expected, but "
1651          + this.medication.getClass().getName() + " was encountered");
1652    return (Reference) this.medication;
1653  }
1654
1655  public boolean hasMedicationReference() {
1656      return this.medication instanceof Reference;
1657  }
1658
1659  public boolean hasMedication() {
1660    return this.medication != null && !this.medication.isEmpty();
1661  }
1662
1663  /**
1664   * @param value {@link #medication} (Identifies the medication being
1665   *              administered. This is either a link to a resource representing
1666   *              the details of the medication or a simple attribute carrying a
1667   *              code that identifies the medication from a known list of
1668   *              medications.)
1669   */
1670  public MedicationDispense setMedication(Type value) {
1671    if (value != null && !(value instanceof CodeableConcept || value instanceof Reference))
1672      throw new Error("Not the right type for MedicationDispense.medication[x]: " + value.fhirType());
1673    this.medication = value;
1674    return this;
1675  }
1676
1677  /**
1678   * @return {@link #subject} (A link to a resource representing the person or the
1679   *         group to whom the medication will be given.)
1680   */
1681  public Reference getSubject() {
1682    if (this.subject == null)
1683      if (Configuration.errorOnAutoCreate())
1684        throw new Error("Attempt to auto-create MedicationDispense.subject");
1685      else if (Configuration.doAutoCreate())
1686        this.subject = new Reference(); // cc
1687    return this.subject;
1688  }
1689
1690  public boolean hasSubject() {
1691    return this.subject != null && !this.subject.isEmpty();
1692  }
1693
1694  /**
1695   * @param value {@link #subject} (A link to a resource representing the person
1696   *              or the group to whom the medication will be given.)
1697   */
1698  public MedicationDispense setSubject(Reference value) {
1699    this.subject = value;
1700    return this;
1701  }
1702
1703  /**
1704   * @return {@link #subject} The actual object that is the target of the
1705   *         reference. The reference library doesn't populate this, but you can
1706   *         use it to hold the resource if you resolve it. (A link to a resource
1707   *         representing the person or the group to whom the medication will be
1708   *         given.)
1709   */
1710  public Resource getSubjectTarget() {
1711    return this.subjectTarget;
1712  }
1713
1714  /**
1715   * @param value {@link #subject} The actual object that is the target of the
1716   *              reference. The reference library doesn't use these, but you can
1717   *              use it to hold the resource if you resolve it. (A link to a
1718   *              resource representing the person or the group to whom the
1719   *              medication will be given.)
1720   */
1721  public MedicationDispense setSubjectTarget(Resource value) {
1722    this.subjectTarget = value;
1723    return this;
1724  }
1725
1726  /**
1727   * @return {@link #context} (The encounter or episode of care that establishes
1728   *         the context for this event.)
1729   */
1730  public Reference getContext() {
1731    if (this.context == null)
1732      if (Configuration.errorOnAutoCreate())
1733        throw new Error("Attempt to auto-create MedicationDispense.context");
1734      else if (Configuration.doAutoCreate())
1735        this.context = new Reference(); // cc
1736    return this.context;
1737  }
1738
1739  public boolean hasContext() {
1740    return this.context != null && !this.context.isEmpty();
1741  }
1742
1743  /**
1744   * @param value {@link #context} (The encounter or episode of care that
1745   *              establishes the context for this event.)
1746   */
1747  public MedicationDispense setContext(Reference value) {
1748    this.context = value;
1749    return this;
1750  }
1751
1752  /**
1753   * @return {@link #context} The actual object that is the target of the
1754   *         reference. The reference library doesn't populate this, but you can
1755   *         use it to hold the resource if you resolve it. (The encounter or
1756   *         episode of care that establishes the context for this event.)
1757   */
1758  public Resource getContextTarget() {
1759    return this.contextTarget;
1760  }
1761
1762  /**
1763   * @param value {@link #context} The actual object that is the target of the
1764   *              reference. The reference library doesn't use these, but you can
1765   *              use it to hold the resource if you resolve it. (The encounter or
1766   *              episode of care that establishes the context for this event.)
1767   */
1768  public MedicationDispense setContextTarget(Resource value) {
1769    this.contextTarget = value;
1770    return this;
1771  }
1772
1773  /**
1774   * @return {@link #supportingInformation} (Additional information that supports
1775   *         the medication being dispensed.)
1776   */
1777  public List<Reference> getSupportingInformation() {
1778    if (this.supportingInformation == null)
1779      this.supportingInformation = new ArrayList<Reference>();
1780    return this.supportingInformation;
1781  }
1782
1783  /**
1784   * @return Returns a reference to <code>this</code> for easy method chaining
1785   */
1786  public MedicationDispense setSupportingInformation(List<Reference> theSupportingInformation) {
1787    this.supportingInformation = theSupportingInformation;
1788    return this;
1789  }
1790
1791  public boolean hasSupportingInformation() {
1792    if (this.supportingInformation == null)
1793      return false;
1794    for (Reference item : this.supportingInformation)
1795      if (!item.isEmpty())
1796        return true;
1797    return false;
1798  }
1799
1800  public Reference addSupportingInformation() { // 3
1801    Reference t = new Reference();
1802    if (this.supportingInformation == null)
1803      this.supportingInformation = new ArrayList<Reference>();
1804    this.supportingInformation.add(t);
1805    return t;
1806  }
1807
1808  public MedicationDispense addSupportingInformation(Reference t) { // 3
1809    if (t == null)
1810      return this;
1811    if (this.supportingInformation == null)
1812      this.supportingInformation = new ArrayList<Reference>();
1813    this.supportingInformation.add(t);
1814    return this;
1815  }
1816
1817  /**
1818   * @return The first repetition of repeating field
1819   *         {@link #supportingInformation}, creating it if it does not already
1820   *         exist
1821   */
1822  public Reference getSupportingInformationFirstRep() {
1823    if (getSupportingInformation().isEmpty()) {
1824      addSupportingInformation();
1825    }
1826    return getSupportingInformation().get(0);
1827  }
1828
1829  /**
1830   * @return {@link #performer} (Indicates who or what performed the event.)
1831   */
1832  public List<MedicationDispensePerformerComponent> getPerformer() {
1833    if (this.performer == null)
1834      this.performer = new ArrayList<MedicationDispensePerformerComponent>();
1835    return this.performer;
1836  }
1837
1838  /**
1839   * @return Returns a reference to <code>this</code> for easy method chaining
1840   */
1841  public MedicationDispense setPerformer(List<MedicationDispensePerformerComponent> thePerformer) {
1842    this.performer = thePerformer;
1843    return this;
1844  }
1845
1846  public boolean hasPerformer() {
1847    if (this.performer == null)
1848      return false;
1849    for (MedicationDispensePerformerComponent item : this.performer)
1850      if (!item.isEmpty())
1851        return true;
1852    return false;
1853  }
1854
1855  public MedicationDispensePerformerComponent addPerformer() { // 3
1856    MedicationDispensePerformerComponent t = new MedicationDispensePerformerComponent();
1857    if (this.performer == null)
1858      this.performer = new ArrayList<MedicationDispensePerformerComponent>();
1859    this.performer.add(t);
1860    return t;
1861  }
1862
1863  public MedicationDispense addPerformer(MedicationDispensePerformerComponent t) { // 3
1864    if (t == null)
1865      return this;
1866    if (this.performer == null)
1867      this.performer = new ArrayList<MedicationDispensePerformerComponent>();
1868    this.performer.add(t);
1869    return this;
1870  }
1871
1872  /**
1873   * @return The first repetition of repeating field {@link #performer}, creating
1874   *         it if it does not already exist
1875   */
1876  public MedicationDispensePerformerComponent getPerformerFirstRep() {
1877    if (getPerformer().isEmpty()) {
1878      addPerformer();
1879    }
1880    return getPerformer().get(0);
1881  }
1882
1883  /**
1884   * @return {@link #location} (The principal physical location where the dispense
1885   *         was performed.)
1886   */
1887  public Reference getLocation() {
1888    if (this.location == null)
1889      if (Configuration.errorOnAutoCreate())
1890        throw new Error("Attempt to auto-create MedicationDispense.location");
1891      else if (Configuration.doAutoCreate())
1892        this.location = new Reference(); // cc
1893    return this.location;
1894  }
1895
1896  public boolean hasLocation() {
1897    return this.location != null && !this.location.isEmpty();
1898  }
1899
1900  /**
1901   * @param value {@link #location} (The principal physical location where the
1902   *              dispense was performed.)
1903   */
1904  public MedicationDispense setLocation(Reference value) {
1905    this.location = value;
1906    return this;
1907  }
1908
1909  /**
1910   * @return {@link #location} The actual object that is the target of the
1911   *         reference. The reference library doesn't populate this, but you can
1912   *         use it to hold the resource if you resolve it. (The principal
1913   *         physical location where the dispense was performed.)
1914   */
1915  public Location getLocationTarget() {
1916    if (this.locationTarget == null)
1917      if (Configuration.errorOnAutoCreate())
1918        throw new Error("Attempt to auto-create MedicationDispense.location");
1919      else if (Configuration.doAutoCreate())
1920        this.locationTarget = new Location(); // aa
1921    return this.locationTarget;
1922  }
1923
1924  /**
1925   * @param value {@link #location} The actual object that is the target of the
1926   *              reference. The reference library doesn't use these, but you can
1927   *              use it to hold the resource if you resolve it. (The principal
1928   *              physical location where the dispense was performed.)
1929   */
1930  public MedicationDispense setLocationTarget(Location value) {
1931    this.locationTarget = value;
1932    return this;
1933  }
1934
1935  /**
1936   * @return {@link #authorizingPrescription} (Indicates the medication order that
1937   *         is being dispensed against.)
1938   */
1939  public List<Reference> getAuthorizingPrescription() {
1940    if (this.authorizingPrescription == null)
1941      this.authorizingPrescription = new ArrayList<Reference>();
1942    return this.authorizingPrescription;
1943  }
1944
1945  /**
1946   * @return Returns a reference to <code>this</code> for easy method chaining
1947   */
1948  public MedicationDispense setAuthorizingPrescription(List<Reference> theAuthorizingPrescription) {
1949    this.authorizingPrescription = theAuthorizingPrescription;
1950    return this;
1951  }
1952
1953  public boolean hasAuthorizingPrescription() {
1954    if (this.authorizingPrescription == null)
1955      return false;
1956    for (Reference item : this.authorizingPrescription)
1957      if (!item.isEmpty())
1958        return true;
1959    return false;
1960  }
1961
1962  public Reference addAuthorizingPrescription() { // 3
1963    Reference t = new Reference();
1964    if (this.authorizingPrescription == null)
1965      this.authorizingPrescription = new ArrayList<Reference>();
1966    this.authorizingPrescription.add(t);
1967    return t;
1968  }
1969
1970  public MedicationDispense addAuthorizingPrescription(Reference t) { // 3
1971    if (t == null)
1972      return this;
1973    if (this.authorizingPrescription == null)
1974      this.authorizingPrescription = new ArrayList<Reference>();
1975    this.authorizingPrescription.add(t);
1976    return this;
1977  }
1978
1979  /**
1980   * @return The first repetition of repeating field
1981   *         {@link #authorizingPrescription}, creating it if it does not already
1982   *         exist
1983   */
1984  public Reference getAuthorizingPrescriptionFirstRep() {
1985    if (getAuthorizingPrescription().isEmpty()) {
1986      addAuthorizingPrescription();
1987    }
1988    return getAuthorizingPrescription().get(0);
1989  }
1990
1991  /**
1992   * @return {@link #type} (Indicates the type of dispensing event that is
1993   *         performed. For example, Trial Fill, Completion of Trial, Partial
1994   *         Fill, Emergency Fill, Samples, etc.)
1995   */
1996  public CodeableConcept getType() {
1997    if (this.type == null)
1998      if (Configuration.errorOnAutoCreate())
1999        throw new Error("Attempt to auto-create MedicationDispense.type");
2000      else if (Configuration.doAutoCreate())
2001        this.type = new CodeableConcept(); // cc
2002    return this.type;
2003  }
2004
2005  public boolean hasType() {
2006    return this.type != null && !this.type.isEmpty();
2007  }
2008
2009  /**
2010   * @param value {@link #type} (Indicates the type of dispensing event that is
2011   *              performed. For example, Trial Fill, Completion of Trial, Partial
2012   *              Fill, Emergency Fill, Samples, etc.)
2013   */
2014  public MedicationDispense setType(CodeableConcept value) {
2015    this.type = value;
2016    return this;
2017  }
2018
2019  /**
2020   * @return {@link #quantity} (The amount of medication that has been dispensed.
2021   *         Includes unit of measure.)
2022   */
2023  public Quantity getQuantity() {
2024    if (this.quantity == null)
2025      if (Configuration.errorOnAutoCreate())
2026        throw new Error("Attempt to auto-create MedicationDispense.quantity");
2027      else if (Configuration.doAutoCreate())
2028        this.quantity = new Quantity(); // cc
2029    return this.quantity;
2030  }
2031
2032  public boolean hasQuantity() {
2033    return this.quantity != null && !this.quantity.isEmpty();
2034  }
2035
2036  /**
2037   * @param value {@link #quantity} (The amount of medication that has been
2038   *              dispensed. Includes unit of measure.)
2039   */
2040  public MedicationDispense setQuantity(Quantity value) {
2041    this.quantity = value;
2042    return this;
2043  }
2044
2045  /**
2046   * @return {@link #daysSupply} (The amount of medication expressed as a timing
2047   *         amount.)
2048   */
2049  public Quantity getDaysSupply() {
2050    if (this.daysSupply == null)
2051      if (Configuration.errorOnAutoCreate())
2052        throw new Error("Attempt to auto-create MedicationDispense.daysSupply");
2053      else if (Configuration.doAutoCreate())
2054        this.daysSupply = new Quantity(); // cc
2055    return this.daysSupply;
2056  }
2057
2058  public boolean hasDaysSupply() {
2059    return this.daysSupply != null && !this.daysSupply.isEmpty();
2060  }
2061
2062  /**
2063   * @param value {@link #daysSupply} (The amount of medication expressed as a
2064   *              timing amount.)
2065   */
2066  public MedicationDispense setDaysSupply(Quantity value) {
2067    this.daysSupply = value;
2068    return this;
2069  }
2070
2071  /**
2072   * @return {@link #whenPrepared} (The time when the dispensed product was
2073   *         packaged and reviewed.). This is the underlying object with id, value
2074   *         and extensions. The accessor "getWhenPrepared" gives direct access to
2075   *         the value
2076   */
2077  public DateTimeType getWhenPreparedElement() {
2078    if (this.whenPrepared == null)
2079      if (Configuration.errorOnAutoCreate())
2080        throw new Error("Attempt to auto-create MedicationDispense.whenPrepared");
2081      else if (Configuration.doAutoCreate())
2082        this.whenPrepared = new DateTimeType(); // bb
2083    return this.whenPrepared;
2084  }
2085
2086  public boolean hasWhenPreparedElement() {
2087    return this.whenPrepared != null && !this.whenPrepared.isEmpty();
2088  }
2089
2090  public boolean hasWhenPrepared() {
2091    return this.whenPrepared != null && !this.whenPrepared.isEmpty();
2092  }
2093
2094  /**
2095   * @param value {@link #whenPrepared} (The time when the dispensed product was
2096   *              packaged and reviewed.). This is the underlying object with id,
2097   *              value and extensions. The accessor "getWhenPrepared" gives
2098   *              direct access to the value
2099   */
2100  public MedicationDispense setWhenPreparedElement(DateTimeType value) {
2101    this.whenPrepared = value;
2102    return this;
2103  }
2104
2105  /**
2106   * @return The time when the dispensed product was packaged and reviewed.
2107   */
2108  public Date getWhenPrepared() {
2109    return this.whenPrepared == null ? null : this.whenPrepared.getValue();
2110  }
2111
2112  /**
2113   * @param value The time when the dispensed product was packaged and reviewed.
2114   */
2115  public MedicationDispense setWhenPrepared(Date value) {
2116    if (value == null)
2117      this.whenPrepared = null;
2118    else {
2119      if (this.whenPrepared == null)
2120        this.whenPrepared = new DateTimeType();
2121      this.whenPrepared.setValue(value);
2122    }
2123    return this;
2124  }
2125
2126  /**
2127   * @return {@link #whenHandedOver} (The time the dispensed product was provided
2128   *         to the patient or their representative.). This is the underlying
2129   *         object with id, value and extensions. The accessor
2130   *         "getWhenHandedOver" gives direct access to the value
2131   */
2132  public DateTimeType getWhenHandedOverElement() {
2133    if (this.whenHandedOver == null)
2134      if (Configuration.errorOnAutoCreate())
2135        throw new Error("Attempt to auto-create MedicationDispense.whenHandedOver");
2136      else if (Configuration.doAutoCreate())
2137        this.whenHandedOver = new DateTimeType(); // bb
2138    return this.whenHandedOver;
2139  }
2140
2141  public boolean hasWhenHandedOverElement() {
2142    return this.whenHandedOver != null && !this.whenHandedOver.isEmpty();
2143  }
2144
2145  public boolean hasWhenHandedOver() {
2146    return this.whenHandedOver != null && !this.whenHandedOver.isEmpty();
2147  }
2148
2149  /**
2150   * @param value {@link #whenHandedOver} (The time the dispensed product was
2151   *              provided to the patient or their representative.). This is the
2152   *              underlying object with id, value and extensions. The accessor
2153   *              "getWhenHandedOver" gives direct access to the value
2154   */
2155  public MedicationDispense setWhenHandedOverElement(DateTimeType value) {
2156    this.whenHandedOver = value;
2157    return this;
2158  }
2159
2160  /**
2161   * @return The time the dispensed product was provided to the patient or their
2162   *         representative.
2163   */
2164  public Date getWhenHandedOver() {
2165    return this.whenHandedOver == null ? null : this.whenHandedOver.getValue();
2166  }
2167
2168  /**
2169   * @param value The time the dispensed product was provided to the patient or
2170   *              their representative.
2171   */
2172  public MedicationDispense setWhenHandedOver(Date value) {
2173    if (value == null)
2174      this.whenHandedOver = null;
2175    else {
2176      if (this.whenHandedOver == null)
2177        this.whenHandedOver = new DateTimeType();
2178      this.whenHandedOver.setValue(value);
2179    }
2180    return this;
2181  }
2182
2183  /**
2184   * @return {@link #destination} (Identification of the facility/location where
2185   *         the medication was shipped to, as part of the dispense event.)
2186   */
2187  public Reference getDestination() {
2188    if (this.destination == null)
2189      if (Configuration.errorOnAutoCreate())
2190        throw new Error("Attempt to auto-create MedicationDispense.destination");
2191      else if (Configuration.doAutoCreate())
2192        this.destination = new Reference(); // cc
2193    return this.destination;
2194  }
2195
2196  public boolean hasDestination() {
2197    return this.destination != null && !this.destination.isEmpty();
2198  }
2199
2200  /**
2201   * @param value {@link #destination} (Identification of the facility/location
2202   *              where the medication was shipped to, as part of the dispense
2203   *              event.)
2204   */
2205  public MedicationDispense setDestination(Reference value) {
2206    this.destination = value;
2207    return this;
2208  }
2209
2210  /**
2211   * @return {@link #destination} The actual object that is the target of the
2212   *         reference. The reference library doesn't populate this, but you can
2213   *         use it to hold the resource if you resolve it. (Identification of the
2214   *         facility/location where the medication was shipped to, as part of the
2215   *         dispense event.)
2216   */
2217  public Location getDestinationTarget() {
2218    if (this.destinationTarget == null)
2219      if (Configuration.errorOnAutoCreate())
2220        throw new Error("Attempt to auto-create MedicationDispense.destination");
2221      else if (Configuration.doAutoCreate())
2222        this.destinationTarget = new Location(); // aa
2223    return this.destinationTarget;
2224  }
2225
2226  /**
2227   * @param value {@link #destination} The actual object that is the target of the
2228   *              reference. The reference library doesn't use these, but you can
2229   *              use it to hold the resource if you resolve it. (Identification
2230   *              of the facility/location where the medication was shipped to, as
2231   *              part of the dispense event.)
2232   */
2233  public MedicationDispense setDestinationTarget(Location value) {
2234    this.destinationTarget = value;
2235    return this;
2236  }
2237
2238  /**
2239   * @return {@link #receiver} (Identifies the person who picked up the
2240   *         medication. This will usually be a patient or their caregiver, but
2241   *         some cases exist where it can be a healthcare professional.)
2242   */
2243  public List<Reference> getReceiver() {
2244    if (this.receiver == null)
2245      this.receiver = new ArrayList<Reference>();
2246    return this.receiver;
2247  }
2248
2249  /**
2250   * @return Returns a reference to <code>this</code> for easy method chaining
2251   */
2252  public MedicationDispense setReceiver(List<Reference> theReceiver) {
2253    this.receiver = theReceiver;
2254    return this;
2255  }
2256
2257  public boolean hasReceiver() {
2258    if (this.receiver == null)
2259      return false;
2260    for (Reference item : this.receiver)
2261      if (!item.isEmpty())
2262        return true;
2263    return false;
2264  }
2265
2266  public Reference addReceiver() { // 3
2267    Reference t = new Reference();
2268    if (this.receiver == null)
2269      this.receiver = new ArrayList<Reference>();
2270    this.receiver.add(t);
2271    return t;
2272  }
2273
2274  public MedicationDispense addReceiver(Reference t) { // 3
2275    if (t == null)
2276      return this;
2277    if (this.receiver == null)
2278      this.receiver = new ArrayList<Reference>();
2279    this.receiver.add(t);
2280    return this;
2281  }
2282
2283  /**
2284   * @return The first repetition of repeating field {@link #receiver}, creating
2285   *         it if it does not already exist
2286   */
2287  public Reference getReceiverFirstRep() {
2288    if (getReceiver().isEmpty()) {
2289      addReceiver();
2290    }
2291    return getReceiver().get(0);
2292  }
2293
2294  /**
2295   * @return {@link #note} (Extra information about the dispense that could not be
2296   *         conveyed in the other attributes.)
2297   */
2298  public List<Annotation> getNote() {
2299    if (this.note == null)
2300      this.note = new ArrayList<Annotation>();
2301    return this.note;
2302  }
2303
2304  /**
2305   * @return Returns a reference to <code>this</code> for easy method chaining
2306   */
2307  public MedicationDispense setNote(List<Annotation> theNote) {
2308    this.note = theNote;
2309    return this;
2310  }
2311
2312  public boolean hasNote() {
2313    if (this.note == null)
2314      return false;
2315    for (Annotation item : this.note)
2316      if (!item.isEmpty())
2317        return true;
2318    return false;
2319  }
2320
2321  public Annotation addNote() { // 3
2322    Annotation t = new Annotation();
2323    if (this.note == null)
2324      this.note = new ArrayList<Annotation>();
2325    this.note.add(t);
2326    return t;
2327  }
2328
2329  public MedicationDispense addNote(Annotation t) { // 3
2330    if (t == null)
2331      return this;
2332    if (this.note == null)
2333      this.note = new ArrayList<Annotation>();
2334    this.note.add(t);
2335    return this;
2336  }
2337
2338  /**
2339   * @return The first repetition of repeating field {@link #note}, creating it if
2340   *         it does not already exist
2341   */
2342  public Annotation getNoteFirstRep() {
2343    if (getNote().isEmpty()) {
2344      addNote();
2345    }
2346    return getNote().get(0);
2347  }
2348
2349  /**
2350   * @return {@link #dosageInstruction} (Indicates how the medication is to be
2351   *         used by the patient.)
2352   */
2353  public List<Dosage> getDosageInstruction() {
2354    if (this.dosageInstruction == null)
2355      this.dosageInstruction = new ArrayList<Dosage>();
2356    return this.dosageInstruction;
2357  }
2358
2359  /**
2360   * @return Returns a reference to <code>this</code> for easy method chaining
2361   */
2362  public MedicationDispense setDosageInstruction(List<Dosage> theDosageInstruction) {
2363    this.dosageInstruction = theDosageInstruction;
2364    return this;
2365  }
2366
2367  public boolean hasDosageInstruction() {
2368    if (this.dosageInstruction == null)
2369      return false;
2370    for (Dosage item : this.dosageInstruction)
2371      if (!item.isEmpty())
2372        return true;
2373    return false;
2374  }
2375
2376  public Dosage addDosageInstruction() { // 3
2377    Dosage t = new Dosage();
2378    if (this.dosageInstruction == null)
2379      this.dosageInstruction = new ArrayList<Dosage>();
2380    this.dosageInstruction.add(t);
2381    return t;
2382  }
2383
2384  public MedicationDispense addDosageInstruction(Dosage t) { // 3
2385    if (t == null)
2386      return this;
2387    if (this.dosageInstruction == null)
2388      this.dosageInstruction = new ArrayList<Dosage>();
2389    this.dosageInstruction.add(t);
2390    return this;
2391  }
2392
2393  /**
2394   * @return The first repetition of repeating field {@link #dosageInstruction},
2395   *         creating it if it does not already exist
2396   */
2397  public Dosage getDosageInstructionFirstRep() {
2398    if (getDosageInstruction().isEmpty()) {
2399      addDosageInstruction();
2400    }
2401    return getDosageInstruction().get(0);
2402  }
2403
2404  /**
2405   * @return {@link #substitution} (Indicates whether or not substitution was made
2406   *         as part of the dispense. In some cases, substitution will be expected
2407   *         but does not happen, in other cases substitution is not expected but
2408   *         does happen. This block explains what substitution did or did not
2409   *         happen and why. If nothing is specified, substitution was not done.)
2410   */
2411  public MedicationDispenseSubstitutionComponent getSubstitution() {
2412    if (this.substitution == null)
2413      if (Configuration.errorOnAutoCreate())
2414        throw new Error("Attempt to auto-create MedicationDispense.substitution");
2415      else if (Configuration.doAutoCreate())
2416        this.substitution = new MedicationDispenseSubstitutionComponent(); // cc
2417    return this.substitution;
2418  }
2419
2420  public boolean hasSubstitution() {
2421    return this.substitution != null && !this.substitution.isEmpty();
2422  }
2423
2424  /**
2425   * @param value {@link #substitution} (Indicates whether or not substitution was
2426   *              made as part of the dispense. In some cases, substitution will
2427   *              be expected but does not happen, in other cases substitution is
2428   *              not expected but does happen. This block explains what
2429   *              substitution did or did not happen and why. If nothing is
2430   *              specified, substitution was not done.)
2431   */
2432  public MedicationDispense setSubstitution(MedicationDispenseSubstitutionComponent value) {
2433    this.substitution = value;
2434    return this;
2435  }
2436
2437  /**
2438   * @return {@link #detectedIssue} (Indicates an actual or potential clinical
2439   *         issue with or between one or more active or proposed clinical actions
2440   *         for a patient; e.g. drug-drug interaction, duplicate therapy, dosage
2441   *         alert etc.)
2442   */
2443  public List<Reference> getDetectedIssue() {
2444    if (this.detectedIssue == null)
2445      this.detectedIssue = new ArrayList<Reference>();
2446    return this.detectedIssue;
2447  }
2448
2449  /**
2450   * @return Returns a reference to <code>this</code> for easy method chaining
2451   */
2452  public MedicationDispense setDetectedIssue(List<Reference> theDetectedIssue) {
2453    this.detectedIssue = theDetectedIssue;
2454    return this;
2455  }
2456
2457  public boolean hasDetectedIssue() {
2458    if (this.detectedIssue == null)
2459      return false;
2460    for (Reference item : this.detectedIssue)
2461      if (!item.isEmpty())
2462        return true;
2463    return false;
2464  }
2465
2466  public Reference addDetectedIssue() { // 3
2467    Reference t = new Reference();
2468    if (this.detectedIssue == null)
2469      this.detectedIssue = new ArrayList<Reference>();
2470    this.detectedIssue.add(t);
2471    return t;
2472  }
2473
2474  public MedicationDispense addDetectedIssue(Reference t) { // 3
2475    if (t == null)
2476      return this;
2477    if (this.detectedIssue == null)
2478      this.detectedIssue = new ArrayList<Reference>();
2479    this.detectedIssue.add(t);
2480    return this;
2481  }
2482
2483  /**
2484   * @return The first repetition of repeating field {@link #detectedIssue},
2485   *         creating it if it does not already exist
2486   */
2487  public Reference getDetectedIssueFirstRep() {
2488    if (getDetectedIssue().isEmpty()) {
2489      addDetectedIssue();
2490    }
2491    return getDetectedIssue().get(0);
2492  }
2493
2494  /**
2495   * @return {@link #eventHistory} (A summary of the events of interest that have
2496   *         occurred, such as when the dispense was verified.)
2497   */
2498  public List<Reference> getEventHistory() {
2499    if (this.eventHistory == null)
2500      this.eventHistory = new ArrayList<Reference>();
2501    return this.eventHistory;
2502  }
2503
2504  /**
2505   * @return Returns a reference to <code>this</code> for easy method chaining
2506   */
2507  public MedicationDispense setEventHistory(List<Reference> theEventHistory) {
2508    this.eventHistory = theEventHistory;
2509    return this;
2510  }
2511
2512  public boolean hasEventHistory() {
2513    if (this.eventHistory == null)
2514      return false;
2515    for (Reference item : this.eventHistory)
2516      if (!item.isEmpty())
2517        return true;
2518    return false;
2519  }
2520
2521  public Reference addEventHistory() { // 3
2522    Reference t = new Reference();
2523    if (this.eventHistory == null)
2524      this.eventHistory = new ArrayList<Reference>();
2525    this.eventHistory.add(t);
2526    return t;
2527  }
2528
2529  public MedicationDispense addEventHistory(Reference t) { // 3
2530    if (t == null)
2531      return this;
2532    if (this.eventHistory == null)
2533      this.eventHistory = new ArrayList<Reference>();
2534    this.eventHistory.add(t);
2535    return this;
2536  }
2537
2538  /**
2539   * @return The first repetition of repeating field {@link #eventHistory},
2540   *         creating it if it does not already exist
2541   */
2542  public Reference getEventHistoryFirstRep() {
2543    if (getEventHistory().isEmpty()) {
2544      addEventHistory();
2545    }
2546    return getEventHistory().get(0);
2547  }
2548
2549  protected void listChildren(List<Property> children) {
2550    super.listChildren(children);
2551    children.add(new Property("identifier", "Identifier",
2552        "Identifiers associated with this Medication Dispense that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate. They are business identifiers assigned to this resource by the performer or other systems and remain constant as the resource is updated and propagates from server to server.",
2553        0, java.lang.Integer.MAX_VALUE, identifier));
2554    children.add(new Property("partOf", "Reference(Procedure)", "The procedure that trigger the dispense.", 0,
2555        java.lang.Integer.MAX_VALUE, partOf));
2556    children.add(
2557        new Property("status", "code", "A code specifying the state of the set of dispense events.", 0, 1, status));
2558    children.add(new Property("statusReason[x]", "CodeableConcept|Reference(DetectedIssue)",
2559        "Indicates the reason why a dispense was not performed.", 0, 1, statusReason));
2560    children.add(new Property("category", "CodeableConcept",
2561        "Indicates the type of medication dispense (for example, where the medication is expected to be consumed or administered (i.e. inpatient or outpatient)).",
2562        0, 1, category));
2563    children.add(new Property("medication[x]", "CodeableConcept|Reference(Medication)",
2564        "Identifies the medication being administered. This is either a link to a resource representing the details of the medication or a simple attribute carrying a code that identifies the medication from a known list of medications.",
2565        0, 1, medication));
2566    children.add(new Property("subject", "Reference(Patient|Group)",
2567        "A link to a resource representing the person or the group to whom the medication will be given.", 0, 1,
2568        subject));
2569    children.add(new Property("context", "Reference(Encounter|EpisodeOfCare)",
2570        "The encounter or episode of care that establishes the context for this event.", 0, 1, context));
2571    children.add(new Property("supportingInformation", "Reference(Any)",
2572        "Additional information that supports the medication being dispensed.", 0, java.lang.Integer.MAX_VALUE,
2573        supportingInformation));
2574    children.add(new Property("performer", "", "Indicates who or what performed the event.", 0,
2575        java.lang.Integer.MAX_VALUE, performer));
2576    children.add(new Property("location", "Reference(Location)",
2577        "The principal physical location where the dispense was performed.", 0, 1, location));
2578    children.add(new Property("authorizingPrescription", "Reference(MedicationRequest)",
2579        "Indicates the medication order that is being dispensed against.", 0, java.lang.Integer.MAX_VALUE,
2580        authorizingPrescription));
2581    children.add(new Property("type", "CodeableConcept",
2582        "Indicates the type of dispensing event that is performed. For example, Trial Fill, Completion of Trial, Partial Fill, Emergency Fill, Samples, etc.",
2583        0, 1, type));
2584    children.add(new Property("quantity", "SimpleQuantity",
2585        "The amount of medication that has been dispensed. Includes unit of measure.", 0, 1, quantity));
2586    children.add(new Property("daysSupply", "SimpleQuantity", "The amount of medication expressed as a timing amount.",
2587        0, 1, daysSupply));
2588    children.add(new Property("whenPrepared", "dateTime",
2589        "The time when the dispensed product was packaged and reviewed.", 0, 1, whenPrepared));
2590    children.add(new Property("whenHandedOver", "dateTime",
2591        "The time the dispensed product was provided to the patient or their representative.", 0, 1, whenHandedOver));
2592    children.add(new Property("destination", "Reference(Location)",
2593        "Identification of the facility/location where the medication was shipped to, as part of the dispense event.",
2594        0, 1, destination));
2595    children.add(new Property("receiver", "Reference(Patient|Practitioner)",
2596        "Identifies the person who picked up the medication.  This will usually be a patient or their caregiver, but some cases exist where it can be a healthcare professional.",
2597        0, java.lang.Integer.MAX_VALUE, receiver));
2598    children.add(new Property("note", "Annotation",
2599        "Extra information about the dispense that could not be conveyed in the other attributes.", 0,
2600        java.lang.Integer.MAX_VALUE, note));
2601    children
2602        .add(new Property("dosageInstruction", "Dosage", "Indicates how the medication is to be used by the patient.",
2603            0, java.lang.Integer.MAX_VALUE, dosageInstruction));
2604    children.add(new Property("substitution", "",
2605        "Indicates whether or not substitution was made as part of the dispense.  In some cases, substitution will be expected but does not happen, in other cases substitution is not expected but does happen.  This block explains what substitution did or did not happen and why.  If nothing is specified, substitution was not done.",
2606        0, 1, substitution));
2607    children.add(new Property("detectedIssue", "Reference(DetectedIssue)",
2608        "Indicates an actual or potential clinical issue with or between one or more active or proposed clinical actions for a patient; e.g. drug-drug interaction, duplicate therapy, dosage alert etc.",
2609        0, java.lang.Integer.MAX_VALUE, detectedIssue));
2610    children.add(new Property("eventHistory", "Reference(Provenance)",
2611        "A summary of the events of interest that have occurred, such as when the dispense was verified.", 0,
2612        java.lang.Integer.MAX_VALUE, eventHistory));
2613  }
2614
2615  @Override
2616  public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2617    switch (_hash) {
2618    case -1618432855:
2619      /* identifier */ return new Property("identifier", "Identifier",
2620          "Identifiers associated with this Medication Dispense that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate. They are business identifiers assigned to this resource by the performer or other systems and remain constant as the resource is updated and propagates from server to server.",
2621          0, java.lang.Integer.MAX_VALUE, identifier);
2622    case -995410646:
2623      /* partOf */ return new Property("partOf", "Reference(Procedure)", "The procedure that trigger the dispense.", 0,
2624          java.lang.Integer.MAX_VALUE, partOf);
2625    case -892481550:
2626      /* status */ return new Property("status", "code", "A code specifying the state of the set of dispense events.",
2627          0, 1, status);
2628    case -1421632534:
2629      /* statusReason[x] */ return new Property("statusReason[x]", "CodeableConcept|Reference(DetectedIssue)",
2630          "Indicates the reason why a dispense was not performed.", 0, 1, statusReason);
2631    case 2051346646:
2632      /* statusReason */ return new Property("statusReason[x]", "CodeableConcept|Reference(DetectedIssue)",
2633          "Indicates the reason why a dispense was not performed.", 0, 1, statusReason);
2634    case 2082934763:
2635      /* statusReasonCodeableConcept */ return new Property("statusReason[x]",
2636          "CodeableConcept|Reference(DetectedIssue)", "Indicates the reason why a dispense was not performed.", 0, 1,
2637          statusReason);
2638    case 1344200469:
2639      /* statusReasonReference */ return new Property("statusReason[x]", "CodeableConcept|Reference(DetectedIssue)",
2640          "Indicates the reason why a dispense was not performed.", 0, 1, statusReason);
2641    case 50511102:
2642      /* category */ return new Property("category", "CodeableConcept",
2643          "Indicates the type of medication dispense (for example, where the medication is expected to be consumed or administered (i.e. inpatient or outpatient)).",
2644          0, 1, category);
2645    case 1458402129:
2646      /* medication[x] */ return new Property("medication[x]", "CodeableConcept|Reference(Medication)",
2647          "Identifies the medication being administered. This is either a link to a resource representing the details of the medication or a simple attribute carrying a code that identifies the medication from a known list of medications.",
2648          0, 1, medication);
2649    case 1998965455:
2650      /* medication */ return new Property("medication[x]", "CodeableConcept|Reference(Medication)",
2651          "Identifies the medication being administered. This is either a link to a resource representing the details of the medication or a simple attribute carrying a code that identifies the medication from a known list of medications.",
2652          0, 1, medication);
2653    case -209845038:
2654      /* medicationCodeableConcept */ return new Property("medication[x]", "CodeableConcept|Reference(Medication)",
2655          "Identifies the medication being administered. This is either a link to a resource representing the details of the medication or a simple attribute carrying a code that identifies the medication from a known list of medications.",
2656          0, 1, medication);
2657    case 2104315196:
2658      /* medicationReference */ return new Property("medication[x]", "CodeableConcept|Reference(Medication)",
2659          "Identifies the medication being administered. This is either a link to a resource representing the details of the medication or a simple attribute carrying a code that identifies the medication from a known list of medications.",
2660          0, 1, medication);
2661    case -1867885268:
2662      /* subject */ return new Property("subject", "Reference(Patient|Group)",
2663          "A link to a resource representing the person or the group to whom the medication will be given.", 0, 1,
2664          subject);
2665    case 951530927:
2666      /* context */ return new Property("context", "Reference(Encounter|EpisodeOfCare)",
2667          "The encounter or episode of care that establishes the context for this event.", 0, 1, context);
2668    case -1248768647:
2669      /* supportingInformation */ return new Property("supportingInformation", "Reference(Any)",
2670          "Additional information that supports the medication being dispensed.", 0, java.lang.Integer.MAX_VALUE,
2671          supportingInformation);
2672    case 481140686:
2673      /* performer */ return new Property("performer", "", "Indicates who or what performed the event.", 0,
2674          java.lang.Integer.MAX_VALUE, performer);
2675    case 1901043637:
2676      /* location */ return new Property("location", "Reference(Location)",
2677          "The principal physical location where the dispense was performed.", 0, 1, location);
2678    case -1237557856:
2679      /* authorizingPrescription */ return new Property("authorizingPrescription", "Reference(MedicationRequest)",
2680          "Indicates the medication order that is being dispensed against.", 0, java.lang.Integer.MAX_VALUE,
2681          authorizingPrescription);
2682    case 3575610:
2683      /* type */ return new Property("type", "CodeableConcept",
2684          "Indicates the type of dispensing event that is performed. For example, Trial Fill, Completion of Trial, Partial Fill, Emergency Fill, Samples, etc.",
2685          0, 1, type);
2686    case -1285004149:
2687      /* quantity */ return new Property("quantity", "SimpleQuantity",
2688          "The amount of medication that has been dispensed. Includes unit of measure.", 0, 1, quantity);
2689    case 197175334:
2690      /* daysSupply */ return new Property("daysSupply", "SimpleQuantity",
2691          "The amount of medication expressed as a timing amount.", 0, 1, daysSupply);
2692    case -562837097:
2693      /* whenPrepared */ return new Property("whenPrepared", "dateTime",
2694          "The time when the dispensed product was packaged and reviewed.", 0, 1, whenPrepared);
2695    case -940241380:
2696      /* whenHandedOver */ return new Property("whenHandedOver", "dateTime",
2697          "The time the dispensed product was provided to the patient or their representative.", 0, 1, whenHandedOver);
2698    case -1429847026:
2699      /* destination */ return new Property("destination", "Reference(Location)",
2700          "Identification of the facility/location where the medication was shipped to, as part of the dispense event.",
2701          0, 1, destination);
2702    case -808719889:
2703      /* receiver */ return new Property("receiver", "Reference(Patient|Practitioner)",
2704          "Identifies the person who picked up the medication.  This will usually be a patient or their caregiver, but some cases exist where it can be a healthcare professional.",
2705          0, java.lang.Integer.MAX_VALUE, receiver);
2706    case 3387378:
2707      /* note */ return new Property("note", "Annotation",
2708          "Extra information about the dispense that could not be conveyed in the other attributes.", 0,
2709          java.lang.Integer.MAX_VALUE, note);
2710    case -1201373865:
2711      /* dosageInstruction */ return new Property("dosageInstruction", "Dosage",
2712          "Indicates how the medication is to be used by the patient.", 0, java.lang.Integer.MAX_VALUE,
2713          dosageInstruction);
2714    case 826147581:
2715      /* substitution */ return new Property("substitution", "",
2716          "Indicates whether or not substitution was made as part of the dispense.  In some cases, substitution will be expected but does not happen, in other cases substitution is not expected but does happen.  This block explains what substitution did or did not happen and why.  If nothing is specified, substitution was not done.",
2717          0, 1, substitution);
2718    case 51602295:
2719      /* detectedIssue */ return new Property("detectedIssue", "Reference(DetectedIssue)",
2720          "Indicates an actual or potential clinical issue with or between one or more active or proposed clinical actions for a patient; e.g. drug-drug interaction, duplicate therapy, dosage alert etc.",
2721          0, java.lang.Integer.MAX_VALUE, detectedIssue);
2722    case 1835190426:
2723      /* eventHistory */ return new Property("eventHistory", "Reference(Provenance)",
2724          "A summary of the events of interest that have occurred, such as when the dispense was verified.", 0,
2725          java.lang.Integer.MAX_VALUE, eventHistory);
2726    default:
2727      return super.getNamedProperty(_hash, _name, _checkValid);
2728    }
2729
2730  }
2731
2732  @Override
2733  public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2734    switch (hash) {
2735    case -1618432855:
2736      /* identifier */ return this.identifier == null ? new Base[0]
2737          : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
2738    case -995410646:
2739      /* partOf */ return this.partOf == null ? new Base[0] : this.partOf.toArray(new Base[this.partOf.size()]); // Reference
2740    case -892481550:
2741      /* status */ return this.status == null ? new Base[0] : new Base[] { this.status }; // Enumeration<MedicationDispenseStatus>
2742    case 2051346646:
2743      /* statusReason */ return this.statusReason == null ? new Base[0] : new Base[] { this.statusReason }; // Type
2744    case 50511102:
2745      /* category */ return this.category == null ? new Base[0] : new Base[] { this.category }; // CodeableConcept
2746    case 1998965455:
2747      /* medication */ return this.medication == null ? new Base[0] : new Base[] { this.medication }; // Type
2748    case -1867885268:
2749      /* subject */ return this.subject == null ? new Base[0] : new Base[] { this.subject }; // Reference
2750    case 951530927:
2751      /* context */ return this.context == null ? new Base[0] : new Base[] { this.context }; // Reference
2752    case -1248768647:
2753      /* supportingInformation */ return this.supportingInformation == null ? new Base[0]
2754          : this.supportingInformation.toArray(new Base[this.supportingInformation.size()]); // Reference
2755    case 481140686:
2756      /* performer */ return this.performer == null ? new Base[0]
2757          : this.performer.toArray(new Base[this.performer.size()]); // MedicationDispensePerformerComponent
2758    case 1901043637:
2759      /* location */ return this.location == null ? new Base[0] : new Base[] { this.location }; // Reference
2760    case -1237557856:
2761      /* authorizingPrescription */ return this.authorizingPrescription == null ? new Base[0]
2762          : this.authorizingPrescription.toArray(new Base[this.authorizingPrescription.size()]); // Reference
2763    case 3575610:
2764      /* type */ return this.type == null ? new Base[0] : new Base[] { this.type }; // CodeableConcept
2765    case -1285004149:
2766      /* quantity */ return this.quantity == null ? new Base[0] : new Base[] { this.quantity }; // Quantity
2767    case 197175334:
2768      /* daysSupply */ return this.daysSupply == null ? new Base[0] : new Base[] { this.daysSupply }; // Quantity
2769    case -562837097:
2770      /* whenPrepared */ return this.whenPrepared == null ? new Base[0] : new Base[] { this.whenPrepared }; // DateTimeType
2771    case -940241380:
2772      /* whenHandedOver */ return this.whenHandedOver == null ? new Base[0] : new Base[] { this.whenHandedOver }; // DateTimeType
2773    case -1429847026:
2774      /* destination */ return this.destination == null ? new Base[0] : new Base[] { this.destination }; // Reference
2775    case -808719889:
2776      /* receiver */ return this.receiver == null ? new Base[0] : this.receiver.toArray(new Base[this.receiver.size()]); // Reference
2777    case 3387378:
2778      /* note */ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
2779    case -1201373865:
2780      /* dosageInstruction */ return this.dosageInstruction == null ? new Base[0]
2781          : this.dosageInstruction.toArray(new Base[this.dosageInstruction.size()]); // Dosage
2782    case 826147581:
2783      /* substitution */ return this.substitution == null ? new Base[0] : new Base[] { this.substitution }; // MedicationDispenseSubstitutionComponent
2784    case 51602295:
2785      /* detectedIssue */ return this.detectedIssue == null ? new Base[0]
2786          : this.detectedIssue.toArray(new Base[this.detectedIssue.size()]); // Reference
2787    case 1835190426:
2788      /* eventHistory */ return this.eventHistory == null ? new Base[0]
2789          : this.eventHistory.toArray(new Base[this.eventHistory.size()]); // Reference
2790    default:
2791      return super.getProperty(hash, name, checkValid);
2792    }
2793
2794  }
2795
2796  @Override
2797  public Base setProperty(int hash, String name, Base value) throws FHIRException {
2798    switch (hash) {
2799    case -1618432855: // identifier
2800      this.getIdentifier().add(castToIdentifier(value)); // Identifier
2801      return value;
2802    case -995410646: // partOf
2803      this.getPartOf().add(castToReference(value)); // Reference
2804      return value;
2805    case -892481550: // status
2806      value = new MedicationDispenseStatusEnumFactory().fromType(castToCode(value));
2807      this.status = (Enumeration) value; // Enumeration<MedicationDispenseStatus>
2808      return value;
2809    case 2051346646: // statusReason
2810      this.statusReason = castToType(value); // Type
2811      return value;
2812    case 50511102: // category
2813      this.category = castToCodeableConcept(value); // CodeableConcept
2814      return value;
2815    case 1998965455: // medication
2816      this.medication = castToType(value); // Type
2817      return value;
2818    case -1867885268: // subject
2819      this.subject = castToReference(value); // Reference
2820      return value;
2821    case 951530927: // context
2822      this.context = castToReference(value); // Reference
2823      return value;
2824    case -1248768647: // supportingInformation
2825      this.getSupportingInformation().add(castToReference(value)); // Reference
2826      return value;
2827    case 481140686: // performer
2828      this.getPerformer().add((MedicationDispensePerformerComponent) value); // MedicationDispensePerformerComponent
2829      return value;
2830    case 1901043637: // location
2831      this.location = castToReference(value); // Reference
2832      return value;
2833    case -1237557856: // authorizingPrescription
2834      this.getAuthorizingPrescription().add(castToReference(value)); // Reference
2835      return value;
2836    case 3575610: // type
2837      this.type = castToCodeableConcept(value); // CodeableConcept
2838      return value;
2839    case -1285004149: // quantity
2840      this.quantity = castToQuantity(value); // Quantity
2841      return value;
2842    case 197175334: // daysSupply
2843      this.daysSupply = castToQuantity(value); // Quantity
2844      return value;
2845    case -562837097: // whenPrepared
2846      this.whenPrepared = castToDateTime(value); // DateTimeType
2847      return value;
2848    case -940241380: // whenHandedOver
2849      this.whenHandedOver = castToDateTime(value); // DateTimeType
2850      return value;
2851    case -1429847026: // destination
2852      this.destination = castToReference(value); // Reference
2853      return value;
2854    case -808719889: // receiver
2855      this.getReceiver().add(castToReference(value)); // Reference
2856      return value;
2857    case 3387378: // note
2858      this.getNote().add(castToAnnotation(value)); // Annotation
2859      return value;
2860    case -1201373865: // dosageInstruction
2861      this.getDosageInstruction().add(castToDosage(value)); // Dosage
2862      return value;
2863    case 826147581: // substitution
2864      this.substitution = (MedicationDispenseSubstitutionComponent) value; // MedicationDispenseSubstitutionComponent
2865      return value;
2866    case 51602295: // detectedIssue
2867      this.getDetectedIssue().add(castToReference(value)); // Reference
2868      return value;
2869    case 1835190426: // eventHistory
2870      this.getEventHistory().add(castToReference(value)); // Reference
2871      return value;
2872    default:
2873      return super.setProperty(hash, name, value);
2874    }
2875
2876  }
2877
2878  @Override
2879  public Base setProperty(String name, Base value) throws FHIRException {
2880    if (name.equals("identifier")) {
2881      this.getIdentifier().add(castToIdentifier(value));
2882    } else if (name.equals("partOf")) {
2883      this.getPartOf().add(castToReference(value));
2884    } else if (name.equals("status")) {
2885      value = new MedicationDispenseStatusEnumFactory().fromType(castToCode(value));
2886      this.status = (Enumeration) value; // Enumeration<MedicationDispenseStatus>
2887    } else if (name.equals("statusReason[x]")) {
2888      this.statusReason = castToType(value); // Type
2889    } else if (name.equals("category")) {
2890      this.category = castToCodeableConcept(value); // CodeableConcept
2891    } else if (name.equals("medication[x]")) {
2892      this.medication = castToType(value); // Type
2893    } else if (name.equals("subject")) {
2894      this.subject = castToReference(value); // Reference
2895    } else if (name.equals("context")) {
2896      this.context = castToReference(value); // Reference
2897    } else if (name.equals("supportingInformation")) {
2898      this.getSupportingInformation().add(castToReference(value));
2899    } else if (name.equals("performer")) {
2900      this.getPerformer().add((MedicationDispensePerformerComponent) value);
2901    } else if (name.equals("location")) {
2902      this.location = castToReference(value); // Reference
2903    } else if (name.equals("authorizingPrescription")) {
2904      this.getAuthorizingPrescription().add(castToReference(value));
2905    } else if (name.equals("type")) {
2906      this.type = castToCodeableConcept(value); // CodeableConcept
2907    } else if (name.equals("quantity")) {
2908      this.quantity = castToQuantity(value); // Quantity
2909    } else if (name.equals("daysSupply")) {
2910      this.daysSupply = castToQuantity(value); // Quantity
2911    } else if (name.equals("whenPrepared")) {
2912      this.whenPrepared = castToDateTime(value); // DateTimeType
2913    } else if (name.equals("whenHandedOver")) {
2914      this.whenHandedOver = castToDateTime(value); // DateTimeType
2915    } else if (name.equals("destination")) {
2916      this.destination = castToReference(value); // Reference
2917    } else if (name.equals("receiver")) {
2918      this.getReceiver().add(castToReference(value));
2919    } else if (name.equals("note")) {
2920      this.getNote().add(castToAnnotation(value));
2921    } else if (name.equals("dosageInstruction")) {
2922      this.getDosageInstruction().add(castToDosage(value));
2923    } else if (name.equals("substitution")) {
2924      this.substitution = (MedicationDispenseSubstitutionComponent) value; // MedicationDispenseSubstitutionComponent
2925    } else if (name.equals("detectedIssue")) {
2926      this.getDetectedIssue().add(castToReference(value));
2927    } else if (name.equals("eventHistory")) {
2928      this.getEventHistory().add(castToReference(value));
2929    } else
2930      return super.setProperty(name, value);
2931    return value;
2932  }
2933
2934  @Override
2935  public void removeChild(String name, Base value) throws FHIRException {
2936    if (name.equals("identifier")) {
2937      this.getIdentifier().remove(castToIdentifier(value));
2938    } else if (name.equals("partOf")) {
2939      this.getPartOf().remove(castToReference(value));
2940    } else if (name.equals("status")) {
2941      this.status = null;
2942    } else if (name.equals("statusReason[x]")) {
2943      this.statusReason = null;
2944    } else if (name.equals("category")) {
2945      this.category = null;
2946    } else if (name.equals("medication[x]")) {
2947      this.medication = null;
2948    } else if (name.equals("subject")) {
2949      this.subject = null;
2950    } else if (name.equals("context")) {
2951      this.context = null;
2952    } else if (name.equals("supportingInformation")) {
2953      this.getSupportingInformation().remove(castToReference(value));
2954    } else if (name.equals("performer")) {
2955      this.getPerformer().remove((MedicationDispensePerformerComponent) value);
2956    } else if (name.equals("location")) {
2957      this.location = null;
2958    } else if (name.equals("authorizingPrescription")) {
2959      this.getAuthorizingPrescription().remove(castToReference(value));
2960    } else if (name.equals("type")) {
2961      this.type = null;
2962    } else if (name.equals("quantity")) {
2963      this.quantity = null;
2964    } else if (name.equals("daysSupply")) {
2965      this.daysSupply = null;
2966    } else if (name.equals("whenPrepared")) {
2967      this.whenPrepared = null;
2968    } else if (name.equals("whenHandedOver")) {
2969      this.whenHandedOver = null;
2970    } else if (name.equals("destination")) {
2971      this.destination = null;
2972    } else if (name.equals("receiver")) {
2973      this.getReceiver().remove(castToReference(value));
2974    } else if (name.equals("note")) {
2975      this.getNote().remove(castToAnnotation(value));
2976    } else if (name.equals("dosageInstruction")) {
2977      this.getDosageInstruction().remove(castToDosage(value));
2978    } else if (name.equals("substitution")) {
2979      this.substitution = (MedicationDispenseSubstitutionComponent) value; // MedicationDispenseSubstitutionComponent
2980    } else if (name.equals("detectedIssue")) {
2981      this.getDetectedIssue().remove(castToReference(value));
2982    } else if (name.equals("eventHistory")) {
2983      this.getEventHistory().remove(castToReference(value));
2984    } else
2985      super.removeChild(name, value);
2986    
2987  }
2988
2989  @Override
2990  public Base makeProperty(int hash, String name) throws FHIRException {
2991    switch (hash) {
2992    case -1618432855:
2993      return addIdentifier();
2994    case -995410646:
2995      return addPartOf();
2996    case -892481550:
2997      return getStatusElement();
2998    case -1421632534:
2999      return getStatusReason();
3000    case 2051346646:
3001      return getStatusReason();
3002    case 50511102:
3003      return getCategory();
3004    case 1458402129:
3005      return getMedication();
3006    case 1998965455:
3007      return getMedication();
3008    case -1867885268:
3009      return getSubject();
3010    case 951530927:
3011      return getContext();
3012    case -1248768647:
3013      return addSupportingInformation();
3014    case 481140686:
3015      return addPerformer();
3016    case 1901043637:
3017      return getLocation();
3018    case -1237557856:
3019      return addAuthorizingPrescription();
3020    case 3575610:
3021      return getType();
3022    case -1285004149:
3023      return getQuantity();
3024    case 197175334:
3025      return getDaysSupply();
3026    case -562837097:
3027      return getWhenPreparedElement();
3028    case -940241380:
3029      return getWhenHandedOverElement();
3030    case -1429847026:
3031      return getDestination();
3032    case -808719889:
3033      return addReceiver();
3034    case 3387378:
3035      return addNote();
3036    case -1201373865:
3037      return addDosageInstruction();
3038    case 826147581:
3039      return getSubstitution();
3040    case 51602295:
3041      return addDetectedIssue();
3042    case 1835190426:
3043      return addEventHistory();
3044    default:
3045      return super.makeProperty(hash, name);
3046    }
3047
3048  }
3049
3050  @Override
3051  public String[] getTypesForProperty(int hash, String name) throws FHIRException {
3052    switch (hash) {
3053    case -1618432855:
3054      /* identifier */ return new String[] { "Identifier" };
3055    case -995410646:
3056      /* partOf */ return new String[] { "Reference" };
3057    case -892481550:
3058      /* status */ return new String[] { "code" };
3059    case 2051346646:
3060      /* statusReason */ return new String[] { "CodeableConcept", "Reference" };
3061    case 50511102:
3062      /* category */ return new String[] { "CodeableConcept" };
3063    case 1998965455:
3064      /* medication */ return new String[] { "CodeableConcept", "Reference" };
3065    case -1867885268:
3066      /* subject */ return new String[] { "Reference" };
3067    case 951530927:
3068      /* context */ return new String[] { "Reference" };
3069    case -1248768647:
3070      /* supportingInformation */ return new String[] { "Reference" };
3071    case 481140686:
3072      /* performer */ return new String[] {};
3073    case 1901043637:
3074      /* location */ return new String[] { "Reference" };
3075    case -1237557856:
3076      /* authorizingPrescription */ return new String[] { "Reference" };
3077    case 3575610:
3078      /* type */ return new String[] { "CodeableConcept" };
3079    case -1285004149:
3080      /* quantity */ return new String[] { "SimpleQuantity" };
3081    case 197175334:
3082      /* daysSupply */ return new String[] { "SimpleQuantity" };
3083    case -562837097:
3084      /* whenPrepared */ return new String[] { "dateTime" };
3085    case -940241380:
3086      /* whenHandedOver */ return new String[] { "dateTime" };
3087    case -1429847026:
3088      /* destination */ return new String[] { "Reference" };
3089    case -808719889:
3090      /* receiver */ return new String[] { "Reference" };
3091    case 3387378:
3092      /* note */ return new String[] { "Annotation" };
3093    case -1201373865:
3094      /* dosageInstruction */ return new String[] { "Dosage" };
3095    case 826147581:
3096      /* substitution */ return new String[] {};
3097    case 51602295:
3098      /* detectedIssue */ return new String[] { "Reference" };
3099    case 1835190426:
3100      /* eventHistory */ return new String[] { "Reference" };
3101    default:
3102      return super.getTypesForProperty(hash, name);
3103    }
3104
3105  }
3106
3107  @Override
3108  public Base addChild(String name) throws FHIRException {
3109    if (name.equals("identifier")) {
3110      return addIdentifier();
3111    } else if (name.equals("partOf")) {
3112      return addPartOf();
3113    } else if (name.equals("status")) {
3114      throw new FHIRException("Cannot call addChild on a singleton property MedicationDispense.status");
3115    } else if (name.equals("statusReasonCodeableConcept")) {
3116      this.statusReason = new CodeableConcept();
3117      return this.statusReason;
3118    } else if (name.equals("statusReasonReference")) {
3119      this.statusReason = new Reference();
3120      return this.statusReason;
3121    } else if (name.equals("category")) {
3122      this.category = new CodeableConcept();
3123      return this.category;
3124    } else if (name.equals("medicationCodeableConcept")) {
3125      this.medication = new CodeableConcept();
3126      return this.medication;
3127    } else if (name.equals("medicationReference")) {
3128      this.medication = new Reference();
3129      return this.medication;
3130    } else if (name.equals("subject")) {
3131      this.subject = new Reference();
3132      return this.subject;
3133    } else if (name.equals("context")) {
3134      this.context = new Reference();
3135      return this.context;
3136    } else if (name.equals("supportingInformation")) {
3137      return addSupportingInformation();
3138    } else if (name.equals("performer")) {
3139      return addPerformer();
3140    } else if (name.equals("location")) {
3141      this.location = new Reference();
3142      return this.location;
3143    } else if (name.equals("authorizingPrescription")) {
3144      return addAuthorizingPrescription();
3145    } else if (name.equals("type")) {
3146      this.type = new CodeableConcept();
3147      return this.type;
3148    } else if (name.equals("quantity")) {
3149      this.quantity = new Quantity();
3150      return this.quantity;
3151    } else if (name.equals("daysSupply")) {
3152      this.daysSupply = new Quantity();
3153      return this.daysSupply;
3154    } else if (name.equals("whenPrepared")) {
3155      throw new FHIRException("Cannot call addChild on a singleton property MedicationDispense.whenPrepared");
3156    } else if (name.equals("whenHandedOver")) {
3157      throw new FHIRException("Cannot call addChild on a singleton property MedicationDispense.whenHandedOver");
3158    } else if (name.equals("destination")) {
3159      this.destination = new Reference();
3160      return this.destination;
3161    } else if (name.equals("receiver")) {
3162      return addReceiver();
3163    } else if (name.equals("note")) {
3164      return addNote();
3165    } else if (name.equals("dosageInstruction")) {
3166      return addDosageInstruction();
3167    } else if (name.equals("substitution")) {
3168      this.substitution = new MedicationDispenseSubstitutionComponent();
3169      return this.substitution;
3170    } else if (name.equals("detectedIssue")) {
3171      return addDetectedIssue();
3172    } else if (name.equals("eventHistory")) {
3173      return addEventHistory();
3174    } else
3175      return super.addChild(name);
3176  }
3177
3178  public String fhirType() {
3179    return "MedicationDispense";
3180
3181  }
3182
3183  public MedicationDispense copy() {
3184    MedicationDispense dst = new MedicationDispense();
3185    copyValues(dst);
3186    return dst;
3187  }
3188
3189  public void copyValues(MedicationDispense dst) {
3190    super.copyValues(dst);
3191    if (identifier != null) {
3192      dst.identifier = new ArrayList<Identifier>();
3193      for (Identifier i : identifier)
3194        dst.identifier.add(i.copy());
3195    }
3196    ;
3197    if (partOf != null) {
3198      dst.partOf = new ArrayList<Reference>();
3199      for (Reference i : partOf)
3200        dst.partOf.add(i.copy());
3201    }
3202    ;
3203    dst.status = status == null ? null : status.copy();
3204    dst.statusReason = statusReason == null ? null : statusReason.copy();
3205    dst.category = category == null ? null : category.copy();
3206    dst.medication = medication == null ? null : medication.copy();
3207    dst.subject = subject == null ? null : subject.copy();
3208    dst.context = context == null ? null : context.copy();
3209    if (supportingInformation != null) {
3210      dst.supportingInformation = new ArrayList<Reference>();
3211      for (Reference i : supportingInformation)
3212        dst.supportingInformation.add(i.copy());
3213    }
3214    ;
3215    if (performer != null) {
3216      dst.performer = new ArrayList<MedicationDispensePerformerComponent>();
3217      for (MedicationDispensePerformerComponent i : performer)
3218        dst.performer.add(i.copy());
3219    }
3220    ;
3221    dst.location = location == null ? null : location.copy();
3222    if (authorizingPrescription != null) {
3223      dst.authorizingPrescription = new ArrayList<Reference>();
3224      for (Reference i : authorizingPrescription)
3225        dst.authorizingPrescription.add(i.copy());
3226    }
3227    ;
3228    dst.type = type == null ? null : type.copy();
3229    dst.quantity = quantity == null ? null : quantity.copy();
3230    dst.daysSupply = daysSupply == null ? null : daysSupply.copy();
3231    dst.whenPrepared = whenPrepared == null ? null : whenPrepared.copy();
3232    dst.whenHandedOver = whenHandedOver == null ? null : whenHandedOver.copy();
3233    dst.destination = destination == null ? null : destination.copy();
3234    if (receiver != null) {
3235      dst.receiver = new ArrayList<Reference>();
3236      for (Reference i : receiver)
3237        dst.receiver.add(i.copy());
3238    }
3239    ;
3240    if (note != null) {
3241      dst.note = new ArrayList<Annotation>();
3242      for (Annotation i : note)
3243        dst.note.add(i.copy());
3244    }
3245    ;
3246    if (dosageInstruction != null) {
3247      dst.dosageInstruction = new ArrayList<Dosage>();
3248      for (Dosage i : dosageInstruction)
3249        dst.dosageInstruction.add(i.copy());
3250    }
3251    ;
3252    dst.substitution = substitution == null ? null : substitution.copy();
3253    if (detectedIssue != null) {
3254      dst.detectedIssue = new ArrayList<Reference>();
3255      for (Reference i : detectedIssue)
3256        dst.detectedIssue.add(i.copy());
3257    }
3258    ;
3259    if (eventHistory != null) {
3260      dst.eventHistory = new ArrayList<Reference>();
3261      for (Reference i : eventHistory)
3262        dst.eventHistory.add(i.copy());
3263    }
3264    ;
3265  }
3266
3267  protected MedicationDispense typedCopy() {
3268    return copy();
3269  }
3270
3271  @Override
3272  public boolean equalsDeep(Base other_) {
3273    if (!super.equalsDeep(other_))
3274      return false;
3275    if (!(other_ instanceof MedicationDispense))
3276      return false;
3277    MedicationDispense o = (MedicationDispense) other_;
3278    return compareDeep(identifier, o.identifier, true) && compareDeep(partOf, o.partOf, true)
3279        && compareDeep(status, o.status, true) && compareDeep(statusReason, o.statusReason, true)
3280        && compareDeep(category, o.category, true) && compareDeep(medication, o.medication, true)
3281        && compareDeep(subject, o.subject, true) && compareDeep(context, o.context, true)
3282        && compareDeep(supportingInformation, o.supportingInformation, true)
3283        && compareDeep(performer, o.performer, true) && compareDeep(location, o.location, true)
3284        && compareDeep(authorizingPrescription, o.authorizingPrescription, true) && compareDeep(type, o.type, true)
3285        && compareDeep(quantity, o.quantity, true) && compareDeep(daysSupply, o.daysSupply, true)
3286        && compareDeep(whenPrepared, o.whenPrepared, true) && compareDeep(whenHandedOver, o.whenHandedOver, true)
3287        && compareDeep(destination, o.destination, true) && compareDeep(receiver, o.receiver, true)
3288        && compareDeep(note, o.note, true) && compareDeep(dosageInstruction, o.dosageInstruction, true)
3289        && compareDeep(substitution, o.substitution, true) && compareDeep(detectedIssue, o.detectedIssue, true)
3290        && compareDeep(eventHistory, o.eventHistory, true);
3291  }
3292
3293  @Override
3294  public boolean equalsShallow(Base other_) {
3295    if (!super.equalsShallow(other_))
3296      return false;
3297    if (!(other_ instanceof MedicationDispense))
3298      return false;
3299    MedicationDispense o = (MedicationDispense) other_;
3300    return compareValues(status, o.status, true) && compareValues(whenPrepared, o.whenPrepared, true)
3301        && compareValues(whenHandedOver, o.whenHandedOver, true);
3302  }
3303
3304  public boolean isEmpty() {
3305    return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, partOf, status, statusReason, category,
3306        medication, subject, context, supportingInformation, performer, location, authorizingPrescription, type,
3307        quantity, daysSupply, whenPrepared, whenHandedOver, destination, receiver, note, dosageInstruction,
3308        substitution, detectedIssue, eventHistory);
3309  }
3310
3311  @Override
3312  public ResourceType getResourceType() {
3313    return ResourceType.MedicationDispense;
3314  }
3315
3316  /**
3317   * Search parameter: <b>identifier</b>
3318   * <p>
3319   * Description: <b>Returns dispenses with this external identifier</b><br>
3320   * Type: <b>token</b><br>
3321   * Path: <b>MedicationDispense.identifier</b><br>
3322   * </p>
3323   */
3324  @SearchParamDefinition(name = "identifier", path = "MedicationDispense.identifier", description = "Returns dispenses with this external identifier", type = "token")
3325  public static final String SP_IDENTIFIER = "identifier";
3326  /**
3327   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
3328   * <p>
3329   * Description: <b>Returns dispenses with this external identifier</b><br>
3330   * Type: <b>token</b><br>
3331   * Path: <b>MedicationDispense.identifier</b><br>
3332   * </p>
3333   */
3334  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(
3335      SP_IDENTIFIER);
3336
3337  /**
3338   * Search parameter: <b>performer</b>
3339   * <p>
3340   * Description: <b>Returns dispenses performed by a specific individual</b><br>
3341   * Type: <b>reference</b><br>
3342   * Path: <b>MedicationDispense.performer.actor</b><br>
3343   * </p>
3344   */
3345  @SearchParamDefinition(name = "performer", path = "MedicationDispense.performer.actor", description = "Returns dispenses performed by a specific individual", type = "reference", providesMembershipIn = {
3346      @ca.uhn.fhir.model.api.annotation.Compartment(name = "Practitioner") }, target = { Device.class,
3347          Organization.class, Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class })
3348  public static final String SP_PERFORMER = "performer";
3349  /**
3350   * <b>Fluent Client</b> search parameter constant for <b>performer</b>
3351   * <p>
3352   * Description: <b>Returns dispenses performed by a specific individual</b><br>
3353   * Type: <b>reference</b><br>
3354   * Path: <b>MedicationDispense.performer.actor</b><br>
3355   * </p>
3356   */
3357  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PERFORMER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
3358      SP_PERFORMER);
3359
3360  /**
3361   * Constant for fluent queries to be used to add include statements. Specifies
3362   * the path value of "<b>MedicationDispense:performer</b>".
3363   */
3364  public static final ca.uhn.fhir.model.api.Include INCLUDE_PERFORMER = new ca.uhn.fhir.model.api.Include(
3365      "MedicationDispense:performer").toLocked();
3366
3367  /**
3368   * Search parameter: <b>code</b>
3369   * <p>
3370   * Description: <b>Returns dispenses of this medicine code</b><br>
3371   * Type: <b>token</b><br>
3372   * Path: <b>MedicationDispense.medicationCodeableConcept</b><br>
3373   * </p>
3374   */
3375  @SearchParamDefinition(name = "code", path = "(MedicationDispense.medication as CodeableConcept)", description = "Returns dispenses of this medicine code", type = "token")
3376  public static final String SP_CODE = "code";
3377  /**
3378   * <b>Fluent Client</b> search parameter constant for <b>code</b>
3379   * <p>
3380   * Description: <b>Returns dispenses of this medicine code</b><br>
3381   * Type: <b>token</b><br>
3382   * Path: <b>MedicationDispense.medicationCodeableConcept</b><br>
3383   * </p>
3384   */
3385  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(
3386      SP_CODE);
3387
3388  /**
3389   * Search parameter: <b>receiver</b>
3390   * <p>
3391   * Description: <b>The identity of a receiver to list dispenses for</b><br>
3392   * Type: <b>reference</b><br>
3393   * Path: <b>MedicationDispense.receiver</b><br>
3394   * </p>
3395   */
3396  @SearchParamDefinition(name = "receiver", path = "MedicationDispense.receiver", description = "The identity of a receiver to list dispenses for", type = "reference", providesMembershipIn = {
3397      @ca.uhn.fhir.model.api.annotation.Compartment(name = "Patient"),
3398      @ca.uhn.fhir.model.api.annotation.Compartment(name = "Practitioner") }, target = { Patient.class,
3399          Practitioner.class })
3400  public static final String SP_RECEIVER = "receiver";
3401  /**
3402   * <b>Fluent Client</b> search parameter constant for <b>receiver</b>
3403   * <p>
3404   * Description: <b>The identity of a receiver to list dispenses for</b><br>
3405   * Type: <b>reference</b><br>
3406   * Path: <b>MedicationDispense.receiver</b><br>
3407   * </p>
3408   */
3409  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam RECEIVER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
3410      SP_RECEIVER);
3411
3412  /**
3413   * Constant for fluent queries to be used to add include statements. Specifies
3414   * the path value of "<b>MedicationDispense:receiver</b>".
3415   */
3416  public static final ca.uhn.fhir.model.api.Include INCLUDE_RECEIVER = new ca.uhn.fhir.model.api.Include(
3417      "MedicationDispense:receiver").toLocked();
3418
3419  /**
3420   * Search parameter: <b>subject</b>
3421   * <p>
3422   * Description: <b>The identity of a patient for whom to list dispenses</b><br>
3423   * Type: <b>reference</b><br>
3424   * Path: <b>MedicationDispense.subject</b><br>
3425   * </p>
3426   */
3427  @SearchParamDefinition(name = "subject", path = "MedicationDispense.subject", description = "The identity of a patient for whom to list dispenses", type = "reference", providesMembershipIn = {
3428      @ca.uhn.fhir.model.api.annotation.Compartment(name = "Patient") }, target = { Group.class, Patient.class })
3429  public static final String SP_SUBJECT = "subject";
3430  /**
3431   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
3432   * <p>
3433   * Description: <b>The identity of a patient for whom to list dispenses</b><br>
3434   * Type: <b>reference</b><br>
3435   * Path: <b>MedicationDispense.subject</b><br>
3436   * </p>
3437   */
3438  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
3439      SP_SUBJECT);
3440
3441  /**
3442   * Constant for fluent queries to be used to add include statements. Specifies
3443   * the path value of "<b>MedicationDispense:subject</b>".
3444   */
3445  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include(
3446      "MedicationDispense:subject").toLocked();
3447
3448  /**
3449   * Search parameter: <b>destination</b>
3450   * <p>
3451   * Description: <b>Returns dispenses that should be sent to a specific
3452   * destination</b><br>
3453   * Type: <b>reference</b><br>
3454   * Path: <b>MedicationDispense.destination</b><br>
3455   * </p>
3456   */
3457  @SearchParamDefinition(name = "destination", path = "MedicationDispense.destination", description = "Returns dispenses that should be sent to a specific destination", type = "reference", target = {
3458      Location.class })
3459  public static final String SP_DESTINATION = "destination";
3460  /**
3461   * <b>Fluent Client</b> search parameter constant for <b>destination</b>
3462   * <p>
3463   * Description: <b>Returns dispenses that should be sent to a specific
3464   * destination</b><br>
3465   * Type: <b>reference</b><br>
3466   * Path: <b>MedicationDispense.destination</b><br>
3467   * </p>
3468   */
3469  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam DESTINATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
3470      SP_DESTINATION);
3471
3472  /**
3473   * Constant for fluent queries to be used to add include statements. Specifies
3474   * the path value of "<b>MedicationDispense:destination</b>".
3475   */
3476  public static final ca.uhn.fhir.model.api.Include INCLUDE_DESTINATION = new ca.uhn.fhir.model.api.Include(
3477      "MedicationDispense:destination").toLocked();
3478
3479  /**
3480   * Search parameter: <b>medication</b>
3481   * <p>
3482   * Description: <b>Returns dispenses of this medicine resource</b><br>
3483   * Type: <b>reference</b><br>
3484   * Path: <b>MedicationDispense.medicationReference</b><br>
3485   * </p>
3486   */
3487  @SearchParamDefinition(name = "medication", path = "(MedicationDispense.medication as Reference)", description = "Returns dispenses of this medicine resource", type = "reference", target = {
3488      Medication.class })
3489  public static final String SP_MEDICATION = "medication";
3490  /**
3491   * <b>Fluent Client</b> search parameter constant for <b>medication</b>
3492   * <p>
3493   * Description: <b>Returns dispenses of this medicine resource</b><br>
3494   * Type: <b>reference</b><br>
3495   * Path: <b>MedicationDispense.medicationReference</b><br>
3496   * </p>
3497   */
3498  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam MEDICATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
3499      SP_MEDICATION);
3500
3501  /**
3502   * Constant for fluent queries to be used to add include statements. Specifies
3503   * the path value of "<b>MedicationDispense:medication</b>".
3504   */
3505  public static final ca.uhn.fhir.model.api.Include INCLUDE_MEDICATION = new ca.uhn.fhir.model.api.Include(
3506      "MedicationDispense:medication").toLocked();
3507
3508  /**
3509   * Search parameter: <b>responsibleparty</b>
3510   * <p>
3511   * Description: <b>Returns dispenses with the specified responsible
3512   * party</b><br>
3513   * Type: <b>reference</b><br>
3514   * Path: <b>MedicationDispense.substitution.responsibleParty</b><br>
3515   * </p>
3516   */
3517  @SearchParamDefinition(name = "responsibleparty", path = "MedicationDispense.substitution.responsibleParty", description = "Returns dispenses with the specified responsible party", type = "reference", target = {
3518      Practitioner.class, PractitionerRole.class })
3519  public static final String SP_RESPONSIBLEPARTY = "responsibleparty";
3520  /**
3521   * <b>Fluent Client</b> search parameter constant for <b>responsibleparty</b>
3522   * <p>
3523   * Description: <b>Returns dispenses with the specified responsible
3524   * party</b><br>
3525   * Type: <b>reference</b><br>
3526   * Path: <b>MedicationDispense.substitution.responsibleParty</b><br>
3527   * </p>
3528   */
3529  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam RESPONSIBLEPARTY = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
3530      SP_RESPONSIBLEPARTY);
3531
3532  /**
3533   * Constant for fluent queries to be used to add include statements. Specifies
3534   * the path value of "<b>MedicationDispense:responsibleparty</b>".
3535   */
3536  public static final ca.uhn.fhir.model.api.Include INCLUDE_RESPONSIBLEPARTY = new ca.uhn.fhir.model.api.Include(
3537      "MedicationDispense:responsibleparty").toLocked();
3538
3539  /**
3540   * Search parameter: <b>type</b>
3541   * <p>
3542   * Description: <b>Returns dispenses of a specific type</b><br>
3543   * Type: <b>token</b><br>
3544   * Path: <b>MedicationDispense.type</b><br>
3545   * </p>
3546   */
3547  @SearchParamDefinition(name = "type", path = "MedicationDispense.type", description = "Returns dispenses of a specific type", type = "token")
3548  public static final String SP_TYPE = "type";
3549  /**
3550   * <b>Fluent Client</b> search parameter constant for <b>type</b>
3551   * <p>
3552   * Description: <b>Returns dispenses of a specific type</b><br>
3553   * Type: <b>token</b><br>
3554   * Path: <b>MedicationDispense.type</b><br>
3555   * </p>
3556   */
3557  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(
3558      SP_TYPE);
3559
3560  /**
3561   * Search parameter: <b>whenhandedover</b>
3562   * <p>
3563   * Description: <b>Returns dispenses handed over on this date</b><br>
3564   * Type: <b>date</b><br>
3565   * Path: <b>MedicationDispense.whenHandedOver</b><br>
3566   * </p>
3567   */
3568  @SearchParamDefinition(name = "whenhandedover", path = "MedicationDispense.whenHandedOver", description = "Returns dispenses handed over on this date", type = "date")
3569  public static final String SP_WHENHANDEDOVER = "whenhandedover";
3570  /**
3571   * <b>Fluent Client</b> search parameter constant for <b>whenhandedover</b>
3572   * <p>
3573   * Description: <b>Returns dispenses handed over on this date</b><br>
3574   * Type: <b>date</b><br>
3575   * Path: <b>MedicationDispense.whenHandedOver</b><br>
3576   * </p>
3577   */
3578  public static final ca.uhn.fhir.rest.gclient.DateClientParam WHENHANDEDOVER = new ca.uhn.fhir.rest.gclient.DateClientParam(
3579      SP_WHENHANDEDOVER);
3580
3581  /**
3582   * Search parameter: <b>whenprepared</b>
3583   * <p>
3584   * Description: <b>Returns dispenses prepared on this date</b><br>
3585   * Type: <b>date</b><br>
3586   * Path: <b>MedicationDispense.whenPrepared</b><br>
3587   * </p>
3588   */
3589  @SearchParamDefinition(name = "whenprepared", path = "MedicationDispense.whenPrepared", description = "Returns dispenses prepared on this date", type = "date")
3590  public static final String SP_WHENPREPARED = "whenprepared";
3591  /**
3592   * <b>Fluent Client</b> search parameter constant for <b>whenprepared</b>
3593   * <p>
3594   * Description: <b>Returns dispenses prepared on this date</b><br>
3595   * Type: <b>date</b><br>
3596   * Path: <b>MedicationDispense.whenPrepared</b><br>
3597   * </p>
3598   */
3599  public static final ca.uhn.fhir.rest.gclient.DateClientParam WHENPREPARED = new ca.uhn.fhir.rest.gclient.DateClientParam(
3600      SP_WHENPREPARED);
3601
3602  /**
3603   * Search parameter: <b>prescription</b>
3604   * <p>
3605   * Description: <b>The identity of a prescription to list dispenses from</b><br>
3606   * Type: <b>reference</b><br>
3607   * Path: <b>MedicationDispense.authorizingPrescription</b><br>
3608   * </p>
3609   */
3610  @SearchParamDefinition(name = "prescription", path = "MedicationDispense.authorizingPrescription", description = "The identity of a prescription to list dispenses from", type = "reference", target = {
3611      MedicationRequest.class })
3612  public static final String SP_PRESCRIPTION = "prescription";
3613  /**
3614   * <b>Fluent Client</b> search parameter constant for <b>prescription</b>
3615   * <p>
3616   * Description: <b>The identity of a prescription to list dispenses from</b><br>
3617   * Type: <b>reference</b><br>
3618   * Path: <b>MedicationDispense.authorizingPrescription</b><br>
3619   * </p>
3620   */
3621  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PRESCRIPTION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
3622      SP_PRESCRIPTION);
3623
3624  /**
3625   * Constant for fluent queries to be used to add include statements. Specifies
3626   * the path value of "<b>MedicationDispense:prescription</b>".
3627   */
3628  public static final ca.uhn.fhir.model.api.Include INCLUDE_PRESCRIPTION = new ca.uhn.fhir.model.api.Include(
3629      "MedicationDispense:prescription").toLocked();
3630
3631  /**
3632   * Search parameter: <b>patient</b>
3633   * <p>
3634   * Description: <b>The identity of a patient to list dispenses for</b><br>
3635   * Type: <b>reference</b><br>
3636   * Path: <b>MedicationDispense.subject</b><br>
3637   * </p>
3638   */
3639  @SearchParamDefinition(name = "patient", path = "MedicationDispense.subject.where(resolve() is Patient)", description = "The identity of a patient to list dispenses  for", type = "reference", providesMembershipIn = {
3640      @ca.uhn.fhir.model.api.annotation.Compartment(name = "Patient") }, target = { Patient.class })
3641  public static final String SP_PATIENT = "patient";
3642  /**
3643   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
3644   * <p>
3645   * Description: <b>The identity of a patient to list dispenses for</b><br>
3646   * Type: <b>reference</b><br>
3647   * Path: <b>MedicationDispense.subject</b><br>
3648   * </p>
3649   */
3650  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
3651      SP_PATIENT);
3652
3653  /**
3654   * Constant for fluent queries to be used to add include statements. Specifies
3655   * the path value of "<b>MedicationDispense:patient</b>".
3656   */
3657  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include(
3658      "MedicationDispense:patient").toLocked();
3659
3660  /**
3661   * Search parameter: <b>context</b>
3662   * <p>
3663   * Description: <b>Returns dispenses with a specific context (episode or episode
3664   * of care)</b><br>
3665   * Type: <b>reference</b><br>
3666   * Path: <b>MedicationDispense.context</b><br>
3667   * </p>
3668   */
3669  @SearchParamDefinition(name = "context", path = "MedicationDispense.context", description = "Returns dispenses with a specific context (episode or episode of care)", type = "reference", target = {
3670      Encounter.class, EpisodeOfCare.class })
3671  public static final String SP_CONTEXT = "context";
3672  /**
3673   * <b>Fluent Client</b> search parameter constant for <b>context</b>
3674   * <p>
3675   * Description: <b>Returns dispenses with a specific context (episode or episode
3676   * of care)</b><br>
3677   * Type: <b>reference</b><br>
3678   * Path: <b>MedicationDispense.context</b><br>
3679   * </p>
3680   */
3681  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam CONTEXT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
3682      SP_CONTEXT);
3683
3684  /**
3685   * Constant for fluent queries to be used to add include statements. Specifies
3686   * the path value of "<b>MedicationDispense:context</b>".
3687   */
3688  public static final ca.uhn.fhir.model.api.Include INCLUDE_CONTEXT = new ca.uhn.fhir.model.api.Include(
3689      "MedicationDispense:context").toLocked();
3690
3691  /**
3692   * Search parameter: <b>status</b>
3693   * <p>
3694   * Description: <b>Returns dispenses with a specified dispense status</b><br>
3695   * Type: <b>token</b><br>
3696   * Path: <b>MedicationDispense.status</b><br>
3697   * </p>
3698   */
3699  @SearchParamDefinition(name = "status", path = "MedicationDispense.status", description = "Returns dispenses with a specified dispense status", type = "token")
3700  public static final String SP_STATUS = "status";
3701  /**
3702   * <b>Fluent Client</b> search parameter constant for <b>status</b>
3703   * <p>
3704   * Description: <b>Returns dispenses with a specified dispense status</b><br>
3705   * Type: <b>token</b><br>
3706   * Path: <b>MedicationDispense.status</b><br>
3707   * </p>
3708   */
3709  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(
3710      SP_STATUS);
3711
3712}