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