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