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