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 Fri, Jul 15, 2022 11:20+1000 for FHIR v5.0.0-snapshot2
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 * Todo.
052 */
053@ResourceDef(name="SubstanceReferenceInformation", profile="http://hl7.org/fhir/StructureDefinition/SubstanceReferenceInformation")
054public class SubstanceReferenceInformation extends DomainResource {
055
056    @Block()
057    public static class SubstanceReferenceInformationGeneComponent extends BackboneElement implements IBaseBackboneElement {
058        /**
059         * Todo.
060         */
061        @Child(name = "geneSequenceOrigin", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
062        @Description(shortDefinition="Todo", formalDefinition="Todo." )
063        protected CodeableConcept geneSequenceOrigin;
064
065        /**
066         * Todo.
067         */
068        @Child(name = "gene", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
069        @Description(shortDefinition="Todo", formalDefinition="Todo." )
070        protected CodeableConcept gene;
071
072        /**
073         * Todo.
074         */
075        @Child(name = "source", type = {DocumentReference.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
076        @Description(shortDefinition="Todo", formalDefinition="Todo." )
077        protected List<Reference> source;
078
079        private static final long serialVersionUID = -1733820939L;
080
081    /**
082     * Constructor
083     */
084      public SubstanceReferenceInformationGeneComponent() {
085        super();
086      }
087
088        /**
089         * @return {@link #geneSequenceOrigin} (Todo.)
090         */
091        public CodeableConcept getGeneSequenceOrigin() { 
092          if (this.geneSequenceOrigin == null)
093            if (Configuration.errorOnAutoCreate())
094              throw new Error("Attempt to auto-create SubstanceReferenceInformationGeneComponent.geneSequenceOrigin");
095            else if (Configuration.doAutoCreate())
096              this.geneSequenceOrigin = new CodeableConcept(); // cc
097          return this.geneSequenceOrigin;
098        }
099
100        public boolean hasGeneSequenceOrigin() { 
101          return this.geneSequenceOrigin != null && !this.geneSequenceOrigin.isEmpty();
102        }
103
104        /**
105         * @param value {@link #geneSequenceOrigin} (Todo.)
106         */
107        public SubstanceReferenceInformationGeneComponent setGeneSequenceOrigin(CodeableConcept value) { 
108          this.geneSequenceOrigin = value;
109          return this;
110        }
111
112        /**
113         * @return {@link #gene} (Todo.)
114         */
115        public CodeableConcept getGene() { 
116          if (this.gene == null)
117            if (Configuration.errorOnAutoCreate())
118              throw new Error("Attempt to auto-create SubstanceReferenceInformationGeneComponent.gene");
119            else if (Configuration.doAutoCreate())
120              this.gene = new CodeableConcept(); // cc
121          return this.gene;
122        }
123
124        public boolean hasGene() { 
125          return this.gene != null && !this.gene.isEmpty();
126        }
127
128        /**
129         * @param value {@link #gene} (Todo.)
130         */
131        public SubstanceReferenceInformationGeneComponent setGene(CodeableConcept value) { 
132          this.gene = value;
133          return this;
134        }
135
136        /**
137         * @return {@link #source} (Todo.)
138         */
139        public List<Reference> getSource() { 
140          if (this.source == null)
141            this.source = new ArrayList<Reference>();
142          return this.source;
143        }
144
145        /**
146         * @return Returns a reference to <code>this</code> for easy method chaining
147         */
148        public SubstanceReferenceInformationGeneComponent setSource(List<Reference> theSource) { 
149          this.source = theSource;
150          return this;
151        }
152
153        public boolean hasSource() { 
154          if (this.source == null)
155            return false;
156          for (Reference item : this.source)
157            if (!item.isEmpty())
158              return true;
159          return false;
160        }
161
162        public Reference addSource() { //3
163          Reference t = new Reference();
164          if (this.source == null)
165            this.source = new ArrayList<Reference>();
166          this.source.add(t);
167          return t;
168        }
169
170        public SubstanceReferenceInformationGeneComponent addSource(Reference t) { //3
171          if (t == null)
172            return this;
173          if (this.source == null)
174            this.source = new ArrayList<Reference>();
175          this.source.add(t);
176          return this;
177        }
178
179        /**
180         * @return The first repetition of repeating field {@link #source}, creating it if it does not already exist {3}
181         */
182        public Reference getSourceFirstRep() { 
183          if (getSource().isEmpty()) {
184            addSource();
185          }
186          return getSource().get(0);
187        }
188
189        protected void listChildren(List<Property> children) {
190          super.listChildren(children);
191          children.add(new Property("geneSequenceOrigin", "CodeableConcept", "Todo.", 0, 1, geneSequenceOrigin));
192          children.add(new Property("gene", "CodeableConcept", "Todo.", 0, 1, gene));
193          children.add(new Property("source", "Reference(DocumentReference)", "Todo.", 0, java.lang.Integer.MAX_VALUE, source));
194        }
195
196        @Override
197        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
198          switch (_hash) {
199          case -1089463108: /*geneSequenceOrigin*/  return new Property("geneSequenceOrigin", "CodeableConcept", "Todo.", 0, 1, geneSequenceOrigin);
200          case 3169045: /*gene*/  return new Property("gene", "CodeableConcept", "Todo.", 0, 1, gene);
201          case -896505829: /*source*/  return new Property("source", "Reference(DocumentReference)", "Todo.", 0, java.lang.Integer.MAX_VALUE, source);
202          default: return super.getNamedProperty(_hash, _name, _checkValid);
203          }
204
205        }
206
207      @Override
208      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
209        switch (hash) {
210        case -1089463108: /*geneSequenceOrigin*/ return this.geneSequenceOrigin == null ? new Base[0] : new Base[] {this.geneSequenceOrigin}; // CodeableConcept
211        case 3169045: /*gene*/ return this.gene == null ? new Base[0] : new Base[] {this.gene}; // CodeableConcept
212        case -896505829: /*source*/ return this.source == null ? new Base[0] : this.source.toArray(new Base[this.source.size()]); // Reference
213        default: return super.getProperty(hash, name, checkValid);
214        }
215
216      }
217
218      @Override
219      public Base setProperty(int hash, String name, Base value) throws FHIRException {
220        switch (hash) {
221        case -1089463108: // geneSequenceOrigin
222          this.geneSequenceOrigin = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
223          return value;
224        case 3169045: // gene
225          this.gene = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
226          return value;
227        case -896505829: // source
228          this.getSource().add(TypeConvertor.castToReference(value)); // Reference
229          return value;
230        default: return super.setProperty(hash, name, value);
231        }
232
233      }
234
235      @Override
236      public Base setProperty(String name, Base value) throws FHIRException {
237        if (name.equals("geneSequenceOrigin")) {
238          this.geneSequenceOrigin = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
239        } else if (name.equals("gene")) {
240          this.gene = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
241        } else if (name.equals("source")) {
242          this.getSource().add(TypeConvertor.castToReference(value));
243        } else
244          return super.setProperty(name, value);
245        return value;
246      }
247
248      @Override
249      public Base makeProperty(int hash, String name) throws FHIRException {
250        switch (hash) {
251        case -1089463108:  return getGeneSequenceOrigin();
252        case 3169045:  return getGene();
253        case -896505829:  return addSource(); 
254        default: return super.makeProperty(hash, name);
255        }
256
257      }
258
259      @Override
260      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
261        switch (hash) {
262        case -1089463108: /*geneSequenceOrigin*/ return new String[] {"CodeableConcept"};
263        case 3169045: /*gene*/ return new String[] {"CodeableConcept"};
264        case -896505829: /*source*/ return new String[] {"Reference"};
265        default: return super.getTypesForProperty(hash, name);
266        }
267
268      }
269
270      @Override
271      public Base addChild(String name) throws FHIRException {
272        if (name.equals("geneSequenceOrigin")) {
273          this.geneSequenceOrigin = new CodeableConcept();
274          return this.geneSequenceOrigin;
275        }
276        else if (name.equals("gene")) {
277          this.gene = new CodeableConcept();
278          return this.gene;
279        }
280        else if (name.equals("source")) {
281          return addSource();
282        }
283        else
284          return super.addChild(name);
285      }
286
287      public SubstanceReferenceInformationGeneComponent copy() {
288        SubstanceReferenceInformationGeneComponent dst = new SubstanceReferenceInformationGeneComponent();
289        copyValues(dst);
290        return dst;
291      }
292
293      public void copyValues(SubstanceReferenceInformationGeneComponent dst) {
294        super.copyValues(dst);
295        dst.geneSequenceOrigin = geneSequenceOrigin == null ? null : geneSequenceOrigin.copy();
296        dst.gene = gene == null ? null : gene.copy();
297        if (source != null) {
298          dst.source = new ArrayList<Reference>();
299          for (Reference i : source)
300            dst.source.add(i.copy());
301        };
302      }
303
304      @Override
305      public boolean equalsDeep(Base other_) {
306        if (!super.equalsDeep(other_))
307          return false;
308        if (!(other_ instanceof SubstanceReferenceInformationGeneComponent))
309          return false;
310        SubstanceReferenceInformationGeneComponent o = (SubstanceReferenceInformationGeneComponent) other_;
311        return compareDeep(geneSequenceOrigin, o.geneSequenceOrigin, true) && compareDeep(gene, o.gene, true)
312           && compareDeep(source, o.source, true);
313      }
314
315      @Override
316      public boolean equalsShallow(Base other_) {
317        if (!super.equalsShallow(other_))
318          return false;
319        if (!(other_ instanceof SubstanceReferenceInformationGeneComponent))
320          return false;
321        SubstanceReferenceInformationGeneComponent o = (SubstanceReferenceInformationGeneComponent) other_;
322        return true;
323      }
324
325      public boolean isEmpty() {
326        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(geneSequenceOrigin, gene, source
327          );
328      }
329
330  public String fhirType() {
331    return "SubstanceReferenceInformation.gene";
332
333  }
334
335  }
336
337    @Block()
338    public static class SubstanceReferenceInformationGeneElementComponent extends BackboneElement implements IBaseBackboneElement {
339        /**
340         * Todo.
341         */
342        @Child(name = "type", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
343        @Description(shortDefinition="Todo", formalDefinition="Todo." )
344        protected CodeableConcept type;
345
346        /**
347         * Todo.
348         */
349        @Child(name = "element", type = {Identifier.class}, order=2, min=0, max=1, modifier=false, summary=true)
350        @Description(shortDefinition="Todo", formalDefinition="Todo." )
351        protected Identifier element;
352
353        /**
354         * Todo.
355         */
356        @Child(name = "source", type = {DocumentReference.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
357        @Description(shortDefinition="Todo", formalDefinition="Todo." )
358        protected List<Reference> source;
359
360        private static final long serialVersionUID = 261257288L;
361
362    /**
363     * Constructor
364     */
365      public SubstanceReferenceInformationGeneElementComponent() {
366        super();
367      }
368
369        /**
370         * @return {@link #type} (Todo.)
371         */
372        public CodeableConcept getType() { 
373          if (this.type == null)
374            if (Configuration.errorOnAutoCreate())
375              throw new Error("Attempt to auto-create SubstanceReferenceInformationGeneElementComponent.type");
376            else if (Configuration.doAutoCreate())
377              this.type = new CodeableConcept(); // cc
378          return this.type;
379        }
380
381        public boolean hasType() { 
382          return this.type != null && !this.type.isEmpty();
383        }
384
385        /**
386         * @param value {@link #type} (Todo.)
387         */
388        public SubstanceReferenceInformationGeneElementComponent setType(CodeableConcept value) { 
389          this.type = value;
390          return this;
391        }
392
393        /**
394         * @return {@link #element} (Todo.)
395         */
396        public Identifier getElement() { 
397          if (this.element == null)
398            if (Configuration.errorOnAutoCreate())
399              throw new Error("Attempt to auto-create SubstanceReferenceInformationGeneElementComponent.element");
400            else if (Configuration.doAutoCreate())
401              this.element = new Identifier(); // cc
402          return this.element;
403        }
404
405        public boolean hasElement() { 
406          return this.element != null && !this.element.isEmpty();
407        }
408
409        /**
410         * @param value {@link #element} (Todo.)
411         */
412        public SubstanceReferenceInformationGeneElementComponent setElement(Identifier value) { 
413          this.element = value;
414          return this;
415        }
416
417        /**
418         * @return {@link #source} (Todo.)
419         */
420        public List<Reference> getSource() { 
421          if (this.source == null)
422            this.source = new ArrayList<Reference>();
423          return this.source;
424        }
425
426        /**
427         * @return Returns a reference to <code>this</code> for easy method chaining
428         */
429        public SubstanceReferenceInformationGeneElementComponent setSource(List<Reference> theSource) { 
430          this.source = theSource;
431          return this;
432        }
433
434        public boolean hasSource() { 
435          if (this.source == null)
436            return false;
437          for (Reference item : this.source)
438            if (!item.isEmpty())
439              return true;
440          return false;
441        }
442
443        public Reference addSource() { //3
444          Reference t = new Reference();
445          if (this.source == null)
446            this.source = new ArrayList<Reference>();
447          this.source.add(t);
448          return t;
449        }
450
451        public SubstanceReferenceInformationGeneElementComponent addSource(Reference t) { //3
452          if (t == null)
453            return this;
454          if (this.source == null)
455            this.source = new ArrayList<Reference>();
456          this.source.add(t);
457          return this;
458        }
459
460        /**
461         * @return The first repetition of repeating field {@link #source}, creating it if it does not already exist {3}
462         */
463        public Reference getSourceFirstRep() { 
464          if (getSource().isEmpty()) {
465            addSource();
466          }
467          return getSource().get(0);
468        }
469
470        protected void listChildren(List<Property> children) {
471          super.listChildren(children);
472          children.add(new Property("type", "CodeableConcept", "Todo.", 0, 1, type));
473          children.add(new Property("element", "Identifier", "Todo.", 0, 1, element));
474          children.add(new Property("source", "Reference(DocumentReference)", "Todo.", 0, java.lang.Integer.MAX_VALUE, source));
475        }
476
477        @Override
478        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
479          switch (_hash) {
480          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "Todo.", 0, 1, type);
481          case -1662836996: /*element*/  return new Property("element", "Identifier", "Todo.", 0, 1, element);
482          case -896505829: /*source*/  return new Property("source", "Reference(DocumentReference)", "Todo.", 0, java.lang.Integer.MAX_VALUE, source);
483          default: return super.getNamedProperty(_hash, _name, _checkValid);
484          }
485
486        }
487
488      @Override
489      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
490        switch (hash) {
491        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
492        case -1662836996: /*element*/ return this.element == null ? new Base[0] : new Base[] {this.element}; // Identifier
493        case -896505829: /*source*/ return this.source == null ? new Base[0] : this.source.toArray(new Base[this.source.size()]); // Reference
494        default: return super.getProperty(hash, name, checkValid);
495        }
496
497      }
498
499      @Override
500      public Base setProperty(int hash, String name, Base value) throws FHIRException {
501        switch (hash) {
502        case 3575610: // type
503          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
504          return value;
505        case -1662836996: // element
506          this.element = TypeConvertor.castToIdentifier(value); // Identifier
507          return value;
508        case -896505829: // source
509          this.getSource().add(TypeConvertor.castToReference(value)); // Reference
510          return value;
511        default: return super.setProperty(hash, name, value);
512        }
513
514      }
515
516      @Override
517      public Base setProperty(String name, Base value) throws FHIRException {
518        if (name.equals("type")) {
519          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
520        } else if (name.equals("element")) {
521          this.element = TypeConvertor.castToIdentifier(value); // Identifier
522        } else if (name.equals("source")) {
523          this.getSource().add(TypeConvertor.castToReference(value));
524        } else
525          return super.setProperty(name, value);
526        return value;
527      }
528
529      @Override
530      public Base makeProperty(int hash, String name) throws FHIRException {
531        switch (hash) {
532        case 3575610:  return getType();
533        case -1662836996:  return getElement();
534        case -896505829:  return addSource(); 
535        default: return super.makeProperty(hash, name);
536        }
537
538      }
539
540      @Override
541      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
542        switch (hash) {
543        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
544        case -1662836996: /*element*/ return new String[] {"Identifier"};
545        case -896505829: /*source*/ return new String[] {"Reference"};
546        default: return super.getTypesForProperty(hash, name);
547        }
548
549      }
550
551      @Override
552      public Base addChild(String name) throws FHIRException {
553        if (name.equals("type")) {
554          this.type = new CodeableConcept();
555          return this.type;
556        }
557        else if (name.equals("element")) {
558          this.element = new Identifier();
559          return this.element;
560        }
561        else if (name.equals("source")) {
562          return addSource();
563        }
564        else
565          return super.addChild(name);
566      }
567
568      public SubstanceReferenceInformationGeneElementComponent copy() {
569        SubstanceReferenceInformationGeneElementComponent dst = new SubstanceReferenceInformationGeneElementComponent();
570        copyValues(dst);
571        return dst;
572      }
573
574      public void copyValues(SubstanceReferenceInformationGeneElementComponent dst) {
575        super.copyValues(dst);
576        dst.type = type == null ? null : type.copy();
577        dst.element = element == null ? null : element.copy();
578        if (source != null) {
579          dst.source = new ArrayList<Reference>();
580          for (Reference i : source)
581            dst.source.add(i.copy());
582        };
583      }
584
585      @Override
586      public boolean equalsDeep(Base other_) {
587        if (!super.equalsDeep(other_))
588          return false;
589        if (!(other_ instanceof SubstanceReferenceInformationGeneElementComponent))
590          return false;
591        SubstanceReferenceInformationGeneElementComponent o = (SubstanceReferenceInformationGeneElementComponent) other_;
592        return compareDeep(type, o.type, true) && compareDeep(element, o.element, true) && compareDeep(source, o.source, true)
593          ;
594      }
595
596      @Override
597      public boolean equalsShallow(Base other_) {
598        if (!super.equalsShallow(other_))
599          return false;
600        if (!(other_ instanceof SubstanceReferenceInformationGeneElementComponent))
601          return false;
602        SubstanceReferenceInformationGeneElementComponent o = (SubstanceReferenceInformationGeneElementComponent) other_;
603        return true;
604      }
605
606      public boolean isEmpty() {
607        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, element, source);
608      }
609
610  public String fhirType() {
611    return "SubstanceReferenceInformation.geneElement";
612
613  }
614
615  }
616
617    @Block()
618    public static class SubstanceReferenceInformationTargetComponent extends BackboneElement implements IBaseBackboneElement {
619        /**
620         * Todo.
621         */
622        @Child(name = "target", type = {Identifier.class}, order=1, min=0, max=1, modifier=false, summary=true)
623        @Description(shortDefinition="Todo", formalDefinition="Todo." )
624        protected Identifier target;
625
626        /**
627         * Todo.
628         */
629        @Child(name = "type", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
630        @Description(shortDefinition="Todo", formalDefinition="Todo." )
631        protected CodeableConcept type;
632
633        /**
634         * Todo.
635         */
636        @Child(name = "interaction", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true)
637        @Description(shortDefinition="Todo", formalDefinition="Todo." )
638        protected CodeableConcept interaction;
639
640        /**
641         * Todo.
642         */
643        @Child(name = "organism", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=true)
644        @Description(shortDefinition="Todo", formalDefinition="Todo." )
645        protected CodeableConcept organism;
646
647        /**
648         * Todo.
649         */
650        @Child(name = "organismType", type = {CodeableConcept.class}, order=5, min=0, max=1, modifier=false, summary=true)
651        @Description(shortDefinition="Todo", formalDefinition="Todo." )
652        protected CodeableConcept organismType;
653
654        /**
655         * Todo.
656         */
657        @Child(name = "amount", type = {Quantity.class, Range.class, StringType.class}, order=6, min=0, max=1, modifier=false, summary=true)
658        @Description(shortDefinition="Todo", formalDefinition="Todo." )
659        protected DataType amount;
660
661        /**
662         * Todo.
663         */
664        @Child(name = "amountType", type = {CodeableConcept.class}, order=7, min=0, max=1, modifier=false, summary=true)
665        @Description(shortDefinition="Todo", formalDefinition="Todo." )
666        protected CodeableConcept amountType;
667
668        /**
669         * Todo.
670         */
671        @Child(name = "source", type = {DocumentReference.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
672        @Description(shortDefinition="Todo", formalDefinition="Todo." )
673        protected List<Reference> source;
674
675        private static final long serialVersionUID = 819518021L;
676
677    /**
678     * Constructor
679     */
680      public SubstanceReferenceInformationTargetComponent() {
681        super();
682      }
683
684        /**
685         * @return {@link #target} (Todo.)
686         */
687        public Identifier getTarget() { 
688          if (this.target == null)
689            if (Configuration.errorOnAutoCreate())
690              throw new Error("Attempt to auto-create SubstanceReferenceInformationTargetComponent.target");
691            else if (Configuration.doAutoCreate())
692              this.target = new Identifier(); // cc
693          return this.target;
694        }
695
696        public boolean hasTarget() { 
697          return this.target != null && !this.target.isEmpty();
698        }
699
700        /**
701         * @param value {@link #target} (Todo.)
702         */
703        public SubstanceReferenceInformationTargetComponent setTarget(Identifier value) { 
704          this.target = value;
705          return this;
706        }
707
708        /**
709         * @return {@link #type} (Todo.)
710         */
711        public CodeableConcept getType() { 
712          if (this.type == null)
713            if (Configuration.errorOnAutoCreate())
714              throw new Error("Attempt to auto-create SubstanceReferenceInformationTargetComponent.type");
715            else if (Configuration.doAutoCreate())
716              this.type = new CodeableConcept(); // cc
717          return this.type;
718        }
719
720        public boolean hasType() { 
721          return this.type != null && !this.type.isEmpty();
722        }
723
724        /**
725         * @param value {@link #type} (Todo.)
726         */
727        public SubstanceReferenceInformationTargetComponent setType(CodeableConcept value) { 
728          this.type = value;
729          return this;
730        }
731
732        /**
733         * @return {@link #interaction} (Todo.)
734         */
735        public CodeableConcept getInteraction() { 
736          if (this.interaction == null)
737            if (Configuration.errorOnAutoCreate())
738              throw new Error("Attempt to auto-create SubstanceReferenceInformationTargetComponent.interaction");
739            else if (Configuration.doAutoCreate())
740              this.interaction = new CodeableConcept(); // cc
741          return this.interaction;
742        }
743
744        public boolean hasInteraction() { 
745          return this.interaction != null && !this.interaction.isEmpty();
746        }
747
748        /**
749         * @param value {@link #interaction} (Todo.)
750         */
751        public SubstanceReferenceInformationTargetComponent setInteraction(CodeableConcept value) { 
752          this.interaction = value;
753          return this;
754        }
755
756        /**
757         * @return {@link #organism} (Todo.)
758         */
759        public CodeableConcept getOrganism() { 
760          if (this.organism == null)
761            if (Configuration.errorOnAutoCreate())
762              throw new Error("Attempt to auto-create SubstanceReferenceInformationTargetComponent.organism");
763            else if (Configuration.doAutoCreate())
764              this.organism = new CodeableConcept(); // cc
765          return this.organism;
766        }
767
768        public boolean hasOrganism() { 
769          return this.organism != null && !this.organism.isEmpty();
770        }
771
772        /**
773         * @param value {@link #organism} (Todo.)
774         */
775        public SubstanceReferenceInformationTargetComponent setOrganism(CodeableConcept value) { 
776          this.organism = value;
777          return this;
778        }
779
780        /**
781         * @return {@link #organismType} (Todo.)
782         */
783        public CodeableConcept getOrganismType() { 
784          if (this.organismType == null)
785            if (Configuration.errorOnAutoCreate())
786              throw new Error("Attempt to auto-create SubstanceReferenceInformationTargetComponent.organismType");
787            else if (Configuration.doAutoCreate())
788              this.organismType = new CodeableConcept(); // cc
789          return this.organismType;
790        }
791
792        public boolean hasOrganismType() { 
793          return this.organismType != null && !this.organismType.isEmpty();
794        }
795
796        /**
797         * @param value {@link #organismType} (Todo.)
798         */
799        public SubstanceReferenceInformationTargetComponent setOrganismType(CodeableConcept value) { 
800          this.organismType = value;
801          return this;
802        }
803
804        /**
805         * @return {@link #amount} (Todo.)
806         */
807        public DataType getAmount() { 
808          return this.amount;
809        }
810
811        /**
812         * @return {@link #amount} (Todo.)
813         */
814        public Quantity getAmountQuantity() throws FHIRException { 
815          if (this.amount == null)
816            this.amount = new Quantity();
817          if (!(this.amount instanceof Quantity))
818            throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.amount.getClass().getName()+" was encountered");
819          return (Quantity) this.amount;
820        }
821
822        public boolean hasAmountQuantity() { 
823          return this != null && this.amount instanceof Quantity;
824        }
825
826        /**
827         * @return {@link #amount} (Todo.)
828         */
829        public Range getAmountRange() throws FHIRException { 
830          if (this.amount == null)
831            this.amount = new Range();
832          if (!(this.amount instanceof Range))
833            throw new FHIRException("Type mismatch: the type Range was expected, but "+this.amount.getClass().getName()+" was encountered");
834          return (Range) this.amount;
835        }
836
837        public boolean hasAmountRange() { 
838          return this != null && this.amount instanceof Range;
839        }
840
841        /**
842         * @return {@link #amount} (Todo.)
843         */
844        public StringType getAmountStringType() throws FHIRException { 
845          if (this.amount == null)
846            this.amount = new StringType();
847          if (!(this.amount instanceof StringType))
848            throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.amount.getClass().getName()+" was encountered");
849          return (StringType) this.amount;
850        }
851
852        public boolean hasAmountStringType() { 
853          return this != null && this.amount instanceof StringType;
854        }
855
856        public boolean hasAmount() { 
857          return this.amount != null && !this.amount.isEmpty();
858        }
859
860        /**
861         * @param value {@link #amount} (Todo.)
862         */
863        public SubstanceReferenceInformationTargetComponent setAmount(DataType value) { 
864          if (value != null && !(value instanceof Quantity || value instanceof Range || value instanceof StringType))
865            throw new Error("Not the right type for SubstanceReferenceInformation.target.amount[x]: "+value.fhirType());
866          this.amount = value;
867          return this;
868        }
869
870        /**
871         * @return {@link #amountType} (Todo.)
872         */
873        public CodeableConcept getAmountType() { 
874          if (this.amountType == null)
875            if (Configuration.errorOnAutoCreate())
876              throw new Error("Attempt to auto-create SubstanceReferenceInformationTargetComponent.amountType");
877            else if (Configuration.doAutoCreate())
878              this.amountType = new CodeableConcept(); // cc
879          return this.amountType;
880        }
881
882        public boolean hasAmountType() { 
883          return this.amountType != null && !this.amountType.isEmpty();
884        }
885
886        /**
887         * @param value {@link #amountType} (Todo.)
888         */
889        public SubstanceReferenceInformationTargetComponent setAmountType(CodeableConcept value) { 
890          this.amountType = value;
891          return this;
892        }
893
894        /**
895         * @return {@link #source} (Todo.)
896         */
897        public List<Reference> getSource() { 
898          if (this.source == null)
899            this.source = new ArrayList<Reference>();
900          return this.source;
901        }
902
903        /**
904         * @return Returns a reference to <code>this</code> for easy method chaining
905         */
906        public SubstanceReferenceInformationTargetComponent setSource(List<Reference> theSource) { 
907          this.source = theSource;
908          return this;
909        }
910
911        public boolean hasSource() { 
912          if (this.source == null)
913            return false;
914          for (Reference item : this.source)
915            if (!item.isEmpty())
916              return true;
917          return false;
918        }
919
920        public Reference addSource() { //3
921          Reference t = new Reference();
922          if (this.source == null)
923            this.source = new ArrayList<Reference>();
924          this.source.add(t);
925          return t;
926        }
927
928        public SubstanceReferenceInformationTargetComponent addSource(Reference t) { //3
929          if (t == null)
930            return this;
931          if (this.source == null)
932            this.source = new ArrayList<Reference>();
933          this.source.add(t);
934          return this;
935        }
936
937        /**
938         * @return The first repetition of repeating field {@link #source}, creating it if it does not already exist {3}
939         */
940        public Reference getSourceFirstRep() { 
941          if (getSource().isEmpty()) {
942            addSource();
943          }
944          return getSource().get(0);
945        }
946
947        protected void listChildren(List<Property> children) {
948          super.listChildren(children);
949          children.add(new Property("target", "Identifier", "Todo.", 0, 1, target));
950          children.add(new Property("type", "CodeableConcept", "Todo.", 0, 1, type));
951          children.add(new Property("interaction", "CodeableConcept", "Todo.", 0, 1, interaction));
952          children.add(new Property("organism", "CodeableConcept", "Todo.", 0, 1, organism));
953          children.add(new Property("organismType", "CodeableConcept", "Todo.", 0, 1, organismType));
954          children.add(new Property("amount[x]", "Quantity|Range|string", "Todo.", 0, 1, amount));
955          children.add(new Property("amountType", "CodeableConcept", "Todo.", 0, 1, amountType));
956          children.add(new Property("source", "Reference(DocumentReference)", "Todo.", 0, java.lang.Integer.MAX_VALUE, source));
957        }
958
959        @Override
960        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
961          switch (_hash) {
962          case -880905839: /*target*/  return new Property("target", "Identifier", "Todo.", 0, 1, target);
963          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "Todo.", 0, 1, type);
964          case 1844104722: /*interaction*/  return new Property("interaction", "CodeableConcept", "Todo.", 0, 1, interaction);
965          case 1316389074: /*organism*/  return new Property("organism", "CodeableConcept", "Todo.", 0, 1, organism);
966          case 988662572: /*organismType*/  return new Property("organismType", "CodeableConcept", "Todo.", 0, 1, organismType);
967          case 646780200: /*amount[x]*/  return new Property("amount[x]", "Quantity|Range|string", "Todo.", 0, 1, amount);
968          case -1413853096: /*amount*/  return new Property("amount[x]", "Quantity|Range|string", "Todo.", 0, 1, amount);
969          case 1664303363: /*amountQuantity*/  return new Property("amount[x]", "Quantity", "Todo.", 0, 1, amount);
970          case -1223462971: /*amountRange*/  return new Property("amount[x]", "Range", "Todo.", 0, 1, amount);
971          case 773651081: /*amountString*/  return new Property("amount[x]", "string", "Todo.", 0, 1, amount);
972          case -1424857166: /*amountType*/  return new Property("amountType", "CodeableConcept", "Todo.", 0, 1, amountType);
973          case -896505829: /*source*/  return new Property("source", "Reference(DocumentReference)", "Todo.", 0, java.lang.Integer.MAX_VALUE, source);
974          default: return super.getNamedProperty(_hash, _name, _checkValid);
975          }
976
977        }
978
979      @Override
980      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
981        switch (hash) {
982        case -880905839: /*target*/ return this.target == null ? new Base[0] : new Base[] {this.target}; // Identifier
983        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
984        case 1844104722: /*interaction*/ return this.interaction == null ? new Base[0] : new Base[] {this.interaction}; // CodeableConcept
985        case 1316389074: /*organism*/ return this.organism == null ? new Base[0] : new Base[] {this.organism}; // CodeableConcept
986        case 988662572: /*organismType*/ return this.organismType == null ? new Base[0] : new Base[] {this.organismType}; // CodeableConcept
987        case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : new Base[] {this.amount}; // DataType
988        case -1424857166: /*amountType*/ return this.amountType == null ? new Base[0] : new Base[] {this.amountType}; // CodeableConcept
989        case -896505829: /*source*/ return this.source == null ? new Base[0] : this.source.toArray(new Base[this.source.size()]); // Reference
990        default: return super.getProperty(hash, name, checkValid);
991        }
992
993      }
994
995      @Override
996      public Base setProperty(int hash, String name, Base value) throws FHIRException {
997        switch (hash) {
998        case -880905839: // target
999          this.target = TypeConvertor.castToIdentifier(value); // Identifier
1000          return value;
1001        case 3575610: // type
1002          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1003          return value;
1004        case 1844104722: // interaction
1005          this.interaction = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1006          return value;
1007        case 1316389074: // organism
1008          this.organism = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1009          return value;
1010        case 988662572: // organismType
1011          this.organismType = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1012          return value;
1013        case -1413853096: // amount
1014          this.amount = TypeConvertor.castToType(value); // DataType
1015          return value;
1016        case -1424857166: // amountType
1017          this.amountType = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1018          return value;
1019        case -896505829: // source
1020          this.getSource().add(TypeConvertor.castToReference(value)); // Reference
1021          return value;
1022        default: return super.setProperty(hash, name, value);
1023        }
1024
1025      }
1026
1027      @Override
1028      public Base setProperty(String name, Base value) throws FHIRException {
1029        if (name.equals("target")) {
1030          this.target = TypeConvertor.castToIdentifier(value); // Identifier
1031        } else if (name.equals("type")) {
1032          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1033        } else if (name.equals("interaction")) {
1034          this.interaction = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1035        } else if (name.equals("organism")) {
1036          this.organism = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1037        } else if (name.equals("organismType")) {
1038          this.organismType = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1039        } else if (name.equals("amount[x]")) {
1040          this.amount = TypeConvertor.castToType(value); // DataType
1041        } else if (name.equals("amountType")) {
1042          this.amountType = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1043        } else if (name.equals("source")) {
1044          this.getSource().add(TypeConvertor.castToReference(value));
1045        } else
1046          return super.setProperty(name, value);
1047        return value;
1048      }
1049
1050      @Override
1051      public Base makeProperty(int hash, String name) throws FHIRException {
1052        switch (hash) {
1053        case -880905839:  return getTarget();
1054        case 3575610:  return getType();
1055        case 1844104722:  return getInteraction();
1056        case 1316389074:  return getOrganism();
1057        case 988662572:  return getOrganismType();
1058        case 646780200:  return getAmount();
1059        case -1413853096:  return getAmount();
1060        case -1424857166:  return getAmountType();
1061        case -896505829:  return addSource(); 
1062        default: return super.makeProperty(hash, name);
1063        }
1064
1065      }
1066
1067      @Override
1068      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1069        switch (hash) {
1070        case -880905839: /*target*/ return new String[] {"Identifier"};
1071        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
1072        case 1844104722: /*interaction*/ return new String[] {"CodeableConcept"};
1073        case 1316389074: /*organism*/ return new String[] {"CodeableConcept"};
1074        case 988662572: /*organismType*/ return new String[] {"CodeableConcept"};
1075        case -1413853096: /*amount*/ return new String[] {"Quantity", "Range", "string"};
1076        case -1424857166: /*amountType*/ return new String[] {"CodeableConcept"};
1077        case -896505829: /*source*/ return new String[] {"Reference"};
1078        default: return super.getTypesForProperty(hash, name);
1079        }
1080
1081      }
1082
1083      @Override
1084      public Base addChild(String name) throws FHIRException {
1085        if (name.equals("target")) {
1086          this.target = new Identifier();
1087          return this.target;
1088        }
1089        else if (name.equals("type")) {
1090          this.type = new CodeableConcept();
1091          return this.type;
1092        }
1093        else if (name.equals("interaction")) {
1094          this.interaction = new CodeableConcept();
1095          return this.interaction;
1096        }
1097        else if (name.equals("organism")) {
1098          this.organism = new CodeableConcept();
1099          return this.organism;
1100        }
1101        else if (name.equals("organismType")) {
1102          this.organismType = new CodeableConcept();
1103          return this.organismType;
1104        }
1105        else if (name.equals("amountQuantity")) {
1106          this.amount = new Quantity();
1107          return this.amount;
1108        }
1109        else if (name.equals("amountRange")) {
1110          this.amount = new Range();
1111          return this.amount;
1112        }
1113        else if (name.equals("amountString")) {
1114          this.amount = new StringType();
1115          return this.amount;
1116        }
1117        else if (name.equals("amountType")) {
1118          this.amountType = new CodeableConcept();
1119          return this.amountType;
1120        }
1121        else if (name.equals("source")) {
1122          return addSource();
1123        }
1124        else
1125          return super.addChild(name);
1126      }
1127
1128      public SubstanceReferenceInformationTargetComponent copy() {
1129        SubstanceReferenceInformationTargetComponent dst = new SubstanceReferenceInformationTargetComponent();
1130        copyValues(dst);
1131        return dst;
1132      }
1133
1134      public void copyValues(SubstanceReferenceInformationTargetComponent dst) {
1135        super.copyValues(dst);
1136        dst.target = target == null ? null : target.copy();
1137        dst.type = type == null ? null : type.copy();
1138        dst.interaction = interaction == null ? null : interaction.copy();
1139        dst.organism = organism == null ? null : organism.copy();
1140        dst.organismType = organismType == null ? null : organismType.copy();
1141        dst.amount = amount == null ? null : amount.copy();
1142        dst.amountType = amountType == null ? null : amountType.copy();
1143        if (source != null) {
1144          dst.source = new ArrayList<Reference>();
1145          for (Reference i : source)
1146            dst.source.add(i.copy());
1147        };
1148      }
1149
1150      @Override
1151      public boolean equalsDeep(Base other_) {
1152        if (!super.equalsDeep(other_))
1153          return false;
1154        if (!(other_ instanceof SubstanceReferenceInformationTargetComponent))
1155          return false;
1156        SubstanceReferenceInformationTargetComponent o = (SubstanceReferenceInformationTargetComponent) other_;
1157        return compareDeep(target, o.target, true) && compareDeep(type, o.type, true) && compareDeep(interaction, o.interaction, true)
1158           && compareDeep(organism, o.organism, true) && compareDeep(organismType, o.organismType, true) && compareDeep(amount, o.amount, true)
1159           && compareDeep(amountType, o.amountType, true) && compareDeep(source, o.source, true);
1160      }
1161
1162      @Override
1163      public boolean equalsShallow(Base other_) {
1164        if (!super.equalsShallow(other_))
1165          return false;
1166        if (!(other_ instanceof SubstanceReferenceInformationTargetComponent))
1167          return false;
1168        SubstanceReferenceInformationTargetComponent o = (SubstanceReferenceInformationTargetComponent) other_;
1169        return true;
1170      }
1171
1172      public boolean isEmpty() {
1173        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(target, type, interaction
1174          , organism, organismType, amount, amountType, source);
1175      }
1176
1177  public String fhirType() {
1178    return "SubstanceReferenceInformation.target";
1179
1180  }
1181
1182  }
1183
1184    /**
1185     * Todo.
1186     */
1187    @Child(name = "comment", type = {StringType.class}, order=0, min=0, max=1, modifier=false, summary=true)
1188    @Description(shortDefinition="Todo", formalDefinition="Todo." )
1189    protected StringType comment;
1190
1191    /**
1192     * Todo.
1193     */
1194    @Child(name = "gene", type = {}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1195    @Description(shortDefinition="Todo", formalDefinition="Todo." )
1196    protected List<SubstanceReferenceInformationGeneComponent> gene;
1197
1198    /**
1199     * Todo.
1200     */
1201    @Child(name = "geneElement", type = {}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1202    @Description(shortDefinition="Todo", formalDefinition="Todo." )
1203    protected List<SubstanceReferenceInformationGeneElementComponent> geneElement;
1204
1205    /**
1206     * Todo.
1207     */
1208    @Child(name = "target", type = {}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1209    @Description(shortDefinition="Todo", formalDefinition="Todo." )
1210    protected List<SubstanceReferenceInformationTargetComponent> target;
1211
1212    private static final long serialVersionUID = -496299386L;
1213
1214  /**
1215   * Constructor
1216   */
1217    public SubstanceReferenceInformation() {
1218      super();
1219    }
1220
1221    /**
1222     * @return {@link #comment} (Todo.). This is the underlying object with id, value and extensions. The accessor "getComment" gives direct access to the value
1223     */
1224    public StringType getCommentElement() { 
1225      if (this.comment == null)
1226        if (Configuration.errorOnAutoCreate())
1227          throw new Error("Attempt to auto-create SubstanceReferenceInformation.comment");
1228        else if (Configuration.doAutoCreate())
1229          this.comment = new StringType(); // bb
1230      return this.comment;
1231    }
1232
1233    public boolean hasCommentElement() { 
1234      return this.comment != null && !this.comment.isEmpty();
1235    }
1236
1237    public boolean hasComment() { 
1238      return this.comment != null && !this.comment.isEmpty();
1239    }
1240
1241    /**
1242     * @param value {@link #comment} (Todo.). This is the underlying object with id, value and extensions. The accessor "getComment" gives direct access to the value
1243     */
1244    public SubstanceReferenceInformation setCommentElement(StringType value) { 
1245      this.comment = value;
1246      return this;
1247    }
1248
1249    /**
1250     * @return Todo.
1251     */
1252    public String getComment() { 
1253      return this.comment == null ? null : this.comment.getValue();
1254    }
1255
1256    /**
1257     * @param value Todo.
1258     */
1259    public SubstanceReferenceInformation setComment(String value) { 
1260      if (Utilities.noString(value))
1261        this.comment = null;
1262      else {
1263        if (this.comment == null)
1264          this.comment = new StringType();
1265        this.comment.setValue(value);
1266      }
1267      return this;
1268    }
1269
1270    /**
1271     * @return {@link #gene} (Todo.)
1272     */
1273    public List<SubstanceReferenceInformationGeneComponent> getGene() { 
1274      if (this.gene == null)
1275        this.gene = new ArrayList<SubstanceReferenceInformationGeneComponent>();
1276      return this.gene;
1277    }
1278
1279    /**
1280     * @return Returns a reference to <code>this</code> for easy method chaining
1281     */
1282    public SubstanceReferenceInformation setGene(List<SubstanceReferenceInformationGeneComponent> theGene) { 
1283      this.gene = theGene;
1284      return this;
1285    }
1286
1287    public boolean hasGene() { 
1288      if (this.gene == null)
1289        return false;
1290      for (SubstanceReferenceInformationGeneComponent item : this.gene)
1291        if (!item.isEmpty())
1292          return true;
1293      return false;
1294    }
1295
1296    public SubstanceReferenceInformationGeneComponent addGene() { //3
1297      SubstanceReferenceInformationGeneComponent t = new SubstanceReferenceInformationGeneComponent();
1298      if (this.gene == null)
1299        this.gene = new ArrayList<SubstanceReferenceInformationGeneComponent>();
1300      this.gene.add(t);
1301      return t;
1302    }
1303
1304    public SubstanceReferenceInformation addGene(SubstanceReferenceInformationGeneComponent t) { //3
1305      if (t == null)
1306        return this;
1307      if (this.gene == null)
1308        this.gene = new ArrayList<SubstanceReferenceInformationGeneComponent>();
1309      this.gene.add(t);
1310      return this;
1311    }
1312
1313    /**
1314     * @return The first repetition of repeating field {@link #gene}, creating it if it does not already exist {3}
1315     */
1316    public SubstanceReferenceInformationGeneComponent getGeneFirstRep() { 
1317      if (getGene().isEmpty()) {
1318        addGene();
1319      }
1320      return getGene().get(0);
1321    }
1322
1323    /**
1324     * @return {@link #geneElement} (Todo.)
1325     */
1326    public List<SubstanceReferenceInformationGeneElementComponent> getGeneElement() { 
1327      if (this.geneElement == null)
1328        this.geneElement = new ArrayList<SubstanceReferenceInformationGeneElementComponent>();
1329      return this.geneElement;
1330    }
1331
1332    /**
1333     * @return Returns a reference to <code>this</code> for easy method chaining
1334     */
1335    public SubstanceReferenceInformation setGeneElement(List<SubstanceReferenceInformationGeneElementComponent> theGeneElement) { 
1336      this.geneElement = theGeneElement;
1337      return this;
1338    }
1339
1340    public boolean hasGeneElement() { 
1341      if (this.geneElement == null)
1342        return false;
1343      for (SubstanceReferenceInformationGeneElementComponent item : this.geneElement)
1344        if (!item.isEmpty())
1345          return true;
1346      return false;
1347    }
1348
1349    public SubstanceReferenceInformationGeneElementComponent addGeneElement() { //3
1350      SubstanceReferenceInformationGeneElementComponent t = new SubstanceReferenceInformationGeneElementComponent();
1351      if (this.geneElement == null)
1352        this.geneElement = new ArrayList<SubstanceReferenceInformationGeneElementComponent>();
1353      this.geneElement.add(t);
1354      return t;
1355    }
1356
1357    public SubstanceReferenceInformation addGeneElement(SubstanceReferenceInformationGeneElementComponent t) { //3
1358      if (t == null)
1359        return this;
1360      if (this.geneElement == null)
1361        this.geneElement = new ArrayList<SubstanceReferenceInformationGeneElementComponent>();
1362      this.geneElement.add(t);
1363      return this;
1364    }
1365
1366    /**
1367     * @return The first repetition of repeating field {@link #geneElement}, creating it if it does not already exist {3}
1368     */
1369    public SubstanceReferenceInformationGeneElementComponent getGeneElementFirstRep() { 
1370      if (getGeneElement().isEmpty()) {
1371        addGeneElement();
1372      }
1373      return getGeneElement().get(0);
1374    }
1375
1376    /**
1377     * @return {@link #target} (Todo.)
1378     */
1379    public List<SubstanceReferenceInformationTargetComponent> getTarget() { 
1380      if (this.target == null)
1381        this.target = new ArrayList<SubstanceReferenceInformationTargetComponent>();
1382      return this.target;
1383    }
1384
1385    /**
1386     * @return Returns a reference to <code>this</code> for easy method chaining
1387     */
1388    public SubstanceReferenceInformation setTarget(List<SubstanceReferenceInformationTargetComponent> theTarget) { 
1389      this.target = theTarget;
1390      return this;
1391    }
1392
1393    public boolean hasTarget() { 
1394      if (this.target == null)
1395        return false;
1396      for (SubstanceReferenceInformationTargetComponent item : this.target)
1397        if (!item.isEmpty())
1398          return true;
1399      return false;
1400    }
1401
1402    public SubstanceReferenceInformationTargetComponent addTarget() { //3
1403      SubstanceReferenceInformationTargetComponent t = new SubstanceReferenceInformationTargetComponent();
1404      if (this.target == null)
1405        this.target = new ArrayList<SubstanceReferenceInformationTargetComponent>();
1406      this.target.add(t);
1407      return t;
1408    }
1409
1410    public SubstanceReferenceInformation addTarget(SubstanceReferenceInformationTargetComponent t) { //3
1411      if (t == null)
1412        return this;
1413      if (this.target == null)
1414        this.target = new ArrayList<SubstanceReferenceInformationTargetComponent>();
1415      this.target.add(t);
1416      return this;
1417    }
1418
1419    /**
1420     * @return The first repetition of repeating field {@link #target}, creating it if it does not already exist {3}
1421     */
1422    public SubstanceReferenceInformationTargetComponent getTargetFirstRep() { 
1423      if (getTarget().isEmpty()) {
1424        addTarget();
1425      }
1426      return getTarget().get(0);
1427    }
1428
1429      protected void listChildren(List<Property> children) {
1430        super.listChildren(children);
1431        children.add(new Property("comment", "string", "Todo.", 0, 1, comment));
1432        children.add(new Property("gene", "", "Todo.", 0, java.lang.Integer.MAX_VALUE, gene));
1433        children.add(new Property("geneElement", "", "Todo.", 0, java.lang.Integer.MAX_VALUE, geneElement));
1434        children.add(new Property("target", "", "Todo.", 0, java.lang.Integer.MAX_VALUE, target));
1435      }
1436
1437      @Override
1438      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1439        switch (_hash) {
1440        case 950398559: /*comment*/  return new Property("comment", "string", "Todo.", 0, 1, comment);
1441        case 3169045: /*gene*/  return new Property("gene", "", "Todo.", 0, java.lang.Integer.MAX_VALUE, gene);
1442        case -94918105: /*geneElement*/  return new Property("geneElement", "", "Todo.", 0, java.lang.Integer.MAX_VALUE, geneElement);
1443        case -880905839: /*target*/  return new Property("target", "", "Todo.", 0, java.lang.Integer.MAX_VALUE, target);
1444        default: return super.getNamedProperty(_hash, _name, _checkValid);
1445        }
1446
1447      }
1448
1449      @Override
1450      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1451        switch (hash) {
1452        case 950398559: /*comment*/ return this.comment == null ? new Base[0] : new Base[] {this.comment}; // StringType
1453        case 3169045: /*gene*/ return this.gene == null ? new Base[0] : this.gene.toArray(new Base[this.gene.size()]); // SubstanceReferenceInformationGeneComponent
1454        case -94918105: /*geneElement*/ return this.geneElement == null ? new Base[0] : this.geneElement.toArray(new Base[this.geneElement.size()]); // SubstanceReferenceInformationGeneElementComponent
1455        case -880905839: /*target*/ return this.target == null ? new Base[0] : this.target.toArray(new Base[this.target.size()]); // SubstanceReferenceInformationTargetComponent
1456        default: return super.getProperty(hash, name, checkValid);
1457        }
1458
1459      }
1460
1461      @Override
1462      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1463        switch (hash) {
1464        case 950398559: // comment
1465          this.comment = TypeConvertor.castToString(value); // StringType
1466          return value;
1467        case 3169045: // gene
1468          this.getGene().add((SubstanceReferenceInformationGeneComponent) value); // SubstanceReferenceInformationGeneComponent
1469          return value;
1470        case -94918105: // geneElement
1471          this.getGeneElement().add((SubstanceReferenceInformationGeneElementComponent) value); // SubstanceReferenceInformationGeneElementComponent
1472          return value;
1473        case -880905839: // target
1474          this.getTarget().add((SubstanceReferenceInformationTargetComponent) value); // SubstanceReferenceInformationTargetComponent
1475          return value;
1476        default: return super.setProperty(hash, name, value);
1477        }
1478
1479      }
1480
1481      @Override
1482      public Base setProperty(String name, Base value) throws FHIRException {
1483        if (name.equals("comment")) {
1484          this.comment = TypeConvertor.castToString(value); // StringType
1485        } else if (name.equals("gene")) {
1486          this.getGene().add((SubstanceReferenceInformationGeneComponent) value);
1487        } else if (name.equals("geneElement")) {
1488          this.getGeneElement().add((SubstanceReferenceInformationGeneElementComponent) value);
1489        } else if (name.equals("target")) {
1490          this.getTarget().add((SubstanceReferenceInformationTargetComponent) value);
1491        } else
1492          return super.setProperty(name, value);
1493        return value;
1494      }
1495
1496      @Override
1497      public Base makeProperty(int hash, String name) throws FHIRException {
1498        switch (hash) {
1499        case 950398559:  return getCommentElement();
1500        case 3169045:  return addGene(); 
1501        case -94918105:  return addGeneElement(); 
1502        case -880905839:  return addTarget(); 
1503        default: return super.makeProperty(hash, name);
1504        }
1505
1506      }
1507
1508      @Override
1509      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1510        switch (hash) {
1511        case 950398559: /*comment*/ return new String[] {"string"};
1512        case 3169045: /*gene*/ return new String[] {};
1513        case -94918105: /*geneElement*/ return new String[] {};
1514        case -880905839: /*target*/ return new String[] {};
1515        default: return super.getTypesForProperty(hash, name);
1516        }
1517
1518      }
1519
1520      @Override
1521      public Base addChild(String name) throws FHIRException {
1522        if (name.equals("comment")) {
1523          throw new FHIRException("Cannot call addChild on a primitive type SubstanceReferenceInformation.comment");
1524        }
1525        else if (name.equals("gene")) {
1526          return addGene();
1527        }
1528        else if (name.equals("geneElement")) {
1529          return addGeneElement();
1530        }
1531        else if (name.equals("target")) {
1532          return addTarget();
1533        }
1534        else
1535          return super.addChild(name);
1536      }
1537
1538  public String fhirType() {
1539    return "SubstanceReferenceInformation";
1540
1541  }
1542
1543      public SubstanceReferenceInformation copy() {
1544        SubstanceReferenceInformation dst = new SubstanceReferenceInformation();
1545        copyValues(dst);
1546        return dst;
1547      }
1548
1549      public void copyValues(SubstanceReferenceInformation dst) {
1550        super.copyValues(dst);
1551        dst.comment = comment == null ? null : comment.copy();
1552        if (gene != null) {
1553          dst.gene = new ArrayList<SubstanceReferenceInformationGeneComponent>();
1554          for (SubstanceReferenceInformationGeneComponent i : gene)
1555            dst.gene.add(i.copy());
1556        };
1557        if (geneElement != null) {
1558          dst.geneElement = new ArrayList<SubstanceReferenceInformationGeneElementComponent>();
1559          for (SubstanceReferenceInformationGeneElementComponent i : geneElement)
1560            dst.geneElement.add(i.copy());
1561        };
1562        if (target != null) {
1563          dst.target = new ArrayList<SubstanceReferenceInformationTargetComponent>();
1564          for (SubstanceReferenceInformationTargetComponent i : target)
1565            dst.target.add(i.copy());
1566        };
1567      }
1568
1569      protected SubstanceReferenceInformation typedCopy() {
1570        return copy();
1571      }
1572
1573      @Override
1574      public boolean equalsDeep(Base other_) {
1575        if (!super.equalsDeep(other_))
1576          return false;
1577        if (!(other_ instanceof SubstanceReferenceInformation))
1578          return false;
1579        SubstanceReferenceInformation o = (SubstanceReferenceInformation) other_;
1580        return compareDeep(comment, o.comment, true) && compareDeep(gene, o.gene, true) && compareDeep(geneElement, o.geneElement, true)
1581           && compareDeep(target, o.target, true);
1582      }
1583
1584      @Override
1585      public boolean equalsShallow(Base other_) {
1586        if (!super.equalsShallow(other_))
1587          return false;
1588        if (!(other_ instanceof SubstanceReferenceInformation))
1589          return false;
1590        SubstanceReferenceInformation o = (SubstanceReferenceInformation) other_;
1591        return compareValues(comment, o.comment, true);
1592      }
1593
1594      public boolean isEmpty() {
1595        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(comment, gene, geneElement
1596          , target);
1597      }
1598
1599  @Override
1600  public ResourceType getResourceType() {
1601    return ResourceType.SubstanceReferenceInformation;
1602   }
1603
1604
1605}
1606