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