001package org.hl7.fhir.r4.model;
002
003
004
005/*
006  Copyright (c) 2011+, HL7, Inc.
007  All rights reserved.
008  
009  Redistribution and use in source and binary forms, with or without modification, 
010  are permitted provided that the following conditions are met:
011  
012   * Redistributions of source code must retain the above copyright notice, this 
013     list of conditions and the following disclaimer.
014   * Redistributions in binary form must reproduce the above copyright notice, 
015     this list of conditions and the following disclaimer in the documentation 
016     and/or other materials provided with the distribution.
017   * Neither the name of HL7 nor the names of its contributors may be used to 
018     endorse or promote products derived from this software without specific 
019     prior written permission.
020  
021  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
022  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
023  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
024  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
025  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
026  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
027  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
028  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
029  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
030  POSSIBILITY OF SUCH DAMAGE.
031  
032*/
033
034
035// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1
036
037import java.util.*;
038
039import org.hl7.fhir.utilities.Utilities;
040import ca.uhn.fhir.model.api.annotation.ResourceDef;
041import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
042import ca.uhn.fhir.model.api.annotation.Child;
043import ca.uhn.fhir.model.api.annotation.ChildOrder;
044import ca.uhn.fhir.model.api.annotation.Description;
045import ca.uhn.fhir.model.api.annotation.Block;
046import org.hl7.fhir.instance.model.api.*;
047import org.hl7.fhir.exceptions.FHIRException;
048/**
049 * This resource is primarily used for the identification and definition of a medication for the purposes of prescribing, dispensing, and administering a medication as well as for making statements about medication use.
050 */
051@ResourceDef(name="Medication", profile="http://hl7.org/fhir/StructureDefinition/Medication")
052public class Medication extends DomainResource {
053
054    public enum MedicationStatus {
055        /**
056         * The medication is available for use.
057         */
058        ACTIVE, 
059        /**
060         * The medication is not available for use.
061         */
062        INACTIVE, 
063        /**
064         * The medication was entered in error.
065         */
066        ENTEREDINERROR, 
067        /**
068         * added to help the parsers with the generic types
069         */
070        NULL;
071        public static MedicationStatus fromCode(String codeString) throws FHIRException {
072            if (codeString == null || "".equals(codeString))
073                return null;
074        if ("active".equals(codeString))
075          return ACTIVE;
076        if ("inactive".equals(codeString))
077          return INACTIVE;
078        if ("entered-in-error".equals(codeString))
079          return ENTEREDINERROR;
080        if (Configuration.isAcceptInvalidEnums())
081          return null;
082        else
083          throw new FHIRException("Unknown MedicationStatus code '"+codeString+"'");
084        }
085        public String toCode() {
086          switch (this) {
087            case ACTIVE: return "active";
088            case INACTIVE: return "inactive";
089            case ENTEREDINERROR: return "entered-in-error";
090            case NULL: return null;
091            default: return "?";
092          }
093        }
094        public String getSystem() {
095          switch (this) {
096            case ACTIVE: return "http://hl7.org/fhir/CodeSystem/medication-status";
097            case INACTIVE: return "http://hl7.org/fhir/CodeSystem/medication-status";
098            case ENTEREDINERROR: return "http://hl7.org/fhir/CodeSystem/medication-status";
099            case NULL: return null;
100            default: return "?";
101          }
102        }
103        public String getDefinition() {
104          switch (this) {
105            case ACTIVE: return "The medication is available for use.";
106            case INACTIVE: return "The medication is not available for use.";
107            case ENTEREDINERROR: return "The medication was entered in error.";
108            case NULL: return null;
109            default: return "?";
110          }
111        }
112        public String getDisplay() {
113          switch (this) {
114            case ACTIVE: return "Active";
115            case INACTIVE: return "Inactive";
116            case ENTEREDINERROR: return "Entered in Error";
117            case NULL: return null;
118            default: return "?";
119          }
120        }
121    }
122
123  public static class MedicationStatusEnumFactory implements EnumFactory<MedicationStatus> {
124    public MedicationStatus fromCode(String codeString) throws IllegalArgumentException {
125      if (codeString == null || "".equals(codeString))
126            if (codeString == null || "".equals(codeString))
127                return null;
128        if ("active".equals(codeString))
129          return MedicationStatus.ACTIVE;
130        if ("inactive".equals(codeString))
131          return MedicationStatus.INACTIVE;
132        if ("entered-in-error".equals(codeString))
133          return MedicationStatus.ENTEREDINERROR;
134        throw new IllegalArgumentException("Unknown MedicationStatus code '"+codeString+"'");
135        }
136        public Enumeration<MedicationStatus> fromType(Base code) throws FHIRException {
137          if (code == null)
138            return null;
139          if (code.isEmpty())
140            return new Enumeration<MedicationStatus>(this);
141          String codeString = ((PrimitiveType) code).asStringValue();
142          if (codeString == null || "".equals(codeString))
143            return null;
144        if ("active".equals(codeString))
145          return new Enumeration<MedicationStatus>(this, MedicationStatus.ACTIVE);
146        if ("inactive".equals(codeString))
147          return new Enumeration<MedicationStatus>(this, MedicationStatus.INACTIVE);
148        if ("entered-in-error".equals(codeString))
149          return new Enumeration<MedicationStatus>(this, MedicationStatus.ENTEREDINERROR);
150        throw new FHIRException("Unknown MedicationStatus code '"+codeString+"'");
151        }
152    public String toCode(MedicationStatus code) {
153      if (code == MedicationStatus.ACTIVE)
154        return "active";
155      if (code == MedicationStatus.INACTIVE)
156        return "inactive";
157      if (code == MedicationStatus.ENTEREDINERROR)
158        return "entered-in-error";
159      return "?";
160      }
161    public String toSystem(MedicationStatus code) {
162      return code.getSystem();
163      }
164    }
165
166    @Block()
167    public static class MedicationIngredientComponent extends BackboneElement implements IBaseBackboneElement {
168        /**
169         * The actual ingredient - either a substance (simple ingredient) or another medication of a medication.
170         */
171        @Child(name = "item", type = {CodeableConcept.class, Substance.class, Medication.class}, order=1, min=1, max=1, modifier=false, summary=false)
172        @Description(shortDefinition="The actual ingredient or content", formalDefinition="The actual ingredient - either a substance (simple ingredient) or another medication of a medication." )
173        protected Type item;
174
175        /**
176         * Indication of whether this ingredient affects the therapeutic action of the drug.
177         */
178        @Child(name = "isActive", type = {BooleanType.class}, order=2, min=0, max=1, modifier=false, summary=false)
179        @Description(shortDefinition="Active ingredient indicator", formalDefinition="Indication of whether this ingredient affects the therapeutic action of the drug." )
180        protected BooleanType isActive;
181
182        /**
183         * Specifies how many (or how much) of the items there are in this Medication.  For example, 250 mg per tablet.  This is expressed as a ratio where the numerator is 250mg and the denominator is 1 tablet.
184         */
185        @Child(name = "strength", type = {Ratio.class}, order=3, min=0, max=1, modifier=false, summary=false)
186        @Description(shortDefinition="Quantity of ingredient present", formalDefinition="Specifies how many (or how much) of the items there are in this Medication.  For example, 250 mg per tablet.  This is expressed as a ratio where the numerator is 250mg and the denominator is 1 tablet." )
187        protected Ratio strength;
188
189        private static final long serialVersionUID = 1365103497L;
190
191    /**
192     * Constructor
193     */
194      public MedicationIngredientComponent() {
195        super();
196      }
197
198    /**
199     * Constructor
200     */
201      public MedicationIngredientComponent(Type item) {
202        super();
203        this.item = item;
204      }
205
206        /**
207         * @return {@link #item} (The actual ingredient - either a substance (simple ingredient) or another medication of a medication.)
208         */
209        public Type getItem() { 
210          return this.item;
211        }
212
213        /**
214         * @return {@link #item} (The actual ingredient - either a substance (simple ingredient) or another medication of a medication.)
215         */
216        public CodeableConcept getItemCodeableConcept() throws FHIRException { 
217          if (this.item == null)
218            this.item = new CodeableConcept();
219          if (!(this.item instanceof CodeableConcept))
220            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.item.getClass().getName()+" was encountered");
221          return (CodeableConcept) this.item;
222        }
223
224        public boolean hasItemCodeableConcept() { 
225          return this != null && this.item instanceof CodeableConcept;
226        }
227
228        /**
229         * @return {@link #item} (The actual ingredient - either a substance (simple ingredient) or another medication of a medication.)
230         */
231        public Reference getItemReference() throws FHIRException { 
232          if (this.item == null)
233            this.item = new Reference();
234          if (!(this.item instanceof Reference))
235            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.item.getClass().getName()+" was encountered");
236          return (Reference) this.item;
237        }
238
239        public boolean hasItemReference() { 
240          return this != null && this.item instanceof Reference;
241        }
242
243        public boolean hasItem() { 
244          return this.item != null && !this.item.isEmpty();
245        }
246
247        /**
248         * @param value {@link #item} (The actual ingredient - either a substance (simple ingredient) or another medication of a medication.)
249         */
250        public MedicationIngredientComponent setItem(Type value) { 
251          if (value != null && !(value instanceof CodeableConcept || value instanceof Reference))
252            throw new Error("Not the right type for Medication.ingredient.item[x]: "+value.fhirType());
253          this.item = value;
254          return this;
255        }
256
257        /**
258         * @return {@link #isActive} (Indication of whether this ingredient affects the therapeutic action of the drug.). This is the underlying object with id, value and extensions. The accessor "getIsActive" gives direct access to the value
259         */
260        public BooleanType getIsActiveElement() { 
261          if (this.isActive == null)
262            if (Configuration.errorOnAutoCreate())
263              throw new Error("Attempt to auto-create MedicationIngredientComponent.isActive");
264            else if (Configuration.doAutoCreate())
265              this.isActive = new BooleanType(); // bb
266          return this.isActive;
267        }
268
269        public boolean hasIsActiveElement() { 
270          return this.isActive != null && !this.isActive.isEmpty();
271        }
272
273        public boolean hasIsActive() { 
274          return this.isActive != null && !this.isActive.isEmpty();
275        }
276
277        /**
278         * @param value {@link #isActive} (Indication of whether this ingredient affects the therapeutic action of the drug.). This is the underlying object with id, value and extensions. The accessor "getIsActive" gives direct access to the value
279         */
280        public MedicationIngredientComponent setIsActiveElement(BooleanType value) { 
281          this.isActive = value;
282          return this;
283        }
284
285        /**
286         * @return Indication of whether this ingredient affects the therapeutic action of the drug.
287         */
288        public boolean getIsActive() { 
289          return this.isActive == null || this.isActive.isEmpty() ? false : this.isActive.getValue();
290        }
291
292        /**
293         * @param value Indication of whether this ingredient affects the therapeutic action of the drug.
294         */
295        public MedicationIngredientComponent setIsActive(boolean value) { 
296            if (this.isActive == null)
297              this.isActive = new BooleanType();
298            this.isActive.setValue(value);
299          return this;
300        }
301
302        /**
303         * @return {@link #strength} (Specifies how many (or how much) of the items there are in this Medication.  For example, 250 mg per tablet.  This is expressed as a ratio where the numerator is 250mg and the denominator is 1 tablet.)
304         */
305        public Ratio getStrength() { 
306          if (this.strength == null)
307            if (Configuration.errorOnAutoCreate())
308              throw new Error("Attempt to auto-create MedicationIngredientComponent.strength");
309            else if (Configuration.doAutoCreate())
310              this.strength = new Ratio(); // cc
311          return this.strength;
312        }
313
314        public boolean hasStrength() { 
315          return this.strength != null && !this.strength.isEmpty();
316        }
317
318        /**
319         * @param value {@link #strength} (Specifies how many (or how much) of the items there are in this Medication.  For example, 250 mg per tablet.  This is expressed as a ratio where the numerator is 250mg and the denominator is 1 tablet.)
320         */
321        public MedicationIngredientComponent setStrength(Ratio value) { 
322          this.strength = value;
323          return this;
324        }
325
326        protected void listChildren(List<Property> children) {
327          super.listChildren(children);
328          children.add(new Property("item[x]", "CodeableConcept|Reference(Substance|Medication)", "The actual ingredient - either a substance (simple ingredient) or another medication of a medication.", 0, 1, item));
329          children.add(new Property("isActive", "boolean", "Indication of whether this ingredient affects the therapeutic action of the drug.", 0, 1, isActive));
330          children.add(new Property("strength", "Ratio", "Specifies how many (or how much) of the items there are in this Medication.  For example, 250 mg per tablet.  This is expressed as a ratio where the numerator is 250mg and the denominator is 1 tablet.", 0, 1, strength));
331        }
332
333        @Override
334        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
335          switch (_hash) {
336          case 2116201613: /*item[x]*/  return new Property("item[x]", "CodeableConcept|Reference(Substance|Medication)", "The actual ingredient - either a substance (simple ingredient) or another medication of a medication.", 0, 1, item);
337          case 3242771: /*item*/  return new Property("item[x]", "CodeableConcept|Reference(Substance|Medication)", "The actual ingredient - either a substance (simple ingredient) or another medication of a medication.", 0, 1, item);
338          case 106644494: /*itemCodeableConcept*/  return new Property("item[x]", "CodeableConcept|Reference(Substance|Medication)", "The actual ingredient - either a substance (simple ingredient) or another medication of a medication.", 0, 1, item);
339          case 1376364920: /*itemReference*/  return new Property("item[x]", "CodeableConcept|Reference(Substance|Medication)", "The actual ingredient - either a substance (simple ingredient) or another medication of a medication.", 0, 1, item);
340          case -748916528: /*isActive*/  return new Property("isActive", "boolean", "Indication of whether this ingredient affects the therapeutic action of the drug.", 0, 1, isActive);
341          case 1791316033: /*strength*/  return new Property("strength", "Ratio", "Specifies how many (or how much) of the items there are in this Medication.  For example, 250 mg per tablet.  This is expressed as a ratio where the numerator is 250mg and the denominator is 1 tablet.", 0, 1, strength);
342          default: return super.getNamedProperty(_hash, _name, _checkValid);
343          }
344
345        }
346
347      @Override
348      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
349        switch (hash) {
350        case 3242771: /*item*/ return this.item == null ? new Base[0] : new Base[] {this.item}; // Type
351        case -748916528: /*isActive*/ return this.isActive == null ? new Base[0] : new Base[] {this.isActive}; // BooleanType
352        case 1791316033: /*strength*/ return this.strength == null ? new Base[0] : new Base[] {this.strength}; // Ratio
353        default: return super.getProperty(hash, name, checkValid);
354        }
355
356      }
357
358      @Override
359      public Base setProperty(int hash, String name, Base value) throws FHIRException {
360        switch (hash) {
361        case 3242771: // item
362          this.item = castToType(value); // Type
363          return value;
364        case -748916528: // isActive
365          this.isActive = castToBoolean(value); // BooleanType
366          return value;
367        case 1791316033: // strength
368          this.strength = castToRatio(value); // Ratio
369          return value;
370        default: return super.setProperty(hash, name, value);
371        }
372
373      }
374
375      @Override
376      public Base setProperty(String name, Base value) throws FHIRException {
377        if (name.equals("item[x]")) {
378          this.item = castToType(value); // Type
379        } else if (name.equals("isActive")) {
380          this.isActive = castToBoolean(value); // BooleanType
381        } else if (name.equals("strength")) {
382          this.strength = castToRatio(value); // Ratio
383        } else
384          return super.setProperty(name, value);
385        return value;
386      }
387
388      @Override
389      public Base makeProperty(int hash, String name) throws FHIRException {
390        switch (hash) {
391        case 2116201613:  return getItem(); 
392        case 3242771:  return getItem(); 
393        case -748916528:  return getIsActiveElement();
394        case 1791316033:  return getStrength(); 
395        default: return super.makeProperty(hash, name);
396        }
397
398      }
399
400      @Override
401      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
402        switch (hash) {
403        case 3242771: /*item*/ return new String[] {"CodeableConcept", "Reference"};
404        case -748916528: /*isActive*/ return new String[] {"boolean"};
405        case 1791316033: /*strength*/ return new String[] {"Ratio"};
406        default: return super.getTypesForProperty(hash, name);
407        }
408
409      }
410
411      @Override
412      public Base addChild(String name) throws FHIRException {
413        if (name.equals("itemCodeableConcept")) {
414          this.item = new CodeableConcept();
415          return this.item;
416        }
417        else if (name.equals("itemReference")) {
418          this.item = new Reference();
419          return this.item;
420        }
421        else if (name.equals("isActive")) {
422          throw new FHIRException("Cannot call addChild on a primitive type Medication.isActive");
423        }
424        else if (name.equals("strength")) {
425          this.strength = new Ratio();
426          return this.strength;
427        }
428        else
429          return super.addChild(name);
430      }
431
432      public MedicationIngredientComponent copy() {
433        MedicationIngredientComponent dst = new MedicationIngredientComponent();
434        copyValues(dst);
435        return dst;
436      }
437
438      public void copyValues(MedicationIngredientComponent dst) {
439        super.copyValues(dst);
440        dst.item = item == null ? null : item.copy();
441        dst.isActive = isActive == null ? null : isActive.copy();
442        dst.strength = strength == null ? null : strength.copy();
443      }
444
445      @Override
446      public boolean equalsDeep(Base other_) {
447        if (!super.equalsDeep(other_))
448          return false;
449        if (!(other_ instanceof MedicationIngredientComponent))
450          return false;
451        MedicationIngredientComponent o = (MedicationIngredientComponent) other_;
452        return compareDeep(item, o.item, true) && compareDeep(isActive, o.isActive, true) && compareDeep(strength, o.strength, true)
453          ;
454      }
455
456      @Override
457      public boolean equalsShallow(Base other_) {
458        if (!super.equalsShallow(other_))
459          return false;
460        if (!(other_ instanceof MedicationIngredientComponent))
461          return false;
462        MedicationIngredientComponent o = (MedicationIngredientComponent) other_;
463        return compareValues(isActive, o.isActive, true);
464      }
465
466      public boolean isEmpty() {
467        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(item, isActive, strength
468          );
469      }
470
471  public String fhirType() {
472    return "Medication.ingredient";
473
474  }
475
476  }
477
478    @Block()
479    public static class MedicationBatchComponent extends BackboneElement implements IBaseBackboneElement {
480        /**
481         * The assigned lot number of a batch of the specified product.
482         */
483        @Child(name = "lotNumber", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=false)
484        @Description(shortDefinition="Identifier assigned to batch", formalDefinition="The assigned lot number of a batch of the specified product." )
485        protected StringType lotNumber;
486
487        /**
488         * When this specific batch of product will expire.
489         */
490        @Child(name = "expirationDate", type = {DateTimeType.class}, order=2, min=0, max=1, modifier=false, summary=false)
491        @Description(shortDefinition="When batch will expire", formalDefinition="When this specific batch of product will expire." )
492        protected DateTimeType expirationDate;
493
494        private static final long serialVersionUID = 1982738755L;
495
496    /**
497     * Constructor
498     */
499      public MedicationBatchComponent() {
500        super();
501      }
502
503        /**
504         * @return {@link #lotNumber} (The assigned lot number of a batch of the specified product.). This is the underlying object with id, value and extensions. The accessor "getLotNumber" gives direct access to the value
505         */
506        public StringType getLotNumberElement() { 
507          if (this.lotNumber == null)
508            if (Configuration.errorOnAutoCreate())
509              throw new Error("Attempt to auto-create MedicationBatchComponent.lotNumber");
510            else if (Configuration.doAutoCreate())
511              this.lotNumber = new StringType(); // bb
512          return this.lotNumber;
513        }
514
515        public boolean hasLotNumberElement() { 
516          return this.lotNumber != null && !this.lotNumber.isEmpty();
517        }
518
519        public boolean hasLotNumber() { 
520          return this.lotNumber != null && !this.lotNumber.isEmpty();
521        }
522
523        /**
524         * @param value {@link #lotNumber} (The assigned lot number of a batch of the specified product.). This is the underlying object with id, value and extensions. The accessor "getLotNumber" gives direct access to the value
525         */
526        public MedicationBatchComponent setLotNumberElement(StringType value) { 
527          this.lotNumber = value;
528          return this;
529        }
530
531        /**
532         * @return The assigned lot number of a batch of the specified product.
533         */
534        public String getLotNumber() { 
535          return this.lotNumber == null ? null : this.lotNumber.getValue();
536        }
537
538        /**
539         * @param value The assigned lot number of a batch of the specified product.
540         */
541        public MedicationBatchComponent setLotNumber(String value) { 
542          if (Utilities.noString(value))
543            this.lotNumber = null;
544          else {
545            if (this.lotNumber == null)
546              this.lotNumber = new StringType();
547            this.lotNumber.setValue(value);
548          }
549          return this;
550        }
551
552        /**
553         * @return {@link #expirationDate} (When this specific batch of product will expire.). This is the underlying object with id, value and extensions. The accessor "getExpirationDate" gives direct access to the value
554         */
555        public DateTimeType getExpirationDateElement() { 
556          if (this.expirationDate == null)
557            if (Configuration.errorOnAutoCreate())
558              throw new Error("Attempt to auto-create MedicationBatchComponent.expirationDate");
559            else if (Configuration.doAutoCreate())
560              this.expirationDate = new DateTimeType(); // bb
561          return this.expirationDate;
562        }
563
564        public boolean hasExpirationDateElement() { 
565          return this.expirationDate != null && !this.expirationDate.isEmpty();
566        }
567
568        public boolean hasExpirationDate() { 
569          return this.expirationDate != null && !this.expirationDate.isEmpty();
570        }
571
572        /**
573         * @param value {@link #expirationDate} (When this specific batch of product will expire.). This is the underlying object with id, value and extensions. The accessor "getExpirationDate" gives direct access to the value
574         */
575        public MedicationBatchComponent setExpirationDateElement(DateTimeType value) { 
576          this.expirationDate = value;
577          return this;
578        }
579
580        /**
581         * @return When this specific batch of product will expire.
582         */
583        public Date getExpirationDate() { 
584          return this.expirationDate == null ? null : this.expirationDate.getValue();
585        }
586
587        /**
588         * @param value When this specific batch of product will expire.
589         */
590        public MedicationBatchComponent setExpirationDate(Date value) { 
591          if (value == null)
592            this.expirationDate = null;
593          else {
594            if (this.expirationDate == null)
595              this.expirationDate = new DateTimeType();
596            this.expirationDate.setValue(value);
597          }
598          return this;
599        }
600
601        protected void listChildren(List<Property> children) {
602          super.listChildren(children);
603          children.add(new Property("lotNumber", "string", "The assigned lot number of a batch of the specified product.", 0, 1, lotNumber));
604          children.add(new Property("expirationDate", "dateTime", "When this specific batch of product will expire.", 0, 1, expirationDate));
605        }
606
607        @Override
608        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
609          switch (_hash) {
610          case 462547450: /*lotNumber*/  return new Property("lotNumber", "string", "The assigned lot number of a batch of the specified product.", 0, 1, lotNumber);
611          case -668811523: /*expirationDate*/  return new Property("expirationDate", "dateTime", "When this specific batch of product will expire.", 0, 1, expirationDate);
612          default: return super.getNamedProperty(_hash, _name, _checkValid);
613          }
614
615        }
616
617      @Override
618      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
619        switch (hash) {
620        case 462547450: /*lotNumber*/ return this.lotNumber == null ? new Base[0] : new Base[] {this.lotNumber}; // StringType
621        case -668811523: /*expirationDate*/ return this.expirationDate == null ? new Base[0] : new Base[] {this.expirationDate}; // DateTimeType
622        default: return super.getProperty(hash, name, checkValid);
623        }
624
625      }
626
627      @Override
628      public Base setProperty(int hash, String name, Base value) throws FHIRException {
629        switch (hash) {
630        case 462547450: // lotNumber
631          this.lotNumber = castToString(value); // StringType
632          return value;
633        case -668811523: // expirationDate
634          this.expirationDate = castToDateTime(value); // DateTimeType
635          return value;
636        default: return super.setProperty(hash, name, value);
637        }
638
639      }
640
641      @Override
642      public Base setProperty(String name, Base value) throws FHIRException {
643        if (name.equals("lotNumber")) {
644          this.lotNumber = castToString(value); // StringType
645        } else if (name.equals("expirationDate")) {
646          this.expirationDate = castToDateTime(value); // DateTimeType
647        } else
648          return super.setProperty(name, value);
649        return value;
650      }
651
652      @Override
653      public Base makeProperty(int hash, String name) throws FHIRException {
654        switch (hash) {
655        case 462547450:  return getLotNumberElement();
656        case -668811523:  return getExpirationDateElement();
657        default: return super.makeProperty(hash, name);
658        }
659
660      }
661
662      @Override
663      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
664        switch (hash) {
665        case 462547450: /*lotNumber*/ return new String[] {"string"};
666        case -668811523: /*expirationDate*/ return new String[] {"dateTime"};
667        default: return super.getTypesForProperty(hash, name);
668        }
669
670      }
671
672      @Override
673      public Base addChild(String name) throws FHIRException {
674        if (name.equals("lotNumber")) {
675          throw new FHIRException("Cannot call addChild on a primitive type Medication.lotNumber");
676        }
677        else if (name.equals("expirationDate")) {
678          throw new FHIRException("Cannot call addChild on a primitive type Medication.expirationDate");
679        }
680        else
681          return super.addChild(name);
682      }
683
684      public MedicationBatchComponent copy() {
685        MedicationBatchComponent dst = new MedicationBatchComponent();
686        copyValues(dst);
687        return dst;
688      }
689
690      public void copyValues(MedicationBatchComponent dst) {
691        super.copyValues(dst);
692        dst.lotNumber = lotNumber == null ? null : lotNumber.copy();
693        dst.expirationDate = expirationDate == null ? null : expirationDate.copy();
694      }
695
696      @Override
697      public boolean equalsDeep(Base other_) {
698        if (!super.equalsDeep(other_))
699          return false;
700        if (!(other_ instanceof MedicationBatchComponent))
701          return false;
702        MedicationBatchComponent o = (MedicationBatchComponent) other_;
703        return compareDeep(lotNumber, o.lotNumber, true) && compareDeep(expirationDate, o.expirationDate, true)
704          ;
705      }
706
707      @Override
708      public boolean equalsShallow(Base other_) {
709        if (!super.equalsShallow(other_))
710          return false;
711        if (!(other_ instanceof MedicationBatchComponent))
712          return false;
713        MedicationBatchComponent o = (MedicationBatchComponent) other_;
714        return compareValues(lotNumber, o.lotNumber, true) && compareValues(expirationDate, o.expirationDate, true)
715          ;
716      }
717
718      public boolean isEmpty() {
719        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(lotNumber, expirationDate
720          );
721      }
722
723  public String fhirType() {
724    return "Medication.batch";
725
726  }
727
728  }
729
730    /**
731     * Business identifier for this medication.
732     */
733    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
734    @Description(shortDefinition="Business identifier for this medication", formalDefinition="Business identifier for this medication." )
735    protected List<Identifier> identifier;
736
737    /**
738     * A code (or set of codes) that specify this medication, or a textual description if no code is available. Usage note: This could be a standard medication code such as a code from RxNorm, SNOMED CT, IDMP etc. It could also be a national or local formulary code, optionally with translations to other code systems.
739     */
740    @Child(name = "code", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
741    @Description(shortDefinition="Codes that identify this medication", formalDefinition="A code (or set of codes) that specify this medication, or a textual description if no code is available. Usage note: This could be a standard medication code such as a code from RxNorm, SNOMED CT, IDMP etc. It could also be a national or local formulary code, optionally with translations to other code systems." )
742    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-codes")
743    protected CodeableConcept code;
744
745    /**
746     * A code to indicate if the medication is in active use.
747     */
748    @Child(name = "status", type = {CodeType.class}, order=2, min=0, max=1, modifier=true, summary=true)
749    @Description(shortDefinition="active | inactive | entered-in-error", formalDefinition="A code to indicate if the medication is in active use." )
750    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-status")
751    protected Enumeration<MedicationStatus> status;
752
753    /**
754     * Describes the details of the manufacturer of the medication product.  This is not intended to represent the distributor of a medication product.
755     */
756    @Child(name = "manufacturer", type = {Organization.class}, order=3, min=0, max=1, modifier=false, summary=true)
757    @Description(shortDefinition="Manufacturer of the item", formalDefinition="Describes the details of the manufacturer of the medication product.  This is not intended to represent the distributor of a medication product." )
758    protected Reference manufacturer;
759
760    /**
761     * The actual object that is the target of the reference (Describes the details of the manufacturer of the medication product.  This is not intended to represent the distributor of a medication product.)
762     */
763    protected Organization manufacturerTarget;
764
765    /**
766     * Describes the form of the item.  Powder; tablets; capsule.
767     */
768    @Child(name = "form", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=false)
769    @Description(shortDefinition="powder | tablets | capsule +", formalDefinition="Describes the form of the item.  Powder; tablets; capsule." )
770    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-form-codes")
771    protected CodeableConcept form;
772
773    /**
774     * Specific amount of the drug in the packaged product.  For example, when specifying a product that has the same strength (For example, Insulin glargine 100 unit per mL solution for injection), this attribute provides additional clarification of the package amount (For example, 3 mL, 10mL, etc.).
775     */
776    @Child(name = "amount", type = {Ratio.class}, order=5, min=0, max=1, modifier=false, summary=true)
777    @Description(shortDefinition="Amount of drug in package", formalDefinition="Specific amount of the drug in the packaged product.  For example, when specifying a product that has the same strength (For example, Insulin glargine 100 unit per mL solution for injection), this attribute provides additional clarification of the package amount (For example, 3 mL, 10mL, etc.)." )
778    protected Ratio amount;
779
780    /**
781     * Identifies a particular constituent of interest in the product.
782     */
783    @Child(name = "ingredient", type = {}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
784    @Description(shortDefinition="Active or inactive ingredient", formalDefinition="Identifies a particular constituent of interest in the product." )
785    protected List<MedicationIngredientComponent> ingredient;
786
787    /**
788     * Information that only applies to packages (not products).
789     */
790    @Child(name = "batch", type = {}, order=7, min=0, max=1, modifier=false, summary=false)
791    @Description(shortDefinition="Details about packaged medications", formalDefinition="Information that only applies to packages (not products)." )
792    protected MedicationBatchComponent batch;
793
794    private static final long serialVersionUID = 781229373L;
795
796  /**
797   * Constructor
798   */
799    public Medication() {
800      super();
801    }
802
803    /**
804     * @return {@link #identifier} (Business identifier for this medication.)
805     */
806    public List<Identifier> getIdentifier() { 
807      if (this.identifier == null)
808        this.identifier = new ArrayList<Identifier>();
809      return this.identifier;
810    }
811
812    /**
813     * @return Returns a reference to <code>this</code> for easy method chaining
814     */
815    public Medication setIdentifier(List<Identifier> theIdentifier) { 
816      this.identifier = theIdentifier;
817      return this;
818    }
819
820    public boolean hasIdentifier() { 
821      if (this.identifier == null)
822        return false;
823      for (Identifier item : this.identifier)
824        if (!item.isEmpty())
825          return true;
826      return false;
827    }
828
829    public Identifier addIdentifier() { //3
830      Identifier t = new Identifier();
831      if (this.identifier == null)
832        this.identifier = new ArrayList<Identifier>();
833      this.identifier.add(t);
834      return t;
835    }
836
837    public Medication addIdentifier(Identifier t) { //3
838      if (t == null)
839        return this;
840      if (this.identifier == null)
841        this.identifier = new ArrayList<Identifier>();
842      this.identifier.add(t);
843      return this;
844    }
845
846    /**
847     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
848     */
849    public Identifier getIdentifierFirstRep() { 
850      if (getIdentifier().isEmpty()) {
851        addIdentifier();
852      }
853      return getIdentifier().get(0);
854    }
855
856    /**
857     * @return {@link #code} (A code (or set of codes) that specify this medication, or a textual description if no code is available. Usage note: This could be a standard medication code such as a code from RxNorm, SNOMED CT, IDMP etc. It could also be a national or local formulary code, optionally with translations to other code systems.)
858     */
859    public CodeableConcept getCode() { 
860      if (this.code == null)
861        if (Configuration.errorOnAutoCreate())
862          throw new Error("Attempt to auto-create Medication.code");
863        else if (Configuration.doAutoCreate())
864          this.code = new CodeableConcept(); // cc
865      return this.code;
866    }
867
868    public boolean hasCode() { 
869      return this.code != null && !this.code.isEmpty();
870    }
871
872    /**
873     * @param value {@link #code} (A code (or set of codes) that specify this medication, or a textual description if no code is available. Usage note: This could be a standard medication code such as a code from RxNorm, SNOMED CT, IDMP etc. It could also be a national or local formulary code, optionally with translations to other code systems.)
874     */
875    public Medication setCode(CodeableConcept value) { 
876      this.code = value;
877      return this;
878    }
879
880    /**
881     * @return {@link #status} (A code to indicate if the medication is in active use.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
882     */
883    public Enumeration<MedicationStatus> getStatusElement() { 
884      if (this.status == null)
885        if (Configuration.errorOnAutoCreate())
886          throw new Error("Attempt to auto-create Medication.status");
887        else if (Configuration.doAutoCreate())
888          this.status = new Enumeration<MedicationStatus>(new MedicationStatusEnumFactory()); // bb
889      return this.status;
890    }
891
892    public boolean hasStatusElement() { 
893      return this.status != null && !this.status.isEmpty();
894    }
895
896    public boolean hasStatus() { 
897      return this.status != null && !this.status.isEmpty();
898    }
899
900    /**
901     * @param value {@link #status} (A code to indicate if the medication is in active use.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
902     */
903    public Medication setStatusElement(Enumeration<MedicationStatus> value) { 
904      this.status = value;
905      return this;
906    }
907
908    /**
909     * @return A code to indicate if the medication is in active use.
910     */
911    public MedicationStatus getStatus() { 
912      return this.status == null ? null : this.status.getValue();
913    }
914
915    /**
916     * @param value A code to indicate if the medication is in active use.
917     */
918    public Medication setStatus(MedicationStatus value) { 
919      if (value == null)
920        this.status = null;
921      else {
922        if (this.status == null)
923          this.status = new Enumeration<MedicationStatus>(new MedicationStatusEnumFactory());
924        this.status.setValue(value);
925      }
926      return this;
927    }
928
929    /**
930     * @return {@link #manufacturer} (Describes the details of the manufacturer of the medication product.  This is not intended to represent the distributor of a medication product.)
931     */
932    public Reference getManufacturer() { 
933      if (this.manufacturer == null)
934        if (Configuration.errorOnAutoCreate())
935          throw new Error("Attempt to auto-create Medication.manufacturer");
936        else if (Configuration.doAutoCreate())
937          this.manufacturer = new Reference(); // cc
938      return this.manufacturer;
939    }
940
941    public boolean hasManufacturer() { 
942      return this.manufacturer != null && !this.manufacturer.isEmpty();
943    }
944
945    /**
946     * @param value {@link #manufacturer} (Describes the details of the manufacturer of the medication product.  This is not intended to represent the distributor of a medication product.)
947     */
948    public Medication setManufacturer(Reference value) { 
949      this.manufacturer = value;
950      return this;
951    }
952
953    /**
954     * @return {@link #manufacturer} 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. (Describes the details of the manufacturer of the medication product.  This is not intended to represent the distributor of a medication product.)
955     */
956    public Organization getManufacturerTarget() { 
957      if (this.manufacturerTarget == null)
958        if (Configuration.errorOnAutoCreate())
959          throw new Error("Attempt to auto-create Medication.manufacturer");
960        else if (Configuration.doAutoCreate())
961          this.manufacturerTarget = new Organization(); // aa
962      return this.manufacturerTarget;
963    }
964
965    /**
966     * @param value {@link #manufacturer} 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. (Describes the details of the manufacturer of the medication product.  This is not intended to represent the distributor of a medication product.)
967     */
968    public Medication setManufacturerTarget(Organization value) { 
969      this.manufacturerTarget = value;
970      return this;
971    }
972
973    /**
974     * @return {@link #form} (Describes the form of the item.  Powder; tablets; capsule.)
975     */
976    public CodeableConcept getForm() { 
977      if (this.form == null)
978        if (Configuration.errorOnAutoCreate())
979          throw new Error("Attempt to auto-create Medication.form");
980        else if (Configuration.doAutoCreate())
981          this.form = new CodeableConcept(); // cc
982      return this.form;
983    }
984
985    public boolean hasForm() { 
986      return this.form != null && !this.form.isEmpty();
987    }
988
989    /**
990     * @param value {@link #form} (Describes the form of the item.  Powder; tablets; capsule.)
991     */
992    public Medication setForm(CodeableConcept value) { 
993      this.form = value;
994      return this;
995    }
996
997    /**
998     * @return {@link #amount} (Specific amount of the drug in the packaged product.  For example, when specifying a product that has the same strength (For example, Insulin glargine 100 unit per mL solution for injection), this attribute provides additional clarification of the package amount (For example, 3 mL, 10mL, etc.).)
999     */
1000    public Ratio getAmount() { 
1001      if (this.amount == null)
1002        if (Configuration.errorOnAutoCreate())
1003          throw new Error("Attempt to auto-create Medication.amount");
1004        else if (Configuration.doAutoCreate())
1005          this.amount = new Ratio(); // cc
1006      return this.amount;
1007    }
1008
1009    public boolean hasAmount() { 
1010      return this.amount != null && !this.amount.isEmpty();
1011    }
1012
1013    /**
1014     * @param value {@link #amount} (Specific amount of the drug in the packaged product.  For example, when specifying a product that has the same strength (For example, Insulin glargine 100 unit per mL solution for injection), this attribute provides additional clarification of the package amount (For example, 3 mL, 10mL, etc.).)
1015     */
1016    public Medication setAmount(Ratio value) { 
1017      this.amount = value;
1018      return this;
1019    }
1020
1021    /**
1022     * @return {@link #ingredient} (Identifies a particular constituent of interest in the product.)
1023     */
1024    public List<MedicationIngredientComponent> getIngredient() { 
1025      if (this.ingredient == null)
1026        this.ingredient = new ArrayList<MedicationIngredientComponent>();
1027      return this.ingredient;
1028    }
1029
1030    /**
1031     * @return Returns a reference to <code>this</code> for easy method chaining
1032     */
1033    public Medication setIngredient(List<MedicationIngredientComponent> theIngredient) { 
1034      this.ingredient = theIngredient;
1035      return this;
1036    }
1037
1038    public boolean hasIngredient() { 
1039      if (this.ingredient == null)
1040        return false;
1041      for (MedicationIngredientComponent item : this.ingredient)
1042        if (!item.isEmpty())
1043          return true;
1044      return false;
1045    }
1046
1047    public MedicationIngredientComponent addIngredient() { //3
1048      MedicationIngredientComponent t = new MedicationIngredientComponent();
1049      if (this.ingredient == null)
1050        this.ingredient = new ArrayList<MedicationIngredientComponent>();
1051      this.ingredient.add(t);
1052      return t;
1053    }
1054
1055    public Medication addIngredient(MedicationIngredientComponent t) { //3
1056      if (t == null)
1057        return this;
1058      if (this.ingredient == null)
1059        this.ingredient = new ArrayList<MedicationIngredientComponent>();
1060      this.ingredient.add(t);
1061      return this;
1062    }
1063
1064    /**
1065     * @return The first repetition of repeating field {@link #ingredient}, creating it if it does not already exist
1066     */
1067    public MedicationIngredientComponent getIngredientFirstRep() { 
1068      if (getIngredient().isEmpty()) {
1069        addIngredient();
1070      }
1071      return getIngredient().get(0);
1072    }
1073
1074    /**
1075     * @return {@link #batch} (Information that only applies to packages (not products).)
1076     */
1077    public MedicationBatchComponent getBatch() { 
1078      if (this.batch == null)
1079        if (Configuration.errorOnAutoCreate())
1080          throw new Error("Attempt to auto-create Medication.batch");
1081        else if (Configuration.doAutoCreate())
1082          this.batch = new MedicationBatchComponent(); // cc
1083      return this.batch;
1084    }
1085
1086    public boolean hasBatch() { 
1087      return this.batch != null && !this.batch.isEmpty();
1088    }
1089
1090    /**
1091     * @param value {@link #batch} (Information that only applies to packages (not products).)
1092     */
1093    public Medication setBatch(MedicationBatchComponent value) { 
1094      this.batch = value;
1095      return this;
1096    }
1097
1098      protected void listChildren(List<Property> children) {
1099        super.listChildren(children);
1100        children.add(new Property("identifier", "Identifier", "Business identifier for this medication.", 0, java.lang.Integer.MAX_VALUE, identifier));
1101        children.add(new Property("code", "CodeableConcept", "A code (or set of codes) that specify this medication, or a textual description if no code is available. Usage note: This could be a standard medication code such as a code from RxNorm, SNOMED CT, IDMP etc. It could also be a national or local formulary code, optionally with translations to other code systems.", 0, 1, code));
1102        children.add(new Property("status", "code", "A code to indicate if the medication is in active use.", 0, 1, status));
1103        children.add(new Property("manufacturer", "Reference(Organization)", "Describes the details of the manufacturer of the medication product.  This is not intended to represent the distributor of a medication product.", 0, 1, manufacturer));
1104        children.add(new Property("form", "CodeableConcept", "Describes the form of the item.  Powder; tablets; capsule.", 0, 1, form));
1105        children.add(new Property("amount", "Ratio", "Specific amount of the drug in the packaged product.  For example, when specifying a product that has the same strength (For example, Insulin glargine 100 unit per mL solution for injection), this attribute provides additional clarification of the package amount (For example, 3 mL, 10mL, etc.).", 0, 1, amount));
1106        children.add(new Property("ingredient", "", "Identifies a particular constituent of interest in the product.", 0, java.lang.Integer.MAX_VALUE, ingredient));
1107        children.add(new Property("batch", "", "Information that only applies to packages (not products).", 0, 1, batch));
1108      }
1109
1110      @Override
1111      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1112        switch (_hash) {
1113        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Business identifier for this medication.", 0, java.lang.Integer.MAX_VALUE, identifier);
1114        case 3059181: /*code*/  return new Property("code", "CodeableConcept", "A code (or set of codes) that specify this medication, or a textual description if no code is available. Usage note: This could be a standard medication code such as a code from RxNorm, SNOMED CT, IDMP etc. It could also be a national or local formulary code, optionally with translations to other code systems.", 0, 1, code);
1115        case -892481550: /*status*/  return new Property("status", "code", "A code to indicate if the medication is in active use.", 0, 1, status);
1116        case -1969347631: /*manufacturer*/  return new Property("manufacturer", "Reference(Organization)", "Describes the details of the manufacturer of the medication product.  This is not intended to represent the distributor of a medication product.", 0, 1, manufacturer);
1117        case 3148996: /*form*/  return new Property("form", "CodeableConcept", "Describes the form of the item.  Powder; tablets; capsule.", 0, 1, form);
1118        case -1413853096: /*amount*/  return new Property("amount", "Ratio", "Specific amount of the drug in the packaged product.  For example, when specifying a product that has the same strength (For example, Insulin glargine 100 unit per mL solution for injection), this attribute provides additional clarification of the package amount (For example, 3 mL, 10mL, etc.).", 0, 1, amount);
1119        case -206409263: /*ingredient*/  return new Property("ingredient", "", "Identifies a particular constituent of interest in the product.", 0, java.lang.Integer.MAX_VALUE, ingredient);
1120        case 93509434: /*batch*/  return new Property("batch", "", "Information that only applies to packages (not products).", 0, 1, batch);
1121        default: return super.getNamedProperty(_hash, _name, _checkValid);
1122        }
1123
1124      }
1125
1126      @Override
1127      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1128        switch (hash) {
1129        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1130        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept
1131        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<MedicationStatus>
1132        case -1969347631: /*manufacturer*/ return this.manufacturer == null ? new Base[0] : new Base[] {this.manufacturer}; // Reference
1133        case 3148996: /*form*/ return this.form == null ? new Base[0] : new Base[] {this.form}; // CodeableConcept
1134        case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : new Base[] {this.amount}; // Ratio
1135        case -206409263: /*ingredient*/ return this.ingredient == null ? new Base[0] : this.ingredient.toArray(new Base[this.ingredient.size()]); // MedicationIngredientComponent
1136        case 93509434: /*batch*/ return this.batch == null ? new Base[0] : new Base[] {this.batch}; // MedicationBatchComponent
1137        default: return super.getProperty(hash, name, checkValid);
1138        }
1139
1140      }
1141
1142      @Override
1143      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1144        switch (hash) {
1145        case -1618432855: // identifier
1146          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1147          return value;
1148        case 3059181: // code
1149          this.code = castToCodeableConcept(value); // CodeableConcept
1150          return value;
1151        case -892481550: // status
1152          value = new MedicationStatusEnumFactory().fromType(castToCode(value));
1153          this.status = (Enumeration) value; // Enumeration<MedicationStatus>
1154          return value;
1155        case -1969347631: // manufacturer
1156          this.manufacturer = castToReference(value); // Reference
1157          return value;
1158        case 3148996: // form
1159          this.form = castToCodeableConcept(value); // CodeableConcept
1160          return value;
1161        case -1413853096: // amount
1162          this.amount = castToRatio(value); // Ratio
1163          return value;
1164        case -206409263: // ingredient
1165          this.getIngredient().add((MedicationIngredientComponent) value); // MedicationIngredientComponent
1166          return value;
1167        case 93509434: // batch
1168          this.batch = (MedicationBatchComponent) value; // MedicationBatchComponent
1169          return value;
1170        default: return super.setProperty(hash, name, value);
1171        }
1172
1173      }
1174
1175      @Override
1176      public Base setProperty(String name, Base value) throws FHIRException {
1177        if (name.equals("identifier")) {
1178          this.getIdentifier().add(castToIdentifier(value));
1179        } else if (name.equals("code")) {
1180          this.code = castToCodeableConcept(value); // CodeableConcept
1181        } else if (name.equals("status")) {
1182          value = new MedicationStatusEnumFactory().fromType(castToCode(value));
1183          this.status = (Enumeration) value; // Enumeration<MedicationStatus>
1184        } else if (name.equals("manufacturer")) {
1185          this.manufacturer = castToReference(value); // Reference
1186        } else if (name.equals("form")) {
1187          this.form = castToCodeableConcept(value); // CodeableConcept
1188        } else if (name.equals("amount")) {
1189          this.amount = castToRatio(value); // Ratio
1190        } else if (name.equals("ingredient")) {
1191          this.getIngredient().add((MedicationIngredientComponent) value);
1192        } else if (name.equals("batch")) {
1193          this.batch = (MedicationBatchComponent) value; // MedicationBatchComponent
1194        } else
1195          return super.setProperty(name, value);
1196        return value;
1197      }
1198
1199      @Override
1200      public Base makeProperty(int hash, String name) throws FHIRException {
1201        switch (hash) {
1202        case -1618432855:  return addIdentifier(); 
1203        case 3059181:  return getCode(); 
1204        case -892481550:  return getStatusElement();
1205        case -1969347631:  return getManufacturer(); 
1206        case 3148996:  return getForm(); 
1207        case -1413853096:  return getAmount(); 
1208        case -206409263:  return addIngredient(); 
1209        case 93509434:  return getBatch(); 
1210        default: return super.makeProperty(hash, name);
1211        }
1212
1213      }
1214
1215      @Override
1216      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1217        switch (hash) {
1218        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
1219        case 3059181: /*code*/ return new String[] {"CodeableConcept"};
1220        case -892481550: /*status*/ return new String[] {"code"};
1221        case -1969347631: /*manufacturer*/ return new String[] {"Reference"};
1222        case 3148996: /*form*/ return new String[] {"CodeableConcept"};
1223        case -1413853096: /*amount*/ return new String[] {"Ratio"};
1224        case -206409263: /*ingredient*/ return new String[] {};
1225        case 93509434: /*batch*/ return new String[] {};
1226        default: return super.getTypesForProperty(hash, name);
1227        }
1228
1229      }
1230
1231      @Override
1232      public Base addChild(String name) throws FHIRException {
1233        if (name.equals("identifier")) {
1234          return addIdentifier();
1235        }
1236        else if (name.equals("code")) {
1237          this.code = new CodeableConcept();
1238          return this.code;
1239        }
1240        else if (name.equals("status")) {
1241          throw new FHIRException("Cannot call addChild on a primitive type Medication.status");
1242        }
1243        else if (name.equals("manufacturer")) {
1244          this.manufacturer = new Reference();
1245          return this.manufacturer;
1246        }
1247        else if (name.equals("form")) {
1248          this.form = new CodeableConcept();
1249          return this.form;
1250        }
1251        else if (name.equals("amount")) {
1252          this.amount = new Ratio();
1253          return this.amount;
1254        }
1255        else if (name.equals("ingredient")) {
1256          return addIngredient();
1257        }
1258        else if (name.equals("batch")) {
1259          this.batch = new MedicationBatchComponent();
1260          return this.batch;
1261        }
1262        else
1263          return super.addChild(name);
1264      }
1265
1266  public String fhirType() {
1267    return "Medication";
1268
1269  }
1270
1271      public Medication copy() {
1272        Medication dst = new Medication();
1273        copyValues(dst);
1274        return dst;
1275      }
1276
1277      public void copyValues(Medication dst) {
1278        super.copyValues(dst);
1279        if (identifier != null) {
1280          dst.identifier = new ArrayList<Identifier>();
1281          for (Identifier i : identifier)
1282            dst.identifier.add(i.copy());
1283        };
1284        dst.code = code == null ? null : code.copy();
1285        dst.status = status == null ? null : status.copy();
1286        dst.manufacturer = manufacturer == null ? null : manufacturer.copy();
1287        dst.form = form == null ? null : form.copy();
1288        dst.amount = amount == null ? null : amount.copy();
1289        if (ingredient != null) {
1290          dst.ingredient = new ArrayList<MedicationIngredientComponent>();
1291          for (MedicationIngredientComponent i : ingredient)
1292            dst.ingredient.add(i.copy());
1293        };
1294        dst.batch = batch == null ? null : batch.copy();
1295      }
1296
1297      protected Medication typedCopy() {
1298        return copy();
1299      }
1300
1301      @Override
1302      public boolean equalsDeep(Base other_) {
1303        if (!super.equalsDeep(other_))
1304          return false;
1305        if (!(other_ instanceof Medication))
1306          return false;
1307        Medication o = (Medication) other_;
1308        return compareDeep(identifier, o.identifier, true) && compareDeep(code, o.code, true) && compareDeep(status, o.status, true)
1309           && compareDeep(manufacturer, o.manufacturer, true) && compareDeep(form, o.form, true) && compareDeep(amount, o.amount, true)
1310           && compareDeep(ingredient, o.ingredient, true) && compareDeep(batch, o.batch, true);
1311      }
1312
1313      @Override
1314      public boolean equalsShallow(Base other_) {
1315        if (!super.equalsShallow(other_))
1316          return false;
1317        if (!(other_ instanceof Medication))
1318          return false;
1319        Medication o = (Medication) other_;
1320        return compareValues(status, o.status, true);
1321      }
1322
1323      public boolean isEmpty() {
1324        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, code, status
1325          , manufacturer, form, amount, ingredient, batch);
1326      }
1327
1328  @Override
1329  public ResourceType getResourceType() {
1330    return ResourceType.Medication;
1331   }
1332
1333 /**
1334   * Search parameter: <b>ingredient-code</b>
1335   * <p>
1336   * Description: <b>Returns medications for this ingredient code</b><br>
1337   * Type: <b>token</b><br>
1338   * Path: <b>Medication.ingredient.itemCodeableConcept</b><br>
1339   * </p>
1340   */
1341  @SearchParamDefinition(name="ingredient-code", path="(Medication.ingredient.item as CodeableConcept)", description="Returns medications for this ingredient code", type="token" )
1342  public static final String SP_INGREDIENT_CODE = "ingredient-code";
1343 /**
1344   * <b>Fluent Client</b> search parameter constant for <b>ingredient-code</b>
1345   * <p>
1346   * Description: <b>Returns medications for this ingredient code</b><br>
1347   * Type: <b>token</b><br>
1348   * Path: <b>Medication.ingredient.itemCodeableConcept</b><br>
1349   * </p>
1350   */
1351  public static final ca.uhn.fhir.rest.gclient.TokenClientParam INGREDIENT_CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_INGREDIENT_CODE);
1352
1353 /**
1354   * Search parameter: <b>identifier</b>
1355   * <p>
1356   * Description: <b>Returns medications with this external identifier</b><br>
1357   * Type: <b>token</b><br>
1358   * Path: <b>Medication.identifier</b><br>
1359   * </p>
1360   */
1361  @SearchParamDefinition(name="identifier", path="Medication.identifier", description="Returns medications with this external identifier", type="token" )
1362  public static final String SP_IDENTIFIER = "identifier";
1363 /**
1364   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
1365   * <p>
1366   * Description: <b>Returns medications with this external identifier</b><br>
1367   * Type: <b>token</b><br>
1368   * Path: <b>Medication.identifier</b><br>
1369   * </p>
1370   */
1371  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
1372
1373 /**
1374   * Search parameter: <b>code</b>
1375   * <p>
1376   * Description: <b>Returns medications for a specific code</b><br>
1377   * Type: <b>token</b><br>
1378   * Path: <b>Medication.code</b><br>
1379   * </p>
1380   */
1381  @SearchParamDefinition(name="code", path="Medication.code", description="Returns medications for a specific code", type="token" )
1382  public static final String SP_CODE = "code";
1383 /**
1384   * <b>Fluent Client</b> search parameter constant for <b>code</b>
1385   * <p>
1386   * Description: <b>Returns medications for a specific code</b><br>
1387   * Type: <b>token</b><br>
1388   * Path: <b>Medication.code</b><br>
1389   * </p>
1390   */
1391  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CODE);
1392
1393 /**
1394   * Search parameter: <b>ingredient</b>
1395   * <p>
1396   * Description: <b>Returns medications for this ingredient reference</b><br>
1397   * Type: <b>reference</b><br>
1398   * Path: <b>Medication.ingredient.itemReference</b><br>
1399   * </p>
1400   */
1401  @SearchParamDefinition(name="ingredient", path="(Medication.ingredient.item as Reference)", description="Returns medications for this ingredient reference", type="reference", target={Medication.class, Substance.class } )
1402  public static final String SP_INGREDIENT = "ingredient";
1403 /**
1404   * <b>Fluent Client</b> search parameter constant for <b>ingredient</b>
1405   * <p>
1406   * Description: <b>Returns medications for this ingredient reference</b><br>
1407   * Type: <b>reference</b><br>
1408   * Path: <b>Medication.ingredient.itemReference</b><br>
1409   * </p>
1410   */
1411  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam INGREDIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_INGREDIENT);
1412
1413/**
1414   * Constant for fluent queries to be used to add include statements. Specifies
1415   * the path value of "<b>Medication:ingredient</b>".
1416   */
1417  public static final ca.uhn.fhir.model.api.Include INCLUDE_INGREDIENT = new ca.uhn.fhir.model.api.Include("Medication:ingredient").toLocked();
1418
1419 /**
1420   * Search parameter: <b>form</b>
1421   * <p>
1422   * Description: <b>Returns medications for a specific dose form</b><br>
1423   * Type: <b>token</b><br>
1424   * Path: <b>Medication.form</b><br>
1425   * </p>
1426   */
1427  @SearchParamDefinition(name="form", path="Medication.form", description="Returns medications for a specific dose form", type="token" )
1428  public static final String SP_FORM = "form";
1429 /**
1430   * <b>Fluent Client</b> search parameter constant for <b>form</b>
1431   * <p>
1432   * Description: <b>Returns medications for a specific dose form</b><br>
1433   * Type: <b>token</b><br>
1434   * Path: <b>Medication.form</b><br>
1435   * </p>
1436   */
1437  public static final ca.uhn.fhir.rest.gclient.TokenClientParam FORM = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_FORM);
1438
1439 /**
1440   * Search parameter: <b>lot-number</b>
1441   * <p>
1442   * Description: <b>Returns medications in a batch with this lot number</b><br>
1443   * Type: <b>token</b><br>
1444   * Path: <b>Medication.batch.lotNumber</b><br>
1445   * </p>
1446   */
1447  @SearchParamDefinition(name="lot-number", path="Medication.batch.lotNumber", description="Returns medications in a batch with this lot number", type="token" )
1448  public static final String SP_LOT_NUMBER = "lot-number";
1449 /**
1450   * <b>Fluent Client</b> search parameter constant for <b>lot-number</b>
1451   * <p>
1452   * Description: <b>Returns medications in a batch with this lot number</b><br>
1453   * Type: <b>token</b><br>
1454   * Path: <b>Medication.batch.lotNumber</b><br>
1455   * </p>
1456   */
1457  public static final ca.uhn.fhir.rest.gclient.TokenClientParam LOT_NUMBER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_LOT_NUMBER);
1458
1459 /**
1460   * Search parameter: <b>expiration-date</b>
1461   * <p>
1462   * Description: <b>Returns medications in a batch with this expiration date</b><br>
1463   * Type: <b>date</b><br>
1464   * Path: <b>Medication.batch.expirationDate</b><br>
1465   * </p>
1466   */
1467  @SearchParamDefinition(name="expiration-date", path="Medication.batch.expirationDate", description="Returns medications in a batch with this expiration date", type="date" )
1468  public static final String SP_EXPIRATION_DATE = "expiration-date";
1469 /**
1470   * <b>Fluent Client</b> search parameter constant for <b>expiration-date</b>
1471   * <p>
1472   * Description: <b>Returns medications in a batch with this expiration date</b><br>
1473   * Type: <b>date</b><br>
1474   * Path: <b>Medication.batch.expirationDate</b><br>
1475   * </p>
1476   */
1477  public static final ca.uhn.fhir.rest.gclient.DateClientParam EXPIRATION_DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_EXPIRATION_DATE);
1478
1479 /**
1480   * Search parameter: <b>manufacturer</b>
1481   * <p>
1482   * Description: <b>Returns medications made or sold for this manufacturer</b><br>
1483   * Type: <b>reference</b><br>
1484   * Path: <b>Medication.manufacturer</b><br>
1485   * </p>
1486   */
1487  @SearchParamDefinition(name="manufacturer", path="Medication.manufacturer", description="Returns medications made or sold for this manufacturer", type="reference", target={Organization.class } )
1488  public static final String SP_MANUFACTURER = "manufacturer";
1489 /**
1490   * <b>Fluent Client</b> search parameter constant for <b>manufacturer</b>
1491   * <p>
1492   * Description: <b>Returns medications made or sold for this manufacturer</b><br>
1493   * Type: <b>reference</b><br>
1494   * Path: <b>Medication.manufacturer</b><br>
1495   * </p>
1496   */
1497  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam MANUFACTURER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_MANUFACTURER);
1498
1499/**
1500   * Constant for fluent queries to be used to add include statements. Specifies
1501   * the path value of "<b>Medication:manufacturer</b>".
1502   */
1503  public static final ca.uhn.fhir.model.api.Include INCLUDE_MANUFACTURER = new ca.uhn.fhir.model.api.Include("Medication:manufacturer").toLocked();
1504
1505 /**
1506   * Search parameter: <b>status</b>
1507   * <p>
1508   * Description: <b>Returns medications for this status</b><br>
1509   * Type: <b>token</b><br>
1510   * Path: <b>Medication.status</b><br>
1511   * </p>
1512   */
1513  @SearchParamDefinition(name="status", path="Medication.status", description="Returns medications for this status", type="token" )
1514  public static final String SP_STATUS = "status";
1515 /**
1516   * <b>Fluent Client</b> search parameter constant for <b>status</b>
1517   * <p>
1518   * Description: <b>Returns medications for this status</b><br>
1519   * Type: <b>token</b><br>
1520   * Path: <b>Medication.status</b><br>
1521   * </p>
1522   */
1523  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
1524
1525
1526}