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