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