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