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