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