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