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