001package org.hl7.fhir.dstu2016may.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 Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
033import java.util.ArrayList;
034import java.util.List;
035
036import org.hl7.fhir.exceptions.FHIRException;
037import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
038import org.hl7.fhir.utilities.Utilities;
039
040import ca.uhn.fhir.model.api.annotation.Block;
041import ca.uhn.fhir.model.api.annotation.Child;
042import ca.uhn.fhir.model.api.annotation.Description;
043import ca.uhn.fhir.model.api.annotation.ResourceDef;
044import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
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/Profile/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         * Actions implied by the administration have been temporarily halted, but are expected to continue later. May also be called "suspended".
058         */
059        ONHOLD, 
060        /**
061         * All actions that are implied by the administration have occurred.
062         */
063        COMPLETED, 
064        /**
065         * The administration was entered in error and therefore nullified.
066         */
067        ENTEREDINERROR, 
068        /**
069         * Actions implied by the administration have been permanently halted, before all of them occurred.
070         */
071        STOPPED, 
072        /**
073         * added to help the parsers
074         */
075        NULL;
076        public static MedicationAdministrationStatus fromCode(String codeString) throws FHIRException {
077            if (codeString == null || "".equals(codeString))
078                return null;
079        if ("in-progress".equals(codeString))
080          return INPROGRESS;
081        if ("on-hold".equals(codeString))
082          return ONHOLD;
083        if ("completed".equals(codeString))
084          return COMPLETED;
085        if ("entered-in-error".equals(codeString))
086          return ENTEREDINERROR;
087        if ("stopped".equals(codeString))
088          return STOPPED;
089        throw new FHIRException("Unknown MedicationAdministrationStatus code '"+codeString+"'");
090        }
091        public String toCode() {
092          switch (this) {
093            case INPROGRESS: return "in-progress";
094            case ONHOLD: return "on-hold";
095            case COMPLETED: return "completed";
096            case ENTEREDINERROR: return "entered-in-error";
097            case STOPPED: return "stopped";
098            default: return "?";
099          }
100        }
101        public String getSystem() {
102          switch (this) {
103            case INPROGRESS: return "http://hl7.org/fhir/medication-admin-status";
104            case ONHOLD: return "http://hl7.org/fhir/medication-admin-status";
105            case COMPLETED: return "http://hl7.org/fhir/medication-admin-status";
106            case ENTEREDINERROR: return "http://hl7.org/fhir/medication-admin-status";
107            case STOPPED: return "http://hl7.org/fhir/medication-admin-status";
108            default: return "?";
109          }
110        }
111        public String getDefinition() {
112          switch (this) {
113            case INPROGRESS: return "The administration has started but has not yet completed.";
114            case ONHOLD: return "Actions implied by the administration have been temporarily halted, but are expected to continue later. May also be called \"suspended\".";
115            case COMPLETED: return "All actions that are implied by the administration have occurred.";
116            case ENTEREDINERROR: return "The administration was entered in error and therefore nullified.";
117            case STOPPED: return "Actions implied by the administration have been permanently halted, before all of them occurred.";
118            default: return "?";
119          }
120        }
121        public String getDisplay() {
122          switch (this) {
123            case INPROGRESS: return "In Progress";
124            case ONHOLD: return "On Hold";
125            case COMPLETED: return "Completed";
126            case ENTEREDINERROR: return "Entered in Error";
127            case STOPPED: return "Stopped";
128            default: return "?";
129          }
130        }
131    }
132
133  public static class MedicationAdministrationStatusEnumFactory implements EnumFactory<MedicationAdministrationStatus> {
134    public MedicationAdministrationStatus fromCode(String codeString) throws IllegalArgumentException {
135      if (codeString == null || "".equals(codeString))
136            if (codeString == null || "".equals(codeString))
137                return null;
138        if ("in-progress".equals(codeString))
139          return MedicationAdministrationStatus.INPROGRESS;
140        if ("on-hold".equals(codeString))
141          return MedicationAdministrationStatus.ONHOLD;
142        if ("completed".equals(codeString))
143          return MedicationAdministrationStatus.COMPLETED;
144        if ("entered-in-error".equals(codeString))
145          return MedicationAdministrationStatus.ENTEREDINERROR;
146        if ("stopped".equals(codeString))
147          return MedicationAdministrationStatus.STOPPED;
148        throw new IllegalArgumentException("Unknown MedicationAdministrationStatus code '"+codeString+"'");
149        }
150        public Enumeration<MedicationAdministrationStatus> fromType(Base code) throws FHIRException {
151          if (code == null || code.isEmpty())
152            return null;
153          String codeString = ((PrimitiveType) code).asStringValue();
154          if (codeString == null || "".equals(codeString))
155            return null;
156        if ("in-progress".equals(codeString))
157          return new Enumeration<MedicationAdministrationStatus>(this, MedicationAdministrationStatus.INPROGRESS);
158        if ("on-hold".equals(codeString))
159          return new Enumeration<MedicationAdministrationStatus>(this, MedicationAdministrationStatus.ONHOLD);
160        if ("completed".equals(codeString))
161          return new Enumeration<MedicationAdministrationStatus>(this, MedicationAdministrationStatus.COMPLETED);
162        if ("entered-in-error".equals(codeString))
163          return new Enumeration<MedicationAdministrationStatus>(this, MedicationAdministrationStatus.ENTEREDINERROR);
164        if ("stopped".equals(codeString))
165          return new Enumeration<MedicationAdministrationStatus>(this, MedicationAdministrationStatus.STOPPED);
166        throw new FHIRException("Unknown MedicationAdministrationStatus code '"+codeString+"'");
167        }
168    public String toCode(MedicationAdministrationStatus code) {
169      if (code == MedicationAdministrationStatus.INPROGRESS)
170        return "in-progress";
171      if (code == MedicationAdministrationStatus.ONHOLD)
172        return "on-hold";
173      if (code == MedicationAdministrationStatus.COMPLETED)
174        return "completed";
175      if (code == MedicationAdministrationStatus.ENTEREDINERROR)
176        return "entered-in-error";
177      if (code == MedicationAdministrationStatus.STOPPED)
178        return "stopped";
179      return "?";
180      }
181    public String toSystem(MedicationAdministrationStatus code) {
182      return code.getSystem();
183      }
184    }
185
186    @Block()
187    public static class MedicationAdministrationDosageComponent extends BackboneElement implements IBaseBackboneElement {
188        /**
189         * Free text dosage instructions can be used for cases where the instructions are too complex to code. When coded instructions are present, the free text instructions may still be present for display to humans taking or administering the medication.
190         */
191        @Child(name = "text", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true)
192        @Description(shortDefinition="Free text dosage instructions e.g. SIG", formalDefinition="Free text dosage instructions can be used for cases where the instructions are too complex to code. When coded instructions are present, the free text instructions may still be present for display to humans taking or administering the medication." )
193        protected StringType text;
194
195        /**
196         * A coded specification of the anatomic site where the medication first entered the body.  For example, "left arm".
197         */
198        @Child(name = "site", type = {CodeableConcept.class, BodySite.class}, order=2, min=0, max=1, modifier=false, summary=true)
199        @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\"." )
200        protected Type site;
201
202        /**
203         * A code specifying the route or physiological path of administration of a therapeutic agent into or onto the patient.  For example, topical, intravenous, etc.
204         */
205        @Child(name = "route", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true)
206        @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." )
207        protected CodeableConcept route;
208
209        /**
210         * 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.
211         */
212        @Child(name = "method", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=true)
213        @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." )
214        protected CodeableConcept method;
215
216        /**
217         * 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.
218         */
219        @Child(name = "quantity", type = {SimpleQuantity.class}, order=5, min=0, max=1, modifier=false, summary=true)
220        @Description(shortDefinition="Amount administered in one 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." )
221        protected SimpleQuantity quantity;
222
223        /**
224         * 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.  Currently we do not specify a default of '1' in the denominator, but this is being discussed.  Other examples:  200 mcg/min or 200 mcg/1 minute; 1 liter/8 hours.
225         */
226        @Child(name = "rate", type = {Ratio.class, Range.class}, order=6, min=0, max=1, modifier=false, summary=true)
227        @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.  Currently we do not specify a default of '1' in the denominator, but this is being discussed.  Other examples:  200 mcg/min or 200 mcg/1 minute; 1 liter/8 hours." )
228        protected Type rate;
229
230        private static final long serialVersionUID = -1772198879L;
231
232    /**
233     * Constructor
234     */
235      public MedicationAdministrationDosageComponent() {
236        super();
237      }
238
239        /**
240         * @return {@link #text} (Free text dosage instructions can be used for cases where the instructions are too complex to code. When coded instructions are present, the free text instructions may still be present for display to humans taking or administering the medication.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value
241         */
242        public StringType getTextElement() { 
243          if (this.text == null)
244            if (Configuration.errorOnAutoCreate())
245              throw new Error("Attempt to auto-create MedicationAdministrationDosageComponent.text");
246            else if (Configuration.doAutoCreate())
247              this.text = new StringType(); // bb
248          return this.text;
249        }
250
251        public boolean hasTextElement() { 
252          return this.text != null && !this.text.isEmpty();
253        }
254
255        public boolean hasText() { 
256          return this.text != null && !this.text.isEmpty();
257        }
258
259        /**
260         * @param value {@link #text} (Free text dosage instructions can be used for cases where the instructions are too complex to code. When coded instructions are present, the free text instructions may still be present for display to humans taking or administering the medication.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value
261         */
262        public MedicationAdministrationDosageComponent setTextElement(StringType value) { 
263          this.text = value;
264          return this;
265        }
266
267        /**
268         * @return Free text dosage instructions can be used for cases where the instructions are too complex to code. When coded instructions are present, the free text instructions may still be present for display to humans taking or administering the medication.
269         */
270        public String getText() { 
271          return this.text == null ? null : this.text.getValue();
272        }
273
274        /**
275         * @param value Free text dosage instructions can be used for cases where the instructions are too complex to code. When coded instructions are present, the free text instructions may still be present for display to humans taking or administering the medication.
276         */
277        public MedicationAdministrationDosageComponent setText(String value) { 
278          if (Utilities.noString(value))
279            this.text = null;
280          else {
281            if (this.text == null)
282              this.text = new StringType();
283            this.text.setValue(value);
284          }
285          return this;
286        }
287
288        /**
289         * @return {@link #site} (A coded specification of the anatomic site where the medication first entered the body.  For example, "left arm".)
290         */
291        public Type getSite() { 
292          return this.site;
293        }
294
295        /**
296         * @return {@link #site} (A coded specification of the anatomic site where the medication first entered the body.  For example, "left arm".)
297         */
298        public CodeableConcept getSiteCodeableConcept() throws FHIRException { 
299          if (!(this.site instanceof CodeableConcept))
300            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.site.getClass().getName()+" was encountered");
301          return (CodeableConcept) this.site;
302        }
303
304        public boolean hasSiteCodeableConcept() { 
305          return this.site instanceof CodeableConcept;
306        }
307
308        /**
309         * @return {@link #site} (A coded specification of the anatomic site where the medication first entered the body.  For example, "left arm".)
310         */
311        public Reference getSiteReference() throws FHIRException { 
312          if (!(this.site instanceof Reference))
313            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.site.getClass().getName()+" was encountered");
314          return (Reference) this.site;
315        }
316
317        public boolean hasSiteReference() { 
318          return this.site instanceof Reference;
319        }
320
321        public boolean hasSite() { 
322          return this.site != null && !this.site.isEmpty();
323        }
324
325        /**
326         * @param value {@link #site} (A coded specification of the anatomic site where the medication first entered the body.  For example, "left arm".)
327         */
328        public MedicationAdministrationDosageComponent setSite(Type value) { 
329          this.site = value;
330          return this;
331        }
332
333        /**
334         * @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.)
335         */
336        public CodeableConcept getRoute() { 
337          if (this.route == null)
338            if (Configuration.errorOnAutoCreate())
339              throw new Error("Attempt to auto-create MedicationAdministrationDosageComponent.route");
340            else if (Configuration.doAutoCreate())
341              this.route = new CodeableConcept(); // cc
342          return this.route;
343        }
344
345        public boolean hasRoute() { 
346          return this.route != null && !this.route.isEmpty();
347        }
348
349        /**
350         * @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.)
351         */
352        public MedicationAdministrationDosageComponent setRoute(CodeableConcept value) { 
353          this.route = value;
354          return this;
355        }
356
357        /**
358         * @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.)
359         */
360        public CodeableConcept getMethod() { 
361          if (this.method == null)
362            if (Configuration.errorOnAutoCreate())
363              throw new Error("Attempt to auto-create MedicationAdministrationDosageComponent.method");
364            else if (Configuration.doAutoCreate())
365              this.method = new CodeableConcept(); // cc
366          return this.method;
367        }
368
369        public boolean hasMethod() { 
370          return this.method != null && !this.method.isEmpty();
371        }
372
373        /**
374         * @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.)
375         */
376        public MedicationAdministrationDosageComponent setMethod(CodeableConcept value) { 
377          this.method = value;
378          return this;
379        }
380
381        /**
382         * @return {@link #quantity} (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.)
383         */
384        public SimpleQuantity getQuantity() { 
385          if (this.quantity == null)
386            if (Configuration.errorOnAutoCreate())
387              throw new Error("Attempt to auto-create MedicationAdministrationDosageComponent.quantity");
388            else if (Configuration.doAutoCreate())
389              this.quantity = new SimpleQuantity(); // cc
390          return this.quantity;
391        }
392
393        public boolean hasQuantity() { 
394          return this.quantity != null && !this.quantity.isEmpty();
395        }
396
397        /**
398         * @param value {@link #quantity} (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.)
399         */
400        public MedicationAdministrationDosageComponent setQuantity(SimpleQuantity value) { 
401          this.quantity = value;
402          return this;
403        }
404
405        /**
406         * @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.  Currently we do not specify a default of '1' in the denominator, but this is being discussed.  Other examples:  200 mcg/min or 200 mcg/1 minute; 1 liter/8 hours.)
407         */
408        public Type getRate() { 
409          return this.rate;
410        }
411
412        /**
413         * @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.  Currently we do not specify a default of '1' in the denominator, but this is being discussed.  Other examples:  200 mcg/min or 200 mcg/1 minute; 1 liter/8 hours.)
414         */
415        public Ratio getRateRatio() throws FHIRException { 
416          if (!(this.rate instanceof Ratio))
417            throw new FHIRException("Type mismatch: the type Ratio was expected, but "+this.rate.getClass().getName()+" was encountered");
418          return (Ratio) this.rate;
419        }
420
421        public boolean hasRateRatio() { 
422          return this.rate instanceof Ratio;
423        }
424
425        /**
426         * @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.  Currently we do not specify a default of '1' in the denominator, but this is being discussed.  Other examples:  200 mcg/min or 200 mcg/1 minute; 1 liter/8 hours.)
427         */
428        public Range getRateRange() throws FHIRException { 
429          if (!(this.rate instanceof Range))
430            throw new FHIRException("Type mismatch: the type Range was expected, but "+this.rate.getClass().getName()+" was encountered");
431          return (Range) this.rate;
432        }
433
434        public boolean hasRateRange() { 
435          return this.rate instanceof Range;
436        }
437
438        public boolean hasRate() { 
439          return this.rate != null && !this.rate.isEmpty();
440        }
441
442        /**
443         * @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.  Currently we do not specify a default of '1' in the denominator, but this is being discussed.  Other examples:  200 mcg/min or 200 mcg/1 minute; 1 liter/8 hours.)
444         */
445        public MedicationAdministrationDosageComponent setRate(Type value) { 
446          this.rate = value;
447          return this;
448        }
449
450        protected void listChildren(List<Property> childrenList) {
451          super.listChildren(childrenList);
452          childrenList.add(new Property("text", "string", "Free text dosage instructions can be used for cases where the instructions are too complex to code. When coded instructions are present, the free text instructions may still be present for display to humans taking or administering the medication.", 0, java.lang.Integer.MAX_VALUE, text));
453          childrenList.add(new Property("site[x]", "CodeableConcept|Reference(BodySite)", "A coded specification of the anatomic site where the medication first entered the body.  For example, \"left arm\".", 0, java.lang.Integer.MAX_VALUE, site));
454          childrenList.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, java.lang.Integer.MAX_VALUE, route));
455          childrenList.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, java.lang.Integer.MAX_VALUE, method));
456          childrenList.add(new Property("quantity", "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, java.lang.Integer.MAX_VALUE, quantity));
457          childrenList.add(new Property("rate[x]", "Ratio|Range", "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.  Currently we do not specify a default of '1' in the denominator, but this is being discussed.  Other examples:  200 mcg/min or 200 mcg/1 minute; 1 liter/8 hours.", 0, java.lang.Integer.MAX_VALUE, rate));
458        }
459
460      @Override
461      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
462        switch (hash) {
463        case 3556653: /*text*/ return this.text == null ? new Base[0] : new Base[] {this.text}; // StringType
464        case 3530567: /*site*/ return this.site == null ? new Base[0] : new Base[] {this.site}; // Type
465        case 108704329: /*route*/ return this.route == null ? new Base[0] : new Base[] {this.route}; // CodeableConcept
466        case -1077554975: /*method*/ return this.method == null ? new Base[0] : new Base[] {this.method}; // CodeableConcept
467        case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // SimpleQuantity
468        case 3493088: /*rate*/ return this.rate == null ? new Base[0] : new Base[] {this.rate}; // Type
469        default: return super.getProperty(hash, name, checkValid);
470        }
471
472      }
473
474      @Override
475      public void setProperty(int hash, String name, Base value) throws FHIRException {
476        switch (hash) {
477        case 3556653: // text
478          this.text = castToString(value); // StringType
479          break;
480        case 3530567: // site
481          this.site = (Type) value; // Type
482          break;
483        case 108704329: // route
484          this.route = castToCodeableConcept(value); // CodeableConcept
485          break;
486        case -1077554975: // method
487          this.method = castToCodeableConcept(value); // CodeableConcept
488          break;
489        case -1285004149: // quantity
490          this.quantity = castToSimpleQuantity(value); // SimpleQuantity
491          break;
492        case 3493088: // rate
493          this.rate = (Type) value; // Type
494          break;
495        default: super.setProperty(hash, name, value);
496        }
497
498      }
499
500      @Override
501      public void setProperty(String name, Base value) throws FHIRException {
502        if (name.equals("text"))
503          this.text = castToString(value); // StringType
504        else if (name.equals("site[x]"))
505          this.site = (Type) value; // Type
506        else if (name.equals("route"))
507          this.route = castToCodeableConcept(value); // CodeableConcept
508        else if (name.equals("method"))
509          this.method = castToCodeableConcept(value); // CodeableConcept
510        else if (name.equals("quantity"))
511          this.quantity = castToSimpleQuantity(value); // SimpleQuantity
512        else if (name.equals("rate[x]"))
513          this.rate = (Type) value; // Type
514        else
515          super.setProperty(name, value);
516      }
517
518      @Override
519      public Base makeProperty(int hash, String name) throws FHIRException {
520        switch (hash) {
521        case 3556653: throw new FHIRException("Cannot make property text as it is not a complex type"); // StringType
522        case 2099997657:  return getSite(); // Type
523        case 108704329:  return getRoute(); // CodeableConcept
524        case -1077554975:  return getMethod(); // CodeableConcept
525        case -1285004149:  return getQuantity(); // SimpleQuantity
526        case 983460768:  return getRate(); // Type
527        default: return super.makeProperty(hash, name);
528        }
529
530      }
531
532      @Override
533      public Base addChild(String name) throws FHIRException {
534        if (name.equals("text")) {
535          throw new FHIRException("Cannot call addChild on a primitive type MedicationAdministration.text");
536        }
537        else if (name.equals("siteCodeableConcept")) {
538          this.site = new CodeableConcept();
539          return this.site;
540        }
541        else if (name.equals("siteReference")) {
542          this.site = new Reference();
543          return this.site;
544        }
545        else if (name.equals("route")) {
546          this.route = new CodeableConcept();
547          return this.route;
548        }
549        else if (name.equals("method")) {
550          this.method = new CodeableConcept();
551          return this.method;
552        }
553        else if (name.equals("quantity")) {
554          this.quantity = new SimpleQuantity();
555          return this.quantity;
556        }
557        else if (name.equals("rateRatio")) {
558          this.rate = new Ratio();
559          return this.rate;
560        }
561        else if (name.equals("rateRange")) {
562          this.rate = new Range();
563          return this.rate;
564        }
565        else
566          return super.addChild(name);
567      }
568
569      public MedicationAdministrationDosageComponent copy() {
570        MedicationAdministrationDosageComponent dst = new MedicationAdministrationDosageComponent();
571        copyValues(dst);
572        dst.text = text == null ? null : text.copy();
573        dst.site = site == null ? null : site.copy();
574        dst.route = route == null ? null : route.copy();
575        dst.method = method == null ? null : method.copy();
576        dst.quantity = quantity == null ? null : quantity.copy();
577        dst.rate = rate == null ? null : rate.copy();
578        return dst;
579      }
580
581      @Override
582      public boolean equalsDeep(Base other) {
583        if (!super.equalsDeep(other))
584          return false;
585        if (!(other instanceof MedicationAdministrationDosageComponent))
586          return false;
587        MedicationAdministrationDosageComponent o = (MedicationAdministrationDosageComponent) other;
588        return compareDeep(text, o.text, true) && compareDeep(site, o.site, true) && compareDeep(route, o.route, true)
589           && compareDeep(method, o.method, true) && compareDeep(quantity, o.quantity, true) && compareDeep(rate, o.rate, true)
590          ;
591      }
592
593      @Override
594      public boolean equalsShallow(Base other) {
595        if (!super.equalsShallow(other))
596          return false;
597        if (!(other instanceof MedicationAdministrationDosageComponent))
598          return false;
599        MedicationAdministrationDosageComponent o = (MedicationAdministrationDosageComponent) other;
600        return compareValues(text, o.text, true);
601      }
602
603      public boolean isEmpty() {
604        return super.isEmpty() && (text == null || text.isEmpty()) && (site == null || site.isEmpty())
605           && (route == null || route.isEmpty()) && (method == null || method.isEmpty()) && (quantity == null || quantity.isEmpty())
606           && (rate == null || rate.isEmpty());
607      }
608
609  public String fhirType() {
610    return "MedicationAdministration.dosage";
611
612  }
613
614  }
615
616    /**
617     * External identifier - FHIR will generate its own internal identifiers (probably URLs) which do not need to be explicitly managed by the resource.  The identifier here is one that would be used by another non-FHIR system - for example an automated medication pump would provide a record each time it operated; an administration while the patient was off the ward might be made with a different system and entered after the event.  Particularly important if these records have to be updated.
618     */
619    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
620    @Description(shortDefinition="External identifier", formalDefinition="External identifier - FHIR will generate its own internal identifiers (probably URLs) which do not need to be explicitly managed by the resource.  The identifier here is one that would be used by another non-FHIR system - for example an automated medication pump would provide a record each time it operated; an administration while the patient was off the ward might be made with a different system and entered after the event.  Particularly important if these records have to be updated." )
621    protected List<Identifier> identifier;
622
623    /**
624     * 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.
625     */
626    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
627    @Description(shortDefinition="in-progress | on-hold | completed | entered-in-error | stopped", 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." )
628    protected Enumeration<MedicationAdministrationStatus> status;
629
630    /**
631     * 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.
632     */
633    @Child(name = "medication", type = {CodeableConcept.class, Medication.class}, order=2, min=1, max=1, modifier=false, summary=true)
634    @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." )
635    protected Type medication;
636
637    /**
638     * The person or animal receiving the medication.
639     */
640    @Child(name = "patient", type = {Patient.class}, order=3, min=1, max=1, modifier=false, summary=true)
641    @Description(shortDefinition="Who received medication", formalDefinition="The person or animal receiving the medication." )
642    protected Reference patient;
643
644    /**
645     * The actual object that is the target of the reference (The person or animal receiving the medication.)
646     */
647    protected Patient patientTarget;
648
649    /**
650     * The visit, admission or other contact between patient and health care provider the medication administration was performed as part of.
651     */
652    @Child(name = "encounter", type = {Encounter.class}, order=4, min=0, max=1, modifier=false, summary=true)
653    @Description(shortDefinition="Encounter administered as part of", formalDefinition="The visit, admission or other contact between patient and health care provider the medication administration was performed as part of." )
654    protected Reference encounter;
655
656    /**
657     * The actual object that is the target of the reference (The visit, admission or other contact between patient and health care provider the medication administration was performed as part of.)
658     */
659    protected Encounter encounterTarget;
660
661    /**
662     * 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.
663     */
664    @Child(name = "effectiveTime", type = {DateTimeType.class, Period.class}, order=5, min=1, max=1, modifier=false, summary=true)
665    @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." )
666    protected Type effectiveTime;
667
668    /**
669     * The individual who was responsible for giving the medication to the patient.
670     */
671    @Child(name = "practitioner", type = {Practitioner.class, Patient.class, RelatedPerson.class}, order=6, min=0, max=1, modifier=false, summary=true)
672    @Description(shortDefinition="Who administered substance", formalDefinition="The individual who was responsible for giving the medication to the patient." )
673    protected Reference practitioner;
674
675    /**
676     * The actual object that is the target of the reference (The individual who was responsible for giving the medication to the patient.)
677     */
678    protected Resource practitionerTarget;
679
680    /**
681     * The original request, instruction or authority to perform the administration.
682     */
683    @Child(name = "prescription", type = {MedicationOrder.class}, order=7, min=0, max=1, modifier=false, summary=true)
684    @Description(shortDefinition="Order administration performed against", formalDefinition="The original request, instruction or authority to perform the administration." )
685    protected Reference prescription;
686
687    /**
688     * The actual object that is the target of the reference (The original request, instruction or authority to perform the administration.)
689     */
690    protected MedicationOrder prescriptionTarget;
691
692    /**
693     * Set this to true if the record is saying that the medication was NOT administered.
694     */
695    @Child(name = "wasNotGiven", type = {BooleanType.class}, order=8, min=0, max=1, modifier=true, summary=true)
696    @Description(shortDefinition="True if medication not administered", formalDefinition="Set this to true if the record is saying that the medication was NOT administered." )
697    protected BooleanType wasNotGiven;
698
699    /**
700     * A code indicating why the administration was not performed.
701     */
702    @Child(name = "reasonNotGiven", type = {CodeableConcept.class}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
703    @Description(shortDefinition="Reason administration not performed", formalDefinition="A code indicating why the administration was not performed." )
704    protected List<CodeableConcept> reasonNotGiven;
705
706    /**
707     * A code indicating why the medication was given.
708     */
709    @Child(name = "reasonGiven", type = {CodeableConcept.class}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
710    @Description(shortDefinition="Reason administration performed", formalDefinition="A code indicating why the medication was given." )
711    protected List<CodeableConcept> reasonGiven;
712
713    /**
714     * The device used in administering the medication to the patient.  For example, a particular infusion pump.
715     */
716    @Child(name = "device", type = {Device.class}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
717    @Description(shortDefinition="Device used to administer", formalDefinition="The device used in administering the medication to the patient.  For example, a particular infusion pump." )
718    protected List<Reference> device;
719    /**
720     * 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.)
721     */
722    protected List<Device> deviceTarget;
723
724
725    /**
726     * Extra information about the medication administration that is not conveyed by the other attributes.
727     */
728    @Child(name = "note", type = {Annotation.class}, order=12, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
729    @Description(shortDefinition="Information about the administration", formalDefinition="Extra information about the medication administration that is not conveyed by the other attributes." )
730    protected List<Annotation> note;
731
732    /**
733     * Describes the medication dosage information details e.g. dose, rate, site, route, etc.
734     */
735    @Child(name = "dosage", type = {}, order=13, min=0, max=1, modifier=false, summary=true)
736    @Description(shortDefinition="Details of how medication was taken", formalDefinition="Describes the medication dosage information details e.g. dose, rate, site, route, etc." )
737    protected MedicationAdministrationDosageComponent dosage;
738
739    private static final long serialVersionUID = 1357790003L;
740
741  /**
742   * Constructor
743   */
744    public MedicationAdministration() {
745      super();
746    }
747
748  /**
749   * Constructor
750   */
751    public MedicationAdministration(Enumeration<MedicationAdministrationStatus> status, Type medication, Reference patient, Type effectiveTime) {
752      super();
753      this.status = status;
754      this.medication = medication;
755      this.patient = patient;
756      this.effectiveTime = effectiveTime;
757    }
758
759    /**
760     * @return {@link #identifier} (External identifier - FHIR will generate its own internal identifiers (probably URLs) which do not need to be explicitly managed by the resource.  The identifier here is one that would be used by another non-FHIR system - for example an automated medication pump would provide a record each time it operated; an administration while the patient was off the ward might be made with a different system and entered after the event.  Particularly important if these records have to be updated.)
761     */
762    public List<Identifier> getIdentifier() { 
763      if (this.identifier == null)
764        this.identifier = new ArrayList<Identifier>();
765      return this.identifier;
766    }
767
768    public boolean hasIdentifier() { 
769      if (this.identifier == null)
770        return false;
771      for (Identifier item : this.identifier)
772        if (!item.isEmpty())
773          return true;
774      return false;
775    }
776
777    /**
778     * @return {@link #identifier} (External identifier - FHIR will generate its own internal identifiers (probably URLs) which do not need to be explicitly managed by the resource.  The identifier here is one that would be used by another non-FHIR system - for example an automated medication pump would provide a record each time it operated; an administration while the patient was off the ward might be made with a different system and entered after the event.  Particularly important if these records have to be updated.)
779     */
780    // syntactic sugar
781    public Identifier addIdentifier() { //3
782      Identifier t = new Identifier();
783      if (this.identifier == null)
784        this.identifier = new ArrayList<Identifier>();
785      this.identifier.add(t);
786      return t;
787    }
788
789    // syntactic sugar
790    public MedicationAdministration addIdentifier(Identifier t) { //3
791      if (t == null)
792        return this;
793      if (this.identifier == null)
794        this.identifier = new ArrayList<Identifier>();
795      this.identifier.add(t);
796      return this;
797    }
798
799    /**
800     * @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
801     */
802    public Enumeration<MedicationAdministrationStatus> getStatusElement() { 
803      if (this.status == null)
804        if (Configuration.errorOnAutoCreate())
805          throw new Error("Attempt to auto-create MedicationAdministration.status");
806        else if (Configuration.doAutoCreate())
807          this.status = new Enumeration<MedicationAdministrationStatus>(new MedicationAdministrationStatusEnumFactory()); // bb
808      return this.status;
809    }
810
811    public boolean hasStatusElement() { 
812      return this.status != null && !this.status.isEmpty();
813    }
814
815    public boolean hasStatus() { 
816      return this.status != null && !this.status.isEmpty();
817    }
818
819    /**
820     * @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
821     */
822    public MedicationAdministration setStatusElement(Enumeration<MedicationAdministrationStatus> value) { 
823      this.status = value;
824      return this;
825    }
826
827    /**
828     * @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.
829     */
830    public MedicationAdministrationStatus getStatus() { 
831      return this.status == null ? null : this.status.getValue();
832    }
833
834    /**
835     * @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.
836     */
837    public MedicationAdministration setStatus(MedicationAdministrationStatus value) { 
838        if (this.status == null)
839          this.status = new Enumeration<MedicationAdministrationStatus>(new MedicationAdministrationStatusEnumFactory());
840        this.status.setValue(value);
841      return this;
842    }
843
844    /**
845     * @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.)
846     */
847    public Type getMedication() { 
848      return this.medication;
849    }
850
851    /**
852     * @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.)
853     */
854    public CodeableConcept getMedicationCodeableConcept() throws FHIRException { 
855      if (!(this.medication instanceof CodeableConcept))
856        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.medication.getClass().getName()+" was encountered");
857      return (CodeableConcept) this.medication;
858    }
859
860    public boolean hasMedicationCodeableConcept() { 
861      return this.medication instanceof CodeableConcept;
862    }
863
864    /**
865     * @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.)
866     */
867    public Reference getMedicationReference() throws FHIRException { 
868      if (!(this.medication instanceof Reference))
869        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.medication.getClass().getName()+" was encountered");
870      return (Reference) this.medication;
871    }
872
873    public boolean hasMedicationReference() { 
874      return this.medication instanceof Reference;
875    }
876
877    public boolean hasMedication() { 
878      return this.medication != null && !this.medication.isEmpty();
879    }
880
881    /**
882     * @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.)
883     */
884    public MedicationAdministration setMedication(Type value) { 
885      this.medication = value;
886      return this;
887    }
888
889    /**
890     * @return {@link #patient} (The person or animal receiving the medication.)
891     */
892    public Reference getPatient() { 
893      if (this.patient == null)
894        if (Configuration.errorOnAutoCreate())
895          throw new Error("Attempt to auto-create MedicationAdministration.patient");
896        else if (Configuration.doAutoCreate())
897          this.patient = new Reference(); // cc
898      return this.patient;
899    }
900
901    public boolean hasPatient() { 
902      return this.patient != null && !this.patient.isEmpty();
903    }
904
905    /**
906     * @param value {@link #patient} (The person or animal receiving the medication.)
907     */
908    public MedicationAdministration setPatient(Reference value) { 
909      this.patient = value;
910      return this;
911    }
912
913    /**
914     * @return {@link #patient} 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 receiving the medication.)
915     */
916    public Patient getPatientTarget() { 
917      if (this.patientTarget == null)
918        if (Configuration.errorOnAutoCreate())
919          throw new Error("Attempt to auto-create MedicationAdministration.patient");
920        else if (Configuration.doAutoCreate())
921          this.patientTarget = new Patient(); // aa
922      return this.patientTarget;
923    }
924
925    /**
926     * @param value {@link #patient} 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 receiving the medication.)
927     */
928    public MedicationAdministration setPatientTarget(Patient value) { 
929      this.patientTarget = value;
930      return this;
931    }
932
933    /**
934     * @return {@link #encounter} (The visit, admission or other contact between patient and health care provider the medication administration was performed as part of.)
935     */
936    public Reference getEncounter() { 
937      if (this.encounter == null)
938        if (Configuration.errorOnAutoCreate())
939          throw new Error("Attempt to auto-create MedicationAdministration.encounter");
940        else if (Configuration.doAutoCreate())
941          this.encounter = new Reference(); // cc
942      return this.encounter;
943    }
944
945    public boolean hasEncounter() { 
946      return this.encounter != null && !this.encounter.isEmpty();
947    }
948
949    /**
950     * @param value {@link #encounter} (The visit, admission or other contact between patient and health care provider the medication administration was performed as part of.)
951     */
952    public MedicationAdministration setEncounter(Reference value) { 
953      this.encounter = value;
954      return this;
955    }
956
957    /**
958     * @return {@link #encounter} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The visit, admission or other contact between patient and health care provider the medication administration was performed as part of.)
959     */
960    public Encounter getEncounterTarget() { 
961      if (this.encounterTarget == null)
962        if (Configuration.errorOnAutoCreate())
963          throw new Error("Attempt to auto-create MedicationAdministration.encounter");
964        else if (Configuration.doAutoCreate())
965          this.encounterTarget = new Encounter(); // aa
966      return this.encounterTarget;
967    }
968
969    /**
970     * @param value {@link #encounter} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The visit, admission or other contact between patient and health care provider the medication administration was performed as part of.)
971     */
972    public MedicationAdministration setEncounterTarget(Encounter value) { 
973      this.encounterTarget = value;
974      return this;
975    }
976
977    /**
978     * @return {@link #effectiveTime} (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.)
979     */
980    public Type getEffectiveTime() { 
981      return this.effectiveTime;
982    }
983
984    /**
985     * @return {@link #effectiveTime} (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.)
986     */
987    public DateTimeType getEffectiveTimeDateTimeType() throws FHIRException { 
988      if (!(this.effectiveTime instanceof DateTimeType))
989        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.effectiveTime.getClass().getName()+" was encountered");
990      return (DateTimeType) this.effectiveTime;
991    }
992
993    public boolean hasEffectiveTimeDateTimeType() { 
994      return this.effectiveTime instanceof DateTimeType;
995    }
996
997    /**
998     * @return {@link #effectiveTime} (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.)
999     */
1000    public Period getEffectiveTimePeriod() throws FHIRException { 
1001      if (!(this.effectiveTime instanceof Period))
1002        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.effectiveTime.getClass().getName()+" was encountered");
1003      return (Period) this.effectiveTime;
1004    }
1005
1006    public boolean hasEffectiveTimePeriod() { 
1007      return this.effectiveTime instanceof Period;
1008    }
1009
1010    public boolean hasEffectiveTime() { 
1011      return this.effectiveTime != null && !this.effectiveTime.isEmpty();
1012    }
1013
1014    /**
1015     * @param value {@link #effectiveTime} (A specific date/time or interval of time during which the administration took place (or did not take place, when the 'notGiven' attribute is true). For many administrations, such as swallowing a tablet the use of dateTime is more appropriate.)
1016     */
1017    public MedicationAdministration setEffectiveTime(Type value) { 
1018      this.effectiveTime = value;
1019      return this;
1020    }
1021
1022    /**
1023     * @return {@link #practitioner} (The individual who was responsible for giving the medication to the patient.)
1024     */
1025    public Reference getPractitioner() { 
1026      if (this.practitioner == null)
1027        if (Configuration.errorOnAutoCreate())
1028          throw new Error("Attempt to auto-create MedicationAdministration.practitioner");
1029        else if (Configuration.doAutoCreate())
1030          this.practitioner = new Reference(); // cc
1031      return this.practitioner;
1032    }
1033
1034    public boolean hasPractitioner() { 
1035      return this.practitioner != null && !this.practitioner.isEmpty();
1036    }
1037
1038    /**
1039     * @param value {@link #practitioner} (The individual who was responsible for giving the medication to the patient.)
1040     */
1041    public MedicationAdministration setPractitioner(Reference value) { 
1042      this.practitioner = value;
1043      return this;
1044    }
1045
1046    /**
1047     * @return {@link #practitioner} 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 individual who was responsible for giving the medication to the patient.)
1048     */
1049    public Resource getPractitionerTarget() { 
1050      return this.practitionerTarget;
1051    }
1052
1053    /**
1054     * @param value {@link #practitioner} 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 individual who was responsible for giving the medication to the patient.)
1055     */
1056    public MedicationAdministration setPractitionerTarget(Resource value) { 
1057      this.practitionerTarget = value;
1058      return this;
1059    }
1060
1061    /**
1062     * @return {@link #prescription} (The original request, instruction or authority to perform the administration.)
1063     */
1064    public Reference getPrescription() { 
1065      if (this.prescription == null)
1066        if (Configuration.errorOnAutoCreate())
1067          throw new Error("Attempt to auto-create MedicationAdministration.prescription");
1068        else if (Configuration.doAutoCreate())
1069          this.prescription = new Reference(); // cc
1070      return this.prescription;
1071    }
1072
1073    public boolean hasPrescription() { 
1074      return this.prescription != null && !this.prescription.isEmpty();
1075    }
1076
1077    /**
1078     * @param value {@link #prescription} (The original request, instruction or authority to perform the administration.)
1079     */
1080    public MedicationAdministration setPrescription(Reference value) { 
1081      this.prescription = value;
1082      return this;
1083    }
1084
1085    /**
1086     * @return {@link #prescription} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The original request, instruction or authority to perform the administration.)
1087     */
1088    public MedicationOrder getPrescriptionTarget() { 
1089      if (this.prescriptionTarget == null)
1090        if (Configuration.errorOnAutoCreate())
1091          throw new Error("Attempt to auto-create MedicationAdministration.prescription");
1092        else if (Configuration.doAutoCreate())
1093          this.prescriptionTarget = new MedicationOrder(); // aa
1094      return this.prescriptionTarget;
1095    }
1096
1097    /**
1098     * @param value {@link #prescription} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The original request, instruction or authority to perform the administration.)
1099     */
1100    public MedicationAdministration setPrescriptionTarget(MedicationOrder value) { 
1101      this.prescriptionTarget = value;
1102      return this;
1103    }
1104
1105    /**
1106     * @return {@link #wasNotGiven} (Set this to true if the record is saying that the medication was NOT administered.). This is the underlying object with id, value and extensions. The accessor "getWasNotGiven" gives direct access to the value
1107     */
1108    public BooleanType getWasNotGivenElement() { 
1109      if (this.wasNotGiven == null)
1110        if (Configuration.errorOnAutoCreate())
1111          throw new Error("Attempt to auto-create MedicationAdministration.wasNotGiven");
1112        else if (Configuration.doAutoCreate())
1113          this.wasNotGiven = new BooleanType(); // bb
1114      return this.wasNotGiven;
1115    }
1116
1117    public boolean hasWasNotGivenElement() { 
1118      return this.wasNotGiven != null && !this.wasNotGiven.isEmpty();
1119    }
1120
1121    public boolean hasWasNotGiven() { 
1122      return this.wasNotGiven != null && !this.wasNotGiven.isEmpty();
1123    }
1124
1125    /**
1126     * @param value {@link #wasNotGiven} (Set this to true if the record is saying that the medication was NOT administered.). This is the underlying object with id, value and extensions. The accessor "getWasNotGiven" gives direct access to the value
1127     */
1128    public MedicationAdministration setWasNotGivenElement(BooleanType value) { 
1129      this.wasNotGiven = value;
1130      return this;
1131    }
1132
1133    /**
1134     * @return Set this to true if the record is saying that the medication was NOT administered.
1135     */
1136    public boolean getWasNotGiven() { 
1137      return this.wasNotGiven == null || this.wasNotGiven.isEmpty() ? false : this.wasNotGiven.getValue();
1138    }
1139
1140    /**
1141     * @param value Set this to true if the record is saying that the medication was NOT administered.
1142     */
1143    public MedicationAdministration setWasNotGiven(boolean value) { 
1144        if (this.wasNotGiven == null)
1145          this.wasNotGiven = new BooleanType();
1146        this.wasNotGiven.setValue(value);
1147      return this;
1148    }
1149
1150    /**
1151     * @return {@link #reasonNotGiven} (A code indicating why the administration was not performed.)
1152     */
1153    public List<CodeableConcept> getReasonNotGiven() { 
1154      if (this.reasonNotGiven == null)
1155        this.reasonNotGiven = new ArrayList<CodeableConcept>();
1156      return this.reasonNotGiven;
1157    }
1158
1159    public boolean hasReasonNotGiven() { 
1160      if (this.reasonNotGiven == null)
1161        return false;
1162      for (CodeableConcept item : this.reasonNotGiven)
1163        if (!item.isEmpty())
1164          return true;
1165      return false;
1166    }
1167
1168    /**
1169     * @return {@link #reasonNotGiven} (A code indicating why the administration was not performed.)
1170     */
1171    // syntactic sugar
1172    public CodeableConcept addReasonNotGiven() { //3
1173      CodeableConcept t = new CodeableConcept();
1174      if (this.reasonNotGiven == null)
1175        this.reasonNotGiven = new ArrayList<CodeableConcept>();
1176      this.reasonNotGiven.add(t);
1177      return t;
1178    }
1179
1180    // syntactic sugar
1181    public MedicationAdministration addReasonNotGiven(CodeableConcept t) { //3
1182      if (t == null)
1183        return this;
1184      if (this.reasonNotGiven == null)
1185        this.reasonNotGiven = new ArrayList<CodeableConcept>();
1186      this.reasonNotGiven.add(t);
1187      return this;
1188    }
1189
1190    /**
1191     * @return {@link #reasonGiven} (A code indicating why the medication was given.)
1192     */
1193    public List<CodeableConcept> getReasonGiven() { 
1194      if (this.reasonGiven == null)
1195        this.reasonGiven = new ArrayList<CodeableConcept>();
1196      return this.reasonGiven;
1197    }
1198
1199    public boolean hasReasonGiven() { 
1200      if (this.reasonGiven == null)
1201        return false;
1202      for (CodeableConcept item : this.reasonGiven)
1203        if (!item.isEmpty())
1204          return true;
1205      return false;
1206    }
1207
1208    /**
1209     * @return {@link #reasonGiven} (A code indicating why the medication was given.)
1210     */
1211    // syntactic sugar
1212    public CodeableConcept addReasonGiven() { //3
1213      CodeableConcept t = new CodeableConcept();
1214      if (this.reasonGiven == null)
1215        this.reasonGiven = new ArrayList<CodeableConcept>();
1216      this.reasonGiven.add(t);
1217      return t;
1218    }
1219
1220    // syntactic sugar
1221    public MedicationAdministration addReasonGiven(CodeableConcept t) { //3
1222      if (t == null)
1223        return this;
1224      if (this.reasonGiven == null)
1225        this.reasonGiven = new ArrayList<CodeableConcept>();
1226      this.reasonGiven.add(t);
1227      return this;
1228    }
1229
1230    /**
1231     * @return {@link #device} (The device used in administering the medication to the patient.  For example, a particular infusion pump.)
1232     */
1233    public List<Reference> getDevice() { 
1234      if (this.device == null)
1235        this.device = new ArrayList<Reference>();
1236      return this.device;
1237    }
1238
1239    public boolean hasDevice() { 
1240      if (this.device == null)
1241        return false;
1242      for (Reference item : this.device)
1243        if (!item.isEmpty())
1244          return true;
1245      return false;
1246    }
1247
1248    /**
1249     * @return {@link #device} (The device used in administering the medication to the patient.  For example, a particular infusion pump.)
1250     */
1251    // syntactic sugar
1252    public Reference addDevice() { //3
1253      Reference t = new Reference();
1254      if (this.device == null)
1255        this.device = new ArrayList<Reference>();
1256      this.device.add(t);
1257      return t;
1258    }
1259
1260    // syntactic sugar
1261    public MedicationAdministration addDevice(Reference t) { //3
1262      if (t == null)
1263        return this;
1264      if (this.device == null)
1265        this.device = new ArrayList<Reference>();
1266      this.device.add(t);
1267      return this;
1268    }
1269
1270    /**
1271     * @return {@link #device} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. The device used in administering the medication to the patient.  For example, a particular infusion pump.)
1272     */
1273    public List<Device> getDeviceTarget() { 
1274      if (this.deviceTarget == null)
1275        this.deviceTarget = new ArrayList<Device>();
1276      return this.deviceTarget;
1277    }
1278
1279    // syntactic sugar
1280    /**
1281     * @return {@link #device} (Add an actual object that is the target of the reference. The reference library doesn't use these, but you can use this to hold the resources if you resolvethemt. The device used in administering the medication to the patient.  For example, a particular infusion pump.)
1282     */
1283    public Device addDeviceTarget() { 
1284      Device r = new Device();
1285      if (this.deviceTarget == null)
1286        this.deviceTarget = new ArrayList<Device>();
1287      this.deviceTarget.add(r);
1288      return r;
1289    }
1290
1291    /**
1292     * @return {@link #note} (Extra information about the medication administration that is not conveyed by the other attributes.)
1293     */
1294    public List<Annotation> getNote() { 
1295      if (this.note == null)
1296        this.note = new ArrayList<Annotation>();
1297      return this.note;
1298    }
1299
1300    public boolean hasNote() { 
1301      if (this.note == null)
1302        return false;
1303      for (Annotation item : this.note)
1304        if (!item.isEmpty())
1305          return true;
1306      return false;
1307    }
1308
1309    /**
1310     * @return {@link #note} (Extra information about the medication administration that is not conveyed by the other attributes.)
1311     */
1312    // syntactic sugar
1313    public Annotation addNote() { //3
1314      Annotation t = new Annotation();
1315      if (this.note == null)
1316        this.note = new ArrayList<Annotation>();
1317      this.note.add(t);
1318      return t;
1319    }
1320
1321    // syntactic sugar
1322    public MedicationAdministration addNote(Annotation t) { //3
1323      if (t == null)
1324        return this;
1325      if (this.note == null)
1326        this.note = new ArrayList<Annotation>();
1327      this.note.add(t);
1328      return this;
1329    }
1330
1331    /**
1332     * @return {@link #dosage} (Describes the medication dosage information details e.g. dose, rate, site, route, etc.)
1333     */
1334    public MedicationAdministrationDosageComponent getDosage() { 
1335      if (this.dosage == null)
1336        if (Configuration.errorOnAutoCreate())
1337          throw new Error("Attempt to auto-create MedicationAdministration.dosage");
1338        else if (Configuration.doAutoCreate())
1339          this.dosage = new MedicationAdministrationDosageComponent(); // cc
1340      return this.dosage;
1341    }
1342
1343    public boolean hasDosage() { 
1344      return this.dosage != null && !this.dosage.isEmpty();
1345    }
1346
1347    /**
1348     * @param value {@link #dosage} (Describes the medication dosage information details e.g. dose, rate, site, route, etc.)
1349     */
1350    public MedicationAdministration setDosage(MedicationAdministrationDosageComponent value) { 
1351      this.dosage = value;
1352      return this;
1353    }
1354
1355      protected void listChildren(List<Property> childrenList) {
1356        super.listChildren(childrenList);
1357        childrenList.add(new Property("identifier", "Identifier", "External identifier - FHIR will generate its own internal identifiers (probably URLs) which do not need to be explicitly managed by the resource.  The identifier here is one that would be used by another non-FHIR system - for example an automated medication pump would provide a record each time it operated; an administration while the patient was off the ward might be made with a different system and entered after the event.  Particularly important if these records have to be updated.", 0, java.lang.Integer.MAX_VALUE, identifier));
1358        childrenList.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, java.lang.Integer.MAX_VALUE, status));
1359        childrenList.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, java.lang.Integer.MAX_VALUE, medication));
1360        childrenList.add(new Property("patient", "Reference(Patient)", "The person or animal receiving the medication.", 0, java.lang.Integer.MAX_VALUE, patient));
1361        childrenList.add(new Property("encounter", "Reference(Encounter)", "The visit, admission or other contact between patient and health care provider the medication administration was performed as part of.", 0, java.lang.Integer.MAX_VALUE, encounter));
1362        childrenList.add(new Property("effectiveTime[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, java.lang.Integer.MAX_VALUE, effectiveTime));
1363        childrenList.add(new Property("practitioner", "Reference(Practitioner|Patient|RelatedPerson)", "The individual who was responsible for giving the medication to the patient.", 0, java.lang.Integer.MAX_VALUE, practitioner));
1364        childrenList.add(new Property("prescription", "Reference(MedicationOrder)", "The original request, instruction or authority to perform the administration.", 0, java.lang.Integer.MAX_VALUE, prescription));
1365        childrenList.add(new Property("wasNotGiven", "boolean", "Set this to true if the record is saying that the medication was NOT administered.", 0, java.lang.Integer.MAX_VALUE, wasNotGiven));
1366        childrenList.add(new Property("reasonNotGiven", "CodeableConcept", "A code indicating why the administration was not performed.", 0, java.lang.Integer.MAX_VALUE, reasonNotGiven));
1367        childrenList.add(new Property("reasonGiven", "CodeableConcept", "A code indicating why the medication was given.", 0, java.lang.Integer.MAX_VALUE, reasonGiven));
1368        childrenList.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));
1369        childrenList.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));
1370        childrenList.add(new Property("dosage", "", "Describes the medication dosage information details e.g. dose, rate, site, route, etc.", 0, java.lang.Integer.MAX_VALUE, dosage));
1371      }
1372
1373      @Override
1374      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1375        switch (hash) {
1376        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1377        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<MedicationAdministrationStatus>
1378        case 1998965455: /*medication*/ return this.medication == null ? new Base[0] : new Base[] {this.medication}; // Type
1379        case -791418107: /*patient*/ return this.patient == null ? new Base[0] : new Base[] {this.patient}; // Reference
1380        case 1524132147: /*encounter*/ return this.encounter == null ? new Base[0] : new Base[] {this.encounter}; // Reference
1381        case -929905388: /*effectiveTime*/ return this.effectiveTime == null ? new Base[0] : new Base[] {this.effectiveTime}; // Type
1382        case 574573338: /*practitioner*/ return this.practitioner == null ? new Base[0] : new Base[] {this.practitioner}; // Reference
1383        case 460301338: /*prescription*/ return this.prescription == null ? new Base[0] : new Base[] {this.prescription}; // Reference
1384        case -1050911117: /*wasNotGiven*/ return this.wasNotGiven == null ? new Base[0] : new Base[] {this.wasNotGiven}; // BooleanType
1385        case 2101123790: /*reasonNotGiven*/ return this.reasonNotGiven == null ? new Base[0] : this.reasonNotGiven.toArray(new Base[this.reasonNotGiven.size()]); // CodeableConcept
1386        case 914964377: /*reasonGiven*/ return this.reasonGiven == null ? new Base[0] : this.reasonGiven.toArray(new Base[this.reasonGiven.size()]); // CodeableConcept
1387        case -1335157162: /*device*/ return this.device == null ? new Base[0] : this.device.toArray(new Base[this.device.size()]); // Reference
1388        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
1389        case -1326018889: /*dosage*/ return this.dosage == null ? new Base[0] : new Base[] {this.dosage}; // MedicationAdministrationDosageComponent
1390        default: return super.getProperty(hash, name, checkValid);
1391        }
1392
1393      }
1394
1395      @Override
1396      public void setProperty(int hash, String name, Base value) throws FHIRException {
1397        switch (hash) {
1398        case -1618432855: // identifier
1399          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1400          break;
1401        case -892481550: // status
1402          this.status = new MedicationAdministrationStatusEnumFactory().fromType(value); // Enumeration<MedicationAdministrationStatus>
1403          break;
1404        case 1998965455: // medication
1405          this.medication = (Type) value; // Type
1406          break;
1407        case -791418107: // patient
1408          this.patient = castToReference(value); // Reference
1409          break;
1410        case 1524132147: // encounter
1411          this.encounter = castToReference(value); // Reference
1412          break;
1413        case -929905388: // effectiveTime
1414          this.effectiveTime = (Type) value; // Type
1415          break;
1416        case 574573338: // practitioner
1417          this.practitioner = castToReference(value); // Reference
1418          break;
1419        case 460301338: // prescription
1420          this.prescription = castToReference(value); // Reference
1421          break;
1422        case -1050911117: // wasNotGiven
1423          this.wasNotGiven = castToBoolean(value); // BooleanType
1424          break;
1425        case 2101123790: // reasonNotGiven
1426          this.getReasonNotGiven().add(castToCodeableConcept(value)); // CodeableConcept
1427          break;
1428        case 914964377: // reasonGiven
1429          this.getReasonGiven().add(castToCodeableConcept(value)); // CodeableConcept
1430          break;
1431        case -1335157162: // device
1432          this.getDevice().add(castToReference(value)); // Reference
1433          break;
1434        case 3387378: // note
1435          this.getNote().add(castToAnnotation(value)); // Annotation
1436          break;
1437        case -1326018889: // dosage
1438          this.dosage = (MedicationAdministrationDosageComponent) value; // MedicationAdministrationDosageComponent
1439          break;
1440        default: super.setProperty(hash, name, value);
1441        }
1442
1443      }
1444
1445      @Override
1446      public void setProperty(String name, Base value) throws FHIRException {
1447        if (name.equals("identifier"))
1448          this.getIdentifier().add(castToIdentifier(value));
1449        else if (name.equals("status"))
1450          this.status = new MedicationAdministrationStatusEnumFactory().fromType(value); // Enumeration<MedicationAdministrationStatus>
1451        else if (name.equals("medication[x]"))
1452          this.medication = (Type) value; // Type
1453        else if (name.equals("patient"))
1454          this.patient = castToReference(value); // Reference
1455        else if (name.equals("encounter"))
1456          this.encounter = castToReference(value); // Reference
1457        else if (name.equals("effectiveTime[x]"))
1458          this.effectiveTime = (Type) value; // Type
1459        else if (name.equals("practitioner"))
1460          this.practitioner = castToReference(value); // Reference
1461        else if (name.equals("prescription"))
1462          this.prescription = castToReference(value); // Reference
1463        else if (name.equals("wasNotGiven"))
1464          this.wasNotGiven = castToBoolean(value); // BooleanType
1465        else if (name.equals("reasonNotGiven"))
1466          this.getReasonNotGiven().add(castToCodeableConcept(value));
1467        else if (name.equals("reasonGiven"))
1468          this.getReasonGiven().add(castToCodeableConcept(value));
1469        else if (name.equals("device"))
1470          this.getDevice().add(castToReference(value));
1471        else if (name.equals("note"))
1472          this.getNote().add(castToAnnotation(value));
1473        else if (name.equals("dosage"))
1474          this.dosage = (MedicationAdministrationDosageComponent) value; // MedicationAdministrationDosageComponent
1475        else
1476          super.setProperty(name, value);
1477      }
1478
1479      @Override
1480      public Base makeProperty(int hash, String name) throws FHIRException {
1481        switch (hash) {
1482        case -1618432855:  return addIdentifier(); // Identifier
1483        case -892481550: throw new FHIRException("Cannot make property status as it is not a complex type"); // Enumeration<MedicationAdministrationStatus>
1484        case 1458402129:  return getMedication(); // Type
1485        case -791418107:  return getPatient(); // Reference
1486        case 1524132147:  return getEncounter(); // Reference
1487        case -272263444:  return getEffectiveTime(); // Type
1488        case 574573338:  return getPractitioner(); // Reference
1489        case 460301338:  return getPrescription(); // Reference
1490        case -1050911117: throw new FHIRException("Cannot make property wasNotGiven as it is not a complex type"); // BooleanType
1491        case 2101123790:  return addReasonNotGiven(); // CodeableConcept
1492        case 914964377:  return addReasonGiven(); // CodeableConcept
1493        case -1335157162:  return addDevice(); // Reference
1494        case 3387378:  return addNote(); // Annotation
1495        case -1326018889:  return getDosage(); // MedicationAdministrationDosageComponent
1496        default: return super.makeProperty(hash, name);
1497        }
1498
1499      }
1500
1501      @Override
1502      public Base addChild(String name) throws FHIRException {
1503        if (name.equals("identifier")) {
1504          return addIdentifier();
1505        }
1506        else if (name.equals("status")) {
1507          throw new FHIRException("Cannot call addChild on a primitive type MedicationAdministration.status");
1508        }
1509        else if (name.equals("medicationCodeableConcept")) {
1510          this.medication = new CodeableConcept();
1511          return this.medication;
1512        }
1513        else if (name.equals("medicationReference")) {
1514          this.medication = new Reference();
1515          return this.medication;
1516        }
1517        else if (name.equals("patient")) {
1518          this.patient = new Reference();
1519          return this.patient;
1520        }
1521        else if (name.equals("encounter")) {
1522          this.encounter = new Reference();
1523          return this.encounter;
1524        }
1525        else if (name.equals("effectiveTimeDateTime")) {
1526          this.effectiveTime = new DateTimeType();
1527          return this.effectiveTime;
1528        }
1529        else if (name.equals("effectiveTimePeriod")) {
1530          this.effectiveTime = new Period();
1531          return this.effectiveTime;
1532        }
1533        else if (name.equals("practitioner")) {
1534          this.practitioner = new Reference();
1535          return this.practitioner;
1536        }
1537        else if (name.equals("prescription")) {
1538          this.prescription = new Reference();
1539          return this.prescription;
1540        }
1541        else if (name.equals("wasNotGiven")) {
1542          throw new FHIRException("Cannot call addChild on a primitive type MedicationAdministration.wasNotGiven");
1543        }
1544        else if (name.equals("reasonNotGiven")) {
1545          return addReasonNotGiven();
1546        }
1547        else if (name.equals("reasonGiven")) {
1548          return addReasonGiven();
1549        }
1550        else if (name.equals("device")) {
1551          return addDevice();
1552        }
1553        else if (name.equals("note")) {
1554          return addNote();
1555        }
1556        else if (name.equals("dosage")) {
1557          this.dosage = new MedicationAdministrationDosageComponent();
1558          return this.dosage;
1559        }
1560        else
1561          return super.addChild(name);
1562      }
1563
1564  public String fhirType() {
1565    return "MedicationAdministration";
1566
1567  }
1568
1569      public MedicationAdministration copy() {
1570        MedicationAdministration dst = new MedicationAdministration();
1571        copyValues(dst);
1572        if (identifier != null) {
1573          dst.identifier = new ArrayList<Identifier>();
1574          for (Identifier i : identifier)
1575            dst.identifier.add(i.copy());
1576        };
1577        dst.status = status == null ? null : status.copy();
1578        dst.medication = medication == null ? null : medication.copy();
1579        dst.patient = patient == null ? null : patient.copy();
1580        dst.encounter = encounter == null ? null : encounter.copy();
1581        dst.effectiveTime = effectiveTime == null ? null : effectiveTime.copy();
1582        dst.practitioner = practitioner == null ? null : practitioner.copy();
1583        dst.prescription = prescription == null ? null : prescription.copy();
1584        dst.wasNotGiven = wasNotGiven == null ? null : wasNotGiven.copy();
1585        if (reasonNotGiven != null) {
1586          dst.reasonNotGiven = new ArrayList<CodeableConcept>();
1587          for (CodeableConcept i : reasonNotGiven)
1588            dst.reasonNotGiven.add(i.copy());
1589        };
1590        if (reasonGiven != null) {
1591          dst.reasonGiven = new ArrayList<CodeableConcept>();
1592          for (CodeableConcept i : reasonGiven)
1593            dst.reasonGiven.add(i.copy());
1594        };
1595        if (device != null) {
1596          dst.device = new ArrayList<Reference>();
1597          for (Reference i : device)
1598            dst.device.add(i.copy());
1599        };
1600        if (note != null) {
1601          dst.note = new ArrayList<Annotation>();
1602          for (Annotation i : note)
1603            dst.note.add(i.copy());
1604        };
1605        dst.dosage = dosage == null ? null : dosage.copy();
1606        return dst;
1607      }
1608
1609      protected MedicationAdministration typedCopy() {
1610        return copy();
1611      }
1612
1613      @Override
1614      public boolean equalsDeep(Base other) {
1615        if (!super.equalsDeep(other))
1616          return false;
1617        if (!(other instanceof MedicationAdministration))
1618          return false;
1619        MedicationAdministration o = (MedicationAdministration) other;
1620        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(medication, o.medication, true)
1621           && compareDeep(patient, o.patient, true) && compareDeep(encounter, o.encounter, true) && compareDeep(effectiveTime, o.effectiveTime, true)
1622           && compareDeep(practitioner, o.practitioner, true) && compareDeep(prescription, o.prescription, true)
1623           && compareDeep(wasNotGiven, o.wasNotGiven, true) && compareDeep(reasonNotGiven, o.reasonNotGiven, true)
1624           && compareDeep(reasonGiven, o.reasonGiven, true) && compareDeep(device, o.device, true) && compareDeep(note, o.note, true)
1625           && compareDeep(dosage, o.dosage, true);
1626      }
1627
1628      @Override
1629      public boolean equalsShallow(Base other) {
1630        if (!super.equalsShallow(other))
1631          return false;
1632        if (!(other instanceof MedicationAdministration))
1633          return false;
1634        MedicationAdministration o = (MedicationAdministration) other;
1635        return compareValues(status, o.status, true) && compareValues(wasNotGiven, o.wasNotGiven, true);
1636      }
1637
1638      public boolean isEmpty() {
1639        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (status == null || status.isEmpty())
1640           && (medication == null || medication.isEmpty()) && (patient == null || patient.isEmpty())
1641           && (encounter == null || encounter.isEmpty()) && (effectiveTime == null || effectiveTime.isEmpty())
1642           && (practitioner == null || practitioner.isEmpty()) && (prescription == null || prescription.isEmpty())
1643           && (wasNotGiven == null || wasNotGiven.isEmpty()) && (reasonNotGiven == null || reasonNotGiven.isEmpty())
1644           && (reasonGiven == null || reasonGiven.isEmpty()) && (device == null || device.isEmpty())
1645           && (note == null || note.isEmpty()) && (dosage == null || dosage.isEmpty());
1646      }
1647
1648  @Override
1649  public ResourceType getResourceType() {
1650    return ResourceType.MedicationAdministration;
1651   }
1652
1653 /**
1654   * Search parameter: <b>medication</b>
1655   * <p>
1656   * Description: <b>Return administrations of this medication resource</b><br>
1657   * Type: <b>reference</b><br>
1658   * Path: <b>MedicationAdministration.medicationReference</b><br>
1659   * </p>
1660   */
1661  @SearchParamDefinition(name="medication", path="MedicationAdministration.medication.as(Reference)", description="Return administrations of this medication resource", type="reference" )
1662  public static final String SP_MEDICATION = "medication";
1663 /**
1664   * <b>Fluent Client</b> search parameter constant for <b>medication</b>
1665   * <p>
1666   * Description: <b>Return administrations of this medication resource</b><br>
1667   * Type: <b>reference</b><br>
1668   * Path: <b>MedicationAdministration.medicationReference</b><br>
1669   * </p>
1670   */
1671  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam MEDICATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_MEDICATION);
1672
1673/**
1674   * Constant for fluent queries to be used to add include statements. Specifies
1675   * the path value of "<b>MedicationAdministration:medication</b>".
1676   */
1677  public static final ca.uhn.fhir.model.api.Include INCLUDE_MEDICATION = new ca.uhn.fhir.model.api.Include("MedicationAdministration:medication").toLocked();
1678
1679 /**
1680   * Search parameter: <b>effectivetime</b>
1681   * <p>
1682   * Description: <b>Date administration happened (or did not happen)</b><br>
1683   * Type: <b>date</b><br>
1684   * Path: <b>MedicationAdministration.effectiveTime[x]</b><br>
1685   * </p>
1686   */
1687  @SearchParamDefinition(name="effectivetime", path="MedicationAdministration.effectiveTime", description="Date administration happened (or did not happen)", type="date" )
1688  public static final String SP_EFFECTIVETIME = "effectivetime";
1689 /**
1690   * <b>Fluent Client</b> search parameter constant for <b>effectivetime</b>
1691   * <p>
1692   * Description: <b>Date administration happened (or did not happen)</b><br>
1693   * Type: <b>date</b><br>
1694   * Path: <b>MedicationAdministration.effectiveTime[x]</b><br>
1695   * </p>
1696   */
1697  public static final ca.uhn.fhir.rest.gclient.DateClientParam EFFECTIVETIME = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_EFFECTIVETIME);
1698
1699 /**
1700   * Search parameter: <b>patient</b>
1701   * <p>
1702   * Description: <b>The identity of a patient to list administrations  for</b><br>
1703   * Type: <b>reference</b><br>
1704   * Path: <b>MedicationAdministration.patient</b><br>
1705   * </p>
1706   */
1707  @SearchParamDefinition(name="patient", path="MedicationAdministration.patient", description="The identity of a patient to list administrations  for", type="reference" )
1708  public static final String SP_PATIENT = "patient";
1709 /**
1710   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
1711   * <p>
1712   * Description: <b>The identity of a patient to list administrations  for</b><br>
1713   * Type: <b>reference</b><br>
1714   * Path: <b>MedicationAdministration.patient</b><br>
1715   * </p>
1716   */
1717  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
1718
1719/**
1720   * Constant for fluent queries to be used to add include statements. Specifies
1721   * the path value of "<b>MedicationAdministration:patient</b>".
1722   */
1723  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("MedicationAdministration:patient").toLocked();
1724
1725 /**
1726   * Search parameter: <b>practitioner</b>
1727   * <p>
1728   * Description: <b>Who administered substance</b><br>
1729   * Type: <b>reference</b><br>
1730   * Path: <b>MedicationAdministration.practitioner</b><br>
1731   * </p>
1732   */
1733  @SearchParamDefinition(name="practitioner", path="MedicationAdministration.practitioner", description="Who administered substance", type="reference" )
1734  public static final String SP_PRACTITIONER = "practitioner";
1735 /**
1736   * <b>Fluent Client</b> search parameter constant for <b>practitioner</b>
1737   * <p>
1738   * Description: <b>Who administered substance</b><br>
1739   * Type: <b>reference</b><br>
1740   * Path: <b>MedicationAdministration.practitioner</b><br>
1741   * </p>
1742   */
1743  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PRACTITIONER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PRACTITIONER);
1744
1745/**
1746   * Constant for fluent queries to be used to add include statements. Specifies
1747   * the path value of "<b>MedicationAdministration:practitioner</b>".
1748   */
1749  public static final ca.uhn.fhir.model.api.Include INCLUDE_PRACTITIONER = new ca.uhn.fhir.model.api.Include("MedicationAdministration:practitioner").toLocked();
1750
1751 /**
1752   * Search parameter: <b>status</b>
1753   * <p>
1754   * Description: <b>MedicationAdministration event status (for example one of active/paused/completed/nullified)</b><br>
1755   * Type: <b>token</b><br>
1756   * Path: <b>MedicationAdministration.status</b><br>
1757   * </p>
1758   */
1759  @SearchParamDefinition(name="status", path="MedicationAdministration.status", description="MedicationAdministration event status (for example one of active/paused/completed/nullified)", type="token" )
1760  public static final String SP_STATUS = "status";
1761 /**
1762   * <b>Fluent Client</b> search parameter constant for <b>status</b>
1763   * <p>
1764   * Description: <b>MedicationAdministration event status (for example one of active/paused/completed/nullified)</b><br>
1765   * Type: <b>token</b><br>
1766   * Path: <b>MedicationAdministration.status</b><br>
1767   * </p>
1768   */
1769  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
1770
1771 /**
1772   * Search parameter: <b>prescription</b>
1773   * <p>
1774   * Description: <b>The identity of a prescription to list administrations from</b><br>
1775   * Type: <b>reference</b><br>
1776   * Path: <b>MedicationAdministration.prescription</b><br>
1777   * </p>
1778   */
1779  @SearchParamDefinition(name="prescription", path="MedicationAdministration.prescription", description="The identity of a prescription to list administrations from", type="reference" )
1780  public static final String SP_PRESCRIPTION = "prescription";
1781 /**
1782   * <b>Fluent Client</b> search parameter constant for <b>prescription</b>
1783   * <p>
1784   * Description: <b>The identity of a prescription to list administrations from</b><br>
1785   * Type: <b>reference</b><br>
1786   * Path: <b>MedicationAdministration.prescription</b><br>
1787   * </p>
1788   */
1789  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PRESCRIPTION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PRESCRIPTION);
1790
1791/**
1792   * Constant for fluent queries to be used to add include statements. Specifies
1793   * the path value of "<b>MedicationAdministration:prescription</b>".
1794   */
1795  public static final ca.uhn.fhir.model.api.Include INCLUDE_PRESCRIPTION = new ca.uhn.fhir.model.api.Include("MedicationAdministration:prescription").toLocked();
1796
1797 /**
1798   * Search parameter: <b>device</b>
1799   * <p>
1800   * Description: <b>Return administrations with this administration device identity</b><br>
1801   * Type: <b>reference</b><br>
1802   * Path: <b>MedicationAdministration.device</b><br>
1803   * </p>
1804   */
1805  @SearchParamDefinition(name="device", path="MedicationAdministration.device", description="Return administrations with this administration device identity", type="reference" )
1806  public static final String SP_DEVICE = "device";
1807 /**
1808   * <b>Fluent Client</b> search parameter constant for <b>device</b>
1809   * <p>
1810   * Description: <b>Return administrations with this administration device identity</b><br>
1811   * Type: <b>reference</b><br>
1812   * Path: <b>MedicationAdministration.device</b><br>
1813   * </p>
1814   */
1815  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam DEVICE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_DEVICE);
1816
1817/**
1818   * Constant for fluent queries to be used to add include statements. Specifies
1819   * the path value of "<b>MedicationAdministration:device</b>".
1820   */
1821  public static final ca.uhn.fhir.model.api.Include INCLUDE_DEVICE = new ca.uhn.fhir.model.api.Include("MedicationAdministration:device").toLocked();
1822
1823 /**
1824   * Search parameter: <b>code</b>
1825   * <p>
1826   * Description: <b>Return administrations of this medication code</b><br>
1827   * Type: <b>token</b><br>
1828   * Path: <b>MedicationAdministration.medicationCodeableConcept</b><br>
1829   * </p>
1830   */
1831  @SearchParamDefinition(name="code", path="MedicationAdministration.medication.as(CodeableConcept)", description="Return administrations of this medication code", type="token" )
1832  public static final String SP_CODE = "code";
1833 /**
1834   * <b>Fluent Client</b> search parameter constant for <b>code</b>
1835   * <p>
1836   * Description: <b>Return administrations of this medication code</b><br>
1837   * Type: <b>token</b><br>
1838   * Path: <b>MedicationAdministration.medicationCodeableConcept</b><br>
1839   * </p>
1840   */
1841  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CODE);
1842
1843 /**
1844   * Search parameter: <b>encounter</b>
1845   * <p>
1846   * Description: <b>Return administrations that share this encounter</b><br>
1847   * Type: <b>reference</b><br>
1848   * Path: <b>MedicationAdministration.encounter</b><br>
1849   * </p>
1850   */
1851  @SearchParamDefinition(name="encounter", path="MedicationAdministration.encounter", description="Return administrations that share this encounter", type="reference" )
1852  public static final String SP_ENCOUNTER = "encounter";
1853 /**
1854   * <b>Fluent Client</b> search parameter constant for <b>encounter</b>
1855   * <p>
1856   * Description: <b>Return administrations that share this encounter</b><br>
1857   * Type: <b>reference</b><br>
1858   * Path: <b>MedicationAdministration.encounter</b><br>
1859   * </p>
1860   */
1861  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENCOUNTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENCOUNTER);
1862
1863/**
1864   * Constant for fluent queries to be used to add include statements. Specifies
1865   * the path value of "<b>MedicationAdministration:encounter</b>".
1866   */
1867  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENCOUNTER = new ca.uhn.fhir.model.api.Include("MedicationAdministration:encounter").toLocked();
1868
1869 /**
1870   * Search parameter: <b>identifier</b>
1871   * <p>
1872   * Description: <b>Return administrations with this external identifier</b><br>
1873   * Type: <b>token</b><br>
1874   * Path: <b>MedicationAdministration.identifier</b><br>
1875   * </p>
1876   */
1877  @SearchParamDefinition(name="identifier", path="MedicationAdministration.identifier", description="Return administrations with this external identifier", type="token" )
1878  public static final String SP_IDENTIFIER = "identifier";
1879 /**
1880   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
1881   * <p>
1882   * Description: <b>Return administrations with this external identifier</b><br>
1883   * Type: <b>token</b><br>
1884   * Path: <b>MedicationAdministration.identifier</b><br>
1885   * </p>
1886   */
1887  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
1888
1889 /**
1890   * Search parameter: <b>wasnotgiven</b>
1891   * <p>
1892   * Description: <b>Administrations that were not made</b><br>
1893   * Type: <b>token</b><br>
1894   * Path: <b>MedicationAdministration.wasNotGiven</b><br>
1895   * </p>
1896   */
1897  @SearchParamDefinition(name="wasnotgiven", path="MedicationAdministration.wasNotGiven", description="Administrations that were not made", type="token" )
1898  public static final String SP_WASNOTGIVEN = "wasnotgiven";
1899 /**
1900   * <b>Fluent Client</b> search parameter constant for <b>wasnotgiven</b>
1901   * <p>
1902   * Description: <b>Administrations that were not made</b><br>
1903   * Type: <b>token</b><br>
1904   * Path: <b>MedicationAdministration.wasNotGiven</b><br>
1905   * </p>
1906   */
1907  public static final ca.uhn.fhir.rest.gclient.TokenClientParam WASNOTGIVEN = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_WASNOTGIVEN);
1908
1909
1910}
1911