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