001package org.hl7.fhir.dstu3.model;
002
003
004
005
006/*
007  Copyright (c) 2011+, HL7, Inc.
008  All rights reserved.
009  
010  Redistribution and use in source and binary forms, with or without modification, 
011  are permitted provided that the following conditions are met:
012  
013   * Redistributions of source code must retain the above copyright notice, this 
014     list of conditions and the following disclaimer.
015   * Redistributions in binary form must reproduce the above copyright notice, 
016     this list of conditions and the following disclaimer in the documentation 
017     and/or other materials provided with the distribution.
018   * Neither the name of HL7 nor the names of its contributors may be used to 
019     endorse or promote products derived from this software without specific 
020     prior written permission.
021  
022  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
023  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
024  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
025  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
026  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
027  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
028  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
029  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
030  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
031  POSSIBILITY OF SUCH DAMAGE.
032  
033*/
034
035// Generated on Fri, Mar 16, 2018 15:21+1100 for FHIR v3.0.x
036import java.util.ArrayList;
037import java.util.Date;
038import java.util.List;
039
040import org.hl7.fhir.exceptions.FHIRException;
041import org.hl7.fhir.exceptions.FHIRFormatError;
042import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
043
044import ca.uhn.fhir.model.api.annotation.Block;
045import ca.uhn.fhir.model.api.annotation.Child;
046import ca.uhn.fhir.model.api.annotation.Description;
047import ca.uhn.fhir.model.api.annotation.ResourceDef;
048import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
049/**
050 * Indicates that a medication product is to be or has been dispensed for a named person/patient.  This includes a description of the medication product (supply) provided and the instructions for administering the medication.  The medication dispense is the result of a pharmacy system responding to a medication order.
051 */
052@ResourceDef(name="MedicationDispense", profile="http://hl7.org/fhir/Profile/MedicationDispense")
053public class MedicationDispense extends DomainResource {
054
055    public enum MedicationDispenseStatus {
056        /**
057         * 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.
058         */
059        PREPARATION, 
060        /**
061         * The dispense has started but has not yet completed.
062         */
063        INPROGRESS, 
064        /**
065         * Actions implied by the administration have been temporarily halted, but are expected to continue later. May also be called "suspended"
066         */
067        ONHOLD, 
068        /**
069         * All actions that are implied by the dispense have occurred.
070         */
071        COMPLETED, 
072        /**
073         * The dispense was entered in error and therefore nullified.
074         */
075        ENTEREDINERROR, 
076        /**
077         * Actions implied by the dispense have been permanently halted, before all of them occurred.
078         */
079        STOPPED, 
080        /**
081         * added to help the parsers with the generic types
082         */
083        NULL;
084        public static MedicationDispenseStatus fromCode(String codeString) throws FHIRException {
085            if (codeString == null || "".equals(codeString))
086                return null;
087        if ("preparation".equals(codeString))
088          return PREPARATION;
089        if ("in-progress".equals(codeString))
090          return INPROGRESS;
091        if ("on-hold".equals(codeString))
092          return ONHOLD;
093        if ("completed".equals(codeString))
094          return COMPLETED;
095        if ("entered-in-error".equals(codeString))
096          return ENTEREDINERROR;
097        if ("stopped".equals(codeString))
098          return STOPPED;
099        if (Configuration.isAcceptInvalidEnums())
100          return null;
101        else
102          throw new FHIRException("Unknown MedicationDispenseStatus code '"+codeString+"'");
103        }
104        public String toCode() {
105          switch (this) {
106            case PREPARATION: return "preparation";
107            case INPROGRESS: return "in-progress";
108            case ONHOLD: return "on-hold";
109            case COMPLETED: return "completed";
110            case ENTEREDINERROR: return "entered-in-error";
111            case STOPPED: return "stopped";
112            case NULL: return null;
113            default: return "?";
114          }
115        }
116        public String getSystem() {
117          switch (this) {
118            case PREPARATION: return "http://hl7.org/fhir/medication-dispense-status";
119            case INPROGRESS: return "http://hl7.org/fhir/medication-dispense-status";
120            case ONHOLD: return "http://hl7.org/fhir/medication-dispense-status";
121            case COMPLETED: return "http://hl7.org/fhir/medication-dispense-status";
122            case ENTEREDINERROR: return "http://hl7.org/fhir/medication-dispense-status";
123            case STOPPED: return "http://hl7.org/fhir/medication-dispense-status";
124            case NULL: return null;
125            default: return "?";
126          }
127        }
128        public String getDefinition() {
129          switch (this) {
130            case PREPARATION: 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.";
131            case INPROGRESS: return "The dispense has started but has not yet completed.";
132            case ONHOLD: return "Actions implied by the administration have been temporarily halted, but are expected to continue later. May also be called \"suspended\"";
133            case COMPLETED: return "All actions that are implied by the dispense have occurred.";
134            case ENTEREDINERROR: return "The dispense was entered in error and therefore nullified.";
135            case STOPPED: return "Actions implied by the dispense have been permanently halted, before all of them occurred.";
136            case NULL: return null;
137            default: return "?";
138          }
139        }
140        public String getDisplay() {
141          switch (this) {
142            case PREPARATION: return "Preparation";
143            case INPROGRESS: return "In Progress";
144            case ONHOLD: return "On Hold";
145            case COMPLETED: return "Completed";
146            case ENTEREDINERROR: return "Entered in-Error";
147            case STOPPED: return "Stopped";
148            case NULL: return null;
149            default: return "?";
150          }
151        }
152    }
153
154  public static class MedicationDispenseStatusEnumFactory implements EnumFactory<MedicationDispenseStatus> {
155    public MedicationDispenseStatus fromCode(String codeString) throws IllegalArgumentException {
156      if (codeString == null || "".equals(codeString))
157            if (codeString == null || "".equals(codeString))
158                return null;
159        if ("preparation".equals(codeString))
160          return MedicationDispenseStatus.PREPARATION;
161        if ("in-progress".equals(codeString))
162          return MedicationDispenseStatus.INPROGRESS;
163        if ("on-hold".equals(codeString))
164          return MedicationDispenseStatus.ONHOLD;
165        if ("completed".equals(codeString))
166          return MedicationDispenseStatus.COMPLETED;
167        if ("entered-in-error".equals(codeString))
168          return MedicationDispenseStatus.ENTEREDINERROR;
169        if ("stopped".equals(codeString))
170          return MedicationDispenseStatus.STOPPED;
171        throw new IllegalArgumentException("Unknown MedicationDispenseStatus code '"+codeString+"'");
172        }
173        public Enumeration<MedicationDispenseStatus> fromType(PrimitiveType<?> code) throws FHIRException {
174          if (code == null)
175            return null;
176          if (code.isEmpty())
177            return new Enumeration<MedicationDispenseStatus>(this);
178          String codeString = code.asStringValue();
179          if (codeString == null || "".equals(codeString))
180            return null;
181        if ("preparation".equals(codeString))
182          return new Enumeration<MedicationDispenseStatus>(this, MedicationDispenseStatus.PREPARATION);
183        if ("in-progress".equals(codeString))
184          return new Enumeration<MedicationDispenseStatus>(this, MedicationDispenseStatus.INPROGRESS);
185        if ("on-hold".equals(codeString))
186          return new Enumeration<MedicationDispenseStatus>(this, MedicationDispenseStatus.ONHOLD);
187        if ("completed".equals(codeString))
188          return new Enumeration<MedicationDispenseStatus>(this, MedicationDispenseStatus.COMPLETED);
189        if ("entered-in-error".equals(codeString))
190          return new Enumeration<MedicationDispenseStatus>(this, MedicationDispenseStatus.ENTEREDINERROR);
191        if ("stopped".equals(codeString))
192          return new Enumeration<MedicationDispenseStatus>(this, MedicationDispenseStatus.STOPPED);
193        throw new FHIRException("Unknown MedicationDispenseStatus code '"+codeString+"'");
194        }
195    public String toCode(MedicationDispenseStatus code) {
196       if (code == MedicationDispenseStatus.NULL)
197           return null;
198       if (code == MedicationDispenseStatus.PREPARATION)
199        return "preparation";
200      if (code == MedicationDispenseStatus.INPROGRESS)
201        return "in-progress";
202      if (code == MedicationDispenseStatus.ONHOLD)
203        return "on-hold";
204      if (code == MedicationDispenseStatus.COMPLETED)
205        return "completed";
206      if (code == MedicationDispenseStatus.ENTEREDINERROR)
207        return "entered-in-error";
208      if (code == MedicationDispenseStatus.STOPPED)
209        return "stopped";
210      return "?";
211   }
212    public String toSystem(MedicationDispenseStatus code) {
213      return code.getSystem();
214      }
215    }
216
217    @Block()
218    public static class MedicationDispensePerformerComponent extends BackboneElement implements IBaseBackboneElement {
219        /**
220         * The device, practitioner, etc. who performed the action.  It should be assumed that the actor is the dispenser of the medication.
221         */
222        @Child(name = "actor", type = {Practitioner.class, Organization.class, Patient.class, Device.class, RelatedPerson.class}, order=1, min=1, max=1, modifier=false, summary=false)
223        @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." )
224        protected Reference actor;
225
226        /**
227         * The actual object that is the target of the reference (The device, practitioner, etc. who performed the action.  It should be assumed that the actor is the dispenser of the medication.)
228         */
229        protected Resource actorTarget;
230
231        /**
232         * The organization the device or practitioner was acting on behalf of.
233         */
234        @Child(name = "onBehalfOf", type = {Organization.class}, order=2, min=0, max=1, modifier=false, summary=false)
235        @Description(shortDefinition="Organization organization was acting for", formalDefinition="The organization the device or practitioner was acting on behalf of." )
236        protected Reference onBehalfOf;
237
238        /**
239         * The actual object that is the target of the reference (The organization the device or practitioner was acting on behalf of.)
240         */
241        protected Organization onBehalfOfTarget;
242
243        private static final long serialVersionUID = -488386403L;
244
245    /**
246     * Constructor
247     */
248      public MedicationDispensePerformerComponent() {
249        super();
250      }
251
252    /**
253     * Constructor
254     */
255      public MedicationDispensePerformerComponent(Reference actor) {
256        super();
257        this.actor = actor;
258      }
259
260        /**
261         * @return {@link #actor} (The device, practitioner, etc. who performed the action.  It should be assumed that the actor is the dispenser of the medication.)
262         */
263        public Reference getActor() { 
264          if (this.actor == null)
265            if (Configuration.errorOnAutoCreate())
266              throw new Error("Attempt to auto-create MedicationDispensePerformerComponent.actor");
267            else if (Configuration.doAutoCreate())
268              this.actor = new Reference(); // cc
269          return this.actor;
270        }
271
272        public boolean hasActor() { 
273          return this.actor != null && !this.actor.isEmpty();
274        }
275
276        /**
277         * @param value {@link #actor} (The device, practitioner, etc. who performed the action.  It should be assumed that the actor is the dispenser of the medication.)
278         */
279        public MedicationDispensePerformerComponent setActor(Reference value)  { 
280          this.actor = value;
281          return this;
282        }
283
284        /**
285         * @return {@link #actor} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The device, practitioner, etc. who performed the action.  It should be assumed that the actor is the dispenser of the medication.)
286         */
287        public Resource getActorTarget() { 
288          return this.actorTarget;
289        }
290
291        /**
292         * @param value {@link #actor} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The device, practitioner, etc. who performed the action.  It should be assumed that the actor is the dispenser of the medication.)
293         */
294        public MedicationDispensePerformerComponent setActorTarget(Resource value) { 
295          this.actorTarget = value;
296          return this;
297        }
298
299        /**
300         * @return {@link #onBehalfOf} (The organization the device or practitioner was acting on behalf of.)
301         */
302        public Reference getOnBehalfOf() { 
303          if (this.onBehalfOf == null)
304            if (Configuration.errorOnAutoCreate())
305              throw new Error("Attempt to auto-create MedicationDispensePerformerComponent.onBehalfOf");
306            else if (Configuration.doAutoCreate())
307              this.onBehalfOf = new Reference(); // cc
308          return this.onBehalfOf;
309        }
310
311        public boolean hasOnBehalfOf() { 
312          return this.onBehalfOf != null && !this.onBehalfOf.isEmpty();
313        }
314
315        /**
316         * @param value {@link #onBehalfOf} (The organization the device or practitioner was acting on behalf of.)
317         */
318        public MedicationDispensePerformerComponent setOnBehalfOf(Reference value)  { 
319          this.onBehalfOf = value;
320          return this;
321        }
322
323        /**
324         * @return {@link #onBehalfOf} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The organization the device or practitioner was acting on behalf of.)
325         */
326        public Organization getOnBehalfOfTarget() { 
327          if (this.onBehalfOfTarget == null)
328            if (Configuration.errorOnAutoCreate())
329              throw new Error("Attempt to auto-create MedicationDispensePerformerComponent.onBehalfOf");
330            else if (Configuration.doAutoCreate())
331              this.onBehalfOfTarget = new Organization(); // aa
332          return this.onBehalfOfTarget;
333        }
334
335        /**
336         * @param value {@link #onBehalfOf} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The organization the device or practitioner was acting on behalf of.)
337         */
338        public MedicationDispensePerformerComponent setOnBehalfOfTarget(Organization value) { 
339          this.onBehalfOfTarget = value;
340          return this;
341        }
342
343        protected void listChildren(List<Property> children) {
344          super.listChildren(children);
345          children.add(new Property("actor", "Reference(Practitioner|Organization|Patient|Device|RelatedPerson)", "The device, practitioner, etc. who performed the action.  It should be assumed that the actor is the dispenser of the medication.", 0, 1, actor));
346          children.add(new Property("onBehalfOf", "Reference(Organization)", "The organization the device or practitioner was acting on behalf of.", 0, 1, onBehalfOf));
347        }
348
349        @Override
350        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
351          switch (_hash) {
352          case 92645877: /*actor*/  return new Property("actor", "Reference(Practitioner|Organization|Patient|Device|RelatedPerson)", "The device, practitioner, etc. who performed the action.  It should be assumed that the actor is the dispenser of the medication.", 0, 1, actor);
353          case -14402964: /*onBehalfOf*/  return new Property("onBehalfOf", "Reference(Organization)", "The organization the device or practitioner was acting on behalf of.", 0, 1, onBehalfOf);
354          default: return super.getNamedProperty(_hash, _name, _checkValid);
355          }
356
357        }
358
359      @Override
360      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
361        switch (hash) {
362        case 92645877: /*actor*/ return this.actor == null ? new Base[0] : new Base[] {this.actor}; // Reference
363        case -14402964: /*onBehalfOf*/ return this.onBehalfOf == null ? new Base[0] : new Base[] {this.onBehalfOf}; // Reference
364        default: return super.getProperty(hash, name, checkValid);
365        }
366
367      }
368
369      @Override
370      public Base setProperty(int hash, String name, Base value) throws FHIRException {
371        switch (hash) {
372        case 92645877: // actor
373          this.actor = castToReference(value); // Reference
374          return value;
375        case -14402964: // onBehalfOf
376          this.onBehalfOf = castToReference(value); // Reference
377          return value;
378        default: return super.setProperty(hash, name, value);
379        }
380
381      }
382
383      @Override
384      public Base setProperty(String name, Base value) throws FHIRException {
385        if (name.equals("actor")) {
386          this.actor = castToReference(value); // Reference
387        } else if (name.equals("onBehalfOf")) {
388          this.onBehalfOf = castToReference(value); // Reference
389        } else
390          return super.setProperty(name, value);
391        return value;
392      }
393
394      @Override
395      public Base makeProperty(int hash, String name) throws FHIRException {
396        switch (hash) {
397        case 92645877:  return getActor(); 
398        case -14402964:  return getOnBehalfOf(); 
399        default: return super.makeProperty(hash, name);
400        }
401
402      }
403
404      @Override
405      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
406        switch (hash) {
407        case 92645877: /*actor*/ return new String[] {"Reference"};
408        case -14402964: /*onBehalfOf*/ return new String[] {"Reference"};
409        default: return super.getTypesForProperty(hash, name);
410        }
411
412      }
413
414      @Override
415      public Base addChild(String name) throws FHIRException {
416        if (name.equals("actor")) {
417          this.actor = new Reference();
418          return this.actor;
419        }
420        else if (name.equals("onBehalfOf")) {
421          this.onBehalfOf = new Reference();
422          return this.onBehalfOf;
423        }
424        else
425          return super.addChild(name);
426      }
427
428      public MedicationDispensePerformerComponent copy() {
429        MedicationDispensePerformerComponent dst = new MedicationDispensePerformerComponent();
430        copyValues(dst);
431        dst.actor = actor == null ? null : actor.copy();
432        dst.onBehalfOf = onBehalfOf == null ? null : onBehalfOf.copy();
433        return dst;
434      }
435
436      @Override
437      public boolean equalsDeep(Base other_) {
438        if (!super.equalsDeep(other_))
439          return false;
440        if (!(other_ instanceof MedicationDispensePerformerComponent))
441          return false;
442        MedicationDispensePerformerComponent o = (MedicationDispensePerformerComponent) other_;
443        return compareDeep(actor, o.actor, true) && compareDeep(onBehalfOf, o.onBehalfOf, true);
444      }
445
446      @Override
447      public boolean equalsShallow(Base other_) {
448        if (!super.equalsShallow(other_))
449          return false;
450        if (!(other_ instanceof MedicationDispensePerformerComponent))
451          return false;
452        MedicationDispensePerformerComponent o = (MedicationDispensePerformerComponent) other_;
453        return true;
454      }
455
456      public boolean isEmpty() {
457        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(actor, onBehalfOf);
458      }
459
460  public String fhirType() {
461    return "MedicationDispense.performer";
462
463  }
464
465  }
466
467    @Block()
468    public static class MedicationDispenseSubstitutionComponent extends BackboneElement implements IBaseBackboneElement {
469        /**
470         * True if the dispenser dispensed a different drug or product from what was prescribed.
471         */
472        @Child(name = "wasSubstituted", type = {BooleanType.class}, order=1, min=1, max=1, modifier=false, summary=false)
473        @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." )
474        protected BooleanType wasSubstituted;
475
476        /**
477         * A code signifying whether a different drug was dispensed from what was prescribed.
478         */
479        @Child(name = "type", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
480        @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." )
481        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/v3-ActSubstanceAdminSubstitutionCode")
482        protected CodeableConcept type;
483
484        /**
485         * Indicates the reason for the substitution of (or lack of substitution) from what was prescribed.
486         */
487        @Child(name = "reason", type = {CodeableConcept.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
488        @Description(shortDefinition="Why was substitution made", formalDefinition="Indicates the reason for the substitution of (or lack of substitution) from what was prescribed." )
489        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/v3-SubstanceAdminSubstitutionReason")
490        protected List<CodeableConcept> reason;
491
492        /**
493         * The person or organization that has primary responsibility for the substitution.
494         */
495        @Child(name = "responsibleParty", type = {Practitioner.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
496        @Description(shortDefinition="Who is responsible for the substitution", formalDefinition="The person or organization that has primary responsibility for the substitution." )
497        protected List<Reference> responsibleParty;
498        /**
499         * The actual objects that are the target of the reference (The person or organization that has primary responsibility for the substitution.)
500         */
501        protected List<Practitioner> responsiblePartyTarget;
502
503
504        private static final long serialVersionUID = -728152257L;
505
506    /**
507     * Constructor
508     */
509      public MedicationDispenseSubstitutionComponent() {
510        super();
511      }
512
513    /**
514     * Constructor
515     */
516      public MedicationDispenseSubstitutionComponent(BooleanType wasSubstituted) {
517        super();
518        this.wasSubstituted = wasSubstituted;
519      }
520
521        /**
522         * @return {@link #wasSubstituted} (True if the dispenser dispensed a different drug or product from what was prescribed.). This is the underlying object with id, value and extensions. The accessor "getWasSubstituted" gives direct access to the value
523         */
524        public BooleanType getWasSubstitutedElement() { 
525          if (this.wasSubstituted == null)
526            if (Configuration.errorOnAutoCreate())
527              throw new Error("Attempt to auto-create MedicationDispenseSubstitutionComponent.wasSubstituted");
528            else if (Configuration.doAutoCreate())
529              this.wasSubstituted = new BooleanType(); // bb
530          return this.wasSubstituted;
531        }
532
533        public boolean hasWasSubstitutedElement() { 
534          return this.wasSubstituted != null && !this.wasSubstituted.isEmpty();
535        }
536
537        public boolean hasWasSubstituted() { 
538          return this.wasSubstituted != null && !this.wasSubstituted.isEmpty();
539        }
540
541        /**
542         * @param value {@link #wasSubstituted} (True if the dispenser dispensed a different drug or product from what was prescribed.). This is the underlying object with id, value and extensions. The accessor "getWasSubstituted" gives direct access to the value
543         */
544        public MedicationDispenseSubstitutionComponent setWasSubstitutedElement(BooleanType value) { 
545          this.wasSubstituted = value;
546          return this;
547        }
548
549        /**
550         * @return True if the dispenser dispensed a different drug or product from what was prescribed.
551         */
552        public boolean getWasSubstituted() { 
553          return this.wasSubstituted == null || this.wasSubstituted.isEmpty() ? false : this.wasSubstituted.getValue();
554        }
555
556        /**
557         * @param value True if the dispenser dispensed a different drug or product from what was prescribed.
558         */
559        public MedicationDispenseSubstitutionComponent setWasSubstituted(boolean value) { 
560            if (this.wasSubstituted == null)
561              this.wasSubstituted = new BooleanType();
562            this.wasSubstituted.setValue(value);
563          return this;
564        }
565
566        /**
567         * @return {@link #type} (A code signifying whether a different drug was dispensed from what was prescribed.)
568         */
569        public CodeableConcept getType() { 
570          if (this.type == null)
571            if (Configuration.errorOnAutoCreate())
572              throw new Error("Attempt to auto-create MedicationDispenseSubstitutionComponent.type");
573            else if (Configuration.doAutoCreate())
574              this.type = new CodeableConcept(); // cc
575          return this.type;
576        }
577
578        public boolean hasType() { 
579          return this.type != null && !this.type.isEmpty();
580        }
581
582        /**
583         * @param value {@link #type} (A code signifying whether a different drug was dispensed from what was prescribed.)
584         */
585        public MedicationDispenseSubstitutionComponent setType(CodeableConcept value)  { 
586          this.type = value;
587          return this;
588        }
589
590        /**
591         * @return {@link #reason} (Indicates the reason for the substitution of (or lack of substitution) from what was prescribed.)
592         */
593        public List<CodeableConcept> getReason() { 
594          if (this.reason == null)
595            this.reason = new ArrayList<CodeableConcept>();
596          return this.reason;
597        }
598
599        /**
600         * @return Returns a reference to <code>this</code> for easy method chaining
601         */
602        public MedicationDispenseSubstitutionComponent setReason(List<CodeableConcept> theReason) { 
603          this.reason = theReason;
604          return this;
605        }
606
607        public boolean hasReason() { 
608          if (this.reason == null)
609            return false;
610          for (CodeableConcept item : this.reason)
611            if (!item.isEmpty())
612              return true;
613          return false;
614        }
615
616        public CodeableConcept addReason() { //3
617          CodeableConcept t = new CodeableConcept();
618          if (this.reason == null)
619            this.reason = new ArrayList<CodeableConcept>();
620          this.reason.add(t);
621          return t;
622        }
623
624        public MedicationDispenseSubstitutionComponent addReason(CodeableConcept t) { //3
625          if (t == null)
626            return this;
627          if (this.reason == null)
628            this.reason = new ArrayList<CodeableConcept>();
629          this.reason.add(t);
630          return this;
631        }
632
633        /**
634         * @return The first repetition of repeating field {@link #reason}, creating it if it does not already exist
635         */
636        public CodeableConcept getReasonFirstRep() { 
637          if (getReason().isEmpty()) {
638            addReason();
639          }
640          return getReason().get(0);
641        }
642
643        /**
644         * @return {@link #responsibleParty} (The person or organization that has primary responsibility for the substitution.)
645         */
646        public List<Reference> getResponsibleParty() { 
647          if (this.responsibleParty == null)
648            this.responsibleParty = new ArrayList<Reference>();
649          return this.responsibleParty;
650        }
651
652        /**
653         * @return Returns a reference to <code>this</code> for easy method chaining
654         */
655        public MedicationDispenseSubstitutionComponent setResponsibleParty(List<Reference> theResponsibleParty) { 
656          this.responsibleParty = theResponsibleParty;
657          return this;
658        }
659
660        public boolean hasResponsibleParty() { 
661          if (this.responsibleParty == null)
662            return false;
663          for (Reference item : this.responsibleParty)
664            if (!item.isEmpty())
665              return true;
666          return false;
667        }
668
669        public Reference addResponsibleParty() { //3
670          Reference t = new Reference();
671          if (this.responsibleParty == null)
672            this.responsibleParty = new ArrayList<Reference>();
673          this.responsibleParty.add(t);
674          return t;
675        }
676
677        public MedicationDispenseSubstitutionComponent addResponsibleParty(Reference t) { //3
678          if (t == null)
679            return this;
680          if (this.responsibleParty == null)
681            this.responsibleParty = new ArrayList<Reference>();
682          this.responsibleParty.add(t);
683          return this;
684        }
685
686        /**
687         * @return The first repetition of repeating field {@link #responsibleParty}, creating it if it does not already exist
688         */
689        public Reference getResponsiblePartyFirstRep() { 
690          if (getResponsibleParty().isEmpty()) {
691            addResponsibleParty();
692          }
693          return getResponsibleParty().get(0);
694        }
695
696        protected void listChildren(List<Property> children) {
697          super.listChildren(children);
698          children.add(new Property("wasSubstituted", "boolean", "True if the dispenser dispensed a different drug or product from what was prescribed.", 0, 1, wasSubstituted));
699          children.add(new Property("type", "CodeableConcept", "A code signifying whether a different drug was dispensed from what was prescribed.", 0, 1, type));
700          children.add(new Property("reason", "CodeableConcept", "Indicates the reason for the substitution of (or lack of substitution) from what was prescribed.", 0, java.lang.Integer.MAX_VALUE, reason));
701          children.add(new Property("responsibleParty", "Reference(Practitioner)", "The person or organization that has primary responsibility for the substitution.", 0, java.lang.Integer.MAX_VALUE, responsibleParty));
702        }
703
704        @Override
705        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
706          switch (_hash) {
707          case -592113567: /*wasSubstituted*/  return new Property("wasSubstituted", "boolean", "True if the dispenser dispensed a different drug or product from what was prescribed.", 0, 1, wasSubstituted);
708          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "A code signifying whether a different drug was dispensed from what was prescribed.", 0, 1, type);
709          case -934964668: /*reason*/  return new Property("reason", "CodeableConcept", "Indicates the reason for the substitution of (or lack of substitution) from what was prescribed.", 0, java.lang.Integer.MAX_VALUE, reason);
710          case 1511509392: /*responsibleParty*/  return new Property("responsibleParty", "Reference(Practitioner)", "The person or organization that has primary responsibility for the substitution.", 0, java.lang.Integer.MAX_VALUE, responsibleParty);
711          default: return super.getNamedProperty(_hash, _name, _checkValid);
712          }
713
714        }
715
716      @Override
717      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
718        switch (hash) {
719        case -592113567: /*wasSubstituted*/ return this.wasSubstituted == null ? new Base[0] : new Base[] {this.wasSubstituted}; // BooleanType
720        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
721        case -934964668: /*reason*/ return this.reason == null ? new Base[0] : this.reason.toArray(new Base[this.reason.size()]); // CodeableConcept
722        case 1511509392: /*responsibleParty*/ return this.responsibleParty == null ? new Base[0] : this.responsibleParty.toArray(new Base[this.responsibleParty.size()]); // Reference
723        default: return super.getProperty(hash, name, checkValid);
724        }
725
726      }
727
728      @Override
729      public Base setProperty(int hash, String name, Base value) throws FHIRException {
730        switch (hash) {
731        case -592113567: // wasSubstituted
732          this.wasSubstituted = castToBoolean(value); // BooleanType
733          return value;
734        case 3575610: // type
735          this.type = castToCodeableConcept(value); // CodeableConcept
736          return value;
737        case -934964668: // reason
738          this.getReason().add(castToCodeableConcept(value)); // CodeableConcept
739          return value;
740        case 1511509392: // responsibleParty
741          this.getResponsibleParty().add(castToReference(value)); // Reference
742          return value;
743        default: return super.setProperty(hash, name, value);
744        }
745
746      }
747
748      @Override
749      public Base setProperty(String name, Base value) throws FHIRException {
750        if (name.equals("wasSubstituted")) {
751          this.wasSubstituted = castToBoolean(value); // BooleanType
752        } else if (name.equals("type")) {
753          this.type = castToCodeableConcept(value); // CodeableConcept
754        } else if (name.equals("reason")) {
755          this.getReason().add(castToCodeableConcept(value));
756        } else if (name.equals("responsibleParty")) {
757          this.getResponsibleParty().add(castToReference(value));
758        } else
759          return super.setProperty(name, value);
760        return value;
761      }
762
763      @Override
764      public Base makeProperty(int hash, String name) throws FHIRException {
765        switch (hash) {
766        case -592113567:  return getWasSubstitutedElement();
767        case 3575610:  return getType(); 
768        case -934964668:  return addReason(); 
769        case 1511509392:  return addResponsibleParty(); 
770        default: return super.makeProperty(hash, name);
771        }
772
773      }
774
775      @Override
776      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
777        switch (hash) {
778        case -592113567: /*wasSubstituted*/ return new String[] {"boolean"};
779        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
780        case -934964668: /*reason*/ return new String[] {"CodeableConcept"};
781        case 1511509392: /*responsibleParty*/ return new String[] {"Reference"};
782        default: return super.getTypesForProperty(hash, name);
783        }
784
785      }
786
787      @Override
788      public Base addChild(String name) throws FHIRException {
789        if (name.equals("wasSubstituted")) {
790          throw new FHIRException("Cannot call addChild on a singleton property MedicationDispense.wasSubstituted");
791        }
792        else if (name.equals("type")) {
793          this.type = new CodeableConcept();
794          return this.type;
795        }
796        else if (name.equals("reason")) {
797          return addReason();
798        }
799        else if (name.equals("responsibleParty")) {
800          return addResponsibleParty();
801        }
802        else
803          return super.addChild(name);
804      }
805
806      public MedicationDispenseSubstitutionComponent copy() {
807        MedicationDispenseSubstitutionComponent dst = new MedicationDispenseSubstitutionComponent();
808        copyValues(dst);
809        dst.wasSubstituted = wasSubstituted == null ? null : wasSubstituted.copy();
810        dst.type = type == null ? null : type.copy();
811        if (reason != null) {
812          dst.reason = new ArrayList<CodeableConcept>();
813          for (CodeableConcept i : reason)
814            dst.reason.add(i.copy());
815        };
816        if (responsibleParty != null) {
817          dst.responsibleParty = new ArrayList<Reference>();
818          for (Reference i : responsibleParty)
819            dst.responsibleParty.add(i.copy());
820        };
821        return dst;
822      }
823
824      @Override
825      public boolean equalsDeep(Base other_) {
826        if (!super.equalsDeep(other_))
827          return false;
828        if (!(other_ instanceof MedicationDispenseSubstitutionComponent))
829          return false;
830        MedicationDispenseSubstitutionComponent o = (MedicationDispenseSubstitutionComponent) other_;
831        return compareDeep(wasSubstituted, o.wasSubstituted, true) && compareDeep(type, o.type, true) && compareDeep(reason, o.reason, true)
832           && compareDeep(responsibleParty, o.responsibleParty, true);
833      }
834
835      @Override
836      public boolean equalsShallow(Base other_) {
837        if (!super.equalsShallow(other_))
838          return false;
839        if (!(other_ instanceof MedicationDispenseSubstitutionComponent))
840          return false;
841        MedicationDispenseSubstitutionComponent o = (MedicationDispenseSubstitutionComponent) other_;
842        return compareValues(wasSubstituted, o.wasSubstituted, true);
843      }
844
845      public boolean isEmpty() {
846        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(wasSubstituted, type, reason
847          , responsibleParty);
848      }
849
850  public String fhirType() {
851    return "MedicationDispense.substitution";
852
853  }
854
855  }
856
857    /**
858     * Identifier assigned by the dispensing facility - this is an identifier assigned outside FHIR.
859     */
860    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
861    @Description(shortDefinition="External identifier", formalDefinition="Identifier assigned by the dispensing facility - this is an identifier assigned outside FHIR." )
862    protected List<Identifier> identifier;
863
864    /**
865     * The procedure that the dispense is done because of.
866     */
867    @Child(name = "partOf", type = {Procedure.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
868    @Description(shortDefinition="Event that dispense is part of", formalDefinition="The procedure that the dispense is done because of." )
869    protected List<Reference> partOf;
870    /**
871     * The actual objects that are the target of the reference (The procedure that the dispense is done because of.)
872     */
873    protected List<Procedure> partOfTarget;
874
875
876    /**
877     * A code specifying the state of the set of dispense events.
878     */
879    @Child(name = "status", type = {CodeType.class}, order=2, min=0, max=1, modifier=true, summary=true)
880    @Description(shortDefinition="preparation | in-progress | on-hold | completed | entered-in-error | stopped", formalDefinition="A code specifying the state of the set of dispense events." )
881    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-dispense-status")
882    protected Enumeration<MedicationDispenseStatus> status;
883
884    /**
885     * Indicates type of medication dispense and where the medication is expected to be consumed or administered.
886     */
887    @Child(name = "category", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=false)
888    @Description(shortDefinition="Type of medication dispense", formalDefinition="Indicates type of medication dispense and where the medication is expected to be consumed or administered." )
889    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-dispense-category")
890    protected CodeableConcept category;
891
892    /**
893     * 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.
894     */
895    @Child(name = "medication", type = {CodeableConcept.class, Medication.class}, order=4, min=1, max=1, modifier=false, summary=true)
896    @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." )
897    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-codes")
898    protected Type medication;
899
900    /**
901     * A link to a resource representing the person or the group to whom the medication will be given.
902     */
903    @Child(name = "subject", type = {Patient.class, Group.class}, order=5, min=0, max=1, modifier=false, summary=true)
904    @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." )
905    protected Reference subject;
906
907    /**
908     * The actual object that is the target of the reference (A link to a resource representing the person or the group to whom the medication will be given.)
909     */
910    protected Resource subjectTarget;
911
912    /**
913     * The encounter or episode of care that establishes the context for this event.
914     */
915    @Child(name = "context", type = {Encounter.class, EpisodeOfCare.class}, order=6, min=0, max=1, modifier=false, summary=false)
916    @Description(shortDefinition="Encounter / Episode associated with event", formalDefinition="The encounter or episode of care that establishes the context for this event." )
917    protected Reference context;
918
919    /**
920     * The actual object that is the target of the reference (The encounter or episode of care that establishes the context for this event.)
921     */
922    protected Resource contextTarget;
923
924    /**
925     * Additional information that supports the medication being dispensed.
926     */
927    @Child(name = "supportingInformation", type = {Reference.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
928    @Description(shortDefinition="Information that supports the dispensing of the medication", formalDefinition="Additional information that supports the medication being dispensed." )
929    protected List<Reference> supportingInformation;
930    /**
931     * The actual objects that are the target of the reference (Additional information that supports the medication being dispensed.)
932     */
933    protected List<Resource> supportingInformationTarget;
934
935
936    /**
937     * Indicates who or what performed the event.  It should be assumed that the performer is the dispenser of the medication.
938     */
939    @Child(name = "performer", type = {}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
940    @Description(shortDefinition="Who performed event", formalDefinition="Indicates who or what performed the event.  It should be assumed that the performer is the dispenser of the medication." )
941    protected List<MedicationDispensePerformerComponent> performer;
942
943    /**
944     * Indicates the medication order that is being dispensed against.
945     */
946    @Child(name = "authorizingPrescription", type = {MedicationRequest.class}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
947    @Description(shortDefinition="Medication order that authorizes the dispense", formalDefinition="Indicates the medication order that is being dispensed against." )
948    protected List<Reference> authorizingPrescription;
949    /**
950     * The actual objects that are the target of the reference (Indicates the medication order that is being dispensed against.)
951     */
952    protected List<MedicationRequest> authorizingPrescriptionTarget;
953
954
955    /**
956     * Indicates the type of dispensing event that is performed. For example, Trial Fill, Completion of Trial, Partial Fill, Emergency Fill, Samples, etc.
957     */
958    @Child(name = "type", type = {CodeableConcept.class}, order=10, min=0, max=1, modifier=false, summary=false)
959    @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." )
960    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/v3-ActPharmacySupplyType")
961    protected CodeableConcept type;
962
963    /**
964     * The amount of medication that has been dispensed. Includes unit of measure.
965     */
966    @Child(name = "quantity", type = {SimpleQuantity.class}, order=11, min=0, max=1, modifier=false, summary=false)
967    @Description(shortDefinition="Amount dispensed", formalDefinition="The amount of medication that has been dispensed. Includes unit of measure." )
968    protected SimpleQuantity quantity;
969
970    /**
971     * The amount of medication expressed as a timing amount.
972     */
973    @Child(name = "daysSupply", type = {SimpleQuantity.class}, order=12, min=0, max=1, modifier=false, summary=false)
974    @Description(shortDefinition="Amount of medication expressed as a timing amount", formalDefinition="The amount of medication expressed as a timing amount." )
975    protected SimpleQuantity daysSupply;
976
977    /**
978     * The time when the dispensed product was packaged and reviewed.
979     */
980    @Child(name = "whenPrepared", type = {DateTimeType.class}, order=13, min=0, max=1, modifier=false, summary=true)
981    @Description(shortDefinition="When product was packaged and reviewed", formalDefinition="The time when the dispensed product was packaged and reviewed." )
982    protected DateTimeType whenPrepared;
983
984    /**
985     * The time the dispensed product was provided to the patient or their representative.
986     */
987    @Child(name = "whenHandedOver", type = {DateTimeType.class}, order=14, min=0, max=1, modifier=false, summary=false)
988    @Description(shortDefinition="When product was given out", formalDefinition="The time the dispensed product was provided to the patient or their representative." )
989    protected DateTimeType whenHandedOver;
990
991    /**
992     * Identification of the facility/location where the medication was shipped to, as part of the dispense event.
993     */
994    @Child(name = "destination", type = {Location.class}, order=15, min=0, max=1, modifier=false, summary=false)
995    @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." )
996    protected Reference destination;
997
998    /**
999     * The actual object that is the target of the reference (Identification of the facility/location where the medication was shipped to, as part of the dispense event.)
1000     */
1001    protected Location destinationTarget;
1002
1003    /**
1004     * 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.
1005     */
1006    @Child(name = "receiver", type = {Patient.class, Practitioner.class}, order=16, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1007    @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." )
1008    protected List<Reference> receiver;
1009    /**
1010     * The actual objects that are the target of the reference (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.)
1011     */
1012    protected List<Resource> receiverTarget;
1013
1014
1015    /**
1016     * Extra information about the dispense that could not be conveyed in the other attributes.
1017     */
1018    @Child(name = "note", type = {Annotation.class}, order=17, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1019    @Description(shortDefinition="Information about the dispense", formalDefinition="Extra information about the dispense that could not be conveyed in the other attributes." )
1020    protected List<Annotation> note;
1021
1022    /**
1023     * Indicates how the medication is to be used by the patient.
1024     */
1025    @Child(name = "dosageInstruction", type = {Dosage.class}, order=18, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1026    @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." )
1027    protected List<Dosage> dosageInstruction;
1028
1029    /**
1030     * 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.
1031     */
1032    @Child(name = "substitution", type = {}, order=19, min=0, max=1, modifier=false, summary=false)
1033    @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." )
1034    protected MedicationDispenseSubstitutionComponent substitution;
1035
1036    /**
1037     * 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.
1038     */
1039    @Child(name = "detectedIssue", type = {DetectedIssue.class}, order=20, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1040    @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." )
1041    protected List<Reference> detectedIssue;
1042    /**
1043     * The actual objects that are the target of the reference (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.)
1044     */
1045    protected List<DetectedIssue> detectedIssueTarget;
1046
1047
1048    /**
1049     * True if the dispense was not performed for some reason.
1050     */
1051    @Child(name = "notDone", type = {BooleanType.class}, order=21, min=0, max=1, modifier=false, summary=false)
1052    @Description(shortDefinition="Whether the dispense was or was not performed", formalDefinition="True if the dispense was not performed for some reason." )
1053    protected BooleanType notDone;
1054
1055    /**
1056     * Indicates the reason why a dispense was not performed.
1057     */
1058    @Child(name = "notDoneReason", type = {CodeableConcept.class, DetectedIssue.class}, order=22, min=0, max=1, modifier=false, summary=false)
1059    @Description(shortDefinition="Why a dispense was not performed", formalDefinition="Indicates the reason why a dispense was not performed." )
1060    protected Type notDoneReason;
1061
1062    /**
1063     * A summary of the events of interest that have occurred, such as when the dispense was verified.
1064     */
1065    @Child(name = "eventHistory", type = {Provenance.class}, order=23, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1066    @Description(shortDefinition="A list of releveant lifecycle events", formalDefinition="A summary of the events of interest that have occurred, such as when the dispense was verified." )
1067    protected List<Reference> eventHistory;
1068    /**
1069     * The actual objects that are the target of the reference (A summary of the events of interest that have occurred, such as when the dispense was verified.)
1070     */
1071    protected List<Provenance> eventHistoryTarget;
1072
1073
1074    private static final long serialVersionUID = 1951426869L;
1075
1076  /**
1077   * Constructor
1078   */
1079    public MedicationDispense() {
1080      super();
1081    }
1082
1083  /**
1084   * Constructor
1085   */
1086    public MedicationDispense(Type medication) {
1087      super();
1088      this.medication = medication;
1089    }
1090
1091    /**
1092     * @return {@link #identifier} (Identifier assigned by the dispensing facility - this is an identifier assigned outside FHIR.)
1093     */
1094    public List<Identifier> getIdentifier() { 
1095      if (this.identifier == null)
1096        this.identifier = new ArrayList<Identifier>();
1097      return this.identifier;
1098    }
1099
1100    /**
1101     * @return Returns a reference to <code>this</code> for easy method chaining
1102     */
1103    public MedicationDispense setIdentifier(List<Identifier> theIdentifier) { 
1104      this.identifier = theIdentifier;
1105      return this;
1106    }
1107
1108    public boolean hasIdentifier() { 
1109      if (this.identifier == null)
1110        return false;
1111      for (Identifier item : this.identifier)
1112        if (!item.isEmpty())
1113          return true;
1114      return false;
1115    }
1116
1117    public Identifier addIdentifier() { //3
1118      Identifier t = new Identifier();
1119      if (this.identifier == null)
1120        this.identifier = new ArrayList<Identifier>();
1121      this.identifier.add(t);
1122      return t;
1123    }
1124
1125    public MedicationDispense addIdentifier(Identifier t) { //3
1126      if (t == null)
1127        return this;
1128      if (this.identifier == null)
1129        this.identifier = new ArrayList<Identifier>();
1130      this.identifier.add(t);
1131      return this;
1132    }
1133
1134    /**
1135     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
1136     */
1137    public Identifier getIdentifierFirstRep() { 
1138      if (getIdentifier().isEmpty()) {
1139        addIdentifier();
1140      }
1141      return getIdentifier().get(0);
1142    }
1143
1144    /**
1145     * @return {@link #partOf} (The procedure that the dispense is done because of.)
1146     */
1147    public List<Reference> getPartOf() { 
1148      if (this.partOf == null)
1149        this.partOf = new ArrayList<Reference>();
1150      return this.partOf;
1151    }
1152
1153    /**
1154     * @return Returns a reference to <code>this</code> for easy method chaining
1155     */
1156    public MedicationDispense setPartOf(List<Reference> thePartOf) { 
1157      this.partOf = thePartOf;
1158      return this;
1159    }
1160
1161    public boolean hasPartOf() { 
1162      if (this.partOf == null)
1163        return false;
1164      for (Reference item : this.partOf)
1165        if (!item.isEmpty())
1166          return true;
1167      return false;
1168    }
1169
1170    public Reference addPartOf() { //3
1171      Reference t = new Reference();
1172      if (this.partOf == null)
1173        this.partOf = new ArrayList<Reference>();
1174      this.partOf.add(t);
1175      return t;
1176    }
1177
1178    public MedicationDispense addPartOf(Reference t) { //3
1179      if (t == null)
1180        return this;
1181      if (this.partOf == null)
1182        this.partOf = new ArrayList<Reference>();
1183      this.partOf.add(t);
1184      return this;
1185    }
1186
1187    /**
1188     * @return The first repetition of repeating field {@link #partOf}, creating it if it does not already exist
1189     */
1190    public Reference getPartOfFirstRep() { 
1191      if (getPartOf().isEmpty()) {
1192        addPartOf();
1193      }
1194      return getPartOf().get(0);
1195    }
1196
1197    /**
1198     * @return {@link #status} (A code specifying the state of the set of dispense events.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1199     */
1200    public Enumeration<MedicationDispenseStatus> getStatusElement() { 
1201      if (this.status == null)
1202        if (Configuration.errorOnAutoCreate())
1203          throw new Error("Attempt to auto-create MedicationDispense.status");
1204        else if (Configuration.doAutoCreate())
1205          this.status = new Enumeration<MedicationDispenseStatus>(new MedicationDispenseStatusEnumFactory()); // bb
1206      return this.status;
1207    }
1208
1209    public boolean hasStatusElement() { 
1210      return this.status != null && !this.status.isEmpty();
1211    }
1212
1213    public boolean hasStatus() { 
1214      return this.status != null && !this.status.isEmpty();
1215    }
1216
1217    /**
1218     * @param value {@link #status} (A code specifying the state of the set of dispense events.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1219     */
1220    public MedicationDispense setStatusElement(Enumeration<MedicationDispenseStatus> value) { 
1221      this.status = value;
1222      return this;
1223    }
1224
1225    /**
1226     * @return A code specifying the state of the set of dispense events.
1227     */
1228    public MedicationDispenseStatus getStatus() { 
1229      return this.status == null ? null : this.status.getValue();
1230    }
1231
1232    /**
1233     * @param value A code specifying the state of the set of dispense events.
1234     */
1235    public MedicationDispense setStatus(MedicationDispenseStatus value) { 
1236      if (value == null)
1237        this.status = null;
1238      else {
1239        if (this.status == null)
1240          this.status = new Enumeration<MedicationDispenseStatus>(new MedicationDispenseStatusEnumFactory());
1241        this.status.setValue(value);
1242      }
1243      return this;
1244    }
1245
1246    /**
1247     * @return {@link #category} (Indicates type of medication dispense and where the medication is expected to be consumed or administered.)
1248     */
1249    public CodeableConcept getCategory() { 
1250      if (this.category == null)
1251        if (Configuration.errorOnAutoCreate())
1252          throw new Error("Attempt to auto-create MedicationDispense.category");
1253        else if (Configuration.doAutoCreate())
1254          this.category = new CodeableConcept(); // cc
1255      return this.category;
1256    }
1257
1258    public boolean hasCategory() { 
1259      return this.category != null && !this.category.isEmpty();
1260    }
1261
1262    /**
1263     * @param value {@link #category} (Indicates type of medication dispense and where the medication is expected to be consumed or administered.)
1264     */
1265    public MedicationDispense setCategory(CodeableConcept value)  { 
1266      this.category = value;
1267      return this;
1268    }
1269
1270    /**
1271     * @return {@link #medication} (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.)
1272     */
1273    public Type getMedication() { 
1274      return this.medication;
1275    }
1276
1277    /**
1278     * @return {@link #medication} (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.)
1279     */
1280    public CodeableConcept getMedicationCodeableConcept() throws FHIRException { 
1281      if (this.medication == null)
1282        return null;
1283      if (!(this.medication instanceof CodeableConcept))
1284        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.medication.getClass().getName()+" was encountered");
1285      return (CodeableConcept) this.medication;
1286    }
1287
1288    public boolean hasMedicationCodeableConcept() {
1289        return this.medication instanceof CodeableConcept;
1290    }
1291
1292    /**
1293     * @return {@link #medication} (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.)
1294     */
1295    public Reference getMedicationReference() throws FHIRException { 
1296      if (this.medication == null)
1297        return null;
1298      if (!(this.medication instanceof Reference))
1299        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.medication.getClass().getName()+" was encountered");
1300      return (Reference) this.medication;
1301    }
1302
1303    public boolean hasMedicationReference() {
1304        return this.medication instanceof Reference;
1305    }
1306
1307    public boolean hasMedication() { 
1308      return this.medication != null && !this.medication.isEmpty();
1309    }
1310
1311    /**
1312     * @param value {@link #medication} (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.)
1313     */
1314    public MedicationDispense setMedication(Type value) throws FHIRFormatError { 
1315      if (value != null && !(value instanceof CodeableConcept || value instanceof Reference))
1316        throw new FHIRFormatError("Not the right type for MedicationDispense.medication[x]: "+value.fhirType());
1317      this.medication = value;
1318      return this;
1319    }
1320
1321    /**
1322     * @return {@link #subject} (A link to a resource representing the person or the group to whom the medication will be given.)
1323     */
1324    public Reference getSubject() { 
1325      if (this.subject == null)
1326        if (Configuration.errorOnAutoCreate())
1327          throw new Error("Attempt to auto-create MedicationDispense.subject");
1328        else if (Configuration.doAutoCreate())
1329          this.subject = new Reference(); // cc
1330      return this.subject;
1331    }
1332
1333    public boolean hasSubject() { 
1334      return this.subject != null && !this.subject.isEmpty();
1335    }
1336
1337    /**
1338     * @param value {@link #subject} (A link to a resource representing the person or the group to whom the medication will be given.)
1339     */
1340    public MedicationDispense setSubject(Reference value)  { 
1341      this.subject = value;
1342      return this;
1343    }
1344
1345    /**
1346     * @return {@link #subject} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (A link to a resource representing the person or the group to whom the medication will be given.)
1347     */
1348    public Resource getSubjectTarget() { 
1349      return this.subjectTarget;
1350    }
1351
1352    /**
1353     * @param value {@link #subject} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (A link to a resource representing the person or the group to whom the medication will be given.)
1354     */
1355    public MedicationDispense setSubjectTarget(Resource value) { 
1356      this.subjectTarget = value;
1357      return this;
1358    }
1359
1360    /**
1361     * @return {@link #context} (The encounter or episode of care that establishes the context for this event.)
1362     */
1363    public Reference getContext() { 
1364      if (this.context == null)
1365        if (Configuration.errorOnAutoCreate())
1366          throw new Error("Attempt to auto-create MedicationDispense.context");
1367        else if (Configuration.doAutoCreate())
1368          this.context = new Reference(); // cc
1369      return this.context;
1370    }
1371
1372    public boolean hasContext() { 
1373      return this.context != null && !this.context.isEmpty();
1374    }
1375
1376    /**
1377     * @param value {@link #context} (The encounter or episode of care that establishes the context for this event.)
1378     */
1379    public MedicationDispense setContext(Reference value)  { 
1380      this.context = value;
1381      return this;
1382    }
1383
1384    /**
1385     * @return {@link #context} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The encounter or episode of care that establishes the context for this event.)
1386     */
1387    public Resource getContextTarget() { 
1388      return this.contextTarget;
1389    }
1390
1391    /**
1392     * @param value {@link #context} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The encounter or episode of care that establishes the context for this event.)
1393     */
1394    public MedicationDispense setContextTarget(Resource value) { 
1395      this.contextTarget = value;
1396      return this;
1397    }
1398
1399    /**
1400     * @return {@link #supportingInformation} (Additional information that supports the medication being dispensed.)
1401     */
1402    public List<Reference> getSupportingInformation() { 
1403      if (this.supportingInformation == null)
1404        this.supportingInformation = new ArrayList<Reference>();
1405      return this.supportingInformation;
1406    }
1407
1408    /**
1409     * @return Returns a reference to <code>this</code> for easy method chaining
1410     */
1411    public MedicationDispense setSupportingInformation(List<Reference> theSupportingInformation) { 
1412      this.supportingInformation = theSupportingInformation;
1413      return this;
1414    }
1415
1416    public boolean hasSupportingInformation() { 
1417      if (this.supportingInformation == null)
1418        return false;
1419      for (Reference item : this.supportingInformation)
1420        if (!item.isEmpty())
1421          return true;
1422      return false;
1423    }
1424
1425    public Reference addSupportingInformation() { //3
1426      Reference t = new Reference();
1427      if (this.supportingInformation == null)
1428        this.supportingInformation = new ArrayList<Reference>();
1429      this.supportingInformation.add(t);
1430      return t;
1431    }
1432
1433    public MedicationDispense addSupportingInformation(Reference t) { //3
1434      if (t == null)
1435        return this;
1436      if (this.supportingInformation == null)
1437        this.supportingInformation = new ArrayList<Reference>();
1438      this.supportingInformation.add(t);
1439      return this;
1440    }
1441
1442    /**
1443     * @return The first repetition of repeating field {@link #supportingInformation}, creating it if it does not already exist
1444     */
1445    public Reference getSupportingInformationFirstRep() { 
1446      if (getSupportingInformation().isEmpty()) {
1447        addSupportingInformation();
1448      }
1449      return getSupportingInformation().get(0);
1450    }
1451
1452    /**
1453     * @return {@link #performer} (Indicates who or what performed the event.  It should be assumed that the performer is the dispenser of the medication.)
1454     */
1455    public List<MedicationDispensePerformerComponent> getPerformer() { 
1456      if (this.performer == null)
1457        this.performer = new ArrayList<MedicationDispensePerformerComponent>();
1458      return this.performer;
1459    }
1460
1461    /**
1462     * @return Returns a reference to <code>this</code> for easy method chaining
1463     */
1464    public MedicationDispense setPerformer(List<MedicationDispensePerformerComponent> thePerformer) { 
1465      this.performer = thePerformer;
1466      return this;
1467    }
1468
1469    public boolean hasPerformer() { 
1470      if (this.performer == null)
1471        return false;
1472      for (MedicationDispensePerformerComponent item : this.performer)
1473        if (!item.isEmpty())
1474          return true;
1475      return false;
1476    }
1477
1478    public MedicationDispensePerformerComponent addPerformer() { //3
1479      MedicationDispensePerformerComponent t = new MedicationDispensePerformerComponent();
1480      if (this.performer == null)
1481        this.performer = new ArrayList<MedicationDispensePerformerComponent>();
1482      this.performer.add(t);
1483      return t;
1484    }
1485
1486    public MedicationDispense addPerformer(MedicationDispensePerformerComponent t) { //3
1487      if (t == null)
1488        return this;
1489      if (this.performer == null)
1490        this.performer = new ArrayList<MedicationDispensePerformerComponent>();
1491      this.performer.add(t);
1492      return this;
1493    }
1494
1495    /**
1496     * @return The first repetition of repeating field {@link #performer}, creating it if it does not already exist
1497     */
1498    public MedicationDispensePerformerComponent getPerformerFirstRep() { 
1499      if (getPerformer().isEmpty()) {
1500        addPerformer();
1501      }
1502      return getPerformer().get(0);
1503    }
1504
1505    /**
1506     * @return {@link #authorizingPrescription} (Indicates the medication order that is being dispensed against.)
1507     */
1508    public List<Reference> getAuthorizingPrescription() { 
1509      if (this.authorizingPrescription == null)
1510        this.authorizingPrescription = new ArrayList<Reference>();
1511      return this.authorizingPrescription;
1512    }
1513
1514    /**
1515     * @return Returns a reference to <code>this</code> for easy method chaining
1516     */
1517    public MedicationDispense setAuthorizingPrescription(List<Reference> theAuthorizingPrescription) { 
1518      this.authorizingPrescription = theAuthorizingPrescription;
1519      return this;
1520    }
1521
1522    public boolean hasAuthorizingPrescription() { 
1523      if (this.authorizingPrescription == null)
1524        return false;
1525      for (Reference item : this.authorizingPrescription)
1526        if (!item.isEmpty())
1527          return true;
1528      return false;
1529    }
1530
1531    public Reference addAuthorizingPrescription() { //3
1532      Reference t = new Reference();
1533      if (this.authorizingPrescription == null)
1534        this.authorizingPrescription = new ArrayList<Reference>();
1535      this.authorizingPrescription.add(t);
1536      return t;
1537    }
1538
1539    public MedicationDispense addAuthorizingPrescription(Reference t) { //3
1540      if (t == null)
1541        return this;
1542      if (this.authorizingPrescription == null)
1543        this.authorizingPrescription = new ArrayList<Reference>();
1544      this.authorizingPrescription.add(t);
1545      return this;
1546    }
1547
1548    /**
1549     * @return The first repetition of repeating field {@link #authorizingPrescription}, creating it if it does not already exist
1550     */
1551    public Reference getAuthorizingPrescriptionFirstRep() { 
1552      if (getAuthorizingPrescription().isEmpty()) {
1553        addAuthorizingPrescription();
1554      }
1555      return getAuthorizingPrescription().get(0);
1556    }
1557
1558    /**
1559     * @return {@link #type} (Indicates the type of dispensing event that is performed. For example, Trial Fill, Completion of Trial, Partial Fill, Emergency Fill, Samples, etc.)
1560     */
1561    public CodeableConcept getType() { 
1562      if (this.type == null)
1563        if (Configuration.errorOnAutoCreate())
1564          throw new Error("Attempt to auto-create MedicationDispense.type");
1565        else if (Configuration.doAutoCreate())
1566          this.type = new CodeableConcept(); // cc
1567      return this.type;
1568    }
1569
1570    public boolean hasType() { 
1571      return this.type != null && !this.type.isEmpty();
1572    }
1573
1574    /**
1575     * @param value {@link #type} (Indicates the type of dispensing event that is performed. For example, Trial Fill, Completion of Trial, Partial Fill, Emergency Fill, Samples, etc.)
1576     */
1577    public MedicationDispense setType(CodeableConcept value)  { 
1578      this.type = value;
1579      return this;
1580    }
1581
1582    /**
1583     * @return {@link #quantity} (The amount of medication that has been dispensed. Includes unit of measure.)
1584     */
1585    public SimpleQuantity getQuantity() { 
1586      if (this.quantity == null)
1587        if (Configuration.errorOnAutoCreate())
1588          throw new Error("Attempt to auto-create MedicationDispense.quantity");
1589        else if (Configuration.doAutoCreate())
1590          this.quantity = new SimpleQuantity(); // cc
1591      return this.quantity;
1592    }
1593
1594    public boolean hasQuantity() { 
1595      return this.quantity != null && !this.quantity.isEmpty();
1596    }
1597
1598    /**
1599     * @param value {@link #quantity} (The amount of medication that has been dispensed. Includes unit of measure.)
1600     */
1601    public MedicationDispense setQuantity(SimpleQuantity value)  { 
1602      this.quantity = value;
1603      return this;
1604    }
1605
1606    /**
1607     * @return {@link #daysSupply} (The amount of medication expressed as a timing amount.)
1608     */
1609    public SimpleQuantity getDaysSupply() { 
1610      if (this.daysSupply == null)
1611        if (Configuration.errorOnAutoCreate())
1612          throw new Error("Attempt to auto-create MedicationDispense.daysSupply");
1613        else if (Configuration.doAutoCreate())
1614          this.daysSupply = new SimpleQuantity(); // cc
1615      return this.daysSupply;
1616    }
1617
1618    public boolean hasDaysSupply() { 
1619      return this.daysSupply != null && !this.daysSupply.isEmpty();
1620    }
1621
1622    /**
1623     * @param value {@link #daysSupply} (The amount of medication expressed as a timing amount.)
1624     */
1625    public MedicationDispense setDaysSupply(SimpleQuantity value)  { 
1626      this.daysSupply = value;
1627      return this;
1628    }
1629
1630    /**
1631     * @return {@link #whenPrepared} (The time when the dispensed product was packaged and reviewed.). This is the underlying object with id, value and extensions. The accessor "getWhenPrepared" gives direct access to the value
1632     */
1633    public DateTimeType getWhenPreparedElement() { 
1634      if (this.whenPrepared == null)
1635        if (Configuration.errorOnAutoCreate())
1636          throw new Error("Attempt to auto-create MedicationDispense.whenPrepared");
1637        else if (Configuration.doAutoCreate())
1638          this.whenPrepared = new DateTimeType(); // bb
1639      return this.whenPrepared;
1640    }
1641
1642    public boolean hasWhenPreparedElement() { 
1643      return this.whenPrepared != null && !this.whenPrepared.isEmpty();
1644    }
1645
1646    public boolean hasWhenPrepared() { 
1647      return this.whenPrepared != null && !this.whenPrepared.isEmpty();
1648    }
1649
1650    /**
1651     * @param value {@link #whenPrepared} (The time when the dispensed product was packaged and reviewed.). This is the underlying object with id, value and extensions. The accessor "getWhenPrepared" gives direct access to the value
1652     */
1653    public MedicationDispense setWhenPreparedElement(DateTimeType value) { 
1654      this.whenPrepared = value;
1655      return this;
1656    }
1657
1658    /**
1659     * @return The time when the dispensed product was packaged and reviewed.
1660     */
1661    public Date getWhenPrepared() { 
1662      return this.whenPrepared == null ? null : this.whenPrepared.getValue();
1663    }
1664
1665    /**
1666     * @param value The time when the dispensed product was packaged and reviewed.
1667     */
1668    public MedicationDispense setWhenPrepared(Date value) { 
1669      if (value == null)
1670        this.whenPrepared = null;
1671      else {
1672        if (this.whenPrepared == null)
1673          this.whenPrepared = new DateTimeType();
1674        this.whenPrepared.setValue(value);
1675      }
1676      return this;
1677    }
1678
1679    /**
1680     * @return {@link #whenHandedOver} (The time the dispensed product was provided to the patient or their representative.). This is the underlying object with id, value and extensions. The accessor "getWhenHandedOver" gives direct access to the value
1681     */
1682    public DateTimeType getWhenHandedOverElement() { 
1683      if (this.whenHandedOver == null)
1684        if (Configuration.errorOnAutoCreate())
1685          throw new Error("Attempt to auto-create MedicationDispense.whenHandedOver");
1686        else if (Configuration.doAutoCreate())
1687          this.whenHandedOver = new DateTimeType(); // bb
1688      return this.whenHandedOver;
1689    }
1690
1691    public boolean hasWhenHandedOverElement() { 
1692      return this.whenHandedOver != null && !this.whenHandedOver.isEmpty();
1693    }
1694
1695    public boolean hasWhenHandedOver() { 
1696      return this.whenHandedOver != null && !this.whenHandedOver.isEmpty();
1697    }
1698
1699    /**
1700     * @param value {@link #whenHandedOver} (The time the dispensed product was provided to the patient or their representative.). This is the underlying object with id, value and extensions. The accessor "getWhenHandedOver" gives direct access to the value
1701     */
1702    public MedicationDispense setWhenHandedOverElement(DateTimeType value) { 
1703      this.whenHandedOver = value;
1704      return this;
1705    }
1706
1707    /**
1708     * @return The time the dispensed product was provided to the patient or their representative.
1709     */
1710    public Date getWhenHandedOver() { 
1711      return this.whenHandedOver == null ? null : this.whenHandedOver.getValue();
1712    }
1713
1714    /**
1715     * @param value The time the dispensed product was provided to the patient or their representative.
1716     */
1717    public MedicationDispense setWhenHandedOver(Date value) { 
1718      if (value == null)
1719        this.whenHandedOver = null;
1720      else {
1721        if (this.whenHandedOver == null)
1722          this.whenHandedOver = new DateTimeType();
1723        this.whenHandedOver.setValue(value);
1724      }
1725      return this;
1726    }
1727
1728    /**
1729     * @return {@link #destination} (Identification of the facility/location where the medication was shipped to, as part of the dispense event.)
1730     */
1731    public Reference getDestination() { 
1732      if (this.destination == null)
1733        if (Configuration.errorOnAutoCreate())
1734          throw new Error("Attempt to auto-create MedicationDispense.destination");
1735        else if (Configuration.doAutoCreate())
1736          this.destination = new Reference(); // cc
1737      return this.destination;
1738    }
1739
1740    public boolean hasDestination() { 
1741      return this.destination != null && !this.destination.isEmpty();
1742    }
1743
1744    /**
1745     * @param value {@link #destination} (Identification of the facility/location where the medication was shipped to, as part of the dispense event.)
1746     */
1747    public MedicationDispense setDestination(Reference value)  { 
1748      this.destination = value;
1749      return this;
1750    }
1751
1752    /**
1753     * @return {@link #destination} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Identification of the facility/location where the medication was shipped to, as part of the dispense event.)
1754     */
1755    public Location getDestinationTarget() { 
1756      if (this.destinationTarget == null)
1757        if (Configuration.errorOnAutoCreate())
1758          throw new Error("Attempt to auto-create MedicationDispense.destination");
1759        else if (Configuration.doAutoCreate())
1760          this.destinationTarget = new Location(); // aa
1761      return this.destinationTarget;
1762    }
1763
1764    /**
1765     * @param value {@link #destination} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Identification of the facility/location where the medication was shipped to, as part of the dispense event.)
1766     */
1767    public MedicationDispense setDestinationTarget(Location value) { 
1768      this.destinationTarget = value;
1769      return this;
1770    }
1771
1772    /**
1773     * @return {@link #receiver} (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.)
1774     */
1775    public List<Reference> getReceiver() { 
1776      if (this.receiver == null)
1777        this.receiver = new ArrayList<Reference>();
1778      return this.receiver;
1779    }
1780
1781    /**
1782     * @return Returns a reference to <code>this</code> for easy method chaining
1783     */
1784    public MedicationDispense setReceiver(List<Reference> theReceiver) { 
1785      this.receiver = theReceiver;
1786      return this;
1787    }
1788
1789    public boolean hasReceiver() { 
1790      if (this.receiver == null)
1791        return false;
1792      for (Reference item : this.receiver)
1793        if (!item.isEmpty())
1794          return true;
1795      return false;
1796    }
1797
1798    public Reference addReceiver() { //3
1799      Reference t = new Reference();
1800      if (this.receiver == null)
1801        this.receiver = new ArrayList<Reference>();
1802      this.receiver.add(t);
1803      return t;
1804    }
1805
1806    public MedicationDispense addReceiver(Reference t) { //3
1807      if (t == null)
1808        return this;
1809      if (this.receiver == null)
1810        this.receiver = new ArrayList<Reference>();
1811      this.receiver.add(t);
1812      return this;
1813    }
1814
1815    /**
1816     * @return The first repetition of repeating field {@link #receiver}, creating it if it does not already exist
1817     */
1818    public Reference getReceiverFirstRep() { 
1819      if (getReceiver().isEmpty()) {
1820        addReceiver();
1821      }
1822      return getReceiver().get(0);
1823    }
1824
1825    /**
1826     * @return {@link #note} (Extra information about the dispense that could not be conveyed in the other attributes.)
1827     */
1828    public List<Annotation> getNote() { 
1829      if (this.note == null)
1830        this.note = new ArrayList<Annotation>();
1831      return this.note;
1832    }
1833
1834    /**
1835     * @return Returns a reference to <code>this</code> for easy method chaining
1836     */
1837    public MedicationDispense setNote(List<Annotation> theNote) { 
1838      this.note = theNote;
1839      return this;
1840    }
1841
1842    public boolean hasNote() { 
1843      if (this.note == null)
1844        return false;
1845      for (Annotation item : this.note)
1846        if (!item.isEmpty())
1847          return true;
1848      return false;
1849    }
1850
1851    public Annotation addNote() { //3
1852      Annotation t = new Annotation();
1853      if (this.note == null)
1854        this.note = new ArrayList<Annotation>();
1855      this.note.add(t);
1856      return t;
1857    }
1858
1859    public MedicationDispense addNote(Annotation t) { //3
1860      if (t == null)
1861        return this;
1862      if (this.note == null)
1863        this.note = new ArrayList<Annotation>();
1864      this.note.add(t);
1865      return this;
1866    }
1867
1868    /**
1869     * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist
1870     */
1871    public Annotation getNoteFirstRep() { 
1872      if (getNote().isEmpty()) {
1873        addNote();
1874      }
1875      return getNote().get(0);
1876    }
1877
1878    /**
1879     * @return {@link #dosageInstruction} (Indicates how the medication is to be used by the patient.)
1880     */
1881    public List<Dosage> getDosageInstruction() { 
1882      if (this.dosageInstruction == null)
1883        this.dosageInstruction = new ArrayList<Dosage>();
1884      return this.dosageInstruction;
1885    }
1886
1887    /**
1888     * @return Returns a reference to <code>this</code> for easy method chaining
1889     */
1890    public MedicationDispense setDosageInstruction(List<Dosage> theDosageInstruction) { 
1891      this.dosageInstruction = theDosageInstruction;
1892      return this;
1893    }
1894
1895    public boolean hasDosageInstruction() { 
1896      if (this.dosageInstruction == null)
1897        return false;
1898      for (Dosage item : this.dosageInstruction)
1899        if (!item.isEmpty())
1900          return true;
1901      return false;
1902    }
1903
1904    public Dosage addDosageInstruction() { //3
1905      Dosage t = new Dosage();
1906      if (this.dosageInstruction == null)
1907        this.dosageInstruction = new ArrayList<Dosage>();
1908      this.dosageInstruction.add(t);
1909      return t;
1910    }
1911
1912    public MedicationDispense addDosageInstruction(Dosage t) { //3
1913      if (t == null)
1914        return this;
1915      if (this.dosageInstruction == null)
1916        this.dosageInstruction = new ArrayList<Dosage>();
1917      this.dosageInstruction.add(t);
1918      return this;
1919    }
1920
1921    /**
1922     * @return The first repetition of repeating field {@link #dosageInstruction}, creating it if it does not already exist
1923     */
1924    public Dosage getDosageInstructionFirstRep() { 
1925      if (getDosageInstruction().isEmpty()) {
1926        addDosageInstruction();
1927      }
1928      return getDosageInstruction().get(0);
1929    }
1930
1931    /**
1932     * @return {@link #substitution} (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.)
1933     */
1934    public MedicationDispenseSubstitutionComponent getSubstitution() { 
1935      if (this.substitution == null)
1936        if (Configuration.errorOnAutoCreate())
1937          throw new Error("Attempt to auto-create MedicationDispense.substitution");
1938        else if (Configuration.doAutoCreate())
1939          this.substitution = new MedicationDispenseSubstitutionComponent(); // cc
1940      return this.substitution;
1941    }
1942
1943    public boolean hasSubstitution() { 
1944      return this.substitution != null && !this.substitution.isEmpty();
1945    }
1946
1947    /**
1948     * @param value {@link #substitution} (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.)
1949     */
1950    public MedicationDispense setSubstitution(MedicationDispenseSubstitutionComponent value)  { 
1951      this.substitution = value;
1952      return this;
1953    }
1954
1955    /**
1956     * @return {@link #detectedIssue} (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.)
1957     */
1958    public List<Reference> getDetectedIssue() { 
1959      if (this.detectedIssue == null)
1960        this.detectedIssue = new ArrayList<Reference>();
1961      return this.detectedIssue;
1962    }
1963
1964    /**
1965     * @return Returns a reference to <code>this</code> for easy method chaining
1966     */
1967    public MedicationDispense setDetectedIssue(List<Reference> theDetectedIssue) { 
1968      this.detectedIssue = theDetectedIssue;
1969      return this;
1970    }
1971
1972    public boolean hasDetectedIssue() { 
1973      if (this.detectedIssue == null)
1974        return false;
1975      for (Reference item : this.detectedIssue)
1976        if (!item.isEmpty())
1977          return true;
1978      return false;
1979    }
1980
1981    public Reference addDetectedIssue() { //3
1982      Reference t = new Reference();
1983      if (this.detectedIssue == null)
1984        this.detectedIssue = new ArrayList<Reference>();
1985      this.detectedIssue.add(t);
1986      return t;
1987    }
1988
1989    public MedicationDispense addDetectedIssue(Reference t) { //3
1990      if (t == null)
1991        return this;
1992      if (this.detectedIssue == null)
1993        this.detectedIssue = new ArrayList<Reference>();
1994      this.detectedIssue.add(t);
1995      return this;
1996    }
1997
1998    /**
1999     * @return The first repetition of repeating field {@link #detectedIssue}, creating it if it does not already exist
2000     */
2001    public Reference getDetectedIssueFirstRep() { 
2002      if (getDetectedIssue().isEmpty()) {
2003        addDetectedIssue();
2004      }
2005      return getDetectedIssue().get(0);
2006    }
2007
2008    /**
2009     * @return {@link #notDone} (True if the dispense was not performed for some reason.). This is the underlying object with id, value and extensions. The accessor "getNotDone" gives direct access to the value
2010     */
2011    public BooleanType getNotDoneElement() { 
2012      if (this.notDone == null)
2013        if (Configuration.errorOnAutoCreate())
2014          throw new Error("Attempt to auto-create MedicationDispense.notDone");
2015        else if (Configuration.doAutoCreate())
2016          this.notDone = new BooleanType(); // bb
2017      return this.notDone;
2018    }
2019
2020    public boolean hasNotDoneElement() { 
2021      return this.notDone != null && !this.notDone.isEmpty();
2022    }
2023
2024    public boolean hasNotDone() { 
2025      return this.notDone != null && !this.notDone.isEmpty();
2026    }
2027
2028    /**
2029     * @param value {@link #notDone} (True if the dispense was not performed for some reason.). This is the underlying object with id, value and extensions. The accessor "getNotDone" gives direct access to the value
2030     */
2031    public MedicationDispense setNotDoneElement(BooleanType value) { 
2032      this.notDone = value;
2033      return this;
2034    }
2035
2036    /**
2037     * @return True if the dispense was not performed for some reason.
2038     */
2039    public boolean getNotDone() { 
2040      return this.notDone == null || this.notDone.isEmpty() ? false : this.notDone.getValue();
2041    }
2042
2043    /**
2044     * @param value True if the dispense was not performed for some reason.
2045     */
2046    public MedicationDispense setNotDone(boolean value) { 
2047        if (this.notDone == null)
2048          this.notDone = new BooleanType();
2049        this.notDone.setValue(value);
2050      return this;
2051    }
2052
2053    /**
2054     * @return {@link #notDoneReason} (Indicates the reason why a dispense was not performed.)
2055     */
2056    public Type getNotDoneReason() { 
2057      return this.notDoneReason;
2058    }
2059
2060    /**
2061     * @return {@link #notDoneReason} (Indicates the reason why a dispense was not performed.)
2062     */
2063    public CodeableConcept getNotDoneReasonCodeableConcept() throws FHIRException { 
2064      if (this.notDoneReason == null)
2065        return null;
2066      if (!(this.notDoneReason instanceof CodeableConcept))
2067        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.notDoneReason.getClass().getName()+" was encountered");
2068      return (CodeableConcept) this.notDoneReason;
2069    }
2070
2071    public boolean hasNotDoneReasonCodeableConcept() {
2072        return this.notDoneReason instanceof CodeableConcept;
2073    }
2074
2075    /**
2076     * @return {@link #notDoneReason} (Indicates the reason why a dispense was not performed.)
2077     */
2078    public Reference getNotDoneReasonReference() throws FHIRException { 
2079      if (this.notDoneReason == null)
2080        return null;
2081      if (!(this.notDoneReason instanceof Reference))
2082        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.notDoneReason.getClass().getName()+" was encountered");
2083      return (Reference) this.notDoneReason;
2084    }
2085
2086    public boolean hasNotDoneReasonReference() {
2087        return this.notDoneReason instanceof Reference;
2088    }
2089
2090    public boolean hasNotDoneReason() { 
2091      return this.notDoneReason != null && !this.notDoneReason.isEmpty();
2092    }
2093
2094    /**
2095     * @param value {@link #notDoneReason} (Indicates the reason why a dispense was not performed.)
2096     */
2097    public MedicationDispense setNotDoneReason(Type value) throws FHIRFormatError { 
2098      if (value != null && !(value instanceof CodeableConcept || value instanceof Reference))
2099        throw new FHIRFormatError("Not the right type for MedicationDispense.notDoneReason[x]: "+value.fhirType());
2100      this.notDoneReason = value;
2101      return this;
2102    }
2103
2104    /**
2105     * @return {@link #eventHistory} (A summary of the events of interest that have occurred, such as when the dispense was verified.)
2106     */
2107    public List<Reference> getEventHistory() { 
2108      if (this.eventHistory == null)
2109        this.eventHistory = new ArrayList<Reference>();
2110      return this.eventHistory;
2111    }
2112
2113    /**
2114     * @return Returns a reference to <code>this</code> for easy method chaining
2115     */
2116    public MedicationDispense setEventHistory(List<Reference> theEventHistory) { 
2117      this.eventHistory = theEventHistory;
2118      return this;
2119    }
2120
2121    public boolean hasEventHistory() { 
2122      if (this.eventHistory == null)
2123        return false;
2124      for (Reference item : this.eventHistory)
2125        if (!item.isEmpty())
2126          return true;
2127      return false;
2128    }
2129
2130    public Reference addEventHistory() { //3
2131      Reference t = new Reference();
2132      if (this.eventHistory == null)
2133        this.eventHistory = new ArrayList<Reference>();
2134      this.eventHistory.add(t);
2135      return t;
2136    }
2137
2138    public MedicationDispense addEventHistory(Reference t) { //3
2139      if (t == null)
2140        return this;
2141      if (this.eventHistory == null)
2142        this.eventHistory = new ArrayList<Reference>();
2143      this.eventHistory.add(t);
2144      return this;
2145    }
2146
2147    /**
2148     * @return The first repetition of repeating field {@link #eventHistory}, creating it if it does not already exist
2149     */
2150    public Reference getEventHistoryFirstRep() { 
2151      if (getEventHistory().isEmpty()) {
2152        addEventHistory();
2153      }
2154      return getEventHistory().get(0);
2155    }
2156
2157      protected void listChildren(List<Property> children) {
2158        super.listChildren(children);
2159        children.add(new Property("identifier", "Identifier", "Identifier assigned by the dispensing facility - this is an identifier assigned outside FHIR.", 0, java.lang.Integer.MAX_VALUE, identifier));
2160        children.add(new Property("partOf", "Reference(Procedure)", "The procedure that the dispense is done because of.", 0, java.lang.Integer.MAX_VALUE, partOf));
2161        children.add(new Property("status", "code", "A code specifying the state of the set of dispense events.", 0, 1, status));
2162        children.add(new Property("category", "CodeableConcept", "Indicates type of medication dispense and where the medication is expected to be consumed or administered.", 0, 1, category));
2163        children.add(new Property("medication[x]", "CodeableConcept|Reference(Medication)", "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.", 0, 1, medication));
2164        children.add(new Property("subject", "Reference(Patient|Group)", "A link to a resource representing the person or the group to whom the medication will be given.", 0, 1, subject));
2165        children.add(new Property("context", "Reference(Encounter|EpisodeOfCare)", "The encounter or episode of care that establishes the context for this event.", 0, 1, context));
2166        children.add(new Property("supportingInformation", "Reference(Any)", "Additional information that supports the medication being dispensed.", 0, java.lang.Integer.MAX_VALUE, supportingInformation));
2167        children.add(new Property("performer", "", "Indicates who or what performed the event.  It should be assumed that the performer is the dispenser of the medication.", 0, java.lang.Integer.MAX_VALUE, performer));
2168        children.add(new Property("authorizingPrescription", "Reference(MedicationRequest)", "Indicates the medication order that is being dispensed against.", 0, java.lang.Integer.MAX_VALUE, authorizingPrescription));
2169        children.add(new Property("type", "CodeableConcept", "Indicates the type of dispensing event that is performed. For example, Trial Fill, Completion of Trial, Partial Fill, Emergency Fill, Samples, etc.", 0, 1, type));
2170        children.add(new Property("quantity", "SimpleQuantity", "The amount of medication that has been dispensed. Includes unit of measure.", 0, 1, quantity));
2171        children.add(new Property("daysSupply", "SimpleQuantity", "The amount of medication expressed as a timing amount.", 0, 1, daysSupply));
2172        children.add(new Property("whenPrepared", "dateTime", "The time when the dispensed product was packaged and reviewed.", 0, 1, whenPrepared));
2173        children.add(new Property("whenHandedOver", "dateTime", "The time the dispensed product was provided to the patient or their representative.", 0, 1, whenHandedOver));
2174        children.add(new Property("destination", "Reference(Location)", "Identification of the facility/location where the medication was shipped to, as part of the dispense event.", 0, 1, destination));
2175        children.add(new Property("receiver", "Reference(Patient|Practitioner)", "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.", 0, java.lang.Integer.MAX_VALUE, receiver));
2176        children.add(new Property("note", "Annotation", "Extra information about the dispense that could not be conveyed in the other attributes.", 0, java.lang.Integer.MAX_VALUE, note));
2177        children.add(new Property("dosageInstruction", "Dosage", "Indicates how the medication is to be used by the patient.", 0, java.lang.Integer.MAX_VALUE, dosageInstruction));
2178        children.add(new Property("substitution", "", "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.", 0, 1, substitution));
2179        children.add(new Property("detectedIssue", "Reference(DetectedIssue)", "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.", 0, java.lang.Integer.MAX_VALUE, detectedIssue));
2180        children.add(new Property("notDone", "boolean", "True if the dispense was not performed for some reason.", 0, 1, notDone));
2181        children.add(new Property("notDoneReason[x]", "CodeableConcept|Reference(DetectedIssue)", "Indicates the reason why a dispense was not performed.", 0, 1, notDoneReason));
2182        children.add(new Property("eventHistory", "Reference(Provenance)", "A summary of the events of interest that have occurred, such as when the dispense was verified.", 0, java.lang.Integer.MAX_VALUE, eventHistory));
2183      }
2184
2185      @Override
2186      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2187        switch (_hash) {
2188        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Identifier assigned by the dispensing facility - this is an identifier assigned outside FHIR.", 0, java.lang.Integer.MAX_VALUE, identifier);
2189        case -995410646: /*partOf*/  return new Property("partOf", "Reference(Procedure)", "The procedure that the dispense is done because of.", 0, java.lang.Integer.MAX_VALUE, partOf);
2190        case -892481550: /*status*/  return new Property("status", "code", "A code specifying the state of the set of dispense events.", 0, 1, status);
2191        case 50511102: /*category*/  return new Property("category", "CodeableConcept", "Indicates type of medication dispense and where the medication is expected to be consumed or administered.", 0, 1, category);
2192        case 1458402129: /*medication[x]*/  return new Property("medication[x]", "CodeableConcept|Reference(Medication)", "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.", 0, 1, medication);
2193        case 1998965455: /*medication*/  return new Property("medication[x]", "CodeableConcept|Reference(Medication)", "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.", 0, 1, medication);
2194        case -209845038: /*medicationCodeableConcept*/  return new Property("medication[x]", "CodeableConcept|Reference(Medication)", "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.", 0, 1, medication);
2195        case 2104315196: /*medicationReference*/  return new Property("medication[x]", "CodeableConcept|Reference(Medication)", "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.", 0, 1, medication);
2196        case -1867885268: /*subject*/  return new Property("subject", "Reference(Patient|Group)", "A link to a resource representing the person or the group to whom the medication will be given.", 0, 1, subject);
2197        case 951530927: /*context*/  return new Property("context", "Reference(Encounter|EpisodeOfCare)", "The encounter or episode of care that establishes the context for this event.", 0, 1, context);
2198        case -1248768647: /*supportingInformation*/  return new Property("supportingInformation", "Reference(Any)", "Additional information that supports the medication being dispensed.", 0, java.lang.Integer.MAX_VALUE, supportingInformation);
2199        case 481140686: /*performer*/  return new Property("performer", "", "Indicates who or what performed the event.  It should be assumed that the performer is the dispenser of the medication.", 0, java.lang.Integer.MAX_VALUE, performer);
2200        case -1237557856: /*authorizingPrescription*/  return new Property("authorizingPrescription", "Reference(MedicationRequest)", "Indicates the medication order that is being dispensed against.", 0, java.lang.Integer.MAX_VALUE, authorizingPrescription);
2201        case 3575610: /*type*/  return new Property("type", "CodeableConcept", "Indicates the type of dispensing event that is performed. For example, Trial Fill, Completion of Trial, Partial Fill, Emergency Fill, Samples, etc.", 0, 1, type);
2202        case -1285004149: /*quantity*/  return new Property("quantity", "SimpleQuantity", "The amount of medication that has been dispensed. Includes unit of measure.", 0, 1, quantity);
2203        case 197175334: /*daysSupply*/  return new Property("daysSupply", "SimpleQuantity", "The amount of medication expressed as a timing amount.", 0, 1, daysSupply);
2204        case -562837097: /*whenPrepared*/  return new Property("whenPrepared", "dateTime", "The time when the dispensed product was packaged and reviewed.", 0, 1, whenPrepared);
2205        case -940241380: /*whenHandedOver*/  return new Property("whenHandedOver", "dateTime", "The time the dispensed product was provided to the patient or their representative.", 0, 1, whenHandedOver);
2206        case -1429847026: /*destination*/  return new Property("destination", "Reference(Location)", "Identification of the facility/location where the medication was shipped to, as part of the dispense event.", 0, 1, destination);
2207        case -808719889: /*receiver*/  return new Property("receiver", "Reference(Patient|Practitioner)", "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.", 0, java.lang.Integer.MAX_VALUE, receiver);
2208        case 3387378: /*note*/  return new Property("note", "Annotation", "Extra information about the dispense that could not be conveyed in the other attributes.", 0, java.lang.Integer.MAX_VALUE, note);
2209        case -1201373865: /*dosageInstruction*/  return new Property("dosageInstruction", "Dosage", "Indicates how the medication is to be used by the patient.", 0, java.lang.Integer.MAX_VALUE, dosageInstruction);
2210        case 826147581: /*substitution*/  return new Property("substitution", "", "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.", 0, 1, substitution);
2211        case 51602295: /*detectedIssue*/  return new Property("detectedIssue", "Reference(DetectedIssue)", "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.", 0, java.lang.Integer.MAX_VALUE, detectedIssue);
2212        case 2128257269: /*notDone*/  return new Property("notDone", "boolean", "True if the dispense was not performed for some reason.", 0, 1, notDone);
2213        case -1762771385: /*notDoneReason[x]*/  return new Property("notDoneReason[x]", "CodeableConcept|Reference(DetectedIssue)", "Indicates the reason why a dispense was not performed.", 0, 1, notDoneReason);
2214        case -1973169255: /*notDoneReason*/  return new Property("notDoneReason[x]", "CodeableConcept|Reference(DetectedIssue)", "Indicates the reason why a dispense was not performed.", 0, 1, notDoneReason);
2215        case -930607416: /*notDoneReasonCodeableConcept*/  return new Property("notDoneReason[x]", "CodeableConcept|Reference(DetectedIssue)", "Indicates the reason why a dispense was not performed.", 0, 1, notDoneReason);
2216        case 1030457266: /*notDoneReasonReference*/  return new Property("notDoneReason[x]", "CodeableConcept|Reference(DetectedIssue)", "Indicates the reason why a dispense was not performed.", 0, 1, notDoneReason);
2217        case 1835190426: /*eventHistory*/  return new Property("eventHistory", "Reference(Provenance)", "A summary of the events of interest that have occurred, such as when the dispense was verified.", 0, java.lang.Integer.MAX_VALUE, eventHistory);
2218        default: return super.getNamedProperty(_hash, _name, _checkValid);
2219        }
2220
2221      }
2222
2223      @Override
2224      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2225        switch (hash) {
2226        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
2227        case -995410646: /*partOf*/ return this.partOf == null ? new Base[0] : this.partOf.toArray(new Base[this.partOf.size()]); // Reference
2228        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<MedicationDispenseStatus>
2229        case 50511102: /*category*/ return this.category == null ? new Base[0] : new Base[] {this.category}; // CodeableConcept
2230        case 1998965455: /*medication*/ return this.medication == null ? new Base[0] : new Base[] {this.medication}; // Type
2231        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
2232        case 951530927: /*context*/ return this.context == null ? new Base[0] : new Base[] {this.context}; // Reference
2233        case -1248768647: /*supportingInformation*/ return this.supportingInformation == null ? new Base[0] : this.supportingInformation.toArray(new Base[this.supportingInformation.size()]); // Reference
2234        case 481140686: /*performer*/ return this.performer == null ? new Base[0] : this.performer.toArray(new Base[this.performer.size()]); // MedicationDispensePerformerComponent
2235        case -1237557856: /*authorizingPrescription*/ return this.authorizingPrescription == null ? new Base[0] : this.authorizingPrescription.toArray(new Base[this.authorizingPrescription.size()]); // Reference
2236        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
2237        case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // SimpleQuantity
2238        case 197175334: /*daysSupply*/ return this.daysSupply == null ? new Base[0] : new Base[] {this.daysSupply}; // SimpleQuantity
2239        case -562837097: /*whenPrepared*/ return this.whenPrepared == null ? new Base[0] : new Base[] {this.whenPrepared}; // DateTimeType
2240        case -940241380: /*whenHandedOver*/ return this.whenHandedOver == null ? new Base[0] : new Base[] {this.whenHandedOver}; // DateTimeType
2241        case -1429847026: /*destination*/ return this.destination == null ? new Base[0] : new Base[] {this.destination}; // Reference
2242        case -808719889: /*receiver*/ return this.receiver == null ? new Base[0] : this.receiver.toArray(new Base[this.receiver.size()]); // Reference
2243        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
2244        case -1201373865: /*dosageInstruction*/ return this.dosageInstruction == null ? new Base[0] : this.dosageInstruction.toArray(new Base[this.dosageInstruction.size()]); // Dosage
2245        case 826147581: /*substitution*/ return this.substitution == null ? new Base[0] : new Base[] {this.substitution}; // MedicationDispenseSubstitutionComponent
2246        case 51602295: /*detectedIssue*/ return this.detectedIssue == null ? new Base[0] : this.detectedIssue.toArray(new Base[this.detectedIssue.size()]); // Reference
2247        case 2128257269: /*notDone*/ return this.notDone == null ? new Base[0] : new Base[] {this.notDone}; // BooleanType
2248        case -1973169255: /*notDoneReason*/ return this.notDoneReason == null ? new Base[0] : new Base[] {this.notDoneReason}; // Type
2249        case 1835190426: /*eventHistory*/ return this.eventHistory == null ? new Base[0] : this.eventHistory.toArray(new Base[this.eventHistory.size()]); // Reference
2250        default: return super.getProperty(hash, name, checkValid);
2251        }
2252
2253      }
2254
2255      @Override
2256      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2257        switch (hash) {
2258        case -1618432855: // identifier
2259          this.getIdentifier().add(castToIdentifier(value)); // Identifier
2260          return value;
2261        case -995410646: // partOf
2262          this.getPartOf().add(castToReference(value)); // Reference
2263          return value;
2264        case -892481550: // status
2265          value = new MedicationDispenseStatusEnumFactory().fromType(castToCode(value));
2266          this.status = (Enumeration) value; // Enumeration<MedicationDispenseStatus>
2267          return value;
2268        case 50511102: // category
2269          this.category = castToCodeableConcept(value); // CodeableConcept
2270          return value;
2271        case 1998965455: // medication
2272          this.medication = castToType(value); // Type
2273          return value;
2274        case -1867885268: // subject
2275          this.subject = castToReference(value); // Reference
2276          return value;
2277        case 951530927: // context
2278          this.context = castToReference(value); // Reference
2279          return value;
2280        case -1248768647: // supportingInformation
2281          this.getSupportingInformation().add(castToReference(value)); // Reference
2282          return value;
2283        case 481140686: // performer
2284          this.getPerformer().add((MedicationDispensePerformerComponent) value); // MedicationDispensePerformerComponent
2285          return value;
2286        case -1237557856: // authorizingPrescription
2287          this.getAuthorizingPrescription().add(castToReference(value)); // Reference
2288          return value;
2289        case 3575610: // type
2290          this.type = castToCodeableConcept(value); // CodeableConcept
2291          return value;
2292        case -1285004149: // quantity
2293          this.quantity = castToSimpleQuantity(value); // SimpleQuantity
2294          return value;
2295        case 197175334: // daysSupply
2296          this.daysSupply = castToSimpleQuantity(value); // SimpleQuantity
2297          return value;
2298        case -562837097: // whenPrepared
2299          this.whenPrepared = castToDateTime(value); // DateTimeType
2300          return value;
2301        case -940241380: // whenHandedOver
2302          this.whenHandedOver = castToDateTime(value); // DateTimeType
2303          return value;
2304        case -1429847026: // destination
2305          this.destination = castToReference(value); // Reference
2306          return value;
2307        case -808719889: // receiver
2308          this.getReceiver().add(castToReference(value)); // Reference
2309          return value;
2310        case 3387378: // note
2311          this.getNote().add(castToAnnotation(value)); // Annotation
2312          return value;
2313        case -1201373865: // dosageInstruction
2314          this.getDosageInstruction().add(castToDosage(value)); // Dosage
2315          return value;
2316        case 826147581: // substitution
2317          this.substitution = (MedicationDispenseSubstitutionComponent) value; // MedicationDispenseSubstitutionComponent
2318          return value;
2319        case 51602295: // detectedIssue
2320          this.getDetectedIssue().add(castToReference(value)); // Reference
2321          return value;
2322        case 2128257269: // notDone
2323          this.notDone = castToBoolean(value); // BooleanType
2324          return value;
2325        case -1973169255: // notDoneReason
2326          this.notDoneReason = castToType(value); // Type
2327          return value;
2328        case 1835190426: // eventHistory
2329          this.getEventHistory().add(castToReference(value)); // Reference
2330          return value;
2331        default: return super.setProperty(hash, name, value);
2332        }
2333
2334      }
2335
2336      @Override
2337      public Base setProperty(String name, Base value) throws FHIRException {
2338        if (name.equals("identifier")) {
2339          this.getIdentifier().add(castToIdentifier(value));
2340        } else if (name.equals("partOf")) {
2341          this.getPartOf().add(castToReference(value));
2342        } else if (name.equals("status")) {
2343          value = new MedicationDispenseStatusEnumFactory().fromType(castToCode(value));
2344          this.status = (Enumeration) value; // Enumeration<MedicationDispenseStatus>
2345        } else if (name.equals("category")) {
2346          this.category = castToCodeableConcept(value); // CodeableConcept
2347        } else if (name.equals("medication[x]")) {
2348          this.medication = castToType(value); // Type
2349        } else if (name.equals("subject")) {
2350          this.subject = castToReference(value); // Reference
2351        } else if (name.equals("context")) {
2352          this.context = castToReference(value); // Reference
2353        } else if (name.equals("supportingInformation")) {
2354          this.getSupportingInformation().add(castToReference(value));
2355        } else if (name.equals("performer")) {
2356          this.getPerformer().add((MedicationDispensePerformerComponent) value);
2357        } else if (name.equals("authorizingPrescription")) {
2358          this.getAuthorizingPrescription().add(castToReference(value));
2359        } else if (name.equals("type")) {
2360          this.type = castToCodeableConcept(value); // CodeableConcept
2361        } else if (name.equals("quantity")) {
2362          this.quantity = castToSimpleQuantity(value); // SimpleQuantity
2363        } else if (name.equals("daysSupply")) {
2364          this.daysSupply = castToSimpleQuantity(value); // SimpleQuantity
2365        } else if (name.equals("whenPrepared")) {
2366          this.whenPrepared = castToDateTime(value); // DateTimeType
2367        } else if (name.equals("whenHandedOver")) {
2368          this.whenHandedOver = castToDateTime(value); // DateTimeType
2369        } else if (name.equals("destination")) {
2370          this.destination = castToReference(value); // Reference
2371        } else if (name.equals("receiver")) {
2372          this.getReceiver().add(castToReference(value));
2373        } else if (name.equals("note")) {
2374          this.getNote().add(castToAnnotation(value));
2375        } else if (name.equals("dosageInstruction")) {
2376          this.getDosageInstruction().add(castToDosage(value));
2377        } else if (name.equals("substitution")) {
2378          this.substitution = (MedicationDispenseSubstitutionComponent) value; // MedicationDispenseSubstitutionComponent
2379        } else if (name.equals("detectedIssue")) {
2380          this.getDetectedIssue().add(castToReference(value));
2381        } else if (name.equals("notDone")) {
2382          this.notDone = castToBoolean(value); // BooleanType
2383        } else if (name.equals("notDoneReason[x]")) {
2384          this.notDoneReason = castToType(value); // Type
2385        } else if (name.equals("eventHistory")) {
2386          this.getEventHistory().add(castToReference(value));
2387        } else
2388          return super.setProperty(name, value);
2389        return value;
2390      }
2391
2392      @Override
2393      public Base makeProperty(int hash, String name) throws FHIRException {
2394        switch (hash) {
2395        case -1618432855:  return addIdentifier(); 
2396        case -995410646:  return addPartOf(); 
2397        case -892481550:  return getStatusElement();
2398        case 50511102:  return getCategory(); 
2399        case 1458402129:  return getMedication(); 
2400        case 1998965455:  return getMedication(); 
2401        case -1867885268:  return getSubject(); 
2402        case 951530927:  return getContext(); 
2403        case -1248768647:  return addSupportingInformation(); 
2404        case 481140686:  return addPerformer(); 
2405        case -1237557856:  return addAuthorizingPrescription(); 
2406        case 3575610:  return getType(); 
2407        case -1285004149:  return getQuantity(); 
2408        case 197175334:  return getDaysSupply(); 
2409        case -562837097:  return getWhenPreparedElement();
2410        case -940241380:  return getWhenHandedOverElement();
2411        case -1429847026:  return getDestination(); 
2412        case -808719889:  return addReceiver(); 
2413        case 3387378:  return addNote(); 
2414        case -1201373865:  return addDosageInstruction(); 
2415        case 826147581:  return getSubstitution(); 
2416        case 51602295:  return addDetectedIssue(); 
2417        case 2128257269:  return getNotDoneElement();
2418        case -1762771385:  return getNotDoneReason(); 
2419        case -1973169255:  return getNotDoneReason(); 
2420        case 1835190426:  return addEventHistory(); 
2421        default: return super.makeProperty(hash, name);
2422        }
2423
2424      }
2425
2426      @Override
2427      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2428        switch (hash) {
2429        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
2430        case -995410646: /*partOf*/ return new String[] {"Reference"};
2431        case -892481550: /*status*/ return new String[] {"code"};
2432        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
2433        case 1998965455: /*medication*/ return new String[] {"CodeableConcept", "Reference"};
2434        case -1867885268: /*subject*/ return new String[] {"Reference"};
2435        case 951530927: /*context*/ return new String[] {"Reference"};
2436        case -1248768647: /*supportingInformation*/ return new String[] {"Reference"};
2437        case 481140686: /*performer*/ return new String[] {};
2438        case -1237557856: /*authorizingPrescription*/ return new String[] {"Reference"};
2439        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
2440        case -1285004149: /*quantity*/ return new String[] {"SimpleQuantity"};
2441        case 197175334: /*daysSupply*/ return new String[] {"SimpleQuantity"};
2442        case -562837097: /*whenPrepared*/ return new String[] {"dateTime"};
2443        case -940241380: /*whenHandedOver*/ return new String[] {"dateTime"};
2444        case -1429847026: /*destination*/ return new String[] {"Reference"};
2445        case -808719889: /*receiver*/ return new String[] {"Reference"};
2446        case 3387378: /*note*/ return new String[] {"Annotation"};
2447        case -1201373865: /*dosageInstruction*/ return new String[] {"Dosage"};
2448        case 826147581: /*substitution*/ return new String[] {};
2449        case 51602295: /*detectedIssue*/ return new String[] {"Reference"};
2450        case 2128257269: /*notDone*/ return new String[] {"boolean"};
2451        case -1973169255: /*notDoneReason*/ return new String[] {"CodeableConcept", "Reference"};
2452        case 1835190426: /*eventHistory*/ return new String[] {"Reference"};
2453        default: return super.getTypesForProperty(hash, name);
2454        }
2455
2456      }
2457
2458      @Override
2459      public Base addChild(String name) throws FHIRException {
2460        if (name.equals("identifier")) {
2461          return addIdentifier();
2462        }
2463        else if (name.equals("partOf")) {
2464          return addPartOf();
2465        }
2466        else if (name.equals("status")) {
2467          throw new FHIRException("Cannot call addChild on a singleton property MedicationDispense.status");
2468        }
2469        else if (name.equals("category")) {
2470          this.category = new CodeableConcept();
2471          return this.category;
2472        }
2473        else if (name.equals("medicationCodeableConcept")) {
2474          this.medication = new CodeableConcept();
2475          return this.medication;
2476        }
2477        else if (name.equals("medicationReference")) {
2478          this.medication = new Reference();
2479          return this.medication;
2480        }
2481        else if (name.equals("subject")) {
2482          this.subject = new Reference();
2483          return this.subject;
2484        }
2485        else if (name.equals("context")) {
2486          this.context = new Reference();
2487          return this.context;
2488        }
2489        else if (name.equals("supportingInformation")) {
2490          return addSupportingInformation();
2491        }
2492        else if (name.equals("performer")) {
2493          return addPerformer();
2494        }
2495        else if (name.equals("authorizingPrescription")) {
2496          return addAuthorizingPrescription();
2497        }
2498        else if (name.equals("type")) {
2499          this.type = new CodeableConcept();
2500          return this.type;
2501        }
2502        else if (name.equals("quantity")) {
2503          this.quantity = new SimpleQuantity();
2504          return this.quantity;
2505        }
2506        else if (name.equals("daysSupply")) {
2507          this.daysSupply = new SimpleQuantity();
2508          return this.daysSupply;
2509        }
2510        else if (name.equals("whenPrepared")) {
2511          throw new FHIRException("Cannot call addChild on a singleton property MedicationDispense.whenPrepared");
2512        }
2513        else if (name.equals("whenHandedOver")) {
2514          throw new FHIRException("Cannot call addChild on a singleton property MedicationDispense.whenHandedOver");
2515        }
2516        else if (name.equals("destination")) {
2517          this.destination = new Reference();
2518          return this.destination;
2519        }
2520        else if (name.equals("receiver")) {
2521          return addReceiver();
2522        }
2523        else if (name.equals("note")) {
2524          return addNote();
2525        }
2526        else if (name.equals("dosageInstruction")) {
2527          return addDosageInstruction();
2528        }
2529        else if (name.equals("substitution")) {
2530          this.substitution = new MedicationDispenseSubstitutionComponent();
2531          return this.substitution;
2532        }
2533        else if (name.equals("detectedIssue")) {
2534          return addDetectedIssue();
2535        }
2536        else if (name.equals("notDone")) {
2537          throw new FHIRException("Cannot call addChild on a singleton property MedicationDispense.notDone");
2538        }
2539        else if (name.equals("notDoneReasonCodeableConcept")) {
2540          this.notDoneReason = new CodeableConcept();
2541          return this.notDoneReason;
2542        }
2543        else if (name.equals("notDoneReasonReference")) {
2544          this.notDoneReason = new Reference();
2545          return this.notDoneReason;
2546        }
2547        else if (name.equals("eventHistory")) {
2548          return addEventHistory();
2549        }
2550        else
2551          return super.addChild(name);
2552      }
2553
2554  public String fhirType() {
2555    return "MedicationDispense";
2556
2557  }
2558
2559      public MedicationDispense copy() {
2560        MedicationDispense dst = new MedicationDispense();
2561        copyValues(dst);
2562        if (identifier != null) {
2563          dst.identifier = new ArrayList<Identifier>();
2564          for (Identifier i : identifier)
2565            dst.identifier.add(i.copy());
2566        };
2567        if (partOf != null) {
2568          dst.partOf = new ArrayList<Reference>();
2569          for (Reference i : partOf)
2570            dst.partOf.add(i.copy());
2571        };
2572        dst.status = status == null ? null : status.copy();
2573        dst.category = category == null ? null : category.copy();
2574        dst.medication = medication == null ? null : medication.copy();
2575        dst.subject = subject == null ? null : subject.copy();
2576        dst.context = context == null ? null : context.copy();
2577        if (supportingInformation != null) {
2578          dst.supportingInformation = new ArrayList<Reference>();
2579          for (Reference i : supportingInformation)
2580            dst.supportingInformation.add(i.copy());
2581        };
2582        if (performer != null) {
2583          dst.performer = new ArrayList<MedicationDispensePerformerComponent>();
2584          for (MedicationDispensePerformerComponent i : performer)
2585            dst.performer.add(i.copy());
2586        };
2587        if (authorizingPrescription != null) {
2588          dst.authorizingPrescription = new ArrayList<Reference>();
2589          for (Reference i : authorizingPrescription)
2590            dst.authorizingPrescription.add(i.copy());
2591        };
2592        dst.type = type == null ? null : type.copy();
2593        dst.quantity = quantity == null ? null : quantity.copy();
2594        dst.daysSupply = daysSupply == null ? null : daysSupply.copy();
2595        dst.whenPrepared = whenPrepared == null ? null : whenPrepared.copy();
2596        dst.whenHandedOver = whenHandedOver == null ? null : whenHandedOver.copy();
2597        dst.destination = destination == null ? null : destination.copy();
2598        if (receiver != null) {
2599          dst.receiver = new ArrayList<Reference>();
2600          for (Reference i : receiver)
2601            dst.receiver.add(i.copy());
2602        };
2603        if (note != null) {
2604          dst.note = new ArrayList<Annotation>();
2605          for (Annotation i : note)
2606            dst.note.add(i.copy());
2607        };
2608        if (dosageInstruction != null) {
2609          dst.dosageInstruction = new ArrayList<Dosage>();
2610          for (Dosage i : dosageInstruction)
2611            dst.dosageInstruction.add(i.copy());
2612        };
2613        dst.substitution = substitution == null ? null : substitution.copy();
2614        if (detectedIssue != null) {
2615          dst.detectedIssue = new ArrayList<Reference>();
2616          for (Reference i : detectedIssue)
2617            dst.detectedIssue.add(i.copy());
2618        };
2619        dst.notDone = notDone == null ? null : notDone.copy();
2620        dst.notDoneReason = notDoneReason == null ? null : notDoneReason.copy();
2621        if (eventHistory != null) {
2622          dst.eventHistory = new ArrayList<Reference>();
2623          for (Reference i : eventHistory)
2624            dst.eventHistory.add(i.copy());
2625        };
2626        return dst;
2627      }
2628
2629      protected MedicationDispense typedCopy() {
2630        return copy();
2631      }
2632
2633      @Override
2634      public boolean equalsDeep(Base other_) {
2635        if (!super.equalsDeep(other_))
2636          return false;
2637        if (!(other_ instanceof MedicationDispense))
2638          return false;
2639        MedicationDispense o = (MedicationDispense) other_;
2640        return compareDeep(identifier, o.identifier, true) && compareDeep(partOf, o.partOf, true) && compareDeep(status, o.status, true)
2641           && compareDeep(category, o.category, true) && compareDeep(medication, o.medication, true) && compareDeep(subject, o.subject, true)
2642           && compareDeep(context, o.context, true) && compareDeep(supportingInformation, o.supportingInformation, true)
2643           && compareDeep(performer, o.performer, true) && compareDeep(authorizingPrescription, o.authorizingPrescription, true)
2644           && compareDeep(type, o.type, true) && compareDeep(quantity, o.quantity, true) && compareDeep(daysSupply, o.daysSupply, true)
2645           && compareDeep(whenPrepared, o.whenPrepared, true) && compareDeep(whenHandedOver, o.whenHandedOver, true)
2646           && compareDeep(destination, o.destination, true) && compareDeep(receiver, o.receiver, true) && compareDeep(note, o.note, true)
2647           && compareDeep(dosageInstruction, o.dosageInstruction, true) && compareDeep(substitution, o.substitution, true)
2648           && compareDeep(detectedIssue, o.detectedIssue, true) && compareDeep(notDone, o.notDone, true) && compareDeep(notDoneReason, o.notDoneReason, true)
2649           && compareDeep(eventHistory, o.eventHistory, true);
2650      }
2651
2652      @Override
2653      public boolean equalsShallow(Base other_) {
2654        if (!super.equalsShallow(other_))
2655          return false;
2656        if (!(other_ instanceof MedicationDispense))
2657          return false;
2658        MedicationDispense o = (MedicationDispense) other_;
2659        return compareValues(status, o.status, true) && compareValues(whenPrepared, o.whenPrepared, true) && compareValues(whenHandedOver, o.whenHandedOver, true)
2660           && compareValues(notDone, o.notDone, true);
2661      }
2662
2663      public boolean isEmpty() {
2664        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, partOf, status
2665          , category, medication, subject, context, supportingInformation, performer, authorizingPrescription
2666          , type, quantity, daysSupply, whenPrepared, whenHandedOver, destination, receiver
2667          , note, dosageInstruction, substitution, detectedIssue, notDone, notDoneReason, eventHistory
2668          );
2669      }
2670
2671  @Override
2672  public ResourceType getResourceType() {
2673    return ResourceType.MedicationDispense;
2674   }
2675
2676 /**
2677   * Search parameter: <b>identifier</b>
2678   * <p>
2679   * Description: <b>Return dispenses with this external identifier</b><br>
2680   * Type: <b>token</b><br>
2681   * Path: <b>MedicationDispense.identifier</b><br>
2682   * </p>
2683   */
2684  @SearchParamDefinition(name="identifier", path="MedicationDispense.identifier", description="Return dispenses with this external identifier", type="token" )
2685  public static final String SP_IDENTIFIER = "identifier";
2686 /**
2687   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2688   * <p>
2689   * Description: <b>Return dispenses with this external identifier</b><br>
2690   * Type: <b>token</b><br>
2691   * Path: <b>MedicationDispense.identifier</b><br>
2692   * </p>
2693   */
2694  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
2695
2696 /**
2697   * Search parameter: <b>performer</b>
2698   * <p>
2699   * Description: <b>Return dispenses performed by a specific individual</b><br>
2700   * Type: <b>reference</b><br>
2701   * Path: <b>MedicationDispense.performer.actor</b><br>
2702   * </p>
2703   */
2704  @SearchParamDefinition(name="performer", path="MedicationDispense.performer.actor", description="Return dispenses performed by a specific individual", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner") }, target={Device.class, Organization.class, Patient.class, Practitioner.class, RelatedPerson.class } )
2705  public static final String SP_PERFORMER = "performer";
2706 /**
2707   * <b>Fluent Client</b> search parameter constant for <b>performer</b>
2708   * <p>
2709   * Description: <b>Return dispenses performed by a specific individual</b><br>
2710   * Type: <b>reference</b><br>
2711   * Path: <b>MedicationDispense.performer.actor</b><br>
2712   * </p>
2713   */
2714  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PERFORMER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PERFORMER);
2715
2716/**
2717   * Constant for fluent queries to be used to add include statements. Specifies
2718   * the path value of "<b>MedicationDispense:performer</b>".
2719   */
2720  public static final ca.uhn.fhir.model.api.Include INCLUDE_PERFORMER = new ca.uhn.fhir.model.api.Include("MedicationDispense:performer").toLocked();
2721
2722 /**
2723   * Search parameter: <b>code</b>
2724   * <p>
2725   * Description: <b>Return dispenses of this medicine code</b><br>
2726   * Type: <b>token</b><br>
2727   * Path: <b>MedicationDispense.medicationCodeableConcept</b><br>
2728   * </p>
2729   */
2730  @SearchParamDefinition(name="code", path="MedicationDispense.medication.as(CodeableConcept)", description="Return dispenses of this medicine code", type="token" )
2731  public static final String SP_CODE = "code";
2732 /**
2733   * <b>Fluent Client</b> search parameter constant for <b>code</b>
2734   * <p>
2735   * Description: <b>Return dispenses of this medicine code</b><br>
2736   * Type: <b>token</b><br>
2737   * Path: <b>MedicationDispense.medicationCodeableConcept</b><br>
2738   * </p>
2739   */
2740  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CODE);
2741
2742 /**
2743   * Search parameter: <b>receiver</b>
2744   * <p>
2745   * Description: <b>The identity of a receiver to list dispenses for</b><br>
2746   * Type: <b>reference</b><br>
2747   * Path: <b>MedicationDispense.receiver</b><br>
2748   * </p>
2749   */
2750  @SearchParamDefinition(name="receiver", path="MedicationDispense.receiver", description="The identity of a receiver to list dispenses for", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner") }, target={Patient.class, Practitioner.class } )
2751  public static final String SP_RECEIVER = "receiver";
2752 /**
2753   * <b>Fluent Client</b> search parameter constant for <b>receiver</b>
2754   * <p>
2755   * Description: <b>The identity of a receiver to list dispenses for</b><br>
2756   * Type: <b>reference</b><br>
2757   * Path: <b>MedicationDispense.receiver</b><br>
2758   * </p>
2759   */
2760  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam RECEIVER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_RECEIVER);
2761
2762/**
2763   * Constant for fluent queries to be used to add include statements. Specifies
2764   * the path value of "<b>MedicationDispense:receiver</b>".
2765   */
2766  public static final ca.uhn.fhir.model.api.Include INCLUDE_RECEIVER = new ca.uhn.fhir.model.api.Include("MedicationDispense:receiver").toLocked();
2767
2768 /**
2769   * Search parameter: <b>subject</b>
2770   * <p>
2771   * Description: <b>The identity of a patient to list dispenses  for</b><br>
2772   * Type: <b>reference</b><br>
2773   * Path: <b>MedicationDispense.subject</b><br>
2774   * </p>
2775   */
2776  @SearchParamDefinition(name="subject", path="MedicationDispense.subject", description="The identity of a patient to list dispenses  for", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Group.class, Patient.class } )
2777  public static final String SP_SUBJECT = "subject";
2778 /**
2779   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
2780   * <p>
2781   * Description: <b>The identity of a patient to list dispenses  for</b><br>
2782   * Type: <b>reference</b><br>
2783   * Path: <b>MedicationDispense.subject</b><br>
2784   * </p>
2785   */
2786  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
2787
2788/**
2789   * Constant for fluent queries to be used to add include statements. Specifies
2790   * the path value of "<b>MedicationDispense:subject</b>".
2791   */
2792  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("MedicationDispense:subject").toLocked();
2793
2794 /**
2795   * Search parameter: <b>destination</b>
2796   * <p>
2797   * Description: <b>Return dispenses that should be sent to a specific destination</b><br>
2798   * Type: <b>reference</b><br>
2799   * Path: <b>MedicationDispense.destination</b><br>
2800   * </p>
2801   */
2802  @SearchParamDefinition(name="destination", path="MedicationDispense.destination", description="Return dispenses that should be sent to a specific destination", type="reference", target={Location.class } )
2803  public static final String SP_DESTINATION = "destination";
2804 /**
2805   * <b>Fluent Client</b> search parameter constant for <b>destination</b>
2806   * <p>
2807   * Description: <b>Return dispenses that should be sent to a specific destination</b><br>
2808   * Type: <b>reference</b><br>
2809   * Path: <b>MedicationDispense.destination</b><br>
2810   * </p>
2811   */
2812  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam DESTINATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_DESTINATION);
2813
2814/**
2815   * Constant for fluent queries to be used to add include statements. Specifies
2816   * the path value of "<b>MedicationDispense:destination</b>".
2817   */
2818  public static final ca.uhn.fhir.model.api.Include INCLUDE_DESTINATION = new ca.uhn.fhir.model.api.Include("MedicationDispense:destination").toLocked();
2819
2820 /**
2821   * Search parameter: <b>medication</b>
2822   * <p>
2823   * Description: <b>Return dispenses of this medicine resource</b><br>
2824   * Type: <b>reference</b><br>
2825   * Path: <b>MedicationDispense.medicationReference</b><br>
2826   * </p>
2827   */
2828  @SearchParamDefinition(name="medication", path="MedicationDispense.medication.as(Reference)", description="Return dispenses of this medicine resource", type="reference", target={Medication.class } )
2829  public static final String SP_MEDICATION = "medication";
2830 /**
2831   * <b>Fluent Client</b> search parameter constant for <b>medication</b>
2832   * <p>
2833   * Description: <b>Return dispenses of this medicine resource</b><br>
2834   * Type: <b>reference</b><br>
2835   * Path: <b>MedicationDispense.medicationReference</b><br>
2836   * </p>
2837   */
2838  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam MEDICATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_MEDICATION);
2839
2840/**
2841   * Constant for fluent queries to be used to add include statements. Specifies
2842   * the path value of "<b>MedicationDispense:medication</b>".
2843   */
2844  public static final ca.uhn.fhir.model.api.Include INCLUDE_MEDICATION = new ca.uhn.fhir.model.api.Include("MedicationDispense:medication").toLocked();
2845
2846 /**
2847   * Search parameter: <b>responsibleparty</b>
2848   * <p>
2849   * Description: <b>Return dispenses with the specified responsible party</b><br>
2850   * Type: <b>reference</b><br>
2851   * Path: <b>MedicationDispense.substitution.responsibleParty</b><br>
2852   * </p>
2853   */
2854  @SearchParamDefinition(name="responsibleparty", path="MedicationDispense.substitution.responsibleParty", description="Return dispenses with the specified responsible party", type="reference", target={Practitioner.class } )
2855  public static final String SP_RESPONSIBLEPARTY = "responsibleparty";
2856 /**
2857   * <b>Fluent Client</b> search parameter constant for <b>responsibleparty</b>
2858   * <p>
2859   * Description: <b>Return dispenses with the specified responsible party</b><br>
2860   * Type: <b>reference</b><br>
2861   * Path: <b>MedicationDispense.substitution.responsibleParty</b><br>
2862   * </p>
2863   */
2864  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam RESPONSIBLEPARTY = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_RESPONSIBLEPARTY);
2865
2866/**
2867   * Constant for fluent queries to be used to add include statements. Specifies
2868   * the path value of "<b>MedicationDispense:responsibleparty</b>".
2869   */
2870  public static final ca.uhn.fhir.model.api.Include INCLUDE_RESPONSIBLEPARTY = new ca.uhn.fhir.model.api.Include("MedicationDispense:responsibleparty").toLocked();
2871
2872 /**
2873   * Search parameter: <b>type</b>
2874   * <p>
2875   * Description: <b>Return dispenses of a specific type</b><br>
2876   * Type: <b>token</b><br>
2877   * Path: <b>MedicationDispense.type</b><br>
2878   * </p>
2879   */
2880  @SearchParamDefinition(name="type", path="MedicationDispense.type", description="Return dispenses of a specific type", type="token" )
2881  public static final String SP_TYPE = "type";
2882 /**
2883   * <b>Fluent Client</b> search parameter constant for <b>type</b>
2884   * <p>
2885   * Description: <b>Return dispenses of a specific type</b><br>
2886   * Type: <b>token</b><br>
2887   * Path: <b>MedicationDispense.type</b><br>
2888   * </p>
2889   */
2890  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_TYPE);
2891
2892 /**
2893   * Search parameter: <b>whenhandedover</b>
2894   * <p>
2895   * Description: <b>Returns dispenses handed over on this date</b><br>
2896   * Type: <b>date</b><br>
2897   * Path: <b>MedicationDispense.whenHandedOver</b><br>
2898   * </p>
2899   */
2900  @SearchParamDefinition(name="whenhandedover", path="MedicationDispense.whenHandedOver", description="Returns dispenses handed over on this date", type="date" )
2901  public static final String SP_WHENHANDEDOVER = "whenhandedover";
2902 /**
2903   * <b>Fluent Client</b> search parameter constant for <b>whenhandedover</b>
2904   * <p>
2905   * Description: <b>Returns dispenses handed over on this date</b><br>
2906   * Type: <b>date</b><br>
2907   * Path: <b>MedicationDispense.whenHandedOver</b><br>
2908   * </p>
2909   */
2910  public static final ca.uhn.fhir.rest.gclient.DateClientParam WHENHANDEDOVER = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_WHENHANDEDOVER);
2911
2912 /**
2913   * Search parameter: <b>whenprepared</b>
2914   * <p>
2915   * Description: <b>Returns dispenses prepared on this date</b><br>
2916   * Type: <b>date</b><br>
2917   * Path: <b>MedicationDispense.whenPrepared</b><br>
2918   * </p>
2919   */
2920  @SearchParamDefinition(name="whenprepared", path="MedicationDispense.whenPrepared", description="Returns dispenses prepared on this date", type="date" )
2921  public static final String SP_WHENPREPARED = "whenprepared";
2922 /**
2923   * <b>Fluent Client</b> search parameter constant for <b>whenprepared</b>
2924   * <p>
2925   * Description: <b>Returns dispenses prepared on this date</b><br>
2926   * Type: <b>date</b><br>
2927   * Path: <b>MedicationDispense.whenPrepared</b><br>
2928   * </p>
2929   */
2930  public static final ca.uhn.fhir.rest.gclient.DateClientParam WHENPREPARED = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_WHENPREPARED);
2931
2932 /**
2933   * Search parameter: <b>prescription</b>
2934   * <p>
2935   * Description: <b>The identity of a prescription to list dispenses from</b><br>
2936   * Type: <b>reference</b><br>
2937   * Path: <b>MedicationDispense.authorizingPrescription</b><br>
2938   * </p>
2939   */
2940  @SearchParamDefinition(name="prescription", path="MedicationDispense.authorizingPrescription", description="The identity of a prescription to list dispenses from", type="reference", target={MedicationRequest.class } )
2941  public static final String SP_PRESCRIPTION = "prescription";
2942 /**
2943   * <b>Fluent Client</b> search parameter constant for <b>prescription</b>
2944   * <p>
2945   * Description: <b>The identity of a prescription to list dispenses from</b><br>
2946   * Type: <b>reference</b><br>
2947   * Path: <b>MedicationDispense.authorizingPrescription</b><br>
2948   * </p>
2949   */
2950  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PRESCRIPTION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PRESCRIPTION);
2951
2952/**
2953   * Constant for fluent queries to be used to add include statements. Specifies
2954   * the path value of "<b>MedicationDispense:prescription</b>".
2955   */
2956  public static final ca.uhn.fhir.model.api.Include INCLUDE_PRESCRIPTION = new ca.uhn.fhir.model.api.Include("MedicationDispense:prescription").toLocked();
2957
2958 /**
2959   * Search parameter: <b>patient</b>
2960   * <p>
2961   * Description: <b>The identity of a patient to list dispenses  for</b><br>
2962   * Type: <b>reference</b><br>
2963   * Path: <b>MedicationDispense.subject</b><br>
2964   * </p>
2965   */
2966  @SearchParamDefinition(name="patient", path="MedicationDispense.subject", description="The identity of a patient to list dispenses  for", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Patient.class } )
2967  public static final String SP_PATIENT = "patient";
2968 /**
2969   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
2970   * <p>
2971   * Description: <b>The identity of a patient to list dispenses  for</b><br>
2972   * Type: <b>reference</b><br>
2973   * Path: <b>MedicationDispense.subject</b><br>
2974   * </p>
2975   */
2976  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
2977
2978/**
2979   * Constant for fluent queries to be used to add include statements. Specifies
2980   * the path value of "<b>MedicationDispense:patient</b>".
2981   */
2982  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("MedicationDispense:patient").toLocked();
2983
2984 /**
2985   * Search parameter: <b>context</b>
2986   * <p>
2987   * Description: <b>Returns dispenses with a specific context (episode or episode of care)</b><br>
2988   * Type: <b>reference</b><br>
2989   * Path: <b>MedicationDispense.context</b><br>
2990   * </p>
2991   */
2992  @SearchParamDefinition(name="context", path="MedicationDispense.context", description="Returns dispenses with a specific context (episode or episode of care)", type="reference", target={Encounter.class, EpisodeOfCare.class } )
2993  public static final String SP_CONTEXT = "context";
2994 /**
2995   * <b>Fluent Client</b> search parameter constant for <b>context</b>
2996   * <p>
2997   * Description: <b>Returns dispenses with a specific context (episode or episode of care)</b><br>
2998   * Type: <b>reference</b><br>
2999   * Path: <b>MedicationDispense.context</b><br>
3000   * </p>
3001   */
3002  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam CONTEXT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_CONTEXT);
3003
3004/**
3005   * Constant for fluent queries to be used to add include statements. Specifies
3006   * the path value of "<b>MedicationDispense:context</b>".
3007   */
3008  public static final ca.uhn.fhir.model.api.Include INCLUDE_CONTEXT = new ca.uhn.fhir.model.api.Include("MedicationDispense:context").toLocked();
3009
3010 /**
3011   * Search parameter: <b>status</b>
3012   * <p>
3013   * Description: <b>Return dispenses with a specified dispense status</b><br>
3014   * Type: <b>token</b><br>
3015   * Path: <b>MedicationDispense.status</b><br>
3016   * </p>
3017   */
3018  @SearchParamDefinition(name="status", path="MedicationDispense.status", description="Return dispenses with a specified dispense status", type="token" )
3019  public static final String SP_STATUS = "status";
3020 /**
3021   * <b>Fluent Client</b> search parameter constant for <b>status</b>
3022   * <p>
3023   * Description: <b>Return dispenses with a specified dispense status</b><br>
3024   * Type: <b>token</b><br>
3025   * Path: <b>MedicationDispense.status</b><br>
3026   * </p>
3027   */
3028  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
3029
3030
3031}