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 != null && 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 != null && 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 != null && 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 != null && 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 != null && 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 != null && 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     * @deprecated Use Reference#setResource(IBaseResource) instead
1564     */
1565    @Deprecated
1566    public List<DocumentReference> getSourceTarget() {
1567      if (this.sourceTarget == null)
1568        this.sourceTarget = new ArrayList<DocumentReference>();
1569      return this.sourceTarget;
1570    }
1571
1572    /**
1573     * @deprecated Use Reference#setResource(IBaseResource) instead
1574     */
1575    @Deprecated
1576    public DocumentReference addSourceTarget() {
1577      DocumentReference r = new DocumentReference();
1578      if (this.sourceTarget == null)
1579        this.sourceTarget = new ArrayList<DocumentReference>();
1580      this.sourceTarget.add(r);
1581      return r;
1582    }
1583
1584    /**
1585     * @return {@link #representation} (Molecular structural representation.)
1586     */
1587    public List<SubstanceSpecificationStructureRepresentationComponent> getRepresentation() {
1588      if (this.representation == null)
1589        this.representation = new ArrayList<SubstanceSpecificationStructureRepresentationComponent>();
1590      return this.representation;
1591    }
1592
1593    /**
1594     * @return Returns a reference to <code>this</code> for easy method chaining
1595     */
1596    public SubstanceSpecificationStructureComponent setRepresentation(
1597        List<SubstanceSpecificationStructureRepresentationComponent> theRepresentation) {
1598      this.representation = theRepresentation;
1599      return this;
1600    }
1601
1602    public boolean hasRepresentation() {
1603      if (this.representation == null)
1604        return false;
1605      for (SubstanceSpecificationStructureRepresentationComponent item : this.representation)
1606        if (!item.isEmpty())
1607          return true;
1608      return false;
1609    }
1610
1611    public SubstanceSpecificationStructureRepresentationComponent addRepresentation() { // 3
1612      SubstanceSpecificationStructureRepresentationComponent t = new SubstanceSpecificationStructureRepresentationComponent();
1613      if (this.representation == null)
1614        this.representation = new ArrayList<SubstanceSpecificationStructureRepresentationComponent>();
1615      this.representation.add(t);
1616      return t;
1617    }
1618
1619    public SubstanceSpecificationStructureComponent addRepresentation(
1620        SubstanceSpecificationStructureRepresentationComponent t) { // 3
1621      if (t == null)
1622        return this;
1623      if (this.representation == null)
1624        this.representation = new ArrayList<SubstanceSpecificationStructureRepresentationComponent>();
1625      this.representation.add(t);
1626      return this;
1627    }
1628
1629    /**
1630     * @return The first repetition of repeating field {@link #representation},
1631     *         creating it if it does not already exist
1632     */
1633    public SubstanceSpecificationStructureRepresentationComponent getRepresentationFirstRep() {
1634      if (getRepresentation().isEmpty()) {
1635        addRepresentation();
1636      }
1637      return getRepresentation().get(0);
1638    }
1639
1640    protected void listChildren(List<Property> children) {
1641      super.listChildren(children);
1642      children.add(new Property("stereochemistry", "CodeableConcept", "Stereochemistry type.", 0, 1, stereochemistry));
1643      children.add(new Property("opticalActivity", "CodeableConcept", "Optical activity type.", 0, 1, opticalActivity));
1644      children.add(new Property("molecularFormula", "string", "Molecular formula.", 0, 1, molecularFormula));
1645      children.add(new Property("molecularFormulaByMoiety", "string",
1646          "Specified per moiety according to the Hill system, i.e. first C, then H, then alphabetical, each moiety separated by a dot.",
1647          0, 1, molecularFormulaByMoiety));
1648      children.add(new Property("isotope", "",
1649          "Applicable for single substances that contain a radionuclide or a non-natural isotopic ratio.", 0,
1650          java.lang.Integer.MAX_VALUE, isotope));
1651      children.add(new Property("molecularWeight", "@SubstanceSpecification.structure.isotope.molecularWeight",
1652          "The molecular weight or weight range (for proteins, polymers or nucleic acids).", 0, 1, molecularWeight));
1653      children.add(new Property("source", "Reference(DocumentReference)", "Supporting literature.", 0,
1654          java.lang.Integer.MAX_VALUE, source));
1655      children.add(new Property("representation", "", "Molecular structural representation.", 0,
1656          java.lang.Integer.MAX_VALUE, representation));
1657    }
1658
1659    @Override
1660    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1661      switch (_hash) {
1662      case 263475116:
1663        /* stereochemistry */ return new Property("stereochemistry", "CodeableConcept", "Stereochemistry type.", 0, 1,
1664            stereochemistry);
1665      case 1420900135:
1666        /* opticalActivity */ return new Property("opticalActivity", "CodeableConcept", "Optical activity type.", 0, 1,
1667            opticalActivity);
1668      case 616660246:
1669        /* molecularFormula */ return new Property("molecularFormula", "string", "Molecular formula.", 0, 1,
1670            molecularFormula);
1671      case 1315452848:
1672        /* molecularFormulaByMoiety */ return new Property("molecularFormulaByMoiety", "string",
1673            "Specified per moiety according to the Hill system, i.e. first C, then H, then alphabetical, each moiety separated by a dot.",
1674            0, 1, molecularFormulaByMoiety);
1675      case 2097035189:
1676        /* isotope */ return new Property("isotope", "",
1677            "Applicable for single substances that contain a radionuclide or a non-natural isotopic ratio.", 0,
1678            java.lang.Integer.MAX_VALUE, isotope);
1679      case 635625672:
1680        /* molecularWeight */ return new Property("molecularWeight",
1681            "@SubstanceSpecification.structure.isotope.molecularWeight",
1682            "The molecular weight or weight range (for proteins, polymers or nucleic acids).", 0, 1, molecularWeight);
1683      case -896505829:
1684        /* source */ return new Property("source", "Reference(DocumentReference)", "Supporting literature.", 0,
1685            java.lang.Integer.MAX_VALUE, source);
1686      case -671065907:
1687        /* representation */ return new Property("representation", "", "Molecular structural representation.", 0,
1688            java.lang.Integer.MAX_VALUE, representation);
1689      default:
1690        return super.getNamedProperty(_hash, _name, _checkValid);
1691      }
1692
1693    }
1694
1695    @Override
1696    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1697      switch (hash) {
1698      case 263475116:
1699        /* stereochemistry */ return this.stereochemistry == null ? new Base[0] : new Base[] { this.stereochemistry }; // CodeableConcept
1700      case 1420900135:
1701        /* opticalActivity */ return this.opticalActivity == null ? new Base[0] : new Base[] { this.opticalActivity }; // CodeableConcept
1702      case 616660246:
1703        /* molecularFormula */ return this.molecularFormula == null ? new Base[0]
1704            : new Base[] { this.molecularFormula }; // StringType
1705      case 1315452848:
1706        /* molecularFormulaByMoiety */ return this.molecularFormulaByMoiety == null ? new Base[0]
1707            : new Base[] { this.molecularFormulaByMoiety }; // StringType
1708      case 2097035189:
1709        /* isotope */ return this.isotope == null ? new Base[0] : this.isotope.toArray(new Base[this.isotope.size()]); // SubstanceSpecificationStructureIsotopeComponent
1710      case 635625672:
1711        /* molecularWeight */ return this.molecularWeight == null ? new Base[0] : new Base[] { this.molecularWeight }; // SubstanceSpecificationStructureIsotopeMolecularWeightComponent
1712      case -896505829:
1713        /* source */ return this.source == null ? new Base[0] : this.source.toArray(new Base[this.source.size()]); // Reference
1714      case -671065907:
1715        /* representation */ return this.representation == null ? new Base[0]
1716            : this.representation.toArray(new Base[this.representation.size()]); // SubstanceSpecificationStructureRepresentationComponent
1717      default:
1718        return super.getProperty(hash, name, checkValid);
1719      }
1720
1721    }
1722
1723    @Override
1724    public Base setProperty(int hash, String name, Base value) throws FHIRException {
1725      switch (hash) {
1726      case 263475116: // stereochemistry
1727        this.stereochemistry = castToCodeableConcept(value); // CodeableConcept
1728        return value;
1729      case 1420900135: // opticalActivity
1730        this.opticalActivity = castToCodeableConcept(value); // CodeableConcept
1731        return value;
1732      case 616660246: // molecularFormula
1733        this.molecularFormula = castToString(value); // StringType
1734        return value;
1735      case 1315452848: // molecularFormulaByMoiety
1736        this.molecularFormulaByMoiety = castToString(value); // StringType
1737        return value;
1738      case 2097035189: // isotope
1739        this.getIsotope().add((SubstanceSpecificationStructureIsotopeComponent) value); // SubstanceSpecificationStructureIsotopeComponent
1740        return value;
1741      case 635625672: // molecularWeight
1742        this.molecularWeight = (SubstanceSpecificationStructureIsotopeMolecularWeightComponent) value; // SubstanceSpecificationStructureIsotopeMolecularWeightComponent
1743        return value;
1744      case -896505829: // source
1745        this.getSource().add(castToReference(value)); // Reference
1746        return value;
1747      case -671065907: // representation
1748        this.getRepresentation().add((SubstanceSpecificationStructureRepresentationComponent) value); // SubstanceSpecificationStructureRepresentationComponent
1749        return value;
1750      default:
1751        return super.setProperty(hash, name, value);
1752      }
1753
1754    }
1755
1756    @Override
1757    public Base setProperty(String name, Base value) throws FHIRException {
1758      if (name.equals("stereochemistry")) {
1759        this.stereochemistry = castToCodeableConcept(value); // CodeableConcept
1760      } else if (name.equals("opticalActivity")) {
1761        this.opticalActivity = castToCodeableConcept(value); // CodeableConcept
1762      } else if (name.equals("molecularFormula")) {
1763        this.molecularFormula = castToString(value); // StringType
1764      } else if (name.equals("molecularFormulaByMoiety")) {
1765        this.molecularFormulaByMoiety = castToString(value); // StringType
1766      } else if (name.equals("isotope")) {
1767        this.getIsotope().add((SubstanceSpecificationStructureIsotopeComponent) value);
1768      } else if (name.equals("molecularWeight")) {
1769        this.molecularWeight = (SubstanceSpecificationStructureIsotopeMolecularWeightComponent) value; // SubstanceSpecificationStructureIsotopeMolecularWeightComponent
1770      } else if (name.equals("source")) {
1771        this.getSource().add(castToReference(value));
1772      } else if (name.equals("representation")) {
1773        this.getRepresentation().add((SubstanceSpecificationStructureRepresentationComponent) value);
1774      } else
1775        return super.setProperty(name, value);
1776      return value;
1777    }
1778
1779  @Override
1780  public void removeChild(String name, Base value) throws FHIRException {
1781      if (name.equals("stereochemistry")) {
1782        this.stereochemistry = null;
1783      } else if (name.equals("opticalActivity")) {
1784        this.opticalActivity = null;
1785      } else if (name.equals("molecularFormula")) {
1786        this.molecularFormula = null;
1787      } else if (name.equals("molecularFormulaByMoiety")) {
1788        this.molecularFormulaByMoiety = null;
1789      } else if (name.equals("isotope")) {
1790        this.getIsotope().remove((SubstanceSpecificationStructureIsotopeComponent) value);
1791      } else if (name.equals("molecularWeight")) {
1792        this.molecularWeight = (SubstanceSpecificationStructureIsotopeMolecularWeightComponent) value; // SubstanceSpecificationStructureIsotopeMolecularWeightComponent
1793      } else if (name.equals("source")) {
1794        this.getSource().remove(castToReference(value));
1795      } else if (name.equals("representation")) {
1796        this.getRepresentation().remove((SubstanceSpecificationStructureRepresentationComponent) value);
1797      } else
1798        super.removeChild(name, value);
1799      
1800    }
1801
1802    @Override
1803    public Base makeProperty(int hash, String name) throws FHIRException {
1804      switch (hash) {
1805      case 263475116:
1806        return getStereochemistry();
1807      case 1420900135:
1808        return getOpticalActivity();
1809      case 616660246:
1810        return getMolecularFormulaElement();
1811      case 1315452848:
1812        return getMolecularFormulaByMoietyElement();
1813      case 2097035189:
1814        return addIsotope();
1815      case 635625672:
1816        return getMolecularWeight();
1817      case -896505829:
1818        return addSource();
1819      case -671065907:
1820        return addRepresentation();
1821      default:
1822        return super.makeProperty(hash, name);
1823      }
1824
1825    }
1826
1827    @Override
1828    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1829      switch (hash) {
1830      case 263475116:
1831        /* stereochemistry */ return new String[] { "CodeableConcept" };
1832      case 1420900135:
1833        /* opticalActivity */ return new String[] { "CodeableConcept" };
1834      case 616660246:
1835        /* molecularFormula */ return new String[] { "string" };
1836      case 1315452848:
1837        /* molecularFormulaByMoiety */ return new String[] { "string" };
1838      case 2097035189:
1839        /* isotope */ return new String[] {};
1840      case 635625672:
1841        /* molecularWeight */ return new String[] { "@SubstanceSpecification.structure.isotope.molecularWeight" };
1842      case -896505829:
1843        /* source */ return new String[] { "Reference" };
1844      case -671065907:
1845        /* representation */ return new String[] {};
1846      default:
1847        return super.getTypesForProperty(hash, name);
1848      }
1849
1850    }
1851
1852    @Override
1853    public Base addChild(String name) throws FHIRException {
1854      if (name.equals("stereochemistry")) {
1855        this.stereochemistry = new CodeableConcept();
1856        return this.stereochemistry;
1857      } else if (name.equals("opticalActivity")) {
1858        this.opticalActivity = new CodeableConcept();
1859        return this.opticalActivity;
1860      } else if (name.equals("molecularFormula")) {
1861        throw new FHIRException("Cannot call addChild on a singleton property SubstanceSpecification.molecularFormula");
1862      } else if (name.equals("molecularFormulaByMoiety")) {
1863        throw new FHIRException(
1864            "Cannot call addChild on a singleton property SubstanceSpecification.molecularFormulaByMoiety");
1865      } else if (name.equals("isotope")) {
1866        return addIsotope();
1867      } else if (name.equals("molecularWeight")) {
1868        this.molecularWeight = new SubstanceSpecificationStructureIsotopeMolecularWeightComponent();
1869        return this.molecularWeight;
1870      } else if (name.equals("source")) {
1871        return addSource();
1872      } else if (name.equals("representation")) {
1873        return addRepresentation();
1874      } else
1875        return super.addChild(name);
1876    }
1877
1878    public SubstanceSpecificationStructureComponent copy() {
1879      SubstanceSpecificationStructureComponent dst = new SubstanceSpecificationStructureComponent();
1880      copyValues(dst);
1881      return dst;
1882    }
1883
1884    public void copyValues(SubstanceSpecificationStructureComponent dst) {
1885      super.copyValues(dst);
1886      dst.stereochemistry = stereochemistry == null ? null : stereochemistry.copy();
1887      dst.opticalActivity = opticalActivity == null ? null : opticalActivity.copy();
1888      dst.molecularFormula = molecularFormula == null ? null : molecularFormula.copy();
1889      dst.molecularFormulaByMoiety = molecularFormulaByMoiety == null ? null : molecularFormulaByMoiety.copy();
1890      if (isotope != null) {
1891        dst.isotope = new ArrayList<SubstanceSpecificationStructureIsotopeComponent>();
1892        for (SubstanceSpecificationStructureIsotopeComponent i : isotope)
1893          dst.isotope.add(i.copy());
1894      }
1895      ;
1896      dst.molecularWeight = molecularWeight == null ? null : molecularWeight.copy();
1897      if (source != null) {
1898        dst.source = new ArrayList<Reference>();
1899        for (Reference i : source)
1900          dst.source.add(i.copy());
1901      }
1902      ;
1903      if (representation != null) {
1904        dst.representation = new ArrayList<SubstanceSpecificationStructureRepresentationComponent>();
1905        for (SubstanceSpecificationStructureRepresentationComponent i : representation)
1906          dst.representation.add(i.copy());
1907      }
1908      ;
1909    }
1910
1911    @Override
1912    public boolean equalsDeep(Base other_) {
1913      if (!super.equalsDeep(other_))
1914        return false;
1915      if (!(other_ instanceof SubstanceSpecificationStructureComponent))
1916        return false;
1917      SubstanceSpecificationStructureComponent o = (SubstanceSpecificationStructureComponent) other_;
1918      return compareDeep(stereochemistry, o.stereochemistry, true)
1919          && compareDeep(opticalActivity, o.opticalActivity, true)
1920          && compareDeep(molecularFormula, o.molecularFormula, true)
1921          && compareDeep(molecularFormulaByMoiety, o.molecularFormulaByMoiety, true)
1922          && compareDeep(isotope, o.isotope, true) && compareDeep(molecularWeight, o.molecularWeight, true)
1923          && compareDeep(source, o.source, true) && compareDeep(representation, o.representation, true);
1924    }
1925
1926    @Override
1927    public boolean equalsShallow(Base other_) {
1928      if (!super.equalsShallow(other_))
1929        return false;
1930      if (!(other_ instanceof SubstanceSpecificationStructureComponent))
1931        return false;
1932      SubstanceSpecificationStructureComponent o = (SubstanceSpecificationStructureComponent) other_;
1933      return compareValues(molecularFormula, o.molecularFormula, true)
1934          && compareValues(molecularFormulaByMoiety, o.molecularFormulaByMoiety, true);
1935    }
1936
1937    public boolean isEmpty() {
1938      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(stereochemistry, opticalActivity, molecularFormula,
1939          molecularFormulaByMoiety, isotope, molecularWeight, source, representation);
1940    }
1941
1942    public String fhirType() {
1943      return "SubstanceSpecification.structure";
1944
1945    }
1946
1947  }
1948
1949  @Block()
1950  public static class SubstanceSpecificationStructureIsotopeComponent extends BackboneElement
1951      implements IBaseBackboneElement {
1952    /**
1953     * Substance identifier for each non-natural or radioisotope.
1954     */
1955    @Child(name = "identifier", type = {
1956        Identifier.class }, order = 1, min = 0, max = 1, modifier = false, summary = true)
1957    @Description(shortDefinition = "Substance identifier for each non-natural or radioisotope", formalDefinition = "Substance identifier for each non-natural or radioisotope.")
1958    protected Identifier identifier;
1959
1960    /**
1961     * Substance name for each non-natural or radioisotope.
1962     */
1963    @Child(name = "name", type = {
1964        CodeableConcept.class }, order = 2, min = 0, max = 1, modifier = false, summary = true)
1965    @Description(shortDefinition = "Substance name for each non-natural or radioisotope", formalDefinition = "Substance name for each non-natural or radioisotope.")
1966    protected CodeableConcept name;
1967
1968    /**
1969     * The type of isotopic substitution present in a single substance.
1970     */
1971    @Child(name = "substitution", type = {
1972        CodeableConcept.class }, order = 3, min = 0, max = 1, modifier = false, summary = true)
1973    @Description(shortDefinition = "The type of isotopic substitution present in a single substance", formalDefinition = "The type of isotopic substitution present in a single substance.")
1974    protected CodeableConcept substitution;
1975
1976    /**
1977     * Half life - for a non-natural nuclide.
1978     */
1979    @Child(name = "halfLife", type = { Quantity.class }, order = 4, min = 0, max = 1, modifier = false, summary = true)
1980    @Description(shortDefinition = "Half life - for a non-natural nuclide", formalDefinition = "Half life - for a non-natural nuclide.")
1981    protected Quantity halfLife;
1982
1983    /**
1984     * The molecular weight or weight range (for proteins, polymers or nucleic
1985     * acids).
1986     */
1987    @Child(name = "molecularWeight", type = {}, order = 5, min = 0, max = 1, modifier = false, summary = true)
1988    @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).")
1989    protected SubstanceSpecificationStructureIsotopeMolecularWeightComponent molecularWeight;
1990
1991    private static final long serialVersionUID = -531167114L;
1992
1993    /**
1994     * Constructor
1995     */
1996    public SubstanceSpecificationStructureIsotopeComponent() {
1997      super();
1998    }
1999
2000    /**
2001     * @return {@link #identifier} (Substance identifier for each non-natural or
2002     *         radioisotope.)
2003     */
2004    public Identifier getIdentifier() {
2005      if (this.identifier == null)
2006        if (Configuration.errorOnAutoCreate())
2007          throw new Error("Attempt to auto-create SubstanceSpecificationStructureIsotopeComponent.identifier");
2008        else if (Configuration.doAutoCreate())
2009          this.identifier = new Identifier(); // cc
2010      return this.identifier;
2011    }
2012
2013    public boolean hasIdentifier() {
2014      return this.identifier != null && !this.identifier.isEmpty();
2015    }
2016
2017    /**
2018     * @param value {@link #identifier} (Substance identifier for each non-natural
2019     *              or radioisotope.)
2020     */
2021    public SubstanceSpecificationStructureIsotopeComponent setIdentifier(Identifier value) {
2022      this.identifier = value;
2023      return this;
2024    }
2025
2026    /**
2027     * @return {@link #name} (Substance name for each non-natural or radioisotope.)
2028     */
2029    public CodeableConcept getName() {
2030      if (this.name == null)
2031        if (Configuration.errorOnAutoCreate())
2032          throw new Error("Attempt to auto-create SubstanceSpecificationStructureIsotopeComponent.name");
2033        else if (Configuration.doAutoCreate())
2034          this.name = new CodeableConcept(); // cc
2035      return this.name;
2036    }
2037
2038    public boolean hasName() {
2039      return this.name != null && !this.name.isEmpty();
2040    }
2041
2042    /**
2043     * @param value {@link #name} (Substance name for each non-natural or
2044     *              radioisotope.)
2045     */
2046    public SubstanceSpecificationStructureIsotopeComponent setName(CodeableConcept value) {
2047      this.name = value;
2048      return this;
2049    }
2050
2051    /**
2052     * @return {@link #substitution} (The type of isotopic substitution present in a
2053     *         single substance.)
2054     */
2055    public CodeableConcept getSubstitution() {
2056      if (this.substitution == null)
2057        if (Configuration.errorOnAutoCreate())
2058          throw new Error("Attempt to auto-create SubstanceSpecificationStructureIsotopeComponent.substitution");
2059        else if (Configuration.doAutoCreate())
2060          this.substitution = new CodeableConcept(); // cc
2061      return this.substitution;
2062    }
2063
2064    public boolean hasSubstitution() {
2065      return this.substitution != null && !this.substitution.isEmpty();
2066    }
2067
2068    /**
2069     * @param value {@link #substitution} (The type of isotopic substitution present
2070     *              in a single substance.)
2071     */
2072    public SubstanceSpecificationStructureIsotopeComponent setSubstitution(CodeableConcept value) {
2073      this.substitution = value;
2074      return this;
2075    }
2076
2077    /**
2078     * @return {@link #halfLife} (Half life - for a non-natural nuclide.)
2079     */
2080    public Quantity getHalfLife() {
2081      if (this.halfLife == null)
2082        if (Configuration.errorOnAutoCreate())
2083          throw new Error("Attempt to auto-create SubstanceSpecificationStructureIsotopeComponent.halfLife");
2084        else if (Configuration.doAutoCreate())
2085          this.halfLife = new Quantity(); // cc
2086      return this.halfLife;
2087    }
2088
2089    public boolean hasHalfLife() {
2090      return this.halfLife != null && !this.halfLife.isEmpty();
2091    }
2092
2093    /**
2094     * @param value {@link #halfLife} (Half life - for a non-natural nuclide.)
2095     */
2096    public SubstanceSpecificationStructureIsotopeComponent setHalfLife(Quantity value) {
2097      this.halfLife = value;
2098      return this;
2099    }
2100
2101    /**
2102     * @return {@link #molecularWeight} (The molecular weight or weight range (for
2103     *         proteins, polymers or nucleic acids).)
2104     */
2105    public SubstanceSpecificationStructureIsotopeMolecularWeightComponent getMolecularWeight() {
2106      if (this.molecularWeight == null)
2107        if (Configuration.errorOnAutoCreate())
2108          throw new Error("Attempt to auto-create SubstanceSpecificationStructureIsotopeComponent.molecularWeight");
2109        else if (Configuration.doAutoCreate())
2110          this.molecularWeight = new SubstanceSpecificationStructureIsotopeMolecularWeightComponent(); // cc
2111      return this.molecularWeight;
2112    }
2113
2114    public boolean hasMolecularWeight() {
2115      return this.molecularWeight != null && !this.molecularWeight.isEmpty();
2116    }
2117
2118    /**
2119     * @param value {@link #molecularWeight} (The molecular weight or weight range
2120     *              (for proteins, polymers or nucleic acids).)
2121     */
2122    public SubstanceSpecificationStructureIsotopeComponent setMolecularWeight(
2123        SubstanceSpecificationStructureIsotopeMolecularWeightComponent value) {
2124      this.molecularWeight = value;
2125      return this;
2126    }
2127
2128    protected void listChildren(List<Property> children) {
2129      super.listChildren(children);
2130      children.add(new Property("identifier", "Identifier",
2131          "Substance identifier for each non-natural or radioisotope.", 0, 1, identifier));
2132      children.add(
2133          new Property("name", "CodeableConcept", "Substance name for each non-natural or radioisotope.", 0, 1, name));
2134      children.add(new Property("substitution", "CodeableConcept",
2135          "The type of isotopic substitution present in a single substance.", 0, 1, substitution));
2136      children.add(new Property("halfLife", "Quantity", "Half life - for a non-natural nuclide.", 0, 1, halfLife));
2137      children.add(new Property("molecularWeight", "",
2138          "The molecular weight or weight range (for proteins, polymers or nucleic acids).", 0, 1, molecularWeight));
2139    }
2140
2141    @Override
2142    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2143      switch (_hash) {
2144      case -1618432855:
2145        /* identifier */ return new Property("identifier", "Identifier",
2146            "Substance identifier for each non-natural or radioisotope.", 0, 1, identifier);
2147      case 3373707:
2148        /* name */ return new Property("name", "CodeableConcept",
2149            "Substance name for each non-natural or radioisotope.", 0, 1, name);
2150      case 826147581:
2151        /* substitution */ return new Property("substitution", "CodeableConcept",
2152            "The type of isotopic substitution present in a single substance.", 0, 1, substitution);
2153      case -54292017:
2154        /* halfLife */ return new Property("halfLife", "Quantity", "Half life - for a non-natural nuclide.", 0, 1,
2155            halfLife);
2156      case 635625672:
2157        /* molecularWeight */ return new Property("molecularWeight", "",
2158            "The molecular weight or weight range (for proteins, polymers or nucleic acids).", 0, 1, molecularWeight);
2159      default:
2160        return super.getNamedProperty(_hash, _name, _checkValid);
2161      }
2162
2163    }
2164
2165    @Override
2166    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2167      switch (hash) {
2168      case -1618432855:
2169        /* identifier */ return this.identifier == null ? new Base[0] : new Base[] { this.identifier }; // Identifier
2170      case 3373707:
2171        /* name */ return this.name == null ? new Base[0] : new Base[] { this.name }; // CodeableConcept
2172      case 826147581:
2173        /* substitution */ return this.substitution == null ? new Base[0] : new Base[] { this.substitution }; // CodeableConcept
2174      case -54292017:
2175        /* halfLife */ return this.halfLife == null ? new Base[0] : new Base[] { this.halfLife }; // Quantity
2176      case 635625672:
2177        /* molecularWeight */ return this.molecularWeight == null ? new Base[0] : new Base[] { this.molecularWeight }; // SubstanceSpecificationStructureIsotopeMolecularWeightComponent
2178      default:
2179        return super.getProperty(hash, name, checkValid);
2180      }
2181
2182    }
2183
2184    @Override
2185    public Base setProperty(int hash, String name, Base value) throws FHIRException {
2186      switch (hash) {
2187      case -1618432855: // identifier
2188        this.identifier = castToIdentifier(value); // Identifier
2189        return value;
2190      case 3373707: // name
2191        this.name = castToCodeableConcept(value); // CodeableConcept
2192        return value;
2193      case 826147581: // substitution
2194        this.substitution = castToCodeableConcept(value); // CodeableConcept
2195        return value;
2196      case -54292017: // halfLife
2197        this.halfLife = castToQuantity(value); // Quantity
2198        return value;
2199      case 635625672: // molecularWeight
2200        this.molecularWeight = (SubstanceSpecificationStructureIsotopeMolecularWeightComponent) value; // SubstanceSpecificationStructureIsotopeMolecularWeightComponent
2201        return value;
2202      default:
2203        return super.setProperty(hash, name, value);
2204      }
2205
2206    }
2207
2208    @Override
2209    public Base setProperty(String name, Base value) throws FHIRException {
2210      if (name.equals("identifier")) {
2211        this.identifier = castToIdentifier(value); // Identifier
2212      } else if (name.equals("name")) {
2213        this.name = castToCodeableConcept(value); // CodeableConcept
2214      } else if (name.equals("substitution")) {
2215        this.substitution = castToCodeableConcept(value); // CodeableConcept
2216      } else if (name.equals("halfLife")) {
2217        this.halfLife = castToQuantity(value); // Quantity
2218      } else if (name.equals("molecularWeight")) {
2219        this.molecularWeight = (SubstanceSpecificationStructureIsotopeMolecularWeightComponent) value; // SubstanceSpecificationStructureIsotopeMolecularWeightComponent
2220      } else
2221        return super.setProperty(name, value);
2222      return value;
2223    }
2224
2225  @Override
2226  public void removeChild(String name, Base value) throws FHIRException {
2227      if (name.equals("identifier")) {
2228        this.identifier = null;
2229      } else if (name.equals("name")) {
2230        this.name = null;
2231      } else if (name.equals("substitution")) {
2232        this.substitution = null;
2233      } else if (name.equals("halfLife")) {
2234        this.halfLife = null;
2235      } else if (name.equals("molecularWeight")) {
2236        this.molecularWeight = (SubstanceSpecificationStructureIsotopeMolecularWeightComponent) value; // SubstanceSpecificationStructureIsotopeMolecularWeightComponent
2237      } else
2238        super.removeChild(name, value);
2239      
2240    }
2241
2242    @Override
2243    public Base makeProperty(int hash, String name) throws FHIRException {
2244      switch (hash) {
2245      case -1618432855:
2246        return getIdentifier();
2247      case 3373707:
2248        return getName();
2249      case 826147581:
2250        return getSubstitution();
2251      case -54292017:
2252        return getHalfLife();
2253      case 635625672:
2254        return getMolecularWeight();
2255      default:
2256        return super.makeProperty(hash, name);
2257      }
2258
2259    }
2260
2261    @Override
2262    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2263      switch (hash) {
2264      case -1618432855:
2265        /* identifier */ return new String[] { "Identifier" };
2266      case 3373707:
2267        /* name */ return new String[] { "CodeableConcept" };
2268      case 826147581:
2269        /* substitution */ return new String[] { "CodeableConcept" };
2270      case -54292017:
2271        /* halfLife */ return new String[] { "Quantity" };
2272      case 635625672:
2273        /* molecularWeight */ return new String[] {};
2274      default:
2275        return super.getTypesForProperty(hash, name);
2276      }
2277
2278    }
2279
2280    @Override
2281    public Base addChild(String name) throws FHIRException {
2282      if (name.equals("identifier")) {
2283        this.identifier = new Identifier();
2284        return this.identifier;
2285      } else if (name.equals("name")) {
2286        this.name = new CodeableConcept();
2287        return this.name;
2288      } else if (name.equals("substitution")) {
2289        this.substitution = new CodeableConcept();
2290        return this.substitution;
2291      } else if (name.equals("halfLife")) {
2292        this.halfLife = new Quantity();
2293        return this.halfLife;
2294      } else if (name.equals("molecularWeight")) {
2295        this.molecularWeight = new SubstanceSpecificationStructureIsotopeMolecularWeightComponent();
2296        return this.molecularWeight;
2297      } else
2298        return super.addChild(name);
2299    }
2300
2301    public SubstanceSpecificationStructureIsotopeComponent copy() {
2302      SubstanceSpecificationStructureIsotopeComponent dst = new SubstanceSpecificationStructureIsotopeComponent();
2303      copyValues(dst);
2304      return dst;
2305    }
2306
2307    public void copyValues(SubstanceSpecificationStructureIsotopeComponent dst) {
2308      super.copyValues(dst);
2309      dst.identifier = identifier == null ? null : identifier.copy();
2310      dst.name = name == null ? null : name.copy();
2311      dst.substitution = substitution == null ? null : substitution.copy();
2312      dst.halfLife = halfLife == null ? null : halfLife.copy();
2313      dst.molecularWeight = molecularWeight == null ? null : molecularWeight.copy();
2314    }
2315
2316    @Override
2317    public boolean equalsDeep(Base other_) {
2318      if (!super.equalsDeep(other_))
2319        return false;
2320      if (!(other_ instanceof SubstanceSpecificationStructureIsotopeComponent))
2321        return false;
2322      SubstanceSpecificationStructureIsotopeComponent o = (SubstanceSpecificationStructureIsotopeComponent) other_;
2323      return compareDeep(identifier, o.identifier, true) && compareDeep(name, o.name, true)
2324          && compareDeep(substitution, o.substitution, true) && compareDeep(halfLife, o.halfLife, true)
2325          && compareDeep(molecularWeight, o.molecularWeight, true);
2326    }
2327
2328    @Override
2329    public boolean equalsShallow(Base other_) {
2330      if (!super.equalsShallow(other_))
2331        return false;
2332      if (!(other_ instanceof SubstanceSpecificationStructureIsotopeComponent))
2333        return false;
2334      SubstanceSpecificationStructureIsotopeComponent o = (SubstanceSpecificationStructureIsotopeComponent) other_;
2335      return true;
2336    }
2337
2338    public boolean isEmpty() {
2339      return super.isEmpty()
2340          && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, name, substitution, halfLife, molecularWeight);
2341    }
2342
2343    public String fhirType() {
2344      return "SubstanceSpecification.structure.isotope";
2345
2346    }
2347
2348  }
2349
2350  @Block()
2351  public static class SubstanceSpecificationStructureIsotopeMolecularWeightComponent extends BackboneElement
2352      implements IBaseBackboneElement {
2353    /**
2354     * The method by which the molecular weight was determined.
2355     */
2356    @Child(name = "method", type = {
2357        CodeableConcept.class }, order = 1, min = 0, max = 1, modifier = false, summary = true)
2358    @Description(shortDefinition = "The method by which the molecular weight was determined", formalDefinition = "The method by which the molecular weight was determined.")
2359    protected CodeableConcept method;
2360
2361    /**
2362     * Type of molecular weight such as exact, average (also known as. number
2363     * average), weight average.
2364     */
2365    @Child(name = "type", type = {
2366        CodeableConcept.class }, order = 2, min = 0, max = 1, modifier = false, summary = true)
2367    @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.")
2368    protected CodeableConcept type;
2369
2370    /**
2371     * Used to capture quantitative values for a variety of elements. If only limits
2372     * are given, the arithmetic mean would be the average. If only a single
2373     * definite value for a given element is given, it would be captured in this
2374     * field.
2375     */
2376    @Child(name = "amount", type = { Quantity.class }, order = 3, min = 0, max = 1, modifier = false, summary = true)
2377    @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.")
2378    protected Quantity amount;
2379
2380    private static final long serialVersionUID = 805939780L;
2381
2382    /**
2383     * Constructor
2384     */
2385    public SubstanceSpecificationStructureIsotopeMolecularWeightComponent() {
2386      super();
2387    }
2388
2389    /**
2390     * @return {@link #method} (The method by which the molecular weight was
2391     *         determined.)
2392     */
2393    public CodeableConcept getMethod() {
2394      if (this.method == null)
2395        if (Configuration.errorOnAutoCreate())
2396          throw new Error(
2397              "Attempt to auto-create SubstanceSpecificationStructureIsotopeMolecularWeightComponent.method");
2398        else if (Configuration.doAutoCreate())
2399          this.method = new CodeableConcept(); // cc
2400      return this.method;
2401    }
2402
2403    public boolean hasMethod() {
2404      return this.method != null && !this.method.isEmpty();
2405    }
2406
2407    /**
2408     * @param value {@link #method} (The method by which the molecular weight was
2409     *              determined.)
2410     */
2411    public SubstanceSpecificationStructureIsotopeMolecularWeightComponent setMethod(CodeableConcept value) {
2412      this.method = value;
2413      return this;
2414    }
2415
2416    /**
2417     * @return {@link #type} (Type of molecular weight such as exact, average (also
2418     *         known as. number average), weight average.)
2419     */
2420    public CodeableConcept getType() {
2421      if (this.type == null)
2422        if (Configuration.errorOnAutoCreate())
2423          throw new Error("Attempt to auto-create SubstanceSpecificationStructureIsotopeMolecularWeightComponent.type");
2424        else if (Configuration.doAutoCreate())
2425          this.type = new CodeableConcept(); // cc
2426      return this.type;
2427    }
2428
2429    public boolean hasType() {
2430      return this.type != null && !this.type.isEmpty();
2431    }
2432
2433    /**
2434     * @param value {@link #type} (Type of molecular weight such as exact, average
2435     *              (also known as. number average), weight average.)
2436     */
2437    public SubstanceSpecificationStructureIsotopeMolecularWeightComponent setType(CodeableConcept value) {
2438      this.type = value;
2439      return this;
2440    }
2441
2442    /**
2443     * @return {@link #amount} (Used to capture quantitative values for a variety of
2444     *         elements. If only limits are given, the arithmetic mean would be the
2445     *         average. If only a single definite value for a given element is
2446     *         given, it would be captured in this field.)
2447     */
2448    public Quantity getAmount() {
2449      if (this.amount == null)
2450        if (Configuration.errorOnAutoCreate())
2451          throw new Error(
2452              "Attempt to auto-create SubstanceSpecificationStructureIsotopeMolecularWeightComponent.amount");
2453        else if (Configuration.doAutoCreate())
2454          this.amount = new Quantity(); // cc
2455      return this.amount;
2456    }
2457
2458    public boolean hasAmount() {
2459      return this.amount != null && !this.amount.isEmpty();
2460    }
2461
2462    /**
2463     * @param value {@link #amount} (Used to capture quantitative values for a
2464     *              variety of elements. If only limits are given, the arithmetic
2465     *              mean would be the average. If only a single definite value for a
2466     *              given element is given, it would be captured in this field.)
2467     */
2468    public SubstanceSpecificationStructureIsotopeMolecularWeightComponent setAmount(Quantity value) {
2469      this.amount = value;
2470      return this;
2471    }
2472
2473    protected void listChildren(List<Property> children) {
2474      super.listChildren(children);
2475      children.add(new Property("method", "CodeableConcept", "The method by which the molecular weight was determined.",
2476          0, 1, method));
2477      children.add(new Property("type", "CodeableConcept",
2478          "Type of molecular weight such as exact, average (also known as. number average), weight average.", 0, 1,
2479          type));
2480      children.add(new Property("amount", "Quantity",
2481          "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.",
2482          0, 1, amount));
2483    }
2484
2485    @Override
2486    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2487      switch (_hash) {
2488      case -1077554975:
2489        /* method */ return new Property("method", "CodeableConcept",
2490            "The method by which the molecular weight was determined.", 0, 1, method);
2491      case 3575610:
2492        /* type */ return new Property("type", "CodeableConcept",
2493            "Type of molecular weight such as exact, average (also known as. number average), weight average.", 0, 1,
2494            type);
2495      case -1413853096:
2496        /* amount */ return new Property("amount", "Quantity",
2497            "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.",
2498            0, 1, amount);
2499      default:
2500        return super.getNamedProperty(_hash, _name, _checkValid);
2501      }
2502
2503    }
2504
2505    @Override
2506    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2507      switch (hash) {
2508      case -1077554975:
2509        /* method */ return this.method == null ? new Base[0] : new Base[] { this.method }; // CodeableConcept
2510      case 3575610:
2511        /* type */ return this.type == null ? new Base[0] : new Base[] { this.type }; // CodeableConcept
2512      case -1413853096:
2513        /* amount */ return this.amount == null ? new Base[0] : new Base[] { this.amount }; // Quantity
2514      default:
2515        return super.getProperty(hash, name, checkValid);
2516      }
2517
2518    }
2519
2520    @Override
2521    public Base setProperty(int hash, String name, Base value) throws FHIRException {
2522      switch (hash) {
2523      case -1077554975: // method
2524        this.method = castToCodeableConcept(value); // CodeableConcept
2525        return value;
2526      case 3575610: // type
2527        this.type = castToCodeableConcept(value); // CodeableConcept
2528        return value;
2529      case -1413853096: // amount
2530        this.amount = castToQuantity(value); // Quantity
2531        return value;
2532      default:
2533        return super.setProperty(hash, name, value);
2534      }
2535
2536    }
2537
2538    @Override
2539    public Base setProperty(String name, Base value) throws FHIRException {
2540      if (name.equals("method")) {
2541        this.method = castToCodeableConcept(value); // CodeableConcept
2542      } else if (name.equals("type")) {
2543        this.type = castToCodeableConcept(value); // CodeableConcept
2544      } else if (name.equals("amount")) {
2545        this.amount = castToQuantity(value); // Quantity
2546      } else
2547        return super.setProperty(name, value);
2548      return value;
2549    }
2550
2551  @Override
2552  public void removeChild(String name, Base value) throws FHIRException {
2553      if (name.equals("method")) {
2554        this.method = null;
2555      } else if (name.equals("type")) {
2556        this.type = null;
2557      } else if (name.equals("amount")) {
2558        this.amount = null;
2559      } else
2560        super.removeChild(name, value);
2561      
2562    }
2563
2564    @Override
2565    public Base makeProperty(int hash, String name) throws FHIRException {
2566      switch (hash) {
2567      case -1077554975:
2568        return getMethod();
2569      case 3575610:
2570        return getType();
2571      case -1413853096:
2572        return getAmount();
2573      default:
2574        return super.makeProperty(hash, name);
2575      }
2576
2577    }
2578
2579    @Override
2580    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2581      switch (hash) {
2582      case -1077554975:
2583        /* method */ return new String[] { "CodeableConcept" };
2584      case 3575610:
2585        /* type */ return new String[] { "CodeableConcept" };
2586      case -1413853096:
2587        /* amount */ return new String[] { "Quantity" };
2588      default:
2589        return super.getTypesForProperty(hash, name);
2590      }
2591
2592    }
2593
2594    @Override
2595    public Base addChild(String name) throws FHIRException {
2596      if (name.equals("method")) {
2597        this.method = new CodeableConcept();
2598        return this.method;
2599      } else if (name.equals("type")) {
2600        this.type = new CodeableConcept();
2601        return this.type;
2602      } else if (name.equals("amount")) {
2603        this.amount = new Quantity();
2604        return this.amount;
2605      } else
2606        return super.addChild(name);
2607    }
2608
2609    public SubstanceSpecificationStructureIsotopeMolecularWeightComponent copy() {
2610      SubstanceSpecificationStructureIsotopeMolecularWeightComponent dst = new SubstanceSpecificationStructureIsotopeMolecularWeightComponent();
2611      copyValues(dst);
2612      return dst;
2613    }
2614
2615    public void copyValues(SubstanceSpecificationStructureIsotopeMolecularWeightComponent dst) {
2616      super.copyValues(dst);
2617      dst.method = method == null ? null : method.copy();
2618      dst.type = type == null ? null : type.copy();
2619      dst.amount = amount == null ? null : amount.copy();
2620    }
2621
2622    @Override
2623    public boolean equalsDeep(Base other_) {
2624      if (!super.equalsDeep(other_))
2625        return false;
2626      if (!(other_ instanceof SubstanceSpecificationStructureIsotopeMolecularWeightComponent))
2627        return false;
2628      SubstanceSpecificationStructureIsotopeMolecularWeightComponent o = (SubstanceSpecificationStructureIsotopeMolecularWeightComponent) other_;
2629      return compareDeep(method, o.method, true) && compareDeep(type, o.type, true)
2630          && compareDeep(amount, o.amount, true);
2631    }
2632
2633    @Override
2634    public boolean equalsShallow(Base other_) {
2635      if (!super.equalsShallow(other_))
2636        return false;
2637      if (!(other_ instanceof SubstanceSpecificationStructureIsotopeMolecularWeightComponent))
2638        return false;
2639      SubstanceSpecificationStructureIsotopeMolecularWeightComponent o = (SubstanceSpecificationStructureIsotopeMolecularWeightComponent) other_;
2640      return true;
2641    }
2642
2643    public boolean isEmpty() {
2644      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(method, type, amount);
2645    }
2646
2647    public String fhirType() {
2648      return "SubstanceSpecification.structure.isotope.molecularWeight";
2649
2650    }
2651
2652  }
2653
2654  @Block()
2655  public static class SubstanceSpecificationStructureRepresentationComponent extends BackboneElement
2656      implements IBaseBackboneElement {
2657    /**
2658     * The type of structure (e.g. Full, Partial, Representative).
2659     */
2660    @Child(name = "type", type = {
2661        CodeableConcept.class }, order = 1, min = 0, max = 1, modifier = false, summary = true)
2662    @Description(shortDefinition = "The type of structure (e.g. Full, Partial, Representative)", formalDefinition = "The type of structure (e.g. Full, Partial, Representative).")
2663    protected CodeableConcept type;
2664
2665    /**
2666     * The structural representation as text string in a format e.g. InChI, SMILES,
2667     * MOLFILE, CDX.
2668     */
2669    @Child(name = "representation", type = {
2670        StringType.class }, order = 2, min = 0, max = 1, modifier = false, summary = true)
2671    @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.")
2672    protected StringType representation;
2673
2674    /**
2675     * An attached file with the structural representation.
2676     */
2677    @Child(name = "attachment", type = {
2678        Attachment.class }, order = 3, min = 0, max = 1, modifier = false, summary = true)
2679    @Description(shortDefinition = "An attached file with the structural representation", formalDefinition = "An attached file with the structural representation.")
2680    protected Attachment attachment;
2681
2682    private static final long serialVersionUID = 167954495L;
2683
2684    /**
2685     * Constructor
2686     */
2687    public SubstanceSpecificationStructureRepresentationComponent() {
2688      super();
2689    }
2690
2691    /**
2692     * @return {@link #type} (The type of structure (e.g. Full, Partial,
2693     *         Representative).)
2694     */
2695    public CodeableConcept getType() {
2696      if (this.type == null)
2697        if (Configuration.errorOnAutoCreate())
2698          throw new Error("Attempt to auto-create SubstanceSpecificationStructureRepresentationComponent.type");
2699        else if (Configuration.doAutoCreate())
2700          this.type = new CodeableConcept(); // cc
2701      return this.type;
2702    }
2703
2704    public boolean hasType() {
2705      return this.type != null && !this.type.isEmpty();
2706    }
2707
2708    /**
2709     * @param value {@link #type} (The type of structure (e.g. Full, Partial,
2710     *              Representative).)
2711     */
2712    public SubstanceSpecificationStructureRepresentationComponent setType(CodeableConcept value) {
2713      this.type = value;
2714      return this;
2715    }
2716
2717    /**
2718     * @return {@link #representation} (The structural representation as text string
2719     *         in a format e.g. InChI, SMILES, MOLFILE, CDX.). This is the
2720     *         underlying object with id, value and extensions. The accessor
2721     *         "getRepresentation" gives direct access to the value
2722     */
2723    public StringType getRepresentationElement() {
2724      if (this.representation == null)
2725        if (Configuration.errorOnAutoCreate())
2726          throw new Error(
2727              "Attempt to auto-create SubstanceSpecificationStructureRepresentationComponent.representation");
2728        else if (Configuration.doAutoCreate())
2729          this.representation = new StringType(); // bb
2730      return this.representation;
2731    }
2732
2733    public boolean hasRepresentationElement() {
2734      return this.representation != null && !this.representation.isEmpty();
2735    }
2736
2737    public boolean hasRepresentation() {
2738      return this.representation != null && !this.representation.isEmpty();
2739    }
2740
2741    /**
2742     * @param value {@link #representation} (The structural representation as text
2743     *              string in a format e.g. InChI, SMILES, MOLFILE, CDX.). This is
2744     *              the underlying object with id, value and extensions. The
2745     *              accessor "getRepresentation" gives direct access to the value
2746     */
2747    public SubstanceSpecificationStructureRepresentationComponent setRepresentationElement(StringType value) {
2748      this.representation = value;
2749      return this;
2750    }
2751
2752    /**
2753     * @return The structural representation as text string in a format e.g. InChI,
2754     *         SMILES, MOLFILE, CDX.
2755     */
2756    public String getRepresentation() {
2757      return this.representation == null ? null : this.representation.getValue();
2758    }
2759
2760    /**
2761     * @param value The structural representation as text string in a format e.g.
2762     *              InChI, SMILES, MOLFILE, CDX.
2763     */
2764    public SubstanceSpecificationStructureRepresentationComponent setRepresentation(String value) {
2765      if (Utilities.noString(value))
2766        this.representation = null;
2767      else {
2768        if (this.representation == null)
2769          this.representation = new StringType();
2770        this.representation.setValue(value);
2771      }
2772      return this;
2773    }
2774
2775    /**
2776     * @return {@link #attachment} (An attached file with the structural
2777     *         representation.)
2778     */
2779    public Attachment getAttachment() {
2780      if (this.attachment == null)
2781        if (Configuration.errorOnAutoCreate())
2782          throw new Error("Attempt to auto-create SubstanceSpecificationStructureRepresentationComponent.attachment");
2783        else if (Configuration.doAutoCreate())
2784          this.attachment = new Attachment(); // cc
2785      return this.attachment;
2786    }
2787
2788    public boolean hasAttachment() {
2789      return this.attachment != null && !this.attachment.isEmpty();
2790    }
2791
2792    /**
2793     * @param value {@link #attachment} (An attached file with the structural
2794     *              representation.)
2795     */
2796    public SubstanceSpecificationStructureRepresentationComponent setAttachment(Attachment value) {
2797      this.attachment = value;
2798      return this;
2799    }
2800
2801    protected void listChildren(List<Property> children) {
2802      super.listChildren(children);
2803      children.add(new Property("type", "CodeableConcept",
2804          "The type of structure (e.g. Full, Partial, Representative).", 0, 1, type));
2805      children.add(new Property("representation", "string",
2806          "The structural representation as text string in a format e.g. InChI, SMILES, MOLFILE, CDX.", 0, 1,
2807          representation));
2808      children.add(new Property("attachment", "Attachment", "An attached file with the structural representation.", 0,
2809          1, attachment));
2810    }
2811
2812    @Override
2813    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2814      switch (_hash) {
2815      case 3575610:
2816        /* type */ return new Property("type", "CodeableConcept",
2817            "The type of structure (e.g. Full, Partial, Representative).", 0, 1, type);
2818      case -671065907:
2819        /* representation */ return new Property("representation", "string",
2820            "The structural representation as text string in a format e.g. InChI, SMILES, MOLFILE, CDX.", 0, 1,
2821            representation);
2822      case -1963501277:
2823        /* attachment */ return new Property("attachment", "Attachment",
2824            "An attached file with the structural representation.", 0, 1, attachment);
2825      default:
2826        return super.getNamedProperty(_hash, _name, _checkValid);
2827      }
2828
2829    }
2830
2831    @Override
2832    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2833      switch (hash) {
2834      case 3575610:
2835        /* type */ return this.type == null ? new Base[0] : new Base[] { this.type }; // CodeableConcept
2836      case -671065907:
2837        /* representation */ return this.representation == null ? new Base[0] : new Base[] { this.representation }; // StringType
2838      case -1963501277:
2839        /* attachment */ return this.attachment == null ? new Base[0] : new Base[] { this.attachment }; // Attachment
2840      default:
2841        return super.getProperty(hash, name, checkValid);
2842      }
2843
2844    }
2845
2846    @Override
2847    public Base setProperty(int hash, String name, Base value) throws FHIRException {
2848      switch (hash) {
2849      case 3575610: // type
2850        this.type = castToCodeableConcept(value); // CodeableConcept
2851        return value;
2852      case -671065907: // representation
2853        this.representation = castToString(value); // StringType
2854        return value;
2855      case -1963501277: // attachment
2856        this.attachment = castToAttachment(value); // Attachment
2857        return value;
2858      default:
2859        return super.setProperty(hash, name, value);
2860      }
2861
2862    }
2863
2864    @Override
2865    public Base setProperty(String name, Base value) throws FHIRException {
2866      if (name.equals("type")) {
2867        this.type = castToCodeableConcept(value); // CodeableConcept
2868      } else if (name.equals("representation")) {
2869        this.representation = castToString(value); // StringType
2870      } else if (name.equals("attachment")) {
2871        this.attachment = castToAttachment(value); // Attachment
2872      } else
2873        return super.setProperty(name, value);
2874      return value;
2875    }
2876
2877  @Override
2878  public void removeChild(String name, Base value) throws FHIRException {
2879      if (name.equals("type")) {
2880        this.type = null;
2881      } else if (name.equals("representation")) {
2882        this.representation = null;
2883      } else if (name.equals("attachment")) {
2884        this.attachment = null;
2885      } else
2886        super.removeChild(name, value);
2887      
2888    }
2889
2890    @Override
2891    public Base makeProperty(int hash, String name) throws FHIRException {
2892      switch (hash) {
2893      case 3575610:
2894        return getType();
2895      case -671065907:
2896        return getRepresentationElement();
2897      case -1963501277:
2898        return getAttachment();
2899      default:
2900        return super.makeProperty(hash, name);
2901      }
2902
2903    }
2904
2905    @Override
2906    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2907      switch (hash) {
2908      case 3575610:
2909        /* type */ return new String[] { "CodeableConcept" };
2910      case -671065907:
2911        /* representation */ return new String[] { "string" };
2912      case -1963501277:
2913        /* attachment */ return new String[] { "Attachment" };
2914      default:
2915        return super.getTypesForProperty(hash, name);
2916      }
2917
2918    }
2919
2920    @Override
2921    public Base addChild(String name) throws FHIRException {
2922      if (name.equals("type")) {
2923        this.type = new CodeableConcept();
2924        return this.type;
2925      } else if (name.equals("representation")) {
2926        throw new FHIRException("Cannot call addChild on a singleton property SubstanceSpecification.representation");
2927      } else if (name.equals("attachment")) {
2928        this.attachment = new Attachment();
2929        return this.attachment;
2930      } else
2931        return super.addChild(name);
2932    }
2933
2934    public SubstanceSpecificationStructureRepresentationComponent copy() {
2935      SubstanceSpecificationStructureRepresentationComponent dst = new SubstanceSpecificationStructureRepresentationComponent();
2936      copyValues(dst);
2937      return dst;
2938    }
2939
2940    public void copyValues(SubstanceSpecificationStructureRepresentationComponent dst) {
2941      super.copyValues(dst);
2942      dst.type = type == null ? null : type.copy();
2943      dst.representation = representation == null ? null : representation.copy();
2944      dst.attachment = attachment == null ? null : attachment.copy();
2945    }
2946
2947    @Override
2948    public boolean equalsDeep(Base other_) {
2949      if (!super.equalsDeep(other_))
2950        return false;
2951      if (!(other_ instanceof SubstanceSpecificationStructureRepresentationComponent))
2952        return false;
2953      SubstanceSpecificationStructureRepresentationComponent o = (SubstanceSpecificationStructureRepresentationComponent) other_;
2954      return compareDeep(type, o.type, true) && compareDeep(representation, o.representation, true)
2955          && compareDeep(attachment, o.attachment, true);
2956    }
2957
2958    @Override
2959    public boolean equalsShallow(Base other_) {
2960      if (!super.equalsShallow(other_))
2961        return false;
2962      if (!(other_ instanceof SubstanceSpecificationStructureRepresentationComponent))
2963        return false;
2964      SubstanceSpecificationStructureRepresentationComponent o = (SubstanceSpecificationStructureRepresentationComponent) other_;
2965      return compareValues(representation, o.representation, true);
2966    }
2967
2968    public boolean isEmpty() {
2969      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, representation, attachment);
2970    }
2971
2972    public String fhirType() {
2973      return "SubstanceSpecification.structure.representation";
2974
2975    }
2976
2977  }
2978
2979  @Block()
2980  public static class SubstanceSpecificationCodeComponent extends BackboneElement implements IBaseBackboneElement {
2981    /**
2982     * The specific code.
2983     */
2984    @Child(name = "code", type = {
2985        CodeableConcept.class }, order = 1, min = 0, max = 1, modifier = false, summary = true)
2986    @Description(shortDefinition = "The specific code", formalDefinition = "The specific code.")
2987    protected CodeableConcept code;
2988
2989    /**
2990     * Status of the code assignment.
2991     */
2992    @Child(name = "status", type = {
2993        CodeableConcept.class }, order = 2, min = 0, max = 1, modifier = false, summary = true)
2994    @Description(shortDefinition = "Status of the code assignment", formalDefinition = "Status of the code assignment.")
2995    protected CodeableConcept status;
2996
2997    /**
2998     * The date at which the code status is changed as part of the terminology
2999     * maintenance.
3000     */
3001    @Child(name = "statusDate", type = {
3002        DateTimeType.class }, order = 3, min = 0, max = 1, modifier = false, summary = true)
3003    @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.")
3004    protected DateTimeType statusDate;
3005
3006    /**
3007     * Any comment can be provided in this field, if necessary.
3008     */
3009    @Child(name = "comment", type = { StringType.class }, order = 4, min = 0, max = 1, modifier = false, summary = true)
3010    @Description(shortDefinition = "Any comment can be provided in this field, if necessary", formalDefinition = "Any comment can be provided in this field, if necessary.")
3011    protected StringType comment;
3012
3013    /**
3014     * Supporting literature.
3015     */
3016    @Child(name = "source", type = {
3017        DocumentReference.class }, order = 5, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
3018    @Description(shortDefinition = "Supporting literature", formalDefinition = "Supporting literature.")
3019    protected List<Reference> source;
3020    /**
3021     * The actual objects that are the target of the reference (Supporting
3022     * literature.)
3023     */
3024    protected List<DocumentReference> sourceTarget;
3025
3026    private static final long serialVersionUID = -1629693460L;
3027
3028    /**
3029     * Constructor
3030     */
3031    public SubstanceSpecificationCodeComponent() {
3032      super();
3033    }
3034
3035    /**
3036     * @return {@link #code} (The specific code.)
3037     */
3038    public CodeableConcept getCode() {
3039      if (this.code == null)
3040        if (Configuration.errorOnAutoCreate())
3041          throw new Error("Attempt to auto-create SubstanceSpecificationCodeComponent.code");
3042        else if (Configuration.doAutoCreate())
3043          this.code = new CodeableConcept(); // cc
3044      return this.code;
3045    }
3046
3047    public boolean hasCode() {
3048      return this.code != null && !this.code.isEmpty();
3049    }
3050
3051    /**
3052     * @param value {@link #code} (The specific code.)
3053     */
3054    public SubstanceSpecificationCodeComponent setCode(CodeableConcept value) {
3055      this.code = value;
3056      return this;
3057    }
3058
3059    /**
3060     * @return {@link #status} (Status of the code assignment.)
3061     */
3062    public CodeableConcept getStatus() {
3063      if (this.status == null)
3064        if (Configuration.errorOnAutoCreate())
3065          throw new Error("Attempt to auto-create SubstanceSpecificationCodeComponent.status");
3066        else if (Configuration.doAutoCreate())
3067          this.status = new CodeableConcept(); // cc
3068      return this.status;
3069    }
3070
3071    public boolean hasStatus() {
3072      return this.status != null && !this.status.isEmpty();
3073    }
3074
3075    /**
3076     * @param value {@link #status} (Status of the code assignment.)
3077     */
3078    public SubstanceSpecificationCodeComponent setStatus(CodeableConcept value) {
3079      this.status = value;
3080      return this;
3081    }
3082
3083    /**
3084     * @return {@link #statusDate} (The date at which the code status is changed as
3085     *         part of the terminology maintenance.). This is the underlying object
3086     *         with id, value and extensions. The accessor "getStatusDate" gives
3087     *         direct access to the value
3088     */
3089    public DateTimeType getStatusDateElement() {
3090      if (this.statusDate == null)
3091        if (Configuration.errorOnAutoCreate())
3092          throw new Error("Attempt to auto-create SubstanceSpecificationCodeComponent.statusDate");
3093        else if (Configuration.doAutoCreate())
3094          this.statusDate = new DateTimeType(); // bb
3095      return this.statusDate;
3096    }
3097
3098    public boolean hasStatusDateElement() {
3099      return this.statusDate != null && !this.statusDate.isEmpty();
3100    }
3101
3102    public boolean hasStatusDate() {
3103      return this.statusDate != null && !this.statusDate.isEmpty();
3104    }
3105
3106    /**
3107     * @param value {@link #statusDate} (The date at which the code status is
3108     *              changed as part of the terminology maintenance.). This is the
3109     *              underlying object with id, value and extensions. The accessor
3110     *              "getStatusDate" gives direct access to the value
3111     */
3112    public SubstanceSpecificationCodeComponent setStatusDateElement(DateTimeType value) {
3113      this.statusDate = value;
3114      return this;
3115    }
3116
3117    /**
3118     * @return The date at which the code status is changed as part of the
3119     *         terminology maintenance.
3120     */
3121    public Date getStatusDate() {
3122      return this.statusDate == null ? null : this.statusDate.getValue();
3123    }
3124
3125    /**
3126     * @param value The date at which the code status is changed as part of the
3127     *              terminology maintenance.
3128     */
3129    public SubstanceSpecificationCodeComponent setStatusDate(Date value) {
3130      if (value == null)
3131        this.statusDate = null;
3132      else {
3133        if (this.statusDate == null)
3134          this.statusDate = new DateTimeType();
3135        this.statusDate.setValue(value);
3136      }
3137      return this;
3138    }
3139
3140    /**
3141     * @return {@link #comment} (Any comment can be provided in this field, if
3142     *         necessary.). This is the underlying object with id, value and
3143     *         extensions. The accessor "getComment" gives direct access to the
3144     *         value
3145     */
3146    public StringType getCommentElement() {
3147      if (this.comment == null)
3148        if (Configuration.errorOnAutoCreate())
3149          throw new Error("Attempt to auto-create SubstanceSpecificationCodeComponent.comment");
3150        else if (Configuration.doAutoCreate())
3151          this.comment = new StringType(); // bb
3152      return this.comment;
3153    }
3154
3155    public boolean hasCommentElement() {
3156      return this.comment != null && !this.comment.isEmpty();
3157    }
3158
3159    public boolean hasComment() {
3160      return this.comment != null && !this.comment.isEmpty();
3161    }
3162
3163    /**
3164     * @param value {@link #comment} (Any comment can be provided in this field, if
3165     *              necessary.). This is the underlying object with id, value and
3166     *              extensions. The accessor "getComment" gives direct access to the
3167     *              value
3168     */
3169    public SubstanceSpecificationCodeComponent setCommentElement(StringType value) {
3170      this.comment = value;
3171      return this;
3172    }
3173
3174    /**
3175     * @return Any comment can be provided in this field, if necessary.
3176     */
3177    public String getComment() {
3178      return this.comment == null ? null : this.comment.getValue();
3179    }
3180
3181    /**
3182     * @param value Any comment can be provided in this field, if necessary.
3183     */
3184    public SubstanceSpecificationCodeComponent setComment(String value) {
3185      if (Utilities.noString(value))
3186        this.comment = null;
3187      else {
3188        if (this.comment == null)
3189          this.comment = new StringType();
3190        this.comment.setValue(value);
3191      }
3192      return this;
3193    }
3194
3195    /**
3196     * @return {@link #source} (Supporting literature.)
3197     */
3198    public List<Reference> getSource() {
3199      if (this.source == null)
3200        this.source = new ArrayList<Reference>();
3201      return this.source;
3202    }
3203
3204    /**
3205     * @return Returns a reference to <code>this</code> for easy method chaining
3206     */
3207    public SubstanceSpecificationCodeComponent setSource(List<Reference> theSource) {
3208      this.source = theSource;
3209      return this;
3210    }
3211
3212    public boolean hasSource() {
3213      if (this.source == null)
3214        return false;
3215      for (Reference item : this.source)
3216        if (!item.isEmpty())
3217          return true;
3218      return false;
3219    }
3220
3221    public Reference addSource() { // 3
3222      Reference t = new Reference();
3223      if (this.source == null)
3224        this.source = new ArrayList<Reference>();
3225      this.source.add(t);
3226      return t;
3227    }
3228
3229    public SubstanceSpecificationCodeComponent addSource(Reference t) { // 3
3230      if (t == null)
3231        return this;
3232      if (this.source == null)
3233        this.source = new ArrayList<Reference>();
3234      this.source.add(t);
3235      return this;
3236    }
3237
3238    /**
3239     * @return The first repetition of repeating field {@link #source}, creating it
3240     *         if it does not already exist
3241     */
3242    public Reference getSourceFirstRep() {
3243      if (getSource().isEmpty()) {
3244        addSource();
3245      }
3246      return getSource().get(0);
3247    }
3248
3249    /**
3250     * @deprecated Use Reference#setResource(IBaseResource) instead
3251     */
3252    @Deprecated
3253    public List<DocumentReference> getSourceTarget() {
3254      if (this.sourceTarget == null)
3255        this.sourceTarget = new ArrayList<DocumentReference>();
3256      return this.sourceTarget;
3257    }
3258
3259    /**
3260     * @deprecated Use Reference#setResource(IBaseResource) instead
3261     */
3262    @Deprecated
3263    public DocumentReference addSourceTarget() {
3264      DocumentReference r = new DocumentReference();
3265      if (this.sourceTarget == null)
3266        this.sourceTarget = new ArrayList<DocumentReference>();
3267      this.sourceTarget.add(r);
3268      return r;
3269    }
3270
3271    protected void listChildren(List<Property> children) {
3272      super.listChildren(children);
3273      children.add(new Property("code", "CodeableConcept", "The specific code.", 0, 1, code));
3274      children.add(new Property("status", "CodeableConcept", "Status of the code assignment.", 0, 1, status));
3275      children.add(new Property("statusDate", "dateTime",
3276          "The date at which the code status is changed as part of the terminology maintenance.", 0, 1, statusDate));
3277      children.add(
3278          new Property("comment", "string", "Any comment can be provided in this field, if necessary.", 0, 1, comment));
3279      children.add(new Property("source", "Reference(DocumentReference)", "Supporting literature.", 0,
3280          java.lang.Integer.MAX_VALUE, source));
3281    }
3282
3283    @Override
3284    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
3285      switch (_hash) {
3286      case 3059181:
3287        /* code */ return new Property("code", "CodeableConcept", "The specific code.", 0, 1, code);
3288      case -892481550:
3289        /* status */ return new Property("status", "CodeableConcept", "Status of the code assignment.", 0, 1, status);
3290      case 247524032:
3291        /* statusDate */ return new Property("statusDate", "dateTime",
3292            "The date at which the code status is changed as part of the terminology maintenance.", 0, 1, statusDate);
3293      case 950398559:
3294        /* comment */ return new Property("comment", "string",
3295            "Any comment can be provided in this field, if necessary.", 0, 1, comment);
3296      case -896505829:
3297        /* source */ return new Property("source", "Reference(DocumentReference)", "Supporting literature.", 0,
3298            java.lang.Integer.MAX_VALUE, source);
3299      default:
3300        return super.getNamedProperty(_hash, _name, _checkValid);
3301      }
3302
3303    }
3304
3305    @Override
3306    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
3307      switch (hash) {
3308      case 3059181:
3309        /* code */ return this.code == null ? new Base[0] : new Base[] { this.code }; // CodeableConcept
3310      case -892481550:
3311        /* status */ return this.status == null ? new Base[0] : new Base[] { this.status }; // CodeableConcept
3312      case 247524032:
3313        /* statusDate */ return this.statusDate == null ? new Base[0] : new Base[] { this.statusDate }; // DateTimeType
3314      case 950398559:
3315        /* comment */ return this.comment == null ? new Base[0] : new Base[] { this.comment }; // StringType
3316      case -896505829:
3317        /* source */ return this.source == null ? new Base[0] : this.source.toArray(new Base[this.source.size()]); // Reference
3318      default:
3319        return super.getProperty(hash, name, checkValid);
3320      }
3321
3322    }
3323
3324    @Override
3325    public Base setProperty(int hash, String name, Base value) throws FHIRException {
3326      switch (hash) {
3327      case 3059181: // code
3328        this.code = castToCodeableConcept(value); // CodeableConcept
3329        return value;
3330      case -892481550: // status
3331        this.status = castToCodeableConcept(value); // CodeableConcept
3332        return value;
3333      case 247524032: // statusDate
3334        this.statusDate = castToDateTime(value); // DateTimeType
3335        return value;
3336      case 950398559: // comment
3337        this.comment = castToString(value); // StringType
3338        return value;
3339      case -896505829: // source
3340        this.getSource().add(castToReference(value)); // Reference
3341        return value;
3342      default:
3343        return super.setProperty(hash, name, value);
3344      }
3345
3346    }
3347
3348    @Override
3349    public Base setProperty(String name, Base value) throws FHIRException {
3350      if (name.equals("code")) {
3351        this.code = castToCodeableConcept(value); // CodeableConcept
3352      } else if (name.equals("status")) {
3353        this.status = castToCodeableConcept(value); // CodeableConcept
3354      } else if (name.equals("statusDate")) {
3355        this.statusDate = castToDateTime(value); // DateTimeType
3356      } else if (name.equals("comment")) {
3357        this.comment = castToString(value); // StringType
3358      } else if (name.equals("source")) {
3359        this.getSource().add(castToReference(value));
3360      } else
3361        return super.setProperty(name, value);
3362      return value;
3363    }
3364
3365  @Override
3366  public void removeChild(String name, Base value) throws FHIRException {
3367      if (name.equals("code")) {
3368        this.code = null;
3369      } else if (name.equals("status")) {
3370        this.status = null;
3371      } else if (name.equals("statusDate")) {
3372        this.statusDate = null;
3373      } else if (name.equals("comment")) {
3374        this.comment = null;
3375      } else if (name.equals("source")) {
3376        this.getSource().remove(castToReference(value));
3377      } else
3378        super.removeChild(name, value);
3379      
3380    }
3381
3382    @Override
3383    public Base makeProperty(int hash, String name) throws FHIRException {
3384      switch (hash) {
3385      case 3059181:
3386        return getCode();
3387      case -892481550:
3388        return getStatus();
3389      case 247524032:
3390        return getStatusDateElement();
3391      case 950398559:
3392        return getCommentElement();
3393      case -896505829:
3394        return addSource();
3395      default:
3396        return super.makeProperty(hash, name);
3397      }
3398
3399    }
3400
3401    @Override
3402    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
3403      switch (hash) {
3404      case 3059181:
3405        /* code */ return new String[] { "CodeableConcept" };
3406      case -892481550:
3407        /* status */ return new String[] { "CodeableConcept" };
3408      case 247524032:
3409        /* statusDate */ return new String[] { "dateTime" };
3410      case 950398559:
3411        /* comment */ return new String[] { "string" };
3412      case -896505829:
3413        /* source */ return new String[] { "Reference" };
3414      default:
3415        return super.getTypesForProperty(hash, name);
3416      }
3417
3418    }
3419
3420    @Override
3421    public Base addChild(String name) throws FHIRException {
3422      if (name.equals("code")) {
3423        this.code = new CodeableConcept();
3424        return this.code;
3425      } else if (name.equals("status")) {
3426        this.status = new CodeableConcept();
3427        return this.status;
3428      } else if (name.equals("statusDate")) {
3429        throw new FHIRException("Cannot call addChild on a singleton property SubstanceSpecification.statusDate");
3430      } else if (name.equals("comment")) {
3431        throw new FHIRException("Cannot call addChild on a singleton property SubstanceSpecification.comment");
3432      } else if (name.equals("source")) {
3433        return addSource();
3434      } else
3435        return super.addChild(name);
3436    }
3437
3438    public SubstanceSpecificationCodeComponent copy() {
3439      SubstanceSpecificationCodeComponent dst = new SubstanceSpecificationCodeComponent();
3440      copyValues(dst);
3441      return dst;
3442    }
3443
3444    public void copyValues(SubstanceSpecificationCodeComponent dst) {
3445      super.copyValues(dst);
3446      dst.code = code == null ? null : code.copy();
3447      dst.status = status == null ? null : status.copy();
3448      dst.statusDate = statusDate == null ? null : statusDate.copy();
3449      dst.comment = comment == null ? null : comment.copy();
3450      if (source != null) {
3451        dst.source = new ArrayList<Reference>();
3452        for (Reference i : source)
3453          dst.source.add(i.copy());
3454      }
3455      ;
3456    }
3457
3458    @Override
3459    public boolean equalsDeep(Base other_) {
3460      if (!super.equalsDeep(other_))
3461        return false;
3462      if (!(other_ instanceof SubstanceSpecificationCodeComponent))
3463        return false;
3464      SubstanceSpecificationCodeComponent o = (SubstanceSpecificationCodeComponent) other_;
3465      return compareDeep(code, o.code, true) && compareDeep(status, o.status, true)
3466          && compareDeep(statusDate, o.statusDate, true) && compareDeep(comment, o.comment, true)
3467          && compareDeep(source, o.source, true);
3468    }
3469
3470    @Override
3471    public boolean equalsShallow(Base other_) {
3472      if (!super.equalsShallow(other_))
3473        return false;
3474      if (!(other_ instanceof SubstanceSpecificationCodeComponent))
3475        return false;
3476      SubstanceSpecificationCodeComponent o = (SubstanceSpecificationCodeComponent) other_;
3477      return compareValues(statusDate, o.statusDate, true) && compareValues(comment, o.comment, true);
3478    }
3479
3480    public boolean isEmpty() {
3481      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(code, status, statusDate, comment, source);
3482    }
3483
3484    public String fhirType() {
3485      return "SubstanceSpecification.code";
3486
3487    }
3488
3489  }
3490
3491  @Block()
3492  public static class SubstanceSpecificationNameComponent extends BackboneElement implements IBaseBackboneElement {
3493    /**
3494     * The actual name.
3495     */
3496    @Child(name = "name", type = { StringType.class }, order = 1, min = 1, max = 1, modifier = false, summary = true)
3497    @Description(shortDefinition = "The actual name", formalDefinition = "The actual name.")
3498    protected StringType name;
3499
3500    /**
3501     * Name type.
3502     */
3503    @Child(name = "type", type = {
3504        CodeableConcept.class }, order = 2, min = 0, max = 1, modifier = false, summary = true)
3505    @Description(shortDefinition = "Name type", formalDefinition = "Name type.")
3506    protected CodeableConcept type;
3507
3508    /**
3509     * The status of the name.
3510     */
3511    @Child(name = "status", type = {
3512        CodeableConcept.class }, order = 3, min = 0, max = 1, modifier = false, summary = true)
3513    @Description(shortDefinition = "The status of the name", formalDefinition = "The status of the name.")
3514    protected CodeableConcept status;
3515
3516    /**
3517     * If this is the preferred name for this substance.
3518     */
3519    @Child(name = "preferred", type = {
3520        BooleanType.class }, order = 4, min = 0, max = 1, modifier = false, summary = true)
3521    @Description(shortDefinition = "If this is the preferred name for this substance", formalDefinition = "If this is the preferred name for this substance.")
3522    protected BooleanType preferred;
3523
3524    /**
3525     * Language of the name.
3526     */
3527    @Child(name = "language", type = {
3528        CodeableConcept.class }, order = 5, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
3529    @Description(shortDefinition = "Language of the name", formalDefinition = "Language of the name.")
3530    protected List<CodeableConcept> language;
3531
3532    /**
3533     * The use context of this name for example if there is a different name a drug
3534     * active ingredient as opposed to a food colour additive.
3535     */
3536    @Child(name = "domain", type = {
3537        CodeableConcept.class }, order = 6, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
3538    @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.")
3539    protected List<CodeableConcept> domain;
3540
3541    /**
3542     * The jurisdiction where this name applies.
3543     */
3544    @Child(name = "jurisdiction", type = {
3545        CodeableConcept.class }, order = 7, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
3546    @Description(shortDefinition = "The jurisdiction where this name applies", formalDefinition = "The jurisdiction where this name applies.")
3547    protected List<CodeableConcept> jurisdiction;
3548
3549    /**
3550     * A synonym of this name.
3551     */
3552    @Child(name = "synonym", type = {
3553        SubstanceSpecificationNameComponent.class }, order = 8, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
3554    @Description(shortDefinition = "A synonym of this name", formalDefinition = "A synonym of this name.")
3555    protected List<SubstanceSpecificationNameComponent> synonym;
3556
3557    /**
3558     * A translation for this name.
3559     */
3560    @Child(name = "translation", type = {
3561        SubstanceSpecificationNameComponent.class }, order = 9, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
3562    @Description(shortDefinition = "A translation for this name", formalDefinition = "A translation for this name.")
3563    protected List<SubstanceSpecificationNameComponent> translation;
3564
3565    /**
3566     * Details of the official nature of this name.
3567     */
3568    @Child(name = "official", type = {}, order = 10, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
3569    @Description(shortDefinition = "Details of the official nature of this name", formalDefinition = "Details of the official nature of this name.")
3570    protected List<SubstanceSpecificationNameOfficialComponent> official;
3571
3572    /**
3573     * Supporting literature.
3574     */
3575    @Child(name = "source", type = {
3576        DocumentReference.class }, order = 11, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
3577    @Description(shortDefinition = "Supporting literature", formalDefinition = "Supporting literature.")
3578    protected List<Reference> source;
3579    /**
3580     * The actual objects that are the target of the reference (Supporting
3581     * literature.)
3582     */
3583    protected List<DocumentReference> sourceTarget;
3584
3585    private static final long serialVersionUID = 1547107852L;
3586
3587    /**
3588     * Constructor
3589     */
3590    public SubstanceSpecificationNameComponent() {
3591      super();
3592    }
3593
3594    /**
3595     * Constructor
3596     */
3597    public SubstanceSpecificationNameComponent(StringType name) {
3598      super();
3599      this.name = name;
3600    }
3601
3602    /**
3603     * @return {@link #name} (The actual name.). This is the underlying object with
3604     *         id, value and extensions. The accessor "getName" gives direct access
3605     *         to the value
3606     */
3607    public StringType getNameElement() {
3608      if (this.name == null)
3609        if (Configuration.errorOnAutoCreate())
3610          throw new Error("Attempt to auto-create SubstanceSpecificationNameComponent.name");
3611        else if (Configuration.doAutoCreate())
3612          this.name = new StringType(); // bb
3613      return this.name;
3614    }
3615
3616    public boolean hasNameElement() {
3617      return this.name != null && !this.name.isEmpty();
3618    }
3619
3620    public boolean hasName() {
3621      return this.name != null && !this.name.isEmpty();
3622    }
3623
3624    /**
3625     * @param value {@link #name} (The actual name.). This is the underlying object
3626     *              with id, value and extensions. The accessor "getName" gives
3627     *              direct access to the value
3628     */
3629    public SubstanceSpecificationNameComponent setNameElement(StringType value) {
3630      this.name = value;
3631      return this;
3632    }
3633
3634    /**
3635     * @return The actual name.
3636     */
3637    public String getName() {
3638      return this.name == null ? null : this.name.getValue();
3639    }
3640
3641    /**
3642     * @param value The actual name.
3643     */
3644    public SubstanceSpecificationNameComponent setName(String value) {
3645      if (this.name == null)
3646        this.name = new StringType();
3647      this.name.setValue(value);
3648      return this;
3649    }
3650
3651    /**
3652     * @return {@link #type} (Name type.)
3653     */
3654    public CodeableConcept getType() {
3655      if (this.type == null)
3656        if (Configuration.errorOnAutoCreate())
3657          throw new Error("Attempt to auto-create SubstanceSpecificationNameComponent.type");
3658        else if (Configuration.doAutoCreate())
3659          this.type = new CodeableConcept(); // cc
3660      return this.type;
3661    }
3662
3663    public boolean hasType() {
3664      return this.type != null && !this.type.isEmpty();
3665    }
3666
3667    /**
3668     * @param value {@link #type} (Name type.)
3669     */
3670    public SubstanceSpecificationNameComponent setType(CodeableConcept value) {
3671      this.type = value;
3672      return this;
3673    }
3674
3675    /**
3676     * @return {@link #status} (The status of the name.)
3677     */
3678    public CodeableConcept getStatus() {
3679      if (this.status == null)
3680        if (Configuration.errorOnAutoCreate())
3681          throw new Error("Attempt to auto-create SubstanceSpecificationNameComponent.status");
3682        else if (Configuration.doAutoCreate())
3683          this.status = new CodeableConcept(); // cc
3684      return this.status;
3685    }
3686
3687    public boolean hasStatus() {
3688      return this.status != null && !this.status.isEmpty();
3689    }
3690
3691    /**
3692     * @param value {@link #status} (The status of the name.)
3693     */
3694    public SubstanceSpecificationNameComponent setStatus(CodeableConcept value) {
3695      this.status = value;
3696      return this;
3697    }
3698
3699    /**
3700     * @return {@link #preferred} (If this is the preferred name for this
3701     *         substance.). This is the underlying object with id, value and
3702     *         extensions. The accessor "getPreferred" gives direct access to the
3703     *         value
3704     */
3705    public BooleanType getPreferredElement() {
3706      if (this.preferred == null)
3707        if (Configuration.errorOnAutoCreate())
3708          throw new Error("Attempt to auto-create SubstanceSpecificationNameComponent.preferred");
3709        else if (Configuration.doAutoCreate())
3710          this.preferred = new BooleanType(); // bb
3711      return this.preferred;
3712    }
3713
3714    public boolean hasPreferredElement() {
3715      return this.preferred != null && !this.preferred.isEmpty();
3716    }
3717
3718    public boolean hasPreferred() {
3719      return this.preferred != null && !this.preferred.isEmpty();
3720    }
3721
3722    /**
3723     * @param value {@link #preferred} (If this is the preferred name for this
3724     *              substance.). This is the underlying object with id, value and
3725     *              extensions. The accessor "getPreferred" gives direct access to
3726     *              the value
3727     */
3728    public SubstanceSpecificationNameComponent setPreferredElement(BooleanType value) {
3729      this.preferred = value;
3730      return this;
3731    }
3732
3733    /**
3734     * @return If this is the preferred name for this substance.
3735     */
3736    public boolean getPreferred() {
3737      return this.preferred == null || this.preferred.isEmpty() ? false : this.preferred.getValue();
3738    }
3739
3740    /**
3741     * @param value If this is the preferred name for this substance.
3742     */
3743    public SubstanceSpecificationNameComponent setPreferred(boolean value) {
3744      if (this.preferred == null)
3745        this.preferred = new BooleanType();
3746      this.preferred.setValue(value);
3747      return this;
3748    }
3749
3750    /**
3751     * @return {@link #language} (Language of the name.)
3752     */
3753    public List<CodeableConcept> getLanguage() {
3754      if (this.language == null)
3755        this.language = new ArrayList<CodeableConcept>();
3756      return this.language;
3757    }
3758
3759    /**
3760     * @return Returns a reference to <code>this</code> for easy method chaining
3761     */
3762    public SubstanceSpecificationNameComponent setLanguage(List<CodeableConcept> theLanguage) {
3763      this.language = theLanguage;
3764      return this;
3765    }
3766
3767    public boolean hasLanguage() {
3768      if (this.language == null)
3769        return false;
3770      for (CodeableConcept item : this.language)
3771        if (!item.isEmpty())
3772          return true;
3773      return false;
3774    }
3775
3776    public CodeableConcept addLanguage() { // 3
3777      CodeableConcept t = new CodeableConcept();
3778      if (this.language == null)
3779        this.language = new ArrayList<CodeableConcept>();
3780      this.language.add(t);
3781      return t;
3782    }
3783
3784    public SubstanceSpecificationNameComponent addLanguage(CodeableConcept t) { // 3
3785      if (t == null)
3786        return this;
3787      if (this.language == null)
3788        this.language = new ArrayList<CodeableConcept>();
3789      this.language.add(t);
3790      return this;
3791    }
3792
3793    /**
3794     * @return The first repetition of repeating field {@link #language}, creating
3795     *         it if it does not already exist
3796     */
3797    public CodeableConcept getLanguageFirstRep() {
3798      if (getLanguage().isEmpty()) {
3799        addLanguage();
3800      }
3801      return getLanguage().get(0);
3802    }
3803
3804    /**
3805     * @return {@link #domain} (The use context of this name for example if there is
3806     *         a different name a drug active ingredient as opposed to a food colour
3807     *         additive.)
3808     */
3809    public List<CodeableConcept> getDomain() {
3810      if (this.domain == null)
3811        this.domain = new ArrayList<CodeableConcept>();
3812      return this.domain;
3813    }
3814
3815    /**
3816     * @return Returns a reference to <code>this</code> for easy method chaining
3817     */
3818    public SubstanceSpecificationNameComponent setDomain(List<CodeableConcept> theDomain) {
3819      this.domain = theDomain;
3820      return this;
3821    }
3822
3823    public boolean hasDomain() {
3824      if (this.domain == null)
3825        return false;
3826      for (CodeableConcept item : this.domain)
3827        if (!item.isEmpty())
3828          return true;
3829      return false;
3830    }
3831
3832    public CodeableConcept addDomain() { // 3
3833      CodeableConcept t = new CodeableConcept();
3834      if (this.domain == null)
3835        this.domain = new ArrayList<CodeableConcept>();
3836      this.domain.add(t);
3837      return t;
3838    }
3839
3840    public SubstanceSpecificationNameComponent addDomain(CodeableConcept t) { // 3
3841      if (t == null)
3842        return this;
3843      if (this.domain == null)
3844        this.domain = new ArrayList<CodeableConcept>();
3845      this.domain.add(t);
3846      return this;
3847    }
3848
3849    /**
3850     * @return The first repetition of repeating field {@link #domain}, creating it
3851     *         if it does not already exist
3852     */
3853    public CodeableConcept getDomainFirstRep() {
3854      if (getDomain().isEmpty()) {
3855        addDomain();
3856      }
3857      return getDomain().get(0);
3858    }
3859
3860    /**
3861     * @return {@link #jurisdiction} (The jurisdiction where this name applies.)
3862     */
3863    public List<CodeableConcept> getJurisdiction() {
3864      if (this.jurisdiction == null)
3865        this.jurisdiction = new ArrayList<CodeableConcept>();
3866      return this.jurisdiction;
3867    }
3868
3869    /**
3870     * @return Returns a reference to <code>this</code> for easy method chaining
3871     */
3872    public SubstanceSpecificationNameComponent setJurisdiction(List<CodeableConcept> theJurisdiction) {
3873      this.jurisdiction = theJurisdiction;
3874      return this;
3875    }
3876
3877    public boolean hasJurisdiction() {
3878      if (this.jurisdiction == null)
3879        return false;
3880      for (CodeableConcept item : this.jurisdiction)
3881        if (!item.isEmpty())
3882          return true;
3883      return false;
3884    }
3885
3886    public CodeableConcept addJurisdiction() { // 3
3887      CodeableConcept t = new CodeableConcept();
3888      if (this.jurisdiction == null)
3889        this.jurisdiction = new ArrayList<CodeableConcept>();
3890      this.jurisdiction.add(t);
3891      return t;
3892    }
3893
3894    public SubstanceSpecificationNameComponent addJurisdiction(CodeableConcept t) { // 3
3895      if (t == null)
3896        return this;
3897      if (this.jurisdiction == null)
3898        this.jurisdiction = new ArrayList<CodeableConcept>();
3899      this.jurisdiction.add(t);
3900      return this;
3901    }
3902
3903    /**
3904     * @return The first repetition of repeating field {@link #jurisdiction},
3905     *         creating it if it does not already exist
3906     */
3907    public CodeableConcept getJurisdictionFirstRep() {
3908      if (getJurisdiction().isEmpty()) {
3909        addJurisdiction();
3910      }
3911      return getJurisdiction().get(0);
3912    }
3913
3914    /**
3915     * @return {@link #synonym} (A synonym of this name.)
3916     */
3917    public List<SubstanceSpecificationNameComponent> getSynonym() {
3918      if (this.synonym == null)
3919        this.synonym = new ArrayList<SubstanceSpecificationNameComponent>();
3920      return this.synonym;
3921    }
3922
3923    /**
3924     * @return Returns a reference to <code>this</code> for easy method chaining
3925     */
3926    public SubstanceSpecificationNameComponent setSynonym(List<SubstanceSpecificationNameComponent> theSynonym) {
3927      this.synonym = theSynonym;
3928      return this;
3929    }
3930
3931    public boolean hasSynonym() {
3932      if (this.synonym == null)
3933        return false;
3934      for (SubstanceSpecificationNameComponent item : this.synonym)
3935        if (!item.isEmpty())
3936          return true;
3937      return false;
3938    }
3939
3940    public SubstanceSpecificationNameComponent addSynonym() { // 3
3941      SubstanceSpecificationNameComponent t = new SubstanceSpecificationNameComponent();
3942      if (this.synonym == null)
3943        this.synonym = new ArrayList<SubstanceSpecificationNameComponent>();
3944      this.synonym.add(t);
3945      return t;
3946    }
3947
3948    public SubstanceSpecificationNameComponent addSynonym(SubstanceSpecificationNameComponent t) { // 3
3949      if (t == null)
3950        return this;
3951      if (this.synonym == null)
3952        this.synonym = new ArrayList<SubstanceSpecificationNameComponent>();
3953      this.synonym.add(t);
3954      return this;
3955    }
3956
3957    /**
3958     * @return The first repetition of repeating field {@link #synonym}, creating it
3959     *         if it does not already exist
3960     */
3961    public SubstanceSpecificationNameComponent getSynonymFirstRep() {
3962      if (getSynonym().isEmpty()) {
3963        addSynonym();
3964      }
3965      return getSynonym().get(0);
3966    }
3967
3968    /**
3969     * @return {@link #translation} (A translation for this name.)
3970     */
3971    public List<SubstanceSpecificationNameComponent> getTranslation() {
3972      if (this.translation == null)
3973        this.translation = new ArrayList<SubstanceSpecificationNameComponent>();
3974      return this.translation;
3975    }
3976
3977    /**
3978     * @return Returns a reference to <code>this</code> for easy method chaining
3979     */
3980    public SubstanceSpecificationNameComponent setTranslation(
3981        List<SubstanceSpecificationNameComponent> theTranslation) {
3982      this.translation = theTranslation;
3983      return this;
3984    }
3985
3986    public boolean hasTranslation() {
3987      if (this.translation == null)
3988        return false;
3989      for (SubstanceSpecificationNameComponent item : this.translation)
3990        if (!item.isEmpty())
3991          return true;
3992      return false;
3993    }
3994
3995    public SubstanceSpecificationNameComponent addTranslation() { // 3
3996      SubstanceSpecificationNameComponent t = new SubstanceSpecificationNameComponent();
3997      if (this.translation == null)
3998        this.translation = new ArrayList<SubstanceSpecificationNameComponent>();
3999      this.translation.add(t);
4000      return t;
4001    }
4002
4003    public SubstanceSpecificationNameComponent addTranslation(SubstanceSpecificationNameComponent t) { // 3
4004      if (t == null)
4005        return this;
4006      if (this.translation == null)
4007        this.translation = new ArrayList<SubstanceSpecificationNameComponent>();
4008      this.translation.add(t);
4009      return this;
4010    }
4011
4012    /**
4013     * @return The first repetition of repeating field {@link #translation},
4014     *         creating it if it does not already exist
4015     */
4016    public SubstanceSpecificationNameComponent getTranslationFirstRep() {
4017      if (getTranslation().isEmpty()) {
4018        addTranslation();
4019      }
4020      return getTranslation().get(0);
4021    }
4022
4023    /**
4024     * @return {@link #official} (Details of the official nature of this name.)
4025     */
4026    public List<SubstanceSpecificationNameOfficialComponent> getOfficial() {
4027      if (this.official == null)
4028        this.official = new ArrayList<SubstanceSpecificationNameOfficialComponent>();
4029      return this.official;
4030    }
4031
4032    /**
4033     * @return Returns a reference to <code>this</code> for easy method chaining
4034     */
4035    public SubstanceSpecificationNameComponent setOfficial(
4036        List<SubstanceSpecificationNameOfficialComponent> theOfficial) {
4037      this.official = theOfficial;
4038      return this;
4039    }
4040
4041    public boolean hasOfficial() {
4042      if (this.official == null)
4043        return false;
4044      for (SubstanceSpecificationNameOfficialComponent item : this.official)
4045        if (!item.isEmpty())
4046          return true;
4047      return false;
4048    }
4049
4050    public SubstanceSpecificationNameOfficialComponent addOfficial() { // 3
4051      SubstanceSpecificationNameOfficialComponent t = new SubstanceSpecificationNameOfficialComponent();
4052      if (this.official == null)
4053        this.official = new ArrayList<SubstanceSpecificationNameOfficialComponent>();
4054      this.official.add(t);
4055      return t;
4056    }
4057
4058    public SubstanceSpecificationNameComponent addOfficial(SubstanceSpecificationNameOfficialComponent t) { // 3
4059      if (t == null)
4060        return this;
4061      if (this.official == null)
4062        this.official = new ArrayList<SubstanceSpecificationNameOfficialComponent>();
4063      this.official.add(t);
4064      return this;
4065    }
4066
4067    /**
4068     * @return The first repetition of repeating field {@link #official}, creating
4069     *         it if it does not already exist
4070     */
4071    public SubstanceSpecificationNameOfficialComponent getOfficialFirstRep() {
4072      if (getOfficial().isEmpty()) {
4073        addOfficial();
4074      }
4075      return getOfficial().get(0);
4076    }
4077
4078    /**
4079     * @return {@link #source} (Supporting literature.)
4080     */
4081    public List<Reference> getSource() {
4082      if (this.source == null)
4083        this.source = new ArrayList<Reference>();
4084      return this.source;
4085    }
4086
4087    /**
4088     * @return Returns a reference to <code>this</code> for easy method chaining
4089     */
4090    public SubstanceSpecificationNameComponent setSource(List<Reference> theSource) {
4091      this.source = theSource;
4092      return this;
4093    }
4094
4095    public boolean hasSource() {
4096      if (this.source == null)
4097        return false;
4098      for (Reference item : this.source)
4099        if (!item.isEmpty())
4100          return true;
4101      return false;
4102    }
4103
4104    public Reference addSource() { // 3
4105      Reference t = new Reference();
4106      if (this.source == null)
4107        this.source = new ArrayList<Reference>();
4108      this.source.add(t);
4109      return t;
4110    }
4111
4112    public SubstanceSpecificationNameComponent addSource(Reference t) { // 3
4113      if (t == null)
4114        return this;
4115      if (this.source == null)
4116        this.source = new ArrayList<Reference>();
4117      this.source.add(t);
4118      return this;
4119    }
4120
4121    /**
4122     * @return The first repetition of repeating field {@link #source}, creating it
4123     *         if it does not already exist
4124     */
4125    public Reference getSourceFirstRep() {
4126      if (getSource().isEmpty()) {
4127        addSource();
4128      }
4129      return getSource().get(0);
4130    }
4131
4132    /**
4133     * @deprecated Use Reference#setResource(IBaseResource) instead
4134     */
4135    @Deprecated
4136    public List<DocumentReference> getSourceTarget() {
4137      if (this.sourceTarget == null)
4138        this.sourceTarget = new ArrayList<DocumentReference>();
4139      return this.sourceTarget;
4140    }
4141
4142    /**
4143     * @deprecated Use Reference#setResource(IBaseResource) instead
4144     */
4145    @Deprecated
4146    public DocumentReference addSourceTarget() {
4147      DocumentReference r = new DocumentReference();
4148      if (this.sourceTarget == null)
4149        this.sourceTarget = new ArrayList<DocumentReference>();
4150      this.sourceTarget.add(r);
4151      return r;
4152    }
4153
4154    protected void listChildren(List<Property> children) {
4155      super.listChildren(children);
4156      children.add(new Property("name", "string", "The actual name.", 0, 1, name));
4157      children.add(new Property("type", "CodeableConcept", "Name type.", 0, 1, type));
4158      children.add(new Property("status", "CodeableConcept", "The status of the name.", 0, 1, status));
4159      children.add(
4160          new Property("preferred", "boolean", "If this is the preferred name for this substance.", 0, 1, preferred));
4161      children.add(new Property("language", "CodeableConcept", "Language of the name.", 0, java.lang.Integer.MAX_VALUE,
4162          language));
4163      children.add(new Property("domain", "CodeableConcept",
4164          "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.",
4165          0, java.lang.Integer.MAX_VALUE, domain));
4166      children.add(new Property("jurisdiction", "CodeableConcept", "The jurisdiction where this name applies.", 0,
4167          java.lang.Integer.MAX_VALUE, jurisdiction));
4168      children.add(new Property("synonym", "@SubstanceSpecification.name", "A synonym of this name.", 0,
4169          java.lang.Integer.MAX_VALUE, synonym));
4170      children.add(new Property("translation", "@SubstanceSpecification.name", "A translation for this name.", 0,
4171          java.lang.Integer.MAX_VALUE, translation));
4172      children.add(new Property("official", "", "Details of the official nature of this name.", 0,
4173          java.lang.Integer.MAX_VALUE, official));
4174      children.add(new Property("source", "Reference(DocumentReference)", "Supporting literature.", 0,
4175          java.lang.Integer.MAX_VALUE, source));
4176    }
4177
4178    @Override
4179    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
4180      switch (_hash) {
4181      case 3373707:
4182        /* name */ return new Property("name", "string", "The actual name.", 0, 1, name);
4183      case 3575610:
4184        /* type */ return new Property("type", "CodeableConcept", "Name type.", 0, 1, type);
4185      case -892481550:
4186        /* status */ return new Property("status", "CodeableConcept", "The status of the name.", 0, 1, status);
4187      case -1294005119:
4188        /* preferred */ return new Property("preferred", "boolean", "If this is the preferred name for this substance.",
4189            0, 1, preferred);
4190      case -1613589672:
4191        /* language */ return new Property("language", "CodeableConcept", "Language of the name.", 0,
4192            java.lang.Integer.MAX_VALUE, language);
4193      case -1326197564:
4194        /* domain */ return new Property("domain", "CodeableConcept",
4195            "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.",
4196            0, java.lang.Integer.MAX_VALUE, domain);
4197      case -507075711:
4198        /* jurisdiction */ return new Property("jurisdiction", "CodeableConcept",
4199            "The jurisdiction where this name applies.", 0, java.lang.Integer.MAX_VALUE, jurisdiction);
4200      case -1742128133:
4201        /* synonym */ return new Property("synonym", "@SubstanceSpecification.name", "A synonym of this name.", 0,
4202            java.lang.Integer.MAX_VALUE, synonym);
4203      case -1840647503:
4204        /* translation */ return new Property("translation", "@SubstanceSpecification.name",
4205            "A translation for this name.", 0, java.lang.Integer.MAX_VALUE, translation);
4206      case -765289749:
4207        /* official */ return new Property("official", "", "Details of the official nature of this name.", 0,
4208            java.lang.Integer.MAX_VALUE, official);
4209      case -896505829:
4210        /* source */ return new Property("source", "Reference(DocumentReference)", "Supporting literature.", 0,
4211            java.lang.Integer.MAX_VALUE, source);
4212      default:
4213        return super.getNamedProperty(_hash, _name, _checkValid);
4214      }
4215
4216    }
4217
4218    @Override
4219    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
4220      switch (hash) {
4221      case 3373707:
4222        /* name */ return this.name == null ? new Base[0] : new Base[] { this.name }; // StringType
4223      case 3575610:
4224        /* type */ return this.type == null ? new Base[0] : new Base[] { this.type }; // CodeableConcept
4225      case -892481550:
4226        /* status */ return this.status == null ? new Base[0] : new Base[] { this.status }; // CodeableConcept
4227      case -1294005119:
4228        /* preferred */ return this.preferred == null ? new Base[0] : new Base[] { this.preferred }; // BooleanType
4229      case -1613589672:
4230        /* language */ return this.language == null ? new Base[0]
4231            : this.language.toArray(new Base[this.language.size()]); // CodeableConcept
4232      case -1326197564:
4233        /* domain */ return this.domain == null ? new Base[0] : this.domain.toArray(new Base[this.domain.size()]); // CodeableConcept
4234      case -507075711:
4235        /* jurisdiction */ return this.jurisdiction == null ? new Base[0]
4236            : this.jurisdiction.toArray(new Base[this.jurisdiction.size()]); // CodeableConcept
4237      case -1742128133:
4238        /* synonym */ return this.synonym == null ? new Base[0] : this.synonym.toArray(new Base[this.synonym.size()]); // SubstanceSpecificationNameComponent
4239      case -1840647503:
4240        /* translation */ return this.translation == null ? new Base[0]
4241            : this.translation.toArray(new Base[this.translation.size()]); // SubstanceSpecificationNameComponent
4242      case -765289749:
4243        /* official */ return this.official == null ? new Base[0]
4244            : this.official.toArray(new Base[this.official.size()]); // SubstanceSpecificationNameOfficialComponent
4245      case -896505829:
4246        /* source */ return this.source == null ? new Base[0] : this.source.toArray(new Base[this.source.size()]); // Reference
4247      default:
4248        return super.getProperty(hash, name, checkValid);
4249      }
4250
4251    }
4252
4253    @Override
4254    public Base setProperty(int hash, String name, Base value) throws FHIRException {
4255      switch (hash) {
4256      case 3373707: // name
4257        this.name = castToString(value); // StringType
4258        return value;
4259      case 3575610: // type
4260        this.type = castToCodeableConcept(value); // CodeableConcept
4261        return value;
4262      case -892481550: // status
4263        this.status = castToCodeableConcept(value); // CodeableConcept
4264        return value;
4265      case -1294005119: // preferred
4266        this.preferred = castToBoolean(value); // BooleanType
4267        return value;
4268      case -1613589672: // language
4269        this.getLanguage().add(castToCodeableConcept(value)); // CodeableConcept
4270        return value;
4271      case -1326197564: // domain
4272        this.getDomain().add(castToCodeableConcept(value)); // CodeableConcept
4273        return value;
4274      case -507075711: // jurisdiction
4275        this.getJurisdiction().add(castToCodeableConcept(value)); // CodeableConcept
4276        return value;
4277      case -1742128133: // synonym
4278        this.getSynonym().add((SubstanceSpecificationNameComponent) value); // SubstanceSpecificationNameComponent
4279        return value;
4280      case -1840647503: // translation
4281        this.getTranslation().add((SubstanceSpecificationNameComponent) value); // SubstanceSpecificationNameComponent
4282        return value;
4283      case -765289749: // official
4284        this.getOfficial().add((SubstanceSpecificationNameOfficialComponent) value); // SubstanceSpecificationNameOfficialComponent
4285        return value;
4286      case -896505829: // source
4287        this.getSource().add(castToReference(value)); // Reference
4288        return value;
4289      default:
4290        return super.setProperty(hash, name, value);
4291      }
4292
4293    }
4294
4295    @Override
4296    public Base setProperty(String name, Base value) throws FHIRException {
4297      if (name.equals("name")) {
4298        this.name = castToString(value); // StringType
4299      } else if (name.equals("type")) {
4300        this.type = castToCodeableConcept(value); // CodeableConcept
4301      } else if (name.equals("status")) {
4302        this.status = castToCodeableConcept(value); // CodeableConcept
4303      } else if (name.equals("preferred")) {
4304        this.preferred = castToBoolean(value); // BooleanType
4305      } else if (name.equals("language")) {
4306        this.getLanguage().add(castToCodeableConcept(value));
4307      } else if (name.equals("domain")) {
4308        this.getDomain().add(castToCodeableConcept(value));
4309      } else if (name.equals("jurisdiction")) {
4310        this.getJurisdiction().add(castToCodeableConcept(value));
4311      } else if (name.equals("synonym")) {
4312        this.getSynonym().add((SubstanceSpecificationNameComponent) value);
4313      } else if (name.equals("translation")) {
4314        this.getTranslation().add((SubstanceSpecificationNameComponent) value);
4315      } else if (name.equals("official")) {
4316        this.getOfficial().add((SubstanceSpecificationNameOfficialComponent) value);
4317      } else if (name.equals("source")) {
4318        this.getSource().add(castToReference(value));
4319      } else
4320        return super.setProperty(name, value);
4321      return value;
4322    }
4323
4324  @Override
4325  public void removeChild(String name, Base value) throws FHIRException {
4326      if (name.equals("name")) {
4327        this.name = null;
4328      } else if (name.equals("type")) {
4329        this.type = null;
4330      } else if (name.equals("status")) {
4331        this.status = null;
4332      } else if (name.equals("preferred")) {
4333        this.preferred = null;
4334      } else if (name.equals("language")) {
4335        this.getLanguage().remove(castToCodeableConcept(value));
4336      } else if (name.equals("domain")) {
4337        this.getDomain().remove(castToCodeableConcept(value));
4338      } else if (name.equals("jurisdiction")) {
4339        this.getJurisdiction().remove(castToCodeableConcept(value));
4340      } else if (name.equals("synonym")) {
4341        this.getSynonym().remove((SubstanceSpecificationNameComponent) value);
4342      } else if (name.equals("translation")) {
4343        this.getTranslation().remove((SubstanceSpecificationNameComponent) value);
4344      } else if (name.equals("official")) {
4345        this.getOfficial().remove((SubstanceSpecificationNameOfficialComponent) value);
4346      } else if (name.equals("source")) {
4347        this.getSource().remove(castToReference(value));
4348      } else
4349        super.removeChild(name, value);
4350      
4351    }
4352
4353    @Override
4354    public Base makeProperty(int hash, String name) throws FHIRException {
4355      switch (hash) {
4356      case 3373707:
4357        return getNameElement();
4358      case 3575610:
4359        return getType();
4360      case -892481550:
4361        return getStatus();
4362      case -1294005119:
4363        return getPreferredElement();
4364      case -1613589672:
4365        return addLanguage();
4366      case -1326197564:
4367        return addDomain();
4368      case -507075711:
4369        return addJurisdiction();
4370      case -1742128133:
4371        return addSynonym();
4372      case -1840647503:
4373        return addTranslation();
4374      case -765289749:
4375        return addOfficial();
4376      case -896505829:
4377        return addSource();
4378      default:
4379        return super.makeProperty(hash, name);
4380      }
4381
4382    }
4383
4384    @Override
4385    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
4386      switch (hash) {
4387      case 3373707:
4388        /* name */ return new String[] { "string" };
4389      case 3575610:
4390        /* type */ return new String[] { "CodeableConcept" };
4391      case -892481550:
4392        /* status */ return new String[] { "CodeableConcept" };
4393      case -1294005119:
4394        /* preferred */ return new String[] { "boolean" };
4395      case -1613589672:
4396        /* language */ return new String[] { "CodeableConcept" };
4397      case -1326197564:
4398        /* domain */ return new String[] { "CodeableConcept" };
4399      case -507075711:
4400        /* jurisdiction */ return new String[] { "CodeableConcept" };
4401      case -1742128133:
4402        /* synonym */ return new String[] { "@SubstanceSpecification.name" };
4403      case -1840647503:
4404        /* translation */ return new String[] { "@SubstanceSpecification.name" };
4405      case -765289749:
4406        /* official */ return new String[] {};
4407      case -896505829:
4408        /* source */ return new String[] { "Reference" };
4409      default:
4410        return super.getTypesForProperty(hash, name);
4411      }
4412
4413    }
4414
4415    @Override
4416    public Base addChild(String name) throws FHIRException {
4417      if (name.equals("name")) {
4418        throw new FHIRException("Cannot call addChild on a singleton property SubstanceSpecification.name");
4419      } else if (name.equals("type")) {
4420        this.type = new CodeableConcept();
4421        return this.type;
4422      } else if (name.equals("status")) {
4423        this.status = new CodeableConcept();
4424        return this.status;
4425      } else if (name.equals("preferred")) {
4426        throw new FHIRException("Cannot call addChild on a singleton property SubstanceSpecification.preferred");
4427      } else if (name.equals("language")) {
4428        return addLanguage();
4429      } else if (name.equals("domain")) {
4430        return addDomain();
4431      } else if (name.equals("jurisdiction")) {
4432        return addJurisdiction();
4433      } else if (name.equals("synonym")) {
4434        return addSynonym();
4435      } else if (name.equals("translation")) {
4436        return addTranslation();
4437      } else if (name.equals("official")) {
4438        return addOfficial();
4439      } else if (name.equals("source")) {
4440        return addSource();
4441      } else
4442        return super.addChild(name);
4443    }
4444
4445    public SubstanceSpecificationNameComponent copy() {
4446      SubstanceSpecificationNameComponent dst = new SubstanceSpecificationNameComponent();
4447      copyValues(dst);
4448      return dst;
4449    }
4450
4451    public void copyValues(SubstanceSpecificationNameComponent dst) {
4452      super.copyValues(dst);
4453      dst.name = name == null ? null : name.copy();
4454      dst.type = type == null ? null : type.copy();
4455      dst.status = status == null ? null : status.copy();
4456      dst.preferred = preferred == null ? null : preferred.copy();
4457      if (language != null) {
4458        dst.language = new ArrayList<CodeableConcept>();
4459        for (CodeableConcept i : language)
4460          dst.language.add(i.copy());
4461      }
4462      ;
4463      if (domain != null) {
4464        dst.domain = new ArrayList<CodeableConcept>();
4465        for (CodeableConcept i : domain)
4466          dst.domain.add(i.copy());
4467      }
4468      ;
4469      if (jurisdiction != null) {
4470        dst.jurisdiction = new ArrayList<CodeableConcept>();
4471        for (CodeableConcept i : jurisdiction)
4472          dst.jurisdiction.add(i.copy());
4473      }
4474      ;
4475      if (synonym != null) {
4476        dst.synonym = new ArrayList<SubstanceSpecificationNameComponent>();
4477        for (SubstanceSpecificationNameComponent i : synonym)
4478          dst.synonym.add(i.copy());
4479      }
4480      ;
4481      if (translation != null) {
4482        dst.translation = new ArrayList<SubstanceSpecificationNameComponent>();
4483        for (SubstanceSpecificationNameComponent i : translation)
4484          dst.translation.add(i.copy());
4485      }
4486      ;
4487      if (official != null) {
4488        dst.official = new ArrayList<SubstanceSpecificationNameOfficialComponent>();
4489        for (SubstanceSpecificationNameOfficialComponent i : official)
4490          dst.official.add(i.copy());
4491      }
4492      ;
4493      if (source != null) {
4494        dst.source = new ArrayList<Reference>();
4495        for (Reference i : source)
4496          dst.source.add(i.copy());
4497      }
4498      ;
4499    }
4500
4501    @Override
4502    public boolean equalsDeep(Base other_) {
4503      if (!super.equalsDeep(other_))
4504        return false;
4505      if (!(other_ instanceof SubstanceSpecificationNameComponent))
4506        return false;
4507      SubstanceSpecificationNameComponent o = (SubstanceSpecificationNameComponent) other_;
4508      return compareDeep(name, o.name, true) && compareDeep(type, o.type, true) && compareDeep(status, o.status, true)
4509          && compareDeep(preferred, o.preferred, true) && compareDeep(language, o.language, true)
4510          && compareDeep(domain, o.domain, true) && compareDeep(jurisdiction, o.jurisdiction, true)
4511          && compareDeep(synonym, o.synonym, true) && compareDeep(translation, o.translation, true)
4512          && compareDeep(official, o.official, true) && compareDeep(source, o.source, true);
4513    }
4514
4515    @Override
4516    public boolean equalsShallow(Base other_) {
4517      if (!super.equalsShallow(other_))
4518        return false;
4519      if (!(other_ instanceof SubstanceSpecificationNameComponent))
4520        return false;
4521      SubstanceSpecificationNameComponent o = (SubstanceSpecificationNameComponent) other_;
4522      return compareValues(name, o.name, true) && compareValues(preferred, o.preferred, true);
4523    }
4524
4525    public boolean isEmpty() {
4526      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(name, type, status, preferred, language, domain,
4527          jurisdiction, synonym, translation, official, source);
4528    }
4529
4530    public String fhirType() {
4531      return "SubstanceSpecification.name";
4532
4533    }
4534
4535  }
4536
4537  @Block()
4538  public static class SubstanceSpecificationNameOfficialComponent extends BackboneElement
4539      implements IBaseBackboneElement {
4540    /**
4541     * Which authority uses this official name.
4542     */
4543    @Child(name = "authority", type = {
4544        CodeableConcept.class }, order = 1, min = 0, max = 1, modifier = false, summary = true)
4545    @Description(shortDefinition = "Which authority uses this official name", formalDefinition = "Which authority uses this official name.")
4546    protected CodeableConcept authority;
4547
4548    /**
4549     * The status of the official name.
4550     */
4551    @Child(name = "status", type = {
4552        CodeableConcept.class }, order = 2, min = 0, max = 1, modifier = false, summary = true)
4553    @Description(shortDefinition = "The status of the official name", formalDefinition = "The status of the official name.")
4554    protected CodeableConcept status;
4555
4556    /**
4557     * Date of official name change.
4558     */
4559    @Child(name = "date", type = { DateTimeType.class }, order = 3, min = 0, max = 1, modifier = false, summary = true)
4560    @Description(shortDefinition = "Date of official name change", formalDefinition = "Date of official name change.")
4561    protected DateTimeType date;
4562
4563    private static final long serialVersionUID = -2040011008L;
4564
4565    /**
4566     * Constructor
4567     */
4568    public SubstanceSpecificationNameOfficialComponent() {
4569      super();
4570    }
4571
4572    /**
4573     * @return {@link #authority} (Which authority uses this official name.)
4574     */
4575    public CodeableConcept getAuthority() {
4576      if (this.authority == null)
4577        if (Configuration.errorOnAutoCreate())
4578          throw new Error("Attempt to auto-create SubstanceSpecificationNameOfficialComponent.authority");
4579        else if (Configuration.doAutoCreate())
4580          this.authority = new CodeableConcept(); // cc
4581      return this.authority;
4582    }
4583
4584    public boolean hasAuthority() {
4585      return this.authority != null && !this.authority.isEmpty();
4586    }
4587
4588    /**
4589     * @param value {@link #authority} (Which authority uses this official name.)
4590     */
4591    public SubstanceSpecificationNameOfficialComponent setAuthority(CodeableConcept value) {
4592      this.authority = value;
4593      return this;
4594    }
4595
4596    /**
4597     * @return {@link #status} (The status of the official name.)
4598     */
4599    public CodeableConcept getStatus() {
4600      if (this.status == null)
4601        if (Configuration.errorOnAutoCreate())
4602          throw new Error("Attempt to auto-create SubstanceSpecificationNameOfficialComponent.status");
4603        else if (Configuration.doAutoCreate())
4604          this.status = new CodeableConcept(); // cc
4605      return this.status;
4606    }
4607
4608    public boolean hasStatus() {
4609      return this.status != null && !this.status.isEmpty();
4610    }
4611
4612    /**
4613     * @param value {@link #status} (The status of the official name.)
4614     */
4615    public SubstanceSpecificationNameOfficialComponent setStatus(CodeableConcept value) {
4616      this.status = value;
4617      return this;
4618    }
4619
4620    /**
4621     * @return {@link #date} (Date of official name change.). This is the underlying
4622     *         object with id, value and extensions. The accessor "getDate" gives
4623     *         direct access to the value
4624     */
4625    public DateTimeType getDateElement() {
4626      if (this.date == null)
4627        if (Configuration.errorOnAutoCreate())
4628          throw new Error("Attempt to auto-create SubstanceSpecificationNameOfficialComponent.date");
4629        else if (Configuration.doAutoCreate())
4630          this.date = new DateTimeType(); // bb
4631      return this.date;
4632    }
4633
4634    public boolean hasDateElement() {
4635      return this.date != null && !this.date.isEmpty();
4636    }
4637
4638    public boolean hasDate() {
4639      return this.date != null && !this.date.isEmpty();
4640    }
4641
4642    /**
4643     * @param value {@link #date} (Date of official name change.). This is the
4644     *              underlying object with id, value and extensions. The accessor
4645     *              "getDate" gives direct access to the value
4646     */
4647    public SubstanceSpecificationNameOfficialComponent setDateElement(DateTimeType value) {
4648      this.date = value;
4649      return this;
4650    }
4651
4652    /**
4653     * @return Date of official name change.
4654     */
4655    public Date getDate() {
4656      return this.date == null ? null : this.date.getValue();
4657    }
4658
4659    /**
4660     * @param value Date of official name change.
4661     */
4662    public SubstanceSpecificationNameOfficialComponent setDate(Date value) {
4663      if (value == null)
4664        this.date = null;
4665      else {
4666        if (this.date == null)
4667          this.date = new DateTimeType();
4668        this.date.setValue(value);
4669      }
4670      return this;
4671    }
4672
4673    protected void listChildren(List<Property> children) {
4674      super.listChildren(children);
4675      children.add(
4676          new Property("authority", "CodeableConcept", "Which authority uses this official name.", 0, 1, authority));
4677      children.add(new Property("status", "CodeableConcept", "The status of the official name.", 0, 1, status));
4678      children.add(new Property("date", "dateTime", "Date of official name change.", 0, 1, date));
4679    }
4680
4681    @Override
4682    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
4683      switch (_hash) {
4684      case 1475610435:
4685        /* authority */ return new Property("authority", "CodeableConcept", "Which authority uses this official name.",
4686            0, 1, authority);
4687      case -892481550:
4688        /* status */ return new Property("status", "CodeableConcept", "The status of the official name.", 0, 1, status);
4689      case 3076014:
4690        /* date */ return new Property("date", "dateTime", "Date of official name change.", 0, 1, date);
4691      default:
4692        return super.getNamedProperty(_hash, _name, _checkValid);
4693      }
4694
4695    }
4696
4697    @Override
4698    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
4699      switch (hash) {
4700      case 1475610435:
4701        /* authority */ return this.authority == null ? new Base[0] : new Base[] { this.authority }; // CodeableConcept
4702      case -892481550:
4703        /* status */ return this.status == null ? new Base[0] : new Base[] { this.status }; // CodeableConcept
4704      case 3076014:
4705        /* date */ return this.date == null ? new Base[0] : new Base[] { this.date }; // DateTimeType
4706      default:
4707        return super.getProperty(hash, name, checkValid);
4708      }
4709
4710    }
4711
4712    @Override
4713    public Base setProperty(int hash, String name, Base value) throws FHIRException {
4714      switch (hash) {
4715      case 1475610435: // authority
4716        this.authority = castToCodeableConcept(value); // CodeableConcept
4717        return value;
4718      case -892481550: // status
4719        this.status = castToCodeableConcept(value); // CodeableConcept
4720        return value;
4721      case 3076014: // date
4722        this.date = castToDateTime(value); // DateTimeType
4723        return value;
4724      default:
4725        return super.setProperty(hash, name, value);
4726      }
4727
4728    }
4729
4730    @Override
4731    public Base setProperty(String name, Base value) throws FHIRException {
4732      if (name.equals("authority")) {
4733        this.authority = castToCodeableConcept(value); // CodeableConcept
4734      } else if (name.equals("status")) {
4735        this.status = castToCodeableConcept(value); // CodeableConcept
4736      } else if (name.equals("date")) {
4737        this.date = castToDateTime(value); // DateTimeType
4738      } else
4739        return super.setProperty(name, value);
4740      return value;
4741    }
4742
4743  @Override
4744  public void removeChild(String name, Base value) throws FHIRException {
4745      if (name.equals("authority")) {
4746        this.authority = null;
4747      } else if (name.equals("status")) {
4748        this.status = null;
4749      } else if (name.equals("date")) {
4750        this.date = null;
4751      } else
4752        super.removeChild(name, value);
4753      
4754    }
4755
4756    @Override
4757    public Base makeProperty(int hash, String name) throws FHIRException {
4758      switch (hash) {
4759      case 1475610435:
4760        return getAuthority();
4761      case -892481550:
4762        return getStatus();
4763      case 3076014:
4764        return getDateElement();
4765      default:
4766        return super.makeProperty(hash, name);
4767      }
4768
4769    }
4770
4771    @Override
4772    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
4773      switch (hash) {
4774      case 1475610435:
4775        /* authority */ return new String[] { "CodeableConcept" };
4776      case -892481550:
4777        /* status */ return new String[] { "CodeableConcept" };
4778      case 3076014:
4779        /* date */ return new String[] { "dateTime" };
4780      default:
4781        return super.getTypesForProperty(hash, name);
4782      }
4783
4784    }
4785
4786    @Override
4787    public Base addChild(String name) throws FHIRException {
4788      if (name.equals("authority")) {
4789        this.authority = new CodeableConcept();
4790        return this.authority;
4791      } else if (name.equals("status")) {
4792        this.status = new CodeableConcept();
4793        return this.status;
4794      } else if (name.equals("date")) {
4795        throw new FHIRException("Cannot call addChild on a singleton property SubstanceSpecification.date");
4796      } else
4797        return super.addChild(name);
4798    }
4799
4800    public SubstanceSpecificationNameOfficialComponent copy() {
4801      SubstanceSpecificationNameOfficialComponent dst = new SubstanceSpecificationNameOfficialComponent();
4802      copyValues(dst);
4803      return dst;
4804    }
4805
4806    public void copyValues(SubstanceSpecificationNameOfficialComponent dst) {
4807      super.copyValues(dst);
4808      dst.authority = authority == null ? null : authority.copy();
4809      dst.status = status == null ? null : status.copy();
4810      dst.date = date == null ? null : date.copy();
4811    }
4812
4813    @Override
4814    public boolean equalsDeep(Base other_) {
4815      if (!super.equalsDeep(other_))
4816        return false;
4817      if (!(other_ instanceof SubstanceSpecificationNameOfficialComponent))
4818        return false;
4819      SubstanceSpecificationNameOfficialComponent o = (SubstanceSpecificationNameOfficialComponent) other_;
4820      return compareDeep(authority, o.authority, true) && compareDeep(status, o.status, true)
4821          && compareDeep(date, o.date, true);
4822    }
4823
4824    @Override
4825    public boolean equalsShallow(Base other_) {
4826      if (!super.equalsShallow(other_))
4827        return false;
4828      if (!(other_ instanceof SubstanceSpecificationNameOfficialComponent))
4829        return false;
4830      SubstanceSpecificationNameOfficialComponent o = (SubstanceSpecificationNameOfficialComponent) other_;
4831      return compareValues(date, o.date, true);
4832    }
4833
4834    public boolean isEmpty() {
4835      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(authority, status, date);
4836    }
4837
4838    public String fhirType() {
4839      return "SubstanceSpecification.name.official";
4840
4841    }
4842
4843  }
4844
4845  @Block()
4846  public static class SubstanceSpecificationRelationshipComponent extends BackboneElement
4847      implements IBaseBackboneElement {
4848    /**
4849     * A pointer to another substance, as a resource or just a representational
4850     * code.
4851     */
4852    @Child(name = "substance", type = { SubstanceSpecification.class,
4853        CodeableConcept.class }, order = 1, min = 0, max = 1, modifier = false, summary = true)
4854    @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.")
4855    protected Type substance;
4856
4857    /**
4858     * For example "salt to parent", "active moiety", "starting material".
4859     */
4860    @Child(name = "relationship", type = {
4861        CodeableConcept.class }, order = 2, min = 0, max = 1, modifier = false, summary = true)
4862    @Description(shortDefinition = "For example \"salt to parent\", \"active moiety\", \"starting material\"", formalDefinition = "For example \"salt to parent\", \"active moiety\", \"starting material\".")
4863    protected CodeableConcept relationship;
4864
4865    /**
4866     * For example where an enzyme strongly bonds with a particular substance, this
4867     * is a defining relationship for that enzyme, out of several possible substance
4868     * relationships.
4869     */
4870    @Child(name = "isDefining", type = {
4871        BooleanType.class }, order = 3, min = 0, max = 1, modifier = false, summary = true)
4872    @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.")
4873    protected BooleanType isDefining;
4874
4875    /**
4876     * A numeric factor for the relationship, for instance to express that the salt
4877     * of a substance has some percentage of the active substance in relation to
4878     * some other.
4879     */
4880    @Child(name = "amount", type = { Quantity.class, Range.class, Ratio.class,
4881        StringType.class }, order = 4, min = 0, max = 1, modifier = false, summary = true)
4882    @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.")
4883    protected Type amount;
4884
4885    /**
4886     * For use when the numeric.
4887     */
4888    @Child(name = "amountRatioLowLimit", type = {
4889        Ratio.class }, order = 5, min = 0, max = 1, modifier = false, summary = true)
4890    @Description(shortDefinition = "For use when the numeric", formalDefinition = "For use when the numeric.")
4891    protected Ratio amountRatioLowLimit;
4892
4893    /**
4894     * An operator for the amount, for example "average", "approximately", "less
4895     * than".
4896     */
4897    @Child(name = "amountType", type = {
4898        CodeableConcept.class }, order = 6, min = 0, max = 1, modifier = false, summary = true)
4899    @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\".")
4900    protected CodeableConcept amountType;
4901
4902    /**
4903     * Supporting literature.
4904     */
4905    @Child(name = "source", type = {
4906        DocumentReference.class }, order = 7, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
4907    @Description(shortDefinition = "Supporting literature", formalDefinition = "Supporting literature.")
4908    protected List<Reference> source;
4909    /**
4910     * The actual objects that are the target of the reference (Supporting
4911     * literature.)
4912     */
4913    protected List<DocumentReference> sourceTarget;
4914
4915    private static final long serialVersionUID = -1277419269L;
4916
4917    /**
4918     * Constructor
4919     */
4920    public SubstanceSpecificationRelationshipComponent() {
4921      super();
4922    }
4923
4924    /**
4925     * @return {@link #substance} (A pointer to another substance, as a resource or
4926     *         just a representational code.)
4927     */
4928    public Type getSubstance() {
4929      return this.substance;
4930    }
4931
4932    /**
4933     * @return {@link #substance} (A pointer to another substance, as a resource or
4934     *         just a representational code.)
4935     */
4936    public Reference getSubstanceReference() throws FHIRException {
4937      if (this.substance == null)
4938        this.substance = new Reference();
4939      if (!(this.substance instanceof Reference))
4940        throw new FHIRException("Type mismatch: the type Reference was expected, but "
4941            + this.substance.getClass().getName() + " was encountered");
4942      return (Reference) this.substance;
4943    }
4944
4945    public boolean hasSubstanceReference() {
4946      return this != null && this.substance instanceof Reference;
4947    }
4948
4949    /**
4950     * @return {@link #substance} (A pointer to another substance, as a resource or
4951     *         just a representational code.)
4952     */
4953    public CodeableConcept getSubstanceCodeableConcept() throws FHIRException {
4954      if (this.substance == null)
4955        this.substance = new CodeableConcept();
4956      if (!(this.substance instanceof CodeableConcept))
4957        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "
4958            + this.substance.getClass().getName() + " was encountered");
4959      return (CodeableConcept) this.substance;
4960    }
4961
4962    public boolean hasSubstanceCodeableConcept() {
4963      return this != null && this.substance instanceof CodeableConcept;
4964    }
4965
4966    public boolean hasSubstance() {
4967      return this.substance != null && !this.substance.isEmpty();
4968    }
4969
4970    /**
4971     * @param value {@link #substance} (A pointer to another substance, as a
4972     *              resource or just a representational code.)
4973     */
4974    public SubstanceSpecificationRelationshipComponent setSubstance(Type value) {
4975      if (value != null && !(value instanceof Reference || value instanceof CodeableConcept))
4976        throw new Error("Not the right type for SubstanceSpecification.relationship.substance[x]: " + value.fhirType());
4977      this.substance = value;
4978      return this;
4979    }
4980
4981    /**
4982     * @return {@link #relationship} (For example "salt to parent", "active moiety",
4983     *         "starting material".)
4984     */
4985    public CodeableConcept getRelationship() {
4986      if (this.relationship == null)
4987        if (Configuration.errorOnAutoCreate())
4988          throw new Error("Attempt to auto-create SubstanceSpecificationRelationshipComponent.relationship");
4989        else if (Configuration.doAutoCreate())
4990          this.relationship = new CodeableConcept(); // cc
4991      return this.relationship;
4992    }
4993
4994    public boolean hasRelationship() {
4995      return this.relationship != null && !this.relationship.isEmpty();
4996    }
4997
4998    /**
4999     * @param value {@link #relationship} (For example "salt to parent", "active
5000     *              moiety", "starting material".)
5001     */
5002    public SubstanceSpecificationRelationshipComponent setRelationship(CodeableConcept value) {
5003      this.relationship = value;
5004      return this;
5005    }
5006
5007    /**
5008     * @return {@link #isDefining} (For example where an enzyme strongly bonds with
5009     *         a particular substance, this is a defining relationship for that
5010     *         enzyme, out of several possible substance relationships.). This is
5011     *         the underlying object with id, value and extensions. The accessor
5012     *         "getIsDefining" gives direct access to the value
5013     */
5014    public BooleanType getIsDefiningElement() {
5015      if (this.isDefining == null)
5016        if (Configuration.errorOnAutoCreate())
5017          throw new Error("Attempt to auto-create SubstanceSpecificationRelationshipComponent.isDefining");
5018        else if (Configuration.doAutoCreate())
5019          this.isDefining = new BooleanType(); // bb
5020      return this.isDefining;
5021    }
5022
5023    public boolean hasIsDefiningElement() {
5024      return this.isDefining != null && !this.isDefining.isEmpty();
5025    }
5026
5027    public boolean hasIsDefining() {
5028      return this.isDefining != null && !this.isDefining.isEmpty();
5029    }
5030
5031    /**
5032     * @param value {@link #isDefining} (For example where an enzyme strongly bonds
5033     *              with a particular substance, this is a defining relationship for
5034     *              that enzyme, out of several possible substance relationships.).
5035     *              This is the underlying object with id, value and extensions. The
5036     *              accessor "getIsDefining" gives direct access to the value
5037     */
5038    public SubstanceSpecificationRelationshipComponent setIsDefiningElement(BooleanType value) {
5039      this.isDefining = value;
5040      return this;
5041    }
5042
5043    /**
5044     * @return For example where an enzyme strongly bonds with a particular
5045     *         substance, this is a defining relationship for that enzyme, out of
5046     *         several possible substance relationships.
5047     */
5048    public boolean getIsDefining() {
5049      return this.isDefining == null || this.isDefining.isEmpty() ? false : this.isDefining.getValue();
5050    }
5051
5052    /**
5053     * @param value For example where an enzyme strongly bonds with a particular
5054     *              substance, this is a defining relationship for that enzyme, out
5055     *              of several possible substance relationships.
5056     */
5057    public SubstanceSpecificationRelationshipComponent setIsDefining(boolean value) {
5058      if (this.isDefining == null)
5059        this.isDefining = new BooleanType();
5060      this.isDefining.setValue(value);
5061      return this;
5062    }
5063
5064    /**
5065     * @return {@link #amount} (A numeric factor for the relationship, for instance
5066     *         to express that the salt of a substance has some percentage of the
5067     *         active substance in relation to some other.)
5068     */
5069    public Type getAmount() {
5070      return this.amount;
5071    }
5072
5073    /**
5074     * @return {@link #amount} (A numeric factor for the relationship, for instance
5075     *         to express that the salt of a substance has some percentage of the
5076     *         active substance in relation to some other.)
5077     */
5078    public Quantity getAmountQuantity() throws FHIRException {
5079      if (this.amount == null)
5080        this.amount = new Quantity();
5081      if (!(this.amount instanceof Quantity))
5082        throw new FHIRException("Type mismatch: the type Quantity was expected, but " + this.amount.getClass().getName()
5083            + " was encountered");
5084      return (Quantity) this.amount;
5085    }
5086
5087    public boolean hasAmountQuantity() {
5088      return this != null && this.amount instanceof Quantity;
5089    }
5090
5091    /**
5092     * @return {@link #amount} (A numeric factor for the relationship, for instance
5093     *         to express that the salt of a substance has some percentage of the
5094     *         active substance in relation to some other.)
5095     */
5096    public Range getAmountRange() throws FHIRException {
5097      if (this.amount == null)
5098        this.amount = new Range();
5099      if (!(this.amount instanceof Range))
5100        throw new FHIRException(
5101            "Type mismatch: the type Range was expected, but " + this.amount.getClass().getName() + " was encountered");
5102      return (Range) this.amount;
5103    }
5104
5105    public boolean hasAmountRange() {
5106      return this != null && this.amount instanceof Range;
5107    }
5108
5109    /**
5110     * @return {@link #amount} (A numeric factor for the relationship, for instance
5111     *         to express that the salt of a substance has some percentage of the
5112     *         active substance in relation to some other.)
5113     */
5114    public Ratio getAmountRatio() throws FHIRException {
5115      if (this.amount == null)
5116        this.amount = new Ratio();
5117      if (!(this.amount instanceof Ratio))
5118        throw new FHIRException(
5119            "Type mismatch: the type Ratio was expected, but " + this.amount.getClass().getName() + " was encountered");
5120      return (Ratio) this.amount;
5121    }
5122
5123    public boolean hasAmountRatio() {
5124      return this != null && this.amount instanceof Ratio;
5125    }
5126
5127    /**
5128     * @return {@link #amount} (A numeric factor for the relationship, for instance
5129     *         to express that the salt of a substance has some percentage of the
5130     *         active substance in relation to some other.)
5131     */
5132    public StringType getAmountStringType() throws FHIRException {
5133      if (this.amount == null)
5134        this.amount = new StringType();
5135      if (!(this.amount instanceof StringType))
5136        throw new FHIRException("Type mismatch: the type StringType was expected, but "
5137            + this.amount.getClass().getName() + " was encountered");
5138      return (StringType) this.amount;
5139    }
5140
5141    public boolean hasAmountStringType() {
5142      return this != null && this.amount instanceof StringType;
5143    }
5144
5145    public boolean hasAmount() {
5146      return this.amount != null && !this.amount.isEmpty();
5147    }
5148
5149    /**
5150     * @param value {@link #amount} (A numeric factor for the relationship, for
5151     *              instance to express that the salt of a substance has some
5152     *              percentage of the active substance in relation to some other.)
5153     */
5154    public SubstanceSpecificationRelationshipComponent setAmount(Type value) {
5155      if (value != null && !(value instanceof Quantity || value instanceof Range || value instanceof Ratio
5156          || value instanceof StringType))
5157        throw new Error("Not the right type for SubstanceSpecification.relationship.amount[x]: " + value.fhirType());
5158      this.amount = value;
5159      return this;
5160    }
5161
5162    /**
5163     * @return {@link #amountRatioLowLimit} (For use when the numeric.)
5164     */
5165    public Ratio getAmountRatioLowLimit() {
5166      if (this.amountRatioLowLimit == null)
5167        if (Configuration.errorOnAutoCreate())
5168          throw new Error("Attempt to auto-create SubstanceSpecificationRelationshipComponent.amountRatioLowLimit");
5169        else if (Configuration.doAutoCreate())
5170          this.amountRatioLowLimit = new Ratio(); // cc
5171      return this.amountRatioLowLimit;
5172    }
5173
5174    public boolean hasAmountRatioLowLimit() {
5175      return this.amountRatioLowLimit != null && !this.amountRatioLowLimit.isEmpty();
5176    }
5177
5178    /**
5179     * @param value {@link #amountRatioLowLimit} (For use when the numeric.)
5180     */
5181    public SubstanceSpecificationRelationshipComponent setAmountRatioLowLimit(Ratio value) {
5182      this.amountRatioLowLimit = value;
5183      return this;
5184    }
5185
5186    /**
5187     * @return {@link #amountType} (An operator for the amount, for example
5188     *         "average", "approximately", "less than".)
5189     */
5190    public CodeableConcept getAmountType() {
5191      if (this.amountType == null)
5192        if (Configuration.errorOnAutoCreate())
5193          throw new Error("Attempt to auto-create SubstanceSpecificationRelationshipComponent.amountType");
5194        else if (Configuration.doAutoCreate())
5195          this.amountType = new CodeableConcept(); // cc
5196      return this.amountType;
5197    }
5198
5199    public boolean hasAmountType() {
5200      return this.amountType != null && !this.amountType.isEmpty();
5201    }
5202
5203    /**
5204     * @param value {@link #amountType} (An operator for the amount, for example
5205     *              "average", "approximately", "less than".)
5206     */
5207    public SubstanceSpecificationRelationshipComponent setAmountType(CodeableConcept value) {
5208      this.amountType = value;
5209      return this;
5210    }
5211
5212    /**
5213     * @return {@link #source} (Supporting literature.)
5214     */
5215    public List<Reference> getSource() {
5216      if (this.source == null)
5217        this.source = new ArrayList<Reference>();
5218      return this.source;
5219    }
5220
5221    /**
5222     * @return Returns a reference to <code>this</code> for easy method chaining
5223     */
5224    public SubstanceSpecificationRelationshipComponent setSource(List<Reference> theSource) {
5225      this.source = theSource;
5226      return this;
5227    }
5228
5229    public boolean hasSource() {
5230      if (this.source == null)
5231        return false;
5232      for (Reference item : this.source)
5233        if (!item.isEmpty())
5234          return true;
5235      return false;
5236    }
5237
5238    public Reference addSource() { // 3
5239      Reference t = new Reference();
5240      if (this.source == null)
5241        this.source = new ArrayList<Reference>();
5242      this.source.add(t);
5243      return t;
5244    }
5245
5246    public SubstanceSpecificationRelationshipComponent addSource(Reference t) { // 3
5247      if (t == null)
5248        return this;
5249      if (this.source == null)
5250        this.source = new ArrayList<Reference>();
5251      this.source.add(t);
5252      return this;
5253    }
5254
5255    /**
5256     * @return The first repetition of repeating field {@link #source}, creating it
5257     *         if it does not already exist
5258     */
5259    public Reference getSourceFirstRep() {
5260      if (getSource().isEmpty()) {
5261        addSource();
5262      }
5263      return getSource().get(0);
5264    }
5265
5266    /**
5267     * @deprecated Use Reference#setResource(IBaseResource) instead
5268     */
5269    @Deprecated
5270    public List<DocumentReference> getSourceTarget() {
5271      if (this.sourceTarget == null)
5272        this.sourceTarget = new ArrayList<DocumentReference>();
5273      return this.sourceTarget;
5274    }
5275
5276    /**
5277     * @deprecated Use Reference#setResource(IBaseResource) instead
5278     */
5279    @Deprecated
5280    public DocumentReference addSourceTarget() {
5281      DocumentReference r = new DocumentReference();
5282      if (this.sourceTarget == null)
5283        this.sourceTarget = new ArrayList<DocumentReference>();
5284      this.sourceTarget.add(r);
5285      return r;
5286    }
5287
5288    protected void listChildren(List<Property> children) {
5289      super.listChildren(children);
5290      children.add(new Property("substance[x]", "Reference(SubstanceSpecification)|CodeableConcept",
5291          "A pointer to another substance, as a resource or just a representational code.", 0, 1, substance));
5292      children.add(new Property("relationship", "CodeableConcept",
5293          "For example \"salt to parent\", \"active moiety\", \"starting material\".", 0, 1, relationship));
5294      children.add(new Property("isDefining", "boolean",
5295          "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.",
5296          0, 1, isDefining));
5297      children.add(new Property("amount[x]", "Quantity|Range|Ratio|string",
5298          "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.",
5299          0, 1, amount));
5300      children
5301          .add(new Property("amountRatioLowLimit", "Ratio", "For use when the numeric.", 0, 1, amountRatioLowLimit));
5302      children.add(new Property("amountType", "CodeableConcept",
5303          "An operator for the amount, for example \"average\", \"approximately\", \"less than\".", 0, 1, amountType));
5304      children.add(new Property("source", "Reference(DocumentReference)", "Supporting literature.", 0,
5305          java.lang.Integer.MAX_VALUE, source));
5306    }
5307
5308    @Override
5309    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
5310      switch (_hash) {
5311      case 2127194384:
5312        /* substance[x] */ return new Property("substance[x]", "Reference(SubstanceSpecification)|CodeableConcept",
5313            "A pointer to another substance, as a resource or just a representational code.", 0, 1, substance);
5314      case 530040176:
5315        /* substance */ return new Property("substance[x]", "Reference(SubstanceSpecification)|CodeableConcept",
5316            "A pointer to another substance, as a resource or just a representational code.", 0, 1, substance);
5317      case 516208571:
5318        /* substanceReference */ return new Property("substance[x]",
5319            "Reference(SubstanceSpecification)|CodeableConcept",
5320            "A pointer to another substance, as a resource or just a representational code.", 0, 1, substance);
5321      case -1974119407:
5322        /* substanceCodeableConcept */ return new Property("substance[x]",
5323            "Reference(SubstanceSpecification)|CodeableConcept",
5324            "A pointer to another substance, as a resource or just a representational code.", 0, 1, substance);
5325      case -261851592:
5326        /* relationship */ return new Property("relationship", "CodeableConcept",
5327            "For example \"salt to parent\", \"active moiety\", \"starting material\".", 0, 1, relationship);
5328      case -141812990:
5329        /* isDefining */ return new Property("isDefining", "boolean",
5330            "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.",
5331            0, 1, isDefining);
5332      case 646780200:
5333        /* amount[x] */ return new Property("amount[x]", "Quantity|Range|Ratio|string",
5334            "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.",
5335            0, 1, amount);
5336      case -1413853096:
5337        /* amount */ return new Property("amount[x]", "Quantity|Range|Ratio|string",
5338            "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.",
5339            0, 1, amount);
5340      case 1664303363:
5341        /* amountQuantity */ return new Property("amount[x]", "Quantity|Range|Ratio|string",
5342            "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.",
5343            0, 1, amount);
5344      case -1223462971:
5345        /* amountRange */ return new Property("amount[x]", "Quantity|Range|Ratio|string",
5346            "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.",
5347            0, 1, amount);
5348      case -1223457133:
5349        /* amountRatio */ return new Property("amount[x]", "Quantity|Range|Ratio|string",
5350            "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.",
5351            0, 1, amount);
5352      case 773651081:
5353        /* amountString */ return new Property("amount[x]", "Quantity|Range|Ratio|string",
5354            "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.",
5355            0, 1, amount);
5356      case 2140623994:
5357        /* amountRatioLowLimit */ return new Property("amountRatioLowLimit", "Ratio", "For use when the numeric.", 0, 1,
5358            amountRatioLowLimit);
5359      case -1424857166:
5360        /* amountType */ return new Property("amountType", "CodeableConcept",
5361            "An operator for the amount, for example \"average\", \"approximately\", \"less than\".", 0, 1, amountType);
5362      case -896505829:
5363        /* source */ return new Property("source", "Reference(DocumentReference)", "Supporting literature.", 0,
5364            java.lang.Integer.MAX_VALUE, source);
5365      default:
5366        return super.getNamedProperty(_hash, _name, _checkValid);
5367      }
5368
5369    }
5370
5371    @Override
5372    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
5373      switch (hash) {
5374      case 530040176:
5375        /* substance */ return this.substance == null ? new Base[0] : new Base[] { this.substance }; // Type
5376      case -261851592:
5377        /* relationship */ return this.relationship == null ? new Base[0] : new Base[] { this.relationship }; // CodeableConcept
5378      case -141812990:
5379        /* isDefining */ return this.isDefining == null ? new Base[0] : new Base[] { this.isDefining }; // BooleanType
5380      case -1413853096:
5381        /* amount */ return this.amount == null ? new Base[0] : new Base[] { this.amount }; // Type
5382      case 2140623994:
5383        /* amountRatioLowLimit */ return this.amountRatioLowLimit == null ? new Base[0]
5384            : new Base[] { this.amountRatioLowLimit }; // Ratio
5385      case -1424857166:
5386        /* amountType */ return this.amountType == null ? new Base[0] : new Base[] { this.amountType }; // CodeableConcept
5387      case -896505829:
5388        /* source */ return this.source == null ? new Base[0] : this.source.toArray(new Base[this.source.size()]); // Reference
5389      default:
5390        return super.getProperty(hash, name, checkValid);
5391      }
5392
5393    }
5394
5395    @Override
5396    public Base setProperty(int hash, String name, Base value) throws FHIRException {
5397      switch (hash) {
5398      case 530040176: // substance
5399        this.substance = castToType(value); // Type
5400        return value;
5401      case -261851592: // relationship
5402        this.relationship = castToCodeableConcept(value); // CodeableConcept
5403        return value;
5404      case -141812990: // isDefining
5405        this.isDefining = castToBoolean(value); // BooleanType
5406        return value;
5407      case -1413853096: // amount
5408        this.amount = castToType(value); // Type
5409        return value;
5410      case 2140623994: // amountRatioLowLimit
5411        this.amountRatioLowLimit = castToRatio(value); // Ratio
5412        return value;
5413      case -1424857166: // amountType
5414        this.amountType = castToCodeableConcept(value); // CodeableConcept
5415        return value;
5416      case -896505829: // source
5417        this.getSource().add(castToReference(value)); // Reference
5418        return value;
5419      default:
5420        return super.setProperty(hash, name, value);
5421      }
5422
5423    }
5424
5425    @Override
5426    public Base setProperty(String name, Base value) throws FHIRException {
5427      if (name.equals("substance[x]")) {
5428        this.substance = castToType(value); // Type
5429      } else if (name.equals("relationship")) {
5430        this.relationship = castToCodeableConcept(value); // CodeableConcept
5431      } else if (name.equals("isDefining")) {
5432        this.isDefining = castToBoolean(value); // BooleanType
5433      } else if (name.equals("amount[x]")) {
5434        this.amount = castToType(value); // Type
5435      } else if (name.equals("amountRatioLowLimit")) {
5436        this.amountRatioLowLimit = castToRatio(value); // Ratio
5437      } else if (name.equals("amountType")) {
5438        this.amountType = castToCodeableConcept(value); // CodeableConcept
5439      } else if (name.equals("source")) {
5440        this.getSource().add(castToReference(value));
5441      } else
5442        return super.setProperty(name, value);
5443      return value;
5444    }
5445
5446  @Override
5447  public void removeChild(String name, Base value) throws FHIRException {
5448      if (name.equals("substance[x]")) {
5449        this.substance = null;
5450      } else if (name.equals("relationship")) {
5451        this.relationship = null;
5452      } else if (name.equals("isDefining")) {
5453        this.isDefining = null;
5454      } else if (name.equals("amount[x]")) {
5455        this.amount = null;
5456      } else if (name.equals("amountRatioLowLimit")) {
5457        this.amountRatioLowLimit = null;
5458      } else if (name.equals("amountType")) {
5459        this.amountType = null;
5460      } else if (name.equals("source")) {
5461        this.getSource().remove(castToReference(value));
5462      } else
5463        super.removeChild(name, value);
5464      
5465    }
5466
5467    @Override
5468    public Base makeProperty(int hash, String name) throws FHIRException {
5469      switch (hash) {
5470      case 2127194384:
5471        return getSubstance();
5472      case 530040176:
5473        return getSubstance();
5474      case -261851592:
5475        return getRelationship();
5476      case -141812990:
5477        return getIsDefiningElement();
5478      case 646780200:
5479        return getAmount();
5480      case -1413853096:
5481        return getAmount();
5482      case 2140623994:
5483        return getAmountRatioLowLimit();
5484      case -1424857166:
5485        return getAmountType();
5486      case -896505829:
5487        return addSource();
5488      default:
5489        return super.makeProperty(hash, name);
5490      }
5491
5492    }
5493
5494    @Override
5495    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
5496      switch (hash) {
5497      case 530040176:
5498        /* substance */ return new String[] { "Reference", "CodeableConcept" };
5499      case -261851592:
5500        /* relationship */ return new String[] { "CodeableConcept" };
5501      case -141812990:
5502        /* isDefining */ return new String[] { "boolean" };
5503      case -1413853096:
5504        /* amount */ return new String[] { "Quantity", "Range", "Ratio", "string" };
5505      case 2140623994:
5506        /* amountRatioLowLimit */ return new String[] { "Ratio" };
5507      case -1424857166:
5508        /* amountType */ return new String[] { "CodeableConcept" };
5509      case -896505829:
5510        /* source */ return new String[] { "Reference" };
5511      default:
5512        return super.getTypesForProperty(hash, name);
5513      }
5514
5515    }
5516
5517    @Override
5518    public Base addChild(String name) throws FHIRException {
5519      if (name.equals("substanceReference")) {
5520        this.substance = new Reference();
5521        return this.substance;
5522      } else if (name.equals("substanceCodeableConcept")) {
5523        this.substance = new CodeableConcept();
5524        return this.substance;
5525      } else if (name.equals("relationship")) {
5526        this.relationship = new CodeableConcept();
5527        return this.relationship;
5528      } else if (name.equals("isDefining")) {
5529        throw new FHIRException("Cannot call addChild on a singleton property SubstanceSpecification.isDefining");
5530      } else if (name.equals("amountQuantity")) {
5531        this.amount = new Quantity();
5532        return this.amount;
5533      } else if (name.equals("amountRange")) {
5534        this.amount = new Range();
5535        return this.amount;
5536      } else if (name.equals("amountRatio")) {
5537        this.amount = new Ratio();
5538        return this.amount;
5539      } else if (name.equals("amountString")) {
5540        this.amount = new StringType();
5541        return this.amount;
5542      } else if (name.equals("amountRatioLowLimit")) {
5543        this.amountRatioLowLimit = new Ratio();
5544        return this.amountRatioLowLimit;
5545      } else if (name.equals("amountType")) {
5546        this.amountType = new CodeableConcept();
5547        return this.amountType;
5548      } else if (name.equals("source")) {
5549        return addSource();
5550      } else
5551        return super.addChild(name);
5552    }
5553
5554    public SubstanceSpecificationRelationshipComponent copy() {
5555      SubstanceSpecificationRelationshipComponent dst = new SubstanceSpecificationRelationshipComponent();
5556      copyValues(dst);
5557      return dst;
5558    }
5559
5560    public void copyValues(SubstanceSpecificationRelationshipComponent dst) {
5561      super.copyValues(dst);
5562      dst.substance = substance == null ? null : substance.copy();
5563      dst.relationship = relationship == null ? null : relationship.copy();
5564      dst.isDefining = isDefining == null ? null : isDefining.copy();
5565      dst.amount = amount == null ? null : amount.copy();
5566      dst.amountRatioLowLimit = amountRatioLowLimit == null ? null : amountRatioLowLimit.copy();
5567      dst.amountType = amountType == null ? null : amountType.copy();
5568      if (source != null) {
5569        dst.source = new ArrayList<Reference>();
5570        for (Reference i : source)
5571          dst.source.add(i.copy());
5572      }
5573      ;
5574    }
5575
5576    @Override
5577    public boolean equalsDeep(Base other_) {
5578      if (!super.equalsDeep(other_))
5579        return false;
5580      if (!(other_ instanceof SubstanceSpecificationRelationshipComponent))
5581        return false;
5582      SubstanceSpecificationRelationshipComponent o = (SubstanceSpecificationRelationshipComponent) other_;
5583      return compareDeep(substance, o.substance, true) && compareDeep(relationship, o.relationship, true)
5584          && compareDeep(isDefining, o.isDefining, true) && compareDeep(amount, o.amount, true)
5585          && compareDeep(amountRatioLowLimit, o.amountRatioLowLimit, true)
5586          && compareDeep(amountType, o.amountType, true) && compareDeep(source, o.source, true);
5587    }
5588
5589    @Override
5590    public boolean equalsShallow(Base other_) {
5591      if (!super.equalsShallow(other_))
5592        return false;
5593      if (!(other_ instanceof SubstanceSpecificationRelationshipComponent))
5594        return false;
5595      SubstanceSpecificationRelationshipComponent o = (SubstanceSpecificationRelationshipComponent) other_;
5596      return compareValues(isDefining, o.isDefining, true);
5597    }
5598
5599    public boolean isEmpty() {
5600      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(substance, relationship, isDefining, amount,
5601          amountRatioLowLimit, amountType, source);
5602    }
5603
5604    public String fhirType() {
5605      return "SubstanceSpecification.relationship";
5606
5607    }
5608
5609  }
5610
5611  /**
5612   * Identifier by which this substance is known.
5613   */
5614  @Child(name = "identifier", type = {
5615      Identifier.class }, order = 0, min = 0, max = 1, modifier = false, summary = true)
5616  @Description(shortDefinition = "Identifier by which this substance is known", formalDefinition = "Identifier by which this substance is known.")
5617  protected Identifier identifier;
5618
5619  /**
5620   * High level categorization, e.g. polymer or nucleic acid.
5621   */
5622  @Child(name = "type", type = { CodeableConcept.class }, order = 1, min = 0, max = 1, modifier = false, summary = true)
5623  @Description(shortDefinition = "High level categorization, e.g. polymer or nucleic acid", formalDefinition = "High level categorization, e.g. polymer or nucleic acid.")
5624  protected CodeableConcept type;
5625
5626  /**
5627   * Status of substance within the catalogue e.g. approved.
5628   */
5629  @Child(name = "status", type = {
5630      CodeableConcept.class }, order = 2, min = 0, max = 1, modifier = false, summary = true)
5631  @Description(shortDefinition = "Status of substance within the catalogue e.g. approved", formalDefinition = "Status of substance within the catalogue e.g. approved.")
5632  protected CodeableConcept status;
5633
5634  /**
5635   * If the substance applies to only human or veterinary use.
5636   */
5637  @Child(name = "domain", type = {
5638      CodeableConcept.class }, order = 3, min = 0, max = 1, modifier = false, summary = true)
5639  @Description(shortDefinition = "If the substance applies to only human or veterinary use", formalDefinition = "If the substance applies to only human or veterinary use.")
5640  protected CodeableConcept domain;
5641
5642  /**
5643   * Textual description of the substance.
5644   */
5645  @Child(name = "description", type = {
5646      StringType.class }, order = 4, min = 0, max = 1, modifier = false, summary = true)
5647  @Description(shortDefinition = "Textual description of the substance", formalDefinition = "Textual description of the substance.")
5648  protected StringType description;
5649
5650  /**
5651   * Supporting literature.
5652   */
5653  @Child(name = "source", type = {
5654      DocumentReference.class }, order = 5, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
5655  @Description(shortDefinition = "Supporting literature", formalDefinition = "Supporting literature.")
5656  protected List<Reference> source;
5657  /**
5658   * The actual objects that are the target of the reference (Supporting
5659   * literature.)
5660   */
5661  protected List<DocumentReference> sourceTarget;
5662
5663  /**
5664   * Textual comment about this record of a substance.
5665   */
5666  @Child(name = "comment", type = { StringType.class }, order = 6, min = 0, max = 1, modifier = false, summary = true)
5667  @Description(shortDefinition = "Textual comment about this record of a substance", formalDefinition = "Textual comment about this record of a substance.")
5668  protected StringType comment;
5669
5670  /**
5671   * Moiety, for structural modifications.
5672   */
5673  @Child(name = "moiety", type = {}, order = 7, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
5674  @Description(shortDefinition = "Moiety, for structural modifications", formalDefinition = "Moiety, for structural modifications.")
5675  protected List<SubstanceSpecificationMoietyComponent> moiety;
5676
5677  /**
5678   * General specifications for this substance, including how it is related to
5679   * other substances.
5680   */
5681  @Child(name = "property", type = {}, order = 8, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
5682  @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.")
5683  protected List<SubstanceSpecificationPropertyComponent> property;
5684
5685  /**
5686   * General information detailing this substance.
5687   */
5688  @Child(name = "referenceInformation", type = {
5689      SubstanceReferenceInformation.class }, order = 9, min = 0, max = 1, modifier = false, summary = true)
5690  @Description(shortDefinition = "General information detailing this substance", formalDefinition = "General information detailing this substance.")
5691  protected Reference referenceInformation;
5692
5693  /**
5694   * The actual object that is the target of the reference (General information
5695   * detailing this substance.)
5696   */
5697  protected SubstanceReferenceInformation referenceInformationTarget;
5698
5699  /**
5700   * Structural information.
5701   */
5702  @Child(name = "structure", type = {}, order = 10, min = 0, max = 1, modifier = false, summary = true)
5703  @Description(shortDefinition = "Structural information", formalDefinition = "Structural information.")
5704  protected SubstanceSpecificationStructureComponent structure;
5705
5706  /**
5707   * Codes associated with the substance.
5708   */
5709  @Child(name = "code", type = {}, order = 11, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
5710  @Description(shortDefinition = "Codes associated with the substance", formalDefinition = "Codes associated with the substance.")
5711  protected List<SubstanceSpecificationCodeComponent> code;
5712
5713  /**
5714   * Names applicable to this substance.
5715   */
5716  @Child(name = "name", type = {}, order = 12, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
5717  @Description(shortDefinition = "Names applicable to this substance", formalDefinition = "Names applicable to this substance.")
5718  protected List<SubstanceSpecificationNameComponent> name;
5719
5720  /**
5721   * The molecular weight or weight range (for proteins, polymers or nucleic
5722   * acids).
5723   */
5724  @Child(name = "molecularWeight", type = {
5725      SubstanceSpecificationStructureIsotopeMolecularWeightComponent.class }, order = 13, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
5726  @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).")
5727  protected List<SubstanceSpecificationStructureIsotopeMolecularWeightComponent> molecularWeight;
5728
5729  /**
5730   * A link between this substance and another, with details of the relationship.
5731   */
5732  @Child(name = "relationship", type = {}, order = 14, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
5733  @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.")
5734  protected List<SubstanceSpecificationRelationshipComponent> relationship;
5735
5736  /**
5737   * Data items specific to nucleic acids.
5738   */
5739  @Child(name = "nucleicAcid", type = {
5740      SubstanceNucleicAcid.class }, order = 15, min = 0, max = 1, modifier = false, summary = true)
5741  @Description(shortDefinition = "Data items specific to nucleic acids", formalDefinition = "Data items specific to nucleic acids.")
5742  protected Reference nucleicAcid;
5743
5744  /**
5745   * The actual object that is the target of the reference (Data items specific to
5746   * nucleic acids.)
5747   */
5748  protected SubstanceNucleicAcid nucleicAcidTarget;
5749
5750  /**
5751   * Data items specific to polymers.
5752   */
5753  @Child(name = "polymer", type = {
5754      SubstancePolymer.class }, order = 16, min = 0, max = 1, modifier = false, summary = true)
5755  @Description(shortDefinition = "Data items specific to polymers", formalDefinition = "Data items specific to polymers.")
5756  protected Reference polymer;
5757
5758  /**
5759   * The actual object that is the target of the reference (Data items specific to
5760   * polymers.)
5761   */
5762  protected SubstancePolymer polymerTarget;
5763
5764  /**
5765   * Data items specific to proteins.
5766   */
5767  @Child(name = "protein", type = {
5768      SubstanceProtein.class }, order = 17, min = 0, max = 1, modifier = false, summary = true)
5769  @Description(shortDefinition = "Data items specific to proteins", formalDefinition = "Data items specific to proteins.")
5770  protected Reference protein;
5771
5772  /**
5773   * The actual object that is the target of the reference (Data items specific to
5774   * proteins.)
5775   */
5776  protected SubstanceProtein proteinTarget;
5777
5778  /**
5779   * Material or taxonomic/anatomical source for the substance.
5780   */
5781  @Child(name = "sourceMaterial", type = {
5782      SubstanceSourceMaterial.class }, order = 18, min = 0, max = 1, modifier = false, summary = true)
5783  @Description(shortDefinition = "Material or taxonomic/anatomical source for the substance", formalDefinition = "Material or taxonomic/anatomical source for the substance.")
5784  protected Reference sourceMaterial;
5785
5786  /**
5787   * The actual object that is the target of the reference (Material or
5788   * taxonomic/anatomical source for the substance.)
5789   */
5790  protected SubstanceSourceMaterial sourceMaterialTarget;
5791
5792  private static final long serialVersionUID = 1782072718L;
5793
5794  /**
5795   * Constructor
5796   */
5797  public SubstanceSpecification() {
5798    super();
5799  }
5800
5801  /**
5802   * @return {@link #identifier} (Identifier by which this substance is known.)
5803   */
5804  public Identifier getIdentifier() {
5805    if (this.identifier == null)
5806      if (Configuration.errorOnAutoCreate())
5807        throw new Error("Attempt to auto-create SubstanceSpecification.identifier");
5808      else if (Configuration.doAutoCreate())
5809        this.identifier = new Identifier(); // cc
5810    return this.identifier;
5811  }
5812
5813  public boolean hasIdentifier() {
5814    return this.identifier != null && !this.identifier.isEmpty();
5815  }
5816
5817  /**
5818   * @param value {@link #identifier} (Identifier by which this substance is
5819   *              known.)
5820   */
5821  public SubstanceSpecification setIdentifier(Identifier value) {
5822    this.identifier = value;
5823    return this;
5824  }
5825
5826  /**
5827   * @return {@link #type} (High level categorization, e.g. polymer or nucleic
5828   *         acid.)
5829   */
5830  public CodeableConcept getType() {
5831    if (this.type == null)
5832      if (Configuration.errorOnAutoCreate())
5833        throw new Error("Attempt to auto-create SubstanceSpecification.type");
5834      else if (Configuration.doAutoCreate())
5835        this.type = new CodeableConcept(); // cc
5836    return this.type;
5837  }
5838
5839  public boolean hasType() {
5840    return this.type != null && !this.type.isEmpty();
5841  }
5842
5843  /**
5844   * @param value {@link #type} (High level categorization, e.g. polymer or
5845   *              nucleic acid.)
5846   */
5847  public SubstanceSpecification setType(CodeableConcept value) {
5848    this.type = value;
5849    return this;
5850  }
5851
5852  /**
5853   * @return {@link #status} (Status of substance within the catalogue e.g.
5854   *         approved.)
5855   */
5856  public CodeableConcept getStatus() {
5857    if (this.status == null)
5858      if (Configuration.errorOnAutoCreate())
5859        throw new Error("Attempt to auto-create SubstanceSpecification.status");
5860      else if (Configuration.doAutoCreate())
5861        this.status = new CodeableConcept(); // cc
5862    return this.status;
5863  }
5864
5865  public boolean hasStatus() {
5866    return this.status != null && !this.status.isEmpty();
5867  }
5868
5869  /**
5870   * @param value {@link #status} (Status of substance within the catalogue e.g.
5871   *              approved.)
5872   */
5873  public SubstanceSpecification setStatus(CodeableConcept value) {
5874    this.status = value;
5875    return this;
5876  }
5877
5878  /**
5879   * @return {@link #domain} (If the substance applies to only human or veterinary
5880   *         use.)
5881   */
5882  public CodeableConcept getDomain() {
5883    if (this.domain == null)
5884      if (Configuration.errorOnAutoCreate())
5885        throw new Error("Attempt to auto-create SubstanceSpecification.domain");
5886      else if (Configuration.doAutoCreate())
5887        this.domain = new CodeableConcept(); // cc
5888    return this.domain;
5889  }
5890
5891  public boolean hasDomain() {
5892    return this.domain != null && !this.domain.isEmpty();
5893  }
5894
5895  /**
5896   * @param value {@link #domain} (If the substance applies to only human or
5897   *              veterinary use.)
5898   */
5899  public SubstanceSpecification setDomain(CodeableConcept value) {
5900    this.domain = value;
5901    return this;
5902  }
5903
5904  /**
5905   * @return {@link #description} (Textual description of the substance.). This is
5906   *         the underlying object with id, value and extensions. The accessor
5907   *         "getDescription" gives direct access to the value
5908   */
5909  public StringType getDescriptionElement() {
5910    if (this.description == null)
5911      if (Configuration.errorOnAutoCreate())
5912        throw new Error("Attempt to auto-create SubstanceSpecification.description");
5913      else if (Configuration.doAutoCreate())
5914        this.description = new StringType(); // bb
5915    return this.description;
5916  }
5917
5918  public boolean hasDescriptionElement() {
5919    return this.description != null && !this.description.isEmpty();
5920  }
5921
5922  public boolean hasDescription() {
5923    return this.description != null && !this.description.isEmpty();
5924  }
5925
5926  /**
5927   * @param value {@link #description} (Textual description of the substance.).
5928   *              This is the underlying object with id, value and extensions. The
5929   *              accessor "getDescription" gives direct access to the value
5930   */
5931  public SubstanceSpecification setDescriptionElement(StringType value) {
5932    this.description = value;
5933    return this;
5934  }
5935
5936  /**
5937   * @return Textual description of the substance.
5938   */
5939  public String getDescription() {
5940    return this.description == null ? null : this.description.getValue();
5941  }
5942
5943  /**
5944   * @param value Textual description of the substance.
5945   */
5946  public SubstanceSpecification setDescription(String value) {
5947    if (Utilities.noString(value))
5948      this.description = null;
5949    else {
5950      if (this.description == null)
5951        this.description = new StringType();
5952      this.description.setValue(value);
5953    }
5954    return this;
5955  }
5956
5957  /**
5958   * @return {@link #source} (Supporting literature.)
5959   */
5960  public List<Reference> getSource() {
5961    if (this.source == null)
5962      this.source = new ArrayList<Reference>();
5963    return this.source;
5964  }
5965
5966  /**
5967   * @return Returns a reference to <code>this</code> for easy method chaining
5968   */
5969  public SubstanceSpecification setSource(List<Reference> theSource) {
5970    this.source = theSource;
5971    return this;
5972  }
5973
5974  public boolean hasSource() {
5975    if (this.source == null)
5976      return false;
5977    for (Reference item : this.source)
5978      if (!item.isEmpty())
5979        return true;
5980    return false;
5981  }
5982
5983  public Reference addSource() { // 3
5984    Reference t = new Reference();
5985    if (this.source == null)
5986      this.source = new ArrayList<Reference>();
5987    this.source.add(t);
5988    return t;
5989  }
5990
5991  public SubstanceSpecification addSource(Reference t) { // 3
5992    if (t == null)
5993      return this;
5994    if (this.source == null)
5995      this.source = new ArrayList<Reference>();
5996    this.source.add(t);
5997    return this;
5998  }
5999
6000  /**
6001   * @return The first repetition of repeating field {@link #source}, creating it
6002   *         if it does not already exist
6003   */
6004  public Reference getSourceFirstRep() {
6005    if (getSource().isEmpty()) {
6006      addSource();
6007    }
6008    return getSource().get(0);
6009  }
6010
6011  /**
6012   * @deprecated Use Reference#setResource(IBaseResource) instead
6013   */
6014  @Deprecated
6015  public List<DocumentReference> getSourceTarget() {
6016    if (this.sourceTarget == null)
6017      this.sourceTarget = new ArrayList<DocumentReference>();
6018    return this.sourceTarget;
6019  }
6020
6021  /**
6022   * @deprecated Use Reference#setResource(IBaseResource) instead
6023   */
6024  @Deprecated
6025  public DocumentReference addSourceTarget() {
6026    DocumentReference r = new DocumentReference();
6027    if (this.sourceTarget == null)
6028      this.sourceTarget = new ArrayList<DocumentReference>();
6029    this.sourceTarget.add(r);
6030    return r;
6031  }
6032
6033  /**
6034   * @return {@link #comment} (Textual comment about this record of a substance.).
6035   *         This is the underlying object with id, value and extensions. The
6036   *         accessor "getComment" gives direct access to the value
6037   */
6038  public StringType getCommentElement() {
6039    if (this.comment == null)
6040      if (Configuration.errorOnAutoCreate())
6041        throw new Error("Attempt to auto-create SubstanceSpecification.comment");
6042      else if (Configuration.doAutoCreate())
6043        this.comment = new StringType(); // bb
6044    return this.comment;
6045  }
6046
6047  public boolean hasCommentElement() {
6048    return this.comment != null && !this.comment.isEmpty();
6049  }
6050
6051  public boolean hasComment() {
6052    return this.comment != null && !this.comment.isEmpty();
6053  }
6054
6055  /**
6056   * @param value {@link #comment} (Textual comment about this record of a
6057   *              substance.). This is the underlying object with id, value and
6058   *              extensions. The accessor "getComment" gives direct access to the
6059   *              value
6060   */
6061  public SubstanceSpecification setCommentElement(StringType value) {
6062    this.comment = value;
6063    return this;
6064  }
6065
6066  /**
6067   * @return Textual comment about this record of a substance.
6068   */
6069  public String getComment() {
6070    return this.comment == null ? null : this.comment.getValue();
6071  }
6072
6073  /**
6074   * @param value Textual comment about this record of a substance.
6075   */
6076  public SubstanceSpecification setComment(String value) {
6077    if (Utilities.noString(value))
6078      this.comment = null;
6079    else {
6080      if (this.comment == null)
6081        this.comment = new StringType();
6082      this.comment.setValue(value);
6083    }
6084    return this;
6085  }
6086
6087  /**
6088   * @return {@link #moiety} (Moiety, for structural modifications.)
6089   */
6090  public List<SubstanceSpecificationMoietyComponent> getMoiety() {
6091    if (this.moiety == null)
6092      this.moiety = new ArrayList<SubstanceSpecificationMoietyComponent>();
6093    return this.moiety;
6094  }
6095
6096  /**
6097   * @return Returns a reference to <code>this</code> for easy method chaining
6098   */
6099  public SubstanceSpecification setMoiety(List<SubstanceSpecificationMoietyComponent> theMoiety) {
6100    this.moiety = theMoiety;
6101    return this;
6102  }
6103
6104  public boolean hasMoiety() {
6105    if (this.moiety == null)
6106      return false;
6107    for (SubstanceSpecificationMoietyComponent item : this.moiety)
6108      if (!item.isEmpty())
6109        return true;
6110    return false;
6111  }
6112
6113  public SubstanceSpecificationMoietyComponent addMoiety() { // 3
6114    SubstanceSpecificationMoietyComponent t = new SubstanceSpecificationMoietyComponent();
6115    if (this.moiety == null)
6116      this.moiety = new ArrayList<SubstanceSpecificationMoietyComponent>();
6117    this.moiety.add(t);
6118    return t;
6119  }
6120
6121  public SubstanceSpecification addMoiety(SubstanceSpecificationMoietyComponent t) { // 3
6122    if (t == null)
6123      return this;
6124    if (this.moiety == null)
6125      this.moiety = new ArrayList<SubstanceSpecificationMoietyComponent>();
6126    this.moiety.add(t);
6127    return this;
6128  }
6129
6130  /**
6131   * @return The first repetition of repeating field {@link #moiety}, creating it
6132   *         if it does not already exist
6133   */
6134  public SubstanceSpecificationMoietyComponent getMoietyFirstRep() {
6135    if (getMoiety().isEmpty()) {
6136      addMoiety();
6137    }
6138    return getMoiety().get(0);
6139  }
6140
6141  /**
6142   * @return {@link #property} (General specifications for this substance,
6143   *         including how it is related to other substances.)
6144   */
6145  public List<SubstanceSpecificationPropertyComponent> getProperty() {
6146    if (this.property == null)
6147      this.property = new ArrayList<SubstanceSpecificationPropertyComponent>();
6148    return this.property;
6149  }
6150
6151  /**
6152   * @return Returns a reference to <code>this</code> for easy method chaining
6153   */
6154  public SubstanceSpecification setProperty(List<SubstanceSpecificationPropertyComponent> theProperty) {
6155    this.property = theProperty;
6156    return this;
6157  }
6158
6159  public boolean hasProperty() {
6160    if (this.property == null)
6161      return false;
6162    for (SubstanceSpecificationPropertyComponent item : this.property)
6163      if (!item.isEmpty())
6164        return true;
6165    return false;
6166  }
6167
6168  public SubstanceSpecificationPropertyComponent addProperty() { // 3
6169    SubstanceSpecificationPropertyComponent t = new SubstanceSpecificationPropertyComponent();
6170    if (this.property == null)
6171      this.property = new ArrayList<SubstanceSpecificationPropertyComponent>();
6172    this.property.add(t);
6173    return t;
6174  }
6175
6176  public SubstanceSpecification addProperty(SubstanceSpecificationPropertyComponent t) { // 3
6177    if (t == null)
6178      return this;
6179    if (this.property == null)
6180      this.property = new ArrayList<SubstanceSpecificationPropertyComponent>();
6181    this.property.add(t);
6182    return this;
6183  }
6184
6185  /**
6186   * @return The first repetition of repeating field {@link #property}, creating
6187   *         it if it does not already exist
6188   */
6189  public SubstanceSpecificationPropertyComponent getPropertyFirstRep() {
6190    if (getProperty().isEmpty()) {
6191      addProperty();
6192    }
6193    return getProperty().get(0);
6194  }
6195
6196  /**
6197   * @return {@link #referenceInformation} (General information detailing this
6198   *         substance.)
6199   */
6200  public Reference getReferenceInformation() {
6201    if (this.referenceInformation == null)
6202      if (Configuration.errorOnAutoCreate())
6203        throw new Error("Attempt to auto-create SubstanceSpecification.referenceInformation");
6204      else if (Configuration.doAutoCreate())
6205        this.referenceInformation = new Reference(); // cc
6206    return this.referenceInformation;
6207  }
6208
6209  public boolean hasReferenceInformation() {
6210    return this.referenceInformation != null && !this.referenceInformation.isEmpty();
6211  }
6212
6213  /**
6214   * @param value {@link #referenceInformation} (General information detailing
6215   *              this substance.)
6216   */
6217  public SubstanceSpecification setReferenceInformation(Reference value) {
6218    this.referenceInformation = value;
6219    return this;
6220  }
6221
6222  /**
6223   * @return {@link #referenceInformation} The actual object that is the target of
6224   *         the reference. The reference library doesn't populate this, but you
6225   *         can use it to hold the resource if you resolve it. (General
6226   *         information detailing this substance.)
6227   */
6228  public SubstanceReferenceInformation getReferenceInformationTarget() {
6229    if (this.referenceInformationTarget == null)
6230      if (Configuration.errorOnAutoCreate())
6231        throw new Error("Attempt to auto-create SubstanceSpecification.referenceInformation");
6232      else if (Configuration.doAutoCreate())
6233        this.referenceInformationTarget = new SubstanceReferenceInformation(); // aa
6234    return this.referenceInformationTarget;
6235  }
6236
6237  /**
6238   * @param value {@link #referenceInformation} The actual object that is the
6239   *              target of the reference. The reference library doesn't use
6240   *              these, but you can use it to hold the resource if you resolve
6241   *              it. (General information detailing this substance.)
6242   */
6243  public SubstanceSpecification setReferenceInformationTarget(SubstanceReferenceInformation value) {
6244    this.referenceInformationTarget = value;
6245    return this;
6246  }
6247
6248  /**
6249   * @return {@link #structure} (Structural information.)
6250   */
6251  public SubstanceSpecificationStructureComponent getStructure() {
6252    if (this.structure == null)
6253      if (Configuration.errorOnAutoCreate())
6254        throw new Error("Attempt to auto-create SubstanceSpecification.structure");
6255      else if (Configuration.doAutoCreate())
6256        this.structure = new SubstanceSpecificationStructureComponent(); // cc
6257    return this.structure;
6258  }
6259
6260  public boolean hasStructure() {
6261    return this.structure != null && !this.structure.isEmpty();
6262  }
6263
6264  /**
6265   * @param value {@link #structure} (Structural information.)
6266   */
6267  public SubstanceSpecification setStructure(SubstanceSpecificationStructureComponent value) {
6268    this.structure = value;
6269    return this;
6270  }
6271
6272  /**
6273   * @return {@link #code} (Codes associated with the substance.)
6274   */
6275  public List<SubstanceSpecificationCodeComponent> getCode() {
6276    if (this.code == null)
6277      this.code = new ArrayList<SubstanceSpecificationCodeComponent>();
6278    return this.code;
6279  }
6280
6281  /**
6282   * @return Returns a reference to <code>this</code> for easy method chaining
6283   */
6284  public SubstanceSpecification setCode(List<SubstanceSpecificationCodeComponent> theCode) {
6285    this.code = theCode;
6286    return this;
6287  }
6288
6289  public boolean hasCode() {
6290    if (this.code == null)
6291      return false;
6292    for (SubstanceSpecificationCodeComponent item : this.code)
6293      if (!item.isEmpty())
6294        return true;
6295    return false;
6296  }
6297
6298  public SubstanceSpecificationCodeComponent addCode() { // 3
6299    SubstanceSpecificationCodeComponent t = new SubstanceSpecificationCodeComponent();
6300    if (this.code == null)
6301      this.code = new ArrayList<SubstanceSpecificationCodeComponent>();
6302    this.code.add(t);
6303    return t;
6304  }
6305
6306  public SubstanceSpecification addCode(SubstanceSpecificationCodeComponent t) { // 3
6307    if (t == null)
6308      return this;
6309    if (this.code == null)
6310      this.code = new ArrayList<SubstanceSpecificationCodeComponent>();
6311    this.code.add(t);
6312    return this;
6313  }
6314
6315  /**
6316   * @return The first repetition of repeating field {@link #code}, creating it if
6317   *         it does not already exist
6318   */
6319  public SubstanceSpecificationCodeComponent getCodeFirstRep() {
6320    if (getCode().isEmpty()) {
6321      addCode();
6322    }
6323    return getCode().get(0);
6324  }
6325
6326  /**
6327   * @return {@link #name} (Names applicable to this substance.)
6328   */
6329  public List<SubstanceSpecificationNameComponent> getName() {
6330    if (this.name == null)
6331      this.name = new ArrayList<SubstanceSpecificationNameComponent>();
6332    return this.name;
6333  }
6334
6335  /**
6336   * @return Returns a reference to <code>this</code> for easy method chaining
6337   */
6338  public SubstanceSpecification setName(List<SubstanceSpecificationNameComponent> theName) {
6339    this.name = theName;
6340    return this;
6341  }
6342
6343  public boolean hasName() {
6344    if (this.name == null)
6345      return false;
6346    for (SubstanceSpecificationNameComponent item : this.name)
6347      if (!item.isEmpty())
6348        return true;
6349    return false;
6350  }
6351
6352  public SubstanceSpecificationNameComponent addName() { // 3
6353    SubstanceSpecificationNameComponent t = new SubstanceSpecificationNameComponent();
6354    if (this.name == null)
6355      this.name = new ArrayList<SubstanceSpecificationNameComponent>();
6356    this.name.add(t);
6357    return t;
6358  }
6359
6360  public SubstanceSpecification addName(SubstanceSpecificationNameComponent t) { // 3
6361    if (t == null)
6362      return this;
6363    if (this.name == null)
6364      this.name = new ArrayList<SubstanceSpecificationNameComponent>();
6365    this.name.add(t);
6366    return this;
6367  }
6368
6369  /**
6370   * @return The first repetition of repeating field {@link #name}, creating it if
6371   *         it does not already exist
6372   */
6373  public SubstanceSpecificationNameComponent getNameFirstRep() {
6374    if (getName().isEmpty()) {
6375      addName();
6376    }
6377    return getName().get(0);
6378  }
6379
6380  /**
6381   * @return {@link #molecularWeight} (The molecular weight or weight range (for
6382   *         proteins, polymers or nucleic acids).)
6383   */
6384  public List<SubstanceSpecificationStructureIsotopeMolecularWeightComponent> getMolecularWeight() {
6385    if (this.molecularWeight == null)
6386      this.molecularWeight = new ArrayList<SubstanceSpecificationStructureIsotopeMolecularWeightComponent>();
6387    return this.molecularWeight;
6388  }
6389
6390  /**
6391   * @return Returns a reference to <code>this</code> for easy method chaining
6392   */
6393  public SubstanceSpecification setMolecularWeight(
6394      List<SubstanceSpecificationStructureIsotopeMolecularWeightComponent> theMolecularWeight) {
6395    this.molecularWeight = theMolecularWeight;
6396    return this;
6397  }
6398
6399  public boolean hasMolecularWeight() {
6400    if (this.molecularWeight == null)
6401      return false;
6402    for (SubstanceSpecificationStructureIsotopeMolecularWeightComponent item : this.molecularWeight)
6403      if (!item.isEmpty())
6404        return true;
6405    return false;
6406  }
6407
6408  public SubstanceSpecificationStructureIsotopeMolecularWeightComponent addMolecularWeight() { // 3
6409    SubstanceSpecificationStructureIsotopeMolecularWeightComponent t = new SubstanceSpecificationStructureIsotopeMolecularWeightComponent();
6410    if (this.molecularWeight == null)
6411      this.molecularWeight = new ArrayList<SubstanceSpecificationStructureIsotopeMolecularWeightComponent>();
6412    this.molecularWeight.add(t);
6413    return t;
6414  }
6415
6416  public SubstanceSpecification addMolecularWeight(SubstanceSpecificationStructureIsotopeMolecularWeightComponent t) { // 3
6417    if (t == null)
6418      return this;
6419    if (this.molecularWeight == null)
6420      this.molecularWeight = new ArrayList<SubstanceSpecificationStructureIsotopeMolecularWeightComponent>();
6421    this.molecularWeight.add(t);
6422    return this;
6423  }
6424
6425  /**
6426   * @return The first repetition of repeating field {@link #molecularWeight},
6427   *         creating it if it does not already exist
6428   */
6429  public SubstanceSpecificationStructureIsotopeMolecularWeightComponent getMolecularWeightFirstRep() {
6430    if (getMolecularWeight().isEmpty()) {
6431      addMolecularWeight();
6432    }
6433    return getMolecularWeight().get(0);
6434  }
6435
6436  /**
6437   * @return {@link #relationship} (A link between this substance and another,
6438   *         with details of the relationship.)
6439   */
6440  public List<SubstanceSpecificationRelationshipComponent> getRelationship() {
6441    if (this.relationship == null)
6442      this.relationship = new ArrayList<SubstanceSpecificationRelationshipComponent>();
6443    return this.relationship;
6444  }
6445
6446  /**
6447   * @return Returns a reference to <code>this</code> for easy method chaining
6448   */
6449  public SubstanceSpecification setRelationship(List<SubstanceSpecificationRelationshipComponent> theRelationship) {
6450    this.relationship = theRelationship;
6451    return this;
6452  }
6453
6454  public boolean hasRelationship() {
6455    if (this.relationship == null)
6456      return false;
6457    for (SubstanceSpecificationRelationshipComponent item : this.relationship)
6458      if (!item.isEmpty())
6459        return true;
6460    return false;
6461  }
6462
6463  public SubstanceSpecificationRelationshipComponent addRelationship() { // 3
6464    SubstanceSpecificationRelationshipComponent t = new SubstanceSpecificationRelationshipComponent();
6465    if (this.relationship == null)
6466      this.relationship = new ArrayList<SubstanceSpecificationRelationshipComponent>();
6467    this.relationship.add(t);
6468    return t;
6469  }
6470
6471  public SubstanceSpecification addRelationship(SubstanceSpecificationRelationshipComponent t) { // 3
6472    if (t == null)
6473      return this;
6474    if (this.relationship == null)
6475      this.relationship = new ArrayList<SubstanceSpecificationRelationshipComponent>();
6476    this.relationship.add(t);
6477    return this;
6478  }
6479
6480  /**
6481   * @return The first repetition of repeating field {@link #relationship},
6482   *         creating it if it does not already exist
6483   */
6484  public SubstanceSpecificationRelationshipComponent getRelationshipFirstRep() {
6485    if (getRelationship().isEmpty()) {
6486      addRelationship();
6487    }
6488    return getRelationship().get(0);
6489  }
6490
6491  /**
6492   * @return {@link #nucleicAcid} (Data items specific to nucleic acids.)
6493   */
6494  public Reference getNucleicAcid() {
6495    if (this.nucleicAcid == null)
6496      if (Configuration.errorOnAutoCreate())
6497        throw new Error("Attempt to auto-create SubstanceSpecification.nucleicAcid");
6498      else if (Configuration.doAutoCreate())
6499        this.nucleicAcid = new Reference(); // cc
6500    return this.nucleicAcid;
6501  }
6502
6503  public boolean hasNucleicAcid() {
6504    return this.nucleicAcid != null && !this.nucleicAcid.isEmpty();
6505  }
6506
6507  /**
6508   * @param value {@link #nucleicAcid} (Data items specific to nucleic acids.)
6509   */
6510  public SubstanceSpecification setNucleicAcid(Reference value) {
6511    this.nucleicAcid = value;
6512    return this;
6513  }
6514
6515  /**
6516   * @return {@link #nucleicAcid} The actual object that is the target of the
6517   *         reference. The reference library doesn't populate this, but you can
6518   *         use it to hold the resource if you resolve it. (Data items specific
6519   *         to nucleic acids.)
6520   */
6521  public SubstanceNucleicAcid getNucleicAcidTarget() {
6522    if (this.nucleicAcidTarget == null)
6523      if (Configuration.errorOnAutoCreate())
6524        throw new Error("Attempt to auto-create SubstanceSpecification.nucleicAcid");
6525      else if (Configuration.doAutoCreate())
6526        this.nucleicAcidTarget = new SubstanceNucleicAcid(); // aa
6527    return this.nucleicAcidTarget;
6528  }
6529
6530  /**
6531   * @param value {@link #nucleicAcid} The actual object that is the target of the
6532   *              reference. The reference library doesn't use these, but you can
6533   *              use it to hold the resource if you resolve it. (Data items
6534   *              specific to nucleic acids.)
6535   */
6536  public SubstanceSpecification setNucleicAcidTarget(SubstanceNucleicAcid value) {
6537    this.nucleicAcidTarget = value;
6538    return this;
6539  }
6540
6541  /**
6542   * @return {@link #polymer} (Data items specific to polymers.)
6543   */
6544  public Reference getPolymer() {
6545    if (this.polymer == null)
6546      if (Configuration.errorOnAutoCreate())
6547        throw new Error("Attempt to auto-create SubstanceSpecification.polymer");
6548      else if (Configuration.doAutoCreate())
6549        this.polymer = new Reference(); // cc
6550    return this.polymer;
6551  }
6552
6553  public boolean hasPolymer() {
6554    return this.polymer != null && !this.polymer.isEmpty();
6555  }
6556
6557  /**
6558   * @param value {@link #polymer} (Data items specific to polymers.)
6559   */
6560  public SubstanceSpecification setPolymer(Reference value) {
6561    this.polymer = value;
6562    return this;
6563  }
6564
6565  /**
6566   * @return {@link #polymer} The actual object that is the target of the
6567   *         reference. The reference library doesn't populate this, but you can
6568   *         use it to hold the resource if you resolve it. (Data items specific
6569   *         to polymers.)
6570   */
6571  public SubstancePolymer getPolymerTarget() {
6572    if (this.polymerTarget == null)
6573      if (Configuration.errorOnAutoCreate())
6574        throw new Error("Attempt to auto-create SubstanceSpecification.polymer");
6575      else if (Configuration.doAutoCreate())
6576        this.polymerTarget = new SubstancePolymer(); // aa
6577    return this.polymerTarget;
6578  }
6579
6580  /**
6581   * @param value {@link #polymer} The actual object that is the target of the
6582   *              reference. The reference library doesn't use these, but you can
6583   *              use it to hold the resource if you resolve it. (Data items
6584   *              specific to polymers.)
6585   */
6586  public SubstanceSpecification setPolymerTarget(SubstancePolymer value) {
6587    this.polymerTarget = value;
6588    return this;
6589  }
6590
6591  /**
6592   * @return {@link #protein} (Data items specific to proteins.)
6593   */
6594  public Reference getProtein() {
6595    if (this.protein == null)
6596      if (Configuration.errorOnAutoCreate())
6597        throw new Error("Attempt to auto-create SubstanceSpecification.protein");
6598      else if (Configuration.doAutoCreate())
6599        this.protein = new Reference(); // cc
6600    return this.protein;
6601  }
6602
6603  public boolean hasProtein() {
6604    return this.protein != null && !this.protein.isEmpty();
6605  }
6606
6607  /**
6608   * @param value {@link #protein} (Data items specific to proteins.)
6609   */
6610  public SubstanceSpecification setProtein(Reference value) {
6611    this.protein = value;
6612    return this;
6613  }
6614
6615  /**
6616   * @return {@link #protein} The actual object that is the target of the
6617   *         reference. The reference library doesn't populate this, but you can
6618   *         use it to hold the resource if you resolve it. (Data items specific
6619   *         to proteins.)
6620   */
6621  public SubstanceProtein getProteinTarget() {
6622    if (this.proteinTarget == null)
6623      if (Configuration.errorOnAutoCreate())
6624        throw new Error("Attempt to auto-create SubstanceSpecification.protein");
6625      else if (Configuration.doAutoCreate())
6626        this.proteinTarget = new SubstanceProtein(); // aa
6627    return this.proteinTarget;
6628  }
6629
6630  /**
6631   * @param value {@link #protein} The actual object that is the target of the
6632   *              reference. The reference library doesn't use these, but you can
6633   *              use it to hold the resource if you resolve it. (Data items
6634   *              specific to proteins.)
6635   */
6636  public SubstanceSpecification setProteinTarget(SubstanceProtein value) {
6637    this.proteinTarget = value;
6638    return this;
6639  }
6640
6641  /**
6642   * @return {@link #sourceMaterial} (Material or taxonomic/anatomical source for
6643   *         the substance.)
6644   */
6645  public Reference getSourceMaterial() {
6646    if (this.sourceMaterial == null)
6647      if (Configuration.errorOnAutoCreate())
6648        throw new Error("Attempt to auto-create SubstanceSpecification.sourceMaterial");
6649      else if (Configuration.doAutoCreate())
6650        this.sourceMaterial = new Reference(); // cc
6651    return this.sourceMaterial;
6652  }
6653
6654  public boolean hasSourceMaterial() {
6655    return this.sourceMaterial != null && !this.sourceMaterial.isEmpty();
6656  }
6657
6658  /**
6659   * @param value {@link #sourceMaterial} (Material or taxonomic/anatomical source
6660   *              for the substance.)
6661   */
6662  public SubstanceSpecification setSourceMaterial(Reference value) {
6663    this.sourceMaterial = value;
6664    return this;
6665  }
6666
6667  /**
6668   * @return {@link #sourceMaterial} The actual object that is the target of the
6669   *         reference. The reference library doesn't populate this, but you can
6670   *         use it to hold the resource if you resolve it. (Material or
6671   *         taxonomic/anatomical source for the substance.)
6672   */
6673  public SubstanceSourceMaterial getSourceMaterialTarget() {
6674    if (this.sourceMaterialTarget == null)
6675      if (Configuration.errorOnAutoCreate())
6676        throw new Error("Attempt to auto-create SubstanceSpecification.sourceMaterial");
6677      else if (Configuration.doAutoCreate())
6678        this.sourceMaterialTarget = new SubstanceSourceMaterial(); // aa
6679    return this.sourceMaterialTarget;
6680  }
6681
6682  /**
6683   * @param value {@link #sourceMaterial} The actual object that is the target of
6684   *              the reference. The reference library doesn't use these, but you
6685   *              can use it to hold the resource if you resolve it. (Material or
6686   *              taxonomic/anatomical source for the substance.)
6687   */
6688  public SubstanceSpecification setSourceMaterialTarget(SubstanceSourceMaterial value) {
6689    this.sourceMaterialTarget = value;
6690    return this;
6691  }
6692
6693  protected void listChildren(List<Property> children) {
6694    super.listChildren(children);
6695    children.add(
6696        new Property("identifier", "Identifier", "Identifier by which this substance is known.", 0, 1, identifier));
6697    children.add(new Property("type", "CodeableConcept", "High level categorization, e.g. polymer or nucleic acid.", 0,
6698        1, type));
6699    children.add(new Property("status", "CodeableConcept", "Status of substance within the catalogue e.g. approved.", 0,
6700        1, status));
6701    children.add(new Property("domain", "CodeableConcept", "If the substance applies to only human or veterinary use.",
6702        0, 1, domain));
6703    children.add(new Property("description", "string", "Textual description of the substance.", 0, 1, description));
6704    children.add(new Property("source", "Reference(DocumentReference)", "Supporting literature.", 0,
6705        java.lang.Integer.MAX_VALUE, source));
6706    children.add(new Property("comment", "string", "Textual comment about this record of a substance.", 0, 1, comment));
6707    children.add(
6708        new Property("moiety", "", "Moiety, for structural modifications.", 0, java.lang.Integer.MAX_VALUE, moiety));
6709    children.add(new Property("property", "",
6710        "General specifications for this substance, including how it is related to other substances.", 0,
6711        java.lang.Integer.MAX_VALUE, property));
6712    children.add(new Property("referenceInformation", "Reference(SubstanceReferenceInformation)",
6713        "General information detailing this substance.", 0, 1, referenceInformation));
6714    children.add(new Property("structure", "", "Structural information.", 0, 1, structure));
6715    children
6716        .add(new Property("code", "", "Codes associated with the substance.", 0, java.lang.Integer.MAX_VALUE, code));
6717    children.add(new Property("name", "", "Names applicable to this substance.", 0, java.lang.Integer.MAX_VALUE, name));
6718    children.add(new Property("molecularWeight", "@SubstanceSpecification.structure.isotope.molecularWeight",
6719        "The molecular weight or weight range (for proteins, polymers or nucleic acids).", 0,
6720        java.lang.Integer.MAX_VALUE, molecularWeight));
6721    children.add(
6722        new Property("relationship", "", "A link between this substance and another, with details of the relationship.",
6723            0, java.lang.Integer.MAX_VALUE, relationship));
6724    children.add(new Property("nucleicAcid", "Reference(SubstanceNucleicAcid)", "Data items specific to nucleic acids.",
6725        0, 1, nucleicAcid));
6726    children
6727        .add(new Property("polymer", "Reference(SubstancePolymer)", "Data items specific to polymers.", 0, 1, polymer));
6728    children
6729        .add(new Property("protein", "Reference(SubstanceProtein)", "Data items specific to proteins.", 0, 1, protein));
6730    children.add(new Property("sourceMaterial", "Reference(SubstanceSourceMaterial)",
6731        "Material or taxonomic/anatomical source for the substance.", 0, 1, sourceMaterial));
6732  }
6733
6734  @Override
6735  public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
6736    switch (_hash) {
6737    case -1618432855:
6738      /* identifier */ return new Property("identifier", "Identifier", "Identifier by which this substance is known.",
6739          0, 1, identifier);
6740    case 3575610:
6741      /* type */ return new Property("type", "CodeableConcept",
6742          "High level categorization, e.g. polymer or nucleic acid.", 0, 1, type);
6743    case -892481550:
6744      /* status */ return new Property("status", "CodeableConcept",
6745          "Status of substance within the catalogue e.g. approved.", 0, 1, status);
6746    case -1326197564:
6747      /* domain */ return new Property("domain", "CodeableConcept",
6748          "If the substance applies to only human or veterinary use.", 0, 1, domain);
6749    case -1724546052:
6750      /* description */ return new Property("description", "string", "Textual description of the substance.", 0, 1,
6751          description);
6752    case -896505829:
6753      /* source */ return new Property("source", "Reference(DocumentReference)", "Supporting literature.", 0,
6754          java.lang.Integer.MAX_VALUE, source);
6755    case 950398559:
6756      /* comment */ return new Property("comment", "string", "Textual comment about this record of a substance.", 0, 1,
6757          comment);
6758    case -1068650173:
6759      /* moiety */ return new Property("moiety", "", "Moiety, for structural modifications.", 0,
6760          java.lang.Integer.MAX_VALUE, moiety);
6761    case -993141291:
6762      /* property */ return new Property("property", "",
6763          "General specifications for this substance, including how it is related to other substances.", 0,
6764          java.lang.Integer.MAX_VALUE, property);
6765    case -2117930783:
6766      /* referenceInformation */ return new Property("referenceInformation", "Reference(SubstanceReferenceInformation)",
6767          "General information detailing this substance.", 0, 1, referenceInformation);
6768    case 144518515:
6769      /* structure */ return new Property("structure", "", "Structural information.", 0, 1, structure);
6770    case 3059181:
6771      /* code */ return new Property("code", "", "Codes associated with the substance.", 0, java.lang.Integer.MAX_VALUE,
6772          code);
6773    case 3373707:
6774      /* name */ return new Property("name", "", "Names applicable to this substance.", 0, java.lang.Integer.MAX_VALUE,
6775          name);
6776    case 635625672:
6777      /* molecularWeight */ return new Property("molecularWeight",
6778          "@SubstanceSpecification.structure.isotope.molecularWeight",
6779          "The molecular weight or weight range (for proteins, polymers or nucleic acids).", 0,
6780          java.lang.Integer.MAX_VALUE, molecularWeight);
6781    case -261851592:
6782      /* relationship */ return new Property("relationship", "",
6783          "A link between this substance and another, with details of the relationship.", 0,
6784          java.lang.Integer.MAX_VALUE, relationship);
6785    case 1625275180:
6786      /* nucleicAcid */ return new Property("nucleicAcid", "Reference(SubstanceNucleicAcid)",
6787          "Data items specific to nucleic acids.", 0, 1, nucleicAcid);
6788    case -397514098:
6789      /* polymer */ return new Property("polymer", "Reference(SubstancePolymer)", "Data items specific to polymers.", 0,
6790          1, polymer);
6791    case -309012605:
6792      /* protein */ return new Property("protein", "Reference(SubstanceProtein)", "Data items specific to proteins.", 0,
6793          1, protein);
6794    case -1064442270:
6795      /* sourceMaterial */ return new Property("sourceMaterial", "Reference(SubstanceSourceMaterial)",
6796          "Material or taxonomic/anatomical source for the substance.", 0, 1, sourceMaterial);
6797    default:
6798      return super.getNamedProperty(_hash, _name, _checkValid);
6799    }
6800
6801  }
6802
6803  @Override
6804  public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
6805    switch (hash) {
6806    case -1618432855:
6807      /* identifier */ return this.identifier == null ? new Base[0] : new Base[] { this.identifier }; // Identifier
6808    case 3575610:
6809      /* type */ return this.type == null ? new Base[0] : new Base[] { this.type }; // CodeableConcept
6810    case -892481550:
6811      /* status */ return this.status == null ? new Base[0] : new Base[] { this.status }; // CodeableConcept
6812    case -1326197564:
6813      /* domain */ return this.domain == null ? new Base[0] : new Base[] { this.domain }; // CodeableConcept
6814    case -1724546052:
6815      /* description */ return this.description == null ? new Base[0] : new Base[] { this.description }; // StringType
6816    case -896505829:
6817      /* source */ return this.source == null ? new Base[0] : this.source.toArray(new Base[this.source.size()]); // Reference
6818    case 950398559:
6819      /* comment */ return this.comment == null ? new Base[0] : new Base[] { this.comment }; // StringType
6820    case -1068650173:
6821      /* moiety */ return this.moiety == null ? new Base[0] : this.moiety.toArray(new Base[this.moiety.size()]); // SubstanceSpecificationMoietyComponent
6822    case -993141291:
6823      /* property */ return this.property == null ? new Base[0] : this.property.toArray(new Base[this.property.size()]); // SubstanceSpecificationPropertyComponent
6824    case -2117930783:
6825      /* referenceInformation */ return this.referenceInformation == null ? new Base[0]
6826          : new Base[] { this.referenceInformation }; // Reference
6827    case 144518515:
6828      /* structure */ return this.structure == null ? new Base[0] : new Base[] { this.structure }; // SubstanceSpecificationStructureComponent
6829    case 3059181:
6830      /* code */ return this.code == null ? new Base[0] : this.code.toArray(new Base[this.code.size()]); // SubstanceSpecificationCodeComponent
6831    case 3373707:
6832      /* name */ return this.name == null ? new Base[0] : this.name.toArray(new Base[this.name.size()]); // SubstanceSpecificationNameComponent
6833    case 635625672:
6834      /* molecularWeight */ return this.molecularWeight == null ? new Base[0]
6835          : this.molecularWeight.toArray(new Base[this.molecularWeight.size()]); // SubstanceSpecificationStructureIsotopeMolecularWeightComponent
6836    case -261851592:
6837      /* relationship */ return this.relationship == null ? new Base[0]
6838          : this.relationship.toArray(new Base[this.relationship.size()]); // SubstanceSpecificationRelationshipComponent
6839    case 1625275180:
6840      /* nucleicAcid */ return this.nucleicAcid == null ? new Base[0] : new Base[] { this.nucleicAcid }; // Reference
6841    case -397514098:
6842      /* polymer */ return this.polymer == null ? new Base[0] : new Base[] { this.polymer }; // Reference
6843    case -309012605:
6844      /* protein */ return this.protein == null ? new Base[0] : new Base[] { this.protein }; // Reference
6845    case -1064442270:
6846      /* sourceMaterial */ return this.sourceMaterial == null ? new Base[0] : new Base[] { this.sourceMaterial }; // Reference
6847    default:
6848      return super.getProperty(hash, name, checkValid);
6849    }
6850
6851  }
6852
6853  @Override
6854  public Base setProperty(int hash, String name, Base value) throws FHIRException {
6855    switch (hash) {
6856    case -1618432855: // identifier
6857      this.identifier = castToIdentifier(value); // Identifier
6858      return value;
6859    case 3575610: // type
6860      this.type = castToCodeableConcept(value); // CodeableConcept
6861      return value;
6862    case -892481550: // status
6863      this.status = castToCodeableConcept(value); // CodeableConcept
6864      return value;
6865    case -1326197564: // domain
6866      this.domain = castToCodeableConcept(value); // CodeableConcept
6867      return value;
6868    case -1724546052: // description
6869      this.description = castToString(value); // StringType
6870      return value;
6871    case -896505829: // source
6872      this.getSource().add(castToReference(value)); // Reference
6873      return value;
6874    case 950398559: // comment
6875      this.comment = castToString(value); // StringType
6876      return value;
6877    case -1068650173: // moiety
6878      this.getMoiety().add((SubstanceSpecificationMoietyComponent) value); // SubstanceSpecificationMoietyComponent
6879      return value;
6880    case -993141291: // property
6881      this.getProperty().add((SubstanceSpecificationPropertyComponent) value); // SubstanceSpecificationPropertyComponent
6882      return value;
6883    case -2117930783: // referenceInformation
6884      this.referenceInformation = castToReference(value); // Reference
6885      return value;
6886    case 144518515: // structure
6887      this.structure = (SubstanceSpecificationStructureComponent) value; // SubstanceSpecificationStructureComponent
6888      return value;
6889    case 3059181: // code
6890      this.getCode().add((SubstanceSpecificationCodeComponent) value); // SubstanceSpecificationCodeComponent
6891      return value;
6892    case 3373707: // name
6893      this.getName().add((SubstanceSpecificationNameComponent) value); // SubstanceSpecificationNameComponent
6894      return value;
6895    case 635625672: // molecularWeight
6896      this.getMolecularWeight().add((SubstanceSpecificationStructureIsotopeMolecularWeightComponent) value); // SubstanceSpecificationStructureIsotopeMolecularWeightComponent
6897      return value;
6898    case -261851592: // relationship
6899      this.getRelationship().add((SubstanceSpecificationRelationshipComponent) value); // SubstanceSpecificationRelationshipComponent
6900      return value;
6901    case 1625275180: // nucleicAcid
6902      this.nucleicAcid = castToReference(value); // Reference
6903      return value;
6904    case -397514098: // polymer
6905      this.polymer = castToReference(value); // Reference
6906      return value;
6907    case -309012605: // protein
6908      this.protein = castToReference(value); // Reference
6909      return value;
6910    case -1064442270: // sourceMaterial
6911      this.sourceMaterial = castToReference(value); // Reference
6912      return value;
6913    default:
6914      return super.setProperty(hash, name, value);
6915    }
6916
6917  }
6918
6919  @Override
6920  public Base setProperty(String name, Base value) throws FHIRException {
6921    if (name.equals("identifier")) {
6922      this.identifier = castToIdentifier(value); // Identifier
6923    } else if (name.equals("type")) {
6924      this.type = castToCodeableConcept(value); // CodeableConcept
6925    } else if (name.equals("status")) {
6926      this.status = castToCodeableConcept(value); // CodeableConcept
6927    } else if (name.equals("domain")) {
6928      this.domain = castToCodeableConcept(value); // CodeableConcept
6929    } else if (name.equals("description")) {
6930      this.description = castToString(value); // StringType
6931    } else if (name.equals("source")) {
6932      this.getSource().add(castToReference(value));
6933    } else if (name.equals("comment")) {
6934      this.comment = castToString(value); // StringType
6935    } else if (name.equals("moiety")) {
6936      this.getMoiety().add((SubstanceSpecificationMoietyComponent) value);
6937    } else if (name.equals("property")) {
6938      this.getProperty().add((SubstanceSpecificationPropertyComponent) value);
6939    } else if (name.equals("referenceInformation")) {
6940      this.referenceInformation = castToReference(value); // Reference
6941    } else if (name.equals("structure")) {
6942      this.structure = (SubstanceSpecificationStructureComponent) value; // SubstanceSpecificationStructureComponent
6943    } else if (name.equals("code")) {
6944      this.getCode().add((SubstanceSpecificationCodeComponent) value);
6945    } else if (name.equals("name")) {
6946      this.getName().add((SubstanceSpecificationNameComponent) value);
6947    } else if (name.equals("molecularWeight")) {
6948      this.getMolecularWeight().add((SubstanceSpecificationStructureIsotopeMolecularWeightComponent) value);
6949    } else if (name.equals("relationship")) {
6950      this.getRelationship().add((SubstanceSpecificationRelationshipComponent) value);
6951    } else if (name.equals("nucleicAcid")) {
6952      this.nucleicAcid = castToReference(value); // Reference
6953    } else if (name.equals("polymer")) {
6954      this.polymer = castToReference(value); // Reference
6955    } else if (name.equals("protein")) {
6956      this.protein = castToReference(value); // Reference
6957    } else if (name.equals("sourceMaterial")) {
6958      this.sourceMaterial = castToReference(value); // Reference
6959    } else
6960      return super.setProperty(name, value);
6961    return value;
6962  }
6963
6964  @Override
6965  public void removeChild(String name, Base value) throws FHIRException {
6966    if (name.equals("identifier")) {
6967      this.identifier = null;
6968    } else if (name.equals("type")) {
6969      this.type = null;
6970    } else if (name.equals("status")) {
6971      this.status = null;
6972    } else if (name.equals("domain")) {
6973      this.domain = null;
6974    } else if (name.equals("description")) {
6975      this.description = null;
6976    } else if (name.equals("source")) {
6977      this.getSource().remove(castToReference(value));
6978    } else if (name.equals("comment")) {
6979      this.comment = null;
6980    } else if (name.equals("moiety")) {
6981      this.getMoiety().remove((SubstanceSpecificationMoietyComponent) value);
6982    } else if (name.equals("property")) {
6983      this.getProperty().remove((SubstanceSpecificationPropertyComponent) value);
6984    } else if (name.equals("referenceInformation")) {
6985      this.referenceInformation = null;
6986    } else if (name.equals("structure")) {
6987      this.structure = (SubstanceSpecificationStructureComponent) value; // SubstanceSpecificationStructureComponent
6988    } else if (name.equals("code")) {
6989      this.getCode().remove((SubstanceSpecificationCodeComponent) value);
6990    } else if (name.equals("name")) {
6991      this.getName().remove((SubstanceSpecificationNameComponent) value);
6992    } else if (name.equals("molecularWeight")) {
6993      this.getMolecularWeight().remove((SubstanceSpecificationStructureIsotopeMolecularWeightComponent) value);
6994    } else if (name.equals("relationship")) {
6995      this.getRelationship().remove((SubstanceSpecificationRelationshipComponent) value);
6996    } else if (name.equals("nucleicAcid")) {
6997      this.nucleicAcid = null;
6998    } else if (name.equals("polymer")) {
6999      this.polymer = null;
7000    } else if (name.equals("protein")) {
7001      this.protein = null;
7002    } else if (name.equals("sourceMaterial")) {
7003      this.sourceMaterial = null;
7004    } else
7005      super.removeChild(name, value);
7006    
7007  }
7008
7009  @Override
7010  public Base makeProperty(int hash, String name) throws FHIRException {
7011    switch (hash) {
7012    case -1618432855:
7013      return getIdentifier();
7014    case 3575610:
7015      return getType();
7016    case -892481550:
7017      return getStatus();
7018    case -1326197564:
7019      return getDomain();
7020    case -1724546052:
7021      return getDescriptionElement();
7022    case -896505829:
7023      return addSource();
7024    case 950398559:
7025      return getCommentElement();
7026    case -1068650173:
7027      return addMoiety();
7028    case -993141291:
7029      return addProperty();
7030    case -2117930783:
7031      return getReferenceInformation();
7032    case 144518515:
7033      return getStructure();
7034    case 3059181:
7035      return addCode();
7036    case 3373707:
7037      return addName();
7038    case 635625672:
7039      return addMolecularWeight();
7040    case -261851592:
7041      return addRelationship();
7042    case 1625275180:
7043      return getNucleicAcid();
7044    case -397514098:
7045      return getPolymer();
7046    case -309012605:
7047      return getProtein();
7048    case -1064442270:
7049      return getSourceMaterial();
7050    default:
7051      return super.makeProperty(hash, name);
7052    }
7053
7054  }
7055
7056  @Override
7057  public String[] getTypesForProperty(int hash, String name) throws FHIRException {
7058    switch (hash) {
7059    case -1618432855:
7060      /* identifier */ return new String[] { "Identifier" };
7061    case 3575610:
7062      /* type */ return new String[] { "CodeableConcept" };
7063    case -892481550:
7064      /* status */ return new String[] { "CodeableConcept" };
7065    case -1326197564:
7066      /* domain */ return new String[] { "CodeableConcept" };
7067    case -1724546052:
7068      /* description */ return new String[] { "string" };
7069    case -896505829:
7070      /* source */ return new String[] { "Reference" };
7071    case 950398559:
7072      /* comment */ return new String[] { "string" };
7073    case -1068650173:
7074      /* moiety */ return new String[] {};
7075    case -993141291:
7076      /* property */ return new String[] {};
7077    case -2117930783:
7078      /* referenceInformation */ return new String[] { "Reference" };
7079    case 144518515:
7080      /* structure */ return new String[] {};
7081    case 3059181:
7082      /* code */ return new String[] {};
7083    case 3373707:
7084      /* name */ return new String[] {};
7085    case 635625672:
7086      /* molecularWeight */ return new String[] { "@SubstanceSpecification.structure.isotope.molecularWeight" };
7087    case -261851592:
7088      /* relationship */ return new String[] {};
7089    case 1625275180:
7090      /* nucleicAcid */ return new String[] { "Reference" };
7091    case -397514098:
7092      /* polymer */ return new String[] { "Reference" };
7093    case -309012605:
7094      /* protein */ return new String[] { "Reference" };
7095    case -1064442270:
7096      /* sourceMaterial */ return new String[] { "Reference" };
7097    default:
7098      return super.getTypesForProperty(hash, name);
7099    }
7100
7101  }
7102
7103  @Override
7104  public Base addChild(String name) throws FHIRException {
7105    if (name.equals("identifier")) {
7106      this.identifier = new Identifier();
7107      return this.identifier;
7108    } else if (name.equals("type")) {
7109      this.type = new CodeableConcept();
7110      return this.type;
7111    } else if (name.equals("status")) {
7112      this.status = new CodeableConcept();
7113      return this.status;
7114    } else if (name.equals("domain")) {
7115      this.domain = new CodeableConcept();
7116      return this.domain;
7117    } else if (name.equals("description")) {
7118      throw new FHIRException("Cannot call addChild on a singleton property SubstanceSpecification.description");
7119    } else if (name.equals("source")) {
7120      return addSource();
7121    } else if (name.equals("comment")) {
7122      throw new FHIRException("Cannot call addChild on a singleton property SubstanceSpecification.comment");
7123    } else if (name.equals("moiety")) {
7124      return addMoiety();
7125    } else if (name.equals("property")) {
7126      return addProperty();
7127    } else if (name.equals("referenceInformation")) {
7128      this.referenceInformation = new Reference();
7129      return this.referenceInformation;
7130    } else if (name.equals("structure")) {
7131      this.structure = new SubstanceSpecificationStructureComponent();
7132      return this.structure;
7133    } else if (name.equals("code")) {
7134      return addCode();
7135    } else if (name.equals("name")) {
7136      return addName();
7137    } else if (name.equals("molecularWeight")) {
7138      return addMolecularWeight();
7139    } else if (name.equals("relationship")) {
7140      return addRelationship();
7141    } else if (name.equals("nucleicAcid")) {
7142      this.nucleicAcid = new Reference();
7143      return this.nucleicAcid;
7144    } else if (name.equals("polymer")) {
7145      this.polymer = new Reference();
7146      return this.polymer;
7147    } else if (name.equals("protein")) {
7148      this.protein = new Reference();
7149      return this.protein;
7150    } else if (name.equals("sourceMaterial")) {
7151      this.sourceMaterial = new Reference();
7152      return this.sourceMaterial;
7153    } else
7154      return super.addChild(name);
7155  }
7156
7157  public String fhirType() {
7158    return "SubstanceSpecification";
7159
7160  }
7161
7162  public SubstanceSpecification copy() {
7163    SubstanceSpecification dst = new SubstanceSpecification();
7164    copyValues(dst);
7165    return dst;
7166  }
7167
7168  public void copyValues(SubstanceSpecification dst) {
7169    super.copyValues(dst);
7170    dst.identifier = identifier == null ? null : identifier.copy();
7171    dst.type = type == null ? null : type.copy();
7172    dst.status = status == null ? null : status.copy();
7173    dst.domain = domain == null ? null : domain.copy();
7174    dst.description = description == null ? null : description.copy();
7175    if (source != null) {
7176      dst.source = new ArrayList<Reference>();
7177      for (Reference i : source)
7178        dst.source.add(i.copy());
7179    }
7180    ;
7181    dst.comment = comment == null ? null : comment.copy();
7182    if (moiety != null) {
7183      dst.moiety = new ArrayList<SubstanceSpecificationMoietyComponent>();
7184      for (SubstanceSpecificationMoietyComponent i : moiety)
7185        dst.moiety.add(i.copy());
7186    }
7187    ;
7188    if (property != null) {
7189      dst.property = new ArrayList<SubstanceSpecificationPropertyComponent>();
7190      for (SubstanceSpecificationPropertyComponent i : property)
7191        dst.property.add(i.copy());
7192    }
7193    ;
7194    dst.referenceInformation = referenceInformation == null ? null : referenceInformation.copy();
7195    dst.structure = structure == null ? null : structure.copy();
7196    if (code != null) {
7197      dst.code = new ArrayList<SubstanceSpecificationCodeComponent>();
7198      for (SubstanceSpecificationCodeComponent i : code)
7199        dst.code.add(i.copy());
7200    }
7201    ;
7202    if (name != null) {
7203      dst.name = new ArrayList<SubstanceSpecificationNameComponent>();
7204      for (SubstanceSpecificationNameComponent i : name)
7205        dst.name.add(i.copy());
7206    }
7207    ;
7208    if (molecularWeight != null) {
7209      dst.molecularWeight = new ArrayList<SubstanceSpecificationStructureIsotopeMolecularWeightComponent>();
7210      for (SubstanceSpecificationStructureIsotopeMolecularWeightComponent i : molecularWeight)
7211        dst.molecularWeight.add(i.copy());
7212    }
7213    ;
7214    if (relationship != null) {
7215      dst.relationship = new ArrayList<SubstanceSpecificationRelationshipComponent>();
7216      for (SubstanceSpecificationRelationshipComponent i : relationship)
7217        dst.relationship.add(i.copy());
7218    }
7219    ;
7220    dst.nucleicAcid = nucleicAcid == null ? null : nucleicAcid.copy();
7221    dst.polymer = polymer == null ? null : polymer.copy();
7222    dst.protein = protein == null ? null : protein.copy();
7223    dst.sourceMaterial = sourceMaterial == null ? null : sourceMaterial.copy();
7224  }
7225
7226  protected SubstanceSpecification typedCopy() {
7227    return copy();
7228  }
7229
7230  @Override
7231  public boolean equalsDeep(Base other_) {
7232    if (!super.equalsDeep(other_))
7233      return false;
7234    if (!(other_ instanceof SubstanceSpecification))
7235      return false;
7236    SubstanceSpecification o = (SubstanceSpecification) other_;
7237    return compareDeep(identifier, o.identifier, true) && compareDeep(type, o.type, true)
7238        && compareDeep(status, o.status, true) && compareDeep(domain, o.domain, true)
7239        && compareDeep(description, o.description, true) && compareDeep(source, o.source, true)
7240        && compareDeep(comment, o.comment, true) && compareDeep(moiety, o.moiety, true)
7241        && compareDeep(property, o.property, true) && compareDeep(referenceInformation, o.referenceInformation, true)
7242        && compareDeep(structure, o.structure, true) && compareDeep(code, o.code, true)
7243        && compareDeep(name, o.name, true) && compareDeep(molecularWeight, o.molecularWeight, true)
7244        && compareDeep(relationship, o.relationship, true) && compareDeep(nucleicAcid, o.nucleicAcid, true)
7245        && compareDeep(polymer, o.polymer, true) && compareDeep(protein, o.protein, true)
7246        && compareDeep(sourceMaterial, o.sourceMaterial, true);
7247  }
7248
7249  @Override
7250  public boolean equalsShallow(Base other_) {
7251    if (!super.equalsShallow(other_))
7252      return false;
7253    if (!(other_ instanceof SubstanceSpecification))
7254      return false;
7255    SubstanceSpecification o = (SubstanceSpecification) other_;
7256    return compareValues(description, o.description, true) && compareValues(comment, o.comment, true);
7257  }
7258
7259  public boolean isEmpty() {
7260    return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, type, status, domain, description,
7261        source, comment, moiety, property, referenceInformation, structure, code, name, molecularWeight, relationship,
7262        nucleicAcid, polymer, protein, sourceMaterial);
7263  }
7264
7265  @Override
7266  public ResourceType getResourceType() {
7267    return ResourceType.SubstanceSpecification;
7268  }
7269
7270  /**
7271   * Search parameter: <b>code</b>
7272   * <p>
7273   * Description: <b>The specific code</b><br>
7274   * Type: <b>token</b><br>
7275   * Path: <b>SubstanceSpecification.code.code</b><br>
7276   * </p>
7277   */
7278  @SearchParamDefinition(name = "code", path = "SubstanceSpecification.code.code", description = "The specific code", type = "token")
7279  public static final String SP_CODE = "code";
7280  /**
7281   * <b>Fluent Client</b> search parameter constant for <b>code</b>
7282   * <p>
7283   * Description: <b>The specific code</b><br>
7284   * Type: <b>token</b><br>
7285   * Path: <b>SubstanceSpecification.code.code</b><br>
7286   * </p>
7287   */
7288  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(
7289      SP_CODE);
7290
7291}