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