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