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