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