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