001package org.hl7.fhir.r4.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Thu, Sep 13, 2018 09:04-0400 for FHIR v3.5.0
033
034import java.util.*;
035
036import org.hl7.fhir.utilities.Utilities;
037import ca.uhn.fhir.model.api.annotation.ResourceDef;
038import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.ChildOrder;
041import ca.uhn.fhir.model.api.annotation.Description;
042import ca.uhn.fhir.model.api.annotation.Block;
043import org.hl7.fhir.instance.model.api.*;
044import org.hl7.fhir.exceptions.FHIRException;
045/**
046 * The detailed description of a substance, typically at a level beyond what is used for prescribing.
047 */
048@ResourceDef(name="SubstanceSpecification", profile="http://hl7.org/fhir/StructureDefinition/SubstanceSpecification")
049public class SubstanceSpecification extends DomainResource {
050
051    @Block()
052    public static class SubstanceSpecificationMoietyComponent extends BackboneElement implements IBaseBackboneElement {
053        /**
054         * Role that the moiety is playing.
055         */
056        @Child(name = "role", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
057        @Description(shortDefinition="Role that the moiety is playing", formalDefinition="Role that the moiety is playing." )
058        protected CodeableConcept role;
059
060        /**
061         * Identifier by which this moiety substance is known.
062         */
063        @Child(name = "identifier", type = {Identifier.class}, order=2, min=0, max=1, modifier=false, summary=true)
064        @Description(shortDefinition="Identifier by which this moiety substance is known", formalDefinition="Identifier by which this moiety substance is known." )
065        protected Identifier identifier;
066
067        /**
068         * Textual name for this moiety substance.
069         */
070        @Child(name = "name", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true)
071        @Description(shortDefinition="Textual name for this moiety substance", formalDefinition="Textual name for this moiety substance." )
072        protected StringType name;
073
074        /**
075         * Stereochemistry type.
076         */
077        @Child(name = "stereochemistry", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=true)
078        @Description(shortDefinition="Stereochemistry type", formalDefinition="Stereochemistry type." )
079        protected CodeableConcept stereochemistry;
080
081        /**
082         * Optical activity type.
083         */
084        @Child(name = "opticalActivity", type = {CodeableConcept.class}, order=5, min=0, max=1, modifier=false, summary=true)
085        @Description(shortDefinition="Optical activity type", formalDefinition="Optical activity type." )
086        protected CodeableConcept opticalActivity;
087
088        /**
089         * Molecular formula.
090         */
091        @Child(name = "molecularFormula", type = {StringType.class}, order=6, min=0, max=1, modifier=false, summary=true)
092        @Description(shortDefinition="Molecular formula", formalDefinition="Molecular formula." )
093        protected StringType molecularFormula;
094
095        /**
096         * Quantitative value for this moiety.
097         */
098        @Child(name = "amount", type = {StringType.class}, order=7, min=0, max=1, modifier=false, summary=true)
099        @Description(shortDefinition="Quantitative value for this moiety", formalDefinition="Quantitative value for this moiety." )
100        protected StringType amount;
101
102        private static final long serialVersionUID = 45594592L;
103
104    /**
105     * Constructor
106     */
107      public SubstanceSpecificationMoietyComponent() {
108        super();
109      }
110
111        /**
112         * @return {@link #role} (Role that the moiety is playing.)
113         */
114        public CodeableConcept getRole() { 
115          if (this.role == null)
116            if (Configuration.errorOnAutoCreate())
117              throw new Error("Attempt to auto-create SubstanceSpecificationMoietyComponent.role");
118            else if (Configuration.doAutoCreate())
119              this.role = new CodeableConcept(); // cc
120          return this.role;
121        }
122
123        public boolean hasRole() { 
124          return this.role != null && !this.role.isEmpty();
125        }
126
127        /**
128         * @param value {@link #role} (Role that the moiety is playing.)
129         */
130        public SubstanceSpecificationMoietyComponent setRole(CodeableConcept value) { 
131          this.role = value;
132          return this;
133        }
134
135        /**
136         * @return {@link #identifier} (Identifier by which this moiety substance is known.)
137         */
138        public Identifier getIdentifier() { 
139          if (this.identifier == null)
140            if (Configuration.errorOnAutoCreate())
141              throw new Error("Attempt to auto-create SubstanceSpecificationMoietyComponent.identifier");
142            else if (Configuration.doAutoCreate())
143              this.identifier = new Identifier(); // cc
144          return this.identifier;
145        }
146
147        public boolean hasIdentifier() { 
148          return this.identifier != null && !this.identifier.isEmpty();
149        }
150
151        /**
152         * @param value {@link #identifier} (Identifier by which this moiety substance is known.)
153         */
154        public SubstanceSpecificationMoietyComponent setIdentifier(Identifier value) { 
155          this.identifier = value;
156          return this;
157        }
158
159        /**
160         * @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
161         */
162        public StringType getNameElement() { 
163          if (this.name == null)
164            if (Configuration.errorOnAutoCreate())
165              throw new Error("Attempt to auto-create SubstanceSpecificationMoietyComponent.name");
166            else if (Configuration.doAutoCreate())
167              this.name = new StringType(); // bb
168          return this.name;
169        }
170
171        public boolean hasNameElement() { 
172          return this.name != null && !this.name.isEmpty();
173        }
174
175        public boolean hasName() { 
176          return this.name != null && !this.name.isEmpty();
177        }
178
179        /**
180         * @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
181         */
182        public SubstanceSpecificationMoietyComponent setNameElement(StringType value) { 
183          this.name = value;
184          return this;
185        }
186
187        /**
188         * @return Textual name for this moiety substance.
189         */
190        public String getName() { 
191          return this.name == null ? null : this.name.getValue();
192        }
193
194        /**
195         * @param value Textual name for this moiety substance.
196         */
197        public SubstanceSpecificationMoietyComponent setName(String value) { 
198          if (Utilities.noString(value))
199            this.name = null;
200          else {
201            if (this.name == null)
202              this.name = new StringType();
203            this.name.setValue(value);
204          }
205          return this;
206        }
207
208        /**
209         * @return {@link #stereochemistry} (Stereochemistry type.)
210         */
211        public CodeableConcept getStereochemistry() { 
212          if (this.stereochemistry == null)
213            if (Configuration.errorOnAutoCreate())
214              throw new Error("Attempt to auto-create SubstanceSpecificationMoietyComponent.stereochemistry");
215            else if (Configuration.doAutoCreate())
216              this.stereochemistry = new CodeableConcept(); // cc
217          return this.stereochemistry;
218        }
219
220        public boolean hasStereochemistry() { 
221          return this.stereochemistry != null && !this.stereochemistry.isEmpty();
222        }
223
224        /**
225         * @param value {@link #stereochemistry} (Stereochemistry type.)
226         */
227        public SubstanceSpecificationMoietyComponent setStereochemistry(CodeableConcept value) { 
228          this.stereochemistry = value;
229          return this;
230        }
231
232        /**
233         * @return {@link #opticalActivity} (Optical activity type.)
234         */
235        public CodeableConcept getOpticalActivity() { 
236          if (this.opticalActivity == null)
237            if (Configuration.errorOnAutoCreate())
238              throw new Error("Attempt to auto-create SubstanceSpecificationMoietyComponent.opticalActivity");
239            else if (Configuration.doAutoCreate())
240              this.opticalActivity = new CodeableConcept(); // cc
241          return this.opticalActivity;
242        }
243
244        public boolean hasOpticalActivity() { 
245          return this.opticalActivity != null && !this.opticalActivity.isEmpty();
246        }
247
248        /**
249         * @param value {@link #opticalActivity} (Optical activity type.)
250         */
251        public SubstanceSpecificationMoietyComponent setOpticalActivity(CodeableConcept value) { 
252          this.opticalActivity = value;
253          return this;
254        }
255
256        /**
257         * @return {@link #molecularFormula} (Molecular formula.). This is the underlying object with id, value and extensions. The accessor "getMolecularFormula" gives direct access to the value
258         */
259        public StringType getMolecularFormulaElement() { 
260          if (this.molecularFormula == null)
261            if (Configuration.errorOnAutoCreate())
262              throw new Error("Attempt to auto-create SubstanceSpecificationMoietyComponent.molecularFormula");
263            else if (Configuration.doAutoCreate())
264              this.molecularFormula = new StringType(); // bb
265          return this.molecularFormula;
266        }
267
268        public boolean hasMolecularFormulaElement() { 
269          return this.molecularFormula != null && !this.molecularFormula.isEmpty();
270        }
271
272        public boolean hasMolecularFormula() { 
273          return this.molecularFormula != null && !this.molecularFormula.isEmpty();
274        }
275
276        /**
277         * @param value {@link #molecularFormula} (Molecular formula.). This is the underlying object with id, value and extensions. The accessor "getMolecularFormula" gives direct access to the value
278         */
279        public SubstanceSpecificationMoietyComponent setMolecularFormulaElement(StringType value) { 
280          this.molecularFormula = value;
281          return this;
282        }
283
284        /**
285         * @return Molecular formula.
286         */
287        public String getMolecularFormula() { 
288          return this.molecularFormula == null ? null : this.molecularFormula.getValue();
289        }
290
291        /**
292         * @param value Molecular formula.
293         */
294        public SubstanceSpecificationMoietyComponent setMolecularFormula(String value) { 
295          if (Utilities.noString(value))
296            this.molecularFormula = null;
297          else {
298            if (this.molecularFormula == null)
299              this.molecularFormula = new StringType();
300            this.molecularFormula.setValue(value);
301          }
302          return this;
303        }
304
305        /**
306         * @return {@link #amount} (Quantitative value for this moiety.). This is the underlying object with id, value and extensions. The accessor "getAmount" gives direct access to the value
307         */
308        public StringType getAmountElement() { 
309          if (this.amount == null)
310            if (Configuration.errorOnAutoCreate())
311              throw new Error("Attempt to auto-create SubstanceSpecificationMoietyComponent.amount");
312            else if (Configuration.doAutoCreate())
313              this.amount = new StringType(); // bb
314          return this.amount;
315        }
316
317        public boolean hasAmountElement() { 
318          return this.amount != null && !this.amount.isEmpty();
319        }
320
321        public boolean hasAmount() { 
322          return this.amount != null && !this.amount.isEmpty();
323        }
324
325        /**
326         * @param value {@link #amount} (Quantitative value for this moiety.). This is the underlying object with id, value and extensions. The accessor "getAmount" gives direct access to the value
327         */
328        public SubstanceSpecificationMoietyComponent setAmountElement(StringType value) { 
329          this.amount = value;
330          return this;
331        }
332
333        /**
334         * @return Quantitative value for this moiety.
335         */
336        public String getAmount() { 
337          return this.amount == null ? null : this.amount.getValue();
338        }
339
340        /**
341         * @param value Quantitative value for this moiety.
342         */
343        public SubstanceSpecificationMoietyComponent setAmount(String value) { 
344          if (Utilities.noString(value))
345            this.amount = null;
346          else {
347            if (this.amount == null)
348              this.amount = new StringType();
349            this.amount.setValue(value);
350          }
351          return this;
352        }
353
354        protected void listChildren(List<Property> children) {
355          super.listChildren(children);
356          children.add(new Property("role", "CodeableConcept", "Role that the moiety is playing.", 0, 1, role));
357          children.add(new Property("identifier", "Identifier", "Identifier by which this moiety substance is known.", 0, 1, identifier));
358          children.add(new Property("name", "string", "Textual name for this moiety substance.", 0, 1, name));
359          children.add(new Property("stereochemistry", "CodeableConcept", "Stereochemistry type.", 0, 1, stereochemistry));
360          children.add(new Property("opticalActivity", "CodeableConcept", "Optical activity type.", 0, 1, opticalActivity));
361          children.add(new Property("molecularFormula", "string", "Molecular formula.", 0, 1, molecularFormula));
362          children.add(new Property("amount", "string", "Quantitative value for this moiety.", 0, 1, amount));
363        }
364
365        @Override
366        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
367          switch (_hash) {
368          case 3506294: /*role*/  return new Property("role", "CodeableConcept", "Role that the moiety is playing.", 0, 1, role);
369          case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Identifier by which this moiety substance is known.", 0, 1, identifier);
370          case 3373707: /*name*/  return new Property("name", "string", "Textual name for this moiety substance.", 0, 1, name);
371          case 263475116: /*stereochemistry*/  return new Property("stereochemistry", "CodeableConcept", "Stereochemistry type.", 0, 1, stereochemistry);
372          case 1420900135: /*opticalActivity*/  return new Property("opticalActivity", "CodeableConcept", "Optical activity type.", 0, 1, opticalActivity);
373          case 616660246: /*molecularFormula*/  return new Property("molecularFormula", "string", "Molecular formula.", 0, 1, molecularFormula);
374          case -1413853096: /*amount*/  return new Property("amount", "string", "Quantitative value for this moiety.", 0, 1, amount);
375          default: return super.getNamedProperty(_hash, _name, _checkValid);
376          }
377
378        }
379
380      @Override
381      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
382        switch (hash) {
383        case 3506294: /*role*/ return this.role == null ? new Base[0] : new Base[] {this.role}; // CodeableConcept
384        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : new Base[] {this.identifier}; // Identifier
385        case 3373707: /*name*/ return this.name == null ? new Base[0] : new Base[] {this.name}; // StringType
386        case 263475116: /*stereochemistry*/ return this.stereochemistry == null ? new Base[0] : new Base[] {this.stereochemistry}; // CodeableConcept
387        case 1420900135: /*opticalActivity*/ return this.opticalActivity == null ? new Base[0] : new Base[] {this.opticalActivity}; // CodeableConcept
388        case 616660246: /*molecularFormula*/ return this.molecularFormula == null ? new Base[0] : new Base[] {this.molecularFormula}; // StringType
389        case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : new Base[] {this.amount}; // StringType
390        default: return super.getProperty(hash, name, checkValid);
391        }
392
393      }
394
395      @Override
396      public Base setProperty(int hash, String name, Base value) throws FHIRException {
397        switch (hash) {
398        case 3506294: // role
399          this.role = castToCodeableConcept(value); // CodeableConcept
400          return value;
401        case -1618432855: // identifier
402          this.identifier = castToIdentifier(value); // Identifier
403          return value;
404        case 3373707: // name
405          this.name = castToString(value); // StringType
406          return value;
407        case 263475116: // stereochemistry
408          this.stereochemistry = castToCodeableConcept(value); // CodeableConcept
409          return value;
410        case 1420900135: // opticalActivity
411          this.opticalActivity = castToCodeableConcept(value); // CodeableConcept
412          return value;
413        case 616660246: // molecularFormula
414          this.molecularFormula = castToString(value); // StringType
415          return value;
416        case -1413853096: // amount
417          this.amount = castToString(value); // StringType
418          return value;
419        default: return super.setProperty(hash, name, value);
420        }
421
422      }
423
424      @Override
425      public Base setProperty(String name, Base value) throws FHIRException {
426        if (name.equals("role")) {
427          this.role = castToCodeableConcept(value); // CodeableConcept
428        } else if (name.equals("identifier")) {
429          this.identifier = castToIdentifier(value); // Identifier
430        } else if (name.equals("name")) {
431          this.name = castToString(value); // StringType
432        } else if (name.equals("stereochemistry")) {
433          this.stereochemistry = castToCodeableConcept(value); // CodeableConcept
434        } else if (name.equals("opticalActivity")) {
435          this.opticalActivity = castToCodeableConcept(value); // CodeableConcept
436        } else if (name.equals("molecularFormula")) {
437          this.molecularFormula = castToString(value); // StringType
438        } else if (name.equals("amount")) {
439          this.amount = castToString(value); // StringType
440        } else
441          return super.setProperty(name, value);
442        return value;
443      }
444
445      @Override
446      public Base makeProperty(int hash, String name) throws FHIRException {
447        switch (hash) {
448        case 3506294:  return getRole(); 
449        case -1618432855:  return getIdentifier(); 
450        case 3373707:  return getNameElement();
451        case 263475116:  return getStereochemistry(); 
452        case 1420900135:  return getOpticalActivity(); 
453        case 616660246:  return getMolecularFormulaElement();
454        case -1413853096:  return getAmountElement();
455        default: return super.makeProperty(hash, name);
456        }
457
458      }
459
460      @Override
461      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
462        switch (hash) {
463        case 3506294: /*role*/ return new String[] {"CodeableConcept"};
464        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
465        case 3373707: /*name*/ return new String[] {"string"};
466        case 263475116: /*stereochemistry*/ return new String[] {"CodeableConcept"};
467        case 1420900135: /*opticalActivity*/ return new String[] {"CodeableConcept"};
468        case 616660246: /*molecularFormula*/ return new String[] {"string"};
469        case -1413853096: /*amount*/ return new String[] {"string"};
470        default: return super.getTypesForProperty(hash, name);
471        }
472
473      }
474
475      @Override
476      public Base addChild(String name) throws FHIRException {
477        if (name.equals("role")) {
478          this.role = new CodeableConcept();
479          return this.role;
480        }
481        else if (name.equals("identifier")) {
482          this.identifier = new Identifier();
483          return this.identifier;
484        }
485        else if (name.equals("name")) {
486          throw new FHIRException("Cannot call addChild on a primitive type SubstanceSpecification.name");
487        }
488        else if (name.equals("stereochemistry")) {
489          this.stereochemistry = new CodeableConcept();
490          return this.stereochemistry;
491        }
492        else if (name.equals("opticalActivity")) {
493          this.opticalActivity = new CodeableConcept();
494          return this.opticalActivity;
495        }
496        else if (name.equals("molecularFormula")) {
497          throw new FHIRException("Cannot call addChild on a primitive type SubstanceSpecification.molecularFormula");
498        }
499        else if (name.equals("amount")) {
500          throw new FHIRException("Cannot call addChild on a primitive type SubstanceSpecification.amount");
501        }
502        else
503          return super.addChild(name);
504      }
505
506      public SubstanceSpecificationMoietyComponent copy() {
507        SubstanceSpecificationMoietyComponent dst = new SubstanceSpecificationMoietyComponent();
508        copyValues(dst);
509        dst.role = role == null ? null : role.copy();
510        dst.identifier = identifier == null ? null : identifier.copy();
511        dst.name = name == null ? null : name.copy();
512        dst.stereochemistry = stereochemistry == null ? null : stereochemistry.copy();
513        dst.opticalActivity = opticalActivity == null ? null : opticalActivity.copy();
514        dst.molecularFormula = molecularFormula == null ? null : molecularFormula.copy();
515        dst.amount = amount == null ? null : amount.copy();
516        return dst;
517      }
518
519      @Override
520      public boolean equalsDeep(Base other_) {
521        if (!super.equalsDeep(other_))
522          return false;
523        if (!(other_ instanceof SubstanceSpecificationMoietyComponent))
524          return false;
525        SubstanceSpecificationMoietyComponent o = (SubstanceSpecificationMoietyComponent) other_;
526        return compareDeep(role, o.role, true) && compareDeep(identifier, o.identifier, true) && compareDeep(name, o.name, true)
527           && compareDeep(stereochemistry, o.stereochemistry, true) && compareDeep(opticalActivity, o.opticalActivity, true)
528           && compareDeep(molecularFormula, o.molecularFormula, true) && compareDeep(amount, o.amount, true)
529          ;
530      }
531
532      @Override
533      public boolean equalsShallow(Base other_) {
534        if (!super.equalsShallow(other_))
535          return false;
536        if (!(other_ instanceof SubstanceSpecificationMoietyComponent))
537          return false;
538        SubstanceSpecificationMoietyComponent o = (SubstanceSpecificationMoietyComponent) other_;
539        return compareValues(name, o.name, true) && compareValues(molecularFormula, o.molecularFormula, true)
540           && compareValues(amount, o.amount, true);
541      }
542
543      public boolean isEmpty() {
544        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(role, identifier, name, stereochemistry
545          , opticalActivity, molecularFormula, amount);
546      }
547
548  public String fhirType() {
549    return "SubstanceSpecification.moiety";
550
551  }
552
553  }
554
555    @Block()
556    public static class SubstanceSpecificationPropertyComponent extends BackboneElement implements IBaseBackboneElement {
557        /**
558         * Description todo.
559         */
560        @Child(name = "type", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
561        @Description(shortDefinition="Description todo", formalDefinition="Description todo." )
562        protected CodeableConcept type;
563
564        /**
565         * Description todo.
566         */
567        @Child(name = "name", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
568        @Description(shortDefinition="Description todo", formalDefinition="Description todo." )
569        protected CodeableConcept name;
570
571        /**
572         * A field that should be used to capture parameters that were used in the measurement of a property.
573         */
574        @Child(name = "parameters", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true)
575        @Description(shortDefinition="A field that should be used to capture parameters that were used in the measurement of a property", formalDefinition="A field that should be used to capture parameters that were used in the measurement of a property." )
576        protected StringType parameters;
577
578        /**
579         * Identifier for a substance upon which a defining property depends.
580         */
581        @Child(name = "substanceId", type = {Identifier.class}, order=4, min=0, max=1, modifier=false, summary=true)
582        @Description(shortDefinition="Identifier for a substance upon which a defining property depends", formalDefinition="Identifier for a substance upon which a defining property depends." )
583        protected Identifier substanceId;
584
585        /**
586         * Description todo.
587         */
588        @Child(name = "substanceName", type = {StringType.class}, order=5, min=0, max=1, modifier=false, summary=true)
589        @Description(shortDefinition="Description todo", formalDefinition="Description todo." )
590        protected StringType substanceName;
591
592        /**
593         * Quantitative value for this property.
594         */
595        @Child(name = "amount", type = {StringType.class}, order=6, min=0, max=1, modifier=false, summary=true)
596        @Description(shortDefinition="Quantitative value for this property", formalDefinition="Quantitative value for this property." )
597        protected StringType amount;
598
599        private static final long serialVersionUID = 83235941L;
600
601    /**
602     * Constructor
603     */
604      public SubstanceSpecificationPropertyComponent() {
605        super();
606      }
607
608        /**
609         * @return {@link #type} (Description todo.)
610         */
611        public CodeableConcept getType() { 
612          if (this.type == null)
613            if (Configuration.errorOnAutoCreate())
614              throw new Error("Attempt to auto-create SubstanceSpecificationPropertyComponent.type");
615            else if (Configuration.doAutoCreate())
616              this.type = new CodeableConcept(); // cc
617          return this.type;
618        }
619
620        public boolean hasType() { 
621          return this.type != null && !this.type.isEmpty();
622        }
623
624        /**
625         * @param value {@link #type} (Description todo.)
626         */
627        public SubstanceSpecificationPropertyComponent setType(CodeableConcept value) { 
628          this.type = value;
629          return this;
630        }
631
632        /**
633         * @return {@link #name} (Description todo.)
634         */
635        public CodeableConcept getName() { 
636          if (this.name == null)
637            if (Configuration.errorOnAutoCreate())
638              throw new Error("Attempt to auto-create SubstanceSpecificationPropertyComponent.name");
639            else if (Configuration.doAutoCreate())
640              this.name = new CodeableConcept(); // cc
641          return this.name;
642        }
643
644        public boolean hasName() { 
645          return this.name != null && !this.name.isEmpty();
646        }
647
648        /**
649         * @param value {@link #name} (Description todo.)
650         */
651        public SubstanceSpecificationPropertyComponent setName(CodeableConcept value) { 
652          this.name = value;
653          return this;
654        }
655
656        /**
657         * @return {@link #parameters} (A field that should be used to capture parameters that were used in the measurement of a property.). This is the underlying object with id, value and extensions. The accessor "getParameters" gives direct access to the value
658         */
659        public StringType getParametersElement() { 
660          if (this.parameters == null)
661            if (Configuration.errorOnAutoCreate())
662              throw new Error("Attempt to auto-create SubstanceSpecificationPropertyComponent.parameters");
663            else if (Configuration.doAutoCreate())
664              this.parameters = new StringType(); // bb
665          return this.parameters;
666        }
667
668        public boolean hasParametersElement() { 
669          return this.parameters != null && !this.parameters.isEmpty();
670        }
671
672        public boolean hasParameters() { 
673          return this.parameters != null && !this.parameters.isEmpty();
674        }
675
676        /**
677         * @param value {@link #parameters} (A field that should be used to capture parameters that were used in the measurement of a property.). This is the underlying object with id, value and extensions. The accessor "getParameters" gives direct access to the value
678         */
679        public SubstanceSpecificationPropertyComponent setParametersElement(StringType value) { 
680          this.parameters = value;
681          return this;
682        }
683
684        /**
685         * @return A field that should be used to capture parameters that were used in the measurement of a property.
686         */
687        public String getParameters() { 
688          return this.parameters == null ? null : this.parameters.getValue();
689        }
690
691        /**
692         * @param value A field that should be used to capture parameters that were used in the measurement of a property.
693         */
694        public SubstanceSpecificationPropertyComponent setParameters(String value) { 
695          if (Utilities.noString(value))
696            this.parameters = null;
697          else {
698            if (this.parameters == null)
699              this.parameters = new StringType();
700            this.parameters.setValue(value);
701          }
702          return this;
703        }
704
705        /**
706         * @return {@link #substanceId} (Identifier for a substance upon which a defining property depends.)
707         */
708        public Identifier getSubstanceId() { 
709          if (this.substanceId == null)
710            if (Configuration.errorOnAutoCreate())
711              throw new Error("Attempt to auto-create SubstanceSpecificationPropertyComponent.substanceId");
712            else if (Configuration.doAutoCreate())
713              this.substanceId = new Identifier(); // cc
714          return this.substanceId;
715        }
716
717        public boolean hasSubstanceId() { 
718          return this.substanceId != null && !this.substanceId.isEmpty();
719        }
720
721        /**
722         * @param value {@link #substanceId} (Identifier for a substance upon which a defining property depends.)
723         */
724        public SubstanceSpecificationPropertyComponent setSubstanceId(Identifier value) { 
725          this.substanceId = value;
726          return this;
727        }
728
729        /**
730         * @return {@link #substanceName} (Description todo.). This is the underlying object with id, value and extensions. The accessor "getSubstanceName" gives direct access to the value
731         */
732        public StringType getSubstanceNameElement() { 
733          if (this.substanceName == null)
734            if (Configuration.errorOnAutoCreate())
735              throw new Error("Attempt to auto-create SubstanceSpecificationPropertyComponent.substanceName");
736            else if (Configuration.doAutoCreate())
737              this.substanceName = new StringType(); // bb
738          return this.substanceName;
739        }
740
741        public boolean hasSubstanceNameElement() { 
742          return this.substanceName != null && !this.substanceName.isEmpty();
743        }
744
745        public boolean hasSubstanceName() { 
746          return this.substanceName != null && !this.substanceName.isEmpty();
747        }
748
749        /**
750         * @param value {@link #substanceName} (Description todo.). This is the underlying object with id, value and extensions. The accessor "getSubstanceName" gives direct access to the value
751         */
752        public SubstanceSpecificationPropertyComponent setSubstanceNameElement(StringType value) { 
753          this.substanceName = value;
754          return this;
755        }
756
757        /**
758         * @return Description todo.
759         */
760        public String getSubstanceName() { 
761          return this.substanceName == null ? null : this.substanceName.getValue();
762        }
763
764        /**
765         * @param value Description todo.
766         */
767        public SubstanceSpecificationPropertyComponent setSubstanceName(String value) { 
768          if (Utilities.noString(value))
769            this.substanceName = null;
770          else {
771            if (this.substanceName == null)
772              this.substanceName = new StringType();
773            this.substanceName.setValue(value);
774          }
775          return this;
776        }
777
778        /**
779         * @return {@link #amount} (Quantitative value for this property.). This is the underlying object with id, value and extensions. The accessor "getAmount" gives direct access to the value
780         */
781        public StringType getAmountElement() { 
782          if (this.amount == null)
783            if (Configuration.errorOnAutoCreate())
784              throw new Error("Attempt to auto-create SubstanceSpecificationPropertyComponent.amount");
785            else if (Configuration.doAutoCreate())
786              this.amount = new StringType(); // bb
787          return this.amount;
788        }
789
790        public boolean hasAmountElement() { 
791          return this.amount != null && !this.amount.isEmpty();
792        }
793
794        public boolean hasAmount() { 
795          return this.amount != null && !this.amount.isEmpty();
796        }
797
798        /**
799         * @param value {@link #amount} (Quantitative value for this property.). This is the underlying object with id, value and extensions. The accessor "getAmount" gives direct access to the value
800         */
801        public SubstanceSpecificationPropertyComponent setAmountElement(StringType value) { 
802          this.amount = value;
803          return this;
804        }
805
806        /**
807         * @return Quantitative value for this property.
808         */
809        public String getAmount() { 
810          return this.amount == null ? null : this.amount.getValue();
811        }
812
813        /**
814         * @param value Quantitative value for this property.
815         */
816        public SubstanceSpecificationPropertyComponent setAmount(String value) { 
817          if (Utilities.noString(value))
818            this.amount = null;
819          else {
820            if (this.amount == null)
821              this.amount = new StringType();
822            this.amount.setValue(value);
823          }
824          return this;
825        }
826
827        protected void listChildren(List<Property> children) {
828          super.listChildren(children);
829          children.add(new Property("type", "CodeableConcept", "Description todo.", 0, 1, type));
830          children.add(new Property("name", "CodeableConcept", "Description todo.", 0, 1, name));
831          children.add(new Property("parameters", "string", "A field that should be used to capture parameters that were used in the measurement of a property.", 0, 1, parameters));
832          children.add(new Property("substanceId", "Identifier", "Identifier for a substance upon which a defining property depends.", 0, 1, substanceId));
833          children.add(new Property("substanceName", "string", "Description todo.", 0, 1, substanceName));
834          children.add(new Property("amount", "string", "Quantitative value for this property.", 0, 1, amount));
835        }
836
837        @Override
838        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
839          switch (_hash) {
840          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "Description todo.", 0, 1, type);
841          case 3373707: /*name*/  return new Property("name", "CodeableConcept", "Description todo.", 0, 1, name);
842          case 458736106: /*parameters*/  return new Property("parameters", "string", "A field that should be used to capture parameters that were used in the measurement of a property.", 0, 1, parameters);
843          case -1732496725: /*substanceId*/  return new Property("substanceId", "Identifier", "Identifier for a substance upon which a defining property depends.", 0, 1, substanceId);
844          case 1518107675: /*substanceName*/  return new Property("substanceName", "string", "Description todo.", 0, 1, substanceName);
845          case -1413853096: /*amount*/  return new Property("amount", "string", "Quantitative value for this property.", 0, 1, amount);
846          default: return super.getNamedProperty(_hash, _name, _checkValid);
847          }
848
849        }
850
851      @Override
852      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
853        switch (hash) {
854        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
855        case 3373707: /*name*/ return this.name == null ? new Base[0] : new Base[] {this.name}; // CodeableConcept
856        case 458736106: /*parameters*/ return this.parameters == null ? new Base[0] : new Base[] {this.parameters}; // StringType
857        case -1732496725: /*substanceId*/ return this.substanceId == null ? new Base[0] : new Base[] {this.substanceId}; // Identifier
858        case 1518107675: /*substanceName*/ return this.substanceName == null ? new Base[0] : new Base[] {this.substanceName}; // StringType
859        case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : new Base[] {this.amount}; // StringType
860        default: return super.getProperty(hash, name, checkValid);
861        }
862
863      }
864
865      @Override
866      public Base setProperty(int hash, String name, Base value) throws FHIRException {
867        switch (hash) {
868        case 3575610: // type
869          this.type = castToCodeableConcept(value); // CodeableConcept
870          return value;
871        case 3373707: // name
872          this.name = castToCodeableConcept(value); // CodeableConcept
873          return value;
874        case 458736106: // parameters
875          this.parameters = castToString(value); // StringType
876          return value;
877        case -1732496725: // substanceId
878          this.substanceId = castToIdentifier(value); // Identifier
879          return value;
880        case 1518107675: // substanceName
881          this.substanceName = castToString(value); // StringType
882          return value;
883        case -1413853096: // amount
884          this.amount = castToString(value); // StringType
885          return value;
886        default: return super.setProperty(hash, name, value);
887        }
888
889      }
890
891      @Override
892      public Base setProperty(String name, Base value) throws FHIRException {
893        if (name.equals("type")) {
894          this.type = castToCodeableConcept(value); // CodeableConcept
895        } else if (name.equals("name")) {
896          this.name = castToCodeableConcept(value); // CodeableConcept
897        } else if (name.equals("parameters")) {
898          this.parameters = castToString(value); // StringType
899        } else if (name.equals("substanceId")) {
900          this.substanceId = castToIdentifier(value); // Identifier
901        } else if (name.equals("substanceName")) {
902          this.substanceName = castToString(value); // StringType
903        } else if (name.equals("amount")) {
904          this.amount = castToString(value); // StringType
905        } else
906          return super.setProperty(name, value);
907        return value;
908      }
909
910      @Override
911      public Base makeProperty(int hash, String name) throws FHIRException {
912        switch (hash) {
913        case 3575610:  return getType(); 
914        case 3373707:  return getName(); 
915        case 458736106:  return getParametersElement();
916        case -1732496725:  return getSubstanceId(); 
917        case 1518107675:  return getSubstanceNameElement();
918        case -1413853096:  return getAmountElement();
919        default: return super.makeProperty(hash, name);
920        }
921
922      }
923
924      @Override
925      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
926        switch (hash) {
927        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
928        case 3373707: /*name*/ return new String[] {"CodeableConcept"};
929        case 458736106: /*parameters*/ return new String[] {"string"};
930        case -1732496725: /*substanceId*/ return new String[] {"Identifier"};
931        case 1518107675: /*substanceName*/ return new String[] {"string"};
932        case -1413853096: /*amount*/ return new String[] {"string"};
933        default: return super.getTypesForProperty(hash, name);
934        }
935
936      }
937
938      @Override
939      public Base addChild(String name) throws FHIRException {
940        if (name.equals("type")) {
941          this.type = new CodeableConcept();
942          return this.type;
943        }
944        else if (name.equals("name")) {
945          this.name = new CodeableConcept();
946          return this.name;
947        }
948        else if (name.equals("parameters")) {
949          throw new FHIRException("Cannot call addChild on a primitive type SubstanceSpecification.parameters");
950        }
951        else if (name.equals("substanceId")) {
952          this.substanceId = new Identifier();
953          return this.substanceId;
954        }
955        else if (name.equals("substanceName")) {
956          throw new FHIRException("Cannot call addChild on a primitive type SubstanceSpecification.substanceName");
957        }
958        else if (name.equals("amount")) {
959          throw new FHIRException("Cannot call addChild on a primitive type SubstanceSpecification.amount");
960        }
961        else
962          return super.addChild(name);
963      }
964
965      public SubstanceSpecificationPropertyComponent copy() {
966        SubstanceSpecificationPropertyComponent dst = new SubstanceSpecificationPropertyComponent();
967        copyValues(dst);
968        dst.type = type == null ? null : type.copy();
969        dst.name = name == null ? null : name.copy();
970        dst.parameters = parameters == null ? null : parameters.copy();
971        dst.substanceId = substanceId == null ? null : substanceId.copy();
972        dst.substanceName = substanceName == null ? null : substanceName.copy();
973        dst.amount = amount == null ? null : amount.copy();
974        return dst;
975      }
976
977      @Override
978      public boolean equalsDeep(Base other_) {
979        if (!super.equalsDeep(other_))
980          return false;
981        if (!(other_ instanceof SubstanceSpecificationPropertyComponent))
982          return false;
983        SubstanceSpecificationPropertyComponent o = (SubstanceSpecificationPropertyComponent) other_;
984        return compareDeep(type, o.type, true) && compareDeep(name, o.name, true) && compareDeep(parameters, o.parameters, true)
985           && compareDeep(substanceId, o.substanceId, true) && compareDeep(substanceName, o.substanceName, true)
986           && compareDeep(amount, o.amount, true);
987      }
988
989      @Override
990      public boolean equalsShallow(Base other_) {
991        if (!super.equalsShallow(other_))
992          return false;
993        if (!(other_ instanceof SubstanceSpecificationPropertyComponent))
994          return false;
995        SubstanceSpecificationPropertyComponent o = (SubstanceSpecificationPropertyComponent) other_;
996        return compareValues(parameters, o.parameters, true) && compareValues(substanceName, o.substanceName, true)
997           && compareValues(amount, o.amount, true);
998      }
999
1000      public boolean isEmpty() {
1001        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, name, parameters, substanceId
1002          , substanceName, amount);
1003      }
1004
1005  public String fhirType() {
1006    return "SubstanceSpecification.property";
1007
1008  }
1009
1010  }
1011
1012    @Block()
1013    public static class SubstanceSpecificationStructureComponent extends BackboneElement implements IBaseBackboneElement {
1014        /**
1015         * Stereochemistry type.
1016         */
1017        @Child(name = "stereochemistry", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
1018        @Description(shortDefinition="Stereochemistry type", formalDefinition="Stereochemistry type." )
1019        protected CodeableConcept stereochemistry;
1020
1021        /**
1022         * Optical activity type.
1023         */
1024        @Child(name = "opticalActivity", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
1025        @Description(shortDefinition="Optical activity type", formalDefinition="Optical activity type." )
1026        protected CodeableConcept opticalActivity;
1027
1028        /**
1029         * Molecular formula.
1030         */
1031        @Child(name = "molecularFormula", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true)
1032        @Description(shortDefinition="Molecular formula", formalDefinition="Molecular formula." )
1033        protected StringType molecularFormula;
1034
1035        /**
1036         * Specified per moiety according to the Hill system, i.e. first C, then H, then alphabetical. and each moiety separated by a dot.
1037         */
1038        @Child(name = "molecularFormulaByMoiety", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=true)
1039        @Description(shortDefinition="Specified per moiety according to the Hill system, i.e. first C, then H, then alphabetical. and each moiety separated by a dot", formalDefinition="Specified per moiety according to the Hill system, i.e. first C, then H, then alphabetical. and each moiety separated by a dot." )
1040        protected StringType molecularFormulaByMoiety;
1041
1042        /**
1043         * Applicable for single substances that contain a radionuclide or a non-natural isotopic ratio.
1044         */
1045        @Child(name = "isotope", type = {}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1046        @Description(shortDefinition="Applicable for single substances that contain a radionuclide or a non-natural isotopic ratio", formalDefinition="Applicable for single substances that contain a radionuclide or a non-natural isotopic ratio." )
1047        protected List<SubstanceSpecificationStructureIsotopeComponent> isotope;
1048
1049        /**
1050         * The molecular weight or weight range (for proteins, polymers or nucleic acids).
1051         */
1052        @Child(name = "molecularWeight", type = {SubstanceSpecificationStructureIsotopeMolecularWeightComponent.class}, order=6, min=0, max=1, modifier=false, summary=true)
1053        @Description(shortDefinition="The molecular weight or weight range (for proteins, polymers or nucleic acids)", formalDefinition="The molecular weight or weight range (for proteins, polymers or nucleic acids)." )
1054        protected SubstanceSpecificationStructureIsotopeMolecularWeightComponent molecularWeight;
1055
1056        /**
1057         * Supporting literature.
1058         */
1059        @Child(name = "referenceSource", type = {DocumentReference.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1060        @Description(shortDefinition="Supporting literature", formalDefinition="Supporting literature." )
1061        protected List<Reference> referenceSource;
1062        /**
1063         * The actual objects that are the target of the reference (Supporting literature.)
1064         */
1065        protected List<DocumentReference> referenceSourceTarget;
1066
1067
1068        /**
1069         * Molectular structural representation.
1070         */
1071        @Child(name = "structuralRepresentation", type = {}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1072        @Description(shortDefinition="Molectular structural representation", formalDefinition="Molectular structural representation." )
1073        protected List<SubstanceSpecificationStructureStructuralRepresentationComponent> structuralRepresentation;
1074
1075        private static final long serialVersionUID = -2087062825L;
1076
1077    /**
1078     * Constructor
1079     */
1080      public SubstanceSpecificationStructureComponent() {
1081        super();
1082      }
1083
1084        /**
1085         * @return {@link #stereochemistry} (Stereochemistry type.)
1086         */
1087        public CodeableConcept getStereochemistry() { 
1088          if (this.stereochemistry == null)
1089            if (Configuration.errorOnAutoCreate())
1090              throw new Error("Attempt to auto-create SubstanceSpecificationStructureComponent.stereochemistry");
1091            else if (Configuration.doAutoCreate())
1092              this.stereochemistry = new CodeableConcept(); // cc
1093          return this.stereochemistry;
1094        }
1095
1096        public boolean hasStereochemistry() { 
1097          return this.stereochemistry != null && !this.stereochemistry.isEmpty();
1098        }
1099
1100        /**
1101         * @param value {@link #stereochemistry} (Stereochemistry type.)
1102         */
1103        public SubstanceSpecificationStructureComponent setStereochemistry(CodeableConcept value) { 
1104          this.stereochemistry = value;
1105          return this;
1106        }
1107
1108        /**
1109         * @return {@link #opticalActivity} (Optical activity type.)
1110         */
1111        public CodeableConcept getOpticalActivity() { 
1112          if (this.opticalActivity == null)
1113            if (Configuration.errorOnAutoCreate())
1114              throw new Error("Attempt to auto-create SubstanceSpecificationStructureComponent.opticalActivity");
1115            else if (Configuration.doAutoCreate())
1116              this.opticalActivity = new CodeableConcept(); // cc
1117          return this.opticalActivity;
1118        }
1119
1120        public boolean hasOpticalActivity() { 
1121          return this.opticalActivity != null && !this.opticalActivity.isEmpty();
1122        }
1123
1124        /**
1125         * @param value {@link #opticalActivity} (Optical activity type.)
1126         */
1127        public SubstanceSpecificationStructureComponent setOpticalActivity(CodeableConcept value) { 
1128          this.opticalActivity = value;
1129          return this;
1130        }
1131
1132        /**
1133         * @return {@link #molecularFormula} (Molecular formula.). This is the underlying object with id, value and extensions. The accessor "getMolecularFormula" gives direct access to the value
1134         */
1135        public StringType getMolecularFormulaElement() { 
1136          if (this.molecularFormula == null)
1137            if (Configuration.errorOnAutoCreate())
1138              throw new Error("Attempt to auto-create SubstanceSpecificationStructureComponent.molecularFormula");
1139            else if (Configuration.doAutoCreate())
1140              this.molecularFormula = new StringType(); // bb
1141          return this.molecularFormula;
1142        }
1143
1144        public boolean hasMolecularFormulaElement() { 
1145          return this.molecularFormula != null && !this.molecularFormula.isEmpty();
1146        }
1147
1148        public boolean hasMolecularFormula() { 
1149          return this.molecularFormula != null && !this.molecularFormula.isEmpty();
1150        }
1151
1152        /**
1153         * @param value {@link #molecularFormula} (Molecular formula.). This is the underlying object with id, value and extensions. The accessor "getMolecularFormula" gives direct access to the value
1154         */
1155        public SubstanceSpecificationStructureComponent setMolecularFormulaElement(StringType value) { 
1156          this.molecularFormula = value;
1157          return this;
1158        }
1159
1160        /**
1161         * @return Molecular formula.
1162         */
1163        public String getMolecularFormula() { 
1164          return this.molecularFormula == null ? null : this.molecularFormula.getValue();
1165        }
1166
1167        /**
1168         * @param value Molecular formula.
1169         */
1170        public SubstanceSpecificationStructureComponent setMolecularFormula(String value) { 
1171          if (Utilities.noString(value))
1172            this.molecularFormula = null;
1173          else {
1174            if (this.molecularFormula == null)
1175              this.molecularFormula = new StringType();
1176            this.molecularFormula.setValue(value);
1177          }
1178          return this;
1179        }
1180
1181        /**
1182         * @return {@link #molecularFormulaByMoiety} (Specified per moiety according to the Hill system, i.e. first C, then H, then alphabetical. and 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
1183         */
1184        public StringType getMolecularFormulaByMoietyElement() { 
1185          if (this.molecularFormulaByMoiety == null)
1186            if (Configuration.errorOnAutoCreate())
1187              throw new Error("Attempt to auto-create SubstanceSpecificationStructureComponent.molecularFormulaByMoiety");
1188            else if (Configuration.doAutoCreate())
1189              this.molecularFormulaByMoiety = new StringType(); // bb
1190          return this.molecularFormulaByMoiety;
1191        }
1192
1193        public boolean hasMolecularFormulaByMoietyElement() { 
1194          return this.molecularFormulaByMoiety != null && !this.molecularFormulaByMoiety.isEmpty();
1195        }
1196
1197        public boolean hasMolecularFormulaByMoiety() { 
1198          return this.molecularFormulaByMoiety != null && !this.molecularFormulaByMoiety.isEmpty();
1199        }
1200
1201        /**
1202         * @param value {@link #molecularFormulaByMoiety} (Specified per moiety according to the Hill system, i.e. first C, then H, then alphabetical. and 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
1203         */
1204        public SubstanceSpecificationStructureComponent setMolecularFormulaByMoietyElement(StringType value) { 
1205          this.molecularFormulaByMoiety = value;
1206          return this;
1207        }
1208
1209        /**
1210         * @return Specified per moiety according to the Hill system, i.e. first C, then H, then alphabetical. and each moiety separated by a dot.
1211         */
1212        public String getMolecularFormulaByMoiety() { 
1213          return this.molecularFormulaByMoiety == null ? null : this.molecularFormulaByMoiety.getValue();
1214        }
1215
1216        /**
1217         * @param value Specified per moiety according to the Hill system, i.e. first C, then H, then alphabetical. and each moiety separated by a dot.
1218         */
1219        public SubstanceSpecificationStructureComponent setMolecularFormulaByMoiety(String value) { 
1220          if (Utilities.noString(value))
1221            this.molecularFormulaByMoiety = null;
1222          else {
1223            if (this.molecularFormulaByMoiety == null)
1224              this.molecularFormulaByMoiety = new StringType();
1225            this.molecularFormulaByMoiety.setValue(value);
1226          }
1227          return this;
1228        }
1229
1230        /**
1231         * @return {@link #isotope} (Applicable for single substances that contain a radionuclide or a non-natural isotopic ratio.)
1232         */
1233        public List<SubstanceSpecificationStructureIsotopeComponent> getIsotope() { 
1234          if (this.isotope == null)
1235            this.isotope = new ArrayList<SubstanceSpecificationStructureIsotopeComponent>();
1236          return this.isotope;
1237        }
1238
1239        /**
1240         * @return Returns a reference to <code>this</code> for easy method chaining
1241         */
1242        public SubstanceSpecificationStructureComponent setIsotope(List<SubstanceSpecificationStructureIsotopeComponent> theIsotope) { 
1243          this.isotope = theIsotope;
1244          return this;
1245        }
1246
1247        public boolean hasIsotope() { 
1248          if (this.isotope == null)
1249            return false;
1250          for (SubstanceSpecificationStructureIsotopeComponent item : this.isotope)
1251            if (!item.isEmpty())
1252              return true;
1253          return false;
1254        }
1255
1256        public SubstanceSpecificationStructureIsotopeComponent addIsotope() { //3
1257          SubstanceSpecificationStructureIsotopeComponent t = new SubstanceSpecificationStructureIsotopeComponent();
1258          if (this.isotope == null)
1259            this.isotope = new ArrayList<SubstanceSpecificationStructureIsotopeComponent>();
1260          this.isotope.add(t);
1261          return t;
1262        }
1263
1264        public SubstanceSpecificationStructureComponent addIsotope(SubstanceSpecificationStructureIsotopeComponent t) { //3
1265          if (t == null)
1266            return this;
1267          if (this.isotope == null)
1268            this.isotope = new ArrayList<SubstanceSpecificationStructureIsotopeComponent>();
1269          this.isotope.add(t);
1270          return this;
1271        }
1272
1273        /**
1274         * @return The first repetition of repeating field {@link #isotope}, creating it if it does not already exist
1275         */
1276        public SubstanceSpecificationStructureIsotopeComponent getIsotopeFirstRep() { 
1277          if (getIsotope().isEmpty()) {
1278            addIsotope();
1279          }
1280          return getIsotope().get(0);
1281        }
1282
1283        /**
1284         * @return {@link #molecularWeight} (The molecular weight or weight range (for proteins, polymers or nucleic acids).)
1285         */
1286        public SubstanceSpecificationStructureIsotopeMolecularWeightComponent getMolecularWeight() { 
1287          if (this.molecularWeight == null)
1288            if (Configuration.errorOnAutoCreate())
1289              throw new Error("Attempt to auto-create SubstanceSpecificationStructureComponent.molecularWeight");
1290            else if (Configuration.doAutoCreate())
1291              this.molecularWeight = new SubstanceSpecificationStructureIsotopeMolecularWeightComponent(); // cc
1292          return this.molecularWeight;
1293        }
1294
1295        public boolean hasMolecularWeight() { 
1296          return this.molecularWeight != null && !this.molecularWeight.isEmpty();
1297        }
1298
1299        /**
1300         * @param value {@link #molecularWeight} (The molecular weight or weight range (for proteins, polymers or nucleic acids).)
1301         */
1302        public SubstanceSpecificationStructureComponent setMolecularWeight(SubstanceSpecificationStructureIsotopeMolecularWeightComponent value) { 
1303          this.molecularWeight = value;
1304          return this;
1305        }
1306
1307        /**
1308         * @return {@link #referenceSource} (Supporting literature.)
1309         */
1310        public List<Reference> getReferenceSource() { 
1311          if (this.referenceSource == null)
1312            this.referenceSource = new ArrayList<Reference>();
1313          return this.referenceSource;
1314        }
1315
1316        /**
1317         * @return Returns a reference to <code>this</code> for easy method chaining
1318         */
1319        public SubstanceSpecificationStructureComponent setReferenceSource(List<Reference> theReferenceSource) { 
1320          this.referenceSource = theReferenceSource;
1321          return this;
1322        }
1323
1324        public boolean hasReferenceSource() { 
1325          if (this.referenceSource == null)
1326            return false;
1327          for (Reference item : this.referenceSource)
1328            if (!item.isEmpty())
1329              return true;
1330          return false;
1331        }
1332
1333        public Reference addReferenceSource() { //3
1334          Reference t = new Reference();
1335          if (this.referenceSource == null)
1336            this.referenceSource = new ArrayList<Reference>();
1337          this.referenceSource.add(t);
1338          return t;
1339        }
1340
1341        public SubstanceSpecificationStructureComponent addReferenceSource(Reference t) { //3
1342          if (t == null)
1343            return this;
1344          if (this.referenceSource == null)
1345            this.referenceSource = new ArrayList<Reference>();
1346          this.referenceSource.add(t);
1347          return this;
1348        }
1349
1350        /**
1351         * @return The first repetition of repeating field {@link #referenceSource}, creating it if it does not already exist
1352         */
1353        public Reference getReferenceSourceFirstRep() { 
1354          if (getReferenceSource().isEmpty()) {
1355            addReferenceSource();
1356          }
1357          return getReferenceSource().get(0);
1358        }
1359
1360        /**
1361         * @deprecated Use Reference#setResource(IBaseResource) instead
1362         */
1363        @Deprecated
1364        public List<DocumentReference> getReferenceSourceTarget() { 
1365          if (this.referenceSourceTarget == null)
1366            this.referenceSourceTarget = new ArrayList<DocumentReference>();
1367          return this.referenceSourceTarget;
1368        }
1369
1370        /**
1371         * @deprecated Use Reference#setResource(IBaseResource) instead
1372         */
1373        @Deprecated
1374        public DocumentReference addReferenceSourceTarget() { 
1375          DocumentReference r = new DocumentReference();
1376          if (this.referenceSourceTarget == null)
1377            this.referenceSourceTarget = new ArrayList<DocumentReference>();
1378          this.referenceSourceTarget.add(r);
1379          return r;
1380        }
1381
1382        /**
1383         * @return {@link #structuralRepresentation} (Molectular structural representation.)
1384         */
1385        public List<SubstanceSpecificationStructureStructuralRepresentationComponent> getStructuralRepresentation() { 
1386          if (this.structuralRepresentation == null)
1387            this.structuralRepresentation = new ArrayList<SubstanceSpecificationStructureStructuralRepresentationComponent>();
1388          return this.structuralRepresentation;
1389        }
1390
1391        /**
1392         * @return Returns a reference to <code>this</code> for easy method chaining
1393         */
1394        public SubstanceSpecificationStructureComponent setStructuralRepresentation(List<SubstanceSpecificationStructureStructuralRepresentationComponent> theStructuralRepresentation) { 
1395          this.structuralRepresentation = theStructuralRepresentation;
1396          return this;
1397        }
1398
1399        public boolean hasStructuralRepresentation() { 
1400          if (this.structuralRepresentation == null)
1401            return false;
1402          for (SubstanceSpecificationStructureStructuralRepresentationComponent item : this.structuralRepresentation)
1403            if (!item.isEmpty())
1404              return true;
1405          return false;
1406        }
1407
1408        public SubstanceSpecificationStructureStructuralRepresentationComponent addStructuralRepresentation() { //3
1409          SubstanceSpecificationStructureStructuralRepresentationComponent t = new SubstanceSpecificationStructureStructuralRepresentationComponent();
1410          if (this.structuralRepresentation == null)
1411            this.structuralRepresentation = new ArrayList<SubstanceSpecificationStructureStructuralRepresentationComponent>();
1412          this.structuralRepresentation.add(t);
1413          return t;
1414        }
1415
1416        public SubstanceSpecificationStructureComponent addStructuralRepresentation(SubstanceSpecificationStructureStructuralRepresentationComponent t) { //3
1417          if (t == null)
1418            return this;
1419          if (this.structuralRepresentation == null)
1420            this.structuralRepresentation = new ArrayList<SubstanceSpecificationStructureStructuralRepresentationComponent>();
1421          this.structuralRepresentation.add(t);
1422          return this;
1423        }
1424
1425        /**
1426         * @return The first repetition of repeating field {@link #structuralRepresentation}, creating it if it does not already exist
1427         */
1428        public SubstanceSpecificationStructureStructuralRepresentationComponent getStructuralRepresentationFirstRep() { 
1429          if (getStructuralRepresentation().isEmpty()) {
1430            addStructuralRepresentation();
1431          }
1432          return getStructuralRepresentation().get(0);
1433        }
1434
1435        protected void listChildren(List<Property> children) {
1436          super.listChildren(children);
1437          children.add(new Property("stereochemistry", "CodeableConcept", "Stereochemistry type.", 0, 1, stereochemistry));
1438          children.add(new Property("opticalActivity", "CodeableConcept", "Optical activity type.", 0, 1, opticalActivity));
1439          children.add(new Property("molecularFormula", "string", "Molecular formula.", 0, 1, molecularFormula));
1440          children.add(new Property("molecularFormulaByMoiety", "string", "Specified per moiety according to the Hill system, i.e. first C, then H, then alphabetical. and each moiety separated by a dot.", 0, 1, molecularFormulaByMoiety));
1441          children.add(new Property("isotope", "", "Applicable for single substances that contain a radionuclide or a non-natural isotopic ratio.", 0, java.lang.Integer.MAX_VALUE, isotope));
1442          children.add(new Property("molecularWeight", "@SubstanceSpecification.structure.isotope.molecularWeight", "The molecular weight or weight range (for proteins, polymers or nucleic acids).", 0, 1, molecularWeight));
1443          children.add(new Property("referenceSource", "Reference(DocumentReference)", "Supporting literature.", 0, java.lang.Integer.MAX_VALUE, referenceSource));
1444          children.add(new Property("structuralRepresentation", "", "Molectular structural representation.", 0, java.lang.Integer.MAX_VALUE, structuralRepresentation));
1445        }
1446
1447        @Override
1448        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1449          switch (_hash) {
1450          case 263475116: /*stereochemistry*/  return new Property("stereochemistry", "CodeableConcept", "Stereochemistry type.", 0, 1, stereochemistry);
1451          case 1420900135: /*opticalActivity*/  return new Property("opticalActivity", "CodeableConcept", "Optical activity type.", 0, 1, opticalActivity);
1452          case 616660246: /*molecularFormula*/  return new Property("molecularFormula", "string", "Molecular formula.", 0, 1, molecularFormula);
1453          case 1315452848: /*molecularFormulaByMoiety*/  return new Property("molecularFormulaByMoiety", "string", "Specified per moiety according to the Hill system, i.e. first C, then H, then alphabetical. and each moiety separated by a dot.", 0, 1, molecularFormulaByMoiety);
1454          case 2097035189: /*isotope*/  return new Property("isotope", "", "Applicable for single substances that contain a radionuclide or a non-natural isotopic ratio.", 0, java.lang.Integer.MAX_VALUE, isotope);
1455          case 635625672: /*molecularWeight*/  return new Property("molecularWeight", "@SubstanceSpecification.structure.isotope.molecularWeight", "The molecular weight or weight range (for proteins, polymers or nucleic acids).", 0, 1, molecularWeight);
1456          case 882421574: /*referenceSource*/  return new Property("referenceSource", "Reference(DocumentReference)", "Supporting literature.", 0, java.lang.Integer.MAX_VALUE, referenceSource);
1457          case 14311178: /*structuralRepresentation*/  return new Property("structuralRepresentation", "", "Molectular structural representation.", 0, java.lang.Integer.MAX_VALUE, structuralRepresentation);
1458          default: return super.getNamedProperty(_hash, _name, _checkValid);
1459          }
1460
1461        }
1462
1463      @Override
1464      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1465        switch (hash) {
1466        case 263475116: /*stereochemistry*/ return this.stereochemistry == null ? new Base[0] : new Base[] {this.stereochemistry}; // CodeableConcept
1467        case 1420900135: /*opticalActivity*/ return this.opticalActivity == null ? new Base[0] : new Base[] {this.opticalActivity}; // CodeableConcept
1468        case 616660246: /*molecularFormula*/ return this.molecularFormula == null ? new Base[0] : new Base[] {this.molecularFormula}; // StringType
1469        case 1315452848: /*molecularFormulaByMoiety*/ return this.molecularFormulaByMoiety == null ? new Base[0] : new Base[] {this.molecularFormulaByMoiety}; // StringType
1470        case 2097035189: /*isotope*/ return this.isotope == null ? new Base[0] : this.isotope.toArray(new Base[this.isotope.size()]); // SubstanceSpecificationStructureIsotopeComponent
1471        case 635625672: /*molecularWeight*/ return this.molecularWeight == null ? new Base[0] : new Base[] {this.molecularWeight}; // SubstanceSpecificationStructureIsotopeMolecularWeightComponent
1472        case 882421574: /*referenceSource*/ return this.referenceSource == null ? new Base[0] : this.referenceSource.toArray(new Base[this.referenceSource.size()]); // Reference
1473        case 14311178: /*structuralRepresentation*/ return this.structuralRepresentation == null ? new Base[0] : this.structuralRepresentation.toArray(new Base[this.structuralRepresentation.size()]); // SubstanceSpecificationStructureStructuralRepresentationComponent
1474        default: return super.getProperty(hash, name, checkValid);
1475        }
1476
1477      }
1478
1479      @Override
1480      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1481        switch (hash) {
1482        case 263475116: // stereochemistry
1483          this.stereochemistry = castToCodeableConcept(value); // CodeableConcept
1484          return value;
1485        case 1420900135: // opticalActivity
1486          this.opticalActivity = castToCodeableConcept(value); // CodeableConcept
1487          return value;
1488        case 616660246: // molecularFormula
1489          this.molecularFormula = castToString(value); // StringType
1490          return value;
1491        case 1315452848: // molecularFormulaByMoiety
1492          this.molecularFormulaByMoiety = castToString(value); // StringType
1493          return value;
1494        case 2097035189: // isotope
1495          this.getIsotope().add((SubstanceSpecificationStructureIsotopeComponent) value); // SubstanceSpecificationStructureIsotopeComponent
1496          return value;
1497        case 635625672: // molecularWeight
1498          this.molecularWeight = (SubstanceSpecificationStructureIsotopeMolecularWeightComponent) value; // SubstanceSpecificationStructureIsotopeMolecularWeightComponent
1499          return value;
1500        case 882421574: // referenceSource
1501          this.getReferenceSource().add(castToReference(value)); // Reference
1502          return value;
1503        case 14311178: // structuralRepresentation
1504          this.getStructuralRepresentation().add((SubstanceSpecificationStructureStructuralRepresentationComponent) value); // SubstanceSpecificationStructureStructuralRepresentationComponent
1505          return value;
1506        default: return super.setProperty(hash, name, value);
1507        }
1508
1509      }
1510
1511      @Override
1512      public Base setProperty(String name, Base value) throws FHIRException {
1513        if (name.equals("stereochemistry")) {
1514          this.stereochemistry = castToCodeableConcept(value); // CodeableConcept
1515        } else if (name.equals("opticalActivity")) {
1516          this.opticalActivity = castToCodeableConcept(value); // CodeableConcept
1517        } else if (name.equals("molecularFormula")) {
1518          this.molecularFormula = castToString(value); // StringType
1519        } else if (name.equals("molecularFormulaByMoiety")) {
1520          this.molecularFormulaByMoiety = castToString(value); // StringType
1521        } else if (name.equals("isotope")) {
1522          this.getIsotope().add((SubstanceSpecificationStructureIsotopeComponent) value);
1523        } else if (name.equals("molecularWeight")) {
1524          this.molecularWeight = (SubstanceSpecificationStructureIsotopeMolecularWeightComponent) value; // SubstanceSpecificationStructureIsotopeMolecularWeightComponent
1525        } else if (name.equals("referenceSource")) {
1526          this.getReferenceSource().add(castToReference(value));
1527        } else if (name.equals("structuralRepresentation")) {
1528          this.getStructuralRepresentation().add((SubstanceSpecificationStructureStructuralRepresentationComponent) value);
1529        } else
1530          return super.setProperty(name, value);
1531        return value;
1532      }
1533
1534      @Override
1535      public Base makeProperty(int hash, String name) throws FHIRException {
1536        switch (hash) {
1537        case 263475116:  return getStereochemistry(); 
1538        case 1420900135:  return getOpticalActivity(); 
1539        case 616660246:  return getMolecularFormulaElement();
1540        case 1315452848:  return getMolecularFormulaByMoietyElement();
1541        case 2097035189:  return addIsotope(); 
1542        case 635625672:  return getMolecularWeight(); 
1543        case 882421574:  return addReferenceSource(); 
1544        case 14311178:  return addStructuralRepresentation(); 
1545        default: return super.makeProperty(hash, name);
1546        }
1547
1548      }
1549
1550      @Override
1551      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1552        switch (hash) {
1553        case 263475116: /*stereochemistry*/ return new String[] {"CodeableConcept"};
1554        case 1420900135: /*opticalActivity*/ return new String[] {"CodeableConcept"};
1555        case 616660246: /*molecularFormula*/ return new String[] {"string"};
1556        case 1315452848: /*molecularFormulaByMoiety*/ return new String[] {"string"};
1557        case 2097035189: /*isotope*/ return new String[] {};
1558        case 635625672: /*molecularWeight*/ return new String[] {"@SubstanceSpecification.structure.isotope.molecularWeight"};
1559        case 882421574: /*referenceSource*/ return new String[] {"Reference"};
1560        case 14311178: /*structuralRepresentation*/ return new String[] {};
1561        default: return super.getTypesForProperty(hash, name);
1562        }
1563
1564      }
1565
1566      @Override
1567      public Base addChild(String name) throws FHIRException {
1568        if (name.equals("stereochemistry")) {
1569          this.stereochemistry = new CodeableConcept();
1570          return this.stereochemistry;
1571        }
1572        else if (name.equals("opticalActivity")) {
1573          this.opticalActivity = new CodeableConcept();
1574          return this.opticalActivity;
1575        }
1576        else if (name.equals("molecularFormula")) {
1577          throw new FHIRException("Cannot call addChild on a primitive type SubstanceSpecification.molecularFormula");
1578        }
1579        else if (name.equals("molecularFormulaByMoiety")) {
1580          throw new FHIRException("Cannot call addChild on a primitive type SubstanceSpecification.molecularFormulaByMoiety");
1581        }
1582        else if (name.equals("isotope")) {
1583          return addIsotope();
1584        }
1585        else if (name.equals("molecularWeight")) {
1586          this.molecularWeight = new SubstanceSpecificationStructureIsotopeMolecularWeightComponent();
1587          return this.molecularWeight;
1588        }
1589        else if (name.equals("referenceSource")) {
1590          return addReferenceSource();
1591        }
1592        else if (name.equals("structuralRepresentation")) {
1593          return addStructuralRepresentation();
1594        }
1595        else
1596          return super.addChild(name);
1597      }
1598
1599      public SubstanceSpecificationStructureComponent copy() {
1600        SubstanceSpecificationStructureComponent dst = new SubstanceSpecificationStructureComponent();
1601        copyValues(dst);
1602        dst.stereochemistry = stereochemistry == null ? null : stereochemistry.copy();
1603        dst.opticalActivity = opticalActivity == null ? null : opticalActivity.copy();
1604        dst.molecularFormula = molecularFormula == null ? null : molecularFormula.copy();
1605        dst.molecularFormulaByMoiety = molecularFormulaByMoiety == null ? null : molecularFormulaByMoiety.copy();
1606        if (isotope != null) {
1607          dst.isotope = new ArrayList<SubstanceSpecificationStructureIsotopeComponent>();
1608          for (SubstanceSpecificationStructureIsotopeComponent i : isotope)
1609            dst.isotope.add(i.copy());
1610        };
1611        dst.molecularWeight = molecularWeight == null ? null : molecularWeight.copy();
1612        if (referenceSource != null) {
1613          dst.referenceSource = new ArrayList<Reference>();
1614          for (Reference i : referenceSource)
1615            dst.referenceSource.add(i.copy());
1616        };
1617        if (structuralRepresentation != null) {
1618          dst.structuralRepresentation = new ArrayList<SubstanceSpecificationStructureStructuralRepresentationComponent>();
1619          for (SubstanceSpecificationStructureStructuralRepresentationComponent i : structuralRepresentation)
1620            dst.structuralRepresentation.add(i.copy());
1621        };
1622        return dst;
1623      }
1624
1625      @Override
1626      public boolean equalsDeep(Base other_) {
1627        if (!super.equalsDeep(other_))
1628          return false;
1629        if (!(other_ instanceof SubstanceSpecificationStructureComponent))
1630          return false;
1631        SubstanceSpecificationStructureComponent o = (SubstanceSpecificationStructureComponent) other_;
1632        return compareDeep(stereochemistry, o.stereochemistry, true) && compareDeep(opticalActivity, o.opticalActivity, true)
1633           && compareDeep(molecularFormula, o.molecularFormula, true) && compareDeep(molecularFormulaByMoiety, o.molecularFormulaByMoiety, true)
1634           && compareDeep(isotope, o.isotope, true) && compareDeep(molecularWeight, o.molecularWeight, true)
1635           && compareDeep(referenceSource, o.referenceSource, true) && compareDeep(structuralRepresentation, o.structuralRepresentation, true)
1636          ;
1637      }
1638
1639      @Override
1640      public boolean equalsShallow(Base other_) {
1641        if (!super.equalsShallow(other_))
1642          return false;
1643        if (!(other_ instanceof SubstanceSpecificationStructureComponent))
1644          return false;
1645        SubstanceSpecificationStructureComponent o = (SubstanceSpecificationStructureComponent) other_;
1646        return compareValues(molecularFormula, o.molecularFormula, true) && compareValues(molecularFormulaByMoiety, o.molecularFormulaByMoiety, true)
1647          ;
1648      }
1649
1650      public boolean isEmpty() {
1651        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(stereochemistry, opticalActivity
1652          , molecularFormula, molecularFormulaByMoiety, isotope, molecularWeight, referenceSource
1653          , structuralRepresentation);
1654      }
1655
1656  public String fhirType() {
1657    return "SubstanceSpecification.structure";
1658
1659  }
1660
1661  }
1662
1663    @Block()
1664    public static class SubstanceSpecificationStructureIsotopeComponent extends BackboneElement implements IBaseBackboneElement {
1665        /**
1666         * Substance identifier for each non-natural or radioisotope.
1667         */
1668        @Child(name = "nuclideId", type = {Identifier.class}, order=1, min=0, max=1, modifier=false, summary=true)
1669        @Description(shortDefinition="Substance identifier for each non-natural or radioisotope", formalDefinition="Substance identifier for each non-natural or radioisotope." )
1670        protected Identifier nuclideId;
1671
1672        /**
1673         * Substance name for each non-natural or radioisotope.
1674         */
1675        @Child(name = "nuclideName", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
1676        @Description(shortDefinition="Substance name for each non-natural or radioisotope", formalDefinition="Substance name for each non-natural or radioisotope." )
1677        protected CodeableConcept nuclideName;
1678
1679        /**
1680         * The type of isotopic substitution present in a single substance.
1681         */
1682        @Child(name = "substitutionType", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true)
1683        @Description(shortDefinition="The type of isotopic substitution present in a single substance", formalDefinition="The type of isotopic substitution present in a single substance." )
1684        protected CodeableConcept substitutionType;
1685
1686        /**
1687         * Half life - for a non-natural nuclide.
1688         */
1689        @Child(name = "nuclideHalfLife", type = {Quantity.class}, order=4, min=0, max=1, modifier=false, summary=true)
1690        @Description(shortDefinition="Half life - for a non-natural nuclide", formalDefinition="Half life - for a non-natural nuclide." )
1691        protected Quantity nuclideHalfLife;
1692
1693        /**
1694         * Quantitative values for this isotope.
1695         */
1696        @Child(name = "amount", type = {StringType.class}, order=5, min=0, max=1, modifier=false, summary=true)
1697        @Description(shortDefinition="Quantitative values for this isotope", formalDefinition="Quantitative values for this isotope." )
1698        protected StringType amount;
1699
1700        /**
1701         * The molecular weight or weight range (for proteins, polymers or nucleic acids).
1702         */
1703        @Child(name = "molecularWeight", type = {}, order=6, min=0, max=1, modifier=false, summary=true)
1704        @Description(shortDefinition="The molecular weight or weight range (for proteins, polymers or nucleic acids)", formalDefinition="The molecular weight or weight range (for proteins, polymers or nucleic acids)." )
1705        protected SubstanceSpecificationStructureIsotopeMolecularWeightComponent molecularWeight;
1706
1707        private static final long serialVersionUID = -654404311L;
1708
1709    /**
1710     * Constructor
1711     */
1712      public SubstanceSpecificationStructureIsotopeComponent() {
1713        super();
1714      }
1715
1716        /**
1717         * @return {@link #nuclideId} (Substance identifier for each non-natural or radioisotope.)
1718         */
1719        public Identifier getNuclideId() { 
1720          if (this.nuclideId == null)
1721            if (Configuration.errorOnAutoCreate())
1722              throw new Error("Attempt to auto-create SubstanceSpecificationStructureIsotopeComponent.nuclideId");
1723            else if (Configuration.doAutoCreate())
1724              this.nuclideId = new Identifier(); // cc
1725          return this.nuclideId;
1726        }
1727
1728        public boolean hasNuclideId() { 
1729          return this.nuclideId != null && !this.nuclideId.isEmpty();
1730        }
1731
1732        /**
1733         * @param value {@link #nuclideId} (Substance identifier for each non-natural or radioisotope.)
1734         */
1735        public SubstanceSpecificationStructureIsotopeComponent setNuclideId(Identifier value) { 
1736          this.nuclideId = value;
1737          return this;
1738        }
1739
1740        /**
1741         * @return {@link #nuclideName} (Substance name for each non-natural or radioisotope.)
1742         */
1743        public CodeableConcept getNuclideName() { 
1744          if (this.nuclideName == null)
1745            if (Configuration.errorOnAutoCreate())
1746              throw new Error("Attempt to auto-create SubstanceSpecificationStructureIsotopeComponent.nuclideName");
1747            else if (Configuration.doAutoCreate())
1748              this.nuclideName = new CodeableConcept(); // cc
1749          return this.nuclideName;
1750        }
1751
1752        public boolean hasNuclideName() { 
1753          return this.nuclideName != null && !this.nuclideName.isEmpty();
1754        }
1755
1756        /**
1757         * @param value {@link #nuclideName} (Substance name for each non-natural or radioisotope.)
1758         */
1759        public SubstanceSpecificationStructureIsotopeComponent setNuclideName(CodeableConcept value) { 
1760          this.nuclideName = value;
1761          return this;
1762        }
1763
1764        /**
1765         * @return {@link #substitutionType} (The type of isotopic substitution present in a single substance.)
1766         */
1767        public CodeableConcept getSubstitutionType() { 
1768          if (this.substitutionType == null)
1769            if (Configuration.errorOnAutoCreate())
1770              throw new Error("Attempt to auto-create SubstanceSpecificationStructureIsotopeComponent.substitutionType");
1771            else if (Configuration.doAutoCreate())
1772              this.substitutionType = new CodeableConcept(); // cc
1773          return this.substitutionType;
1774        }
1775
1776        public boolean hasSubstitutionType() { 
1777          return this.substitutionType != null && !this.substitutionType.isEmpty();
1778        }
1779
1780        /**
1781         * @param value {@link #substitutionType} (The type of isotopic substitution present in a single substance.)
1782         */
1783        public SubstanceSpecificationStructureIsotopeComponent setSubstitutionType(CodeableConcept value) { 
1784          this.substitutionType = value;
1785          return this;
1786        }
1787
1788        /**
1789         * @return {@link #nuclideHalfLife} (Half life - for a non-natural nuclide.)
1790         */
1791        public Quantity getNuclideHalfLife() { 
1792          if (this.nuclideHalfLife == null)
1793            if (Configuration.errorOnAutoCreate())
1794              throw new Error("Attempt to auto-create SubstanceSpecificationStructureIsotopeComponent.nuclideHalfLife");
1795            else if (Configuration.doAutoCreate())
1796              this.nuclideHalfLife = new Quantity(); // cc
1797          return this.nuclideHalfLife;
1798        }
1799
1800        public boolean hasNuclideHalfLife() { 
1801          return this.nuclideHalfLife != null && !this.nuclideHalfLife.isEmpty();
1802        }
1803
1804        /**
1805         * @param value {@link #nuclideHalfLife} (Half life - for a non-natural nuclide.)
1806         */
1807        public SubstanceSpecificationStructureIsotopeComponent setNuclideHalfLife(Quantity value) { 
1808          this.nuclideHalfLife = value;
1809          return this;
1810        }
1811
1812        /**
1813         * @return {@link #amount} (Quantitative values for this isotope.). This is the underlying object with id, value and extensions. The accessor "getAmount" gives direct access to the value
1814         */
1815        public StringType getAmountElement() { 
1816          if (this.amount == null)
1817            if (Configuration.errorOnAutoCreate())
1818              throw new Error("Attempt to auto-create SubstanceSpecificationStructureIsotopeComponent.amount");
1819            else if (Configuration.doAutoCreate())
1820              this.amount = new StringType(); // bb
1821          return this.amount;
1822        }
1823
1824        public boolean hasAmountElement() { 
1825          return this.amount != null && !this.amount.isEmpty();
1826        }
1827
1828        public boolean hasAmount() { 
1829          return this.amount != null && !this.amount.isEmpty();
1830        }
1831
1832        /**
1833         * @param value {@link #amount} (Quantitative values for this isotope.). This is the underlying object with id, value and extensions. The accessor "getAmount" gives direct access to the value
1834         */
1835        public SubstanceSpecificationStructureIsotopeComponent setAmountElement(StringType value) { 
1836          this.amount = value;
1837          return this;
1838        }
1839
1840        /**
1841         * @return Quantitative values for this isotope.
1842         */
1843        public String getAmount() { 
1844          return this.amount == null ? null : this.amount.getValue();
1845        }
1846
1847        /**
1848         * @param value Quantitative values for this isotope.
1849         */
1850        public SubstanceSpecificationStructureIsotopeComponent setAmount(String value) { 
1851          if (Utilities.noString(value))
1852            this.amount = null;
1853          else {
1854            if (this.amount == null)
1855              this.amount = new StringType();
1856            this.amount.setValue(value);
1857          }
1858          return this;
1859        }
1860
1861        /**
1862         * @return {@link #molecularWeight} (The molecular weight or weight range (for proteins, polymers or nucleic acids).)
1863         */
1864        public SubstanceSpecificationStructureIsotopeMolecularWeightComponent getMolecularWeight() { 
1865          if (this.molecularWeight == null)
1866            if (Configuration.errorOnAutoCreate())
1867              throw new Error("Attempt to auto-create SubstanceSpecificationStructureIsotopeComponent.molecularWeight");
1868            else if (Configuration.doAutoCreate())
1869              this.molecularWeight = new SubstanceSpecificationStructureIsotopeMolecularWeightComponent(); // cc
1870          return this.molecularWeight;
1871        }
1872
1873        public boolean hasMolecularWeight() { 
1874          return this.molecularWeight != null && !this.molecularWeight.isEmpty();
1875        }
1876
1877        /**
1878         * @param value {@link #molecularWeight} (The molecular weight or weight range (for proteins, polymers or nucleic acids).)
1879         */
1880        public SubstanceSpecificationStructureIsotopeComponent setMolecularWeight(SubstanceSpecificationStructureIsotopeMolecularWeightComponent value) { 
1881          this.molecularWeight = value;
1882          return this;
1883        }
1884
1885        protected void listChildren(List<Property> children) {
1886          super.listChildren(children);
1887          children.add(new Property("nuclideId", "Identifier", "Substance identifier for each non-natural or radioisotope.", 0, 1, nuclideId));
1888          children.add(new Property("nuclideName", "CodeableConcept", "Substance name for each non-natural or radioisotope.", 0, 1, nuclideName));
1889          children.add(new Property("substitutionType", "CodeableConcept", "The type of isotopic substitution present in a single substance.", 0, 1, substitutionType));
1890          children.add(new Property("nuclideHalfLife", "Quantity", "Half life - for a non-natural nuclide.", 0, 1, nuclideHalfLife));
1891          children.add(new Property("amount", "string", "Quantitative values for this isotope.", 0, 1, amount));
1892          children.add(new Property("molecularWeight", "", "The molecular weight or weight range (for proteins, polymers or nucleic acids).", 0, 1, molecularWeight));
1893        }
1894
1895        @Override
1896        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1897          switch (_hash) {
1898          case 1654398709: /*nuclideId*/  return new Property("nuclideId", "Identifier", "Substance identifier for each non-natural or radioisotope.", 0, 1, nuclideId);
1899          case 739409381: /*nuclideName*/  return new Property("nuclideName", "CodeableConcept", "Substance name for each non-natural or radioisotope.", 0, 1, nuclideName);
1900          case -1937621033: /*substitutionType*/  return new Property("substitutionType", "CodeableConcept", "The type of isotopic substitution present in a single substance.", 0, 1, substitutionType);
1901          case 1348294697: /*nuclideHalfLife*/  return new Property("nuclideHalfLife", "Quantity", "Half life - for a non-natural nuclide.", 0, 1, nuclideHalfLife);
1902          case -1413853096: /*amount*/  return new Property("amount", "string", "Quantitative values for this isotope.", 0, 1, amount);
1903          case 635625672: /*molecularWeight*/  return new Property("molecularWeight", "", "The molecular weight or weight range (for proteins, polymers or nucleic acids).", 0, 1, molecularWeight);
1904          default: return super.getNamedProperty(_hash, _name, _checkValid);
1905          }
1906
1907        }
1908
1909      @Override
1910      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1911        switch (hash) {
1912        case 1654398709: /*nuclideId*/ return this.nuclideId == null ? new Base[0] : new Base[] {this.nuclideId}; // Identifier
1913        case 739409381: /*nuclideName*/ return this.nuclideName == null ? new Base[0] : new Base[] {this.nuclideName}; // CodeableConcept
1914        case -1937621033: /*substitutionType*/ return this.substitutionType == null ? new Base[0] : new Base[] {this.substitutionType}; // CodeableConcept
1915        case 1348294697: /*nuclideHalfLife*/ return this.nuclideHalfLife == null ? new Base[0] : new Base[] {this.nuclideHalfLife}; // Quantity
1916        case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : new Base[] {this.amount}; // StringType
1917        case 635625672: /*molecularWeight*/ return this.molecularWeight == null ? new Base[0] : new Base[] {this.molecularWeight}; // SubstanceSpecificationStructureIsotopeMolecularWeightComponent
1918        default: return super.getProperty(hash, name, checkValid);
1919        }
1920
1921      }
1922
1923      @Override
1924      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1925        switch (hash) {
1926        case 1654398709: // nuclideId
1927          this.nuclideId = castToIdentifier(value); // Identifier
1928          return value;
1929        case 739409381: // nuclideName
1930          this.nuclideName = castToCodeableConcept(value); // CodeableConcept
1931          return value;
1932        case -1937621033: // substitutionType
1933          this.substitutionType = castToCodeableConcept(value); // CodeableConcept
1934          return value;
1935        case 1348294697: // nuclideHalfLife
1936          this.nuclideHalfLife = castToQuantity(value); // Quantity
1937          return value;
1938        case -1413853096: // amount
1939          this.amount = castToString(value); // StringType
1940          return value;
1941        case 635625672: // molecularWeight
1942          this.molecularWeight = (SubstanceSpecificationStructureIsotopeMolecularWeightComponent) value; // SubstanceSpecificationStructureIsotopeMolecularWeightComponent
1943          return value;
1944        default: return super.setProperty(hash, name, value);
1945        }
1946
1947      }
1948
1949      @Override
1950      public Base setProperty(String name, Base value) throws FHIRException {
1951        if (name.equals("nuclideId")) {
1952          this.nuclideId = castToIdentifier(value); // Identifier
1953        } else if (name.equals("nuclideName")) {
1954          this.nuclideName = castToCodeableConcept(value); // CodeableConcept
1955        } else if (name.equals("substitutionType")) {
1956          this.substitutionType = castToCodeableConcept(value); // CodeableConcept
1957        } else if (name.equals("nuclideHalfLife")) {
1958          this.nuclideHalfLife = castToQuantity(value); // Quantity
1959        } else if (name.equals("amount")) {
1960          this.amount = castToString(value); // StringType
1961        } else if (name.equals("molecularWeight")) {
1962          this.molecularWeight = (SubstanceSpecificationStructureIsotopeMolecularWeightComponent) value; // SubstanceSpecificationStructureIsotopeMolecularWeightComponent
1963        } else
1964          return super.setProperty(name, value);
1965        return value;
1966      }
1967
1968      @Override
1969      public Base makeProperty(int hash, String name) throws FHIRException {
1970        switch (hash) {
1971        case 1654398709:  return getNuclideId(); 
1972        case 739409381:  return getNuclideName(); 
1973        case -1937621033:  return getSubstitutionType(); 
1974        case 1348294697:  return getNuclideHalfLife(); 
1975        case -1413853096:  return getAmountElement();
1976        case 635625672:  return getMolecularWeight(); 
1977        default: return super.makeProperty(hash, name);
1978        }
1979
1980      }
1981
1982      @Override
1983      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1984        switch (hash) {
1985        case 1654398709: /*nuclideId*/ return new String[] {"Identifier"};
1986        case 739409381: /*nuclideName*/ return new String[] {"CodeableConcept"};
1987        case -1937621033: /*substitutionType*/ return new String[] {"CodeableConcept"};
1988        case 1348294697: /*nuclideHalfLife*/ return new String[] {"Quantity"};
1989        case -1413853096: /*amount*/ return new String[] {"string"};
1990        case 635625672: /*molecularWeight*/ return new String[] {};
1991        default: return super.getTypesForProperty(hash, name);
1992        }
1993
1994      }
1995
1996      @Override
1997      public Base addChild(String name) throws FHIRException {
1998        if (name.equals("nuclideId")) {
1999          this.nuclideId = new Identifier();
2000          return this.nuclideId;
2001        }
2002        else if (name.equals("nuclideName")) {
2003          this.nuclideName = new CodeableConcept();
2004          return this.nuclideName;
2005        }
2006        else if (name.equals("substitutionType")) {
2007          this.substitutionType = new CodeableConcept();
2008          return this.substitutionType;
2009        }
2010        else if (name.equals("nuclideHalfLife")) {
2011          this.nuclideHalfLife = new Quantity();
2012          return this.nuclideHalfLife;
2013        }
2014        else if (name.equals("amount")) {
2015          throw new FHIRException("Cannot call addChild on a primitive type SubstanceSpecification.amount");
2016        }
2017        else if (name.equals("molecularWeight")) {
2018          this.molecularWeight = new SubstanceSpecificationStructureIsotopeMolecularWeightComponent();
2019          return this.molecularWeight;
2020        }
2021        else
2022          return super.addChild(name);
2023      }
2024
2025      public SubstanceSpecificationStructureIsotopeComponent copy() {
2026        SubstanceSpecificationStructureIsotopeComponent dst = new SubstanceSpecificationStructureIsotopeComponent();
2027        copyValues(dst);
2028        dst.nuclideId = nuclideId == null ? null : nuclideId.copy();
2029        dst.nuclideName = nuclideName == null ? null : nuclideName.copy();
2030        dst.substitutionType = substitutionType == null ? null : substitutionType.copy();
2031        dst.nuclideHalfLife = nuclideHalfLife == null ? null : nuclideHalfLife.copy();
2032        dst.amount = amount == null ? null : amount.copy();
2033        dst.molecularWeight = molecularWeight == null ? null : molecularWeight.copy();
2034        return dst;
2035      }
2036
2037      @Override
2038      public boolean equalsDeep(Base other_) {
2039        if (!super.equalsDeep(other_))
2040          return false;
2041        if (!(other_ instanceof SubstanceSpecificationStructureIsotopeComponent))
2042          return false;
2043        SubstanceSpecificationStructureIsotopeComponent o = (SubstanceSpecificationStructureIsotopeComponent) other_;
2044        return compareDeep(nuclideId, o.nuclideId, true) && compareDeep(nuclideName, o.nuclideName, true)
2045           && compareDeep(substitutionType, o.substitutionType, true) && compareDeep(nuclideHalfLife, o.nuclideHalfLife, true)
2046           && compareDeep(amount, o.amount, true) && compareDeep(molecularWeight, o.molecularWeight, true)
2047          ;
2048      }
2049
2050      @Override
2051      public boolean equalsShallow(Base other_) {
2052        if (!super.equalsShallow(other_))
2053          return false;
2054        if (!(other_ instanceof SubstanceSpecificationStructureIsotopeComponent))
2055          return false;
2056        SubstanceSpecificationStructureIsotopeComponent o = (SubstanceSpecificationStructureIsotopeComponent) other_;
2057        return compareValues(amount, o.amount, true);
2058      }
2059
2060      public boolean isEmpty() {
2061        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(nuclideId, nuclideName, substitutionType
2062          , nuclideHalfLife, amount, molecularWeight);
2063      }
2064
2065  public String fhirType() {
2066    return "SubstanceSpecification.structure.isotope";
2067
2068  }
2069
2070  }
2071
2072    @Block()
2073    public static class SubstanceSpecificationStructureIsotopeMolecularWeightComponent extends BackboneElement implements IBaseBackboneElement {
2074        /**
2075         * The method by which the molecular weight was determined.
2076         */
2077        @Child(name = "method", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
2078        @Description(shortDefinition="The method by which the molecular weight was determined", formalDefinition="The method by which the molecular weight was determined." )
2079        protected CodeableConcept method;
2080
2081        /**
2082         * Type of molecular weight such as exact, average (also known as. number average), weight average.
2083         */
2084        @Child(name = "type", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
2085        @Description(shortDefinition="Type of molecular weight such as exact, average (also known as. number average), weight average", formalDefinition="Type of molecular weight such as exact, average (also known as. number average), weight average." )
2086        protected CodeableConcept type;
2087
2088        /**
2089         * 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.
2090         */
2091        @Child(name = "amount", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true)
2092        @Description(shortDefinition="Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field", formalDefinition="Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field." )
2093        protected StringType amount;
2094
2095        private static final long serialVersionUID = -1221185948L;
2096
2097    /**
2098     * Constructor
2099     */
2100      public SubstanceSpecificationStructureIsotopeMolecularWeightComponent() {
2101        super();
2102      }
2103
2104        /**
2105         * @return {@link #method} (The method by which the molecular weight was determined.)
2106         */
2107        public CodeableConcept getMethod() { 
2108          if (this.method == null)
2109            if (Configuration.errorOnAutoCreate())
2110              throw new Error("Attempt to auto-create SubstanceSpecificationStructureIsotopeMolecularWeightComponent.method");
2111            else if (Configuration.doAutoCreate())
2112              this.method = new CodeableConcept(); // cc
2113          return this.method;
2114        }
2115
2116        public boolean hasMethod() { 
2117          return this.method != null && !this.method.isEmpty();
2118        }
2119
2120        /**
2121         * @param value {@link #method} (The method by which the molecular weight was determined.)
2122         */
2123        public SubstanceSpecificationStructureIsotopeMolecularWeightComponent setMethod(CodeableConcept value) { 
2124          this.method = value;
2125          return this;
2126        }
2127
2128        /**
2129         * @return {@link #type} (Type of molecular weight such as exact, average (also known as. number average), weight average.)
2130         */
2131        public CodeableConcept getType() { 
2132          if (this.type == null)
2133            if (Configuration.errorOnAutoCreate())
2134              throw new Error("Attempt to auto-create SubstanceSpecificationStructureIsotopeMolecularWeightComponent.type");
2135            else if (Configuration.doAutoCreate())
2136              this.type = new CodeableConcept(); // cc
2137          return this.type;
2138        }
2139
2140        public boolean hasType() { 
2141          return this.type != null && !this.type.isEmpty();
2142        }
2143
2144        /**
2145         * @param value {@link #type} (Type of molecular weight such as exact, average (also known as. number average), weight average.)
2146         */
2147        public SubstanceSpecificationStructureIsotopeMolecularWeightComponent setType(CodeableConcept value) { 
2148          this.type = value;
2149          return this;
2150        }
2151
2152        /**
2153         * @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.). This is the underlying object with id, value and extensions. The accessor "getAmount" gives direct access to the value
2154         */
2155        public StringType getAmountElement() { 
2156          if (this.amount == null)
2157            if (Configuration.errorOnAutoCreate())
2158              throw new Error("Attempt to auto-create SubstanceSpecificationStructureIsotopeMolecularWeightComponent.amount");
2159            else if (Configuration.doAutoCreate())
2160              this.amount = new StringType(); // bb
2161          return this.amount;
2162        }
2163
2164        public boolean hasAmountElement() { 
2165          return this.amount != null && !this.amount.isEmpty();
2166        }
2167
2168        public boolean hasAmount() { 
2169          return this.amount != null && !this.amount.isEmpty();
2170        }
2171
2172        /**
2173         * @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.). This is the underlying object with id, value and extensions. The accessor "getAmount" gives direct access to the value
2174         */
2175        public SubstanceSpecificationStructureIsotopeMolecularWeightComponent setAmountElement(StringType value) { 
2176          this.amount = value;
2177          return this;
2178        }
2179
2180        /**
2181         * @return 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.
2182         */
2183        public String getAmount() { 
2184          return this.amount == null ? null : this.amount.getValue();
2185        }
2186
2187        /**
2188         * @param value 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.
2189         */
2190        public SubstanceSpecificationStructureIsotopeMolecularWeightComponent setAmount(String value) { 
2191          if (Utilities.noString(value))
2192            this.amount = null;
2193          else {
2194            if (this.amount == null)
2195              this.amount = new StringType();
2196            this.amount.setValue(value);
2197          }
2198          return this;
2199        }
2200
2201        protected void listChildren(List<Property> children) {
2202          super.listChildren(children);
2203          children.add(new Property("method", "CodeableConcept", "The method by which the molecular weight was determined.", 0, 1, method));
2204          children.add(new Property("type", "CodeableConcept", "Type of molecular weight such as exact, average (also known as. number average), weight average.", 0, 1, type));
2205          children.add(new Property("amount", "string", "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));
2206        }
2207
2208        @Override
2209        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2210          switch (_hash) {
2211          case -1077554975: /*method*/  return new Property("method", "CodeableConcept", "The method by which the molecular weight was determined.", 0, 1, method);
2212          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);
2213          case -1413853096: /*amount*/  return new Property("amount", "string", "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);
2214          default: return super.getNamedProperty(_hash, _name, _checkValid);
2215          }
2216
2217        }
2218
2219      @Override
2220      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2221        switch (hash) {
2222        case -1077554975: /*method*/ return this.method == null ? new Base[0] : new Base[] {this.method}; // CodeableConcept
2223        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
2224        case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : new Base[] {this.amount}; // StringType
2225        default: return super.getProperty(hash, name, checkValid);
2226        }
2227
2228      }
2229
2230      @Override
2231      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2232        switch (hash) {
2233        case -1077554975: // method
2234          this.method = castToCodeableConcept(value); // CodeableConcept
2235          return value;
2236        case 3575610: // type
2237          this.type = castToCodeableConcept(value); // CodeableConcept
2238          return value;
2239        case -1413853096: // amount
2240          this.amount = castToString(value); // StringType
2241          return value;
2242        default: return super.setProperty(hash, name, value);
2243        }
2244
2245      }
2246
2247      @Override
2248      public Base setProperty(String name, Base value) throws FHIRException {
2249        if (name.equals("method")) {
2250          this.method = castToCodeableConcept(value); // CodeableConcept
2251        } else if (name.equals("type")) {
2252          this.type = castToCodeableConcept(value); // CodeableConcept
2253        } else if (name.equals("amount")) {
2254          this.amount = castToString(value); // StringType
2255        } else
2256          return super.setProperty(name, value);
2257        return value;
2258      }
2259
2260      @Override
2261      public Base makeProperty(int hash, String name) throws FHIRException {
2262        switch (hash) {
2263        case -1077554975:  return getMethod(); 
2264        case 3575610:  return getType(); 
2265        case -1413853096:  return getAmountElement();
2266        default: return super.makeProperty(hash, name);
2267        }
2268
2269      }
2270
2271      @Override
2272      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2273        switch (hash) {
2274        case -1077554975: /*method*/ return new String[] {"CodeableConcept"};
2275        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
2276        case -1413853096: /*amount*/ return new String[] {"string"};
2277        default: return super.getTypesForProperty(hash, name);
2278        }
2279
2280      }
2281
2282      @Override
2283      public Base addChild(String name) throws FHIRException {
2284        if (name.equals("method")) {
2285          this.method = new CodeableConcept();
2286          return this.method;
2287        }
2288        else if (name.equals("type")) {
2289          this.type = new CodeableConcept();
2290          return this.type;
2291        }
2292        else if (name.equals("amount")) {
2293          throw new FHIRException("Cannot call addChild on a primitive type SubstanceSpecification.amount");
2294        }
2295        else
2296          return super.addChild(name);
2297      }
2298
2299      public SubstanceSpecificationStructureIsotopeMolecularWeightComponent copy() {
2300        SubstanceSpecificationStructureIsotopeMolecularWeightComponent dst = new SubstanceSpecificationStructureIsotopeMolecularWeightComponent();
2301        copyValues(dst);
2302        dst.method = method == null ? null : method.copy();
2303        dst.type = type == null ? null : type.copy();
2304        dst.amount = amount == null ? null : amount.copy();
2305        return dst;
2306      }
2307
2308      @Override
2309      public boolean equalsDeep(Base other_) {
2310        if (!super.equalsDeep(other_))
2311          return false;
2312        if (!(other_ instanceof SubstanceSpecificationStructureIsotopeMolecularWeightComponent))
2313          return false;
2314        SubstanceSpecificationStructureIsotopeMolecularWeightComponent o = (SubstanceSpecificationStructureIsotopeMolecularWeightComponent) other_;
2315        return compareDeep(method, o.method, true) && compareDeep(type, o.type, true) && compareDeep(amount, o.amount, true)
2316          ;
2317      }
2318
2319      @Override
2320      public boolean equalsShallow(Base other_) {
2321        if (!super.equalsShallow(other_))
2322          return false;
2323        if (!(other_ instanceof SubstanceSpecificationStructureIsotopeMolecularWeightComponent))
2324          return false;
2325        SubstanceSpecificationStructureIsotopeMolecularWeightComponent o = (SubstanceSpecificationStructureIsotopeMolecularWeightComponent) other_;
2326        return compareValues(amount, o.amount, true);
2327      }
2328
2329      public boolean isEmpty() {
2330        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(method, type, amount);
2331      }
2332
2333  public String fhirType() {
2334    return "SubstanceSpecification.structure.isotope.molecularWeight";
2335
2336  }
2337
2338  }
2339
2340    @Block()
2341    public static class SubstanceSpecificationStructureStructuralRepresentationComponent extends BackboneElement implements IBaseBackboneElement {
2342        /**
2343         * The type of structure (e.g. Full, Partial, Representative).
2344         */
2345        @Child(name = "type", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
2346        @Description(shortDefinition="The type of structure (e.g. Full, Partial, Representative)", formalDefinition="The type of structure (e.g. Full, Partial, Representative)." )
2347        protected CodeableConcept type;
2348
2349        /**
2350         * The structural representation as text string in a format e.g. InChI, SMILES, MOLFILE, CDX.
2351         */
2352        @Child(name = "representation", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=true)
2353        @Description(shortDefinition="The structural representation as text string in a format e.g. InChI, SMILES, MOLFILE, CDX", formalDefinition="The structural representation as text string in a format e.g. InChI, SMILES, MOLFILE, CDX." )
2354        protected StringType representation;
2355
2356        /**
2357         * An attached file with the structural representation.
2358         */
2359        @Child(name = "attachment", type = {Attachment.class}, order=3, min=0, max=1, modifier=false, summary=true)
2360        @Description(shortDefinition="An attached file with the structural representation", formalDefinition="An attached file with the structural representation." )
2361        protected Attachment attachment;
2362
2363        private static final long serialVersionUID = 167954495L;
2364
2365    /**
2366     * Constructor
2367     */
2368      public SubstanceSpecificationStructureStructuralRepresentationComponent() {
2369        super();
2370      }
2371
2372        /**
2373         * @return {@link #type} (The type of structure (e.g. Full, Partial, Representative).)
2374         */
2375        public CodeableConcept getType() { 
2376          if (this.type == null)
2377            if (Configuration.errorOnAutoCreate())
2378              throw new Error("Attempt to auto-create SubstanceSpecificationStructureStructuralRepresentationComponent.type");
2379            else if (Configuration.doAutoCreate())
2380              this.type = new CodeableConcept(); // cc
2381          return this.type;
2382        }
2383
2384        public boolean hasType() { 
2385          return this.type != null && !this.type.isEmpty();
2386        }
2387
2388        /**
2389         * @param value {@link #type} (The type of structure (e.g. Full, Partial, Representative).)
2390         */
2391        public SubstanceSpecificationStructureStructuralRepresentationComponent setType(CodeableConcept value) { 
2392          this.type = value;
2393          return this;
2394        }
2395
2396        /**
2397         * @return {@link #representation} (The structural representation as text string in a format e.g. InChI, SMILES, MOLFILE, CDX.). This is the underlying object with id, value and extensions. The accessor "getRepresentation" gives direct access to the value
2398         */
2399        public StringType getRepresentationElement() { 
2400          if (this.representation == null)
2401            if (Configuration.errorOnAutoCreate())
2402              throw new Error("Attempt to auto-create SubstanceSpecificationStructureStructuralRepresentationComponent.representation");
2403            else if (Configuration.doAutoCreate())
2404              this.representation = new StringType(); // bb
2405          return this.representation;
2406        }
2407
2408        public boolean hasRepresentationElement() { 
2409          return this.representation != null && !this.representation.isEmpty();
2410        }
2411
2412        public boolean hasRepresentation() { 
2413          return this.representation != null && !this.representation.isEmpty();
2414        }
2415
2416        /**
2417         * @param value {@link #representation} (The structural representation as text string in a format e.g. InChI, SMILES, MOLFILE, CDX.). This is the underlying object with id, value and extensions. The accessor "getRepresentation" gives direct access to the value
2418         */
2419        public SubstanceSpecificationStructureStructuralRepresentationComponent setRepresentationElement(StringType value) { 
2420          this.representation = value;
2421          return this;
2422        }
2423
2424        /**
2425         * @return The structural representation as text string in a format e.g. InChI, SMILES, MOLFILE, CDX.
2426         */
2427        public String getRepresentation() { 
2428          return this.representation == null ? null : this.representation.getValue();
2429        }
2430
2431        /**
2432         * @param value The structural representation as text string in a format e.g. InChI, SMILES, MOLFILE, CDX.
2433         */
2434        public SubstanceSpecificationStructureStructuralRepresentationComponent setRepresentation(String value) { 
2435          if (Utilities.noString(value))
2436            this.representation = null;
2437          else {
2438            if (this.representation == null)
2439              this.representation = new StringType();
2440            this.representation.setValue(value);
2441          }
2442          return this;
2443        }
2444
2445        /**
2446         * @return {@link #attachment} (An attached file with the structural representation.)
2447         */
2448        public Attachment getAttachment() { 
2449          if (this.attachment == null)
2450            if (Configuration.errorOnAutoCreate())
2451              throw new Error("Attempt to auto-create SubstanceSpecificationStructureStructuralRepresentationComponent.attachment");
2452            else if (Configuration.doAutoCreate())
2453              this.attachment = new Attachment(); // cc
2454          return this.attachment;
2455        }
2456
2457        public boolean hasAttachment() { 
2458          return this.attachment != null && !this.attachment.isEmpty();
2459        }
2460
2461        /**
2462         * @param value {@link #attachment} (An attached file with the structural representation.)
2463         */
2464        public SubstanceSpecificationStructureStructuralRepresentationComponent setAttachment(Attachment value) { 
2465          this.attachment = value;
2466          return this;
2467        }
2468
2469        protected void listChildren(List<Property> children) {
2470          super.listChildren(children);
2471          children.add(new Property("type", "CodeableConcept", "The type of structure (e.g. Full, Partial, Representative).", 0, 1, type));
2472          children.add(new Property("representation", "string", "The structural representation as text string in a format e.g. InChI, SMILES, MOLFILE, CDX.", 0, 1, representation));
2473          children.add(new Property("attachment", "Attachment", "An attached file with the structural representation.", 0, 1, attachment));
2474        }
2475
2476        @Override
2477        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2478          switch (_hash) {
2479          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "The type of structure (e.g. Full, Partial, Representative).", 0, 1, type);
2480          case -671065907: /*representation*/  return new Property("representation", "string", "The structural representation as text string in a format e.g. InChI, SMILES, MOLFILE, CDX.", 0, 1, representation);
2481          case -1963501277: /*attachment*/  return new Property("attachment", "Attachment", "An attached file with the structural representation.", 0, 1, attachment);
2482          default: return super.getNamedProperty(_hash, _name, _checkValid);
2483          }
2484
2485        }
2486
2487      @Override
2488      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2489        switch (hash) {
2490        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
2491        case -671065907: /*representation*/ return this.representation == null ? new Base[0] : new Base[] {this.representation}; // StringType
2492        case -1963501277: /*attachment*/ return this.attachment == null ? new Base[0] : new Base[] {this.attachment}; // Attachment
2493        default: return super.getProperty(hash, name, checkValid);
2494        }
2495
2496      }
2497
2498      @Override
2499      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2500        switch (hash) {
2501        case 3575610: // type
2502          this.type = castToCodeableConcept(value); // CodeableConcept
2503          return value;
2504        case -671065907: // representation
2505          this.representation = castToString(value); // StringType
2506          return value;
2507        case -1963501277: // attachment
2508          this.attachment = castToAttachment(value); // Attachment
2509          return value;
2510        default: return super.setProperty(hash, name, value);
2511        }
2512
2513      }
2514
2515      @Override
2516      public Base setProperty(String name, Base value) throws FHIRException {
2517        if (name.equals("type")) {
2518          this.type = castToCodeableConcept(value); // CodeableConcept
2519        } else if (name.equals("representation")) {
2520          this.representation = castToString(value); // StringType
2521        } else if (name.equals("attachment")) {
2522          this.attachment = castToAttachment(value); // Attachment
2523        } else
2524          return super.setProperty(name, value);
2525        return value;
2526      }
2527
2528      @Override
2529      public Base makeProperty(int hash, String name) throws FHIRException {
2530        switch (hash) {
2531        case 3575610:  return getType(); 
2532        case -671065907:  return getRepresentationElement();
2533        case -1963501277:  return getAttachment(); 
2534        default: return super.makeProperty(hash, name);
2535        }
2536
2537      }
2538
2539      @Override
2540      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2541        switch (hash) {
2542        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
2543        case -671065907: /*representation*/ return new String[] {"string"};
2544        case -1963501277: /*attachment*/ return new String[] {"Attachment"};
2545        default: return super.getTypesForProperty(hash, name);
2546        }
2547
2548      }
2549
2550      @Override
2551      public Base addChild(String name) throws FHIRException {
2552        if (name.equals("type")) {
2553          this.type = new CodeableConcept();
2554          return this.type;
2555        }
2556        else if (name.equals("representation")) {
2557          throw new FHIRException("Cannot call addChild on a primitive type SubstanceSpecification.representation");
2558        }
2559        else if (name.equals("attachment")) {
2560          this.attachment = new Attachment();
2561          return this.attachment;
2562        }
2563        else
2564          return super.addChild(name);
2565      }
2566
2567      public SubstanceSpecificationStructureStructuralRepresentationComponent copy() {
2568        SubstanceSpecificationStructureStructuralRepresentationComponent dst = new SubstanceSpecificationStructureStructuralRepresentationComponent();
2569        copyValues(dst);
2570        dst.type = type == null ? null : type.copy();
2571        dst.representation = representation == null ? null : representation.copy();
2572        dst.attachment = attachment == null ? null : attachment.copy();
2573        return dst;
2574      }
2575
2576      @Override
2577      public boolean equalsDeep(Base other_) {
2578        if (!super.equalsDeep(other_))
2579          return false;
2580        if (!(other_ instanceof SubstanceSpecificationStructureStructuralRepresentationComponent))
2581          return false;
2582        SubstanceSpecificationStructureStructuralRepresentationComponent o = (SubstanceSpecificationStructureStructuralRepresentationComponent) other_;
2583        return compareDeep(type, o.type, true) && compareDeep(representation, o.representation, true) && compareDeep(attachment, o.attachment, true)
2584          ;
2585      }
2586
2587      @Override
2588      public boolean equalsShallow(Base other_) {
2589        if (!super.equalsShallow(other_))
2590          return false;
2591        if (!(other_ instanceof SubstanceSpecificationStructureStructuralRepresentationComponent))
2592          return false;
2593        SubstanceSpecificationStructureStructuralRepresentationComponent o = (SubstanceSpecificationStructureStructuralRepresentationComponent) other_;
2594        return compareValues(representation, o.representation, true);
2595      }
2596
2597      public boolean isEmpty() {
2598        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, representation, attachment
2599          );
2600      }
2601
2602  public String fhirType() {
2603    return "SubstanceSpecification.structure.structuralRepresentation";
2604
2605  }
2606
2607  }
2608
2609    @Block()
2610    public static class SubstanceSpecificationSubstanceCodeComponent extends BackboneElement implements IBaseBackboneElement {
2611        /**
2612         * The specific code.
2613         */
2614        @Child(name = "code", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
2615        @Description(shortDefinition="The specific code", formalDefinition="The specific code." )
2616        protected CodeableConcept code;
2617
2618        /**
2619         * Status of the code assignment.
2620         */
2621        @Child(name = "status", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
2622        @Description(shortDefinition="Status of the code assignment", formalDefinition="Status of the code assignment." )
2623        protected CodeableConcept status;
2624
2625        /**
2626         * The date at which the code status is changed as part of the terminology maintenance.
2627         */
2628        @Child(name = "statusDate", type = {DateTimeType.class}, order=3, min=0, max=1, modifier=false, summary=true)
2629        @Description(shortDefinition="The date at which the code status is changed as part of the terminology maintenance", formalDefinition="The date at which the code status is changed as part of the terminology maintenance." )
2630        protected DateTimeType statusDate;
2631
2632        /**
2633         * Any comment can be provided in this field, if necessary.
2634         */
2635        @Child(name = "comment", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=true)
2636        @Description(shortDefinition="Any comment can be provided in this field, if necessary", formalDefinition="Any comment can be provided in this field, if necessary." )
2637        protected StringType comment;
2638
2639        /**
2640         * Supporting literature.
2641         */
2642        @Child(name = "referenceSource", type = {StringType.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2643        @Description(shortDefinition="Supporting literature", formalDefinition="Supporting literature." )
2644        protected List<StringType> referenceSource;
2645
2646        private static final long serialVersionUID = 1936663817L;
2647
2648    /**
2649     * Constructor
2650     */
2651      public SubstanceSpecificationSubstanceCodeComponent() {
2652        super();
2653      }
2654
2655        /**
2656         * @return {@link #code} (The specific code.)
2657         */
2658        public CodeableConcept getCode() { 
2659          if (this.code == null)
2660            if (Configuration.errorOnAutoCreate())
2661              throw new Error("Attempt to auto-create SubstanceSpecificationSubstanceCodeComponent.code");
2662            else if (Configuration.doAutoCreate())
2663              this.code = new CodeableConcept(); // cc
2664          return this.code;
2665        }
2666
2667        public boolean hasCode() { 
2668          return this.code != null && !this.code.isEmpty();
2669        }
2670
2671        /**
2672         * @param value {@link #code} (The specific code.)
2673         */
2674        public SubstanceSpecificationSubstanceCodeComponent setCode(CodeableConcept value) { 
2675          this.code = value;
2676          return this;
2677        }
2678
2679        /**
2680         * @return {@link #status} (Status of the code assignment.)
2681         */
2682        public CodeableConcept getStatus() { 
2683          if (this.status == null)
2684            if (Configuration.errorOnAutoCreate())
2685              throw new Error("Attempt to auto-create SubstanceSpecificationSubstanceCodeComponent.status");
2686            else if (Configuration.doAutoCreate())
2687              this.status = new CodeableConcept(); // cc
2688          return this.status;
2689        }
2690
2691        public boolean hasStatus() { 
2692          return this.status != null && !this.status.isEmpty();
2693        }
2694
2695        /**
2696         * @param value {@link #status} (Status of the code assignment.)
2697         */
2698        public SubstanceSpecificationSubstanceCodeComponent setStatus(CodeableConcept value) { 
2699          this.status = value;
2700          return this;
2701        }
2702
2703        /**
2704         * @return {@link #statusDate} (The date at which the code status is changed as part of the terminology maintenance.). This is the underlying object with id, value and extensions. The accessor "getStatusDate" gives direct access to the value
2705         */
2706        public DateTimeType getStatusDateElement() { 
2707          if (this.statusDate == null)
2708            if (Configuration.errorOnAutoCreate())
2709              throw new Error("Attempt to auto-create SubstanceSpecificationSubstanceCodeComponent.statusDate");
2710            else if (Configuration.doAutoCreate())
2711              this.statusDate = new DateTimeType(); // bb
2712          return this.statusDate;
2713        }
2714
2715        public boolean hasStatusDateElement() { 
2716          return this.statusDate != null && !this.statusDate.isEmpty();
2717        }
2718
2719        public boolean hasStatusDate() { 
2720          return this.statusDate != null && !this.statusDate.isEmpty();
2721        }
2722
2723        /**
2724         * @param value {@link #statusDate} (The date at which the code status is changed as part of the terminology maintenance.). This is the underlying object with id, value and extensions. The accessor "getStatusDate" gives direct access to the value
2725         */
2726        public SubstanceSpecificationSubstanceCodeComponent setStatusDateElement(DateTimeType value) { 
2727          this.statusDate = value;
2728          return this;
2729        }
2730
2731        /**
2732         * @return The date at which the code status is changed as part of the terminology maintenance.
2733         */
2734        public Date getStatusDate() { 
2735          return this.statusDate == null ? null : this.statusDate.getValue();
2736        }
2737
2738        /**
2739         * @param value The date at which the code status is changed as part of the terminology maintenance.
2740         */
2741        public SubstanceSpecificationSubstanceCodeComponent setStatusDate(Date value) { 
2742          if (value == null)
2743            this.statusDate = null;
2744          else {
2745            if (this.statusDate == null)
2746              this.statusDate = new DateTimeType();
2747            this.statusDate.setValue(value);
2748          }
2749          return this;
2750        }
2751
2752        /**
2753         * @return {@link #comment} (Any comment can be provided in this field, if necessary.). This is the underlying object with id, value and extensions. The accessor "getComment" gives direct access to the value
2754         */
2755        public StringType getCommentElement() { 
2756          if (this.comment == null)
2757            if (Configuration.errorOnAutoCreate())
2758              throw new Error("Attempt to auto-create SubstanceSpecificationSubstanceCodeComponent.comment");
2759            else if (Configuration.doAutoCreate())
2760              this.comment = new StringType(); // bb
2761          return this.comment;
2762        }
2763
2764        public boolean hasCommentElement() { 
2765          return this.comment != null && !this.comment.isEmpty();
2766        }
2767
2768        public boolean hasComment() { 
2769          return this.comment != null && !this.comment.isEmpty();
2770        }
2771
2772        /**
2773         * @param value {@link #comment} (Any comment can be provided in this field, if necessary.). This is the underlying object with id, value and extensions. The accessor "getComment" gives direct access to the value
2774         */
2775        public SubstanceSpecificationSubstanceCodeComponent setCommentElement(StringType value) { 
2776          this.comment = value;
2777          return this;
2778        }
2779
2780        /**
2781         * @return Any comment can be provided in this field, if necessary.
2782         */
2783        public String getComment() { 
2784          return this.comment == null ? null : this.comment.getValue();
2785        }
2786
2787        /**
2788         * @param value Any comment can be provided in this field, if necessary.
2789         */
2790        public SubstanceSpecificationSubstanceCodeComponent setComment(String value) { 
2791          if (Utilities.noString(value))
2792            this.comment = null;
2793          else {
2794            if (this.comment == null)
2795              this.comment = new StringType();
2796            this.comment.setValue(value);
2797          }
2798          return this;
2799        }
2800
2801        /**
2802         * @return {@link #referenceSource} (Supporting literature.)
2803         */
2804        public List<StringType> getReferenceSource() { 
2805          if (this.referenceSource == null)
2806            this.referenceSource = new ArrayList<StringType>();
2807          return this.referenceSource;
2808        }
2809
2810        /**
2811         * @return Returns a reference to <code>this</code> for easy method chaining
2812         */
2813        public SubstanceSpecificationSubstanceCodeComponent setReferenceSource(List<StringType> theReferenceSource) { 
2814          this.referenceSource = theReferenceSource;
2815          return this;
2816        }
2817
2818        public boolean hasReferenceSource() { 
2819          if (this.referenceSource == null)
2820            return false;
2821          for (StringType item : this.referenceSource)
2822            if (!item.isEmpty())
2823              return true;
2824          return false;
2825        }
2826
2827        /**
2828         * @return {@link #referenceSource} (Supporting literature.)
2829         */
2830        public StringType addReferenceSourceElement() {//2 
2831          StringType t = new StringType();
2832          if (this.referenceSource == null)
2833            this.referenceSource = new ArrayList<StringType>();
2834          this.referenceSource.add(t);
2835          return t;
2836        }
2837
2838        /**
2839         * @param value {@link #referenceSource} (Supporting literature.)
2840         */
2841        public SubstanceSpecificationSubstanceCodeComponent addReferenceSource(String value) { //1
2842          StringType t = new StringType();
2843          t.setValue(value);
2844          if (this.referenceSource == null)
2845            this.referenceSource = new ArrayList<StringType>();
2846          this.referenceSource.add(t);
2847          return this;
2848        }
2849
2850        /**
2851         * @param value {@link #referenceSource} (Supporting literature.)
2852         */
2853        public boolean hasReferenceSource(String value) { 
2854          if (this.referenceSource == null)
2855            return false;
2856          for (StringType v : this.referenceSource)
2857            if (v.getValue().equals(value)) // string
2858              return true;
2859          return false;
2860        }
2861
2862        protected void listChildren(List<Property> children) {
2863          super.listChildren(children);
2864          children.add(new Property("code", "CodeableConcept", "The specific code.", 0, 1, code));
2865          children.add(new Property("status", "CodeableConcept", "Status of the code assignment.", 0, 1, status));
2866          children.add(new Property("statusDate", "dateTime", "The date at which the code status is changed as part of the terminology maintenance.", 0, 1, statusDate));
2867          children.add(new Property("comment", "string", "Any comment can be provided in this field, if necessary.", 0, 1, comment));
2868          children.add(new Property("referenceSource", "string", "Supporting literature.", 0, java.lang.Integer.MAX_VALUE, referenceSource));
2869        }
2870
2871        @Override
2872        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2873          switch (_hash) {
2874          case 3059181: /*code*/  return new Property("code", "CodeableConcept", "The specific code.", 0, 1, code);
2875          case -892481550: /*status*/  return new Property("status", "CodeableConcept", "Status of the code assignment.", 0, 1, status);
2876          case 247524032: /*statusDate*/  return new Property("statusDate", "dateTime", "The date at which the code status is changed as part of the terminology maintenance.", 0, 1, statusDate);
2877          case 950398559: /*comment*/  return new Property("comment", "string", "Any comment can be provided in this field, if necessary.", 0, 1, comment);
2878          case 882421574: /*referenceSource*/  return new Property("referenceSource", "string", "Supporting literature.", 0, java.lang.Integer.MAX_VALUE, referenceSource);
2879          default: return super.getNamedProperty(_hash, _name, _checkValid);
2880          }
2881
2882        }
2883
2884      @Override
2885      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2886        switch (hash) {
2887        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept
2888        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // CodeableConcept
2889        case 247524032: /*statusDate*/ return this.statusDate == null ? new Base[0] : new Base[] {this.statusDate}; // DateTimeType
2890        case 950398559: /*comment*/ return this.comment == null ? new Base[0] : new Base[] {this.comment}; // StringType
2891        case 882421574: /*referenceSource*/ return this.referenceSource == null ? new Base[0] : this.referenceSource.toArray(new Base[this.referenceSource.size()]); // StringType
2892        default: return super.getProperty(hash, name, checkValid);
2893        }
2894
2895      }
2896
2897      @Override
2898      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2899        switch (hash) {
2900        case 3059181: // code
2901          this.code = castToCodeableConcept(value); // CodeableConcept
2902          return value;
2903        case -892481550: // status
2904          this.status = castToCodeableConcept(value); // CodeableConcept
2905          return value;
2906        case 247524032: // statusDate
2907          this.statusDate = castToDateTime(value); // DateTimeType
2908          return value;
2909        case 950398559: // comment
2910          this.comment = castToString(value); // StringType
2911          return value;
2912        case 882421574: // referenceSource
2913          this.getReferenceSource().add(castToString(value)); // StringType
2914          return value;
2915        default: return super.setProperty(hash, name, value);
2916        }
2917
2918      }
2919
2920      @Override
2921      public Base setProperty(String name, Base value) throws FHIRException {
2922        if (name.equals("code")) {
2923          this.code = castToCodeableConcept(value); // CodeableConcept
2924        } else if (name.equals("status")) {
2925          this.status = castToCodeableConcept(value); // CodeableConcept
2926        } else if (name.equals("statusDate")) {
2927          this.statusDate = castToDateTime(value); // DateTimeType
2928        } else if (name.equals("comment")) {
2929          this.comment = castToString(value); // StringType
2930        } else if (name.equals("referenceSource")) {
2931          this.getReferenceSource().add(castToString(value));
2932        } else
2933          return super.setProperty(name, value);
2934        return value;
2935      }
2936
2937      @Override
2938      public Base makeProperty(int hash, String name) throws FHIRException {
2939        switch (hash) {
2940        case 3059181:  return getCode(); 
2941        case -892481550:  return getStatus(); 
2942        case 247524032:  return getStatusDateElement();
2943        case 950398559:  return getCommentElement();
2944        case 882421574:  return addReferenceSourceElement();
2945        default: return super.makeProperty(hash, name);
2946        }
2947
2948      }
2949
2950      @Override
2951      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2952        switch (hash) {
2953        case 3059181: /*code*/ return new String[] {"CodeableConcept"};
2954        case -892481550: /*status*/ return new String[] {"CodeableConcept"};
2955        case 247524032: /*statusDate*/ return new String[] {"dateTime"};
2956        case 950398559: /*comment*/ return new String[] {"string"};
2957        case 882421574: /*referenceSource*/ return new String[] {"string"};
2958        default: return super.getTypesForProperty(hash, name);
2959        }
2960
2961      }
2962
2963      @Override
2964      public Base addChild(String name) throws FHIRException {
2965        if (name.equals("code")) {
2966          this.code = new CodeableConcept();
2967          return this.code;
2968        }
2969        else if (name.equals("status")) {
2970          this.status = new CodeableConcept();
2971          return this.status;
2972        }
2973        else if (name.equals("statusDate")) {
2974          throw new FHIRException("Cannot call addChild on a primitive type SubstanceSpecification.statusDate");
2975        }
2976        else if (name.equals("comment")) {
2977          throw new FHIRException("Cannot call addChild on a primitive type SubstanceSpecification.comment");
2978        }
2979        else if (name.equals("referenceSource")) {
2980          throw new FHIRException("Cannot call addChild on a primitive type SubstanceSpecification.referenceSource");
2981        }
2982        else
2983          return super.addChild(name);
2984      }
2985
2986      public SubstanceSpecificationSubstanceCodeComponent copy() {
2987        SubstanceSpecificationSubstanceCodeComponent dst = new SubstanceSpecificationSubstanceCodeComponent();
2988        copyValues(dst);
2989        dst.code = code == null ? null : code.copy();
2990        dst.status = status == null ? null : status.copy();
2991        dst.statusDate = statusDate == null ? null : statusDate.copy();
2992        dst.comment = comment == null ? null : comment.copy();
2993        if (referenceSource != null) {
2994          dst.referenceSource = new ArrayList<StringType>();
2995          for (StringType i : referenceSource)
2996            dst.referenceSource.add(i.copy());
2997        };
2998        return dst;
2999      }
3000
3001      @Override
3002      public boolean equalsDeep(Base other_) {
3003        if (!super.equalsDeep(other_))
3004          return false;
3005        if (!(other_ instanceof SubstanceSpecificationSubstanceCodeComponent))
3006          return false;
3007        SubstanceSpecificationSubstanceCodeComponent o = (SubstanceSpecificationSubstanceCodeComponent) other_;
3008        return compareDeep(code, o.code, true) && compareDeep(status, o.status, true) && compareDeep(statusDate, o.statusDate, true)
3009           && compareDeep(comment, o.comment, true) && compareDeep(referenceSource, o.referenceSource, true)
3010          ;
3011      }
3012
3013      @Override
3014      public boolean equalsShallow(Base other_) {
3015        if (!super.equalsShallow(other_))
3016          return false;
3017        if (!(other_ instanceof SubstanceSpecificationSubstanceCodeComponent))
3018          return false;
3019        SubstanceSpecificationSubstanceCodeComponent o = (SubstanceSpecificationSubstanceCodeComponent) other_;
3020        return compareValues(statusDate, o.statusDate, true) && compareValues(comment, o.comment, true) && compareValues(referenceSource, o.referenceSource, true)
3021          ;
3022      }
3023
3024      public boolean isEmpty() {
3025        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(code, status, statusDate
3026          , comment, referenceSource);
3027      }
3028
3029  public String fhirType() {
3030    return "SubstanceSpecification.substanceCode";
3031
3032  }
3033
3034  }
3035
3036    @Block()
3037    public static class SubstanceSpecificationSubstanceNameComponent extends BackboneElement implements IBaseBackboneElement {
3038        /**
3039         * The actual name.
3040         */
3041        @Child(name = "name", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true)
3042        @Description(shortDefinition="The actual name", formalDefinition="The actual name." )
3043        protected StringType name;
3044
3045        /**
3046         * Name type.
3047         */
3048        @Child(name = "type", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
3049        @Description(shortDefinition="Name type", formalDefinition="Name type." )
3050        protected CodeableConcept type;
3051
3052        /**
3053         * Language of the name.
3054         */
3055        @Child(name = "language", type = {CodeableConcept.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
3056        @Description(shortDefinition="Language of the name", formalDefinition="Language of the name." )
3057        protected List<CodeableConcept> language;
3058
3059        /**
3060         * 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.
3061         */
3062        @Child(name = "domain", type = {CodeableConcept.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
3063        @Description(shortDefinition="The use context of this name for example if there is a different name a drug active ingredient as opposed to a food colour additive", formalDefinition="The use context of this name for example if there is a different name a drug active ingredient as opposed to a food colour additive." )
3064        protected List<CodeableConcept> domain;
3065
3066        /**
3067         * The jurisdiction where this name applies.
3068         */
3069        @Child(name = "jurisdiction", type = {CodeableConcept.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
3070        @Description(shortDefinition="The jurisdiction where this name applies", formalDefinition="The jurisdiction where this name applies." )
3071        protected List<CodeableConcept> jurisdiction;
3072
3073        /**
3074         * Details of the official nature of this name.
3075         */
3076        @Child(name = "officialName", type = {}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
3077        @Description(shortDefinition="Details of the official nature of this name", formalDefinition="Details of the official nature of this name." )
3078        protected List<SubstanceSpecificationSubstanceNameOfficialNameComponent> officialName;
3079
3080        /**
3081         * Supporting literature.
3082         */
3083        @Child(name = "referenceSource", type = {StringType.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
3084        @Description(shortDefinition="Supporting literature", formalDefinition="Supporting literature." )
3085        protected List<StringType> referenceSource;
3086
3087        private static final long serialVersionUID = -1690760755L;
3088
3089    /**
3090     * Constructor
3091     */
3092      public SubstanceSpecificationSubstanceNameComponent() {
3093        super();
3094      }
3095
3096        /**
3097         * @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
3098         */
3099        public StringType getNameElement() { 
3100          if (this.name == null)
3101            if (Configuration.errorOnAutoCreate())
3102              throw new Error("Attempt to auto-create SubstanceSpecificationSubstanceNameComponent.name");
3103            else if (Configuration.doAutoCreate())
3104              this.name = new StringType(); // bb
3105          return this.name;
3106        }
3107
3108        public boolean hasNameElement() { 
3109          return this.name != null && !this.name.isEmpty();
3110        }
3111
3112        public boolean hasName() { 
3113          return this.name != null && !this.name.isEmpty();
3114        }
3115
3116        /**
3117         * @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
3118         */
3119        public SubstanceSpecificationSubstanceNameComponent setNameElement(StringType value) { 
3120          this.name = value;
3121          return this;
3122        }
3123
3124        /**
3125         * @return The actual name.
3126         */
3127        public String getName() { 
3128          return this.name == null ? null : this.name.getValue();
3129        }
3130
3131        /**
3132         * @param value The actual name.
3133         */
3134        public SubstanceSpecificationSubstanceNameComponent setName(String value) { 
3135          if (Utilities.noString(value))
3136            this.name = null;
3137          else {
3138            if (this.name == null)
3139              this.name = new StringType();
3140            this.name.setValue(value);
3141          }
3142          return this;
3143        }
3144
3145        /**
3146         * @return {@link #type} (Name type.)
3147         */
3148        public CodeableConcept getType() { 
3149          if (this.type == null)
3150            if (Configuration.errorOnAutoCreate())
3151              throw new Error("Attempt to auto-create SubstanceSpecificationSubstanceNameComponent.type");
3152            else if (Configuration.doAutoCreate())
3153              this.type = new CodeableConcept(); // cc
3154          return this.type;
3155        }
3156
3157        public boolean hasType() { 
3158          return this.type != null && !this.type.isEmpty();
3159        }
3160
3161        /**
3162         * @param value {@link #type} (Name type.)
3163         */
3164        public SubstanceSpecificationSubstanceNameComponent setType(CodeableConcept value) { 
3165          this.type = value;
3166          return this;
3167        }
3168
3169        /**
3170         * @return {@link #language} (Language of the name.)
3171         */
3172        public List<CodeableConcept> getLanguage() { 
3173          if (this.language == null)
3174            this.language = new ArrayList<CodeableConcept>();
3175          return this.language;
3176        }
3177
3178        /**
3179         * @return Returns a reference to <code>this</code> for easy method chaining
3180         */
3181        public SubstanceSpecificationSubstanceNameComponent setLanguage(List<CodeableConcept> theLanguage) { 
3182          this.language = theLanguage;
3183          return this;
3184        }
3185
3186        public boolean hasLanguage() { 
3187          if (this.language == null)
3188            return false;
3189          for (CodeableConcept item : this.language)
3190            if (!item.isEmpty())
3191              return true;
3192          return false;
3193        }
3194
3195        public CodeableConcept addLanguage() { //3
3196          CodeableConcept t = new CodeableConcept();
3197          if (this.language == null)
3198            this.language = new ArrayList<CodeableConcept>();
3199          this.language.add(t);
3200          return t;
3201        }
3202
3203        public SubstanceSpecificationSubstanceNameComponent addLanguage(CodeableConcept t) { //3
3204          if (t == null)
3205            return this;
3206          if (this.language == null)
3207            this.language = new ArrayList<CodeableConcept>();
3208          this.language.add(t);
3209          return this;
3210        }
3211
3212        /**
3213         * @return The first repetition of repeating field {@link #language}, creating it if it does not already exist
3214         */
3215        public CodeableConcept getLanguageFirstRep() { 
3216          if (getLanguage().isEmpty()) {
3217            addLanguage();
3218          }
3219          return getLanguage().get(0);
3220        }
3221
3222        /**
3223         * @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.)
3224         */
3225        public List<CodeableConcept> getDomain() { 
3226          if (this.domain == null)
3227            this.domain = new ArrayList<CodeableConcept>();
3228          return this.domain;
3229        }
3230
3231        /**
3232         * @return Returns a reference to <code>this</code> for easy method chaining
3233         */
3234        public SubstanceSpecificationSubstanceNameComponent setDomain(List<CodeableConcept> theDomain) { 
3235          this.domain = theDomain;
3236          return this;
3237        }
3238
3239        public boolean hasDomain() { 
3240          if (this.domain == null)
3241            return false;
3242          for (CodeableConcept item : this.domain)
3243            if (!item.isEmpty())
3244              return true;
3245          return false;
3246        }
3247
3248        public CodeableConcept addDomain() { //3
3249          CodeableConcept t = new CodeableConcept();
3250          if (this.domain == null)
3251            this.domain = new ArrayList<CodeableConcept>();
3252          this.domain.add(t);
3253          return t;
3254        }
3255
3256        public SubstanceSpecificationSubstanceNameComponent addDomain(CodeableConcept t) { //3
3257          if (t == null)
3258            return this;
3259          if (this.domain == null)
3260            this.domain = new ArrayList<CodeableConcept>();
3261          this.domain.add(t);
3262          return this;
3263        }
3264
3265        /**
3266         * @return The first repetition of repeating field {@link #domain}, creating it if it does not already exist
3267         */
3268        public CodeableConcept getDomainFirstRep() { 
3269          if (getDomain().isEmpty()) {
3270            addDomain();
3271          }
3272          return getDomain().get(0);
3273        }
3274
3275        /**
3276         * @return {@link #jurisdiction} (The jurisdiction where this name applies.)
3277         */
3278        public List<CodeableConcept> getJurisdiction() { 
3279          if (this.jurisdiction == null)
3280            this.jurisdiction = new ArrayList<CodeableConcept>();
3281          return this.jurisdiction;
3282        }
3283
3284        /**
3285         * @return Returns a reference to <code>this</code> for easy method chaining
3286         */
3287        public SubstanceSpecificationSubstanceNameComponent setJurisdiction(List<CodeableConcept> theJurisdiction) { 
3288          this.jurisdiction = theJurisdiction;
3289          return this;
3290        }
3291
3292        public boolean hasJurisdiction() { 
3293          if (this.jurisdiction == null)
3294            return false;
3295          for (CodeableConcept item : this.jurisdiction)
3296            if (!item.isEmpty())
3297              return true;
3298          return false;
3299        }
3300
3301        public CodeableConcept addJurisdiction() { //3
3302          CodeableConcept t = new CodeableConcept();
3303          if (this.jurisdiction == null)
3304            this.jurisdiction = new ArrayList<CodeableConcept>();
3305          this.jurisdiction.add(t);
3306          return t;
3307        }
3308
3309        public SubstanceSpecificationSubstanceNameComponent addJurisdiction(CodeableConcept t) { //3
3310          if (t == null)
3311            return this;
3312          if (this.jurisdiction == null)
3313            this.jurisdiction = new ArrayList<CodeableConcept>();
3314          this.jurisdiction.add(t);
3315          return this;
3316        }
3317
3318        /**
3319         * @return The first repetition of repeating field {@link #jurisdiction}, creating it if it does not already exist
3320         */
3321        public CodeableConcept getJurisdictionFirstRep() { 
3322          if (getJurisdiction().isEmpty()) {
3323            addJurisdiction();
3324          }
3325          return getJurisdiction().get(0);
3326        }
3327
3328        /**
3329         * @return {@link #officialName} (Details of the official nature of this name.)
3330         */
3331        public List<SubstanceSpecificationSubstanceNameOfficialNameComponent> getOfficialName() { 
3332          if (this.officialName == null)
3333            this.officialName = new ArrayList<SubstanceSpecificationSubstanceNameOfficialNameComponent>();
3334          return this.officialName;
3335        }
3336
3337        /**
3338         * @return Returns a reference to <code>this</code> for easy method chaining
3339         */
3340        public SubstanceSpecificationSubstanceNameComponent setOfficialName(List<SubstanceSpecificationSubstanceNameOfficialNameComponent> theOfficialName) { 
3341          this.officialName = theOfficialName;
3342          return this;
3343        }
3344
3345        public boolean hasOfficialName() { 
3346          if (this.officialName == null)
3347            return false;
3348          for (SubstanceSpecificationSubstanceNameOfficialNameComponent item : this.officialName)
3349            if (!item.isEmpty())
3350              return true;
3351          return false;
3352        }
3353
3354        public SubstanceSpecificationSubstanceNameOfficialNameComponent addOfficialName() { //3
3355          SubstanceSpecificationSubstanceNameOfficialNameComponent t = new SubstanceSpecificationSubstanceNameOfficialNameComponent();
3356          if (this.officialName == null)
3357            this.officialName = new ArrayList<SubstanceSpecificationSubstanceNameOfficialNameComponent>();
3358          this.officialName.add(t);
3359          return t;
3360        }
3361
3362        public SubstanceSpecificationSubstanceNameComponent addOfficialName(SubstanceSpecificationSubstanceNameOfficialNameComponent t) { //3
3363          if (t == null)
3364            return this;
3365          if (this.officialName == null)
3366            this.officialName = new ArrayList<SubstanceSpecificationSubstanceNameOfficialNameComponent>();
3367          this.officialName.add(t);
3368          return this;
3369        }
3370
3371        /**
3372         * @return The first repetition of repeating field {@link #officialName}, creating it if it does not already exist
3373         */
3374        public SubstanceSpecificationSubstanceNameOfficialNameComponent getOfficialNameFirstRep() { 
3375          if (getOfficialName().isEmpty()) {
3376            addOfficialName();
3377          }
3378          return getOfficialName().get(0);
3379        }
3380
3381        /**
3382         * @return {@link #referenceSource} (Supporting literature.)
3383         */
3384        public List<StringType> getReferenceSource() { 
3385          if (this.referenceSource == null)
3386            this.referenceSource = new ArrayList<StringType>();
3387          return this.referenceSource;
3388        }
3389
3390        /**
3391         * @return Returns a reference to <code>this</code> for easy method chaining
3392         */
3393        public SubstanceSpecificationSubstanceNameComponent setReferenceSource(List<StringType> theReferenceSource) { 
3394          this.referenceSource = theReferenceSource;
3395          return this;
3396        }
3397
3398        public boolean hasReferenceSource() { 
3399          if (this.referenceSource == null)
3400            return false;
3401          for (StringType item : this.referenceSource)
3402            if (!item.isEmpty())
3403              return true;
3404          return false;
3405        }
3406
3407        /**
3408         * @return {@link #referenceSource} (Supporting literature.)
3409         */
3410        public StringType addReferenceSourceElement() {//2 
3411          StringType t = new StringType();
3412          if (this.referenceSource == null)
3413            this.referenceSource = new ArrayList<StringType>();
3414          this.referenceSource.add(t);
3415          return t;
3416        }
3417
3418        /**
3419         * @param value {@link #referenceSource} (Supporting literature.)
3420         */
3421        public SubstanceSpecificationSubstanceNameComponent addReferenceSource(String value) { //1
3422          StringType t = new StringType();
3423          t.setValue(value);
3424          if (this.referenceSource == null)
3425            this.referenceSource = new ArrayList<StringType>();
3426          this.referenceSource.add(t);
3427          return this;
3428        }
3429
3430        /**
3431         * @param value {@link #referenceSource} (Supporting literature.)
3432         */
3433        public boolean hasReferenceSource(String value) { 
3434          if (this.referenceSource == null)
3435            return false;
3436          for (StringType v : this.referenceSource)
3437            if (v.getValue().equals(value)) // string
3438              return true;
3439          return false;
3440        }
3441
3442        protected void listChildren(List<Property> children) {
3443          super.listChildren(children);
3444          children.add(new Property("name", "string", "The actual name.", 0, 1, name));
3445          children.add(new Property("type", "CodeableConcept", "Name type.", 0, 1, type));
3446          children.add(new Property("language", "CodeableConcept", "Language of the name.", 0, java.lang.Integer.MAX_VALUE, language));
3447          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));
3448          children.add(new Property("jurisdiction", "CodeableConcept", "The jurisdiction where this name applies.", 0, java.lang.Integer.MAX_VALUE, jurisdiction));
3449          children.add(new Property("officialName", "", "Details of the official nature of this name.", 0, java.lang.Integer.MAX_VALUE, officialName));
3450          children.add(new Property("referenceSource", "string", "Supporting literature.", 0, java.lang.Integer.MAX_VALUE, referenceSource));
3451        }
3452
3453        @Override
3454        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
3455          switch (_hash) {
3456          case 3373707: /*name*/  return new Property("name", "string", "The actual name.", 0, 1, name);
3457          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "Name type.", 0, 1, type);
3458          case -1613589672: /*language*/  return new Property("language", "CodeableConcept", "Language of the name.", 0, java.lang.Integer.MAX_VALUE, language);
3459          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);
3460          case -507075711: /*jurisdiction*/  return new Property("jurisdiction", "CodeableConcept", "The jurisdiction where this name applies.", 0, java.lang.Integer.MAX_VALUE, jurisdiction);
3461          case 1486494742: /*officialName*/  return new Property("officialName", "", "Details of the official nature of this name.", 0, java.lang.Integer.MAX_VALUE, officialName);
3462          case 882421574: /*referenceSource*/  return new Property("referenceSource", "string", "Supporting literature.", 0, java.lang.Integer.MAX_VALUE, referenceSource);
3463          default: return super.getNamedProperty(_hash, _name, _checkValid);
3464          }
3465
3466        }
3467
3468      @Override
3469      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
3470        switch (hash) {
3471        case 3373707: /*name*/ return this.name == null ? new Base[0] : new Base[] {this.name}; // StringType
3472        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
3473        case -1613589672: /*language*/ return this.language == null ? new Base[0] : this.language.toArray(new Base[this.language.size()]); // CodeableConcept
3474        case -1326197564: /*domain*/ return this.domain == null ? new Base[0] : this.domain.toArray(new Base[this.domain.size()]); // CodeableConcept
3475        case -507075711: /*jurisdiction*/ return this.jurisdiction == null ? new Base[0] : this.jurisdiction.toArray(new Base[this.jurisdiction.size()]); // CodeableConcept
3476        case 1486494742: /*officialName*/ return this.officialName == null ? new Base[0] : this.officialName.toArray(new Base[this.officialName.size()]); // SubstanceSpecificationSubstanceNameOfficialNameComponent
3477        case 882421574: /*referenceSource*/ return this.referenceSource == null ? new Base[0] : this.referenceSource.toArray(new Base[this.referenceSource.size()]); // StringType
3478        default: return super.getProperty(hash, name, checkValid);
3479        }
3480
3481      }
3482
3483      @Override
3484      public Base setProperty(int hash, String name, Base value) throws FHIRException {
3485        switch (hash) {
3486        case 3373707: // name
3487          this.name = castToString(value); // StringType
3488          return value;
3489        case 3575610: // type
3490          this.type = castToCodeableConcept(value); // CodeableConcept
3491          return value;
3492        case -1613589672: // language
3493          this.getLanguage().add(castToCodeableConcept(value)); // CodeableConcept
3494          return value;
3495        case -1326197564: // domain
3496          this.getDomain().add(castToCodeableConcept(value)); // CodeableConcept
3497          return value;
3498        case -507075711: // jurisdiction
3499          this.getJurisdiction().add(castToCodeableConcept(value)); // CodeableConcept
3500          return value;
3501        case 1486494742: // officialName
3502          this.getOfficialName().add((SubstanceSpecificationSubstanceNameOfficialNameComponent) value); // SubstanceSpecificationSubstanceNameOfficialNameComponent
3503          return value;
3504        case 882421574: // referenceSource
3505          this.getReferenceSource().add(castToString(value)); // StringType
3506          return value;
3507        default: return super.setProperty(hash, name, value);
3508        }
3509
3510      }
3511
3512      @Override
3513      public Base setProperty(String name, Base value) throws FHIRException {
3514        if (name.equals("name")) {
3515          this.name = castToString(value); // StringType
3516        } else if (name.equals("type")) {
3517          this.type = castToCodeableConcept(value); // CodeableConcept
3518        } else if (name.equals("language")) {
3519          this.getLanguage().add(castToCodeableConcept(value));
3520        } else if (name.equals("domain")) {
3521          this.getDomain().add(castToCodeableConcept(value));
3522        } else if (name.equals("jurisdiction")) {
3523          this.getJurisdiction().add(castToCodeableConcept(value));
3524        } else if (name.equals("officialName")) {
3525          this.getOfficialName().add((SubstanceSpecificationSubstanceNameOfficialNameComponent) value);
3526        } else if (name.equals("referenceSource")) {
3527          this.getReferenceSource().add(castToString(value));
3528        } else
3529          return super.setProperty(name, value);
3530        return value;
3531      }
3532
3533      @Override
3534      public Base makeProperty(int hash, String name) throws FHIRException {
3535        switch (hash) {
3536        case 3373707:  return getNameElement();
3537        case 3575610:  return getType(); 
3538        case -1613589672:  return addLanguage(); 
3539        case -1326197564:  return addDomain(); 
3540        case -507075711:  return addJurisdiction(); 
3541        case 1486494742:  return addOfficialName(); 
3542        case 882421574:  return addReferenceSourceElement();
3543        default: return super.makeProperty(hash, name);
3544        }
3545
3546      }
3547
3548      @Override
3549      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
3550        switch (hash) {
3551        case 3373707: /*name*/ return new String[] {"string"};
3552        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
3553        case -1613589672: /*language*/ return new String[] {"CodeableConcept"};
3554        case -1326197564: /*domain*/ return new String[] {"CodeableConcept"};
3555        case -507075711: /*jurisdiction*/ return new String[] {"CodeableConcept"};
3556        case 1486494742: /*officialName*/ return new String[] {};
3557        case 882421574: /*referenceSource*/ return new String[] {"string"};
3558        default: return super.getTypesForProperty(hash, name);
3559        }
3560
3561      }
3562
3563      @Override
3564      public Base addChild(String name) throws FHIRException {
3565        if (name.equals("name")) {
3566          throw new FHIRException("Cannot call addChild on a primitive type SubstanceSpecification.name");
3567        }
3568        else if (name.equals("type")) {
3569          this.type = new CodeableConcept();
3570          return this.type;
3571        }
3572        else if (name.equals("language")) {
3573          return addLanguage();
3574        }
3575        else if (name.equals("domain")) {
3576          return addDomain();
3577        }
3578        else if (name.equals("jurisdiction")) {
3579          return addJurisdiction();
3580        }
3581        else if (name.equals("officialName")) {
3582          return addOfficialName();
3583        }
3584        else if (name.equals("referenceSource")) {
3585          throw new FHIRException("Cannot call addChild on a primitive type SubstanceSpecification.referenceSource");
3586        }
3587        else
3588          return super.addChild(name);
3589      }
3590
3591      public SubstanceSpecificationSubstanceNameComponent copy() {
3592        SubstanceSpecificationSubstanceNameComponent dst = new SubstanceSpecificationSubstanceNameComponent();
3593        copyValues(dst);
3594        dst.name = name == null ? null : name.copy();
3595        dst.type = type == null ? null : type.copy();
3596        if (language != null) {
3597          dst.language = new ArrayList<CodeableConcept>();
3598          for (CodeableConcept i : language)
3599            dst.language.add(i.copy());
3600        };
3601        if (domain != null) {
3602          dst.domain = new ArrayList<CodeableConcept>();
3603          for (CodeableConcept i : domain)
3604            dst.domain.add(i.copy());
3605        };
3606        if (jurisdiction != null) {
3607          dst.jurisdiction = new ArrayList<CodeableConcept>();
3608          for (CodeableConcept i : jurisdiction)
3609            dst.jurisdiction.add(i.copy());
3610        };
3611        if (officialName != null) {
3612          dst.officialName = new ArrayList<SubstanceSpecificationSubstanceNameOfficialNameComponent>();
3613          for (SubstanceSpecificationSubstanceNameOfficialNameComponent i : officialName)
3614            dst.officialName.add(i.copy());
3615        };
3616        if (referenceSource != null) {
3617          dst.referenceSource = new ArrayList<StringType>();
3618          for (StringType i : referenceSource)
3619            dst.referenceSource.add(i.copy());
3620        };
3621        return dst;
3622      }
3623
3624      @Override
3625      public boolean equalsDeep(Base other_) {
3626        if (!super.equalsDeep(other_))
3627          return false;
3628        if (!(other_ instanceof SubstanceSpecificationSubstanceNameComponent))
3629          return false;
3630        SubstanceSpecificationSubstanceNameComponent o = (SubstanceSpecificationSubstanceNameComponent) other_;
3631        return compareDeep(name, o.name, true) && compareDeep(type, o.type, true) && compareDeep(language, o.language, true)
3632           && compareDeep(domain, o.domain, true) && compareDeep(jurisdiction, o.jurisdiction, true) && compareDeep(officialName, o.officialName, true)
3633           && compareDeep(referenceSource, o.referenceSource, true);
3634      }
3635
3636      @Override
3637      public boolean equalsShallow(Base other_) {
3638        if (!super.equalsShallow(other_))
3639          return false;
3640        if (!(other_ instanceof SubstanceSpecificationSubstanceNameComponent))
3641          return false;
3642        SubstanceSpecificationSubstanceNameComponent o = (SubstanceSpecificationSubstanceNameComponent) other_;
3643        return compareValues(name, o.name, true) && compareValues(referenceSource, o.referenceSource, true)
3644          ;
3645      }
3646
3647      public boolean isEmpty() {
3648        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(name, type, language, domain
3649          , jurisdiction, officialName, referenceSource);
3650      }
3651
3652  public String fhirType() {
3653    return "SubstanceSpecification.substanceName";
3654
3655  }
3656
3657  }
3658
3659    @Block()
3660    public static class SubstanceSpecificationSubstanceNameOfficialNameComponent extends BackboneElement implements IBaseBackboneElement {
3661        /**
3662         * Which authority uses this official name.
3663         */
3664        @Child(name = "authority", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
3665        @Description(shortDefinition="Which authority uses this official name", formalDefinition="Which authority uses this official name." )
3666        protected CodeableConcept authority;
3667
3668        /**
3669         * The status of the official name.
3670         */
3671        @Child(name = "status", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
3672        @Description(shortDefinition="The status of the official name", formalDefinition="The status of the official name." )
3673        protected CodeableConcept status;
3674
3675        /**
3676         * Date of official name change.
3677         */
3678        @Child(name = "date", type = {DateTimeType.class}, order=3, min=0, max=1, modifier=false, summary=true)
3679        @Description(shortDefinition="Date of official name change", formalDefinition="Date of official name change." )
3680        protected DateTimeType date;
3681
3682        private static final long serialVersionUID = -2040011008L;
3683
3684    /**
3685     * Constructor
3686     */
3687      public SubstanceSpecificationSubstanceNameOfficialNameComponent() {
3688        super();
3689      }
3690
3691        /**
3692         * @return {@link #authority} (Which authority uses this official name.)
3693         */
3694        public CodeableConcept getAuthority() { 
3695          if (this.authority == null)
3696            if (Configuration.errorOnAutoCreate())
3697              throw new Error("Attempt to auto-create SubstanceSpecificationSubstanceNameOfficialNameComponent.authority");
3698            else if (Configuration.doAutoCreate())
3699              this.authority = new CodeableConcept(); // cc
3700          return this.authority;
3701        }
3702
3703        public boolean hasAuthority() { 
3704          return this.authority != null && !this.authority.isEmpty();
3705        }
3706
3707        /**
3708         * @param value {@link #authority} (Which authority uses this official name.)
3709         */
3710        public SubstanceSpecificationSubstanceNameOfficialNameComponent setAuthority(CodeableConcept value) { 
3711          this.authority = value;
3712          return this;
3713        }
3714
3715        /**
3716         * @return {@link #status} (The status of the official name.)
3717         */
3718        public CodeableConcept getStatus() { 
3719          if (this.status == null)
3720            if (Configuration.errorOnAutoCreate())
3721              throw new Error("Attempt to auto-create SubstanceSpecificationSubstanceNameOfficialNameComponent.status");
3722            else if (Configuration.doAutoCreate())
3723              this.status = new CodeableConcept(); // cc
3724          return this.status;
3725        }
3726
3727        public boolean hasStatus() { 
3728          return this.status != null && !this.status.isEmpty();
3729        }
3730
3731        /**
3732         * @param value {@link #status} (The status of the official name.)
3733         */
3734        public SubstanceSpecificationSubstanceNameOfficialNameComponent setStatus(CodeableConcept value) { 
3735          this.status = value;
3736          return this;
3737        }
3738
3739        /**
3740         * @return {@link #date} (Date of official name change.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
3741         */
3742        public DateTimeType getDateElement() { 
3743          if (this.date == null)
3744            if (Configuration.errorOnAutoCreate())
3745              throw new Error("Attempt to auto-create SubstanceSpecificationSubstanceNameOfficialNameComponent.date");
3746            else if (Configuration.doAutoCreate())
3747              this.date = new DateTimeType(); // bb
3748          return this.date;
3749        }
3750
3751        public boolean hasDateElement() { 
3752          return this.date != null && !this.date.isEmpty();
3753        }
3754
3755        public boolean hasDate() { 
3756          return this.date != null && !this.date.isEmpty();
3757        }
3758
3759        /**
3760         * @param value {@link #date} (Date of official name change.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
3761         */
3762        public SubstanceSpecificationSubstanceNameOfficialNameComponent setDateElement(DateTimeType value) { 
3763          this.date = value;
3764          return this;
3765        }
3766
3767        /**
3768         * @return Date of official name change.
3769         */
3770        public Date getDate() { 
3771          return this.date == null ? null : this.date.getValue();
3772        }
3773
3774        /**
3775         * @param value Date of official name change.
3776         */
3777        public SubstanceSpecificationSubstanceNameOfficialNameComponent setDate(Date value) { 
3778          if (value == null)
3779            this.date = null;
3780          else {
3781            if (this.date == null)
3782              this.date = new DateTimeType();
3783            this.date.setValue(value);
3784          }
3785          return this;
3786        }
3787
3788        protected void listChildren(List<Property> children) {
3789          super.listChildren(children);
3790          children.add(new Property("authority", "CodeableConcept", "Which authority uses this official name.", 0, 1, authority));
3791          children.add(new Property("status", "CodeableConcept", "The status of the official name.", 0, 1, status));
3792          children.add(new Property("date", "dateTime", "Date of official name change.", 0, 1, date));
3793        }
3794
3795        @Override
3796        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
3797          switch (_hash) {
3798          case 1475610435: /*authority*/  return new Property("authority", "CodeableConcept", "Which authority uses this official name.", 0, 1, authority);
3799          case -892481550: /*status*/  return new Property("status", "CodeableConcept", "The status of the official name.", 0, 1, status);
3800          case 3076014: /*date*/  return new Property("date", "dateTime", "Date of official name change.", 0, 1, date);
3801          default: return super.getNamedProperty(_hash, _name, _checkValid);
3802          }
3803
3804        }
3805
3806      @Override
3807      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
3808        switch (hash) {
3809        case 1475610435: /*authority*/ return this.authority == null ? new Base[0] : new Base[] {this.authority}; // CodeableConcept
3810        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // CodeableConcept
3811        case 3076014: /*date*/ return this.date == null ? new Base[0] : new Base[] {this.date}; // DateTimeType
3812        default: return super.getProperty(hash, name, checkValid);
3813        }
3814
3815      }
3816
3817      @Override
3818      public Base setProperty(int hash, String name, Base value) throws FHIRException {
3819        switch (hash) {
3820        case 1475610435: // authority
3821          this.authority = castToCodeableConcept(value); // CodeableConcept
3822          return value;
3823        case -892481550: // status
3824          this.status = castToCodeableConcept(value); // CodeableConcept
3825          return value;
3826        case 3076014: // date
3827          this.date = castToDateTime(value); // DateTimeType
3828          return value;
3829        default: return super.setProperty(hash, name, value);
3830        }
3831
3832      }
3833
3834      @Override
3835      public Base setProperty(String name, Base value) throws FHIRException {
3836        if (name.equals("authority")) {
3837          this.authority = castToCodeableConcept(value); // CodeableConcept
3838        } else if (name.equals("status")) {
3839          this.status = castToCodeableConcept(value); // CodeableConcept
3840        } else if (name.equals("date")) {
3841          this.date = castToDateTime(value); // DateTimeType
3842        } else
3843          return super.setProperty(name, value);
3844        return value;
3845      }
3846
3847      @Override
3848      public Base makeProperty(int hash, String name) throws FHIRException {
3849        switch (hash) {
3850        case 1475610435:  return getAuthority(); 
3851        case -892481550:  return getStatus(); 
3852        case 3076014:  return getDateElement();
3853        default: return super.makeProperty(hash, name);
3854        }
3855
3856      }
3857
3858      @Override
3859      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
3860        switch (hash) {
3861        case 1475610435: /*authority*/ return new String[] {"CodeableConcept"};
3862        case -892481550: /*status*/ return new String[] {"CodeableConcept"};
3863        case 3076014: /*date*/ return new String[] {"dateTime"};
3864        default: return super.getTypesForProperty(hash, name);
3865        }
3866
3867      }
3868
3869      @Override
3870      public Base addChild(String name) throws FHIRException {
3871        if (name.equals("authority")) {
3872          this.authority = new CodeableConcept();
3873          return this.authority;
3874        }
3875        else if (name.equals("status")) {
3876          this.status = new CodeableConcept();
3877          return this.status;
3878        }
3879        else if (name.equals("date")) {
3880          throw new FHIRException("Cannot call addChild on a primitive type SubstanceSpecification.date");
3881        }
3882        else
3883          return super.addChild(name);
3884      }
3885
3886      public SubstanceSpecificationSubstanceNameOfficialNameComponent copy() {
3887        SubstanceSpecificationSubstanceNameOfficialNameComponent dst = new SubstanceSpecificationSubstanceNameOfficialNameComponent();
3888        copyValues(dst);
3889        dst.authority = authority == null ? null : authority.copy();
3890        dst.status = status == null ? null : status.copy();
3891        dst.date = date == null ? null : date.copy();
3892        return dst;
3893      }
3894
3895      @Override
3896      public boolean equalsDeep(Base other_) {
3897        if (!super.equalsDeep(other_))
3898          return false;
3899        if (!(other_ instanceof SubstanceSpecificationSubstanceNameOfficialNameComponent))
3900          return false;
3901        SubstanceSpecificationSubstanceNameOfficialNameComponent o = (SubstanceSpecificationSubstanceNameOfficialNameComponent) other_;
3902        return compareDeep(authority, o.authority, true) && compareDeep(status, o.status, true) && compareDeep(date, o.date, true)
3903          ;
3904      }
3905
3906      @Override
3907      public boolean equalsShallow(Base other_) {
3908        if (!super.equalsShallow(other_))
3909          return false;
3910        if (!(other_ instanceof SubstanceSpecificationSubstanceNameOfficialNameComponent))
3911          return false;
3912        SubstanceSpecificationSubstanceNameOfficialNameComponent o = (SubstanceSpecificationSubstanceNameOfficialNameComponent) other_;
3913        return compareValues(date, o.date, true);
3914      }
3915
3916      public boolean isEmpty() {
3917        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(authority, status, date
3918          );
3919      }
3920
3921  public String fhirType() {
3922    return "SubstanceSpecification.substanceName.officialName";
3923
3924  }
3925
3926  }
3927
3928    /**
3929     * Textual comment.
3930     */
3931    @Child(name = "comment", type = {StringType.class}, order=0, min=0, max=1, modifier=false, summary=true)
3932    @Description(shortDefinition="Textual comment", formalDefinition="Textual comment." )
3933    protected StringType comment;
3934
3935    /**
3936     * Chemicals may be stoichiometric or non-stoichiometric.
3937     */
3938    @Child(name = "stoichiometric", type = {BooleanType.class}, order=1, min=0, max=1, modifier=false, summary=true)
3939    @Description(shortDefinition="Chemicals may be stoichiometric or non-stoichiometric", formalDefinition="Chemicals may be stoichiometric or non-stoichiometric." )
3940    protected BooleanType stoichiometric;
3941
3942    /**
3943     * Identifier by which this substance is known.
3944     */
3945    @Child(name = "identifier", type = {Identifier.class}, order=2, min=0, max=1, modifier=false, summary=true)
3946    @Description(shortDefinition="Identifier by which this substance is known", formalDefinition="Identifier by which this substance is known." )
3947    protected Identifier identifier;
3948
3949    /**
3950     * High level categorization, e.g. polymer or nucleic acid.
3951     */
3952    @Child(name = "type", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true)
3953    @Description(shortDefinition="High level categorization, e.g. polymer or nucleic acid", formalDefinition="High level categorization, e.g. polymer or nucleic acid." )
3954    protected CodeableConcept type;
3955
3956    /**
3957     * Supporting literature.
3958     */
3959    @Child(name = "referenceSource", type = {StringType.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
3960    @Description(shortDefinition="Supporting literature", formalDefinition="Supporting literature." )
3961    protected List<StringType> referenceSource;
3962
3963    /**
3964     * Moiety, for structural modifications.
3965     */
3966    @Child(name = "moiety", type = {}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
3967    @Description(shortDefinition="Moiety, for structural modifications", formalDefinition="Moiety, for structural modifications." )
3968    protected List<SubstanceSpecificationMoietyComponent> moiety;
3969
3970    /**
3971     * General specifications for this substance, including how it is related to other substances.
3972     */
3973    @Child(name = "property", type = {}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
3974    @Description(shortDefinition="General specifications for this substance, including how it is related to other substances", formalDefinition="General specifications for this substance, including how it is related to other substances." )
3975    protected List<SubstanceSpecificationPropertyComponent> property;
3976
3977    /**
3978     * General information detailing this substance.
3979     */
3980    @Child(name = "referenceInformation", type = {SubstanceReferenceInformation.class}, order=7, min=0, max=1, modifier=false, summary=true)
3981    @Description(shortDefinition="General information detailing this substance", formalDefinition="General information detailing this substance." )
3982    protected Reference referenceInformation;
3983
3984    /**
3985     * The actual object that is the target of the reference (General information detailing this substance.)
3986     */
3987    protected SubstanceReferenceInformation referenceInformationTarget;
3988
3989    /**
3990     * Structural information.
3991     */
3992    @Child(name = "structure", type = {}, order=8, min=0, max=1, modifier=false, summary=true)
3993    @Description(shortDefinition="Structural information", formalDefinition="Structural information." )
3994    protected SubstanceSpecificationStructureComponent structure;
3995
3996    /**
3997     * Codes associated with the substance.
3998     */
3999    @Child(name = "substanceCode", type = {}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
4000    @Description(shortDefinition="Codes associated with the substance", formalDefinition="Codes associated with the substance." )
4001    protected List<SubstanceSpecificationSubstanceCodeComponent> substanceCode;
4002
4003    /**
4004     * Names applicable to this substence.
4005     */
4006    @Child(name = "substanceName", type = {}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
4007    @Description(shortDefinition="Names applicable to this substence", formalDefinition="Names applicable to this substence." )
4008    protected List<SubstanceSpecificationSubstanceNameComponent> substanceName;
4009
4010    /**
4011     * The molecular weight or weight range (for proteins, polymers or nucleic acids).
4012     */
4013    @Child(name = "molecularWeight", type = {SubstanceSpecificationStructureIsotopeMolecularWeightComponent.class}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
4014    @Description(shortDefinition="The molecular weight or weight range (for proteins, polymers or nucleic acids)", formalDefinition="The molecular weight or weight range (for proteins, polymers or nucleic acids)." )
4015    protected List<SubstanceSpecificationStructureIsotopeMolecularWeightComponent> molecularWeight;
4016
4017    /**
4018     * Data items specific to polymers.
4019     */
4020    @Child(name = "polymer", type = {SubstancePolymer.class}, order=12, min=0, max=1, modifier=false, summary=true)
4021    @Description(shortDefinition="Data items specific to polymers", formalDefinition="Data items specific to polymers." )
4022    protected Reference polymer;
4023
4024    /**
4025     * The actual object that is the target of the reference (Data items specific to polymers.)
4026     */
4027    protected SubstancePolymer polymerTarget;
4028
4029    private static final long serialVersionUID = -55630281L;
4030
4031  /**
4032   * Constructor
4033   */
4034    public SubstanceSpecification() {
4035      super();
4036    }
4037
4038    /**
4039     * @return {@link #comment} (Textual comment.). This is the underlying object with id, value and extensions. The accessor "getComment" gives direct access to the value
4040     */
4041    public StringType getCommentElement() { 
4042      if (this.comment == null)
4043        if (Configuration.errorOnAutoCreate())
4044          throw new Error("Attempt to auto-create SubstanceSpecification.comment");
4045        else if (Configuration.doAutoCreate())
4046          this.comment = new StringType(); // bb
4047      return this.comment;
4048    }
4049
4050    public boolean hasCommentElement() { 
4051      return this.comment != null && !this.comment.isEmpty();
4052    }
4053
4054    public boolean hasComment() { 
4055      return this.comment != null && !this.comment.isEmpty();
4056    }
4057
4058    /**
4059     * @param value {@link #comment} (Textual comment.). This is the underlying object with id, value and extensions. The accessor "getComment" gives direct access to the value
4060     */
4061    public SubstanceSpecification setCommentElement(StringType value) { 
4062      this.comment = value;
4063      return this;
4064    }
4065
4066    /**
4067     * @return Textual comment.
4068     */
4069    public String getComment() { 
4070      return this.comment == null ? null : this.comment.getValue();
4071    }
4072
4073    /**
4074     * @param value Textual comment.
4075     */
4076    public SubstanceSpecification setComment(String value) { 
4077      if (Utilities.noString(value))
4078        this.comment = null;
4079      else {
4080        if (this.comment == null)
4081          this.comment = new StringType();
4082        this.comment.setValue(value);
4083      }
4084      return this;
4085    }
4086
4087    /**
4088     * @return {@link #stoichiometric} (Chemicals may be stoichiometric or non-stoichiometric.). This is the underlying object with id, value and extensions. The accessor "getStoichiometric" gives direct access to the value
4089     */
4090    public BooleanType getStoichiometricElement() { 
4091      if (this.stoichiometric == null)
4092        if (Configuration.errorOnAutoCreate())
4093          throw new Error("Attempt to auto-create SubstanceSpecification.stoichiometric");
4094        else if (Configuration.doAutoCreate())
4095          this.stoichiometric = new BooleanType(); // bb
4096      return this.stoichiometric;
4097    }
4098
4099    public boolean hasStoichiometricElement() { 
4100      return this.stoichiometric != null && !this.stoichiometric.isEmpty();
4101    }
4102
4103    public boolean hasStoichiometric() { 
4104      return this.stoichiometric != null && !this.stoichiometric.isEmpty();
4105    }
4106
4107    /**
4108     * @param value {@link #stoichiometric} (Chemicals may be stoichiometric or non-stoichiometric.). This is the underlying object with id, value and extensions. The accessor "getStoichiometric" gives direct access to the value
4109     */
4110    public SubstanceSpecification setStoichiometricElement(BooleanType value) { 
4111      this.stoichiometric = value;
4112      return this;
4113    }
4114
4115    /**
4116     * @return Chemicals may be stoichiometric or non-stoichiometric.
4117     */
4118    public boolean getStoichiometric() { 
4119      return this.stoichiometric == null || this.stoichiometric.isEmpty() ? false : this.stoichiometric.getValue();
4120    }
4121
4122    /**
4123     * @param value Chemicals may be stoichiometric or non-stoichiometric.
4124     */
4125    public SubstanceSpecification setStoichiometric(boolean value) { 
4126        if (this.stoichiometric == null)
4127          this.stoichiometric = new BooleanType();
4128        this.stoichiometric.setValue(value);
4129      return this;
4130    }
4131
4132    /**
4133     * @return {@link #identifier} (Identifier by which this substance is known.)
4134     */
4135    public Identifier getIdentifier() { 
4136      if (this.identifier == null)
4137        if (Configuration.errorOnAutoCreate())
4138          throw new Error("Attempt to auto-create SubstanceSpecification.identifier");
4139        else if (Configuration.doAutoCreate())
4140          this.identifier = new Identifier(); // cc
4141      return this.identifier;
4142    }
4143
4144    public boolean hasIdentifier() { 
4145      return this.identifier != null && !this.identifier.isEmpty();
4146    }
4147
4148    /**
4149     * @param value {@link #identifier} (Identifier by which this substance is known.)
4150     */
4151    public SubstanceSpecification setIdentifier(Identifier value) { 
4152      this.identifier = value;
4153      return this;
4154    }
4155
4156    /**
4157     * @return {@link #type} (High level categorization, e.g. polymer or nucleic acid.)
4158     */
4159    public CodeableConcept getType() { 
4160      if (this.type == null)
4161        if (Configuration.errorOnAutoCreate())
4162          throw new Error("Attempt to auto-create SubstanceSpecification.type");
4163        else if (Configuration.doAutoCreate())
4164          this.type = new CodeableConcept(); // cc
4165      return this.type;
4166    }
4167
4168    public boolean hasType() { 
4169      return this.type != null && !this.type.isEmpty();
4170    }
4171
4172    /**
4173     * @param value {@link #type} (High level categorization, e.g. polymer or nucleic acid.)
4174     */
4175    public SubstanceSpecification setType(CodeableConcept value) { 
4176      this.type = value;
4177      return this;
4178    }
4179
4180    /**
4181     * @return {@link #referenceSource} (Supporting literature.)
4182     */
4183    public List<StringType> getReferenceSource() { 
4184      if (this.referenceSource == null)
4185        this.referenceSource = new ArrayList<StringType>();
4186      return this.referenceSource;
4187    }
4188
4189    /**
4190     * @return Returns a reference to <code>this</code> for easy method chaining
4191     */
4192    public SubstanceSpecification setReferenceSource(List<StringType> theReferenceSource) { 
4193      this.referenceSource = theReferenceSource;
4194      return this;
4195    }
4196
4197    public boolean hasReferenceSource() { 
4198      if (this.referenceSource == null)
4199        return false;
4200      for (StringType item : this.referenceSource)
4201        if (!item.isEmpty())
4202          return true;
4203      return false;
4204    }
4205
4206    /**
4207     * @return {@link #referenceSource} (Supporting literature.)
4208     */
4209    public StringType addReferenceSourceElement() {//2 
4210      StringType t = new StringType();
4211      if (this.referenceSource == null)
4212        this.referenceSource = new ArrayList<StringType>();
4213      this.referenceSource.add(t);
4214      return t;
4215    }
4216
4217    /**
4218     * @param value {@link #referenceSource} (Supporting literature.)
4219     */
4220    public SubstanceSpecification addReferenceSource(String value) { //1
4221      StringType t = new StringType();
4222      t.setValue(value);
4223      if (this.referenceSource == null)
4224        this.referenceSource = new ArrayList<StringType>();
4225      this.referenceSource.add(t);
4226      return this;
4227    }
4228
4229    /**
4230     * @param value {@link #referenceSource} (Supporting literature.)
4231     */
4232    public boolean hasReferenceSource(String value) { 
4233      if (this.referenceSource == null)
4234        return false;
4235      for (StringType v : this.referenceSource)
4236        if (v.getValue().equals(value)) // string
4237          return true;
4238      return false;
4239    }
4240
4241    /**
4242     * @return {@link #moiety} (Moiety, for structural modifications.)
4243     */
4244    public List<SubstanceSpecificationMoietyComponent> getMoiety() { 
4245      if (this.moiety == null)
4246        this.moiety = new ArrayList<SubstanceSpecificationMoietyComponent>();
4247      return this.moiety;
4248    }
4249
4250    /**
4251     * @return Returns a reference to <code>this</code> for easy method chaining
4252     */
4253    public SubstanceSpecification setMoiety(List<SubstanceSpecificationMoietyComponent> theMoiety) { 
4254      this.moiety = theMoiety;
4255      return this;
4256    }
4257
4258    public boolean hasMoiety() { 
4259      if (this.moiety == null)
4260        return false;
4261      for (SubstanceSpecificationMoietyComponent item : this.moiety)
4262        if (!item.isEmpty())
4263          return true;
4264      return false;
4265    }
4266
4267    public SubstanceSpecificationMoietyComponent addMoiety() { //3
4268      SubstanceSpecificationMoietyComponent t = new SubstanceSpecificationMoietyComponent();
4269      if (this.moiety == null)
4270        this.moiety = new ArrayList<SubstanceSpecificationMoietyComponent>();
4271      this.moiety.add(t);
4272      return t;
4273    }
4274
4275    public SubstanceSpecification addMoiety(SubstanceSpecificationMoietyComponent t) { //3
4276      if (t == null)
4277        return this;
4278      if (this.moiety == null)
4279        this.moiety = new ArrayList<SubstanceSpecificationMoietyComponent>();
4280      this.moiety.add(t);
4281      return this;
4282    }
4283
4284    /**
4285     * @return The first repetition of repeating field {@link #moiety}, creating it if it does not already exist
4286     */
4287    public SubstanceSpecificationMoietyComponent getMoietyFirstRep() { 
4288      if (getMoiety().isEmpty()) {
4289        addMoiety();
4290      }
4291      return getMoiety().get(0);
4292    }
4293
4294    /**
4295     * @return {@link #property} (General specifications for this substance, including how it is related to other substances.)
4296     */
4297    public List<SubstanceSpecificationPropertyComponent> getProperty() { 
4298      if (this.property == null)
4299        this.property = new ArrayList<SubstanceSpecificationPropertyComponent>();
4300      return this.property;
4301    }
4302
4303    /**
4304     * @return Returns a reference to <code>this</code> for easy method chaining
4305     */
4306    public SubstanceSpecification setProperty(List<SubstanceSpecificationPropertyComponent> theProperty) { 
4307      this.property = theProperty;
4308      return this;
4309    }
4310
4311    public boolean hasProperty() { 
4312      if (this.property == null)
4313        return false;
4314      for (SubstanceSpecificationPropertyComponent item : this.property)
4315        if (!item.isEmpty())
4316          return true;
4317      return false;
4318    }
4319
4320    public SubstanceSpecificationPropertyComponent addProperty() { //3
4321      SubstanceSpecificationPropertyComponent t = new SubstanceSpecificationPropertyComponent();
4322      if (this.property == null)
4323        this.property = new ArrayList<SubstanceSpecificationPropertyComponent>();
4324      this.property.add(t);
4325      return t;
4326    }
4327
4328    public SubstanceSpecification addProperty(SubstanceSpecificationPropertyComponent t) { //3
4329      if (t == null)
4330        return this;
4331      if (this.property == null)
4332        this.property = new ArrayList<SubstanceSpecificationPropertyComponent>();
4333      this.property.add(t);
4334      return this;
4335    }
4336
4337    /**
4338     * @return The first repetition of repeating field {@link #property}, creating it if it does not already exist
4339     */
4340    public SubstanceSpecificationPropertyComponent getPropertyFirstRep() { 
4341      if (getProperty().isEmpty()) {
4342        addProperty();
4343      }
4344      return getProperty().get(0);
4345    }
4346
4347    /**
4348     * @return {@link #referenceInformation} (General information detailing this substance.)
4349     */
4350    public Reference getReferenceInformation() { 
4351      if (this.referenceInformation == null)
4352        if (Configuration.errorOnAutoCreate())
4353          throw new Error("Attempt to auto-create SubstanceSpecification.referenceInformation");
4354        else if (Configuration.doAutoCreate())
4355          this.referenceInformation = new Reference(); // cc
4356      return this.referenceInformation;
4357    }
4358
4359    public boolean hasReferenceInformation() { 
4360      return this.referenceInformation != null && !this.referenceInformation.isEmpty();
4361    }
4362
4363    /**
4364     * @param value {@link #referenceInformation} (General information detailing this substance.)
4365     */
4366    public SubstanceSpecification setReferenceInformation(Reference value) { 
4367      this.referenceInformation = value;
4368      return this;
4369    }
4370
4371    /**
4372     * @return {@link #referenceInformation} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (General information detailing this substance.)
4373     */
4374    public SubstanceReferenceInformation getReferenceInformationTarget() { 
4375      if (this.referenceInformationTarget == null)
4376        if (Configuration.errorOnAutoCreate())
4377          throw new Error("Attempt to auto-create SubstanceSpecification.referenceInformation");
4378        else if (Configuration.doAutoCreate())
4379          this.referenceInformationTarget = new SubstanceReferenceInformation(); // aa
4380      return this.referenceInformationTarget;
4381    }
4382
4383    /**
4384     * @param value {@link #referenceInformation} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (General information detailing this substance.)
4385     */
4386    public SubstanceSpecification setReferenceInformationTarget(SubstanceReferenceInformation value) { 
4387      this.referenceInformationTarget = value;
4388      return this;
4389    }
4390
4391    /**
4392     * @return {@link #structure} (Structural information.)
4393     */
4394    public SubstanceSpecificationStructureComponent getStructure() { 
4395      if (this.structure == null)
4396        if (Configuration.errorOnAutoCreate())
4397          throw new Error("Attempt to auto-create SubstanceSpecification.structure");
4398        else if (Configuration.doAutoCreate())
4399          this.structure = new SubstanceSpecificationStructureComponent(); // cc
4400      return this.structure;
4401    }
4402
4403    public boolean hasStructure() { 
4404      return this.structure != null && !this.structure.isEmpty();
4405    }
4406
4407    /**
4408     * @param value {@link #structure} (Structural information.)
4409     */
4410    public SubstanceSpecification setStructure(SubstanceSpecificationStructureComponent value) { 
4411      this.structure = value;
4412      return this;
4413    }
4414
4415    /**
4416     * @return {@link #substanceCode} (Codes associated with the substance.)
4417     */
4418    public List<SubstanceSpecificationSubstanceCodeComponent> getSubstanceCode() { 
4419      if (this.substanceCode == null)
4420        this.substanceCode = new ArrayList<SubstanceSpecificationSubstanceCodeComponent>();
4421      return this.substanceCode;
4422    }
4423
4424    /**
4425     * @return Returns a reference to <code>this</code> for easy method chaining
4426     */
4427    public SubstanceSpecification setSubstanceCode(List<SubstanceSpecificationSubstanceCodeComponent> theSubstanceCode) { 
4428      this.substanceCode = theSubstanceCode;
4429      return this;
4430    }
4431
4432    public boolean hasSubstanceCode() { 
4433      if (this.substanceCode == null)
4434        return false;
4435      for (SubstanceSpecificationSubstanceCodeComponent item : this.substanceCode)
4436        if (!item.isEmpty())
4437          return true;
4438      return false;
4439    }
4440
4441    public SubstanceSpecificationSubstanceCodeComponent addSubstanceCode() { //3
4442      SubstanceSpecificationSubstanceCodeComponent t = new SubstanceSpecificationSubstanceCodeComponent();
4443      if (this.substanceCode == null)
4444        this.substanceCode = new ArrayList<SubstanceSpecificationSubstanceCodeComponent>();
4445      this.substanceCode.add(t);
4446      return t;
4447    }
4448
4449    public SubstanceSpecification addSubstanceCode(SubstanceSpecificationSubstanceCodeComponent t) { //3
4450      if (t == null)
4451        return this;
4452      if (this.substanceCode == null)
4453        this.substanceCode = new ArrayList<SubstanceSpecificationSubstanceCodeComponent>();
4454      this.substanceCode.add(t);
4455      return this;
4456    }
4457
4458    /**
4459     * @return The first repetition of repeating field {@link #substanceCode}, creating it if it does not already exist
4460     */
4461    public SubstanceSpecificationSubstanceCodeComponent getSubstanceCodeFirstRep() { 
4462      if (getSubstanceCode().isEmpty()) {
4463        addSubstanceCode();
4464      }
4465      return getSubstanceCode().get(0);
4466    }
4467
4468    /**
4469     * @return {@link #substanceName} (Names applicable to this substence.)
4470     */
4471    public List<SubstanceSpecificationSubstanceNameComponent> getSubstanceName() { 
4472      if (this.substanceName == null)
4473        this.substanceName = new ArrayList<SubstanceSpecificationSubstanceNameComponent>();
4474      return this.substanceName;
4475    }
4476
4477    /**
4478     * @return Returns a reference to <code>this</code> for easy method chaining
4479     */
4480    public SubstanceSpecification setSubstanceName(List<SubstanceSpecificationSubstanceNameComponent> theSubstanceName) { 
4481      this.substanceName = theSubstanceName;
4482      return this;
4483    }
4484
4485    public boolean hasSubstanceName() { 
4486      if (this.substanceName == null)
4487        return false;
4488      for (SubstanceSpecificationSubstanceNameComponent item : this.substanceName)
4489        if (!item.isEmpty())
4490          return true;
4491      return false;
4492    }
4493
4494    public SubstanceSpecificationSubstanceNameComponent addSubstanceName() { //3
4495      SubstanceSpecificationSubstanceNameComponent t = new SubstanceSpecificationSubstanceNameComponent();
4496      if (this.substanceName == null)
4497        this.substanceName = new ArrayList<SubstanceSpecificationSubstanceNameComponent>();
4498      this.substanceName.add(t);
4499      return t;
4500    }
4501
4502    public SubstanceSpecification addSubstanceName(SubstanceSpecificationSubstanceNameComponent t) { //3
4503      if (t == null)
4504        return this;
4505      if (this.substanceName == null)
4506        this.substanceName = new ArrayList<SubstanceSpecificationSubstanceNameComponent>();
4507      this.substanceName.add(t);
4508      return this;
4509    }
4510
4511    /**
4512     * @return The first repetition of repeating field {@link #substanceName}, creating it if it does not already exist
4513     */
4514    public SubstanceSpecificationSubstanceNameComponent getSubstanceNameFirstRep() { 
4515      if (getSubstanceName().isEmpty()) {
4516        addSubstanceName();
4517      }
4518      return getSubstanceName().get(0);
4519    }
4520
4521    /**
4522     * @return {@link #molecularWeight} (The molecular weight or weight range (for proteins, polymers or nucleic acids).)
4523     */
4524    public List<SubstanceSpecificationStructureIsotopeMolecularWeightComponent> getMolecularWeight() { 
4525      if (this.molecularWeight == null)
4526        this.molecularWeight = new ArrayList<SubstanceSpecificationStructureIsotopeMolecularWeightComponent>();
4527      return this.molecularWeight;
4528    }
4529
4530    /**
4531     * @return Returns a reference to <code>this</code> for easy method chaining
4532     */
4533    public SubstanceSpecification setMolecularWeight(List<SubstanceSpecificationStructureIsotopeMolecularWeightComponent> theMolecularWeight) { 
4534      this.molecularWeight = theMolecularWeight;
4535      return this;
4536    }
4537
4538    public boolean hasMolecularWeight() { 
4539      if (this.molecularWeight == null)
4540        return false;
4541      for (SubstanceSpecificationStructureIsotopeMolecularWeightComponent item : this.molecularWeight)
4542        if (!item.isEmpty())
4543          return true;
4544      return false;
4545    }
4546
4547    public SubstanceSpecificationStructureIsotopeMolecularWeightComponent addMolecularWeight() { //3
4548      SubstanceSpecificationStructureIsotopeMolecularWeightComponent t = new SubstanceSpecificationStructureIsotopeMolecularWeightComponent();
4549      if (this.molecularWeight == null)
4550        this.molecularWeight = new ArrayList<SubstanceSpecificationStructureIsotopeMolecularWeightComponent>();
4551      this.molecularWeight.add(t);
4552      return t;
4553    }
4554
4555    public SubstanceSpecification addMolecularWeight(SubstanceSpecificationStructureIsotopeMolecularWeightComponent t) { //3
4556      if (t == null)
4557        return this;
4558      if (this.molecularWeight == null)
4559        this.molecularWeight = new ArrayList<SubstanceSpecificationStructureIsotopeMolecularWeightComponent>();
4560      this.molecularWeight.add(t);
4561      return this;
4562    }
4563
4564    /**
4565     * @return The first repetition of repeating field {@link #molecularWeight}, creating it if it does not already exist
4566     */
4567    public SubstanceSpecificationStructureIsotopeMolecularWeightComponent getMolecularWeightFirstRep() { 
4568      if (getMolecularWeight().isEmpty()) {
4569        addMolecularWeight();
4570      }
4571      return getMolecularWeight().get(0);
4572    }
4573
4574    /**
4575     * @return {@link #polymer} (Data items specific to polymers.)
4576     */
4577    public Reference getPolymer() { 
4578      if (this.polymer == null)
4579        if (Configuration.errorOnAutoCreate())
4580          throw new Error("Attempt to auto-create SubstanceSpecification.polymer");
4581        else if (Configuration.doAutoCreate())
4582          this.polymer = new Reference(); // cc
4583      return this.polymer;
4584    }
4585
4586    public boolean hasPolymer() { 
4587      return this.polymer != null && !this.polymer.isEmpty();
4588    }
4589
4590    /**
4591     * @param value {@link #polymer} (Data items specific to polymers.)
4592     */
4593    public SubstanceSpecification setPolymer(Reference value) { 
4594      this.polymer = value;
4595      return this;
4596    }
4597
4598    /**
4599     * @return {@link #polymer} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Data items specific to polymers.)
4600     */
4601    public SubstancePolymer getPolymerTarget() { 
4602      if (this.polymerTarget == null)
4603        if (Configuration.errorOnAutoCreate())
4604          throw new Error("Attempt to auto-create SubstanceSpecification.polymer");
4605        else if (Configuration.doAutoCreate())
4606          this.polymerTarget = new SubstancePolymer(); // aa
4607      return this.polymerTarget;
4608    }
4609
4610    /**
4611     * @param value {@link #polymer} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Data items specific to polymers.)
4612     */
4613    public SubstanceSpecification setPolymerTarget(SubstancePolymer value) { 
4614      this.polymerTarget = value;
4615      return this;
4616    }
4617
4618      protected void listChildren(List<Property> children) {
4619        super.listChildren(children);
4620        children.add(new Property("comment", "string", "Textual comment.", 0, 1, comment));
4621        children.add(new Property("stoichiometric", "boolean", "Chemicals may be stoichiometric or non-stoichiometric.", 0, 1, stoichiometric));
4622        children.add(new Property("identifier", "Identifier", "Identifier by which this substance is known.", 0, 1, identifier));
4623        children.add(new Property("type", "CodeableConcept", "High level categorization, e.g. polymer or nucleic acid.", 0, 1, type));
4624        children.add(new Property("referenceSource", "string", "Supporting literature.", 0, java.lang.Integer.MAX_VALUE, referenceSource));
4625        children.add(new Property("moiety", "", "Moiety, for structural modifications.", 0, java.lang.Integer.MAX_VALUE, moiety));
4626        children.add(new Property("property", "", "General specifications for this substance, including how it is related to other substances.", 0, java.lang.Integer.MAX_VALUE, property));
4627        children.add(new Property("referenceInformation", "Reference(SubstanceReferenceInformation)", "General information detailing this substance.", 0, 1, referenceInformation));
4628        children.add(new Property("structure", "", "Structural information.", 0, 1, structure));
4629        children.add(new Property("substanceCode", "", "Codes associated with the substance.", 0, java.lang.Integer.MAX_VALUE, substanceCode));
4630        children.add(new Property("substanceName", "", "Names applicable to this substence.", 0, java.lang.Integer.MAX_VALUE, substanceName));
4631        children.add(new Property("molecularWeight", "@SubstanceSpecification.structure.isotope.molecularWeight", "The molecular weight or weight range (for proteins, polymers or nucleic acids).", 0, java.lang.Integer.MAX_VALUE, molecularWeight));
4632        children.add(new Property("polymer", "Reference(SubstancePolymer)", "Data items specific to polymers.", 0, 1, polymer));
4633      }
4634
4635      @Override
4636      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
4637        switch (_hash) {
4638        case 950398559: /*comment*/  return new Property("comment", "string", "Textual comment.", 0, 1, comment);
4639        case -251826186: /*stoichiometric*/  return new Property("stoichiometric", "boolean", "Chemicals may be stoichiometric or non-stoichiometric.", 0, 1, stoichiometric);
4640        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Identifier by which this substance is known.", 0, 1, identifier);
4641        case 3575610: /*type*/  return new Property("type", "CodeableConcept", "High level categorization, e.g. polymer or nucleic acid.", 0, 1, type);
4642        case 882421574: /*referenceSource*/  return new Property("referenceSource", "string", "Supporting literature.", 0, java.lang.Integer.MAX_VALUE, referenceSource);
4643        case -1068650173: /*moiety*/  return new Property("moiety", "", "Moiety, for structural modifications.", 0, java.lang.Integer.MAX_VALUE, moiety);
4644        case -993141291: /*property*/  return new Property("property", "", "General specifications for this substance, including how it is related to other substances.", 0, java.lang.Integer.MAX_VALUE, property);
4645        case -2117930783: /*referenceInformation*/  return new Property("referenceInformation", "Reference(SubstanceReferenceInformation)", "General information detailing this substance.", 0, 1, referenceInformation);
4646        case 144518515: /*structure*/  return new Property("structure", "", "Structural information.", 0, 1, structure);
4647        case 1517793149: /*substanceCode*/  return new Property("substanceCode", "", "Codes associated with the substance.", 0, java.lang.Integer.MAX_VALUE, substanceCode);
4648        case 1518107675: /*substanceName*/  return new Property("substanceName", "", "Names applicable to this substence.", 0, java.lang.Integer.MAX_VALUE, substanceName);
4649        case 635625672: /*molecularWeight*/  return new Property("molecularWeight", "@SubstanceSpecification.structure.isotope.molecularWeight", "The molecular weight or weight range (for proteins, polymers or nucleic acids).", 0, java.lang.Integer.MAX_VALUE, molecularWeight);
4650        case -397514098: /*polymer*/  return new Property("polymer", "Reference(SubstancePolymer)", "Data items specific to polymers.", 0, 1, polymer);
4651        default: return super.getNamedProperty(_hash, _name, _checkValid);
4652        }
4653
4654      }
4655
4656      @Override
4657      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
4658        switch (hash) {
4659        case 950398559: /*comment*/ return this.comment == null ? new Base[0] : new Base[] {this.comment}; // StringType
4660        case -251826186: /*stoichiometric*/ return this.stoichiometric == null ? new Base[0] : new Base[] {this.stoichiometric}; // BooleanType
4661        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : new Base[] {this.identifier}; // Identifier
4662        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
4663        case 882421574: /*referenceSource*/ return this.referenceSource == null ? new Base[0] : this.referenceSource.toArray(new Base[this.referenceSource.size()]); // StringType
4664        case -1068650173: /*moiety*/ return this.moiety == null ? new Base[0] : this.moiety.toArray(new Base[this.moiety.size()]); // SubstanceSpecificationMoietyComponent
4665        case -993141291: /*property*/ return this.property == null ? new Base[0] : this.property.toArray(new Base[this.property.size()]); // SubstanceSpecificationPropertyComponent
4666        case -2117930783: /*referenceInformation*/ return this.referenceInformation == null ? new Base[0] : new Base[] {this.referenceInformation}; // Reference
4667        case 144518515: /*structure*/ return this.structure == null ? new Base[0] : new Base[] {this.structure}; // SubstanceSpecificationStructureComponent
4668        case 1517793149: /*substanceCode*/ return this.substanceCode == null ? new Base[0] : this.substanceCode.toArray(new Base[this.substanceCode.size()]); // SubstanceSpecificationSubstanceCodeComponent
4669        case 1518107675: /*substanceName*/ return this.substanceName == null ? new Base[0] : this.substanceName.toArray(new Base[this.substanceName.size()]); // SubstanceSpecificationSubstanceNameComponent
4670        case 635625672: /*molecularWeight*/ return this.molecularWeight == null ? new Base[0] : this.molecularWeight.toArray(new Base[this.molecularWeight.size()]); // SubstanceSpecificationStructureIsotopeMolecularWeightComponent
4671        case -397514098: /*polymer*/ return this.polymer == null ? new Base[0] : new Base[] {this.polymer}; // Reference
4672        default: return super.getProperty(hash, name, checkValid);
4673        }
4674
4675      }
4676
4677      @Override
4678      public Base setProperty(int hash, String name, Base value) throws FHIRException {
4679        switch (hash) {
4680        case 950398559: // comment
4681          this.comment = castToString(value); // StringType
4682          return value;
4683        case -251826186: // stoichiometric
4684          this.stoichiometric = castToBoolean(value); // BooleanType
4685          return value;
4686        case -1618432855: // identifier
4687          this.identifier = castToIdentifier(value); // Identifier
4688          return value;
4689        case 3575610: // type
4690          this.type = castToCodeableConcept(value); // CodeableConcept
4691          return value;
4692        case 882421574: // referenceSource
4693          this.getReferenceSource().add(castToString(value)); // StringType
4694          return value;
4695        case -1068650173: // moiety
4696          this.getMoiety().add((SubstanceSpecificationMoietyComponent) value); // SubstanceSpecificationMoietyComponent
4697          return value;
4698        case -993141291: // property
4699          this.getProperty().add((SubstanceSpecificationPropertyComponent) value); // SubstanceSpecificationPropertyComponent
4700          return value;
4701        case -2117930783: // referenceInformation
4702          this.referenceInformation = castToReference(value); // Reference
4703          return value;
4704        case 144518515: // structure
4705          this.structure = (SubstanceSpecificationStructureComponent) value; // SubstanceSpecificationStructureComponent
4706          return value;
4707        case 1517793149: // substanceCode
4708          this.getSubstanceCode().add((SubstanceSpecificationSubstanceCodeComponent) value); // SubstanceSpecificationSubstanceCodeComponent
4709          return value;
4710        case 1518107675: // substanceName
4711          this.getSubstanceName().add((SubstanceSpecificationSubstanceNameComponent) value); // SubstanceSpecificationSubstanceNameComponent
4712          return value;
4713        case 635625672: // molecularWeight
4714          this.getMolecularWeight().add((SubstanceSpecificationStructureIsotopeMolecularWeightComponent) value); // SubstanceSpecificationStructureIsotopeMolecularWeightComponent
4715          return value;
4716        case -397514098: // polymer
4717          this.polymer = castToReference(value); // Reference
4718          return value;
4719        default: return super.setProperty(hash, name, value);
4720        }
4721
4722      }
4723
4724      @Override
4725      public Base setProperty(String name, Base value) throws FHIRException {
4726        if (name.equals("comment")) {
4727          this.comment = castToString(value); // StringType
4728        } else if (name.equals("stoichiometric")) {
4729          this.stoichiometric = castToBoolean(value); // BooleanType
4730        } else if (name.equals("identifier")) {
4731          this.identifier = castToIdentifier(value); // Identifier
4732        } else if (name.equals("type")) {
4733          this.type = castToCodeableConcept(value); // CodeableConcept
4734        } else if (name.equals("referenceSource")) {
4735          this.getReferenceSource().add(castToString(value));
4736        } else if (name.equals("moiety")) {
4737          this.getMoiety().add((SubstanceSpecificationMoietyComponent) value);
4738        } else if (name.equals("property")) {
4739          this.getProperty().add((SubstanceSpecificationPropertyComponent) value);
4740        } else if (name.equals("referenceInformation")) {
4741          this.referenceInformation = castToReference(value); // Reference
4742        } else if (name.equals("structure")) {
4743          this.structure = (SubstanceSpecificationStructureComponent) value; // SubstanceSpecificationStructureComponent
4744        } else if (name.equals("substanceCode")) {
4745          this.getSubstanceCode().add((SubstanceSpecificationSubstanceCodeComponent) value);
4746        } else if (name.equals("substanceName")) {
4747          this.getSubstanceName().add((SubstanceSpecificationSubstanceNameComponent) value);
4748        } else if (name.equals("molecularWeight")) {
4749          this.getMolecularWeight().add((SubstanceSpecificationStructureIsotopeMolecularWeightComponent) value);
4750        } else if (name.equals("polymer")) {
4751          this.polymer = castToReference(value); // Reference
4752        } else
4753          return super.setProperty(name, value);
4754        return value;
4755      }
4756
4757      @Override
4758      public Base makeProperty(int hash, String name) throws FHIRException {
4759        switch (hash) {
4760        case 950398559:  return getCommentElement();
4761        case -251826186:  return getStoichiometricElement();
4762        case -1618432855:  return getIdentifier(); 
4763        case 3575610:  return getType(); 
4764        case 882421574:  return addReferenceSourceElement();
4765        case -1068650173:  return addMoiety(); 
4766        case -993141291:  return addProperty(); 
4767        case -2117930783:  return getReferenceInformation(); 
4768        case 144518515:  return getStructure(); 
4769        case 1517793149:  return addSubstanceCode(); 
4770        case 1518107675:  return addSubstanceName(); 
4771        case 635625672:  return addMolecularWeight(); 
4772        case -397514098:  return getPolymer(); 
4773        default: return super.makeProperty(hash, name);
4774        }
4775
4776      }
4777
4778      @Override
4779      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
4780        switch (hash) {
4781        case 950398559: /*comment*/ return new String[] {"string"};
4782        case -251826186: /*stoichiometric*/ return new String[] {"boolean"};
4783        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
4784        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
4785        case 882421574: /*referenceSource*/ return new String[] {"string"};
4786        case -1068650173: /*moiety*/ return new String[] {};
4787        case -993141291: /*property*/ return new String[] {};
4788        case -2117930783: /*referenceInformation*/ return new String[] {"Reference"};
4789        case 144518515: /*structure*/ return new String[] {};
4790        case 1517793149: /*substanceCode*/ return new String[] {};
4791        case 1518107675: /*substanceName*/ return new String[] {};
4792        case 635625672: /*molecularWeight*/ return new String[] {"@SubstanceSpecification.structure.isotope.molecularWeight"};
4793        case -397514098: /*polymer*/ return new String[] {"Reference"};
4794        default: return super.getTypesForProperty(hash, name);
4795        }
4796
4797      }
4798
4799      @Override
4800      public Base addChild(String name) throws FHIRException {
4801        if (name.equals("comment")) {
4802          throw new FHIRException("Cannot call addChild on a primitive type SubstanceSpecification.comment");
4803        }
4804        else if (name.equals("stoichiometric")) {
4805          throw new FHIRException("Cannot call addChild on a primitive type SubstanceSpecification.stoichiometric");
4806        }
4807        else if (name.equals("identifier")) {
4808          this.identifier = new Identifier();
4809          return this.identifier;
4810        }
4811        else if (name.equals("type")) {
4812          this.type = new CodeableConcept();
4813          return this.type;
4814        }
4815        else if (name.equals("referenceSource")) {
4816          throw new FHIRException("Cannot call addChild on a primitive type SubstanceSpecification.referenceSource");
4817        }
4818        else if (name.equals("moiety")) {
4819          return addMoiety();
4820        }
4821        else if (name.equals("property")) {
4822          return addProperty();
4823        }
4824        else if (name.equals("referenceInformation")) {
4825          this.referenceInformation = new Reference();
4826          return this.referenceInformation;
4827        }
4828        else if (name.equals("structure")) {
4829          this.structure = new SubstanceSpecificationStructureComponent();
4830          return this.structure;
4831        }
4832        else if (name.equals("substanceCode")) {
4833          return addSubstanceCode();
4834        }
4835        else if (name.equals("substanceName")) {
4836          return addSubstanceName();
4837        }
4838        else if (name.equals("molecularWeight")) {
4839          return addMolecularWeight();
4840        }
4841        else if (name.equals("polymer")) {
4842          this.polymer = new Reference();
4843          return this.polymer;
4844        }
4845        else
4846          return super.addChild(name);
4847      }
4848
4849  public String fhirType() {
4850    return "SubstanceSpecification";
4851
4852  }
4853
4854      public SubstanceSpecification copy() {
4855        SubstanceSpecification dst = new SubstanceSpecification();
4856        copyValues(dst);
4857        dst.comment = comment == null ? null : comment.copy();
4858        dst.stoichiometric = stoichiometric == null ? null : stoichiometric.copy();
4859        dst.identifier = identifier == null ? null : identifier.copy();
4860        dst.type = type == null ? null : type.copy();
4861        if (referenceSource != null) {
4862          dst.referenceSource = new ArrayList<StringType>();
4863          for (StringType i : referenceSource)
4864            dst.referenceSource.add(i.copy());
4865        };
4866        if (moiety != null) {
4867          dst.moiety = new ArrayList<SubstanceSpecificationMoietyComponent>();
4868          for (SubstanceSpecificationMoietyComponent i : moiety)
4869            dst.moiety.add(i.copy());
4870        };
4871        if (property != null) {
4872          dst.property = new ArrayList<SubstanceSpecificationPropertyComponent>();
4873          for (SubstanceSpecificationPropertyComponent i : property)
4874            dst.property.add(i.copy());
4875        };
4876        dst.referenceInformation = referenceInformation == null ? null : referenceInformation.copy();
4877        dst.structure = structure == null ? null : structure.copy();
4878        if (substanceCode != null) {
4879          dst.substanceCode = new ArrayList<SubstanceSpecificationSubstanceCodeComponent>();
4880          for (SubstanceSpecificationSubstanceCodeComponent i : substanceCode)
4881            dst.substanceCode.add(i.copy());
4882        };
4883        if (substanceName != null) {
4884          dst.substanceName = new ArrayList<SubstanceSpecificationSubstanceNameComponent>();
4885          for (SubstanceSpecificationSubstanceNameComponent i : substanceName)
4886            dst.substanceName.add(i.copy());
4887        };
4888        if (molecularWeight != null) {
4889          dst.molecularWeight = new ArrayList<SubstanceSpecificationStructureIsotopeMolecularWeightComponent>();
4890          for (SubstanceSpecificationStructureIsotopeMolecularWeightComponent i : molecularWeight)
4891            dst.molecularWeight.add(i.copy());
4892        };
4893        dst.polymer = polymer == null ? null : polymer.copy();
4894        return dst;
4895      }
4896
4897      protected SubstanceSpecification typedCopy() {
4898        return copy();
4899      }
4900
4901      @Override
4902      public boolean equalsDeep(Base other_) {
4903        if (!super.equalsDeep(other_))
4904          return false;
4905        if (!(other_ instanceof SubstanceSpecification))
4906          return false;
4907        SubstanceSpecification o = (SubstanceSpecification) other_;
4908        return compareDeep(comment, o.comment, true) && compareDeep(stoichiometric, o.stoichiometric, true)
4909           && compareDeep(identifier, o.identifier, true) && compareDeep(type, o.type, true) && compareDeep(referenceSource, o.referenceSource, true)
4910           && compareDeep(moiety, o.moiety, true) && compareDeep(property, o.property, true) && compareDeep(referenceInformation, o.referenceInformation, true)
4911           && compareDeep(structure, o.structure, true) && compareDeep(substanceCode, o.substanceCode, true)
4912           && compareDeep(substanceName, o.substanceName, true) && compareDeep(molecularWeight, o.molecularWeight, true)
4913           && compareDeep(polymer, o.polymer, true);
4914      }
4915
4916      @Override
4917      public boolean equalsShallow(Base other_) {
4918        if (!super.equalsShallow(other_))
4919          return false;
4920        if (!(other_ instanceof SubstanceSpecification))
4921          return false;
4922        SubstanceSpecification o = (SubstanceSpecification) other_;
4923        return compareValues(comment, o.comment, true) && compareValues(stoichiometric, o.stoichiometric, true)
4924           && compareValues(referenceSource, o.referenceSource, true);
4925      }
4926
4927      public boolean isEmpty() {
4928        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(comment, stoichiometric, identifier
4929          , type, referenceSource, moiety, property, referenceInformation, structure, substanceCode
4930          , substanceName, molecularWeight, polymer);
4931      }
4932
4933  @Override
4934  public ResourceType getResourceType() {
4935    return ResourceType.SubstanceSpecification;
4936   }
4937
4938
4939}
4940