001package org.hl7.fhir.r5.model;
002
003
004/*
005  Copyright (c) 2011+, HL7, Inc.
006  All rights reserved.
007  
008  Redistribution and use in source and binary forms, with or without modification, \
009  are permitted provided that the following conditions are met:
010  
011   * Redistributions of source code must retain the above copyright notice, this \
012     list of conditions and the following disclaimer.
013   * Redistributions in binary form must reproduce the above copyright notice, \
014     this list of conditions and the following disclaimer in the documentation \
015     and/or other materials provided with the distribution.
016   * Neither the name of HL7 nor the names of its contributors may be used to 
017     endorse or promote products derived from this software without specific 
018     prior written permission.
019  
020  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
021  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
022  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
023  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
024  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
025  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
026  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
027  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
028  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
029  POSSIBILITY OF SUCH DAMAGE.
030  */
031
032// Generated on Tue, Dec 28, 2021 07:16+1100 for FHIR v5.0.0-snapshot1
033
034import java.util.ArrayList;
035import java.util.Date;
036import java.util.List;
037import org.hl7.fhir.utilities.Utilities;
038import org.hl7.fhir.r5.model.Enumerations.*;
039import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
040import org.hl7.fhir.exceptions.FHIRException;
041import org.hl7.fhir.instance.model.api.ICompositeType;
042import ca.uhn.fhir.model.api.annotation.ResourceDef;
043import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
044import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
045import ca.uhn.fhir.model.api.annotation.Child;
046import ca.uhn.fhir.model.api.annotation.ChildOrder;
047import ca.uhn.fhir.model.api.annotation.Description;
048import ca.uhn.fhir.model.api.annotation.Block;
049
050/**
051 * The detailed description of a substance, typically at a level beyond what is used for prescribing.
052 */
053@ResourceDef(name="SubstanceDefinition", profile="http://hl7.org/fhir/StructureDefinition/SubstanceDefinition")
054public class SubstanceDefinition extends DomainResource {
055
056    @Block()
057    public static class SubstanceDefinitionMoietyComponent extends BackboneElement implements IBaseBackboneElement {
058        /**
059         * Role that the moiety is playing.
060         */
061        @Child(name = "role", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
062        @Description(shortDefinition="Role that the moiety is playing", formalDefinition="Role that the moiety is playing." )
063        protected CodeableConcept role;
064
065        /**
066         * Identifier by which this moiety substance is known.
067         */
068        @Child(name = "identifier", type = {Identifier.class}, order=2, min=0, max=1, modifier=false, summary=true)
069        @Description(shortDefinition="Identifier by which this moiety substance is known", formalDefinition="Identifier by which this moiety substance is known." )
070        protected Identifier identifier;
071
072        /**
073         * Textual name for this moiety substance.
074         */
075        @Child(name = "name", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true)
076        @Description(shortDefinition="Textual name for this moiety substance", formalDefinition="Textual name for this moiety substance." )
077        protected StringType name;
078
079        /**
080         * Stereochemistry type.
081         */
082        @Child(name = "stereochemistry", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=true)
083        @Description(shortDefinition="Stereochemistry type", formalDefinition="Stereochemistry type." )
084        protected CodeableConcept stereochemistry;
085
086        /**
087         * Optical activity type.
088         */
089        @Child(name = "opticalActivity", type = {CodeableConcept.class}, order=5, min=0, max=1, modifier=false, summary=true)
090        @Description(shortDefinition="Optical activity type", formalDefinition="Optical activity type." )
091        protected CodeableConcept opticalActivity;
092
093        /**
094         * Molecular formula for this moiety of this substance, typically using the Hill system.
095         */
096        @Child(name = "molecularFormula", type = {StringType.class}, order=6, min=0, max=1, modifier=false, summary=true)
097        @Description(shortDefinition="Molecular formula for this moiety of this substance, typically using the Hill system", formalDefinition="Molecular formula for this moiety of this substance, typically using the Hill system." )
098        protected StringType molecularFormula;
099
100        /**
101         * Quantitative value for this moiety.
102         */
103        @Child(name = "amount", type = {Quantity.class, StringType.class}, order=7, min=0, max=1, modifier=false, summary=true)
104        @Description(shortDefinition="Quantitative value for this moiety", formalDefinition="Quantitative value for this moiety." )
105        protected DataType amount;
106
107        /**
108         * The measurement type of the quantitative value.
109         */
110        @Child(name = "amountType", type = {CodeableConcept.class}, order=8, min=0, max=1, modifier=false, summary=true)
111        @Description(shortDefinition="The measurement type of the quantitative value", formalDefinition="The measurement type of the quantitative value." )
112        protected CodeableConcept amountType;
113
114        private static final long serialVersionUID = -1330905924L;
115
116    /**
117     * Constructor
118     */
119      public SubstanceDefinitionMoietyComponent() {
120        super();
121      }
122
123        /**
124         * @return {@link #role} (Role that the moiety is playing.)
125         */
126        public CodeableConcept getRole() { 
127          if (this.role == null)
128            if (Configuration.errorOnAutoCreate())
129              throw new Error("Attempt to auto-create SubstanceDefinitionMoietyComponent.role");
130            else if (Configuration.doAutoCreate())
131              this.role = new CodeableConcept(); // cc
132          return this.role;
133        }
134
135        public boolean hasRole() { 
136          return this.role != null && !this.role.isEmpty();
137        }
138
139        /**
140         * @param value {@link #role} (Role that the moiety is playing.)
141         */
142        public SubstanceDefinitionMoietyComponent setRole(CodeableConcept value) { 
143          this.role = value;
144          return this;
145        }
146
147        /**
148         * @return {@link #identifier} (Identifier by which this moiety substance is known.)
149         */
150        public Identifier getIdentifier() { 
151          if (this.identifier == null)
152            if (Configuration.errorOnAutoCreate())
153              throw new Error("Attempt to auto-create SubstanceDefinitionMoietyComponent.identifier");
154            else if (Configuration.doAutoCreate())
155              this.identifier = new Identifier(); // cc
156          return this.identifier;
157        }
158
159        public boolean hasIdentifier() { 
160          return this.identifier != null && !this.identifier.isEmpty();
161        }
162
163        /**
164         * @param value {@link #identifier} (Identifier by which this moiety substance is known.)
165         */
166        public SubstanceDefinitionMoietyComponent setIdentifier(Identifier value) { 
167          this.identifier = value;
168          return this;
169        }
170
171        /**
172         * @return {@link #name} (Textual name for this moiety substance.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
173         */
174        public StringType getNameElement() { 
175          if (this.name == null)
176            if (Configuration.errorOnAutoCreate())
177              throw new Error("Attempt to auto-create SubstanceDefinitionMoietyComponent.name");
178            else if (Configuration.doAutoCreate())
179              this.name = new StringType(); // bb
180          return this.name;
181        }
182
183        public boolean hasNameElement() { 
184          return this.name != null && !this.name.isEmpty();
185        }
186
187        public boolean hasName() { 
188          return this.name != null && !this.name.isEmpty();
189        }
190
191        /**
192         * @param value {@link #name} (Textual name for this moiety substance.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
193         */
194        public SubstanceDefinitionMoietyComponent setNameElement(StringType value) { 
195          this.name = value;
196          return this;
197        }
198
199        /**
200         * @return Textual name for this moiety substance.
201         */
202        public String getName() { 
203          return this.name == null ? null : this.name.getValue();
204        }
205
206        /**
207         * @param value Textual name for this moiety substance.
208         */
209        public SubstanceDefinitionMoietyComponent setName(String value) { 
210          if (Utilities.noString(value))
211            this.name = null;
212          else {
213            if (this.name == null)
214              this.name = new StringType();
215            this.name.setValue(value);
216          }
217          return this;
218        }
219
220        /**
221         * @return {@link #stereochemistry} (Stereochemistry type.)
222         */
223        public CodeableConcept getStereochemistry() { 
224          if (this.stereochemistry == null)
225            if (Configuration.errorOnAutoCreate())
226              throw new Error("Attempt to auto-create SubstanceDefinitionMoietyComponent.stereochemistry");
227            else if (Configuration.doAutoCreate())
228              this.stereochemistry = new CodeableConcept(); // cc
229          return this.stereochemistry;
230        }
231
232        public boolean hasStereochemistry() { 
233          return this.stereochemistry != null && !this.stereochemistry.isEmpty();
234        }
235
236        /**
237         * @param value {@link #stereochemistry} (Stereochemistry type.)
238         */
239        public SubstanceDefinitionMoietyComponent setStereochemistry(CodeableConcept value) { 
240          this.stereochemistry = value;
241          return this;
242        }
243
244        /**
245         * @return {@link #opticalActivity} (Optical activity type.)
246         */
247        public CodeableConcept getOpticalActivity() { 
248          if (this.opticalActivity == null)
249            if (Configuration.errorOnAutoCreate())
250              throw new Error("Attempt to auto-create SubstanceDefinitionMoietyComponent.opticalActivity");
251            else if (Configuration.doAutoCreate())
252              this.opticalActivity = new CodeableConcept(); // cc
253          return this.opticalActivity;
254        }
255
256        public boolean hasOpticalActivity() { 
257          return this.opticalActivity != null && !this.opticalActivity.isEmpty();
258        }
259
260        /**
261         * @param value {@link #opticalActivity} (Optical activity type.)
262         */
263        public SubstanceDefinitionMoietyComponent setOpticalActivity(CodeableConcept value) { 
264          this.opticalActivity = value;
265          return this;
266        }
267
268        /**
269         * @return {@link #molecularFormula} (Molecular formula for this moiety of this substance, typically using the Hill system.). This is the underlying object with id, value and extensions. The accessor "getMolecularFormula" gives direct access to the value
270         */
271        public StringType getMolecularFormulaElement() { 
272          if (this.molecularFormula == null)
273            if (Configuration.errorOnAutoCreate())
274              throw new Error("Attempt to auto-create SubstanceDefinitionMoietyComponent.molecularFormula");
275            else if (Configuration.doAutoCreate())
276              this.molecularFormula = new StringType(); // bb
277          return this.molecularFormula;
278        }
279
280        public boolean hasMolecularFormulaElement() { 
281          return this.molecularFormula != null && !this.molecularFormula.isEmpty();
282        }
283
284        public boolean hasMolecularFormula() { 
285          return this.molecularFormula != null && !this.molecularFormula.isEmpty();
286        }
287
288        /**
289         * @param value {@link #molecularFormula} (Molecular formula for this moiety of this substance, typically using the Hill system.). This is the underlying object with id, value and extensions. The accessor "getMolecularFormula" gives direct access to the value
290         */
291        public SubstanceDefinitionMoietyComponent setMolecularFormulaElement(StringType value) { 
292          this.molecularFormula = value;
293          return this;
294        }
295
296        /**
297         * @return Molecular formula for this moiety of this substance, typically using the Hill system.
298         */
299        public String getMolecularFormula() { 
300          return this.molecularFormula == null ? null : this.molecularFormula.getValue();
301        }
302
303        /**
304         * @param value Molecular formula for this moiety of this substance, typically using the Hill system.
305         */
306        public SubstanceDefinitionMoietyComponent setMolecularFormula(String value) { 
307          if (Utilities.noString(value))
308            this.molecularFormula = null;
309          else {
310            if (this.molecularFormula == null)
311              this.molecularFormula = new StringType();
312            this.molecularFormula.setValue(value);
313          }
314          return this;
315        }
316
317        /**
318         * @return {@link #amount} (Quantitative value for this moiety.)
319         */
320        public DataType getAmount() { 
321          return this.amount;
322        }
323
324        /**
325         * @return {@link #amount} (Quantitative value for this moiety.)
326         */
327        public Quantity getAmountQuantity() throws FHIRException { 
328          if (this.amount == null)
329            this.amount = new Quantity();
330          if (!(this.amount instanceof Quantity))
331            throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.amount.getClass().getName()+" was encountered");
332          return (Quantity) this.amount;
333        }
334
335        public boolean hasAmountQuantity() { 
336          return this != null && this.amount instanceof Quantity;
337        }
338
339        /**
340         * @return {@link #amount} (Quantitative value for this moiety.)
341         */
342        public StringType getAmountStringType() throws FHIRException { 
343          if (this.amount == null)
344            this.amount = new StringType();
345          if (!(this.amount instanceof StringType))
346            throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.amount.getClass().getName()+" was encountered");
347          return (StringType) this.amount;
348        }
349
350        public boolean hasAmountStringType() { 
351          return this != null && this.amount instanceof StringType;
352        }
353
354        public boolean hasAmount() { 
355          return this.amount != null && !this.amount.isEmpty();
356        }
357
358        /**
359         * @param value {@link #amount} (Quantitative value for this moiety.)
360         */
361        public SubstanceDefinitionMoietyComponent setAmount(DataType value) { 
362          if (value != null && !(value instanceof Quantity || value instanceof StringType))
363            throw new Error("Not the right type for SubstanceDefinition.moiety.amount[x]: "+value.fhirType());
364          this.amount = value;
365          return this;
366        }
367
368        /**
369         * @return {@link #amountType} (The measurement type of the quantitative value.)
370         */
371        public CodeableConcept getAmountType() { 
372          if (this.amountType == null)
373            if (Configuration.errorOnAutoCreate())
374              throw new Error("Attempt to auto-create SubstanceDefinitionMoietyComponent.amountType");
375            else if (Configuration.doAutoCreate())
376              this.amountType = new CodeableConcept(); // cc
377          return this.amountType;
378        }
379
380        public boolean hasAmountType() { 
381          return this.amountType != null && !this.amountType.isEmpty();
382        }
383
384        /**
385         * @param value {@link #amountType} (The measurement type of the quantitative value.)
386         */
387        public SubstanceDefinitionMoietyComponent setAmountType(CodeableConcept value) { 
388          this.amountType = value;
389          return this;
390        }
391
392        protected void listChildren(List<Property> children) {
393          super.listChildren(children);
394          children.add(new Property("role", "CodeableConcept", "Role that the moiety is playing.", 0, 1, role));
395          children.add(new Property("identifier", "Identifier", "Identifier by which this moiety substance is known.", 0, 1, identifier));
396          children.add(new Property("name", "string", "Textual name for this moiety substance.", 0, 1, name));
397          children.add(new Property("stereochemistry", "CodeableConcept", "Stereochemistry type.", 0, 1, stereochemistry));
398          children.add(new Property("opticalActivity", "CodeableConcept", "Optical activity type.", 0, 1, opticalActivity));
399          children.add(new Property("molecularFormula", "string", "Molecular formula for this moiety of this substance, typically using the Hill system.", 0, 1, molecularFormula));
400          children.add(new Property("amount[x]", "Quantity|string", "Quantitative value for this moiety.", 0, 1, amount));
401          children.add(new Property("amountType", "CodeableConcept", "The measurement type of the quantitative value.", 0, 1, amountType));
402        }
403
404        @Override
405        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
406          switch (_hash) {
407          case 3506294: /*role*/  return new Property("role", "CodeableConcept", "Role that the moiety is playing.", 0, 1, role);
408          case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Identifier by which this moiety substance is known.", 0, 1, identifier);
409          case 3373707: /*name*/  return new Property("name", "string", "Textual name for this moiety substance.", 0, 1, name);
410          case 263475116: /*stereochemistry*/  return new Property("stereochemistry", "CodeableConcept", "Stereochemistry type.", 0, 1, stereochemistry);
411          case 1420900135: /*opticalActivity*/  return new Property("opticalActivity", "CodeableConcept", "Optical activity type.", 0, 1, opticalActivity);
412          case 616660246: /*molecularFormula*/  return new Property("molecularFormula", "string", "Molecular formula for this moiety of this substance, typically using the Hill system.", 0, 1, molecularFormula);
413          case 646780200: /*amount[x]*/  return new Property("amount[x]", "Quantity|string", "Quantitative value for this moiety.", 0, 1, amount);
414          case -1413853096: /*amount*/  return new Property("amount[x]", "Quantity|string", "Quantitative value for this moiety.", 0, 1, amount);
415          case 1664303363: /*amountQuantity*/  return new Property("amount[x]", "Quantity", "Quantitative value for this moiety.", 0, 1, amount);
416          case 773651081: /*amountString*/  return new Property("amount[x]", "string", "Quantitative value for this moiety.", 0, 1, amount);
417          case -1424857166: /*amountType*/  return new Property("amountType", "CodeableConcept", "The measurement type of the quantitative value.", 0, 1, amountType);
418          default: return super.getNamedProperty(_hash, _name, _checkValid);
419          }
420
421        }
422
423      @Override
424      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
425        switch (hash) {
426        case 3506294: /*role*/ return this.role == null ? new Base[0] : new Base[] {this.role}; // CodeableConcept
427        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : new Base[] {this.identifier}; // Identifier
428        case 3373707: /*name*/ return this.name == null ? new Base[0] : new Base[] {this.name}; // StringType
429        case 263475116: /*stereochemistry*/ return this.stereochemistry == null ? new Base[0] : new Base[] {this.stereochemistry}; // CodeableConcept
430        case 1420900135: /*opticalActivity*/ return this.opticalActivity == null ? new Base[0] : new Base[] {this.opticalActivity}; // CodeableConcept
431        case 616660246: /*molecularFormula*/ return this.molecularFormula == null ? new Base[0] : new Base[] {this.molecularFormula}; // StringType
432        case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : new Base[] {this.amount}; // DataType
433        case -1424857166: /*amountType*/ return this.amountType == null ? new Base[0] : new Base[] {this.amountType}; // CodeableConcept
434        default: return super.getProperty(hash, name, checkValid);
435        }
436
437      }
438
439      @Override
440      public Base setProperty(int hash, String name, Base value) throws FHIRException {
441        switch (hash) {
442        case 3506294: // role
443          this.role = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
444          return value;
445        case -1618432855: // identifier
446          this.identifier = TypeConvertor.castToIdentifier(value); // Identifier
447          return value;
448        case 3373707: // name
449          this.name = TypeConvertor.castToString(value); // StringType
450          return value;
451        case 263475116: // stereochemistry
452          this.stereochemistry = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
453          return value;
454        case 1420900135: // opticalActivity
455          this.opticalActivity = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
456          return value;
457        case 616660246: // molecularFormula
458          this.molecularFormula = TypeConvertor.castToString(value); // StringType
459          return value;
460        case -1413853096: // amount
461          this.amount = TypeConvertor.castToType(value); // DataType
462          return value;
463        case -1424857166: // amountType
464          this.amountType = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
465          return value;
466        default: return super.setProperty(hash, name, value);
467        }
468
469      }
470
471      @Override
472      public Base setProperty(String name, Base value) throws FHIRException {
473        if (name.equals("role")) {
474          this.role = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
475        } else if (name.equals("identifier")) {
476          this.identifier = TypeConvertor.castToIdentifier(value); // Identifier
477        } else if (name.equals("name")) {
478          this.name = TypeConvertor.castToString(value); // StringType
479        } else if (name.equals("stereochemistry")) {
480          this.stereochemistry = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
481        } else if (name.equals("opticalActivity")) {
482          this.opticalActivity = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
483        } else if (name.equals("molecularFormula")) {
484          this.molecularFormula = TypeConvertor.castToString(value); // StringType
485        } else if (name.equals("amount[x]")) {
486          this.amount = TypeConvertor.castToType(value); // DataType
487        } else if (name.equals("amountType")) {
488          this.amountType = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
489        } else
490          return super.setProperty(name, value);
491        return value;
492      }
493
494      @Override
495      public Base makeProperty(int hash, String name) throws FHIRException {
496        switch (hash) {
497        case 3506294:  return getRole();
498        case -1618432855:  return getIdentifier();
499        case 3373707:  return getNameElement();
500        case 263475116:  return getStereochemistry();
501        case 1420900135:  return getOpticalActivity();
502        case 616660246:  return getMolecularFormulaElement();
503        case 646780200:  return getAmount();
504        case -1413853096:  return getAmount();
505        case -1424857166:  return getAmountType();
506        default: return super.makeProperty(hash, name);
507        }
508
509      }
510
511      @Override
512      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
513        switch (hash) {
514        case 3506294: /*role*/ return new String[] {"CodeableConcept"};
515        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
516        case 3373707: /*name*/ return new String[] {"string"};
517        case 263475116: /*stereochemistry*/ return new String[] {"CodeableConcept"};
518        case 1420900135: /*opticalActivity*/ return new String[] {"CodeableConcept"};
519        case 616660246: /*molecularFormula*/ return new String[] {"string"};
520        case -1413853096: /*amount*/ return new String[] {"Quantity", "string"};
521        case -1424857166: /*amountType*/ return new String[] {"CodeableConcept"};
522        default: return super.getTypesForProperty(hash, name);
523        }
524
525      }
526
527      @Override
528      public Base addChild(String name) throws FHIRException {
529        if (name.equals("role")) {
530          this.role = new CodeableConcept();
531          return this.role;
532        }
533        else if (name.equals("identifier")) {
534          this.identifier = new Identifier();
535          return this.identifier;
536        }
537        else if (name.equals("name")) {
538          throw new FHIRException("Cannot call addChild on a primitive type SubstanceDefinition.moiety.name");
539        }
540        else if (name.equals("stereochemistry")) {
541          this.stereochemistry = new CodeableConcept();
542          return this.stereochemistry;
543        }
544        else if (name.equals("opticalActivity")) {
545          this.opticalActivity = new CodeableConcept();
546          return this.opticalActivity;
547        }
548        else if (name.equals("molecularFormula")) {
549          throw new FHIRException("Cannot call addChild on a primitive type SubstanceDefinition.moiety.molecularFormula");
550        }
551        else if (name.equals("amountQuantity")) {
552          this.amount = new Quantity();
553          return this.amount;
554        }
555        else if (name.equals("amountString")) {
556          this.amount = new StringType();
557          return this.amount;
558        }
559        else if (name.equals("amountType")) {
560          this.amountType = new CodeableConcept();
561          return this.amountType;
562        }
563        else
564          return super.addChild(name);
565      }
566
567      public SubstanceDefinitionMoietyComponent copy() {
568        SubstanceDefinitionMoietyComponent dst = new SubstanceDefinitionMoietyComponent();
569        copyValues(dst);
570        return dst;
571      }
572
573      public void copyValues(SubstanceDefinitionMoietyComponent dst) {
574        super.copyValues(dst);
575        dst.role = role == null ? null : role.copy();
576        dst.identifier = identifier == null ? null : identifier.copy();
577        dst.name = name == null ? null : name.copy();
578        dst.stereochemistry = stereochemistry == null ? null : stereochemistry.copy();
579        dst.opticalActivity = opticalActivity == null ? null : opticalActivity.copy();
580        dst.molecularFormula = molecularFormula == null ? null : molecularFormula.copy();
581        dst.amount = amount == null ? null : amount.copy();
582        dst.amountType = amountType == null ? null : amountType.copy();
583      }
584
585      @Override
586      public boolean equalsDeep(Base other_) {
587        if (!super.equalsDeep(other_))
588          return false;
589        if (!(other_ instanceof SubstanceDefinitionMoietyComponent))
590          return false;
591        SubstanceDefinitionMoietyComponent o = (SubstanceDefinitionMoietyComponent) other_;
592        return compareDeep(role, o.role, true) && compareDeep(identifier, o.identifier, true) && compareDeep(name, o.name, true)
593           && compareDeep(stereochemistry, o.stereochemistry, true) && compareDeep(opticalActivity, o.opticalActivity, true)
594           && compareDeep(molecularFormula, o.molecularFormula, true) && compareDeep(amount, o.amount, true)
595           && compareDeep(amountType, o.amountType, true);
596      }
597
598      @Override
599      public boolean equalsShallow(Base other_) {
600        if (!super.equalsShallow(other_))
601          return false;
602        if (!(other_ instanceof SubstanceDefinitionMoietyComponent))
603          return false;
604        SubstanceDefinitionMoietyComponent o = (SubstanceDefinitionMoietyComponent) other_;
605        return compareValues(name, o.name, true) && compareValues(molecularFormula, o.molecularFormula, true)
606          ;
607      }
608
609      public boolean isEmpty() {
610        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(role, identifier, name, stereochemistry
611          , opticalActivity, molecularFormula, amount, amountType);
612      }
613
614  public String fhirType() {
615    return "SubstanceDefinition.moiety";
616
617  }
618
619  }
620
621    @Block()
622    public static class SubstanceDefinitionPropertyComponent extends BackboneElement implements IBaseBackboneElement {
623        /**
624         * A code expressing the type of characteristic.
625         */
626        @Child(name = "type", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=true)
627        @Description(shortDefinition="A code expressing the type of characteristic", formalDefinition="A code expressing the type of characteristic." )
628        protected CodeableConcept type;
629
630        /**
631         * A value for the characteristic.
632         */
633        @Child(name = "value", type = {CodeableConcept.class, Quantity.class, DateType.class, BooleanType.class, Attachment.class}, order=2, min=0, max=1, modifier=false, summary=true)
634        @Description(shortDefinition="A value for the characteristic", formalDefinition="A value for the characteristic." )
635        protected DataType value;
636
637        private static final long serialVersionUID = -1659186716L;
638
639    /**
640     * Constructor
641     */
642      public SubstanceDefinitionPropertyComponent() {
643        super();
644      }
645
646    /**
647     * Constructor
648     */
649      public SubstanceDefinitionPropertyComponent(CodeableConcept type) {
650        super();
651        this.setType(type);
652      }
653
654        /**
655         * @return {@link #type} (A code expressing the type of characteristic.)
656         */
657        public CodeableConcept getType() { 
658          if (this.type == null)
659            if (Configuration.errorOnAutoCreate())
660              throw new Error("Attempt to auto-create SubstanceDefinitionPropertyComponent.type");
661            else if (Configuration.doAutoCreate())
662              this.type = new CodeableConcept(); // cc
663          return this.type;
664        }
665
666        public boolean hasType() { 
667          return this.type != null && !this.type.isEmpty();
668        }
669
670        /**
671         * @param value {@link #type} (A code expressing the type of characteristic.)
672         */
673        public SubstanceDefinitionPropertyComponent setType(CodeableConcept value) { 
674          this.type = value;
675          return this;
676        }
677
678        /**
679         * @return {@link #value} (A value for the characteristic.)
680         */
681        public DataType getValue() { 
682          return this.value;
683        }
684
685        /**
686         * @return {@link #value} (A value for the characteristic.)
687         */
688        public CodeableConcept getValueCodeableConcept() throws FHIRException { 
689          if (this.value == null)
690            this.value = new CodeableConcept();
691          if (!(this.value instanceof CodeableConcept))
692            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.value.getClass().getName()+" was encountered");
693          return (CodeableConcept) this.value;
694        }
695
696        public boolean hasValueCodeableConcept() { 
697          return this != null && this.value instanceof CodeableConcept;
698        }
699
700        /**
701         * @return {@link #value} (A value for the characteristic.)
702         */
703        public Quantity getValueQuantity() throws FHIRException { 
704          if (this.value == null)
705            this.value = new Quantity();
706          if (!(this.value instanceof Quantity))
707            throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.value.getClass().getName()+" was encountered");
708          return (Quantity) this.value;
709        }
710
711        public boolean hasValueQuantity() { 
712          return this != null && this.value instanceof Quantity;
713        }
714
715        /**
716         * @return {@link #value} (A value for the characteristic.)
717         */
718        public DateType getValueDateType() throws FHIRException { 
719          if (this.value == null)
720            this.value = new DateType();
721          if (!(this.value instanceof DateType))
722            throw new FHIRException("Type mismatch: the type DateType was expected, but "+this.value.getClass().getName()+" was encountered");
723          return (DateType) this.value;
724        }
725
726        public boolean hasValueDateType() { 
727          return this != null && this.value instanceof DateType;
728        }
729
730        /**
731         * @return {@link #value} (A value for the characteristic.)
732         */
733        public BooleanType getValueBooleanType() throws FHIRException { 
734          if (this.value == null)
735            this.value = new BooleanType();
736          if (!(this.value instanceof BooleanType))
737            throw new FHIRException("Type mismatch: the type BooleanType was expected, but "+this.value.getClass().getName()+" was encountered");
738          return (BooleanType) this.value;
739        }
740
741        public boolean hasValueBooleanType() { 
742          return this != null && this.value instanceof BooleanType;
743        }
744
745        /**
746         * @return {@link #value} (A value for the characteristic.)
747         */
748        public Attachment getValueAttachment() throws FHIRException { 
749          if (this.value == null)
750            this.value = new Attachment();
751          if (!(this.value instanceof Attachment))
752            throw new FHIRException("Type mismatch: the type Attachment was expected, but "+this.value.getClass().getName()+" was encountered");
753          return (Attachment) this.value;
754        }
755
756        public boolean hasValueAttachment() { 
757          return this != null && this.value instanceof Attachment;
758        }
759
760        public boolean hasValue() { 
761          return this.value != null && !this.value.isEmpty();
762        }
763
764        /**
765         * @param value {@link #value} (A value for the characteristic.)
766         */
767        public SubstanceDefinitionPropertyComponent setValue(DataType value) { 
768          if (value != null && !(value instanceof CodeableConcept || value instanceof Quantity || value instanceof DateType || value instanceof BooleanType || value instanceof Attachment))
769            throw new Error("Not the right type for SubstanceDefinition.property.value[x]: "+value.fhirType());
770          this.value = value;
771          return this;
772        }
773
774        protected void listChildren(List<Property> children) {
775          super.listChildren(children);
776          children.add(new Property("type", "CodeableConcept", "A code expressing the type of characteristic.", 0, 1, type));
777          children.add(new Property("value[x]", "CodeableConcept|Quantity|date|boolean|Attachment", "A value for the characteristic.", 0, 1, value));
778        }
779
780        @Override
781        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
782          switch (_hash) {
783          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "A code expressing the type of characteristic.", 0, 1, type);
784          case -1410166417: /*value[x]*/  return new Property("value[x]", "CodeableConcept|Quantity|date|boolean|Attachment", "A value for the characteristic.", 0, 1, value);
785          case 111972721: /*value*/  return new Property("value[x]", "CodeableConcept|Quantity|date|boolean|Attachment", "A value for the characteristic.", 0, 1, value);
786          case 924902896: /*valueCodeableConcept*/  return new Property("value[x]", "CodeableConcept", "A value for the characteristic.", 0, 1, value);
787          case -2029823716: /*valueQuantity*/  return new Property("value[x]", "Quantity", "A value for the characteristic.", 0, 1, value);
788          case -766192449: /*valueDate*/  return new Property("value[x]", "date", "A value for the characteristic.", 0, 1, value);
789          case 733421943: /*valueBoolean*/  return new Property("value[x]", "boolean", "A value for the characteristic.", 0, 1, value);
790          case -475566732: /*valueAttachment*/  return new Property("value[x]", "Attachment", "A value for the characteristic.", 0, 1, value);
791          default: return super.getNamedProperty(_hash, _name, _checkValid);
792          }
793
794        }
795
796      @Override
797      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
798        switch (hash) {
799        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
800        case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // DataType
801        default: return super.getProperty(hash, name, checkValid);
802        }
803
804      }
805
806      @Override
807      public Base setProperty(int hash, String name, Base value) throws FHIRException {
808        switch (hash) {
809        case 3575610: // type
810          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
811          return value;
812        case 111972721: // value
813          this.value = TypeConvertor.castToType(value); // DataType
814          return value;
815        default: return super.setProperty(hash, name, value);
816        }
817
818      }
819
820      @Override
821      public Base setProperty(String name, Base value) throws FHIRException {
822        if (name.equals("type")) {
823          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
824        } else if (name.equals("value[x]")) {
825          this.value = TypeConvertor.castToType(value); // DataType
826        } else
827          return super.setProperty(name, value);
828        return value;
829      }
830
831      @Override
832      public Base makeProperty(int hash, String name) throws FHIRException {
833        switch (hash) {
834        case 3575610:  return getType();
835        case -1410166417:  return getValue();
836        case 111972721:  return getValue();
837        default: return super.makeProperty(hash, name);
838        }
839
840      }
841
842      @Override
843      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
844        switch (hash) {
845        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
846        case 111972721: /*value*/ return new String[] {"CodeableConcept", "Quantity", "date", "boolean", "Attachment"};
847        default: return super.getTypesForProperty(hash, name);
848        }
849
850      }
851
852      @Override
853      public Base addChild(String name) throws FHIRException {
854        if (name.equals("type")) {
855          this.type = new CodeableConcept();
856          return this.type;
857        }
858        else if (name.equals("valueCodeableConcept")) {
859          this.value = new CodeableConcept();
860          return this.value;
861        }
862        else if (name.equals("valueQuantity")) {
863          this.value = new Quantity();
864          return this.value;
865        }
866        else if (name.equals("valueDate")) {
867          this.value = new DateType();
868          return this.value;
869        }
870        else if (name.equals("valueBoolean")) {
871          this.value = new BooleanType();
872          return this.value;
873        }
874        else if (name.equals("valueAttachment")) {
875          this.value = new Attachment();
876          return this.value;
877        }
878        else
879          return super.addChild(name);
880      }
881
882      public SubstanceDefinitionPropertyComponent copy() {
883        SubstanceDefinitionPropertyComponent dst = new SubstanceDefinitionPropertyComponent();
884        copyValues(dst);
885        return dst;
886      }
887
888      public void copyValues(SubstanceDefinitionPropertyComponent dst) {
889        super.copyValues(dst);
890        dst.type = type == null ? null : type.copy();
891        dst.value = value == null ? null : value.copy();
892      }
893
894      @Override
895      public boolean equalsDeep(Base other_) {
896        if (!super.equalsDeep(other_))
897          return false;
898        if (!(other_ instanceof SubstanceDefinitionPropertyComponent))
899          return false;
900        SubstanceDefinitionPropertyComponent o = (SubstanceDefinitionPropertyComponent) other_;
901        return compareDeep(type, o.type, true) && compareDeep(value, o.value, true);
902      }
903
904      @Override
905      public boolean equalsShallow(Base other_) {
906        if (!super.equalsShallow(other_))
907          return false;
908        if (!(other_ instanceof SubstanceDefinitionPropertyComponent))
909          return false;
910        SubstanceDefinitionPropertyComponent o = (SubstanceDefinitionPropertyComponent) other_;
911        return true;
912      }
913
914      public boolean isEmpty() {
915        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, value);
916      }
917
918  public String fhirType() {
919    return "SubstanceDefinition.property";
920
921  }
922
923  }
924
925    @Block()
926    public static class SubstanceDefinitionMolecularWeightComponent extends BackboneElement implements IBaseBackboneElement {
927        /**
928         * The method by which the molecular weight was determined.
929         */
930        @Child(name = "method", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
931        @Description(shortDefinition="The method by which the molecular weight was determined", formalDefinition="The method by which the molecular weight was determined." )
932        protected CodeableConcept method;
933
934        /**
935         * Type of molecular weight such as exact, average (also known as. number average), weight average.
936         */
937        @Child(name = "type", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
938        @Description(shortDefinition="Type of molecular weight such as exact, average (also known as. number average), weight average", formalDefinition="Type of molecular weight such as exact, average (also known as. number average), weight average." )
939        protected CodeableConcept type;
940
941        /**
942         * Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.
943         */
944        @Child(name = "amount", type = {Quantity.class}, order=3, min=1, max=1, modifier=false, summary=true)
945        @Description(shortDefinition="Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field", formalDefinition="Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field." )
946        protected Quantity amount;
947
948        private static final long serialVersionUID = 805939780L;
949
950    /**
951     * Constructor
952     */
953      public SubstanceDefinitionMolecularWeightComponent() {
954        super();
955      }
956
957    /**
958     * Constructor
959     */
960      public SubstanceDefinitionMolecularWeightComponent(Quantity amount) {
961        super();
962        this.setAmount(amount);
963      }
964
965        /**
966         * @return {@link #method} (The method by which the molecular weight was determined.)
967         */
968        public CodeableConcept getMethod() { 
969          if (this.method == null)
970            if (Configuration.errorOnAutoCreate())
971              throw new Error("Attempt to auto-create SubstanceDefinitionMolecularWeightComponent.method");
972            else if (Configuration.doAutoCreate())
973              this.method = new CodeableConcept(); // cc
974          return this.method;
975        }
976
977        public boolean hasMethod() { 
978          return this.method != null && !this.method.isEmpty();
979        }
980
981        /**
982         * @param value {@link #method} (The method by which the molecular weight was determined.)
983         */
984        public SubstanceDefinitionMolecularWeightComponent setMethod(CodeableConcept value) { 
985          this.method = value;
986          return this;
987        }
988
989        /**
990         * @return {@link #type} (Type of molecular weight such as exact, average (also known as. number average), weight average.)
991         */
992        public CodeableConcept getType() { 
993          if (this.type == null)
994            if (Configuration.errorOnAutoCreate())
995              throw new Error("Attempt to auto-create SubstanceDefinitionMolecularWeightComponent.type");
996            else if (Configuration.doAutoCreate())
997              this.type = new CodeableConcept(); // cc
998          return this.type;
999        }
1000
1001        public boolean hasType() { 
1002          return this.type != null && !this.type.isEmpty();
1003        }
1004
1005        /**
1006         * @param value {@link #type} (Type of molecular weight such as exact, average (also known as. number average), weight average.)
1007         */
1008        public SubstanceDefinitionMolecularWeightComponent setType(CodeableConcept value) { 
1009          this.type = value;
1010          return this;
1011        }
1012
1013        /**
1014         * @return {@link #amount} (Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.)
1015         */
1016        public Quantity getAmount() { 
1017          if (this.amount == null)
1018            if (Configuration.errorOnAutoCreate())
1019              throw new Error("Attempt to auto-create SubstanceDefinitionMolecularWeightComponent.amount");
1020            else if (Configuration.doAutoCreate())
1021              this.amount = new Quantity(); // cc
1022          return this.amount;
1023        }
1024
1025        public boolean hasAmount() { 
1026          return this.amount != null && !this.amount.isEmpty();
1027        }
1028
1029        /**
1030         * @param value {@link #amount} (Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.)
1031         */
1032        public SubstanceDefinitionMolecularWeightComponent setAmount(Quantity value) { 
1033          this.amount = value;
1034          return this;
1035        }
1036
1037        protected void listChildren(List<Property> children) {
1038          super.listChildren(children);
1039          children.add(new Property("method", "CodeableConcept", "The method by which the molecular weight was determined.", 0, 1, method));
1040          children.add(new Property("type", "CodeableConcept", "Type of molecular weight such as exact, average (also known as. number average), weight average.", 0, 1, type));
1041          children.add(new Property("amount", "Quantity", "Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.", 0, 1, amount));
1042        }
1043
1044        @Override
1045        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1046          switch (_hash) {
1047          case -1077554975: /*method*/  return new Property("method", "CodeableConcept", "The method by which the molecular weight was determined.", 0, 1, method);
1048          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "Type of molecular weight such as exact, average (also known as. number average), weight average.", 0, 1, type);
1049          case -1413853096: /*amount*/  return new Property("amount", "Quantity", "Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.", 0, 1, amount);
1050          default: return super.getNamedProperty(_hash, _name, _checkValid);
1051          }
1052
1053        }
1054
1055      @Override
1056      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1057        switch (hash) {
1058        case -1077554975: /*method*/ return this.method == null ? new Base[0] : new Base[] {this.method}; // CodeableConcept
1059        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
1060        case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : new Base[] {this.amount}; // Quantity
1061        default: return super.getProperty(hash, name, checkValid);
1062        }
1063
1064      }
1065
1066      @Override
1067      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1068        switch (hash) {
1069        case -1077554975: // method
1070          this.method = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1071          return value;
1072        case 3575610: // type
1073          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1074          return value;
1075        case -1413853096: // amount
1076          this.amount = TypeConvertor.castToQuantity(value); // Quantity
1077          return value;
1078        default: return super.setProperty(hash, name, value);
1079        }
1080
1081      }
1082
1083      @Override
1084      public Base setProperty(String name, Base value) throws FHIRException {
1085        if (name.equals("method")) {
1086          this.method = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1087        } else if (name.equals("type")) {
1088          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1089        } else if (name.equals("amount")) {
1090          this.amount = TypeConvertor.castToQuantity(value); // Quantity
1091        } else
1092          return super.setProperty(name, value);
1093        return value;
1094      }
1095
1096      @Override
1097      public Base makeProperty(int hash, String name) throws FHIRException {
1098        switch (hash) {
1099        case -1077554975:  return getMethod();
1100        case 3575610:  return getType();
1101        case -1413853096:  return getAmount();
1102        default: return super.makeProperty(hash, name);
1103        }
1104
1105      }
1106
1107      @Override
1108      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1109        switch (hash) {
1110        case -1077554975: /*method*/ return new String[] {"CodeableConcept"};
1111        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
1112        case -1413853096: /*amount*/ return new String[] {"Quantity"};
1113        default: return super.getTypesForProperty(hash, name);
1114        }
1115
1116      }
1117
1118      @Override
1119      public Base addChild(String name) throws FHIRException {
1120        if (name.equals("method")) {
1121          this.method = new CodeableConcept();
1122          return this.method;
1123        }
1124        else if (name.equals("type")) {
1125          this.type = new CodeableConcept();
1126          return this.type;
1127        }
1128        else if (name.equals("amount")) {
1129          this.amount = new Quantity();
1130          return this.amount;
1131        }
1132        else
1133          return super.addChild(name);
1134      }
1135
1136      public SubstanceDefinitionMolecularWeightComponent copy() {
1137        SubstanceDefinitionMolecularWeightComponent dst = new SubstanceDefinitionMolecularWeightComponent();
1138        copyValues(dst);
1139        return dst;
1140      }
1141
1142      public void copyValues(SubstanceDefinitionMolecularWeightComponent dst) {
1143        super.copyValues(dst);
1144        dst.method = method == null ? null : method.copy();
1145        dst.type = type == null ? null : type.copy();
1146        dst.amount = amount == null ? null : amount.copy();
1147      }
1148
1149      @Override
1150      public boolean equalsDeep(Base other_) {
1151        if (!super.equalsDeep(other_))
1152          return false;
1153        if (!(other_ instanceof SubstanceDefinitionMolecularWeightComponent))
1154          return false;
1155        SubstanceDefinitionMolecularWeightComponent o = (SubstanceDefinitionMolecularWeightComponent) other_;
1156        return compareDeep(method, o.method, true) && compareDeep(type, o.type, true) && compareDeep(amount, o.amount, true)
1157          ;
1158      }
1159
1160      @Override
1161      public boolean equalsShallow(Base other_) {
1162        if (!super.equalsShallow(other_))
1163          return false;
1164        if (!(other_ instanceof SubstanceDefinitionMolecularWeightComponent))
1165          return false;
1166        SubstanceDefinitionMolecularWeightComponent o = (SubstanceDefinitionMolecularWeightComponent) other_;
1167        return true;
1168      }
1169
1170      public boolean isEmpty() {
1171        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(method, type, amount);
1172      }
1173
1174  public String fhirType() {
1175    return "SubstanceDefinition.molecularWeight";
1176
1177  }
1178
1179  }
1180
1181    @Block()
1182    public static class SubstanceDefinitionStructureComponent extends BackboneElement implements IBaseBackboneElement {
1183        /**
1184         * Stereochemistry type.
1185         */
1186        @Child(name = "stereochemistry", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
1187        @Description(shortDefinition="Stereochemistry type", formalDefinition="Stereochemistry type." )
1188        protected CodeableConcept stereochemistry;
1189
1190        /**
1191         * Optical activity type.
1192         */
1193        @Child(name = "opticalActivity", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
1194        @Description(shortDefinition="Optical activity type", formalDefinition="Optical activity type." )
1195        protected CodeableConcept opticalActivity;
1196
1197        /**
1198         * Molecular formula of this substance, typically using the Hill system.
1199         */
1200        @Child(name = "molecularFormula", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true)
1201        @Description(shortDefinition="Molecular formula of this substance, typically using the Hill system", formalDefinition="Molecular formula of this substance, typically using the Hill system." )
1202        protected StringType molecularFormula;
1203
1204        /**
1205         * Specified per moiety according to the Hill system, i.e. first C, then H, then alphabetical, each moiety separated by a dot.
1206         */
1207        @Child(name = "molecularFormulaByMoiety", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=true)
1208        @Description(shortDefinition="Specified per moiety according to the Hill system, i.e. first C, then H, then alphabetical, each moiety separated by a dot", formalDefinition="Specified per moiety according to the Hill system, i.e. first C, then H, then alphabetical, each moiety separated by a dot." )
1209        protected StringType molecularFormulaByMoiety;
1210
1211        /**
1212         * The molecular weight or weight range (for proteins, polymers or nucleic acids).
1213         */
1214        @Child(name = "molecularWeight", type = {SubstanceDefinitionMolecularWeightComponent.class}, order=5, min=0, max=1, modifier=false, summary=true)
1215        @Description(shortDefinition="The molecular weight or weight range (for proteins, polymers or nucleic acids)", formalDefinition="The molecular weight or weight range (for proteins, polymers or nucleic acids)." )
1216        protected SubstanceDefinitionMolecularWeightComponent molecularWeight;
1217
1218        /**
1219         * The method used to elucidate the structure or characterization of the drug substance. Examples: X-ray, HPLC, NMR, Peptide mapping, Ligand binding assay.
1220         */
1221        @Child(name = "technique", type = {CodeableConcept.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1222        @Description(shortDefinition="The method used to elucidate the structure or characterization of the drug substance. Examples: X-ray, HPLC, NMR, Peptide mapping, Ligand binding assay", formalDefinition="The method used to elucidate the structure or characterization of the drug substance. Examples: X-ray, HPLC, NMR, Peptide mapping, Ligand binding assay." )
1223        protected List<CodeableConcept> technique;
1224
1225        /**
1226         * Supporting literature about the source of information.
1227         */
1228        @Child(name = "sourceDocument", type = {DocumentReference.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1229        @Description(shortDefinition="Supporting literature about the source of information", formalDefinition="Supporting literature about the source of information." )
1230        protected List<Reference> sourceDocument;
1231
1232        /**
1233         * A depiction of the structure or characterization of the substance.
1234         */
1235        @Child(name = "representation", type = {}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1236        @Description(shortDefinition="A depiction of the structure or characterization of the substance", formalDefinition="A depiction of the structure or characterization of the substance." )
1237        protected List<SubstanceDefinitionStructureRepresentationComponent> representation;
1238
1239        private static final long serialVersionUID = -2137814144L;
1240
1241    /**
1242     * Constructor
1243     */
1244      public SubstanceDefinitionStructureComponent() {
1245        super();
1246      }
1247
1248        /**
1249         * @return {@link #stereochemistry} (Stereochemistry type.)
1250         */
1251        public CodeableConcept getStereochemistry() { 
1252          if (this.stereochemistry == null)
1253            if (Configuration.errorOnAutoCreate())
1254              throw new Error("Attempt to auto-create SubstanceDefinitionStructureComponent.stereochemistry");
1255            else if (Configuration.doAutoCreate())
1256              this.stereochemistry = new CodeableConcept(); // cc
1257          return this.stereochemistry;
1258        }
1259
1260        public boolean hasStereochemistry() { 
1261          return this.stereochemistry != null && !this.stereochemistry.isEmpty();
1262        }
1263
1264        /**
1265         * @param value {@link #stereochemistry} (Stereochemistry type.)
1266         */
1267        public SubstanceDefinitionStructureComponent setStereochemistry(CodeableConcept value) { 
1268          this.stereochemistry = value;
1269          return this;
1270        }
1271
1272        /**
1273         * @return {@link #opticalActivity} (Optical activity type.)
1274         */
1275        public CodeableConcept getOpticalActivity() { 
1276          if (this.opticalActivity == null)
1277            if (Configuration.errorOnAutoCreate())
1278              throw new Error("Attempt to auto-create SubstanceDefinitionStructureComponent.opticalActivity");
1279            else if (Configuration.doAutoCreate())
1280              this.opticalActivity = new CodeableConcept(); // cc
1281          return this.opticalActivity;
1282        }
1283
1284        public boolean hasOpticalActivity() { 
1285          return this.opticalActivity != null && !this.opticalActivity.isEmpty();
1286        }
1287
1288        /**
1289         * @param value {@link #opticalActivity} (Optical activity type.)
1290         */
1291        public SubstanceDefinitionStructureComponent setOpticalActivity(CodeableConcept value) { 
1292          this.opticalActivity = value;
1293          return this;
1294        }
1295
1296        /**
1297         * @return {@link #molecularFormula} (Molecular formula of this substance, typically using the Hill system.). This is the underlying object with id, value and extensions. The accessor "getMolecularFormula" gives direct access to the value
1298         */
1299        public StringType getMolecularFormulaElement() { 
1300          if (this.molecularFormula == null)
1301            if (Configuration.errorOnAutoCreate())
1302              throw new Error("Attempt to auto-create SubstanceDefinitionStructureComponent.molecularFormula");
1303            else if (Configuration.doAutoCreate())
1304              this.molecularFormula = new StringType(); // bb
1305          return this.molecularFormula;
1306        }
1307
1308        public boolean hasMolecularFormulaElement() { 
1309          return this.molecularFormula != null && !this.molecularFormula.isEmpty();
1310        }
1311
1312        public boolean hasMolecularFormula() { 
1313          return this.molecularFormula != null && !this.molecularFormula.isEmpty();
1314        }
1315
1316        /**
1317         * @param value {@link #molecularFormula} (Molecular formula of this substance, typically using the Hill system.). This is the underlying object with id, value and extensions. The accessor "getMolecularFormula" gives direct access to the value
1318         */
1319        public SubstanceDefinitionStructureComponent setMolecularFormulaElement(StringType value) { 
1320          this.molecularFormula = value;
1321          return this;
1322        }
1323
1324        /**
1325         * @return Molecular formula of this substance, typically using the Hill system.
1326         */
1327        public String getMolecularFormula() { 
1328          return this.molecularFormula == null ? null : this.molecularFormula.getValue();
1329        }
1330
1331        /**
1332         * @param value Molecular formula of this substance, typically using the Hill system.
1333         */
1334        public SubstanceDefinitionStructureComponent setMolecularFormula(String value) { 
1335          if (Utilities.noString(value))
1336            this.molecularFormula = null;
1337          else {
1338            if (this.molecularFormula == null)
1339              this.molecularFormula = new StringType();
1340            this.molecularFormula.setValue(value);
1341          }
1342          return this;
1343        }
1344
1345        /**
1346         * @return {@link #molecularFormulaByMoiety} (Specified per moiety according to the Hill system, i.e. first C, then H, then alphabetical, each moiety separated by a dot.). This is the underlying object with id, value and extensions. The accessor "getMolecularFormulaByMoiety" gives direct access to the value
1347         */
1348        public StringType getMolecularFormulaByMoietyElement() { 
1349          if (this.molecularFormulaByMoiety == null)
1350            if (Configuration.errorOnAutoCreate())
1351              throw new Error("Attempt to auto-create SubstanceDefinitionStructureComponent.molecularFormulaByMoiety");
1352            else if (Configuration.doAutoCreate())
1353              this.molecularFormulaByMoiety = new StringType(); // bb
1354          return this.molecularFormulaByMoiety;
1355        }
1356
1357        public boolean hasMolecularFormulaByMoietyElement() { 
1358          return this.molecularFormulaByMoiety != null && !this.molecularFormulaByMoiety.isEmpty();
1359        }
1360
1361        public boolean hasMolecularFormulaByMoiety() { 
1362          return this.molecularFormulaByMoiety != null && !this.molecularFormulaByMoiety.isEmpty();
1363        }
1364
1365        /**
1366         * @param value {@link #molecularFormulaByMoiety} (Specified per moiety according to the Hill system, i.e. first C, then H, then alphabetical, each moiety separated by a dot.). This is the underlying object with id, value and extensions. The accessor "getMolecularFormulaByMoiety" gives direct access to the value
1367         */
1368        public SubstanceDefinitionStructureComponent setMolecularFormulaByMoietyElement(StringType value) { 
1369          this.molecularFormulaByMoiety = value;
1370          return this;
1371        }
1372
1373        /**
1374         * @return Specified per moiety according to the Hill system, i.e. first C, then H, then alphabetical, each moiety separated by a dot.
1375         */
1376        public String getMolecularFormulaByMoiety() { 
1377          return this.molecularFormulaByMoiety == null ? null : this.molecularFormulaByMoiety.getValue();
1378        }
1379
1380        /**
1381         * @param value Specified per moiety according to the Hill system, i.e. first C, then H, then alphabetical, each moiety separated by a dot.
1382         */
1383        public SubstanceDefinitionStructureComponent setMolecularFormulaByMoiety(String value) { 
1384          if (Utilities.noString(value))
1385            this.molecularFormulaByMoiety = null;
1386          else {
1387            if (this.molecularFormulaByMoiety == null)
1388              this.molecularFormulaByMoiety = new StringType();
1389            this.molecularFormulaByMoiety.setValue(value);
1390          }
1391          return this;
1392        }
1393
1394        /**
1395         * @return {@link #molecularWeight} (The molecular weight or weight range (for proteins, polymers or nucleic acids).)
1396         */
1397        public SubstanceDefinitionMolecularWeightComponent getMolecularWeight() { 
1398          if (this.molecularWeight == null)
1399            if (Configuration.errorOnAutoCreate())
1400              throw new Error("Attempt to auto-create SubstanceDefinitionStructureComponent.molecularWeight");
1401            else if (Configuration.doAutoCreate())
1402              this.molecularWeight = new SubstanceDefinitionMolecularWeightComponent(); // cc
1403          return this.molecularWeight;
1404        }
1405
1406        public boolean hasMolecularWeight() { 
1407          return this.molecularWeight != null && !this.molecularWeight.isEmpty();
1408        }
1409
1410        /**
1411         * @param value {@link #molecularWeight} (The molecular weight or weight range (for proteins, polymers or nucleic acids).)
1412         */
1413        public SubstanceDefinitionStructureComponent setMolecularWeight(SubstanceDefinitionMolecularWeightComponent value) { 
1414          this.molecularWeight = value;
1415          return this;
1416        }
1417
1418        /**
1419         * @return {@link #technique} (The method used to elucidate the structure or characterization of the drug substance. Examples: X-ray, HPLC, NMR, Peptide mapping, Ligand binding assay.)
1420         */
1421        public List<CodeableConcept> getTechnique() { 
1422          if (this.technique == null)
1423            this.technique = new ArrayList<CodeableConcept>();
1424          return this.technique;
1425        }
1426
1427        /**
1428         * @return Returns a reference to <code>this</code> for easy method chaining
1429         */
1430        public SubstanceDefinitionStructureComponent setTechnique(List<CodeableConcept> theTechnique) { 
1431          this.technique = theTechnique;
1432          return this;
1433        }
1434
1435        public boolean hasTechnique() { 
1436          if (this.technique == null)
1437            return false;
1438          for (CodeableConcept item : this.technique)
1439            if (!item.isEmpty())
1440              return true;
1441          return false;
1442        }
1443
1444        public CodeableConcept addTechnique() { //3
1445          CodeableConcept t = new CodeableConcept();
1446          if (this.technique == null)
1447            this.technique = new ArrayList<CodeableConcept>();
1448          this.technique.add(t);
1449          return t;
1450        }
1451
1452        public SubstanceDefinitionStructureComponent addTechnique(CodeableConcept t) { //3
1453          if (t == null)
1454            return this;
1455          if (this.technique == null)
1456            this.technique = new ArrayList<CodeableConcept>();
1457          this.technique.add(t);
1458          return this;
1459        }
1460
1461        /**
1462         * @return The first repetition of repeating field {@link #technique}, creating it if it does not already exist {3}
1463         */
1464        public CodeableConcept getTechniqueFirstRep() { 
1465          if (getTechnique().isEmpty()) {
1466            addTechnique();
1467          }
1468          return getTechnique().get(0);
1469        }
1470
1471        /**
1472         * @return {@link #sourceDocument} (Supporting literature about the source of information.)
1473         */
1474        public List<Reference> getSourceDocument() { 
1475          if (this.sourceDocument == null)
1476            this.sourceDocument = new ArrayList<Reference>();
1477          return this.sourceDocument;
1478        }
1479
1480        /**
1481         * @return Returns a reference to <code>this</code> for easy method chaining
1482         */
1483        public SubstanceDefinitionStructureComponent setSourceDocument(List<Reference> theSourceDocument) { 
1484          this.sourceDocument = theSourceDocument;
1485          return this;
1486        }
1487
1488        public boolean hasSourceDocument() { 
1489          if (this.sourceDocument == null)
1490            return false;
1491          for (Reference item : this.sourceDocument)
1492            if (!item.isEmpty())
1493              return true;
1494          return false;
1495        }
1496
1497        public Reference addSourceDocument() { //3
1498          Reference t = new Reference();
1499          if (this.sourceDocument == null)
1500            this.sourceDocument = new ArrayList<Reference>();
1501          this.sourceDocument.add(t);
1502          return t;
1503        }
1504
1505        public SubstanceDefinitionStructureComponent addSourceDocument(Reference t) { //3
1506          if (t == null)
1507            return this;
1508          if (this.sourceDocument == null)
1509            this.sourceDocument = new ArrayList<Reference>();
1510          this.sourceDocument.add(t);
1511          return this;
1512        }
1513
1514        /**
1515         * @return The first repetition of repeating field {@link #sourceDocument}, creating it if it does not already exist {3}
1516         */
1517        public Reference getSourceDocumentFirstRep() { 
1518          if (getSourceDocument().isEmpty()) {
1519            addSourceDocument();
1520          }
1521          return getSourceDocument().get(0);
1522        }
1523
1524        /**
1525         * @return {@link #representation} (A depiction of the structure or characterization of the substance.)
1526         */
1527        public List<SubstanceDefinitionStructureRepresentationComponent> getRepresentation() { 
1528          if (this.representation == null)
1529            this.representation = new ArrayList<SubstanceDefinitionStructureRepresentationComponent>();
1530          return this.representation;
1531        }
1532
1533        /**
1534         * @return Returns a reference to <code>this</code> for easy method chaining
1535         */
1536        public SubstanceDefinitionStructureComponent setRepresentation(List<SubstanceDefinitionStructureRepresentationComponent> theRepresentation) { 
1537          this.representation = theRepresentation;
1538          return this;
1539        }
1540
1541        public boolean hasRepresentation() { 
1542          if (this.representation == null)
1543            return false;
1544          for (SubstanceDefinitionStructureRepresentationComponent item : this.representation)
1545            if (!item.isEmpty())
1546              return true;
1547          return false;
1548        }
1549
1550        public SubstanceDefinitionStructureRepresentationComponent addRepresentation() { //3
1551          SubstanceDefinitionStructureRepresentationComponent t = new SubstanceDefinitionStructureRepresentationComponent();
1552          if (this.representation == null)
1553            this.representation = new ArrayList<SubstanceDefinitionStructureRepresentationComponent>();
1554          this.representation.add(t);
1555          return t;
1556        }
1557
1558        public SubstanceDefinitionStructureComponent addRepresentation(SubstanceDefinitionStructureRepresentationComponent t) { //3
1559          if (t == null)
1560            return this;
1561          if (this.representation == null)
1562            this.representation = new ArrayList<SubstanceDefinitionStructureRepresentationComponent>();
1563          this.representation.add(t);
1564          return this;
1565        }
1566
1567        /**
1568         * @return The first repetition of repeating field {@link #representation}, creating it if it does not already exist {3}
1569         */
1570        public SubstanceDefinitionStructureRepresentationComponent getRepresentationFirstRep() { 
1571          if (getRepresentation().isEmpty()) {
1572            addRepresentation();
1573          }
1574          return getRepresentation().get(0);
1575        }
1576
1577        protected void listChildren(List<Property> children) {
1578          super.listChildren(children);
1579          children.add(new Property("stereochemistry", "CodeableConcept", "Stereochemistry type.", 0, 1, stereochemistry));
1580          children.add(new Property("opticalActivity", "CodeableConcept", "Optical activity type.", 0, 1, opticalActivity));
1581          children.add(new Property("molecularFormula", "string", "Molecular formula of this substance, typically using the Hill system.", 0, 1, molecularFormula));
1582          children.add(new Property("molecularFormulaByMoiety", "string", "Specified per moiety according to the Hill system, i.e. first C, then H, then alphabetical, each moiety separated by a dot.", 0, 1, molecularFormulaByMoiety));
1583          children.add(new Property("molecularWeight", "@SubstanceDefinition.molecularWeight", "The molecular weight or weight range (for proteins, polymers or nucleic acids).", 0, 1, molecularWeight));
1584          children.add(new Property("technique", "CodeableConcept", "The method used to elucidate the structure or characterization of the drug substance. Examples: X-ray, HPLC, NMR, Peptide mapping, Ligand binding assay.", 0, java.lang.Integer.MAX_VALUE, technique));
1585          children.add(new Property("sourceDocument", "Reference(DocumentReference)", "Supporting literature about the source of information.", 0, java.lang.Integer.MAX_VALUE, sourceDocument));
1586          children.add(new Property("representation", "", "A depiction of the structure or characterization of the substance.", 0, java.lang.Integer.MAX_VALUE, representation));
1587        }
1588
1589        @Override
1590        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1591          switch (_hash) {
1592          case 263475116: /*stereochemistry*/  return new Property("stereochemistry", "CodeableConcept", "Stereochemistry type.", 0, 1, stereochemistry);
1593          case 1420900135: /*opticalActivity*/  return new Property("opticalActivity", "CodeableConcept", "Optical activity type.", 0, 1, opticalActivity);
1594          case 616660246: /*molecularFormula*/  return new Property("molecularFormula", "string", "Molecular formula of this substance, typically using the Hill system.", 0, 1, molecularFormula);
1595          case 1315452848: /*molecularFormulaByMoiety*/  return new Property("molecularFormulaByMoiety", "string", "Specified per moiety according to the Hill system, i.e. first C, then H, then alphabetical, each moiety separated by a dot.", 0, 1, molecularFormulaByMoiety);
1596          case 635625672: /*molecularWeight*/  return new Property("molecularWeight", "@SubstanceDefinition.molecularWeight", "The molecular weight or weight range (for proteins, polymers or nucleic acids).", 0, 1, molecularWeight);
1597          case 1469675088: /*technique*/  return new Property("technique", "CodeableConcept", "The method used to elucidate the structure or characterization of the drug substance. Examples: X-ray, HPLC, NMR, Peptide mapping, Ligand binding assay.", 0, java.lang.Integer.MAX_VALUE, technique);
1598          case -501788074: /*sourceDocument*/  return new Property("sourceDocument", "Reference(DocumentReference)", "Supporting literature about the source of information.", 0, java.lang.Integer.MAX_VALUE, sourceDocument);
1599          case -671065907: /*representation*/  return new Property("representation", "", "A depiction of the structure or characterization of the substance.", 0, java.lang.Integer.MAX_VALUE, representation);
1600          default: return super.getNamedProperty(_hash, _name, _checkValid);
1601          }
1602
1603        }
1604
1605      @Override
1606      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1607        switch (hash) {
1608        case 263475116: /*stereochemistry*/ return this.stereochemistry == null ? new Base[0] : new Base[] {this.stereochemistry}; // CodeableConcept
1609        case 1420900135: /*opticalActivity*/ return this.opticalActivity == null ? new Base[0] : new Base[] {this.opticalActivity}; // CodeableConcept
1610        case 616660246: /*molecularFormula*/ return this.molecularFormula == null ? new Base[0] : new Base[] {this.molecularFormula}; // StringType
1611        case 1315452848: /*molecularFormulaByMoiety*/ return this.molecularFormulaByMoiety == null ? new Base[0] : new Base[] {this.molecularFormulaByMoiety}; // StringType
1612        case 635625672: /*molecularWeight*/ return this.molecularWeight == null ? new Base[0] : new Base[] {this.molecularWeight}; // SubstanceDefinitionMolecularWeightComponent
1613        case 1469675088: /*technique*/ return this.technique == null ? new Base[0] : this.technique.toArray(new Base[this.technique.size()]); // CodeableConcept
1614        case -501788074: /*sourceDocument*/ return this.sourceDocument == null ? new Base[0] : this.sourceDocument.toArray(new Base[this.sourceDocument.size()]); // Reference
1615        case -671065907: /*representation*/ return this.representation == null ? new Base[0] : this.representation.toArray(new Base[this.representation.size()]); // SubstanceDefinitionStructureRepresentationComponent
1616        default: return super.getProperty(hash, name, checkValid);
1617        }
1618
1619      }
1620
1621      @Override
1622      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1623        switch (hash) {
1624        case 263475116: // stereochemistry
1625          this.stereochemistry = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1626          return value;
1627        case 1420900135: // opticalActivity
1628          this.opticalActivity = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1629          return value;
1630        case 616660246: // molecularFormula
1631          this.molecularFormula = TypeConvertor.castToString(value); // StringType
1632          return value;
1633        case 1315452848: // molecularFormulaByMoiety
1634          this.molecularFormulaByMoiety = TypeConvertor.castToString(value); // StringType
1635          return value;
1636        case 635625672: // molecularWeight
1637          this.molecularWeight = (SubstanceDefinitionMolecularWeightComponent) value; // SubstanceDefinitionMolecularWeightComponent
1638          return value;
1639        case 1469675088: // technique
1640          this.getTechnique().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
1641          return value;
1642        case -501788074: // sourceDocument
1643          this.getSourceDocument().add(TypeConvertor.castToReference(value)); // Reference
1644          return value;
1645        case -671065907: // representation
1646          this.getRepresentation().add((SubstanceDefinitionStructureRepresentationComponent) value); // SubstanceDefinitionStructureRepresentationComponent
1647          return value;
1648        default: return super.setProperty(hash, name, value);
1649        }
1650
1651      }
1652
1653      @Override
1654      public Base setProperty(String name, Base value) throws FHIRException {
1655        if (name.equals("stereochemistry")) {
1656          this.stereochemistry = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1657        } else if (name.equals("opticalActivity")) {
1658          this.opticalActivity = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1659        } else if (name.equals("molecularFormula")) {
1660          this.molecularFormula = TypeConvertor.castToString(value); // StringType
1661        } else if (name.equals("molecularFormulaByMoiety")) {
1662          this.molecularFormulaByMoiety = TypeConvertor.castToString(value); // StringType
1663        } else if (name.equals("molecularWeight")) {
1664          this.molecularWeight = (SubstanceDefinitionMolecularWeightComponent) value; // SubstanceDefinitionMolecularWeightComponent
1665        } else if (name.equals("technique")) {
1666          this.getTechnique().add(TypeConvertor.castToCodeableConcept(value));
1667        } else if (name.equals("sourceDocument")) {
1668          this.getSourceDocument().add(TypeConvertor.castToReference(value));
1669        } else if (name.equals("representation")) {
1670          this.getRepresentation().add((SubstanceDefinitionStructureRepresentationComponent) value);
1671        } else
1672          return super.setProperty(name, value);
1673        return value;
1674      }
1675
1676      @Override
1677      public Base makeProperty(int hash, String name) throws FHIRException {
1678        switch (hash) {
1679        case 263475116:  return getStereochemistry();
1680        case 1420900135:  return getOpticalActivity();
1681        case 616660246:  return getMolecularFormulaElement();
1682        case 1315452848:  return getMolecularFormulaByMoietyElement();
1683        case 635625672:  return getMolecularWeight();
1684        case 1469675088:  return addTechnique(); 
1685        case -501788074:  return addSourceDocument(); 
1686        case -671065907:  return addRepresentation(); 
1687        default: return super.makeProperty(hash, name);
1688        }
1689
1690      }
1691
1692      @Override
1693      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1694        switch (hash) {
1695        case 263475116: /*stereochemistry*/ return new String[] {"CodeableConcept"};
1696        case 1420900135: /*opticalActivity*/ return new String[] {"CodeableConcept"};
1697        case 616660246: /*molecularFormula*/ return new String[] {"string"};
1698        case 1315452848: /*molecularFormulaByMoiety*/ return new String[] {"string"};
1699        case 635625672: /*molecularWeight*/ return new String[] {"@SubstanceDefinition.molecularWeight"};
1700        case 1469675088: /*technique*/ return new String[] {"CodeableConcept"};
1701        case -501788074: /*sourceDocument*/ return new String[] {"Reference"};
1702        case -671065907: /*representation*/ return new String[] {};
1703        default: return super.getTypesForProperty(hash, name);
1704        }
1705
1706      }
1707
1708      @Override
1709      public Base addChild(String name) throws FHIRException {
1710        if (name.equals("stereochemistry")) {
1711          this.stereochemistry = new CodeableConcept();
1712          return this.stereochemistry;
1713        }
1714        else if (name.equals("opticalActivity")) {
1715          this.opticalActivity = new CodeableConcept();
1716          return this.opticalActivity;
1717        }
1718        else if (name.equals("molecularFormula")) {
1719          throw new FHIRException("Cannot call addChild on a primitive type SubstanceDefinition.structure.molecularFormula");
1720        }
1721        else if (name.equals("molecularFormulaByMoiety")) {
1722          throw new FHIRException("Cannot call addChild on a primitive type SubstanceDefinition.structure.molecularFormulaByMoiety");
1723        }
1724        else if (name.equals("molecularWeight")) {
1725          this.molecularWeight = new SubstanceDefinitionMolecularWeightComponent();
1726          return this.molecularWeight;
1727        }
1728        else if (name.equals("technique")) {
1729          return addTechnique();
1730        }
1731        else if (name.equals("sourceDocument")) {
1732          return addSourceDocument();
1733        }
1734        else if (name.equals("representation")) {
1735          return addRepresentation();
1736        }
1737        else
1738          return super.addChild(name);
1739      }
1740
1741      public SubstanceDefinitionStructureComponent copy() {
1742        SubstanceDefinitionStructureComponent dst = new SubstanceDefinitionStructureComponent();
1743        copyValues(dst);
1744        return dst;
1745      }
1746
1747      public void copyValues(SubstanceDefinitionStructureComponent dst) {
1748        super.copyValues(dst);
1749        dst.stereochemistry = stereochemistry == null ? null : stereochemistry.copy();
1750        dst.opticalActivity = opticalActivity == null ? null : opticalActivity.copy();
1751        dst.molecularFormula = molecularFormula == null ? null : molecularFormula.copy();
1752        dst.molecularFormulaByMoiety = molecularFormulaByMoiety == null ? null : molecularFormulaByMoiety.copy();
1753        dst.molecularWeight = molecularWeight == null ? null : molecularWeight.copy();
1754        if (technique != null) {
1755          dst.technique = new ArrayList<CodeableConcept>();
1756          for (CodeableConcept i : technique)
1757            dst.technique.add(i.copy());
1758        };
1759        if (sourceDocument != null) {
1760          dst.sourceDocument = new ArrayList<Reference>();
1761          for (Reference i : sourceDocument)
1762            dst.sourceDocument.add(i.copy());
1763        };
1764        if (representation != null) {
1765          dst.representation = new ArrayList<SubstanceDefinitionStructureRepresentationComponent>();
1766          for (SubstanceDefinitionStructureRepresentationComponent i : representation)
1767            dst.representation.add(i.copy());
1768        };
1769      }
1770
1771      @Override
1772      public boolean equalsDeep(Base other_) {
1773        if (!super.equalsDeep(other_))
1774          return false;
1775        if (!(other_ instanceof SubstanceDefinitionStructureComponent))
1776          return false;
1777        SubstanceDefinitionStructureComponent o = (SubstanceDefinitionStructureComponent) other_;
1778        return compareDeep(stereochemistry, o.stereochemistry, true) && compareDeep(opticalActivity, o.opticalActivity, true)
1779           && compareDeep(molecularFormula, o.molecularFormula, true) && compareDeep(molecularFormulaByMoiety, o.molecularFormulaByMoiety, true)
1780           && compareDeep(molecularWeight, o.molecularWeight, true) && compareDeep(technique, o.technique, true)
1781           && compareDeep(sourceDocument, o.sourceDocument, true) && compareDeep(representation, o.representation, true)
1782          ;
1783      }
1784
1785      @Override
1786      public boolean equalsShallow(Base other_) {
1787        if (!super.equalsShallow(other_))
1788          return false;
1789        if (!(other_ instanceof SubstanceDefinitionStructureComponent))
1790          return false;
1791        SubstanceDefinitionStructureComponent o = (SubstanceDefinitionStructureComponent) other_;
1792        return compareValues(molecularFormula, o.molecularFormula, true) && compareValues(molecularFormulaByMoiety, o.molecularFormulaByMoiety, true)
1793          ;
1794      }
1795
1796      public boolean isEmpty() {
1797        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(stereochemistry, opticalActivity
1798          , molecularFormula, molecularFormulaByMoiety, molecularWeight, technique, sourceDocument
1799          , representation);
1800      }
1801
1802  public String fhirType() {
1803    return "SubstanceDefinition.structure";
1804
1805  }
1806
1807  }
1808
1809    @Block()
1810    public static class SubstanceDefinitionStructureRepresentationComponent extends BackboneElement implements IBaseBackboneElement {
1811        /**
1812         * The kind of structural representation (e.g. full, partial).
1813         */
1814        @Child(name = "type", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
1815        @Description(shortDefinition="The kind of structural representation (e.g. full, partial)", formalDefinition="The kind of structural representation (e.g. full, partial)." )
1816        protected CodeableConcept type;
1817
1818        /**
1819         * The structural representation or characterization as a text string in a standard format.
1820         */
1821        @Child(name = "representation", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=true)
1822        @Description(shortDefinition="The structural representation or characterization as a text string in a standard format", formalDefinition="The structural representation or characterization as a text string in a standard format." )
1823        protected StringType representation;
1824
1825        /**
1826         * The format of the representation e.g. InChI, SMILES, MOLFILE, CDX, SDF, PDB, mmCIF. The logical content type rather than the physical file format of a document.
1827         */
1828        @Child(name = "format", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true)
1829        @Description(shortDefinition="The format of the representation e.g. InChI, SMILES, MOLFILE, CDX, SDF, PDB, mmCIF. The logical content type rather than the physical file format of a document", formalDefinition="The format of the representation e.g. InChI, SMILES, MOLFILE, CDX, SDF, PDB, mmCIF. The logical content type rather than the physical file format of a document." )
1830        protected CodeableConcept format;
1831
1832        /**
1833         * An attached file with the structural representation or characterization e.g. a molecular structure graphic of the substance, a JCAMP or AnIML file.
1834         */
1835        @Child(name = "document", type = {DocumentReference.class}, order=4, min=0, max=1, modifier=false, summary=true)
1836        @Description(shortDefinition="An attached file with the structural representation or characterization e.g. a molecular structure graphic of the substance, a JCAMP or AnIML file", formalDefinition="An attached file with the structural representation or characterization e.g. a molecular structure graphic of the substance, a JCAMP or AnIML file." )
1837        protected Reference document;
1838
1839        private static final long serialVersionUID = 138704347L;
1840
1841    /**
1842     * Constructor
1843     */
1844      public SubstanceDefinitionStructureRepresentationComponent() {
1845        super();
1846      }
1847
1848        /**
1849         * @return {@link #type} (The kind of structural representation (e.g. full, partial).)
1850         */
1851        public CodeableConcept getType() { 
1852          if (this.type == null)
1853            if (Configuration.errorOnAutoCreate())
1854              throw new Error("Attempt to auto-create SubstanceDefinitionStructureRepresentationComponent.type");
1855            else if (Configuration.doAutoCreate())
1856              this.type = new CodeableConcept(); // cc
1857          return this.type;
1858        }
1859
1860        public boolean hasType() { 
1861          return this.type != null && !this.type.isEmpty();
1862        }
1863
1864        /**
1865         * @param value {@link #type} (The kind of structural representation (e.g. full, partial).)
1866         */
1867        public SubstanceDefinitionStructureRepresentationComponent setType(CodeableConcept value) { 
1868          this.type = value;
1869          return this;
1870        }
1871
1872        /**
1873         * @return {@link #representation} (The structural representation or characterization as a text string in a standard format.). This is the underlying object with id, value and extensions. The accessor "getRepresentation" gives direct access to the value
1874         */
1875        public StringType getRepresentationElement() { 
1876          if (this.representation == null)
1877            if (Configuration.errorOnAutoCreate())
1878              throw new Error("Attempt to auto-create SubstanceDefinitionStructureRepresentationComponent.representation");
1879            else if (Configuration.doAutoCreate())
1880              this.representation = new StringType(); // bb
1881          return this.representation;
1882        }
1883
1884        public boolean hasRepresentationElement() { 
1885          return this.representation != null && !this.representation.isEmpty();
1886        }
1887
1888        public boolean hasRepresentation() { 
1889          return this.representation != null && !this.representation.isEmpty();
1890        }
1891
1892        /**
1893         * @param value {@link #representation} (The structural representation or characterization as a text string in a standard format.). This is the underlying object with id, value and extensions. The accessor "getRepresentation" gives direct access to the value
1894         */
1895        public SubstanceDefinitionStructureRepresentationComponent setRepresentationElement(StringType value) { 
1896          this.representation = value;
1897          return this;
1898        }
1899
1900        /**
1901         * @return The structural representation or characterization as a text string in a standard format.
1902         */
1903        public String getRepresentation() { 
1904          return this.representation == null ? null : this.representation.getValue();
1905        }
1906
1907        /**
1908         * @param value The structural representation or characterization as a text string in a standard format.
1909         */
1910        public SubstanceDefinitionStructureRepresentationComponent setRepresentation(String value) { 
1911          if (Utilities.noString(value))
1912            this.representation = null;
1913          else {
1914            if (this.representation == null)
1915              this.representation = new StringType();
1916            this.representation.setValue(value);
1917          }
1918          return this;
1919        }
1920
1921        /**
1922         * @return {@link #format} (The format of the representation e.g. InChI, SMILES, MOLFILE, CDX, SDF, PDB, mmCIF. The logical content type rather than the physical file format of a document.)
1923         */
1924        public CodeableConcept getFormat() { 
1925          if (this.format == null)
1926            if (Configuration.errorOnAutoCreate())
1927              throw new Error("Attempt to auto-create SubstanceDefinitionStructureRepresentationComponent.format");
1928            else if (Configuration.doAutoCreate())
1929              this.format = new CodeableConcept(); // cc
1930          return this.format;
1931        }
1932
1933        public boolean hasFormat() { 
1934          return this.format != null && !this.format.isEmpty();
1935        }
1936
1937        /**
1938         * @param value {@link #format} (The format of the representation e.g. InChI, SMILES, MOLFILE, CDX, SDF, PDB, mmCIF. The logical content type rather than the physical file format of a document.)
1939         */
1940        public SubstanceDefinitionStructureRepresentationComponent setFormat(CodeableConcept value) { 
1941          this.format = value;
1942          return this;
1943        }
1944
1945        /**
1946         * @return {@link #document} (An attached file with the structural representation or characterization e.g. a molecular structure graphic of the substance, a JCAMP or AnIML file.)
1947         */
1948        public Reference getDocument() { 
1949          if (this.document == null)
1950            if (Configuration.errorOnAutoCreate())
1951              throw new Error("Attempt to auto-create SubstanceDefinitionStructureRepresentationComponent.document");
1952            else if (Configuration.doAutoCreate())
1953              this.document = new Reference(); // cc
1954          return this.document;
1955        }
1956
1957        public boolean hasDocument() { 
1958          return this.document != null && !this.document.isEmpty();
1959        }
1960
1961        /**
1962         * @param value {@link #document} (An attached file with the structural representation or characterization e.g. a molecular structure graphic of the substance, a JCAMP or AnIML file.)
1963         */
1964        public SubstanceDefinitionStructureRepresentationComponent setDocument(Reference value) { 
1965          this.document = value;
1966          return this;
1967        }
1968
1969        protected void listChildren(List<Property> children) {
1970          super.listChildren(children);
1971          children.add(new Property("type", "CodeableConcept", "The kind of structural representation (e.g. full, partial).", 0, 1, type));
1972          children.add(new Property("representation", "string", "The structural representation or characterization as a text string in a standard format.", 0, 1, representation));
1973          children.add(new Property("format", "CodeableConcept", "The format of the representation e.g. InChI, SMILES, MOLFILE, CDX, SDF, PDB, mmCIF. The logical content type rather than the physical file format of a document.", 0, 1, format));
1974          children.add(new Property("document", "Reference(DocumentReference)", "An attached file with the structural representation or characterization e.g. a molecular structure graphic of the substance, a JCAMP or AnIML file.", 0, 1, document));
1975        }
1976
1977        @Override
1978        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1979          switch (_hash) {
1980          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "The kind of structural representation (e.g. full, partial).", 0, 1, type);
1981          case -671065907: /*representation*/  return new Property("representation", "string", "The structural representation or characterization as a text string in a standard format.", 0, 1, representation);
1982          case -1268779017: /*format*/  return new Property("format", "CodeableConcept", "The format of the representation e.g. InChI, SMILES, MOLFILE, CDX, SDF, PDB, mmCIF. The logical content type rather than the physical file format of a document.", 0, 1, format);
1983          case 861720859: /*document*/  return new Property("document", "Reference(DocumentReference)", "An attached file with the structural representation or characterization e.g. a molecular structure graphic of the substance, a JCAMP or AnIML file.", 0, 1, document);
1984          default: return super.getNamedProperty(_hash, _name, _checkValid);
1985          }
1986
1987        }
1988
1989      @Override
1990      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1991        switch (hash) {
1992        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
1993        case -671065907: /*representation*/ return this.representation == null ? new Base[0] : new Base[] {this.representation}; // StringType
1994        case -1268779017: /*format*/ return this.format == null ? new Base[0] : new Base[] {this.format}; // CodeableConcept
1995        case 861720859: /*document*/ return this.document == null ? new Base[0] : new Base[] {this.document}; // Reference
1996        default: return super.getProperty(hash, name, checkValid);
1997        }
1998
1999      }
2000
2001      @Override
2002      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2003        switch (hash) {
2004        case 3575610: // type
2005          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
2006          return value;
2007        case -671065907: // representation
2008          this.representation = TypeConvertor.castToString(value); // StringType
2009          return value;
2010        case -1268779017: // format
2011          this.format = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
2012          return value;
2013        case 861720859: // document
2014          this.document = TypeConvertor.castToReference(value); // Reference
2015          return value;
2016        default: return super.setProperty(hash, name, value);
2017        }
2018
2019      }
2020
2021      @Override
2022      public Base setProperty(String name, Base value) throws FHIRException {
2023        if (name.equals("type")) {
2024          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
2025        } else if (name.equals("representation")) {
2026          this.representation = TypeConvertor.castToString(value); // StringType
2027        } else if (name.equals("format")) {
2028          this.format = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
2029        } else if (name.equals("document")) {
2030          this.document = TypeConvertor.castToReference(value); // Reference
2031        } else
2032          return super.setProperty(name, value);
2033        return value;
2034      }
2035
2036      @Override
2037      public Base makeProperty(int hash, String name) throws FHIRException {
2038        switch (hash) {
2039        case 3575610:  return getType();
2040        case -671065907:  return getRepresentationElement();
2041        case -1268779017:  return getFormat();
2042        case 861720859:  return getDocument();
2043        default: return super.makeProperty(hash, name);
2044        }
2045
2046      }
2047
2048      @Override
2049      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2050        switch (hash) {
2051        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
2052        case -671065907: /*representation*/ return new String[] {"string"};
2053        case -1268779017: /*format*/ return new String[] {"CodeableConcept"};
2054        case 861720859: /*document*/ return new String[] {"Reference"};
2055        default: return super.getTypesForProperty(hash, name);
2056        }
2057
2058      }
2059
2060      @Override
2061      public Base addChild(String name) throws FHIRException {
2062        if (name.equals("type")) {
2063          this.type = new CodeableConcept();
2064          return this.type;
2065        }
2066        else if (name.equals("representation")) {
2067          throw new FHIRException("Cannot call addChild on a primitive type SubstanceDefinition.structure.representation.representation");
2068        }
2069        else if (name.equals("format")) {
2070          this.format = new CodeableConcept();
2071          return this.format;
2072        }
2073        else if (name.equals("document")) {
2074          this.document = new Reference();
2075          return this.document;
2076        }
2077        else
2078          return super.addChild(name);
2079      }
2080
2081      public SubstanceDefinitionStructureRepresentationComponent copy() {
2082        SubstanceDefinitionStructureRepresentationComponent dst = new SubstanceDefinitionStructureRepresentationComponent();
2083        copyValues(dst);
2084        return dst;
2085      }
2086
2087      public void copyValues(SubstanceDefinitionStructureRepresentationComponent dst) {
2088        super.copyValues(dst);
2089        dst.type = type == null ? null : type.copy();
2090        dst.representation = representation == null ? null : representation.copy();
2091        dst.format = format == null ? null : format.copy();
2092        dst.document = document == null ? null : document.copy();
2093      }
2094
2095      @Override
2096      public boolean equalsDeep(Base other_) {
2097        if (!super.equalsDeep(other_))
2098          return false;
2099        if (!(other_ instanceof SubstanceDefinitionStructureRepresentationComponent))
2100          return false;
2101        SubstanceDefinitionStructureRepresentationComponent o = (SubstanceDefinitionStructureRepresentationComponent) other_;
2102        return compareDeep(type, o.type, true) && compareDeep(representation, o.representation, true) && compareDeep(format, o.format, true)
2103           && compareDeep(document, o.document, true);
2104      }
2105
2106      @Override
2107      public boolean equalsShallow(Base other_) {
2108        if (!super.equalsShallow(other_))
2109          return false;
2110        if (!(other_ instanceof SubstanceDefinitionStructureRepresentationComponent))
2111          return false;
2112        SubstanceDefinitionStructureRepresentationComponent o = (SubstanceDefinitionStructureRepresentationComponent) other_;
2113        return compareValues(representation, o.representation, true);
2114      }
2115
2116      public boolean isEmpty() {
2117        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, representation, format
2118          , document);
2119      }
2120
2121  public String fhirType() {
2122    return "SubstanceDefinition.structure.representation";
2123
2124  }
2125
2126  }
2127
2128    @Block()
2129    public static class SubstanceDefinitionCodeComponent extends BackboneElement implements IBaseBackboneElement {
2130        /**
2131         * The specific code.
2132         */
2133        @Child(name = "code", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
2134        @Description(shortDefinition="The specific code", formalDefinition="The specific code." )
2135        protected CodeableConcept code;
2136
2137        /**
2138         * Status of the code assignment, for example 'provisional', 'approved'.
2139         */
2140        @Child(name = "status", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
2141        @Description(shortDefinition="Status of the code assignment, for example 'provisional', 'approved'", formalDefinition="Status of the code assignment, for example 'provisional', 'approved'." )
2142        protected CodeableConcept status;
2143
2144        /**
2145         * The date at which the code status is changed as part of the terminology maintenance.
2146         */
2147        @Child(name = "statusDate", type = {DateTimeType.class}, order=3, min=0, max=1, modifier=false, summary=true)
2148        @Description(shortDefinition="The date at which the code status is changed as part of the terminology maintenance", formalDefinition="The date at which the code status is changed as part of the terminology maintenance." )
2149        protected DateTimeType statusDate;
2150
2151        /**
2152         * Any comment can be provided in this field, if necessary.
2153         */
2154        @Child(name = "note", type = {Annotation.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2155        @Description(shortDefinition="Any comment can be provided in this field, if necessary", formalDefinition="Any comment can be provided in this field, if necessary." )
2156        protected List<Annotation> note;
2157
2158        /**
2159         * Supporting literature.
2160         */
2161        @Child(name = "source", type = {DocumentReference.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2162        @Description(shortDefinition="Supporting literature", formalDefinition="Supporting literature." )
2163        protected List<Reference> source;
2164
2165        private static final long serialVersionUID = 1140562105L;
2166
2167    /**
2168     * Constructor
2169     */
2170      public SubstanceDefinitionCodeComponent() {
2171        super();
2172      }
2173
2174        /**
2175         * @return {@link #code} (The specific code.)
2176         */
2177        public CodeableConcept getCode() { 
2178          if (this.code == null)
2179            if (Configuration.errorOnAutoCreate())
2180              throw new Error("Attempt to auto-create SubstanceDefinitionCodeComponent.code");
2181            else if (Configuration.doAutoCreate())
2182              this.code = new CodeableConcept(); // cc
2183          return this.code;
2184        }
2185
2186        public boolean hasCode() { 
2187          return this.code != null && !this.code.isEmpty();
2188        }
2189
2190        /**
2191         * @param value {@link #code} (The specific code.)
2192         */
2193        public SubstanceDefinitionCodeComponent setCode(CodeableConcept value) { 
2194          this.code = value;
2195          return this;
2196        }
2197
2198        /**
2199         * @return {@link #status} (Status of the code assignment, for example 'provisional', 'approved'.)
2200         */
2201        public CodeableConcept getStatus() { 
2202          if (this.status == null)
2203            if (Configuration.errorOnAutoCreate())
2204              throw new Error("Attempt to auto-create SubstanceDefinitionCodeComponent.status");
2205            else if (Configuration.doAutoCreate())
2206              this.status = new CodeableConcept(); // cc
2207          return this.status;
2208        }
2209
2210        public boolean hasStatus() { 
2211          return this.status != null && !this.status.isEmpty();
2212        }
2213
2214        /**
2215         * @param value {@link #status} (Status of the code assignment, for example 'provisional', 'approved'.)
2216         */
2217        public SubstanceDefinitionCodeComponent setStatus(CodeableConcept value) { 
2218          this.status = value;
2219          return this;
2220        }
2221
2222        /**
2223         * @return {@link #statusDate} (The date at which the code status is changed as part of the terminology maintenance.). This is the underlying object with id, value and extensions. The accessor "getStatusDate" gives direct access to the value
2224         */
2225        public DateTimeType getStatusDateElement() { 
2226          if (this.statusDate == null)
2227            if (Configuration.errorOnAutoCreate())
2228              throw new Error("Attempt to auto-create SubstanceDefinitionCodeComponent.statusDate");
2229            else if (Configuration.doAutoCreate())
2230              this.statusDate = new DateTimeType(); // bb
2231          return this.statusDate;
2232        }
2233
2234        public boolean hasStatusDateElement() { 
2235          return this.statusDate != null && !this.statusDate.isEmpty();
2236        }
2237
2238        public boolean hasStatusDate() { 
2239          return this.statusDate != null && !this.statusDate.isEmpty();
2240        }
2241
2242        /**
2243         * @param value {@link #statusDate} (The date at which the code status is changed as part of the terminology maintenance.). This is the underlying object with id, value and extensions. The accessor "getStatusDate" gives direct access to the value
2244         */
2245        public SubstanceDefinitionCodeComponent setStatusDateElement(DateTimeType value) { 
2246          this.statusDate = value;
2247          return this;
2248        }
2249
2250        /**
2251         * @return The date at which the code status is changed as part of the terminology maintenance.
2252         */
2253        public Date getStatusDate() { 
2254          return this.statusDate == null ? null : this.statusDate.getValue();
2255        }
2256
2257        /**
2258         * @param value The date at which the code status is changed as part of the terminology maintenance.
2259         */
2260        public SubstanceDefinitionCodeComponent setStatusDate(Date value) { 
2261          if (value == null)
2262            this.statusDate = null;
2263          else {
2264            if (this.statusDate == null)
2265              this.statusDate = new DateTimeType();
2266            this.statusDate.setValue(value);
2267          }
2268          return this;
2269        }
2270
2271        /**
2272         * @return {@link #note} (Any comment can be provided in this field, if necessary.)
2273         */
2274        public List<Annotation> getNote() { 
2275          if (this.note == null)
2276            this.note = new ArrayList<Annotation>();
2277          return this.note;
2278        }
2279
2280        /**
2281         * @return Returns a reference to <code>this</code> for easy method chaining
2282         */
2283        public SubstanceDefinitionCodeComponent setNote(List<Annotation> theNote) { 
2284          this.note = theNote;
2285          return this;
2286        }
2287
2288        public boolean hasNote() { 
2289          if (this.note == null)
2290            return false;
2291          for (Annotation item : this.note)
2292            if (!item.isEmpty())
2293              return true;
2294          return false;
2295        }
2296
2297        public Annotation addNote() { //3
2298          Annotation t = new Annotation();
2299          if (this.note == null)
2300            this.note = new ArrayList<Annotation>();
2301          this.note.add(t);
2302          return t;
2303        }
2304
2305        public SubstanceDefinitionCodeComponent addNote(Annotation t) { //3
2306          if (t == null)
2307            return this;
2308          if (this.note == null)
2309            this.note = new ArrayList<Annotation>();
2310          this.note.add(t);
2311          return this;
2312        }
2313
2314        /**
2315         * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist {3}
2316         */
2317        public Annotation getNoteFirstRep() { 
2318          if (getNote().isEmpty()) {
2319            addNote();
2320          }
2321          return getNote().get(0);
2322        }
2323
2324        /**
2325         * @return {@link #source} (Supporting literature.)
2326         */
2327        public List<Reference> getSource() { 
2328          if (this.source == null)
2329            this.source = new ArrayList<Reference>();
2330          return this.source;
2331        }
2332
2333        /**
2334         * @return Returns a reference to <code>this</code> for easy method chaining
2335         */
2336        public SubstanceDefinitionCodeComponent setSource(List<Reference> theSource) { 
2337          this.source = theSource;
2338          return this;
2339        }
2340
2341        public boolean hasSource() { 
2342          if (this.source == null)
2343            return false;
2344          for (Reference item : this.source)
2345            if (!item.isEmpty())
2346              return true;
2347          return false;
2348        }
2349
2350        public Reference addSource() { //3
2351          Reference t = new Reference();
2352          if (this.source == null)
2353            this.source = new ArrayList<Reference>();
2354          this.source.add(t);
2355          return t;
2356        }
2357
2358        public SubstanceDefinitionCodeComponent addSource(Reference t) { //3
2359          if (t == null)
2360            return this;
2361          if (this.source == null)
2362            this.source = new ArrayList<Reference>();
2363          this.source.add(t);
2364          return this;
2365        }
2366
2367        /**
2368         * @return The first repetition of repeating field {@link #source}, creating it if it does not already exist {3}
2369         */
2370        public Reference getSourceFirstRep() { 
2371          if (getSource().isEmpty()) {
2372            addSource();
2373          }
2374          return getSource().get(0);
2375        }
2376
2377        protected void listChildren(List<Property> children) {
2378          super.listChildren(children);
2379          children.add(new Property("code", "CodeableConcept", "The specific code.", 0, 1, code));
2380          children.add(new Property("status", "CodeableConcept", "Status of the code assignment, for example 'provisional', 'approved'.", 0, 1, status));
2381          children.add(new Property("statusDate", "dateTime", "The date at which the code status is changed as part of the terminology maintenance.", 0, 1, statusDate));
2382          children.add(new Property("note", "Annotation", "Any comment can be provided in this field, if necessary.", 0, java.lang.Integer.MAX_VALUE, note));
2383          children.add(new Property("source", "Reference(DocumentReference)", "Supporting literature.", 0, java.lang.Integer.MAX_VALUE, source));
2384        }
2385
2386        @Override
2387        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2388          switch (_hash) {
2389          case 3059181: /*code*/  return new Property("code", "CodeableConcept", "The specific code.", 0, 1, code);
2390          case -892481550: /*status*/  return new Property("status", "CodeableConcept", "Status of the code assignment, for example 'provisional', 'approved'.", 0, 1, status);
2391          case 247524032: /*statusDate*/  return new Property("statusDate", "dateTime", "The date at which the code status is changed as part of the terminology maintenance.", 0, 1, statusDate);
2392          case 3387378: /*note*/  return new Property("note", "Annotation", "Any comment can be provided in this field, if necessary.", 0, java.lang.Integer.MAX_VALUE, note);
2393          case -896505829: /*source*/  return new Property("source", "Reference(DocumentReference)", "Supporting literature.", 0, java.lang.Integer.MAX_VALUE, source);
2394          default: return super.getNamedProperty(_hash, _name, _checkValid);
2395          }
2396
2397        }
2398
2399      @Override
2400      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2401        switch (hash) {
2402        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept
2403        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // CodeableConcept
2404        case 247524032: /*statusDate*/ return this.statusDate == null ? new Base[0] : new Base[] {this.statusDate}; // DateTimeType
2405        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
2406        case -896505829: /*source*/ return this.source == null ? new Base[0] : this.source.toArray(new Base[this.source.size()]); // Reference
2407        default: return super.getProperty(hash, name, checkValid);
2408        }
2409
2410      }
2411
2412      @Override
2413      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2414        switch (hash) {
2415        case 3059181: // code
2416          this.code = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
2417          return value;
2418        case -892481550: // status
2419          this.status = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
2420          return value;
2421        case 247524032: // statusDate
2422          this.statusDate = TypeConvertor.castToDateTime(value); // DateTimeType
2423          return value;
2424        case 3387378: // note
2425          this.getNote().add(TypeConvertor.castToAnnotation(value)); // Annotation
2426          return value;
2427        case -896505829: // source
2428          this.getSource().add(TypeConvertor.castToReference(value)); // Reference
2429          return value;
2430        default: return super.setProperty(hash, name, value);
2431        }
2432
2433      }
2434
2435      @Override
2436      public Base setProperty(String name, Base value) throws FHIRException {
2437        if (name.equals("code")) {
2438          this.code = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
2439        } else if (name.equals("status")) {
2440          this.status = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
2441        } else if (name.equals("statusDate")) {
2442          this.statusDate = TypeConvertor.castToDateTime(value); // DateTimeType
2443        } else if (name.equals("note")) {
2444          this.getNote().add(TypeConvertor.castToAnnotation(value));
2445        } else if (name.equals("source")) {
2446          this.getSource().add(TypeConvertor.castToReference(value));
2447        } else
2448          return super.setProperty(name, value);
2449        return value;
2450      }
2451
2452      @Override
2453      public Base makeProperty(int hash, String name) throws FHIRException {
2454        switch (hash) {
2455        case 3059181:  return getCode();
2456        case -892481550:  return getStatus();
2457        case 247524032:  return getStatusDateElement();
2458        case 3387378:  return addNote(); 
2459        case -896505829:  return addSource(); 
2460        default: return super.makeProperty(hash, name);
2461        }
2462
2463      }
2464
2465      @Override
2466      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2467        switch (hash) {
2468        case 3059181: /*code*/ return new String[] {"CodeableConcept"};
2469        case -892481550: /*status*/ return new String[] {"CodeableConcept"};
2470        case 247524032: /*statusDate*/ return new String[] {"dateTime"};
2471        case 3387378: /*note*/ return new String[] {"Annotation"};
2472        case -896505829: /*source*/ return new String[] {"Reference"};
2473        default: return super.getTypesForProperty(hash, name);
2474        }
2475
2476      }
2477
2478      @Override
2479      public Base addChild(String name) throws FHIRException {
2480        if (name.equals("code")) {
2481          this.code = new CodeableConcept();
2482          return this.code;
2483        }
2484        else if (name.equals("status")) {
2485          this.status = new CodeableConcept();
2486          return this.status;
2487        }
2488        else if (name.equals("statusDate")) {
2489          throw new FHIRException("Cannot call addChild on a primitive type SubstanceDefinition.code.statusDate");
2490        }
2491        else if (name.equals("note")) {
2492          return addNote();
2493        }
2494        else if (name.equals("source")) {
2495          return addSource();
2496        }
2497        else
2498          return super.addChild(name);
2499      }
2500
2501      public SubstanceDefinitionCodeComponent copy() {
2502        SubstanceDefinitionCodeComponent dst = new SubstanceDefinitionCodeComponent();
2503        copyValues(dst);
2504        return dst;
2505      }
2506
2507      public void copyValues(SubstanceDefinitionCodeComponent dst) {
2508        super.copyValues(dst);
2509        dst.code = code == null ? null : code.copy();
2510        dst.status = status == null ? null : status.copy();
2511        dst.statusDate = statusDate == null ? null : statusDate.copy();
2512        if (note != null) {
2513          dst.note = new ArrayList<Annotation>();
2514          for (Annotation i : note)
2515            dst.note.add(i.copy());
2516        };
2517        if (source != null) {
2518          dst.source = new ArrayList<Reference>();
2519          for (Reference i : source)
2520            dst.source.add(i.copy());
2521        };
2522      }
2523
2524      @Override
2525      public boolean equalsDeep(Base other_) {
2526        if (!super.equalsDeep(other_))
2527          return false;
2528        if (!(other_ instanceof SubstanceDefinitionCodeComponent))
2529          return false;
2530        SubstanceDefinitionCodeComponent o = (SubstanceDefinitionCodeComponent) other_;
2531        return compareDeep(code, o.code, true) && compareDeep(status, o.status, true) && compareDeep(statusDate, o.statusDate, true)
2532           && compareDeep(note, o.note, true) && compareDeep(source, o.source, true);
2533      }
2534
2535      @Override
2536      public boolean equalsShallow(Base other_) {
2537        if (!super.equalsShallow(other_))
2538          return false;
2539        if (!(other_ instanceof SubstanceDefinitionCodeComponent))
2540          return false;
2541        SubstanceDefinitionCodeComponent o = (SubstanceDefinitionCodeComponent) other_;
2542        return compareValues(statusDate, o.statusDate, true);
2543      }
2544
2545      public boolean isEmpty() {
2546        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(code, status, statusDate
2547          , note, source);
2548      }
2549
2550  public String fhirType() {
2551    return "SubstanceDefinition.code";
2552
2553  }
2554
2555  }
2556
2557    @Block()
2558    public static class SubstanceDefinitionNameComponent extends BackboneElement implements IBaseBackboneElement {
2559        /**
2560         * The actual name.
2561         */
2562        @Child(name = "name", type = {StringType.class}, order=1, min=1, max=1, modifier=false, summary=true)
2563        @Description(shortDefinition="The actual name", formalDefinition="The actual name." )
2564        protected StringType name;
2565
2566        /**
2567         * Name type, for example 'systematic',  'scientific, 'brand'.
2568         */
2569        @Child(name = "type", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
2570        @Description(shortDefinition="Name type, for example 'systematic',  'scientific, 'brand'", formalDefinition="Name type, for example 'systematic',  'scientific, 'brand'." )
2571        protected CodeableConcept type;
2572
2573        /**
2574         * The status of the name, for example 'current', 'proposed'.
2575         */
2576        @Child(name = "status", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true)
2577        @Description(shortDefinition="The status of the name, for example 'current', 'proposed'", formalDefinition="The status of the name, for example 'current', 'proposed'." )
2578        protected CodeableConcept status;
2579
2580        /**
2581         * If this is the preferred name for this substance.
2582         */
2583        @Child(name = "preferred", type = {BooleanType.class}, order=4, min=0, max=1, modifier=false, summary=true)
2584        @Description(shortDefinition="If this is the preferred name for this substance", formalDefinition="If this is the preferred name for this substance." )
2585        protected BooleanType preferred;
2586
2587        /**
2588         * Human language that the name is written in.
2589         */
2590        @Child(name = "language", type = {CodeableConcept.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2591        @Description(shortDefinition="Human language that the name is written in", formalDefinition="Human language that the name is written in." )
2592        protected List<CodeableConcept> language;
2593
2594        /**
2595         * The use context of this name for example if there is a different name a drug active ingredient as opposed to a food colour additive.
2596         */
2597        @Child(name = "domain", type = {CodeableConcept.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2598        @Description(shortDefinition="The use context of this name for example if there is a different name a drug active ingredient as opposed to a food colour additive", formalDefinition="The use context of this name for example if there is a different name a drug active ingredient as opposed to a food colour additive." )
2599        protected List<CodeableConcept> domain;
2600
2601        /**
2602         * The jurisdiction where this name applies.
2603         */
2604        @Child(name = "jurisdiction", type = {CodeableConcept.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2605        @Description(shortDefinition="The jurisdiction where this name applies", formalDefinition="The jurisdiction where this name applies." )
2606        protected List<CodeableConcept> jurisdiction;
2607
2608        /**
2609         * A synonym of this particular name, by which the substance is also known.
2610         */
2611        @Child(name = "synonym", type = {SubstanceDefinitionNameComponent.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2612        @Description(shortDefinition="A synonym of this particular name, by which the substance is also known", formalDefinition="A synonym of this particular name, by which the substance is also known." )
2613        protected List<SubstanceDefinitionNameComponent> synonym;
2614
2615        /**
2616         * A translation for this name into another human language.
2617         */
2618        @Child(name = "translation", type = {SubstanceDefinitionNameComponent.class}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2619        @Description(shortDefinition="A translation for this name into another human language", formalDefinition="A translation for this name into another human language." )
2620        protected List<SubstanceDefinitionNameComponent> translation;
2621
2622        /**
2623         * Details of the official nature of this name.
2624         */
2625        @Child(name = "official", type = {}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2626        @Description(shortDefinition="Details of the official nature of this name", formalDefinition="Details of the official nature of this name." )
2627        protected List<SubstanceDefinitionNameOfficialComponent> official;
2628
2629        /**
2630         * Supporting literature.
2631         */
2632        @Child(name = "source", type = {DocumentReference.class}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2633        @Description(shortDefinition="Supporting literature", formalDefinition="Supporting literature." )
2634        protected List<Reference> source;
2635
2636        private static final long serialVersionUID = -1184238780L;
2637
2638    /**
2639     * Constructor
2640     */
2641      public SubstanceDefinitionNameComponent() {
2642        super();
2643      }
2644
2645    /**
2646     * Constructor
2647     */
2648      public SubstanceDefinitionNameComponent(String name) {
2649        super();
2650        this.setName(name);
2651      }
2652
2653        /**
2654         * @return {@link #name} (The actual name.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
2655         */
2656        public StringType getNameElement() { 
2657          if (this.name == null)
2658            if (Configuration.errorOnAutoCreate())
2659              throw new Error("Attempt to auto-create SubstanceDefinitionNameComponent.name");
2660            else if (Configuration.doAutoCreate())
2661              this.name = new StringType(); // bb
2662          return this.name;
2663        }
2664
2665        public boolean hasNameElement() { 
2666          return this.name != null && !this.name.isEmpty();
2667        }
2668
2669        public boolean hasName() { 
2670          return this.name != null && !this.name.isEmpty();
2671        }
2672
2673        /**
2674         * @param value {@link #name} (The actual name.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value
2675         */
2676        public SubstanceDefinitionNameComponent setNameElement(StringType value) { 
2677          this.name = value;
2678          return this;
2679        }
2680
2681        /**
2682         * @return The actual name.
2683         */
2684        public String getName() { 
2685          return this.name == null ? null : this.name.getValue();
2686        }
2687
2688        /**
2689         * @param value The actual name.
2690         */
2691        public SubstanceDefinitionNameComponent setName(String value) { 
2692            if (this.name == null)
2693              this.name = new StringType();
2694            this.name.setValue(value);
2695          return this;
2696        }
2697
2698        /**
2699         * @return {@link #type} (Name type, for example 'systematic',  'scientific, 'brand'.)
2700         */
2701        public CodeableConcept getType() { 
2702          if (this.type == null)
2703            if (Configuration.errorOnAutoCreate())
2704              throw new Error("Attempt to auto-create SubstanceDefinitionNameComponent.type");
2705            else if (Configuration.doAutoCreate())
2706              this.type = new CodeableConcept(); // cc
2707          return this.type;
2708        }
2709
2710        public boolean hasType() { 
2711          return this.type != null && !this.type.isEmpty();
2712        }
2713
2714        /**
2715         * @param value {@link #type} (Name type, for example 'systematic',  'scientific, 'brand'.)
2716         */
2717        public SubstanceDefinitionNameComponent setType(CodeableConcept value) { 
2718          this.type = value;
2719          return this;
2720        }
2721
2722        /**
2723         * @return {@link #status} (The status of the name, for example 'current', 'proposed'.)
2724         */
2725        public CodeableConcept getStatus() { 
2726          if (this.status == null)
2727            if (Configuration.errorOnAutoCreate())
2728              throw new Error("Attempt to auto-create SubstanceDefinitionNameComponent.status");
2729            else if (Configuration.doAutoCreate())
2730              this.status = new CodeableConcept(); // cc
2731          return this.status;
2732        }
2733
2734        public boolean hasStatus() { 
2735          return this.status != null && !this.status.isEmpty();
2736        }
2737
2738        /**
2739         * @param value {@link #status} (The status of the name, for example 'current', 'proposed'.)
2740         */
2741        public SubstanceDefinitionNameComponent setStatus(CodeableConcept value) { 
2742          this.status = value;
2743          return this;
2744        }
2745
2746        /**
2747         * @return {@link #preferred} (If this is the preferred name for this substance.). This is the underlying object with id, value and extensions. The accessor "getPreferred" gives direct access to the value
2748         */
2749        public BooleanType getPreferredElement() { 
2750          if (this.preferred == null)
2751            if (Configuration.errorOnAutoCreate())
2752              throw new Error("Attempt to auto-create SubstanceDefinitionNameComponent.preferred");
2753            else if (Configuration.doAutoCreate())
2754              this.preferred = new BooleanType(); // bb
2755          return this.preferred;
2756        }
2757
2758        public boolean hasPreferredElement() { 
2759          return this.preferred != null && !this.preferred.isEmpty();
2760        }
2761
2762        public boolean hasPreferred() { 
2763          return this.preferred != null && !this.preferred.isEmpty();
2764        }
2765
2766        /**
2767         * @param value {@link #preferred} (If this is the preferred name for this substance.). This is the underlying object with id, value and extensions. The accessor "getPreferred" gives direct access to the value
2768         */
2769        public SubstanceDefinitionNameComponent setPreferredElement(BooleanType value) { 
2770          this.preferred = value;
2771          return this;
2772        }
2773
2774        /**
2775         * @return If this is the preferred name for this substance.
2776         */
2777        public boolean getPreferred() { 
2778          return this.preferred == null || this.preferred.isEmpty() ? false : this.preferred.getValue();
2779        }
2780
2781        /**
2782         * @param value If this is the preferred name for this substance.
2783         */
2784        public SubstanceDefinitionNameComponent setPreferred(boolean value) { 
2785            if (this.preferred == null)
2786              this.preferred = new BooleanType();
2787            this.preferred.setValue(value);
2788          return this;
2789        }
2790
2791        /**
2792         * @return {@link #language} (Human language that the name is written in.)
2793         */
2794        public List<CodeableConcept> getLanguage() { 
2795          if (this.language == null)
2796            this.language = new ArrayList<CodeableConcept>();
2797          return this.language;
2798        }
2799
2800        /**
2801         * @return Returns a reference to <code>this</code> for easy method chaining
2802         */
2803        public SubstanceDefinitionNameComponent setLanguage(List<CodeableConcept> theLanguage) { 
2804          this.language = theLanguage;
2805          return this;
2806        }
2807
2808        public boolean hasLanguage() { 
2809          if (this.language == null)
2810            return false;
2811          for (CodeableConcept item : this.language)
2812            if (!item.isEmpty())
2813              return true;
2814          return false;
2815        }
2816
2817        public CodeableConcept addLanguage() { //3
2818          CodeableConcept t = new CodeableConcept();
2819          if (this.language == null)
2820            this.language = new ArrayList<CodeableConcept>();
2821          this.language.add(t);
2822          return t;
2823        }
2824
2825        public SubstanceDefinitionNameComponent addLanguage(CodeableConcept t) { //3
2826          if (t == null)
2827            return this;
2828          if (this.language == null)
2829            this.language = new ArrayList<CodeableConcept>();
2830          this.language.add(t);
2831          return this;
2832        }
2833
2834        /**
2835         * @return The first repetition of repeating field {@link #language}, creating it if it does not already exist {3}
2836         */
2837        public CodeableConcept getLanguageFirstRep() { 
2838          if (getLanguage().isEmpty()) {
2839            addLanguage();
2840          }
2841          return getLanguage().get(0);
2842        }
2843
2844        /**
2845         * @return {@link #domain} (The use context of this name for example if there is a different name a drug active ingredient as opposed to a food colour additive.)
2846         */
2847        public List<CodeableConcept> getDomain() { 
2848          if (this.domain == null)
2849            this.domain = new ArrayList<CodeableConcept>();
2850          return this.domain;
2851        }
2852
2853        /**
2854         * @return Returns a reference to <code>this</code> for easy method chaining
2855         */
2856        public SubstanceDefinitionNameComponent setDomain(List<CodeableConcept> theDomain) { 
2857          this.domain = theDomain;
2858          return this;
2859        }
2860
2861        public boolean hasDomain() { 
2862          if (this.domain == null)
2863            return false;
2864          for (CodeableConcept item : this.domain)
2865            if (!item.isEmpty())
2866              return true;
2867          return false;
2868        }
2869
2870        public CodeableConcept addDomain() { //3
2871          CodeableConcept t = new CodeableConcept();
2872          if (this.domain == null)
2873            this.domain = new ArrayList<CodeableConcept>();
2874          this.domain.add(t);
2875          return t;
2876        }
2877
2878        public SubstanceDefinitionNameComponent addDomain(CodeableConcept t) { //3
2879          if (t == null)
2880            return this;
2881          if (this.domain == null)
2882            this.domain = new ArrayList<CodeableConcept>();
2883          this.domain.add(t);
2884          return this;
2885        }
2886
2887        /**
2888         * @return The first repetition of repeating field {@link #domain}, creating it if it does not already exist {3}
2889         */
2890        public CodeableConcept getDomainFirstRep() { 
2891          if (getDomain().isEmpty()) {
2892            addDomain();
2893          }
2894          return getDomain().get(0);
2895        }
2896
2897        /**
2898         * @return {@link #jurisdiction} (The jurisdiction where this name applies.)
2899         */
2900        public List<CodeableConcept> getJurisdiction() { 
2901          if (this.jurisdiction == null)
2902            this.jurisdiction = new ArrayList<CodeableConcept>();
2903          return this.jurisdiction;
2904        }
2905
2906        /**
2907         * @return Returns a reference to <code>this</code> for easy method chaining
2908         */
2909        public SubstanceDefinitionNameComponent setJurisdiction(List<CodeableConcept> theJurisdiction) { 
2910          this.jurisdiction = theJurisdiction;
2911          return this;
2912        }
2913
2914        public boolean hasJurisdiction() { 
2915          if (this.jurisdiction == null)
2916            return false;
2917          for (CodeableConcept item : this.jurisdiction)
2918            if (!item.isEmpty())
2919              return true;
2920          return false;
2921        }
2922
2923        public CodeableConcept addJurisdiction() { //3
2924          CodeableConcept t = new CodeableConcept();
2925          if (this.jurisdiction == null)
2926            this.jurisdiction = new ArrayList<CodeableConcept>();
2927          this.jurisdiction.add(t);
2928          return t;
2929        }
2930
2931        public SubstanceDefinitionNameComponent addJurisdiction(CodeableConcept t) { //3
2932          if (t == null)
2933            return this;
2934          if (this.jurisdiction == null)
2935            this.jurisdiction = new ArrayList<CodeableConcept>();
2936          this.jurisdiction.add(t);
2937          return this;
2938        }
2939
2940        /**
2941         * @return The first repetition of repeating field {@link #jurisdiction}, creating it if it does not already exist {3}
2942         */
2943        public CodeableConcept getJurisdictionFirstRep() { 
2944          if (getJurisdiction().isEmpty()) {
2945            addJurisdiction();
2946          }
2947          return getJurisdiction().get(0);
2948        }
2949
2950        /**
2951         * @return {@link #synonym} (A synonym of this particular name, by which the substance is also known.)
2952         */
2953        public List<SubstanceDefinitionNameComponent> getSynonym() { 
2954          if (this.synonym == null)
2955            this.synonym = new ArrayList<SubstanceDefinitionNameComponent>();
2956          return this.synonym;
2957        }
2958
2959        /**
2960         * @return Returns a reference to <code>this</code> for easy method chaining
2961         */
2962        public SubstanceDefinitionNameComponent setSynonym(List<SubstanceDefinitionNameComponent> theSynonym) { 
2963          this.synonym = theSynonym;
2964          return this;
2965        }
2966
2967        public boolean hasSynonym() { 
2968          if (this.synonym == null)
2969            return false;
2970          for (SubstanceDefinitionNameComponent item : this.synonym)
2971            if (!item.isEmpty())
2972              return true;
2973          return false;
2974        }
2975
2976        public SubstanceDefinitionNameComponent addSynonym() { //3
2977          SubstanceDefinitionNameComponent t = new SubstanceDefinitionNameComponent();
2978          if (this.synonym == null)
2979            this.synonym = new ArrayList<SubstanceDefinitionNameComponent>();
2980          this.synonym.add(t);
2981          return t;
2982        }
2983
2984        public SubstanceDefinitionNameComponent addSynonym(SubstanceDefinitionNameComponent t) { //3
2985          if (t == null)
2986            return this;
2987          if (this.synonym == null)
2988            this.synonym = new ArrayList<SubstanceDefinitionNameComponent>();
2989          this.synonym.add(t);
2990          return this;
2991        }
2992
2993        /**
2994         * @return The first repetition of repeating field {@link #synonym}, creating it if it does not already exist {3}
2995         */
2996        public SubstanceDefinitionNameComponent getSynonymFirstRep() { 
2997          if (getSynonym().isEmpty()) {
2998            addSynonym();
2999          }
3000          return getSynonym().get(0);
3001        }
3002
3003        /**
3004         * @return {@link #translation} (A translation for this name into another human language.)
3005         */
3006        public List<SubstanceDefinitionNameComponent> getTranslation() { 
3007          if (this.translation == null)
3008            this.translation = new ArrayList<SubstanceDefinitionNameComponent>();
3009          return this.translation;
3010        }
3011
3012        /**
3013         * @return Returns a reference to <code>this</code> for easy method chaining
3014         */
3015        public SubstanceDefinitionNameComponent setTranslation(List<SubstanceDefinitionNameComponent> theTranslation) { 
3016          this.translation = theTranslation;
3017          return this;
3018        }
3019
3020        public boolean hasTranslation() { 
3021          if (this.translation == null)
3022            return false;
3023          for (SubstanceDefinitionNameComponent item : this.translation)
3024            if (!item.isEmpty())
3025              return true;
3026          return false;
3027        }
3028
3029        public SubstanceDefinitionNameComponent addTranslation() { //3
3030          SubstanceDefinitionNameComponent t = new SubstanceDefinitionNameComponent();
3031          if (this.translation == null)
3032            this.translation = new ArrayList<SubstanceDefinitionNameComponent>();
3033          this.translation.add(t);
3034          return t;
3035        }
3036
3037        public SubstanceDefinitionNameComponent addTranslation(SubstanceDefinitionNameComponent t) { //3
3038          if (t == null)
3039            return this;
3040          if (this.translation == null)
3041            this.translation = new ArrayList<SubstanceDefinitionNameComponent>();
3042          this.translation.add(t);
3043          return this;
3044        }
3045
3046        /**
3047         * @return The first repetition of repeating field {@link #translation}, creating it if it does not already exist {3}
3048         */
3049        public SubstanceDefinitionNameComponent getTranslationFirstRep() { 
3050          if (getTranslation().isEmpty()) {
3051            addTranslation();
3052          }
3053          return getTranslation().get(0);
3054        }
3055
3056        /**
3057         * @return {@link #official} (Details of the official nature of this name.)
3058         */
3059        public List<SubstanceDefinitionNameOfficialComponent> getOfficial() { 
3060          if (this.official == null)
3061            this.official = new ArrayList<SubstanceDefinitionNameOfficialComponent>();
3062          return this.official;
3063        }
3064
3065        /**
3066         * @return Returns a reference to <code>this</code> for easy method chaining
3067         */
3068        public SubstanceDefinitionNameComponent setOfficial(List<SubstanceDefinitionNameOfficialComponent> theOfficial) { 
3069          this.official = theOfficial;
3070          return this;
3071        }
3072
3073        public boolean hasOfficial() { 
3074          if (this.official == null)
3075            return false;
3076          for (SubstanceDefinitionNameOfficialComponent item : this.official)
3077            if (!item.isEmpty())
3078              return true;
3079          return false;
3080        }
3081
3082        public SubstanceDefinitionNameOfficialComponent addOfficial() { //3
3083          SubstanceDefinitionNameOfficialComponent t = new SubstanceDefinitionNameOfficialComponent();
3084          if (this.official == null)
3085            this.official = new ArrayList<SubstanceDefinitionNameOfficialComponent>();
3086          this.official.add(t);
3087          return t;
3088        }
3089
3090        public SubstanceDefinitionNameComponent addOfficial(SubstanceDefinitionNameOfficialComponent t) { //3
3091          if (t == null)
3092            return this;
3093          if (this.official == null)
3094            this.official = new ArrayList<SubstanceDefinitionNameOfficialComponent>();
3095          this.official.add(t);
3096          return this;
3097        }
3098
3099        /**
3100         * @return The first repetition of repeating field {@link #official}, creating it if it does not already exist {3}
3101         */
3102        public SubstanceDefinitionNameOfficialComponent getOfficialFirstRep() { 
3103          if (getOfficial().isEmpty()) {
3104            addOfficial();
3105          }
3106          return getOfficial().get(0);
3107        }
3108
3109        /**
3110         * @return {@link #source} (Supporting literature.)
3111         */
3112        public List<Reference> getSource() { 
3113          if (this.source == null)
3114            this.source = new ArrayList<Reference>();
3115          return this.source;
3116        }
3117
3118        /**
3119         * @return Returns a reference to <code>this</code> for easy method chaining
3120         */
3121        public SubstanceDefinitionNameComponent setSource(List<Reference> theSource) { 
3122          this.source = theSource;
3123          return this;
3124        }
3125
3126        public boolean hasSource() { 
3127          if (this.source == null)
3128            return false;
3129          for (Reference item : this.source)
3130            if (!item.isEmpty())
3131              return true;
3132          return false;
3133        }
3134
3135        public Reference addSource() { //3
3136          Reference t = new Reference();
3137          if (this.source == null)
3138            this.source = new ArrayList<Reference>();
3139          this.source.add(t);
3140          return t;
3141        }
3142
3143        public SubstanceDefinitionNameComponent addSource(Reference t) { //3
3144          if (t == null)
3145            return this;
3146          if (this.source == null)
3147            this.source = new ArrayList<Reference>();
3148          this.source.add(t);
3149          return this;
3150        }
3151
3152        /**
3153         * @return The first repetition of repeating field {@link #source}, creating it if it does not already exist {3}
3154         */
3155        public Reference getSourceFirstRep() { 
3156          if (getSource().isEmpty()) {
3157            addSource();
3158          }
3159          return getSource().get(0);
3160        }
3161
3162        protected void listChildren(List<Property> children) {
3163          super.listChildren(children);
3164          children.add(new Property("name", "string", "The actual name.", 0, 1, name));
3165          children.add(new Property("type", "CodeableConcept", "Name type, for example 'systematic',  'scientific, 'brand'.", 0, 1, type));
3166          children.add(new Property("status", "CodeableConcept", "The status of the name, for example 'current', 'proposed'.", 0, 1, status));
3167          children.add(new Property("preferred", "boolean", "If this is the preferred name for this substance.", 0, 1, preferred));
3168          children.add(new Property("language", "CodeableConcept", "Human language that the name is written in.", 0, java.lang.Integer.MAX_VALUE, language));
3169          children.add(new Property("domain", "CodeableConcept", "The use context of this name for example if there is a different name a drug active ingredient as opposed to a food colour additive.", 0, java.lang.Integer.MAX_VALUE, domain));
3170          children.add(new Property("jurisdiction", "CodeableConcept", "The jurisdiction where this name applies.", 0, java.lang.Integer.MAX_VALUE, jurisdiction));
3171          children.add(new Property("synonym", "@SubstanceDefinition.name", "A synonym of this particular name, by which the substance is also known.", 0, java.lang.Integer.MAX_VALUE, synonym));
3172          children.add(new Property("translation", "@SubstanceDefinition.name", "A translation for this name into another human language.", 0, java.lang.Integer.MAX_VALUE, translation));
3173          children.add(new Property("official", "", "Details of the official nature of this name.", 0, java.lang.Integer.MAX_VALUE, official));
3174          children.add(new Property("source", "Reference(DocumentReference)", "Supporting literature.", 0, java.lang.Integer.MAX_VALUE, source));
3175        }
3176
3177        @Override
3178        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
3179          switch (_hash) {
3180          case 3373707: /*name*/  return new Property("name", "string", "The actual name.", 0, 1, name);
3181          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "Name type, for example 'systematic',  'scientific, 'brand'.", 0, 1, type);
3182          case -892481550: /*status*/  return new Property("status", "CodeableConcept", "The status of the name, for example 'current', 'proposed'.", 0, 1, status);
3183          case -1294005119: /*preferred*/  return new Property("preferred", "boolean", "If this is the preferred name for this substance.", 0, 1, preferred);
3184          case -1613589672: /*language*/  return new Property("language", "CodeableConcept", "Human language that the name is written in.", 0, java.lang.Integer.MAX_VALUE, language);
3185          case -1326197564: /*domain*/  return new Property("domain", "CodeableConcept", "The use context of this name for example if there is a different name a drug active ingredient as opposed to a food colour additive.", 0, java.lang.Integer.MAX_VALUE, domain);
3186          case -507075711: /*jurisdiction*/  return new Property("jurisdiction", "CodeableConcept", "The jurisdiction where this name applies.", 0, java.lang.Integer.MAX_VALUE, jurisdiction);
3187          case -1742128133: /*synonym*/  return new Property("synonym", "@SubstanceDefinition.name", "A synonym of this particular name, by which the substance is also known.", 0, java.lang.Integer.MAX_VALUE, synonym);
3188          case -1840647503: /*translation*/  return new Property("translation", "@SubstanceDefinition.name", "A translation for this name into another human language.", 0, java.lang.Integer.MAX_VALUE, translation);
3189          case -765289749: /*official*/  return new Property("official", "", "Details of the official nature of this name.", 0, java.lang.Integer.MAX_VALUE, official);
3190          case -896505829: /*source*/  return new Property("source", "Reference(DocumentReference)", "Supporting literature.", 0, java.lang.Integer.MAX_VALUE, source);
3191          default: return super.getNamedProperty(_hash, _name, _checkValid);
3192          }
3193
3194        }
3195
3196      @Override
3197      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
3198        switch (hash) {
3199        case 3373707: /*name*/ return this.name == null ? new Base[0] : new Base[] {this.name}; // StringType
3200        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
3201        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // CodeableConcept
3202        case -1294005119: /*preferred*/ return this.preferred == null ? new Base[0] : new Base[] {this.preferred}; // BooleanType
3203        case -1613589672: /*language*/ return this.language == null ? new Base[0] : this.language.toArray(new Base[this.language.size()]); // CodeableConcept
3204        case -1326197564: /*domain*/ return this.domain == null ? new Base[0] : this.domain.toArray(new Base[this.domain.size()]); // CodeableConcept
3205        case -507075711: /*jurisdiction*/ return this.jurisdiction == null ? new Base[0] : this.jurisdiction.toArray(new Base[this.jurisdiction.size()]); // CodeableConcept
3206        case -1742128133: /*synonym*/ return this.synonym == null ? new Base[0] : this.synonym.toArray(new Base[this.synonym.size()]); // SubstanceDefinitionNameComponent
3207        case -1840647503: /*translation*/ return this.translation == null ? new Base[0] : this.translation.toArray(new Base[this.translation.size()]); // SubstanceDefinitionNameComponent
3208        case -765289749: /*official*/ return this.official == null ? new Base[0] : this.official.toArray(new Base[this.official.size()]); // SubstanceDefinitionNameOfficialComponent
3209        case -896505829: /*source*/ return this.source == null ? new Base[0] : this.source.toArray(new Base[this.source.size()]); // Reference
3210        default: return super.getProperty(hash, name, checkValid);
3211        }
3212
3213      }
3214
3215      @Override
3216      public Base setProperty(int hash, String name, Base value) throws FHIRException {
3217        switch (hash) {
3218        case 3373707: // name
3219          this.name = TypeConvertor.castToString(value); // StringType
3220          return value;
3221        case 3575610: // type
3222          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
3223          return value;
3224        case -892481550: // status
3225          this.status = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
3226          return value;
3227        case -1294005119: // preferred
3228          this.preferred = TypeConvertor.castToBoolean(value); // BooleanType
3229          return value;
3230        case -1613589672: // language
3231          this.getLanguage().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
3232          return value;
3233        case -1326197564: // domain
3234          this.getDomain().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
3235          return value;
3236        case -507075711: // jurisdiction
3237          this.getJurisdiction().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
3238          return value;
3239        case -1742128133: // synonym
3240          this.getSynonym().add((SubstanceDefinitionNameComponent) value); // SubstanceDefinitionNameComponent
3241          return value;
3242        case -1840647503: // translation
3243          this.getTranslation().add((SubstanceDefinitionNameComponent) value); // SubstanceDefinitionNameComponent
3244          return value;
3245        case -765289749: // official
3246          this.getOfficial().add((SubstanceDefinitionNameOfficialComponent) value); // SubstanceDefinitionNameOfficialComponent
3247          return value;
3248        case -896505829: // source
3249          this.getSource().add(TypeConvertor.castToReference(value)); // Reference
3250          return value;
3251        default: return super.setProperty(hash, name, value);
3252        }
3253
3254      }
3255
3256      @Override
3257      public Base setProperty(String name, Base value) throws FHIRException {
3258        if (name.equals("name")) {
3259          this.name = TypeConvertor.castToString(value); // StringType
3260        } else if (name.equals("type")) {
3261          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
3262        } else if (name.equals("status")) {
3263          this.status = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
3264        } else if (name.equals("preferred")) {
3265          this.preferred = TypeConvertor.castToBoolean(value); // BooleanType
3266        } else if (name.equals("language")) {
3267          this.getLanguage().add(TypeConvertor.castToCodeableConcept(value));
3268        } else if (name.equals("domain")) {
3269          this.getDomain().add(TypeConvertor.castToCodeableConcept(value));
3270        } else if (name.equals("jurisdiction")) {
3271          this.getJurisdiction().add(TypeConvertor.castToCodeableConcept(value));
3272        } else if (name.equals("synonym")) {
3273          this.getSynonym().add((SubstanceDefinitionNameComponent) value);
3274        } else if (name.equals("translation")) {
3275          this.getTranslation().add((SubstanceDefinitionNameComponent) value);
3276        } else if (name.equals("official")) {
3277          this.getOfficial().add((SubstanceDefinitionNameOfficialComponent) value);
3278        } else if (name.equals("source")) {
3279          this.getSource().add(TypeConvertor.castToReference(value));
3280        } else
3281          return super.setProperty(name, value);
3282        return value;
3283      }
3284
3285      @Override
3286      public Base makeProperty(int hash, String name) throws FHIRException {
3287        switch (hash) {
3288        case 3373707:  return getNameElement();
3289        case 3575610:  return getType();
3290        case -892481550:  return getStatus();
3291        case -1294005119:  return getPreferredElement();
3292        case -1613589672:  return addLanguage(); 
3293        case -1326197564:  return addDomain(); 
3294        case -507075711:  return addJurisdiction(); 
3295        case -1742128133:  return addSynonym(); 
3296        case -1840647503:  return addTranslation(); 
3297        case -765289749:  return addOfficial(); 
3298        case -896505829:  return addSource(); 
3299        default: return super.makeProperty(hash, name);
3300        }
3301
3302      }
3303
3304      @Override
3305      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
3306        switch (hash) {
3307        case 3373707: /*name*/ return new String[] {"string"};
3308        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
3309        case -892481550: /*status*/ return new String[] {"CodeableConcept"};
3310        case -1294005119: /*preferred*/ return new String[] {"boolean"};
3311        case -1613589672: /*language*/ return new String[] {"CodeableConcept"};
3312        case -1326197564: /*domain*/ return new String[] {"CodeableConcept"};
3313        case -507075711: /*jurisdiction*/ return new String[] {"CodeableConcept"};
3314        case -1742128133: /*synonym*/ return new String[] {"@SubstanceDefinition.name"};
3315        case -1840647503: /*translation*/ return new String[] {"@SubstanceDefinition.name"};
3316        case -765289749: /*official*/ return new String[] {};
3317        case -896505829: /*source*/ return new String[] {"Reference"};
3318        default: return super.getTypesForProperty(hash, name);
3319        }
3320
3321      }
3322
3323      @Override
3324      public Base addChild(String name) throws FHIRException {
3325        if (name.equals("name")) {
3326          throw new FHIRException("Cannot call addChild on a primitive type SubstanceDefinition.name.name");
3327        }
3328        else if (name.equals("type")) {
3329          this.type = new CodeableConcept();
3330          return this.type;
3331        }
3332        else if (name.equals("status")) {
3333          this.status = new CodeableConcept();
3334          return this.status;
3335        }
3336        else if (name.equals("preferred")) {
3337          throw new FHIRException("Cannot call addChild on a primitive type SubstanceDefinition.name.preferred");
3338        }
3339        else if (name.equals("language")) {
3340          return addLanguage();
3341        }
3342        else if (name.equals("domain")) {
3343          return addDomain();
3344        }
3345        else if (name.equals("jurisdiction")) {
3346          return addJurisdiction();
3347        }
3348        else if (name.equals("synonym")) {
3349          return addSynonym();
3350        }
3351        else if (name.equals("translation")) {
3352          return addTranslation();
3353        }
3354        else if (name.equals("official")) {
3355          return addOfficial();
3356        }
3357        else if (name.equals("source")) {
3358          return addSource();
3359        }
3360        else
3361          return super.addChild(name);
3362      }
3363
3364      public SubstanceDefinitionNameComponent copy() {
3365        SubstanceDefinitionNameComponent dst = new SubstanceDefinitionNameComponent();
3366        copyValues(dst);
3367        return dst;
3368      }
3369
3370      public void copyValues(SubstanceDefinitionNameComponent dst) {
3371        super.copyValues(dst);
3372        dst.name = name == null ? null : name.copy();
3373        dst.type = type == null ? null : type.copy();
3374        dst.status = status == null ? null : status.copy();
3375        dst.preferred = preferred == null ? null : preferred.copy();
3376        if (language != null) {
3377          dst.language = new ArrayList<CodeableConcept>();
3378          for (CodeableConcept i : language)
3379            dst.language.add(i.copy());
3380        };
3381        if (domain != null) {
3382          dst.domain = new ArrayList<CodeableConcept>();
3383          for (CodeableConcept i : domain)
3384            dst.domain.add(i.copy());
3385        };
3386        if (jurisdiction != null) {
3387          dst.jurisdiction = new ArrayList<CodeableConcept>();
3388          for (CodeableConcept i : jurisdiction)
3389            dst.jurisdiction.add(i.copy());
3390        };
3391        if (synonym != null) {
3392          dst.synonym = new ArrayList<SubstanceDefinitionNameComponent>();
3393          for (SubstanceDefinitionNameComponent i : synonym)
3394            dst.synonym.add(i.copy());
3395        };
3396        if (translation != null) {
3397          dst.translation = new ArrayList<SubstanceDefinitionNameComponent>();
3398          for (SubstanceDefinitionNameComponent i : translation)
3399            dst.translation.add(i.copy());
3400        };
3401        if (official != null) {
3402          dst.official = new ArrayList<SubstanceDefinitionNameOfficialComponent>();
3403          for (SubstanceDefinitionNameOfficialComponent i : official)
3404            dst.official.add(i.copy());
3405        };
3406        if (source != null) {
3407          dst.source = new ArrayList<Reference>();
3408          for (Reference i : source)
3409            dst.source.add(i.copy());
3410        };
3411      }
3412
3413      @Override
3414      public boolean equalsDeep(Base other_) {
3415        if (!super.equalsDeep(other_))
3416          return false;
3417        if (!(other_ instanceof SubstanceDefinitionNameComponent))
3418          return false;
3419        SubstanceDefinitionNameComponent o = (SubstanceDefinitionNameComponent) other_;
3420        return compareDeep(name, o.name, true) && compareDeep(type, o.type, true) && compareDeep(status, o.status, true)
3421           && compareDeep(preferred, o.preferred, true) && compareDeep(language, o.language, true) && compareDeep(domain, o.domain, true)
3422           && compareDeep(jurisdiction, o.jurisdiction, true) && compareDeep(synonym, o.synonym, true) && compareDeep(translation, o.translation, true)
3423           && compareDeep(official, o.official, true) && compareDeep(source, o.source, true);
3424      }
3425
3426      @Override
3427      public boolean equalsShallow(Base other_) {
3428        if (!super.equalsShallow(other_))
3429          return false;
3430        if (!(other_ instanceof SubstanceDefinitionNameComponent))
3431          return false;
3432        SubstanceDefinitionNameComponent o = (SubstanceDefinitionNameComponent) other_;
3433        return compareValues(name, o.name, true) && compareValues(preferred, o.preferred, true);
3434      }
3435
3436      public boolean isEmpty() {
3437        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(name, type, status, preferred
3438          , language, domain, jurisdiction, synonym, translation, official, source);
3439      }
3440
3441  public String fhirType() {
3442    return "SubstanceDefinition.name";
3443
3444  }
3445
3446  }
3447
3448    @Block()
3449    public static class SubstanceDefinitionNameOfficialComponent extends BackboneElement implements IBaseBackboneElement {
3450        /**
3451         * Which authority uses this official name.
3452         */
3453        @Child(name = "authority", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
3454        @Description(shortDefinition="Which authority uses this official name", formalDefinition="Which authority uses this official name." )
3455        protected CodeableConcept authority;
3456
3457        /**
3458         * The status of the official name, for example 'provisional', 'approved'.
3459         */
3460        @Child(name = "status", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
3461        @Description(shortDefinition="The status of the official name, for example 'provisional', 'approved'", formalDefinition="The status of the official name, for example 'provisional', 'approved'." )
3462        protected CodeableConcept status;
3463
3464        /**
3465         * Date of official name change.
3466         */
3467        @Child(name = "date", type = {DateTimeType.class}, order=3, min=0, max=1, modifier=false, summary=true)
3468        @Description(shortDefinition="Date of official name change", formalDefinition="Date of official name change." )
3469        protected DateTimeType date;
3470
3471        private static final long serialVersionUID = -2040011008L;
3472
3473    /**
3474     * Constructor
3475     */
3476      public SubstanceDefinitionNameOfficialComponent() {
3477        super();
3478      }
3479
3480        /**
3481         * @return {@link #authority} (Which authority uses this official name.)
3482         */
3483        public CodeableConcept getAuthority() { 
3484          if (this.authority == null)
3485            if (Configuration.errorOnAutoCreate())
3486              throw new Error("Attempt to auto-create SubstanceDefinitionNameOfficialComponent.authority");
3487            else if (Configuration.doAutoCreate())
3488              this.authority = new CodeableConcept(); // cc
3489          return this.authority;
3490        }
3491
3492        public boolean hasAuthority() { 
3493          return this.authority != null && !this.authority.isEmpty();
3494        }
3495
3496        /**
3497         * @param value {@link #authority} (Which authority uses this official name.)
3498         */
3499        public SubstanceDefinitionNameOfficialComponent setAuthority(CodeableConcept value) { 
3500          this.authority = value;
3501          return this;
3502        }
3503
3504        /**
3505         * @return {@link #status} (The status of the official name, for example 'provisional', 'approved'.)
3506         */
3507        public CodeableConcept getStatus() { 
3508          if (this.status == null)
3509            if (Configuration.errorOnAutoCreate())
3510              throw new Error("Attempt to auto-create SubstanceDefinitionNameOfficialComponent.status");
3511            else if (Configuration.doAutoCreate())
3512              this.status = new CodeableConcept(); // cc
3513          return this.status;
3514        }
3515
3516        public boolean hasStatus() { 
3517          return this.status != null && !this.status.isEmpty();
3518        }
3519
3520        /**
3521         * @param value {@link #status} (The status of the official name, for example 'provisional', 'approved'.)
3522         */
3523        public SubstanceDefinitionNameOfficialComponent setStatus(CodeableConcept value) { 
3524          this.status = value;
3525          return this;
3526        }
3527
3528        /**
3529         * @return {@link #date} (Date of official name change.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
3530         */
3531        public DateTimeType getDateElement() { 
3532          if (this.date == null)
3533            if (Configuration.errorOnAutoCreate())
3534              throw new Error("Attempt to auto-create SubstanceDefinitionNameOfficialComponent.date");
3535            else if (Configuration.doAutoCreate())
3536              this.date = new DateTimeType(); // bb
3537          return this.date;
3538        }
3539
3540        public boolean hasDateElement() { 
3541          return this.date != null && !this.date.isEmpty();
3542        }
3543
3544        public boolean hasDate() { 
3545          return this.date != null && !this.date.isEmpty();
3546        }
3547
3548        /**
3549         * @param value {@link #date} (Date of official name change.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
3550         */
3551        public SubstanceDefinitionNameOfficialComponent setDateElement(DateTimeType value) { 
3552          this.date = value;
3553          return this;
3554        }
3555
3556        /**
3557         * @return Date of official name change.
3558         */
3559        public Date getDate() { 
3560          return this.date == null ? null : this.date.getValue();
3561        }
3562
3563        /**
3564         * @param value Date of official name change.
3565         */
3566        public SubstanceDefinitionNameOfficialComponent setDate(Date value) { 
3567          if (value == null)
3568            this.date = null;
3569          else {
3570            if (this.date == null)
3571              this.date = new DateTimeType();
3572            this.date.setValue(value);
3573          }
3574          return this;
3575        }
3576
3577        protected void listChildren(List<Property> children) {
3578          super.listChildren(children);
3579          children.add(new Property("authority", "CodeableConcept", "Which authority uses this official name.", 0, 1, authority));
3580          children.add(new Property("status", "CodeableConcept", "The status of the official name, for example 'provisional', 'approved'.", 0, 1, status));
3581          children.add(new Property("date", "dateTime", "Date of official name change.", 0, 1, date));
3582        }
3583
3584        @Override
3585        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
3586          switch (_hash) {
3587          case 1475610435: /*authority*/  return new Property("authority", "CodeableConcept", "Which authority uses this official name.", 0, 1, authority);
3588          case -892481550: /*status*/  return new Property("status", "CodeableConcept", "The status of the official name, for example 'provisional', 'approved'.", 0, 1, status);
3589          case 3076014: /*date*/  return new Property("date", "dateTime", "Date of official name change.", 0, 1, date);
3590          default: return super.getNamedProperty(_hash, _name, _checkValid);
3591          }
3592
3593        }
3594
3595      @Override
3596      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
3597        switch (hash) {
3598        case 1475610435: /*authority*/ return this.authority == null ? new Base[0] : new Base[] {this.authority}; // CodeableConcept
3599        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // CodeableConcept
3600        case 3076014: /*date*/ return this.date == null ? new Base[0] : new Base[] {this.date}; // DateTimeType
3601        default: return super.getProperty(hash, name, checkValid);
3602        }
3603
3604      }
3605
3606      @Override
3607      public Base setProperty(int hash, String name, Base value) throws FHIRException {
3608        switch (hash) {
3609        case 1475610435: // authority
3610          this.authority = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
3611          return value;
3612        case -892481550: // status
3613          this.status = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
3614          return value;
3615        case 3076014: // date
3616          this.date = TypeConvertor.castToDateTime(value); // DateTimeType
3617          return value;
3618        default: return super.setProperty(hash, name, value);
3619        }
3620
3621      }
3622
3623      @Override
3624      public Base setProperty(String name, Base value) throws FHIRException {
3625        if (name.equals("authority")) {
3626          this.authority = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
3627        } else if (name.equals("status")) {
3628          this.status = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
3629        } else if (name.equals("date")) {
3630          this.date = TypeConvertor.castToDateTime(value); // DateTimeType
3631        } else
3632          return super.setProperty(name, value);
3633        return value;
3634      }
3635
3636      @Override
3637      public Base makeProperty(int hash, String name) throws FHIRException {
3638        switch (hash) {
3639        case 1475610435:  return getAuthority();
3640        case -892481550:  return getStatus();
3641        case 3076014:  return getDateElement();
3642        default: return super.makeProperty(hash, name);
3643        }
3644
3645      }
3646
3647      @Override
3648      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
3649        switch (hash) {
3650        case 1475610435: /*authority*/ return new String[] {"CodeableConcept"};
3651        case -892481550: /*status*/ return new String[] {"CodeableConcept"};
3652        case 3076014: /*date*/ return new String[] {"dateTime"};
3653        default: return super.getTypesForProperty(hash, name);
3654        }
3655
3656      }
3657
3658      @Override
3659      public Base addChild(String name) throws FHIRException {
3660        if (name.equals("authority")) {
3661          this.authority = new CodeableConcept();
3662          return this.authority;
3663        }
3664        else if (name.equals("status")) {
3665          this.status = new CodeableConcept();
3666          return this.status;
3667        }
3668        else if (name.equals("date")) {
3669          throw new FHIRException("Cannot call addChild on a primitive type SubstanceDefinition.name.official.date");
3670        }
3671        else
3672          return super.addChild(name);
3673      }
3674
3675      public SubstanceDefinitionNameOfficialComponent copy() {
3676        SubstanceDefinitionNameOfficialComponent dst = new SubstanceDefinitionNameOfficialComponent();
3677        copyValues(dst);
3678        return dst;
3679      }
3680
3681      public void copyValues(SubstanceDefinitionNameOfficialComponent dst) {
3682        super.copyValues(dst);
3683        dst.authority = authority == null ? null : authority.copy();
3684        dst.status = status == null ? null : status.copy();
3685        dst.date = date == null ? null : date.copy();
3686      }
3687
3688      @Override
3689      public boolean equalsDeep(Base other_) {
3690        if (!super.equalsDeep(other_))
3691          return false;
3692        if (!(other_ instanceof SubstanceDefinitionNameOfficialComponent))
3693          return false;
3694        SubstanceDefinitionNameOfficialComponent o = (SubstanceDefinitionNameOfficialComponent) other_;
3695        return compareDeep(authority, o.authority, true) && compareDeep(status, o.status, true) && compareDeep(date, o.date, true)
3696          ;
3697      }
3698
3699      @Override
3700      public boolean equalsShallow(Base other_) {
3701        if (!super.equalsShallow(other_))
3702          return false;
3703        if (!(other_ instanceof SubstanceDefinitionNameOfficialComponent))
3704          return false;
3705        SubstanceDefinitionNameOfficialComponent o = (SubstanceDefinitionNameOfficialComponent) other_;
3706        return compareValues(date, o.date, true);
3707      }
3708
3709      public boolean isEmpty() {
3710        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(authority, status, date
3711          );
3712      }
3713
3714  public String fhirType() {
3715    return "SubstanceDefinition.name.official";
3716
3717  }
3718
3719  }
3720
3721    @Block()
3722    public static class SubstanceDefinitionRelationshipComponent extends BackboneElement implements IBaseBackboneElement {
3723        /**
3724         * A pointer to another substance, as a resource or just a representational code.
3725         */
3726        @Child(name = "substanceDefinition", type = {SubstanceDefinition.class, CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
3727        @Description(shortDefinition="A pointer to another substance, as a resource or just a representational code", formalDefinition="A pointer to another substance, as a resource or just a representational code." )
3728        protected DataType substanceDefinition;
3729
3730        /**
3731         * For example "salt to parent", "active moiety", "starting material", "polymorph", "impurity of".
3732         */
3733        @Child(name = "type", type = {CodeableConcept.class}, order=2, min=1, max=1, modifier=false, summary=true)
3734        @Description(shortDefinition="For example \"salt to parent\", \"active moiety\", \"starting material\", \"polymorph\", \"impurity of\"", formalDefinition="For example \"salt to parent\", \"active moiety\", \"starting material\", \"polymorph\", \"impurity of\"." )
3735        protected CodeableConcept type;
3736
3737        /**
3738         * For example where an enzyme strongly bonds with a particular substance, this is a defining relationship for that enzyme, out of several possible substance relationships.
3739         */
3740        @Child(name = "isDefining", type = {BooleanType.class}, order=3, min=0, max=1, modifier=false, summary=true)
3741        @Description(shortDefinition="For example where an enzyme strongly bonds with a particular substance, this is a defining relationship for that enzyme, out of several possible substance relationships", formalDefinition="For example where an enzyme strongly bonds with a particular substance, this is a defining relationship for that enzyme, out of several possible substance relationships." )
3742        protected BooleanType isDefining;
3743
3744        /**
3745         * A numeric factor for the relationship, for instance to express that the salt of a substance has some percentage of the active substance in relation to some other.
3746         */
3747        @Child(name = "amount", type = {Quantity.class, Ratio.class, StringType.class}, order=4, min=0, max=1, modifier=false, summary=true)
3748        @Description(shortDefinition="A numeric factor for the relationship, for instance to express that the salt of a substance has some percentage of the active substance in relation to some other", formalDefinition="A numeric factor for the relationship, for instance to express that the salt of a substance has some percentage of the active substance in relation to some other." )
3749        protected DataType amount;
3750
3751        /**
3752         * For use when the numeric has an uncertain range.
3753         */
3754        @Child(name = "amountRatioHighLimit", type = {Ratio.class}, order=5, min=0, max=1, modifier=false, summary=true)
3755        @Description(shortDefinition="For use when the numeric has an uncertain range", formalDefinition="For use when the numeric has an uncertain range." )
3756        protected Ratio amountRatioHighLimit;
3757
3758        /**
3759         * An operator for the amount, for example "average", "approximately", "less than".
3760         */
3761        @Child(name = "amountType", type = {CodeableConcept.class}, order=6, min=0, max=1, modifier=false, summary=true)
3762        @Description(shortDefinition="An operator for the amount, for example \"average\", \"approximately\", \"less than\"", formalDefinition="An operator for the amount, for example \"average\", \"approximately\", \"less than\"." )
3763        protected CodeableConcept amountType;
3764
3765        /**
3766         * Supporting literature.
3767         */
3768        @Child(name = "source", type = {DocumentReference.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
3769        @Description(shortDefinition="Supporting literature", formalDefinition="Supporting literature." )
3770        protected List<Reference> source;
3771
3772        private static final long serialVersionUID = 447426308L;
3773
3774    /**
3775     * Constructor
3776     */
3777      public SubstanceDefinitionRelationshipComponent() {
3778        super();
3779      }
3780
3781    /**
3782     * Constructor
3783     */
3784      public SubstanceDefinitionRelationshipComponent(CodeableConcept type) {
3785        super();
3786        this.setType(type);
3787      }
3788
3789        /**
3790         * @return {@link #substanceDefinition} (A pointer to another substance, as a resource or just a representational code.)
3791         */
3792        public DataType getSubstanceDefinition() { 
3793          return this.substanceDefinition;
3794        }
3795
3796        /**
3797         * @return {@link #substanceDefinition} (A pointer to another substance, as a resource or just a representational code.)
3798         */
3799        public Reference getSubstanceDefinitionReference() throws FHIRException { 
3800          if (this.substanceDefinition == null)
3801            this.substanceDefinition = new Reference();
3802          if (!(this.substanceDefinition instanceof Reference))
3803            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.substanceDefinition.getClass().getName()+" was encountered");
3804          return (Reference) this.substanceDefinition;
3805        }
3806
3807        public boolean hasSubstanceDefinitionReference() { 
3808          return this != null && this.substanceDefinition instanceof Reference;
3809        }
3810
3811        /**
3812         * @return {@link #substanceDefinition} (A pointer to another substance, as a resource or just a representational code.)
3813         */
3814        public CodeableConcept getSubstanceDefinitionCodeableConcept() throws FHIRException { 
3815          if (this.substanceDefinition == null)
3816            this.substanceDefinition = new CodeableConcept();
3817          if (!(this.substanceDefinition instanceof CodeableConcept))
3818            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.substanceDefinition.getClass().getName()+" was encountered");
3819          return (CodeableConcept) this.substanceDefinition;
3820        }
3821
3822        public boolean hasSubstanceDefinitionCodeableConcept() { 
3823          return this != null && this.substanceDefinition instanceof CodeableConcept;
3824        }
3825
3826        public boolean hasSubstanceDefinition() { 
3827          return this.substanceDefinition != null && !this.substanceDefinition.isEmpty();
3828        }
3829
3830        /**
3831         * @param value {@link #substanceDefinition} (A pointer to another substance, as a resource or just a representational code.)
3832         */
3833        public SubstanceDefinitionRelationshipComponent setSubstanceDefinition(DataType value) { 
3834          if (value != null && !(value instanceof Reference || value instanceof CodeableConcept))
3835            throw new Error("Not the right type for SubstanceDefinition.relationship.substanceDefinition[x]: "+value.fhirType());
3836          this.substanceDefinition = value;
3837          return this;
3838        }
3839
3840        /**
3841         * @return {@link #type} (For example "salt to parent", "active moiety", "starting material", "polymorph", "impurity of".)
3842         */
3843        public CodeableConcept getType() { 
3844          if (this.type == null)
3845            if (Configuration.errorOnAutoCreate())
3846              throw new Error("Attempt to auto-create SubstanceDefinitionRelationshipComponent.type");
3847            else if (Configuration.doAutoCreate())
3848              this.type = new CodeableConcept(); // cc
3849          return this.type;
3850        }
3851
3852        public boolean hasType() { 
3853          return this.type != null && !this.type.isEmpty();
3854        }
3855
3856        /**
3857         * @param value {@link #type} (For example "salt to parent", "active moiety", "starting material", "polymorph", "impurity of".)
3858         */
3859        public SubstanceDefinitionRelationshipComponent setType(CodeableConcept value) { 
3860          this.type = value;
3861          return this;
3862        }
3863
3864        /**
3865         * @return {@link #isDefining} (For example where an enzyme strongly bonds with a particular substance, this is a defining relationship for that enzyme, out of several possible substance relationships.). This is the underlying object with id, value and extensions. The accessor "getIsDefining" gives direct access to the value
3866         */
3867        public BooleanType getIsDefiningElement() { 
3868          if (this.isDefining == null)
3869            if (Configuration.errorOnAutoCreate())
3870              throw new Error("Attempt to auto-create SubstanceDefinitionRelationshipComponent.isDefining");
3871            else if (Configuration.doAutoCreate())
3872              this.isDefining = new BooleanType(); // bb
3873          return this.isDefining;
3874        }
3875
3876        public boolean hasIsDefiningElement() { 
3877          return this.isDefining != null && !this.isDefining.isEmpty();
3878        }
3879
3880        public boolean hasIsDefining() { 
3881          return this.isDefining != null && !this.isDefining.isEmpty();
3882        }
3883
3884        /**
3885         * @param value {@link #isDefining} (For example where an enzyme strongly bonds with a particular substance, this is a defining relationship for that enzyme, out of several possible substance relationships.). This is the underlying object with id, value and extensions. The accessor "getIsDefining" gives direct access to the value
3886         */
3887        public SubstanceDefinitionRelationshipComponent setIsDefiningElement(BooleanType value) { 
3888          this.isDefining = value;
3889          return this;
3890        }
3891
3892        /**
3893         * @return For example where an enzyme strongly bonds with a particular substance, this is a defining relationship for that enzyme, out of several possible substance relationships.
3894         */
3895        public boolean getIsDefining() { 
3896          return this.isDefining == null || this.isDefining.isEmpty() ? false : this.isDefining.getValue();
3897        }
3898
3899        /**
3900         * @param value For example where an enzyme strongly bonds with a particular substance, this is a defining relationship for that enzyme, out of several possible substance relationships.
3901         */
3902        public SubstanceDefinitionRelationshipComponent setIsDefining(boolean value) { 
3903            if (this.isDefining == null)
3904              this.isDefining = new BooleanType();
3905            this.isDefining.setValue(value);
3906          return this;
3907        }
3908
3909        /**
3910         * @return {@link #amount} (A numeric factor for the relationship, for instance to express that the salt of a substance has some percentage of the active substance in relation to some other.)
3911         */
3912        public DataType getAmount() { 
3913          return this.amount;
3914        }
3915
3916        /**
3917         * @return {@link #amount} (A numeric factor for the relationship, for instance to express that the salt of a substance has some percentage of the active substance in relation to some other.)
3918         */
3919        public Quantity getAmountQuantity() throws FHIRException { 
3920          if (this.amount == null)
3921            this.amount = new Quantity();
3922          if (!(this.amount instanceof Quantity))
3923            throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.amount.getClass().getName()+" was encountered");
3924          return (Quantity) this.amount;
3925        }
3926
3927        public boolean hasAmountQuantity() { 
3928          return this != null && this.amount instanceof Quantity;
3929        }
3930
3931        /**
3932         * @return {@link #amount} (A numeric factor for the relationship, for instance to express that the salt of a substance has some percentage of the active substance in relation to some other.)
3933         */
3934        public Ratio getAmountRatio() throws FHIRException { 
3935          if (this.amount == null)
3936            this.amount = new Ratio();
3937          if (!(this.amount instanceof Ratio))
3938            throw new FHIRException("Type mismatch: the type Ratio was expected, but "+this.amount.getClass().getName()+" was encountered");
3939          return (Ratio) this.amount;
3940        }
3941
3942        public boolean hasAmountRatio() { 
3943          return this != null && this.amount instanceof Ratio;
3944        }
3945
3946        /**
3947         * @return {@link #amount} (A numeric factor for the relationship, for instance to express that the salt of a substance has some percentage of the active substance in relation to some other.)
3948         */
3949        public StringType getAmountStringType() throws FHIRException { 
3950          if (this.amount == null)
3951            this.amount = new StringType();
3952          if (!(this.amount instanceof StringType))
3953            throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.amount.getClass().getName()+" was encountered");
3954          return (StringType) this.amount;
3955        }
3956
3957        public boolean hasAmountStringType() { 
3958          return this != null && this.amount instanceof StringType;
3959        }
3960
3961        public boolean hasAmount() { 
3962          return this.amount != null && !this.amount.isEmpty();
3963        }
3964
3965        /**
3966         * @param value {@link #amount} (A numeric factor for the relationship, for instance to express that the salt of a substance has some percentage of the active substance in relation to some other.)
3967         */
3968        public SubstanceDefinitionRelationshipComponent setAmount(DataType value) { 
3969          if (value != null && !(value instanceof Quantity || value instanceof Ratio || value instanceof StringType))
3970            throw new Error("Not the right type for SubstanceDefinition.relationship.amount[x]: "+value.fhirType());
3971          this.amount = value;
3972          return this;
3973        }
3974
3975        /**
3976         * @return {@link #amountRatioHighLimit} (For use when the numeric has an uncertain range.)
3977         */
3978        public Ratio getAmountRatioHighLimit() { 
3979          if (this.amountRatioHighLimit == null)
3980            if (Configuration.errorOnAutoCreate())
3981              throw new Error("Attempt to auto-create SubstanceDefinitionRelationshipComponent.amountRatioHighLimit");
3982            else if (Configuration.doAutoCreate())
3983              this.amountRatioHighLimit = new Ratio(); // cc
3984          return this.amountRatioHighLimit;
3985        }
3986
3987        public boolean hasAmountRatioHighLimit() { 
3988          return this.amountRatioHighLimit != null && !this.amountRatioHighLimit.isEmpty();
3989        }
3990
3991        /**
3992         * @param value {@link #amountRatioHighLimit} (For use when the numeric has an uncertain range.)
3993         */
3994        public SubstanceDefinitionRelationshipComponent setAmountRatioHighLimit(Ratio value) { 
3995          this.amountRatioHighLimit = value;
3996          return this;
3997        }
3998
3999        /**
4000         * @return {@link #amountType} (An operator for the amount, for example "average", "approximately", "less than".)
4001         */
4002        public CodeableConcept getAmountType() { 
4003          if (this.amountType == null)
4004            if (Configuration.errorOnAutoCreate())
4005              throw new Error("Attempt to auto-create SubstanceDefinitionRelationshipComponent.amountType");
4006            else if (Configuration.doAutoCreate())
4007              this.amountType = new CodeableConcept(); // cc
4008          return this.amountType;
4009        }
4010
4011        public boolean hasAmountType() { 
4012          return this.amountType != null && !this.amountType.isEmpty();
4013        }
4014
4015        /**
4016         * @param value {@link #amountType} (An operator for the amount, for example "average", "approximately", "less than".)
4017         */
4018        public SubstanceDefinitionRelationshipComponent setAmountType(CodeableConcept value) { 
4019          this.amountType = value;
4020          return this;
4021        }
4022
4023        /**
4024         * @return {@link #source} (Supporting literature.)
4025         */
4026        public List<Reference> getSource() { 
4027          if (this.source == null)
4028            this.source = new ArrayList<Reference>();
4029          return this.source;
4030        }
4031
4032        /**
4033         * @return Returns a reference to <code>this</code> for easy method chaining
4034         */
4035        public SubstanceDefinitionRelationshipComponent setSource(List<Reference> theSource) { 
4036          this.source = theSource;
4037          return this;
4038        }
4039
4040        public boolean hasSource() { 
4041          if (this.source == null)
4042            return false;
4043          for (Reference item : this.source)
4044            if (!item.isEmpty())
4045              return true;
4046          return false;
4047        }
4048
4049        public Reference addSource() { //3
4050          Reference t = new Reference();
4051          if (this.source == null)
4052            this.source = new ArrayList<Reference>();
4053          this.source.add(t);
4054          return t;
4055        }
4056
4057        public SubstanceDefinitionRelationshipComponent addSource(Reference t) { //3
4058          if (t == null)
4059            return this;
4060          if (this.source == null)
4061            this.source = new ArrayList<Reference>();
4062          this.source.add(t);
4063          return this;
4064        }
4065
4066        /**
4067         * @return The first repetition of repeating field {@link #source}, creating it if it does not already exist {3}
4068         */
4069        public Reference getSourceFirstRep() { 
4070          if (getSource().isEmpty()) {
4071            addSource();
4072          }
4073          return getSource().get(0);
4074        }
4075
4076        protected void listChildren(List<Property> children) {
4077          super.listChildren(children);
4078          children.add(new Property("substanceDefinition[x]", "Reference(SubstanceDefinition)|CodeableConcept", "A pointer to another substance, as a resource or just a representational code.", 0, 1, substanceDefinition));
4079          children.add(new Property("type", "CodeableConcept", "For example \"salt to parent\", \"active moiety\", \"starting material\", \"polymorph\", \"impurity of\".", 0, 1, type));
4080          children.add(new Property("isDefining", "boolean", "For example where an enzyme strongly bonds with a particular substance, this is a defining relationship for that enzyme, out of several possible substance relationships.", 0, 1, isDefining));
4081          children.add(new Property("amount[x]", "Quantity|Ratio|string", "A numeric factor for the relationship, for instance to express that the salt of a substance has some percentage of the active substance in relation to some other.", 0, 1, amount));
4082          children.add(new Property("amountRatioHighLimit", "Ratio", "For use when the numeric has an uncertain range.", 0, 1, amountRatioHighLimit));
4083          children.add(new Property("amountType", "CodeableConcept", "An operator for the amount, for example \"average\", \"approximately\", \"less than\".", 0, 1, amountType));
4084          children.add(new Property("source", "Reference(DocumentReference)", "Supporting literature.", 0, java.lang.Integer.MAX_VALUE, source));
4085        }
4086
4087        @Override
4088        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
4089          switch (_hash) {
4090          case -1767011651: /*substanceDefinition[x]*/  return new Property("substanceDefinition[x]", "Reference(SubstanceDefinition)|CodeableConcept", "A pointer to another substance, as a resource or just a representational code.", 0, 1, substanceDefinition);
4091          case 718195427: /*substanceDefinition*/  return new Property("substanceDefinition[x]", "Reference(SubstanceDefinition)|CodeableConcept", "A pointer to another substance, as a resource or just a representational code.", 0, 1, substanceDefinition);
4092          case -308206680: /*substanceDefinitionReference*/  return new Property("substanceDefinition[x]", "Reference(SubstanceDefinition)", "A pointer to another substance, as a resource or just a representational code.", 0, 1, substanceDefinition);
4093          case -132490690: /*substanceDefinitionCodeableConcept*/  return new Property("substanceDefinition[x]", "CodeableConcept", "A pointer to another substance, as a resource or just a representational code.", 0, 1, substanceDefinition);
4094          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "For example \"salt to parent\", \"active moiety\", \"starting material\", \"polymorph\", \"impurity of\".", 0, 1, type);
4095          case -141812990: /*isDefining*/  return new Property("isDefining", "boolean", "For example where an enzyme strongly bonds with a particular substance, this is a defining relationship for that enzyme, out of several possible substance relationships.", 0, 1, isDefining);
4096          case 646780200: /*amount[x]*/  return new Property("amount[x]", "Quantity|Ratio|string", "A numeric factor for the relationship, for instance to express that the salt of a substance has some percentage of the active substance in relation to some other.", 0, 1, amount);
4097          case -1413853096: /*amount*/  return new Property("amount[x]", "Quantity|Ratio|string", "A numeric factor for the relationship, for instance to express that the salt of a substance has some percentage of the active substance in relation to some other.", 0, 1, amount);
4098          case 1664303363: /*amountQuantity*/  return new Property("amount[x]", "Quantity", "A numeric factor for the relationship, for instance to express that the salt of a substance has some percentage of the active substance in relation to some other.", 0, 1, amount);
4099          case -1223457133: /*amountRatio*/  return new Property("amount[x]", "Ratio", "A numeric factor for the relationship, for instance to express that the salt of a substance has some percentage of the active substance in relation to some other.", 0, 1, amount);
4100          case 773651081: /*amountString*/  return new Property("amount[x]", "string", "A numeric factor for the relationship, for instance to express that the salt of a substance has some percentage of the active substance in relation to some other.", 0, 1, amount);
4101          case -1832648218: /*amountRatioHighLimit*/  return new Property("amountRatioHighLimit", "Ratio", "For use when the numeric has an uncertain range.", 0, 1, amountRatioHighLimit);
4102          case -1424857166: /*amountType*/  return new Property("amountType", "CodeableConcept", "An operator for the amount, for example \"average\", \"approximately\", \"less than\".", 0, 1, amountType);
4103          case -896505829: /*source*/  return new Property("source", "Reference(DocumentReference)", "Supporting literature.", 0, java.lang.Integer.MAX_VALUE, source);
4104          default: return super.getNamedProperty(_hash, _name, _checkValid);
4105          }
4106
4107        }
4108
4109      @Override
4110      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
4111        switch (hash) {
4112        case 718195427: /*substanceDefinition*/ return this.substanceDefinition == null ? new Base[0] : new Base[] {this.substanceDefinition}; // DataType
4113        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
4114        case -141812990: /*isDefining*/ return this.isDefining == null ? new Base[0] : new Base[] {this.isDefining}; // BooleanType
4115        case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : new Base[] {this.amount}; // DataType
4116        case -1832648218: /*amountRatioHighLimit*/ return this.amountRatioHighLimit == null ? new Base[0] : new Base[] {this.amountRatioHighLimit}; // Ratio
4117        case -1424857166: /*amountType*/ return this.amountType == null ? new Base[0] : new Base[] {this.amountType}; // CodeableConcept
4118        case -896505829: /*source*/ return this.source == null ? new Base[0] : this.source.toArray(new Base[this.source.size()]); // Reference
4119        default: return super.getProperty(hash, name, checkValid);
4120        }
4121
4122      }
4123
4124      @Override
4125      public Base setProperty(int hash, String name, Base value) throws FHIRException {
4126        switch (hash) {
4127        case 718195427: // substanceDefinition
4128          this.substanceDefinition = TypeConvertor.castToType(value); // DataType
4129          return value;
4130        case 3575610: // type
4131          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
4132          return value;
4133        case -141812990: // isDefining
4134          this.isDefining = TypeConvertor.castToBoolean(value); // BooleanType
4135          return value;
4136        case -1413853096: // amount
4137          this.amount = TypeConvertor.castToType(value); // DataType
4138          return value;
4139        case -1832648218: // amountRatioHighLimit
4140          this.amountRatioHighLimit = TypeConvertor.castToRatio(value); // Ratio
4141          return value;
4142        case -1424857166: // amountType
4143          this.amountType = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
4144          return value;
4145        case -896505829: // source
4146          this.getSource().add(TypeConvertor.castToReference(value)); // Reference
4147          return value;
4148        default: return super.setProperty(hash, name, value);
4149        }
4150
4151      }
4152
4153      @Override
4154      public Base setProperty(String name, Base value) throws FHIRException {
4155        if (name.equals("substanceDefinition[x]")) {
4156          this.substanceDefinition = TypeConvertor.castToType(value); // DataType
4157        } else if (name.equals("type")) {
4158          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
4159        } else if (name.equals("isDefining")) {
4160          this.isDefining = TypeConvertor.castToBoolean(value); // BooleanType
4161        } else if (name.equals("amount[x]")) {
4162          this.amount = TypeConvertor.castToType(value); // DataType
4163        } else if (name.equals("amountRatioHighLimit")) {
4164          this.amountRatioHighLimit = TypeConvertor.castToRatio(value); // Ratio
4165        } else if (name.equals("amountType")) {
4166          this.amountType = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
4167        } else if (name.equals("source")) {
4168          this.getSource().add(TypeConvertor.castToReference(value));
4169        } else
4170          return super.setProperty(name, value);
4171        return value;
4172      }
4173
4174      @Override
4175      public Base makeProperty(int hash, String name) throws FHIRException {
4176        switch (hash) {
4177        case -1767011651:  return getSubstanceDefinition();
4178        case 718195427:  return getSubstanceDefinition();
4179        case 3575610:  return getType();
4180        case -141812990:  return getIsDefiningElement();
4181        case 646780200:  return getAmount();
4182        case -1413853096:  return getAmount();
4183        case -1832648218:  return getAmountRatioHighLimit();
4184        case -1424857166:  return getAmountType();
4185        case -896505829:  return addSource(); 
4186        default: return super.makeProperty(hash, name);
4187        }
4188
4189      }
4190
4191      @Override
4192      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
4193        switch (hash) {
4194        case 718195427: /*substanceDefinition*/ return new String[] {"Reference", "CodeableConcept"};
4195        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
4196        case -141812990: /*isDefining*/ return new String[] {"boolean"};
4197        case -1413853096: /*amount*/ return new String[] {"Quantity", "Ratio", "string"};
4198        case -1832648218: /*amountRatioHighLimit*/ return new String[] {"Ratio"};
4199        case -1424857166: /*amountType*/ return new String[] {"CodeableConcept"};
4200        case -896505829: /*source*/ return new String[] {"Reference"};
4201        default: return super.getTypesForProperty(hash, name);
4202        }
4203
4204      }
4205
4206      @Override
4207      public Base addChild(String name) throws FHIRException {
4208        if (name.equals("substanceDefinitionReference")) {
4209          this.substanceDefinition = new Reference();
4210          return this.substanceDefinition;
4211        }
4212        else if (name.equals("substanceDefinitionCodeableConcept")) {
4213          this.substanceDefinition = new CodeableConcept();
4214          return this.substanceDefinition;
4215        }
4216        else if (name.equals("type")) {
4217          this.type = new CodeableConcept();
4218          return this.type;
4219        }
4220        else if (name.equals("isDefining")) {
4221          throw new FHIRException("Cannot call addChild on a primitive type SubstanceDefinition.relationship.isDefining");
4222        }
4223        else if (name.equals("amountQuantity")) {
4224          this.amount = new Quantity();
4225          return this.amount;
4226        }
4227        else if (name.equals("amountRatio")) {
4228          this.amount = new Ratio();
4229          return this.amount;
4230        }
4231        else if (name.equals("amountString")) {
4232          this.amount = new StringType();
4233          return this.amount;
4234        }
4235        else if (name.equals("amountRatioHighLimit")) {
4236          this.amountRatioHighLimit = new Ratio();
4237          return this.amountRatioHighLimit;
4238        }
4239        else if (name.equals("amountType")) {
4240          this.amountType = new CodeableConcept();
4241          return this.amountType;
4242        }
4243        else if (name.equals("source")) {
4244          return addSource();
4245        }
4246        else
4247          return super.addChild(name);
4248      }
4249
4250      public SubstanceDefinitionRelationshipComponent copy() {
4251        SubstanceDefinitionRelationshipComponent dst = new SubstanceDefinitionRelationshipComponent();
4252        copyValues(dst);
4253        return dst;
4254      }
4255
4256      public void copyValues(SubstanceDefinitionRelationshipComponent dst) {
4257        super.copyValues(dst);
4258        dst.substanceDefinition = substanceDefinition == null ? null : substanceDefinition.copy();
4259        dst.type = type == null ? null : type.copy();
4260        dst.isDefining = isDefining == null ? null : isDefining.copy();
4261        dst.amount = amount == null ? null : amount.copy();
4262        dst.amountRatioHighLimit = amountRatioHighLimit == null ? null : amountRatioHighLimit.copy();
4263        dst.amountType = amountType == null ? null : amountType.copy();
4264        if (source != null) {
4265          dst.source = new ArrayList<Reference>();
4266          for (Reference i : source)
4267            dst.source.add(i.copy());
4268        };
4269      }
4270
4271      @Override
4272      public boolean equalsDeep(Base other_) {
4273        if (!super.equalsDeep(other_))
4274          return false;
4275        if (!(other_ instanceof SubstanceDefinitionRelationshipComponent))
4276          return false;
4277        SubstanceDefinitionRelationshipComponent o = (SubstanceDefinitionRelationshipComponent) other_;
4278        return compareDeep(substanceDefinition, o.substanceDefinition, true) && compareDeep(type, o.type, true)
4279           && compareDeep(isDefining, o.isDefining, true) && compareDeep(amount, o.amount, true) && compareDeep(amountRatioHighLimit, o.amountRatioHighLimit, true)
4280           && compareDeep(amountType, o.amountType, true) && compareDeep(source, o.source, true);
4281      }
4282
4283      @Override
4284      public boolean equalsShallow(Base other_) {
4285        if (!super.equalsShallow(other_))
4286          return false;
4287        if (!(other_ instanceof SubstanceDefinitionRelationshipComponent))
4288          return false;
4289        SubstanceDefinitionRelationshipComponent o = (SubstanceDefinitionRelationshipComponent) other_;
4290        return compareValues(isDefining, o.isDefining, true);
4291      }
4292
4293      public boolean isEmpty() {
4294        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(substanceDefinition, type
4295          , isDefining, amount, amountRatioHighLimit, amountType, source);
4296      }
4297
4298  public String fhirType() {
4299    return "SubstanceDefinition.relationship";
4300
4301  }
4302
4303  }
4304
4305    @Block()
4306    public static class SubstanceDefinitionSourceMaterialComponent extends BackboneElement implements IBaseBackboneElement {
4307        /**
4308         * A classification that provides the origin of the raw material. Example: cat hair would be an Animal source type.
4309         */
4310        @Child(name = "type", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
4311        @Description(shortDefinition="A classification that provides the origin of the raw material. Example: cat hair would be an Animal source type", formalDefinition="A classification that provides the origin of the raw material. Example: cat hair would be an Animal source type." )
4312        protected CodeableConcept type;
4313
4314        /**
4315         * The genus of an organism, typically referring to the Latin epithet of the genus element of the plant/animal scientific name.
4316         */
4317        @Child(name = "genus", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
4318        @Description(shortDefinition="The genus of an organism, typically referring to the Latin epithet of the genus element of the plant/animal scientific name", formalDefinition="The genus of an organism, typically referring to the Latin epithet of the genus element of the plant/animal scientific name." )
4319        protected CodeableConcept genus;
4320
4321        /**
4322         * The species of an organism, typically referring to the Latin epithet of the species of the plant/animal.
4323         */
4324        @Child(name = "species", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true)
4325        @Description(shortDefinition="The species of an organism, typically referring to the Latin epithet of the species of the plant/animal", formalDefinition="The species of an organism, typically referring to the Latin epithet of the species of the plant/animal." )
4326        protected CodeableConcept species;
4327
4328        /**
4329         * An anatomical origin of the source material within an organism.
4330         */
4331        @Child(name = "part", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=true)
4332        @Description(shortDefinition="An anatomical origin of the source material within an organism", formalDefinition="An anatomical origin of the source material within an organism." )
4333        protected CodeableConcept part;
4334
4335        /**
4336         * The country or countries where the material is harvested.
4337         */
4338        @Child(name = "countryOfOrigin", type = {CodeableConcept.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
4339        @Description(shortDefinition="The country or countries where the material is harvested", formalDefinition="The country or countries where the material is harvested." )
4340        protected List<CodeableConcept> countryOfOrigin;
4341
4342        private static final long serialVersionUID = 569352795L;
4343
4344    /**
4345     * Constructor
4346     */
4347      public SubstanceDefinitionSourceMaterialComponent() {
4348        super();
4349      }
4350
4351        /**
4352         * @return {@link #type} (A classification that provides the origin of the raw material. Example: cat hair would be an Animal source type.)
4353         */
4354        public CodeableConcept getType() { 
4355          if (this.type == null)
4356            if (Configuration.errorOnAutoCreate())
4357              throw new Error("Attempt to auto-create SubstanceDefinitionSourceMaterialComponent.type");
4358            else if (Configuration.doAutoCreate())
4359              this.type = new CodeableConcept(); // cc
4360          return this.type;
4361        }
4362
4363        public boolean hasType() { 
4364          return this.type != null && !this.type.isEmpty();
4365        }
4366
4367        /**
4368         * @param value {@link #type} (A classification that provides the origin of the raw material. Example: cat hair would be an Animal source type.)
4369         */
4370        public SubstanceDefinitionSourceMaterialComponent setType(CodeableConcept value) { 
4371          this.type = value;
4372          return this;
4373        }
4374
4375        /**
4376         * @return {@link #genus} (The genus of an organism, typically referring to the Latin epithet of the genus element of the plant/animal scientific name.)
4377         */
4378        public CodeableConcept getGenus() { 
4379          if (this.genus == null)
4380            if (Configuration.errorOnAutoCreate())
4381              throw new Error("Attempt to auto-create SubstanceDefinitionSourceMaterialComponent.genus");
4382            else if (Configuration.doAutoCreate())
4383              this.genus = new CodeableConcept(); // cc
4384          return this.genus;
4385        }
4386
4387        public boolean hasGenus() { 
4388          return this.genus != null && !this.genus.isEmpty();
4389        }
4390
4391        /**
4392         * @param value {@link #genus} (The genus of an organism, typically referring to the Latin epithet of the genus element of the plant/animal scientific name.)
4393         */
4394        public SubstanceDefinitionSourceMaterialComponent setGenus(CodeableConcept value) { 
4395          this.genus = value;
4396          return this;
4397        }
4398
4399        /**
4400         * @return {@link #species} (The species of an organism, typically referring to the Latin epithet of the species of the plant/animal.)
4401         */
4402        public CodeableConcept getSpecies() { 
4403          if (this.species == null)
4404            if (Configuration.errorOnAutoCreate())
4405              throw new Error("Attempt to auto-create SubstanceDefinitionSourceMaterialComponent.species");
4406            else if (Configuration.doAutoCreate())
4407              this.species = new CodeableConcept(); // cc
4408          return this.species;
4409        }
4410
4411        public boolean hasSpecies() { 
4412          return this.species != null && !this.species.isEmpty();
4413        }
4414
4415        /**
4416         * @param value {@link #species} (The species of an organism, typically referring to the Latin epithet of the species of the plant/animal.)
4417         */
4418        public SubstanceDefinitionSourceMaterialComponent setSpecies(CodeableConcept value) { 
4419          this.species = value;
4420          return this;
4421        }
4422
4423        /**
4424         * @return {@link #part} (An anatomical origin of the source material within an organism.)
4425         */
4426        public CodeableConcept getPart() { 
4427          if (this.part == null)
4428            if (Configuration.errorOnAutoCreate())
4429              throw new Error("Attempt to auto-create SubstanceDefinitionSourceMaterialComponent.part");
4430            else if (Configuration.doAutoCreate())
4431              this.part = new CodeableConcept(); // cc
4432          return this.part;
4433        }
4434
4435        public boolean hasPart() { 
4436          return this.part != null && !this.part.isEmpty();
4437        }
4438
4439        /**
4440         * @param value {@link #part} (An anatomical origin of the source material within an organism.)
4441         */
4442        public SubstanceDefinitionSourceMaterialComponent setPart(CodeableConcept value) { 
4443          this.part = value;
4444          return this;
4445        }
4446
4447        /**
4448         * @return {@link #countryOfOrigin} (The country or countries where the material is harvested.)
4449         */
4450        public List<CodeableConcept> getCountryOfOrigin() { 
4451          if (this.countryOfOrigin == null)
4452            this.countryOfOrigin = new ArrayList<CodeableConcept>();
4453          return this.countryOfOrigin;
4454        }
4455
4456        /**
4457         * @return Returns a reference to <code>this</code> for easy method chaining
4458         */
4459        public SubstanceDefinitionSourceMaterialComponent setCountryOfOrigin(List<CodeableConcept> theCountryOfOrigin) { 
4460          this.countryOfOrigin = theCountryOfOrigin;
4461          return this;
4462        }
4463
4464        public boolean hasCountryOfOrigin() { 
4465          if (this.countryOfOrigin == null)
4466            return false;
4467          for (CodeableConcept item : this.countryOfOrigin)
4468            if (!item.isEmpty())
4469              return true;
4470          return false;
4471        }
4472
4473        public CodeableConcept addCountryOfOrigin() { //3
4474          CodeableConcept t = new CodeableConcept();
4475          if (this.countryOfOrigin == null)
4476            this.countryOfOrigin = new ArrayList<CodeableConcept>();
4477          this.countryOfOrigin.add(t);
4478          return t;
4479        }
4480
4481        public SubstanceDefinitionSourceMaterialComponent addCountryOfOrigin(CodeableConcept t) { //3
4482          if (t == null)
4483            return this;
4484          if (this.countryOfOrigin == null)
4485            this.countryOfOrigin = new ArrayList<CodeableConcept>();
4486          this.countryOfOrigin.add(t);
4487          return this;
4488        }
4489
4490        /**
4491         * @return The first repetition of repeating field {@link #countryOfOrigin}, creating it if it does not already exist {3}
4492         */
4493        public CodeableConcept getCountryOfOriginFirstRep() { 
4494          if (getCountryOfOrigin().isEmpty()) {
4495            addCountryOfOrigin();
4496          }
4497          return getCountryOfOrigin().get(0);
4498        }
4499
4500        protected void listChildren(List<Property> children) {
4501          super.listChildren(children);
4502          children.add(new Property("type", "CodeableConcept", "A classification that provides the origin of the raw material. Example: cat hair would be an Animal source type.", 0, 1, type));
4503          children.add(new Property("genus", "CodeableConcept", "The genus of an organism, typically referring to the Latin epithet of the genus element of the plant/animal scientific name.", 0, 1, genus));
4504          children.add(new Property("species", "CodeableConcept", "The species of an organism, typically referring to the Latin epithet of the species of the plant/animal.", 0, 1, species));
4505          children.add(new Property("part", "CodeableConcept", "An anatomical origin of the source material within an organism.", 0, 1, part));
4506          children.add(new Property("countryOfOrigin", "CodeableConcept", "The country or countries where the material is harvested.", 0, java.lang.Integer.MAX_VALUE, countryOfOrigin));
4507        }
4508
4509        @Override
4510        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
4511          switch (_hash) {
4512          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "A classification that provides the origin of the raw material. Example: cat hair would be an Animal source type.", 0, 1, type);
4513          case 98241006: /*genus*/  return new Property("genus", "CodeableConcept", "The genus of an organism, typically referring to the Latin epithet of the genus element of the plant/animal scientific name.", 0, 1, genus);
4514          case -2008465092: /*species*/  return new Property("species", "CodeableConcept", "The species of an organism, typically referring to the Latin epithet of the species of the plant/animal.", 0, 1, species);
4515          case 3433459: /*part*/  return new Property("part", "CodeableConcept", "An anatomical origin of the source material within an organism.", 0, 1, part);
4516          case 57176467: /*countryOfOrigin*/  return new Property("countryOfOrigin", "CodeableConcept", "The country or countries where the material is harvested.", 0, java.lang.Integer.MAX_VALUE, countryOfOrigin);
4517          default: return super.getNamedProperty(_hash, _name, _checkValid);
4518          }
4519
4520        }
4521
4522      @Override
4523      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
4524        switch (hash) {
4525        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
4526        case 98241006: /*genus*/ return this.genus == null ? new Base[0] : new Base[] {this.genus}; // CodeableConcept
4527        case -2008465092: /*species*/ return this.species == null ? new Base[0] : new Base[] {this.species}; // CodeableConcept
4528        case 3433459: /*part*/ return this.part == null ? new Base[0] : new Base[] {this.part}; // CodeableConcept
4529        case 57176467: /*countryOfOrigin*/ return this.countryOfOrigin == null ? new Base[0] : this.countryOfOrigin.toArray(new Base[this.countryOfOrigin.size()]); // CodeableConcept
4530        default: return super.getProperty(hash, name, checkValid);
4531        }
4532
4533      }
4534
4535      @Override
4536      public Base setProperty(int hash, String name, Base value) throws FHIRException {
4537        switch (hash) {
4538        case 3575610: // type
4539          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
4540          return value;
4541        case 98241006: // genus
4542          this.genus = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
4543          return value;
4544        case -2008465092: // species
4545          this.species = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
4546          return value;
4547        case 3433459: // part
4548          this.part = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
4549          return value;
4550        case 57176467: // countryOfOrigin
4551          this.getCountryOfOrigin().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
4552          return value;
4553        default: return super.setProperty(hash, name, value);
4554        }
4555
4556      }
4557
4558      @Override
4559      public Base setProperty(String name, Base value) throws FHIRException {
4560        if (name.equals("type")) {
4561          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
4562        } else if (name.equals("genus")) {
4563          this.genus = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
4564        } else if (name.equals("species")) {
4565          this.species = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
4566        } else if (name.equals("part")) {
4567          this.part = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
4568        } else if (name.equals("countryOfOrigin")) {
4569          this.getCountryOfOrigin().add(TypeConvertor.castToCodeableConcept(value));
4570        } else
4571          return super.setProperty(name, value);
4572        return value;
4573      }
4574
4575      @Override
4576      public Base makeProperty(int hash, String name) throws FHIRException {
4577        switch (hash) {
4578        case 3575610:  return getType();
4579        case 98241006:  return getGenus();
4580        case -2008465092:  return getSpecies();
4581        case 3433459:  return getPart();
4582        case 57176467:  return addCountryOfOrigin(); 
4583        default: return super.makeProperty(hash, name);
4584        }
4585
4586      }
4587
4588      @Override
4589      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
4590        switch (hash) {
4591        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
4592        case 98241006: /*genus*/ return new String[] {"CodeableConcept"};
4593        case -2008465092: /*species*/ return new String[] {"CodeableConcept"};
4594        case 3433459: /*part*/ return new String[] {"CodeableConcept"};
4595        case 57176467: /*countryOfOrigin*/ return new String[] {"CodeableConcept"};
4596        default: return super.getTypesForProperty(hash, name);
4597        }
4598
4599      }
4600
4601      @Override
4602      public Base addChild(String name) throws FHIRException {
4603        if (name.equals("type")) {
4604          this.type = new CodeableConcept();
4605          return this.type;
4606        }
4607        else if (name.equals("genus")) {
4608          this.genus = new CodeableConcept();
4609          return this.genus;
4610        }
4611        else if (name.equals("species")) {
4612          this.species = new CodeableConcept();
4613          return this.species;
4614        }
4615        else if (name.equals("part")) {
4616          this.part = new CodeableConcept();
4617          return this.part;
4618        }
4619        else if (name.equals("countryOfOrigin")) {
4620          return addCountryOfOrigin();
4621        }
4622        else
4623          return super.addChild(name);
4624      }
4625
4626      public SubstanceDefinitionSourceMaterialComponent copy() {
4627        SubstanceDefinitionSourceMaterialComponent dst = new SubstanceDefinitionSourceMaterialComponent();
4628        copyValues(dst);
4629        return dst;
4630      }
4631
4632      public void copyValues(SubstanceDefinitionSourceMaterialComponent dst) {
4633        super.copyValues(dst);
4634        dst.type = type == null ? null : type.copy();
4635        dst.genus = genus == null ? null : genus.copy();
4636        dst.species = species == null ? null : species.copy();
4637        dst.part = part == null ? null : part.copy();
4638        if (countryOfOrigin != null) {
4639          dst.countryOfOrigin = new ArrayList<CodeableConcept>();
4640          for (CodeableConcept i : countryOfOrigin)
4641            dst.countryOfOrigin.add(i.copy());
4642        };
4643      }
4644
4645      @Override
4646      public boolean equalsDeep(Base other_) {
4647        if (!super.equalsDeep(other_))
4648          return false;
4649        if (!(other_ instanceof SubstanceDefinitionSourceMaterialComponent))
4650          return false;
4651        SubstanceDefinitionSourceMaterialComponent o = (SubstanceDefinitionSourceMaterialComponent) other_;
4652        return compareDeep(type, o.type, true) && compareDeep(genus, o.genus, true) && compareDeep(species, o.species, true)
4653           && compareDeep(part, o.part, true) && compareDeep(countryOfOrigin, o.countryOfOrigin, true);
4654      }
4655
4656      @Override
4657      public boolean equalsShallow(Base other_) {
4658        if (!super.equalsShallow(other_))
4659          return false;
4660        if (!(other_ instanceof SubstanceDefinitionSourceMaterialComponent))
4661          return false;
4662        SubstanceDefinitionSourceMaterialComponent o = (SubstanceDefinitionSourceMaterialComponent) other_;
4663        return true;
4664      }
4665
4666      public boolean isEmpty() {
4667        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, genus, species, part
4668          , countryOfOrigin);
4669      }
4670
4671  public String fhirType() {
4672    return "SubstanceDefinition.sourceMaterial";
4673
4674  }
4675
4676  }
4677
4678    /**
4679     * Identifier by which this substance is known.
4680     */
4681    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
4682    @Description(shortDefinition="Identifier by which this substance is known", formalDefinition="Identifier by which this substance is known." )
4683    protected List<Identifier> identifier;
4684
4685    /**
4686     * A business level identifier of the substance.
4687     */
4688    @Child(name = "version", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true)
4689    @Description(shortDefinition="A business level identifier of the substance", formalDefinition="A business level identifier of the substance." )
4690    protected StringType version;
4691
4692    /**
4693     * Status of substance within the catalogue e.g. approved.
4694     */
4695    @Child(name = "status", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
4696    @Description(shortDefinition="Status of substance within the catalogue e.g. approved", formalDefinition="Status of substance within the catalogue e.g. approved." )
4697    protected CodeableConcept status;
4698
4699    /**
4700     * A high level categorization, e.g. polymer or nucleic acid, or food, chemical, biological, or a lower level such as the general types of polymer (linear or branch chain) or type of impurity (process related or contaminant).
4701     */
4702    @Child(name = "classification", type = {CodeableConcept.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
4703    @Description(shortDefinition="A high level categorization, e.g. polymer or nucleic acid, or food, chemical, biological, or a lower level such as the general types of polymer (linear or branch chain) or type of impurity (process related or contaminant)", formalDefinition="A high level categorization, e.g. polymer or nucleic acid, or food, chemical, biological, or a lower level such as the general types of polymer (linear or branch chain) or type of impurity (process related or contaminant)." )
4704    protected List<CodeableConcept> classification;
4705
4706    /**
4707     * If the substance applies to only human or veterinary use.
4708     */
4709    @Child(name = "domain", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=true)
4710    @Description(shortDefinition="If the substance applies to only human or veterinary use", formalDefinition="If the substance applies to only human or veterinary use." )
4711    protected CodeableConcept domain;
4712
4713    /**
4714     * The quality standard, established benchmark, to which substance complies (e.g. USP/NF, Ph. Eur, JP, BP, Company Standard).
4715     */
4716    @Child(name = "grade", type = {CodeableConcept.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
4717    @Description(shortDefinition="The quality standard, established benchmark, to which substance complies (e.g. USP/NF, Ph. Eur, JP, BP, Company Standard)", formalDefinition="The quality standard, established benchmark, to which substance complies (e.g. USP/NF, Ph. Eur, JP, BP, Company Standard)." )
4718    protected List<CodeableConcept> grade;
4719
4720    /**
4721     * Textual description of the substance.
4722     */
4723    @Child(name = "description", type = {MarkdownType.class}, order=6, min=0, max=1, modifier=false, summary=true)
4724    @Description(shortDefinition="Textual description of the substance", formalDefinition="Textual description of the substance." )
4725    protected MarkdownType description;
4726
4727    /**
4728     * Supporting literature.
4729     */
4730    @Child(name = "informationSource", type = {Citation.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
4731    @Description(shortDefinition="Supporting literature", formalDefinition="Supporting literature." )
4732    protected List<Reference> informationSource;
4733
4734    /**
4735     * Textual comment about the substance's catalogue or registry record.
4736     */
4737    @Child(name = "note", type = {Annotation.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
4738    @Description(shortDefinition="Textual comment about the substance's catalogue or registry record", formalDefinition="Textual comment about the substance's catalogue or registry record." )
4739    protected List<Annotation> note;
4740
4741    /**
4742     * A company that makes this substance.
4743     */
4744    @Child(name = "manufacturer", type = {Organization.class}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
4745    @Description(shortDefinition="A company that makes this substance", formalDefinition="A company that makes this substance." )
4746    protected List<Reference> manufacturer;
4747
4748    /**
4749     * A company that supplies this substance.
4750     */
4751    @Child(name = "supplier", type = {Organization.class}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
4752    @Description(shortDefinition="A company that supplies this substance", formalDefinition="A company that supplies this substance." )
4753    protected List<Reference> supplier;
4754
4755    /**
4756     * Moiety, for structural modifications.
4757     */
4758    @Child(name = "moiety", type = {}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
4759    @Description(shortDefinition="Moiety, for structural modifications", formalDefinition="Moiety, for structural modifications." )
4760    protected List<SubstanceDefinitionMoietyComponent> moiety;
4761
4762    /**
4763     * General specifications for this substance.
4764     */
4765    @Child(name = "property", type = {}, order=12, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
4766    @Description(shortDefinition="General specifications for this substance", formalDefinition="General specifications for this substance." )
4767    protected List<SubstanceDefinitionPropertyComponent> property;
4768
4769    /**
4770     * General information detailing this substance.
4771     */
4772    @Child(name = "referenceInformation", type = {SubstanceReferenceInformation.class}, order=13, min=0, max=1, modifier=false, summary=true)
4773    @Description(shortDefinition="General information detailing this substance", formalDefinition="General information detailing this substance." )
4774    protected Reference referenceInformation;
4775
4776    /**
4777     * The molecular weight or weight range (for proteins, polymers or nucleic acids).
4778     */
4779    @Child(name = "molecularWeight", type = {}, order=14, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
4780    @Description(shortDefinition="The molecular weight or weight range (for proteins, polymers or nucleic acids)", formalDefinition="The molecular weight or weight range (for proteins, polymers or nucleic acids)." )
4781    protected List<SubstanceDefinitionMolecularWeightComponent> molecularWeight;
4782
4783    /**
4784     * Structural information.
4785     */
4786    @Child(name = "structure", type = {}, order=15, min=0, max=1, modifier=false, summary=true)
4787    @Description(shortDefinition="Structural information", formalDefinition="Structural information." )
4788    protected SubstanceDefinitionStructureComponent structure;
4789
4790    /**
4791     * Codes associated with the substance.
4792     */
4793    @Child(name = "code", type = {}, order=16, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
4794    @Description(shortDefinition="Codes associated with the substance", formalDefinition="Codes associated with the substance." )
4795    protected List<SubstanceDefinitionCodeComponent> code;
4796
4797    /**
4798     * Names applicable to this substance.
4799     */
4800    @Child(name = "name", type = {}, order=17, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
4801    @Description(shortDefinition="Names applicable to this substance", formalDefinition="Names applicable to this substance." )
4802    protected List<SubstanceDefinitionNameComponent> name;
4803
4804    /**
4805     * A link between this substance and another, with details of the relationship.
4806     */
4807    @Child(name = "relationship", type = {}, order=18, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
4808    @Description(shortDefinition="A link between this substance and another, with details of the relationship", formalDefinition="A link between this substance and another, with details of the relationship." )
4809    protected List<SubstanceDefinitionRelationshipComponent> relationship;
4810
4811    /**
4812     * Data items specific to nucleic acids.
4813     */
4814    @Child(name = "nucleicAcid", type = {SubstanceNucleicAcid.class}, order=19, min=0, max=1, modifier=false, summary=true)
4815    @Description(shortDefinition="Data items specific to nucleic acids", formalDefinition="Data items specific to nucleic acids." )
4816    protected Reference nucleicAcid;
4817
4818    /**
4819     * Data items specific to polymers.
4820     */
4821    @Child(name = "polymer", type = {SubstancePolymer.class}, order=20, min=0, max=1, modifier=false, summary=true)
4822    @Description(shortDefinition="Data items specific to polymers", formalDefinition="Data items specific to polymers." )
4823    protected Reference polymer;
4824
4825    /**
4826     * Data items specific to proteins.
4827     */
4828    @Child(name = "protein", type = {SubstanceProtein.class}, order=21, min=0, max=1, modifier=false, summary=true)
4829    @Description(shortDefinition="Data items specific to proteins", formalDefinition="Data items specific to proteins." )
4830    protected Reference protein;
4831
4832    /**
4833     * Material or taxonomic/anatomical source for the substance.
4834     */
4835    @Child(name = "sourceMaterial", type = {}, order=22, min=0, max=1, modifier=false, summary=true)
4836    @Description(shortDefinition="Material or taxonomic/anatomical source for the substance", formalDefinition="Material or taxonomic/anatomical source for the substance." )
4837    protected SubstanceDefinitionSourceMaterialComponent sourceMaterial;
4838
4839    private static final long serialVersionUID = 23576785L;
4840
4841  /**
4842   * Constructor
4843   */
4844    public SubstanceDefinition() {
4845      super();
4846    }
4847
4848    /**
4849     * @return {@link #identifier} (Identifier by which this substance is known.)
4850     */
4851    public List<Identifier> getIdentifier() { 
4852      if (this.identifier == null)
4853        this.identifier = new ArrayList<Identifier>();
4854      return this.identifier;
4855    }
4856
4857    /**
4858     * @return Returns a reference to <code>this</code> for easy method chaining
4859     */
4860    public SubstanceDefinition setIdentifier(List<Identifier> theIdentifier) { 
4861      this.identifier = theIdentifier;
4862      return this;
4863    }
4864
4865    public boolean hasIdentifier() { 
4866      if (this.identifier == null)
4867        return false;
4868      for (Identifier item : this.identifier)
4869        if (!item.isEmpty())
4870          return true;
4871      return false;
4872    }
4873
4874    public Identifier addIdentifier() { //3
4875      Identifier t = new Identifier();
4876      if (this.identifier == null)
4877        this.identifier = new ArrayList<Identifier>();
4878      this.identifier.add(t);
4879      return t;
4880    }
4881
4882    public SubstanceDefinition addIdentifier(Identifier t) { //3
4883      if (t == null)
4884        return this;
4885      if (this.identifier == null)
4886        this.identifier = new ArrayList<Identifier>();
4887      this.identifier.add(t);
4888      return this;
4889    }
4890
4891    /**
4892     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist {3}
4893     */
4894    public Identifier getIdentifierFirstRep() { 
4895      if (getIdentifier().isEmpty()) {
4896        addIdentifier();
4897      }
4898      return getIdentifier().get(0);
4899    }
4900
4901    /**
4902     * @return {@link #version} (A business level identifier of the substance.). This is the underlying object with id, value and extensions. The accessor "getVersion" gives direct access to the value
4903     */
4904    public StringType getVersionElement() { 
4905      if (this.version == null)
4906        if (Configuration.errorOnAutoCreate())
4907          throw new Error("Attempt to auto-create SubstanceDefinition.version");
4908        else if (Configuration.doAutoCreate())
4909          this.version = new StringType(); // bb
4910      return this.version;
4911    }
4912
4913    public boolean hasVersionElement() { 
4914      return this.version != null && !this.version.isEmpty();
4915    }
4916
4917    public boolean hasVersion() { 
4918      return this.version != null && !this.version.isEmpty();
4919    }
4920
4921    /**
4922     * @param value {@link #version} (A business level identifier of the substance.). This is the underlying object with id, value and extensions. The accessor "getVersion" gives direct access to the value
4923     */
4924    public SubstanceDefinition setVersionElement(StringType value) { 
4925      this.version = value;
4926      return this;
4927    }
4928
4929    /**
4930     * @return A business level identifier of the substance.
4931     */
4932    public String getVersion() { 
4933      return this.version == null ? null : this.version.getValue();
4934    }
4935
4936    /**
4937     * @param value A business level identifier of the substance.
4938     */
4939    public SubstanceDefinition setVersion(String value) { 
4940      if (Utilities.noString(value))
4941        this.version = null;
4942      else {
4943        if (this.version == null)
4944          this.version = new StringType();
4945        this.version.setValue(value);
4946      }
4947      return this;
4948    }
4949
4950    /**
4951     * @return {@link #status} (Status of substance within the catalogue e.g. approved.)
4952     */
4953    public CodeableConcept getStatus() { 
4954      if (this.status == null)
4955        if (Configuration.errorOnAutoCreate())
4956          throw new Error("Attempt to auto-create SubstanceDefinition.status");
4957        else if (Configuration.doAutoCreate())
4958          this.status = new CodeableConcept(); // cc
4959      return this.status;
4960    }
4961
4962    public boolean hasStatus() { 
4963      return this.status != null && !this.status.isEmpty();
4964    }
4965
4966    /**
4967     * @param value {@link #status} (Status of substance within the catalogue e.g. approved.)
4968     */
4969    public SubstanceDefinition setStatus(CodeableConcept value) { 
4970      this.status = value;
4971      return this;
4972    }
4973
4974    /**
4975     * @return {@link #classification} (A high level categorization, e.g. polymer or nucleic acid, or food, chemical, biological, or a lower level such as the general types of polymer (linear or branch chain) or type of impurity (process related or contaminant).)
4976     */
4977    public List<CodeableConcept> getClassification() { 
4978      if (this.classification == null)
4979        this.classification = new ArrayList<CodeableConcept>();
4980      return this.classification;
4981    }
4982
4983    /**
4984     * @return Returns a reference to <code>this</code> for easy method chaining
4985     */
4986    public SubstanceDefinition setClassification(List<CodeableConcept> theClassification) { 
4987      this.classification = theClassification;
4988      return this;
4989    }
4990
4991    public boolean hasClassification() { 
4992      if (this.classification == null)
4993        return false;
4994      for (CodeableConcept item : this.classification)
4995        if (!item.isEmpty())
4996          return true;
4997      return false;
4998    }
4999
5000    public CodeableConcept addClassification() { //3
5001      CodeableConcept t = new CodeableConcept();
5002      if (this.classification == null)
5003        this.classification = new ArrayList<CodeableConcept>();
5004      this.classification.add(t);
5005      return t;
5006    }
5007
5008    public SubstanceDefinition addClassification(CodeableConcept t) { //3
5009      if (t == null)
5010        return this;
5011      if (this.classification == null)
5012        this.classification = new ArrayList<CodeableConcept>();
5013      this.classification.add(t);
5014      return this;
5015    }
5016
5017    /**
5018     * @return The first repetition of repeating field {@link #classification}, creating it if it does not already exist {3}
5019     */
5020    public CodeableConcept getClassificationFirstRep() { 
5021      if (getClassification().isEmpty()) {
5022        addClassification();
5023      }
5024      return getClassification().get(0);
5025    }
5026
5027    /**
5028     * @return {@link #domain} (If the substance applies to only human or veterinary use.)
5029     */
5030    public CodeableConcept getDomain() { 
5031      if (this.domain == null)
5032        if (Configuration.errorOnAutoCreate())
5033          throw new Error("Attempt to auto-create SubstanceDefinition.domain");
5034        else if (Configuration.doAutoCreate())
5035          this.domain = new CodeableConcept(); // cc
5036      return this.domain;
5037    }
5038
5039    public boolean hasDomain() { 
5040      return this.domain != null && !this.domain.isEmpty();
5041    }
5042
5043    /**
5044     * @param value {@link #domain} (If the substance applies to only human or veterinary use.)
5045     */
5046    public SubstanceDefinition setDomain(CodeableConcept value) { 
5047      this.domain = value;
5048      return this;
5049    }
5050
5051    /**
5052     * @return {@link #grade} (The quality standard, established benchmark, to which substance complies (e.g. USP/NF, Ph. Eur, JP, BP, Company Standard).)
5053     */
5054    public List<CodeableConcept> getGrade() { 
5055      if (this.grade == null)
5056        this.grade = new ArrayList<CodeableConcept>();
5057      return this.grade;
5058    }
5059
5060    /**
5061     * @return Returns a reference to <code>this</code> for easy method chaining
5062     */
5063    public SubstanceDefinition setGrade(List<CodeableConcept> theGrade) { 
5064      this.grade = theGrade;
5065      return this;
5066    }
5067
5068    public boolean hasGrade() { 
5069      if (this.grade == null)
5070        return false;
5071      for (CodeableConcept item : this.grade)
5072        if (!item.isEmpty())
5073          return true;
5074      return false;
5075    }
5076
5077    public CodeableConcept addGrade() { //3
5078      CodeableConcept t = new CodeableConcept();
5079      if (this.grade == null)
5080        this.grade = new ArrayList<CodeableConcept>();
5081      this.grade.add(t);
5082      return t;
5083    }
5084
5085    public SubstanceDefinition addGrade(CodeableConcept t) { //3
5086      if (t == null)
5087        return this;
5088      if (this.grade == null)
5089        this.grade = new ArrayList<CodeableConcept>();
5090      this.grade.add(t);
5091      return this;
5092    }
5093
5094    /**
5095     * @return The first repetition of repeating field {@link #grade}, creating it if it does not already exist {3}
5096     */
5097    public CodeableConcept getGradeFirstRep() { 
5098      if (getGrade().isEmpty()) {
5099        addGrade();
5100      }
5101      return getGrade().get(0);
5102    }
5103
5104    /**
5105     * @return {@link #description} (Textual description of the substance.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
5106     */
5107    public MarkdownType getDescriptionElement() { 
5108      if (this.description == null)
5109        if (Configuration.errorOnAutoCreate())
5110          throw new Error("Attempt to auto-create SubstanceDefinition.description");
5111        else if (Configuration.doAutoCreate())
5112          this.description = new MarkdownType(); // bb
5113      return this.description;
5114    }
5115
5116    public boolean hasDescriptionElement() { 
5117      return this.description != null && !this.description.isEmpty();
5118    }
5119
5120    public boolean hasDescription() { 
5121      return this.description != null && !this.description.isEmpty();
5122    }
5123
5124    /**
5125     * @param value {@link #description} (Textual description of the substance.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
5126     */
5127    public SubstanceDefinition setDescriptionElement(MarkdownType value) { 
5128      this.description = value;
5129      return this;
5130    }
5131
5132    /**
5133     * @return Textual description of the substance.
5134     */
5135    public String getDescription() { 
5136      return this.description == null ? null : this.description.getValue();
5137    }
5138
5139    /**
5140     * @param value Textual description of the substance.
5141     */
5142    public SubstanceDefinition setDescription(String value) { 
5143      if (value == null)
5144        this.description = null;
5145      else {
5146        if (this.description == null)
5147          this.description = new MarkdownType();
5148        this.description.setValue(value);
5149      }
5150      return this;
5151    }
5152
5153    /**
5154     * @return {@link #informationSource} (Supporting literature.)
5155     */
5156    public List<Reference> getInformationSource() { 
5157      if (this.informationSource == null)
5158        this.informationSource = new ArrayList<Reference>();
5159      return this.informationSource;
5160    }
5161
5162    /**
5163     * @return Returns a reference to <code>this</code> for easy method chaining
5164     */
5165    public SubstanceDefinition setInformationSource(List<Reference> theInformationSource) { 
5166      this.informationSource = theInformationSource;
5167      return this;
5168    }
5169
5170    public boolean hasInformationSource() { 
5171      if (this.informationSource == null)
5172        return false;
5173      for (Reference item : this.informationSource)
5174        if (!item.isEmpty())
5175          return true;
5176      return false;
5177    }
5178
5179    public Reference addInformationSource() { //3
5180      Reference t = new Reference();
5181      if (this.informationSource == null)
5182        this.informationSource = new ArrayList<Reference>();
5183      this.informationSource.add(t);
5184      return t;
5185    }
5186
5187    public SubstanceDefinition addInformationSource(Reference t) { //3
5188      if (t == null)
5189        return this;
5190      if (this.informationSource == null)
5191        this.informationSource = new ArrayList<Reference>();
5192      this.informationSource.add(t);
5193      return this;
5194    }
5195
5196    /**
5197     * @return The first repetition of repeating field {@link #informationSource}, creating it if it does not already exist {3}
5198     */
5199    public Reference getInformationSourceFirstRep() { 
5200      if (getInformationSource().isEmpty()) {
5201        addInformationSource();
5202      }
5203      return getInformationSource().get(0);
5204    }
5205
5206    /**
5207     * @return {@link #note} (Textual comment about the substance's catalogue or registry record.)
5208     */
5209    public List<Annotation> getNote() { 
5210      if (this.note == null)
5211        this.note = new ArrayList<Annotation>();
5212      return this.note;
5213    }
5214
5215    /**
5216     * @return Returns a reference to <code>this</code> for easy method chaining
5217     */
5218    public SubstanceDefinition setNote(List<Annotation> theNote) { 
5219      this.note = theNote;
5220      return this;
5221    }
5222
5223    public boolean hasNote() { 
5224      if (this.note == null)
5225        return false;
5226      for (Annotation item : this.note)
5227        if (!item.isEmpty())
5228          return true;
5229      return false;
5230    }
5231
5232    public Annotation addNote() { //3
5233      Annotation t = new Annotation();
5234      if (this.note == null)
5235        this.note = new ArrayList<Annotation>();
5236      this.note.add(t);
5237      return t;
5238    }
5239
5240    public SubstanceDefinition addNote(Annotation t) { //3
5241      if (t == null)
5242        return this;
5243      if (this.note == null)
5244        this.note = new ArrayList<Annotation>();
5245      this.note.add(t);
5246      return this;
5247    }
5248
5249    /**
5250     * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist {3}
5251     */
5252    public Annotation getNoteFirstRep() { 
5253      if (getNote().isEmpty()) {
5254        addNote();
5255      }
5256      return getNote().get(0);
5257    }
5258
5259    /**
5260     * @return {@link #manufacturer} (A company that makes this substance.)
5261     */
5262    public List<Reference> getManufacturer() { 
5263      if (this.manufacturer == null)
5264        this.manufacturer = new ArrayList<Reference>();
5265      return this.manufacturer;
5266    }
5267
5268    /**
5269     * @return Returns a reference to <code>this</code> for easy method chaining
5270     */
5271    public SubstanceDefinition setManufacturer(List<Reference> theManufacturer) { 
5272      this.manufacturer = theManufacturer;
5273      return this;
5274    }
5275
5276    public boolean hasManufacturer() { 
5277      if (this.manufacturer == null)
5278        return false;
5279      for (Reference item : this.manufacturer)
5280        if (!item.isEmpty())
5281          return true;
5282      return false;
5283    }
5284
5285    public Reference addManufacturer() { //3
5286      Reference t = new Reference();
5287      if (this.manufacturer == null)
5288        this.manufacturer = new ArrayList<Reference>();
5289      this.manufacturer.add(t);
5290      return t;
5291    }
5292
5293    public SubstanceDefinition addManufacturer(Reference t) { //3
5294      if (t == null)
5295        return this;
5296      if (this.manufacturer == null)
5297        this.manufacturer = new ArrayList<Reference>();
5298      this.manufacturer.add(t);
5299      return this;
5300    }
5301
5302    /**
5303     * @return The first repetition of repeating field {@link #manufacturer}, creating it if it does not already exist {3}
5304     */
5305    public Reference getManufacturerFirstRep() { 
5306      if (getManufacturer().isEmpty()) {
5307        addManufacturer();
5308      }
5309      return getManufacturer().get(0);
5310    }
5311
5312    /**
5313     * @return {@link #supplier} (A company that supplies this substance.)
5314     */
5315    public List<Reference> getSupplier() { 
5316      if (this.supplier == null)
5317        this.supplier = new ArrayList<Reference>();
5318      return this.supplier;
5319    }
5320
5321    /**
5322     * @return Returns a reference to <code>this</code> for easy method chaining
5323     */
5324    public SubstanceDefinition setSupplier(List<Reference> theSupplier) { 
5325      this.supplier = theSupplier;
5326      return this;
5327    }
5328
5329    public boolean hasSupplier() { 
5330      if (this.supplier == null)
5331        return false;
5332      for (Reference item : this.supplier)
5333        if (!item.isEmpty())
5334          return true;
5335      return false;
5336    }
5337
5338    public Reference addSupplier() { //3
5339      Reference t = new Reference();
5340      if (this.supplier == null)
5341        this.supplier = new ArrayList<Reference>();
5342      this.supplier.add(t);
5343      return t;
5344    }
5345
5346    public SubstanceDefinition addSupplier(Reference t) { //3
5347      if (t == null)
5348        return this;
5349      if (this.supplier == null)
5350        this.supplier = new ArrayList<Reference>();
5351      this.supplier.add(t);
5352      return this;
5353    }
5354
5355    /**
5356     * @return The first repetition of repeating field {@link #supplier}, creating it if it does not already exist {3}
5357     */
5358    public Reference getSupplierFirstRep() { 
5359      if (getSupplier().isEmpty()) {
5360        addSupplier();
5361      }
5362      return getSupplier().get(0);
5363    }
5364
5365    /**
5366     * @return {@link #moiety} (Moiety, for structural modifications.)
5367     */
5368    public List<SubstanceDefinitionMoietyComponent> getMoiety() { 
5369      if (this.moiety == null)
5370        this.moiety = new ArrayList<SubstanceDefinitionMoietyComponent>();
5371      return this.moiety;
5372    }
5373
5374    /**
5375     * @return Returns a reference to <code>this</code> for easy method chaining
5376     */
5377    public SubstanceDefinition setMoiety(List<SubstanceDefinitionMoietyComponent> theMoiety) { 
5378      this.moiety = theMoiety;
5379      return this;
5380    }
5381
5382    public boolean hasMoiety() { 
5383      if (this.moiety == null)
5384        return false;
5385      for (SubstanceDefinitionMoietyComponent item : this.moiety)
5386        if (!item.isEmpty())
5387          return true;
5388      return false;
5389    }
5390
5391    public SubstanceDefinitionMoietyComponent addMoiety() { //3
5392      SubstanceDefinitionMoietyComponent t = new SubstanceDefinitionMoietyComponent();
5393      if (this.moiety == null)
5394        this.moiety = new ArrayList<SubstanceDefinitionMoietyComponent>();
5395      this.moiety.add(t);
5396      return t;
5397    }
5398
5399    public SubstanceDefinition addMoiety(SubstanceDefinitionMoietyComponent t) { //3
5400      if (t == null)
5401        return this;
5402      if (this.moiety == null)
5403        this.moiety = new ArrayList<SubstanceDefinitionMoietyComponent>();
5404      this.moiety.add(t);
5405      return this;
5406    }
5407
5408    /**
5409     * @return The first repetition of repeating field {@link #moiety}, creating it if it does not already exist {3}
5410     */
5411    public SubstanceDefinitionMoietyComponent getMoietyFirstRep() { 
5412      if (getMoiety().isEmpty()) {
5413        addMoiety();
5414      }
5415      return getMoiety().get(0);
5416    }
5417
5418    /**
5419     * @return {@link #property} (General specifications for this substance.)
5420     */
5421    public List<SubstanceDefinitionPropertyComponent> getProperty() { 
5422      if (this.property == null)
5423        this.property = new ArrayList<SubstanceDefinitionPropertyComponent>();
5424      return this.property;
5425    }
5426
5427    /**
5428     * @return Returns a reference to <code>this</code> for easy method chaining
5429     */
5430    public SubstanceDefinition setProperty(List<SubstanceDefinitionPropertyComponent> theProperty) { 
5431      this.property = theProperty;
5432      return this;
5433    }
5434
5435    public boolean hasProperty() { 
5436      if (this.property == null)
5437        return false;
5438      for (SubstanceDefinitionPropertyComponent item : this.property)
5439        if (!item.isEmpty())
5440          return true;
5441      return false;
5442    }
5443
5444    public SubstanceDefinitionPropertyComponent addProperty() { //3
5445      SubstanceDefinitionPropertyComponent t = new SubstanceDefinitionPropertyComponent();
5446      if (this.property == null)
5447        this.property = new ArrayList<SubstanceDefinitionPropertyComponent>();
5448      this.property.add(t);
5449      return t;
5450    }
5451
5452    public SubstanceDefinition addProperty(SubstanceDefinitionPropertyComponent t) { //3
5453      if (t == null)
5454        return this;
5455      if (this.property == null)
5456        this.property = new ArrayList<SubstanceDefinitionPropertyComponent>();
5457      this.property.add(t);
5458      return this;
5459    }
5460
5461    /**
5462     * @return The first repetition of repeating field {@link #property}, creating it if it does not already exist {3}
5463     */
5464    public SubstanceDefinitionPropertyComponent getPropertyFirstRep() { 
5465      if (getProperty().isEmpty()) {
5466        addProperty();
5467      }
5468      return getProperty().get(0);
5469    }
5470
5471    /**
5472     * @return {@link #referenceInformation} (General information detailing this substance.)
5473     */
5474    public Reference getReferenceInformation() { 
5475      if (this.referenceInformation == null)
5476        if (Configuration.errorOnAutoCreate())
5477          throw new Error("Attempt to auto-create SubstanceDefinition.referenceInformation");
5478        else if (Configuration.doAutoCreate())
5479          this.referenceInformation = new Reference(); // cc
5480      return this.referenceInformation;
5481    }
5482
5483    public boolean hasReferenceInformation() { 
5484      return this.referenceInformation != null && !this.referenceInformation.isEmpty();
5485    }
5486
5487    /**
5488     * @param value {@link #referenceInformation} (General information detailing this substance.)
5489     */
5490    public SubstanceDefinition setReferenceInformation(Reference value) { 
5491      this.referenceInformation = value;
5492      return this;
5493    }
5494
5495    /**
5496     * @return {@link #molecularWeight} (The molecular weight or weight range (for proteins, polymers or nucleic acids).)
5497     */
5498    public List<SubstanceDefinitionMolecularWeightComponent> getMolecularWeight() { 
5499      if (this.molecularWeight == null)
5500        this.molecularWeight = new ArrayList<SubstanceDefinitionMolecularWeightComponent>();
5501      return this.molecularWeight;
5502    }
5503
5504    /**
5505     * @return Returns a reference to <code>this</code> for easy method chaining
5506     */
5507    public SubstanceDefinition setMolecularWeight(List<SubstanceDefinitionMolecularWeightComponent> theMolecularWeight) { 
5508      this.molecularWeight = theMolecularWeight;
5509      return this;
5510    }
5511
5512    public boolean hasMolecularWeight() { 
5513      if (this.molecularWeight == null)
5514        return false;
5515      for (SubstanceDefinitionMolecularWeightComponent item : this.molecularWeight)
5516        if (!item.isEmpty())
5517          return true;
5518      return false;
5519    }
5520
5521    public SubstanceDefinitionMolecularWeightComponent addMolecularWeight() { //3
5522      SubstanceDefinitionMolecularWeightComponent t = new SubstanceDefinitionMolecularWeightComponent();
5523      if (this.molecularWeight == null)
5524        this.molecularWeight = new ArrayList<SubstanceDefinitionMolecularWeightComponent>();
5525      this.molecularWeight.add(t);
5526      return t;
5527    }
5528
5529    public SubstanceDefinition addMolecularWeight(SubstanceDefinitionMolecularWeightComponent t) { //3
5530      if (t == null)
5531        return this;
5532      if (this.molecularWeight == null)
5533        this.molecularWeight = new ArrayList<SubstanceDefinitionMolecularWeightComponent>();
5534      this.molecularWeight.add(t);
5535      return this;
5536    }
5537
5538    /**
5539     * @return The first repetition of repeating field {@link #molecularWeight}, creating it if it does not already exist {3}
5540     */
5541    public SubstanceDefinitionMolecularWeightComponent getMolecularWeightFirstRep() { 
5542      if (getMolecularWeight().isEmpty()) {
5543        addMolecularWeight();
5544      }
5545      return getMolecularWeight().get(0);
5546    }
5547
5548    /**
5549     * @return {@link #structure} (Structural information.)
5550     */
5551    public SubstanceDefinitionStructureComponent getStructure() { 
5552      if (this.structure == null)
5553        if (Configuration.errorOnAutoCreate())
5554          throw new Error("Attempt to auto-create SubstanceDefinition.structure");
5555        else if (Configuration.doAutoCreate())
5556          this.structure = new SubstanceDefinitionStructureComponent(); // cc
5557      return this.structure;
5558    }
5559
5560    public boolean hasStructure() { 
5561      return this.structure != null && !this.structure.isEmpty();
5562    }
5563
5564    /**
5565     * @param value {@link #structure} (Structural information.)
5566     */
5567    public SubstanceDefinition setStructure(SubstanceDefinitionStructureComponent value) { 
5568      this.structure = value;
5569      return this;
5570    }
5571
5572    /**
5573     * @return {@link #code} (Codes associated with the substance.)
5574     */
5575    public List<SubstanceDefinitionCodeComponent> getCode() { 
5576      if (this.code == null)
5577        this.code = new ArrayList<SubstanceDefinitionCodeComponent>();
5578      return this.code;
5579    }
5580
5581    /**
5582     * @return Returns a reference to <code>this</code> for easy method chaining
5583     */
5584    public SubstanceDefinition setCode(List<SubstanceDefinitionCodeComponent> theCode) { 
5585      this.code = theCode;
5586      return this;
5587    }
5588
5589    public boolean hasCode() { 
5590      if (this.code == null)
5591        return false;
5592      for (SubstanceDefinitionCodeComponent item : this.code)
5593        if (!item.isEmpty())
5594          return true;
5595      return false;
5596    }
5597
5598    public SubstanceDefinitionCodeComponent addCode() { //3
5599      SubstanceDefinitionCodeComponent t = new SubstanceDefinitionCodeComponent();
5600      if (this.code == null)
5601        this.code = new ArrayList<SubstanceDefinitionCodeComponent>();
5602      this.code.add(t);
5603      return t;
5604    }
5605
5606    public SubstanceDefinition addCode(SubstanceDefinitionCodeComponent t) { //3
5607      if (t == null)
5608        return this;
5609      if (this.code == null)
5610        this.code = new ArrayList<SubstanceDefinitionCodeComponent>();
5611      this.code.add(t);
5612      return this;
5613    }
5614
5615    /**
5616     * @return The first repetition of repeating field {@link #code}, creating it if it does not already exist {3}
5617     */
5618    public SubstanceDefinitionCodeComponent getCodeFirstRep() { 
5619      if (getCode().isEmpty()) {
5620        addCode();
5621      }
5622      return getCode().get(0);
5623    }
5624
5625    /**
5626     * @return {@link #name} (Names applicable to this substance.)
5627     */
5628    public List<SubstanceDefinitionNameComponent> getName() { 
5629      if (this.name == null)
5630        this.name = new ArrayList<SubstanceDefinitionNameComponent>();
5631      return this.name;
5632    }
5633
5634    /**
5635     * @return Returns a reference to <code>this</code> for easy method chaining
5636     */
5637    public SubstanceDefinition setName(List<SubstanceDefinitionNameComponent> theName) { 
5638      this.name = theName;
5639      return this;
5640    }
5641
5642    public boolean hasName() { 
5643      if (this.name == null)
5644        return false;
5645      for (SubstanceDefinitionNameComponent item : this.name)
5646        if (!item.isEmpty())
5647          return true;
5648      return false;
5649    }
5650
5651    public SubstanceDefinitionNameComponent addName() { //3
5652      SubstanceDefinitionNameComponent t = new SubstanceDefinitionNameComponent();
5653      if (this.name == null)
5654        this.name = new ArrayList<SubstanceDefinitionNameComponent>();
5655      this.name.add(t);
5656      return t;
5657    }
5658
5659    public SubstanceDefinition addName(SubstanceDefinitionNameComponent t) { //3
5660      if (t == null)
5661        return this;
5662      if (this.name == null)
5663        this.name = new ArrayList<SubstanceDefinitionNameComponent>();
5664      this.name.add(t);
5665      return this;
5666    }
5667
5668    /**
5669     * @return The first repetition of repeating field {@link #name}, creating it if it does not already exist {3}
5670     */
5671    public SubstanceDefinitionNameComponent getNameFirstRep() { 
5672      if (getName().isEmpty()) {
5673        addName();
5674      }
5675      return getName().get(0);
5676    }
5677
5678    /**
5679     * @return {@link #relationship} (A link between this substance and another, with details of the relationship.)
5680     */
5681    public List<SubstanceDefinitionRelationshipComponent> getRelationship() { 
5682      if (this.relationship == null)
5683        this.relationship = new ArrayList<SubstanceDefinitionRelationshipComponent>();
5684      return this.relationship;
5685    }
5686
5687    /**
5688     * @return Returns a reference to <code>this</code> for easy method chaining
5689     */
5690    public SubstanceDefinition setRelationship(List<SubstanceDefinitionRelationshipComponent> theRelationship) { 
5691      this.relationship = theRelationship;
5692      return this;
5693    }
5694
5695    public boolean hasRelationship() { 
5696      if (this.relationship == null)
5697        return false;
5698      for (SubstanceDefinitionRelationshipComponent item : this.relationship)
5699        if (!item.isEmpty())
5700          return true;
5701      return false;
5702    }
5703
5704    public SubstanceDefinitionRelationshipComponent addRelationship() { //3
5705      SubstanceDefinitionRelationshipComponent t = new SubstanceDefinitionRelationshipComponent();
5706      if (this.relationship == null)
5707        this.relationship = new ArrayList<SubstanceDefinitionRelationshipComponent>();
5708      this.relationship.add(t);
5709      return t;
5710    }
5711
5712    public SubstanceDefinition addRelationship(SubstanceDefinitionRelationshipComponent t) { //3
5713      if (t == null)
5714        return this;
5715      if (this.relationship == null)
5716        this.relationship = new ArrayList<SubstanceDefinitionRelationshipComponent>();
5717      this.relationship.add(t);
5718      return this;
5719    }
5720
5721    /**
5722     * @return The first repetition of repeating field {@link #relationship}, creating it if it does not already exist {3}
5723     */
5724    public SubstanceDefinitionRelationshipComponent getRelationshipFirstRep() { 
5725      if (getRelationship().isEmpty()) {
5726        addRelationship();
5727      }
5728      return getRelationship().get(0);
5729    }
5730
5731    /**
5732     * @return {@link #nucleicAcid} (Data items specific to nucleic acids.)
5733     */
5734    public Reference getNucleicAcid() { 
5735      if (this.nucleicAcid == null)
5736        if (Configuration.errorOnAutoCreate())
5737          throw new Error("Attempt to auto-create SubstanceDefinition.nucleicAcid");
5738        else if (Configuration.doAutoCreate())
5739          this.nucleicAcid = new Reference(); // cc
5740      return this.nucleicAcid;
5741    }
5742
5743    public boolean hasNucleicAcid() { 
5744      return this.nucleicAcid != null && !this.nucleicAcid.isEmpty();
5745    }
5746
5747    /**
5748     * @param value {@link #nucleicAcid} (Data items specific to nucleic acids.)
5749     */
5750    public SubstanceDefinition setNucleicAcid(Reference value) { 
5751      this.nucleicAcid = value;
5752      return this;
5753    }
5754
5755    /**
5756     * @return {@link #polymer} (Data items specific to polymers.)
5757     */
5758    public Reference getPolymer() { 
5759      if (this.polymer == null)
5760        if (Configuration.errorOnAutoCreate())
5761          throw new Error("Attempt to auto-create SubstanceDefinition.polymer");
5762        else if (Configuration.doAutoCreate())
5763          this.polymer = new Reference(); // cc
5764      return this.polymer;
5765    }
5766
5767    public boolean hasPolymer() { 
5768      return this.polymer != null && !this.polymer.isEmpty();
5769    }
5770
5771    /**
5772     * @param value {@link #polymer} (Data items specific to polymers.)
5773     */
5774    public SubstanceDefinition setPolymer(Reference value) { 
5775      this.polymer = value;
5776      return this;
5777    }
5778
5779    /**
5780     * @return {@link #protein} (Data items specific to proteins.)
5781     */
5782    public Reference getProtein() { 
5783      if (this.protein == null)
5784        if (Configuration.errorOnAutoCreate())
5785          throw new Error("Attempt to auto-create SubstanceDefinition.protein");
5786        else if (Configuration.doAutoCreate())
5787          this.protein = new Reference(); // cc
5788      return this.protein;
5789    }
5790
5791    public boolean hasProtein() { 
5792      return this.protein != null && !this.protein.isEmpty();
5793    }
5794
5795    /**
5796     * @param value {@link #protein} (Data items specific to proteins.)
5797     */
5798    public SubstanceDefinition setProtein(Reference value) { 
5799      this.protein = value;
5800      return this;
5801    }
5802
5803    /**
5804     * @return {@link #sourceMaterial} (Material or taxonomic/anatomical source for the substance.)
5805     */
5806    public SubstanceDefinitionSourceMaterialComponent getSourceMaterial() { 
5807      if (this.sourceMaterial == null)
5808        if (Configuration.errorOnAutoCreate())
5809          throw new Error("Attempt to auto-create SubstanceDefinition.sourceMaterial");
5810        else if (Configuration.doAutoCreate())
5811          this.sourceMaterial = new SubstanceDefinitionSourceMaterialComponent(); // cc
5812      return this.sourceMaterial;
5813    }
5814
5815    public boolean hasSourceMaterial() { 
5816      return this.sourceMaterial != null && !this.sourceMaterial.isEmpty();
5817    }
5818
5819    /**
5820     * @param value {@link #sourceMaterial} (Material or taxonomic/anatomical source for the substance.)
5821     */
5822    public SubstanceDefinition setSourceMaterial(SubstanceDefinitionSourceMaterialComponent value) { 
5823      this.sourceMaterial = value;
5824      return this;
5825    }
5826
5827      protected void listChildren(List<Property> children) {
5828        super.listChildren(children);
5829        children.add(new Property("identifier", "Identifier", "Identifier by which this substance is known.", 0, java.lang.Integer.MAX_VALUE, identifier));
5830        children.add(new Property("version", "string", "A business level identifier of the substance.", 0, 1, version));
5831        children.add(new Property("status", "CodeableConcept", "Status of substance within the catalogue e.g. approved.", 0, 1, status));
5832        children.add(new Property("classification", "CodeableConcept", "A high level categorization, e.g. polymer or nucleic acid, or food, chemical, biological, or a lower level such as the general types of polymer (linear or branch chain) or type of impurity (process related or contaminant).", 0, java.lang.Integer.MAX_VALUE, classification));
5833        children.add(new Property("domain", "CodeableConcept", "If the substance applies to only human or veterinary use.", 0, 1, domain));
5834        children.add(new Property("grade", "CodeableConcept", "The quality standard, established benchmark, to which substance complies (e.g. USP/NF, Ph. Eur, JP, BP, Company Standard).", 0, java.lang.Integer.MAX_VALUE, grade));
5835        children.add(new Property("description", "markdown", "Textual description of the substance.", 0, 1, description));
5836        children.add(new Property("informationSource", "Reference(Citation)", "Supporting literature.", 0, java.lang.Integer.MAX_VALUE, informationSource));
5837        children.add(new Property("note", "Annotation", "Textual comment about the substance's catalogue or registry record.", 0, java.lang.Integer.MAX_VALUE, note));
5838        children.add(new Property("manufacturer", "Reference(Organization)", "A company that makes this substance.", 0, java.lang.Integer.MAX_VALUE, manufacturer));
5839        children.add(new Property("supplier", "Reference(Organization)", "A company that supplies this substance.", 0, java.lang.Integer.MAX_VALUE, supplier));
5840        children.add(new Property("moiety", "", "Moiety, for structural modifications.", 0, java.lang.Integer.MAX_VALUE, moiety));
5841        children.add(new Property("property", "", "General specifications for this substance.", 0, java.lang.Integer.MAX_VALUE, property));
5842        children.add(new Property("referenceInformation", "Reference(SubstanceReferenceInformation)", "General information detailing this substance.", 0, 1, referenceInformation));
5843        children.add(new Property("molecularWeight", "", "The molecular weight or weight range (for proteins, polymers or nucleic acids).", 0, java.lang.Integer.MAX_VALUE, molecularWeight));
5844        children.add(new Property("structure", "", "Structural information.", 0, 1, structure));
5845        children.add(new Property("code", "", "Codes associated with the substance.", 0, java.lang.Integer.MAX_VALUE, code));
5846        children.add(new Property("name", "", "Names applicable to this substance.", 0, java.lang.Integer.MAX_VALUE, name));
5847        children.add(new Property("relationship", "", "A link between this substance and another, with details of the relationship.", 0, java.lang.Integer.MAX_VALUE, relationship));
5848        children.add(new Property("nucleicAcid", "Reference(SubstanceNucleicAcid)", "Data items specific to nucleic acids.", 0, 1, nucleicAcid));
5849        children.add(new Property("polymer", "Reference(SubstancePolymer)", "Data items specific to polymers.", 0, 1, polymer));
5850        children.add(new Property("protein", "Reference(SubstanceProtein)", "Data items specific to proteins.", 0, 1, protein));
5851        children.add(new Property("sourceMaterial", "", "Material or taxonomic/anatomical source for the substance.", 0, 1, sourceMaterial));
5852      }
5853
5854      @Override
5855      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
5856        switch (_hash) {
5857        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Identifier by which this substance is known.", 0, java.lang.Integer.MAX_VALUE, identifier);
5858        case 351608024: /*version*/  return new Property("version", "string", "A business level identifier of the substance.", 0, 1, version);
5859        case -892481550: /*status*/  return new Property("status", "CodeableConcept", "Status of substance within the catalogue e.g. approved.", 0, 1, status);
5860        case 382350310: /*classification*/  return new Property("classification", "CodeableConcept", "A high level categorization, e.g. polymer or nucleic acid, or food, chemical, biological, or a lower level such as the general types of polymer (linear or branch chain) or type of impurity (process related or contaminant).", 0, java.lang.Integer.MAX_VALUE, classification);
5861        case -1326197564: /*domain*/  return new Property("domain", "CodeableConcept", "If the substance applies to only human or veterinary use.", 0, 1, domain);
5862        case 98615255: /*grade*/  return new Property("grade", "CodeableConcept", "The quality standard, established benchmark, to which substance complies (e.g. USP/NF, Ph. Eur, JP, BP, Company Standard).", 0, java.lang.Integer.MAX_VALUE, grade);
5863        case -1724546052: /*description*/  return new Property("description", "markdown", "Textual description of the substance.", 0, 1, description);
5864        case -2123220889: /*informationSource*/  return new Property("informationSource", "Reference(Citation)", "Supporting literature.", 0, java.lang.Integer.MAX_VALUE, informationSource);
5865        case 3387378: /*note*/  return new Property("note", "Annotation", "Textual comment about the substance's catalogue or registry record.", 0, java.lang.Integer.MAX_VALUE, note);
5866        case -1969347631: /*manufacturer*/  return new Property("manufacturer", "Reference(Organization)", "A company that makes this substance.", 0, java.lang.Integer.MAX_VALUE, manufacturer);
5867        case -1663305268: /*supplier*/  return new Property("supplier", "Reference(Organization)", "A company that supplies this substance.", 0, java.lang.Integer.MAX_VALUE, supplier);
5868        case -1068650173: /*moiety*/  return new Property("moiety", "", "Moiety, for structural modifications.", 0, java.lang.Integer.MAX_VALUE, moiety);
5869        case -993141291: /*property*/  return new Property("property", "", "General specifications for this substance.", 0, java.lang.Integer.MAX_VALUE, property);
5870        case -2117930783: /*referenceInformation*/  return new Property("referenceInformation", "Reference(SubstanceReferenceInformation)", "General information detailing this substance.", 0, 1, referenceInformation);
5871        case 635625672: /*molecularWeight*/  return new Property("molecularWeight", "", "The molecular weight or weight range (for proteins, polymers or nucleic acids).", 0, java.lang.Integer.MAX_VALUE, molecularWeight);
5872        case 144518515: /*structure*/  return new Property("structure", "", "Structural information.", 0, 1, structure);
5873        case 3059181: /*code*/  return new Property("code", "", "Codes associated with the substance.", 0, java.lang.Integer.MAX_VALUE, code);
5874        case 3373707: /*name*/  return new Property("name", "", "Names applicable to this substance.", 0, java.lang.Integer.MAX_VALUE, name);
5875        case -261851592: /*relationship*/  return new Property("relationship", "", "A link between this substance and another, with details of the relationship.", 0, java.lang.Integer.MAX_VALUE, relationship);
5876        case 1625275180: /*nucleicAcid*/  return new Property("nucleicAcid", "Reference(SubstanceNucleicAcid)", "Data items specific to nucleic acids.", 0, 1, nucleicAcid);
5877        case -397514098: /*polymer*/  return new Property("polymer", "Reference(SubstancePolymer)", "Data items specific to polymers.", 0, 1, polymer);
5878        case -309012605: /*protein*/  return new Property("protein", "Reference(SubstanceProtein)", "Data items specific to proteins.", 0, 1, protein);
5879        case -1064442270: /*sourceMaterial*/  return new Property("sourceMaterial", "", "Material or taxonomic/anatomical source for the substance.", 0, 1, sourceMaterial);
5880        default: return super.getNamedProperty(_hash, _name, _checkValid);
5881        }
5882
5883      }
5884
5885      @Override
5886      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
5887        switch (hash) {
5888        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
5889        case 351608024: /*version*/ return this.version == null ? new Base[0] : new Base[] {this.version}; // StringType
5890        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // CodeableConcept
5891        case 382350310: /*classification*/ return this.classification == null ? new Base[0] : this.classification.toArray(new Base[this.classification.size()]); // CodeableConcept
5892        case -1326197564: /*domain*/ return this.domain == null ? new Base[0] : new Base[] {this.domain}; // CodeableConcept
5893        case 98615255: /*grade*/ return this.grade == null ? new Base[0] : this.grade.toArray(new Base[this.grade.size()]); // CodeableConcept
5894        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // MarkdownType
5895        case -2123220889: /*informationSource*/ return this.informationSource == null ? new Base[0] : this.informationSource.toArray(new Base[this.informationSource.size()]); // Reference
5896        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
5897        case -1969347631: /*manufacturer*/ return this.manufacturer == null ? new Base[0] : this.manufacturer.toArray(new Base[this.manufacturer.size()]); // Reference
5898        case -1663305268: /*supplier*/ return this.supplier == null ? new Base[0] : this.supplier.toArray(new Base[this.supplier.size()]); // Reference
5899        case -1068650173: /*moiety*/ return this.moiety == null ? new Base[0] : this.moiety.toArray(new Base[this.moiety.size()]); // SubstanceDefinitionMoietyComponent
5900        case -993141291: /*property*/ return this.property == null ? new Base[0] : this.property.toArray(new Base[this.property.size()]); // SubstanceDefinitionPropertyComponent
5901        case -2117930783: /*referenceInformation*/ return this.referenceInformation == null ? new Base[0] : new Base[] {this.referenceInformation}; // Reference
5902        case 635625672: /*molecularWeight*/ return this.molecularWeight == null ? new Base[0] : this.molecularWeight.toArray(new Base[this.molecularWeight.size()]); // SubstanceDefinitionMolecularWeightComponent
5903        case 144518515: /*structure*/ return this.structure == null ? new Base[0] : new Base[] {this.structure}; // SubstanceDefinitionStructureComponent
5904        case 3059181: /*code*/ return this.code == null ? new Base[0] : this.code.toArray(new Base[this.code.size()]); // SubstanceDefinitionCodeComponent
5905        case 3373707: /*name*/ return this.name == null ? new Base[0] : this.name.toArray(new Base[this.name.size()]); // SubstanceDefinitionNameComponent
5906        case -261851592: /*relationship*/ return this.relationship == null ? new Base[0] : this.relationship.toArray(new Base[this.relationship.size()]); // SubstanceDefinitionRelationshipComponent
5907        case 1625275180: /*nucleicAcid*/ return this.nucleicAcid == null ? new Base[0] : new Base[] {this.nucleicAcid}; // Reference
5908        case -397514098: /*polymer*/ return this.polymer == null ? new Base[0] : new Base[] {this.polymer}; // Reference
5909        case -309012605: /*protein*/ return this.protein == null ? new Base[0] : new Base[] {this.protein}; // Reference
5910        case -1064442270: /*sourceMaterial*/ return this.sourceMaterial == null ? new Base[0] : new Base[] {this.sourceMaterial}; // SubstanceDefinitionSourceMaterialComponent
5911        default: return super.getProperty(hash, name, checkValid);
5912        }
5913
5914      }
5915
5916      @Override
5917      public Base setProperty(int hash, String name, Base value) throws FHIRException {
5918        switch (hash) {
5919        case -1618432855: // identifier
5920          this.getIdentifier().add(TypeConvertor.castToIdentifier(value)); // Identifier
5921          return value;
5922        case 351608024: // version
5923          this.version = TypeConvertor.castToString(value); // StringType
5924          return value;
5925        case -892481550: // status
5926          this.status = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
5927          return value;
5928        case 382350310: // classification
5929          this.getClassification().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
5930          return value;
5931        case -1326197564: // domain
5932          this.domain = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
5933          return value;
5934        case 98615255: // grade
5935          this.getGrade().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
5936          return value;
5937        case -1724546052: // description
5938          this.description = TypeConvertor.castToMarkdown(value); // MarkdownType
5939          return value;
5940        case -2123220889: // informationSource
5941          this.getInformationSource().add(TypeConvertor.castToReference(value)); // Reference
5942          return value;
5943        case 3387378: // note
5944          this.getNote().add(TypeConvertor.castToAnnotation(value)); // Annotation
5945          return value;
5946        case -1969347631: // manufacturer
5947          this.getManufacturer().add(TypeConvertor.castToReference(value)); // Reference
5948          return value;
5949        case -1663305268: // supplier
5950          this.getSupplier().add(TypeConvertor.castToReference(value)); // Reference
5951          return value;
5952        case -1068650173: // moiety
5953          this.getMoiety().add((SubstanceDefinitionMoietyComponent) value); // SubstanceDefinitionMoietyComponent
5954          return value;
5955        case -993141291: // property
5956          this.getProperty().add((SubstanceDefinitionPropertyComponent) value); // SubstanceDefinitionPropertyComponent
5957          return value;
5958        case -2117930783: // referenceInformation
5959          this.referenceInformation = TypeConvertor.castToReference(value); // Reference
5960          return value;
5961        case 635625672: // molecularWeight
5962          this.getMolecularWeight().add((SubstanceDefinitionMolecularWeightComponent) value); // SubstanceDefinitionMolecularWeightComponent
5963          return value;
5964        case 144518515: // structure
5965          this.structure = (SubstanceDefinitionStructureComponent) value; // SubstanceDefinitionStructureComponent
5966          return value;
5967        case 3059181: // code
5968          this.getCode().add((SubstanceDefinitionCodeComponent) value); // SubstanceDefinitionCodeComponent
5969          return value;
5970        case 3373707: // name
5971          this.getName().add((SubstanceDefinitionNameComponent) value); // SubstanceDefinitionNameComponent
5972          return value;
5973        case -261851592: // relationship
5974          this.getRelationship().add((SubstanceDefinitionRelationshipComponent) value); // SubstanceDefinitionRelationshipComponent
5975          return value;
5976        case 1625275180: // nucleicAcid
5977          this.nucleicAcid = TypeConvertor.castToReference(value); // Reference
5978          return value;
5979        case -397514098: // polymer
5980          this.polymer = TypeConvertor.castToReference(value); // Reference
5981          return value;
5982        case -309012605: // protein
5983          this.protein = TypeConvertor.castToReference(value); // Reference
5984          return value;
5985        case -1064442270: // sourceMaterial
5986          this.sourceMaterial = (SubstanceDefinitionSourceMaterialComponent) value; // SubstanceDefinitionSourceMaterialComponent
5987          return value;
5988        default: return super.setProperty(hash, name, value);
5989        }
5990
5991      }
5992
5993      @Override
5994      public Base setProperty(String name, Base value) throws FHIRException {
5995        if (name.equals("identifier")) {
5996          this.getIdentifier().add(TypeConvertor.castToIdentifier(value));
5997        } else if (name.equals("version")) {
5998          this.version = TypeConvertor.castToString(value); // StringType
5999        } else if (name.equals("status")) {
6000          this.status = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
6001        } else if (name.equals("classification")) {
6002          this.getClassification().add(TypeConvertor.castToCodeableConcept(value));
6003        } else if (name.equals("domain")) {
6004          this.domain = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
6005        } else if (name.equals("grade")) {
6006          this.getGrade().add(TypeConvertor.castToCodeableConcept(value));
6007        } else if (name.equals("description")) {
6008          this.description = TypeConvertor.castToMarkdown(value); // MarkdownType
6009        } else if (name.equals("informationSource")) {
6010          this.getInformationSource().add(TypeConvertor.castToReference(value));
6011        } else if (name.equals("note")) {
6012          this.getNote().add(TypeConvertor.castToAnnotation(value));
6013        } else if (name.equals("manufacturer")) {
6014          this.getManufacturer().add(TypeConvertor.castToReference(value));
6015        } else if (name.equals("supplier")) {
6016          this.getSupplier().add(TypeConvertor.castToReference(value));
6017        } else if (name.equals("moiety")) {
6018          this.getMoiety().add((SubstanceDefinitionMoietyComponent) value);
6019        } else if (name.equals("property")) {
6020          this.getProperty().add((SubstanceDefinitionPropertyComponent) value);
6021        } else if (name.equals("referenceInformation")) {
6022          this.referenceInformation = TypeConvertor.castToReference(value); // Reference
6023        } else if (name.equals("molecularWeight")) {
6024          this.getMolecularWeight().add((SubstanceDefinitionMolecularWeightComponent) value);
6025        } else if (name.equals("structure")) {
6026          this.structure = (SubstanceDefinitionStructureComponent) value; // SubstanceDefinitionStructureComponent
6027        } else if (name.equals("code")) {
6028          this.getCode().add((SubstanceDefinitionCodeComponent) value);
6029        } else if (name.equals("name")) {
6030          this.getName().add((SubstanceDefinitionNameComponent) value);
6031        } else if (name.equals("relationship")) {
6032          this.getRelationship().add((SubstanceDefinitionRelationshipComponent) value);
6033        } else if (name.equals("nucleicAcid")) {
6034          this.nucleicAcid = TypeConvertor.castToReference(value); // Reference
6035        } else if (name.equals("polymer")) {
6036          this.polymer = TypeConvertor.castToReference(value); // Reference
6037        } else if (name.equals("protein")) {
6038          this.protein = TypeConvertor.castToReference(value); // Reference
6039        } else if (name.equals("sourceMaterial")) {
6040          this.sourceMaterial = (SubstanceDefinitionSourceMaterialComponent) value; // SubstanceDefinitionSourceMaterialComponent
6041        } else
6042          return super.setProperty(name, value);
6043        return value;
6044      }
6045
6046      @Override
6047      public Base makeProperty(int hash, String name) throws FHIRException {
6048        switch (hash) {
6049        case -1618432855:  return addIdentifier(); 
6050        case 351608024:  return getVersionElement();
6051        case -892481550:  return getStatus();
6052        case 382350310:  return addClassification(); 
6053        case -1326197564:  return getDomain();
6054        case 98615255:  return addGrade(); 
6055        case -1724546052:  return getDescriptionElement();
6056        case -2123220889:  return addInformationSource(); 
6057        case 3387378:  return addNote(); 
6058        case -1969347631:  return addManufacturer(); 
6059        case -1663305268:  return addSupplier(); 
6060        case -1068650173:  return addMoiety(); 
6061        case -993141291:  return addProperty(); 
6062        case -2117930783:  return getReferenceInformation();
6063        case 635625672:  return addMolecularWeight(); 
6064        case 144518515:  return getStructure();
6065        case 3059181:  return addCode(); 
6066        case 3373707:  return addName(); 
6067        case -261851592:  return addRelationship(); 
6068        case 1625275180:  return getNucleicAcid();
6069        case -397514098:  return getPolymer();
6070        case -309012605:  return getProtein();
6071        case -1064442270:  return getSourceMaterial();
6072        default: return super.makeProperty(hash, name);
6073        }
6074
6075      }
6076
6077      @Override
6078      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
6079        switch (hash) {
6080        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
6081        case 351608024: /*version*/ return new String[] {"string"};
6082        case -892481550: /*status*/ return new String[] {"CodeableConcept"};
6083        case 382350310: /*classification*/ return new String[] {"CodeableConcept"};
6084        case -1326197564: /*domain*/ return new String[] {"CodeableConcept"};
6085        case 98615255: /*grade*/ return new String[] {"CodeableConcept"};
6086        case -1724546052: /*description*/ return new String[] {"markdown"};
6087        case -2123220889: /*informationSource*/ return new String[] {"Reference"};
6088        case 3387378: /*note*/ return new String[] {"Annotation"};
6089        case -1969347631: /*manufacturer*/ return new String[] {"Reference"};
6090        case -1663305268: /*supplier*/ return new String[] {"Reference"};
6091        case -1068650173: /*moiety*/ return new String[] {};
6092        case -993141291: /*property*/ return new String[] {};
6093        case -2117930783: /*referenceInformation*/ return new String[] {"Reference"};
6094        case 635625672: /*molecularWeight*/ return new String[] {};
6095        case 144518515: /*structure*/ return new String[] {};
6096        case 3059181: /*code*/ return new String[] {};
6097        case 3373707: /*name*/ return new String[] {};
6098        case -261851592: /*relationship*/ return new String[] {};
6099        case 1625275180: /*nucleicAcid*/ return new String[] {"Reference"};
6100        case -397514098: /*polymer*/ return new String[] {"Reference"};
6101        case -309012605: /*protein*/ return new String[] {"Reference"};
6102        case -1064442270: /*sourceMaterial*/ return new String[] {};
6103        default: return super.getTypesForProperty(hash, name);
6104        }
6105
6106      }
6107
6108      @Override
6109      public Base addChild(String name) throws FHIRException {
6110        if (name.equals("identifier")) {
6111          return addIdentifier();
6112        }
6113        else if (name.equals("version")) {
6114          throw new FHIRException("Cannot call addChild on a primitive type SubstanceDefinition.version");
6115        }
6116        else if (name.equals("status")) {
6117          this.status = new CodeableConcept();
6118          return this.status;
6119        }
6120        else if (name.equals("classification")) {
6121          return addClassification();
6122        }
6123        else if (name.equals("domain")) {
6124          this.domain = new CodeableConcept();
6125          return this.domain;
6126        }
6127        else if (name.equals("grade")) {
6128          return addGrade();
6129        }
6130        else if (name.equals("description")) {
6131          throw new FHIRException("Cannot call addChild on a primitive type SubstanceDefinition.description");
6132        }
6133        else if (name.equals("informationSource")) {
6134          return addInformationSource();
6135        }
6136        else if (name.equals("note")) {
6137          return addNote();
6138        }
6139        else if (name.equals("manufacturer")) {
6140          return addManufacturer();
6141        }
6142        else if (name.equals("supplier")) {
6143          return addSupplier();
6144        }
6145        else if (name.equals("moiety")) {
6146          return addMoiety();
6147        }
6148        else if (name.equals("property")) {
6149          return addProperty();
6150        }
6151        else if (name.equals("referenceInformation")) {
6152          this.referenceInformation = new Reference();
6153          return this.referenceInformation;
6154        }
6155        else if (name.equals("molecularWeight")) {
6156          return addMolecularWeight();
6157        }
6158        else if (name.equals("structure")) {
6159          this.structure = new SubstanceDefinitionStructureComponent();
6160          return this.structure;
6161        }
6162        else if (name.equals("code")) {
6163          return addCode();
6164        }
6165        else if (name.equals("name")) {
6166          return addName();
6167        }
6168        else if (name.equals("relationship")) {
6169          return addRelationship();
6170        }
6171        else if (name.equals("nucleicAcid")) {
6172          this.nucleicAcid = new Reference();
6173          return this.nucleicAcid;
6174        }
6175        else if (name.equals("polymer")) {
6176          this.polymer = new Reference();
6177          return this.polymer;
6178        }
6179        else if (name.equals("protein")) {
6180          this.protein = new Reference();
6181          return this.protein;
6182        }
6183        else if (name.equals("sourceMaterial")) {
6184          this.sourceMaterial = new SubstanceDefinitionSourceMaterialComponent();
6185          return this.sourceMaterial;
6186        }
6187        else
6188          return super.addChild(name);
6189      }
6190
6191  public String fhirType() {
6192    return "SubstanceDefinition";
6193
6194  }
6195
6196      public SubstanceDefinition copy() {
6197        SubstanceDefinition dst = new SubstanceDefinition();
6198        copyValues(dst);
6199        return dst;
6200      }
6201
6202      public void copyValues(SubstanceDefinition dst) {
6203        super.copyValues(dst);
6204        if (identifier != null) {
6205          dst.identifier = new ArrayList<Identifier>();
6206          for (Identifier i : identifier)
6207            dst.identifier.add(i.copy());
6208        };
6209        dst.version = version == null ? null : version.copy();
6210        dst.status = status == null ? null : status.copy();
6211        if (classification != null) {
6212          dst.classification = new ArrayList<CodeableConcept>();
6213          for (CodeableConcept i : classification)
6214            dst.classification.add(i.copy());
6215        };
6216        dst.domain = domain == null ? null : domain.copy();
6217        if (grade != null) {
6218          dst.grade = new ArrayList<CodeableConcept>();
6219          for (CodeableConcept i : grade)
6220            dst.grade.add(i.copy());
6221        };
6222        dst.description = description == null ? null : description.copy();
6223        if (informationSource != null) {
6224          dst.informationSource = new ArrayList<Reference>();
6225          for (Reference i : informationSource)
6226            dst.informationSource.add(i.copy());
6227        };
6228        if (note != null) {
6229          dst.note = new ArrayList<Annotation>();
6230          for (Annotation i : note)
6231            dst.note.add(i.copy());
6232        };
6233        if (manufacturer != null) {
6234          dst.manufacturer = new ArrayList<Reference>();
6235          for (Reference i : manufacturer)
6236            dst.manufacturer.add(i.copy());
6237        };
6238        if (supplier != null) {
6239          dst.supplier = new ArrayList<Reference>();
6240          for (Reference i : supplier)
6241            dst.supplier.add(i.copy());
6242        };
6243        if (moiety != null) {
6244          dst.moiety = new ArrayList<SubstanceDefinitionMoietyComponent>();
6245          for (SubstanceDefinitionMoietyComponent i : moiety)
6246            dst.moiety.add(i.copy());
6247        };
6248        if (property != null) {
6249          dst.property = new ArrayList<SubstanceDefinitionPropertyComponent>();
6250          for (SubstanceDefinitionPropertyComponent i : property)
6251            dst.property.add(i.copy());
6252        };
6253        dst.referenceInformation = referenceInformation == null ? null : referenceInformation.copy();
6254        if (molecularWeight != null) {
6255          dst.molecularWeight = new ArrayList<SubstanceDefinitionMolecularWeightComponent>();
6256          for (SubstanceDefinitionMolecularWeightComponent i : molecularWeight)
6257            dst.molecularWeight.add(i.copy());
6258        };
6259        dst.structure = structure == null ? null : structure.copy();
6260        if (code != null) {
6261          dst.code = new ArrayList<SubstanceDefinitionCodeComponent>();
6262          for (SubstanceDefinitionCodeComponent i : code)
6263            dst.code.add(i.copy());
6264        };
6265        if (name != null) {
6266          dst.name = new ArrayList<SubstanceDefinitionNameComponent>();
6267          for (SubstanceDefinitionNameComponent i : name)
6268            dst.name.add(i.copy());
6269        };
6270        if (relationship != null) {
6271          dst.relationship = new ArrayList<SubstanceDefinitionRelationshipComponent>();
6272          for (SubstanceDefinitionRelationshipComponent i : relationship)
6273            dst.relationship.add(i.copy());
6274        };
6275        dst.nucleicAcid = nucleicAcid == null ? null : nucleicAcid.copy();
6276        dst.polymer = polymer == null ? null : polymer.copy();
6277        dst.protein = protein == null ? null : protein.copy();
6278        dst.sourceMaterial = sourceMaterial == null ? null : sourceMaterial.copy();
6279      }
6280
6281      protected SubstanceDefinition typedCopy() {
6282        return copy();
6283      }
6284
6285      @Override
6286      public boolean equalsDeep(Base other_) {
6287        if (!super.equalsDeep(other_))
6288          return false;
6289        if (!(other_ instanceof SubstanceDefinition))
6290          return false;
6291        SubstanceDefinition o = (SubstanceDefinition) other_;
6292        return compareDeep(identifier, o.identifier, true) && compareDeep(version, o.version, true) && compareDeep(status, o.status, true)
6293           && compareDeep(classification, o.classification, true) && compareDeep(domain, o.domain, true) && compareDeep(grade, o.grade, true)
6294           && compareDeep(description, o.description, true) && compareDeep(informationSource, o.informationSource, true)
6295           && compareDeep(note, o.note, true) && compareDeep(manufacturer, o.manufacturer, true) && compareDeep(supplier, o.supplier, true)
6296           && compareDeep(moiety, o.moiety, true) && compareDeep(property, o.property, true) && compareDeep(referenceInformation, o.referenceInformation, true)
6297           && compareDeep(molecularWeight, o.molecularWeight, true) && compareDeep(structure, o.structure, true)
6298           && compareDeep(code, o.code, true) && compareDeep(name, o.name, true) && compareDeep(relationship, o.relationship, true)
6299           && compareDeep(nucleicAcid, o.nucleicAcid, true) && compareDeep(polymer, o.polymer, true) && compareDeep(protein, o.protein, true)
6300           && compareDeep(sourceMaterial, o.sourceMaterial, true);
6301      }
6302
6303      @Override
6304      public boolean equalsShallow(Base other_) {
6305        if (!super.equalsShallow(other_))
6306          return false;
6307        if (!(other_ instanceof SubstanceDefinition))
6308          return false;
6309        SubstanceDefinition o = (SubstanceDefinition) other_;
6310        return compareValues(version, o.version, true) && compareValues(description, o.description, true);
6311      }
6312
6313      public boolean isEmpty() {
6314        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, version, status
6315          , classification, domain, grade, description, informationSource, note, manufacturer
6316          , supplier, moiety, property, referenceInformation, molecularWeight, structure, code
6317          , name, relationship, nucleicAcid, polymer, protein, sourceMaterial);
6318      }
6319
6320  @Override
6321  public ResourceType getResourceType() {
6322    return ResourceType.SubstanceDefinition;
6323   }
6324
6325 /**
6326   * Search parameter: <b>classification</b>
6327   * <p>
6328   * Description: <b>High or low level categorization, e.g. polymer vs. nucleic acid or linear vs. branch chain</b><br>
6329   * Type: <b>token</b><br>
6330   * Path: <b>SubstanceDefinition.classification</b><br>
6331   * </p>
6332   */
6333  @SearchParamDefinition(name="classification", path="SubstanceDefinition.classification", description="High or low level categorization, e.g. polymer vs. nucleic acid or linear vs. branch chain", type="token" )
6334  public static final String SP_CLASSIFICATION = "classification";
6335 /**
6336   * <b>Fluent Client</b> search parameter constant for <b>classification</b>
6337   * <p>
6338   * Description: <b>High or low level categorization, e.g. polymer vs. nucleic acid or linear vs. branch chain</b><br>
6339   * Type: <b>token</b><br>
6340   * Path: <b>SubstanceDefinition.classification</b><br>
6341   * </p>
6342   */
6343  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CLASSIFICATION = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CLASSIFICATION);
6344
6345 /**
6346   * Search parameter: <b>code</b>
6347   * <p>
6348   * Description: <b>The specific code</b><br>
6349   * Type: <b>token</b><br>
6350   * Path: <b>SubstanceDefinition.code.code</b><br>
6351   * </p>
6352   */
6353  @SearchParamDefinition(name="code", path="SubstanceDefinition.code.code", description="The specific code", type="token" )
6354  public static final String SP_CODE = "code";
6355 /**
6356   * <b>Fluent Client</b> search parameter constant for <b>code</b>
6357   * <p>
6358   * Description: <b>The specific code</b><br>
6359   * Type: <b>token</b><br>
6360   * Path: <b>SubstanceDefinition.code.code</b><br>
6361   * </p>
6362   */
6363  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CODE);
6364
6365 /**
6366   * Search parameter: <b>domain</b>
6367   * <p>
6368   * Description: <b>If the substance applies to only human or veterinary use</b><br>
6369   * Type: <b>token</b><br>
6370   * Path: <b>SubstanceDefinition.domain</b><br>
6371   * </p>
6372   */
6373  @SearchParamDefinition(name="domain", path="SubstanceDefinition.domain", description="If the substance applies to only human or veterinary use", type="token" )
6374  public static final String SP_DOMAIN = "domain";
6375 /**
6376   * <b>Fluent Client</b> search parameter constant for <b>domain</b>
6377   * <p>
6378   * Description: <b>If the substance applies to only human or veterinary use</b><br>
6379   * Type: <b>token</b><br>
6380   * Path: <b>SubstanceDefinition.domain</b><br>
6381   * </p>
6382   */
6383  public static final ca.uhn.fhir.rest.gclient.TokenClientParam DOMAIN = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_DOMAIN);
6384
6385 /**
6386   * Search parameter: <b>identifier</b>
6387   * <p>
6388   * Description: <b>Identifier by which this substance is known</b><br>
6389   * Type: <b>token</b><br>
6390   * Path: <b>SubstanceDefinition.identifier</b><br>
6391   * </p>
6392   */
6393  @SearchParamDefinition(name="identifier", path="SubstanceDefinition.identifier", description="Identifier by which this substance is known", type="token" )
6394  public static final String SP_IDENTIFIER = "identifier";
6395 /**
6396   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
6397   * <p>
6398   * Description: <b>Identifier by which this substance is known</b><br>
6399   * Type: <b>token</b><br>
6400   * Path: <b>SubstanceDefinition.identifier</b><br>
6401   * </p>
6402   */
6403  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
6404
6405 /**
6406   * Search parameter: <b>name</b>
6407   * <p>
6408   * Description: <b>The actual name</b><br>
6409   * Type: <b>string</b><br>
6410   * Path: <b>SubstanceDefinition.name.name</b><br>
6411   * </p>
6412   */
6413  @SearchParamDefinition(name="name", path="SubstanceDefinition.name.name", description="The actual name", type="string" )
6414  public static final String SP_NAME = "name";
6415 /**
6416   * <b>Fluent Client</b> search parameter constant for <b>name</b>
6417   * <p>
6418   * Description: <b>The actual name</b><br>
6419   * Type: <b>string</b><br>
6420   * Path: <b>SubstanceDefinition.name.name</b><br>
6421   * </p>
6422   */
6423  public static final ca.uhn.fhir.rest.gclient.StringClientParam NAME = new ca.uhn.fhir.rest.gclient.StringClientParam(SP_NAME);
6424
6425
6426}
6427