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