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 * A kind of specimen with associated set of requirements.
052 */
053@ResourceDef(name="SpecimenDefinition", profile="http://hl7.org/fhir/StructureDefinition/SpecimenDefinition")
054public class SpecimenDefinition extends DomainResource {
055
056    public enum SpecimenContainedPreference {
057        /**
058         * This type of contained specimen is preferred to collect this kind of specimen.
059         */
060        PREFERRED, 
061        /**
062         * This type of conditioned specimen is an alternate.
063         */
064        ALTERNATE, 
065        /**
066         * added to help the parsers with the generic types
067         */
068        NULL;
069        public static SpecimenContainedPreference fromCode(String codeString) throws FHIRException {
070            if (codeString == null || "".equals(codeString))
071                return null;
072        if ("preferred".equals(codeString))
073          return PREFERRED;
074        if ("alternate".equals(codeString))
075          return ALTERNATE;
076        if (Configuration.isAcceptInvalidEnums())
077          return null;
078        else
079          throw new FHIRException("Unknown SpecimenContainedPreference code '"+codeString+"'");
080        }
081        public String toCode() {
082          switch (this) {
083            case PREFERRED: return "preferred";
084            case ALTERNATE: return "alternate";
085            case NULL: return null;
086            default: return "?";
087          }
088        }
089        public String getSystem() {
090          switch (this) {
091            case PREFERRED: return "http://hl7.org/fhir/specimen-contained-preference";
092            case ALTERNATE: return "http://hl7.org/fhir/specimen-contained-preference";
093            case NULL: return null;
094            default: return "?";
095          }
096        }
097        public String getDefinition() {
098          switch (this) {
099            case PREFERRED: return "This type of contained specimen is preferred to collect this kind of specimen.";
100            case ALTERNATE: return "This type of conditioned specimen is an alternate.";
101            case NULL: return null;
102            default: return "?";
103          }
104        }
105        public String getDisplay() {
106          switch (this) {
107            case PREFERRED: return "Preferred";
108            case ALTERNATE: return "Alternate";
109            case NULL: return null;
110            default: return "?";
111          }
112        }
113    }
114
115  public static class SpecimenContainedPreferenceEnumFactory implements EnumFactory<SpecimenContainedPreference> {
116    public SpecimenContainedPreference fromCode(String codeString) throws IllegalArgumentException {
117      if (codeString == null || "".equals(codeString))
118            if (codeString == null || "".equals(codeString))
119                return null;
120        if ("preferred".equals(codeString))
121          return SpecimenContainedPreference.PREFERRED;
122        if ("alternate".equals(codeString))
123          return SpecimenContainedPreference.ALTERNATE;
124        throw new IllegalArgumentException("Unknown SpecimenContainedPreference code '"+codeString+"'");
125        }
126        public Enumeration<SpecimenContainedPreference> fromType(Base code) throws FHIRException {
127          if (code == null)
128            return null;
129          if (code.isEmpty())
130            return new Enumeration<SpecimenContainedPreference>(this);
131          String codeString = ((PrimitiveType) code).asStringValue();
132          if (codeString == null || "".equals(codeString))
133            return null;
134        if ("preferred".equals(codeString))
135          return new Enumeration<SpecimenContainedPreference>(this, SpecimenContainedPreference.PREFERRED);
136        if ("alternate".equals(codeString))
137          return new Enumeration<SpecimenContainedPreference>(this, SpecimenContainedPreference.ALTERNATE);
138        throw new FHIRException("Unknown SpecimenContainedPreference code '"+codeString+"'");
139        }
140    public String toCode(SpecimenContainedPreference code) {
141      if (code == SpecimenContainedPreference.PREFERRED)
142        return "preferred";
143      if (code == SpecimenContainedPreference.ALTERNATE)
144        return "alternate";
145      return "?";
146      }
147    public String toSystem(SpecimenContainedPreference code) {
148      return code.getSystem();
149      }
150    }
151
152    @Block()
153    public static class SpecimenDefinitionTypeTestedComponent extends BackboneElement implements IBaseBackboneElement {
154        /**
155         * Primary of secondary specimen.
156         */
157        @Child(name = "isDerived", type = {BooleanType.class}, order=1, min=0, max=1, modifier=false, summary=false)
158        @Description(shortDefinition="Primary or secondary specimen", formalDefinition="Primary of secondary specimen." )
159        protected BooleanType isDerived;
160
161        /**
162         * The kind of specimen conditioned for testing expected by lab.
163         */
164        @Child(name = "type", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
165        @Description(shortDefinition="Type of intended specimen", formalDefinition="The kind of specimen conditioned for testing expected by lab." )
166        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://terminology.hl7.org/ValueSet/v2-0487")
167        protected CodeableConcept type;
168
169        /**
170         * The preference for this type of conditioned specimen.
171         */
172        @Child(name = "preference", type = {CodeType.class}, order=3, min=1, max=1, modifier=false, summary=false)
173        @Description(shortDefinition="preferred | alternate", formalDefinition="The preference for this type of conditioned specimen." )
174        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/specimen-contained-preference")
175        protected Enumeration<SpecimenContainedPreference> preference;
176
177        /**
178         * The specimen's container.
179         */
180        @Child(name = "container", type = {}, order=4, min=0, max=1, modifier=false, summary=false)
181        @Description(shortDefinition="The specimen's container", formalDefinition="The specimen's container." )
182        protected SpecimenDefinitionTypeTestedContainerComponent container;
183
184        /**
185         * Requirements for delivery and special handling of this kind of conditioned specimen.
186         */
187        @Child(name = "requirement", type = {StringType.class}, order=5, min=0, max=1, modifier=false, summary=false)
188        @Description(shortDefinition="Requirements for specimen delivery and special handling", formalDefinition="Requirements for delivery and special handling of this kind of conditioned specimen." )
189        protected StringType requirement;
190
191        /**
192         * The usual time that a specimen of this kind is retained after the ordered tests are completed, for the purpose of additional testing.
193         */
194        @Child(name = "retentionTime", type = {Duration.class}, order=6, min=0, max=1, modifier=false, summary=false)
195        @Description(shortDefinition="The usual time for retaining this kind of specimen", formalDefinition="The usual time that a specimen of this kind is retained after the ordered tests are completed, for the purpose of additional testing." )
196        protected Duration retentionTime;
197
198        /**
199         * Specimen can be used by only one test or panel if the value is "true".
200         */
201        @Child(name = "singleUse", type = {BooleanType.class}, order=7, min=0, max=1, modifier=false, summary=false)
202        @Description(shortDefinition="Specimen for single use only", formalDefinition="Specimen can be used by only one test or panel if the value is \"true\"." )
203        protected BooleanType singleUse;
204
205        /**
206         * Criterion for rejection of the specimen in its container by the laboratory.
207         */
208        @Child(name = "rejectionCriterion", type = {CodeableConcept.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
209        @Description(shortDefinition="Criterion specified for specimen rejection", formalDefinition="Criterion for rejection of the specimen in its container by the laboratory." )
210        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/rejection-criteria")
211        protected List<CodeableConcept> rejectionCriterion;
212
213        /**
214         * Set of instructions for preservation/transport of the specimen at a defined temperature interval, prior the testing process.
215         */
216        @Child(name = "handling", type = {}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
217        @Description(shortDefinition="Specimen handling before testing", formalDefinition="Set of instructions for preservation/transport of the specimen at a defined temperature interval, prior the testing process." )
218        protected List<SpecimenDefinitionTypeTestedHandlingComponent> handling;
219
220        /**
221         * Where the specimen will be tested: e.g., lab, sector, device or any combination of these.
222         */
223        @Child(name = "testingDestination", type = {CodeableConcept.class}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
224        @Description(shortDefinition="Where the specimen will be tested", formalDefinition="Where the specimen will be tested: e.g., lab, sector, device or any combination of these." )
225        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/diagnostic-service-sections")
226        protected List<CodeableConcept> testingDestination;
227
228        private static final long serialVersionUID = 1859673754L;
229
230    /**
231     * Constructor
232     */
233      public SpecimenDefinitionTypeTestedComponent() {
234        super();
235      }
236
237    /**
238     * Constructor
239     */
240      public SpecimenDefinitionTypeTestedComponent(SpecimenContainedPreference preference) {
241        super();
242        this.setPreference(preference);
243      }
244
245        /**
246         * @return {@link #isDerived} (Primary of secondary specimen.). This is the underlying object with id, value and extensions. The accessor "getIsDerived" gives direct access to the value
247         */
248        public BooleanType getIsDerivedElement() { 
249          if (this.isDerived == null)
250            if (Configuration.errorOnAutoCreate())
251              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedComponent.isDerived");
252            else if (Configuration.doAutoCreate())
253              this.isDerived = new BooleanType(); // bb
254          return this.isDerived;
255        }
256
257        public boolean hasIsDerivedElement() { 
258          return this.isDerived != null && !this.isDerived.isEmpty();
259        }
260
261        public boolean hasIsDerived() { 
262          return this.isDerived != null && !this.isDerived.isEmpty();
263        }
264
265        /**
266         * @param value {@link #isDerived} (Primary of secondary specimen.). This is the underlying object with id, value and extensions. The accessor "getIsDerived" gives direct access to the value
267         */
268        public SpecimenDefinitionTypeTestedComponent setIsDerivedElement(BooleanType value) { 
269          this.isDerived = value;
270          return this;
271        }
272
273        /**
274         * @return Primary of secondary specimen.
275         */
276        public boolean getIsDerived() { 
277          return this.isDerived == null || this.isDerived.isEmpty() ? false : this.isDerived.getValue();
278        }
279
280        /**
281         * @param value Primary of secondary specimen.
282         */
283        public SpecimenDefinitionTypeTestedComponent setIsDerived(boolean value) { 
284            if (this.isDerived == null)
285              this.isDerived = new BooleanType();
286            this.isDerived.setValue(value);
287          return this;
288        }
289
290        /**
291         * @return {@link #type} (The kind of specimen conditioned for testing expected by lab.)
292         */
293        public CodeableConcept getType() { 
294          if (this.type == null)
295            if (Configuration.errorOnAutoCreate())
296              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedComponent.type");
297            else if (Configuration.doAutoCreate())
298              this.type = new CodeableConcept(); // cc
299          return this.type;
300        }
301
302        public boolean hasType() { 
303          return this.type != null && !this.type.isEmpty();
304        }
305
306        /**
307         * @param value {@link #type} (The kind of specimen conditioned for testing expected by lab.)
308         */
309        public SpecimenDefinitionTypeTestedComponent setType(CodeableConcept value) { 
310          this.type = value;
311          return this;
312        }
313
314        /**
315         * @return {@link #preference} (The preference for this type of conditioned specimen.). This is the underlying object with id, value and extensions. The accessor "getPreference" gives direct access to the value
316         */
317        public Enumeration<SpecimenContainedPreference> getPreferenceElement() { 
318          if (this.preference == null)
319            if (Configuration.errorOnAutoCreate())
320              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedComponent.preference");
321            else if (Configuration.doAutoCreate())
322              this.preference = new Enumeration<SpecimenContainedPreference>(new SpecimenContainedPreferenceEnumFactory()); // bb
323          return this.preference;
324        }
325
326        public boolean hasPreferenceElement() { 
327          return this.preference != null && !this.preference.isEmpty();
328        }
329
330        public boolean hasPreference() { 
331          return this.preference != null && !this.preference.isEmpty();
332        }
333
334        /**
335         * @param value {@link #preference} (The preference for this type of conditioned specimen.). This is the underlying object with id, value and extensions. The accessor "getPreference" gives direct access to the value
336         */
337        public SpecimenDefinitionTypeTestedComponent setPreferenceElement(Enumeration<SpecimenContainedPreference> value) { 
338          this.preference = value;
339          return this;
340        }
341
342        /**
343         * @return The preference for this type of conditioned specimen.
344         */
345        public SpecimenContainedPreference getPreference() { 
346          return this.preference == null ? null : this.preference.getValue();
347        }
348
349        /**
350         * @param value The preference for this type of conditioned specimen.
351         */
352        public SpecimenDefinitionTypeTestedComponent setPreference(SpecimenContainedPreference value) { 
353            if (this.preference == null)
354              this.preference = new Enumeration<SpecimenContainedPreference>(new SpecimenContainedPreferenceEnumFactory());
355            this.preference.setValue(value);
356          return this;
357        }
358
359        /**
360         * @return {@link #container} (The specimen's container.)
361         */
362        public SpecimenDefinitionTypeTestedContainerComponent getContainer() { 
363          if (this.container == null)
364            if (Configuration.errorOnAutoCreate())
365              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedComponent.container");
366            else if (Configuration.doAutoCreate())
367              this.container = new SpecimenDefinitionTypeTestedContainerComponent(); // cc
368          return this.container;
369        }
370
371        public boolean hasContainer() { 
372          return this.container != null && !this.container.isEmpty();
373        }
374
375        /**
376         * @param value {@link #container} (The specimen's container.)
377         */
378        public SpecimenDefinitionTypeTestedComponent setContainer(SpecimenDefinitionTypeTestedContainerComponent value) { 
379          this.container = value;
380          return this;
381        }
382
383        /**
384         * @return {@link #requirement} (Requirements for delivery and special handling of this kind of conditioned specimen.). This is the underlying object with id, value and extensions. The accessor "getRequirement" gives direct access to the value
385         */
386        public StringType getRequirementElement() { 
387          if (this.requirement == null)
388            if (Configuration.errorOnAutoCreate())
389              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedComponent.requirement");
390            else if (Configuration.doAutoCreate())
391              this.requirement = new StringType(); // bb
392          return this.requirement;
393        }
394
395        public boolean hasRequirementElement() { 
396          return this.requirement != null && !this.requirement.isEmpty();
397        }
398
399        public boolean hasRequirement() { 
400          return this.requirement != null && !this.requirement.isEmpty();
401        }
402
403        /**
404         * @param value {@link #requirement} (Requirements for delivery and special handling of this kind of conditioned specimen.). This is the underlying object with id, value and extensions. The accessor "getRequirement" gives direct access to the value
405         */
406        public SpecimenDefinitionTypeTestedComponent setRequirementElement(StringType value) { 
407          this.requirement = value;
408          return this;
409        }
410
411        /**
412         * @return Requirements for delivery and special handling of this kind of conditioned specimen.
413         */
414        public String getRequirement() { 
415          return this.requirement == null ? null : this.requirement.getValue();
416        }
417
418        /**
419         * @param value Requirements for delivery and special handling of this kind of conditioned specimen.
420         */
421        public SpecimenDefinitionTypeTestedComponent setRequirement(String value) { 
422          if (Utilities.noString(value))
423            this.requirement = null;
424          else {
425            if (this.requirement == null)
426              this.requirement = new StringType();
427            this.requirement.setValue(value);
428          }
429          return this;
430        }
431
432        /**
433         * @return {@link #retentionTime} (The usual time that a specimen of this kind is retained after the ordered tests are completed, for the purpose of additional testing.)
434         */
435        public Duration getRetentionTime() { 
436          if (this.retentionTime == null)
437            if (Configuration.errorOnAutoCreate())
438              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedComponent.retentionTime");
439            else if (Configuration.doAutoCreate())
440              this.retentionTime = new Duration(); // cc
441          return this.retentionTime;
442        }
443
444        public boolean hasRetentionTime() { 
445          return this.retentionTime != null && !this.retentionTime.isEmpty();
446        }
447
448        /**
449         * @param value {@link #retentionTime} (The usual time that a specimen of this kind is retained after the ordered tests are completed, for the purpose of additional testing.)
450         */
451        public SpecimenDefinitionTypeTestedComponent setRetentionTime(Duration value) { 
452          this.retentionTime = value;
453          return this;
454        }
455
456        /**
457         * @return {@link #singleUse} (Specimen can be used by only one test or panel if the value is "true".). This is the underlying object with id, value and extensions. The accessor "getSingleUse" gives direct access to the value
458         */
459        public BooleanType getSingleUseElement() { 
460          if (this.singleUse == null)
461            if (Configuration.errorOnAutoCreate())
462              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedComponent.singleUse");
463            else if (Configuration.doAutoCreate())
464              this.singleUse = new BooleanType(); // bb
465          return this.singleUse;
466        }
467
468        public boolean hasSingleUseElement() { 
469          return this.singleUse != null && !this.singleUse.isEmpty();
470        }
471
472        public boolean hasSingleUse() { 
473          return this.singleUse != null && !this.singleUse.isEmpty();
474        }
475
476        /**
477         * @param value {@link #singleUse} (Specimen can be used by only one test or panel if the value is "true".). This is the underlying object with id, value and extensions. The accessor "getSingleUse" gives direct access to the value
478         */
479        public SpecimenDefinitionTypeTestedComponent setSingleUseElement(BooleanType value) { 
480          this.singleUse = value;
481          return this;
482        }
483
484        /**
485         * @return Specimen can be used by only one test or panel if the value is "true".
486         */
487        public boolean getSingleUse() { 
488          return this.singleUse == null || this.singleUse.isEmpty() ? false : this.singleUse.getValue();
489        }
490
491        /**
492         * @param value Specimen can be used by only one test or panel if the value is "true".
493         */
494        public SpecimenDefinitionTypeTestedComponent setSingleUse(boolean value) { 
495            if (this.singleUse == null)
496              this.singleUse = new BooleanType();
497            this.singleUse.setValue(value);
498          return this;
499        }
500
501        /**
502         * @return {@link #rejectionCriterion} (Criterion for rejection of the specimen in its container by the laboratory.)
503         */
504        public List<CodeableConcept> getRejectionCriterion() { 
505          if (this.rejectionCriterion == null)
506            this.rejectionCriterion = new ArrayList<CodeableConcept>();
507          return this.rejectionCriterion;
508        }
509
510        /**
511         * @return Returns a reference to <code>this</code> for easy method chaining
512         */
513        public SpecimenDefinitionTypeTestedComponent setRejectionCriterion(List<CodeableConcept> theRejectionCriterion) { 
514          this.rejectionCriterion = theRejectionCriterion;
515          return this;
516        }
517
518        public boolean hasRejectionCriterion() { 
519          if (this.rejectionCriterion == null)
520            return false;
521          for (CodeableConcept item : this.rejectionCriterion)
522            if (!item.isEmpty())
523              return true;
524          return false;
525        }
526
527        public CodeableConcept addRejectionCriterion() { //3
528          CodeableConcept t = new CodeableConcept();
529          if (this.rejectionCriterion == null)
530            this.rejectionCriterion = new ArrayList<CodeableConcept>();
531          this.rejectionCriterion.add(t);
532          return t;
533        }
534
535        public SpecimenDefinitionTypeTestedComponent addRejectionCriterion(CodeableConcept t) { //3
536          if (t == null)
537            return this;
538          if (this.rejectionCriterion == null)
539            this.rejectionCriterion = new ArrayList<CodeableConcept>();
540          this.rejectionCriterion.add(t);
541          return this;
542        }
543
544        /**
545         * @return The first repetition of repeating field {@link #rejectionCriterion}, creating it if it does not already exist {3}
546         */
547        public CodeableConcept getRejectionCriterionFirstRep() { 
548          if (getRejectionCriterion().isEmpty()) {
549            addRejectionCriterion();
550          }
551          return getRejectionCriterion().get(0);
552        }
553
554        /**
555         * @return {@link #handling} (Set of instructions for preservation/transport of the specimen at a defined temperature interval, prior the testing process.)
556         */
557        public List<SpecimenDefinitionTypeTestedHandlingComponent> getHandling() { 
558          if (this.handling == null)
559            this.handling = new ArrayList<SpecimenDefinitionTypeTestedHandlingComponent>();
560          return this.handling;
561        }
562
563        /**
564         * @return Returns a reference to <code>this</code> for easy method chaining
565         */
566        public SpecimenDefinitionTypeTestedComponent setHandling(List<SpecimenDefinitionTypeTestedHandlingComponent> theHandling) { 
567          this.handling = theHandling;
568          return this;
569        }
570
571        public boolean hasHandling() { 
572          if (this.handling == null)
573            return false;
574          for (SpecimenDefinitionTypeTestedHandlingComponent item : this.handling)
575            if (!item.isEmpty())
576              return true;
577          return false;
578        }
579
580        public SpecimenDefinitionTypeTestedHandlingComponent addHandling() { //3
581          SpecimenDefinitionTypeTestedHandlingComponent t = new SpecimenDefinitionTypeTestedHandlingComponent();
582          if (this.handling == null)
583            this.handling = new ArrayList<SpecimenDefinitionTypeTestedHandlingComponent>();
584          this.handling.add(t);
585          return t;
586        }
587
588        public SpecimenDefinitionTypeTestedComponent addHandling(SpecimenDefinitionTypeTestedHandlingComponent t) { //3
589          if (t == null)
590            return this;
591          if (this.handling == null)
592            this.handling = new ArrayList<SpecimenDefinitionTypeTestedHandlingComponent>();
593          this.handling.add(t);
594          return this;
595        }
596
597        /**
598         * @return The first repetition of repeating field {@link #handling}, creating it if it does not already exist {3}
599         */
600        public SpecimenDefinitionTypeTestedHandlingComponent getHandlingFirstRep() { 
601          if (getHandling().isEmpty()) {
602            addHandling();
603          }
604          return getHandling().get(0);
605        }
606
607        /**
608         * @return {@link #testingDestination} (Where the specimen will be tested: e.g., lab, sector, device or any combination of these.)
609         */
610        public List<CodeableConcept> getTestingDestination() { 
611          if (this.testingDestination == null)
612            this.testingDestination = new ArrayList<CodeableConcept>();
613          return this.testingDestination;
614        }
615
616        /**
617         * @return Returns a reference to <code>this</code> for easy method chaining
618         */
619        public SpecimenDefinitionTypeTestedComponent setTestingDestination(List<CodeableConcept> theTestingDestination) { 
620          this.testingDestination = theTestingDestination;
621          return this;
622        }
623
624        public boolean hasTestingDestination() { 
625          if (this.testingDestination == null)
626            return false;
627          for (CodeableConcept item : this.testingDestination)
628            if (!item.isEmpty())
629              return true;
630          return false;
631        }
632
633        public CodeableConcept addTestingDestination() { //3
634          CodeableConcept t = new CodeableConcept();
635          if (this.testingDestination == null)
636            this.testingDestination = new ArrayList<CodeableConcept>();
637          this.testingDestination.add(t);
638          return t;
639        }
640
641        public SpecimenDefinitionTypeTestedComponent addTestingDestination(CodeableConcept t) { //3
642          if (t == null)
643            return this;
644          if (this.testingDestination == null)
645            this.testingDestination = new ArrayList<CodeableConcept>();
646          this.testingDestination.add(t);
647          return this;
648        }
649
650        /**
651         * @return The first repetition of repeating field {@link #testingDestination}, creating it if it does not already exist {3}
652         */
653        public CodeableConcept getTestingDestinationFirstRep() { 
654          if (getTestingDestination().isEmpty()) {
655            addTestingDestination();
656          }
657          return getTestingDestination().get(0);
658        }
659
660        protected void listChildren(List<Property> children) {
661          super.listChildren(children);
662          children.add(new Property("isDerived", "boolean", "Primary of secondary specimen.", 0, 1, isDerived));
663          children.add(new Property("type", "CodeableConcept", "The kind of specimen conditioned for testing expected by lab.", 0, 1, type));
664          children.add(new Property("preference", "code", "The preference for this type of conditioned specimen.", 0, 1, preference));
665          children.add(new Property("container", "", "The specimen's container.", 0, 1, container));
666          children.add(new Property("requirement", "string", "Requirements for delivery and special handling of this kind of conditioned specimen.", 0, 1, requirement));
667          children.add(new Property("retentionTime", "Duration", "The usual time that a specimen of this kind is retained after the ordered tests are completed, for the purpose of additional testing.", 0, 1, retentionTime));
668          children.add(new Property("singleUse", "boolean", "Specimen can be used by only one test or panel if the value is \"true\".", 0, 1, singleUse));
669          children.add(new Property("rejectionCriterion", "CodeableConcept", "Criterion for rejection of the specimen in its container by the laboratory.", 0, java.lang.Integer.MAX_VALUE, rejectionCriterion));
670          children.add(new Property("handling", "", "Set of instructions for preservation/transport of the specimen at a defined temperature interval, prior the testing process.", 0, java.lang.Integer.MAX_VALUE, handling));
671          children.add(new Property("testingDestination", "CodeableConcept", "Where the specimen will be tested: e.g., lab, sector, device or any combination of these.", 0, java.lang.Integer.MAX_VALUE, testingDestination));
672        }
673
674        @Override
675        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
676          switch (_hash) {
677          case 976346515: /*isDerived*/  return new Property("isDerived", "boolean", "Primary of secondary specimen.", 0, 1, isDerived);
678          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "The kind of specimen conditioned for testing expected by lab.", 0, 1, type);
679          case -1459831589: /*preference*/  return new Property("preference", "code", "The preference for this type of conditioned specimen.", 0, 1, preference);
680          case -410956671: /*container*/  return new Property("container", "", "The specimen's container.", 0, 1, container);
681          case 363387971: /*requirement*/  return new Property("requirement", "string", "Requirements for delivery and special handling of this kind of conditioned specimen.", 0, 1, requirement);
682          case 1434969867: /*retentionTime*/  return new Property("retentionTime", "Duration", "The usual time that a specimen of this kind is retained after the ordered tests are completed, for the purpose of additional testing.", 0, 1, retentionTime);
683          case -1494547425: /*singleUse*/  return new Property("singleUse", "boolean", "Specimen can be used by only one test or panel if the value is \"true\".", 0, 1, singleUse);
684          case -553706344: /*rejectionCriterion*/  return new Property("rejectionCriterion", "CodeableConcept", "Criterion for rejection of the specimen in its container by the laboratory.", 0, java.lang.Integer.MAX_VALUE, rejectionCriterion);
685          case 2072805: /*handling*/  return new Property("handling", "", "Set of instructions for preservation/transport of the specimen at a defined temperature interval, prior the testing process.", 0, java.lang.Integer.MAX_VALUE, handling);
686          case 939511774: /*testingDestination*/  return new Property("testingDestination", "CodeableConcept", "Where the specimen will be tested: e.g., lab, sector, device or any combination of these.", 0, java.lang.Integer.MAX_VALUE, testingDestination);
687          default: return super.getNamedProperty(_hash, _name, _checkValid);
688          }
689
690        }
691
692      @Override
693      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
694        switch (hash) {
695        case 976346515: /*isDerived*/ return this.isDerived == null ? new Base[0] : new Base[] {this.isDerived}; // BooleanType
696        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
697        case -1459831589: /*preference*/ return this.preference == null ? new Base[0] : new Base[] {this.preference}; // Enumeration<SpecimenContainedPreference>
698        case -410956671: /*container*/ return this.container == null ? new Base[0] : new Base[] {this.container}; // SpecimenDefinitionTypeTestedContainerComponent
699        case 363387971: /*requirement*/ return this.requirement == null ? new Base[0] : new Base[] {this.requirement}; // StringType
700        case 1434969867: /*retentionTime*/ return this.retentionTime == null ? new Base[0] : new Base[] {this.retentionTime}; // Duration
701        case -1494547425: /*singleUse*/ return this.singleUse == null ? new Base[0] : new Base[] {this.singleUse}; // BooleanType
702        case -553706344: /*rejectionCriterion*/ return this.rejectionCriterion == null ? new Base[0] : this.rejectionCriterion.toArray(new Base[this.rejectionCriterion.size()]); // CodeableConcept
703        case 2072805: /*handling*/ return this.handling == null ? new Base[0] : this.handling.toArray(new Base[this.handling.size()]); // SpecimenDefinitionTypeTestedHandlingComponent
704        case 939511774: /*testingDestination*/ return this.testingDestination == null ? new Base[0] : this.testingDestination.toArray(new Base[this.testingDestination.size()]); // CodeableConcept
705        default: return super.getProperty(hash, name, checkValid);
706        }
707
708      }
709
710      @Override
711      public Base setProperty(int hash, String name, Base value) throws FHIRException {
712        switch (hash) {
713        case 976346515: // isDerived
714          this.isDerived = TypeConvertor.castToBoolean(value); // BooleanType
715          return value;
716        case 3575610: // type
717          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
718          return value;
719        case -1459831589: // preference
720          value = new SpecimenContainedPreferenceEnumFactory().fromType(TypeConvertor.castToCode(value));
721          this.preference = (Enumeration) value; // Enumeration<SpecimenContainedPreference>
722          return value;
723        case -410956671: // container
724          this.container = (SpecimenDefinitionTypeTestedContainerComponent) value; // SpecimenDefinitionTypeTestedContainerComponent
725          return value;
726        case 363387971: // requirement
727          this.requirement = TypeConvertor.castToString(value); // StringType
728          return value;
729        case 1434969867: // retentionTime
730          this.retentionTime = TypeConvertor.castToDuration(value); // Duration
731          return value;
732        case -1494547425: // singleUse
733          this.singleUse = TypeConvertor.castToBoolean(value); // BooleanType
734          return value;
735        case -553706344: // rejectionCriterion
736          this.getRejectionCriterion().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
737          return value;
738        case 2072805: // handling
739          this.getHandling().add((SpecimenDefinitionTypeTestedHandlingComponent) value); // SpecimenDefinitionTypeTestedHandlingComponent
740          return value;
741        case 939511774: // testingDestination
742          this.getTestingDestination().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
743          return value;
744        default: return super.setProperty(hash, name, value);
745        }
746
747      }
748
749      @Override
750      public Base setProperty(String name, Base value) throws FHIRException {
751        if (name.equals("isDerived")) {
752          this.isDerived = TypeConvertor.castToBoolean(value); // BooleanType
753        } else if (name.equals("type")) {
754          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
755        } else if (name.equals("preference")) {
756          value = new SpecimenContainedPreferenceEnumFactory().fromType(TypeConvertor.castToCode(value));
757          this.preference = (Enumeration) value; // Enumeration<SpecimenContainedPreference>
758        } else if (name.equals("container")) {
759          this.container = (SpecimenDefinitionTypeTestedContainerComponent) value; // SpecimenDefinitionTypeTestedContainerComponent
760        } else if (name.equals("requirement")) {
761          this.requirement = TypeConvertor.castToString(value); // StringType
762        } else if (name.equals("retentionTime")) {
763          this.retentionTime = TypeConvertor.castToDuration(value); // Duration
764        } else if (name.equals("singleUse")) {
765          this.singleUse = TypeConvertor.castToBoolean(value); // BooleanType
766        } else if (name.equals("rejectionCriterion")) {
767          this.getRejectionCriterion().add(TypeConvertor.castToCodeableConcept(value));
768        } else if (name.equals("handling")) {
769          this.getHandling().add((SpecimenDefinitionTypeTestedHandlingComponent) value);
770        } else if (name.equals("testingDestination")) {
771          this.getTestingDestination().add(TypeConvertor.castToCodeableConcept(value));
772        } else
773          return super.setProperty(name, value);
774        return value;
775      }
776
777      @Override
778      public Base makeProperty(int hash, String name) throws FHIRException {
779        switch (hash) {
780        case 976346515:  return getIsDerivedElement();
781        case 3575610:  return getType();
782        case -1459831589:  return getPreferenceElement();
783        case -410956671:  return getContainer();
784        case 363387971:  return getRequirementElement();
785        case 1434969867:  return getRetentionTime();
786        case -1494547425:  return getSingleUseElement();
787        case -553706344:  return addRejectionCriterion(); 
788        case 2072805:  return addHandling(); 
789        case 939511774:  return addTestingDestination(); 
790        default: return super.makeProperty(hash, name);
791        }
792
793      }
794
795      @Override
796      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
797        switch (hash) {
798        case 976346515: /*isDerived*/ return new String[] {"boolean"};
799        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
800        case -1459831589: /*preference*/ return new String[] {"code"};
801        case -410956671: /*container*/ return new String[] {};
802        case 363387971: /*requirement*/ return new String[] {"string"};
803        case 1434969867: /*retentionTime*/ return new String[] {"Duration"};
804        case -1494547425: /*singleUse*/ return new String[] {"boolean"};
805        case -553706344: /*rejectionCriterion*/ return new String[] {"CodeableConcept"};
806        case 2072805: /*handling*/ return new String[] {};
807        case 939511774: /*testingDestination*/ return new String[] {"CodeableConcept"};
808        default: return super.getTypesForProperty(hash, name);
809        }
810
811      }
812
813      @Override
814      public Base addChild(String name) throws FHIRException {
815        if (name.equals("isDerived")) {
816          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.typeTested.isDerived");
817        }
818        else if (name.equals("type")) {
819          this.type = new CodeableConcept();
820          return this.type;
821        }
822        else if (name.equals("preference")) {
823          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.typeTested.preference");
824        }
825        else if (name.equals("container")) {
826          this.container = new SpecimenDefinitionTypeTestedContainerComponent();
827          return this.container;
828        }
829        else if (name.equals("requirement")) {
830          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.typeTested.requirement");
831        }
832        else if (name.equals("retentionTime")) {
833          this.retentionTime = new Duration();
834          return this.retentionTime;
835        }
836        else if (name.equals("singleUse")) {
837          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.typeTested.singleUse");
838        }
839        else if (name.equals("rejectionCriterion")) {
840          return addRejectionCriterion();
841        }
842        else if (name.equals("handling")) {
843          return addHandling();
844        }
845        else if (name.equals("testingDestination")) {
846          return addTestingDestination();
847        }
848        else
849          return super.addChild(name);
850      }
851
852      public SpecimenDefinitionTypeTestedComponent copy() {
853        SpecimenDefinitionTypeTestedComponent dst = new SpecimenDefinitionTypeTestedComponent();
854        copyValues(dst);
855        return dst;
856      }
857
858      public void copyValues(SpecimenDefinitionTypeTestedComponent dst) {
859        super.copyValues(dst);
860        dst.isDerived = isDerived == null ? null : isDerived.copy();
861        dst.type = type == null ? null : type.copy();
862        dst.preference = preference == null ? null : preference.copy();
863        dst.container = container == null ? null : container.copy();
864        dst.requirement = requirement == null ? null : requirement.copy();
865        dst.retentionTime = retentionTime == null ? null : retentionTime.copy();
866        dst.singleUse = singleUse == null ? null : singleUse.copy();
867        if (rejectionCriterion != null) {
868          dst.rejectionCriterion = new ArrayList<CodeableConcept>();
869          for (CodeableConcept i : rejectionCriterion)
870            dst.rejectionCriterion.add(i.copy());
871        };
872        if (handling != null) {
873          dst.handling = new ArrayList<SpecimenDefinitionTypeTestedHandlingComponent>();
874          for (SpecimenDefinitionTypeTestedHandlingComponent i : handling)
875            dst.handling.add(i.copy());
876        };
877        if (testingDestination != null) {
878          dst.testingDestination = new ArrayList<CodeableConcept>();
879          for (CodeableConcept i : testingDestination)
880            dst.testingDestination.add(i.copy());
881        };
882      }
883
884      @Override
885      public boolean equalsDeep(Base other_) {
886        if (!super.equalsDeep(other_))
887          return false;
888        if (!(other_ instanceof SpecimenDefinitionTypeTestedComponent))
889          return false;
890        SpecimenDefinitionTypeTestedComponent o = (SpecimenDefinitionTypeTestedComponent) other_;
891        return compareDeep(isDerived, o.isDerived, true) && compareDeep(type, o.type, true) && compareDeep(preference, o.preference, true)
892           && compareDeep(container, o.container, true) && compareDeep(requirement, o.requirement, true) && compareDeep(retentionTime, o.retentionTime, true)
893           && compareDeep(singleUse, o.singleUse, true) && compareDeep(rejectionCriterion, o.rejectionCriterion, true)
894           && compareDeep(handling, o.handling, true) && compareDeep(testingDestination, o.testingDestination, true)
895          ;
896      }
897
898      @Override
899      public boolean equalsShallow(Base other_) {
900        if (!super.equalsShallow(other_))
901          return false;
902        if (!(other_ instanceof SpecimenDefinitionTypeTestedComponent))
903          return false;
904        SpecimenDefinitionTypeTestedComponent o = (SpecimenDefinitionTypeTestedComponent) other_;
905        return compareValues(isDerived, o.isDerived, true) && compareValues(preference, o.preference, true)
906           && compareValues(requirement, o.requirement, true) && compareValues(singleUse, o.singleUse, true);
907      }
908
909      public boolean isEmpty() {
910        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(isDerived, type, preference
911          , container, requirement, retentionTime, singleUse, rejectionCriterion, handling
912          , testingDestination);
913      }
914
915  public String fhirType() {
916    return "SpecimenDefinition.typeTested";
917
918  }
919
920  }
921
922    @Block()
923    public static class SpecimenDefinitionTypeTestedContainerComponent extends BackboneElement implements IBaseBackboneElement {
924        /**
925         * The type of material of the container.
926         */
927        @Child(name = "material", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=false)
928        @Description(shortDefinition="The material type used for the container", formalDefinition="The type of material of the container." )
929        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/container-material")
930        protected CodeableConcept material;
931
932        /**
933         * The type of container used to contain this kind of specimen.
934         */
935        @Child(name = "type", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
936        @Description(shortDefinition="Kind of container associated with the kind of specimen", formalDefinition="The type of container used to contain this kind of specimen." )
937        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/specimen-container-type")
938        protected CodeableConcept type;
939
940        /**
941         * Color of container cap.
942         */
943        @Child(name = "cap", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=false)
944        @Description(shortDefinition="Color of container cap", formalDefinition="Color of container cap." )
945        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/container-cap")
946        protected CodeableConcept cap;
947
948        /**
949         * The textual description of the kind of container.
950         */
951        @Child(name = "description", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=false)
952        @Description(shortDefinition="The description of the kind of container", formalDefinition="The textual description of the kind of container." )
953        protected StringType description;
954
955        /**
956         * The capacity (volume or other measure) of this kind of container.
957         */
958        @Child(name = "capacity", type = {Quantity.class}, order=5, min=0, max=1, modifier=false, summary=false)
959        @Description(shortDefinition="The capacity of this kind of container", formalDefinition="The capacity (volume or other measure) of this kind of container." )
960        protected Quantity capacity;
961
962        /**
963         * The minimum volume to be conditioned in the container.
964         */
965        @Child(name = "minimumVolume", type = {Quantity.class, StringType.class}, order=6, min=0, max=1, modifier=false, summary=false)
966        @Description(shortDefinition="Minimum volume", formalDefinition="The minimum volume to be conditioned in the container." )
967        protected DataType minimumVolume;
968
969        /**
970         * Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.
971         */
972        @Child(name = "additive", type = {}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
973        @Description(shortDefinition="Additive associated with container", formalDefinition="Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA." )
974        protected List<SpecimenDefinitionTypeTestedContainerAdditiveComponent> additive;
975
976        /**
977         * Special processing that should be applied to the container for this kind of specimen.
978         */
979        @Child(name = "preparation", type = {StringType.class}, order=8, min=0, max=1, modifier=false, summary=false)
980        @Description(shortDefinition="Special processing applied to the container for this specimen type", formalDefinition="Special processing that should be applied to the container for this kind of specimen." )
981        protected StringType preparation;
982
983        private static final long serialVersionUID = -1498817064L;
984
985    /**
986     * Constructor
987     */
988      public SpecimenDefinitionTypeTestedContainerComponent() {
989        super();
990      }
991
992        /**
993         * @return {@link #material} (The type of material of the container.)
994         */
995        public CodeableConcept getMaterial() { 
996          if (this.material == null)
997            if (Configuration.errorOnAutoCreate())
998              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedContainerComponent.material");
999            else if (Configuration.doAutoCreate())
1000              this.material = new CodeableConcept(); // cc
1001          return this.material;
1002        }
1003
1004        public boolean hasMaterial() { 
1005          return this.material != null && !this.material.isEmpty();
1006        }
1007
1008        /**
1009         * @param value {@link #material} (The type of material of the container.)
1010         */
1011        public SpecimenDefinitionTypeTestedContainerComponent setMaterial(CodeableConcept value) { 
1012          this.material = value;
1013          return this;
1014        }
1015
1016        /**
1017         * @return {@link #type} (The type of container used to contain this kind of specimen.)
1018         */
1019        public CodeableConcept getType() { 
1020          if (this.type == null)
1021            if (Configuration.errorOnAutoCreate())
1022              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedContainerComponent.type");
1023            else if (Configuration.doAutoCreate())
1024              this.type = new CodeableConcept(); // cc
1025          return this.type;
1026        }
1027
1028        public boolean hasType() { 
1029          return this.type != null && !this.type.isEmpty();
1030        }
1031
1032        /**
1033         * @param value {@link #type} (The type of container used to contain this kind of specimen.)
1034         */
1035        public SpecimenDefinitionTypeTestedContainerComponent setType(CodeableConcept value) { 
1036          this.type = value;
1037          return this;
1038        }
1039
1040        /**
1041         * @return {@link #cap} (Color of container cap.)
1042         */
1043        public CodeableConcept getCap() { 
1044          if (this.cap == null)
1045            if (Configuration.errorOnAutoCreate())
1046              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedContainerComponent.cap");
1047            else if (Configuration.doAutoCreate())
1048              this.cap = new CodeableConcept(); // cc
1049          return this.cap;
1050        }
1051
1052        public boolean hasCap() { 
1053          return this.cap != null && !this.cap.isEmpty();
1054        }
1055
1056        /**
1057         * @param value {@link #cap} (Color of container cap.)
1058         */
1059        public SpecimenDefinitionTypeTestedContainerComponent setCap(CodeableConcept value) { 
1060          this.cap = value;
1061          return this;
1062        }
1063
1064        /**
1065         * @return {@link #description} (The textual description of the kind of container.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
1066         */
1067        public StringType getDescriptionElement() { 
1068          if (this.description == null)
1069            if (Configuration.errorOnAutoCreate())
1070              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedContainerComponent.description");
1071            else if (Configuration.doAutoCreate())
1072              this.description = new StringType(); // bb
1073          return this.description;
1074        }
1075
1076        public boolean hasDescriptionElement() { 
1077          return this.description != null && !this.description.isEmpty();
1078        }
1079
1080        public boolean hasDescription() { 
1081          return this.description != null && !this.description.isEmpty();
1082        }
1083
1084        /**
1085         * @param value {@link #description} (The textual description of the kind of container.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
1086         */
1087        public SpecimenDefinitionTypeTestedContainerComponent setDescriptionElement(StringType value) { 
1088          this.description = value;
1089          return this;
1090        }
1091
1092        /**
1093         * @return The textual description of the kind of container.
1094         */
1095        public String getDescription() { 
1096          return this.description == null ? null : this.description.getValue();
1097        }
1098
1099        /**
1100         * @param value The textual description of the kind of container.
1101         */
1102        public SpecimenDefinitionTypeTestedContainerComponent setDescription(String value) { 
1103          if (Utilities.noString(value))
1104            this.description = null;
1105          else {
1106            if (this.description == null)
1107              this.description = new StringType();
1108            this.description.setValue(value);
1109          }
1110          return this;
1111        }
1112
1113        /**
1114         * @return {@link #capacity} (The capacity (volume or other measure) of this kind of container.)
1115         */
1116        public Quantity getCapacity() { 
1117          if (this.capacity == null)
1118            if (Configuration.errorOnAutoCreate())
1119              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedContainerComponent.capacity");
1120            else if (Configuration.doAutoCreate())
1121              this.capacity = new Quantity(); // cc
1122          return this.capacity;
1123        }
1124
1125        public boolean hasCapacity() { 
1126          return this.capacity != null && !this.capacity.isEmpty();
1127        }
1128
1129        /**
1130         * @param value {@link #capacity} (The capacity (volume or other measure) of this kind of container.)
1131         */
1132        public SpecimenDefinitionTypeTestedContainerComponent setCapacity(Quantity value) { 
1133          this.capacity = value;
1134          return this;
1135        }
1136
1137        /**
1138         * @return {@link #minimumVolume} (The minimum volume to be conditioned in the container.)
1139         */
1140        public DataType getMinimumVolume() { 
1141          return this.minimumVolume;
1142        }
1143
1144        /**
1145         * @return {@link #minimumVolume} (The minimum volume to be conditioned in the container.)
1146         */
1147        public Quantity getMinimumVolumeQuantity() throws FHIRException { 
1148          if (this.minimumVolume == null)
1149            this.minimumVolume = new Quantity();
1150          if (!(this.minimumVolume instanceof Quantity))
1151            throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.minimumVolume.getClass().getName()+" was encountered");
1152          return (Quantity) this.minimumVolume;
1153        }
1154
1155        public boolean hasMinimumVolumeQuantity() { 
1156          return this != null && this.minimumVolume instanceof Quantity;
1157        }
1158
1159        /**
1160         * @return {@link #minimumVolume} (The minimum volume to be conditioned in the container.)
1161         */
1162        public StringType getMinimumVolumeStringType() throws FHIRException { 
1163          if (this.minimumVolume == null)
1164            this.minimumVolume = new StringType();
1165          if (!(this.minimumVolume instanceof StringType))
1166            throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.minimumVolume.getClass().getName()+" was encountered");
1167          return (StringType) this.minimumVolume;
1168        }
1169
1170        public boolean hasMinimumVolumeStringType() { 
1171          return this != null && this.minimumVolume instanceof StringType;
1172        }
1173
1174        public boolean hasMinimumVolume() { 
1175          return this.minimumVolume != null && !this.minimumVolume.isEmpty();
1176        }
1177
1178        /**
1179         * @param value {@link #minimumVolume} (The minimum volume to be conditioned in the container.)
1180         */
1181        public SpecimenDefinitionTypeTestedContainerComponent setMinimumVolume(DataType value) { 
1182          if (value != null && !(value instanceof Quantity || value instanceof StringType))
1183            throw new Error("Not the right type for SpecimenDefinition.typeTested.container.minimumVolume[x]: "+value.fhirType());
1184          this.minimumVolume = value;
1185          return this;
1186        }
1187
1188        /**
1189         * @return {@link #additive} (Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.)
1190         */
1191        public List<SpecimenDefinitionTypeTestedContainerAdditiveComponent> getAdditive() { 
1192          if (this.additive == null)
1193            this.additive = new ArrayList<SpecimenDefinitionTypeTestedContainerAdditiveComponent>();
1194          return this.additive;
1195        }
1196
1197        /**
1198         * @return Returns a reference to <code>this</code> for easy method chaining
1199         */
1200        public SpecimenDefinitionTypeTestedContainerComponent setAdditive(List<SpecimenDefinitionTypeTestedContainerAdditiveComponent> theAdditive) { 
1201          this.additive = theAdditive;
1202          return this;
1203        }
1204
1205        public boolean hasAdditive() { 
1206          if (this.additive == null)
1207            return false;
1208          for (SpecimenDefinitionTypeTestedContainerAdditiveComponent item : this.additive)
1209            if (!item.isEmpty())
1210              return true;
1211          return false;
1212        }
1213
1214        public SpecimenDefinitionTypeTestedContainerAdditiveComponent addAdditive() { //3
1215          SpecimenDefinitionTypeTestedContainerAdditiveComponent t = new SpecimenDefinitionTypeTestedContainerAdditiveComponent();
1216          if (this.additive == null)
1217            this.additive = new ArrayList<SpecimenDefinitionTypeTestedContainerAdditiveComponent>();
1218          this.additive.add(t);
1219          return t;
1220        }
1221
1222        public SpecimenDefinitionTypeTestedContainerComponent addAdditive(SpecimenDefinitionTypeTestedContainerAdditiveComponent t) { //3
1223          if (t == null)
1224            return this;
1225          if (this.additive == null)
1226            this.additive = new ArrayList<SpecimenDefinitionTypeTestedContainerAdditiveComponent>();
1227          this.additive.add(t);
1228          return this;
1229        }
1230
1231        /**
1232         * @return The first repetition of repeating field {@link #additive}, creating it if it does not already exist {3}
1233         */
1234        public SpecimenDefinitionTypeTestedContainerAdditiveComponent getAdditiveFirstRep() { 
1235          if (getAdditive().isEmpty()) {
1236            addAdditive();
1237          }
1238          return getAdditive().get(0);
1239        }
1240
1241        /**
1242         * @return {@link #preparation} (Special processing that should be applied to the container for this kind of specimen.). This is the underlying object with id, value and extensions. The accessor "getPreparation" gives direct access to the value
1243         */
1244        public StringType getPreparationElement() { 
1245          if (this.preparation == null)
1246            if (Configuration.errorOnAutoCreate())
1247              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedContainerComponent.preparation");
1248            else if (Configuration.doAutoCreate())
1249              this.preparation = new StringType(); // bb
1250          return this.preparation;
1251        }
1252
1253        public boolean hasPreparationElement() { 
1254          return this.preparation != null && !this.preparation.isEmpty();
1255        }
1256
1257        public boolean hasPreparation() { 
1258          return this.preparation != null && !this.preparation.isEmpty();
1259        }
1260
1261        /**
1262         * @param value {@link #preparation} (Special processing that should be applied to the container for this kind of specimen.). This is the underlying object with id, value and extensions. The accessor "getPreparation" gives direct access to the value
1263         */
1264        public SpecimenDefinitionTypeTestedContainerComponent setPreparationElement(StringType value) { 
1265          this.preparation = value;
1266          return this;
1267        }
1268
1269        /**
1270         * @return Special processing that should be applied to the container for this kind of specimen.
1271         */
1272        public String getPreparation() { 
1273          return this.preparation == null ? null : this.preparation.getValue();
1274        }
1275
1276        /**
1277         * @param value Special processing that should be applied to the container for this kind of specimen.
1278         */
1279        public SpecimenDefinitionTypeTestedContainerComponent setPreparation(String value) { 
1280          if (Utilities.noString(value))
1281            this.preparation = null;
1282          else {
1283            if (this.preparation == null)
1284              this.preparation = new StringType();
1285            this.preparation.setValue(value);
1286          }
1287          return this;
1288        }
1289
1290        protected void listChildren(List<Property> children) {
1291          super.listChildren(children);
1292          children.add(new Property("material", "CodeableConcept", "The type of material of the container.", 0, 1, material));
1293          children.add(new Property("type", "CodeableConcept", "The type of container used to contain this kind of specimen.", 0, 1, type));
1294          children.add(new Property("cap", "CodeableConcept", "Color of container cap.", 0, 1, cap));
1295          children.add(new Property("description", "string", "The textual description of the kind of container.", 0, 1, description));
1296          children.add(new Property("capacity", "Quantity", "The capacity (volume or other measure) of this kind of container.", 0, 1, capacity));
1297          children.add(new Property("minimumVolume[x]", "Quantity|string", "The minimum volume to be conditioned in the container.", 0, 1, minimumVolume));
1298          children.add(new Property("additive", "", "Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.", 0, java.lang.Integer.MAX_VALUE, additive));
1299          children.add(new Property("preparation", "string", "Special processing that should be applied to the container for this kind of specimen.", 0, 1, preparation));
1300        }
1301
1302        @Override
1303        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1304          switch (_hash) {
1305          case 299066663: /*material*/  return new Property("material", "CodeableConcept", "The type of material of the container.", 0, 1, material);
1306          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "The type of container used to contain this kind of specimen.", 0, 1, type);
1307          case 98258: /*cap*/  return new Property("cap", "CodeableConcept", "Color of container cap.", 0, 1, cap);
1308          case -1724546052: /*description*/  return new Property("description", "string", "The textual description of the kind of container.", 0, 1, description);
1309          case -67824454: /*capacity*/  return new Property("capacity", "Quantity", "The capacity (volume or other measure) of this kind of container.", 0, 1, capacity);
1310          case 371830456: /*minimumVolume[x]*/  return new Property("minimumVolume[x]", "Quantity|string", "The minimum volume to be conditioned in the container.", 0, 1, minimumVolume);
1311          case -1674665784: /*minimumVolume*/  return new Property("minimumVolume[x]", "Quantity|string", "The minimum volume to be conditioned in the container.", 0, 1, minimumVolume);
1312          case -532143757: /*minimumVolumeQuantity*/  return new Property("minimumVolume[x]", "Quantity", "The minimum volume to be conditioned in the container.", 0, 1, minimumVolume);
1313          case 248461049: /*minimumVolumeString*/  return new Property("minimumVolume[x]", "string", "The minimum volume to be conditioned in the container.", 0, 1, minimumVolume);
1314          case -1226589236: /*additive*/  return new Property("additive", "", "Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.", 0, java.lang.Integer.MAX_VALUE, additive);
1315          case -1315428713: /*preparation*/  return new Property("preparation", "string", "Special processing that should be applied to the container for this kind of specimen.", 0, 1, preparation);
1316          default: return super.getNamedProperty(_hash, _name, _checkValid);
1317          }
1318
1319        }
1320
1321      @Override
1322      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1323        switch (hash) {
1324        case 299066663: /*material*/ return this.material == null ? new Base[0] : new Base[] {this.material}; // CodeableConcept
1325        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
1326        case 98258: /*cap*/ return this.cap == null ? new Base[0] : new Base[] {this.cap}; // CodeableConcept
1327        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // StringType
1328        case -67824454: /*capacity*/ return this.capacity == null ? new Base[0] : new Base[] {this.capacity}; // Quantity
1329        case -1674665784: /*minimumVolume*/ return this.minimumVolume == null ? new Base[0] : new Base[] {this.minimumVolume}; // DataType
1330        case -1226589236: /*additive*/ return this.additive == null ? new Base[0] : this.additive.toArray(new Base[this.additive.size()]); // SpecimenDefinitionTypeTestedContainerAdditiveComponent
1331        case -1315428713: /*preparation*/ return this.preparation == null ? new Base[0] : new Base[] {this.preparation}; // StringType
1332        default: return super.getProperty(hash, name, checkValid);
1333        }
1334
1335      }
1336
1337      @Override
1338      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1339        switch (hash) {
1340        case 299066663: // material
1341          this.material = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1342          return value;
1343        case 3575610: // type
1344          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1345          return value;
1346        case 98258: // cap
1347          this.cap = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1348          return value;
1349        case -1724546052: // description
1350          this.description = TypeConvertor.castToString(value); // StringType
1351          return value;
1352        case -67824454: // capacity
1353          this.capacity = TypeConvertor.castToQuantity(value); // Quantity
1354          return value;
1355        case -1674665784: // minimumVolume
1356          this.minimumVolume = TypeConvertor.castToType(value); // DataType
1357          return value;
1358        case -1226589236: // additive
1359          this.getAdditive().add((SpecimenDefinitionTypeTestedContainerAdditiveComponent) value); // SpecimenDefinitionTypeTestedContainerAdditiveComponent
1360          return value;
1361        case -1315428713: // preparation
1362          this.preparation = TypeConvertor.castToString(value); // StringType
1363          return value;
1364        default: return super.setProperty(hash, name, value);
1365        }
1366
1367      }
1368
1369      @Override
1370      public Base setProperty(String name, Base value) throws FHIRException {
1371        if (name.equals("material")) {
1372          this.material = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1373        } else if (name.equals("type")) {
1374          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1375        } else if (name.equals("cap")) {
1376          this.cap = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1377        } else if (name.equals("description")) {
1378          this.description = TypeConvertor.castToString(value); // StringType
1379        } else if (name.equals("capacity")) {
1380          this.capacity = TypeConvertor.castToQuantity(value); // Quantity
1381        } else if (name.equals("minimumVolume[x]")) {
1382          this.minimumVolume = TypeConvertor.castToType(value); // DataType
1383        } else if (name.equals("additive")) {
1384          this.getAdditive().add((SpecimenDefinitionTypeTestedContainerAdditiveComponent) value);
1385        } else if (name.equals("preparation")) {
1386          this.preparation = TypeConvertor.castToString(value); // StringType
1387        } else
1388          return super.setProperty(name, value);
1389        return value;
1390      }
1391
1392      @Override
1393      public Base makeProperty(int hash, String name) throws FHIRException {
1394        switch (hash) {
1395        case 299066663:  return getMaterial();
1396        case 3575610:  return getType();
1397        case 98258:  return getCap();
1398        case -1724546052:  return getDescriptionElement();
1399        case -67824454:  return getCapacity();
1400        case 371830456:  return getMinimumVolume();
1401        case -1674665784:  return getMinimumVolume();
1402        case -1226589236:  return addAdditive(); 
1403        case -1315428713:  return getPreparationElement();
1404        default: return super.makeProperty(hash, name);
1405        }
1406
1407      }
1408
1409      @Override
1410      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1411        switch (hash) {
1412        case 299066663: /*material*/ return new String[] {"CodeableConcept"};
1413        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
1414        case 98258: /*cap*/ return new String[] {"CodeableConcept"};
1415        case -1724546052: /*description*/ return new String[] {"string"};
1416        case -67824454: /*capacity*/ return new String[] {"Quantity"};
1417        case -1674665784: /*minimumVolume*/ return new String[] {"Quantity", "string"};
1418        case -1226589236: /*additive*/ return new String[] {};
1419        case -1315428713: /*preparation*/ return new String[] {"string"};
1420        default: return super.getTypesForProperty(hash, name);
1421        }
1422
1423      }
1424
1425      @Override
1426      public Base addChild(String name) throws FHIRException {
1427        if (name.equals("material")) {
1428          this.material = new CodeableConcept();
1429          return this.material;
1430        }
1431        else if (name.equals("type")) {
1432          this.type = new CodeableConcept();
1433          return this.type;
1434        }
1435        else if (name.equals("cap")) {
1436          this.cap = new CodeableConcept();
1437          return this.cap;
1438        }
1439        else if (name.equals("description")) {
1440          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.typeTested.container.description");
1441        }
1442        else if (name.equals("capacity")) {
1443          this.capacity = new Quantity();
1444          return this.capacity;
1445        }
1446        else if (name.equals("minimumVolumeQuantity")) {
1447          this.minimumVolume = new Quantity();
1448          return this.minimumVolume;
1449        }
1450        else if (name.equals("minimumVolumeString")) {
1451          this.minimumVolume = new StringType();
1452          return this.minimumVolume;
1453        }
1454        else if (name.equals("additive")) {
1455          return addAdditive();
1456        }
1457        else if (name.equals("preparation")) {
1458          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.typeTested.container.preparation");
1459        }
1460        else
1461          return super.addChild(name);
1462      }
1463
1464      public SpecimenDefinitionTypeTestedContainerComponent copy() {
1465        SpecimenDefinitionTypeTestedContainerComponent dst = new SpecimenDefinitionTypeTestedContainerComponent();
1466        copyValues(dst);
1467        return dst;
1468      }
1469
1470      public void copyValues(SpecimenDefinitionTypeTestedContainerComponent dst) {
1471        super.copyValues(dst);
1472        dst.material = material == null ? null : material.copy();
1473        dst.type = type == null ? null : type.copy();
1474        dst.cap = cap == null ? null : cap.copy();
1475        dst.description = description == null ? null : description.copy();
1476        dst.capacity = capacity == null ? null : capacity.copy();
1477        dst.minimumVolume = minimumVolume == null ? null : minimumVolume.copy();
1478        if (additive != null) {
1479          dst.additive = new ArrayList<SpecimenDefinitionTypeTestedContainerAdditiveComponent>();
1480          for (SpecimenDefinitionTypeTestedContainerAdditiveComponent i : additive)
1481            dst.additive.add(i.copy());
1482        };
1483        dst.preparation = preparation == null ? null : preparation.copy();
1484      }
1485
1486      @Override
1487      public boolean equalsDeep(Base other_) {
1488        if (!super.equalsDeep(other_))
1489          return false;
1490        if (!(other_ instanceof SpecimenDefinitionTypeTestedContainerComponent))
1491          return false;
1492        SpecimenDefinitionTypeTestedContainerComponent o = (SpecimenDefinitionTypeTestedContainerComponent) other_;
1493        return compareDeep(material, o.material, true) && compareDeep(type, o.type, true) && compareDeep(cap, o.cap, true)
1494           && compareDeep(description, o.description, true) && compareDeep(capacity, o.capacity, true) && compareDeep(minimumVolume, o.minimumVolume, true)
1495           && compareDeep(additive, o.additive, true) && compareDeep(preparation, o.preparation, true);
1496      }
1497
1498      @Override
1499      public boolean equalsShallow(Base other_) {
1500        if (!super.equalsShallow(other_))
1501          return false;
1502        if (!(other_ instanceof SpecimenDefinitionTypeTestedContainerComponent))
1503          return false;
1504        SpecimenDefinitionTypeTestedContainerComponent o = (SpecimenDefinitionTypeTestedContainerComponent) other_;
1505        return compareValues(description, o.description, true) && compareValues(preparation, o.preparation, true)
1506          ;
1507      }
1508
1509      public boolean isEmpty() {
1510        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(material, type, cap, description
1511          , capacity, minimumVolume, additive, preparation);
1512      }
1513
1514  public String fhirType() {
1515    return "SpecimenDefinition.typeTested.container";
1516
1517  }
1518
1519  }
1520
1521    @Block()
1522    public static class SpecimenDefinitionTypeTestedContainerAdditiveComponent extends BackboneElement implements IBaseBackboneElement {
1523        /**
1524         * Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.
1525         */
1526        @Child(name = "additive", type = {CodeableConcept.class, SubstanceDefinition.class}, order=1, min=1, max=1, modifier=false, summary=false)
1527        @Description(shortDefinition="Additive associated with container", formalDefinition="Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA." )
1528        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://terminology.hl7.org/ValueSet/v2-0371")
1529        protected DataType additive;
1530
1531        private static final long serialVersionUID = 201856258L;
1532
1533    /**
1534     * Constructor
1535     */
1536      public SpecimenDefinitionTypeTestedContainerAdditiveComponent() {
1537        super();
1538      }
1539
1540    /**
1541     * Constructor
1542     */
1543      public SpecimenDefinitionTypeTestedContainerAdditiveComponent(DataType additive) {
1544        super();
1545        this.setAdditive(additive);
1546      }
1547
1548        /**
1549         * @return {@link #additive} (Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.)
1550         */
1551        public DataType getAdditive() { 
1552          return this.additive;
1553        }
1554
1555        /**
1556         * @return {@link #additive} (Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.)
1557         */
1558        public CodeableConcept getAdditiveCodeableConcept() throws FHIRException { 
1559          if (this.additive == null)
1560            this.additive = new CodeableConcept();
1561          if (!(this.additive instanceof CodeableConcept))
1562            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.additive.getClass().getName()+" was encountered");
1563          return (CodeableConcept) this.additive;
1564        }
1565
1566        public boolean hasAdditiveCodeableConcept() { 
1567          return this != null && this.additive instanceof CodeableConcept;
1568        }
1569
1570        /**
1571         * @return {@link #additive} (Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.)
1572         */
1573        public Reference getAdditiveReference() throws FHIRException { 
1574          if (this.additive == null)
1575            this.additive = new Reference();
1576          if (!(this.additive instanceof Reference))
1577            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.additive.getClass().getName()+" was encountered");
1578          return (Reference) this.additive;
1579        }
1580
1581        public boolean hasAdditiveReference() { 
1582          return this != null && this.additive instanceof Reference;
1583        }
1584
1585        public boolean hasAdditive() { 
1586          return this.additive != null && !this.additive.isEmpty();
1587        }
1588
1589        /**
1590         * @param value {@link #additive} (Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.)
1591         */
1592        public SpecimenDefinitionTypeTestedContainerAdditiveComponent setAdditive(DataType value) { 
1593          if (value != null && !(value instanceof CodeableConcept || value instanceof Reference))
1594            throw new Error("Not the right type for SpecimenDefinition.typeTested.container.additive.additive[x]: "+value.fhirType());
1595          this.additive = value;
1596          return this;
1597        }
1598
1599        protected void listChildren(List<Property> children) {
1600          super.listChildren(children);
1601          children.add(new Property("additive[x]", "CodeableConcept|Reference(SubstanceDefinition)", "Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.", 0, 1, additive));
1602        }
1603
1604        @Override
1605        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1606          switch (_hash) {
1607          case 261915956: /*additive[x]*/  return new Property("additive[x]", "CodeableConcept|Reference(SubstanceDefinition)", "Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.", 0, 1, additive);
1608          case -1226589236: /*additive*/  return new Property("additive[x]", "CodeableConcept|Reference(SubstanceDefinition)", "Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.", 0, 1, additive);
1609          case 1330272821: /*additiveCodeableConcept*/  return new Property("additive[x]", "CodeableConcept", "Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.", 0, 1, additive);
1610          case -386783009: /*additiveReference*/  return new Property("additive[x]", "Reference(SubstanceDefinition)", "Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.", 0, 1, additive);
1611          default: return super.getNamedProperty(_hash, _name, _checkValid);
1612          }
1613
1614        }
1615
1616      @Override
1617      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1618        switch (hash) {
1619        case -1226589236: /*additive*/ return this.additive == null ? new Base[0] : new Base[] {this.additive}; // DataType
1620        default: return super.getProperty(hash, name, checkValid);
1621        }
1622
1623      }
1624
1625      @Override
1626      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1627        switch (hash) {
1628        case -1226589236: // additive
1629          this.additive = TypeConvertor.castToType(value); // DataType
1630          return value;
1631        default: return super.setProperty(hash, name, value);
1632        }
1633
1634      }
1635
1636      @Override
1637      public Base setProperty(String name, Base value) throws FHIRException {
1638        if (name.equals("additive[x]")) {
1639          this.additive = TypeConvertor.castToType(value); // DataType
1640        } else
1641          return super.setProperty(name, value);
1642        return value;
1643      }
1644
1645      @Override
1646      public Base makeProperty(int hash, String name) throws FHIRException {
1647        switch (hash) {
1648        case 261915956:  return getAdditive();
1649        case -1226589236:  return getAdditive();
1650        default: return super.makeProperty(hash, name);
1651        }
1652
1653      }
1654
1655      @Override
1656      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1657        switch (hash) {
1658        case -1226589236: /*additive*/ return new String[] {"CodeableConcept", "Reference"};
1659        default: return super.getTypesForProperty(hash, name);
1660        }
1661
1662      }
1663
1664      @Override
1665      public Base addChild(String name) throws FHIRException {
1666        if (name.equals("additiveCodeableConcept")) {
1667          this.additive = new CodeableConcept();
1668          return this.additive;
1669        }
1670        else if (name.equals("additiveReference")) {
1671          this.additive = new Reference();
1672          return this.additive;
1673        }
1674        else
1675          return super.addChild(name);
1676      }
1677
1678      public SpecimenDefinitionTypeTestedContainerAdditiveComponent copy() {
1679        SpecimenDefinitionTypeTestedContainerAdditiveComponent dst = new SpecimenDefinitionTypeTestedContainerAdditiveComponent();
1680        copyValues(dst);
1681        return dst;
1682      }
1683
1684      public void copyValues(SpecimenDefinitionTypeTestedContainerAdditiveComponent dst) {
1685        super.copyValues(dst);
1686        dst.additive = additive == null ? null : additive.copy();
1687      }
1688
1689      @Override
1690      public boolean equalsDeep(Base other_) {
1691        if (!super.equalsDeep(other_))
1692          return false;
1693        if (!(other_ instanceof SpecimenDefinitionTypeTestedContainerAdditiveComponent))
1694          return false;
1695        SpecimenDefinitionTypeTestedContainerAdditiveComponent o = (SpecimenDefinitionTypeTestedContainerAdditiveComponent) other_;
1696        return compareDeep(additive, o.additive, true);
1697      }
1698
1699      @Override
1700      public boolean equalsShallow(Base other_) {
1701        if (!super.equalsShallow(other_))
1702          return false;
1703        if (!(other_ instanceof SpecimenDefinitionTypeTestedContainerAdditiveComponent))
1704          return false;
1705        SpecimenDefinitionTypeTestedContainerAdditiveComponent o = (SpecimenDefinitionTypeTestedContainerAdditiveComponent) other_;
1706        return true;
1707      }
1708
1709      public boolean isEmpty() {
1710        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(additive);
1711      }
1712
1713  public String fhirType() {
1714    return "SpecimenDefinition.typeTested.container.additive";
1715
1716  }
1717
1718  }
1719
1720    @Block()
1721    public static class SpecimenDefinitionTypeTestedHandlingComponent extends BackboneElement implements IBaseBackboneElement {
1722        /**
1723         * It qualifies the interval of temperature, which characterizes an occurrence of handling. Conditions that are not related to temperature may be handled in the instruction element.
1724         */
1725        @Child(name = "temperatureQualifier", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=false)
1726        @Description(shortDefinition="Qualifies the interval of temperature", formalDefinition="It qualifies the interval of temperature, which characterizes an occurrence of handling. Conditions that are not related to temperature may be handled in the instruction element." )
1727        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/handling-condition")
1728        protected CodeableConcept temperatureQualifier;
1729
1730        /**
1731         * The temperature interval for this set of handling instructions.
1732         */
1733        @Child(name = "temperatureRange", type = {Range.class}, order=2, min=0, max=1, modifier=false, summary=false)
1734        @Description(shortDefinition="Temperature range for these handling instructions", formalDefinition="The temperature interval for this set of handling instructions." )
1735        protected Range temperatureRange;
1736
1737        /**
1738         * The maximum time interval of preservation of the specimen with these conditions.
1739         */
1740        @Child(name = "maxDuration", type = {Duration.class}, order=3, min=0, max=1, modifier=false, summary=false)
1741        @Description(shortDefinition="Maximum preservation time", formalDefinition="The maximum time interval of preservation of the specimen with these conditions." )
1742        protected Duration maxDuration;
1743
1744        /**
1745         * Additional textual instructions for the preservation or transport of the specimen. For instance, 'Protect from light exposure'.
1746         */
1747        @Child(name = "instruction", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=false)
1748        @Description(shortDefinition="Preservation instruction", formalDefinition="Additional textual instructions for the preservation or transport of the specimen. For instance, 'Protect from light exposure'." )
1749        protected StringType instruction;
1750
1751        private static final long serialVersionUID = 2130906844L;
1752
1753    /**
1754     * Constructor
1755     */
1756      public SpecimenDefinitionTypeTestedHandlingComponent() {
1757        super();
1758      }
1759
1760        /**
1761         * @return {@link #temperatureQualifier} (It qualifies the interval of temperature, which characterizes an occurrence of handling. Conditions that are not related to temperature may be handled in the instruction element.)
1762         */
1763        public CodeableConcept getTemperatureQualifier() { 
1764          if (this.temperatureQualifier == null)
1765            if (Configuration.errorOnAutoCreate())
1766              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedHandlingComponent.temperatureQualifier");
1767            else if (Configuration.doAutoCreate())
1768              this.temperatureQualifier = new CodeableConcept(); // cc
1769          return this.temperatureQualifier;
1770        }
1771
1772        public boolean hasTemperatureQualifier() { 
1773          return this.temperatureQualifier != null && !this.temperatureQualifier.isEmpty();
1774        }
1775
1776        /**
1777         * @param value {@link #temperatureQualifier} (It qualifies the interval of temperature, which characterizes an occurrence of handling. Conditions that are not related to temperature may be handled in the instruction element.)
1778         */
1779        public SpecimenDefinitionTypeTestedHandlingComponent setTemperatureQualifier(CodeableConcept value) { 
1780          this.temperatureQualifier = value;
1781          return this;
1782        }
1783
1784        /**
1785         * @return {@link #temperatureRange} (The temperature interval for this set of handling instructions.)
1786         */
1787        public Range getTemperatureRange() { 
1788          if (this.temperatureRange == null)
1789            if (Configuration.errorOnAutoCreate())
1790              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedHandlingComponent.temperatureRange");
1791            else if (Configuration.doAutoCreate())
1792              this.temperatureRange = new Range(); // cc
1793          return this.temperatureRange;
1794        }
1795
1796        public boolean hasTemperatureRange() { 
1797          return this.temperatureRange != null && !this.temperatureRange.isEmpty();
1798        }
1799
1800        /**
1801         * @param value {@link #temperatureRange} (The temperature interval for this set of handling instructions.)
1802         */
1803        public SpecimenDefinitionTypeTestedHandlingComponent setTemperatureRange(Range value) { 
1804          this.temperatureRange = value;
1805          return this;
1806        }
1807
1808        /**
1809         * @return {@link #maxDuration} (The maximum time interval of preservation of the specimen with these conditions.)
1810         */
1811        public Duration getMaxDuration() { 
1812          if (this.maxDuration == null)
1813            if (Configuration.errorOnAutoCreate())
1814              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedHandlingComponent.maxDuration");
1815            else if (Configuration.doAutoCreate())
1816              this.maxDuration = new Duration(); // cc
1817          return this.maxDuration;
1818        }
1819
1820        public boolean hasMaxDuration() { 
1821          return this.maxDuration != null && !this.maxDuration.isEmpty();
1822        }
1823
1824        /**
1825         * @param value {@link #maxDuration} (The maximum time interval of preservation of the specimen with these conditions.)
1826         */
1827        public SpecimenDefinitionTypeTestedHandlingComponent setMaxDuration(Duration value) { 
1828          this.maxDuration = value;
1829          return this;
1830        }
1831
1832        /**
1833         * @return {@link #instruction} (Additional textual instructions for the preservation or transport of the specimen. For instance, 'Protect from light exposure'.). This is the underlying object with id, value and extensions. The accessor "getInstruction" gives direct access to the value
1834         */
1835        public StringType getInstructionElement() { 
1836          if (this.instruction == null)
1837            if (Configuration.errorOnAutoCreate())
1838              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedHandlingComponent.instruction");
1839            else if (Configuration.doAutoCreate())
1840              this.instruction = new StringType(); // bb
1841          return this.instruction;
1842        }
1843
1844        public boolean hasInstructionElement() { 
1845          return this.instruction != null && !this.instruction.isEmpty();
1846        }
1847
1848        public boolean hasInstruction() { 
1849          return this.instruction != null && !this.instruction.isEmpty();
1850        }
1851
1852        /**
1853         * @param value {@link #instruction} (Additional textual instructions for the preservation or transport of the specimen. For instance, 'Protect from light exposure'.). This is the underlying object with id, value and extensions. The accessor "getInstruction" gives direct access to the value
1854         */
1855        public SpecimenDefinitionTypeTestedHandlingComponent setInstructionElement(StringType value) { 
1856          this.instruction = value;
1857          return this;
1858        }
1859
1860        /**
1861         * @return Additional textual instructions for the preservation or transport of the specimen. For instance, 'Protect from light exposure'.
1862         */
1863        public String getInstruction() { 
1864          return this.instruction == null ? null : this.instruction.getValue();
1865        }
1866
1867        /**
1868         * @param value Additional textual instructions for the preservation or transport of the specimen. For instance, 'Protect from light exposure'.
1869         */
1870        public SpecimenDefinitionTypeTestedHandlingComponent setInstruction(String value) { 
1871          if (Utilities.noString(value))
1872            this.instruction = null;
1873          else {
1874            if (this.instruction == null)
1875              this.instruction = new StringType();
1876            this.instruction.setValue(value);
1877          }
1878          return this;
1879        }
1880
1881        protected void listChildren(List<Property> children) {
1882          super.listChildren(children);
1883          children.add(new Property("temperatureQualifier", "CodeableConcept", "It qualifies the interval of temperature, which characterizes an occurrence of handling. Conditions that are not related to temperature may be handled in the instruction element.", 0, 1, temperatureQualifier));
1884          children.add(new Property("temperatureRange", "Range", "The temperature interval for this set of handling instructions.", 0, 1, temperatureRange));
1885          children.add(new Property("maxDuration", "Duration", "The maximum time interval of preservation of the specimen with these conditions.", 0, 1, maxDuration));
1886          children.add(new Property("instruction", "string", "Additional textual instructions for the preservation or transport of the specimen. For instance, 'Protect from light exposure'.", 0, 1, instruction));
1887        }
1888
1889        @Override
1890        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1891          switch (_hash) {
1892          case 548941206: /*temperatureQualifier*/  return new Property("temperatureQualifier", "CodeableConcept", "It qualifies the interval of temperature, which characterizes an occurrence of handling. Conditions that are not related to temperature may be handled in the instruction element.", 0, 1, temperatureQualifier);
1893          case -39203799: /*temperatureRange*/  return new Property("temperatureRange", "Range", "The temperature interval for this set of handling instructions.", 0, 1, temperatureRange);
1894          case 40284952: /*maxDuration*/  return new Property("maxDuration", "Duration", "The maximum time interval of preservation of the specimen with these conditions.", 0, 1, maxDuration);
1895          case 301526158: /*instruction*/  return new Property("instruction", "string", "Additional textual instructions for the preservation or transport of the specimen. For instance, 'Protect from light exposure'.", 0, 1, instruction);
1896          default: return super.getNamedProperty(_hash, _name, _checkValid);
1897          }
1898
1899        }
1900
1901      @Override
1902      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1903        switch (hash) {
1904        case 548941206: /*temperatureQualifier*/ return this.temperatureQualifier == null ? new Base[0] : new Base[] {this.temperatureQualifier}; // CodeableConcept
1905        case -39203799: /*temperatureRange*/ return this.temperatureRange == null ? new Base[0] : new Base[] {this.temperatureRange}; // Range
1906        case 40284952: /*maxDuration*/ return this.maxDuration == null ? new Base[0] : new Base[] {this.maxDuration}; // Duration
1907        case 301526158: /*instruction*/ return this.instruction == null ? new Base[0] : new Base[] {this.instruction}; // StringType
1908        default: return super.getProperty(hash, name, checkValid);
1909        }
1910
1911      }
1912
1913      @Override
1914      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1915        switch (hash) {
1916        case 548941206: // temperatureQualifier
1917          this.temperatureQualifier = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1918          return value;
1919        case -39203799: // temperatureRange
1920          this.temperatureRange = TypeConvertor.castToRange(value); // Range
1921          return value;
1922        case 40284952: // maxDuration
1923          this.maxDuration = TypeConvertor.castToDuration(value); // Duration
1924          return value;
1925        case 301526158: // instruction
1926          this.instruction = TypeConvertor.castToString(value); // StringType
1927          return value;
1928        default: return super.setProperty(hash, name, value);
1929        }
1930
1931      }
1932
1933      @Override
1934      public Base setProperty(String name, Base value) throws FHIRException {
1935        if (name.equals("temperatureQualifier")) {
1936          this.temperatureQualifier = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1937        } else if (name.equals("temperatureRange")) {
1938          this.temperatureRange = TypeConvertor.castToRange(value); // Range
1939        } else if (name.equals("maxDuration")) {
1940          this.maxDuration = TypeConvertor.castToDuration(value); // Duration
1941        } else if (name.equals("instruction")) {
1942          this.instruction = TypeConvertor.castToString(value); // StringType
1943        } else
1944          return super.setProperty(name, value);
1945        return value;
1946      }
1947
1948      @Override
1949      public Base makeProperty(int hash, String name) throws FHIRException {
1950        switch (hash) {
1951        case 548941206:  return getTemperatureQualifier();
1952        case -39203799:  return getTemperatureRange();
1953        case 40284952:  return getMaxDuration();
1954        case 301526158:  return getInstructionElement();
1955        default: return super.makeProperty(hash, name);
1956        }
1957
1958      }
1959
1960      @Override
1961      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1962        switch (hash) {
1963        case 548941206: /*temperatureQualifier*/ return new String[] {"CodeableConcept"};
1964        case -39203799: /*temperatureRange*/ return new String[] {"Range"};
1965        case 40284952: /*maxDuration*/ return new String[] {"Duration"};
1966        case 301526158: /*instruction*/ return new String[] {"string"};
1967        default: return super.getTypesForProperty(hash, name);
1968        }
1969
1970      }
1971
1972      @Override
1973      public Base addChild(String name) throws FHIRException {
1974        if (name.equals("temperatureQualifier")) {
1975          this.temperatureQualifier = new CodeableConcept();
1976          return this.temperatureQualifier;
1977        }
1978        else if (name.equals("temperatureRange")) {
1979          this.temperatureRange = new Range();
1980          return this.temperatureRange;
1981        }
1982        else if (name.equals("maxDuration")) {
1983          this.maxDuration = new Duration();
1984          return this.maxDuration;
1985        }
1986        else if (name.equals("instruction")) {
1987          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.typeTested.handling.instruction");
1988        }
1989        else
1990          return super.addChild(name);
1991      }
1992
1993      public SpecimenDefinitionTypeTestedHandlingComponent copy() {
1994        SpecimenDefinitionTypeTestedHandlingComponent dst = new SpecimenDefinitionTypeTestedHandlingComponent();
1995        copyValues(dst);
1996        return dst;
1997      }
1998
1999      public void copyValues(SpecimenDefinitionTypeTestedHandlingComponent dst) {
2000        super.copyValues(dst);
2001        dst.temperatureQualifier = temperatureQualifier == null ? null : temperatureQualifier.copy();
2002        dst.temperatureRange = temperatureRange == null ? null : temperatureRange.copy();
2003        dst.maxDuration = maxDuration == null ? null : maxDuration.copy();
2004        dst.instruction = instruction == null ? null : instruction.copy();
2005      }
2006
2007      @Override
2008      public boolean equalsDeep(Base other_) {
2009        if (!super.equalsDeep(other_))
2010          return false;
2011        if (!(other_ instanceof SpecimenDefinitionTypeTestedHandlingComponent))
2012          return false;
2013        SpecimenDefinitionTypeTestedHandlingComponent o = (SpecimenDefinitionTypeTestedHandlingComponent) other_;
2014        return compareDeep(temperatureQualifier, o.temperatureQualifier, true) && compareDeep(temperatureRange, o.temperatureRange, true)
2015           && compareDeep(maxDuration, o.maxDuration, true) && compareDeep(instruction, o.instruction, true)
2016          ;
2017      }
2018
2019      @Override
2020      public boolean equalsShallow(Base other_) {
2021        if (!super.equalsShallow(other_))
2022          return false;
2023        if (!(other_ instanceof SpecimenDefinitionTypeTestedHandlingComponent))
2024          return false;
2025        SpecimenDefinitionTypeTestedHandlingComponent o = (SpecimenDefinitionTypeTestedHandlingComponent) other_;
2026        return compareValues(instruction, o.instruction, true);
2027      }
2028
2029      public boolean isEmpty() {
2030        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(temperatureQualifier, temperatureRange
2031          , maxDuration, instruction);
2032      }
2033
2034  public String fhirType() {
2035    return "SpecimenDefinition.typeTested.handling";
2036
2037  }
2038
2039  }
2040
2041    /**
2042     * An absolute URL that is used to identify this SpecimenDefinition when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this SpecimenDefinition is (or will be) published. The URL SHOULD include the major version of the SpecimenDefinition. For more information see Technical and Business Versions.
2043     */
2044    @Child(name = "url", type = {UriType.class}, order=0, min=0, max=1, modifier=false, summary=true)
2045    @Description(shortDefinition="Logical canonical URL to reference this SpecimenDefinition (globally unique)", formalDefinition="An absolute URL that is used to identify this SpecimenDefinition when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this SpecimenDefinition is (or will be) published. The URL SHOULD include the major version of the SpecimenDefinition. For more information see Technical and Business Versions." )
2046    protected UriType url;
2047
2048    /**
2049     * A business identifier assigned to this SpecimenDefinition.
2050     */
2051    @Child(name = "identifier", type = {Identifier.class}, order=1, min=0, max=1, modifier=false, summary=true)
2052    @Description(shortDefinition="Business identifier", formalDefinition="A business identifier assigned to this SpecimenDefinition." )
2053    protected Identifier identifier;
2054
2055    /**
2056     * The identifier that is used to identify this version of the SpecimenDefinition when it is referenced in a specification, model, design or instance. This is an arbitrary value managed by the SpecimenDefinition author and is not expected to be globally unique.
2057     */
2058    @Child(name = "version", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=true)
2059    @Description(shortDefinition="Business version of the SpecimenDefinition", formalDefinition="The identifier that is used to identify this version of the SpecimenDefinition when it is referenced in a specification, model, design or instance. This is an arbitrary value managed by the SpecimenDefinition author and is not expected to be globally unique." )
2060    protected StringType version;
2061
2062    /**
2063     * A short, descriptive, user-friendly title for the SpecimenDefinition.
2064     */
2065    @Child(name = "title", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true)
2066    @Description(shortDefinition="Name for this SpecimenDefinition (Human friendly)", formalDefinition="A short, descriptive, user-friendly title for the SpecimenDefinition." )
2067    protected StringType title;
2068
2069    /**
2070     * The canonical URL pointing to another FHIR-defined SpecimenDefinition that is adhered to in whole or in part by this definition.
2071     */
2072    @Child(name = "derivedFromCanonical", type = {CanonicalType.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2073    @Description(shortDefinition="Based on FHIR definition of another SpecimenDefinition", formalDefinition="The canonical URL pointing to another FHIR-defined SpecimenDefinition that is adhered to in whole or in part by this definition." )
2074    protected List<CanonicalType> derivedFromCanonical;
2075
2076    /**
2077     * The URL pointing to an externally-defined type of specimen, guideline or other definition that is adhered to in whole or in part by this definition.
2078     */
2079    @Child(name = "derivedFromUri", type = {UriType.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2080    @Description(shortDefinition="Based on external definition", formalDefinition="The URL pointing to an externally-defined type of specimen, guideline or other definition that is adhered to in whole or in part by this definition." )
2081    protected List<UriType> derivedFromUri;
2082
2083    /**
2084     * The current state of theSpecimenDefinition.
2085     */
2086    @Child(name = "status", type = {CodeType.class}, order=6, min=1, max=1, modifier=true, summary=true)
2087    @Description(shortDefinition="draft | active | retired | unknown", formalDefinition="The current state of theSpecimenDefinition." )
2088    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/publication-status")
2089    protected Enumeration<PublicationStatus> status;
2090
2091    /**
2092     * A flag to indicate that this SpecimenDefinition is not authored for  genuine usage.
2093     */
2094    @Child(name = "experimental", type = {BooleanType.class}, order=7, min=0, max=1, modifier=true, summary=true)
2095    @Description(shortDefinition="If this SpecimenDefinition is not for real usage", formalDefinition="A flag to indicate that this SpecimenDefinition is not authored for  genuine usage." )
2096    protected BooleanType experimental;
2097
2098    /**
2099     * A code or group definition that describes the intended subject  from which this kind of specimen is to be collected.
2100     */
2101    @Child(name = "subject", type = {CodeableConcept.class, Group.class}, order=8, min=0, max=1, modifier=false, summary=true)
2102    @Description(shortDefinition="Type of subject for specimen collection", formalDefinition="A code or group definition that describes the intended subject  from which this kind of specimen is to be collected." )
2103    protected DataType subject;
2104
2105    /**
2106     * For draft definitions, indicates the date of initial creation. For active definitions, represents the date of activation. For withdrawn definitions, indicates the date of withdrawal.
2107     */
2108    @Child(name = "date", type = {DateTimeType.class}, order=9, min=0, max=1, modifier=false, summary=true)
2109    @Description(shortDefinition="Date status first applied", formalDefinition="For draft definitions, indicates the date of initial creation. For active definitions, represents the date of activation. For withdrawn definitions, indicates the date of withdrawal." )
2110    protected DateTimeType date;
2111
2112    /**
2113     * Helps establish the "authority/credibility" of the SpecimenDefinition. May also allow for contact.
2114     */
2115    @Child(name = "publisher", type = {Practitioner.class, PractitionerRole.class, Organization.class}, order=10, min=0, max=1, modifier=false, summary=true)
2116    @Description(shortDefinition="The name of the individual or organization that published the SpecimenDefinition", formalDefinition="Helps establish the \"authority/credibility\" of the SpecimenDefinition. May also allow for contact." )
2117    protected Reference publisher;
2118
2119    /**
2120     * Contact details to assist a user in finding and communicating with the publisher.
2121     */
2122    @Child(name = "contact", type = {ContactDetail.class}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2123    @Description(shortDefinition="Contact details for the publisher", formalDefinition="Contact details to assist a user in finding and communicating with the publisher." )
2124    protected List<ContactDetail> contact;
2125
2126    /**
2127     * A free text natural language description of the SpecimenDefinition from the consumer's perspective.
2128     */
2129    @Child(name = "description", type = {MarkdownType.class}, order=12, min=0, max=1, modifier=false, summary=false)
2130    @Description(shortDefinition="Natural language description of the SpecimenDefinition", formalDefinition="A free text natural language description of the SpecimenDefinition from the consumer's perspective." )
2131    protected MarkdownType description;
2132
2133    /**
2134     * The content was developed with a focus and intent of supporting the contexts that are listed. These terms may be used to assist with indexing and searching of specimen definitions.
2135     */
2136    @Child(name = "useContext", type = {UsageContext.class}, order=13, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2137    @Description(shortDefinition="Content intends to support these contexts", formalDefinition="The content was developed with a focus and intent of supporting the contexts that are listed. These terms may be used to assist with indexing and searching of specimen definitions." )
2138    protected List<UsageContext> useContext;
2139
2140    /**
2141     * A jurisdiction in which the SpecimenDefinition is intended to be used.
2142     */
2143    @Child(name = "jurisdiction", type = {CodeableConcept.class}, order=14, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2144    @Description(shortDefinition="Intended jurisdiction for this SpecimenDefinition (if applicable)", formalDefinition="A jurisdiction in which the SpecimenDefinition is intended to be used." )
2145    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/jurisdiction")
2146    protected List<CodeableConcept> jurisdiction;
2147
2148    /**
2149     * Explains why this SpecimeDefinition is needed and why it has been designed as it has.
2150     */
2151    @Child(name = "purpose", type = {MarkdownType.class}, order=15, min=0, max=1, modifier=false, summary=false)
2152    @Description(shortDefinition="Why this SpecimenDefinition is defined", formalDefinition="Explains why this SpecimeDefinition is needed and why it has been designed as it has." )
2153    protected MarkdownType purpose;
2154
2155    /**
2156     * Copyright statement relating to the SpecimenDefinition and/or its contents. Copyright statements are generally legal restrictions on the use and publishing of the SpecimenDefinition.
2157     */
2158    @Child(name = "copyright", type = {MarkdownType.class}, order=16, min=0, max=1, modifier=false, summary=false)
2159    @Description(shortDefinition="Use and/or publishing restrictions", formalDefinition="Copyright statement relating to the SpecimenDefinition and/or its contents. Copyright statements are generally legal restrictions on the use and publishing of the SpecimenDefinition." )
2160    protected MarkdownType copyright;
2161
2162    /**
2163     * The date on which the asset content was approved by the publisher. Approval happens once when the content is officially approved for usage.
2164     */
2165    @Child(name = "approvalDate", type = {DateType.class}, order=17, min=0, max=1, modifier=false, summary=false)
2166    @Description(shortDefinition="When SpecimenDefinition was approved by publisher", formalDefinition="The date on which the asset content was approved by the publisher. Approval happens once when the content is officially approved for usage." )
2167    protected DateType approvalDate;
2168
2169    /**
2170     * The date on which the asset content was last reviewed. Review happens periodically after that, but doesn't change the original approval date.
2171     */
2172    @Child(name = "lastReviewDate", type = {DateType.class}, order=18, min=0, max=1, modifier=false, summary=false)
2173    @Description(shortDefinition="The date on which the asset content was last reviewed", formalDefinition="The date on which the asset content was last reviewed. Review happens periodically after that, but doesn't change the original approval date." )
2174    protected DateType lastReviewDate;
2175
2176    /**
2177     * The period during which the SpecimenDefinition content was or is planned to be effective.
2178     */
2179    @Child(name = "effectivePeriod", type = {Period.class}, order=19, min=0, max=1, modifier=false, summary=true)
2180    @Description(shortDefinition="The effective date range for the SpecimenDefinition", formalDefinition="The period during which the SpecimenDefinition content was or is planned to be effective." )
2181    protected Period effectivePeriod;
2182
2183    /**
2184     * The kind of material to be collected.
2185     */
2186    @Child(name = "typeCollected", type = {CodeableConcept.class}, order=20, min=0, max=1, modifier=false, summary=true)
2187    @Description(shortDefinition="Kind of material to collect", formalDefinition="The kind of material to be collected." )
2188    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://terminology.hl7.org/ValueSet/v2-0487")
2189    protected CodeableConcept typeCollected;
2190
2191    /**
2192     * Preparation of the patient for specimen collection.
2193     */
2194    @Child(name = "patientPreparation", type = {CodeableConcept.class}, order=21, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2195    @Description(shortDefinition="Patient preparation for collection", formalDefinition="Preparation of the patient for specimen collection." )
2196    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/prepare-patient-prior-specimen-collection")
2197    protected List<CodeableConcept> patientPreparation;
2198
2199    /**
2200     * Time aspect of specimen collection (duration or offset).
2201     */
2202    @Child(name = "timeAspect", type = {StringType.class}, order=22, min=0, max=1, modifier=false, summary=true)
2203    @Description(shortDefinition="Time aspect for collection", formalDefinition="Time aspect of specimen collection (duration or offset)." )
2204    protected StringType timeAspect;
2205
2206    /**
2207     * The action to be performed for collecting the specimen.
2208     */
2209    @Child(name = "collection", type = {CodeableConcept.class}, order=23, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2210    @Description(shortDefinition="Specimen collection procedure", formalDefinition="The action to be performed for collecting the specimen." )
2211    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/specimen-collection")
2212    protected List<CodeableConcept> collection;
2213
2214    /**
2215     * Specimen conditioned in a container as expected by the testing laboratory.
2216     */
2217    @Child(name = "typeTested", type = {}, order=24, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2218    @Description(shortDefinition="Specimen in container intended for testing by lab", formalDefinition="Specimen conditioned in a container as expected by the testing laboratory." )
2219    protected List<SpecimenDefinitionTypeTestedComponent> typeTested;
2220
2221    private static final long serialVersionUID = 830184995L;
2222
2223  /**
2224   * Constructor
2225   */
2226    public SpecimenDefinition() {
2227      super();
2228    }
2229
2230  /**
2231   * Constructor
2232   */
2233    public SpecimenDefinition(PublicationStatus status) {
2234      super();
2235      this.setStatus(status);
2236    }
2237
2238    /**
2239     * @return {@link #url} (An absolute URL that is used to identify this SpecimenDefinition when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this SpecimenDefinition is (or will be) published. The URL SHOULD include the major version of the SpecimenDefinition. For more information see Technical and Business Versions.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value
2240     */
2241    public UriType getUrlElement() { 
2242      if (this.url == null)
2243        if (Configuration.errorOnAutoCreate())
2244          throw new Error("Attempt to auto-create SpecimenDefinition.url");
2245        else if (Configuration.doAutoCreate())
2246          this.url = new UriType(); // bb
2247      return this.url;
2248    }
2249
2250    public boolean hasUrlElement() { 
2251      return this.url != null && !this.url.isEmpty();
2252    }
2253
2254    public boolean hasUrl() { 
2255      return this.url != null && !this.url.isEmpty();
2256    }
2257
2258    /**
2259     * @param value {@link #url} (An absolute URL that is used to identify this SpecimenDefinition when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this SpecimenDefinition is (or will be) published. The URL SHOULD include the major version of the SpecimenDefinition. For more information see Technical and Business Versions.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value
2260     */
2261    public SpecimenDefinition setUrlElement(UriType value) { 
2262      this.url = value;
2263      return this;
2264    }
2265
2266    /**
2267     * @return An absolute URL that is used to identify this SpecimenDefinition when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this SpecimenDefinition is (or will be) published. The URL SHOULD include the major version of the SpecimenDefinition. For more information see Technical and Business Versions.
2268     */
2269    public String getUrl() { 
2270      return this.url == null ? null : this.url.getValue();
2271    }
2272
2273    /**
2274     * @param value An absolute URL that is used to identify this SpecimenDefinition when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this SpecimenDefinition is (or will be) published. The URL SHOULD include the major version of the SpecimenDefinition. For more information see Technical and Business Versions.
2275     */
2276    public SpecimenDefinition setUrl(String value) { 
2277      if (Utilities.noString(value))
2278        this.url = null;
2279      else {
2280        if (this.url == null)
2281          this.url = new UriType();
2282        this.url.setValue(value);
2283      }
2284      return this;
2285    }
2286
2287    /**
2288     * @return {@link #identifier} (A business identifier assigned to this SpecimenDefinition.)
2289     */
2290    public Identifier getIdentifier() { 
2291      if (this.identifier == null)
2292        if (Configuration.errorOnAutoCreate())
2293          throw new Error("Attempt to auto-create SpecimenDefinition.identifier");
2294        else if (Configuration.doAutoCreate())
2295          this.identifier = new Identifier(); // cc
2296      return this.identifier;
2297    }
2298
2299    public boolean hasIdentifier() { 
2300      return this.identifier != null && !this.identifier.isEmpty();
2301    }
2302
2303    /**
2304     * @param value {@link #identifier} (A business identifier assigned to this SpecimenDefinition.)
2305     */
2306    public SpecimenDefinition setIdentifier(Identifier value) { 
2307      this.identifier = value;
2308      return this;
2309    }
2310
2311    /**
2312     * @return {@link #version} (The identifier that is used to identify this version of the SpecimenDefinition when it is referenced in a specification, model, design or instance. This is an arbitrary value managed by the SpecimenDefinition author and is not expected to be globally unique.). This is the underlying object with id, value and extensions. The accessor "getVersion" gives direct access to the value
2313     */
2314    public StringType getVersionElement() { 
2315      if (this.version == null)
2316        if (Configuration.errorOnAutoCreate())
2317          throw new Error("Attempt to auto-create SpecimenDefinition.version");
2318        else if (Configuration.doAutoCreate())
2319          this.version = new StringType(); // bb
2320      return this.version;
2321    }
2322
2323    public boolean hasVersionElement() { 
2324      return this.version != null && !this.version.isEmpty();
2325    }
2326
2327    public boolean hasVersion() { 
2328      return this.version != null && !this.version.isEmpty();
2329    }
2330
2331    /**
2332     * @param value {@link #version} (The identifier that is used to identify this version of the SpecimenDefinition when it is referenced in a specification, model, design or instance. This is an arbitrary value managed by the SpecimenDefinition author and is not expected to be globally unique.). This is the underlying object with id, value and extensions. The accessor "getVersion" gives direct access to the value
2333     */
2334    public SpecimenDefinition setVersionElement(StringType value) { 
2335      this.version = value;
2336      return this;
2337    }
2338
2339    /**
2340     * @return The identifier that is used to identify this version of the SpecimenDefinition when it is referenced in a specification, model, design or instance. This is an arbitrary value managed by the SpecimenDefinition author and is not expected to be globally unique.
2341     */
2342    public String getVersion() { 
2343      return this.version == null ? null : this.version.getValue();
2344    }
2345
2346    /**
2347     * @param value The identifier that is used to identify this version of the SpecimenDefinition when it is referenced in a specification, model, design or instance. This is an arbitrary value managed by the SpecimenDefinition author and is not expected to be globally unique.
2348     */
2349    public SpecimenDefinition setVersion(String value) { 
2350      if (Utilities.noString(value))
2351        this.version = null;
2352      else {
2353        if (this.version == null)
2354          this.version = new StringType();
2355        this.version.setValue(value);
2356      }
2357      return this;
2358    }
2359
2360    /**
2361     * @return {@link #title} (A short, descriptive, user-friendly title for the SpecimenDefinition.). This is the underlying object with id, value and extensions. The accessor "getTitle" gives direct access to the value
2362     */
2363    public StringType getTitleElement() { 
2364      if (this.title == null)
2365        if (Configuration.errorOnAutoCreate())
2366          throw new Error("Attempt to auto-create SpecimenDefinition.title");
2367        else if (Configuration.doAutoCreate())
2368          this.title = new StringType(); // bb
2369      return this.title;
2370    }
2371
2372    public boolean hasTitleElement() { 
2373      return this.title != null && !this.title.isEmpty();
2374    }
2375
2376    public boolean hasTitle() { 
2377      return this.title != null && !this.title.isEmpty();
2378    }
2379
2380    /**
2381     * @param value {@link #title} (A short, descriptive, user-friendly title for the SpecimenDefinition.). This is the underlying object with id, value and extensions. The accessor "getTitle" gives direct access to the value
2382     */
2383    public SpecimenDefinition setTitleElement(StringType value) { 
2384      this.title = value;
2385      return this;
2386    }
2387
2388    /**
2389     * @return A short, descriptive, user-friendly title for the SpecimenDefinition.
2390     */
2391    public String getTitle() { 
2392      return this.title == null ? null : this.title.getValue();
2393    }
2394
2395    /**
2396     * @param value A short, descriptive, user-friendly title for the SpecimenDefinition.
2397     */
2398    public SpecimenDefinition setTitle(String value) { 
2399      if (Utilities.noString(value))
2400        this.title = null;
2401      else {
2402        if (this.title == null)
2403          this.title = new StringType();
2404        this.title.setValue(value);
2405      }
2406      return this;
2407    }
2408
2409    /**
2410     * @return {@link #derivedFromCanonical} (The canonical URL pointing to another FHIR-defined SpecimenDefinition that is adhered to in whole or in part by this definition.)
2411     */
2412    public List<CanonicalType> getDerivedFromCanonical() { 
2413      if (this.derivedFromCanonical == null)
2414        this.derivedFromCanonical = new ArrayList<CanonicalType>();
2415      return this.derivedFromCanonical;
2416    }
2417
2418    /**
2419     * @return Returns a reference to <code>this</code> for easy method chaining
2420     */
2421    public SpecimenDefinition setDerivedFromCanonical(List<CanonicalType> theDerivedFromCanonical) { 
2422      this.derivedFromCanonical = theDerivedFromCanonical;
2423      return this;
2424    }
2425
2426    public boolean hasDerivedFromCanonical() { 
2427      if (this.derivedFromCanonical == null)
2428        return false;
2429      for (CanonicalType item : this.derivedFromCanonical)
2430        if (!item.isEmpty())
2431          return true;
2432      return false;
2433    }
2434
2435    /**
2436     * @return {@link #derivedFromCanonical} (The canonical URL pointing to another FHIR-defined SpecimenDefinition that is adhered to in whole or in part by this definition.)
2437     */
2438    public CanonicalType addDerivedFromCanonicalElement() {//2 
2439      CanonicalType t = new CanonicalType();
2440      if (this.derivedFromCanonical == null)
2441        this.derivedFromCanonical = new ArrayList<CanonicalType>();
2442      this.derivedFromCanonical.add(t);
2443      return t;
2444    }
2445
2446    /**
2447     * @param value {@link #derivedFromCanonical} (The canonical URL pointing to another FHIR-defined SpecimenDefinition that is adhered to in whole or in part by this definition.)
2448     */
2449    public SpecimenDefinition addDerivedFromCanonical(String value) { //1
2450      CanonicalType t = new CanonicalType();
2451      t.setValue(value);
2452      if (this.derivedFromCanonical == null)
2453        this.derivedFromCanonical = new ArrayList<CanonicalType>();
2454      this.derivedFromCanonical.add(t);
2455      return this;
2456    }
2457
2458    /**
2459     * @param value {@link #derivedFromCanonical} (The canonical URL pointing to another FHIR-defined SpecimenDefinition that is adhered to in whole or in part by this definition.)
2460     */
2461    public boolean hasDerivedFromCanonical(String value) { 
2462      if (this.derivedFromCanonical == null)
2463        return false;
2464      for (CanonicalType v : this.derivedFromCanonical)
2465        if (v.getValue().equals(value)) // canonical
2466          return true;
2467      return false;
2468    }
2469
2470    /**
2471     * @return {@link #derivedFromUri} (The URL pointing to an externally-defined type of specimen, guideline or other definition that is adhered to in whole or in part by this definition.)
2472     */
2473    public List<UriType> getDerivedFromUri() { 
2474      if (this.derivedFromUri == null)
2475        this.derivedFromUri = new ArrayList<UriType>();
2476      return this.derivedFromUri;
2477    }
2478
2479    /**
2480     * @return Returns a reference to <code>this</code> for easy method chaining
2481     */
2482    public SpecimenDefinition setDerivedFromUri(List<UriType> theDerivedFromUri) { 
2483      this.derivedFromUri = theDerivedFromUri;
2484      return this;
2485    }
2486
2487    public boolean hasDerivedFromUri() { 
2488      if (this.derivedFromUri == null)
2489        return false;
2490      for (UriType item : this.derivedFromUri)
2491        if (!item.isEmpty())
2492          return true;
2493      return false;
2494    }
2495
2496    /**
2497     * @return {@link #derivedFromUri} (The URL pointing to an externally-defined type of specimen, guideline or other definition that is adhered to in whole or in part by this definition.)
2498     */
2499    public UriType addDerivedFromUriElement() {//2 
2500      UriType t = new UriType();
2501      if (this.derivedFromUri == null)
2502        this.derivedFromUri = new ArrayList<UriType>();
2503      this.derivedFromUri.add(t);
2504      return t;
2505    }
2506
2507    /**
2508     * @param value {@link #derivedFromUri} (The URL pointing to an externally-defined type of specimen, guideline or other definition that is adhered to in whole or in part by this definition.)
2509     */
2510    public SpecimenDefinition addDerivedFromUri(String value) { //1
2511      UriType t = new UriType();
2512      t.setValue(value);
2513      if (this.derivedFromUri == null)
2514        this.derivedFromUri = new ArrayList<UriType>();
2515      this.derivedFromUri.add(t);
2516      return this;
2517    }
2518
2519    /**
2520     * @param value {@link #derivedFromUri} (The URL pointing to an externally-defined type of specimen, guideline or other definition that is adhered to in whole or in part by this definition.)
2521     */
2522    public boolean hasDerivedFromUri(String value) { 
2523      if (this.derivedFromUri == null)
2524        return false;
2525      for (UriType v : this.derivedFromUri)
2526        if (v.getValue().equals(value)) // uri
2527          return true;
2528      return false;
2529    }
2530
2531    /**
2532     * @return {@link #status} (The current state of theSpecimenDefinition.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
2533     */
2534    public Enumeration<PublicationStatus> getStatusElement() { 
2535      if (this.status == null)
2536        if (Configuration.errorOnAutoCreate())
2537          throw new Error("Attempt to auto-create SpecimenDefinition.status");
2538        else if (Configuration.doAutoCreate())
2539          this.status = new Enumeration<PublicationStatus>(new PublicationStatusEnumFactory()); // bb
2540      return this.status;
2541    }
2542
2543    public boolean hasStatusElement() { 
2544      return this.status != null && !this.status.isEmpty();
2545    }
2546
2547    public boolean hasStatus() { 
2548      return this.status != null && !this.status.isEmpty();
2549    }
2550
2551    /**
2552     * @param value {@link #status} (The current state of theSpecimenDefinition.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
2553     */
2554    public SpecimenDefinition setStatusElement(Enumeration<PublicationStatus> value) { 
2555      this.status = value;
2556      return this;
2557    }
2558
2559    /**
2560     * @return The current state of theSpecimenDefinition.
2561     */
2562    public PublicationStatus getStatus() { 
2563      return this.status == null ? null : this.status.getValue();
2564    }
2565
2566    /**
2567     * @param value The current state of theSpecimenDefinition.
2568     */
2569    public SpecimenDefinition setStatus(PublicationStatus value) { 
2570        if (this.status == null)
2571          this.status = new Enumeration<PublicationStatus>(new PublicationStatusEnumFactory());
2572        this.status.setValue(value);
2573      return this;
2574    }
2575
2576    /**
2577     * @return {@link #experimental} (A flag to indicate that this SpecimenDefinition is not authored for  genuine usage.). This is the underlying object with id, value and extensions. The accessor "getExperimental" gives direct access to the value
2578     */
2579    public BooleanType getExperimentalElement() { 
2580      if (this.experimental == null)
2581        if (Configuration.errorOnAutoCreate())
2582          throw new Error("Attempt to auto-create SpecimenDefinition.experimental");
2583        else if (Configuration.doAutoCreate())
2584          this.experimental = new BooleanType(); // bb
2585      return this.experimental;
2586    }
2587
2588    public boolean hasExperimentalElement() { 
2589      return this.experimental != null && !this.experimental.isEmpty();
2590    }
2591
2592    public boolean hasExperimental() { 
2593      return this.experimental != null && !this.experimental.isEmpty();
2594    }
2595
2596    /**
2597     * @param value {@link #experimental} (A flag to indicate that this SpecimenDefinition is not authored for  genuine usage.). This is the underlying object with id, value and extensions. The accessor "getExperimental" gives direct access to the value
2598     */
2599    public SpecimenDefinition setExperimentalElement(BooleanType value) { 
2600      this.experimental = value;
2601      return this;
2602    }
2603
2604    /**
2605     * @return A flag to indicate that this SpecimenDefinition is not authored for  genuine usage.
2606     */
2607    public boolean getExperimental() { 
2608      return this.experimental == null || this.experimental.isEmpty() ? false : this.experimental.getValue();
2609    }
2610
2611    /**
2612     * @param value A flag to indicate that this SpecimenDefinition is not authored for  genuine usage.
2613     */
2614    public SpecimenDefinition setExperimental(boolean value) { 
2615        if (this.experimental == null)
2616          this.experimental = new BooleanType();
2617        this.experimental.setValue(value);
2618      return this;
2619    }
2620
2621    /**
2622     * @return {@link #subject} (A code or group definition that describes the intended subject  from which this kind of specimen is to be collected.)
2623     */
2624    public DataType getSubject() { 
2625      return this.subject;
2626    }
2627
2628    /**
2629     * @return {@link #subject} (A code or group definition that describes the intended subject  from which this kind of specimen is to be collected.)
2630     */
2631    public CodeableConcept getSubjectCodeableConcept() throws FHIRException { 
2632      if (this.subject == null)
2633        this.subject = new CodeableConcept();
2634      if (!(this.subject instanceof CodeableConcept))
2635        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.subject.getClass().getName()+" was encountered");
2636      return (CodeableConcept) this.subject;
2637    }
2638
2639    public boolean hasSubjectCodeableConcept() { 
2640      return this != null && this.subject instanceof CodeableConcept;
2641    }
2642
2643    /**
2644     * @return {@link #subject} (A code or group definition that describes the intended subject  from which this kind of specimen is to be collected.)
2645     */
2646    public Reference getSubjectReference() throws FHIRException { 
2647      if (this.subject == null)
2648        this.subject = new Reference();
2649      if (!(this.subject instanceof Reference))
2650        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.subject.getClass().getName()+" was encountered");
2651      return (Reference) this.subject;
2652    }
2653
2654    public boolean hasSubjectReference() { 
2655      return this != null && this.subject instanceof Reference;
2656    }
2657
2658    public boolean hasSubject() { 
2659      return this.subject != null && !this.subject.isEmpty();
2660    }
2661
2662    /**
2663     * @param value {@link #subject} (A code or group definition that describes the intended subject  from which this kind of specimen is to be collected.)
2664     */
2665    public SpecimenDefinition setSubject(DataType value) { 
2666      if (value != null && !(value instanceof CodeableConcept || value instanceof Reference))
2667        throw new Error("Not the right type for SpecimenDefinition.subject[x]: "+value.fhirType());
2668      this.subject = value;
2669      return this;
2670    }
2671
2672    /**
2673     * @return {@link #date} (For draft definitions, indicates the date of initial creation. For active definitions, represents the date of activation. For withdrawn definitions, indicates the date of withdrawal.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
2674     */
2675    public DateTimeType getDateElement() { 
2676      if (this.date == null)
2677        if (Configuration.errorOnAutoCreate())
2678          throw new Error("Attempt to auto-create SpecimenDefinition.date");
2679        else if (Configuration.doAutoCreate())
2680          this.date = new DateTimeType(); // bb
2681      return this.date;
2682    }
2683
2684    public boolean hasDateElement() { 
2685      return this.date != null && !this.date.isEmpty();
2686    }
2687
2688    public boolean hasDate() { 
2689      return this.date != null && !this.date.isEmpty();
2690    }
2691
2692    /**
2693     * @param value {@link #date} (For draft definitions, indicates the date of initial creation. For active definitions, represents the date of activation. For withdrawn definitions, indicates the date of withdrawal.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
2694     */
2695    public SpecimenDefinition setDateElement(DateTimeType value) { 
2696      this.date = value;
2697      return this;
2698    }
2699
2700    /**
2701     * @return For draft definitions, indicates the date of initial creation. For active definitions, represents the date of activation. For withdrawn definitions, indicates the date of withdrawal.
2702     */
2703    public Date getDate() { 
2704      return this.date == null ? null : this.date.getValue();
2705    }
2706
2707    /**
2708     * @param value For draft definitions, indicates the date of initial creation. For active definitions, represents the date of activation. For withdrawn definitions, indicates the date of withdrawal.
2709     */
2710    public SpecimenDefinition setDate(Date value) { 
2711      if (value == null)
2712        this.date = null;
2713      else {
2714        if (this.date == null)
2715          this.date = new DateTimeType();
2716        this.date.setValue(value);
2717      }
2718      return this;
2719    }
2720
2721    /**
2722     * @return {@link #publisher} (Helps establish the "authority/credibility" of the SpecimenDefinition. May also allow for contact.)
2723     */
2724    public Reference getPublisher() { 
2725      if (this.publisher == null)
2726        if (Configuration.errorOnAutoCreate())
2727          throw new Error("Attempt to auto-create SpecimenDefinition.publisher");
2728        else if (Configuration.doAutoCreate())
2729          this.publisher = new Reference(); // cc
2730      return this.publisher;
2731    }
2732
2733    public boolean hasPublisher() { 
2734      return this.publisher != null && !this.publisher.isEmpty();
2735    }
2736
2737    /**
2738     * @param value {@link #publisher} (Helps establish the "authority/credibility" of the SpecimenDefinition. May also allow for contact.)
2739     */
2740    public SpecimenDefinition setPublisher(Reference value) { 
2741      this.publisher = value;
2742      return this;
2743    }
2744
2745    /**
2746     * @return {@link #contact} (Contact details to assist a user in finding and communicating with the publisher.)
2747     */
2748    public List<ContactDetail> getContact() { 
2749      if (this.contact == null)
2750        this.contact = new ArrayList<ContactDetail>();
2751      return this.contact;
2752    }
2753
2754    /**
2755     * @return Returns a reference to <code>this</code> for easy method chaining
2756     */
2757    public SpecimenDefinition setContact(List<ContactDetail> theContact) { 
2758      this.contact = theContact;
2759      return this;
2760    }
2761
2762    public boolean hasContact() { 
2763      if (this.contact == null)
2764        return false;
2765      for (ContactDetail item : this.contact)
2766        if (!item.isEmpty())
2767          return true;
2768      return false;
2769    }
2770
2771    public ContactDetail addContact() { //3
2772      ContactDetail t = new ContactDetail();
2773      if (this.contact == null)
2774        this.contact = new ArrayList<ContactDetail>();
2775      this.contact.add(t);
2776      return t;
2777    }
2778
2779    public SpecimenDefinition addContact(ContactDetail t) { //3
2780      if (t == null)
2781        return this;
2782      if (this.contact == null)
2783        this.contact = new ArrayList<ContactDetail>();
2784      this.contact.add(t);
2785      return this;
2786    }
2787
2788    /**
2789     * @return The first repetition of repeating field {@link #contact}, creating it if it does not already exist {3}
2790     */
2791    public ContactDetail getContactFirstRep() { 
2792      if (getContact().isEmpty()) {
2793        addContact();
2794      }
2795      return getContact().get(0);
2796    }
2797
2798    /**
2799     * @return {@link #description} (A free text natural language description of the SpecimenDefinition from the consumer's perspective.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
2800     */
2801    public MarkdownType getDescriptionElement() { 
2802      if (this.description == null)
2803        if (Configuration.errorOnAutoCreate())
2804          throw new Error("Attempt to auto-create SpecimenDefinition.description");
2805        else if (Configuration.doAutoCreate())
2806          this.description = new MarkdownType(); // bb
2807      return this.description;
2808    }
2809
2810    public boolean hasDescriptionElement() { 
2811      return this.description != null && !this.description.isEmpty();
2812    }
2813
2814    public boolean hasDescription() { 
2815      return this.description != null && !this.description.isEmpty();
2816    }
2817
2818    /**
2819     * @param value {@link #description} (A free text natural language description of the SpecimenDefinition from the consumer's perspective.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
2820     */
2821    public SpecimenDefinition setDescriptionElement(MarkdownType value) { 
2822      this.description = value;
2823      return this;
2824    }
2825
2826    /**
2827     * @return A free text natural language description of the SpecimenDefinition from the consumer's perspective.
2828     */
2829    public String getDescription() { 
2830      return this.description == null ? null : this.description.getValue();
2831    }
2832
2833    /**
2834     * @param value A free text natural language description of the SpecimenDefinition from the consumer's perspective.
2835     */
2836    public SpecimenDefinition setDescription(String value) { 
2837      if (value == null)
2838        this.description = null;
2839      else {
2840        if (this.description == null)
2841          this.description = new MarkdownType();
2842        this.description.setValue(value);
2843      }
2844      return this;
2845    }
2846
2847    /**
2848     * @return {@link #useContext} (The content was developed with a focus and intent of supporting the contexts that are listed. These terms may be used to assist with indexing and searching of specimen definitions.)
2849     */
2850    public List<UsageContext> getUseContext() { 
2851      if (this.useContext == null)
2852        this.useContext = new ArrayList<UsageContext>();
2853      return this.useContext;
2854    }
2855
2856    /**
2857     * @return Returns a reference to <code>this</code> for easy method chaining
2858     */
2859    public SpecimenDefinition setUseContext(List<UsageContext> theUseContext) { 
2860      this.useContext = theUseContext;
2861      return this;
2862    }
2863
2864    public boolean hasUseContext() { 
2865      if (this.useContext == null)
2866        return false;
2867      for (UsageContext item : this.useContext)
2868        if (!item.isEmpty())
2869          return true;
2870      return false;
2871    }
2872
2873    public UsageContext addUseContext() { //3
2874      UsageContext t = new UsageContext();
2875      if (this.useContext == null)
2876        this.useContext = new ArrayList<UsageContext>();
2877      this.useContext.add(t);
2878      return t;
2879    }
2880
2881    public SpecimenDefinition addUseContext(UsageContext t) { //3
2882      if (t == null)
2883        return this;
2884      if (this.useContext == null)
2885        this.useContext = new ArrayList<UsageContext>();
2886      this.useContext.add(t);
2887      return this;
2888    }
2889
2890    /**
2891     * @return The first repetition of repeating field {@link #useContext}, creating it if it does not already exist {3}
2892     */
2893    public UsageContext getUseContextFirstRep() { 
2894      if (getUseContext().isEmpty()) {
2895        addUseContext();
2896      }
2897      return getUseContext().get(0);
2898    }
2899
2900    /**
2901     * @return {@link #jurisdiction} (A jurisdiction in which the SpecimenDefinition is intended to be used.)
2902     */
2903    public List<CodeableConcept> getJurisdiction() { 
2904      if (this.jurisdiction == null)
2905        this.jurisdiction = new ArrayList<CodeableConcept>();
2906      return this.jurisdiction;
2907    }
2908
2909    /**
2910     * @return Returns a reference to <code>this</code> for easy method chaining
2911     */
2912    public SpecimenDefinition setJurisdiction(List<CodeableConcept> theJurisdiction) { 
2913      this.jurisdiction = theJurisdiction;
2914      return this;
2915    }
2916
2917    public boolean hasJurisdiction() { 
2918      if (this.jurisdiction == null)
2919        return false;
2920      for (CodeableConcept item : this.jurisdiction)
2921        if (!item.isEmpty())
2922          return true;
2923      return false;
2924    }
2925
2926    public CodeableConcept addJurisdiction() { //3
2927      CodeableConcept t = new CodeableConcept();
2928      if (this.jurisdiction == null)
2929        this.jurisdiction = new ArrayList<CodeableConcept>();
2930      this.jurisdiction.add(t);
2931      return t;
2932    }
2933
2934    public SpecimenDefinition addJurisdiction(CodeableConcept t) { //3
2935      if (t == null)
2936        return this;
2937      if (this.jurisdiction == null)
2938        this.jurisdiction = new ArrayList<CodeableConcept>();
2939      this.jurisdiction.add(t);
2940      return this;
2941    }
2942
2943    /**
2944     * @return The first repetition of repeating field {@link #jurisdiction}, creating it if it does not already exist {3}
2945     */
2946    public CodeableConcept getJurisdictionFirstRep() { 
2947      if (getJurisdiction().isEmpty()) {
2948        addJurisdiction();
2949      }
2950      return getJurisdiction().get(0);
2951    }
2952
2953    /**
2954     * @return {@link #purpose} (Explains why this SpecimeDefinition is needed and why it has been designed as it has.). This is the underlying object with id, value and extensions. The accessor "getPurpose" gives direct access to the value
2955     */
2956    public MarkdownType getPurposeElement() { 
2957      if (this.purpose == null)
2958        if (Configuration.errorOnAutoCreate())
2959          throw new Error("Attempt to auto-create SpecimenDefinition.purpose");
2960        else if (Configuration.doAutoCreate())
2961          this.purpose = new MarkdownType(); // bb
2962      return this.purpose;
2963    }
2964
2965    public boolean hasPurposeElement() { 
2966      return this.purpose != null && !this.purpose.isEmpty();
2967    }
2968
2969    public boolean hasPurpose() { 
2970      return this.purpose != null && !this.purpose.isEmpty();
2971    }
2972
2973    /**
2974     * @param value {@link #purpose} (Explains why this SpecimeDefinition is needed and why it has been designed as it has.). This is the underlying object with id, value and extensions. The accessor "getPurpose" gives direct access to the value
2975     */
2976    public SpecimenDefinition setPurposeElement(MarkdownType value) { 
2977      this.purpose = value;
2978      return this;
2979    }
2980
2981    /**
2982     * @return Explains why this SpecimeDefinition is needed and why it has been designed as it has.
2983     */
2984    public String getPurpose() { 
2985      return this.purpose == null ? null : this.purpose.getValue();
2986    }
2987
2988    /**
2989     * @param value Explains why this SpecimeDefinition is needed and why it has been designed as it has.
2990     */
2991    public SpecimenDefinition setPurpose(String value) { 
2992      if (value == null)
2993        this.purpose = null;
2994      else {
2995        if (this.purpose == null)
2996          this.purpose = new MarkdownType();
2997        this.purpose.setValue(value);
2998      }
2999      return this;
3000    }
3001
3002    /**
3003     * @return {@link #copyright} (Copyright statement relating to the SpecimenDefinition and/or its contents. Copyright statements are generally legal restrictions on the use and publishing of the SpecimenDefinition.). This is the underlying object with id, value and extensions. The accessor "getCopyright" gives direct access to the value
3004     */
3005    public MarkdownType getCopyrightElement() { 
3006      if (this.copyright == null)
3007        if (Configuration.errorOnAutoCreate())
3008          throw new Error("Attempt to auto-create SpecimenDefinition.copyright");
3009        else if (Configuration.doAutoCreate())
3010          this.copyright = new MarkdownType(); // bb
3011      return this.copyright;
3012    }
3013
3014    public boolean hasCopyrightElement() { 
3015      return this.copyright != null && !this.copyright.isEmpty();
3016    }
3017
3018    public boolean hasCopyright() { 
3019      return this.copyright != null && !this.copyright.isEmpty();
3020    }
3021
3022    /**
3023     * @param value {@link #copyright} (Copyright statement relating to the SpecimenDefinition and/or its contents. Copyright statements are generally legal restrictions on the use and publishing of the SpecimenDefinition.). This is the underlying object with id, value and extensions. The accessor "getCopyright" gives direct access to the value
3024     */
3025    public SpecimenDefinition setCopyrightElement(MarkdownType value) { 
3026      this.copyright = value;
3027      return this;
3028    }
3029
3030    /**
3031     * @return Copyright statement relating to the SpecimenDefinition and/or its contents. Copyright statements are generally legal restrictions on the use and publishing of the SpecimenDefinition.
3032     */
3033    public String getCopyright() { 
3034      return this.copyright == null ? null : this.copyright.getValue();
3035    }
3036
3037    /**
3038     * @param value Copyright statement relating to the SpecimenDefinition and/or its contents. Copyright statements are generally legal restrictions on the use and publishing of the SpecimenDefinition.
3039     */
3040    public SpecimenDefinition setCopyright(String value) { 
3041      if (value == null)
3042        this.copyright = null;
3043      else {
3044        if (this.copyright == null)
3045          this.copyright = new MarkdownType();
3046        this.copyright.setValue(value);
3047      }
3048      return this;
3049    }
3050
3051    /**
3052     * @return {@link #approvalDate} (The date on which the asset content was approved by the publisher. Approval happens once when the content is officially approved for usage.). This is the underlying object with id, value and extensions. The accessor "getApprovalDate" gives direct access to the value
3053     */
3054    public DateType getApprovalDateElement() { 
3055      if (this.approvalDate == null)
3056        if (Configuration.errorOnAutoCreate())
3057          throw new Error("Attempt to auto-create SpecimenDefinition.approvalDate");
3058        else if (Configuration.doAutoCreate())
3059          this.approvalDate = new DateType(); // bb
3060      return this.approvalDate;
3061    }
3062
3063    public boolean hasApprovalDateElement() { 
3064      return this.approvalDate != null && !this.approvalDate.isEmpty();
3065    }
3066
3067    public boolean hasApprovalDate() { 
3068      return this.approvalDate != null && !this.approvalDate.isEmpty();
3069    }
3070
3071    /**
3072     * @param value {@link #approvalDate} (The date on which the asset content was approved by the publisher. Approval happens once when the content is officially approved for usage.). This is the underlying object with id, value and extensions. The accessor "getApprovalDate" gives direct access to the value
3073     */
3074    public SpecimenDefinition setApprovalDateElement(DateType value) { 
3075      this.approvalDate = value;
3076      return this;
3077    }
3078
3079    /**
3080     * @return The date on which the asset content was approved by the publisher. Approval happens once when the content is officially approved for usage.
3081     */
3082    public Date getApprovalDate() { 
3083      return this.approvalDate == null ? null : this.approvalDate.getValue();
3084    }
3085
3086    /**
3087     * @param value The date on which the asset content was approved by the publisher. Approval happens once when the content is officially approved for usage.
3088     */
3089    public SpecimenDefinition setApprovalDate(Date value) { 
3090      if (value == null)
3091        this.approvalDate = null;
3092      else {
3093        if (this.approvalDate == null)
3094          this.approvalDate = new DateType();
3095        this.approvalDate.setValue(value);
3096      }
3097      return this;
3098    }
3099
3100    /**
3101     * @return {@link #lastReviewDate} (The date on which the asset content was last reviewed. Review happens periodically after that, but doesn't change the original approval date.). This is the underlying object with id, value and extensions. The accessor "getLastReviewDate" gives direct access to the value
3102     */
3103    public DateType getLastReviewDateElement() { 
3104      if (this.lastReviewDate == null)
3105        if (Configuration.errorOnAutoCreate())
3106          throw new Error("Attempt to auto-create SpecimenDefinition.lastReviewDate");
3107        else if (Configuration.doAutoCreate())
3108          this.lastReviewDate = new DateType(); // bb
3109      return this.lastReviewDate;
3110    }
3111
3112    public boolean hasLastReviewDateElement() { 
3113      return this.lastReviewDate != null && !this.lastReviewDate.isEmpty();
3114    }
3115
3116    public boolean hasLastReviewDate() { 
3117      return this.lastReviewDate != null && !this.lastReviewDate.isEmpty();
3118    }
3119
3120    /**
3121     * @param value {@link #lastReviewDate} (The date on which the asset content was last reviewed. Review happens periodically after that, but doesn't change the original approval date.). This is the underlying object with id, value and extensions. The accessor "getLastReviewDate" gives direct access to the value
3122     */
3123    public SpecimenDefinition setLastReviewDateElement(DateType value) { 
3124      this.lastReviewDate = value;
3125      return this;
3126    }
3127
3128    /**
3129     * @return The date on which the asset content was last reviewed. Review happens periodically after that, but doesn't change the original approval date.
3130     */
3131    public Date getLastReviewDate() { 
3132      return this.lastReviewDate == null ? null : this.lastReviewDate.getValue();
3133    }
3134
3135    /**
3136     * @param value The date on which the asset content was last reviewed. Review happens periodically after that, but doesn't change the original approval date.
3137     */
3138    public SpecimenDefinition setLastReviewDate(Date value) { 
3139      if (value == null)
3140        this.lastReviewDate = null;
3141      else {
3142        if (this.lastReviewDate == null)
3143          this.lastReviewDate = new DateType();
3144        this.lastReviewDate.setValue(value);
3145      }
3146      return this;
3147    }
3148
3149    /**
3150     * @return {@link #effectivePeriod} (The period during which the SpecimenDefinition content was or is planned to be effective.)
3151     */
3152    public Period getEffectivePeriod() { 
3153      if (this.effectivePeriod == null)
3154        if (Configuration.errorOnAutoCreate())
3155          throw new Error("Attempt to auto-create SpecimenDefinition.effectivePeriod");
3156        else if (Configuration.doAutoCreate())
3157          this.effectivePeriod = new Period(); // cc
3158      return this.effectivePeriod;
3159    }
3160
3161    public boolean hasEffectivePeriod() { 
3162      return this.effectivePeriod != null && !this.effectivePeriod.isEmpty();
3163    }
3164
3165    /**
3166     * @param value {@link #effectivePeriod} (The period during which the SpecimenDefinition content was or is planned to be effective.)
3167     */
3168    public SpecimenDefinition setEffectivePeriod(Period value) { 
3169      this.effectivePeriod = value;
3170      return this;
3171    }
3172
3173    /**
3174     * @return {@link #typeCollected} (The kind of material to be collected.)
3175     */
3176    public CodeableConcept getTypeCollected() { 
3177      if (this.typeCollected == null)
3178        if (Configuration.errorOnAutoCreate())
3179          throw new Error("Attempt to auto-create SpecimenDefinition.typeCollected");
3180        else if (Configuration.doAutoCreate())
3181          this.typeCollected = new CodeableConcept(); // cc
3182      return this.typeCollected;
3183    }
3184
3185    public boolean hasTypeCollected() { 
3186      return this.typeCollected != null && !this.typeCollected.isEmpty();
3187    }
3188
3189    /**
3190     * @param value {@link #typeCollected} (The kind of material to be collected.)
3191     */
3192    public SpecimenDefinition setTypeCollected(CodeableConcept value) { 
3193      this.typeCollected = value;
3194      return this;
3195    }
3196
3197    /**
3198     * @return {@link #patientPreparation} (Preparation of the patient for specimen collection.)
3199     */
3200    public List<CodeableConcept> getPatientPreparation() { 
3201      if (this.patientPreparation == null)
3202        this.patientPreparation = new ArrayList<CodeableConcept>();
3203      return this.patientPreparation;
3204    }
3205
3206    /**
3207     * @return Returns a reference to <code>this</code> for easy method chaining
3208     */
3209    public SpecimenDefinition setPatientPreparation(List<CodeableConcept> thePatientPreparation) { 
3210      this.patientPreparation = thePatientPreparation;
3211      return this;
3212    }
3213
3214    public boolean hasPatientPreparation() { 
3215      if (this.patientPreparation == null)
3216        return false;
3217      for (CodeableConcept item : this.patientPreparation)
3218        if (!item.isEmpty())
3219          return true;
3220      return false;
3221    }
3222
3223    public CodeableConcept addPatientPreparation() { //3
3224      CodeableConcept t = new CodeableConcept();
3225      if (this.patientPreparation == null)
3226        this.patientPreparation = new ArrayList<CodeableConcept>();
3227      this.patientPreparation.add(t);
3228      return t;
3229    }
3230
3231    public SpecimenDefinition addPatientPreparation(CodeableConcept t) { //3
3232      if (t == null)
3233        return this;
3234      if (this.patientPreparation == null)
3235        this.patientPreparation = new ArrayList<CodeableConcept>();
3236      this.patientPreparation.add(t);
3237      return this;
3238    }
3239
3240    /**
3241     * @return The first repetition of repeating field {@link #patientPreparation}, creating it if it does not already exist {3}
3242     */
3243    public CodeableConcept getPatientPreparationFirstRep() { 
3244      if (getPatientPreparation().isEmpty()) {
3245        addPatientPreparation();
3246      }
3247      return getPatientPreparation().get(0);
3248    }
3249
3250    /**
3251     * @return {@link #timeAspect} (Time aspect of specimen collection (duration or offset).). This is the underlying object with id, value and extensions. The accessor "getTimeAspect" gives direct access to the value
3252     */
3253    public StringType getTimeAspectElement() { 
3254      if (this.timeAspect == null)
3255        if (Configuration.errorOnAutoCreate())
3256          throw new Error("Attempt to auto-create SpecimenDefinition.timeAspect");
3257        else if (Configuration.doAutoCreate())
3258          this.timeAspect = new StringType(); // bb
3259      return this.timeAspect;
3260    }
3261
3262    public boolean hasTimeAspectElement() { 
3263      return this.timeAspect != null && !this.timeAspect.isEmpty();
3264    }
3265
3266    public boolean hasTimeAspect() { 
3267      return this.timeAspect != null && !this.timeAspect.isEmpty();
3268    }
3269
3270    /**
3271     * @param value {@link #timeAspect} (Time aspect of specimen collection (duration or offset).). This is the underlying object with id, value and extensions. The accessor "getTimeAspect" gives direct access to the value
3272     */
3273    public SpecimenDefinition setTimeAspectElement(StringType value) { 
3274      this.timeAspect = value;
3275      return this;
3276    }
3277
3278    /**
3279     * @return Time aspect of specimen collection (duration or offset).
3280     */
3281    public String getTimeAspect() { 
3282      return this.timeAspect == null ? null : this.timeAspect.getValue();
3283    }
3284
3285    /**
3286     * @param value Time aspect of specimen collection (duration or offset).
3287     */
3288    public SpecimenDefinition setTimeAspect(String value) { 
3289      if (Utilities.noString(value))
3290        this.timeAspect = null;
3291      else {
3292        if (this.timeAspect == null)
3293          this.timeAspect = new StringType();
3294        this.timeAspect.setValue(value);
3295      }
3296      return this;
3297    }
3298
3299    /**
3300     * @return {@link #collection} (The action to be performed for collecting the specimen.)
3301     */
3302    public List<CodeableConcept> getCollection() { 
3303      if (this.collection == null)
3304        this.collection = new ArrayList<CodeableConcept>();
3305      return this.collection;
3306    }
3307
3308    /**
3309     * @return Returns a reference to <code>this</code> for easy method chaining
3310     */
3311    public SpecimenDefinition setCollection(List<CodeableConcept> theCollection) { 
3312      this.collection = theCollection;
3313      return this;
3314    }
3315
3316    public boolean hasCollection() { 
3317      if (this.collection == null)
3318        return false;
3319      for (CodeableConcept item : this.collection)
3320        if (!item.isEmpty())
3321          return true;
3322      return false;
3323    }
3324
3325    public CodeableConcept addCollection() { //3
3326      CodeableConcept t = new CodeableConcept();
3327      if (this.collection == null)
3328        this.collection = new ArrayList<CodeableConcept>();
3329      this.collection.add(t);
3330      return t;
3331    }
3332
3333    public SpecimenDefinition addCollection(CodeableConcept t) { //3
3334      if (t == null)
3335        return this;
3336      if (this.collection == null)
3337        this.collection = new ArrayList<CodeableConcept>();
3338      this.collection.add(t);
3339      return this;
3340    }
3341
3342    /**
3343     * @return The first repetition of repeating field {@link #collection}, creating it if it does not already exist {3}
3344     */
3345    public CodeableConcept getCollectionFirstRep() { 
3346      if (getCollection().isEmpty()) {
3347        addCollection();
3348      }
3349      return getCollection().get(0);
3350    }
3351
3352    /**
3353     * @return {@link #typeTested} (Specimen conditioned in a container as expected by the testing laboratory.)
3354     */
3355    public List<SpecimenDefinitionTypeTestedComponent> getTypeTested() { 
3356      if (this.typeTested == null)
3357        this.typeTested = new ArrayList<SpecimenDefinitionTypeTestedComponent>();
3358      return this.typeTested;
3359    }
3360
3361    /**
3362     * @return Returns a reference to <code>this</code> for easy method chaining
3363     */
3364    public SpecimenDefinition setTypeTested(List<SpecimenDefinitionTypeTestedComponent> theTypeTested) { 
3365      this.typeTested = theTypeTested;
3366      return this;
3367    }
3368
3369    public boolean hasTypeTested() { 
3370      if (this.typeTested == null)
3371        return false;
3372      for (SpecimenDefinitionTypeTestedComponent item : this.typeTested)
3373        if (!item.isEmpty())
3374          return true;
3375      return false;
3376    }
3377
3378    public SpecimenDefinitionTypeTestedComponent addTypeTested() { //3
3379      SpecimenDefinitionTypeTestedComponent t = new SpecimenDefinitionTypeTestedComponent();
3380      if (this.typeTested == null)
3381        this.typeTested = new ArrayList<SpecimenDefinitionTypeTestedComponent>();
3382      this.typeTested.add(t);
3383      return t;
3384    }
3385
3386    public SpecimenDefinition addTypeTested(SpecimenDefinitionTypeTestedComponent t) { //3
3387      if (t == null)
3388        return this;
3389      if (this.typeTested == null)
3390        this.typeTested = new ArrayList<SpecimenDefinitionTypeTestedComponent>();
3391      this.typeTested.add(t);
3392      return this;
3393    }
3394
3395    /**
3396     * @return The first repetition of repeating field {@link #typeTested}, creating it if it does not already exist {3}
3397     */
3398    public SpecimenDefinitionTypeTestedComponent getTypeTestedFirstRep() { 
3399      if (getTypeTested().isEmpty()) {
3400        addTypeTested();
3401      }
3402      return getTypeTested().get(0);
3403    }
3404
3405      protected void listChildren(List<Property> children) {
3406        super.listChildren(children);
3407        children.add(new Property("url", "uri", "An absolute URL that is used to identify this SpecimenDefinition when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this SpecimenDefinition is (or will be) published. The URL SHOULD include the major version of the SpecimenDefinition. For more information see Technical and Business Versions.", 0, 1, url));
3408        children.add(new Property("identifier", "Identifier", "A business identifier assigned to this SpecimenDefinition.", 0, 1, identifier));
3409        children.add(new Property("version", "string", "The identifier that is used to identify this version of the SpecimenDefinition when it is referenced in a specification, model, design or instance. This is an arbitrary value managed by the SpecimenDefinition author and is not expected to be globally unique.", 0, 1, version));
3410        children.add(new Property("title", "string", "A short, descriptive, user-friendly title for the SpecimenDefinition.", 0, 1, title));
3411        children.add(new Property("derivedFromCanonical", "canonical(SpecimenDefinition)", "The canonical URL pointing to another FHIR-defined SpecimenDefinition that is adhered to in whole or in part by this definition.", 0, java.lang.Integer.MAX_VALUE, derivedFromCanonical));
3412        children.add(new Property("derivedFromUri", "uri", "The URL pointing to an externally-defined type of specimen, guideline or other definition that is adhered to in whole or in part by this definition.", 0, java.lang.Integer.MAX_VALUE, derivedFromUri));
3413        children.add(new Property("status", "code", "The current state of theSpecimenDefinition.", 0, 1, status));
3414        children.add(new Property("experimental", "boolean", "A flag to indicate that this SpecimenDefinition is not authored for  genuine usage.", 0, 1, experimental));
3415        children.add(new Property("subject[x]", "CodeableConcept|Reference(Group)", "A code or group definition that describes the intended subject  from which this kind of specimen is to be collected.", 0, 1, subject));
3416        children.add(new Property("date", "dateTime", "For draft definitions, indicates the date of initial creation. For active definitions, represents the date of activation. For withdrawn definitions, indicates the date of withdrawal.", 0, 1, date));
3417        children.add(new Property("publisher", "Reference(Practitioner|PractitionerRole|Organization)", "Helps establish the \"authority/credibility\" of the SpecimenDefinition. May also allow for contact.", 0, 1, publisher));
3418        children.add(new Property("contact", "ContactDetail", "Contact details to assist a user in finding and communicating with the publisher.", 0, java.lang.Integer.MAX_VALUE, contact));
3419        children.add(new Property("description", "markdown", "A free text natural language description of the SpecimenDefinition from the consumer's perspective.", 0, 1, description));
3420        children.add(new Property("useContext", "UsageContext", "The content was developed with a focus and intent of supporting the contexts that are listed. These terms may be used to assist with indexing and searching of specimen definitions.", 0, java.lang.Integer.MAX_VALUE, useContext));
3421        children.add(new Property("jurisdiction", "CodeableConcept", "A jurisdiction in which the SpecimenDefinition is intended to be used.", 0, java.lang.Integer.MAX_VALUE, jurisdiction));
3422        children.add(new Property("purpose", "markdown", "Explains why this SpecimeDefinition is needed and why it has been designed as it has.", 0, 1, purpose));
3423        children.add(new Property("copyright", "markdown", "Copyright statement relating to the SpecimenDefinition and/or its contents. Copyright statements are generally legal restrictions on the use and publishing of the SpecimenDefinition.", 0, 1, copyright));
3424        children.add(new Property("approvalDate", "date", "The date on which the asset content was approved by the publisher. Approval happens once when the content is officially approved for usage.", 0, 1, approvalDate));
3425        children.add(new Property("lastReviewDate", "date", "The date on which the asset content was last reviewed. Review happens periodically after that, but doesn't change the original approval date.", 0, 1, lastReviewDate));
3426        children.add(new Property("effectivePeriod", "Period", "The period during which the SpecimenDefinition content was or is planned to be effective.", 0, 1, effectivePeriod));
3427        children.add(new Property("typeCollected", "CodeableConcept", "The kind of material to be collected.", 0, 1, typeCollected));
3428        children.add(new Property("patientPreparation", "CodeableConcept", "Preparation of the patient for specimen collection.", 0, java.lang.Integer.MAX_VALUE, patientPreparation));
3429        children.add(new Property("timeAspect", "string", "Time aspect of specimen collection (duration or offset).", 0, 1, timeAspect));
3430        children.add(new Property("collection", "CodeableConcept", "The action to be performed for collecting the specimen.", 0, java.lang.Integer.MAX_VALUE, collection));
3431        children.add(new Property("typeTested", "", "Specimen conditioned in a container as expected by the testing laboratory.", 0, java.lang.Integer.MAX_VALUE, typeTested));
3432      }
3433
3434      @Override
3435      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
3436        switch (_hash) {
3437        case 116079: /*url*/  return new Property("url", "uri", "An absolute URL that is used to identify this SpecimenDefinition when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this SpecimenDefinition is (or will be) published. The URL SHOULD include the major version of the SpecimenDefinition. For more information see Technical and Business Versions.", 0, 1, url);
3438        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "A business identifier assigned to this SpecimenDefinition.", 0, 1, identifier);
3439        case 351608024: /*version*/  return new Property("version", "string", "The identifier that is used to identify this version of the SpecimenDefinition when it is referenced in a specification, model, design or instance. This is an arbitrary value managed by the SpecimenDefinition author and is not expected to be globally unique.", 0, 1, version);
3440        case 110371416: /*title*/  return new Property("title", "string", "A short, descriptive, user-friendly title for the SpecimenDefinition.", 0, 1, title);
3441        case -978133683: /*derivedFromCanonical*/  return new Property("derivedFromCanonical", "canonical(SpecimenDefinition)", "The canonical URL pointing to another FHIR-defined SpecimenDefinition that is adhered to in whole or in part by this definition.", 0, java.lang.Integer.MAX_VALUE, derivedFromCanonical);
3442        case -1076333435: /*derivedFromUri*/  return new Property("derivedFromUri", "uri", "The URL pointing to an externally-defined type of specimen, guideline or other definition that is adhered to in whole or in part by this definition.", 0, java.lang.Integer.MAX_VALUE, derivedFromUri);
3443        case -892481550: /*status*/  return new Property("status", "code", "The current state of theSpecimenDefinition.", 0, 1, status);
3444        case -404562712: /*experimental*/  return new Property("experimental", "boolean", "A flag to indicate that this SpecimenDefinition is not authored for  genuine usage.", 0, 1, experimental);
3445        case -573640748: /*subject[x]*/  return new Property("subject[x]", "CodeableConcept|Reference(Group)", "A code or group definition that describes the intended subject  from which this kind of specimen is to be collected.", 0, 1, subject);
3446        case -1867885268: /*subject*/  return new Property("subject[x]", "CodeableConcept|Reference(Group)", "A code or group definition that describes the intended subject  from which this kind of specimen is to be collected.", 0, 1, subject);
3447        case -1257122603: /*subjectCodeableConcept*/  return new Property("subject[x]", "CodeableConcept", "A code or group definition that describes the intended subject  from which this kind of specimen is to be collected.", 0, 1, subject);
3448        case 772938623: /*subjectReference*/  return new Property("subject[x]", "Reference(Group)", "A code or group definition that describes the intended subject  from which this kind of specimen is to be collected.", 0, 1, subject);
3449        case 3076014: /*date*/  return new Property("date", "dateTime", "For draft definitions, indicates the date of initial creation. For active definitions, represents the date of activation. For withdrawn definitions, indicates the date of withdrawal.", 0, 1, date);
3450        case 1447404028: /*publisher*/  return new Property("publisher", "Reference(Practitioner|PractitionerRole|Organization)", "Helps establish the \"authority/credibility\" of the SpecimenDefinition. May also allow for contact.", 0, 1, publisher);
3451        case 951526432: /*contact*/  return new Property("contact", "ContactDetail", "Contact details to assist a user in finding and communicating with the publisher.", 0, java.lang.Integer.MAX_VALUE, contact);
3452        case -1724546052: /*description*/  return new Property("description", "markdown", "A free text natural language description of the SpecimenDefinition from the consumer's perspective.", 0, 1, description);
3453        case -669707736: /*useContext*/  return new Property("useContext", "UsageContext", "The content was developed with a focus and intent of supporting the contexts that are listed. These terms may be used to assist with indexing and searching of specimen definitions.", 0, java.lang.Integer.MAX_VALUE, useContext);
3454        case -507075711: /*jurisdiction*/  return new Property("jurisdiction", "CodeableConcept", "A jurisdiction in which the SpecimenDefinition is intended to be used.", 0, java.lang.Integer.MAX_VALUE, jurisdiction);
3455        case -220463842: /*purpose*/  return new Property("purpose", "markdown", "Explains why this SpecimeDefinition is needed and why it has been designed as it has.", 0, 1, purpose);
3456        case 1522889671: /*copyright*/  return new Property("copyright", "markdown", "Copyright statement relating to the SpecimenDefinition and/or its contents. Copyright statements are generally legal restrictions on the use and publishing of the SpecimenDefinition.", 0, 1, copyright);
3457        case 223539345: /*approvalDate*/  return new Property("approvalDate", "date", "The date on which the asset content was approved by the publisher. Approval happens once when the content is officially approved for usage.", 0, 1, approvalDate);
3458        case -1687512484: /*lastReviewDate*/  return new Property("lastReviewDate", "date", "The date on which the asset content was last reviewed. Review happens periodically after that, but doesn't change the original approval date.", 0, 1, lastReviewDate);
3459        case -403934648: /*effectivePeriod*/  return new Property("effectivePeriod", "Period", "The period during which the SpecimenDefinition content was or is planned to be effective.", 0, 1, effectivePeriod);
3460        case 588504367: /*typeCollected*/  return new Property("typeCollected", "CodeableConcept", "The kind of material to be collected.", 0, 1, typeCollected);
3461        case -879411630: /*patientPreparation*/  return new Property("patientPreparation", "CodeableConcept", "Preparation of the patient for specimen collection.", 0, java.lang.Integer.MAX_VALUE, patientPreparation);
3462        case 276972933: /*timeAspect*/  return new Property("timeAspect", "string", "Time aspect of specimen collection (duration or offset).", 0, 1, timeAspect);
3463        case -1741312354: /*collection*/  return new Property("collection", "CodeableConcept", "The action to be performed for collecting the specimen.", 0, java.lang.Integer.MAX_VALUE, collection);
3464        case -1407902581: /*typeTested*/  return new Property("typeTested", "", "Specimen conditioned in a container as expected by the testing laboratory.", 0, java.lang.Integer.MAX_VALUE, typeTested);
3465        default: return super.getNamedProperty(_hash, _name, _checkValid);
3466        }
3467
3468      }
3469
3470      @Override
3471      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
3472        switch (hash) {
3473        case 116079: /*url*/ return this.url == null ? new Base[0] : new Base[] {this.url}; // UriType
3474        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : new Base[] {this.identifier}; // Identifier
3475        case 351608024: /*version*/ return this.version == null ? new Base[0] : new Base[] {this.version}; // StringType
3476        case 110371416: /*title*/ return this.title == null ? new Base[0] : new Base[] {this.title}; // StringType
3477        case -978133683: /*derivedFromCanonical*/ return this.derivedFromCanonical == null ? new Base[0] : this.derivedFromCanonical.toArray(new Base[this.derivedFromCanonical.size()]); // CanonicalType
3478        case -1076333435: /*derivedFromUri*/ return this.derivedFromUri == null ? new Base[0] : this.derivedFromUri.toArray(new Base[this.derivedFromUri.size()]); // UriType
3479        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<PublicationStatus>
3480        case -404562712: /*experimental*/ return this.experimental == null ? new Base[0] : new Base[] {this.experimental}; // BooleanType
3481        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // DataType
3482        case 3076014: /*date*/ return this.date == null ? new Base[0] : new Base[] {this.date}; // DateTimeType
3483        case 1447404028: /*publisher*/ return this.publisher == null ? new Base[0] : new Base[] {this.publisher}; // Reference
3484        case 951526432: /*contact*/ return this.contact == null ? new Base[0] : this.contact.toArray(new Base[this.contact.size()]); // ContactDetail
3485        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // MarkdownType
3486        case -669707736: /*useContext*/ return this.useContext == null ? new Base[0] : this.useContext.toArray(new Base[this.useContext.size()]); // UsageContext
3487        case -507075711: /*jurisdiction*/ return this.jurisdiction == null ? new Base[0] : this.jurisdiction.toArray(new Base[this.jurisdiction.size()]); // CodeableConcept
3488        case -220463842: /*purpose*/ return this.purpose == null ? new Base[0] : new Base[] {this.purpose}; // MarkdownType
3489        case 1522889671: /*copyright*/ return this.copyright == null ? new Base[0] : new Base[] {this.copyright}; // MarkdownType
3490        case 223539345: /*approvalDate*/ return this.approvalDate == null ? new Base[0] : new Base[] {this.approvalDate}; // DateType
3491        case -1687512484: /*lastReviewDate*/ return this.lastReviewDate == null ? new Base[0] : new Base[] {this.lastReviewDate}; // DateType
3492        case -403934648: /*effectivePeriod*/ return this.effectivePeriod == null ? new Base[0] : new Base[] {this.effectivePeriod}; // Period
3493        case 588504367: /*typeCollected*/ return this.typeCollected == null ? new Base[0] : new Base[] {this.typeCollected}; // CodeableConcept
3494        case -879411630: /*patientPreparation*/ return this.patientPreparation == null ? new Base[0] : this.patientPreparation.toArray(new Base[this.patientPreparation.size()]); // CodeableConcept
3495        case 276972933: /*timeAspect*/ return this.timeAspect == null ? new Base[0] : new Base[] {this.timeAspect}; // StringType
3496        case -1741312354: /*collection*/ return this.collection == null ? new Base[0] : this.collection.toArray(new Base[this.collection.size()]); // CodeableConcept
3497        case -1407902581: /*typeTested*/ return this.typeTested == null ? new Base[0] : this.typeTested.toArray(new Base[this.typeTested.size()]); // SpecimenDefinitionTypeTestedComponent
3498        default: return super.getProperty(hash, name, checkValid);
3499        }
3500
3501      }
3502
3503      @Override
3504      public Base setProperty(int hash, String name, Base value) throws FHIRException {
3505        switch (hash) {
3506        case 116079: // url
3507          this.url = TypeConvertor.castToUri(value); // UriType
3508          return value;
3509        case -1618432855: // identifier
3510          this.identifier = TypeConvertor.castToIdentifier(value); // Identifier
3511          return value;
3512        case 351608024: // version
3513          this.version = TypeConvertor.castToString(value); // StringType
3514          return value;
3515        case 110371416: // title
3516          this.title = TypeConvertor.castToString(value); // StringType
3517          return value;
3518        case -978133683: // derivedFromCanonical
3519          this.getDerivedFromCanonical().add(TypeConvertor.castToCanonical(value)); // CanonicalType
3520          return value;
3521        case -1076333435: // derivedFromUri
3522          this.getDerivedFromUri().add(TypeConvertor.castToUri(value)); // UriType
3523          return value;
3524        case -892481550: // status
3525          value = new PublicationStatusEnumFactory().fromType(TypeConvertor.castToCode(value));
3526          this.status = (Enumeration) value; // Enumeration<PublicationStatus>
3527          return value;
3528        case -404562712: // experimental
3529          this.experimental = TypeConvertor.castToBoolean(value); // BooleanType
3530          return value;
3531        case -1867885268: // subject
3532          this.subject = TypeConvertor.castToType(value); // DataType
3533          return value;
3534        case 3076014: // date
3535          this.date = TypeConvertor.castToDateTime(value); // DateTimeType
3536          return value;
3537        case 1447404028: // publisher
3538          this.publisher = TypeConvertor.castToReference(value); // Reference
3539          return value;
3540        case 951526432: // contact
3541          this.getContact().add(TypeConvertor.castToContactDetail(value)); // ContactDetail
3542          return value;
3543        case -1724546052: // description
3544          this.description = TypeConvertor.castToMarkdown(value); // MarkdownType
3545          return value;
3546        case -669707736: // useContext
3547          this.getUseContext().add(TypeConvertor.castToUsageContext(value)); // UsageContext
3548          return value;
3549        case -507075711: // jurisdiction
3550          this.getJurisdiction().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
3551          return value;
3552        case -220463842: // purpose
3553          this.purpose = TypeConvertor.castToMarkdown(value); // MarkdownType
3554          return value;
3555        case 1522889671: // copyright
3556          this.copyright = TypeConvertor.castToMarkdown(value); // MarkdownType
3557          return value;
3558        case 223539345: // approvalDate
3559          this.approvalDate = TypeConvertor.castToDate(value); // DateType
3560          return value;
3561        case -1687512484: // lastReviewDate
3562          this.lastReviewDate = TypeConvertor.castToDate(value); // DateType
3563          return value;
3564        case -403934648: // effectivePeriod
3565          this.effectivePeriod = TypeConvertor.castToPeriod(value); // Period
3566          return value;
3567        case 588504367: // typeCollected
3568          this.typeCollected = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
3569          return value;
3570        case -879411630: // patientPreparation
3571          this.getPatientPreparation().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
3572          return value;
3573        case 276972933: // timeAspect
3574          this.timeAspect = TypeConvertor.castToString(value); // StringType
3575          return value;
3576        case -1741312354: // collection
3577          this.getCollection().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
3578          return value;
3579        case -1407902581: // typeTested
3580          this.getTypeTested().add((SpecimenDefinitionTypeTestedComponent) value); // SpecimenDefinitionTypeTestedComponent
3581          return value;
3582        default: return super.setProperty(hash, name, value);
3583        }
3584
3585      }
3586
3587      @Override
3588      public Base setProperty(String name, Base value) throws FHIRException {
3589        if (name.equals("url")) {
3590          this.url = TypeConvertor.castToUri(value); // UriType
3591        } else if (name.equals("identifier")) {
3592          this.identifier = TypeConvertor.castToIdentifier(value); // Identifier
3593        } else if (name.equals("version")) {
3594          this.version = TypeConvertor.castToString(value); // StringType
3595        } else if (name.equals("title")) {
3596          this.title = TypeConvertor.castToString(value); // StringType
3597        } else if (name.equals("derivedFromCanonical")) {
3598          this.getDerivedFromCanonical().add(TypeConvertor.castToCanonical(value));
3599        } else if (name.equals("derivedFromUri")) {
3600          this.getDerivedFromUri().add(TypeConvertor.castToUri(value));
3601        } else if (name.equals("status")) {
3602          value = new PublicationStatusEnumFactory().fromType(TypeConvertor.castToCode(value));
3603          this.status = (Enumeration) value; // Enumeration<PublicationStatus>
3604        } else if (name.equals("experimental")) {
3605          this.experimental = TypeConvertor.castToBoolean(value); // BooleanType
3606        } else if (name.equals("subject[x]")) {
3607          this.subject = TypeConvertor.castToType(value); // DataType
3608        } else if (name.equals("date")) {
3609          this.date = TypeConvertor.castToDateTime(value); // DateTimeType
3610        } else if (name.equals("publisher")) {
3611          this.publisher = TypeConvertor.castToReference(value); // Reference
3612        } else if (name.equals("contact")) {
3613          this.getContact().add(TypeConvertor.castToContactDetail(value));
3614        } else if (name.equals("description")) {
3615          this.description = TypeConvertor.castToMarkdown(value); // MarkdownType
3616        } else if (name.equals("useContext")) {
3617          this.getUseContext().add(TypeConvertor.castToUsageContext(value));
3618        } else if (name.equals("jurisdiction")) {
3619          this.getJurisdiction().add(TypeConvertor.castToCodeableConcept(value));
3620        } else if (name.equals("purpose")) {
3621          this.purpose = TypeConvertor.castToMarkdown(value); // MarkdownType
3622        } else if (name.equals("copyright")) {
3623          this.copyright = TypeConvertor.castToMarkdown(value); // MarkdownType
3624        } else if (name.equals("approvalDate")) {
3625          this.approvalDate = TypeConvertor.castToDate(value); // DateType
3626        } else if (name.equals("lastReviewDate")) {
3627          this.lastReviewDate = TypeConvertor.castToDate(value); // DateType
3628        } else if (name.equals("effectivePeriod")) {
3629          this.effectivePeriod = TypeConvertor.castToPeriod(value); // Period
3630        } else if (name.equals("typeCollected")) {
3631          this.typeCollected = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
3632        } else if (name.equals("patientPreparation")) {
3633          this.getPatientPreparation().add(TypeConvertor.castToCodeableConcept(value));
3634        } else if (name.equals("timeAspect")) {
3635          this.timeAspect = TypeConvertor.castToString(value); // StringType
3636        } else if (name.equals("collection")) {
3637          this.getCollection().add(TypeConvertor.castToCodeableConcept(value));
3638        } else if (name.equals("typeTested")) {
3639          this.getTypeTested().add((SpecimenDefinitionTypeTestedComponent) value);
3640        } else
3641          return super.setProperty(name, value);
3642        return value;
3643      }
3644
3645      @Override
3646      public Base makeProperty(int hash, String name) throws FHIRException {
3647        switch (hash) {
3648        case 116079:  return getUrlElement();
3649        case -1618432855:  return getIdentifier();
3650        case 351608024:  return getVersionElement();
3651        case 110371416:  return getTitleElement();
3652        case -978133683:  return addDerivedFromCanonicalElement();
3653        case -1076333435:  return addDerivedFromUriElement();
3654        case -892481550:  return getStatusElement();
3655        case -404562712:  return getExperimentalElement();
3656        case -573640748:  return getSubject();
3657        case -1867885268:  return getSubject();
3658        case 3076014:  return getDateElement();
3659        case 1447404028:  return getPublisher();
3660        case 951526432:  return addContact(); 
3661        case -1724546052:  return getDescriptionElement();
3662        case -669707736:  return addUseContext(); 
3663        case -507075711:  return addJurisdiction(); 
3664        case -220463842:  return getPurposeElement();
3665        case 1522889671:  return getCopyrightElement();
3666        case 223539345:  return getApprovalDateElement();
3667        case -1687512484:  return getLastReviewDateElement();
3668        case -403934648:  return getEffectivePeriod();
3669        case 588504367:  return getTypeCollected();
3670        case -879411630:  return addPatientPreparation(); 
3671        case 276972933:  return getTimeAspectElement();
3672        case -1741312354:  return addCollection(); 
3673        case -1407902581:  return addTypeTested(); 
3674        default: return super.makeProperty(hash, name);
3675        }
3676
3677      }
3678
3679      @Override
3680      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
3681        switch (hash) {
3682        case 116079: /*url*/ return new String[] {"uri"};
3683        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
3684        case 351608024: /*version*/ return new String[] {"string"};
3685        case 110371416: /*title*/ return new String[] {"string"};
3686        case -978133683: /*derivedFromCanonical*/ return new String[] {"canonical"};
3687        case -1076333435: /*derivedFromUri*/ return new String[] {"uri"};
3688        case -892481550: /*status*/ return new String[] {"code"};
3689        case -404562712: /*experimental*/ return new String[] {"boolean"};
3690        case -1867885268: /*subject*/ return new String[] {"CodeableConcept", "Reference"};
3691        case 3076014: /*date*/ return new String[] {"dateTime"};
3692        case 1447404028: /*publisher*/ return new String[] {"Reference"};
3693        case 951526432: /*contact*/ return new String[] {"ContactDetail"};
3694        case -1724546052: /*description*/ return new String[] {"markdown"};
3695        case -669707736: /*useContext*/ return new String[] {"UsageContext"};
3696        case -507075711: /*jurisdiction*/ return new String[] {"CodeableConcept"};
3697        case -220463842: /*purpose*/ return new String[] {"markdown"};
3698        case 1522889671: /*copyright*/ return new String[] {"markdown"};
3699        case 223539345: /*approvalDate*/ return new String[] {"date"};
3700        case -1687512484: /*lastReviewDate*/ return new String[] {"date"};
3701        case -403934648: /*effectivePeriod*/ return new String[] {"Period"};
3702        case 588504367: /*typeCollected*/ return new String[] {"CodeableConcept"};
3703        case -879411630: /*patientPreparation*/ return new String[] {"CodeableConcept"};
3704        case 276972933: /*timeAspect*/ return new String[] {"string"};
3705        case -1741312354: /*collection*/ return new String[] {"CodeableConcept"};
3706        case -1407902581: /*typeTested*/ return new String[] {};
3707        default: return super.getTypesForProperty(hash, name);
3708        }
3709
3710      }
3711
3712      @Override
3713      public Base addChild(String name) throws FHIRException {
3714        if (name.equals("url")) {
3715          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.url");
3716        }
3717        else if (name.equals("identifier")) {
3718          this.identifier = new Identifier();
3719          return this.identifier;
3720        }
3721        else if (name.equals("version")) {
3722          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.version");
3723        }
3724        else if (name.equals("title")) {
3725          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.title");
3726        }
3727        else if (name.equals("derivedFromCanonical")) {
3728          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.derivedFromCanonical");
3729        }
3730        else if (name.equals("derivedFromUri")) {
3731          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.derivedFromUri");
3732        }
3733        else if (name.equals("status")) {
3734          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.status");
3735        }
3736        else if (name.equals("experimental")) {
3737          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.experimental");
3738        }
3739        else if (name.equals("subjectCodeableConcept")) {
3740          this.subject = new CodeableConcept();
3741          return this.subject;
3742        }
3743        else if (name.equals("subjectReference")) {
3744          this.subject = new Reference();
3745          return this.subject;
3746        }
3747        else if (name.equals("date")) {
3748          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.date");
3749        }
3750        else if (name.equals("publisher")) {
3751          this.publisher = new Reference();
3752          return this.publisher;
3753        }
3754        else if (name.equals("contact")) {
3755          return addContact();
3756        }
3757        else if (name.equals("description")) {
3758          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.description");
3759        }
3760        else if (name.equals("useContext")) {
3761          return addUseContext();
3762        }
3763        else if (name.equals("jurisdiction")) {
3764          return addJurisdiction();
3765        }
3766        else if (name.equals("purpose")) {
3767          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.purpose");
3768        }
3769        else if (name.equals("copyright")) {
3770          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.copyright");
3771        }
3772        else if (name.equals("approvalDate")) {
3773          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.approvalDate");
3774        }
3775        else if (name.equals("lastReviewDate")) {
3776          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.lastReviewDate");
3777        }
3778        else if (name.equals("effectivePeriod")) {
3779          this.effectivePeriod = new Period();
3780          return this.effectivePeriod;
3781        }
3782        else if (name.equals("typeCollected")) {
3783          this.typeCollected = new CodeableConcept();
3784          return this.typeCollected;
3785        }
3786        else if (name.equals("patientPreparation")) {
3787          return addPatientPreparation();
3788        }
3789        else if (name.equals("timeAspect")) {
3790          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.timeAspect");
3791        }
3792        else if (name.equals("collection")) {
3793          return addCollection();
3794        }
3795        else if (name.equals("typeTested")) {
3796          return addTypeTested();
3797        }
3798        else
3799          return super.addChild(name);
3800      }
3801
3802  public String fhirType() {
3803    return "SpecimenDefinition";
3804
3805  }
3806
3807      public SpecimenDefinition copy() {
3808        SpecimenDefinition dst = new SpecimenDefinition();
3809        copyValues(dst);
3810        return dst;
3811      }
3812
3813      public void copyValues(SpecimenDefinition dst) {
3814        super.copyValues(dst);
3815        dst.url = url == null ? null : url.copy();
3816        dst.identifier = identifier == null ? null : identifier.copy();
3817        dst.version = version == null ? null : version.copy();
3818        dst.title = title == null ? null : title.copy();
3819        if (derivedFromCanonical != null) {
3820          dst.derivedFromCanonical = new ArrayList<CanonicalType>();
3821          for (CanonicalType i : derivedFromCanonical)
3822            dst.derivedFromCanonical.add(i.copy());
3823        };
3824        if (derivedFromUri != null) {
3825          dst.derivedFromUri = new ArrayList<UriType>();
3826          for (UriType i : derivedFromUri)
3827            dst.derivedFromUri.add(i.copy());
3828        };
3829        dst.status = status == null ? null : status.copy();
3830        dst.experimental = experimental == null ? null : experimental.copy();
3831        dst.subject = subject == null ? null : subject.copy();
3832        dst.date = date == null ? null : date.copy();
3833        dst.publisher = publisher == null ? null : publisher.copy();
3834        if (contact != null) {
3835          dst.contact = new ArrayList<ContactDetail>();
3836          for (ContactDetail i : contact)
3837            dst.contact.add(i.copy());
3838        };
3839        dst.description = description == null ? null : description.copy();
3840        if (useContext != null) {
3841          dst.useContext = new ArrayList<UsageContext>();
3842          for (UsageContext i : useContext)
3843            dst.useContext.add(i.copy());
3844        };
3845        if (jurisdiction != null) {
3846          dst.jurisdiction = new ArrayList<CodeableConcept>();
3847          for (CodeableConcept i : jurisdiction)
3848            dst.jurisdiction.add(i.copy());
3849        };
3850        dst.purpose = purpose == null ? null : purpose.copy();
3851        dst.copyright = copyright == null ? null : copyright.copy();
3852        dst.approvalDate = approvalDate == null ? null : approvalDate.copy();
3853        dst.lastReviewDate = lastReviewDate == null ? null : lastReviewDate.copy();
3854        dst.effectivePeriod = effectivePeriod == null ? null : effectivePeriod.copy();
3855        dst.typeCollected = typeCollected == null ? null : typeCollected.copy();
3856        if (patientPreparation != null) {
3857          dst.patientPreparation = new ArrayList<CodeableConcept>();
3858          for (CodeableConcept i : patientPreparation)
3859            dst.patientPreparation.add(i.copy());
3860        };
3861        dst.timeAspect = timeAspect == null ? null : timeAspect.copy();
3862        if (collection != null) {
3863          dst.collection = new ArrayList<CodeableConcept>();
3864          for (CodeableConcept i : collection)
3865            dst.collection.add(i.copy());
3866        };
3867        if (typeTested != null) {
3868          dst.typeTested = new ArrayList<SpecimenDefinitionTypeTestedComponent>();
3869          for (SpecimenDefinitionTypeTestedComponent i : typeTested)
3870            dst.typeTested.add(i.copy());
3871        };
3872      }
3873
3874      protected SpecimenDefinition typedCopy() {
3875        return copy();
3876      }
3877
3878      @Override
3879      public boolean equalsDeep(Base other_) {
3880        if (!super.equalsDeep(other_))
3881          return false;
3882        if (!(other_ instanceof SpecimenDefinition))
3883          return false;
3884        SpecimenDefinition o = (SpecimenDefinition) other_;
3885        return compareDeep(url, o.url, true) && compareDeep(identifier, o.identifier, true) && compareDeep(version, o.version, true)
3886           && compareDeep(title, o.title, true) && compareDeep(derivedFromCanonical, o.derivedFromCanonical, true)
3887           && compareDeep(derivedFromUri, o.derivedFromUri, true) && compareDeep(status, o.status, true) && compareDeep(experimental, o.experimental, true)
3888           && compareDeep(subject, o.subject, true) && compareDeep(date, o.date, true) && compareDeep(publisher, o.publisher, true)
3889           && compareDeep(contact, o.contact, true) && compareDeep(description, o.description, true) && compareDeep(useContext, o.useContext, true)
3890           && compareDeep(jurisdiction, o.jurisdiction, true) && compareDeep(purpose, o.purpose, true) && compareDeep(copyright, o.copyright, true)
3891           && compareDeep(approvalDate, o.approvalDate, true) && compareDeep(lastReviewDate, o.lastReviewDate, true)
3892           && compareDeep(effectivePeriod, o.effectivePeriod, true) && compareDeep(typeCollected, o.typeCollected, true)
3893           && compareDeep(patientPreparation, o.patientPreparation, true) && compareDeep(timeAspect, o.timeAspect, true)
3894           && compareDeep(collection, o.collection, true) && compareDeep(typeTested, o.typeTested, true);
3895      }
3896
3897      @Override
3898      public boolean equalsShallow(Base other_) {
3899        if (!super.equalsShallow(other_))
3900          return false;
3901        if (!(other_ instanceof SpecimenDefinition))
3902          return false;
3903        SpecimenDefinition o = (SpecimenDefinition) other_;
3904        return compareValues(url, o.url, true) && compareValues(version, o.version, true) && compareValues(title, o.title, true)
3905           && compareValues(derivedFromCanonical, o.derivedFromCanonical, true) && compareValues(derivedFromUri, o.derivedFromUri, true)
3906           && compareValues(status, o.status, true) && compareValues(experimental, o.experimental, true) && compareValues(date, o.date, true)
3907           && compareValues(description, o.description, true) && compareValues(purpose, o.purpose, true) && compareValues(copyright, o.copyright, true)
3908           && compareValues(approvalDate, o.approvalDate, true) && compareValues(lastReviewDate, o.lastReviewDate, true)
3909           && compareValues(timeAspect, o.timeAspect, true);
3910      }
3911
3912      public boolean isEmpty() {
3913        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(url, identifier, version
3914          , title, derivedFromCanonical, derivedFromUri, status, experimental, subject, date
3915          , publisher, contact, description, useContext, jurisdiction, purpose, copyright
3916          , approvalDate, lastReviewDate, effectivePeriod, typeCollected, patientPreparation
3917          , timeAspect, collection, typeTested);
3918      }
3919
3920  @Override
3921  public ResourceType getResourceType() {
3922    return ResourceType.SpecimenDefinition;
3923   }
3924
3925 /**
3926   * Search parameter: <b>container</b>
3927   * <p>
3928   * Description: <b>The type of specimen conditioned in container expected by the lab</b><br>
3929   * Type: <b>token</b><br>
3930   * Path: <b>SpecimenDefinition.typeTested.container.type</b><br>
3931   * </p>
3932   */
3933  @SearchParamDefinition(name="container", path="SpecimenDefinition.typeTested.container.type", description="The type of specimen conditioned in container expected by the lab", type="token" )
3934  public static final String SP_CONTAINER = "container";
3935 /**
3936   * <b>Fluent Client</b> search parameter constant for <b>container</b>
3937   * <p>
3938   * Description: <b>The type of specimen conditioned in container expected by the lab</b><br>
3939   * Type: <b>token</b><br>
3940   * Path: <b>SpecimenDefinition.typeTested.container.type</b><br>
3941   * </p>
3942   */
3943  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CONTAINER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CONTAINER);
3944
3945 /**
3946   * Search parameter: <b>experimental</b>
3947   * <p>
3948   * Description: <b>Not for genuine usage (true)</b><br>
3949   * Type: <b>token</b><br>
3950   * Path: <b>SpecimenDefinition.experimental</b><br>
3951   * </p>
3952   */
3953  @SearchParamDefinition(name="experimental", path="SpecimenDefinition.experimental", description="Not for genuine usage (true)", type="token" )
3954  public static final String SP_EXPERIMENTAL = "experimental";
3955 /**
3956   * <b>Fluent Client</b> search parameter constant for <b>experimental</b>
3957   * <p>
3958   * Description: <b>Not for genuine usage (true)</b><br>
3959   * Type: <b>token</b><br>
3960   * Path: <b>SpecimenDefinition.experimental</b><br>
3961   * </p>
3962   */
3963  public static final ca.uhn.fhir.rest.gclient.TokenClientParam EXPERIMENTAL = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_EXPERIMENTAL);
3964
3965 /**
3966   * Search parameter: <b>identifier</b>
3967   * <p>
3968   * Description: <b>The unique identifier associated with the SpecimenDefinition</b><br>
3969   * Type: <b>token</b><br>
3970   * Path: <b>SpecimenDefinition.identifier</b><br>
3971   * </p>
3972   */
3973  @SearchParamDefinition(name="identifier", path="SpecimenDefinition.identifier", description="The unique identifier associated with the SpecimenDefinition", type="token" )
3974  public static final String SP_IDENTIFIER = "identifier";
3975 /**
3976   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
3977   * <p>
3978   * Description: <b>The unique identifier associated with the SpecimenDefinition</b><br>
3979   * Type: <b>token</b><br>
3980   * Path: <b>SpecimenDefinition.identifier</b><br>
3981   * </p>
3982   */
3983  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
3984
3985 /**
3986   * Search parameter: <b>is-derived</b>
3987   * <p>
3988   * Description: <b>Primary specimen (false) or derived specimen (true)</b><br>
3989   * Type: <b>token</b><br>
3990   * Path: <b>SpecimenDefinition.typeTested.isDerived</b><br>
3991   * </p>
3992   */
3993  @SearchParamDefinition(name="is-derived", path="SpecimenDefinition.typeTested.isDerived", description="Primary specimen (false) or derived specimen (true)", type="token" )
3994  public static final String SP_IS_DERIVED = "is-derived";
3995 /**
3996   * <b>Fluent Client</b> search parameter constant for <b>is-derived</b>
3997   * <p>
3998   * Description: <b>Primary specimen (false) or derived specimen (true)</b><br>
3999   * Type: <b>token</b><br>
4000   * Path: <b>SpecimenDefinition.typeTested.isDerived</b><br>
4001   * </p>
4002   */
4003  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IS_DERIVED = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IS_DERIVED);
4004
4005 /**
4006   * Search parameter: <b>status</b>
4007   * <p>
4008   * Description: <b>Publication status of the SpecimenDefinition: draft, active, retired, unknown</b><br>
4009   * Type: <b>token</b><br>
4010   * Path: <b>SpecimenDefinition.status</b><br>
4011   * </p>
4012   */
4013  @SearchParamDefinition(name="status", path="SpecimenDefinition.status", description="Publication status of the SpecimenDefinition: draft, active, retired, unknown", type="token" )
4014  public static final String SP_STATUS = "status";
4015 /**
4016   * <b>Fluent Client</b> search parameter constant for <b>status</b>
4017   * <p>
4018   * Description: <b>Publication status of the SpecimenDefinition: draft, active, retired, unknown</b><br>
4019   * Type: <b>token</b><br>
4020   * Path: <b>SpecimenDefinition.status</b><br>
4021   * </p>
4022   */
4023  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
4024
4025 /**
4026   * Search parameter: <b>title</b>
4027   * <p>
4028   * Description: <b>Human-friendly name of the SpecimenDefinition</b><br>
4029   * Type: <b>string</b><br>
4030   * Path: <b>SpecimenDefinition.title</b><br>
4031   * </p>
4032   */
4033  @SearchParamDefinition(name="title", path="SpecimenDefinition.title", description="Human-friendly name of the SpecimenDefinition", type="string" )
4034  public static final String SP_TITLE = "title";
4035 /**
4036   * <b>Fluent Client</b> search parameter constant for <b>title</b>
4037   * <p>
4038   * Description: <b>Human-friendly name of the SpecimenDefinition</b><br>
4039   * Type: <b>string</b><br>
4040   * Path: <b>SpecimenDefinition.title</b><br>
4041   * </p>
4042   */
4043  public static final ca.uhn.fhir.rest.gclient.StringClientParam TITLE = new ca.uhn.fhir.rest.gclient.StringClientParam(SP_TITLE);
4044
4045 /**
4046   * Search parameter: <b>type-tested</b>
4047   * <p>
4048   * Description: <b>The type of specimen conditioned for testing</b><br>
4049   * Type: <b>token</b><br>
4050   * Path: <b>SpecimenDefinition.typeTested.type</b><br>
4051   * </p>
4052   */
4053  @SearchParamDefinition(name="type-tested", path="SpecimenDefinition.typeTested.type", description="The type of specimen conditioned for testing", type="token" )
4054  public static final String SP_TYPE_TESTED = "type-tested";
4055 /**
4056   * <b>Fluent Client</b> search parameter constant for <b>type-tested</b>
4057   * <p>
4058   * Description: <b>The type of specimen conditioned for testing</b><br>
4059   * Type: <b>token</b><br>
4060   * Path: <b>SpecimenDefinition.typeTested.type</b><br>
4061   * </p>
4062   */
4063  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE_TESTED = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_TYPE_TESTED);
4064
4065 /**
4066   * Search parameter: <b>type</b>
4067   * <p>
4068   * Description: <b>The type of collected specimen</b><br>
4069   * Type: <b>token</b><br>
4070   * Path: <b>SpecimenDefinition.typeCollected</b><br>
4071   * </p>
4072   */
4073  @SearchParamDefinition(name="type", path="SpecimenDefinition.typeCollected", description="The type of collected specimen", type="token" )
4074  public static final String SP_TYPE = "type";
4075 /**
4076   * <b>Fluent Client</b> search parameter constant for <b>type</b>
4077   * <p>
4078   * Description: <b>The type of collected specimen</b><br>
4079   * Type: <b>token</b><br>
4080   * Path: <b>SpecimenDefinition.typeCollected</b><br>
4081   * </p>
4082   */
4083  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_TYPE);
4084
4085 /**
4086   * Search parameter: <b>url</b>
4087   * <p>
4088   * Description: <b>The uri that identifies the specimen definition</b><br>
4089   * Type: <b>uri</b><br>
4090   * Path: <b>SpecimenDefinition.url</b><br>
4091   * </p>
4092   */
4093  @SearchParamDefinition(name="url", path="SpecimenDefinition.url", description="The uri that identifies the specimen definition", type="uri" )
4094  public static final String SP_URL = "url";
4095 /**
4096   * <b>Fluent Client</b> search parameter constant for <b>url</b>
4097   * <p>
4098   * Description: <b>The uri that identifies the specimen definition</b><br>
4099   * Type: <b>uri</b><br>
4100   * Path: <b>SpecimenDefinition.url</b><br>
4101   * </p>
4102   */
4103  public static final ca.uhn.fhir.rest.gclient.UriClientParam URL = new ca.uhn.fhir.rest.gclient.UriClientParam(SP_URL);
4104
4105
4106}
4107