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