001package org.hl7.fhir.dstu3.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 Mon, Apr 17, 2017 17:38-0400 for FHIR v3.0.1
033
034import java.util.*;
035
036import org.hl7.fhir.utilities.Utilities;
037import ca.uhn.fhir.model.api.annotation.ResourceDef;
038import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.ChildOrder;
041import ca.uhn.fhir.model.api.annotation.Description;
042import ca.uhn.fhir.model.api.annotation.Block;
043import org.hl7.fhir.instance.model.api.*;
044import org.hl7.fhir.exceptions.FHIRException;
045/**
046 * Describes the event of a patient consuming or otherwise being administered a medication.  This may be as simple as swallowing a tablet or it may be a long running infusion.  Related resources tie this event to the authorizing prescription, and the specific encounter between patient and health care practitioner.
047 */
048@ResourceDef(name="MedicationAdministration", profile="http://hl7.org/fhir/Profile/MedicationAdministration")
049public class MedicationAdministration extends DomainResource {
050
051    public enum MedicationAdministrationStatus {
052        /**
053         * The administration has started but has not yet completed.
054         */
055        INPROGRESS, 
056        /**
057         * Actions implied by the administration have been temporarily halted, but are expected to continue later. May also be called "suspended".
058         */
059        ONHOLD, 
060        /**
061         * All actions that are implied by the administration have occurred.
062         */
063        COMPLETED, 
064        /**
065         * The administration was entered in error and therefore nullified.
066         */
067        ENTEREDINERROR, 
068        /**
069         * Actions implied by the administration have been permanently halted, before all of them occurred.
070         */
071        STOPPED, 
072        /**
073         * The authoring system does not know which of the status values currently applies for this request. Note: This concept is not to be used for "other" - one of the listed statuses is presumed to apply, it's just not known which one.
074         */
075        UNKNOWN, 
076        /**
077         * added to help the parsers with the generic types
078         */
079        NULL;
080        public static MedicationAdministrationStatus fromCode(String codeString) throws FHIRException {
081            if (codeString == null || "".equals(codeString))
082                return null;
083        if ("in-progress".equals(codeString))
084          return INPROGRESS;
085        if ("on-hold".equals(codeString))
086          return ONHOLD;
087        if ("completed".equals(codeString))
088          return COMPLETED;
089        if ("entered-in-error".equals(codeString))
090          return ENTEREDINERROR;
091        if ("stopped".equals(codeString))
092          return STOPPED;
093        if ("unknown".equals(codeString))
094          return UNKNOWN;
095        if (Configuration.isAcceptInvalidEnums())
096          return null;
097        else
098          throw new FHIRException("Unknown MedicationAdministrationStatus code '"+codeString+"'");
099        }
100        public String toCode() {
101          switch (this) {
102            case INPROGRESS: return "in-progress";
103            case ONHOLD: return "on-hold";
104            case COMPLETED: return "completed";
105            case ENTEREDINERROR: return "entered-in-error";
106            case STOPPED: return "stopped";
107            case UNKNOWN: return "unknown";
108            default: return "?";
109          }
110        }
111        public String getSystem() {
112          switch (this) {
113            case INPROGRESS: return "http://hl7.org/fhir/medication-admin-status";
114            case ONHOLD: return "http://hl7.org/fhir/medication-admin-status";
115            case COMPLETED: return "http://hl7.org/fhir/medication-admin-status";
116            case ENTEREDINERROR: return "http://hl7.org/fhir/medication-admin-status";
117            case STOPPED: return "http://hl7.org/fhir/medication-admin-status";
118            case UNKNOWN: return "http://hl7.org/fhir/medication-admin-status";
119            default: return "?";
120          }
121        }
122        public String getDefinition() {
123          switch (this) {
124            case INPROGRESS: return "The administration has started but has not yet completed.";
125            case ONHOLD: return "Actions implied by the administration have been temporarily halted, but are expected to continue later. May also be called \"suspended\".";
126            case COMPLETED: return "All actions that are implied by the administration have occurred.";
127            case ENTEREDINERROR: return "The administration was entered in error and therefore nullified.";
128            case STOPPED: return "Actions implied by the administration have been permanently halted, before all of them occurred.";
129            case UNKNOWN: return "The authoring system does not know which of the status values currently applies for this request. Note: This concept is not to be used for \"other\" - one of the listed statuses is presumed to apply, it's just not known which one.";
130            default: return "?";
131          }
132        }
133        public String getDisplay() {
134          switch (this) {
135            case INPROGRESS: return "In Progress";
136            case ONHOLD: return "On Hold";
137            case COMPLETED: return "Completed";
138            case ENTEREDINERROR: return "Entered in Error";
139            case STOPPED: return "Stopped";
140            case UNKNOWN: return "Unknown";
141            default: return "?";
142          }
143        }
144    }
145
146  public static class MedicationAdministrationStatusEnumFactory implements EnumFactory<MedicationAdministrationStatus> {
147    public MedicationAdministrationStatus fromCode(String codeString) throws IllegalArgumentException {
148      if (codeString == null || "".equals(codeString))
149            if (codeString == null || "".equals(codeString))
150                return null;
151        if ("in-progress".equals(codeString))
152          return MedicationAdministrationStatus.INPROGRESS;
153        if ("on-hold".equals(codeString))
154          return MedicationAdministrationStatus.ONHOLD;
155        if ("completed".equals(codeString))
156          return MedicationAdministrationStatus.COMPLETED;
157        if ("entered-in-error".equals(codeString))
158          return MedicationAdministrationStatus.ENTEREDINERROR;
159        if ("stopped".equals(codeString))
160          return MedicationAdministrationStatus.STOPPED;
161        if ("unknown".equals(codeString))
162          return MedicationAdministrationStatus.UNKNOWN;
163        throw new IllegalArgumentException("Unknown MedicationAdministrationStatus code '"+codeString+"'");
164        }
165        public Enumeration<MedicationAdministrationStatus> fromType(Base code) throws FHIRException {
166          if (code == null)
167            return null;
168          if (code.isEmpty())
169            return new Enumeration<MedicationAdministrationStatus>(this);
170          String codeString = ((PrimitiveType) code).asStringValue();
171          if (codeString == null || "".equals(codeString))
172            return null;
173        if ("in-progress".equals(codeString))
174          return new Enumeration<MedicationAdministrationStatus>(this, MedicationAdministrationStatus.INPROGRESS);
175        if ("on-hold".equals(codeString))
176          return new Enumeration<MedicationAdministrationStatus>(this, MedicationAdministrationStatus.ONHOLD);
177        if ("completed".equals(codeString))
178          return new Enumeration<MedicationAdministrationStatus>(this, MedicationAdministrationStatus.COMPLETED);
179        if ("entered-in-error".equals(codeString))
180          return new Enumeration<MedicationAdministrationStatus>(this, MedicationAdministrationStatus.ENTEREDINERROR);
181        if ("stopped".equals(codeString))
182          return new Enumeration<MedicationAdministrationStatus>(this, MedicationAdministrationStatus.STOPPED);
183        if ("unknown".equals(codeString))
184          return new Enumeration<MedicationAdministrationStatus>(this, MedicationAdministrationStatus.UNKNOWN);
185        throw new FHIRException("Unknown MedicationAdministrationStatus code '"+codeString+"'");
186        }
187    public String toCode(MedicationAdministrationStatus code) {
188      if (code == MedicationAdministrationStatus.INPROGRESS)
189        return "in-progress";
190      if (code == MedicationAdministrationStatus.ONHOLD)
191        return "on-hold";
192      if (code == MedicationAdministrationStatus.COMPLETED)
193        return "completed";
194      if (code == MedicationAdministrationStatus.ENTEREDINERROR)
195        return "entered-in-error";
196      if (code == MedicationAdministrationStatus.STOPPED)
197        return "stopped";
198      if (code == MedicationAdministrationStatus.UNKNOWN)
199        return "unknown";
200      return "?";
201      }
202    public String toSystem(MedicationAdministrationStatus code) {
203      return code.getSystem();
204      }
205    }
206
207    @Block()
208    public static class MedicationAdministrationPerformerComponent extends BackboneElement implements IBaseBackboneElement {
209        /**
210         * The device, practitioner, etc. who performed the action.
211         */
212        @Child(name = "actor", type = {Practitioner.class, Patient.class, RelatedPerson.class, Device.class}, order=1, min=1, max=1, modifier=false, summary=true)
213        @Description(shortDefinition="Individual who was performing", formalDefinition="The device, practitioner, etc. who performed the action." )
214        protected Reference actor;
215
216        /**
217         * The actual object that is the target of the reference (The device, practitioner, etc. who performed the action.)
218         */
219        protected Resource actorTarget;
220
221        /**
222         * The organization the device or practitioner was acting on behalf of.
223         */
224        @Child(name = "onBehalfOf", type = {Organization.class}, order=2, min=0, max=1, modifier=false, summary=false)
225        @Description(shortDefinition="Organization organization was acting for", formalDefinition="The organization the device or practitioner was acting on behalf of." )
226        protected Reference onBehalfOf;
227
228        /**
229         * The actual object that is the target of the reference (The organization the device or practitioner was acting on behalf of.)
230         */
231        protected Organization onBehalfOfTarget;
232
233        private static final long serialVersionUID = -488386403L;
234
235    /**
236     * Constructor
237     */
238      public MedicationAdministrationPerformerComponent() {
239        super();
240      }
241
242    /**
243     * Constructor
244     */
245      public MedicationAdministrationPerformerComponent(Reference actor) {
246        super();
247        this.actor = actor;
248      }
249
250        /**
251         * @return {@link #actor} (The device, practitioner, etc. who performed the action.)
252         */
253        public Reference getActor() { 
254          if (this.actor == null)
255            if (Configuration.errorOnAutoCreate())
256              throw new Error("Attempt to auto-create MedicationAdministrationPerformerComponent.actor");
257            else if (Configuration.doAutoCreate())
258              this.actor = new Reference(); // cc
259          return this.actor;
260        }
261
262        public boolean hasActor() { 
263          return this.actor != null && !this.actor.isEmpty();
264        }
265
266        /**
267         * @param value {@link #actor} (The device, practitioner, etc. who performed the action.)
268         */
269        public MedicationAdministrationPerformerComponent setActor(Reference value) { 
270          this.actor = value;
271          return this;
272        }
273
274        /**
275         * @return {@link #actor} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The device, practitioner, etc. who performed the action.)
276         */
277        public Resource getActorTarget() { 
278          return this.actorTarget;
279        }
280
281        /**
282         * @param value {@link #actor} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The device, practitioner, etc. who performed the action.)
283         */
284        public MedicationAdministrationPerformerComponent setActorTarget(Resource value) { 
285          this.actorTarget = value;
286          return this;
287        }
288
289        /**
290         * @return {@link #onBehalfOf} (The organization the device or practitioner was acting on behalf of.)
291         */
292        public Reference getOnBehalfOf() { 
293          if (this.onBehalfOf == null)
294            if (Configuration.errorOnAutoCreate())
295              throw new Error("Attempt to auto-create MedicationAdministrationPerformerComponent.onBehalfOf");
296            else if (Configuration.doAutoCreate())
297              this.onBehalfOf = new Reference(); // cc
298          return this.onBehalfOf;
299        }
300
301        public boolean hasOnBehalfOf() { 
302          return this.onBehalfOf != null && !this.onBehalfOf.isEmpty();
303        }
304
305        /**
306         * @param value {@link #onBehalfOf} (The organization the device or practitioner was acting on behalf of.)
307         */
308        public MedicationAdministrationPerformerComponent setOnBehalfOf(Reference value) { 
309          this.onBehalfOf = value;
310          return this;
311        }
312
313        /**
314         * @return {@link #onBehalfOf} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The organization the device or practitioner was acting on behalf of.)
315         */
316        public Organization getOnBehalfOfTarget() { 
317          if (this.onBehalfOfTarget == null)
318            if (Configuration.errorOnAutoCreate())
319              throw new Error("Attempt to auto-create MedicationAdministrationPerformerComponent.onBehalfOf");
320            else if (Configuration.doAutoCreate())
321              this.onBehalfOfTarget = new Organization(); // aa
322          return this.onBehalfOfTarget;
323        }
324
325        /**
326         * @param value {@link #onBehalfOf} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The organization the device or practitioner was acting on behalf of.)
327         */
328        public MedicationAdministrationPerformerComponent setOnBehalfOfTarget(Organization value) { 
329          this.onBehalfOfTarget = value;
330          return this;
331        }
332
333        protected void listChildren(List<Property> childrenList) {
334          super.listChildren(childrenList);
335          childrenList.add(new Property("actor", "Reference(Practitioner|Patient|RelatedPerson|Device)", "The device, practitioner, etc. who performed the action.", 0, java.lang.Integer.MAX_VALUE, actor));
336          childrenList.add(new Property("onBehalfOf", "Reference(Organization)", "The organization the device or practitioner was acting on behalf of.", 0, java.lang.Integer.MAX_VALUE, onBehalfOf));
337        }
338
339      @Override
340      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
341        switch (hash) {
342        case 92645877: /*actor*/ return this.actor == null ? new Base[0] : new Base[] {this.actor}; // Reference
343        case -14402964: /*onBehalfOf*/ return this.onBehalfOf == null ? new Base[0] : new Base[] {this.onBehalfOf}; // Reference
344        default: return super.getProperty(hash, name, checkValid);
345        }
346
347      }
348
349      @Override
350      public Base setProperty(int hash, String name, Base value) throws FHIRException {
351        switch (hash) {
352        case 92645877: // actor
353          this.actor = castToReference(value); // Reference
354          return value;
355        case -14402964: // onBehalfOf
356          this.onBehalfOf = castToReference(value); // Reference
357          return value;
358        default: return super.setProperty(hash, name, value);
359        }
360
361      }
362
363      @Override
364      public Base setProperty(String name, Base value) throws FHIRException {
365        if (name.equals("actor")) {
366          this.actor = castToReference(value); // Reference
367        } else if (name.equals("onBehalfOf")) {
368          this.onBehalfOf = castToReference(value); // Reference
369        } else
370          return super.setProperty(name, value);
371        return value;
372      }
373
374      @Override
375      public Base makeProperty(int hash, String name) throws FHIRException {
376        switch (hash) {
377        case 92645877:  return getActor(); 
378        case -14402964:  return getOnBehalfOf(); 
379        default: return super.makeProperty(hash, name);
380        }
381
382      }
383
384      @Override
385      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
386        switch (hash) {
387        case 92645877: /*actor*/ return new String[] {"Reference"};
388        case -14402964: /*onBehalfOf*/ return new String[] {"Reference"};
389        default: return super.getTypesForProperty(hash, name);
390        }
391
392      }
393
394      @Override
395      public Base addChild(String name) throws FHIRException {
396        if (name.equals("actor")) {
397          this.actor = new Reference();
398          return this.actor;
399        }
400        else if (name.equals("onBehalfOf")) {
401          this.onBehalfOf = new Reference();
402          return this.onBehalfOf;
403        }
404        else
405          return super.addChild(name);
406      }
407
408      public MedicationAdministrationPerformerComponent copy() {
409        MedicationAdministrationPerformerComponent dst = new MedicationAdministrationPerformerComponent();
410        copyValues(dst);
411        dst.actor = actor == null ? null : actor.copy();
412        dst.onBehalfOf = onBehalfOf == null ? null : onBehalfOf.copy();
413        return dst;
414      }
415
416      @Override
417      public boolean equalsDeep(Base other) {
418        if (!super.equalsDeep(other))
419          return false;
420        if (!(other instanceof MedicationAdministrationPerformerComponent))
421          return false;
422        MedicationAdministrationPerformerComponent o = (MedicationAdministrationPerformerComponent) other;
423        return compareDeep(actor, o.actor, true) && compareDeep(onBehalfOf, o.onBehalfOf, true);
424      }
425
426      @Override
427      public boolean equalsShallow(Base other) {
428        if (!super.equalsShallow(other))
429          return false;
430        if (!(other instanceof MedicationAdministrationPerformerComponent))
431          return false;
432        MedicationAdministrationPerformerComponent o = (MedicationAdministrationPerformerComponent) other;
433        return true;
434      }
435
436      public boolean isEmpty() {
437        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(actor, onBehalfOf);
438      }
439
440  public String fhirType() {
441    return "MedicationAdministration.performer";
442
443  }
444
445  }
446
447    @Block()
448    public static class MedicationAdministrationDosageComponent extends BackboneElement implements IBaseBackboneElement {
449        /**
450         * Free text dosage can be used for cases where the dosage administered is too complex to code. When coded dosage is present, the free text dosage may still be present for display to humans.
451
452The dosage instructions should reflect the dosage of the medication that was administered.
453         */
454        @Child(name = "text", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=false)
455        @Description(shortDefinition="Free text dosage instructions e.g. SIG", formalDefinition="Free text dosage can be used for cases where the dosage administered is too complex to code. When coded dosage is present, the free text dosage may still be present for display to humans.\r\rThe dosage instructions should reflect the dosage of the medication that was administered." )
456        protected StringType text;
457
458        /**
459         * A coded specification of the anatomic site where the medication first entered the body.  For example, "left arm".
460         */
461        @Child(name = "site", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
462        @Description(shortDefinition="Body site administered to", formalDefinition="A coded specification of the anatomic site where the medication first entered the body.  For example, \"left arm\"." )
463        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/approach-site-codes")
464        protected CodeableConcept site;
465
466        /**
467         * A code specifying the route or physiological path of administration of a therapeutic agent into or onto the patient.  For example, topical, intravenous, etc.
468         */
469        @Child(name = "route", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=false)
470        @Description(shortDefinition="Path of substance into body", formalDefinition="A code specifying the route or physiological path of administration of a therapeutic agent into or onto the patient.  For example, topical, intravenous, etc." )
471        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/route-codes")
472        protected CodeableConcept route;
473
474        /**
475         * A coded value indicating the method by which the medication is intended to be or was introduced into or on the body.  This attribute will most often NOT be populated.  It is most commonly used for injections.  For example, Slow Push, Deep IV.
476         */
477        @Child(name = "method", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=false)
478        @Description(shortDefinition="How drug was administered", formalDefinition="A coded value indicating the method by which the medication is intended to be or was introduced into or on the body.  This attribute will most often NOT be populated.  It is most commonly used for injections.  For example, Slow Push, Deep IV." )
479        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/administration-method-codes")
480        protected CodeableConcept method;
481
482        /**
483         * The amount of the medication given at one administration event.   Use this value when the administration is essentially an instantaneous event such as a swallowing a tablet or giving an injection.
484         */
485        @Child(name = "dose", type = {SimpleQuantity.class}, order=5, min=0, max=1, modifier=false, summary=false)
486        @Description(shortDefinition="Amount of medication per dose", formalDefinition="The amount of the medication given at one administration event.   Use this value when the administration is essentially an instantaneous event such as a swallowing a tablet or giving an injection." )
487        protected SimpleQuantity dose;
488
489        /**
490         * Identifies the speed with which the medication was or will be introduced into the patient.  Typically the rate for an infusion e.g. 100 ml per 1 hour or 100 ml/hr.  May also be expressed as a rate per unit of time e.g. 500 ml per 2 hours.  Other examples:  200 mcg/min or 200 mcg/1 minute; 1 liter/8 hours.
491         */
492        @Child(name = "rate", type = {Ratio.class, SimpleQuantity.class}, order=6, min=0, max=1, modifier=false, summary=false)
493        @Description(shortDefinition="Dose quantity per unit of time", formalDefinition="Identifies the speed with which the medication was or will be introduced into the patient.  Typically the rate for an infusion e.g. 100 ml per 1 hour or 100 ml/hr.  May also be expressed as a rate per unit of time e.g. 500 ml per 2 hours.  Other examples:  200 mcg/min or 200 mcg/1 minute; 1 liter/8 hours." )
494        protected Type rate;
495
496        private static final long serialVersionUID = 1316915516L;
497
498    /**
499     * Constructor
500     */
501      public MedicationAdministrationDosageComponent() {
502        super();
503      }
504
505        /**
506         * @return {@link #text} (Free text dosage can be used for cases where the dosage administered is too complex to code. When coded dosage is present, the free text dosage may still be present for display to humans.
507
508The dosage instructions should reflect the dosage of the medication that was administered.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value
509         */
510        public StringType getTextElement() { 
511          if (this.text == null)
512            if (Configuration.errorOnAutoCreate())
513              throw new Error("Attempt to auto-create MedicationAdministrationDosageComponent.text");
514            else if (Configuration.doAutoCreate())
515              this.text = new StringType(); // bb
516          return this.text;
517        }
518
519        public boolean hasTextElement() { 
520          return this.text != null && !this.text.isEmpty();
521        }
522
523        public boolean hasText() { 
524          return this.text != null && !this.text.isEmpty();
525        }
526
527        /**
528         * @param value {@link #text} (Free text dosage can be used for cases where the dosage administered is too complex to code. When coded dosage is present, the free text dosage may still be present for display to humans.
529
530The dosage instructions should reflect the dosage of the medication that was administered.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value
531         */
532        public MedicationAdministrationDosageComponent setTextElement(StringType value) { 
533          this.text = value;
534          return this;
535        }
536
537        /**
538         * @return Free text dosage can be used for cases where the dosage administered is too complex to code. When coded dosage is present, the free text dosage may still be present for display to humans.
539
540The dosage instructions should reflect the dosage of the medication that was administered.
541         */
542        public String getText() { 
543          return this.text == null ? null : this.text.getValue();
544        }
545
546        /**
547         * @param value Free text dosage can be used for cases where the dosage administered is too complex to code. When coded dosage is present, the free text dosage may still be present for display to humans.
548
549The dosage instructions should reflect the dosage of the medication that was administered.
550         */
551        public MedicationAdministrationDosageComponent setText(String value) { 
552          if (Utilities.noString(value))
553            this.text = null;
554          else {
555            if (this.text == null)
556              this.text = new StringType();
557            this.text.setValue(value);
558          }
559          return this;
560        }
561
562        /**
563         * @return {@link #site} (A coded specification of the anatomic site where the medication first entered the body.  For example, "left arm".)
564         */
565        public CodeableConcept getSite() { 
566          if (this.site == null)
567            if (Configuration.errorOnAutoCreate())
568              throw new Error("Attempt to auto-create MedicationAdministrationDosageComponent.site");
569            else if (Configuration.doAutoCreate())
570              this.site = new CodeableConcept(); // cc
571          return this.site;
572        }
573
574        public boolean hasSite() { 
575          return this.site != null && !this.site.isEmpty();
576        }
577
578        /**
579         * @param value {@link #site} (A coded specification of the anatomic site where the medication first entered the body.  For example, "left arm".)
580         */
581        public MedicationAdministrationDosageComponent setSite(CodeableConcept value) { 
582          this.site = value;
583          return this;
584        }
585
586        /**
587         * @return {@link #route} (A code specifying the route or physiological path of administration of a therapeutic agent into or onto the patient.  For example, topical, intravenous, etc.)
588         */
589        public CodeableConcept getRoute() { 
590          if (this.route == null)
591            if (Configuration.errorOnAutoCreate())
592              throw new Error("Attempt to auto-create MedicationAdministrationDosageComponent.route");
593            else if (Configuration.doAutoCreate())
594              this.route = new CodeableConcept(); // cc
595          return this.route;
596        }
597
598        public boolean hasRoute() { 
599          return this.route != null && !this.route.isEmpty();
600        }
601
602        /**
603         * @param value {@link #route} (A code specifying the route or physiological path of administration of a therapeutic agent into or onto the patient.  For example, topical, intravenous, etc.)
604         */
605        public MedicationAdministrationDosageComponent setRoute(CodeableConcept value) { 
606          this.route = value;
607          return this;
608        }
609
610        /**
611         * @return {@link #method} (A coded value indicating the method by which the medication is intended to be or was introduced into or on the body.  This attribute will most often NOT be populated.  It is most commonly used for injections.  For example, Slow Push, Deep IV.)
612         */
613        public CodeableConcept getMethod() { 
614          if (this.method == null)
615            if (Configuration.errorOnAutoCreate())
616              throw new Error("Attempt to auto-create MedicationAdministrationDosageComponent.method");
617            else if (Configuration.doAutoCreate())
618              this.method = new CodeableConcept(); // cc
619          return this.method;
620        }
621
622        public boolean hasMethod() { 
623          return this.method != null && !this.method.isEmpty();
624        }
625
626        /**
627         * @param value {@link #method} (A coded value indicating the method by which the medication is intended to be or was introduced into or on the body.  This attribute will most often NOT be populated.  It is most commonly used for injections.  For example, Slow Push, Deep IV.)
628         */
629        public MedicationAdministrationDosageComponent setMethod(CodeableConcept value) { 
630          this.method = value;
631          return this;
632        }
633
634        /**
635         * @return {@link #dose} (The amount of the medication given at one administration event.   Use this value when the administration is essentially an instantaneous event such as a swallowing a tablet or giving an injection.)
636         */
637        public SimpleQuantity getDose() { 
638          if (this.dose == null)
639            if (Configuration.errorOnAutoCreate())
640              throw new Error("Attempt to auto-create MedicationAdministrationDosageComponent.dose");
641            else if (Configuration.doAutoCreate())
642              this.dose = new SimpleQuantity(); // cc
643          return this.dose;
644        }
645
646        public boolean hasDose() { 
647          return this.dose != null && !this.dose.isEmpty();
648        }
649
650        /**
651         * @param value {@link #dose} (The amount of the medication given at one administration event.   Use this value when the administration is essentially an instantaneous event such as a swallowing a tablet or giving an injection.)
652         */
653        public MedicationAdministrationDosageComponent setDose(SimpleQuantity value) { 
654          this.dose = value;
655          return this;
656        }
657
658        /**
659         * @return {@link #rate} (Identifies the speed with which the medication was or will be introduced into the patient.  Typically the rate for an infusion e.g. 100 ml per 1 hour or 100 ml/hr.  May also be expressed as a rate per unit of time e.g. 500 ml per 2 hours.  Other examples:  200 mcg/min or 200 mcg/1 minute; 1 liter/8 hours.)
660         */
661        public Type getRate() { 
662          return this.rate;
663        }
664
665        /**
666         * @return {@link #rate} (Identifies the speed with which the medication was or will be introduced into the patient.  Typically the rate for an infusion e.g. 100 ml per 1 hour or 100 ml/hr.  May also be expressed as a rate per unit of time e.g. 500 ml per 2 hours.  Other examples:  200 mcg/min or 200 mcg/1 minute; 1 liter/8 hours.)
667         */
668        public Ratio getRateRatio() throws FHIRException { 
669          if (!(this.rate instanceof Ratio))
670            throw new FHIRException("Type mismatch: the type Ratio was expected, but "+this.rate.getClass().getName()+" was encountered");
671          return (Ratio) this.rate;
672        }
673
674        public boolean hasRateRatio() { 
675          return this.rate instanceof Ratio;
676        }
677
678        /**
679         * @return {@link #rate} (Identifies the speed with which the medication was or will be introduced into the patient.  Typically the rate for an infusion e.g. 100 ml per 1 hour or 100 ml/hr.  May also be expressed as a rate per unit of time e.g. 500 ml per 2 hours.  Other examples:  200 mcg/min or 200 mcg/1 minute; 1 liter/8 hours.)
680         */
681        public SimpleQuantity getRateSimpleQuantity() throws FHIRException { 
682          if (!(this.rate instanceof SimpleQuantity))
683            throw new FHIRException("Type mismatch: the type SimpleQuantity was expected, but "+this.rate.getClass().getName()+" was encountered");
684          return (SimpleQuantity) this.rate;
685        }
686
687        public boolean hasRateSimpleQuantity() { 
688          return this.rate instanceof SimpleQuantity;
689        }
690
691        public boolean hasRate() { 
692          return this.rate != null && !this.rate.isEmpty();
693        }
694
695        /**
696         * @param value {@link #rate} (Identifies the speed with which the medication was or will be introduced into the patient.  Typically the rate for an infusion e.g. 100 ml per 1 hour or 100 ml/hr.  May also be expressed as a rate per unit of time e.g. 500 ml per 2 hours.  Other examples:  200 mcg/min or 200 mcg/1 minute; 1 liter/8 hours.)
697         */
698        public MedicationAdministrationDosageComponent setRate(Type value) { 
699          this.rate = value;
700          return this;
701        }
702
703        protected void listChildren(List<Property> childrenList) {
704          super.listChildren(childrenList);
705          childrenList.add(new Property("text", "string", "Free text dosage can be used for cases where the dosage administered is too complex to code. When coded dosage is present, the free text dosage may still be present for display to humans.\r\rThe dosage instructions should reflect the dosage of the medication that was administered.", 0, java.lang.Integer.MAX_VALUE, text));
706          childrenList.add(new Property("site", "CodeableConcept", "A coded specification of the anatomic site where the medication first entered the body.  For example, \"left arm\".", 0, java.lang.Integer.MAX_VALUE, site));
707          childrenList.add(new Property("route", "CodeableConcept", "A code specifying the route or physiological path of administration of a therapeutic agent into or onto the patient.  For example, topical, intravenous, etc.", 0, java.lang.Integer.MAX_VALUE, route));
708          childrenList.add(new Property("method", "CodeableConcept", "A coded value indicating the method by which the medication is intended to be or was introduced into or on the body.  This attribute will most often NOT be populated.  It is most commonly used for injections.  For example, Slow Push, Deep IV.", 0, java.lang.Integer.MAX_VALUE, method));
709          childrenList.add(new Property("dose", "SimpleQuantity", "The amount of the medication given at one administration event.   Use this value when the administration is essentially an instantaneous event such as a swallowing a tablet or giving an injection.", 0, java.lang.Integer.MAX_VALUE, dose));
710          childrenList.add(new Property("rate[x]", "Ratio|SimpleQuantity", "Identifies the speed with which the medication was or will be introduced into the patient.  Typically the rate for an infusion e.g. 100 ml per 1 hour or 100 ml/hr.  May also be expressed as a rate per unit of time e.g. 500 ml per 2 hours.  Other examples:  200 mcg/min or 200 mcg/1 minute; 1 liter/8 hours.", 0, java.lang.Integer.MAX_VALUE, rate));
711        }
712
713      @Override
714      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
715        switch (hash) {
716        case 3556653: /*text*/ return this.text == null ? new Base[0] : new Base[] {this.text}; // StringType
717        case 3530567: /*site*/ return this.site == null ? new Base[0] : new Base[] {this.site}; // CodeableConcept
718        case 108704329: /*route*/ return this.route == null ? new Base[0] : new Base[] {this.route}; // CodeableConcept
719        case -1077554975: /*method*/ return this.method == null ? new Base[0] : new Base[] {this.method}; // CodeableConcept
720        case 3089437: /*dose*/ return this.dose == null ? new Base[0] : new Base[] {this.dose}; // SimpleQuantity
721        case 3493088: /*rate*/ return this.rate == null ? new Base[0] : new Base[] {this.rate}; // Type
722        default: return super.getProperty(hash, name, checkValid);
723        }
724
725      }
726
727      @Override
728      public Base setProperty(int hash, String name, Base value) throws FHIRException {
729        switch (hash) {
730        case 3556653: // text
731          this.text = castToString(value); // StringType
732          return value;
733        case 3530567: // site
734          this.site = castToCodeableConcept(value); // CodeableConcept
735          return value;
736        case 108704329: // route
737          this.route = castToCodeableConcept(value); // CodeableConcept
738          return value;
739        case -1077554975: // method
740          this.method = castToCodeableConcept(value); // CodeableConcept
741          return value;
742        case 3089437: // dose
743          this.dose = castToSimpleQuantity(value); // SimpleQuantity
744          return value;
745        case 3493088: // rate
746          this.rate = castToType(value); // Type
747          return value;
748        default: return super.setProperty(hash, name, value);
749        }
750
751      }
752
753      @Override
754      public Base setProperty(String name, Base value) throws FHIRException {
755        if (name.equals("text")) {
756          this.text = castToString(value); // StringType
757        } else if (name.equals("site")) {
758          this.site = castToCodeableConcept(value); // CodeableConcept
759        } else if (name.equals("route")) {
760          this.route = castToCodeableConcept(value); // CodeableConcept
761        } else if (name.equals("method")) {
762          this.method = castToCodeableConcept(value); // CodeableConcept
763        } else if (name.equals("dose")) {
764          this.dose = castToSimpleQuantity(value); // SimpleQuantity
765        } else if (name.equals("rate[x]")) {
766          this.rate = castToType(value); // Type
767        } else
768          return super.setProperty(name, value);
769        return value;
770      }
771
772      @Override
773      public Base makeProperty(int hash, String name) throws FHIRException {
774        switch (hash) {
775        case 3556653:  return getTextElement();
776        case 3530567:  return getSite(); 
777        case 108704329:  return getRoute(); 
778        case -1077554975:  return getMethod(); 
779        case 3089437:  return getDose(); 
780        case 983460768:  return getRate(); 
781        case 3493088:  return getRate(); 
782        default: return super.makeProperty(hash, name);
783        }
784
785      }
786
787      @Override
788      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
789        switch (hash) {
790        case 3556653: /*text*/ return new String[] {"string"};
791        case 3530567: /*site*/ return new String[] {"CodeableConcept"};
792        case 108704329: /*route*/ return new String[] {"CodeableConcept"};
793        case -1077554975: /*method*/ return new String[] {"CodeableConcept"};
794        case 3089437: /*dose*/ return new String[] {"SimpleQuantity"};
795        case 3493088: /*rate*/ return new String[] {"Ratio", "SimpleQuantity"};
796        default: return super.getTypesForProperty(hash, name);
797        }
798
799      }
800
801      @Override
802      public Base addChild(String name) throws FHIRException {
803        if (name.equals("text")) {
804          throw new FHIRException("Cannot call addChild on a primitive type MedicationAdministration.text");
805        }
806        else if (name.equals("site")) {
807          this.site = new CodeableConcept();
808          return this.site;
809        }
810        else if (name.equals("route")) {
811          this.route = new CodeableConcept();
812          return this.route;
813        }
814        else if (name.equals("method")) {
815          this.method = new CodeableConcept();
816          return this.method;
817        }
818        else if (name.equals("dose")) {
819          this.dose = new SimpleQuantity();
820          return this.dose;
821        }
822        else if (name.equals("rateRatio")) {
823          this.rate = new Ratio();
824          return this.rate;
825        }
826        else if (name.equals("rateSimpleQuantity")) {
827          this.rate = new SimpleQuantity();
828          return this.rate;
829        }
830        else
831          return super.addChild(name);
832      }
833
834      public MedicationAdministrationDosageComponent copy() {
835        MedicationAdministrationDosageComponent dst = new MedicationAdministrationDosageComponent();
836        copyValues(dst);
837        dst.text = text == null ? null : text.copy();
838        dst.site = site == null ? null : site.copy();
839        dst.route = route == null ? null : route.copy();
840        dst.method = method == null ? null : method.copy();
841        dst.dose = dose == null ? null : dose.copy();
842        dst.rate = rate == null ? null : rate.copy();
843        return dst;
844      }
845
846      @Override
847      public boolean equalsDeep(Base other) {
848        if (!super.equalsDeep(other))
849          return false;
850        if (!(other instanceof MedicationAdministrationDosageComponent))
851          return false;
852        MedicationAdministrationDosageComponent o = (MedicationAdministrationDosageComponent) other;
853        return compareDeep(text, o.text, true) && compareDeep(site, o.site, true) && compareDeep(route, o.route, true)
854           && compareDeep(method, o.method, true) && compareDeep(dose, o.dose, true) && compareDeep(rate, o.rate, true)
855          ;
856      }
857
858      @Override
859      public boolean equalsShallow(Base other) {
860        if (!super.equalsShallow(other))
861          return false;
862        if (!(other instanceof MedicationAdministrationDosageComponent))
863          return false;
864        MedicationAdministrationDosageComponent o = (MedicationAdministrationDosageComponent) other;
865        return compareValues(text, o.text, true);
866      }
867
868      public boolean isEmpty() {
869        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(text, site, route, method
870          , dose, rate);
871      }
872
873  public String fhirType() {
874    return "MedicationAdministration.dosage";
875
876  }
877
878  }
879
880    /**
881     * External identifier - FHIR will generate its own internal identifiers (probably URLs) which do not need to be explicitly managed by the resource.  The identifier here is one that would be used by another non-FHIR system - for example an automated medication pump would provide a record each time it operated; an administration while the patient was off the ward might be made with a different system and entered after the event.  Particularly important if these records have to be updated.
882     */
883    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
884    @Description(shortDefinition="External identifier", formalDefinition="External identifier - FHIR will generate its own internal identifiers (probably URLs) which do not need to be explicitly managed by the resource.  The identifier here is one that would be used by another non-FHIR system - for example an automated medication pump would provide a record each time it operated; an administration while the patient was off the ward might be made with a different system and entered after the event.  Particularly important if these records have to be updated." )
885    protected List<Identifier> identifier;
886
887    /**
888     * A protocol, guideline, orderset or other definition that was adhered to in whole or in part by this event.
889     */
890    @Child(name = "definition", type = {PlanDefinition.class, ActivityDefinition.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
891    @Description(shortDefinition="Instantiates protocol or definition", formalDefinition="A protocol, guideline, orderset or other definition that was adhered to in whole or in part by this event." )
892    protected List<Reference> definition;
893    /**
894     * The actual objects that are the target of the reference (A protocol, guideline, orderset or other definition that was adhered to in whole or in part by this event.)
895     */
896    protected List<Resource> definitionTarget;
897
898
899    /**
900     * A larger event of which this particular event is a component or step.
901     */
902    @Child(name = "partOf", type = {MedicationAdministration.class, Procedure.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
903    @Description(shortDefinition="Part of referenced event", formalDefinition="A larger event of which this particular event is a component or step." )
904    protected List<Reference> partOf;
905    /**
906     * The actual objects that are the target of the reference (A larger event of which this particular event is a component or step.)
907     */
908    protected List<Resource> partOfTarget;
909
910
911    /**
912     * Will generally be set to show that the administration has been completed.  For some long running administrations such as infusions it is possible for an administration to be started but not completed or it may be paused while some other process is under way.
913     */
914    @Child(name = "status", type = {CodeType.class}, order=3, min=1, max=1, modifier=true, summary=true)
915    @Description(shortDefinition="in-progress | on-hold | completed | entered-in-error | stopped | unknown", formalDefinition="Will generally be set to show that the administration has been completed.  For some long running administrations such as infusions it is possible for an administration to be started but not completed or it may be paused while some other process is under way." )
916    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-admin-status")
917    protected Enumeration<MedicationAdministrationStatus> status;
918
919    /**
920     * Indicates the type of medication administration and where the medication is expected to be consumed or administered.
921     */
922    @Child(name = "category", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=false)
923    @Description(shortDefinition="Type of medication usage", formalDefinition="Indicates the type of medication administration and where the medication is expected to be consumed or administered." )
924    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-admin-category")
925    protected CodeableConcept category;
926
927    /**
928     * Identifies the medication that was 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.
929     */
930    @Child(name = "medication", type = {CodeableConcept.class, Medication.class}, order=5, min=1, max=1, modifier=false, summary=true)
931    @Description(shortDefinition="What was administered", formalDefinition="Identifies the medication that was 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." )
932    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-codes")
933    protected Type medication;
934
935    /**
936     * The person or animal or group receiving the medication.
937     */
938    @Child(name = "subject", type = {Patient.class, Group.class}, order=6, min=1, max=1, modifier=false, summary=true)
939    @Description(shortDefinition="Who received medication", formalDefinition="The person or animal or group receiving the medication." )
940    protected Reference subject;
941
942    /**
943     * The actual object that is the target of the reference (The person or animal or group receiving the medication.)
944     */
945    protected Resource subjectTarget;
946
947    /**
948     * The visit, admission or other contact between patient and health care provider the medication administration was performed as part of.
949     */
950    @Child(name = "context", type = {Encounter.class, EpisodeOfCare.class}, order=7, min=0, max=1, modifier=false, summary=false)
951    @Description(shortDefinition="Encounter or Episode of Care administered as part of", formalDefinition="The visit, admission or other contact between patient and health care provider the medication administration was performed as part of." )
952    protected Reference context;
953
954    /**
955     * The actual object that is the target of the reference (The visit, admission or other contact between patient and health care provider the medication administration was performed as part of.)
956     */
957    protected Resource contextTarget;
958
959    /**
960     * Additional information (for example, patient height and weight) that supports the administration of the medication.
961     */
962    @Child(name = "supportingInformation", type = {Reference.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
963    @Description(shortDefinition="Additional information to support administration", formalDefinition="Additional information (for example, patient height and weight) that supports the administration of the medication." )
964    protected List<Reference> supportingInformation;
965    /**
966     * The actual objects that are the target of the reference (Additional information (for example, patient height and weight) that supports the administration of the medication.)
967     */
968    protected List<Resource> supportingInformationTarget;
969
970
971    /**
972     * A specific date/time or interval of time during which the administration took place (or did not take place, when the 'notGiven' attribute is true). For many administrations, such as swallowing a tablet the use of dateTime is more appropriate.
973     */
974    @Child(name = "effective", type = {DateTimeType.class, Period.class}, order=9, min=1, max=1, modifier=false, summary=true)
975    @Description(shortDefinition="Start and end time of administration", formalDefinition="A specific date/time or interval of time during which the administration took place (or did not take place, when the 'notGiven' attribute is true). For many administrations, such as swallowing a tablet the use of dateTime is more appropriate." )
976    protected Type effective;
977
978    /**
979     * The individual who was responsible for giving the medication to the patient.
980     */
981    @Child(name = "performer", type = {}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
982    @Description(shortDefinition="Who administered substance", formalDefinition="The individual who was responsible for giving the medication to the patient." )
983    protected List<MedicationAdministrationPerformerComponent> performer;
984
985    /**
986     * Set this to true if the record is saying that the medication was NOT administered.
987     */
988    @Child(name = "notGiven", type = {BooleanType.class}, order=11, min=0, max=1, modifier=true, summary=true)
989    @Description(shortDefinition="True if medication not administered", formalDefinition="Set this to true if the record is saying that the medication was NOT administered." )
990    protected BooleanType notGiven;
991
992    /**
993     * A code indicating why the administration was not performed.
994     */
995    @Child(name = "reasonNotGiven", type = {CodeableConcept.class}, order=12, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
996    @Description(shortDefinition="Reason administration not performed", formalDefinition="A code indicating why the administration was not performed." )
997    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/reason-medication-not-given-codes")
998    protected List<CodeableConcept> reasonNotGiven;
999
1000    /**
1001     * A code indicating why the medication was given.
1002     */
1003    @Child(name = "reasonCode", type = {CodeableConcept.class}, order=13, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1004    @Description(shortDefinition="Reason administration performed", formalDefinition="A code indicating why the medication was given." )
1005    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/reason-medication-given-codes")
1006    protected List<CodeableConcept> reasonCode;
1007
1008    /**
1009     * Condition or observation that supports why the medication was administered.
1010     */
1011    @Child(name = "reasonReference", type = {Condition.class, Observation.class}, order=14, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1012    @Description(shortDefinition="Condition or Observation that supports why the medication was administered", formalDefinition="Condition or observation that supports why the medication was administered." )
1013    protected List<Reference> reasonReference;
1014    /**
1015     * The actual objects that are the target of the reference (Condition or observation that supports why the medication was administered.)
1016     */
1017    protected List<Resource> reasonReferenceTarget;
1018
1019
1020    /**
1021     * The original request, instruction or authority to perform the administration.
1022     */
1023    @Child(name = "prescription", type = {MedicationRequest.class}, order=15, min=0, max=1, modifier=false, summary=false)
1024    @Description(shortDefinition="Request administration performed against", formalDefinition="The original request, instruction or authority to perform the administration." )
1025    protected Reference prescription;
1026
1027    /**
1028     * The actual object that is the target of the reference (The original request, instruction or authority to perform the administration.)
1029     */
1030    protected MedicationRequest prescriptionTarget;
1031
1032    /**
1033     * The device used in administering the medication to the patient.  For example, a particular infusion pump.
1034     */
1035    @Child(name = "device", type = {Device.class}, order=16, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1036    @Description(shortDefinition="Device used to administer", formalDefinition="The device used in administering the medication to the patient.  For example, a particular infusion pump." )
1037    protected List<Reference> device;
1038    /**
1039     * The actual objects that are the target of the reference (The device used in administering the medication to the patient.  For example, a particular infusion pump.)
1040     */
1041    protected List<Device> deviceTarget;
1042
1043
1044    /**
1045     * Extra information about the medication administration that is not conveyed by the other attributes.
1046     */
1047    @Child(name = "note", type = {Annotation.class}, order=17, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1048    @Description(shortDefinition="Information about the administration", formalDefinition="Extra information about the medication administration that is not conveyed by the other attributes." )
1049    protected List<Annotation> note;
1050
1051    /**
1052     * Describes the medication dosage information details e.g. dose, rate, site, route, etc.
1053     */
1054    @Child(name = "dosage", type = {}, order=18, min=0, max=1, modifier=false, summary=false)
1055    @Description(shortDefinition="Details of how medication was taken", formalDefinition="Describes the medication dosage information details e.g. dose, rate, site, route, etc." )
1056    protected MedicationAdministrationDosageComponent dosage;
1057
1058    /**
1059     * A summary of the events of interest that have occurred, such as when the administration was verified.
1060     */
1061    @Child(name = "eventHistory", type = {Provenance.class}, order=19, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1062    @Description(shortDefinition="A list of events of interest in the lifecycle", formalDefinition="A summary of the events of interest that have occurred, such as when the administration was verified." )
1063    protected List<Reference> eventHistory;
1064    /**
1065     * The actual objects that are the target of the reference (A summary of the events of interest that have occurred, such as when the administration was verified.)
1066     */
1067    protected List<Provenance> eventHistoryTarget;
1068
1069
1070    private static final long serialVersionUID = 673777544L;
1071
1072  /**
1073   * Constructor
1074   */
1075    public MedicationAdministration() {
1076      super();
1077    }
1078
1079  /**
1080   * Constructor
1081   */
1082    public MedicationAdministration(Enumeration<MedicationAdministrationStatus> status, Type medication, Reference subject, Type effective) {
1083      super();
1084      this.status = status;
1085      this.medication = medication;
1086      this.subject = subject;
1087      this.effective = effective;
1088    }
1089
1090    /**
1091     * @return {@link #identifier} (External identifier - FHIR will generate its own internal identifiers (probably URLs) which do not need to be explicitly managed by the resource.  The identifier here is one that would be used by another non-FHIR system - for example an automated medication pump would provide a record each time it operated; an administration while the patient was off the ward might be made with a different system and entered after the event.  Particularly important if these records have to be updated.)
1092     */
1093    public List<Identifier> getIdentifier() { 
1094      if (this.identifier == null)
1095        this.identifier = new ArrayList<Identifier>();
1096      return this.identifier;
1097    }
1098
1099    /**
1100     * @return Returns a reference to <code>this</code> for easy method chaining
1101     */
1102    public MedicationAdministration setIdentifier(List<Identifier> theIdentifier) { 
1103      this.identifier = theIdentifier;
1104      return this;
1105    }
1106
1107    public boolean hasIdentifier() { 
1108      if (this.identifier == null)
1109        return false;
1110      for (Identifier item : this.identifier)
1111        if (!item.isEmpty())
1112          return true;
1113      return false;
1114    }
1115
1116    public Identifier addIdentifier() { //3
1117      Identifier t = new Identifier();
1118      if (this.identifier == null)
1119        this.identifier = new ArrayList<Identifier>();
1120      this.identifier.add(t);
1121      return t;
1122    }
1123
1124    public MedicationAdministration addIdentifier(Identifier t) { //3
1125      if (t == null)
1126        return this;
1127      if (this.identifier == null)
1128        this.identifier = new ArrayList<Identifier>();
1129      this.identifier.add(t);
1130      return this;
1131    }
1132
1133    /**
1134     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
1135     */
1136    public Identifier getIdentifierFirstRep() { 
1137      if (getIdentifier().isEmpty()) {
1138        addIdentifier();
1139      }
1140      return getIdentifier().get(0);
1141    }
1142
1143    /**
1144     * @return {@link #definition} (A protocol, guideline, orderset or other definition that was adhered to in whole or in part by this event.)
1145     */
1146    public List<Reference> getDefinition() { 
1147      if (this.definition == null)
1148        this.definition = new ArrayList<Reference>();
1149      return this.definition;
1150    }
1151
1152    /**
1153     * @return Returns a reference to <code>this</code> for easy method chaining
1154     */
1155    public MedicationAdministration setDefinition(List<Reference> theDefinition) { 
1156      this.definition = theDefinition;
1157      return this;
1158    }
1159
1160    public boolean hasDefinition() { 
1161      if (this.definition == null)
1162        return false;
1163      for (Reference item : this.definition)
1164        if (!item.isEmpty())
1165          return true;
1166      return false;
1167    }
1168
1169    public Reference addDefinition() { //3
1170      Reference t = new Reference();
1171      if (this.definition == null)
1172        this.definition = new ArrayList<Reference>();
1173      this.definition.add(t);
1174      return t;
1175    }
1176
1177    public MedicationAdministration addDefinition(Reference t) { //3
1178      if (t == null)
1179        return this;
1180      if (this.definition == null)
1181        this.definition = new ArrayList<Reference>();
1182      this.definition.add(t);
1183      return this;
1184    }
1185
1186    /**
1187     * @return The first repetition of repeating field {@link #definition}, creating it if it does not already exist
1188     */
1189    public Reference getDefinitionFirstRep() { 
1190      if (getDefinition().isEmpty()) {
1191        addDefinition();
1192      }
1193      return getDefinition().get(0);
1194    }
1195
1196    /**
1197     * @deprecated Use Reference#setResource(IBaseResource) instead
1198     */
1199    @Deprecated
1200    public List<Resource> getDefinitionTarget() { 
1201      if (this.definitionTarget == null)
1202        this.definitionTarget = new ArrayList<Resource>();
1203      return this.definitionTarget;
1204    }
1205
1206    /**
1207     * @return {@link #partOf} (A larger event of which this particular event is a component or step.)
1208     */
1209    public List<Reference> getPartOf() { 
1210      if (this.partOf == null)
1211        this.partOf = new ArrayList<Reference>();
1212      return this.partOf;
1213    }
1214
1215    /**
1216     * @return Returns a reference to <code>this</code> for easy method chaining
1217     */
1218    public MedicationAdministration setPartOf(List<Reference> thePartOf) { 
1219      this.partOf = thePartOf;
1220      return this;
1221    }
1222
1223    public boolean hasPartOf() { 
1224      if (this.partOf == null)
1225        return false;
1226      for (Reference item : this.partOf)
1227        if (!item.isEmpty())
1228          return true;
1229      return false;
1230    }
1231
1232    public Reference addPartOf() { //3
1233      Reference t = new Reference();
1234      if (this.partOf == null)
1235        this.partOf = new ArrayList<Reference>();
1236      this.partOf.add(t);
1237      return t;
1238    }
1239
1240    public MedicationAdministration addPartOf(Reference t) { //3
1241      if (t == null)
1242        return this;
1243      if (this.partOf == null)
1244        this.partOf = new ArrayList<Reference>();
1245      this.partOf.add(t);
1246      return this;
1247    }
1248
1249    /**
1250     * @return The first repetition of repeating field {@link #partOf}, creating it if it does not already exist
1251     */
1252    public Reference getPartOfFirstRep() { 
1253      if (getPartOf().isEmpty()) {
1254        addPartOf();
1255      }
1256      return getPartOf().get(0);
1257    }
1258
1259    /**
1260     * @deprecated Use Reference#setResource(IBaseResource) instead
1261     */
1262    @Deprecated
1263    public List<Resource> getPartOfTarget() { 
1264      if (this.partOfTarget == null)
1265        this.partOfTarget = new ArrayList<Resource>();
1266      return this.partOfTarget;
1267    }
1268
1269    /**
1270     * @return {@link #status} (Will generally be set to show that the administration has been completed.  For some long running administrations such as infusions it is possible for an administration to be started but not completed or it may be paused while some other process is under way.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1271     */
1272    public Enumeration<MedicationAdministrationStatus> getStatusElement() { 
1273      if (this.status == null)
1274        if (Configuration.errorOnAutoCreate())
1275          throw new Error("Attempt to auto-create MedicationAdministration.status");
1276        else if (Configuration.doAutoCreate())
1277          this.status = new Enumeration<MedicationAdministrationStatus>(new MedicationAdministrationStatusEnumFactory()); // bb
1278      return this.status;
1279    }
1280
1281    public boolean hasStatusElement() { 
1282      return this.status != null && !this.status.isEmpty();
1283    }
1284
1285    public boolean hasStatus() { 
1286      return this.status != null && !this.status.isEmpty();
1287    }
1288
1289    /**
1290     * @param value {@link #status} (Will generally be set to show that the administration has been completed.  For some long running administrations such as infusions it is possible for an administration to be started but not completed or it may be paused while some other process is under way.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1291     */
1292    public MedicationAdministration setStatusElement(Enumeration<MedicationAdministrationStatus> value) { 
1293      this.status = value;
1294      return this;
1295    }
1296
1297    /**
1298     * @return Will generally be set to show that the administration has been completed.  For some long running administrations such as infusions it is possible for an administration to be started but not completed or it may be paused while some other process is under way.
1299     */
1300    public MedicationAdministrationStatus getStatus() { 
1301      return this.status == null ? null : this.status.getValue();
1302    }
1303
1304    /**
1305     * @param value Will generally be set to show that the administration has been completed.  For some long running administrations such as infusions it is possible for an administration to be started but not completed or it may be paused while some other process is under way.
1306     */
1307    public MedicationAdministration setStatus(MedicationAdministrationStatus value) { 
1308        if (this.status == null)
1309          this.status = new Enumeration<MedicationAdministrationStatus>(new MedicationAdministrationStatusEnumFactory());
1310        this.status.setValue(value);
1311      return this;
1312    }
1313
1314    /**
1315     * @return {@link #category} (Indicates the type of medication administration and where the medication is expected to be consumed or administered.)
1316     */
1317    public CodeableConcept getCategory() { 
1318      if (this.category == null)
1319        if (Configuration.errorOnAutoCreate())
1320          throw new Error("Attempt to auto-create MedicationAdministration.category");
1321        else if (Configuration.doAutoCreate())
1322          this.category = new CodeableConcept(); // cc
1323      return this.category;
1324    }
1325
1326    public boolean hasCategory() { 
1327      return this.category != null && !this.category.isEmpty();
1328    }
1329
1330    /**
1331     * @param value {@link #category} (Indicates the type of medication administration and where the medication is expected to be consumed or administered.)
1332     */
1333    public MedicationAdministration setCategory(CodeableConcept value) { 
1334      this.category = value;
1335      return this;
1336    }
1337
1338    /**
1339     * @return {@link #medication} (Identifies the medication that was 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.)
1340     */
1341    public Type getMedication() { 
1342      return this.medication;
1343    }
1344
1345    /**
1346     * @return {@link #medication} (Identifies the medication that was 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.)
1347     */
1348    public CodeableConcept getMedicationCodeableConcept() throws FHIRException { 
1349      if (!(this.medication instanceof CodeableConcept))
1350        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.medication.getClass().getName()+" was encountered");
1351      return (CodeableConcept) this.medication;
1352    }
1353
1354    public boolean hasMedicationCodeableConcept() { 
1355      return this.medication instanceof CodeableConcept;
1356    }
1357
1358    /**
1359     * @return {@link #medication} (Identifies the medication that was 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.)
1360     */
1361    public Reference getMedicationReference() throws FHIRException { 
1362      if (!(this.medication instanceof Reference))
1363        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.medication.getClass().getName()+" was encountered");
1364      return (Reference) this.medication;
1365    }
1366
1367    public boolean hasMedicationReference() { 
1368      return this.medication instanceof Reference;
1369    }
1370
1371    public boolean hasMedication() { 
1372      return this.medication != null && !this.medication.isEmpty();
1373    }
1374
1375    /**
1376     * @param value {@link #medication} (Identifies the medication that was 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.)
1377     */
1378    public MedicationAdministration setMedication(Type value) { 
1379      this.medication = value;
1380      return this;
1381    }
1382
1383    /**
1384     * @return {@link #subject} (The person or animal or group receiving the medication.)
1385     */
1386    public Reference getSubject() { 
1387      if (this.subject == null)
1388        if (Configuration.errorOnAutoCreate())
1389          throw new Error("Attempt to auto-create MedicationAdministration.subject");
1390        else if (Configuration.doAutoCreate())
1391          this.subject = new Reference(); // cc
1392      return this.subject;
1393    }
1394
1395    public boolean hasSubject() { 
1396      return this.subject != null && !this.subject.isEmpty();
1397    }
1398
1399    /**
1400     * @param value {@link #subject} (The person or animal or group receiving the medication.)
1401     */
1402    public MedicationAdministration setSubject(Reference value) { 
1403      this.subject = value;
1404      return this;
1405    }
1406
1407    /**
1408     * @return {@link #subject} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The person or animal or group receiving the medication.)
1409     */
1410    public Resource getSubjectTarget() { 
1411      return this.subjectTarget;
1412    }
1413
1414    /**
1415     * @param value {@link #subject} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The person or animal or group receiving the medication.)
1416     */
1417    public MedicationAdministration setSubjectTarget(Resource value) { 
1418      this.subjectTarget = value;
1419      return this;
1420    }
1421
1422    /**
1423     * @return {@link #context} (The visit, admission or other contact between patient and health care provider the medication administration was performed as part of.)
1424     */
1425    public Reference getContext() { 
1426      if (this.context == null)
1427        if (Configuration.errorOnAutoCreate())
1428          throw new Error("Attempt to auto-create MedicationAdministration.context");
1429        else if (Configuration.doAutoCreate())
1430          this.context = new Reference(); // cc
1431      return this.context;
1432    }
1433
1434    public boolean hasContext() { 
1435      return this.context != null && !this.context.isEmpty();
1436    }
1437
1438    /**
1439     * @param value {@link #context} (The visit, admission or other contact between patient and health care provider the medication administration was performed as part of.)
1440     */
1441    public MedicationAdministration setContext(Reference value) { 
1442      this.context = value;
1443      return this;
1444    }
1445
1446    /**
1447     * @return {@link #context} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The visit, admission or other contact between patient and health care provider the medication administration was performed as part of.)
1448     */
1449    public Resource getContextTarget() { 
1450      return this.contextTarget;
1451    }
1452
1453    /**
1454     * @param value {@link #context} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The visit, admission or other contact between patient and health care provider the medication administration was performed as part of.)
1455     */
1456    public MedicationAdministration setContextTarget(Resource value) { 
1457      this.contextTarget = value;
1458      return this;
1459    }
1460
1461    /**
1462     * @return {@link #supportingInformation} (Additional information (for example, patient height and weight) that supports the administration of the medication.)
1463     */
1464    public List<Reference> getSupportingInformation() { 
1465      if (this.supportingInformation == null)
1466        this.supportingInformation = new ArrayList<Reference>();
1467      return this.supportingInformation;
1468    }
1469
1470    /**
1471     * @return Returns a reference to <code>this</code> for easy method chaining
1472     */
1473    public MedicationAdministration setSupportingInformation(List<Reference> theSupportingInformation) { 
1474      this.supportingInformation = theSupportingInformation;
1475      return this;
1476    }
1477
1478    public boolean hasSupportingInformation() { 
1479      if (this.supportingInformation == null)
1480        return false;
1481      for (Reference item : this.supportingInformation)
1482        if (!item.isEmpty())
1483          return true;
1484      return false;
1485    }
1486
1487    public Reference addSupportingInformation() { //3
1488      Reference t = new Reference();
1489      if (this.supportingInformation == null)
1490        this.supportingInformation = new ArrayList<Reference>();
1491      this.supportingInformation.add(t);
1492      return t;
1493    }
1494
1495    public MedicationAdministration addSupportingInformation(Reference t) { //3
1496      if (t == null)
1497        return this;
1498      if (this.supportingInformation == null)
1499        this.supportingInformation = new ArrayList<Reference>();
1500      this.supportingInformation.add(t);
1501      return this;
1502    }
1503
1504    /**
1505     * @return The first repetition of repeating field {@link #supportingInformation}, creating it if it does not already exist
1506     */
1507    public Reference getSupportingInformationFirstRep() { 
1508      if (getSupportingInformation().isEmpty()) {
1509        addSupportingInformation();
1510      }
1511      return getSupportingInformation().get(0);
1512    }
1513
1514    /**
1515     * @deprecated Use Reference#setResource(IBaseResource) instead
1516     */
1517    @Deprecated
1518    public List<Resource> getSupportingInformationTarget() { 
1519      if (this.supportingInformationTarget == null)
1520        this.supportingInformationTarget = new ArrayList<Resource>();
1521      return this.supportingInformationTarget;
1522    }
1523
1524    /**
1525     * @return {@link #effective} (A specific date/time or interval of time during which the administration took place (or did not take place, when the 'notGiven' attribute is true). For many administrations, such as swallowing a tablet the use of dateTime is more appropriate.)
1526     */
1527    public Type getEffective() { 
1528      return this.effective;
1529    }
1530
1531    /**
1532     * @return {@link #effective} (A specific date/time or interval of time during which the administration took place (or did not take place, when the 'notGiven' attribute is true). For many administrations, such as swallowing a tablet the use of dateTime is more appropriate.)
1533     */
1534    public DateTimeType getEffectiveDateTimeType() throws FHIRException { 
1535      if (!(this.effective instanceof DateTimeType))
1536        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.effective.getClass().getName()+" was encountered");
1537      return (DateTimeType) this.effective;
1538    }
1539
1540    public boolean hasEffectiveDateTimeType() { 
1541      return this.effective instanceof DateTimeType;
1542    }
1543
1544    /**
1545     * @return {@link #effective} (A specific date/time or interval of time during which the administration took place (or did not take place, when the 'notGiven' attribute is true). For many administrations, such as swallowing a tablet the use of dateTime is more appropriate.)
1546     */
1547    public Period getEffectivePeriod() throws FHIRException { 
1548      if (!(this.effective instanceof Period))
1549        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.effective.getClass().getName()+" was encountered");
1550      return (Period) this.effective;
1551    }
1552
1553    public boolean hasEffectivePeriod() { 
1554      return this.effective instanceof Period;
1555    }
1556
1557    public boolean hasEffective() { 
1558      return this.effective != null && !this.effective.isEmpty();
1559    }
1560
1561    /**
1562     * @param value {@link #effective} (A specific date/time or interval of time during which the administration took place (or did not take place, when the 'notGiven' attribute is true). For many administrations, such as swallowing a tablet the use of dateTime is more appropriate.)
1563     */
1564    public MedicationAdministration setEffective(Type value) { 
1565      this.effective = value;
1566      return this;
1567    }
1568
1569    /**
1570     * @return {@link #performer} (The individual who was responsible for giving the medication to the patient.)
1571     */
1572    public List<MedicationAdministrationPerformerComponent> getPerformer() { 
1573      if (this.performer == null)
1574        this.performer = new ArrayList<MedicationAdministrationPerformerComponent>();
1575      return this.performer;
1576    }
1577
1578    /**
1579     * @return Returns a reference to <code>this</code> for easy method chaining
1580     */
1581    public MedicationAdministration setPerformer(List<MedicationAdministrationPerformerComponent> thePerformer) { 
1582      this.performer = thePerformer;
1583      return this;
1584    }
1585
1586    public boolean hasPerformer() { 
1587      if (this.performer == null)
1588        return false;
1589      for (MedicationAdministrationPerformerComponent item : this.performer)
1590        if (!item.isEmpty())
1591          return true;
1592      return false;
1593    }
1594
1595    public MedicationAdministrationPerformerComponent addPerformer() { //3
1596      MedicationAdministrationPerformerComponent t = new MedicationAdministrationPerformerComponent();
1597      if (this.performer == null)
1598        this.performer = new ArrayList<MedicationAdministrationPerformerComponent>();
1599      this.performer.add(t);
1600      return t;
1601    }
1602
1603    public MedicationAdministration addPerformer(MedicationAdministrationPerformerComponent t) { //3
1604      if (t == null)
1605        return this;
1606      if (this.performer == null)
1607        this.performer = new ArrayList<MedicationAdministrationPerformerComponent>();
1608      this.performer.add(t);
1609      return this;
1610    }
1611
1612    /**
1613     * @return The first repetition of repeating field {@link #performer}, creating it if it does not already exist
1614     */
1615    public MedicationAdministrationPerformerComponent getPerformerFirstRep() { 
1616      if (getPerformer().isEmpty()) {
1617        addPerformer();
1618      }
1619      return getPerformer().get(0);
1620    }
1621
1622    /**
1623     * @return {@link #notGiven} (Set this to true if the record is saying that the medication was NOT administered.). This is the underlying object with id, value and extensions. The accessor "getNotGiven" gives direct access to the value
1624     */
1625    public BooleanType getNotGivenElement() { 
1626      if (this.notGiven == null)
1627        if (Configuration.errorOnAutoCreate())
1628          throw new Error("Attempt to auto-create MedicationAdministration.notGiven");
1629        else if (Configuration.doAutoCreate())
1630          this.notGiven = new BooleanType(); // bb
1631      return this.notGiven;
1632    }
1633
1634    public boolean hasNotGivenElement() { 
1635      return this.notGiven != null && !this.notGiven.isEmpty();
1636    }
1637
1638    public boolean hasNotGiven() { 
1639      return this.notGiven != null && !this.notGiven.isEmpty();
1640    }
1641
1642    /**
1643     * @param value {@link #notGiven} (Set this to true if the record is saying that the medication was NOT administered.). This is the underlying object with id, value and extensions. The accessor "getNotGiven" gives direct access to the value
1644     */
1645    public MedicationAdministration setNotGivenElement(BooleanType value) { 
1646      this.notGiven = value;
1647      return this;
1648    }
1649
1650    /**
1651     * @return Set this to true if the record is saying that the medication was NOT administered.
1652     */
1653    public boolean getNotGiven() { 
1654      return this.notGiven == null || this.notGiven.isEmpty() ? false : this.notGiven.getValue();
1655    }
1656
1657    /**
1658     * @param value Set this to true if the record is saying that the medication was NOT administered.
1659     */
1660    public MedicationAdministration setNotGiven(boolean value) { 
1661        if (this.notGiven == null)
1662          this.notGiven = new BooleanType();
1663        this.notGiven.setValue(value);
1664      return this;
1665    }
1666
1667    /**
1668     * @return {@link #reasonNotGiven} (A code indicating why the administration was not performed.)
1669     */
1670    public List<CodeableConcept> getReasonNotGiven() { 
1671      if (this.reasonNotGiven == null)
1672        this.reasonNotGiven = new ArrayList<CodeableConcept>();
1673      return this.reasonNotGiven;
1674    }
1675
1676    /**
1677     * @return Returns a reference to <code>this</code> for easy method chaining
1678     */
1679    public MedicationAdministration setReasonNotGiven(List<CodeableConcept> theReasonNotGiven) { 
1680      this.reasonNotGiven = theReasonNotGiven;
1681      return this;
1682    }
1683
1684    public boolean hasReasonNotGiven() { 
1685      if (this.reasonNotGiven == null)
1686        return false;
1687      for (CodeableConcept item : this.reasonNotGiven)
1688        if (!item.isEmpty())
1689          return true;
1690      return false;
1691    }
1692
1693    public CodeableConcept addReasonNotGiven() { //3
1694      CodeableConcept t = new CodeableConcept();
1695      if (this.reasonNotGiven == null)
1696        this.reasonNotGiven = new ArrayList<CodeableConcept>();
1697      this.reasonNotGiven.add(t);
1698      return t;
1699    }
1700
1701    public MedicationAdministration addReasonNotGiven(CodeableConcept t) { //3
1702      if (t == null)
1703        return this;
1704      if (this.reasonNotGiven == null)
1705        this.reasonNotGiven = new ArrayList<CodeableConcept>();
1706      this.reasonNotGiven.add(t);
1707      return this;
1708    }
1709
1710    /**
1711     * @return The first repetition of repeating field {@link #reasonNotGiven}, creating it if it does not already exist
1712     */
1713    public CodeableConcept getReasonNotGivenFirstRep() { 
1714      if (getReasonNotGiven().isEmpty()) {
1715        addReasonNotGiven();
1716      }
1717      return getReasonNotGiven().get(0);
1718    }
1719
1720    /**
1721     * @return {@link #reasonCode} (A code indicating why the medication was given.)
1722     */
1723    public List<CodeableConcept> getReasonCode() { 
1724      if (this.reasonCode == null)
1725        this.reasonCode = new ArrayList<CodeableConcept>();
1726      return this.reasonCode;
1727    }
1728
1729    /**
1730     * @return Returns a reference to <code>this</code> for easy method chaining
1731     */
1732    public MedicationAdministration setReasonCode(List<CodeableConcept> theReasonCode) { 
1733      this.reasonCode = theReasonCode;
1734      return this;
1735    }
1736
1737    public boolean hasReasonCode() { 
1738      if (this.reasonCode == null)
1739        return false;
1740      for (CodeableConcept item : this.reasonCode)
1741        if (!item.isEmpty())
1742          return true;
1743      return false;
1744    }
1745
1746    public CodeableConcept addReasonCode() { //3
1747      CodeableConcept t = new CodeableConcept();
1748      if (this.reasonCode == null)
1749        this.reasonCode = new ArrayList<CodeableConcept>();
1750      this.reasonCode.add(t);
1751      return t;
1752    }
1753
1754    public MedicationAdministration addReasonCode(CodeableConcept t) { //3
1755      if (t == null)
1756        return this;
1757      if (this.reasonCode == null)
1758        this.reasonCode = new ArrayList<CodeableConcept>();
1759      this.reasonCode.add(t);
1760      return this;
1761    }
1762
1763    /**
1764     * @return The first repetition of repeating field {@link #reasonCode}, creating it if it does not already exist
1765     */
1766    public CodeableConcept getReasonCodeFirstRep() { 
1767      if (getReasonCode().isEmpty()) {
1768        addReasonCode();
1769      }
1770      return getReasonCode().get(0);
1771    }
1772
1773    /**
1774     * @return {@link #reasonReference} (Condition or observation that supports why the medication was administered.)
1775     */
1776    public List<Reference> getReasonReference() { 
1777      if (this.reasonReference == null)
1778        this.reasonReference = new ArrayList<Reference>();
1779      return this.reasonReference;
1780    }
1781
1782    /**
1783     * @return Returns a reference to <code>this</code> for easy method chaining
1784     */
1785    public MedicationAdministration setReasonReference(List<Reference> theReasonReference) { 
1786      this.reasonReference = theReasonReference;
1787      return this;
1788    }
1789
1790    public boolean hasReasonReference() { 
1791      if (this.reasonReference == null)
1792        return false;
1793      for (Reference item : this.reasonReference)
1794        if (!item.isEmpty())
1795          return true;
1796      return false;
1797    }
1798
1799    public Reference addReasonReference() { //3
1800      Reference t = new Reference();
1801      if (this.reasonReference == null)
1802        this.reasonReference = new ArrayList<Reference>();
1803      this.reasonReference.add(t);
1804      return t;
1805    }
1806
1807    public MedicationAdministration addReasonReference(Reference t) { //3
1808      if (t == null)
1809        return this;
1810      if (this.reasonReference == null)
1811        this.reasonReference = new ArrayList<Reference>();
1812      this.reasonReference.add(t);
1813      return this;
1814    }
1815
1816    /**
1817     * @return The first repetition of repeating field {@link #reasonReference}, creating it if it does not already exist
1818     */
1819    public Reference getReasonReferenceFirstRep() { 
1820      if (getReasonReference().isEmpty()) {
1821        addReasonReference();
1822      }
1823      return getReasonReference().get(0);
1824    }
1825
1826    /**
1827     * @deprecated Use Reference#setResource(IBaseResource) instead
1828     */
1829    @Deprecated
1830    public List<Resource> getReasonReferenceTarget() { 
1831      if (this.reasonReferenceTarget == null)
1832        this.reasonReferenceTarget = new ArrayList<Resource>();
1833      return this.reasonReferenceTarget;
1834    }
1835
1836    /**
1837     * @return {@link #prescription} (The original request, instruction or authority to perform the administration.)
1838     */
1839    public Reference getPrescription() { 
1840      if (this.prescription == null)
1841        if (Configuration.errorOnAutoCreate())
1842          throw new Error("Attempt to auto-create MedicationAdministration.prescription");
1843        else if (Configuration.doAutoCreate())
1844          this.prescription = new Reference(); // cc
1845      return this.prescription;
1846    }
1847
1848    public boolean hasPrescription() { 
1849      return this.prescription != null && !this.prescription.isEmpty();
1850    }
1851
1852    /**
1853     * @param value {@link #prescription} (The original request, instruction or authority to perform the administration.)
1854     */
1855    public MedicationAdministration setPrescription(Reference value) { 
1856      this.prescription = value;
1857      return this;
1858    }
1859
1860    /**
1861     * @return {@link #prescription} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The original request, instruction or authority to perform the administration.)
1862     */
1863    public MedicationRequest getPrescriptionTarget() { 
1864      if (this.prescriptionTarget == null)
1865        if (Configuration.errorOnAutoCreate())
1866          throw new Error("Attempt to auto-create MedicationAdministration.prescription");
1867        else if (Configuration.doAutoCreate())
1868          this.prescriptionTarget = new MedicationRequest(); // aa
1869      return this.prescriptionTarget;
1870    }
1871
1872    /**
1873     * @param value {@link #prescription} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The original request, instruction or authority to perform the administration.)
1874     */
1875    public MedicationAdministration setPrescriptionTarget(MedicationRequest value) { 
1876      this.prescriptionTarget = value;
1877      return this;
1878    }
1879
1880    /**
1881     * @return {@link #device} (The device used in administering the medication to the patient.  For example, a particular infusion pump.)
1882     */
1883    public List<Reference> getDevice() { 
1884      if (this.device == null)
1885        this.device = new ArrayList<Reference>();
1886      return this.device;
1887    }
1888
1889    /**
1890     * @return Returns a reference to <code>this</code> for easy method chaining
1891     */
1892    public MedicationAdministration setDevice(List<Reference> theDevice) { 
1893      this.device = theDevice;
1894      return this;
1895    }
1896
1897    public boolean hasDevice() { 
1898      if (this.device == null)
1899        return false;
1900      for (Reference item : this.device)
1901        if (!item.isEmpty())
1902          return true;
1903      return false;
1904    }
1905
1906    public Reference addDevice() { //3
1907      Reference t = new Reference();
1908      if (this.device == null)
1909        this.device = new ArrayList<Reference>();
1910      this.device.add(t);
1911      return t;
1912    }
1913
1914    public MedicationAdministration addDevice(Reference t) { //3
1915      if (t == null)
1916        return this;
1917      if (this.device == null)
1918        this.device = new ArrayList<Reference>();
1919      this.device.add(t);
1920      return this;
1921    }
1922
1923    /**
1924     * @return The first repetition of repeating field {@link #device}, creating it if it does not already exist
1925     */
1926    public Reference getDeviceFirstRep() { 
1927      if (getDevice().isEmpty()) {
1928        addDevice();
1929      }
1930      return getDevice().get(0);
1931    }
1932
1933    /**
1934     * @deprecated Use Reference#setResource(IBaseResource) instead
1935     */
1936    @Deprecated
1937    public List<Device> getDeviceTarget() { 
1938      if (this.deviceTarget == null)
1939        this.deviceTarget = new ArrayList<Device>();
1940      return this.deviceTarget;
1941    }
1942
1943    /**
1944     * @deprecated Use Reference#setResource(IBaseResource) instead
1945     */
1946    @Deprecated
1947    public Device addDeviceTarget() { 
1948      Device r = new Device();
1949      if (this.deviceTarget == null)
1950        this.deviceTarget = new ArrayList<Device>();
1951      this.deviceTarget.add(r);
1952      return r;
1953    }
1954
1955    /**
1956     * @return {@link #note} (Extra information about the medication administration that is not conveyed by the other attributes.)
1957     */
1958    public List<Annotation> getNote() { 
1959      if (this.note == null)
1960        this.note = new ArrayList<Annotation>();
1961      return this.note;
1962    }
1963
1964    /**
1965     * @return Returns a reference to <code>this</code> for easy method chaining
1966     */
1967    public MedicationAdministration setNote(List<Annotation> theNote) { 
1968      this.note = theNote;
1969      return this;
1970    }
1971
1972    public boolean hasNote() { 
1973      if (this.note == null)
1974        return false;
1975      for (Annotation item : this.note)
1976        if (!item.isEmpty())
1977          return true;
1978      return false;
1979    }
1980
1981    public Annotation addNote() { //3
1982      Annotation t = new Annotation();
1983      if (this.note == null)
1984        this.note = new ArrayList<Annotation>();
1985      this.note.add(t);
1986      return t;
1987    }
1988
1989    public MedicationAdministration addNote(Annotation t) { //3
1990      if (t == null)
1991        return this;
1992      if (this.note == null)
1993        this.note = new ArrayList<Annotation>();
1994      this.note.add(t);
1995      return this;
1996    }
1997
1998    /**
1999     * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist
2000     */
2001    public Annotation getNoteFirstRep() { 
2002      if (getNote().isEmpty()) {
2003        addNote();
2004      }
2005      return getNote().get(0);
2006    }
2007
2008    /**
2009     * @return {@link #dosage} (Describes the medication dosage information details e.g. dose, rate, site, route, etc.)
2010     */
2011    public MedicationAdministrationDosageComponent getDosage() { 
2012      if (this.dosage == null)
2013        if (Configuration.errorOnAutoCreate())
2014          throw new Error("Attempt to auto-create MedicationAdministration.dosage");
2015        else if (Configuration.doAutoCreate())
2016          this.dosage = new MedicationAdministrationDosageComponent(); // cc
2017      return this.dosage;
2018    }
2019
2020    public boolean hasDosage() { 
2021      return this.dosage != null && !this.dosage.isEmpty();
2022    }
2023
2024    /**
2025     * @param value {@link #dosage} (Describes the medication dosage information details e.g. dose, rate, site, route, etc.)
2026     */
2027    public MedicationAdministration setDosage(MedicationAdministrationDosageComponent value) { 
2028      this.dosage = value;
2029      return this;
2030    }
2031
2032    /**
2033     * @return {@link #eventHistory} (A summary of the events of interest that have occurred, such as when the administration was verified.)
2034     */
2035    public List<Reference> getEventHistory() { 
2036      if (this.eventHistory == null)
2037        this.eventHistory = new ArrayList<Reference>();
2038      return this.eventHistory;
2039    }
2040
2041    /**
2042     * @return Returns a reference to <code>this</code> for easy method chaining
2043     */
2044    public MedicationAdministration setEventHistory(List<Reference> theEventHistory) { 
2045      this.eventHistory = theEventHistory;
2046      return this;
2047    }
2048
2049    public boolean hasEventHistory() { 
2050      if (this.eventHistory == null)
2051        return false;
2052      for (Reference item : this.eventHistory)
2053        if (!item.isEmpty())
2054          return true;
2055      return false;
2056    }
2057
2058    public Reference addEventHistory() { //3
2059      Reference t = new Reference();
2060      if (this.eventHistory == null)
2061        this.eventHistory = new ArrayList<Reference>();
2062      this.eventHistory.add(t);
2063      return t;
2064    }
2065
2066    public MedicationAdministration addEventHistory(Reference t) { //3
2067      if (t == null)
2068        return this;
2069      if (this.eventHistory == null)
2070        this.eventHistory = new ArrayList<Reference>();
2071      this.eventHistory.add(t);
2072      return this;
2073    }
2074
2075    /**
2076     * @return The first repetition of repeating field {@link #eventHistory}, creating it if it does not already exist
2077     */
2078    public Reference getEventHistoryFirstRep() { 
2079      if (getEventHistory().isEmpty()) {
2080        addEventHistory();
2081      }
2082      return getEventHistory().get(0);
2083    }
2084
2085    /**
2086     * @deprecated Use Reference#setResource(IBaseResource) instead
2087     */
2088    @Deprecated
2089    public List<Provenance> getEventHistoryTarget() { 
2090      if (this.eventHistoryTarget == null)
2091        this.eventHistoryTarget = new ArrayList<Provenance>();
2092      return this.eventHistoryTarget;
2093    }
2094
2095    /**
2096     * @deprecated Use Reference#setResource(IBaseResource) instead
2097     */
2098    @Deprecated
2099    public Provenance addEventHistoryTarget() { 
2100      Provenance r = new Provenance();
2101      if (this.eventHistoryTarget == null)
2102        this.eventHistoryTarget = new ArrayList<Provenance>();
2103      this.eventHistoryTarget.add(r);
2104      return r;
2105    }
2106
2107      protected void listChildren(List<Property> childrenList) {
2108        super.listChildren(childrenList);
2109        childrenList.add(new Property("identifier", "Identifier", "External identifier - FHIR will generate its own internal identifiers (probably URLs) which do not need to be explicitly managed by the resource.  The identifier here is one that would be used by another non-FHIR system - for example an automated medication pump would provide a record each time it operated; an administration while the patient was off the ward might be made with a different system and entered after the event.  Particularly important if these records have to be updated.", 0, java.lang.Integer.MAX_VALUE, identifier));
2110        childrenList.add(new Property("definition", "Reference(PlanDefinition|ActivityDefinition)", "A protocol, guideline, orderset or other definition that was adhered to in whole or in part by this event.", 0, java.lang.Integer.MAX_VALUE, definition));
2111        childrenList.add(new Property("partOf", "Reference(MedicationAdministration|Procedure)", "A larger event of which this particular event is a component or step.", 0, java.lang.Integer.MAX_VALUE, partOf));
2112        childrenList.add(new Property("status", "code", "Will generally be set to show that the administration has been completed.  For some long running administrations such as infusions it is possible for an administration to be started but not completed or it may be paused while some other process is under way.", 0, java.lang.Integer.MAX_VALUE, status));
2113        childrenList.add(new Property("category", "CodeableConcept", "Indicates the type of medication administration and where the medication is expected to be consumed or administered.", 0, java.lang.Integer.MAX_VALUE, category));
2114        childrenList.add(new Property("medication[x]", "CodeableConcept|Reference(Medication)", "Identifies the medication that was administered. This is either a link to a resource representing the details of the medication or a simple attribute carrying a code that identifies the medication from a known list of medications.", 0, java.lang.Integer.MAX_VALUE, medication));
2115        childrenList.add(new Property("subject", "Reference(Patient|Group)", "The person or animal or group receiving the medication.", 0, java.lang.Integer.MAX_VALUE, subject));
2116        childrenList.add(new Property("context", "Reference(Encounter|EpisodeOfCare)", "The visit, admission or other contact between patient and health care provider the medication administration was performed as part of.", 0, java.lang.Integer.MAX_VALUE, context));
2117        childrenList.add(new Property("supportingInformation", "Reference(Any)", "Additional information (for example, patient height and weight) that supports the administration of the medication.", 0, java.lang.Integer.MAX_VALUE, supportingInformation));
2118        childrenList.add(new Property("effective[x]", "dateTime|Period", "A specific date/time or interval of time during which the administration took place (or did not take place, when the 'notGiven' attribute is true). For many administrations, such as swallowing a tablet the use of dateTime is more appropriate.", 0, java.lang.Integer.MAX_VALUE, effective));
2119        childrenList.add(new Property("performer", "", "The individual who was responsible for giving the medication to the patient.", 0, java.lang.Integer.MAX_VALUE, performer));
2120        childrenList.add(new Property("notGiven", "boolean", "Set this to true if the record is saying that the medication was NOT administered.", 0, java.lang.Integer.MAX_VALUE, notGiven));
2121        childrenList.add(new Property("reasonNotGiven", "CodeableConcept", "A code indicating why the administration was not performed.", 0, java.lang.Integer.MAX_VALUE, reasonNotGiven));
2122        childrenList.add(new Property("reasonCode", "CodeableConcept", "A code indicating why the medication was given.", 0, java.lang.Integer.MAX_VALUE, reasonCode));
2123        childrenList.add(new Property("reasonReference", "Reference(Condition|Observation)", "Condition or observation that supports why the medication was administered.", 0, java.lang.Integer.MAX_VALUE, reasonReference));
2124        childrenList.add(new Property("prescription", "Reference(MedicationRequest)", "The original request, instruction or authority to perform the administration.", 0, java.lang.Integer.MAX_VALUE, prescription));
2125        childrenList.add(new Property("device", "Reference(Device)", "The device used in administering the medication to the patient.  For example, a particular infusion pump.", 0, java.lang.Integer.MAX_VALUE, device));
2126        childrenList.add(new Property("note", "Annotation", "Extra information about the medication administration that is not conveyed by the other attributes.", 0, java.lang.Integer.MAX_VALUE, note));
2127        childrenList.add(new Property("dosage", "", "Describes the medication dosage information details e.g. dose, rate, site, route, etc.", 0, java.lang.Integer.MAX_VALUE, dosage));
2128        childrenList.add(new Property("eventHistory", "Reference(Provenance)", "A summary of the events of interest that have occurred, such as when the administration was verified.", 0, java.lang.Integer.MAX_VALUE, eventHistory));
2129      }
2130
2131      @Override
2132      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2133        switch (hash) {
2134        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
2135        case -1014418093: /*definition*/ return this.definition == null ? new Base[0] : this.definition.toArray(new Base[this.definition.size()]); // Reference
2136        case -995410646: /*partOf*/ return this.partOf == null ? new Base[0] : this.partOf.toArray(new Base[this.partOf.size()]); // Reference
2137        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<MedicationAdministrationStatus>
2138        case 50511102: /*category*/ return this.category == null ? new Base[0] : new Base[] {this.category}; // CodeableConcept
2139        case 1998965455: /*medication*/ return this.medication == null ? new Base[0] : new Base[] {this.medication}; // Type
2140        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
2141        case 951530927: /*context*/ return this.context == null ? new Base[0] : new Base[] {this.context}; // Reference
2142        case -1248768647: /*supportingInformation*/ return this.supportingInformation == null ? new Base[0] : this.supportingInformation.toArray(new Base[this.supportingInformation.size()]); // Reference
2143        case -1468651097: /*effective*/ return this.effective == null ? new Base[0] : new Base[] {this.effective}; // Type
2144        case 481140686: /*performer*/ return this.performer == null ? new Base[0] : this.performer.toArray(new Base[this.performer.size()]); // MedicationAdministrationPerformerComponent
2145        case 1554065514: /*notGiven*/ return this.notGiven == null ? new Base[0] : new Base[] {this.notGiven}; // BooleanType
2146        case 2101123790: /*reasonNotGiven*/ return this.reasonNotGiven == null ? new Base[0] : this.reasonNotGiven.toArray(new Base[this.reasonNotGiven.size()]); // CodeableConcept
2147        case 722137681: /*reasonCode*/ return this.reasonCode == null ? new Base[0] : this.reasonCode.toArray(new Base[this.reasonCode.size()]); // CodeableConcept
2148        case -1146218137: /*reasonReference*/ return this.reasonReference == null ? new Base[0] : this.reasonReference.toArray(new Base[this.reasonReference.size()]); // Reference
2149        case 460301338: /*prescription*/ return this.prescription == null ? new Base[0] : new Base[] {this.prescription}; // Reference
2150        case -1335157162: /*device*/ return this.device == null ? new Base[0] : this.device.toArray(new Base[this.device.size()]); // Reference
2151        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
2152        case -1326018889: /*dosage*/ return this.dosage == null ? new Base[0] : new Base[] {this.dosage}; // MedicationAdministrationDosageComponent
2153        case 1835190426: /*eventHistory*/ return this.eventHistory == null ? new Base[0] : this.eventHistory.toArray(new Base[this.eventHistory.size()]); // Reference
2154        default: return super.getProperty(hash, name, checkValid);
2155        }
2156
2157      }
2158
2159      @Override
2160      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2161        switch (hash) {
2162        case -1618432855: // identifier
2163          this.getIdentifier().add(castToIdentifier(value)); // Identifier
2164          return value;
2165        case -1014418093: // definition
2166          this.getDefinition().add(castToReference(value)); // Reference
2167          return value;
2168        case -995410646: // partOf
2169          this.getPartOf().add(castToReference(value)); // Reference
2170          return value;
2171        case -892481550: // status
2172          value = new MedicationAdministrationStatusEnumFactory().fromType(castToCode(value));
2173          this.status = (Enumeration) value; // Enumeration<MedicationAdministrationStatus>
2174          return value;
2175        case 50511102: // category
2176          this.category = castToCodeableConcept(value); // CodeableConcept
2177          return value;
2178        case 1998965455: // medication
2179          this.medication = castToType(value); // Type
2180          return value;
2181        case -1867885268: // subject
2182          this.subject = castToReference(value); // Reference
2183          return value;
2184        case 951530927: // context
2185          this.context = castToReference(value); // Reference
2186          return value;
2187        case -1248768647: // supportingInformation
2188          this.getSupportingInformation().add(castToReference(value)); // Reference
2189          return value;
2190        case -1468651097: // effective
2191          this.effective = castToType(value); // Type
2192          return value;
2193        case 481140686: // performer
2194          this.getPerformer().add((MedicationAdministrationPerformerComponent) value); // MedicationAdministrationPerformerComponent
2195          return value;
2196        case 1554065514: // notGiven
2197          this.notGiven = castToBoolean(value); // BooleanType
2198          return value;
2199        case 2101123790: // reasonNotGiven
2200          this.getReasonNotGiven().add(castToCodeableConcept(value)); // CodeableConcept
2201          return value;
2202        case 722137681: // reasonCode
2203          this.getReasonCode().add(castToCodeableConcept(value)); // CodeableConcept
2204          return value;
2205        case -1146218137: // reasonReference
2206          this.getReasonReference().add(castToReference(value)); // Reference
2207          return value;
2208        case 460301338: // prescription
2209          this.prescription = castToReference(value); // Reference
2210          return value;
2211        case -1335157162: // device
2212          this.getDevice().add(castToReference(value)); // Reference
2213          return value;
2214        case 3387378: // note
2215          this.getNote().add(castToAnnotation(value)); // Annotation
2216          return value;
2217        case -1326018889: // dosage
2218          this.dosage = (MedicationAdministrationDosageComponent) value; // MedicationAdministrationDosageComponent
2219          return value;
2220        case 1835190426: // eventHistory
2221          this.getEventHistory().add(castToReference(value)); // Reference
2222          return value;
2223        default: return super.setProperty(hash, name, value);
2224        }
2225
2226      }
2227
2228      @Override
2229      public Base setProperty(String name, Base value) throws FHIRException {
2230        if (name.equals("identifier")) {
2231          this.getIdentifier().add(castToIdentifier(value));
2232        } else if (name.equals("definition")) {
2233          this.getDefinition().add(castToReference(value));
2234        } else if (name.equals("partOf")) {
2235          this.getPartOf().add(castToReference(value));
2236        } else if (name.equals("status")) {
2237          value = new MedicationAdministrationStatusEnumFactory().fromType(castToCode(value));
2238          this.status = (Enumeration) value; // Enumeration<MedicationAdministrationStatus>
2239        } else if (name.equals("category")) {
2240          this.category = castToCodeableConcept(value); // CodeableConcept
2241        } else if (name.equals("medication[x]")) {
2242          this.medication = castToType(value); // Type
2243        } else if (name.equals("subject")) {
2244          this.subject = castToReference(value); // Reference
2245        } else if (name.equals("context")) {
2246          this.context = castToReference(value); // Reference
2247        } else if (name.equals("supportingInformation")) {
2248          this.getSupportingInformation().add(castToReference(value));
2249        } else if (name.equals("effective[x]")) {
2250          this.effective = castToType(value); // Type
2251        } else if (name.equals("performer")) {
2252          this.getPerformer().add((MedicationAdministrationPerformerComponent) value);
2253        } else if (name.equals("notGiven")) {
2254          this.notGiven = castToBoolean(value); // BooleanType
2255        } else if (name.equals("reasonNotGiven")) {
2256          this.getReasonNotGiven().add(castToCodeableConcept(value));
2257        } else if (name.equals("reasonCode")) {
2258          this.getReasonCode().add(castToCodeableConcept(value));
2259        } else if (name.equals("reasonReference")) {
2260          this.getReasonReference().add(castToReference(value));
2261        } else if (name.equals("prescription")) {
2262          this.prescription = castToReference(value); // Reference
2263        } else if (name.equals("device")) {
2264          this.getDevice().add(castToReference(value));
2265        } else if (name.equals("note")) {
2266          this.getNote().add(castToAnnotation(value));
2267        } else if (name.equals("dosage")) {
2268          this.dosage = (MedicationAdministrationDosageComponent) value; // MedicationAdministrationDosageComponent
2269        } else if (name.equals("eventHistory")) {
2270          this.getEventHistory().add(castToReference(value));
2271        } else
2272          return super.setProperty(name, value);
2273        return value;
2274      }
2275
2276      @Override
2277      public Base makeProperty(int hash, String name) throws FHIRException {
2278        switch (hash) {
2279        case -1618432855:  return addIdentifier(); 
2280        case -1014418093:  return addDefinition(); 
2281        case -995410646:  return addPartOf(); 
2282        case -892481550:  return getStatusElement();
2283        case 50511102:  return getCategory(); 
2284        case 1458402129:  return getMedication(); 
2285        case 1998965455:  return getMedication(); 
2286        case -1867885268:  return getSubject(); 
2287        case 951530927:  return getContext(); 
2288        case -1248768647:  return addSupportingInformation(); 
2289        case 247104889:  return getEffective(); 
2290        case -1468651097:  return getEffective(); 
2291        case 481140686:  return addPerformer(); 
2292        case 1554065514:  return getNotGivenElement();
2293        case 2101123790:  return addReasonNotGiven(); 
2294        case 722137681:  return addReasonCode(); 
2295        case -1146218137:  return addReasonReference(); 
2296        case 460301338:  return getPrescription(); 
2297        case -1335157162:  return addDevice(); 
2298        case 3387378:  return addNote(); 
2299        case -1326018889:  return getDosage(); 
2300        case 1835190426:  return addEventHistory(); 
2301        default: return super.makeProperty(hash, name);
2302        }
2303
2304      }
2305
2306      @Override
2307      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2308        switch (hash) {
2309        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
2310        case -1014418093: /*definition*/ return new String[] {"Reference"};
2311        case -995410646: /*partOf*/ return new String[] {"Reference"};
2312        case -892481550: /*status*/ return new String[] {"code"};
2313        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
2314        case 1998965455: /*medication*/ return new String[] {"CodeableConcept", "Reference"};
2315        case -1867885268: /*subject*/ return new String[] {"Reference"};
2316        case 951530927: /*context*/ return new String[] {"Reference"};
2317        case -1248768647: /*supportingInformation*/ return new String[] {"Reference"};
2318        case -1468651097: /*effective*/ return new String[] {"dateTime", "Period"};
2319        case 481140686: /*performer*/ return new String[] {};
2320        case 1554065514: /*notGiven*/ return new String[] {"boolean"};
2321        case 2101123790: /*reasonNotGiven*/ return new String[] {"CodeableConcept"};
2322        case 722137681: /*reasonCode*/ return new String[] {"CodeableConcept"};
2323        case -1146218137: /*reasonReference*/ return new String[] {"Reference"};
2324        case 460301338: /*prescription*/ return new String[] {"Reference"};
2325        case -1335157162: /*device*/ return new String[] {"Reference"};
2326        case 3387378: /*note*/ return new String[] {"Annotation"};
2327        case -1326018889: /*dosage*/ return new String[] {};
2328        case 1835190426: /*eventHistory*/ return new String[] {"Reference"};
2329        default: return super.getTypesForProperty(hash, name);
2330        }
2331
2332      }
2333
2334      @Override
2335      public Base addChild(String name) throws FHIRException {
2336        if (name.equals("identifier")) {
2337          return addIdentifier();
2338        }
2339        else if (name.equals("definition")) {
2340          return addDefinition();
2341        }
2342        else if (name.equals("partOf")) {
2343          return addPartOf();
2344        }
2345        else if (name.equals("status")) {
2346          throw new FHIRException("Cannot call addChild on a primitive type MedicationAdministration.status");
2347        }
2348        else if (name.equals("category")) {
2349          this.category = new CodeableConcept();
2350          return this.category;
2351        }
2352        else if (name.equals("medicationCodeableConcept")) {
2353          this.medication = new CodeableConcept();
2354          return this.medication;
2355        }
2356        else if (name.equals("medicationReference")) {
2357          this.medication = new Reference();
2358          return this.medication;
2359        }
2360        else if (name.equals("subject")) {
2361          this.subject = new Reference();
2362          return this.subject;
2363        }
2364        else if (name.equals("context")) {
2365          this.context = new Reference();
2366          return this.context;
2367        }
2368        else if (name.equals("supportingInformation")) {
2369          return addSupportingInformation();
2370        }
2371        else if (name.equals("effectiveDateTime")) {
2372          this.effective = new DateTimeType();
2373          return this.effective;
2374        }
2375        else if (name.equals("effectivePeriod")) {
2376          this.effective = new Period();
2377          return this.effective;
2378        }
2379        else if (name.equals("performer")) {
2380          return addPerformer();
2381        }
2382        else if (name.equals("notGiven")) {
2383          throw new FHIRException("Cannot call addChild on a primitive type MedicationAdministration.notGiven");
2384        }
2385        else if (name.equals("reasonNotGiven")) {
2386          return addReasonNotGiven();
2387        }
2388        else if (name.equals("reasonCode")) {
2389          return addReasonCode();
2390        }
2391        else if (name.equals("reasonReference")) {
2392          return addReasonReference();
2393        }
2394        else if (name.equals("prescription")) {
2395          this.prescription = new Reference();
2396          return this.prescription;
2397        }
2398        else if (name.equals("device")) {
2399          return addDevice();
2400        }
2401        else if (name.equals("note")) {
2402          return addNote();
2403        }
2404        else if (name.equals("dosage")) {
2405          this.dosage = new MedicationAdministrationDosageComponent();
2406          return this.dosage;
2407        }
2408        else if (name.equals("eventHistory")) {
2409          return addEventHistory();
2410        }
2411        else
2412          return super.addChild(name);
2413      }
2414
2415  public String fhirType() {
2416    return "MedicationAdministration";
2417
2418  }
2419
2420      public MedicationAdministration copy() {
2421        MedicationAdministration dst = new MedicationAdministration();
2422        copyValues(dst);
2423        if (identifier != null) {
2424          dst.identifier = new ArrayList<Identifier>();
2425          for (Identifier i : identifier)
2426            dst.identifier.add(i.copy());
2427        };
2428        if (definition != null) {
2429          dst.definition = new ArrayList<Reference>();
2430          for (Reference i : definition)
2431            dst.definition.add(i.copy());
2432        };
2433        if (partOf != null) {
2434          dst.partOf = new ArrayList<Reference>();
2435          for (Reference i : partOf)
2436            dst.partOf.add(i.copy());
2437        };
2438        dst.status = status == null ? null : status.copy();
2439        dst.category = category == null ? null : category.copy();
2440        dst.medication = medication == null ? null : medication.copy();
2441        dst.subject = subject == null ? null : subject.copy();
2442        dst.context = context == null ? null : context.copy();
2443        if (supportingInformation != null) {
2444          dst.supportingInformation = new ArrayList<Reference>();
2445          for (Reference i : supportingInformation)
2446            dst.supportingInformation.add(i.copy());
2447        };
2448        dst.effective = effective == null ? null : effective.copy();
2449        if (performer != null) {
2450          dst.performer = new ArrayList<MedicationAdministrationPerformerComponent>();
2451          for (MedicationAdministrationPerformerComponent i : performer)
2452            dst.performer.add(i.copy());
2453        };
2454        dst.notGiven = notGiven == null ? null : notGiven.copy();
2455        if (reasonNotGiven != null) {
2456          dst.reasonNotGiven = new ArrayList<CodeableConcept>();
2457          for (CodeableConcept i : reasonNotGiven)
2458            dst.reasonNotGiven.add(i.copy());
2459        };
2460        if (reasonCode != null) {
2461          dst.reasonCode = new ArrayList<CodeableConcept>();
2462          for (CodeableConcept i : reasonCode)
2463            dst.reasonCode.add(i.copy());
2464        };
2465        if (reasonReference != null) {
2466          dst.reasonReference = new ArrayList<Reference>();
2467          for (Reference i : reasonReference)
2468            dst.reasonReference.add(i.copy());
2469        };
2470        dst.prescription = prescription == null ? null : prescription.copy();
2471        if (device != null) {
2472          dst.device = new ArrayList<Reference>();
2473          for (Reference i : device)
2474            dst.device.add(i.copy());
2475        };
2476        if (note != null) {
2477          dst.note = new ArrayList<Annotation>();
2478          for (Annotation i : note)
2479            dst.note.add(i.copy());
2480        };
2481        dst.dosage = dosage == null ? null : dosage.copy();
2482        if (eventHistory != null) {
2483          dst.eventHistory = new ArrayList<Reference>();
2484          for (Reference i : eventHistory)
2485            dst.eventHistory.add(i.copy());
2486        };
2487        return dst;
2488      }
2489
2490      protected MedicationAdministration typedCopy() {
2491        return copy();
2492      }
2493
2494      @Override
2495      public boolean equalsDeep(Base other) {
2496        if (!super.equalsDeep(other))
2497          return false;
2498        if (!(other instanceof MedicationAdministration))
2499          return false;
2500        MedicationAdministration o = (MedicationAdministration) other;
2501        return compareDeep(identifier, o.identifier, true) && compareDeep(definition, o.definition, true)
2502           && compareDeep(partOf, o.partOf, true) && compareDeep(status, o.status, true) && compareDeep(category, o.category, true)
2503           && compareDeep(medication, o.medication, true) && compareDeep(subject, o.subject, true) && compareDeep(context, o.context, true)
2504           && compareDeep(supportingInformation, o.supportingInformation, true) && compareDeep(effective, o.effective, true)
2505           && compareDeep(performer, o.performer, true) && compareDeep(notGiven, o.notGiven, true) && compareDeep(reasonNotGiven, o.reasonNotGiven, true)
2506           && compareDeep(reasonCode, o.reasonCode, true) && compareDeep(reasonReference, o.reasonReference, true)
2507           && compareDeep(prescription, o.prescription, true) && compareDeep(device, o.device, true) && compareDeep(note, o.note, true)
2508           && compareDeep(dosage, o.dosage, true) && compareDeep(eventHistory, o.eventHistory, true);
2509      }
2510
2511      @Override
2512      public boolean equalsShallow(Base other) {
2513        if (!super.equalsShallow(other))
2514          return false;
2515        if (!(other instanceof MedicationAdministration))
2516          return false;
2517        MedicationAdministration o = (MedicationAdministration) other;
2518        return compareValues(status, o.status, true) && compareValues(notGiven, o.notGiven, true);
2519      }
2520
2521      public boolean isEmpty() {
2522        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, definition, partOf
2523          , status, category, medication, subject, context, supportingInformation, effective
2524          , performer, notGiven, reasonNotGiven, reasonCode, reasonReference, prescription
2525          , device, note, dosage, eventHistory);
2526      }
2527
2528  @Override
2529  public ResourceType getResourceType() {
2530    return ResourceType.MedicationAdministration;
2531   }
2532
2533 /**
2534   * Search parameter: <b>identifier</b>
2535   * <p>
2536   * Description: <b>Return administrations with this external identifier</b><br>
2537   * Type: <b>token</b><br>
2538   * Path: <b>MedicationAdministration.identifier</b><br>
2539   * </p>
2540   */
2541  @SearchParamDefinition(name="identifier", path="MedicationAdministration.identifier", description="Return administrations with this external identifier", type="token" )
2542  public static final String SP_IDENTIFIER = "identifier";
2543 /**
2544   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2545   * <p>
2546   * Description: <b>Return administrations with this external identifier</b><br>
2547   * Type: <b>token</b><br>
2548   * Path: <b>MedicationAdministration.identifier</b><br>
2549   * </p>
2550   */
2551  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
2552
2553 /**
2554   * Search parameter: <b>code</b>
2555   * <p>
2556   * Description: <b>Return administrations of this medication code</b><br>
2557   * Type: <b>token</b><br>
2558   * Path: <b>MedicationAdministration.medicationCodeableConcept</b><br>
2559   * </p>
2560   */
2561  @SearchParamDefinition(name="code", path="MedicationAdministration.medication.as(CodeableConcept)", description="Return administrations of this medication code", type="token" )
2562  public static final String SP_CODE = "code";
2563 /**
2564   * <b>Fluent Client</b> search parameter constant for <b>code</b>
2565   * <p>
2566   * Description: <b>Return administrations of this medication code</b><br>
2567   * Type: <b>token</b><br>
2568   * Path: <b>MedicationAdministration.medicationCodeableConcept</b><br>
2569   * </p>
2570   */
2571  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CODE);
2572
2573 /**
2574   * Search parameter: <b>performer</b>
2575   * <p>
2576   * Description: <b>The identify of the individual who administered the medication</b><br>
2577   * Type: <b>reference</b><br>
2578   * Path: <b>MedicationAdministration.performer.actor</b><br>
2579   * </p>
2580   */
2581  @SearchParamDefinition(name="performer", path="MedicationAdministration.performer.actor", description="The identify of the individual who administered the medication", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner"), @ca.uhn.fhir.model.api.annotation.Compartment(name="RelatedPerson") }, target={Device.class, Patient.class, Practitioner.class, RelatedPerson.class } )
2582  public static final String SP_PERFORMER = "performer";
2583 /**
2584   * <b>Fluent Client</b> search parameter constant for <b>performer</b>
2585   * <p>
2586   * Description: <b>The identify of the individual who administered the medication</b><br>
2587   * Type: <b>reference</b><br>
2588   * Path: <b>MedicationAdministration.performer.actor</b><br>
2589   * </p>
2590   */
2591  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PERFORMER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PERFORMER);
2592
2593/**
2594   * Constant for fluent queries to be used to add include statements. Specifies
2595   * the path value of "<b>MedicationAdministration:performer</b>".
2596   */
2597  public static final ca.uhn.fhir.model.api.Include INCLUDE_PERFORMER = new ca.uhn.fhir.model.api.Include("MedicationAdministration:performer").toLocked();
2598
2599 /**
2600   * Search parameter: <b>subject</b>
2601   * <p>
2602   * Description: <b>The identify of the individual or group to list administrations for</b><br>
2603   * Type: <b>reference</b><br>
2604   * Path: <b>MedicationAdministration.subject</b><br>
2605   * </p>
2606   */
2607  @SearchParamDefinition(name="subject", path="MedicationAdministration.subject", description="The identify of the individual or group to list administrations for", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Group.class, Patient.class } )
2608  public static final String SP_SUBJECT = "subject";
2609 /**
2610   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
2611   * <p>
2612   * Description: <b>The identify of the individual or group to list administrations for</b><br>
2613   * Type: <b>reference</b><br>
2614   * Path: <b>MedicationAdministration.subject</b><br>
2615   * </p>
2616   */
2617  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
2618
2619/**
2620   * Constant for fluent queries to be used to add include statements. Specifies
2621   * the path value of "<b>MedicationAdministration:subject</b>".
2622   */
2623  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("MedicationAdministration:subject").toLocked();
2624
2625 /**
2626   * Search parameter: <b>not-given</b>
2627   * <p>
2628   * Description: <b>Administrations that were not made</b><br>
2629   * Type: <b>token</b><br>
2630   * Path: <b>MedicationAdministration.notGiven</b><br>
2631   * </p>
2632   */
2633  @SearchParamDefinition(name="not-given", path="MedicationAdministration.notGiven", description="Administrations that were not made", type="token" )
2634  public static final String SP_NOT_GIVEN = "not-given";
2635 /**
2636   * <b>Fluent Client</b> search parameter constant for <b>not-given</b>
2637   * <p>
2638   * Description: <b>Administrations that were not made</b><br>
2639   * Type: <b>token</b><br>
2640   * Path: <b>MedicationAdministration.notGiven</b><br>
2641   * </p>
2642   */
2643  public static final ca.uhn.fhir.rest.gclient.TokenClientParam NOT_GIVEN = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_NOT_GIVEN);
2644
2645 /**
2646   * Search parameter: <b>medication</b>
2647   * <p>
2648   * Description: <b>Return administrations of this medication resource</b><br>
2649   * Type: <b>reference</b><br>
2650   * Path: <b>MedicationAdministration.medicationReference</b><br>
2651   * </p>
2652   */
2653  @SearchParamDefinition(name="medication", path="MedicationAdministration.medication.as(Reference)", description="Return administrations of this medication resource", type="reference", target={Medication.class } )
2654  public static final String SP_MEDICATION = "medication";
2655 /**
2656   * <b>Fluent Client</b> search parameter constant for <b>medication</b>
2657   * <p>
2658   * Description: <b>Return administrations of this medication resource</b><br>
2659   * Type: <b>reference</b><br>
2660   * Path: <b>MedicationAdministration.medicationReference</b><br>
2661   * </p>
2662   */
2663  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam MEDICATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_MEDICATION);
2664
2665/**
2666   * Constant for fluent queries to be used to add include statements. Specifies
2667   * the path value of "<b>MedicationAdministration:medication</b>".
2668   */
2669  public static final ca.uhn.fhir.model.api.Include INCLUDE_MEDICATION = new ca.uhn.fhir.model.api.Include("MedicationAdministration:medication").toLocked();
2670
2671 /**
2672   * Search parameter: <b>reason-given</b>
2673   * <p>
2674   * Description: <b>Reasons for administering the medication</b><br>
2675   * Type: <b>token</b><br>
2676   * Path: <b>MedicationAdministration.reasonCode</b><br>
2677   * </p>
2678   */
2679  @SearchParamDefinition(name="reason-given", path="MedicationAdministration.reasonCode", description="Reasons for administering the medication", type="token" )
2680  public static final String SP_REASON_GIVEN = "reason-given";
2681 /**
2682   * <b>Fluent Client</b> search parameter constant for <b>reason-given</b>
2683   * <p>
2684   * Description: <b>Reasons for administering the medication</b><br>
2685   * Type: <b>token</b><br>
2686   * Path: <b>MedicationAdministration.reasonCode</b><br>
2687   * </p>
2688   */
2689  public static final ca.uhn.fhir.rest.gclient.TokenClientParam REASON_GIVEN = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_REASON_GIVEN);
2690
2691 /**
2692   * Search parameter: <b>prescription</b>
2693   * <p>
2694   * Description: <b>The identity of a prescription to list administrations from</b><br>
2695   * Type: <b>reference</b><br>
2696   * Path: <b>MedicationAdministration.prescription</b><br>
2697   * </p>
2698   */
2699  @SearchParamDefinition(name="prescription", path="MedicationAdministration.prescription", description="The identity of a prescription to list administrations from", type="reference", target={MedicationRequest.class } )
2700  public static final String SP_PRESCRIPTION = "prescription";
2701 /**
2702   * <b>Fluent Client</b> search parameter constant for <b>prescription</b>
2703   * <p>
2704   * Description: <b>The identity of a prescription to list administrations from</b><br>
2705   * Type: <b>reference</b><br>
2706   * Path: <b>MedicationAdministration.prescription</b><br>
2707   * </p>
2708   */
2709  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PRESCRIPTION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PRESCRIPTION);
2710
2711/**
2712   * Constant for fluent queries to be used to add include statements. Specifies
2713   * the path value of "<b>MedicationAdministration:prescription</b>".
2714   */
2715  public static final ca.uhn.fhir.model.api.Include INCLUDE_PRESCRIPTION = new ca.uhn.fhir.model.api.Include("MedicationAdministration:prescription").toLocked();
2716
2717 /**
2718   * Search parameter: <b>patient</b>
2719   * <p>
2720   * Description: <b>The identity of a patient to list administrations  for</b><br>
2721   * Type: <b>reference</b><br>
2722   * Path: <b>MedicationAdministration.subject</b><br>
2723   * </p>
2724   */
2725  @SearchParamDefinition(name="patient", path="MedicationAdministration.subject", description="The identity of a patient to list administrations  for", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Patient.class } )
2726  public static final String SP_PATIENT = "patient";
2727 /**
2728   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
2729   * <p>
2730   * Description: <b>The identity of a patient to list administrations  for</b><br>
2731   * Type: <b>reference</b><br>
2732   * Path: <b>MedicationAdministration.subject</b><br>
2733   * </p>
2734   */
2735  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
2736
2737/**
2738   * Constant for fluent queries to be used to add include statements. Specifies
2739   * the path value of "<b>MedicationAdministration:patient</b>".
2740   */
2741  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("MedicationAdministration:patient").toLocked();
2742
2743 /**
2744   * Search parameter: <b>effective-time</b>
2745   * <p>
2746   * Description: <b>Date administration happened (or did not happen)</b><br>
2747   * Type: <b>date</b><br>
2748   * Path: <b>MedicationAdministration.effective[x]</b><br>
2749   * </p>
2750   */
2751  @SearchParamDefinition(name="effective-time", path="MedicationAdministration.effective", description="Date administration happened (or did not happen)", type="date" )
2752  public static final String SP_EFFECTIVE_TIME = "effective-time";
2753 /**
2754   * <b>Fluent Client</b> search parameter constant for <b>effective-time</b>
2755   * <p>
2756   * Description: <b>Date administration happened (or did not happen)</b><br>
2757   * Type: <b>date</b><br>
2758   * Path: <b>MedicationAdministration.effective[x]</b><br>
2759   * </p>
2760   */
2761  public static final ca.uhn.fhir.rest.gclient.DateClientParam EFFECTIVE_TIME = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_EFFECTIVE_TIME);
2762
2763 /**
2764   * Search parameter: <b>context</b>
2765   * <p>
2766   * Description: <b>Return administrations that share this encounter or episode of care</b><br>
2767   * Type: <b>reference</b><br>
2768   * Path: <b>MedicationAdministration.context</b><br>
2769   * </p>
2770   */
2771  @SearchParamDefinition(name="context", path="MedicationAdministration.context", description="Return administrations that share this encounter or episode of care", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Encounter") }, target={Encounter.class, EpisodeOfCare.class } )
2772  public static final String SP_CONTEXT = "context";
2773 /**
2774   * <b>Fluent Client</b> search parameter constant for <b>context</b>
2775   * <p>
2776   * Description: <b>Return administrations that share this encounter or episode of care</b><br>
2777   * Type: <b>reference</b><br>
2778   * Path: <b>MedicationAdministration.context</b><br>
2779   * </p>
2780   */
2781  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam CONTEXT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_CONTEXT);
2782
2783/**
2784   * Constant for fluent queries to be used to add include statements. Specifies
2785   * the path value of "<b>MedicationAdministration:context</b>".
2786   */
2787  public static final ca.uhn.fhir.model.api.Include INCLUDE_CONTEXT = new ca.uhn.fhir.model.api.Include("MedicationAdministration:context").toLocked();
2788
2789 /**
2790   * Search parameter: <b>reason-not-given</b>
2791   * <p>
2792   * Description: <b>Reasons for not administering the medication</b><br>
2793   * Type: <b>token</b><br>
2794   * Path: <b>MedicationAdministration.reasonNotGiven</b><br>
2795   * </p>
2796   */
2797  @SearchParamDefinition(name="reason-not-given", path="MedicationAdministration.reasonNotGiven", description="Reasons for not administering the medication", type="token" )
2798  public static final String SP_REASON_NOT_GIVEN = "reason-not-given";
2799 /**
2800   * <b>Fluent Client</b> search parameter constant for <b>reason-not-given</b>
2801   * <p>
2802   * Description: <b>Reasons for not administering the medication</b><br>
2803   * Type: <b>token</b><br>
2804   * Path: <b>MedicationAdministration.reasonNotGiven</b><br>
2805   * </p>
2806   */
2807  public static final ca.uhn.fhir.rest.gclient.TokenClientParam REASON_NOT_GIVEN = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_REASON_NOT_GIVEN);
2808
2809 /**
2810   * Search parameter: <b>device</b>
2811   * <p>
2812   * Description: <b>Return administrations with this administration device identity</b><br>
2813   * Type: <b>reference</b><br>
2814   * Path: <b>MedicationAdministration.device</b><br>
2815   * </p>
2816   */
2817  @SearchParamDefinition(name="device", path="MedicationAdministration.device", description="Return administrations with this administration device identity", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Device") }, target={Device.class } )
2818  public static final String SP_DEVICE = "device";
2819 /**
2820   * <b>Fluent Client</b> search parameter constant for <b>device</b>
2821   * <p>
2822   * Description: <b>Return administrations with this administration device identity</b><br>
2823   * Type: <b>reference</b><br>
2824   * Path: <b>MedicationAdministration.device</b><br>
2825   * </p>
2826   */
2827  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam DEVICE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_DEVICE);
2828
2829/**
2830   * Constant for fluent queries to be used to add include statements. Specifies
2831   * the path value of "<b>MedicationAdministration:device</b>".
2832   */
2833  public static final ca.uhn.fhir.model.api.Include INCLUDE_DEVICE = new ca.uhn.fhir.model.api.Include("MedicationAdministration:device").toLocked();
2834
2835 /**
2836   * Search parameter: <b>status</b>
2837   * <p>
2838   * Description: <b>MedicationAdministration event status (for example one of active/paused/completed/nullified)</b><br>
2839   * Type: <b>token</b><br>
2840   * Path: <b>MedicationAdministration.status</b><br>
2841   * </p>
2842   */
2843  @SearchParamDefinition(name="status", path="MedicationAdministration.status", description="MedicationAdministration event status (for example one of active/paused/completed/nullified)", type="token" )
2844  public static final String SP_STATUS = "status";
2845 /**
2846   * <b>Fluent Client</b> search parameter constant for <b>status</b>
2847   * <p>
2848   * Description: <b>MedicationAdministration event status (for example one of active/paused/completed/nullified)</b><br>
2849   * Type: <b>token</b><br>
2850   * Path: <b>MedicationAdministration.status</b><br>
2851   * </p>
2852   */
2853  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
2854
2855
2856}
2857