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