001package org.hl7.fhir.r5.model;
002
003
004/*
005  Copyright (c) 2011+, HL7, Inc.
006  All rights reserved.
007  
008  Redistribution and use in source and binary forms, with or without modification, \
009  are permitted provided that the following conditions are met:
010  
011   * Redistributions of source code must retain the above copyright notice, this \
012     list of conditions and the following disclaimer.
013   * Redistributions in binary form must reproduce the above copyright notice, \
014     this list of conditions and the following disclaimer in the documentation \
015     and/or other materials provided with the distribution.
016   * Neither the name of HL7 nor the names of its contributors may be used to 
017     endorse or promote products derived from this software without specific 
018     prior written permission.
019  
020  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
021  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
022  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
023  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
024  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
025  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
026  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
027  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
028  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
029  POSSIBILITY OF SUCH DAMAGE.
030  */
031
032// Generated on Tue, Dec 13, 2022 17:53+1100 for FHIR vcurrent
033
034import java.util.ArrayList;
035import java.util.Date;
036import java.util.List;
037import org.hl7.fhir.utilities.Utilities;
038import org.hl7.fhir.r5.model.Enumerations.*;
039import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
040import org.hl7.fhir.exceptions.FHIRException;
041import org.hl7.fhir.instance.model.api.ICompositeType;
042import ca.uhn.fhir.model.api.annotation.ResourceDef;
043import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
044import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
045import ca.uhn.fhir.model.api.annotation.Child;
046import ca.uhn.fhir.model.api.annotation.ChildOrder;
047import ca.uhn.fhir.model.api.annotation.Description;
048import ca.uhn.fhir.model.api.annotation.Block;
049
050/**
051 * A record of a medication that is being consumed by a patient.   A MedicationUsage may indicate that the patient may be taking the medication now or has taken the medication in the past or will be taking the medication in the future.  The source of this information can be the patient, significant other (such as a family member or spouse), or a clinician.  A common scenario where this information is captured is during the history taking process during a patient visit or stay.   The medication information may come from sources such as the patient's memory, from a prescription bottle,  or from a list of medications the patient, clinician or other party maintains. 
052
053The primary difference between a medicationusage and a medicationadministration is that the medication administration has complete administration information and is based on actual administration information from the person who administered the medication.  A medicationusage is often, if not always, less specific.  There is no required date/time when the medication was administered, in fact we only know that a source has reported the patient is taking this medication, where details such as time, quantity, or rate or even medication product may be incomplete or missing or less precise.  As stated earlier, the Medication Usage information may come from the patient's memory, from a prescription bottle or from a list of medications the patient, clinician or other party maintains.  Medication administration is more formal and is not missing detailed information.
054 */
055@ResourceDef(name="MedicationUsage", profile="http://hl7.org/fhir/StructureDefinition/MedicationUsage")
056public class MedicationUsage extends DomainResource {
057
058    public enum MedicationUsageStatusCodes {
059        /**
060         * The action of recording the medication statement is finished.
061         */
062        RECORDED, 
063        /**
064         * Some of the actions that are implied by the medication usage may have occurred.  For example, the patient may have taken some of the medication.  Clinical decision support systems should take this status into account.
065         */
066        ENTEREDINERROR, 
067        /**
068         * The medication usage is draft or preliminary.
069         */
070        DRAFT, 
071        /**
072         * added to help the parsers with the generic types
073         */
074        NULL;
075        public static MedicationUsageStatusCodes fromCode(String codeString) throws FHIRException {
076            if (codeString == null || "".equals(codeString))
077                return null;
078        if ("recorded".equals(codeString))
079          return RECORDED;
080        if ("entered-in-error".equals(codeString))
081          return ENTEREDINERROR;
082        if ("draft".equals(codeString))
083          return DRAFT;
084        if (Configuration.isAcceptInvalidEnums())
085          return null;
086        else
087          throw new FHIRException("Unknown MedicationUsageStatusCodes code '"+codeString+"'");
088        }
089        public String toCode() {
090          switch (this) {
091            case RECORDED: return "recorded";
092            case ENTEREDINERROR: return "entered-in-error";
093            case DRAFT: return "draft";
094            case NULL: return null;
095            default: return "?";
096          }
097        }
098        public String getSystem() {
099          switch (this) {
100            case RECORDED: return "http://hl7.org/fhir/CodeSystem/medication-usage-status";
101            case ENTEREDINERROR: return "http://hl7.org/fhir/CodeSystem/medication-usage-status";
102            case DRAFT: return "http://hl7.org/fhir/CodeSystem/medication-usage-status";
103            case NULL: return null;
104            default: return "?";
105          }
106        }
107        public String getDefinition() {
108          switch (this) {
109            case RECORDED: return "The action of recording the medication statement is finished.";
110            case ENTEREDINERROR: return "Some of the actions that are implied by the medication usage may have occurred.  For example, the patient may have taken some of the medication.  Clinical decision support systems should take this status into account.";
111            case DRAFT: return "The medication usage is draft or preliminary.";
112            case NULL: return null;
113            default: return "?";
114          }
115        }
116        public String getDisplay() {
117          switch (this) {
118            case RECORDED: return "Recorded";
119            case ENTEREDINERROR: return "Entered in Error";
120            case DRAFT: return "Draft";
121            case NULL: return null;
122            default: return "?";
123          }
124        }
125    }
126
127  public static class MedicationUsageStatusCodesEnumFactory implements EnumFactory<MedicationUsageStatusCodes> {
128    public MedicationUsageStatusCodes fromCode(String codeString) throws IllegalArgumentException {
129      if (codeString == null || "".equals(codeString))
130            if (codeString == null || "".equals(codeString))
131                return null;
132        if ("recorded".equals(codeString))
133          return MedicationUsageStatusCodes.RECORDED;
134        if ("entered-in-error".equals(codeString))
135          return MedicationUsageStatusCodes.ENTEREDINERROR;
136        if ("draft".equals(codeString))
137          return MedicationUsageStatusCodes.DRAFT;
138        throw new IllegalArgumentException("Unknown MedicationUsageStatusCodes code '"+codeString+"'");
139        }
140        public Enumeration<MedicationUsageStatusCodes> fromType(PrimitiveType<?> code) throws FHIRException {
141          if (code == null)
142            return null;
143          if (code.isEmpty())
144            return new Enumeration<MedicationUsageStatusCodes>(this, MedicationUsageStatusCodes.NULL, code);
145          String codeString = ((PrimitiveType) code).asStringValue();
146          if (codeString == null || "".equals(codeString))
147            return new Enumeration<MedicationUsageStatusCodes>(this, MedicationUsageStatusCodes.NULL, code);
148        if ("recorded".equals(codeString))
149          return new Enumeration<MedicationUsageStatusCodes>(this, MedicationUsageStatusCodes.RECORDED, code);
150        if ("entered-in-error".equals(codeString))
151          return new Enumeration<MedicationUsageStatusCodes>(this, MedicationUsageStatusCodes.ENTEREDINERROR, code);
152        if ("draft".equals(codeString))
153          return new Enumeration<MedicationUsageStatusCodes>(this, MedicationUsageStatusCodes.DRAFT, code);
154        throw new FHIRException("Unknown MedicationUsageStatusCodes code '"+codeString+"'");
155        }
156    public String toCode(MedicationUsageStatusCodes code) {
157      if (code == MedicationUsageStatusCodes.RECORDED)
158        return "recorded";
159      if (code == MedicationUsageStatusCodes.ENTEREDINERROR)
160        return "entered-in-error";
161      if (code == MedicationUsageStatusCodes.DRAFT)
162        return "draft";
163      return "?";
164      }
165    public String toSystem(MedicationUsageStatusCodes code) {
166      return code.getSystem();
167      }
168    }
169
170    @Block()
171    public static class MedicationUsageAdherenceComponent extends BackboneElement implements IBaseBackboneElement {
172        /**
173         * Type of the adherence for the medication.
174         */
175        @Child(name = "code", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=true)
176        @Description(shortDefinition="Type of adherence", formalDefinition="Type of the adherence for the medication." )
177        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-usage-adherence")
178        protected CodeableConcept code;
179
180        /**
181         * Captures the reason for the current use or adherence of a medication.
182         */
183        @Child(name = "reason", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
184        @Description(shortDefinition="Details of the reason for the current use of the medication", formalDefinition="Captures the reason for the current use or adherence of a medication." )
185        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/reason-medication-status-codes")
186        protected CodeableConcept reason;
187
188        private static final long serialVersionUID = -1479626679L;
189
190    /**
191     * Constructor
192     */
193      public MedicationUsageAdherenceComponent() {
194        super();
195      }
196
197    /**
198     * Constructor
199     */
200      public MedicationUsageAdherenceComponent(CodeableConcept code) {
201        super();
202        this.setCode(code);
203      }
204
205        /**
206         * @return {@link #code} (Type of the adherence for the medication.)
207         */
208        public CodeableConcept getCode() { 
209          if (this.code == null)
210            if (Configuration.errorOnAutoCreate())
211              throw new Error("Attempt to auto-create MedicationUsageAdherenceComponent.code");
212            else if (Configuration.doAutoCreate())
213              this.code = new CodeableConcept(); // cc
214          return this.code;
215        }
216
217        public boolean hasCode() { 
218          return this.code != null && !this.code.isEmpty();
219        }
220
221        /**
222         * @param value {@link #code} (Type of the adherence for the medication.)
223         */
224        public MedicationUsageAdherenceComponent setCode(CodeableConcept value) { 
225          this.code = value;
226          return this;
227        }
228
229        /**
230         * @return {@link #reason} (Captures the reason for the current use or adherence of a medication.)
231         */
232        public CodeableConcept getReason() { 
233          if (this.reason == null)
234            if (Configuration.errorOnAutoCreate())
235              throw new Error("Attempt to auto-create MedicationUsageAdherenceComponent.reason");
236            else if (Configuration.doAutoCreate())
237              this.reason = new CodeableConcept(); // cc
238          return this.reason;
239        }
240
241        public boolean hasReason() { 
242          return this.reason != null && !this.reason.isEmpty();
243        }
244
245        /**
246         * @param value {@link #reason} (Captures the reason for the current use or adherence of a medication.)
247         */
248        public MedicationUsageAdherenceComponent setReason(CodeableConcept value) { 
249          this.reason = value;
250          return this;
251        }
252
253        protected void listChildren(List<Property> children) {
254          super.listChildren(children);
255          children.add(new Property("code", "CodeableConcept", "Type of the adherence for the medication.", 0, 1, code));
256          children.add(new Property("reason", "CodeableConcept", "Captures the reason for the current use or adherence of a medication.", 0, 1, reason));
257        }
258
259        @Override
260        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
261          switch (_hash) {
262          case 3059181: /*code*/  return new Property("code", "CodeableConcept", "Type of the adherence for the medication.", 0, 1, code);
263          case -934964668: /*reason*/  return new Property("reason", "CodeableConcept", "Captures the reason for the current use or adherence of a medication.", 0, 1, reason);
264          default: return super.getNamedProperty(_hash, _name, _checkValid);
265          }
266
267        }
268
269      @Override
270      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
271        switch (hash) {
272        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept
273        case -934964668: /*reason*/ return this.reason == null ? new Base[0] : new Base[] {this.reason}; // CodeableConcept
274        default: return super.getProperty(hash, name, checkValid);
275        }
276
277      }
278
279      @Override
280      public Base setProperty(int hash, String name, Base value) throws FHIRException {
281        switch (hash) {
282        case 3059181: // code
283          this.code = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
284          return value;
285        case -934964668: // reason
286          this.reason = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
287          return value;
288        default: return super.setProperty(hash, name, value);
289        }
290
291      }
292
293      @Override
294      public Base setProperty(String name, Base value) throws FHIRException {
295        if (name.equals("code")) {
296          this.code = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
297        } else if (name.equals("reason")) {
298          this.reason = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
299        } else
300          return super.setProperty(name, value);
301        return value;
302      }
303
304      @Override
305      public Base makeProperty(int hash, String name) throws FHIRException {
306        switch (hash) {
307        case 3059181:  return getCode();
308        case -934964668:  return getReason();
309        default: return super.makeProperty(hash, name);
310        }
311
312      }
313
314      @Override
315      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
316        switch (hash) {
317        case 3059181: /*code*/ return new String[] {"CodeableConcept"};
318        case -934964668: /*reason*/ return new String[] {"CodeableConcept"};
319        default: return super.getTypesForProperty(hash, name);
320        }
321
322      }
323
324      @Override
325      public Base addChild(String name) throws FHIRException {
326        if (name.equals("code")) {
327          this.code = new CodeableConcept();
328          return this.code;
329        }
330        else if (name.equals("reason")) {
331          this.reason = new CodeableConcept();
332          return this.reason;
333        }
334        else
335          return super.addChild(name);
336      }
337
338      public MedicationUsageAdherenceComponent copy() {
339        MedicationUsageAdherenceComponent dst = new MedicationUsageAdherenceComponent();
340        copyValues(dst);
341        return dst;
342      }
343
344      public void copyValues(MedicationUsageAdherenceComponent dst) {
345        super.copyValues(dst);
346        dst.code = code == null ? null : code.copy();
347        dst.reason = reason == null ? null : reason.copy();
348      }
349
350      @Override
351      public boolean equalsDeep(Base other_) {
352        if (!super.equalsDeep(other_))
353          return false;
354        if (!(other_ instanceof MedicationUsageAdherenceComponent))
355          return false;
356        MedicationUsageAdherenceComponent o = (MedicationUsageAdherenceComponent) other_;
357        return compareDeep(code, o.code, true) && compareDeep(reason, o.reason, true);
358      }
359
360      @Override
361      public boolean equalsShallow(Base other_) {
362        if (!super.equalsShallow(other_))
363          return false;
364        if (!(other_ instanceof MedicationUsageAdherenceComponent))
365          return false;
366        MedicationUsageAdherenceComponent o = (MedicationUsageAdherenceComponent) other_;
367        return true;
368      }
369
370      public boolean isEmpty() {
371        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(code, reason);
372      }
373
374  public String fhirType() {
375    return "MedicationUsage.adherence";
376
377  }
378
379  }
380
381    /**
382     * Identifiers associated with this Medication Usage 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.
383     */
384    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
385    @Description(shortDefinition="External identifier", formalDefinition="Identifiers associated with this Medication Usage 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." )
386    protected List<Identifier> identifier;
387
388    /**
389     * A larger event of which this particular MedicationUsage is a component or step.
390     */
391    @Child(name = "partOf", type = {Procedure.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
392    @Description(shortDefinition="Part of referenced event", formalDefinition="A larger event of which this particular MedicationUsage is a component or step." )
393    protected List<Reference> partOf;
394
395    /**
396     * A code representing the status of recording the medication usage.
397     */
398    @Child(name = "status", type = {CodeType.class}, order=2, min=1, max=1, modifier=true, summary=true)
399    @Description(shortDefinition="recorded | entered-in-error | draft", formalDefinition="A code representing the status of recording the medication usage." )
400    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-usage-status")
401    protected Enumeration<MedicationUsageStatusCodes> status;
402
403    /**
404     * Type of medication usage (for example, drug classification like ATC, where meds would be administered, legal category of the medication.).
405     */
406    @Child(name = "category", type = {CodeableConcept.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
407    @Description(shortDefinition="Type of medication usage", formalDefinition="Type of medication usage (for example, drug classification like ATC, where meds would be administered, legal category of the medication.)." )
408    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medicationrequest-admin-location")
409    protected List<CodeableConcept> category;
410
411    /**
412     * Identifies the medication being 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.
413     */
414    @Child(name = "medication", type = {CodeableReference.class}, order=4, min=1, max=1, modifier=false, summary=true)
415    @Description(shortDefinition="What medication was taken", formalDefinition="Identifies the medication being 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." )
416    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-codes")
417    protected CodeableReference medication;
418
419    /**
420     * The person, animal or group who is/was taking the medication.
421     */
422    @Child(name = "subject", type = {Patient.class, Group.class}, order=5, min=1, max=1, modifier=false, summary=true)
423    @Description(shortDefinition="Who is/was taking  the medication", formalDefinition="The person, animal or group who is/was taking the medication." )
424    protected Reference subject;
425
426    /**
427     * The encounter that establishes the context for this MedicationUsage.
428     */
429    @Child(name = "encounter", type = {Encounter.class}, order=6, min=0, max=1, modifier=false, summary=true)
430    @Description(shortDefinition="Encounter associated with MedicationUsage", formalDefinition="The encounter that establishes the context for this MedicationUsage." )
431    protected Reference encounter;
432
433    /**
434     * The interval of time during which it is being asserted that the patient is/was/will be taking the medication (or was not taking, when the MedicationUsage.adherence element is Not Taking).
435     */
436    @Child(name = "effective", type = {DateTimeType.class, Period.class}, order=7, min=0, max=1, modifier=false, summary=true)
437    @Description(shortDefinition="The date/time or interval when the medication is/was/will be taken", formalDefinition="The interval of time during which it is being asserted that the patient is/was/will be taking the medication (or was not taking, when the MedicationUsage.adherence element is Not Taking)." )
438    protected DataType effective;
439
440    /**
441     * The date when the Medication Usage was asserted by the information source.
442     */
443    @Child(name = "dateAsserted", type = {DateTimeType.class}, order=8, min=0, max=1, modifier=false, summary=true)
444    @Description(shortDefinition="When the usage was asserted?", formalDefinition="The date when the Medication Usage was asserted by the information source." )
445    protected DateTimeType dateAsserted;
446
447    /**
448     * The person or organization that provided the information about the taking of this medication. Note: Use derivedFrom when a MedicationUsage is derived from other resources, e.g. Claim or MedicationRequest.
449     */
450    @Child(name = "informationSource", type = {Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class, Organization.class}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
451    @Description(shortDefinition="Person or organization that provided the information about the taking of this medication", formalDefinition="The person or organization that provided the information about the taking of this medication. Note: Use derivedFrom when a MedicationUsage is derived from other resources, e.g. Claim or MedicationRequest." )
452    protected List<Reference> informationSource;
453
454    /**
455     * Allows linking the MedicationUsage to the underlying MedicationRequest, or to other information that supports or is used to derive the MedicationUsage.
456     */
457    @Child(name = "derivedFrom", type = {Reference.class}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
458    @Description(shortDefinition="Link to information used to derive the MedicationUsage", formalDefinition="Allows linking the MedicationUsage to the underlying MedicationRequest, or to other information that supports or is used to derive the MedicationUsage." )
459    protected List<Reference> derivedFrom;
460
461    /**
462     * A concept, Condition or observation that supports why the medication is being/was taken.
463     */
464    @Child(name = "reason", type = {CodeableReference.class}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
465    @Description(shortDefinition="Reason for why the medication is being/was taken", formalDefinition="A concept, Condition or observation that supports why the medication is being/was taken." )
466    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/condition-code")
467    protected List<CodeableReference> reason;
468
469    /**
470     * Provides extra information about the Medication Usage that is not conveyed by the other attributes.
471     */
472    @Child(name = "note", type = {Annotation.class}, order=12, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
473    @Description(shortDefinition="Further information about the usage", formalDefinition="Provides extra information about the Medication Usage that is not conveyed by the other attributes." )
474    protected List<Annotation> note;
475
476    /**
477     * Link to information that is relevant to a medication usage, for example, illicit drug use, gestational age, etc.
478     */
479    @Child(name = "relatedClinicalInformation", type = {Observation.class, Condition.class}, order=13, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
480    @Description(shortDefinition="Link to information relevant to the usage of a medication", formalDefinition="Link to information that is relevant to a medication usage, for example, illicit drug use, gestational age, etc." )
481    protected List<Reference> relatedClinicalInformation;
482
483    /**
484     * The full representation of the dose of the medication included in all dosage instructions.  To be used when multiple dosage instructions are included to represent complex dosing such as increasing or tapering doses.
485     */
486    @Child(name = "renderedDosageInstruction", type = {StringType.class}, order=14, min=0, max=1, modifier=false, summary=false)
487    @Description(shortDefinition="Full representation of the dosage instructions", formalDefinition="The full representation of the dose of the medication included in all dosage instructions.  To be used when multiple dosage instructions are included to represent complex dosing such as increasing or tapering doses." )
488    protected StringType renderedDosageInstruction;
489
490    /**
491     * Indicates how the medication is/was or should be taken by the patient.
492     */
493    @Child(name = "dosage", type = {Dosage.class}, order=15, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
494    @Description(shortDefinition="Details of how medication is/was taken or should be taken", formalDefinition="Indicates how the medication is/was or should be taken by the patient." )
495    protected List<Dosage> dosage;
496
497    /**
498     * Indicates if the medication is being consumed or administered as instructed.
499     */
500    @Child(name = "adherence", type = {}, order=16, min=0, max=1, modifier=false, summary=true)
501    @Description(shortDefinition="Indicates if the medication is being consumed or administered as instructed", formalDefinition="Indicates if the medication is being consumed or administered as instructed." )
502    protected MedicationUsageAdherenceComponent adherence;
503
504    private static final long serialVersionUID = -483194372L;
505
506  /**
507   * Constructor
508   */
509    public MedicationUsage() {
510      super();
511    }
512
513  /**
514   * Constructor
515   */
516    public MedicationUsage(MedicationUsageStatusCodes status, CodeableReference medication, Reference subject) {
517      super();
518      this.setStatus(status);
519      this.setMedication(medication);
520      this.setSubject(subject);
521    }
522
523    /**
524     * @return {@link #identifier} (Identifiers associated with this Medication Usage 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.)
525     */
526    public List<Identifier> getIdentifier() { 
527      if (this.identifier == null)
528        this.identifier = new ArrayList<Identifier>();
529      return this.identifier;
530    }
531
532    /**
533     * @return Returns a reference to <code>this</code> for easy method chaining
534     */
535    public MedicationUsage setIdentifier(List<Identifier> theIdentifier) { 
536      this.identifier = theIdentifier;
537      return this;
538    }
539
540    public boolean hasIdentifier() { 
541      if (this.identifier == null)
542        return false;
543      for (Identifier item : this.identifier)
544        if (!item.isEmpty())
545          return true;
546      return false;
547    }
548
549    public Identifier addIdentifier() { //3
550      Identifier t = new Identifier();
551      if (this.identifier == null)
552        this.identifier = new ArrayList<Identifier>();
553      this.identifier.add(t);
554      return t;
555    }
556
557    public MedicationUsage addIdentifier(Identifier t) { //3
558      if (t == null)
559        return this;
560      if (this.identifier == null)
561        this.identifier = new ArrayList<Identifier>();
562      this.identifier.add(t);
563      return this;
564    }
565
566    /**
567     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist {3}
568     */
569    public Identifier getIdentifierFirstRep() { 
570      if (getIdentifier().isEmpty()) {
571        addIdentifier();
572      }
573      return getIdentifier().get(0);
574    }
575
576    /**
577     * @return {@link #partOf} (A larger event of which this particular MedicationUsage is a component or step.)
578     */
579    public List<Reference> getPartOf() { 
580      if (this.partOf == null)
581        this.partOf = new ArrayList<Reference>();
582      return this.partOf;
583    }
584
585    /**
586     * @return Returns a reference to <code>this</code> for easy method chaining
587     */
588    public MedicationUsage setPartOf(List<Reference> thePartOf) { 
589      this.partOf = thePartOf;
590      return this;
591    }
592
593    public boolean hasPartOf() { 
594      if (this.partOf == null)
595        return false;
596      for (Reference item : this.partOf)
597        if (!item.isEmpty())
598          return true;
599      return false;
600    }
601
602    public Reference addPartOf() { //3
603      Reference t = new Reference();
604      if (this.partOf == null)
605        this.partOf = new ArrayList<Reference>();
606      this.partOf.add(t);
607      return t;
608    }
609
610    public MedicationUsage addPartOf(Reference t) { //3
611      if (t == null)
612        return this;
613      if (this.partOf == null)
614        this.partOf = new ArrayList<Reference>();
615      this.partOf.add(t);
616      return this;
617    }
618
619    /**
620     * @return The first repetition of repeating field {@link #partOf}, creating it if it does not already exist {3}
621     */
622    public Reference getPartOfFirstRep() { 
623      if (getPartOf().isEmpty()) {
624        addPartOf();
625      }
626      return getPartOf().get(0);
627    }
628
629    /**
630     * @return {@link #status} (A code representing the status of recording the medication usage.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
631     */
632    public Enumeration<MedicationUsageStatusCodes> getStatusElement() { 
633      if (this.status == null)
634        if (Configuration.errorOnAutoCreate())
635          throw new Error("Attempt to auto-create MedicationUsage.status");
636        else if (Configuration.doAutoCreate())
637          this.status = new Enumeration<MedicationUsageStatusCodes>(new MedicationUsageStatusCodesEnumFactory()); // bb
638      return this.status;
639    }
640
641    public boolean hasStatusElement() { 
642      return this.status != null && !this.status.isEmpty();
643    }
644
645    public boolean hasStatus() { 
646      return this.status != null && !this.status.isEmpty();
647    }
648
649    /**
650     * @param value {@link #status} (A code representing the status of recording the medication usage.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
651     */
652    public MedicationUsage setStatusElement(Enumeration<MedicationUsageStatusCodes> value) { 
653      this.status = value;
654      return this;
655    }
656
657    /**
658     * @return A code representing the status of recording the medication usage.
659     */
660    public MedicationUsageStatusCodes getStatus() { 
661      return this.status == null ? null : this.status.getValue();
662    }
663
664    /**
665     * @param value A code representing the status of recording the medication usage.
666     */
667    public MedicationUsage setStatus(MedicationUsageStatusCodes value) { 
668        if (this.status == null)
669          this.status = new Enumeration<MedicationUsageStatusCodes>(new MedicationUsageStatusCodesEnumFactory());
670        this.status.setValue(value);
671      return this;
672    }
673
674    /**
675     * @return {@link #category} (Type of medication usage (for example, drug classification like ATC, where meds would be administered, legal category of the medication.).)
676     */
677    public List<CodeableConcept> getCategory() { 
678      if (this.category == null)
679        this.category = new ArrayList<CodeableConcept>();
680      return this.category;
681    }
682
683    /**
684     * @return Returns a reference to <code>this</code> for easy method chaining
685     */
686    public MedicationUsage setCategory(List<CodeableConcept> theCategory) { 
687      this.category = theCategory;
688      return this;
689    }
690
691    public boolean hasCategory() { 
692      if (this.category == null)
693        return false;
694      for (CodeableConcept item : this.category)
695        if (!item.isEmpty())
696          return true;
697      return false;
698    }
699
700    public CodeableConcept addCategory() { //3
701      CodeableConcept t = new CodeableConcept();
702      if (this.category == null)
703        this.category = new ArrayList<CodeableConcept>();
704      this.category.add(t);
705      return t;
706    }
707
708    public MedicationUsage addCategory(CodeableConcept t) { //3
709      if (t == null)
710        return this;
711      if (this.category == null)
712        this.category = new ArrayList<CodeableConcept>();
713      this.category.add(t);
714      return this;
715    }
716
717    /**
718     * @return The first repetition of repeating field {@link #category}, creating it if it does not already exist {3}
719     */
720    public CodeableConcept getCategoryFirstRep() { 
721      if (getCategory().isEmpty()) {
722        addCategory();
723      }
724      return getCategory().get(0);
725    }
726
727    /**
728     * @return {@link #medication} (Identifies the medication being 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.)
729     */
730    public CodeableReference getMedication() { 
731      if (this.medication == null)
732        if (Configuration.errorOnAutoCreate())
733          throw new Error("Attempt to auto-create MedicationUsage.medication");
734        else if (Configuration.doAutoCreate())
735          this.medication = new CodeableReference(); // cc
736      return this.medication;
737    }
738
739    public boolean hasMedication() { 
740      return this.medication != null && !this.medication.isEmpty();
741    }
742
743    /**
744     * @param value {@link #medication} (Identifies the medication being 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.)
745     */
746    public MedicationUsage setMedication(CodeableReference value) { 
747      this.medication = value;
748      return this;
749    }
750
751    /**
752     * @return {@link #subject} (The person, animal or group who is/was taking the medication.)
753     */
754    public Reference getSubject() { 
755      if (this.subject == null)
756        if (Configuration.errorOnAutoCreate())
757          throw new Error("Attempt to auto-create MedicationUsage.subject");
758        else if (Configuration.doAutoCreate())
759          this.subject = new Reference(); // cc
760      return this.subject;
761    }
762
763    public boolean hasSubject() { 
764      return this.subject != null && !this.subject.isEmpty();
765    }
766
767    /**
768     * @param value {@link #subject} (The person, animal or group who is/was taking the medication.)
769     */
770    public MedicationUsage setSubject(Reference value) { 
771      this.subject = value;
772      return this;
773    }
774
775    /**
776     * @return {@link #encounter} (The encounter that establishes the context for this MedicationUsage.)
777     */
778    public Reference getEncounter() { 
779      if (this.encounter == null)
780        if (Configuration.errorOnAutoCreate())
781          throw new Error("Attempt to auto-create MedicationUsage.encounter");
782        else if (Configuration.doAutoCreate())
783          this.encounter = new Reference(); // cc
784      return this.encounter;
785    }
786
787    public boolean hasEncounter() { 
788      return this.encounter != null && !this.encounter.isEmpty();
789    }
790
791    /**
792     * @param value {@link #encounter} (The encounter that establishes the context for this MedicationUsage.)
793     */
794    public MedicationUsage setEncounter(Reference value) { 
795      this.encounter = value;
796      return this;
797    }
798
799    /**
800     * @return {@link #effective} (The interval of time during which it is being asserted that the patient is/was/will be taking the medication (or was not taking, when the MedicationUsage.adherence element is Not Taking).)
801     */
802    public DataType getEffective() { 
803      return this.effective;
804    }
805
806    /**
807     * @return {@link #effective} (The interval of time during which it is being asserted that the patient is/was/will be taking the medication (or was not taking, when the MedicationUsage.adherence element is Not Taking).)
808     */
809    public DateTimeType getEffectiveDateTimeType() throws FHIRException { 
810      if (this.effective == null)
811        this.effective = new DateTimeType();
812      if (!(this.effective instanceof DateTimeType))
813        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.effective.getClass().getName()+" was encountered");
814      return (DateTimeType) this.effective;
815    }
816
817    public boolean hasEffectiveDateTimeType() { 
818      return this != null && this.effective instanceof DateTimeType;
819    }
820
821    /**
822     * @return {@link #effective} (The interval of time during which it is being asserted that the patient is/was/will be taking the medication (or was not taking, when the MedicationUsage.adherence element is Not Taking).)
823     */
824    public Period getEffectivePeriod() throws FHIRException { 
825      if (this.effective == null)
826        this.effective = new Period();
827      if (!(this.effective instanceof Period))
828        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.effective.getClass().getName()+" was encountered");
829      return (Period) this.effective;
830    }
831
832    public boolean hasEffectivePeriod() { 
833      return this != null && this.effective instanceof Period;
834    }
835
836    public boolean hasEffective() { 
837      return this.effective != null && !this.effective.isEmpty();
838    }
839
840    /**
841     * @param value {@link #effective} (The interval of time during which it is being asserted that the patient is/was/will be taking the medication (or was not taking, when the MedicationUsage.adherence element is Not Taking).)
842     */
843    public MedicationUsage setEffective(DataType value) { 
844      if (value != null && !(value instanceof DateTimeType || value instanceof Period))
845        throw new Error("Not the right type for MedicationUsage.effective[x]: "+value.fhirType());
846      this.effective = value;
847      return this;
848    }
849
850    /**
851     * @return {@link #dateAsserted} (The date when the Medication Usage was asserted by the information source.). This is the underlying object with id, value and extensions. The accessor "getDateAsserted" gives direct access to the value
852     */
853    public DateTimeType getDateAssertedElement() { 
854      if (this.dateAsserted == null)
855        if (Configuration.errorOnAutoCreate())
856          throw new Error("Attempt to auto-create MedicationUsage.dateAsserted");
857        else if (Configuration.doAutoCreate())
858          this.dateAsserted = new DateTimeType(); // bb
859      return this.dateAsserted;
860    }
861
862    public boolean hasDateAssertedElement() { 
863      return this.dateAsserted != null && !this.dateAsserted.isEmpty();
864    }
865
866    public boolean hasDateAsserted() { 
867      return this.dateAsserted != null && !this.dateAsserted.isEmpty();
868    }
869
870    /**
871     * @param value {@link #dateAsserted} (The date when the Medication Usage was asserted by the information source.). This is the underlying object with id, value and extensions. The accessor "getDateAsserted" gives direct access to the value
872     */
873    public MedicationUsage setDateAssertedElement(DateTimeType value) { 
874      this.dateAsserted = value;
875      return this;
876    }
877
878    /**
879     * @return The date when the Medication Usage was asserted by the information source.
880     */
881    public Date getDateAsserted() { 
882      return this.dateAsserted == null ? null : this.dateAsserted.getValue();
883    }
884
885    /**
886     * @param value The date when the Medication Usage was asserted by the information source.
887     */
888    public MedicationUsage setDateAsserted(Date value) { 
889      if (value == null)
890        this.dateAsserted = null;
891      else {
892        if (this.dateAsserted == null)
893          this.dateAsserted = new DateTimeType();
894        this.dateAsserted.setValue(value);
895      }
896      return this;
897    }
898
899    /**
900     * @return {@link #informationSource} (The person or organization that provided the information about the taking of this medication. Note: Use derivedFrom when a MedicationUsage is derived from other resources, e.g. Claim or MedicationRequest.)
901     */
902    public List<Reference> getInformationSource() { 
903      if (this.informationSource == null)
904        this.informationSource = new ArrayList<Reference>();
905      return this.informationSource;
906    }
907
908    /**
909     * @return Returns a reference to <code>this</code> for easy method chaining
910     */
911    public MedicationUsage setInformationSource(List<Reference> theInformationSource) { 
912      this.informationSource = theInformationSource;
913      return this;
914    }
915
916    public boolean hasInformationSource() { 
917      if (this.informationSource == null)
918        return false;
919      for (Reference item : this.informationSource)
920        if (!item.isEmpty())
921          return true;
922      return false;
923    }
924
925    public Reference addInformationSource() { //3
926      Reference t = new Reference();
927      if (this.informationSource == null)
928        this.informationSource = new ArrayList<Reference>();
929      this.informationSource.add(t);
930      return t;
931    }
932
933    public MedicationUsage addInformationSource(Reference t) { //3
934      if (t == null)
935        return this;
936      if (this.informationSource == null)
937        this.informationSource = new ArrayList<Reference>();
938      this.informationSource.add(t);
939      return this;
940    }
941
942    /**
943     * @return The first repetition of repeating field {@link #informationSource}, creating it if it does not already exist {3}
944     */
945    public Reference getInformationSourceFirstRep() { 
946      if (getInformationSource().isEmpty()) {
947        addInformationSource();
948      }
949      return getInformationSource().get(0);
950    }
951
952    /**
953     * @return {@link #derivedFrom} (Allows linking the MedicationUsage to the underlying MedicationRequest, or to other information that supports or is used to derive the MedicationUsage.)
954     */
955    public List<Reference> getDerivedFrom() { 
956      if (this.derivedFrom == null)
957        this.derivedFrom = new ArrayList<Reference>();
958      return this.derivedFrom;
959    }
960
961    /**
962     * @return Returns a reference to <code>this</code> for easy method chaining
963     */
964    public MedicationUsage setDerivedFrom(List<Reference> theDerivedFrom) { 
965      this.derivedFrom = theDerivedFrom;
966      return this;
967    }
968
969    public boolean hasDerivedFrom() { 
970      if (this.derivedFrom == null)
971        return false;
972      for (Reference item : this.derivedFrom)
973        if (!item.isEmpty())
974          return true;
975      return false;
976    }
977
978    public Reference addDerivedFrom() { //3
979      Reference t = new Reference();
980      if (this.derivedFrom == null)
981        this.derivedFrom = new ArrayList<Reference>();
982      this.derivedFrom.add(t);
983      return t;
984    }
985
986    public MedicationUsage addDerivedFrom(Reference t) { //3
987      if (t == null)
988        return this;
989      if (this.derivedFrom == null)
990        this.derivedFrom = new ArrayList<Reference>();
991      this.derivedFrom.add(t);
992      return this;
993    }
994
995    /**
996     * @return The first repetition of repeating field {@link #derivedFrom}, creating it if it does not already exist {3}
997     */
998    public Reference getDerivedFromFirstRep() { 
999      if (getDerivedFrom().isEmpty()) {
1000        addDerivedFrom();
1001      }
1002      return getDerivedFrom().get(0);
1003    }
1004
1005    /**
1006     * @return {@link #reason} (A concept, Condition or observation that supports why the medication is being/was taken.)
1007     */
1008    public List<CodeableReference> getReason() { 
1009      if (this.reason == null)
1010        this.reason = new ArrayList<CodeableReference>();
1011      return this.reason;
1012    }
1013
1014    /**
1015     * @return Returns a reference to <code>this</code> for easy method chaining
1016     */
1017    public MedicationUsage setReason(List<CodeableReference> theReason) { 
1018      this.reason = theReason;
1019      return this;
1020    }
1021
1022    public boolean hasReason() { 
1023      if (this.reason == null)
1024        return false;
1025      for (CodeableReference item : this.reason)
1026        if (!item.isEmpty())
1027          return true;
1028      return false;
1029    }
1030
1031    public CodeableReference addReason() { //3
1032      CodeableReference t = new CodeableReference();
1033      if (this.reason == null)
1034        this.reason = new ArrayList<CodeableReference>();
1035      this.reason.add(t);
1036      return t;
1037    }
1038
1039    public MedicationUsage addReason(CodeableReference t) { //3
1040      if (t == null)
1041        return this;
1042      if (this.reason == null)
1043        this.reason = new ArrayList<CodeableReference>();
1044      this.reason.add(t);
1045      return this;
1046    }
1047
1048    /**
1049     * @return The first repetition of repeating field {@link #reason}, creating it if it does not already exist {3}
1050     */
1051    public CodeableReference getReasonFirstRep() { 
1052      if (getReason().isEmpty()) {
1053        addReason();
1054      }
1055      return getReason().get(0);
1056    }
1057
1058    /**
1059     * @return {@link #note} (Provides extra information about the Medication Usage that is not conveyed by the other attributes.)
1060     */
1061    public List<Annotation> getNote() { 
1062      if (this.note == null)
1063        this.note = new ArrayList<Annotation>();
1064      return this.note;
1065    }
1066
1067    /**
1068     * @return Returns a reference to <code>this</code> for easy method chaining
1069     */
1070    public MedicationUsage setNote(List<Annotation> theNote) { 
1071      this.note = theNote;
1072      return this;
1073    }
1074
1075    public boolean hasNote() { 
1076      if (this.note == null)
1077        return false;
1078      for (Annotation item : this.note)
1079        if (!item.isEmpty())
1080          return true;
1081      return false;
1082    }
1083
1084    public Annotation addNote() { //3
1085      Annotation t = new Annotation();
1086      if (this.note == null)
1087        this.note = new ArrayList<Annotation>();
1088      this.note.add(t);
1089      return t;
1090    }
1091
1092    public MedicationUsage addNote(Annotation t) { //3
1093      if (t == null)
1094        return this;
1095      if (this.note == null)
1096        this.note = new ArrayList<Annotation>();
1097      this.note.add(t);
1098      return this;
1099    }
1100
1101    /**
1102     * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist {3}
1103     */
1104    public Annotation getNoteFirstRep() { 
1105      if (getNote().isEmpty()) {
1106        addNote();
1107      }
1108      return getNote().get(0);
1109    }
1110
1111    /**
1112     * @return {@link #relatedClinicalInformation} (Link to information that is relevant to a medication usage, for example, illicit drug use, gestational age, etc.)
1113     */
1114    public List<Reference> getRelatedClinicalInformation() { 
1115      if (this.relatedClinicalInformation == null)
1116        this.relatedClinicalInformation = new ArrayList<Reference>();
1117      return this.relatedClinicalInformation;
1118    }
1119
1120    /**
1121     * @return Returns a reference to <code>this</code> for easy method chaining
1122     */
1123    public MedicationUsage setRelatedClinicalInformation(List<Reference> theRelatedClinicalInformation) { 
1124      this.relatedClinicalInformation = theRelatedClinicalInformation;
1125      return this;
1126    }
1127
1128    public boolean hasRelatedClinicalInformation() { 
1129      if (this.relatedClinicalInformation == null)
1130        return false;
1131      for (Reference item : this.relatedClinicalInformation)
1132        if (!item.isEmpty())
1133          return true;
1134      return false;
1135    }
1136
1137    public Reference addRelatedClinicalInformation() { //3
1138      Reference t = new Reference();
1139      if (this.relatedClinicalInformation == null)
1140        this.relatedClinicalInformation = new ArrayList<Reference>();
1141      this.relatedClinicalInformation.add(t);
1142      return t;
1143    }
1144
1145    public MedicationUsage addRelatedClinicalInformation(Reference t) { //3
1146      if (t == null)
1147        return this;
1148      if (this.relatedClinicalInformation == null)
1149        this.relatedClinicalInformation = new ArrayList<Reference>();
1150      this.relatedClinicalInformation.add(t);
1151      return this;
1152    }
1153
1154    /**
1155     * @return The first repetition of repeating field {@link #relatedClinicalInformation}, creating it if it does not already exist {3}
1156     */
1157    public Reference getRelatedClinicalInformationFirstRep() { 
1158      if (getRelatedClinicalInformation().isEmpty()) {
1159        addRelatedClinicalInformation();
1160      }
1161      return getRelatedClinicalInformation().get(0);
1162    }
1163
1164    /**
1165     * @return {@link #renderedDosageInstruction} (The full representation of the dose of the medication included in all dosage instructions.  To be used when multiple dosage instructions are included to represent complex dosing such as increasing or tapering doses.). This is the underlying object with id, value and extensions. The accessor "getRenderedDosageInstruction" gives direct access to the value
1166     */
1167    public StringType getRenderedDosageInstructionElement() { 
1168      if (this.renderedDosageInstruction == null)
1169        if (Configuration.errorOnAutoCreate())
1170          throw new Error("Attempt to auto-create MedicationUsage.renderedDosageInstruction");
1171        else if (Configuration.doAutoCreate())
1172          this.renderedDosageInstruction = new StringType(); // bb
1173      return this.renderedDosageInstruction;
1174    }
1175
1176    public boolean hasRenderedDosageInstructionElement() { 
1177      return this.renderedDosageInstruction != null && !this.renderedDosageInstruction.isEmpty();
1178    }
1179
1180    public boolean hasRenderedDosageInstruction() { 
1181      return this.renderedDosageInstruction != null && !this.renderedDosageInstruction.isEmpty();
1182    }
1183
1184    /**
1185     * @param value {@link #renderedDosageInstruction} (The full representation of the dose of the medication included in all dosage instructions.  To be used when multiple dosage instructions are included to represent complex dosing such as increasing or tapering doses.). This is the underlying object with id, value and extensions. The accessor "getRenderedDosageInstruction" gives direct access to the value
1186     */
1187    public MedicationUsage setRenderedDosageInstructionElement(StringType value) { 
1188      this.renderedDosageInstruction = value;
1189      return this;
1190    }
1191
1192    /**
1193     * @return The full representation of the dose of the medication included in all dosage instructions.  To be used when multiple dosage instructions are included to represent complex dosing such as increasing or tapering doses.
1194     */
1195    public String getRenderedDosageInstruction() { 
1196      return this.renderedDosageInstruction == null ? null : this.renderedDosageInstruction.getValue();
1197    }
1198
1199    /**
1200     * @param value The full representation of the dose of the medication included in all dosage instructions.  To be used when multiple dosage instructions are included to represent complex dosing such as increasing or tapering doses.
1201     */
1202    public MedicationUsage setRenderedDosageInstruction(String value) { 
1203      if (Utilities.noString(value))
1204        this.renderedDosageInstruction = null;
1205      else {
1206        if (this.renderedDosageInstruction == null)
1207          this.renderedDosageInstruction = new StringType();
1208        this.renderedDosageInstruction.setValue(value);
1209      }
1210      return this;
1211    }
1212
1213    /**
1214     * @return {@link #dosage} (Indicates how the medication is/was or should be taken by the patient.)
1215     */
1216    public List<Dosage> getDosage() { 
1217      if (this.dosage == null)
1218        this.dosage = new ArrayList<Dosage>();
1219      return this.dosage;
1220    }
1221
1222    /**
1223     * @return Returns a reference to <code>this</code> for easy method chaining
1224     */
1225    public MedicationUsage setDosage(List<Dosage> theDosage) { 
1226      this.dosage = theDosage;
1227      return this;
1228    }
1229
1230    public boolean hasDosage() { 
1231      if (this.dosage == null)
1232        return false;
1233      for (Dosage item : this.dosage)
1234        if (!item.isEmpty())
1235          return true;
1236      return false;
1237    }
1238
1239    public Dosage addDosage() { //3
1240      Dosage t = new Dosage();
1241      if (this.dosage == null)
1242        this.dosage = new ArrayList<Dosage>();
1243      this.dosage.add(t);
1244      return t;
1245    }
1246
1247    public MedicationUsage addDosage(Dosage t) { //3
1248      if (t == null)
1249        return this;
1250      if (this.dosage == null)
1251        this.dosage = new ArrayList<Dosage>();
1252      this.dosage.add(t);
1253      return this;
1254    }
1255
1256    /**
1257     * @return The first repetition of repeating field {@link #dosage}, creating it if it does not already exist {3}
1258     */
1259    public Dosage getDosageFirstRep() { 
1260      if (getDosage().isEmpty()) {
1261        addDosage();
1262      }
1263      return getDosage().get(0);
1264    }
1265
1266    /**
1267     * @return {@link #adherence} (Indicates if the medication is being consumed or administered as instructed.)
1268     */
1269    public MedicationUsageAdherenceComponent getAdherence() { 
1270      if (this.adherence == null)
1271        if (Configuration.errorOnAutoCreate())
1272          throw new Error("Attempt to auto-create MedicationUsage.adherence");
1273        else if (Configuration.doAutoCreate())
1274          this.adherence = new MedicationUsageAdherenceComponent(); // cc
1275      return this.adherence;
1276    }
1277
1278    public boolean hasAdherence() { 
1279      return this.adherence != null && !this.adherence.isEmpty();
1280    }
1281
1282    /**
1283     * @param value {@link #adherence} (Indicates if the medication is being consumed or administered as instructed.)
1284     */
1285    public MedicationUsage setAdherence(MedicationUsageAdherenceComponent value) { 
1286      this.adherence = value;
1287      return this;
1288    }
1289
1290      protected void listChildren(List<Property> children) {
1291        super.listChildren(children);
1292        children.add(new Property("identifier", "Identifier", "Identifiers associated with this Medication Usage that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate. They are business identifiers assigned to this resource by the performer or other systems and remain constant as the resource is updated and propagates from server to server.", 0, java.lang.Integer.MAX_VALUE, identifier));
1293        children.add(new Property("partOf", "Reference(Procedure)", "A larger event of which this particular MedicationUsage is a component or step.", 0, java.lang.Integer.MAX_VALUE, partOf));
1294        children.add(new Property("status", "code", "A code representing the status of recording the medication usage.", 0, 1, status));
1295        children.add(new Property("category", "CodeableConcept", "Type of medication usage (for example, drug classification like ATC, where meds would be administered, legal category of the medication.).", 0, java.lang.Integer.MAX_VALUE, category));
1296        children.add(new Property("medication", "CodeableReference(Medication)", "Identifies the medication being administered. This is either a link to a resource representing the details of the medication or a simple attribute carrying a code that identifies the medication from a known list of medications.", 0, 1, medication));
1297        children.add(new Property("subject", "Reference(Patient|Group)", "The person, animal or group who is/was taking the medication.", 0, 1, subject));
1298        children.add(new Property("encounter", "Reference(Encounter)", "The encounter that establishes the context for this MedicationUsage.", 0, 1, encounter));
1299        children.add(new Property("effective[x]", "dateTime|Period", "The interval of time during which it is being asserted that the patient is/was/will be taking the medication (or was not taking, when the MedicationUsage.adherence element is Not Taking).", 0, 1, effective));
1300        children.add(new Property("dateAsserted", "dateTime", "The date when the Medication Usage was asserted by the information source.", 0, 1, dateAsserted));
1301        children.add(new Property("informationSource", "Reference(Patient|Practitioner|PractitionerRole|RelatedPerson|Organization)", "The person or organization that provided the information about the taking of this medication. Note: Use derivedFrom when a MedicationUsage is derived from other resources, e.g. Claim or MedicationRequest.", 0, java.lang.Integer.MAX_VALUE, informationSource));
1302        children.add(new Property("derivedFrom", "Reference(Any)", "Allows linking the MedicationUsage to the underlying MedicationRequest, or to other information that supports or is used to derive the MedicationUsage.", 0, java.lang.Integer.MAX_VALUE, derivedFrom));
1303        children.add(new Property("reason", "CodeableReference(Condition|Observation|DiagnosticReport)", "A concept, Condition or observation that supports why the medication is being/was taken.", 0, java.lang.Integer.MAX_VALUE, reason));
1304        children.add(new Property("note", "Annotation", "Provides extra information about the Medication Usage that is not conveyed by the other attributes.", 0, java.lang.Integer.MAX_VALUE, note));
1305        children.add(new Property("relatedClinicalInformation", "Reference(Observation|Condition)", "Link to information that is relevant to a medication usage, for example, illicit drug use, gestational age, etc.", 0, java.lang.Integer.MAX_VALUE, relatedClinicalInformation));
1306        children.add(new Property("renderedDosageInstruction", "string", "The full representation of the dose of the medication included in all dosage instructions.  To be used when multiple dosage instructions are included to represent complex dosing such as increasing or tapering doses.", 0, 1, renderedDosageInstruction));
1307        children.add(new Property("dosage", "Dosage", "Indicates how the medication is/was or should be taken by the patient.", 0, java.lang.Integer.MAX_VALUE, dosage));
1308        children.add(new Property("adherence", "", "Indicates if the medication is being consumed or administered as instructed.", 0, 1, adherence));
1309      }
1310
1311      @Override
1312      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1313        switch (_hash) {
1314        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Identifiers associated with this Medication Usage that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate. They are business identifiers assigned to this resource by the performer or other systems and remain constant as the resource is updated and propagates from server to server.", 0, java.lang.Integer.MAX_VALUE, identifier);
1315        case -995410646: /*partOf*/  return new Property("partOf", "Reference(Procedure)", "A larger event of which this particular MedicationUsage is a component or step.", 0, java.lang.Integer.MAX_VALUE, partOf);
1316        case -892481550: /*status*/  return new Property("status", "code", "A code representing the status of recording the medication usage.", 0, 1, status);
1317        case 50511102: /*category*/  return new Property("category", "CodeableConcept", "Type of medication usage (for example, drug classification like ATC, where meds would be administered, legal category of the medication.).", 0, java.lang.Integer.MAX_VALUE, category);
1318        case 1998965455: /*medication*/  return new Property("medication", "CodeableReference(Medication)", "Identifies the medication being administered. This is either a link to a resource representing the details of the medication or a simple attribute carrying a code that identifies the medication from a known list of medications.", 0, 1, medication);
1319        case -1867885268: /*subject*/  return new Property("subject", "Reference(Patient|Group)", "The person, animal or group who is/was taking the medication.", 0, 1, subject);
1320        case 1524132147: /*encounter*/  return new Property("encounter", "Reference(Encounter)", "The encounter that establishes the context for this MedicationUsage.", 0, 1, encounter);
1321        case 247104889: /*effective[x]*/  return new Property("effective[x]", "dateTime|Period", "The interval of time during which it is being asserted that the patient is/was/will be taking the medication (or was not taking, when the MedicationUsage.adherence element is Not Taking).", 0, 1, effective);
1322        case -1468651097: /*effective*/  return new Property("effective[x]", "dateTime|Period", "The interval of time during which it is being asserted that the patient is/was/will be taking the medication (or was not taking, when the MedicationUsage.adherence element is Not Taking).", 0, 1, effective);
1323        case -275306910: /*effectiveDateTime*/  return new Property("effective[x]", "dateTime", "The interval of time during which it is being asserted that the patient is/was/will be taking the medication (or was not taking, when the MedicationUsage.adherence element is Not Taking).", 0, 1, effective);
1324        case -403934648: /*effectivePeriod*/  return new Property("effective[x]", "Period", "The interval of time during which it is being asserted that the patient is/was/will be taking the medication (or was not taking, when the MedicationUsage.adherence element is Not Taking).", 0, 1, effective);
1325        case -1980855245: /*dateAsserted*/  return new Property("dateAsserted", "dateTime", "The date when the Medication Usage was asserted by the information source.", 0, 1, dateAsserted);
1326        case -2123220889: /*informationSource*/  return new Property("informationSource", "Reference(Patient|Practitioner|PractitionerRole|RelatedPerson|Organization)", "The person or organization that provided the information about the taking of this medication. Note: Use derivedFrom when a MedicationUsage is derived from other resources, e.g. Claim or MedicationRequest.", 0, java.lang.Integer.MAX_VALUE, informationSource);
1327        case 1077922663: /*derivedFrom*/  return new Property("derivedFrom", "Reference(Any)", "Allows linking the MedicationUsage to the underlying MedicationRequest, or to other information that supports or is used to derive the MedicationUsage.", 0, java.lang.Integer.MAX_VALUE, derivedFrom);
1328        case -934964668: /*reason*/  return new Property("reason", "CodeableReference(Condition|Observation|DiagnosticReport)", "A concept, Condition or observation that supports why the medication is being/was taken.", 0, java.lang.Integer.MAX_VALUE, reason);
1329        case 3387378: /*note*/  return new Property("note", "Annotation", "Provides extra information about the Medication Usage that is not conveyed by the other attributes.", 0, java.lang.Integer.MAX_VALUE, note);
1330        case 1040787950: /*relatedClinicalInformation*/  return new Property("relatedClinicalInformation", "Reference(Observation|Condition)", "Link to information that is relevant to a medication usage, for example, illicit drug use, gestational age, etc.", 0, java.lang.Integer.MAX_VALUE, relatedClinicalInformation);
1331        case 1718902050: /*renderedDosageInstruction*/  return new Property("renderedDosageInstruction", "string", "The full representation of the dose of the medication included in all dosage instructions.  To be used when multiple dosage instructions are included to represent complex dosing such as increasing or tapering doses.", 0, 1, renderedDosageInstruction);
1332        case -1326018889: /*dosage*/  return new Property("dosage", "Dosage", "Indicates how the medication is/was or should be taken by the patient.", 0, java.lang.Integer.MAX_VALUE, dosage);
1333        case -231003683: /*adherence*/  return new Property("adherence", "", "Indicates if the medication is being consumed or administered as instructed.", 0, 1, adherence);
1334        default: return super.getNamedProperty(_hash, _name, _checkValid);
1335        }
1336
1337      }
1338
1339      @Override
1340      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1341        switch (hash) {
1342        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1343        case -995410646: /*partOf*/ return this.partOf == null ? new Base[0] : this.partOf.toArray(new Base[this.partOf.size()]); // Reference
1344        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<MedicationUsageStatusCodes>
1345        case 50511102: /*category*/ return this.category == null ? new Base[0] : this.category.toArray(new Base[this.category.size()]); // CodeableConcept
1346        case 1998965455: /*medication*/ return this.medication == null ? new Base[0] : new Base[] {this.medication}; // CodeableReference
1347        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
1348        case 1524132147: /*encounter*/ return this.encounter == null ? new Base[0] : new Base[] {this.encounter}; // Reference
1349        case -1468651097: /*effective*/ return this.effective == null ? new Base[0] : new Base[] {this.effective}; // DataType
1350        case -1980855245: /*dateAsserted*/ return this.dateAsserted == null ? new Base[0] : new Base[] {this.dateAsserted}; // DateTimeType
1351        case -2123220889: /*informationSource*/ return this.informationSource == null ? new Base[0] : this.informationSource.toArray(new Base[this.informationSource.size()]); // Reference
1352        case 1077922663: /*derivedFrom*/ return this.derivedFrom == null ? new Base[0] : this.derivedFrom.toArray(new Base[this.derivedFrom.size()]); // Reference
1353        case -934964668: /*reason*/ return this.reason == null ? new Base[0] : this.reason.toArray(new Base[this.reason.size()]); // CodeableReference
1354        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
1355        case 1040787950: /*relatedClinicalInformation*/ return this.relatedClinicalInformation == null ? new Base[0] : this.relatedClinicalInformation.toArray(new Base[this.relatedClinicalInformation.size()]); // Reference
1356        case 1718902050: /*renderedDosageInstruction*/ return this.renderedDosageInstruction == null ? new Base[0] : new Base[] {this.renderedDosageInstruction}; // StringType
1357        case -1326018889: /*dosage*/ return this.dosage == null ? new Base[0] : this.dosage.toArray(new Base[this.dosage.size()]); // Dosage
1358        case -231003683: /*adherence*/ return this.adherence == null ? new Base[0] : new Base[] {this.adherence}; // MedicationUsageAdherenceComponent
1359        default: return super.getProperty(hash, name, checkValid);
1360        }
1361
1362      }
1363
1364      @Override
1365      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1366        switch (hash) {
1367        case -1618432855: // identifier
1368          this.getIdentifier().add(TypeConvertor.castToIdentifier(value)); // Identifier
1369          return value;
1370        case -995410646: // partOf
1371          this.getPartOf().add(TypeConvertor.castToReference(value)); // Reference
1372          return value;
1373        case -892481550: // status
1374          value = new MedicationUsageStatusCodesEnumFactory().fromType(TypeConvertor.castToCode(value));
1375          this.status = (Enumeration) value; // Enumeration<MedicationUsageStatusCodes>
1376          return value;
1377        case 50511102: // category
1378          this.getCategory().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
1379          return value;
1380        case 1998965455: // medication
1381          this.medication = TypeConvertor.castToCodeableReference(value); // CodeableReference
1382          return value;
1383        case -1867885268: // subject
1384          this.subject = TypeConvertor.castToReference(value); // Reference
1385          return value;
1386        case 1524132147: // encounter
1387          this.encounter = TypeConvertor.castToReference(value); // Reference
1388          return value;
1389        case -1468651097: // effective
1390          this.effective = TypeConvertor.castToType(value); // DataType
1391          return value;
1392        case -1980855245: // dateAsserted
1393          this.dateAsserted = TypeConvertor.castToDateTime(value); // DateTimeType
1394          return value;
1395        case -2123220889: // informationSource
1396          this.getInformationSource().add(TypeConvertor.castToReference(value)); // Reference
1397          return value;
1398        case 1077922663: // derivedFrom
1399          this.getDerivedFrom().add(TypeConvertor.castToReference(value)); // Reference
1400          return value;
1401        case -934964668: // reason
1402          this.getReason().add(TypeConvertor.castToCodeableReference(value)); // CodeableReference
1403          return value;
1404        case 3387378: // note
1405          this.getNote().add(TypeConvertor.castToAnnotation(value)); // Annotation
1406          return value;
1407        case 1040787950: // relatedClinicalInformation
1408          this.getRelatedClinicalInformation().add(TypeConvertor.castToReference(value)); // Reference
1409          return value;
1410        case 1718902050: // renderedDosageInstruction
1411          this.renderedDosageInstruction = TypeConvertor.castToString(value); // StringType
1412          return value;
1413        case -1326018889: // dosage
1414          this.getDosage().add(TypeConvertor.castToDosage(value)); // Dosage
1415          return value;
1416        case -231003683: // adherence
1417          this.adherence = (MedicationUsageAdherenceComponent) value; // MedicationUsageAdherenceComponent
1418          return value;
1419        default: return super.setProperty(hash, name, value);
1420        }
1421
1422      }
1423
1424      @Override
1425      public Base setProperty(String name, Base value) throws FHIRException {
1426        if (name.equals("identifier")) {
1427          this.getIdentifier().add(TypeConvertor.castToIdentifier(value));
1428        } else if (name.equals("partOf")) {
1429          this.getPartOf().add(TypeConvertor.castToReference(value));
1430        } else if (name.equals("status")) {
1431          value = new MedicationUsageStatusCodesEnumFactory().fromType(TypeConvertor.castToCode(value));
1432          this.status = (Enumeration) value; // Enumeration<MedicationUsageStatusCodes>
1433        } else if (name.equals("category")) {
1434          this.getCategory().add(TypeConvertor.castToCodeableConcept(value));
1435        } else if (name.equals("medication")) {
1436          this.medication = TypeConvertor.castToCodeableReference(value); // CodeableReference
1437        } else if (name.equals("subject")) {
1438          this.subject = TypeConvertor.castToReference(value); // Reference
1439        } else if (name.equals("encounter")) {
1440          this.encounter = TypeConvertor.castToReference(value); // Reference
1441        } else if (name.equals("effective[x]")) {
1442          this.effective = TypeConvertor.castToType(value); // DataType
1443        } else if (name.equals("dateAsserted")) {
1444          this.dateAsserted = TypeConvertor.castToDateTime(value); // DateTimeType
1445        } else if (name.equals("informationSource")) {
1446          this.getInformationSource().add(TypeConvertor.castToReference(value));
1447        } else if (name.equals("derivedFrom")) {
1448          this.getDerivedFrom().add(TypeConvertor.castToReference(value));
1449        } else if (name.equals("reason")) {
1450          this.getReason().add(TypeConvertor.castToCodeableReference(value));
1451        } else if (name.equals("note")) {
1452          this.getNote().add(TypeConvertor.castToAnnotation(value));
1453        } else if (name.equals("relatedClinicalInformation")) {
1454          this.getRelatedClinicalInformation().add(TypeConvertor.castToReference(value));
1455        } else if (name.equals("renderedDosageInstruction")) {
1456          this.renderedDosageInstruction = TypeConvertor.castToString(value); // StringType
1457        } else if (name.equals("dosage")) {
1458          this.getDosage().add(TypeConvertor.castToDosage(value));
1459        } else if (name.equals("adherence")) {
1460          this.adherence = (MedicationUsageAdherenceComponent) value; // MedicationUsageAdherenceComponent
1461        } else
1462          return super.setProperty(name, value);
1463        return value;
1464      }
1465
1466      @Override
1467      public Base makeProperty(int hash, String name) throws FHIRException {
1468        switch (hash) {
1469        case -1618432855:  return addIdentifier(); 
1470        case -995410646:  return addPartOf(); 
1471        case -892481550:  return getStatusElement();
1472        case 50511102:  return addCategory(); 
1473        case 1998965455:  return getMedication();
1474        case -1867885268:  return getSubject();
1475        case 1524132147:  return getEncounter();
1476        case 247104889:  return getEffective();
1477        case -1468651097:  return getEffective();
1478        case -1980855245:  return getDateAssertedElement();
1479        case -2123220889:  return addInformationSource(); 
1480        case 1077922663:  return addDerivedFrom(); 
1481        case -934964668:  return addReason(); 
1482        case 3387378:  return addNote(); 
1483        case 1040787950:  return addRelatedClinicalInformation(); 
1484        case 1718902050:  return getRenderedDosageInstructionElement();
1485        case -1326018889:  return addDosage(); 
1486        case -231003683:  return getAdherence();
1487        default: return super.makeProperty(hash, name);
1488        }
1489
1490      }
1491
1492      @Override
1493      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1494        switch (hash) {
1495        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
1496        case -995410646: /*partOf*/ return new String[] {"Reference"};
1497        case -892481550: /*status*/ return new String[] {"code"};
1498        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
1499        case 1998965455: /*medication*/ return new String[] {"CodeableReference"};
1500        case -1867885268: /*subject*/ return new String[] {"Reference"};
1501        case 1524132147: /*encounter*/ return new String[] {"Reference"};
1502        case -1468651097: /*effective*/ return new String[] {"dateTime", "Period"};
1503        case -1980855245: /*dateAsserted*/ return new String[] {"dateTime"};
1504        case -2123220889: /*informationSource*/ return new String[] {"Reference"};
1505        case 1077922663: /*derivedFrom*/ return new String[] {"Reference"};
1506        case -934964668: /*reason*/ return new String[] {"CodeableReference"};
1507        case 3387378: /*note*/ return new String[] {"Annotation"};
1508        case 1040787950: /*relatedClinicalInformation*/ return new String[] {"Reference"};
1509        case 1718902050: /*renderedDosageInstruction*/ return new String[] {"string"};
1510        case -1326018889: /*dosage*/ return new String[] {"Dosage"};
1511        case -231003683: /*adherence*/ return new String[] {};
1512        default: return super.getTypesForProperty(hash, name);
1513        }
1514
1515      }
1516
1517      @Override
1518      public Base addChild(String name) throws FHIRException {
1519        if (name.equals("identifier")) {
1520          return addIdentifier();
1521        }
1522        else if (name.equals("partOf")) {
1523          return addPartOf();
1524        }
1525        else if (name.equals("status")) {
1526          throw new FHIRException("Cannot call addChild on a primitive type MedicationUsage.status");
1527        }
1528        else if (name.equals("category")) {
1529          return addCategory();
1530        }
1531        else if (name.equals("medication")) {
1532          this.medication = new CodeableReference();
1533          return this.medication;
1534        }
1535        else if (name.equals("subject")) {
1536          this.subject = new Reference();
1537          return this.subject;
1538        }
1539        else if (name.equals("encounter")) {
1540          this.encounter = new Reference();
1541          return this.encounter;
1542        }
1543        else if (name.equals("effectiveDateTime")) {
1544          this.effective = new DateTimeType();
1545          return this.effective;
1546        }
1547        else if (name.equals("effectivePeriod")) {
1548          this.effective = new Period();
1549          return this.effective;
1550        }
1551        else if (name.equals("dateAsserted")) {
1552          throw new FHIRException("Cannot call addChild on a primitive type MedicationUsage.dateAsserted");
1553        }
1554        else if (name.equals("informationSource")) {
1555          return addInformationSource();
1556        }
1557        else if (name.equals("derivedFrom")) {
1558          return addDerivedFrom();
1559        }
1560        else if (name.equals("reason")) {
1561          return addReason();
1562        }
1563        else if (name.equals("note")) {
1564          return addNote();
1565        }
1566        else if (name.equals("relatedClinicalInformation")) {
1567          return addRelatedClinicalInformation();
1568        }
1569        else if (name.equals("renderedDosageInstruction")) {
1570          throw new FHIRException("Cannot call addChild on a primitive type MedicationUsage.renderedDosageInstruction");
1571        }
1572        else if (name.equals("dosage")) {
1573          return addDosage();
1574        }
1575        else if (name.equals("adherence")) {
1576          this.adherence = new MedicationUsageAdherenceComponent();
1577          return this.adherence;
1578        }
1579        else
1580          return super.addChild(name);
1581      }
1582
1583  public String fhirType() {
1584    return "MedicationUsage";
1585
1586  }
1587
1588      public MedicationUsage copy() {
1589        MedicationUsage dst = new MedicationUsage();
1590        copyValues(dst);
1591        return dst;
1592      }
1593
1594      public void copyValues(MedicationUsage dst) {
1595        super.copyValues(dst);
1596        if (identifier != null) {
1597          dst.identifier = new ArrayList<Identifier>();
1598          for (Identifier i : identifier)
1599            dst.identifier.add(i.copy());
1600        };
1601        if (partOf != null) {
1602          dst.partOf = new ArrayList<Reference>();
1603          for (Reference i : partOf)
1604            dst.partOf.add(i.copy());
1605        };
1606        dst.status = status == null ? null : status.copy();
1607        if (category != null) {
1608          dst.category = new ArrayList<CodeableConcept>();
1609          for (CodeableConcept i : category)
1610            dst.category.add(i.copy());
1611        };
1612        dst.medication = medication == null ? null : medication.copy();
1613        dst.subject = subject == null ? null : subject.copy();
1614        dst.encounter = encounter == null ? null : encounter.copy();
1615        dst.effective = effective == null ? null : effective.copy();
1616        dst.dateAsserted = dateAsserted == null ? null : dateAsserted.copy();
1617        if (informationSource != null) {
1618          dst.informationSource = new ArrayList<Reference>();
1619          for (Reference i : informationSource)
1620            dst.informationSource.add(i.copy());
1621        };
1622        if (derivedFrom != null) {
1623          dst.derivedFrom = new ArrayList<Reference>();
1624          for (Reference i : derivedFrom)
1625            dst.derivedFrom.add(i.copy());
1626        };
1627        if (reason != null) {
1628          dst.reason = new ArrayList<CodeableReference>();
1629          for (CodeableReference i : reason)
1630            dst.reason.add(i.copy());
1631        };
1632        if (note != null) {
1633          dst.note = new ArrayList<Annotation>();
1634          for (Annotation i : note)
1635            dst.note.add(i.copy());
1636        };
1637        if (relatedClinicalInformation != null) {
1638          dst.relatedClinicalInformation = new ArrayList<Reference>();
1639          for (Reference i : relatedClinicalInformation)
1640            dst.relatedClinicalInformation.add(i.copy());
1641        };
1642        dst.renderedDosageInstruction = renderedDosageInstruction == null ? null : renderedDosageInstruction.copy();
1643        if (dosage != null) {
1644          dst.dosage = new ArrayList<Dosage>();
1645          for (Dosage i : dosage)
1646            dst.dosage.add(i.copy());
1647        };
1648        dst.adherence = adherence == null ? null : adherence.copy();
1649      }
1650
1651      protected MedicationUsage typedCopy() {
1652        return copy();
1653      }
1654
1655      @Override
1656      public boolean equalsDeep(Base other_) {
1657        if (!super.equalsDeep(other_))
1658          return false;
1659        if (!(other_ instanceof MedicationUsage))
1660          return false;
1661        MedicationUsage o = (MedicationUsage) other_;
1662        return compareDeep(identifier, o.identifier, true) && compareDeep(partOf, o.partOf, true) && compareDeep(status, o.status, true)
1663           && compareDeep(category, o.category, true) && compareDeep(medication, o.medication, true) && compareDeep(subject, o.subject, true)
1664           && compareDeep(encounter, o.encounter, true) && compareDeep(effective, o.effective, true) && compareDeep(dateAsserted, o.dateAsserted, true)
1665           && compareDeep(informationSource, o.informationSource, true) && compareDeep(derivedFrom, o.derivedFrom, true)
1666           && compareDeep(reason, o.reason, true) && compareDeep(note, o.note, true) && compareDeep(relatedClinicalInformation, o.relatedClinicalInformation, true)
1667           && compareDeep(renderedDosageInstruction, o.renderedDosageInstruction, true) && compareDeep(dosage, o.dosage, true)
1668           && compareDeep(adherence, o.adherence, true);
1669      }
1670
1671      @Override
1672      public boolean equalsShallow(Base other_) {
1673        if (!super.equalsShallow(other_))
1674          return false;
1675        if (!(other_ instanceof MedicationUsage))
1676          return false;
1677        MedicationUsage o = (MedicationUsage) other_;
1678        return compareValues(status, o.status, true) && compareValues(dateAsserted, o.dateAsserted, true) && compareValues(renderedDosageInstruction, o.renderedDosageInstruction, true)
1679          ;
1680      }
1681
1682      public boolean isEmpty() {
1683        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, partOf, status
1684          , category, medication, subject, encounter, effective, dateAsserted, informationSource
1685          , derivedFrom, reason, note, relatedClinicalInformation, renderedDosageInstruction
1686          , dosage, adherence);
1687      }
1688
1689  @Override
1690  public ResourceType getResourceType() {
1691    return ResourceType.MedicationUsage;
1692   }
1693
1694 /**
1695   * Search parameter: <b>adherence</b>
1696   * <p>
1697   * Description: <b>Returns statements based on adherence or compliance</b><br>
1698   * Type: <b>token</b><br>
1699   * Path: <b>MedicationUsage.adherence</b><br>
1700   * </p>
1701   */
1702  @SearchParamDefinition(name="adherence", path="MedicationUsage.adherence", description="Returns statements based on adherence or compliance", type="token" )
1703  public static final String SP_ADHERENCE = "adherence";
1704 /**
1705   * <b>Fluent Client</b> search parameter constant for <b>adherence</b>
1706   * <p>
1707   * Description: <b>Returns statements based on adherence or compliance</b><br>
1708   * Type: <b>token</b><br>
1709   * Path: <b>MedicationUsage.adherence</b><br>
1710   * </p>
1711   */
1712  public static final ca.uhn.fhir.rest.gclient.TokenClientParam ADHERENCE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_ADHERENCE);
1713
1714 /**
1715   * Search parameter: <b>category</b>
1716   * <p>
1717   * Description: <b>Returns statements of this category of MedicationUsage</b><br>
1718   * Type: <b>token</b><br>
1719   * Path: <b>MedicationUsage.category</b><br>
1720   * </p>
1721   */
1722  @SearchParamDefinition(name="category", path="MedicationUsage.category", description="Returns statements of this category of MedicationUsage", type="token" )
1723  public static final String SP_CATEGORY = "category";
1724 /**
1725   * <b>Fluent Client</b> search parameter constant for <b>category</b>
1726   * <p>
1727   * Description: <b>Returns statements of this category of MedicationUsage</b><br>
1728   * Type: <b>token</b><br>
1729   * Path: <b>MedicationUsage.category</b><br>
1730   * </p>
1731   */
1732  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CATEGORY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CATEGORY);
1733
1734 /**
1735   * Search parameter: <b>effective</b>
1736   * <p>
1737   * Description: <b>Date when patient was taking (or not taking) the medication</b><br>
1738   * Type: <b>date</b><br>
1739   * Path: <b>MedicationUsage.effective.as(dateTime) | MedicationUsage.effective.as(Period)</b><br>
1740   * </p>
1741   */
1742  @SearchParamDefinition(name="effective", path="MedicationUsage.effective.as(dateTime) | MedicationUsage.effective.as(Period)", description="Date when patient was taking (or not taking) the medication", type="date" )
1743  public static final String SP_EFFECTIVE = "effective";
1744 /**
1745   * <b>Fluent Client</b> search parameter constant for <b>effective</b>
1746   * <p>
1747   * Description: <b>Date when patient was taking (or not taking) the medication</b><br>
1748   * Type: <b>date</b><br>
1749   * Path: <b>MedicationUsage.effective.as(dateTime) | MedicationUsage.effective.as(Period)</b><br>
1750   * </p>
1751   */
1752  public static final ca.uhn.fhir.rest.gclient.DateClientParam EFFECTIVE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_EFFECTIVE);
1753
1754 /**
1755   * Search parameter: <b>encounter</b>
1756   * <p>
1757   * Description: <b>Returns statements for a specific encounter</b><br>
1758   * Type: <b>reference</b><br>
1759   * Path: <b>MedicationUsage.encounter</b><br>
1760   * </p>
1761   */
1762  @SearchParamDefinition(name="encounter", path="MedicationUsage.encounter", description="Returns statements for a specific encounter", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Base FHIR compartment definition for Encounter") }, target={Encounter.class } )
1763  public static final String SP_ENCOUNTER = "encounter";
1764 /**
1765   * <b>Fluent Client</b> search parameter constant for <b>encounter</b>
1766   * <p>
1767   * Description: <b>Returns statements for a specific encounter</b><br>
1768   * Type: <b>reference</b><br>
1769   * Path: <b>MedicationUsage.encounter</b><br>
1770   * </p>
1771   */
1772  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENCOUNTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENCOUNTER);
1773
1774/**
1775   * Constant for fluent queries to be used to add include statements. Specifies
1776   * the path value of "<b>MedicationUsage:encounter</b>".
1777   */
1778  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENCOUNTER = new ca.uhn.fhir.model.api.Include("MedicationUsage:encounter").toLocked();
1779
1780 /**
1781   * Search parameter: <b>source</b>
1782   * <p>
1783   * Description: <b>Who or where the information in the statement came from</b><br>
1784   * Type: <b>reference</b><br>
1785   * Path: <b>MedicationUsage.informationSource</b><br>
1786   * </p>
1787   */
1788  @SearchParamDefinition(name="source", path="MedicationUsage.informationSource", description="Who or where the information in the statement came from", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Base FHIR compartment definition for Practitioner"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Base FHIR compartment definition for RelatedPerson") }, target={Organization.class, Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class } )
1789  public static final String SP_SOURCE = "source";
1790 /**
1791   * <b>Fluent Client</b> search parameter constant for <b>source</b>
1792   * <p>
1793   * Description: <b>Who or where the information in the statement came from</b><br>
1794   * Type: <b>reference</b><br>
1795   * Path: <b>MedicationUsage.informationSource</b><br>
1796   * </p>
1797   */
1798  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SOURCE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SOURCE);
1799
1800/**
1801   * Constant for fluent queries to be used to add include statements. Specifies
1802   * the path value of "<b>MedicationUsage:source</b>".
1803   */
1804  public static final ca.uhn.fhir.model.api.Include INCLUDE_SOURCE = new ca.uhn.fhir.model.api.Include("MedicationUsage:source").toLocked();
1805
1806 /**
1807   * Search parameter: <b>subject</b>
1808   * <p>
1809   * Description: <b>The identity of a patient, animal or group to list statements for</b><br>
1810   * Type: <b>reference</b><br>
1811   * Path: <b>MedicationUsage.subject</b><br>
1812   * </p>
1813   */
1814  @SearchParamDefinition(name="subject", path="MedicationUsage.subject", description="The identity of a patient, animal or group to list statements for", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Base FHIR compartment definition for Patient") }, target={Group.class, Patient.class } )
1815  public static final String SP_SUBJECT = "subject";
1816 /**
1817   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
1818   * <p>
1819   * Description: <b>The identity of a patient, animal or group to list statements for</b><br>
1820   * Type: <b>reference</b><br>
1821   * Path: <b>MedicationUsage.subject</b><br>
1822   * </p>
1823   */
1824  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
1825
1826/**
1827   * Constant for fluent queries to be used to add include statements. Specifies
1828   * the path value of "<b>MedicationUsage:subject</b>".
1829   */
1830  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("MedicationUsage:subject").toLocked();
1831
1832 /**
1833   * Search parameter: <b>code</b>
1834   * <p>
1835   * Description: <b>Multiple Resources: 
1836
1837* [AllergyIntolerance](allergyintolerance.html): Code that identifies the allergy or intolerance
1838* [Condition](condition.html): Code for the condition
1839* [DeviceRequest](devicerequest.html): Code for what is being requested/ordered
1840* [DiagnosticReport](diagnosticreport.html): The code for the report, as opposed to codes for the atomic results, which are the names on the observation resource referred to from the result
1841* [FamilyMemberHistory](familymemberhistory.html): A search by a condition code
1842* [List](list.html): What the purpose of this list is
1843* [Medication](medication.html): Returns medications for a specific code
1844* [MedicationAdministration](medicationadministration.html): Return administrations of this medication code
1845* [MedicationDispense](medicationdispense.html): Returns dispenses of this medicine code
1846* [MedicationRequest](medicationrequest.html): Return prescriptions of this medication code
1847* [MedicationUsage](medicationusage.html): Return statements of this medication code
1848* [Observation](observation.html): The code of the observation type
1849* [Procedure](procedure.html): A code to identify a  procedure
1850</b><br>
1851   * Type: <b>token</b><br>
1852   * Path: <b>AllergyIntolerance.code | AllergyIntolerance.reaction.substance | Condition.code | DeviceRequest.code.concept | DiagnosticReport.code | FamilyMemberHistory.condition.code | List.code | Medication.code | MedicationAdministration.medication.concept | MedicationDispense.medication.concept | MedicationRequest.medication.concept | MedicationUsage.medication.concept | Observation.code | Procedure.code</b><br>
1853   * </p>
1854   */
1855  @SearchParamDefinition(name="code", path="AllergyIntolerance.code | AllergyIntolerance.reaction.substance | Condition.code | DeviceRequest.code.concept | DiagnosticReport.code | FamilyMemberHistory.condition.code | List.code | Medication.code | MedicationAdministration.medication.concept | MedicationDispense.medication.concept | MedicationRequest.medication.concept | MedicationUsage.medication.concept | Observation.code | Procedure.code", description="Multiple Resources: \r\n\r\n* [AllergyIntolerance](allergyintolerance.html): Code that identifies the allergy or intolerance\r\n* [Condition](condition.html): Code for the condition\r\n* [DeviceRequest](devicerequest.html): Code for what is being requested/ordered\r\n* [DiagnosticReport](diagnosticreport.html): The code for the report, as opposed to codes for the atomic results, which are the names on the observation resource referred to from the result\r\n* [FamilyMemberHistory](familymemberhistory.html): A search by a condition code\r\n* [List](list.html): What the purpose of this list is\r\n* [Medication](medication.html): Returns medications for a specific code\r\n* [MedicationAdministration](medicationadministration.html): Return administrations of this medication code\r\n* [MedicationDispense](medicationdispense.html): Returns dispenses of this medicine code\r\n* [MedicationRequest](medicationrequest.html): Return prescriptions of this medication code\r\n* [MedicationUsage](medicationusage.html): Return statements of this medication code\r\n* [Observation](observation.html): The code of the observation type\r\n* [Procedure](procedure.html): A code to identify a  procedure\r\n", type="token" )
1856  public static final String SP_CODE = "code";
1857 /**
1858   * <b>Fluent Client</b> search parameter constant for <b>code</b>
1859   * <p>
1860   * Description: <b>Multiple Resources: 
1861
1862* [AllergyIntolerance](allergyintolerance.html): Code that identifies the allergy or intolerance
1863* [Condition](condition.html): Code for the condition
1864* [DeviceRequest](devicerequest.html): Code for what is being requested/ordered
1865* [DiagnosticReport](diagnosticreport.html): The code for the report, as opposed to codes for the atomic results, which are the names on the observation resource referred to from the result
1866* [FamilyMemberHistory](familymemberhistory.html): A search by a condition code
1867* [List](list.html): What the purpose of this list is
1868* [Medication](medication.html): Returns medications for a specific code
1869* [MedicationAdministration](medicationadministration.html): Return administrations of this medication code
1870* [MedicationDispense](medicationdispense.html): Returns dispenses of this medicine code
1871* [MedicationRequest](medicationrequest.html): Return prescriptions of this medication code
1872* [MedicationUsage](medicationusage.html): Return statements of this medication code
1873* [Observation](observation.html): The code of the observation type
1874* [Procedure](procedure.html): A code to identify a  procedure
1875</b><br>
1876   * Type: <b>token</b><br>
1877   * Path: <b>AllergyIntolerance.code | AllergyIntolerance.reaction.substance | Condition.code | DeviceRequest.code.concept | DiagnosticReport.code | FamilyMemberHistory.condition.code | List.code | Medication.code | MedicationAdministration.medication.concept | MedicationDispense.medication.concept | MedicationRequest.medication.concept | MedicationUsage.medication.concept | Observation.code | Procedure.code</b><br>
1878   * </p>
1879   */
1880  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CODE);
1881
1882 /**
1883   * Search parameter: <b>identifier</b>
1884   * <p>
1885   * Description: <b>Multiple Resources: 
1886
1887* [AllergyIntolerance](allergyintolerance.html): External ids for this item
1888* [CarePlan](careplan.html): External Ids for this plan
1889* [CareTeam](careteam.html): External Ids for this team
1890* [Composition](composition.html): Version-independent identifier for the Composition
1891* [Condition](condition.html): A unique identifier of the condition record
1892* [Consent](consent.html): Identifier for this record (external references)
1893* [DetectedIssue](detectedissue.html): Unique id for the detected issue
1894* [DeviceRequest](devicerequest.html): Business identifier for request/order
1895* [DiagnosticReport](diagnosticreport.html): An identifier for the report
1896* [DocumentManifest](documentmanifest.html): Unique Identifier for the set of documents
1897* [DocumentReference](documentreference.html): Identifier of the attachment binary
1898* [Encounter](encounter.html): Identifier(s) by which this encounter is known
1899* [EpisodeOfCare](episodeofcare.html): Business Identifier(s) relevant for this EpisodeOfCare
1900* [FamilyMemberHistory](familymemberhistory.html): A search by a record identifier
1901* [Goal](goal.html): External Ids for this goal
1902* [ImagingStudy](imagingstudy.html): Identifiers for the Study, such as DICOM Study Instance UID
1903* [Immunization](immunization.html): Business identifier
1904* [List](list.html): Business identifier
1905* [MedicationAdministration](medicationadministration.html): Return administrations with this external identifier
1906* [MedicationDispense](medicationdispense.html): Returns dispenses with this external identifier
1907* [MedicationRequest](medicationrequest.html): Return prescriptions with this external identifier
1908* [MedicationUsage](medicationusage.html): Return statements with this external identifier
1909* [NutritionOrder](nutritionorder.html): Return nutrition orders with this external identifier
1910* [Observation](observation.html): The unique id for a particular observation
1911* [Procedure](procedure.html): A unique identifier for a procedure
1912* [RiskAssessment](riskassessment.html): Unique identifier for the assessment
1913* [ServiceRequest](servicerequest.html): Identifiers assigned to this order
1914* [SupplyDelivery](supplydelivery.html): External identifier
1915* [SupplyRequest](supplyrequest.html): Business Identifier for SupplyRequest
1916* [VisionPrescription](visionprescription.html): Return prescriptions with this external identifier
1917</b><br>
1918   * Type: <b>token</b><br>
1919   * Path: <b>AllergyIntolerance.identifier | CarePlan.identifier | CareTeam.identifier | Composition.identifier | Condition.identifier | Consent.identifier | DetectedIssue.identifier | DeviceRequest.identifier | DiagnosticReport.identifier | DocumentManifest.masterIdentifier | DocumentManifest.identifier | DocumentReference.identifier | Encounter.identifier | EpisodeOfCare.identifier | FamilyMemberHistory.identifier | Goal.identifier | ImagingStudy.identifier | Immunization.identifier | List.identifier | MedicationAdministration.identifier | MedicationDispense.identifier | MedicationRequest.identifier | MedicationUsage.identifier | NutritionOrder.identifier | Observation.identifier | Procedure.identifier | RiskAssessment.identifier | ServiceRequest.identifier | SupplyDelivery.identifier | SupplyRequest.identifier | VisionPrescription.identifier</b><br>
1920   * </p>
1921   */
1922  @SearchParamDefinition(name="identifier", path="AllergyIntolerance.identifier | CarePlan.identifier | CareTeam.identifier | Composition.identifier | Condition.identifier | Consent.identifier | DetectedIssue.identifier | DeviceRequest.identifier | DiagnosticReport.identifier | DocumentManifest.masterIdentifier | DocumentManifest.identifier | DocumentReference.identifier | Encounter.identifier | EpisodeOfCare.identifier | FamilyMemberHistory.identifier | Goal.identifier | ImagingStudy.identifier | Immunization.identifier | List.identifier | MedicationAdministration.identifier | MedicationDispense.identifier | MedicationRequest.identifier | MedicationUsage.identifier | NutritionOrder.identifier | Observation.identifier | Procedure.identifier | RiskAssessment.identifier | ServiceRequest.identifier | SupplyDelivery.identifier | SupplyRequest.identifier | VisionPrescription.identifier", description="Multiple Resources: \r\n\r\n* [AllergyIntolerance](allergyintolerance.html): External ids for this item\r\n* [CarePlan](careplan.html): External Ids for this plan\r\n* [CareTeam](careteam.html): External Ids for this team\r\n* [Composition](composition.html): Version-independent identifier for the Composition\r\n* [Condition](condition.html): A unique identifier of the condition record\r\n* [Consent](consent.html): Identifier for this record (external references)\r\n* [DetectedIssue](detectedissue.html): Unique id for the detected issue\r\n* [DeviceRequest](devicerequest.html): Business identifier for request/order\r\n* [DiagnosticReport](diagnosticreport.html): An identifier for the report\r\n* [DocumentManifest](documentmanifest.html): Unique Identifier for the set of documents\r\n* [DocumentReference](documentreference.html): Identifier of the attachment binary\r\n* [Encounter](encounter.html): Identifier(s) by which this encounter is known\r\n* [EpisodeOfCare](episodeofcare.html): Business Identifier(s) relevant for this EpisodeOfCare\r\n* [FamilyMemberHistory](familymemberhistory.html): A search by a record identifier\r\n* [Goal](goal.html): External Ids for this goal\r\n* [ImagingStudy](imagingstudy.html): Identifiers for the Study, such as DICOM Study Instance UID\r\n* [Immunization](immunization.html): Business identifier\r\n* [List](list.html): Business identifier\r\n* [MedicationAdministration](medicationadministration.html): Return administrations with this external identifier\r\n* [MedicationDispense](medicationdispense.html): Returns dispenses with this external identifier\r\n* [MedicationRequest](medicationrequest.html): Return prescriptions with this external identifier\r\n* [MedicationUsage](medicationusage.html): Return statements with this external identifier\r\n* [NutritionOrder](nutritionorder.html): Return nutrition orders with this external identifier\r\n* [Observation](observation.html): The unique id for a particular observation\r\n* [Procedure](procedure.html): A unique identifier for a procedure\r\n* [RiskAssessment](riskassessment.html): Unique identifier for the assessment\r\n* [ServiceRequest](servicerequest.html): Identifiers assigned to this order\r\n* [SupplyDelivery](supplydelivery.html): External identifier\r\n* [SupplyRequest](supplyrequest.html): Business Identifier for SupplyRequest\r\n* [VisionPrescription](visionprescription.html): Return prescriptions with this external identifier\r\n", type="token" )
1923  public static final String SP_IDENTIFIER = "identifier";
1924 /**
1925   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
1926   * <p>
1927   * Description: <b>Multiple Resources: 
1928
1929* [AllergyIntolerance](allergyintolerance.html): External ids for this item
1930* [CarePlan](careplan.html): External Ids for this plan
1931* [CareTeam](careteam.html): External Ids for this team
1932* [Composition](composition.html): Version-independent identifier for the Composition
1933* [Condition](condition.html): A unique identifier of the condition record
1934* [Consent](consent.html): Identifier for this record (external references)
1935* [DetectedIssue](detectedissue.html): Unique id for the detected issue
1936* [DeviceRequest](devicerequest.html): Business identifier for request/order
1937* [DiagnosticReport](diagnosticreport.html): An identifier for the report
1938* [DocumentManifest](documentmanifest.html): Unique Identifier for the set of documents
1939* [DocumentReference](documentreference.html): Identifier of the attachment binary
1940* [Encounter](encounter.html): Identifier(s) by which this encounter is known
1941* [EpisodeOfCare](episodeofcare.html): Business Identifier(s) relevant for this EpisodeOfCare
1942* [FamilyMemberHistory](familymemberhistory.html): A search by a record identifier
1943* [Goal](goal.html): External Ids for this goal
1944* [ImagingStudy](imagingstudy.html): Identifiers for the Study, such as DICOM Study Instance UID
1945* [Immunization](immunization.html): Business identifier
1946* [List](list.html): Business identifier
1947* [MedicationAdministration](medicationadministration.html): Return administrations with this external identifier
1948* [MedicationDispense](medicationdispense.html): Returns dispenses with this external identifier
1949* [MedicationRequest](medicationrequest.html): Return prescriptions with this external identifier
1950* [MedicationUsage](medicationusage.html): Return statements with this external identifier
1951* [NutritionOrder](nutritionorder.html): Return nutrition orders with this external identifier
1952* [Observation](observation.html): The unique id for a particular observation
1953* [Procedure](procedure.html): A unique identifier for a procedure
1954* [RiskAssessment](riskassessment.html): Unique identifier for the assessment
1955* [ServiceRequest](servicerequest.html): Identifiers assigned to this order
1956* [SupplyDelivery](supplydelivery.html): External identifier
1957* [SupplyRequest](supplyrequest.html): Business Identifier for SupplyRequest
1958* [VisionPrescription](visionprescription.html): Return prescriptions with this external identifier
1959</b><br>
1960   * Type: <b>token</b><br>
1961   * Path: <b>AllergyIntolerance.identifier | CarePlan.identifier | CareTeam.identifier | Composition.identifier | Condition.identifier | Consent.identifier | DetectedIssue.identifier | DeviceRequest.identifier | DiagnosticReport.identifier | DocumentManifest.masterIdentifier | DocumentManifest.identifier | DocumentReference.identifier | Encounter.identifier | EpisodeOfCare.identifier | FamilyMemberHistory.identifier | Goal.identifier | ImagingStudy.identifier | Immunization.identifier | List.identifier | MedicationAdministration.identifier | MedicationDispense.identifier | MedicationRequest.identifier | MedicationUsage.identifier | NutritionOrder.identifier | Observation.identifier | Procedure.identifier | RiskAssessment.identifier | ServiceRequest.identifier | SupplyDelivery.identifier | SupplyRequest.identifier | VisionPrescription.identifier</b><br>
1962   * </p>
1963   */
1964  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
1965
1966 /**
1967   * Search parameter: <b>patient</b>
1968   * <p>
1969   * Description: <b>Multiple Resources: 
1970
1971* [AllergyIntolerance](allergyintolerance.html): Who the sensitivity is for
1972* [CarePlan](careplan.html): Who the care plan is for
1973* [CareTeam](careteam.html): Who care team is for
1974* [ClinicalImpression](clinicalimpression.html): Patient assessed
1975* [Composition](composition.html): Who and/or what the composition is about
1976* [Condition](condition.html): Who has the condition?
1977* [Consent](consent.html): Who the consent applies to
1978* [DetectedIssue](detectedissue.html): Associated patient
1979* [DeviceRequest](devicerequest.html): Individual the service is ordered for
1980* [DeviceUsage](deviceusage.html): Search by patient who used / uses the device
1981* [DiagnosticReport](diagnosticreport.html): The subject of the report if a patient
1982* [DocumentManifest](documentmanifest.html): The subject of the set of documents
1983* [DocumentReference](documentreference.html): Who/what is the subject of the document
1984* [Encounter](encounter.html): The patient present at the encounter
1985* [EpisodeOfCare](episodeofcare.html): The patient who is the focus of this episode of care
1986* [FamilyMemberHistory](familymemberhistory.html): The identity of a subject to list family member history items for
1987* [Flag](flag.html): The identity of a subject to list flags for
1988* [Goal](goal.html): Who this goal is intended for
1989* [ImagingStudy](imagingstudy.html): Who the study is about
1990* [Immunization](immunization.html): The patient for the vaccination record
1991* [List](list.html): If all resources have the same subject
1992* [MedicationAdministration](medicationadministration.html): The identity of a patient to list administrations  for
1993* [MedicationDispense](medicationdispense.html): The identity of a patient to list dispenses  for
1994* [MedicationRequest](medicationrequest.html): Returns prescriptions for a specific patient
1995* [MedicationUsage](medicationusage.html): Returns statements for a specific patient.
1996* [NutritionOrder](nutritionorder.html): The identity of the individual or set of individuals who requires the diet, formula or nutritional supplement
1997* [Observation](observation.html): The subject that the observation is about (if patient)
1998* [Procedure](procedure.html): Search by subject - a patient
1999* [RiskAssessment](riskassessment.html): Who/what does assessment apply to?
2000* [ServiceRequest](servicerequest.html): Search by subject - a patient
2001* [SupplyDelivery](supplydelivery.html): Patient for whom the item is supplied
2002* [SupplyRequest](supplyrequest.html): The patient or subject for whom the supply is destined
2003* [VisionPrescription](visionprescription.html): The identity of a patient to list dispenses for
2004</b><br>
2005   * Type: <b>reference</b><br>
2006   * Path: <b>AllergyIntolerance.patient | CarePlan.subject.where(resolve() is Patient) | CareTeam.subject.where(resolve() is Patient) | ClinicalImpression.subject.where(resolve() is Patient) | Composition.subject.where(resolve() is Patient) | Condition.subject.where(resolve() is Patient) | Consent.subject.where(resolve() is Patient) | DetectedIssue.subject | DeviceRequest.subject.where(resolve() is Patient) | DeviceUsage.patient | DiagnosticReport.subject.where(resolve() is Patient) | DocumentManifest.subject.where(resolve() is Patient) | DocumentReference.subject.where(resolve() is Patient) | Encounter.subject.where(resolve() is Patient) | EpisodeOfCare.patient | FamilyMemberHistory.patient | Flag.subject.where(resolve() is Patient) | Goal.subject.where(resolve() is Patient) | ImagingStudy.subject.where(resolve() is Patient) | Immunization.patient | List.subject.where(resolve() is Patient) | MedicationAdministration.subject.where(resolve() is Patient) | MedicationDispense.subject.where(resolve() is Patient) | MedicationRequest.subject.where(resolve() is Patient) | MedicationUsage.subject.where(resolve() is Patient) | NutritionOrder.subject.where(resolve() is Patient) | Observation.subject.where(resolve() is Patient) | Procedure.subject.where(resolve() is Patient) | RiskAssessment.subject.where(resolve() is Patient) | ServiceRequest.subject.where(resolve() is Patient) | SupplyDelivery.patient | SupplyRequest.deliverFor | VisionPrescription.patient</b><br>
2007   * </p>
2008   */
2009  @SearchParamDefinition(name="patient", path="AllergyIntolerance.patient | CarePlan.subject.where(resolve() is Patient) | CareTeam.subject.where(resolve() is Patient) | ClinicalImpression.subject.where(resolve() is Patient) | Composition.subject.where(resolve() is Patient) | Condition.subject.where(resolve() is Patient) | Consent.subject.where(resolve() is Patient) | DetectedIssue.subject | DeviceRequest.subject.where(resolve() is Patient) | DeviceUsage.patient | DiagnosticReport.subject.where(resolve() is Patient) | DocumentManifest.subject.where(resolve() is Patient) | DocumentReference.subject.where(resolve() is Patient) | Encounter.subject.where(resolve() is Patient) | EpisodeOfCare.patient | FamilyMemberHistory.patient | Flag.subject.where(resolve() is Patient) | Goal.subject.where(resolve() is Patient) | ImagingStudy.subject.where(resolve() is Patient) | Immunization.patient | List.subject.where(resolve() is Patient) | MedicationAdministration.subject.where(resolve() is Patient) | MedicationDispense.subject.where(resolve() is Patient) | MedicationRequest.subject.where(resolve() is Patient) | MedicationUsage.subject.where(resolve() is Patient) | NutritionOrder.subject.where(resolve() is Patient) | Observation.subject.where(resolve() is Patient) | Procedure.subject.where(resolve() is Patient) | RiskAssessment.subject.where(resolve() is Patient) | ServiceRequest.subject.where(resolve() is Patient) | SupplyDelivery.patient | SupplyRequest.deliverFor | VisionPrescription.patient", description="Multiple Resources: \r\n\r\n* [AllergyIntolerance](allergyintolerance.html): Who the sensitivity is for\r\n* [CarePlan](careplan.html): Who the care plan is for\r\n* [CareTeam](careteam.html): Who care team is for\r\n* [ClinicalImpression](clinicalimpression.html): Patient assessed\r\n* [Composition](composition.html): Who and/or what the composition is about\r\n* [Condition](condition.html): Who has the condition?\r\n* [Consent](consent.html): Who the consent applies to\r\n* [DetectedIssue](detectedissue.html): Associated patient\r\n* [DeviceRequest](devicerequest.html): Individual the service is ordered for\r\n* [DeviceUsage](deviceusage.html): Search by patient who used / uses the device\r\n* [DiagnosticReport](diagnosticreport.html): The subject of the report if a patient\r\n* [DocumentManifest](documentmanifest.html): The subject of the set of documents\r\n* [DocumentReference](documentreference.html): Who/what is the subject of the document\r\n* [Encounter](encounter.html): The patient present at the encounter\r\n* [EpisodeOfCare](episodeofcare.html): The patient who is the focus of this episode of care\r\n* [FamilyMemberHistory](familymemberhistory.html): The identity of a subject to list family member history items for\r\n* [Flag](flag.html): The identity of a subject to list flags for\r\n* [Goal](goal.html): Who this goal is intended for\r\n* [ImagingStudy](imagingstudy.html): Who the study is about\r\n* [Immunization](immunization.html): The patient for the vaccination record\r\n* [List](list.html): If all resources have the same subject\r\n* [MedicationAdministration](medicationadministration.html): The identity of a patient to list administrations  for\r\n* [MedicationDispense](medicationdispense.html): The identity of a patient to list dispenses  for\r\n* [MedicationRequest](medicationrequest.html): Returns prescriptions for a specific patient\r\n* [MedicationUsage](medicationusage.html): Returns statements for a specific patient.\r\n* [NutritionOrder](nutritionorder.html): The identity of the individual or set of individuals who requires the diet, formula or nutritional supplement\r\n* [Observation](observation.html): The subject that the observation is about (if patient)\r\n* [Procedure](procedure.html): Search by subject - a patient\r\n* [RiskAssessment](riskassessment.html): Who/what does assessment apply to?\r\n* [ServiceRequest](servicerequest.html): Search by subject - a patient\r\n* [SupplyDelivery](supplydelivery.html): Patient for whom the item is supplied\r\n* [SupplyRequest](supplyrequest.html): The patient or subject for whom the supply is destined\r\n* [VisionPrescription](visionprescription.html): The identity of a patient to list dispenses for\r\n", type="reference", target={BiologicallyDerivedProduct.class, Device.class, Group.class, Location.class, Medication.class, NutritionProduct.class, Organization.class, Patient.class, Practitioner.class, Procedure.class, Substance.class } )
2010  public static final String SP_PATIENT = "patient";
2011 /**
2012   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
2013   * <p>
2014   * Description: <b>Multiple Resources: 
2015
2016* [AllergyIntolerance](allergyintolerance.html): Who the sensitivity is for
2017* [CarePlan](careplan.html): Who the care plan is for
2018* [CareTeam](careteam.html): Who care team is for
2019* [ClinicalImpression](clinicalimpression.html): Patient assessed
2020* [Composition](composition.html): Who and/or what the composition is about
2021* [Condition](condition.html): Who has the condition?
2022* [Consent](consent.html): Who the consent applies to
2023* [DetectedIssue](detectedissue.html): Associated patient
2024* [DeviceRequest](devicerequest.html): Individual the service is ordered for
2025* [DeviceUsage](deviceusage.html): Search by patient who used / uses the device
2026* [DiagnosticReport](diagnosticreport.html): The subject of the report if a patient
2027* [DocumentManifest](documentmanifest.html): The subject of the set of documents
2028* [DocumentReference](documentreference.html): Who/what is the subject of the document
2029* [Encounter](encounter.html): The patient present at the encounter
2030* [EpisodeOfCare](episodeofcare.html): The patient who is the focus of this episode of care
2031* [FamilyMemberHistory](familymemberhistory.html): The identity of a subject to list family member history items for
2032* [Flag](flag.html): The identity of a subject to list flags for
2033* [Goal](goal.html): Who this goal is intended for
2034* [ImagingStudy](imagingstudy.html): Who the study is about
2035* [Immunization](immunization.html): The patient for the vaccination record
2036* [List](list.html): If all resources have the same subject
2037* [MedicationAdministration](medicationadministration.html): The identity of a patient to list administrations  for
2038* [MedicationDispense](medicationdispense.html): The identity of a patient to list dispenses  for
2039* [MedicationRequest](medicationrequest.html): Returns prescriptions for a specific patient
2040* [MedicationUsage](medicationusage.html): Returns statements for a specific patient.
2041* [NutritionOrder](nutritionorder.html): The identity of the individual or set of individuals who requires the diet, formula or nutritional supplement
2042* [Observation](observation.html): The subject that the observation is about (if patient)
2043* [Procedure](procedure.html): Search by subject - a patient
2044* [RiskAssessment](riskassessment.html): Who/what does assessment apply to?
2045* [ServiceRequest](servicerequest.html): Search by subject - a patient
2046* [SupplyDelivery](supplydelivery.html): Patient for whom the item is supplied
2047* [SupplyRequest](supplyrequest.html): The patient or subject for whom the supply is destined
2048* [VisionPrescription](visionprescription.html): The identity of a patient to list dispenses for
2049</b><br>
2050   * Type: <b>reference</b><br>
2051   * Path: <b>AllergyIntolerance.patient | CarePlan.subject.where(resolve() is Patient) | CareTeam.subject.where(resolve() is Patient) | ClinicalImpression.subject.where(resolve() is Patient) | Composition.subject.where(resolve() is Patient) | Condition.subject.where(resolve() is Patient) | Consent.subject.where(resolve() is Patient) | DetectedIssue.subject | DeviceRequest.subject.where(resolve() is Patient) | DeviceUsage.patient | DiagnosticReport.subject.where(resolve() is Patient) | DocumentManifest.subject.where(resolve() is Patient) | DocumentReference.subject.where(resolve() is Patient) | Encounter.subject.where(resolve() is Patient) | EpisodeOfCare.patient | FamilyMemberHistory.patient | Flag.subject.where(resolve() is Patient) | Goal.subject.where(resolve() is Patient) | ImagingStudy.subject.where(resolve() is Patient) | Immunization.patient | List.subject.where(resolve() is Patient) | MedicationAdministration.subject.where(resolve() is Patient) | MedicationDispense.subject.where(resolve() is Patient) | MedicationRequest.subject.where(resolve() is Patient) | MedicationUsage.subject.where(resolve() is Patient) | NutritionOrder.subject.where(resolve() is Patient) | Observation.subject.where(resolve() is Patient) | Procedure.subject.where(resolve() is Patient) | RiskAssessment.subject.where(resolve() is Patient) | ServiceRequest.subject.where(resolve() is Patient) | SupplyDelivery.patient | SupplyRequest.deliverFor | VisionPrescription.patient</b><br>
2052   * </p>
2053   */
2054  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
2055
2056/**
2057   * Constant for fluent queries to be used to add include statements. Specifies
2058   * the path value of "<b>MedicationUsage:patient</b>".
2059   */
2060  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("MedicationUsage:patient").toLocked();
2061
2062 /**
2063   * Search parameter: <b>medication</b>
2064   * <p>
2065   * Description: <b>Multiple Resources: 
2066
2067* [MedicationAdministration](medicationadministration.html): Return administrations of this medication reference
2068* [MedicationDispense](medicationdispense.html): Returns dispenses of this medicine resource
2069* [MedicationRequest](medicationrequest.html): Return prescriptions for this medication reference
2070* [MedicationUsage](medicationusage.html): Return statements of this medication reference
2071</b><br>
2072   * Type: <b>reference</b><br>
2073   * Path: <b>MedicationAdministration.medication.reference | MedicationDispense.medication.reference | MedicationRequest.medication.reference | MedicationUsage.medication.reference</b><br>
2074   * </p>
2075   */
2076  @SearchParamDefinition(name="medication", path="MedicationAdministration.medication.reference | MedicationDispense.medication.reference | MedicationRequest.medication.reference | MedicationUsage.medication.reference", description="Multiple Resources: \r\n\r\n* [MedicationAdministration](medicationadministration.html): Return administrations of this medication reference\r\n* [MedicationDispense](medicationdispense.html): Returns dispenses of this medicine resource\r\n* [MedicationRequest](medicationrequest.html): Return prescriptions for this medication reference\r\n* [MedicationUsage](medicationusage.html): Return statements of this medication reference\r\n", type="reference" )
2077  public static final String SP_MEDICATION = "medication";
2078 /**
2079   * <b>Fluent Client</b> search parameter constant for <b>medication</b>
2080   * <p>
2081   * Description: <b>Multiple Resources: 
2082
2083* [MedicationAdministration](medicationadministration.html): Return administrations of this medication reference
2084* [MedicationDispense](medicationdispense.html): Returns dispenses of this medicine resource
2085* [MedicationRequest](medicationrequest.html): Return prescriptions for this medication reference
2086* [MedicationUsage](medicationusage.html): Return statements of this medication reference
2087</b><br>
2088   * Type: <b>reference</b><br>
2089   * Path: <b>MedicationAdministration.medication.reference | MedicationDispense.medication.reference | MedicationRequest.medication.reference | MedicationUsage.medication.reference</b><br>
2090   * </p>
2091   */
2092  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam MEDICATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_MEDICATION);
2093
2094/**
2095   * Constant for fluent queries to be used to add include statements. Specifies
2096   * the path value of "<b>MedicationUsage:medication</b>".
2097   */
2098  public static final ca.uhn.fhir.model.api.Include INCLUDE_MEDICATION = new ca.uhn.fhir.model.api.Include("MedicationUsage:medication").toLocked();
2099
2100 /**
2101   * Search parameter: <b>status</b>
2102   * <p>
2103   * Description: <b>Multiple Resources: 
2104
2105* [MedicationAdministration](medicationadministration.html): MedicationAdministration event status (for example one of active/paused/completed/nullified)
2106* [MedicationDispense](medicationdispense.html): Returns dispenses with a specified dispense status
2107* [MedicationRequest](medicationrequest.html): Status of the prescription
2108* [MedicationUsage](medicationusage.html): Return statements that match the given status
2109</b><br>
2110   * Type: <b>token</b><br>
2111   * Path: <b>MedicationAdministration.status | MedicationDispense.status | MedicationRequest.status | MedicationUsage.status</b><br>
2112   * </p>
2113   */
2114  @SearchParamDefinition(name="status", path="MedicationAdministration.status | MedicationDispense.status | MedicationRequest.status | MedicationUsage.status", description="Multiple Resources: \r\n\r\n* [MedicationAdministration](medicationadministration.html): MedicationAdministration event status (for example one of active/paused/completed/nullified)\r\n* [MedicationDispense](medicationdispense.html): Returns dispenses with a specified dispense status\r\n* [MedicationRequest](medicationrequest.html): Status of the prescription\r\n* [MedicationUsage](medicationusage.html): Return statements that match the given status\r\n", type="token" )
2115  public static final String SP_STATUS = "status";
2116 /**
2117   * <b>Fluent Client</b> search parameter constant for <b>status</b>
2118   * <p>
2119   * Description: <b>Multiple Resources: 
2120
2121* [MedicationAdministration](medicationadministration.html): MedicationAdministration event status (for example one of active/paused/completed/nullified)
2122* [MedicationDispense](medicationdispense.html): Returns dispenses with a specified dispense status
2123* [MedicationRequest](medicationrequest.html): Status of the prescription
2124* [MedicationUsage](medicationusage.html): Return statements that match the given status
2125</b><br>
2126   * Type: <b>token</b><br>
2127   * Path: <b>MedicationAdministration.status | MedicationDispense.status | MedicationRequest.status | MedicationUsage.status</b><br>
2128   * </p>
2129   */
2130  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
2131
2132
2133}