001package org.hl7.fhir.instance.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
033import java.util.*;
034
035import org.hl7.fhir.exceptions.FHIRException;
036import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
037import org.hl7.fhir.utilities.Utilities;
038
039import ca.uhn.fhir.model.api.annotation.*;
040/**
041 * A record of a medication that is being consumed by a patient.   A MedicationStatement 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 e.g. the patient's memory, from a prescription bottle,  or from a list of medications the patient, clinician or other party maintains 
042
043The primary difference between a medication statement and a medication administration is that the medication administration has complete administration information and is based on actual administration information from the person who administered the medication.  A medication statement 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 statement 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.
044 */
045@ResourceDef(name="MedicationStatement", profile="http://hl7.org/fhir/Profile/MedicationStatement")
046public class MedicationStatement extends DomainResource {
047
048    public enum MedicationStatementStatus {
049        /**
050         * The medication is still being taken.
051         */
052        ACTIVE, 
053        /**
054         * The medication is no longer being taken.
055         */
056        COMPLETED, 
057        /**
058         * The statement was entered in error.
059         */
060        ENTEREDINERROR, 
061        /**
062         * The medication may be taken at some time in the future.
063         */
064        INTENDED, 
065        /**
066         * added to help the parsers
067         */
068        NULL;
069        public static MedicationStatementStatus fromCode(String codeString) throws FHIRException {
070            if (codeString == null || "".equals(codeString))
071                return null;
072        if ("active".equals(codeString))
073          return ACTIVE;
074        if ("completed".equals(codeString))
075          return COMPLETED;
076        if ("entered-in-error".equals(codeString))
077          return ENTEREDINERROR;
078        if ("intended".equals(codeString))
079          return INTENDED;
080        throw new FHIRException("Unknown MedicationStatementStatus code '"+codeString+"'");
081        }
082        public String toCode() {
083          switch (this) {
084            case ACTIVE: return "active";
085            case COMPLETED: return "completed";
086            case ENTEREDINERROR: return "entered-in-error";
087            case INTENDED: return "intended";
088            default: return "?";
089          }
090        }
091        public String getSystem() {
092          switch (this) {
093            case ACTIVE: return "http://hl7.org/fhir/medication-statement-status";
094            case COMPLETED: return "http://hl7.org/fhir/medication-statement-status";
095            case ENTEREDINERROR: return "http://hl7.org/fhir/medication-statement-status";
096            case INTENDED: return "http://hl7.org/fhir/medication-statement-status";
097            default: return "?";
098          }
099        }
100        public String getDefinition() {
101          switch (this) {
102            case ACTIVE: return "The medication is still being taken.";
103            case COMPLETED: return "The medication is no longer being taken.";
104            case ENTEREDINERROR: return "The statement was entered in error.";
105            case INTENDED: return "The medication may be taken at some time in the future.";
106            default: return "?";
107          }
108        }
109        public String getDisplay() {
110          switch (this) {
111            case ACTIVE: return "Active";
112            case COMPLETED: return "Completed";
113            case ENTEREDINERROR: return "Entered in Error";
114            case INTENDED: return "Intended";
115            default: return "?";
116          }
117        }
118    }
119
120  public static class MedicationStatementStatusEnumFactory implements EnumFactory<MedicationStatementStatus> {
121    public MedicationStatementStatus fromCode(String codeString) throws IllegalArgumentException {
122      if (codeString == null || "".equals(codeString))
123            if (codeString == null || "".equals(codeString))
124                return null;
125        if ("active".equals(codeString))
126          return MedicationStatementStatus.ACTIVE;
127        if ("completed".equals(codeString))
128          return MedicationStatementStatus.COMPLETED;
129        if ("entered-in-error".equals(codeString))
130          return MedicationStatementStatus.ENTEREDINERROR;
131        if ("intended".equals(codeString))
132          return MedicationStatementStatus.INTENDED;
133        throw new IllegalArgumentException("Unknown MedicationStatementStatus code '"+codeString+"'");
134        }
135        public Enumeration<MedicationStatementStatus> fromType(Base code) throws FHIRException {
136          if (code == null || code.isEmpty())
137            return null;
138          String codeString = ((PrimitiveType) code).asStringValue();
139          if (codeString == null || "".equals(codeString))
140            return null;
141        if ("active".equals(codeString))
142          return new Enumeration<MedicationStatementStatus>(this, MedicationStatementStatus.ACTIVE);
143        if ("completed".equals(codeString))
144          return new Enumeration<MedicationStatementStatus>(this, MedicationStatementStatus.COMPLETED);
145        if ("entered-in-error".equals(codeString))
146          return new Enumeration<MedicationStatementStatus>(this, MedicationStatementStatus.ENTEREDINERROR);
147        if ("intended".equals(codeString))
148          return new Enumeration<MedicationStatementStatus>(this, MedicationStatementStatus.INTENDED);
149        throw new FHIRException("Unknown MedicationStatementStatus code '"+codeString+"'");
150        }
151    public String toCode(MedicationStatementStatus code) {
152      if (code == MedicationStatementStatus.ACTIVE)
153        return "active";
154      if (code == MedicationStatementStatus.COMPLETED)
155        return "completed";
156      if (code == MedicationStatementStatus.ENTEREDINERROR)
157        return "entered-in-error";
158      if (code == MedicationStatementStatus.INTENDED)
159        return "intended";
160      return "?";
161      }
162    }
163
164    @Block()
165    public static class MedicationStatementDosageComponent extends BackboneElement implements IBaseBackboneElement {
166        /**
167         * Free text dosage information as reported about a patient's medication use. When coded dosage information is present, the free text may still be present for display to humans.
168         */
169        @Child(name = "text", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true)
170        @Description(shortDefinition="Reported dosage information", formalDefinition="Free text dosage information as reported about a patient's medication use. When coded dosage information is present, the free text may still be present for display to humans." )
171        protected StringType text;
172
173        /**
174         * The timing schedule for giving the medication to the patient.  The Schedule data type allows many different expressions, for example.  "Every  8 hours"; "Three times a day"; "1/2 an hour before breakfast for 10 days from 23-Dec 2011:";  "15 Oct 2013, 17 Oct 2013 and 1 Nov 2013".
175         */
176        @Child(name = "timing", type = {Timing.class}, order=2, min=0, max=1, modifier=false, summary=true)
177        @Description(shortDefinition="When/how often was medication taken", formalDefinition="The timing schedule for giving the medication to the patient.  The Schedule data type allows many different expressions, for example.  \"Every  8 hours\"; \"Three times a day\"; \"1/2 an hour before breakfast for 10 days from 23-Dec 2011:\";  \"15 Oct 2013, 17 Oct 2013 and 1 Nov 2013\"." )
178        protected Timing timing;
179
180        /**
181         * Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept).  
182
183Specifically if 'boolean' datatype is selected, then the following logic applies:  If set to True, this indicates that the medication is only taken when needed, within the specified schedule.
184         */
185        @Child(name = "asNeeded", type = {BooleanType.class, CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true)
186        @Description(shortDefinition="Take \"as needed\" (for x)", formalDefinition="Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept).  \n\nSpecifically if 'boolean' datatype is selected, then the following logic applies:  If set to True, this indicates that the medication is only taken when needed, within the specified schedule." )
187        protected Type asNeeded;
188
189        /**
190         * A coded specification of or a reference to the anatomic site where the medication first enters the body.
191         */
192        @Child(name = "site", type = {CodeableConcept.class, BodySite.class}, order=4, min=0, max=1, modifier=false, summary=true)
193        @Description(shortDefinition="Where (on body) medication is/was administered", formalDefinition="A coded specification of or a reference to the anatomic site where the medication first enters the body." )
194        protected Type site;
195
196        /**
197         * A code specifying the route or physiological path of administration of a therapeutic agent into or onto a subject.
198         */
199        @Child(name = "route", type = {CodeableConcept.class}, order=5, min=0, max=1, modifier=false, summary=true)
200        @Description(shortDefinition="How the medication entered the body", formalDefinition="A code specifying the route or physiological path of administration of a therapeutic agent into or onto a subject." )
201        protected CodeableConcept route;
202
203        /**
204         * A coded value indicating the method by which the medication is intended to be or was introduced into or on the body.  This attribute will most often NOT be populated.  It is most commonly used for injections.  For example, Slow Push, Deep IV.
205         */
206        @Child(name = "method", type = {CodeableConcept.class}, order=6, min=0, max=1, modifier=false, summary=true)
207        @Description(shortDefinition="Technique used to administer medication", formalDefinition="A coded value indicating the method by which the medication is intended to be or was introduced into or on the body.  This attribute will most often NOT be populated.  It is most commonly used for injections.  For example, Slow Push, Deep IV." )
208        protected CodeableConcept method;
209
210        /**
211         * The amount of therapeutic or other substance given at one administration event.
212         */
213        @Child(name = "quantity", type = {SimpleQuantity.class, Range.class}, order=7, min=0, max=1, modifier=false, summary=true)
214        @Description(shortDefinition="Amount administered in one dose", formalDefinition="The amount of therapeutic or other substance given at one administration event." )
215        protected Type quantity;
216
217        /**
218         * Identifies the speed with which the medication was or will be introduced into the patient. Typically the rate for an infusion e.g. 100 ml per 1 hour or 100 ml/hr.  May also be expressed as a rate per unit of time e.g. 500 ml per 2 hours.   Currently we do not specify a default of '1' in the denominator, but this is being discussed. Other examples: 200 mcg/min or 200 mcg/1 minute; 1 liter/8 hours.
219         */
220        @Child(name = "rate", type = {Ratio.class, Range.class}, order=8, min=0, max=1, modifier=false, summary=true)
221        @Description(shortDefinition="Dose quantity per unit of time", formalDefinition="Identifies the speed with which the medication was or will be introduced into the patient. Typically the rate for an infusion e.g. 100 ml per 1 hour or 100 ml/hr.  May also be expressed as a rate per unit of time e.g. 500 ml per 2 hours.   Currently we do not specify a default of '1' in the denominator, but this is being discussed. Other examples: 200 mcg/min or 200 mcg/1 minute; 1 liter/8 hours." )
222        protected Type rate;
223
224        /**
225         * The maximum total quantity of a therapeutic substance that may be administered to a subject over the period of time.  For example, 1000mg in 24 hours.
226         */
227        @Child(name = "maxDosePerPeriod", type = {Ratio.class}, order=9, min=0, max=1, modifier=false, summary=true)
228        @Description(shortDefinition="Maximum dose that was consumed per unit of time", formalDefinition="The maximum total quantity of a therapeutic substance that may be administered to a subject over the period of time.  For example, 1000mg in 24 hours." )
229        protected Ratio maxDosePerPeriod;
230
231        private static final long serialVersionUID = 246880733L;
232
233    /*
234     * Constructor
235     */
236      public MedicationStatementDosageComponent() {
237        super();
238      }
239
240        /**
241         * @return {@link #text} (Free text dosage information as reported about a patient's medication use. When coded dosage information is present, the free text may still be present for display to humans.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value
242         */
243        public StringType getTextElement() { 
244          if (this.text == null)
245            if (Configuration.errorOnAutoCreate())
246              throw new Error("Attempt to auto-create MedicationStatementDosageComponent.text");
247            else if (Configuration.doAutoCreate())
248              this.text = new StringType(); // bb
249          return this.text;
250        }
251
252        public boolean hasTextElement() { 
253          return this.text != null && !this.text.isEmpty();
254        }
255
256        public boolean hasText() { 
257          return this.text != null && !this.text.isEmpty();
258        }
259
260        /**
261         * @param value {@link #text} (Free text dosage information as reported about a patient's medication use. When coded dosage information is present, the free text may still be present for display to humans.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value
262         */
263        public MedicationStatementDosageComponent setTextElement(StringType value) { 
264          this.text = value;
265          return this;
266        }
267
268        /**
269         * @return Free text dosage information as reported about a patient's medication use. When coded dosage information is present, the free text may still be present for display to humans.
270         */
271        public String getText() { 
272          return this.text == null ? null : this.text.getValue();
273        }
274
275        /**
276         * @param value Free text dosage information as reported about a patient's medication use. When coded dosage information is present, the free text may still be present for display to humans.
277         */
278        public MedicationStatementDosageComponent setText(String value) { 
279          if (Utilities.noString(value))
280            this.text = null;
281          else {
282            if (this.text == null)
283              this.text = new StringType();
284            this.text.setValue(value);
285          }
286          return this;
287        }
288
289        /**
290         * @return {@link #timing} (The timing schedule for giving the medication to the patient.  The Schedule data type allows many different expressions, for example.  "Every  8 hours"; "Three times a day"; "1/2 an hour before breakfast for 10 days from 23-Dec 2011:";  "15 Oct 2013, 17 Oct 2013 and 1 Nov 2013".)
291         */
292        public Timing getTiming() { 
293          if (this.timing == null)
294            if (Configuration.errorOnAutoCreate())
295              throw new Error("Attempt to auto-create MedicationStatementDosageComponent.timing");
296            else if (Configuration.doAutoCreate())
297              this.timing = new Timing(); // cc
298          return this.timing;
299        }
300
301        public boolean hasTiming() { 
302          return this.timing != null && !this.timing.isEmpty();
303        }
304
305        /**
306         * @param value {@link #timing} (The timing schedule for giving the medication to the patient.  The Schedule data type allows many different expressions, for example.  "Every  8 hours"; "Three times a day"; "1/2 an hour before breakfast for 10 days from 23-Dec 2011:";  "15 Oct 2013, 17 Oct 2013 and 1 Nov 2013".)
307         */
308        public MedicationStatementDosageComponent setTiming(Timing value) { 
309          this.timing = value;
310          return this;
311        }
312
313        /**
314         * @return {@link #asNeeded} (Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept).  
315
316Specifically if 'boolean' datatype is selected, then the following logic applies:  If set to True, this indicates that the medication is only taken when needed, within the specified schedule.)
317         */
318        public Type getAsNeeded() { 
319          return this.asNeeded;
320        }
321
322        /**
323         * @return {@link #asNeeded} (Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept).  
324
325Specifically if 'boolean' datatype is selected, then the following logic applies:  If set to True, this indicates that the medication is only taken when needed, within the specified schedule.)
326         */
327        public BooleanType getAsNeededBooleanType() throws FHIRException { 
328          if (!(this.asNeeded instanceof BooleanType))
329            throw new FHIRException("Type mismatch: the type BooleanType was expected, but "+this.asNeeded.getClass().getName()+" was encountered");
330          return (BooleanType) this.asNeeded;
331        }
332
333        public boolean hasAsNeededBooleanType() { 
334          return this.asNeeded instanceof BooleanType;
335        }
336
337        /**
338         * @return {@link #asNeeded} (Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept).  
339
340Specifically if 'boolean' datatype is selected, then the following logic applies:  If set to True, this indicates that the medication is only taken when needed, within the specified schedule.)
341         */
342        public CodeableConcept getAsNeededCodeableConcept() throws FHIRException { 
343          if (!(this.asNeeded instanceof CodeableConcept))
344            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.asNeeded.getClass().getName()+" was encountered");
345          return (CodeableConcept) this.asNeeded;
346        }
347
348        public boolean hasAsNeededCodeableConcept() { 
349          return this.asNeeded instanceof CodeableConcept;
350        }
351
352        public boolean hasAsNeeded() { 
353          return this.asNeeded != null && !this.asNeeded.isEmpty();
354        }
355
356        /**
357         * @param value {@link #asNeeded} (Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept).  
358
359Specifically if 'boolean' datatype is selected, then the following logic applies:  If set to True, this indicates that the medication is only taken when needed, within the specified schedule.)
360         */
361        public MedicationStatementDosageComponent setAsNeeded(Type value) { 
362          this.asNeeded = value;
363          return this;
364        }
365
366        /**
367         * @return {@link #site} (A coded specification of or a reference to the anatomic site where the medication first enters the body.)
368         */
369        public Type getSite() { 
370          return this.site;
371        }
372
373        /**
374         * @return {@link #site} (A coded specification of or a reference to the anatomic site where the medication first enters the body.)
375         */
376        public CodeableConcept getSiteCodeableConcept() throws FHIRException { 
377          if (!(this.site instanceof CodeableConcept))
378            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.site.getClass().getName()+" was encountered");
379          return (CodeableConcept) this.site;
380        }
381
382        public boolean hasSiteCodeableConcept() { 
383          return this.site instanceof CodeableConcept;
384        }
385
386        /**
387         * @return {@link #site} (A coded specification of or a reference to the anatomic site where the medication first enters the body.)
388         */
389        public Reference getSiteReference() throws FHIRException { 
390          if (!(this.site instanceof Reference))
391            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.site.getClass().getName()+" was encountered");
392          return (Reference) this.site;
393        }
394
395        public boolean hasSiteReference() { 
396          return this.site instanceof Reference;
397        }
398
399        public boolean hasSite() { 
400          return this.site != null && !this.site.isEmpty();
401        }
402
403        /**
404         * @param value {@link #site} (A coded specification of or a reference to the anatomic site where the medication first enters the body.)
405         */
406        public MedicationStatementDosageComponent setSite(Type value) { 
407          this.site = value;
408          return this;
409        }
410
411        /**
412         * @return {@link #route} (A code specifying the route or physiological path of administration of a therapeutic agent into or onto a subject.)
413         */
414        public CodeableConcept getRoute() { 
415          if (this.route == null)
416            if (Configuration.errorOnAutoCreate())
417              throw new Error("Attempt to auto-create MedicationStatementDosageComponent.route");
418            else if (Configuration.doAutoCreate())
419              this.route = new CodeableConcept(); // cc
420          return this.route;
421        }
422
423        public boolean hasRoute() { 
424          return this.route != null && !this.route.isEmpty();
425        }
426
427        /**
428         * @param value {@link #route} (A code specifying the route or physiological path of administration of a therapeutic agent into or onto a subject.)
429         */
430        public MedicationStatementDosageComponent setRoute(CodeableConcept value) { 
431          this.route = value;
432          return this;
433        }
434
435        /**
436         * @return {@link #method} (A coded value indicating the method by which the medication is intended to be or was introduced into or on the body.  This attribute will most often NOT be populated.  It is most commonly used for injections.  For example, Slow Push, Deep IV.)
437         */
438        public CodeableConcept getMethod() { 
439          if (this.method == null)
440            if (Configuration.errorOnAutoCreate())
441              throw new Error("Attempt to auto-create MedicationStatementDosageComponent.method");
442            else if (Configuration.doAutoCreate())
443              this.method = new CodeableConcept(); // cc
444          return this.method;
445        }
446
447        public boolean hasMethod() { 
448          return this.method != null && !this.method.isEmpty();
449        }
450
451        /**
452         * @param value {@link #method} (A coded value indicating the method by which the medication is intended to be or was introduced into or on the body.  This attribute will most often NOT be populated.  It is most commonly used for injections.  For example, Slow Push, Deep IV.)
453         */
454        public MedicationStatementDosageComponent setMethod(CodeableConcept value) { 
455          this.method = value;
456          return this;
457        }
458
459        /**
460         * @return {@link #quantity} (The amount of therapeutic or other substance given at one administration event.)
461         */
462        public Type getQuantity() { 
463          return this.quantity;
464        }
465
466        /**
467         * @return {@link #quantity} (The amount of therapeutic or other substance given at one administration event.)
468         */
469        public SimpleQuantity getQuantitySimpleQuantity() throws FHIRException { 
470          if (!(this.quantity instanceof SimpleQuantity))
471            throw new FHIRException("Type mismatch: the type SimpleQuantity was expected, but "+this.quantity.getClass().getName()+" was encountered");
472          return (SimpleQuantity) this.quantity;
473        }
474
475        public boolean hasQuantitySimpleQuantity() { 
476          return this.quantity instanceof SimpleQuantity;
477        }
478
479        /**
480         * @return {@link #quantity} (The amount of therapeutic or other substance given at one administration event.)
481         */
482        public Range getQuantityRange() throws FHIRException { 
483          if (!(this.quantity instanceof Range))
484            throw new FHIRException("Type mismatch: the type Range was expected, but "+this.quantity.getClass().getName()+" was encountered");
485          return (Range) this.quantity;
486        }
487
488        public boolean hasQuantityRange() { 
489          return this.quantity instanceof Range;
490        }
491
492        public boolean hasQuantity() { 
493          return this.quantity != null && !this.quantity.isEmpty();
494        }
495
496        /**
497         * @param value {@link #quantity} (The amount of therapeutic or other substance given at one administration event.)
498         */
499        public MedicationStatementDosageComponent setQuantity(Type value) { 
500          this.quantity = value;
501          return this;
502        }
503
504        /**
505         * @return {@link #rate} (Identifies the speed with which the medication was or will be introduced into the patient. Typically the rate for an infusion e.g. 100 ml per 1 hour or 100 ml/hr.  May also be expressed as a rate per unit of time e.g. 500 ml per 2 hours.   Currently we do not specify a default of '1' in the denominator, but this is being discussed. Other examples: 200 mcg/min or 200 mcg/1 minute; 1 liter/8 hours.)
506         */
507        public Type getRate() { 
508          return this.rate;
509        }
510
511        /**
512         * @return {@link #rate} (Identifies the speed with which the medication was or will be introduced into the patient. Typically the rate for an infusion e.g. 100 ml per 1 hour or 100 ml/hr.  May also be expressed as a rate per unit of time e.g. 500 ml per 2 hours.   Currently we do not specify a default of '1' in the denominator, but this is being discussed. Other examples: 200 mcg/min or 200 mcg/1 minute; 1 liter/8 hours.)
513         */
514        public Ratio getRateRatio() throws FHIRException { 
515          if (!(this.rate instanceof Ratio))
516            throw new FHIRException("Type mismatch: the type Ratio was expected, but "+this.rate.getClass().getName()+" was encountered");
517          return (Ratio) this.rate;
518        }
519
520        public boolean hasRateRatio() { 
521          return this.rate instanceof Ratio;
522        }
523
524        /**
525         * @return {@link #rate} (Identifies the speed with which the medication was or will be introduced into the patient. Typically the rate for an infusion e.g. 100 ml per 1 hour or 100 ml/hr.  May also be expressed as a rate per unit of time e.g. 500 ml per 2 hours.   Currently we do not specify a default of '1' in the denominator, but this is being discussed. Other examples: 200 mcg/min or 200 mcg/1 minute; 1 liter/8 hours.)
526         */
527        public Range getRateRange() throws FHIRException { 
528          if (!(this.rate instanceof Range))
529            throw new FHIRException("Type mismatch: the type Range was expected, but "+this.rate.getClass().getName()+" was encountered");
530          return (Range) this.rate;
531        }
532
533        public boolean hasRateRange() { 
534          return this.rate instanceof Range;
535        }
536
537        public boolean hasRate() { 
538          return this.rate != null && !this.rate.isEmpty();
539        }
540
541        /**
542         * @param value {@link #rate} (Identifies the speed with which the medication was or will be introduced into the patient. Typically the rate for an infusion e.g. 100 ml per 1 hour or 100 ml/hr.  May also be expressed as a rate per unit of time e.g. 500 ml per 2 hours.   Currently we do not specify a default of '1' in the denominator, but this is being discussed. Other examples: 200 mcg/min or 200 mcg/1 minute; 1 liter/8 hours.)
543         */
544        public MedicationStatementDosageComponent setRate(Type value) { 
545          this.rate = value;
546          return this;
547        }
548
549        /**
550         * @return {@link #maxDosePerPeriod} (The maximum total quantity of a therapeutic substance that may be administered to a subject over the period of time.  For example, 1000mg in 24 hours.)
551         */
552        public Ratio getMaxDosePerPeriod() { 
553          if (this.maxDosePerPeriod == null)
554            if (Configuration.errorOnAutoCreate())
555              throw new Error("Attempt to auto-create MedicationStatementDosageComponent.maxDosePerPeriod");
556            else if (Configuration.doAutoCreate())
557              this.maxDosePerPeriod = new Ratio(); // cc
558          return this.maxDosePerPeriod;
559        }
560
561        public boolean hasMaxDosePerPeriod() { 
562          return this.maxDosePerPeriod != null && !this.maxDosePerPeriod.isEmpty();
563        }
564
565        /**
566         * @param value {@link #maxDosePerPeriod} (The maximum total quantity of a therapeutic substance that may be administered to a subject over the period of time.  For example, 1000mg in 24 hours.)
567         */
568        public MedicationStatementDosageComponent setMaxDosePerPeriod(Ratio value) { 
569          this.maxDosePerPeriod = value;
570          return this;
571        }
572
573        protected void listChildren(List<Property> childrenList) {
574          super.listChildren(childrenList);
575          childrenList.add(new Property("text", "string", "Free text dosage information as reported about a patient's medication use. When coded dosage information is present, the free text may still be present for display to humans.", 0, java.lang.Integer.MAX_VALUE, text));
576          childrenList.add(new Property("timing", "Timing", "The timing schedule for giving the medication to the patient.  The Schedule data type allows many different expressions, for example.  \"Every  8 hours\"; \"Three times a day\"; \"1/2 an hour before breakfast for 10 days from 23-Dec 2011:\";  \"15 Oct 2013, 17 Oct 2013 and 1 Nov 2013\".", 0, java.lang.Integer.MAX_VALUE, timing));
577          childrenList.add(new Property("asNeeded[x]", "boolean|CodeableConcept", "Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept).  \n\nSpecifically if 'boolean' datatype is selected, then the following logic applies:  If set to True, this indicates that the medication is only taken when needed, within the specified schedule.", 0, java.lang.Integer.MAX_VALUE, asNeeded));
578          childrenList.add(new Property("site[x]", "CodeableConcept|Reference(BodySite)", "A coded specification of or a reference to the anatomic site where the medication first enters the body.", 0, java.lang.Integer.MAX_VALUE, site));
579          childrenList.add(new Property("route", "CodeableConcept", "A code specifying the route or physiological path of administration of a therapeutic agent into or onto a subject.", 0, java.lang.Integer.MAX_VALUE, route));
580          childrenList.add(new Property("method", "CodeableConcept", "A coded value indicating the method by which the medication is intended to be or was introduced into or on the body.  This attribute will most often NOT be populated.  It is most commonly used for injections.  For example, Slow Push, Deep IV.", 0, java.lang.Integer.MAX_VALUE, method));
581          childrenList.add(new Property("quantity[x]", "SimpleQuantity|Range", "The amount of therapeutic or other substance given at one administration event.", 0, java.lang.Integer.MAX_VALUE, quantity));
582          childrenList.add(new Property("rate[x]", "Ratio|Range", "Identifies the speed with which the medication was or will be introduced into the patient. Typically the rate for an infusion e.g. 100 ml per 1 hour or 100 ml/hr.  May also be expressed as a rate per unit of time e.g. 500 ml per 2 hours.   Currently we do not specify a default of '1' in the denominator, but this is being discussed. Other examples: 200 mcg/min or 200 mcg/1 minute; 1 liter/8 hours.", 0, java.lang.Integer.MAX_VALUE, rate));
583          childrenList.add(new Property("maxDosePerPeriod", "Ratio", "The maximum total quantity of a therapeutic substance that may be administered to a subject over the period of time.  For example, 1000mg in 24 hours.", 0, java.lang.Integer.MAX_VALUE, maxDosePerPeriod));
584        }
585
586      @Override
587      public void setProperty(String name, Base value) throws FHIRException {
588        if (name.equals("text"))
589          this.text = castToString(value); // StringType
590        else if (name.equals("timing"))
591          this.timing = castToTiming(value); // Timing
592        else if (name.equals("asNeeded[x]"))
593          this.asNeeded = (Type) value; // Type
594        else if (name.equals("site[x]"))
595          this.site = (Type) value; // Type
596        else if (name.equals("route"))
597          this.route = castToCodeableConcept(value); // CodeableConcept
598        else if (name.equals("method"))
599          this.method = castToCodeableConcept(value); // CodeableConcept
600        else if (name.equals("quantity[x]"))
601          this.quantity = (Type) value; // Type
602        else if (name.equals("rate[x]"))
603          this.rate = (Type) value; // Type
604        else if (name.equals("maxDosePerPeriod"))
605          this.maxDosePerPeriod = castToRatio(value); // Ratio
606        else
607          super.setProperty(name, value);
608      }
609
610      @Override
611      public Base addChild(String name) throws FHIRException {
612        if (name.equals("text")) {
613          throw new FHIRException("Cannot call addChild on a primitive type MedicationStatement.text");
614        }
615        else if (name.equals("timing")) {
616          this.timing = new Timing();
617          return this.timing;
618        }
619        else if (name.equals("asNeededBoolean")) {
620          this.asNeeded = new BooleanType();
621          return this.asNeeded;
622        }
623        else if (name.equals("asNeededCodeableConcept")) {
624          this.asNeeded = new CodeableConcept();
625          return this.asNeeded;
626        }
627        else if (name.equals("siteCodeableConcept")) {
628          this.site = new CodeableConcept();
629          return this.site;
630        }
631        else if (name.equals("siteReference")) {
632          this.site = new Reference();
633          return this.site;
634        }
635        else if (name.equals("route")) {
636          this.route = new CodeableConcept();
637          return this.route;
638        }
639        else if (name.equals("method")) {
640          this.method = new CodeableConcept();
641          return this.method;
642        }
643        else if (name.equals("quantitySimpleQuantity")) {
644          this.quantity = new SimpleQuantity();
645          return this.quantity;
646        }
647        else if (name.equals("quantityRange")) {
648          this.quantity = new Range();
649          return this.quantity;
650        }
651        else if (name.equals("rateRatio")) {
652          this.rate = new Ratio();
653          return this.rate;
654        }
655        else if (name.equals("rateRange")) {
656          this.rate = new Range();
657          return this.rate;
658        }
659        else if (name.equals("maxDosePerPeriod")) {
660          this.maxDosePerPeriod = new Ratio();
661          return this.maxDosePerPeriod;
662        }
663        else
664          return super.addChild(name);
665      }
666
667      public MedicationStatementDosageComponent copy() {
668        MedicationStatementDosageComponent dst = new MedicationStatementDosageComponent();
669        copyValues(dst);
670        dst.text = text == null ? null : text.copy();
671        dst.timing = timing == null ? null : timing.copy();
672        dst.asNeeded = asNeeded == null ? null : asNeeded.copy();
673        dst.site = site == null ? null : site.copy();
674        dst.route = route == null ? null : route.copy();
675        dst.method = method == null ? null : method.copy();
676        dst.quantity = quantity == null ? null : quantity.copy();
677        dst.rate = rate == null ? null : rate.copy();
678        dst.maxDosePerPeriod = maxDosePerPeriod == null ? null : maxDosePerPeriod.copy();
679        return dst;
680      }
681
682      @Override
683      public boolean equalsDeep(Base other) {
684        if (!super.equalsDeep(other))
685          return false;
686        if (!(other instanceof MedicationStatementDosageComponent))
687          return false;
688        MedicationStatementDosageComponent o = (MedicationStatementDosageComponent) other;
689        return compareDeep(text, o.text, true) && compareDeep(timing, o.timing, true) && compareDeep(asNeeded, o.asNeeded, true)
690           && compareDeep(site, o.site, true) && compareDeep(route, o.route, true) && compareDeep(method, o.method, true)
691           && compareDeep(quantity, o.quantity, true) && compareDeep(rate, o.rate, true) && compareDeep(maxDosePerPeriod, o.maxDosePerPeriod, true)
692          ;
693      }
694
695      @Override
696      public boolean equalsShallow(Base other) {
697        if (!super.equalsShallow(other))
698          return false;
699        if (!(other instanceof MedicationStatementDosageComponent))
700          return false;
701        MedicationStatementDosageComponent o = (MedicationStatementDosageComponent) other;
702        return compareValues(text, o.text, true);
703      }
704
705      public boolean isEmpty() {
706        return super.isEmpty() && (text == null || text.isEmpty()) && (timing == null || timing.isEmpty())
707           && (asNeeded == null || asNeeded.isEmpty()) && (site == null || site.isEmpty()) && (route == null || route.isEmpty())
708           && (method == null || method.isEmpty()) && (quantity == null || quantity.isEmpty()) && (rate == null || rate.isEmpty())
709           && (maxDosePerPeriod == null || maxDosePerPeriod.isEmpty());
710      }
711
712  public String fhirType() {
713    return "MedicationStatement.dosage";
714
715  }
716
717  }
718
719    /**
720     * External identifier - FHIR will generate its own internal identifiers (probably URLs) which do not need to be explicitly managed by the resource.  The identifier here is one that would be used by another non-FHIR system - for example an automated medication pump would provide a record each time it operated; an administration while the patient was off the ward might be made with a different system and entered after the event.  Particularly important if these records have to be updated.
721     */
722    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
723    @Description(shortDefinition="External identifier", formalDefinition="External identifier - FHIR will generate its own internal identifiers (probably URLs) which do not need to be explicitly managed by the resource.  The identifier here is one that would be used by another non-FHIR system - for example an automated medication pump would provide a record each time it operated; an administration while the patient was off the ward might be made with a different system and entered after the event.  Particularly important if these records have to be updated." )
724    protected List<Identifier> identifier;
725
726    /**
727     * The person or animal who is/was taking the medication.
728     */
729    @Child(name = "patient", type = {Patient.class}, order=1, min=1, max=1, modifier=false, summary=true)
730    @Description(shortDefinition="Who is/was taking  the medication", formalDefinition="The person or animal who is/was taking the medication." )
731    protected Reference patient;
732
733    /**
734     * The actual object that is the target of the reference (The person or animal who is/was taking the medication.)
735     */
736    protected Patient patientTarget;
737
738    /**
739     * The person who provided the information about the taking of this medication.
740     */
741    @Child(name = "informationSource", type = {Patient.class, Practitioner.class, RelatedPerson.class}, order=2, min=0, max=1, modifier=false, summary=true)
742    @Description(shortDefinition="", formalDefinition="The person who provided the information about the taking of this medication." )
743    protected Reference informationSource;
744
745    /**
746     * The actual object that is the target of the reference (The person who provided the information about the taking of this medication.)
747     */
748    protected Resource informationSourceTarget;
749
750    /**
751     * The date when the medication statement was asserted by the information source.
752     */
753    @Child(name = "dateAsserted", type = {DateTimeType.class}, order=3, min=0, max=1, modifier=false, summary=true)
754    @Description(shortDefinition="When the statement was asserted?", formalDefinition="The date when the medication statement was asserted by the information source." )
755    protected DateTimeType dateAsserted;
756
757    /**
758     * A code representing the patient or other source's judgment about the state of the medication used that this statement is about.  Generally this will be active or completed.
759     */
760    @Child(name = "status", type = {CodeType.class}, order=4, min=1, max=1, modifier=true, summary=true)
761    @Description(shortDefinition="active | completed | entered-in-error | intended", formalDefinition="A code representing the patient or other source's judgment about the state of the medication used that this statement is about.  Generally this will be active or completed." )
762    protected Enumeration<MedicationStatementStatus> status;
763
764    /**
765     * Set this to true if the record is saying that the medication was NOT taken.
766     */
767    @Child(name = "wasNotTaken", type = {BooleanType.class}, order=5, min=0, max=1, modifier=true, summary=true)
768    @Description(shortDefinition="True if medication is/was not being taken", formalDefinition="Set this to true if the record is saying that the medication was NOT taken." )
769    protected BooleanType wasNotTaken;
770
771    /**
772     * A code indicating why the medication was not taken.
773     */
774    @Child(name = "reasonNotTaken", type = {CodeableConcept.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
775    @Description(shortDefinition="True if asserting medication was not given", formalDefinition="A code indicating why the medication was not taken." )
776    protected List<CodeableConcept> reasonNotTaken;
777
778    /**
779     * A reason for why the medication is being/was taken.
780     */
781    @Child(name = "reasonForUse", type = {CodeableConcept.class, Condition.class}, order=7, min=0, max=1, modifier=false, summary=true)
782    @Description(shortDefinition="", formalDefinition="A reason for why the medication is being/was taken." )
783    protected Type reasonForUse;
784
785    /**
786     * The interval of time during which it is being asserted that the patient was taking the medication (or was not taking, when the wasNotGiven element is true).
787     */
788    @Child(name = "effective", type = {DateTimeType.class, Period.class}, order=8, min=0, max=1, modifier=false, summary=true)
789    @Description(shortDefinition="Over what period was medication consumed?", formalDefinition="The interval of time during which it is being asserted that the patient was taking the medication (or was not taking, when the wasNotGiven element is true)." )
790    protected Type effective;
791
792    /**
793     * Provides extra information about the medication statement that is not conveyed by the other attributes.
794     */
795    @Child(name = "note", type = {StringType.class}, order=9, min=0, max=1, modifier=false, summary=true)
796    @Description(shortDefinition="Further information about the statement", formalDefinition="Provides extra information about the medication statement that is not conveyed by the other attributes." )
797    protected StringType note;
798
799    /**
800     * Allows linking the MedicationStatement to the underlying MedicationOrder, or to other information that supports the MedicationStatement.
801     */
802    @Child(name = "supportingInformation", type = {}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
803    @Description(shortDefinition="Additional supporting information", formalDefinition="Allows linking the MedicationStatement to the underlying MedicationOrder, or to other information that supports the MedicationStatement." )
804    protected List<Reference> supportingInformation;
805    /**
806     * The actual objects that are the target of the reference (Allows linking the MedicationStatement to the underlying MedicationOrder, or to other information that supports the MedicationStatement.)
807     */
808    protected List<Resource> supportingInformationTarget;
809
810
811    /**
812     * 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.
813     */
814    @Child(name = "medication", type = {CodeableConcept.class, Medication.class}, order=11, min=1, max=1, modifier=false, summary=true)
815    @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." )
816    protected Type medication;
817
818    /**
819     * Indicates how the medication is/was used by the patient.
820     */
821    @Child(name = "dosage", type = {}, order=12, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
822    @Description(shortDefinition="Details of how medication was taken", formalDefinition="Indicates how the medication is/was used by the patient." )
823    protected List<MedicationStatementDosageComponent> dosage;
824
825    private static final long serialVersionUID = 55795672L;
826
827  /*
828   * Constructor
829   */
830    public MedicationStatement() {
831      super();
832    }
833
834  /*
835   * Constructor
836   */
837    public MedicationStatement(Reference patient, Enumeration<MedicationStatementStatus> status, Type medication) {
838      super();
839      this.patient = patient;
840      this.status = status;
841      this.medication = medication;
842    }
843
844    /**
845     * @return {@link #identifier} (External identifier - FHIR will generate its own internal identifiers (probably URLs) which do not need to be explicitly managed by the resource.  The identifier here is one that would be used by another non-FHIR system - for example an automated medication pump would provide a record each time it operated; an administration while the patient was off the ward might be made with a different system and entered after the event.  Particularly important if these records have to be updated.)
846     */
847    public List<Identifier> getIdentifier() { 
848      if (this.identifier == null)
849        this.identifier = new ArrayList<Identifier>();
850      return this.identifier;
851    }
852
853    public boolean hasIdentifier() { 
854      if (this.identifier == null)
855        return false;
856      for (Identifier item : this.identifier)
857        if (!item.isEmpty())
858          return true;
859      return false;
860    }
861
862    /**
863     * @return {@link #identifier} (External identifier - FHIR will generate its own internal identifiers (probably URLs) which do not need to be explicitly managed by the resource.  The identifier here is one that would be used by another non-FHIR system - for example an automated medication pump would provide a record each time it operated; an administration while the patient was off the ward might be made with a different system and entered after the event.  Particularly important if these records have to be updated.)
864     */
865    // syntactic sugar
866    public Identifier addIdentifier() { //3
867      Identifier t = new Identifier();
868      if (this.identifier == null)
869        this.identifier = new ArrayList<Identifier>();
870      this.identifier.add(t);
871      return t;
872    }
873
874    // syntactic sugar
875    public MedicationStatement addIdentifier(Identifier t) { //3
876      if (t == null)
877        return this;
878      if (this.identifier == null)
879        this.identifier = new ArrayList<Identifier>();
880      this.identifier.add(t);
881      return this;
882    }
883
884    /**
885     * @return {@link #patient} (The person or animal who is/was taking the medication.)
886     */
887    public Reference getPatient() { 
888      if (this.patient == null)
889        if (Configuration.errorOnAutoCreate())
890          throw new Error("Attempt to auto-create MedicationStatement.patient");
891        else if (Configuration.doAutoCreate())
892          this.patient = new Reference(); // cc
893      return this.patient;
894    }
895
896    public boolean hasPatient() { 
897      return this.patient != null && !this.patient.isEmpty();
898    }
899
900    /**
901     * @param value {@link #patient} (The person or animal who is/was taking the medication.)
902     */
903    public MedicationStatement setPatient(Reference value) { 
904      this.patient = value;
905      return this;
906    }
907
908    /**
909     * @return {@link #patient} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The person or animal who is/was taking the medication.)
910     */
911    public Patient getPatientTarget() { 
912      if (this.patientTarget == null)
913        if (Configuration.errorOnAutoCreate())
914          throw new Error("Attempt to auto-create MedicationStatement.patient");
915        else if (Configuration.doAutoCreate())
916          this.patientTarget = new Patient(); // aa
917      return this.patientTarget;
918    }
919
920    /**
921     * @param value {@link #patient} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The person or animal who is/was taking the medication.)
922     */
923    public MedicationStatement setPatientTarget(Patient value) { 
924      this.patientTarget = value;
925      return this;
926    }
927
928    /**
929     * @return {@link #informationSource} (The person who provided the information about the taking of this medication.)
930     */
931    public Reference getInformationSource() { 
932      if (this.informationSource == null)
933        if (Configuration.errorOnAutoCreate())
934          throw new Error("Attempt to auto-create MedicationStatement.informationSource");
935        else if (Configuration.doAutoCreate())
936          this.informationSource = new Reference(); // cc
937      return this.informationSource;
938    }
939
940    public boolean hasInformationSource() { 
941      return this.informationSource != null && !this.informationSource.isEmpty();
942    }
943
944    /**
945     * @param value {@link #informationSource} (The person who provided the information about the taking of this medication.)
946     */
947    public MedicationStatement setInformationSource(Reference value) { 
948      this.informationSource = value;
949      return this;
950    }
951
952    /**
953     * @return {@link #informationSource} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The person who provided the information about the taking of this medication.)
954     */
955    public Resource getInformationSourceTarget() { 
956      return this.informationSourceTarget;
957    }
958
959    /**
960     * @param value {@link #informationSource} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The person who provided the information about the taking of this medication.)
961     */
962    public MedicationStatement setInformationSourceTarget(Resource value) { 
963      this.informationSourceTarget = value;
964      return this;
965    }
966
967    /**
968     * @return {@link #dateAsserted} (The date when the medication statement 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
969     */
970    public DateTimeType getDateAssertedElement() { 
971      if (this.dateAsserted == null)
972        if (Configuration.errorOnAutoCreate())
973          throw new Error("Attempt to auto-create MedicationStatement.dateAsserted");
974        else if (Configuration.doAutoCreate())
975          this.dateAsserted = new DateTimeType(); // bb
976      return this.dateAsserted;
977    }
978
979    public boolean hasDateAssertedElement() { 
980      return this.dateAsserted != null && !this.dateAsserted.isEmpty();
981    }
982
983    public boolean hasDateAsserted() { 
984      return this.dateAsserted != null && !this.dateAsserted.isEmpty();
985    }
986
987    /**
988     * @param value {@link #dateAsserted} (The date when the medication statement 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
989     */
990    public MedicationStatement setDateAssertedElement(DateTimeType value) { 
991      this.dateAsserted = value;
992      return this;
993    }
994
995    /**
996     * @return The date when the medication statement was asserted by the information source.
997     */
998    public Date getDateAsserted() { 
999      return this.dateAsserted == null ? null : this.dateAsserted.getValue();
1000    }
1001
1002    /**
1003     * @param value The date when the medication statement was asserted by the information source.
1004     */
1005    public MedicationStatement setDateAsserted(Date value) { 
1006      if (value == null)
1007        this.dateAsserted = null;
1008      else {
1009        if (this.dateAsserted == null)
1010          this.dateAsserted = new DateTimeType();
1011        this.dateAsserted.setValue(value);
1012      }
1013      return this;
1014    }
1015
1016    /**
1017     * @return {@link #status} (A code representing the patient or other source's judgment about the state of the medication used that this statement 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
1018     */
1019    public Enumeration<MedicationStatementStatus> getStatusElement() { 
1020      if (this.status == null)
1021        if (Configuration.errorOnAutoCreate())
1022          throw new Error("Attempt to auto-create MedicationStatement.status");
1023        else if (Configuration.doAutoCreate())
1024          this.status = new Enumeration<MedicationStatementStatus>(new MedicationStatementStatusEnumFactory()); // bb
1025      return this.status;
1026    }
1027
1028    public boolean hasStatusElement() { 
1029      return this.status != null && !this.status.isEmpty();
1030    }
1031
1032    public boolean hasStatus() { 
1033      return this.status != null && !this.status.isEmpty();
1034    }
1035
1036    /**
1037     * @param value {@link #status} (A code representing the patient or other source's judgment about the state of the medication used that this statement 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
1038     */
1039    public MedicationStatement setStatusElement(Enumeration<MedicationStatementStatus> value) { 
1040      this.status = value;
1041      return this;
1042    }
1043
1044    /**
1045     * @return A code representing the patient or other source's judgment about the state of the medication used that this statement is about.  Generally this will be active or completed.
1046     */
1047    public MedicationStatementStatus getStatus() { 
1048      return this.status == null ? null : this.status.getValue();
1049    }
1050
1051    /**
1052     * @param value A code representing the patient or other source's judgment about the state of the medication used that this statement is about.  Generally this will be active or completed.
1053     */
1054    public MedicationStatement setStatus(MedicationStatementStatus value) { 
1055        if (this.status == null)
1056          this.status = new Enumeration<MedicationStatementStatus>(new MedicationStatementStatusEnumFactory());
1057        this.status.setValue(value);
1058      return this;
1059    }
1060
1061    /**
1062     * @return {@link #wasNotTaken} (Set this to true if the record is saying that the medication was NOT taken.). This is the underlying object with id, value and extensions. The accessor "getWasNotTaken" gives direct access to the value
1063     */
1064    public BooleanType getWasNotTakenElement() { 
1065      if (this.wasNotTaken == null)
1066        if (Configuration.errorOnAutoCreate())
1067          throw new Error("Attempt to auto-create MedicationStatement.wasNotTaken");
1068        else if (Configuration.doAutoCreate())
1069          this.wasNotTaken = new BooleanType(); // bb
1070      return this.wasNotTaken;
1071    }
1072
1073    public boolean hasWasNotTakenElement() { 
1074      return this.wasNotTaken != null && !this.wasNotTaken.isEmpty();
1075    }
1076
1077    public boolean hasWasNotTaken() { 
1078      return this.wasNotTaken != null && !this.wasNotTaken.isEmpty();
1079    }
1080
1081    /**
1082     * @param value {@link #wasNotTaken} (Set this to true if the record is saying that the medication was NOT taken.). This is the underlying object with id, value and extensions. The accessor "getWasNotTaken" gives direct access to the value
1083     */
1084    public MedicationStatement setWasNotTakenElement(BooleanType value) { 
1085      this.wasNotTaken = value;
1086      return this;
1087    }
1088
1089    /**
1090     * @return Set this to true if the record is saying that the medication was NOT taken.
1091     */
1092    public boolean getWasNotTaken() { 
1093      return this.wasNotTaken == null || this.wasNotTaken.isEmpty() ? false : this.wasNotTaken.getValue();
1094    }
1095
1096    /**
1097     * @param value Set this to true if the record is saying that the medication was NOT taken.
1098     */
1099    public MedicationStatement setWasNotTaken(boolean value) { 
1100        if (this.wasNotTaken == null)
1101          this.wasNotTaken = new BooleanType();
1102        this.wasNotTaken.setValue(value);
1103      return this;
1104    }
1105
1106    /**
1107     * @return {@link #reasonNotTaken} (A code indicating why the medication was not taken.)
1108     */
1109    public List<CodeableConcept> getReasonNotTaken() { 
1110      if (this.reasonNotTaken == null)
1111        this.reasonNotTaken = new ArrayList<CodeableConcept>();
1112      return this.reasonNotTaken;
1113    }
1114
1115    public boolean hasReasonNotTaken() { 
1116      if (this.reasonNotTaken == null)
1117        return false;
1118      for (CodeableConcept item : this.reasonNotTaken)
1119        if (!item.isEmpty())
1120          return true;
1121      return false;
1122    }
1123
1124    /**
1125     * @return {@link #reasonNotTaken} (A code indicating why the medication was not taken.)
1126     */
1127    // syntactic sugar
1128    public CodeableConcept addReasonNotTaken() { //3
1129      CodeableConcept t = new CodeableConcept();
1130      if (this.reasonNotTaken == null)
1131        this.reasonNotTaken = new ArrayList<CodeableConcept>();
1132      this.reasonNotTaken.add(t);
1133      return t;
1134    }
1135
1136    // syntactic sugar
1137    public MedicationStatement addReasonNotTaken(CodeableConcept t) { //3
1138      if (t == null)
1139        return this;
1140      if (this.reasonNotTaken == null)
1141        this.reasonNotTaken = new ArrayList<CodeableConcept>();
1142      this.reasonNotTaken.add(t);
1143      return this;
1144    }
1145
1146    /**
1147     * @return {@link #reasonForUse} (A reason for why the medication is being/was taken.)
1148     */
1149    public Type getReasonForUse() { 
1150      return this.reasonForUse;
1151    }
1152
1153    /**
1154     * @return {@link #reasonForUse} (A reason for why the medication is being/was taken.)
1155     */
1156    public CodeableConcept getReasonForUseCodeableConcept() throws FHIRException { 
1157      if (!(this.reasonForUse instanceof CodeableConcept))
1158        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.reasonForUse.getClass().getName()+" was encountered");
1159      return (CodeableConcept) this.reasonForUse;
1160    }
1161
1162    public boolean hasReasonForUseCodeableConcept() { 
1163      return this.reasonForUse instanceof CodeableConcept;
1164    }
1165
1166    /**
1167     * @return {@link #reasonForUse} (A reason for why the medication is being/was taken.)
1168     */
1169    public Reference getReasonForUseReference() throws FHIRException { 
1170      if (!(this.reasonForUse instanceof Reference))
1171        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.reasonForUse.getClass().getName()+" was encountered");
1172      return (Reference) this.reasonForUse;
1173    }
1174
1175    public boolean hasReasonForUseReference() { 
1176      return this.reasonForUse instanceof Reference;
1177    }
1178
1179    public boolean hasReasonForUse() { 
1180      return this.reasonForUse != null && !this.reasonForUse.isEmpty();
1181    }
1182
1183    /**
1184     * @param value {@link #reasonForUse} (A reason for why the medication is being/was taken.)
1185     */
1186    public MedicationStatement setReasonForUse(Type value) { 
1187      this.reasonForUse = value;
1188      return this;
1189    }
1190
1191    /**
1192     * @return {@link #effective} (The interval of time during which it is being asserted that the patient was taking the medication (or was not taking, when the wasNotGiven element is true).)
1193     */
1194    public Type getEffective() { 
1195      return this.effective;
1196    }
1197
1198    /**
1199     * @return {@link #effective} (The interval of time during which it is being asserted that the patient was taking the medication (or was not taking, when the wasNotGiven element is true).)
1200     */
1201    public DateTimeType getEffectiveDateTimeType() throws FHIRException { 
1202      if (!(this.effective instanceof DateTimeType))
1203        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.effective.getClass().getName()+" was encountered");
1204      return (DateTimeType) this.effective;
1205    }
1206
1207    public boolean hasEffectiveDateTimeType() { 
1208      return this.effective instanceof DateTimeType;
1209    }
1210
1211    /**
1212     * @return {@link #effective} (The interval of time during which it is being asserted that the patient was taking the medication (or was not taking, when the wasNotGiven element is true).)
1213     */
1214    public Period getEffectivePeriod() throws FHIRException { 
1215      if (!(this.effective instanceof Period))
1216        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.effective.getClass().getName()+" was encountered");
1217      return (Period) this.effective;
1218    }
1219
1220    public boolean hasEffectivePeriod() { 
1221      return this.effective instanceof Period;
1222    }
1223
1224    public boolean hasEffective() { 
1225      return this.effective != null && !this.effective.isEmpty();
1226    }
1227
1228    /**
1229     * @param value {@link #effective} (The interval of time during which it is being asserted that the patient was taking the medication (or was not taking, when the wasNotGiven element is true).)
1230     */
1231    public MedicationStatement setEffective(Type value) { 
1232      this.effective = value;
1233      return this;
1234    }
1235
1236    /**
1237     * @return {@link #note} (Provides extra information about the medication statement that is not conveyed by the other attributes.). This is the underlying object with id, value and extensions. The accessor "getNote" gives direct access to the value
1238     */
1239    public StringType getNoteElement() { 
1240      if (this.note == null)
1241        if (Configuration.errorOnAutoCreate())
1242          throw new Error("Attempt to auto-create MedicationStatement.note");
1243        else if (Configuration.doAutoCreate())
1244          this.note = new StringType(); // bb
1245      return this.note;
1246    }
1247
1248    public boolean hasNoteElement() { 
1249      return this.note != null && !this.note.isEmpty();
1250    }
1251
1252    public boolean hasNote() { 
1253      return this.note != null && !this.note.isEmpty();
1254    }
1255
1256    /**
1257     * @param value {@link #note} (Provides extra information about the medication statement that is not conveyed by the other attributes.). This is the underlying object with id, value and extensions. The accessor "getNote" gives direct access to the value
1258     */
1259    public MedicationStatement setNoteElement(StringType value) { 
1260      this.note = value;
1261      return this;
1262    }
1263
1264    /**
1265     * @return Provides extra information about the medication statement that is not conveyed by the other attributes.
1266     */
1267    public String getNote() { 
1268      return this.note == null ? null : this.note.getValue();
1269    }
1270
1271    /**
1272     * @param value Provides extra information about the medication statement that is not conveyed by the other attributes.
1273     */
1274    public MedicationStatement setNote(String value) { 
1275      if (Utilities.noString(value))
1276        this.note = null;
1277      else {
1278        if (this.note == null)
1279          this.note = new StringType();
1280        this.note.setValue(value);
1281      }
1282      return this;
1283    }
1284
1285    /**
1286     * @return {@link #supportingInformation} (Allows linking the MedicationStatement to the underlying MedicationOrder, or to other information that supports the MedicationStatement.)
1287     */
1288    public List<Reference> getSupportingInformation() { 
1289      if (this.supportingInformation == null)
1290        this.supportingInformation = new ArrayList<Reference>();
1291      return this.supportingInformation;
1292    }
1293
1294    public boolean hasSupportingInformation() { 
1295      if (this.supportingInformation == null)
1296        return false;
1297      for (Reference item : this.supportingInformation)
1298        if (!item.isEmpty())
1299          return true;
1300      return false;
1301    }
1302
1303    /**
1304     * @return {@link #supportingInformation} (Allows linking the MedicationStatement to the underlying MedicationOrder, or to other information that supports the MedicationStatement.)
1305     */
1306    // syntactic sugar
1307    public Reference addSupportingInformation() { //3
1308      Reference t = new Reference();
1309      if (this.supportingInformation == null)
1310        this.supportingInformation = new ArrayList<Reference>();
1311      this.supportingInformation.add(t);
1312      return t;
1313    }
1314
1315    // syntactic sugar
1316    public MedicationStatement addSupportingInformation(Reference t) { //3
1317      if (t == null)
1318        return this;
1319      if (this.supportingInformation == null)
1320        this.supportingInformation = new ArrayList<Reference>();
1321      this.supportingInformation.add(t);
1322      return this;
1323    }
1324
1325    /**
1326     * @return {@link #supportingInformation} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. Allows linking the MedicationStatement to the underlying MedicationOrder, or to other information that supports the MedicationStatement.)
1327     */
1328    public List<Resource> getSupportingInformationTarget() { 
1329      if (this.supportingInformationTarget == null)
1330        this.supportingInformationTarget = new ArrayList<Resource>();
1331      return this.supportingInformationTarget;
1332    }
1333
1334    /**
1335     * @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.)
1336     */
1337    public Type getMedication() { 
1338      return this.medication;
1339    }
1340
1341    /**
1342     * @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.)
1343     */
1344    public CodeableConcept getMedicationCodeableConcept() throws FHIRException { 
1345      if (!(this.medication instanceof CodeableConcept))
1346        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.medication.getClass().getName()+" was encountered");
1347      return (CodeableConcept) this.medication;
1348    }
1349
1350    public boolean hasMedicationCodeableConcept() { 
1351      return this.medication instanceof CodeableConcept;
1352    }
1353
1354    /**
1355     * @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.)
1356     */
1357    public Reference getMedicationReference() throws FHIRException { 
1358      if (!(this.medication instanceof Reference))
1359        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.medication.getClass().getName()+" was encountered");
1360      return (Reference) this.medication;
1361    }
1362
1363    public boolean hasMedicationReference() { 
1364      return this.medication instanceof Reference;
1365    }
1366
1367    public boolean hasMedication() { 
1368      return this.medication != null && !this.medication.isEmpty();
1369    }
1370
1371    /**
1372     * @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.)
1373     */
1374    public MedicationStatement setMedication(Type value) { 
1375      this.medication = value;
1376      return this;
1377    }
1378
1379    /**
1380     * @return {@link #dosage} (Indicates how the medication is/was used by the patient.)
1381     */
1382    public List<MedicationStatementDosageComponent> getDosage() { 
1383      if (this.dosage == null)
1384        this.dosage = new ArrayList<MedicationStatementDosageComponent>();
1385      return this.dosage;
1386    }
1387
1388    public boolean hasDosage() { 
1389      if (this.dosage == null)
1390        return false;
1391      for (MedicationStatementDosageComponent item : this.dosage)
1392        if (!item.isEmpty())
1393          return true;
1394      return false;
1395    }
1396
1397    /**
1398     * @return {@link #dosage} (Indicates how the medication is/was used by the patient.)
1399     */
1400    // syntactic sugar
1401    public MedicationStatementDosageComponent addDosage() { //3
1402      MedicationStatementDosageComponent t = new MedicationStatementDosageComponent();
1403      if (this.dosage == null)
1404        this.dosage = new ArrayList<MedicationStatementDosageComponent>();
1405      this.dosage.add(t);
1406      return t;
1407    }
1408
1409    // syntactic sugar
1410    public MedicationStatement addDosage(MedicationStatementDosageComponent t) { //3
1411      if (t == null)
1412        return this;
1413      if (this.dosage == null)
1414        this.dosage = new ArrayList<MedicationStatementDosageComponent>();
1415      this.dosage.add(t);
1416      return this;
1417    }
1418
1419      protected void listChildren(List<Property> childrenList) {
1420        super.listChildren(childrenList);
1421        childrenList.add(new Property("identifier", "Identifier", "External identifier - FHIR will generate its own internal identifiers (probably URLs) which do not need to be explicitly managed by the resource.  The identifier here is one that would be used by another non-FHIR system - for example an automated medication pump would provide a record each time it operated; an administration while the patient was off the ward might be made with a different system and entered after the event.  Particularly important if these records have to be updated.", 0, java.lang.Integer.MAX_VALUE, identifier));
1422        childrenList.add(new Property("patient", "Reference(Patient)", "The person or animal who is/was taking the medication.", 0, java.lang.Integer.MAX_VALUE, patient));
1423        childrenList.add(new Property("informationSource", "Reference(Patient|Practitioner|RelatedPerson)", "The person who provided the information about the taking of this medication.", 0, java.lang.Integer.MAX_VALUE, informationSource));
1424        childrenList.add(new Property("dateAsserted", "dateTime", "The date when the medication statement was asserted by the information source.", 0, java.lang.Integer.MAX_VALUE, dateAsserted));
1425        childrenList.add(new Property("status", "code", "A code representing the patient or other source's judgment about the state of the medication used that this statement is about.  Generally this will be active or completed.", 0, java.lang.Integer.MAX_VALUE, status));
1426        childrenList.add(new Property("wasNotTaken", "boolean", "Set this to true if the record is saying that the medication was NOT taken.", 0, java.lang.Integer.MAX_VALUE, wasNotTaken));
1427        childrenList.add(new Property("reasonNotTaken", "CodeableConcept", "A code indicating why the medication was not taken.", 0, java.lang.Integer.MAX_VALUE, reasonNotTaken));
1428        childrenList.add(new Property("reasonForUse[x]", "CodeableConcept|Reference(Condition)", "A reason for why the medication is being/was taken.", 0, java.lang.Integer.MAX_VALUE, reasonForUse));
1429        childrenList.add(new Property("effective[x]", "dateTime|Period", "The interval of time during which it is being asserted that the patient was taking the medication (or was not taking, when the wasNotGiven element is true).", 0, java.lang.Integer.MAX_VALUE, effective));
1430        childrenList.add(new Property("note", "string", "Provides extra information about the medication statement that is not conveyed by the other attributes.", 0, java.lang.Integer.MAX_VALUE, note));
1431        childrenList.add(new Property("supportingInformation", "Reference(Any)", "Allows linking the MedicationStatement to the underlying MedicationOrder, or to other information that supports the MedicationStatement.", 0, java.lang.Integer.MAX_VALUE, supportingInformation));
1432        childrenList.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, java.lang.Integer.MAX_VALUE, medication));
1433        childrenList.add(new Property("dosage", "", "Indicates how the medication is/was used by the patient.", 0, java.lang.Integer.MAX_VALUE, dosage));
1434      }
1435
1436      @Override
1437      public void setProperty(String name, Base value) throws FHIRException {
1438        if (name.equals("identifier"))
1439          this.getIdentifier().add(castToIdentifier(value));
1440        else if (name.equals("patient"))
1441          this.patient = castToReference(value); // Reference
1442        else if (name.equals("informationSource"))
1443          this.informationSource = castToReference(value); // Reference
1444        else if (name.equals("dateAsserted"))
1445          this.dateAsserted = castToDateTime(value); // DateTimeType
1446        else if (name.equals("status"))
1447          this.status = new MedicationStatementStatusEnumFactory().fromType(value); // Enumeration<MedicationStatementStatus>
1448        else if (name.equals("wasNotTaken"))
1449          this.wasNotTaken = castToBoolean(value); // BooleanType
1450        else if (name.equals("reasonNotTaken"))
1451          this.getReasonNotTaken().add(castToCodeableConcept(value));
1452        else if (name.equals("reasonForUse[x]"))
1453          this.reasonForUse = (Type) value; // Type
1454        else if (name.equals("effective[x]"))
1455          this.effective = (Type) value; // Type
1456        else if (name.equals("note"))
1457          this.note = castToString(value); // StringType
1458        else if (name.equals("supportingInformation"))
1459          this.getSupportingInformation().add(castToReference(value));
1460        else if (name.equals("medication[x]"))
1461          this.medication = (Type) value; // Type
1462        else if (name.equals("dosage"))
1463          this.getDosage().add((MedicationStatementDosageComponent) value);
1464        else
1465          super.setProperty(name, value);
1466      }
1467
1468      @Override
1469      public Base addChild(String name) throws FHIRException {
1470        if (name.equals("identifier")) {
1471          return addIdentifier();
1472        }
1473        else if (name.equals("patient")) {
1474          this.patient = new Reference();
1475          return this.patient;
1476        }
1477        else if (name.equals("informationSource")) {
1478          this.informationSource = new Reference();
1479          return this.informationSource;
1480        }
1481        else if (name.equals("dateAsserted")) {
1482          throw new FHIRException("Cannot call addChild on a primitive type MedicationStatement.dateAsserted");
1483        }
1484        else if (name.equals("status")) {
1485          throw new FHIRException("Cannot call addChild on a primitive type MedicationStatement.status");
1486        }
1487        else if (name.equals("wasNotTaken")) {
1488          throw new FHIRException("Cannot call addChild on a primitive type MedicationStatement.wasNotTaken");
1489        }
1490        else if (name.equals("reasonNotTaken")) {
1491          return addReasonNotTaken();
1492        }
1493        else if (name.equals("reasonForUseCodeableConcept")) {
1494          this.reasonForUse = new CodeableConcept();
1495          return this.reasonForUse;
1496        }
1497        else if (name.equals("reasonForUseReference")) {
1498          this.reasonForUse = new Reference();
1499          return this.reasonForUse;
1500        }
1501        else if (name.equals("effectiveDateTime")) {
1502          this.effective = new DateTimeType();
1503          return this.effective;
1504        }
1505        else if (name.equals("effectivePeriod")) {
1506          this.effective = new Period();
1507          return this.effective;
1508        }
1509        else if (name.equals("note")) {
1510          throw new FHIRException("Cannot call addChild on a primitive type MedicationStatement.note");
1511        }
1512        else if (name.equals("supportingInformation")) {
1513          return addSupportingInformation();
1514        }
1515        else if (name.equals("medicationCodeableConcept")) {
1516          this.medication = new CodeableConcept();
1517          return this.medication;
1518        }
1519        else if (name.equals("medicationReference")) {
1520          this.medication = new Reference();
1521          return this.medication;
1522        }
1523        else if (name.equals("dosage")) {
1524          return addDosage();
1525        }
1526        else
1527          return super.addChild(name);
1528      }
1529
1530  public String fhirType() {
1531    return "MedicationStatement";
1532
1533  }
1534
1535      public MedicationStatement copy() {
1536        MedicationStatement dst = new MedicationStatement();
1537        copyValues(dst);
1538        if (identifier != null) {
1539          dst.identifier = new ArrayList<Identifier>();
1540          for (Identifier i : identifier)
1541            dst.identifier.add(i.copy());
1542        };
1543        dst.patient = patient == null ? null : patient.copy();
1544        dst.informationSource = informationSource == null ? null : informationSource.copy();
1545        dst.dateAsserted = dateAsserted == null ? null : dateAsserted.copy();
1546        dst.status = status == null ? null : status.copy();
1547        dst.wasNotTaken = wasNotTaken == null ? null : wasNotTaken.copy();
1548        if (reasonNotTaken != null) {
1549          dst.reasonNotTaken = new ArrayList<CodeableConcept>();
1550          for (CodeableConcept i : reasonNotTaken)
1551            dst.reasonNotTaken.add(i.copy());
1552        };
1553        dst.reasonForUse = reasonForUse == null ? null : reasonForUse.copy();
1554        dst.effective = effective == null ? null : effective.copy();
1555        dst.note = note == null ? null : note.copy();
1556        if (supportingInformation != null) {
1557          dst.supportingInformation = new ArrayList<Reference>();
1558          for (Reference i : supportingInformation)
1559            dst.supportingInformation.add(i.copy());
1560        };
1561        dst.medication = medication == null ? null : medication.copy();
1562        if (dosage != null) {
1563          dst.dosage = new ArrayList<MedicationStatementDosageComponent>();
1564          for (MedicationStatementDosageComponent i : dosage)
1565            dst.dosage.add(i.copy());
1566        };
1567        return dst;
1568      }
1569
1570      protected MedicationStatement typedCopy() {
1571        return copy();
1572      }
1573
1574      @Override
1575      public boolean equalsDeep(Base other) {
1576        if (!super.equalsDeep(other))
1577          return false;
1578        if (!(other instanceof MedicationStatement))
1579          return false;
1580        MedicationStatement o = (MedicationStatement) other;
1581        return compareDeep(identifier, o.identifier, true) && compareDeep(patient, o.patient, true) && compareDeep(informationSource, o.informationSource, true)
1582           && compareDeep(dateAsserted, o.dateAsserted, true) && compareDeep(status, o.status, true) && compareDeep(wasNotTaken, o.wasNotTaken, true)
1583           && compareDeep(reasonNotTaken, o.reasonNotTaken, true) && compareDeep(reasonForUse, o.reasonForUse, true)
1584           && compareDeep(effective, o.effective, true) && compareDeep(note, o.note, true) && compareDeep(supportingInformation, o.supportingInformation, true)
1585           && compareDeep(medication, o.medication, true) && compareDeep(dosage, o.dosage, true);
1586      }
1587
1588      @Override
1589      public boolean equalsShallow(Base other) {
1590        if (!super.equalsShallow(other))
1591          return false;
1592        if (!(other instanceof MedicationStatement))
1593          return false;
1594        MedicationStatement o = (MedicationStatement) other;
1595        return compareValues(dateAsserted, o.dateAsserted, true) && compareValues(status, o.status, true) && compareValues(wasNotTaken, o.wasNotTaken, true)
1596           && compareValues(note, o.note, true);
1597      }
1598
1599      public boolean isEmpty() {
1600        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (patient == null || patient.isEmpty())
1601           && (informationSource == null || informationSource.isEmpty()) && (dateAsserted == null || dateAsserted.isEmpty())
1602           && (status == null || status.isEmpty()) && (wasNotTaken == null || wasNotTaken.isEmpty())
1603           && (reasonNotTaken == null || reasonNotTaken.isEmpty()) && (reasonForUse == null || reasonForUse.isEmpty())
1604           && (effective == null || effective.isEmpty()) && (note == null || note.isEmpty()) && (supportingInformation == null || supportingInformation.isEmpty())
1605           && (medication == null || medication.isEmpty()) && (dosage == null || dosage.isEmpty());
1606      }
1607
1608  @Override
1609  public ResourceType getResourceType() {
1610    return ResourceType.MedicationStatement;
1611   }
1612
1613  @SearchParamDefinition(name="identifier", path="MedicationStatement.identifier", description="Return statements with this external identifier", type="token" )
1614  public static final String SP_IDENTIFIER = "identifier";
1615  @SearchParamDefinition(name="code", path="MedicationStatement.medicationCodeableConcept", description="Return administrations of this medication code", type="token" )
1616  public static final String SP_CODE = "code";
1617  @SearchParamDefinition(name="patient", path="MedicationStatement.patient", description="The identity of a patient to list statements  for", type="reference" )
1618  public static final String SP_PATIENT = "patient";
1619  @SearchParamDefinition(name="medication", path="MedicationStatement.medicationReference", description="Return administrations of this medication reference", type="reference" )
1620  public static final String SP_MEDICATION = "medication";
1621  @SearchParamDefinition(name="source", path="MedicationStatement.informationSource", description="Who the information in the statement came from", type="reference" )
1622  public static final String SP_SOURCE = "source";
1623  @SearchParamDefinition(name="effectivedate", path="MedicationStatement.effective[x]", description="Date when patient was taking (or not taking) the medication", type="date" )
1624  public static final String SP_EFFECTIVEDATE = "effectivedate";
1625  @SearchParamDefinition(name="status", path="MedicationStatement.status", description="Return statements that match the given status", type="token" )
1626  public static final String SP_STATUS = "status";
1627
1628}
1629