001package org.hl7.fhir.r5.model;
002
003
004/*
005  Copyright (c) 2011+, HL7, Inc.
006  All rights reserved.
007  
008  Redistribution and use in source and binary forms, with or without modification, \
009  are permitted provided that the following conditions are met:
010  
011   * Redistributions of source code must retain the above copyright notice, this \
012     list of conditions and the following disclaimer.
013   * Redistributions in binary form must reproduce the above copyright notice, \
014     this list of conditions and the following disclaimer in the documentation \
015     and/or other materials provided with the distribution.
016   * Neither the name of HL7 nor the names of its contributors may be used to 
017     endorse or promote products derived from this software without specific 
018     prior written permission.
019  
020  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
021  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
022  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
023  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
024  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
025  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
026  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
027  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
028  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
029  POSSIBILITY OF SUCH DAMAGE.
030  */
031
032// Generated on Thu, Mar 23, 2023 19:59+1100 for FHIR v5.0.0
033
034import java.util.ArrayList;
035import java.util.Date;
036import java.util.List;
037import org.hl7.fhir.utilities.Utilities;
038import org.hl7.fhir.r5.model.Enumerations.*;
039import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
040import org.hl7.fhir.exceptions.FHIRException;
041import org.hl7.fhir.instance.model.api.ICompositeType;
042import ca.uhn.fhir.model.api.annotation.ResourceDef;
043import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
044import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
045import ca.uhn.fhir.model.api.annotation.Child;
046import ca.uhn.fhir.model.api.annotation.ChildOrder;
047import ca.uhn.fhir.model.api.annotation.Description;
048import ca.uhn.fhir.model.api.annotation.Block;
049
050/**
051 * Properties of a substance specific to it being a polymer.
052 */
053@ResourceDef(name="SubstancePolymer", profile="http://hl7.org/fhir/StructureDefinition/SubstancePolymer")
054public class SubstancePolymer extends DomainResource {
055
056    @Block()
057    public static class SubstancePolymerMonomerSetComponent extends BackboneElement implements IBaseBackboneElement {
058        /**
059         * Captures the type of ratio to the entire polymer, e.g. Monomer/Polymer ratio, SRU/Polymer Ratio.
060         */
061        @Child(name = "ratioType", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
062        @Description(shortDefinition="Captures the type of ratio to the entire polymer, e.g. Monomer/Polymer ratio, SRU/Polymer Ratio", formalDefinition="Captures the type of ratio to the entire polymer, e.g. Monomer/Polymer ratio, SRU/Polymer Ratio." )
063        protected CodeableConcept ratioType;
064
065        /**
066         * The starting materials - monomer(s) used in the synthesis of the polymer.
067         */
068        @Child(name = "startingMaterial", type = {}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
069        @Description(shortDefinition="The starting materials - monomer(s) used in the synthesis of the polymer", formalDefinition="The starting materials - monomer(s) used in the synthesis of the polymer." )
070        protected List<SubstancePolymerMonomerSetStartingMaterialComponent> startingMaterial;
071
072        private static final long serialVersionUID = -933825014L;
073
074    /**
075     * Constructor
076     */
077      public SubstancePolymerMonomerSetComponent() {
078        super();
079      }
080
081        /**
082         * @return {@link #ratioType} (Captures the type of ratio to the entire polymer, e.g. Monomer/Polymer ratio, SRU/Polymer Ratio.)
083         */
084        public CodeableConcept getRatioType() { 
085          if (this.ratioType == null)
086            if (Configuration.errorOnAutoCreate())
087              throw new Error("Attempt to auto-create SubstancePolymerMonomerSetComponent.ratioType");
088            else if (Configuration.doAutoCreate())
089              this.ratioType = new CodeableConcept(); // cc
090          return this.ratioType;
091        }
092
093        public boolean hasRatioType() { 
094          return this.ratioType != null && !this.ratioType.isEmpty();
095        }
096
097        /**
098         * @param value {@link #ratioType} (Captures the type of ratio to the entire polymer, e.g. Monomer/Polymer ratio, SRU/Polymer Ratio.)
099         */
100        public SubstancePolymerMonomerSetComponent setRatioType(CodeableConcept value) { 
101          this.ratioType = value;
102          return this;
103        }
104
105        /**
106         * @return {@link #startingMaterial} (The starting materials - monomer(s) used in the synthesis of the polymer.)
107         */
108        public List<SubstancePolymerMonomerSetStartingMaterialComponent> getStartingMaterial() { 
109          if (this.startingMaterial == null)
110            this.startingMaterial = new ArrayList<SubstancePolymerMonomerSetStartingMaterialComponent>();
111          return this.startingMaterial;
112        }
113
114        /**
115         * @return Returns a reference to <code>this</code> for easy method chaining
116         */
117        public SubstancePolymerMonomerSetComponent setStartingMaterial(List<SubstancePolymerMonomerSetStartingMaterialComponent> theStartingMaterial) { 
118          this.startingMaterial = theStartingMaterial;
119          return this;
120        }
121
122        public boolean hasStartingMaterial() { 
123          if (this.startingMaterial == null)
124            return false;
125          for (SubstancePolymerMonomerSetStartingMaterialComponent item : this.startingMaterial)
126            if (!item.isEmpty())
127              return true;
128          return false;
129        }
130
131        public SubstancePolymerMonomerSetStartingMaterialComponent addStartingMaterial() { //3
132          SubstancePolymerMonomerSetStartingMaterialComponent t = new SubstancePolymerMonomerSetStartingMaterialComponent();
133          if (this.startingMaterial == null)
134            this.startingMaterial = new ArrayList<SubstancePolymerMonomerSetStartingMaterialComponent>();
135          this.startingMaterial.add(t);
136          return t;
137        }
138
139        public SubstancePolymerMonomerSetComponent addStartingMaterial(SubstancePolymerMonomerSetStartingMaterialComponent t) { //3
140          if (t == null)
141            return this;
142          if (this.startingMaterial == null)
143            this.startingMaterial = new ArrayList<SubstancePolymerMonomerSetStartingMaterialComponent>();
144          this.startingMaterial.add(t);
145          return this;
146        }
147
148        /**
149         * @return The first repetition of repeating field {@link #startingMaterial}, creating it if it does not already exist {3}
150         */
151        public SubstancePolymerMonomerSetStartingMaterialComponent getStartingMaterialFirstRep() { 
152          if (getStartingMaterial().isEmpty()) {
153            addStartingMaterial();
154          }
155          return getStartingMaterial().get(0);
156        }
157
158        protected void listChildren(List<Property> children) {
159          super.listChildren(children);
160          children.add(new Property("ratioType", "CodeableConcept", "Captures the type of ratio to the entire polymer, e.g. Monomer/Polymer ratio, SRU/Polymer Ratio.", 0, 1, ratioType));
161          children.add(new Property("startingMaterial", "", "The starting materials - monomer(s) used in the synthesis of the polymer.", 0, java.lang.Integer.MAX_VALUE, startingMaterial));
162        }
163
164        @Override
165        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
166          switch (_hash) {
167          case 344937957: /*ratioType*/  return new Property("ratioType", "CodeableConcept", "Captures the type of ratio to the entire polymer, e.g. Monomer/Polymer ratio, SRU/Polymer Ratio.", 0, 1, ratioType);
168          case 442919303: /*startingMaterial*/  return new Property("startingMaterial", "", "The starting materials - monomer(s) used in the synthesis of the polymer.", 0, java.lang.Integer.MAX_VALUE, startingMaterial);
169          default: return super.getNamedProperty(_hash, _name, _checkValid);
170          }
171
172        }
173
174      @Override
175      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
176        switch (hash) {
177        case 344937957: /*ratioType*/ return this.ratioType == null ? new Base[0] : new Base[] {this.ratioType}; // CodeableConcept
178        case 442919303: /*startingMaterial*/ return this.startingMaterial == null ? new Base[0] : this.startingMaterial.toArray(new Base[this.startingMaterial.size()]); // SubstancePolymerMonomerSetStartingMaterialComponent
179        default: return super.getProperty(hash, name, checkValid);
180        }
181
182      }
183
184      @Override
185      public Base setProperty(int hash, String name, Base value) throws FHIRException {
186        switch (hash) {
187        case 344937957: // ratioType
188          this.ratioType = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
189          return value;
190        case 442919303: // startingMaterial
191          this.getStartingMaterial().add((SubstancePolymerMonomerSetStartingMaterialComponent) value); // SubstancePolymerMonomerSetStartingMaterialComponent
192          return value;
193        default: return super.setProperty(hash, name, value);
194        }
195
196      }
197
198      @Override
199      public Base setProperty(String name, Base value) throws FHIRException {
200        if (name.equals("ratioType")) {
201          this.ratioType = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
202        } else if (name.equals("startingMaterial")) {
203          this.getStartingMaterial().add((SubstancePolymerMonomerSetStartingMaterialComponent) value);
204        } else
205          return super.setProperty(name, value);
206        return value;
207      }
208
209      @Override
210      public Base makeProperty(int hash, String name) throws FHIRException {
211        switch (hash) {
212        case 344937957:  return getRatioType();
213        case 442919303:  return addStartingMaterial(); 
214        default: return super.makeProperty(hash, name);
215        }
216
217      }
218
219      @Override
220      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
221        switch (hash) {
222        case 344937957: /*ratioType*/ return new String[] {"CodeableConcept"};
223        case 442919303: /*startingMaterial*/ return new String[] {};
224        default: return super.getTypesForProperty(hash, name);
225        }
226
227      }
228
229      @Override
230      public Base addChild(String name) throws FHIRException {
231        if (name.equals("ratioType")) {
232          this.ratioType = new CodeableConcept();
233          return this.ratioType;
234        }
235        else if (name.equals("startingMaterial")) {
236          return addStartingMaterial();
237        }
238        else
239          return super.addChild(name);
240      }
241
242      public SubstancePolymerMonomerSetComponent copy() {
243        SubstancePolymerMonomerSetComponent dst = new SubstancePolymerMonomerSetComponent();
244        copyValues(dst);
245        return dst;
246      }
247
248      public void copyValues(SubstancePolymerMonomerSetComponent dst) {
249        super.copyValues(dst);
250        dst.ratioType = ratioType == null ? null : ratioType.copy();
251        if (startingMaterial != null) {
252          dst.startingMaterial = new ArrayList<SubstancePolymerMonomerSetStartingMaterialComponent>();
253          for (SubstancePolymerMonomerSetStartingMaterialComponent i : startingMaterial)
254            dst.startingMaterial.add(i.copy());
255        };
256      }
257
258      @Override
259      public boolean equalsDeep(Base other_) {
260        if (!super.equalsDeep(other_))
261          return false;
262        if (!(other_ instanceof SubstancePolymerMonomerSetComponent))
263          return false;
264        SubstancePolymerMonomerSetComponent o = (SubstancePolymerMonomerSetComponent) other_;
265        return compareDeep(ratioType, o.ratioType, true) && compareDeep(startingMaterial, o.startingMaterial, true)
266          ;
267      }
268
269      @Override
270      public boolean equalsShallow(Base other_) {
271        if (!super.equalsShallow(other_))
272          return false;
273        if (!(other_ instanceof SubstancePolymerMonomerSetComponent))
274          return false;
275        SubstancePolymerMonomerSetComponent o = (SubstancePolymerMonomerSetComponent) other_;
276        return true;
277      }
278
279      public boolean isEmpty() {
280        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(ratioType, startingMaterial
281          );
282      }
283
284  public String fhirType() {
285    return "SubstancePolymer.monomerSet";
286
287  }
288
289  }
290
291    @Block()
292    public static class SubstancePolymerMonomerSetStartingMaterialComponent extends BackboneElement implements IBaseBackboneElement {
293        /**
294         * The type of substance for this starting material.
295         */
296        @Child(name = "code", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
297        @Description(shortDefinition="The type of substance for this starting material", formalDefinition="The type of substance for this starting material." )
298        protected CodeableConcept code;
299
300        /**
301         * Substance high level category, e.g. chemical substance.
302         */
303        @Child(name = "category", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
304        @Description(shortDefinition="Substance high level category, e.g. chemical substance", formalDefinition="Substance high level category, e.g. chemical substance." )
305        protected CodeableConcept category;
306
307        /**
308         * Used to specify whether the attribute described is a defining element for the unique identification of the polymer.
309         */
310        @Child(name = "isDefining", type = {BooleanType.class}, order=3, min=0, max=1, modifier=false, summary=true)
311        @Description(shortDefinition="Used to specify whether the attribute described is a defining element for the unique identification of the polymer", formalDefinition="Used to specify whether the attribute described is a defining element for the unique identification of the polymer." )
312        protected BooleanType isDefining;
313
314        /**
315         * A percentage.
316         */
317        @Child(name = "amount", type = {Quantity.class}, order=4, min=0, max=1, modifier=false, summary=true)
318        @Description(shortDefinition="A percentage", formalDefinition="A percentage." )
319        protected Quantity amount;
320
321        private static final long serialVersionUID = -1199515148L;
322
323    /**
324     * Constructor
325     */
326      public SubstancePolymerMonomerSetStartingMaterialComponent() {
327        super();
328      }
329
330        /**
331         * @return {@link #code} (The type of substance for this starting material.)
332         */
333        public CodeableConcept getCode() { 
334          if (this.code == null)
335            if (Configuration.errorOnAutoCreate())
336              throw new Error("Attempt to auto-create SubstancePolymerMonomerSetStartingMaterialComponent.code");
337            else if (Configuration.doAutoCreate())
338              this.code = new CodeableConcept(); // cc
339          return this.code;
340        }
341
342        public boolean hasCode() { 
343          return this.code != null && !this.code.isEmpty();
344        }
345
346        /**
347         * @param value {@link #code} (The type of substance for this starting material.)
348         */
349        public SubstancePolymerMonomerSetStartingMaterialComponent setCode(CodeableConcept value) { 
350          this.code = value;
351          return this;
352        }
353
354        /**
355         * @return {@link #category} (Substance high level category, e.g. chemical substance.)
356         */
357        public CodeableConcept getCategory() { 
358          if (this.category == null)
359            if (Configuration.errorOnAutoCreate())
360              throw new Error("Attempt to auto-create SubstancePolymerMonomerSetStartingMaterialComponent.category");
361            else if (Configuration.doAutoCreate())
362              this.category = new CodeableConcept(); // cc
363          return this.category;
364        }
365
366        public boolean hasCategory() { 
367          return this.category != null && !this.category.isEmpty();
368        }
369
370        /**
371         * @param value {@link #category} (Substance high level category, e.g. chemical substance.)
372         */
373        public SubstancePolymerMonomerSetStartingMaterialComponent setCategory(CodeableConcept value) { 
374          this.category = value;
375          return this;
376        }
377
378        /**
379         * @return {@link #isDefining} (Used to specify whether the attribute described is a defining element for the unique identification of the polymer.). This is the underlying object with id, value and extensions. The accessor "getIsDefining" gives direct access to the value
380         */
381        public BooleanType getIsDefiningElement() { 
382          if (this.isDefining == null)
383            if (Configuration.errorOnAutoCreate())
384              throw new Error("Attempt to auto-create SubstancePolymerMonomerSetStartingMaterialComponent.isDefining");
385            else if (Configuration.doAutoCreate())
386              this.isDefining = new BooleanType(); // bb
387          return this.isDefining;
388        }
389
390        public boolean hasIsDefiningElement() { 
391          return this.isDefining != null && !this.isDefining.isEmpty();
392        }
393
394        public boolean hasIsDefining() { 
395          return this.isDefining != null && !this.isDefining.isEmpty();
396        }
397
398        /**
399         * @param value {@link #isDefining} (Used to specify whether the attribute described is a defining element for the unique identification of the polymer.). This is the underlying object with id, value and extensions. The accessor "getIsDefining" gives direct access to the value
400         */
401        public SubstancePolymerMonomerSetStartingMaterialComponent setIsDefiningElement(BooleanType value) { 
402          this.isDefining = value;
403          return this;
404        }
405
406        /**
407         * @return Used to specify whether the attribute described is a defining element for the unique identification of the polymer.
408         */
409        public boolean getIsDefining() { 
410          return this.isDefining == null || this.isDefining.isEmpty() ? false : this.isDefining.getValue();
411        }
412
413        /**
414         * @param value Used to specify whether the attribute described is a defining element for the unique identification of the polymer.
415         */
416        public SubstancePolymerMonomerSetStartingMaterialComponent setIsDefining(boolean value) { 
417            if (this.isDefining == null)
418              this.isDefining = new BooleanType();
419            this.isDefining.setValue(value);
420          return this;
421        }
422
423        /**
424         * @return {@link #amount} (A percentage.)
425         */
426        public Quantity getAmount() { 
427          if (this.amount == null)
428            if (Configuration.errorOnAutoCreate())
429              throw new Error("Attempt to auto-create SubstancePolymerMonomerSetStartingMaterialComponent.amount");
430            else if (Configuration.doAutoCreate())
431              this.amount = new Quantity(); // cc
432          return this.amount;
433        }
434
435        public boolean hasAmount() { 
436          return this.amount != null && !this.amount.isEmpty();
437        }
438
439        /**
440         * @param value {@link #amount} (A percentage.)
441         */
442        public SubstancePolymerMonomerSetStartingMaterialComponent setAmount(Quantity value) { 
443          this.amount = value;
444          return this;
445        }
446
447        protected void listChildren(List<Property> children) {
448          super.listChildren(children);
449          children.add(new Property("code", "CodeableConcept", "The type of substance for this starting material.", 0, 1, code));
450          children.add(new Property("category", "CodeableConcept", "Substance high level category, e.g. chemical substance.", 0, 1, category));
451          children.add(new Property("isDefining", "boolean", "Used to specify whether the attribute described is a defining element for the unique identification of the polymer.", 0, 1, isDefining));
452          children.add(new Property("amount", "Quantity", "A percentage.", 0, 1, amount));
453        }
454
455        @Override
456        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
457          switch (_hash) {
458          case 3059181: /*code*/  return new Property("code", "CodeableConcept", "The type of substance for this starting material.", 0, 1, code);
459          case 50511102: /*category*/  return new Property("category", "CodeableConcept", "Substance high level category, e.g. chemical substance.", 0, 1, category);
460          case -141812990: /*isDefining*/  return new Property("isDefining", "boolean", "Used to specify whether the attribute described is a defining element for the unique identification of the polymer.", 0, 1, isDefining);
461          case -1413853096: /*amount*/  return new Property("amount", "Quantity", "A percentage.", 0, 1, amount);
462          default: return super.getNamedProperty(_hash, _name, _checkValid);
463          }
464
465        }
466
467      @Override
468      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
469        switch (hash) {
470        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept
471        case 50511102: /*category*/ return this.category == null ? new Base[0] : new Base[] {this.category}; // CodeableConcept
472        case -141812990: /*isDefining*/ return this.isDefining == null ? new Base[0] : new Base[] {this.isDefining}; // BooleanType
473        case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : new Base[] {this.amount}; // Quantity
474        default: return super.getProperty(hash, name, checkValid);
475        }
476
477      }
478
479      @Override
480      public Base setProperty(int hash, String name, Base value) throws FHIRException {
481        switch (hash) {
482        case 3059181: // code
483          this.code = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
484          return value;
485        case 50511102: // category
486          this.category = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
487          return value;
488        case -141812990: // isDefining
489          this.isDefining = TypeConvertor.castToBoolean(value); // BooleanType
490          return value;
491        case -1413853096: // amount
492          this.amount = TypeConvertor.castToQuantity(value); // Quantity
493          return value;
494        default: return super.setProperty(hash, name, value);
495        }
496
497      }
498
499      @Override
500      public Base setProperty(String name, Base value) throws FHIRException {
501        if (name.equals("code")) {
502          this.code = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
503        } else if (name.equals("category")) {
504          this.category = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
505        } else if (name.equals("isDefining")) {
506          this.isDefining = TypeConvertor.castToBoolean(value); // BooleanType
507        } else if (name.equals("amount")) {
508          this.amount = TypeConvertor.castToQuantity(value); // Quantity
509        } else
510          return super.setProperty(name, value);
511        return value;
512      }
513
514      @Override
515      public Base makeProperty(int hash, String name) throws FHIRException {
516        switch (hash) {
517        case 3059181:  return getCode();
518        case 50511102:  return getCategory();
519        case -141812990:  return getIsDefiningElement();
520        case -1413853096:  return getAmount();
521        default: return super.makeProperty(hash, name);
522        }
523
524      }
525
526      @Override
527      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
528        switch (hash) {
529        case 3059181: /*code*/ return new String[] {"CodeableConcept"};
530        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
531        case -141812990: /*isDefining*/ return new String[] {"boolean"};
532        case -1413853096: /*amount*/ return new String[] {"Quantity"};
533        default: return super.getTypesForProperty(hash, name);
534        }
535
536      }
537
538      @Override
539      public Base addChild(String name) throws FHIRException {
540        if (name.equals("code")) {
541          this.code = new CodeableConcept();
542          return this.code;
543        }
544        else if (name.equals("category")) {
545          this.category = new CodeableConcept();
546          return this.category;
547        }
548        else if (name.equals("isDefining")) {
549          throw new FHIRException("Cannot call addChild on a singleton property SubstancePolymer.monomerSet.startingMaterial.isDefining");
550        }
551        else if (name.equals("amount")) {
552          this.amount = new Quantity();
553          return this.amount;
554        }
555        else
556          return super.addChild(name);
557      }
558
559      public SubstancePolymerMonomerSetStartingMaterialComponent copy() {
560        SubstancePolymerMonomerSetStartingMaterialComponent dst = new SubstancePolymerMonomerSetStartingMaterialComponent();
561        copyValues(dst);
562        return dst;
563      }
564
565      public void copyValues(SubstancePolymerMonomerSetStartingMaterialComponent dst) {
566        super.copyValues(dst);
567        dst.code = code == null ? null : code.copy();
568        dst.category = category == null ? null : category.copy();
569        dst.isDefining = isDefining == null ? null : isDefining.copy();
570        dst.amount = amount == null ? null : amount.copy();
571      }
572
573      @Override
574      public boolean equalsDeep(Base other_) {
575        if (!super.equalsDeep(other_))
576          return false;
577        if (!(other_ instanceof SubstancePolymerMonomerSetStartingMaterialComponent))
578          return false;
579        SubstancePolymerMonomerSetStartingMaterialComponent o = (SubstancePolymerMonomerSetStartingMaterialComponent) other_;
580        return compareDeep(code, o.code, true) && compareDeep(category, o.category, true) && compareDeep(isDefining, o.isDefining, true)
581           && compareDeep(amount, o.amount, true);
582      }
583
584      @Override
585      public boolean equalsShallow(Base other_) {
586        if (!super.equalsShallow(other_))
587          return false;
588        if (!(other_ instanceof SubstancePolymerMonomerSetStartingMaterialComponent))
589          return false;
590        SubstancePolymerMonomerSetStartingMaterialComponent o = (SubstancePolymerMonomerSetStartingMaterialComponent) other_;
591        return compareValues(isDefining, o.isDefining, true);
592      }
593
594      public boolean isEmpty() {
595        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(code, category, isDefining
596          , amount);
597      }
598
599  public String fhirType() {
600    return "SubstancePolymer.monomerSet.startingMaterial";
601
602  }
603
604  }
605
606    @Block()
607    public static class SubstancePolymerRepeatComponent extends BackboneElement implements IBaseBackboneElement {
608        /**
609         * A representation of an (average) molecular formula from a polymer.
610         */
611        @Child(name = "averageMolecularFormula", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true)
612        @Description(shortDefinition="A representation of an (average) molecular formula from a polymer", formalDefinition="A representation of an (average) molecular formula from a polymer." )
613        protected StringType averageMolecularFormula;
614
615        /**
616         * How the quantitative amount of Structural Repeat Units is captured (e.g. Exact, Numeric, Average).
617         */
618        @Child(name = "repeatUnitAmountType", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
619        @Description(shortDefinition="How the quantitative amount of Structural Repeat Units is captured (e.g. Exact, Numeric, Average)", formalDefinition="How the quantitative amount of Structural Repeat Units is captured (e.g. Exact, Numeric, Average)." )
620        protected CodeableConcept repeatUnitAmountType;
621
622        /**
623         * An SRU - Structural Repeat Unit.
624         */
625        @Child(name = "repeatUnit", type = {}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
626        @Description(shortDefinition="An SRU - Structural Repeat Unit", formalDefinition="An SRU - Structural Repeat Unit." )
627        protected List<SubstancePolymerRepeatRepeatUnitComponent> repeatUnit;
628
629        private static final long serialVersionUID = -366644176L;
630
631    /**
632     * Constructor
633     */
634      public SubstancePolymerRepeatComponent() {
635        super();
636      }
637
638        /**
639         * @return {@link #averageMolecularFormula} (A representation of an (average) molecular formula from a polymer.). This is the underlying object with id, value and extensions. The accessor "getAverageMolecularFormula" gives direct access to the value
640         */
641        public StringType getAverageMolecularFormulaElement() { 
642          if (this.averageMolecularFormula == null)
643            if (Configuration.errorOnAutoCreate())
644              throw new Error("Attempt to auto-create SubstancePolymerRepeatComponent.averageMolecularFormula");
645            else if (Configuration.doAutoCreate())
646              this.averageMolecularFormula = new StringType(); // bb
647          return this.averageMolecularFormula;
648        }
649
650        public boolean hasAverageMolecularFormulaElement() { 
651          return this.averageMolecularFormula != null && !this.averageMolecularFormula.isEmpty();
652        }
653
654        public boolean hasAverageMolecularFormula() { 
655          return this.averageMolecularFormula != null && !this.averageMolecularFormula.isEmpty();
656        }
657
658        /**
659         * @param value {@link #averageMolecularFormula} (A representation of an (average) molecular formula from a polymer.). This is the underlying object with id, value and extensions. The accessor "getAverageMolecularFormula" gives direct access to the value
660         */
661        public SubstancePolymerRepeatComponent setAverageMolecularFormulaElement(StringType value) { 
662          this.averageMolecularFormula = value;
663          return this;
664        }
665
666        /**
667         * @return A representation of an (average) molecular formula from a polymer.
668         */
669        public String getAverageMolecularFormula() { 
670          return this.averageMolecularFormula == null ? null : this.averageMolecularFormula.getValue();
671        }
672
673        /**
674         * @param value A representation of an (average) molecular formula from a polymer.
675         */
676        public SubstancePolymerRepeatComponent setAverageMolecularFormula(String value) { 
677          if (Utilities.noString(value))
678            this.averageMolecularFormula = null;
679          else {
680            if (this.averageMolecularFormula == null)
681              this.averageMolecularFormula = new StringType();
682            this.averageMolecularFormula.setValue(value);
683          }
684          return this;
685        }
686
687        /**
688         * @return {@link #repeatUnitAmountType} (How the quantitative amount of Structural Repeat Units is captured (e.g. Exact, Numeric, Average).)
689         */
690        public CodeableConcept getRepeatUnitAmountType() { 
691          if (this.repeatUnitAmountType == null)
692            if (Configuration.errorOnAutoCreate())
693              throw new Error("Attempt to auto-create SubstancePolymerRepeatComponent.repeatUnitAmountType");
694            else if (Configuration.doAutoCreate())
695              this.repeatUnitAmountType = new CodeableConcept(); // cc
696          return this.repeatUnitAmountType;
697        }
698
699        public boolean hasRepeatUnitAmountType() { 
700          return this.repeatUnitAmountType != null && !this.repeatUnitAmountType.isEmpty();
701        }
702
703        /**
704         * @param value {@link #repeatUnitAmountType} (How the quantitative amount of Structural Repeat Units is captured (e.g. Exact, Numeric, Average).)
705         */
706        public SubstancePolymerRepeatComponent setRepeatUnitAmountType(CodeableConcept value) { 
707          this.repeatUnitAmountType = value;
708          return this;
709        }
710
711        /**
712         * @return {@link #repeatUnit} (An SRU - Structural Repeat Unit.)
713         */
714        public List<SubstancePolymerRepeatRepeatUnitComponent> getRepeatUnit() { 
715          if (this.repeatUnit == null)
716            this.repeatUnit = new ArrayList<SubstancePolymerRepeatRepeatUnitComponent>();
717          return this.repeatUnit;
718        }
719
720        /**
721         * @return Returns a reference to <code>this</code> for easy method chaining
722         */
723        public SubstancePolymerRepeatComponent setRepeatUnit(List<SubstancePolymerRepeatRepeatUnitComponent> theRepeatUnit) { 
724          this.repeatUnit = theRepeatUnit;
725          return this;
726        }
727
728        public boolean hasRepeatUnit() { 
729          if (this.repeatUnit == null)
730            return false;
731          for (SubstancePolymerRepeatRepeatUnitComponent item : this.repeatUnit)
732            if (!item.isEmpty())
733              return true;
734          return false;
735        }
736
737        public SubstancePolymerRepeatRepeatUnitComponent addRepeatUnit() { //3
738          SubstancePolymerRepeatRepeatUnitComponent t = new SubstancePolymerRepeatRepeatUnitComponent();
739          if (this.repeatUnit == null)
740            this.repeatUnit = new ArrayList<SubstancePolymerRepeatRepeatUnitComponent>();
741          this.repeatUnit.add(t);
742          return t;
743        }
744
745        public SubstancePolymerRepeatComponent addRepeatUnit(SubstancePolymerRepeatRepeatUnitComponent t) { //3
746          if (t == null)
747            return this;
748          if (this.repeatUnit == null)
749            this.repeatUnit = new ArrayList<SubstancePolymerRepeatRepeatUnitComponent>();
750          this.repeatUnit.add(t);
751          return this;
752        }
753
754        /**
755         * @return The first repetition of repeating field {@link #repeatUnit}, creating it if it does not already exist {3}
756         */
757        public SubstancePolymerRepeatRepeatUnitComponent getRepeatUnitFirstRep() { 
758          if (getRepeatUnit().isEmpty()) {
759            addRepeatUnit();
760          }
761          return getRepeatUnit().get(0);
762        }
763
764        protected void listChildren(List<Property> children) {
765          super.listChildren(children);
766          children.add(new Property("averageMolecularFormula", "string", "A representation of an (average) molecular formula from a polymer.", 0, 1, averageMolecularFormula));
767          children.add(new Property("repeatUnitAmountType", "CodeableConcept", "How the quantitative amount of Structural Repeat Units is captured (e.g. Exact, Numeric, Average).", 0, 1, repeatUnitAmountType));
768          children.add(new Property("repeatUnit", "", "An SRU - Structural Repeat Unit.", 0, java.lang.Integer.MAX_VALUE, repeatUnit));
769        }
770
771        @Override
772        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
773          switch (_hash) {
774          case 111461715: /*averageMolecularFormula*/  return new Property("averageMolecularFormula", "string", "A representation of an (average) molecular formula from a polymer.", 0, 1, averageMolecularFormula);
775          case -1994025263: /*repeatUnitAmountType*/  return new Property("repeatUnitAmountType", "CodeableConcept", "How the quantitative amount of Structural Repeat Units is captured (e.g. Exact, Numeric, Average).", 0, 1, repeatUnitAmountType);
776          case 1159607743: /*repeatUnit*/  return new Property("repeatUnit", "", "An SRU - Structural Repeat Unit.", 0, java.lang.Integer.MAX_VALUE, repeatUnit);
777          default: return super.getNamedProperty(_hash, _name, _checkValid);
778          }
779
780        }
781
782      @Override
783      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
784        switch (hash) {
785        case 111461715: /*averageMolecularFormula*/ return this.averageMolecularFormula == null ? new Base[0] : new Base[] {this.averageMolecularFormula}; // StringType
786        case -1994025263: /*repeatUnitAmountType*/ return this.repeatUnitAmountType == null ? new Base[0] : new Base[] {this.repeatUnitAmountType}; // CodeableConcept
787        case 1159607743: /*repeatUnit*/ return this.repeatUnit == null ? new Base[0] : this.repeatUnit.toArray(new Base[this.repeatUnit.size()]); // SubstancePolymerRepeatRepeatUnitComponent
788        default: return super.getProperty(hash, name, checkValid);
789        }
790
791      }
792
793      @Override
794      public Base setProperty(int hash, String name, Base value) throws FHIRException {
795        switch (hash) {
796        case 111461715: // averageMolecularFormula
797          this.averageMolecularFormula = TypeConvertor.castToString(value); // StringType
798          return value;
799        case -1994025263: // repeatUnitAmountType
800          this.repeatUnitAmountType = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
801          return value;
802        case 1159607743: // repeatUnit
803          this.getRepeatUnit().add((SubstancePolymerRepeatRepeatUnitComponent) value); // SubstancePolymerRepeatRepeatUnitComponent
804          return value;
805        default: return super.setProperty(hash, name, value);
806        }
807
808      }
809
810      @Override
811      public Base setProperty(String name, Base value) throws FHIRException {
812        if (name.equals("averageMolecularFormula")) {
813          this.averageMolecularFormula = TypeConvertor.castToString(value); // StringType
814        } else if (name.equals("repeatUnitAmountType")) {
815          this.repeatUnitAmountType = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
816        } else if (name.equals("repeatUnit")) {
817          this.getRepeatUnit().add((SubstancePolymerRepeatRepeatUnitComponent) value);
818        } else
819          return super.setProperty(name, value);
820        return value;
821      }
822
823      @Override
824      public Base makeProperty(int hash, String name) throws FHIRException {
825        switch (hash) {
826        case 111461715:  return getAverageMolecularFormulaElement();
827        case -1994025263:  return getRepeatUnitAmountType();
828        case 1159607743:  return addRepeatUnit(); 
829        default: return super.makeProperty(hash, name);
830        }
831
832      }
833
834      @Override
835      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
836        switch (hash) {
837        case 111461715: /*averageMolecularFormula*/ return new String[] {"string"};
838        case -1994025263: /*repeatUnitAmountType*/ return new String[] {"CodeableConcept"};
839        case 1159607743: /*repeatUnit*/ return new String[] {};
840        default: return super.getTypesForProperty(hash, name);
841        }
842
843      }
844
845      @Override
846      public Base addChild(String name) throws FHIRException {
847        if (name.equals("averageMolecularFormula")) {
848          throw new FHIRException("Cannot call addChild on a singleton property SubstancePolymer.repeat.averageMolecularFormula");
849        }
850        else if (name.equals("repeatUnitAmountType")) {
851          this.repeatUnitAmountType = new CodeableConcept();
852          return this.repeatUnitAmountType;
853        }
854        else if (name.equals("repeatUnit")) {
855          return addRepeatUnit();
856        }
857        else
858          return super.addChild(name);
859      }
860
861      public SubstancePolymerRepeatComponent copy() {
862        SubstancePolymerRepeatComponent dst = new SubstancePolymerRepeatComponent();
863        copyValues(dst);
864        return dst;
865      }
866
867      public void copyValues(SubstancePolymerRepeatComponent dst) {
868        super.copyValues(dst);
869        dst.averageMolecularFormula = averageMolecularFormula == null ? null : averageMolecularFormula.copy();
870        dst.repeatUnitAmountType = repeatUnitAmountType == null ? null : repeatUnitAmountType.copy();
871        if (repeatUnit != null) {
872          dst.repeatUnit = new ArrayList<SubstancePolymerRepeatRepeatUnitComponent>();
873          for (SubstancePolymerRepeatRepeatUnitComponent i : repeatUnit)
874            dst.repeatUnit.add(i.copy());
875        };
876      }
877
878      @Override
879      public boolean equalsDeep(Base other_) {
880        if (!super.equalsDeep(other_))
881          return false;
882        if (!(other_ instanceof SubstancePolymerRepeatComponent))
883          return false;
884        SubstancePolymerRepeatComponent o = (SubstancePolymerRepeatComponent) other_;
885        return compareDeep(averageMolecularFormula, o.averageMolecularFormula, true) && compareDeep(repeatUnitAmountType, o.repeatUnitAmountType, true)
886           && compareDeep(repeatUnit, o.repeatUnit, true);
887      }
888
889      @Override
890      public boolean equalsShallow(Base other_) {
891        if (!super.equalsShallow(other_))
892          return false;
893        if (!(other_ instanceof SubstancePolymerRepeatComponent))
894          return false;
895        SubstancePolymerRepeatComponent o = (SubstancePolymerRepeatComponent) other_;
896        return compareValues(averageMolecularFormula, o.averageMolecularFormula, true);
897      }
898
899      public boolean isEmpty() {
900        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(averageMolecularFormula, repeatUnitAmountType
901          , repeatUnit);
902      }
903
904  public String fhirType() {
905    return "SubstancePolymer.repeat";
906
907  }
908
909  }
910
911    @Block()
912    public static class SubstancePolymerRepeatRepeatUnitComponent extends BackboneElement implements IBaseBackboneElement {
913        /**
914         * Structural repeat units are essential elements for defining polymers.
915         */
916        @Child(name = "unit", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true)
917        @Description(shortDefinition="Structural repeat units are essential elements for defining polymers", formalDefinition="Structural repeat units are essential elements for defining polymers." )
918        protected StringType unit;
919
920        /**
921         * The orientation of the polymerisation, e.g. head-tail, head-head, random.
922         */
923        @Child(name = "orientation", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
924        @Description(shortDefinition="The orientation of the polymerisation, e.g. head-tail, head-head, random", formalDefinition="The orientation of the polymerisation, e.g. head-tail, head-head, random." )
925        protected CodeableConcept orientation;
926
927        /**
928         * Number of repeats of this unit.
929         */
930        @Child(name = "amount", type = {IntegerType.class}, order=3, min=0, max=1, modifier=false, summary=true)
931        @Description(shortDefinition="Number of repeats of this unit", formalDefinition="Number of repeats of this unit." )
932        protected IntegerType amount;
933
934        /**
935         * Applies to homopolymer and block co-polymers where the degree of polymerisation within a block can be described.
936         */
937        @Child(name = "degreeOfPolymerisation", type = {}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
938        @Description(shortDefinition="Applies to homopolymer and block co-polymers where the degree of polymerisation within a block can be described", formalDefinition="Applies to homopolymer and block co-polymers where the degree of polymerisation within a block can be described." )
939        protected List<SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent> degreeOfPolymerisation;
940
941        /**
942         * A graphical structure for this SRU.
943         */
944        @Child(name = "structuralRepresentation", type = {}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
945        @Description(shortDefinition="A graphical structure for this SRU", formalDefinition="A graphical structure for this SRU." )
946        protected List<SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent> structuralRepresentation;
947
948        private static final long serialVersionUID = 727054044L;
949
950    /**
951     * Constructor
952     */
953      public SubstancePolymerRepeatRepeatUnitComponent() {
954        super();
955      }
956
957        /**
958         * @return {@link #unit} (Structural repeat units are essential elements for defining polymers.). This is the underlying object with id, value and extensions. The accessor "getUnit" gives direct access to the value
959         */
960        public StringType getUnitElement() { 
961          if (this.unit == null)
962            if (Configuration.errorOnAutoCreate())
963              throw new Error("Attempt to auto-create SubstancePolymerRepeatRepeatUnitComponent.unit");
964            else if (Configuration.doAutoCreate())
965              this.unit = new StringType(); // bb
966          return this.unit;
967        }
968
969        public boolean hasUnitElement() { 
970          return this.unit != null && !this.unit.isEmpty();
971        }
972
973        public boolean hasUnit() { 
974          return this.unit != null && !this.unit.isEmpty();
975        }
976
977        /**
978         * @param value {@link #unit} (Structural repeat units are essential elements for defining polymers.). This is the underlying object with id, value and extensions. The accessor "getUnit" gives direct access to the value
979         */
980        public SubstancePolymerRepeatRepeatUnitComponent setUnitElement(StringType value) { 
981          this.unit = value;
982          return this;
983        }
984
985        /**
986         * @return Structural repeat units are essential elements for defining polymers.
987         */
988        public String getUnit() { 
989          return this.unit == null ? null : this.unit.getValue();
990        }
991
992        /**
993         * @param value Structural repeat units are essential elements for defining polymers.
994         */
995        public SubstancePolymerRepeatRepeatUnitComponent setUnit(String value) { 
996          if (Utilities.noString(value))
997            this.unit = null;
998          else {
999            if (this.unit == null)
1000              this.unit = new StringType();
1001            this.unit.setValue(value);
1002          }
1003          return this;
1004        }
1005
1006        /**
1007         * @return {@link #orientation} (The orientation of the polymerisation, e.g. head-tail, head-head, random.)
1008         */
1009        public CodeableConcept getOrientation() { 
1010          if (this.orientation == null)
1011            if (Configuration.errorOnAutoCreate())
1012              throw new Error("Attempt to auto-create SubstancePolymerRepeatRepeatUnitComponent.orientation");
1013            else if (Configuration.doAutoCreate())
1014              this.orientation = new CodeableConcept(); // cc
1015          return this.orientation;
1016        }
1017
1018        public boolean hasOrientation() { 
1019          return this.orientation != null && !this.orientation.isEmpty();
1020        }
1021
1022        /**
1023         * @param value {@link #orientation} (The orientation of the polymerisation, e.g. head-tail, head-head, random.)
1024         */
1025        public SubstancePolymerRepeatRepeatUnitComponent setOrientation(CodeableConcept value) { 
1026          this.orientation = value;
1027          return this;
1028        }
1029
1030        /**
1031         * @return {@link #amount} (Number of repeats of this unit.). This is the underlying object with id, value and extensions. The accessor "getAmount" gives direct access to the value
1032         */
1033        public IntegerType getAmountElement() { 
1034          if (this.amount == null)
1035            if (Configuration.errorOnAutoCreate())
1036              throw new Error("Attempt to auto-create SubstancePolymerRepeatRepeatUnitComponent.amount");
1037            else if (Configuration.doAutoCreate())
1038              this.amount = new IntegerType(); // bb
1039          return this.amount;
1040        }
1041
1042        public boolean hasAmountElement() { 
1043          return this.amount != null && !this.amount.isEmpty();
1044        }
1045
1046        public boolean hasAmount() { 
1047          return this.amount != null && !this.amount.isEmpty();
1048        }
1049
1050        /**
1051         * @param value {@link #amount} (Number of repeats of this unit.). This is the underlying object with id, value and extensions. The accessor "getAmount" gives direct access to the value
1052         */
1053        public SubstancePolymerRepeatRepeatUnitComponent setAmountElement(IntegerType value) { 
1054          this.amount = value;
1055          return this;
1056        }
1057
1058        /**
1059         * @return Number of repeats of this unit.
1060         */
1061        public int getAmount() { 
1062          return this.amount == null || this.amount.isEmpty() ? 0 : this.amount.getValue();
1063        }
1064
1065        /**
1066         * @param value Number of repeats of this unit.
1067         */
1068        public SubstancePolymerRepeatRepeatUnitComponent setAmount(int value) { 
1069            if (this.amount == null)
1070              this.amount = new IntegerType();
1071            this.amount.setValue(value);
1072          return this;
1073        }
1074
1075        /**
1076         * @return {@link #degreeOfPolymerisation} (Applies to homopolymer and block co-polymers where the degree of polymerisation within a block can be described.)
1077         */
1078        public List<SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent> getDegreeOfPolymerisation() { 
1079          if (this.degreeOfPolymerisation == null)
1080            this.degreeOfPolymerisation = new ArrayList<SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent>();
1081          return this.degreeOfPolymerisation;
1082        }
1083
1084        /**
1085         * @return Returns a reference to <code>this</code> for easy method chaining
1086         */
1087        public SubstancePolymerRepeatRepeatUnitComponent setDegreeOfPolymerisation(List<SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent> theDegreeOfPolymerisation) { 
1088          this.degreeOfPolymerisation = theDegreeOfPolymerisation;
1089          return this;
1090        }
1091
1092        public boolean hasDegreeOfPolymerisation() { 
1093          if (this.degreeOfPolymerisation == null)
1094            return false;
1095          for (SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent item : this.degreeOfPolymerisation)
1096            if (!item.isEmpty())
1097              return true;
1098          return false;
1099        }
1100
1101        public SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent addDegreeOfPolymerisation() { //3
1102          SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent t = new SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent();
1103          if (this.degreeOfPolymerisation == null)
1104            this.degreeOfPolymerisation = new ArrayList<SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent>();
1105          this.degreeOfPolymerisation.add(t);
1106          return t;
1107        }
1108
1109        public SubstancePolymerRepeatRepeatUnitComponent addDegreeOfPolymerisation(SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent t) { //3
1110          if (t == null)
1111            return this;
1112          if (this.degreeOfPolymerisation == null)
1113            this.degreeOfPolymerisation = new ArrayList<SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent>();
1114          this.degreeOfPolymerisation.add(t);
1115          return this;
1116        }
1117
1118        /**
1119         * @return The first repetition of repeating field {@link #degreeOfPolymerisation}, creating it if it does not already exist {3}
1120         */
1121        public SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent getDegreeOfPolymerisationFirstRep() { 
1122          if (getDegreeOfPolymerisation().isEmpty()) {
1123            addDegreeOfPolymerisation();
1124          }
1125          return getDegreeOfPolymerisation().get(0);
1126        }
1127
1128        /**
1129         * @return {@link #structuralRepresentation} (A graphical structure for this SRU.)
1130         */
1131        public List<SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent> getStructuralRepresentation() { 
1132          if (this.structuralRepresentation == null)
1133            this.structuralRepresentation = new ArrayList<SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent>();
1134          return this.structuralRepresentation;
1135        }
1136
1137        /**
1138         * @return Returns a reference to <code>this</code> for easy method chaining
1139         */
1140        public SubstancePolymerRepeatRepeatUnitComponent setStructuralRepresentation(List<SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent> theStructuralRepresentation) { 
1141          this.structuralRepresentation = theStructuralRepresentation;
1142          return this;
1143        }
1144
1145        public boolean hasStructuralRepresentation() { 
1146          if (this.structuralRepresentation == null)
1147            return false;
1148          for (SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent item : this.structuralRepresentation)
1149            if (!item.isEmpty())
1150              return true;
1151          return false;
1152        }
1153
1154        public SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent addStructuralRepresentation() { //3
1155          SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent t = new SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent();
1156          if (this.structuralRepresentation == null)
1157            this.structuralRepresentation = new ArrayList<SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent>();
1158          this.structuralRepresentation.add(t);
1159          return t;
1160        }
1161
1162        public SubstancePolymerRepeatRepeatUnitComponent addStructuralRepresentation(SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent t) { //3
1163          if (t == null)
1164            return this;
1165          if (this.structuralRepresentation == null)
1166            this.structuralRepresentation = new ArrayList<SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent>();
1167          this.structuralRepresentation.add(t);
1168          return this;
1169        }
1170
1171        /**
1172         * @return The first repetition of repeating field {@link #structuralRepresentation}, creating it if it does not already exist {3}
1173         */
1174        public SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent getStructuralRepresentationFirstRep() { 
1175          if (getStructuralRepresentation().isEmpty()) {
1176            addStructuralRepresentation();
1177          }
1178          return getStructuralRepresentation().get(0);
1179        }
1180
1181        protected void listChildren(List<Property> children) {
1182          super.listChildren(children);
1183          children.add(new Property("unit", "string", "Structural repeat units are essential elements for defining polymers.", 0, 1, unit));
1184          children.add(new Property("orientation", "CodeableConcept", "The orientation of the polymerisation, e.g. head-tail, head-head, random.", 0, 1, orientation));
1185          children.add(new Property("amount", "integer", "Number of repeats of this unit.", 0, 1, amount));
1186          children.add(new Property("degreeOfPolymerisation", "", "Applies to homopolymer and block co-polymers where the degree of polymerisation within a block can be described.", 0, java.lang.Integer.MAX_VALUE, degreeOfPolymerisation));
1187          children.add(new Property("structuralRepresentation", "", "A graphical structure for this SRU.", 0, java.lang.Integer.MAX_VALUE, structuralRepresentation));
1188        }
1189
1190        @Override
1191        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1192          switch (_hash) {
1193          case 3594628: /*unit*/  return new Property("unit", "string", "Structural repeat units are essential elements for defining polymers.", 0, 1, unit);
1194          case -1439500848: /*orientation*/  return new Property("orientation", "CodeableConcept", "The orientation of the polymerisation, e.g. head-tail, head-head, random.", 0, 1, orientation);
1195          case -1413853096: /*amount*/  return new Property("amount", "integer", "Number of repeats of this unit.", 0, 1, amount);
1196          case -159251872: /*degreeOfPolymerisation*/  return new Property("degreeOfPolymerisation", "", "Applies to homopolymer and block co-polymers where the degree of polymerisation within a block can be described.", 0, java.lang.Integer.MAX_VALUE, degreeOfPolymerisation);
1197          case 14311178: /*structuralRepresentation*/  return new Property("structuralRepresentation", "", "A graphical structure for this SRU.", 0, java.lang.Integer.MAX_VALUE, structuralRepresentation);
1198          default: return super.getNamedProperty(_hash, _name, _checkValid);
1199          }
1200
1201        }
1202
1203      @Override
1204      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1205        switch (hash) {
1206        case 3594628: /*unit*/ return this.unit == null ? new Base[0] : new Base[] {this.unit}; // StringType
1207        case -1439500848: /*orientation*/ return this.orientation == null ? new Base[0] : new Base[] {this.orientation}; // CodeableConcept
1208        case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : new Base[] {this.amount}; // IntegerType
1209        case -159251872: /*degreeOfPolymerisation*/ return this.degreeOfPolymerisation == null ? new Base[0] : this.degreeOfPolymerisation.toArray(new Base[this.degreeOfPolymerisation.size()]); // SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent
1210        case 14311178: /*structuralRepresentation*/ return this.structuralRepresentation == null ? new Base[0] : this.structuralRepresentation.toArray(new Base[this.structuralRepresentation.size()]); // SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent
1211        default: return super.getProperty(hash, name, checkValid);
1212        }
1213
1214      }
1215
1216      @Override
1217      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1218        switch (hash) {
1219        case 3594628: // unit
1220          this.unit = TypeConvertor.castToString(value); // StringType
1221          return value;
1222        case -1439500848: // orientation
1223          this.orientation = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1224          return value;
1225        case -1413853096: // amount
1226          this.amount = TypeConvertor.castToInteger(value); // IntegerType
1227          return value;
1228        case -159251872: // degreeOfPolymerisation
1229          this.getDegreeOfPolymerisation().add((SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent) value); // SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent
1230          return value;
1231        case 14311178: // structuralRepresentation
1232          this.getStructuralRepresentation().add((SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent) value); // SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent
1233          return value;
1234        default: return super.setProperty(hash, name, value);
1235        }
1236
1237      }
1238
1239      @Override
1240      public Base setProperty(String name, Base value) throws FHIRException {
1241        if (name.equals("unit")) {
1242          this.unit = TypeConvertor.castToString(value); // StringType
1243        } else if (name.equals("orientation")) {
1244          this.orientation = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1245        } else if (name.equals("amount")) {
1246          this.amount = TypeConvertor.castToInteger(value); // IntegerType
1247        } else if (name.equals("degreeOfPolymerisation")) {
1248          this.getDegreeOfPolymerisation().add((SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent) value);
1249        } else if (name.equals("structuralRepresentation")) {
1250          this.getStructuralRepresentation().add((SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent) value);
1251        } else
1252          return super.setProperty(name, value);
1253        return value;
1254      }
1255
1256      @Override
1257      public Base makeProperty(int hash, String name) throws FHIRException {
1258        switch (hash) {
1259        case 3594628:  return getUnitElement();
1260        case -1439500848:  return getOrientation();
1261        case -1413853096:  return getAmountElement();
1262        case -159251872:  return addDegreeOfPolymerisation(); 
1263        case 14311178:  return addStructuralRepresentation(); 
1264        default: return super.makeProperty(hash, name);
1265        }
1266
1267      }
1268
1269      @Override
1270      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1271        switch (hash) {
1272        case 3594628: /*unit*/ return new String[] {"string"};
1273        case -1439500848: /*orientation*/ return new String[] {"CodeableConcept"};
1274        case -1413853096: /*amount*/ return new String[] {"integer"};
1275        case -159251872: /*degreeOfPolymerisation*/ return new String[] {};
1276        case 14311178: /*structuralRepresentation*/ return new String[] {};
1277        default: return super.getTypesForProperty(hash, name);
1278        }
1279
1280      }
1281
1282      @Override
1283      public Base addChild(String name) throws FHIRException {
1284        if (name.equals("unit")) {
1285          throw new FHIRException("Cannot call addChild on a singleton property SubstancePolymer.repeat.repeatUnit.unit");
1286        }
1287        else if (name.equals("orientation")) {
1288          this.orientation = new CodeableConcept();
1289          return this.orientation;
1290        }
1291        else if (name.equals("amount")) {
1292          throw new FHIRException("Cannot call addChild on a singleton property SubstancePolymer.repeat.repeatUnit.amount");
1293        }
1294        else if (name.equals("degreeOfPolymerisation")) {
1295          return addDegreeOfPolymerisation();
1296        }
1297        else if (name.equals("structuralRepresentation")) {
1298          return addStructuralRepresentation();
1299        }
1300        else
1301          return super.addChild(name);
1302      }
1303
1304      public SubstancePolymerRepeatRepeatUnitComponent copy() {
1305        SubstancePolymerRepeatRepeatUnitComponent dst = new SubstancePolymerRepeatRepeatUnitComponent();
1306        copyValues(dst);
1307        return dst;
1308      }
1309
1310      public void copyValues(SubstancePolymerRepeatRepeatUnitComponent dst) {
1311        super.copyValues(dst);
1312        dst.unit = unit == null ? null : unit.copy();
1313        dst.orientation = orientation == null ? null : orientation.copy();
1314        dst.amount = amount == null ? null : amount.copy();
1315        if (degreeOfPolymerisation != null) {
1316          dst.degreeOfPolymerisation = new ArrayList<SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent>();
1317          for (SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent i : degreeOfPolymerisation)
1318            dst.degreeOfPolymerisation.add(i.copy());
1319        };
1320        if (structuralRepresentation != null) {
1321          dst.structuralRepresentation = new ArrayList<SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent>();
1322          for (SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent i : structuralRepresentation)
1323            dst.structuralRepresentation.add(i.copy());
1324        };
1325      }
1326
1327      @Override
1328      public boolean equalsDeep(Base other_) {
1329        if (!super.equalsDeep(other_))
1330          return false;
1331        if (!(other_ instanceof SubstancePolymerRepeatRepeatUnitComponent))
1332          return false;
1333        SubstancePolymerRepeatRepeatUnitComponent o = (SubstancePolymerRepeatRepeatUnitComponent) other_;
1334        return compareDeep(unit, o.unit, true) && compareDeep(orientation, o.orientation, true) && compareDeep(amount, o.amount, true)
1335           && compareDeep(degreeOfPolymerisation, o.degreeOfPolymerisation, true) && compareDeep(structuralRepresentation, o.structuralRepresentation, true)
1336          ;
1337      }
1338
1339      @Override
1340      public boolean equalsShallow(Base other_) {
1341        if (!super.equalsShallow(other_))
1342          return false;
1343        if (!(other_ instanceof SubstancePolymerRepeatRepeatUnitComponent))
1344          return false;
1345        SubstancePolymerRepeatRepeatUnitComponent o = (SubstancePolymerRepeatRepeatUnitComponent) other_;
1346        return compareValues(unit, o.unit, true) && compareValues(amount, o.amount, true);
1347      }
1348
1349      public boolean isEmpty() {
1350        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(unit, orientation, amount
1351          , degreeOfPolymerisation, structuralRepresentation);
1352      }
1353
1354  public String fhirType() {
1355    return "SubstancePolymer.repeat.repeatUnit";
1356
1357  }
1358
1359  }
1360
1361    @Block()
1362    public static class SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent extends BackboneElement implements IBaseBackboneElement {
1363        /**
1364         * The type of the degree of polymerisation shall be described, e.g. SRU/Polymer Ratio.
1365         */
1366        @Child(name = "type", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
1367        @Description(shortDefinition="The type of the degree of polymerisation shall be described, e.g. SRU/Polymer Ratio", formalDefinition="The type of the degree of polymerisation shall be described, e.g. SRU/Polymer Ratio." )
1368        protected CodeableConcept type;
1369
1370        /**
1371         * An average amount of polymerisation.
1372         */
1373        @Child(name = "average", type = {IntegerType.class}, order=2, min=0, max=1, modifier=false, summary=true)
1374        @Description(shortDefinition="An average amount of polymerisation", formalDefinition="An average amount of polymerisation." )
1375        protected IntegerType average;
1376
1377        /**
1378         * A low expected limit of the amount.
1379         */
1380        @Child(name = "low", type = {IntegerType.class}, order=3, min=0, max=1, modifier=false, summary=true)
1381        @Description(shortDefinition="A low expected limit of the amount", formalDefinition="A low expected limit of the amount." )
1382        protected IntegerType low;
1383
1384        /**
1385         * A high expected limit of the amount.
1386         */
1387        @Child(name = "high", type = {IntegerType.class}, order=4, min=0, max=1, modifier=false, summary=true)
1388        @Description(shortDefinition="A high expected limit of the amount", formalDefinition="A high expected limit of the amount." )
1389        protected IntegerType high;
1390
1391        private static final long serialVersionUID = -1950663748L;
1392
1393    /**
1394     * Constructor
1395     */
1396      public SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent() {
1397        super();
1398      }
1399
1400        /**
1401         * @return {@link #type} (The type of the degree of polymerisation shall be described, e.g. SRU/Polymer Ratio.)
1402         */
1403        public CodeableConcept getType() { 
1404          if (this.type == null)
1405            if (Configuration.errorOnAutoCreate())
1406              throw new Error("Attempt to auto-create SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent.type");
1407            else if (Configuration.doAutoCreate())
1408              this.type = new CodeableConcept(); // cc
1409          return this.type;
1410        }
1411
1412        public boolean hasType() { 
1413          return this.type != null && !this.type.isEmpty();
1414        }
1415
1416        /**
1417         * @param value {@link #type} (The type of the degree of polymerisation shall be described, e.g. SRU/Polymer Ratio.)
1418         */
1419        public SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent setType(CodeableConcept value) { 
1420          this.type = value;
1421          return this;
1422        }
1423
1424        /**
1425         * @return {@link #average} (An average amount of polymerisation.). This is the underlying object with id, value and extensions. The accessor "getAverage" gives direct access to the value
1426         */
1427        public IntegerType getAverageElement() { 
1428          if (this.average == null)
1429            if (Configuration.errorOnAutoCreate())
1430              throw new Error("Attempt to auto-create SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent.average");
1431            else if (Configuration.doAutoCreate())
1432              this.average = new IntegerType(); // bb
1433          return this.average;
1434        }
1435
1436        public boolean hasAverageElement() { 
1437          return this.average != null && !this.average.isEmpty();
1438        }
1439
1440        public boolean hasAverage() { 
1441          return this.average != null && !this.average.isEmpty();
1442        }
1443
1444        /**
1445         * @param value {@link #average} (An average amount of polymerisation.). This is the underlying object with id, value and extensions. The accessor "getAverage" gives direct access to the value
1446         */
1447        public SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent setAverageElement(IntegerType value) { 
1448          this.average = value;
1449          return this;
1450        }
1451
1452        /**
1453         * @return An average amount of polymerisation.
1454         */
1455        public int getAverage() { 
1456          return this.average == null || this.average.isEmpty() ? 0 : this.average.getValue();
1457        }
1458
1459        /**
1460         * @param value An average amount of polymerisation.
1461         */
1462        public SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent setAverage(int value) { 
1463            if (this.average == null)
1464              this.average = new IntegerType();
1465            this.average.setValue(value);
1466          return this;
1467        }
1468
1469        /**
1470         * @return {@link #low} (A low expected limit of the amount.). This is the underlying object with id, value and extensions. The accessor "getLow" gives direct access to the value
1471         */
1472        public IntegerType getLowElement() { 
1473          if (this.low == null)
1474            if (Configuration.errorOnAutoCreate())
1475              throw new Error("Attempt to auto-create SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent.low");
1476            else if (Configuration.doAutoCreate())
1477              this.low = new IntegerType(); // bb
1478          return this.low;
1479        }
1480
1481        public boolean hasLowElement() { 
1482          return this.low != null && !this.low.isEmpty();
1483        }
1484
1485        public boolean hasLow() { 
1486          return this.low != null && !this.low.isEmpty();
1487        }
1488
1489        /**
1490         * @param value {@link #low} (A low expected limit of the amount.). This is the underlying object with id, value and extensions. The accessor "getLow" gives direct access to the value
1491         */
1492        public SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent setLowElement(IntegerType value) { 
1493          this.low = value;
1494          return this;
1495        }
1496
1497        /**
1498         * @return A low expected limit of the amount.
1499         */
1500        public int getLow() { 
1501          return this.low == null || this.low.isEmpty() ? 0 : this.low.getValue();
1502        }
1503
1504        /**
1505         * @param value A low expected limit of the amount.
1506         */
1507        public SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent setLow(int value) { 
1508            if (this.low == null)
1509              this.low = new IntegerType();
1510            this.low.setValue(value);
1511          return this;
1512        }
1513
1514        /**
1515         * @return {@link #high} (A high expected limit of the amount.). This is the underlying object with id, value and extensions. The accessor "getHigh" gives direct access to the value
1516         */
1517        public IntegerType getHighElement() { 
1518          if (this.high == null)
1519            if (Configuration.errorOnAutoCreate())
1520              throw new Error("Attempt to auto-create SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent.high");
1521            else if (Configuration.doAutoCreate())
1522              this.high = new IntegerType(); // bb
1523          return this.high;
1524        }
1525
1526        public boolean hasHighElement() { 
1527          return this.high != null && !this.high.isEmpty();
1528        }
1529
1530        public boolean hasHigh() { 
1531          return this.high != null && !this.high.isEmpty();
1532        }
1533
1534        /**
1535         * @param value {@link #high} (A high expected limit of the amount.). This is the underlying object with id, value and extensions. The accessor "getHigh" gives direct access to the value
1536         */
1537        public SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent setHighElement(IntegerType value) { 
1538          this.high = value;
1539          return this;
1540        }
1541
1542        /**
1543         * @return A high expected limit of the amount.
1544         */
1545        public int getHigh() { 
1546          return this.high == null || this.high.isEmpty() ? 0 : this.high.getValue();
1547        }
1548
1549        /**
1550         * @param value A high expected limit of the amount.
1551         */
1552        public SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent setHigh(int value) { 
1553            if (this.high == null)
1554              this.high = new IntegerType();
1555            this.high.setValue(value);
1556          return this;
1557        }
1558
1559        protected void listChildren(List<Property> children) {
1560          super.listChildren(children);
1561          children.add(new Property("type", "CodeableConcept", "The type of the degree of polymerisation shall be described, e.g. SRU/Polymer Ratio.", 0, 1, type));
1562          children.add(new Property("average", "integer", "An average amount of polymerisation.", 0, 1, average));
1563          children.add(new Property("low", "integer", "A low expected limit of the amount.", 0, 1, low));
1564          children.add(new Property("high", "integer", "A high expected limit of the amount.", 0, 1, high));
1565        }
1566
1567        @Override
1568        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1569          switch (_hash) {
1570          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "The type of the degree of polymerisation shall be described, e.g. SRU/Polymer Ratio.", 0, 1, type);
1571          case -631448035: /*average*/  return new Property("average", "integer", "An average amount of polymerisation.", 0, 1, average);
1572          case 107348: /*low*/  return new Property("low", "integer", "A low expected limit of the amount.", 0, 1, low);
1573          case 3202466: /*high*/  return new Property("high", "integer", "A high expected limit of the amount.", 0, 1, high);
1574          default: return super.getNamedProperty(_hash, _name, _checkValid);
1575          }
1576
1577        }
1578
1579      @Override
1580      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1581        switch (hash) {
1582        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
1583        case -631448035: /*average*/ return this.average == null ? new Base[0] : new Base[] {this.average}; // IntegerType
1584        case 107348: /*low*/ return this.low == null ? new Base[0] : new Base[] {this.low}; // IntegerType
1585        case 3202466: /*high*/ return this.high == null ? new Base[0] : new Base[] {this.high}; // IntegerType
1586        default: return super.getProperty(hash, name, checkValid);
1587        }
1588
1589      }
1590
1591      @Override
1592      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1593        switch (hash) {
1594        case 3575610: // type
1595          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1596          return value;
1597        case -631448035: // average
1598          this.average = TypeConvertor.castToInteger(value); // IntegerType
1599          return value;
1600        case 107348: // low
1601          this.low = TypeConvertor.castToInteger(value); // IntegerType
1602          return value;
1603        case 3202466: // high
1604          this.high = TypeConvertor.castToInteger(value); // IntegerType
1605          return value;
1606        default: return super.setProperty(hash, name, value);
1607        }
1608
1609      }
1610
1611      @Override
1612      public Base setProperty(String name, Base value) throws FHIRException {
1613        if (name.equals("type")) {
1614          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1615        } else if (name.equals("average")) {
1616          this.average = TypeConvertor.castToInteger(value); // IntegerType
1617        } else if (name.equals("low")) {
1618          this.low = TypeConvertor.castToInteger(value); // IntegerType
1619        } else if (name.equals("high")) {
1620          this.high = TypeConvertor.castToInteger(value); // IntegerType
1621        } else
1622          return super.setProperty(name, value);
1623        return value;
1624      }
1625
1626      @Override
1627      public Base makeProperty(int hash, String name) throws FHIRException {
1628        switch (hash) {
1629        case 3575610:  return getType();
1630        case -631448035:  return getAverageElement();
1631        case 107348:  return getLowElement();
1632        case 3202466:  return getHighElement();
1633        default: return super.makeProperty(hash, name);
1634        }
1635
1636      }
1637
1638      @Override
1639      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1640        switch (hash) {
1641        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
1642        case -631448035: /*average*/ return new String[] {"integer"};
1643        case 107348: /*low*/ return new String[] {"integer"};
1644        case 3202466: /*high*/ return new String[] {"integer"};
1645        default: return super.getTypesForProperty(hash, name);
1646        }
1647
1648      }
1649
1650      @Override
1651      public Base addChild(String name) throws FHIRException {
1652        if (name.equals("type")) {
1653          this.type = new CodeableConcept();
1654          return this.type;
1655        }
1656        else if (name.equals("average")) {
1657          throw new FHIRException("Cannot call addChild on a singleton property SubstancePolymer.repeat.repeatUnit.degreeOfPolymerisation.average");
1658        }
1659        else if (name.equals("low")) {
1660          throw new FHIRException("Cannot call addChild on a singleton property SubstancePolymer.repeat.repeatUnit.degreeOfPolymerisation.low");
1661        }
1662        else if (name.equals("high")) {
1663          throw new FHIRException("Cannot call addChild on a singleton property SubstancePolymer.repeat.repeatUnit.degreeOfPolymerisation.high");
1664        }
1665        else
1666          return super.addChild(name);
1667      }
1668
1669      public SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent copy() {
1670        SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent dst = new SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent();
1671        copyValues(dst);
1672        return dst;
1673      }
1674
1675      public void copyValues(SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent dst) {
1676        super.copyValues(dst);
1677        dst.type = type == null ? null : type.copy();
1678        dst.average = average == null ? null : average.copy();
1679        dst.low = low == null ? null : low.copy();
1680        dst.high = high == null ? null : high.copy();
1681      }
1682
1683      @Override
1684      public boolean equalsDeep(Base other_) {
1685        if (!super.equalsDeep(other_))
1686          return false;
1687        if (!(other_ instanceof SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent))
1688          return false;
1689        SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent o = (SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent) other_;
1690        return compareDeep(type, o.type, true) && compareDeep(average, o.average, true) && compareDeep(low, o.low, true)
1691           && compareDeep(high, o.high, true);
1692      }
1693
1694      @Override
1695      public boolean equalsShallow(Base other_) {
1696        if (!super.equalsShallow(other_))
1697          return false;
1698        if (!(other_ instanceof SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent))
1699          return false;
1700        SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent o = (SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationComponent) other_;
1701        return compareValues(average, o.average, true) && compareValues(low, o.low, true) && compareValues(high, o.high, true)
1702          ;
1703      }
1704
1705      public boolean isEmpty() {
1706        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, average, low, high
1707          );
1708      }
1709
1710  public String fhirType() {
1711    return "SubstancePolymer.repeat.repeatUnit.degreeOfPolymerisation";
1712
1713  }
1714
1715  }
1716
1717    @Block()
1718    public static class SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent extends BackboneElement implements IBaseBackboneElement {
1719        /**
1720         * The type of structure (e.g. Full, Partial, Representative).
1721         */
1722        @Child(name = "type", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
1723        @Description(shortDefinition="The type of structure (e.g. Full, Partial, Representative)", formalDefinition="The type of structure (e.g. Full, Partial, Representative)." )
1724        protected CodeableConcept type;
1725
1726        /**
1727         * The structural representation as text string in a standard format e.g. InChI, SMILES, MOLFILE, CDX, SDF, PDB, mmCIF.
1728         */
1729        @Child(name = "representation", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=true)
1730        @Description(shortDefinition="The structural representation as text string in a standard format e.g. InChI, SMILES, MOLFILE, CDX, SDF, PDB, mmCIF", formalDefinition="The structural representation as text string in a standard format e.g. InChI, SMILES, MOLFILE, CDX, SDF, PDB, mmCIF." )
1731        protected StringType representation;
1732
1733        /**
1734         * The format of the representation e.g. InChI, SMILES, MOLFILE, CDX, SDF, PDB, mmCIF.
1735         */
1736        @Child(name = "format", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true)
1737        @Description(shortDefinition="The format of the representation e.g. InChI, SMILES, MOLFILE, CDX, SDF, PDB, mmCIF", formalDefinition="The format of the representation e.g. InChI, SMILES, MOLFILE, CDX, SDF, PDB, mmCIF." )
1738        protected CodeableConcept format;
1739
1740        /**
1741         * An attached file with the structural representation.
1742         */
1743        @Child(name = "attachment", type = {Attachment.class}, order=4, min=0, max=1, modifier=false, summary=true)
1744        @Description(shortDefinition="An attached file with the structural representation", formalDefinition="An attached file with the structural representation." )
1745        protected Attachment attachment;
1746
1747        private static final long serialVersionUID = -1385695515L;
1748
1749    /**
1750     * Constructor
1751     */
1752      public SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent() {
1753        super();
1754      }
1755
1756        /**
1757         * @return {@link #type} (The type of structure (e.g. Full, Partial, Representative).)
1758         */
1759        public CodeableConcept getType() { 
1760          if (this.type == null)
1761            if (Configuration.errorOnAutoCreate())
1762              throw new Error("Attempt to auto-create SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent.type");
1763            else if (Configuration.doAutoCreate())
1764              this.type = new CodeableConcept(); // cc
1765          return this.type;
1766        }
1767
1768        public boolean hasType() { 
1769          return this.type != null && !this.type.isEmpty();
1770        }
1771
1772        /**
1773         * @param value {@link #type} (The type of structure (e.g. Full, Partial, Representative).)
1774         */
1775        public SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent setType(CodeableConcept value) { 
1776          this.type = value;
1777          return this;
1778        }
1779
1780        /**
1781         * @return {@link #representation} (The structural representation as text string in a standard format e.g. InChI, SMILES, MOLFILE, CDX, SDF, PDB, mmCIF.). This is the underlying object with id, value and extensions. The accessor "getRepresentation" gives direct access to the value
1782         */
1783        public StringType getRepresentationElement() { 
1784          if (this.representation == null)
1785            if (Configuration.errorOnAutoCreate())
1786              throw new Error("Attempt to auto-create SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent.representation");
1787            else if (Configuration.doAutoCreate())
1788              this.representation = new StringType(); // bb
1789          return this.representation;
1790        }
1791
1792        public boolean hasRepresentationElement() { 
1793          return this.representation != null && !this.representation.isEmpty();
1794        }
1795
1796        public boolean hasRepresentation() { 
1797          return this.representation != null && !this.representation.isEmpty();
1798        }
1799
1800        /**
1801         * @param value {@link #representation} (The structural representation as text string in a standard format e.g. InChI, SMILES, MOLFILE, CDX, SDF, PDB, mmCIF.). This is the underlying object with id, value and extensions. The accessor "getRepresentation" gives direct access to the value
1802         */
1803        public SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent setRepresentationElement(StringType value) { 
1804          this.representation = value;
1805          return this;
1806        }
1807
1808        /**
1809         * @return The structural representation as text string in a standard format e.g. InChI, SMILES, MOLFILE, CDX, SDF, PDB, mmCIF.
1810         */
1811        public String getRepresentation() { 
1812          return this.representation == null ? null : this.representation.getValue();
1813        }
1814
1815        /**
1816         * @param value The structural representation as text string in a standard format e.g. InChI, SMILES, MOLFILE, CDX, SDF, PDB, mmCIF.
1817         */
1818        public SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent setRepresentation(String value) { 
1819          if (Utilities.noString(value))
1820            this.representation = null;
1821          else {
1822            if (this.representation == null)
1823              this.representation = new StringType();
1824            this.representation.setValue(value);
1825          }
1826          return this;
1827        }
1828
1829        /**
1830         * @return {@link #format} (The format of the representation e.g. InChI, SMILES, MOLFILE, CDX, SDF, PDB, mmCIF.)
1831         */
1832        public CodeableConcept getFormat() { 
1833          if (this.format == null)
1834            if (Configuration.errorOnAutoCreate())
1835              throw new Error("Attempt to auto-create SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent.format");
1836            else if (Configuration.doAutoCreate())
1837              this.format = new CodeableConcept(); // cc
1838          return this.format;
1839        }
1840
1841        public boolean hasFormat() { 
1842          return this.format != null && !this.format.isEmpty();
1843        }
1844
1845        /**
1846         * @param value {@link #format} (The format of the representation e.g. InChI, SMILES, MOLFILE, CDX, SDF, PDB, mmCIF.)
1847         */
1848        public SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent setFormat(CodeableConcept value) { 
1849          this.format = value;
1850          return this;
1851        }
1852
1853        /**
1854         * @return {@link #attachment} (An attached file with the structural representation.)
1855         */
1856        public Attachment getAttachment() { 
1857          if (this.attachment == null)
1858            if (Configuration.errorOnAutoCreate())
1859              throw new Error("Attempt to auto-create SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent.attachment");
1860            else if (Configuration.doAutoCreate())
1861              this.attachment = new Attachment(); // cc
1862          return this.attachment;
1863        }
1864
1865        public boolean hasAttachment() { 
1866          return this.attachment != null && !this.attachment.isEmpty();
1867        }
1868
1869        /**
1870         * @param value {@link #attachment} (An attached file with the structural representation.)
1871         */
1872        public SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent setAttachment(Attachment value) { 
1873          this.attachment = value;
1874          return this;
1875        }
1876
1877        protected void listChildren(List<Property> children) {
1878          super.listChildren(children);
1879          children.add(new Property("type", "CodeableConcept", "The type of structure (e.g. Full, Partial, Representative).", 0, 1, type));
1880          children.add(new Property("representation", "string", "The structural representation as text string in a standard format e.g. InChI, SMILES, MOLFILE, CDX, SDF, PDB, mmCIF.", 0, 1, representation));
1881          children.add(new Property("format", "CodeableConcept", "The format of the representation e.g. InChI, SMILES, MOLFILE, CDX, SDF, PDB, mmCIF.", 0, 1, format));
1882          children.add(new Property("attachment", "Attachment", "An attached file with the structural representation.", 0, 1, attachment));
1883        }
1884
1885        @Override
1886        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1887          switch (_hash) {
1888          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "The type of structure (e.g. Full, Partial, Representative).", 0, 1, type);
1889          case -671065907: /*representation*/  return new Property("representation", "string", "The structural representation as text string in a standard format e.g. InChI, SMILES, MOLFILE, CDX, SDF, PDB, mmCIF.", 0, 1, representation);
1890          case -1268779017: /*format*/  return new Property("format", "CodeableConcept", "The format of the representation e.g. InChI, SMILES, MOLFILE, CDX, SDF, PDB, mmCIF.", 0, 1, format);
1891          case -1963501277: /*attachment*/  return new Property("attachment", "Attachment", "An attached file with the structural representation.", 0, 1, attachment);
1892          default: return super.getNamedProperty(_hash, _name, _checkValid);
1893          }
1894
1895        }
1896
1897      @Override
1898      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1899        switch (hash) {
1900        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
1901        case -671065907: /*representation*/ return this.representation == null ? new Base[0] : new Base[] {this.representation}; // StringType
1902        case -1268779017: /*format*/ return this.format == null ? new Base[0] : new Base[] {this.format}; // CodeableConcept
1903        case -1963501277: /*attachment*/ return this.attachment == null ? new Base[0] : new Base[] {this.attachment}; // Attachment
1904        default: return super.getProperty(hash, name, checkValid);
1905        }
1906
1907      }
1908
1909      @Override
1910      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1911        switch (hash) {
1912        case 3575610: // type
1913          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1914          return value;
1915        case -671065907: // representation
1916          this.representation = TypeConvertor.castToString(value); // StringType
1917          return value;
1918        case -1268779017: // format
1919          this.format = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1920          return value;
1921        case -1963501277: // attachment
1922          this.attachment = TypeConvertor.castToAttachment(value); // Attachment
1923          return value;
1924        default: return super.setProperty(hash, name, value);
1925        }
1926
1927      }
1928
1929      @Override
1930      public Base setProperty(String name, Base value) throws FHIRException {
1931        if (name.equals("type")) {
1932          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1933        } else if (name.equals("representation")) {
1934          this.representation = TypeConvertor.castToString(value); // StringType
1935        } else if (name.equals("format")) {
1936          this.format = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1937        } else if (name.equals("attachment")) {
1938          this.attachment = TypeConvertor.castToAttachment(value); // Attachment
1939        } else
1940          return super.setProperty(name, value);
1941        return value;
1942      }
1943
1944      @Override
1945      public Base makeProperty(int hash, String name) throws FHIRException {
1946        switch (hash) {
1947        case 3575610:  return getType();
1948        case -671065907:  return getRepresentationElement();
1949        case -1268779017:  return getFormat();
1950        case -1963501277:  return getAttachment();
1951        default: return super.makeProperty(hash, name);
1952        }
1953
1954      }
1955
1956      @Override
1957      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1958        switch (hash) {
1959        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
1960        case -671065907: /*representation*/ return new String[] {"string"};
1961        case -1268779017: /*format*/ return new String[] {"CodeableConcept"};
1962        case -1963501277: /*attachment*/ return new String[] {"Attachment"};
1963        default: return super.getTypesForProperty(hash, name);
1964        }
1965
1966      }
1967
1968      @Override
1969      public Base addChild(String name) throws FHIRException {
1970        if (name.equals("type")) {
1971          this.type = new CodeableConcept();
1972          return this.type;
1973        }
1974        else if (name.equals("representation")) {
1975          throw new FHIRException("Cannot call addChild on a singleton property SubstancePolymer.repeat.repeatUnit.structuralRepresentation.representation");
1976        }
1977        else if (name.equals("format")) {
1978          this.format = new CodeableConcept();
1979          return this.format;
1980        }
1981        else if (name.equals("attachment")) {
1982          this.attachment = new Attachment();
1983          return this.attachment;
1984        }
1985        else
1986          return super.addChild(name);
1987      }
1988
1989      public SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent copy() {
1990        SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent dst = new SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent();
1991        copyValues(dst);
1992        return dst;
1993      }
1994
1995      public void copyValues(SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent dst) {
1996        super.copyValues(dst);
1997        dst.type = type == null ? null : type.copy();
1998        dst.representation = representation == null ? null : representation.copy();
1999        dst.format = format == null ? null : format.copy();
2000        dst.attachment = attachment == null ? null : attachment.copy();
2001      }
2002
2003      @Override
2004      public boolean equalsDeep(Base other_) {
2005        if (!super.equalsDeep(other_))
2006          return false;
2007        if (!(other_ instanceof SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent))
2008          return false;
2009        SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent o = (SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent) other_;
2010        return compareDeep(type, o.type, true) && compareDeep(representation, o.representation, true) && compareDeep(format, o.format, true)
2011           && compareDeep(attachment, o.attachment, true);
2012      }
2013
2014      @Override
2015      public boolean equalsShallow(Base other_) {
2016        if (!super.equalsShallow(other_))
2017          return false;
2018        if (!(other_ instanceof SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent))
2019          return false;
2020        SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent o = (SubstancePolymerRepeatRepeatUnitStructuralRepresentationComponent) other_;
2021        return compareValues(representation, o.representation, true);
2022      }
2023
2024      public boolean isEmpty() {
2025        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, representation, format
2026          , attachment);
2027      }
2028
2029  public String fhirType() {
2030    return "SubstancePolymer.repeat.repeatUnit.structuralRepresentation";
2031
2032  }
2033
2034  }
2035
2036    /**
2037     * A business idenfier for this polymer, but typically this is handled by a SubstanceDefinition identifier.
2038     */
2039    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=1, modifier=false, summary=true)
2040    @Description(shortDefinition="A business idenfier for this polymer, but typically this is handled by a SubstanceDefinition identifier", formalDefinition="A business idenfier for this polymer, but typically this is handled by a SubstanceDefinition identifier." )
2041    protected Identifier identifier;
2042
2043    /**
2044     * Overall type of the polymer.
2045     */
2046    @Child(name = "class", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
2047    @Description(shortDefinition="Overall type of the polymer", formalDefinition="Overall type of the polymer." )
2048    protected CodeableConcept class_;
2049
2050    /**
2051     * Polymer geometry, e.g. linear, branched, cross-linked, network or dendritic.
2052     */
2053    @Child(name = "geometry", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
2054    @Description(shortDefinition="Polymer geometry, e.g. linear, branched, cross-linked, network or dendritic", formalDefinition="Polymer geometry, e.g. linear, branched, cross-linked, network or dendritic." )
2055    protected CodeableConcept geometry;
2056
2057    /**
2058     * Descrtibes the copolymer sequence type (polymer connectivity).
2059     */
2060    @Child(name = "copolymerConnectivity", type = {CodeableConcept.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2061    @Description(shortDefinition="Descrtibes the copolymer sequence type (polymer connectivity)", formalDefinition="Descrtibes the copolymer sequence type (polymer connectivity)." )
2062    protected List<CodeableConcept> copolymerConnectivity;
2063
2064    /**
2065     * Todo - this is intended to connect to a repeating full modification structure, also used by Protein and Nucleic Acid . String is just a placeholder.
2066     */
2067    @Child(name = "modification", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=true)
2068    @Description(shortDefinition="Todo - this is intended to connect to a repeating full modification structure, also used by Protein and Nucleic Acid . String is just a placeholder", formalDefinition="Todo - this is intended to connect to a repeating full modification structure, also used by Protein and Nucleic Acid . String is just a placeholder." )
2069    protected StringType modification;
2070
2071    /**
2072     * Todo.
2073     */
2074    @Child(name = "monomerSet", type = {}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2075    @Description(shortDefinition="Todo", formalDefinition="Todo." )
2076    protected List<SubstancePolymerMonomerSetComponent> monomerSet;
2077
2078    /**
2079     * Specifies and quantifies the repeated units and their configuration.
2080     */
2081    @Child(name = "repeat", type = {}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2082    @Description(shortDefinition="Specifies and quantifies the repeated units and their configuration", formalDefinition="Specifies and quantifies the repeated units and their configuration." )
2083    protected List<SubstancePolymerRepeatComponent> repeat;
2084
2085    private static final long serialVersionUID = 11937102L;
2086
2087  /**
2088   * Constructor
2089   */
2090    public SubstancePolymer() {
2091      super();
2092    }
2093
2094    /**
2095     * @return {@link #identifier} (A business idenfier for this polymer, but typically this is handled by a SubstanceDefinition identifier.)
2096     */
2097    public Identifier getIdentifier() { 
2098      if (this.identifier == null)
2099        if (Configuration.errorOnAutoCreate())
2100          throw new Error("Attempt to auto-create SubstancePolymer.identifier");
2101        else if (Configuration.doAutoCreate())
2102          this.identifier = new Identifier(); // cc
2103      return this.identifier;
2104    }
2105
2106    public boolean hasIdentifier() { 
2107      return this.identifier != null && !this.identifier.isEmpty();
2108    }
2109
2110    /**
2111     * @param value {@link #identifier} (A business idenfier for this polymer, but typically this is handled by a SubstanceDefinition identifier.)
2112     */
2113    public SubstancePolymer setIdentifier(Identifier value) { 
2114      this.identifier = value;
2115      return this;
2116    }
2117
2118    /**
2119     * @return {@link #class_} (Overall type of the polymer.)
2120     */
2121    public CodeableConcept getClass_() { 
2122      if (this.class_ == null)
2123        if (Configuration.errorOnAutoCreate())
2124          throw new Error("Attempt to auto-create SubstancePolymer.class_");
2125        else if (Configuration.doAutoCreate())
2126          this.class_ = new CodeableConcept(); // cc
2127      return this.class_;
2128    }
2129
2130    public boolean hasClass_() { 
2131      return this.class_ != null && !this.class_.isEmpty();
2132    }
2133
2134    /**
2135     * @param value {@link #class_} (Overall type of the polymer.)
2136     */
2137    public SubstancePolymer setClass_(CodeableConcept value) { 
2138      this.class_ = value;
2139      return this;
2140    }
2141
2142    /**
2143     * @return {@link #geometry} (Polymer geometry, e.g. linear, branched, cross-linked, network or dendritic.)
2144     */
2145    public CodeableConcept getGeometry() { 
2146      if (this.geometry == null)
2147        if (Configuration.errorOnAutoCreate())
2148          throw new Error("Attempt to auto-create SubstancePolymer.geometry");
2149        else if (Configuration.doAutoCreate())
2150          this.geometry = new CodeableConcept(); // cc
2151      return this.geometry;
2152    }
2153
2154    public boolean hasGeometry() { 
2155      return this.geometry != null && !this.geometry.isEmpty();
2156    }
2157
2158    /**
2159     * @param value {@link #geometry} (Polymer geometry, e.g. linear, branched, cross-linked, network or dendritic.)
2160     */
2161    public SubstancePolymer setGeometry(CodeableConcept value) { 
2162      this.geometry = value;
2163      return this;
2164    }
2165
2166    /**
2167     * @return {@link #copolymerConnectivity} (Descrtibes the copolymer sequence type (polymer connectivity).)
2168     */
2169    public List<CodeableConcept> getCopolymerConnectivity() { 
2170      if (this.copolymerConnectivity == null)
2171        this.copolymerConnectivity = new ArrayList<CodeableConcept>();
2172      return this.copolymerConnectivity;
2173    }
2174
2175    /**
2176     * @return Returns a reference to <code>this</code> for easy method chaining
2177     */
2178    public SubstancePolymer setCopolymerConnectivity(List<CodeableConcept> theCopolymerConnectivity) { 
2179      this.copolymerConnectivity = theCopolymerConnectivity;
2180      return this;
2181    }
2182
2183    public boolean hasCopolymerConnectivity() { 
2184      if (this.copolymerConnectivity == null)
2185        return false;
2186      for (CodeableConcept item : this.copolymerConnectivity)
2187        if (!item.isEmpty())
2188          return true;
2189      return false;
2190    }
2191
2192    public CodeableConcept addCopolymerConnectivity() { //3
2193      CodeableConcept t = new CodeableConcept();
2194      if (this.copolymerConnectivity == null)
2195        this.copolymerConnectivity = new ArrayList<CodeableConcept>();
2196      this.copolymerConnectivity.add(t);
2197      return t;
2198    }
2199
2200    public SubstancePolymer addCopolymerConnectivity(CodeableConcept t) { //3
2201      if (t == null)
2202        return this;
2203      if (this.copolymerConnectivity == null)
2204        this.copolymerConnectivity = new ArrayList<CodeableConcept>();
2205      this.copolymerConnectivity.add(t);
2206      return this;
2207    }
2208
2209    /**
2210     * @return The first repetition of repeating field {@link #copolymerConnectivity}, creating it if it does not already exist {3}
2211     */
2212    public CodeableConcept getCopolymerConnectivityFirstRep() { 
2213      if (getCopolymerConnectivity().isEmpty()) {
2214        addCopolymerConnectivity();
2215      }
2216      return getCopolymerConnectivity().get(0);
2217    }
2218
2219    /**
2220     * @return {@link #modification} (Todo - this is intended to connect to a repeating full modification structure, also used by Protein and Nucleic Acid . String is just a placeholder.). This is the underlying object with id, value and extensions. The accessor "getModification" gives direct access to the value
2221     */
2222    public StringType getModificationElement() { 
2223      if (this.modification == null)
2224        if (Configuration.errorOnAutoCreate())
2225          throw new Error("Attempt to auto-create SubstancePolymer.modification");
2226        else if (Configuration.doAutoCreate())
2227          this.modification = new StringType(); // bb
2228      return this.modification;
2229    }
2230
2231    public boolean hasModificationElement() { 
2232      return this.modification != null && !this.modification.isEmpty();
2233    }
2234
2235    public boolean hasModification() { 
2236      return this.modification != null && !this.modification.isEmpty();
2237    }
2238
2239    /**
2240     * @param value {@link #modification} (Todo - this is intended to connect to a repeating full modification structure, also used by Protein and Nucleic Acid . String is just a placeholder.). This is the underlying object with id, value and extensions. The accessor "getModification" gives direct access to the value
2241     */
2242    public SubstancePolymer setModificationElement(StringType value) { 
2243      this.modification = value;
2244      return this;
2245    }
2246
2247    /**
2248     * @return Todo - this is intended to connect to a repeating full modification structure, also used by Protein and Nucleic Acid . String is just a placeholder.
2249     */
2250    public String getModification() { 
2251      return this.modification == null ? null : this.modification.getValue();
2252    }
2253
2254    /**
2255     * @param value Todo - this is intended to connect to a repeating full modification structure, also used by Protein and Nucleic Acid . String is just a placeholder.
2256     */
2257    public SubstancePolymer setModification(String value) { 
2258      if (Utilities.noString(value))
2259        this.modification = null;
2260      else {
2261        if (this.modification == null)
2262          this.modification = new StringType();
2263        this.modification.setValue(value);
2264      }
2265      return this;
2266    }
2267
2268    /**
2269     * @return {@link #monomerSet} (Todo.)
2270     */
2271    public List<SubstancePolymerMonomerSetComponent> getMonomerSet() { 
2272      if (this.monomerSet == null)
2273        this.monomerSet = new ArrayList<SubstancePolymerMonomerSetComponent>();
2274      return this.monomerSet;
2275    }
2276
2277    /**
2278     * @return Returns a reference to <code>this</code> for easy method chaining
2279     */
2280    public SubstancePolymer setMonomerSet(List<SubstancePolymerMonomerSetComponent> theMonomerSet) { 
2281      this.monomerSet = theMonomerSet;
2282      return this;
2283    }
2284
2285    public boolean hasMonomerSet() { 
2286      if (this.monomerSet == null)
2287        return false;
2288      for (SubstancePolymerMonomerSetComponent item : this.monomerSet)
2289        if (!item.isEmpty())
2290          return true;
2291      return false;
2292    }
2293
2294    public SubstancePolymerMonomerSetComponent addMonomerSet() { //3
2295      SubstancePolymerMonomerSetComponent t = new SubstancePolymerMonomerSetComponent();
2296      if (this.monomerSet == null)
2297        this.monomerSet = new ArrayList<SubstancePolymerMonomerSetComponent>();
2298      this.monomerSet.add(t);
2299      return t;
2300    }
2301
2302    public SubstancePolymer addMonomerSet(SubstancePolymerMonomerSetComponent t) { //3
2303      if (t == null)
2304        return this;
2305      if (this.monomerSet == null)
2306        this.monomerSet = new ArrayList<SubstancePolymerMonomerSetComponent>();
2307      this.monomerSet.add(t);
2308      return this;
2309    }
2310
2311    /**
2312     * @return The first repetition of repeating field {@link #monomerSet}, creating it if it does not already exist {3}
2313     */
2314    public SubstancePolymerMonomerSetComponent getMonomerSetFirstRep() { 
2315      if (getMonomerSet().isEmpty()) {
2316        addMonomerSet();
2317      }
2318      return getMonomerSet().get(0);
2319    }
2320
2321    /**
2322     * @return {@link #repeat} (Specifies and quantifies the repeated units and their configuration.)
2323     */
2324    public List<SubstancePolymerRepeatComponent> getRepeat() { 
2325      if (this.repeat == null)
2326        this.repeat = new ArrayList<SubstancePolymerRepeatComponent>();
2327      return this.repeat;
2328    }
2329
2330    /**
2331     * @return Returns a reference to <code>this</code> for easy method chaining
2332     */
2333    public SubstancePolymer setRepeat(List<SubstancePolymerRepeatComponent> theRepeat) { 
2334      this.repeat = theRepeat;
2335      return this;
2336    }
2337
2338    public boolean hasRepeat() { 
2339      if (this.repeat == null)
2340        return false;
2341      for (SubstancePolymerRepeatComponent item : this.repeat)
2342        if (!item.isEmpty())
2343          return true;
2344      return false;
2345    }
2346
2347    public SubstancePolymerRepeatComponent addRepeat() { //3
2348      SubstancePolymerRepeatComponent t = new SubstancePolymerRepeatComponent();
2349      if (this.repeat == null)
2350        this.repeat = new ArrayList<SubstancePolymerRepeatComponent>();
2351      this.repeat.add(t);
2352      return t;
2353    }
2354
2355    public SubstancePolymer addRepeat(SubstancePolymerRepeatComponent t) { //3
2356      if (t == null)
2357        return this;
2358      if (this.repeat == null)
2359        this.repeat = new ArrayList<SubstancePolymerRepeatComponent>();
2360      this.repeat.add(t);
2361      return this;
2362    }
2363
2364    /**
2365     * @return The first repetition of repeating field {@link #repeat}, creating it if it does not already exist {3}
2366     */
2367    public SubstancePolymerRepeatComponent getRepeatFirstRep() { 
2368      if (getRepeat().isEmpty()) {
2369        addRepeat();
2370      }
2371      return getRepeat().get(0);
2372    }
2373
2374      protected void listChildren(List<Property> children) {
2375        super.listChildren(children);
2376        children.add(new Property("identifier", "Identifier", "A business idenfier for this polymer, but typically this is handled by a SubstanceDefinition identifier.", 0, 1, identifier));
2377        children.add(new Property("class", "CodeableConcept", "Overall type of the polymer.", 0, 1, class_));
2378        children.add(new Property("geometry", "CodeableConcept", "Polymer geometry, e.g. linear, branched, cross-linked, network or dendritic.", 0, 1, geometry));
2379        children.add(new Property("copolymerConnectivity", "CodeableConcept", "Descrtibes the copolymer sequence type (polymer connectivity).", 0, java.lang.Integer.MAX_VALUE, copolymerConnectivity));
2380        children.add(new Property("modification", "string", "Todo - this is intended to connect to a repeating full modification structure, also used by Protein and Nucleic Acid . String is just a placeholder.", 0, 1, modification));
2381        children.add(new Property("monomerSet", "", "Todo.", 0, java.lang.Integer.MAX_VALUE, monomerSet));
2382        children.add(new Property("repeat", "", "Specifies and quantifies the repeated units and their configuration.", 0, java.lang.Integer.MAX_VALUE, repeat));
2383      }
2384
2385      @Override
2386      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2387        switch (_hash) {
2388        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "A business idenfier for this polymer, but typically this is handled by a SubstanceDefinition identifier.", 0, 1, identifier);
2389        case 94742904: /*class*/  return new Property("class", "CodeableConcept", "Overall type of the polymer.", 0, 1, class_);
2390        case 1846020210: /*geometry*/  return new Property("geometry", "CodeableConcept", "Polymer geometry, e.g. linear, branched, cross-linked, network or dendritic.", 0, 1, geometry);
2391        case 997107577: /*copolymerConnectivity*/  return new Property("copolymerConnectivity", "CodeableConcept", "Descrtibes the copolymer sequence type (polymer connectivity).", 0, java.lang.Integer.MAX_VALUE, copolymerConnectivity);
2392        case -684600932: /*modification*/  return new Property("modification", "string", "Todo - this is intended to connect to a repeating full modification structure, also used by Protein and Nucleic Acid . String is just a placeholder.", 0, 1, modification);
2393        case -1622483765: /*monomerSet*/  return new Property("monomerSet", "", "Todo.", 0, java.lang.Integer.MAX_VALUE, monomerSet);
2394        case -934531685: /*repeat*/  return new Property("repeat", "", "Specifies and quantifies the repeated units and their configuration.", 0, java.lang.Integer.MAX_VALUE, repeat);
2395        default: return super.getNamedProperty(_hash, _name, _checkValid);
2396        }
2397
2398      }
2399
2400      @Override
2401      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2402        switch (hash) {
2403        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : new Base[] {this.identifier}; // Identifier
2404        case 94742904: /*class*/ return this.class_ == null ? new Base[0] : new Base[] {this.class_}; // CodeableConcept
2405        case 1846020210: /*geometry*/ return this.geometry == null ? new Base[0] : new Base[] {this.geometry}; // CodeableConcept
2406        case 997107577: /*copolymerConnectivity*/ return this.copolymerConnectivity == null ? new Base[0] : this.copolymerConnectivity.toArray(new Base[this.copolymerConnectivity.size()]); // CodeableConcept
2407        case -684600932: /*modification*/ return this.modification == null ? new Base[0] : new Base[] {this.modification}; // StringType
2408        case -1622483765: /*monomerSet*/ return this.monomerSet == null ? new Base[0] : this.monomerSet.toArray(new Base[this.monomerSet.size()]); // SubstancePolymerMonomerSetComponent
2409        case -934531685: /*repeat*/ return this.repeat == null ? new Base[0] : this.repeat.toArray(new Base[this.repeat.size()]); // SubstancePolymerRepeatComponent
2410        default: return super.getProperty(hash, name, checkValid);
2411        }
2412
2413      }
2414
2415      @Override
2416      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2417        switch (hash) {
2418        case -1618432855: // identifier
2419          this.identifier = TypeConvertor.castToIdentifier(value); // Identifier
2420          return value;
2421        case 94742904: // class
2422          this.class_ = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
2423          return value;
2424        case 1846020210: // geometry
2425          this.geometry = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
2426          return value;
2427        case 997107577: // copolymerConnectivity
2428          this.getCopolymerConnectivity().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
2429          return value;
2430        case -684600932: // modification
2431          this.modification = TypeConvertor.castToString(value); // StringType
2432          return value;
2433        case -1622483765: // monomerSet
2434          this.getMonomerSet().add((SubstancePolymerMonomerSetComponent) value); // SubstancePolymerMonomerSetComponent
2435          return value;
2436        case -934531685: // repeat
2437          this.getRepeat().add((SubstancePolymerRepeatComponent) value); // SubstancePolymerRepeatComponent
2438          return value;
2439        default: return super.setProperty(hash, name, value);
2440        }
2441
2442      }
2443
2444      @Override
2445      public Base setProperty(String name, Base value) throws FHIRException {
2446        if (name.equals("identifier")) {
2447          this.identifier = TypeConvertor.castToIdentifier(value); // Identifier
2448        } else if (name.equals("class")) {
2449          this.class_ = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
2450        } else if (name.equals("geometry")) {
2451          this.geometry = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
2452        } else if (name.equals("copolymerConnectivity")) {
2453          this.getCopolymerConnectivity().add(TypeConvertor.castToCodeableConcept(value));
2454        } else if (name.equals("modification")) {
2455          this.modification = TypeConvertor.castToString(value); // StringType
2456        } else if (name.equals("monomerSet")) {
2457          this.getMonomerSet().add((SubstancePolymerMonomerSetComponent) value);
2458        } else if (name.equals("repeat")) {
2459          this.getRepeat().add((SubstancePolymerRepeatComponent) value);
2460        } else
2461          return super.setProperty(name, value);
2462        return value;
2463      }
2464
2465      @Override
2466      public Base makeProperty(int hash, String name) throws FHIRException {
2467        switch (hash) {
2468        case -1618432855:  return getIdentifier();
2469        case 94742904:  return getClass_();
2470        case 1846020210:  return getGeometry();
2471        case 997107577:  return addCopolymerConnectivity(); 
2472        case -684600932:  return getModificationElement();
2473        case -1622483765:  return addMonomerSet(); 
2474        case -934531685:  return addRepeat(); 
2475        default: return super.makeProperty(hash, name);
2476        }
2477
2478      }
2479
2480      @Override
2481      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2482        switch (hash) {
2483        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
2484        case 94742904: /*class*/ return new String[] {"CodeableConcept"};
2485        case 1846020210: /*geometry*/ return new String[] {"CodeableConcept"};
2486        case 997107577: /*copolymerConnectivity*/ return new String[] {"CodeableConcept"};
2487        case -684600932: /*modification*/ return new String[] {"string"};
2488        case -1622483765: /*monomerSet*/ return new String[] {};
2489        case -934531685: /*repeat*/ return new String[] {};
2490        default: return super.getTypesForProperty(hash, name);
2491        }
2492
2493      }
2494
2495      @Override
2496      public Base addChild(String name) throws FHIRException {
2497        if (name.equals("identifier")) {
2498          this.identifier = new Identifier();
2499          return this.identifier;
2500        }
2501        else if (name.equals("class")) {
2502          this.class_ = new CodeableConcept();
2503          return this.class_;
2504        }
2505        else if (name.equals("geometry")) {
2506          this.geometry = new CodeableConcept();
2507          return this.geometry;
2508        }
2509        else if (name.equals("copolymerConnectivity")) {
2510          return addCopolymerConnectivity();
2511        }
2512        else if (name.equals("modification")) {
2513          throw new FHIRException("Cannot call addChild on a singleton property SubstancePolymer.modification");
2514        }
2515        else if (name.equals("monomerSet")) {
2516          return addMonomerSet();
2517        }
2518        else if (name.equals("repeat")) {
2519          return addRepeat();
2520        }
2521        else
2522          return super.addChild(name);
2523      }
2524
2525  public String fhirType() {
2526    return "SubstancePolymer";
2527
2528  }
2529
2530      public SubstancePolymer copy() {
2531        SubstancePolymer dst = new SubstancePolymer();
2532        copyValues(dst);
2533        return dst;
2534      }
2535
2536      public void copyValues(SubstancePolymer dst) {
2537        super.copyValues(dst);
2538        dst.identifier = identifier == null ? null : identifier.copy();
2539        dst.class_ = class_ == null ? null : class_.copy();
2540        dst.geometry = geometry == null ? null : geometry.copy();
2541        if (copolymerConnectivity != null) {
2542          dst.copolymerConnectivity = new ArrayList<CodeableConcept>();
2543          for (CodeableConcept i : copolymerConnectivity)
2544            dst.copolymerConnectivity.add(i.copy());
2545        };
2546        dst.modification = modification == null ? null : modification.copy();
2547        if (monomerSet != null) {
2548          dst.monomerSet = new ArrayList<SubstancePolymerMonomerSetComponent>();
2549          for (SubstancePolymerMonomerSetComponent i : monomerSet)
2550            dst.monomerSet.add(i.copy());
2551        };
2552        if (repeat != null) {
2553          dst.repeat = new ArrayList<SubstancePolymerRepeatComponent>();
2554          for (SubstancePolymerRepeatComponent i : repeat)
2555            dst.repeat.add(i.copy());
2556        };
2557      }
2558
2559      protected SubstancePolymer typedCopy() {
2560        return copy();
2561      }
2562
2563      @Override
2564      public boolean equalsDeep(Base other_) {
2565        if (!super.equalsDeep(other_))
2566          return false;
2567        if (!(other_ instanceof SubstancePolymer))
2568          return false;
2569        SubstancePolymer o = (SubstancePolymer) other_;
2570        return compareDeep(identifier, o.identifier, true) && compareDeep(class_, o.class_, true) && compareDeep(geometry, o.geometry, true)
2571           && compareDeep(copolymerConnectivity, o.copolymerConnectivity, true) && compareDeep(modification, o.modification, true)
2572           && compareDeep(monomerSet, o.monomerSet, true) && compareDeep(repeat, o.repeat, true);
2573      }
2574
2575      @Override
2576      public boolean equalsShallow(Base other_) {
2577        if (!super.equalsShallow(other_))
2578          return false;
2579        if (!(other_ instanceof SubstancePolymer))
2580          return false;
2581        SubstancePolymer o = (SubstancePolymer) other_;
2582        return compareValues(modification, o.modification, true);
2583      }
2584
2585      public boolean isEmpty() {
2586        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, class_, geometry
2587          , copolymerConnectivity, modification, monomerSet, repeat);
2588      }
2589
2590  @Override
2591  public ResourceType getResourceType() {
2592    return ResourceType.SubstancePolymer;
2593   }
2594
2595
2596}
2597