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