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