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