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