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