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