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