001package org.hl7.fhir.r4b.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, Dec 31, 2021 05:58+1100 for FHIR v4.3.0-snapshot1
033
034import java.util.ArrayList;
035import java.util.Date;
036import java.util.List;
037import org.hl7.fhir.utilities.Utilities;
038import org.hl7.fhir.r4b.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="Specimen requirements", 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="Specimen retention time", 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         * Criterion for rejection of the specimen in its container by the laboratory.
200         */
201        @Child(name = "rejectionCriterion", type = {CodeableConcept.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
202        @Description(shortDefinition="Rejection criterion", formalDefinition="Criterion for rejection of the specimen in its container by the laboratory." )
203        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/rejection-criteria")
204        protected List<CodeableConcept> rejectionCriterion;
205
206        /**
207         * Set of instructions for preservation/transport of the specimen at a defined temperature interval, prior the testing process.
208         */
209        @Child(name = "handling", type = {}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
210        @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." )
211        protected List<SpecimenDefinitionTypeTestedHandlingComponent> handling;
212
213        private static final long serialVersionUID = 308313920L;
214
215    /**
216     * Constructor
217     */
218      public SpecimenDefinitionTypeTestedComponent() {
219        super();
220      }
221
222    /**
223     * Constructor
224     */
225      public SpecimenDefinitionTypeTestedComponent(SpecimenContainedPreference preference) {
226        super();
227        this.setPreference(preference);
228      }
229
230        /**
231         * @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
232         */
233        public BooleanType getIsDerivedElement() { 
234          if (this.isDerived == null)
235            if (Configuration.errorOnAutoCreate())
236              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedComponent.isDerived");
237            else if (Configuration.doAutoCreate())
238              this.isDerived = new BooleanType(); // bb
239          return this.isDerived;
240        }
241
242        public boolean hasIsDerivedElement() { 
243          return this.isDerived != null && !this.isDerived.isEmpty();
244        }
245
246        public boolean hasIsDerived() { 
247          return this.isDerived != null && !this.isDerived.isEmpty();
248        }
249
250        /**
251         * @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
252         */
253        public SpecimenDefinitionTypeTestedComponent setIsDerivedElement(BooleanType value) { 
254          this.isDerived = value;
255          return this;
256        }
257
258        /**
259         * @return Primary of secondary specimen.
260         */
261        public boolean getIsDerived() { 
262          return this.isDerived == null || this.isDerived.isEmpty() ? false : this.isDerived.getValue();
263        }
264
265        /**
266         * @param value Primary of secondary specimen.
267         */
268        public SpecimenDefinitionTypeTestedComponent setIsDerived(boolean value) { 
269            if (this.isDerived == null)
270              this.isDerived = new BooleanType();
271            this.isDerived.setValue(value);
272          return this;
273        }
274
275        /**
276         * @return {@link #type} (The kind of specimen conditioned for testing expected by lab.)
277         */
278        public CodeableConcept getType() { 
279          if (this.type == null)
280            if (Configuration.errorOnAutoCreate())
281              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedComponent.type");
282            else if (Configuration.doAutoCreate())
283              this.type = new CodeableConcept(); // cc
284          return this.type;
285        }
286
287        public boolean hasType() { 
288          return this.type != null && !this.type.isEmpty();
289        }
290
291        /**
292         * @param value {@link #type} (The kind of specimen conditioned for testing expected by lab.)
293         */
294        public SpecimenDefinitionTypeTestedComponent setType(CodeableConcept value) { 
295          this.type = value;
296          return this;
297        }
298
299        /**
300         * @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
301         */
302        public Enumeration<SpecimenContainedPreference> getPreferenceElement() { 
303          if (this.preference == null)
304            if (Configuration.errorOnAutoCreate())
305              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedComponent.preference");
306            else if (Configuration.doAutoCreate())
307              this.preference = new Enumeration<SpecimenContainedPreference>(new SpecimenContainedPreferenceEnumFactory()); // bb
308          return this.preference;
309        }
310
311        public boolean hasPreferenceElement() { 
312          return this.preference != null && !this.preference.isEmpty();
313        }
314
315        public boolean hasPreference() { 
316          return this.preference != null && !this.preference.isEmpty();
317        }
318
319        /**
320         * @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
321         */
322        public SpecimenDefinitionTypeTestedComponent setPreferenceElement(Enumeration<SpecimenContainedPreference> value) { 
323          this.preference = value;
324          return this;
325        }
326
327        /**
328         * @return The preference for this type of conditioned specimen.
329         */
330        public SpecimenContainedPreference getPreference() { 
331          return this.preference == null ? null : this.preference.getValue();
332        }
333
334        /**
335         * @param value The preference for this type of conditioned specimen.
336         */
337        public SpecimenDefinitionTypeTestedComponent setPreference(SpecimenContainedPreference value) { 
338            if (this.preference == null)
339              this.preference = new Enumeration<SpecimenContainedPreference>(new SpecimenContainedPreferenceEnumFactory());
340            this.preference.setValue(value);
341          return this;
342        }
343
344        /**
345         * @return {@link #container} (The specimen's container.)
346         */
347        public SpecimenDefinitionTypeTestedContainerComponent getContainer() { 
348          if (this.container == null)
349            if (Configuration.errorOnAutoCreate())
350              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedComponent.container");
351            else if (Configuration.doAutoCreate())
352              this.container = new SpecimenDefinitionTypeTestedContainerComponent(); // cc
353          return this.container;
354        }
355
356        public boolean hasContainer() { 
357          return this.container != null && !this.container.isEmpty();
358        }
359
360        /**
361         * @param value {@link #container} (The specimen's container.)
362         */
363        public SpecimenDefinitionTypeTestedComponent setContainer(SpecimenDefinitionTypeTestedContainerComponent value) { 
364          this.container = value;
365          return this;
366        }
367
368        /**
369         * @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
370         */
371        public StringType getRequirementElement() { 
372          if (this.requirement == null)
373            if (Configuration.errorOnAutoCreate())
374              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedComponent.requirement");
375            else if (Configuration.doAutoCreate())
376              this.requirement = new StringType(); // bb
377          return this.requirement;
378        }
379
380        public boolean hasRequirementElement() { 
381          return this.requirement != null && !this.requirement.isEmpty();
382        }
383
384        public boolean hasRequirement() { 
385          return this.requirement != null && !this.requirement.isEmpty();
386        }
387
388        /**
389         * @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
390         */
391        public SpecimenDefinitionTypeTestedComponent setRequirementElement(StringType value) { 
392          this.requirement = value;
393          return this;
394        }
395
396        /**
397         * @return Requirements for delivery and special handling of this kind of conditioned specimen.
398         */
399        public String getRequirement() { 
400          return this.requirement == null ? null : this.requirement.getValue();
401        }
402
403        /**
404         * @param value Requirements for delivery and special handling of this kind of conditioned specimen.
405         */
406        public SpecimenDefinitionTypeTestedComponent setRequirement(String value) { 
407          if (Utilities.noString(value))
408            this.requirement = null;
409          else {
410            if (this.requirement == null)
411              this.requirement = new StringType();
412            this.requirement.setValue(value);
413          }
414          return this;
415        }
416
417        /**
418         * @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.)
419         */
420        public Duration getRetentionTime() { 
421          if (this.retentionTime == null)
422            if (Configuration.errorOnAutoCreate())
423              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedComponent.retentionTime");
424            else if (Configuration.doAutoCreate())
425              this.retentionTime = new Duration(); // cc
426          return this.retentionTime;
427        }
428
429        public boolean hasRetentionTime() { 
430          return this.retentionTime != null && !this.retentionTime.isEmpty();
431        }
432
433        /**
434         * @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.)
435         */
436        public SpecimenDefinitionTypeTestedComponent setRetentionTime(Duration value) { 
437          this.retentionTime = value;
438          return this;
439        }
440
441        /**
442         * @return {@link #rejectionCriterion} (Criterion for rejection of the specimen in its container by the laboratory.)
443         */
444        public List<CodeableConcept> getRejectionCriterion() { 
445          if (this.rejectionCriterion == null)
446            this.rejectionCriterion = new ArrayList<CodeableConcept>();
447          return this.rejectionCriterion;
448        }
449
450        /**
451         * @return Returns a reference to <code>this</code> for easy method chaining
452         */
453        public SpecimenDefinitionTypeTestedComponent setRejectionCriterion(List<CodeableConcept> theRejectionCriterion) { 
454          this.rejectionCriterion = theRejectionCriterion;
455          return this;
456        }
457
458        public boolean hasRejectionCriterion() { 
459          if (this.rejectionCriterion == null)
460            return false;
461          for (CodeableConcept item : this.rejectionCriterion)
462            if (!item.isEmpty())
463              return true;
464          return false;
465        }
466
467        public CodeableConcept addRejectionCriterion() { //3
468          CodeableConcept t = new CodeableConcept();
469          if (this.rejectionCriterion == null)
470            this.rejectionCriterion = new ArrayList<CodeableConcept>();
471          this.rejectionCriterion.add(t);
472          return t;
473        }
474
475        public SpecimenDefinitionTypeTestedComponent addRejectionCriterion(CodeableConcept t) { //3
476          if (t == null)
477            return this;
478          if (this.rejectionCriterion == null)
479            this.rejectionCriterion = new ArrayList<CodeableConcept>();
480          this.rejectionCriterion.add(t);
481          return this;
482        }
483
484        /**
485         * @return The first repetition of repeating field {@link #rejectionCriterion}, creating it if it does not already exist {3}
486         */
487        public CodeableConcept getRejectionCriterionFirstRep() { 
488          if (getRejectionCriterion().isEmpty()) {
489            addRejectionCriterion();
490          }
491          return getRejectionCriterion().get(0);
492        }
493
494        /**
495         * @return {@link #handling} (Set of instructions for preservation/transport of the specimen at a defined temperature interval, prior the testing process.)
496         */
497        public List<SpecimenDefinitionTypeTestedHandlingComponent> getHandling() { 
498          if (this.handling == null)
499            this.handling = new ArrayList<SpecimenDefinitionTypeTestedHandlingComponent>();
500          return this.handling;
501        }
502
503        /**
504         * @return Returns a reference to <code>this</code> for easy method chaining
505         */
506        public SpecimenDefinitionTypeTestedComponent setHandling(List<SpecimenDefinitionTypeTestedHandlingComponent> theHandling) { 
507          this.handling = theHandling;
508          return this;
509        }
510
511        public boolean hasHandling() { 
512          if (this.handling == null)
513            return false;
514          for (SpecimenDefinitionTypeTestedHandlingComponent item : this.handling)
515            if (!item.isEmpty())
516              return true;
517          return false;
518        }
519
520        public SpecimenDefinitionTypeTestedHandlingComponent addHandling() { //3
521          SpecimenDefinitionTypeTestedHandlingComponent t = new SpecimenDefinitionTypeTestedHandlingComponent();
522          if (this.handling == null)
523            this.handling = new ArrayList<SpecimenDefinitionTypeTestedHandlingComponent>();
524          this.handling.add(t);
525          return t;
526        }
527
528        public SpecimenDefinitionTypeTestedComponent addHandling(SpecimenDefinitionTypeTestedHandlingComponent t) { //3
529          if (t == null)
530            return this;
531          if (this.handling == null)
532            this.handling = new ArrayList<SpecimenDefinitionTypeTestedHandlingComponent>();
533          this.handling.add(t);
534          return this;
535        }
536
537        /**
538         * @return The first repetition of repeating field {@link #handling}, creating it if it does not already exist {3}
539         */
540        public SpecimenDefinitionTypeTestedHandlingComponent getHandlingFirstRep() { 
541          if (getHandling().isEmpty()) {
542            addHandling();
543          }
544          return getHandling().get(0);
545        }
546
547        protected void listChildren(List<Property> children) {
548          super.listChildren(children);
549          children.add(new Property("isDerived", "boolean", "Primary of secondary specimen.", 0, 1, isDerived));
550          children.add(new Property("type", "CodeableConcept", "The kind of specimen conditioned for testing expected by lab.", 0, 1, type));
551          children.add(new Property("preference", "code", "The preference for this type of conditioned specimen.", 0, 1, preference));
552          children.add(new Property("container", "", "The specimen's container.", 0, 1, container));
553          children.add(new Property("requirement", "string", "Requirements for delivery and special handling of this kind of conditioned specimen.", 0, 1, requirement));
554          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));
555          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));
556          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));
557        }
558
559        @Override
560        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
561          switch (_hash) {
562          case 976346515: /*isDerived*/  return new Property("isDerived", "boolean", "Primary of secondary specimen.", 0, 1, isDerived);
563          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "The kind of specimen conditioned for testing expected by lab.", 0, 1, type);
564          case -1459831589: /*preference*/  return new Property("preference", "code", "The preference for this type of conditioned specimen.", 0, 1, preference);
565          case -410956671: /*container*/  return new Property("container", "", "The specimen's container.", 0, 1, container);
566          case 363387971: /*requirement*/  return new Property("requirement", "string", "Requirements for delivery and special handling of this kind of conditioned specimen.", 0, 1, requirement);
567          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);
568          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);
569          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);
570          default: return super.getNamedProperty(_hash, _name, _checkValid);
571          }
572
573        }
574
575      @Override
576      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
577        switch (hash) {
578        case 976346515: /*isDerived*/ return this.isDerived == null ? new Base[0] : new Base[] {this.isDerived}; // BooleanType
579        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
580        case -1459831589: /*preference*/ return this.preference == null ? new Base[0] : new Base[] {this.preference}; // Enumeration<SpecimenContainedPreference>
581        case -410956671: /*container*/ return this.container == null ? new Base[0] : new Base[] {this.container}; // SpecimenDefinitionTypeTestedContainerComponent
582        case 363387971: /*requirement*/ return this.requirement == null ? new Base[0] : new Base[] {this.requirement}; // StringType
583        case 1434969867: /*retentionTime*/ return this.retentionTime == null ? new Base[0] : new Base[] {this.retentionTime}; // Duration
584        case -553706344: /*rejectionCriterion*/ return this.rejectionCriterion == null ? new Base[0] : this.rejectionCriterion.toArray(new Base[this.rejectionCriterion.size()]); // CodeableConcept
585        case 2072805: /*handling*/ return this.handling == null ? new Base[0] : this.handling.toArray(new Base[this.handling.size()]); // SpecimenDefinitionTypeTestedHandlingComponent
586        default: return super.getProperty(hash, name, checkValid);
587        }
588
589      }
590
591      @Override
592      public Base setProperty(int hash, String name, Base value) throws FHIRException {
593        switch (hash) {
594        case 976346515: // isDerived
595          this.isDerived = TypeConvertor.castToBoolean(value); // BooleanType
596          return value;
597        case 3575610: // type
598          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
599          return value;
600        case -1459831589: // preference
601          value = new SpecimenContainedPreferenceEnumFactory().fromType(TypeConvertor.castToCode(value));
602          this.preference = (Enumeration) value; // Enumeration<SpecimenContainedPreference>
603          return value;
604        case -410956671: // container
605          this.container = (SpecimenDefinitionTypeTestedContainerComponent) value; // SpecimenDefinitionTypeTestedContainerComponent
606          return value;
607        case 363387971: // requirement
608          this.requirement = TypeConvertor.castToString(value); // StringType
609          return value;
610        case 1434969867: // retentionTime
611          this.retentionTime = TypeConvertor.castToDuration(value); // Duration
612          return value;
613        case -553706344: // rejectionCriterion
614          this.getRejectionCriterion().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
615          return value;
616        case 2072805: // handling
617          this.getHandling().add((SpecimenDefinitionTypeTestedHandlingComponent) value); // SpecimenDefinitionTypeTestedHandlingComponent
618          return value;
619        default: return super.setProperty(hash, name, value);
620        }
621
622      }
623
624      @Override
625      public Base setProperty(String name, Base value) throws FHIRException {
626        if (name.equals("isDerived")) {
627          this.isDerived = TypeConvertor.castToBoolean(value); // BooleanType
628        } else if (name.equals("type")) {
629          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
630        } else if (name.equals("preference")) {
631          value = new SpecimenContainedPreferenceEnumFactory().fromType(TypeConvertor.castToCode(value));
632          this.preference = (Enumeration) value; // Enumeration<SpecimenContainedPreference>
633        } else if (name.equals("container")) {
634          this.container = (SpecimenDefinitionTypeTestedContainerComponent) value; // SpecimenDefinitionTypeTestedContainerComponent
635        } else if (name.equals("requirement")) {
636          this.requirement = TypeConvertor.castToString(value); // StringType
637        } else if (name.equals("retentionTime")) {
638          this.retentionTime = TypeConvertor.castToDuration(value); // Duration
639        } else if (name.equals("rejectionCriterion")) {
640          this.getRejectionCriterion().add(TypeConvertor.castToCodeableConcept(value));
641        } else if (name.equals("handling")) {
642          this.getHandling().add((SpecimenDefinitionTypeTestedHandlingComponent) value);
643        } else
644          return super.setProperty(name, value);
645        return value;
646      }
647
648      @Override
649      public Base makeProperty(int hash, String name) throws FHIRException {
650        switch (hash) {
651        case 976346515:  return getIsDerivedElement();
652        case 3575610:  return getType();
653        case -1459831589:  return getPreferenceElement();
654        case -410956671:  return getContainer();
655        case 363387971:  return getRequirementElement();
656        case 1434969867:  return getRetentionTime();
657        case -553706344:  return addRejectionCriterion(); 
658        case 2072805:  return addHandling(); 
659        default: return super.makeProperty(hash, name);
660        }
661
662      }
663
664      @Override
665      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
666        switch (hash) {
667        case 976346515: /*isDerived*/ return new String[] {"boolean"};
668        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
669        case -1459831589: /*preference*/ return new String[] {"code"};
670        case -410956671: /*container*/ return new String[] {};
671        case 363387971: /*requirement*/ return new String[] {"string"};
672        case 1434969867: /*retentionTime*/ return new String[] {"Duration"};
673        case -553706344: /*rejectionCriterion*/ return new String[] {"CodeableConcept"};
674        case 2072805: /*handling*/ return new String[] {};
675        default: return super.getTypesForProperty(hash, name);
676        }
677
678      }
679
680      @Override
681      public Base addChild(String name) throws FHIRException {
682        if (name.equals("isDerived")) {
683          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.typeTested.isDerived");
684        }
685        else if (name.equals("type")) {
686          this.type = new CodeableConcept();
687          return this.type;
688        }
689        else if (name.equals("preference")) {
690          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.typeTested.preference");
691        }
692        else if (name.equals("container")) {
693          this.container = new SpecimenDefinitionTypeTestedContainerComponent();
694          return this.container;
695        }
696        else if (name.equals("requirement")) {
697          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.typeTested.requirement");
698        }
699        else if (name.equals("retentionTime")) {
700          this.retentionTime = new Duration();
701          return this.retentionTime;
702        }
703        else if (name.equals("rejectionCriterion")) {
704          return addRejectionCriterion();
705        }
706        else if (name.equals("handling")) {
707          return addHandling();
708        }
709        else
710          return super.addChild(name);
711      }
712
713      public SpecimenDefinitionTypeTestedComponent copy() {
714        SpecimenDefinitionTypeTestedComponent dst = new SpecimenDefinitionTypeTestedComponent();
715        copyValues(dst);
716        return dst;
717      }
718
719      public void copyValues(SpecimenDefinitionTypeTestedComponent dst) {
720        super.copyValues(dst);
721        dst.isDerived = isDerived == null ? null : isDerived.copy();
722        dst.type = type == null ? null : type.copy();
723        dst.preference = preference == null ? null : preference.copy();
724        dst.container = container == null ? null : container.copy();
725        dst.requirement = requirement == null ? null : requirement.copy();
726        dst.retentionTime = retentionTime == null ? null : retentionTime.copy();
727        if (rejectionCriterion != null) {
728          dst.rejectionCriterion = new ArrayList<CodeableConcept>();
729          for (CodeableConcept i : rejectionCriterion)
730            dst.rejectionCriterion.add(i.copy());
731        };
732        if (handling != null) {
733          dst.handling = new ArrayList<SpecimenDefinitionTypeTestedHandlingComponent>();
734          for (SpecimenDefinitionTypeTestedHandlingComponent i : handling)
735            dst.handling.add(i.copy());
736        };
737      }
738
739      @Override
740      public boolean equalsDeep(Base other_) {
741        if (!super.equalsDeep(other_))
742          return false;
743        if (!(other_ instanceof SpecimenDefinitionTypeTestedComponent))
744          return false;
745        SpecimenDefinitionTypeTestedComponent o = (SpecimenDefinitionTypeTestedComponent) other_;
746        return compareDeep(isDerived, o.isDerived, true) && compareDeep(type, o.type, true) && compareDeep(preference, o.preference, true)
747           && compareDeep(container, o.container, true) && compareDeep(requirement, o.requirement, true) && compareDeep(retentionTime, o.retentionTime, true)
748           && compareDeep(rejectionCriterion, o.rejectionCriterion, true) && compareDeep(handling, o.handling, true)
749          ;
750      }
751
752      @Override
753      public boolean equalsShallow(Base other_) {
754        if (!super.equalsShallow(other_))
755          return false;
756        if (!(other_ instanceof SpecimenDefinitionTypeTestedComponent))
757          return false;
758        SpecimenDefinitionTypeTestedComponent o = (SpecimenDefinitionTypeTestedComponent) other_;
759        return compareValues(isDerived, o.isDerived, true) && compareValues(preference, o.preference, true)
760           && compareValues(requirement, o.requirement, true);
761      }
762
763      public boolean isEmpty() {
764        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(isDerived, type, preference
765          , container, requirement, retentionTime, rejectionCriterion, handling);
766      }
767
768  public String fhirType() {
769    return "SpecimenDefinition.typeTested";
770
771  }
772
773  }
774
775    @Block()
776    public static class SpecimenDefinitionTypeTestedContainerComponent extends BackboneElement implements IBaseBackboneElement {
777        /**
778         * The type of material of the container.
779         */
780        @Child(name = "material", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=false)
781        @Description(shortDefinition="Container material", formalDefinition="The type of material of the container." )
782        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/container-material")
783        protected CodeableConcept material;
784
785        /**
786         * The type of container used to contain this kind of specimen.
787         */
788        @Child(name = "type", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
789        @Description(shortDefinition="Kind of container associated with the kind of specimen", formalDefinition="The type of container used to contain this kind of specimen." )
790        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/specimen-container-type")
791        protected CodeableConcept type;
792
793        /**
794         * Color of container cap.
795         */
796        @Child(name = "cap", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=false)
797        @Description(shortDefinition="Color of container cap", formalDefinition="Color of container cap." )
798        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/container-cap")
799        protected CodeableConcept cap;
800
801        /**
802         * The textual description of the kind of container.
803         */
804        @Child(name = "description", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=false)
805        @Description(shortDefinition="Container description", formalDefinition="The textual description of the kind of container." )
806        protected StringType description;
807
808        /**
809         * The capacity (volume or other measure) of this kind of container.
810         */
811        @Child(name = "capacity", type = {Quantity.class}, order=5, min=0, max=1, modifier=false, summary=false)
812        @Description(shortDefinition="Container capacity", formalDefinition="The capacity (volume or other measure) of this kind of container." )
813        protected Quantity capacity;
814
815        /**
816         * The minimum volume to be conditioned in the container.
817         */
818        @Child(name = "minimumVolume", type = {Quantity.class, StringType.class}, order=6, min=0, max=1, modifier=false, summary=false)
819        @Description(shortDefinition="Minimum volume", formalDefinition="The minimum volume to be conditioned in the container." )
820        protected DataType minimumVolume;
821
822        /**
823         * Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.
824         */
825        @Child(name = "additive", type = {}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
826        @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." )
827        protected List<SpecimenDefinitionTypeTestedContainerAdditiveComponent> additive;
828
829        /**
830         * Special processing that should be applied to the container for this kind of specimen.
831         */
832        @Child(name = "preparation", type = {StringType.class}, order=8, min=0, max=1, modifier=false, summary=false)
833        @Description(shortDefinition="Specimen container preparation", formalDefinition="Special processing that should be applied to the container for this kind of specimen." )
834        protected StringType preparation;
835
836        private static final long serialVersionUID = -1498817064L;
837
838    /**
839     * Constructor
840     */
841      public SpecimenDefinitionTypeTestedContainerComponent() {
842        super();
843      }
844
845        /**
846         * @return {@link #material} (The type of material of the container.)
847         */
848        public CodeableConcept getMaterial() { 
849          if (this.material == null)
850            if (Configuration.errorOnAutoCreate())
851              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedContainerComponent.material");
852            else if (Configuration.doAutoCreate())
853              this.material = new CodeableConcept(); // cc
854          return this.material;
855        }
856
857        public boolean hasMaterial() { 
858          return this.material != null && !this.material.isEmpty();
859        }
860
861        /**
862         * @param value {@link #material} (The type of material of the container.)
863         */
864        public SpecimenDefinitionTypeTestedContainerComponent setMaterial(CodeableConcept value) { 
865          this.material = value;
866          return this;
867        }
868
869        /**
870         * @return {@link #type} (The type of container used to contain this kind of specimen.)
871         */
872        public CodeableConcept getType() { 
873          if (this.type == null)
874            if (Configuration.errorOnAutoCreate())
875              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedContainerComponent.type");
876            else if (Configuration.doAutoCreate())
877              this.type = new CodeableConcept(); // cc
878          return this.type;
879        }
880
881        public boolean hasType() { 
882          return this.type != null && !this.type.isEmpty();
883        }
884
885        /**
886         * @param value {@link #type} (The type of container used to contain this kind of specimen.)
887         */
888        public SpecimenDefinitionTypeTestedContainerComponent setType(CodeableConcept value) { 
889          this.type = value;
890          return this;
891        }
892
893        /**
894         * @return {@link #cap} (Color of container cap.)
895         */
896        public CodeableConcept getCap() { 
897          if (this.cap == null)
898            if (Configuration.errorOnAutoCreate())
899              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedContainerComponent.cap");
900            else if (Configuration.doAutoCreate())
901              this.cap = new CodeableConcept(); // cc
902          return this.cap;
903        }
904
905        public boolean hasCap() { 
906          return this.cap != null && !this.cap.isEmpty();
907        }
908
909        /**
910         * @param value {@link #cap} (Color of container cap.)
911         */
912        public SpecimenDefinitionTypeTestedContainerComponent setCap(CodeableConcept value) { 
913          this.cap = value;
914          return this;
915        }
916
917        /**
918         * @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
919         */
920        public StringType getDescriptionElement() { 
921          if (this.description == null)
922            if (Configuration.errorOnAutoCreate())
923              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedContainerComponent.description");
924            else if (Configuration.doAutoCreate())
925              this.description = new StringType(); // bb
926          return this.description;
927        }
928
929        public boolean hasDescriptionElement() { 
930          return this.description != null && !this.description.isEmpty();
931        }
932
933        public boolean hasDescription() { 
934          return this.description != null && !this.description.isEmpty();
935        }
936
937        /**
938         * @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
939         */
940        public SpecimenDefinitionTypeTestedContainerComponent setDescriptionElement(StringType value) { 
941          this.description = value;
942          return this;
943        }
944
945        /**
946         * @return The textual description of the kind of container.
947         */
948        public String getDescription() { 
949          return this.description == null ? null : this.description.getValue();
950        }
951
952        /**
953         * @param value The textual description of the kind of container.
954         */
955        public SpecimenDefinitionTypeTestedContainerComponent setDescription(String value) { 
956          if (Utilities.noString(value))
957            this.description = null;
958          else {
959            if (this.description == null)
960              this.description = new StringType();
961            this.description.setValue(value);
962          }
963          return this;
964        }
965
966        /**
967         * @return {@link #capacity} (The capacity (volume or other measure) of this kind of container.)
968         */
969        public Quantity getCapacity() { 
970          if (this.capacity == null)
971            if (Configuration.errorOnAutoCreate())
972              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedContainerComponent.capacity");
973            else if (Configuration.doAutoCreate())
974              this.capacity = new Quantity(); // cc
975          return this.capacity;
976        }
977
978        public boolean hasCapacity() { 
979          return this.capacity != null && !this.capacity.isEmpty();
980        }
981
982        /**
983         * @param value {@link #capacity} (The capacity (volume or other measure) of this kind of container.)
984         */
985        public SpecimenDefinitionTypeTestedContainerComponent setCapacity(Quantity value) { 
986          this.capacity = value;
987          return this;
988        }
989
990        /**
991         * @return {@link #minimumVolume} (The minimum volume to be conditioned in the container.)
992         */
993        public DataType getMinimumVolume() { 
994          return this.minimumVolume;
995        }
996
997        /**
998         * @return {@link #minimumVolume} (The minimum volume to be conditioned in the container.)
999         */
1000        public Quantity getMinimumVolumeQuantity() throws FHIRException { 
1001          if (this.minimumVolume == null)
1002            this.minimumVolume = new Quantity();
1003          if (!(this.minimumVolume instanceof Quantity))
1004            throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.minimumVolume.getClass().getName()+" was encountered");
1005          return (Quantity) this.minimumVolume;
1006        }
1007
1008        public boolean hasMinimumVolumeQuantity() { 
1009          return this != null && this.minimumVolume instanceof Quantity;
1010        }
1011
1012        /**
1013         * @return {@link #minimumVolume} (The minimum volume to be conditioned in the container.)
1014         */
1015        public StringType getMinimumVolumeStringType() throws FHIRException { 
1016          if (this.minimumVolume == null)
1017            this.minimumVolume = new StringType();
1018          if (!(this.minimumVolume instanceof StringType))
1019            throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.minimumVolume.getClass().getName()+" was encountered");
1020          return (StringType) this.minimumVolume;
1021        }
1022
1023        public boolean hasMinimumVolumeStringType() { 
1024          return this != null && this.minimumVolume instanceof StringType;
1025        }
1026
1027        public boolean hasMinimumVolume() { 
1028          return this.minimumVolume != null && !this.minimumVolume.isEmpty();
1029        }
1030
1031        /**
1032         * @param value {@link #minimumVolume} (The minimum volume to be conditioned in the container.)
1033         */
1034        public SpecimenDefinitionTypeTestedContainerComponent setMinimumVolume(DataType value) { 
1035          if (value != null && !(value instanceof Quantity || value instanceof StringType))
1036            throw new Error("Not the right type for SpecimenDefinition.typeTested.container.minimumVolume[x]: "+value.fhirType());
1037          this.minimumVolume = value;
1038          return this;
1039        }
1040
1041        /**
1042         * @return {@link #additive} (Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.)
1043         */
1044        public List<SpecimenDefinitionTypeTestedContainerAdditiveComponent> getAdditive() { 
1045          if (this.additive == null)
1046            this.additive = new ArrayList<SpecimenDefinitionTypeTestedContainerAdditiveComponent>();
1047          return this.additive;
1048        }
1049
1050        /**
1051         * @return Returns a reference to <code>this</code> for easy method chaining
1052         */
1053        public SpecimenDefinitionTypeTestedContainerComponent setAdditive(List<SpecimenDefinitionTypeTestedContainerAdditiveComponent> theAdditive) { 
1054          this.additive = theAdditive;
1055          return this;
1056        }
1057
1058        public boolean hasAdditive() { 
1059          if (this.additive == null)
1060            return false;
1061          for (SpecimenDefinitionTypeTestedContainerAdditiveComponent item : this.additive)
1062            if (!item.isEmpty())
1063              return true;
1064          return false;
1065        }
1066
1067        public SpecimenDefinitionTypeTestedContainerAdditiveComponent addAdditive() { //3
1068          SpecimenDefinitionTypeTestedContainerAdditiveComponent t = new SpecimenDefinitionTypeTestedContainerAdditiveComponent();
1069          if (this.additive == null)
1070            this.additive = new ArrayList<SpecimenDefinitionTypeTestedContainerAdditiveComponent>();
1071          this.additive.add(t);
1072          return t;
1073        }
1074
1075        public SpecimenDefinitionTypeTestedContainerComponent addAdditive(SpecimenDefinitionTypeTestedContainerAdditiveComponent t) { //3
1076          if (t == null)
1077            return this;
1078          if (this.additive == null)
1079            this.additive = new ArrayList<SpecimenDefinitionTypeTestedContainerAdditiveComponent>();
1080          this.additive.add(t);
1081          return this;
1082        }
1083
1084        /**
1085         * @return The first repetition of repeating field {@link #additive}, creating it if it does not already exist {3}
1086         */
1087        public SpecimenDefinitionTypeTestedContainerAdditiveComponent getAdditiveFirstRep() { 
1088          if (getAdditive().isEmpty()) {
1089            addAdditive();
1090          }
1091          return getAdditive().get(0);
1092        }
1093
1094        /**
1095         * @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
1096         */
1097        public StringType getPreparationElement() { 
1098          if (this.preparation == null)
1099            if (Configuration.errorOnAutoCreate())
1100              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedContainerComponent.preparation");
1101            else if (Configuration.doAutoCreate())
1102              this.preparation = new StringType(); // bb
1103          return this.preparation;
1104        }
1105
1106        public boolean hasPreparationElement() { 
1107          return this.preparation != null && !this.preparation.isEmpty();
1108        }
1109
1110        public boolean hasPreparation() { 
1111          return this.preparation != null && !this.preparation.isEmpty();
1112        }
1113
1114        /**
1115         * @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
1116         */
1117        public SpecimenDefinitionTypeTestedContainerComponent setPreparationElement(StringType value) { 
1118          this.preparation = value;
1119          return this;
1120        }
1121
1122        /**
1123         * @return Special processing that should be applied to the container for this kind of specimen.
1124         */
1125        public String getPreparation() { 
1126          return this.preparation == null ? null : this.preparation.getValue();
1127        }
1128
1129        /**
1130         * @param value Special processing that should be applied to the container for this kind of specimen.
1131         */
1132        public SpecimenDefinitionTypeTestedContainerComponent setPreparation(String value) { 
1133          if (Utilities.noString(value))
1134            this.preparation = null;
1135          else {
1136            if (this.preparation == null)
1137              this.preparation = new StringType();
1138            this.preparation.setValue(value);
1139          }
1140          return this;
1141        }
1142
1143        protected void listChildren(List<Property> children) {
1144          super.listChildren(children);
1145          children.add(new Property("material", "CodeableConcept", "The type of material of the container.", 0, 1, material));
1146          children.add(new Property("type", "CodeableConcept", "The type of container used to contain this kind of specimen.", 0, 1, type));
1147          children.add(new Property("cap", "CodeableConcept", "Color of container cap.", 0, 1, cap));
1148          children.add(new Property("description", "string", "The textual description of the kind of container.", 0, 1, description));
1149          children.add(new Property("capacity", "Quantity", "The capacity (volume or other measure) of this kind of container.", 0, 1, capacity));
1150          children.add(new Property("minimumVolume[x]", "Quantity|string", "The minimum volume to be conditioned in the container.", 0, 1, minimumVolume));
1151          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));
1152          children.add(new Property("preparation", "string", "Special processing that should be applied to the container for this kind of specimen.", 0, 1, preparation));
1153        }
1154
1155        @Override
1156        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1157          switch (_hash) {
1158          case 299066663: /*material*/  return new Property("material", "CodeableConcept", "The type of material of the container.", 0, 1, material);
1159          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "The type of container used to contain this kind of specimen.", 0, 1, type);
1160          case 98258: /*cap*/  return new Property("cap", "CodeableConcept", "Color of container cap.", 0, 1, cap);
1161          case -1724546052: /*description*/  return new Property("description", "string", "The textual description of the kind of container.", 0, 1, description);
1162          case -67824454: /*capacity*/  return new Property("capacity", "Quantity", "The capacity (volume or other measure) of this kind of container.", 0, 1, capacity);
1163          case 371830456: /*minimumVolume[x]*/  return new Property("minimumVolume[x]", "Quantity|string", "The minimum volume to be conditioned in the container.", 0, 1, minimumVolume);
1164          case -1674665784: /*minimumVolume*/  return new Property("minimumVolume[x]", "Quantity|string", "The minimum volume to be conditioned in the container.", 0, 1, minimumVolume);
1165          case -532143757: /*minimumVolumeQuantity*/  return new Property("minimumVolume[x]", "Quantity", "The minimum volume to be conditioned in the container.", 0, 1, minimumVolume);
1166          case 248461049: /*minimumVolumeString*/  return new Property("minimumVolume[x]", "string", "The minimum volume to be conditioned in the container.", 0, 1, minimumVolume);
1167          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);
1168          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);
1169          default: return super.getNamedProperty(_hash, _name, _checkValid);
1170          }
1171
1172        }
1173
1174      @Override
1175      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1176        switch (hash) {
1177        case 299066663: /*material*/ return this.material == null ? new Base[0] : new Base[] {this.material}; // CodeableConcept
1178        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
1179        case 98258: /*cap*/ return this.cap == null ? new Base[0] : new Base[] {this.cap}; // CodeableConcept
1180        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // StringType
1181        case -67824454: /*capacity*/ return this.capacity == null ? new Base[0] : new Base[] {this.capacity}; // Quantity
1182        case -1674665784: /*minimumVolume*/ return this.minimumVolume == null ? new Base[0] : new Base[] {this.minimumVolume}; // DataType
1183        case -1226589236: /*additive*/ return this.additive == null ? new Base[0] : this.additive.toArray(new Base[this.additive.size()]); // SpecimenDefinitionTypeTestedContainerAdditiveComponent
1184        case -1315428713: /*preparation*/ return this.preparation == null ? new Base[0] : new Base[] {this.preparation}; // StringType
1185        default: return super.getProperty(hash, name, checkValid);
1186        }
1187
1188      }
1189
1190      @Override
1191      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1192        switch (hash) {
1193        case 299066663: // material
1194          this.material = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1195          return value;
1196        case 3575610: // type
1197          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1198          return value;
1199        case 98258: // cap
1200          this.cap = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1201          return value;
1202        case -1724546052: // description
1203          this.description = TypeConvertor.castToString(value); // StringType
1204          return value;
1205        case -67824454: // capacity
1206          this.capacity = TypeConvertor.castToQuantity(value); // Quantity
1207          return value;
1208        case -1674665784: // minimumVolume
1209          this.minimumVolume = TypeConvertor.castToType(value); // DataType
1210          return value;
1211        case -1226589236: // additive
1212          this.getAdditive().add((SpecimenDefinitionTypeTestedContainerAdditiveComponent) value); // SpecimenDefinitionTypeTestedContainerAdditiveComponent
1213          return value;
1214        case -1315428713: // preparation
1215          this.preparation = TypeConvertor.castToString(value); // StringType
1216          return value;
1217        default: return super.setProperty(hash, name, value);
1218        }
1219
1220      }
1221
1222      @Override
1223      public Base setProperty(String name, Base value) throws FHIRException {
1224        if (name.equals("material")) {
1225          this.material = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1226        } else if (name.equals("type")) {
1227          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1228        } else if (name.equals("cap")) {
1229          this.cap = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1230        } else if (name.equals("description")) {
1231          this.description = TypeConvertor.castToString(value); // StringType
1232        } else if (name.equals("capacity")) {
1233          this.capacity = TypeConvertor.castToQuantity(value); // Quantity
1234        } else if (name.equals("minimumVolume[x]")) {
1235          this.minimumVolume = TypeConvertor.castToType(value); // DataType
1236        } else if (name.equals("additive")) {
1237          this.getAdditive().add((SpecimenDefinitionTypeTestedContainerAdditiveComponent) value);
1238        } else if (name.equals("preparation")) {
1239          this.preparation = TypeConvertor.castToString(value); // StringType
1240        } else
1241          return super.setProperty(name, value);
1242        return value;
1243      }
1244
1245      @Override
1246      public Base makeProperty(int hash, String name) throws FHIRException {
1247        switch (hash) {
1248        case 299066663:  return getMaterial();
1249        case 3575610:  return getType();
1250        case 98258:  return getCap();
1251        case -1724546052:  return getDescriptionElement();
1252        case -67824454:  return getCapacity();
1253        case 371830456:  return getMinimumVolume();
1254        case -1674665784:  return getMinimumVolume();
1255        case -1226589236:  return addAdditive(); 
1256        case -1315428713:  return getPreparationElement();
1257        default: return super.makeProperty(hash, name);
1258        }
1259
1260      }
1261
1262      @Override
1263      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1264        switch (hash) {
1265        case 299066663: /*material*/ return new String[] {"CodeableConcept"};
1266        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
1267        case 98258: /*cap*/ return new String[] {"CodeableConcept"};
1268        case -1724546052: /*description*/ return new String[] {"string"};
1269        case -67824454: /*capacity*/ return new String[] {"Quantity"};
1270        case -1674665784: /*minimumVolume*/ return new String[] {"Quantity", "string"};
1271        case -1226589236: /*additive*/ return new String[] {};
1272        case -1315428713: /*preparation*/ return new String[] {"string"};
1273        default: return super.getTypesForProperty(hash, name);
1274        }
1275
1276      }
1277
1278      @Override
1279      public Base addChild(String name) throws FHIRException {
1280        if (name.equals("material")) {
1281          this.material = new CodeableConcept();
1282          return this.material;
1283        }
1284        else if (name.equals("type")) {
1285          this.type = new CodeableConcept();
1286          return this.type;
1287        }
1288        else if (name.equals("cap")) {
1289          this.cap = new CodeableConcept();
1290          return this.cap;
1291        }
1292        else if (name.equals("description")) {
1293          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.typeTested.container.description");
1294        }
1295        else if (name.equals("capacity")) {
1296          this.capacity = new Quantity();
1297          return this.capacity;
1298        }
1299        else if (name.equals("minimumVolumeQuantity")) {
1300          this.minimumVolume = new Quantity();
1301          return this.minimumVolume;
1302        }
1303        else if (name.equals("minimumVolumeString")) {
1304          this.minimumVolume = new StringType();
1305          return this.minimumVolume;
1306        }
1307        else if (name.equals("additive")) {
1308          return addAdditive();
1309        }
1310        else if (name.equals("preparation")) {
1311          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.typeTested.container.preparation");
1312        }
1313        else
1314          return super.addChild(name);
1315      }
1316
1317      public SpecimenDefinitionTypeTestedContainerComponent copy() {
1318        SpecimenDefinitionTypeTestedContainerComponent dst = new SpecimenDefinitionTypeTestedContainerComponent();
1319        copyValues(dst);
1320        return dst;
1321      }
1322
1323      public void copyValues(SpecimenDefinitionTypeTestedContainerComponent dst) {
1324        super.copyValues(dst);
1325        dst.material = material == null ? null : material.copy();
1326        dst.type = type == null ? null : type.copy();
1327        dst.cap = cap == null ? null : cap.copy();
1328        dst.description = description == null ? null : description.copy();
1329        dst.capacity = capacity == null ? null : capacity.copy();
1330        dst.minimumVolume = minimumVolume == null ? null : minimumVolume.copy();
1331        if (additive != null) {
1332          dst.additive = new ArrayList<SpecimenDefinitionTypeTestedContainerAdditiveComponent>();
1333          for (SpecimenDefinitionTypeTestedContainerAdditiveComponent i : additive)
1334            dst.additive.add(i.copy());
1335        };
1336        dst.preparation = preparation == null ? null : preparation.copy();
1337      }
1338
1339      @Override
1340      public boolean equalsDeep(Base other_) {
1341        if (!super.equalsDeep(other_))
1342          return false;
1343        if (!(other_ instanceof SpecimenDefinitionTypeTestedContainerComponent))
1344          return false;
1345        SpecimenDefinitionTypeTestedContainerComponent o = (SpecimenDefinitionTypeTestedContainerComponent) other_;
1346        return compareDeep(material, o.material, true) && compareDeep(type, o.type, true) && compareDeep(cap, o.cap, true)
1347           && compareDeep(description, o.description, true) && compareDeep(capacity, o.capacity, true) && compareDeep(minimumVolume, o.minimumVolume, true)
1348           && compareDeep(additive, o.additive, true) && compareDeep(preparation, o.preparation, true);
1349      }
1350
1351      @Override
1352      public boolean equalsShallow(Base other_) {
1353        if (!super.equalsShallow(other_))
1354          return false;
1355        if (!(other_ instanceof SpecimenDefinitionTypeTestedContainerComponent))
1356          return false;
1357        SpecimenDefinitionTypeTestedContainerComponent o = (SpecimenDefinitionTypeTestedContainerComponent) other_;
1358        return compareValues(description, o.description, true) && compareValues(preparation, o.preparation, true)
1359          ;
1360      }
1361
1362      public boolean isEmpty() {
1363        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(material, type, cap, description
1364          , capacity, minimumVolume, additive, preparation);
1365      }
1366
1367  public String fhirType() {
1368    return "SpecimenDefinition.typeTested.container";
1369
1370  }
1371
1372  }
1373
1374    @Block()
1375    public static class SpecimenDefinitionTypeTestedContainerAdditiveComponent extends BackboneElement implements IBaseBackboneElement {
1376        /**
1377         * Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.
1378         */
1379        @Child(name = "additive", type = {CodeableConcept.class, Substance.class}, order=1, min=1, max=1, modifier=false, summary=false)
1380        @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." )
1381        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://terminology.hl7.org/ValueSet/v2-0371")
1382        protected DataType additive;
1383
1384        private static final long serialVersionUID = 201856258L;
1385
1386    /**
1387     * Constructor
1388     */
1389      public SpecimenDefinitionTypeTestedContainerAdditiveComponent() {
1390        super();
1391      }
1392
1393    /**
1394     * Constructor
1395     */
1396      public SpecimenDefinitionTypeTestedContainerAdditiveComponent(DataType additive) {
1397        super();
1398        this.setAdditive(additive);
1399      }
1400
1401        /**
1402         * @return {@link #additive} (Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.)
1403         */
1404        public DataType getAdditive() { 
1405          return this.additive;
1406        }
1407
1408        /**
1409         * @return {@link #additive} (Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.)
1410         */
1411        public CodeableConcept getAdditiveCodeableConcept() throws FHIRException { 
1412          if (this.additive == null)
1413            this.additive = new CodeableConcept();
1414          if (!(this.additive instanceof CodeableConcept))
1415            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.additive.getClass().getName()+" was encountered");
1416          return (CodeableConcept) this.additive;
1417        }
1418
1419        public boolean hasAdditiveCodeableConcept() { 
1420          return this != null && this.additive instanceof CodeableConcept;
1421        }
1422
1423        /**
1424         * @return {@link #additive} (Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.)
1425         */
1426        public Reference getAdditiveReference() throws FHIRException { 
1427          if (this.additive == null)
1428            this.additive = new Reference();
1429          if (!(this.additive instanceof Reference))
1430            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.additive.getClass().getName()+" was encountered");
1431          return (Reference) this.additive;
1432        }
1433
1434        public boolean hasAdditiveReference() { 
1435          return this != null && this.additive instanceof Reference;
1436        }
1437
1438        public boolean hasAdditive() { 
1439          return this.additive != null && !this.additive.isEmpty();
1440        }
1441
1442        /**
1443         * @param value {@link #additive} (Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.)
1444         */
1445        public SpecimenDefinitionTypeTestedContainerAdditiveComponent setAdditive(DataType value) { 
1446          if (value != null && !(value instanceof CodeableConcept || value instanceof Reference))
1447            throw new Error("Not the right type for SpecimenDefinition.typeTested.container.additive.additive[x]: "+value.fhirType());
1448          this.additive = value;
1449          return this;
1450        }
1451
1452        protected void listChildren(List<Property> children) {
1453          super.listChildren(children);
1454          children.add(new Property("additive[x]", "CodeableConcept|Reference(Substance)", "Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.", 0, 1, additive));
1455        }
1456
1457        @Override
1458        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1459          switch (_hash) {
1460          case 261915956: /*additive[x]*/  return new Property("additive[x]", "CodeableConcept|Reference(Substance)", "Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.", 0, 1, additive);
1461          case -1226589236: /*additive*/  return new Property("additive[x]", "CodeableConcept|Reference(Substance)", "Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.", 0, 1, additive);
1462          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);
1463          case -386783009: /*additiveReference*/  return new Property("additive[x]", "Reference(Substance)", "Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.", 0, 1, additive);
1464          default: return super.getNamedProperty(_hash, _name, _checkValid);
1465          }
1466
1467        }
1468
1469      @Override
1470      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1471        switch (hash) {
1472        case -1226589236: /*additive*/ return this.additive == null ? new Base[0] : new Base[] {this.additive}; // DataType
1473        default: return super.getProperty(hash, name, checkValid);
1474        }
1475
1476      }
1477
1478      @Override
1479      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1480        switch (hash) {
1481        case -1226589236: // additive
1482          this.additive = TypeConvertor.castToType(value); // DataType
1483          return value;
1484        default: return super.setProperty(hash, name, value);
1485        }
1486
1487      }
1488
1489      @Override
1490      public Base setProperty(String name, Base value) throws FHIRException {
1491        if (name.equals("additive[x]")) {
1492          this.additive = TypeConvertor.castToType(value); // DataType
1493        } else
1494          return super.setProperty(name, value);
1495        return value;
1496      }
1497
1498      @Override
1499      public Base makeProperty(int hash, String name) throws FHIRException {
1500        switch (hash) {
1501        case 261915956:  return getAdditive();
1502        case -1226589236:  return getAdditive();
1503        default: return super.makeProperty(hash, name);
1504        }
1505
1506      }
1507
1508      @Override
1509      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1510        switch (hash) {
1511        case -1226589236: /*additive*/ return new String[] {"CodeableConcept", "Reference"};
1512        default: return super.getTypesForProperty(hash, name);
1513        }
1514
1515      }
1516
1517      @Override
1518      public Base addChild(String name) throws FHIRException {
1519        if (name.equals("additiveCodeableConcept")) {
1520          this.additive = new CodeableConcept();
1521          return this.additive;
1522        }
1523        else if (name.equals("additiveReference")) {
1524          this.additive = new Reference();
1525          return this.additive;
1526        }
1527        else
1528          return super.addChild(name);
1529      }
1530
1531      public SpecimenDefinitionTypeTestedContainerAdditiveComponent copy() {
1532        SpecimenDefinitionTypeTestedContainerAdditiveComponent dst = new SpecimenDefinitionTypeTestedContainerAdditiveComponent();
1533        copyValues(dst);
1534        return dst;
1535      }
1536
1537      public void copyValues(SpecimenDefinitionTypeTestedContainerAdditiveComponent dst) {
1538        super.copyValues(dst);
1539        dst.additive = additive == null ? null : additive.copy();
1540      }
1541
1542      @Override
1543      public boolean equalsDeep(Base other_) {
1544        if (!super.equalsDeep(other_))
1545          return false;
1546        if (!(other_ instanceof SpecimenDefinitionTypeTestedContainerAdditiveComponent))
1547          return false;
1548        SpecimenDefinitionTypeTestedContainerAdditiveComponent o = (SpecimenDefinitionTypeTestedContainerAdditiveComponent) other_;
1549        return compareDeep(additive, o.additive, true);
1550      }
1551
1552      @Override
1553      public boolean equalsShallow(Base other_) {
1554        if (!super.equalsShallow(other_))
1555          return false;
1556        if (!(other_ instanceof SpecimenDefinitionTypeTestedContainerAdditiveComponent))
1557          return false;
1558        SpecimenDefinitionTypeTestedContainerAdditiveComponent o = (SpecimenDefinitionTypeTestedContainerAdditiveComponent) other_;
1559        return true;
1560      }
1561
1562      public boolean isEmpty() {
1563        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(additive);
1564      }
1565
1566  public String fhirType() {
1567    return "SpecimenDefinition.typeTested.container.additive";
1568
1569  }
1570
1571  }
1572
1573    @Block()
1574    public static class SpecimenDefinitionTypeTestedHandlingComponent extends BackboneElement implements IBaseBackboneElement {
1575        /**
1576         * 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.
1577         */
1578        @Child(name = "temperatureQualifier", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=false)
1579        @Description(shortDefinition="Temperature qualifier", 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." )
1580        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/handling-condition")
1581        protected CodeableConcept temperatureQualifier;
1582
1583        /**
1584         * The temperature interval for this set of handling instructions.
1585         */
1586        @Child(name = "temperatureRange", type = {Range.class}, order=2, min=0, max=1, modifier=false, summary=false)
1587        @Description(shortDefinition="Temperature range", formalDefinition="The temperature interval for this set of handling instructions." )
1588        protected Range temperatureRange;
1589
1590        /**
1591         * The maximum time interval of preservation of the specimen with these conditions.
1592         */
1593        @Child(name = "maxDuration", type = {Duration.class}, order=3, min=0, max=1, modifier=false, summary=false)
1594        @Description(shortDefinition="Maximum preservation time", formalDefinition="The maximum time interval of preservation of the specimen with these conditions." )
1595        protected Duration maxDuration;
1596
1597        /**
1598         * Additional textual instructions for the preservation or transport of the specimen. For instance, 'Protect from light exposure'.
1599         */
1600        @Child(name = "instruction", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=false)
1601        @Description(shortDefinition="Preservation instruction", formalDefinition="Additional textual instructions for the preservation or transport of the specimen. For instance, 'Protect from light exposure'." )
1602        protected StringType instruction;
1603
1604        private static final long serialVersionUID = 2130906844L;
1605
1606    /**
1607     * Constructor
1608     */
1609      public SpecimenDefinitionTypeTestedHandlingComponent() {
1610        super();
1611      }
1612
1613        /**
1614         * @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.)
1615         */
1616        public CodeableConcept getTemperatureQualifier() { 
1617          if (this.temperatureQualifier == null)
1618            if (Configuration.errorOnAutoCreate())
1619              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedHandlingComponent.temperatureQualifier");
1620            else if (Configuration.doAutoCreate())
1621              this.temperatureQualifier = new CodeableConcept(); // cc
1622          return this.temperatureQualifier;
1623        }
1624
1625        public boolean hasTemperatureQualifier() { 
1626          return this.temperatureQualifier != null && !this.temperatureQualifier.isEmpty();
1627        }
1628
1629        /**
1630         * @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.)
1631         */
1632        public SpecimenDefinitionTypeTestedHandlingComponent setTemperatureQualifier(CodeableConcept value) { 
1633          this.temperatureQualifier = value;
1634          return this;
1635        }
1636
1637        /**
1638         * @return {@link #temperatureRange} (The temperature interval for this set of handling instructions.)
1639         */
1640        public Range getTemperatureRange() { 
1641          if (this.temperatureRange == null)
1642            if (Configuration.errorOnAutoCreate())
1643              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedHandlingComponent.temperatureRange");
1644            else if (Configuration.doAutoCreate())
1645              this.temperatureRange = new Range(); // cc
1646          return this.temperatureRange;
1647        }
1648
1649        public boolean hasTemperatureRange() { 
1650          return this.temperatureRange != null && !this.temperatureRange.isEmpty();
1651        }
1652
1653        /**
1654         * @param value {@link #temperatureRange} (The temperature interval for this set of handling instructions.)
1655         */
1656        public SpecimenDefinitionTypeTestedHandlingComponent setTemperatureRange(Range value) { 
1657          this.temperatureRange = value;
1658          return this;
1659        }
1660
1661        /**
1662         * @return {@link #maxDuration} (The maximum time interval of preservation of the specimen with these conditions.)
1663         */
1664        public Duration getMaxDuration() { 
1665          if (this.maxDuration == null)
1666            if (Configuration.errorOnAutoCreate())
1667              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedHandlingComponent.maxDuration");
1668            else if (Configuration.doAutoCreate())
1669              this.maxDuration = new Duration(); // cc
1670          return this.maxDuration;
1671        }
1672
1673        public boolean hasMaxDuration() { 
1674          return this.maxDuration != null && !this.maxDuration.isEmpty();
1675        }
1676
1677        /**
1678         * @param value {@link #maxDuration} (The maximum time interval of preservation of the specimen with these conditions.)
1679         */
1680        public SpecimenDefinitionTypeTestedHandlingComponent setMaxDuration(Duration value) { 
1681          this.maxDuration = value;
1682          return this;
1683        }
1684
1685        /**
1686         * @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
1687         */
1688        public StringType getInstructionElement() { 
1689          if (this.instruction == null)
1690            if (Configuration.errorOnAutoCreate())
1691              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedHandlingComponent.instruction");
1692            else if (Configuration.doAutoCreate())
1693              this.instruction = new StringType(); // bb
1694          return this.instruction;
1695        }
1696
1697        public boolean hasInstructionElement() { 
1698          return this.instruction != null && !this.instruction.isEmpty();
1699        }
1700
1701        public boolean hasInstruction() { 
1702          return this.instruction != null && !this.instruction.isEmpty();
1703        }
1704
1705        /**
1706         * @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
1707         */
1708        public SpecimenDefinitionTypeTestedHandlingComponent setInstructionElement(StringType value) { 
1709          this.instruction = value;
1710          return this;
1711        }
1712
1713        /**
1714         * @return Additional textual instructions for the preservation or transport of the specimen. For instance, 'Protect from light exposure'.
1715         */
1716        public String getInstruction() { 
1717          return this.instruction == null ? null : this.instruction.getValue();
1718        }
1719
1720        /**
1721         * @param value Additional textual instructions for the preservation or transport of the specimen. For instance, 'Protect from light exposure'.
1722         */
1723        public SpecimenDefinitionTypeTestedHandlingComponent setInstruction(String value) { 
1724          if (Utilities.noString(value))
1725            this.instruction = null;
1726          else {
1727            if (this.instruction == null)
1728              this.instruction = new StringType();
1729            this.instruction.setValue(value);
1730          }
1731          return this;
1732        }
1733
1734        protected void listChildren(List<Property> children) {
1735          super.listChildren(children);
1736          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));
1737          children.add(new Property("temperatureRange", "Range", "The temperature interval for this set of handling instructions.", 0, 1, temperatureRange));
1738          children.add(new Property("maxDuration", "Duration", "The maximum time interval of preservation of the specimen with these conditions.", 0, 1, maxDuration));
1739          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));
1740        }
1741
1742        @Override
1743        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1744          switch (_hash) {
1745          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);
1746          case -39203799: /*temperatureRange*/  return new Property("temperatureRange", "Range", "The temperature interval for this set of handling instructions.", 0, 1, temperatureRange);
1747          case 40284952: /*maxDuration*/  return new Property("maxDuration", "Duration", "The maximum time interval of preservation of the specimen with these conditions.", 0, 1, maxDuration);
1748          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);
1749          default: return super.getNamedProperty(_hash, _name, _checkValid);
1750          }
1751
1752        }
1753
1754      @Override
1755      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1756        switch (hash) {
1757        case 548941206: /*temperatureQualifier*/ return this.temperatureQualifier == null ? new Base[0] : new Base[] {this.temperatureQualifier}; // CodeableConcept
1758        case -39203799: /*temperatureRange*/ return this.temperatureRange == null ? new Base[0] : new Base[] {this.temperatureRange}; // Range
1759        case 40284952: /*maxDuration*/ return this.maxDuration == null ? new Base[0] : new Base[] {this.maxDuration}; // Duration
1760        case 301526158: /*instruction*/ return this.instruction == null ? new Base[0] : new Base[] {this.instruction}; // StringType
1761        default: return super.getProperty(hash, name, checkValid);
1762        }
1763
1764      }
1765
1766      @Override
1767      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1768        switch (hash) {
1769        case 548941206: // temperatureQualifier
1770          this.temperatureQualifier = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1771          return value;
1772        case -39203799: // temperatureRange
1773          this.temperatureRange = TypeConvertor.castToRange(value); // Range
1774          return value;
1775        case 40284952: // maxDuration
1776          this.maxDuration = TypeConvertor.castToDuration(value); // Duration
1777          return value;
1778        case 301526158: // instruction
1779          this.instruction = TypeConvertor.castToString(value); // StringType
1780          return value;
1781        default: return super.setProperty(hash, name, value);
1782        }
1783
1784      }
1785
1786      @Override
1787      public Base setProperty(String name, Base value) throws FHIRException {
1788        if (name.equals("temperatureQualifier")) {
1789          this.temperatureQualifier = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1790        } else if (name.equals("temperatureRange")) {
1791          this.temperatureRange = TypeConvertor.castToRange(value); // Range
1792        } else if (name.equals("maxDuration")) {
1793          this.maxDuration = TypeConvertor.castToDuration(value); // Duration
1794        } else if (name.equals("instruction")) {
1795          this.instruction = TypeConvertor.castToString(value); // StringType
1796        } else
1797          return super.setProperty(name, value);
1798        return value;
1799      }
1800
1801      @Override
1802      public Base makeProperty(int hash, String name) throws FHIRException {
1803        switch (hash) {
1804        case 548941206:  return getTemperatureQualifier();
1805        case -39203799:  return getTemperatureRange();
1806        case 40284952:  return getMaxDuration();
1807        case 301526158:  return getInstructionElement();
1808        default: return super.makeProperty(hash, name);
1809        }
1810
1811      }
1812
1813      @Override
1814      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1815        switch (hash) {
1816        case 548941206: /*temperatureQualifier*/ return new String[] {"CodeableConcept"};
1817        case -39203799: /*temperatureRange*/ return new String[] {"Range"};
1818        case 40284952: /*maxDuration*/ return new String[] {"Duration"};
1819        case 301526158: /*instruction*/ return new String[] {"string"};
1820        default: return super.getTypesForProperty(hash, name);
1821        }
1822
1823      }
1824
1825      @Override
1826      public Base addChild(String name) throws FHIRException {
1827        if (name.equals("temperatureQualifier")) {
1828          this.temperatureQualifier = new CodeableConcept();
1829          return this.temperatureQualifier;
1830        }
1831        else if (name.equals("temperatureRange")) {
1832          this.temperatureRange = new Range();
1833          return this.temperatureRange;
1834        }
1835        else if (name.equals("maxDuration")) {
1836          this.maxDuration = new Duration();
1837          return this.maxDuration;
1838        }
1839        else if (name.equals("instruction")) {
1840          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.typeTested.handling.instruction");
1841        }
1842        else
1843          return super.addChild(name);
1844      }
1845
1846      public SpecimenDefinitionTypeTestedHandlingComponent copy() {
1847        SpecimenDefinitionTypeTestedHandlingComponent dst = new SpecimenDefinitionTypeTestedHandlingComponent();
1848        copyValues(dst);
1849        return dst;
1850      }
1851
1852      public void copyValues(SpecimenDefinitionTypeTestedHandlingComponent dst) {
1853        super.copyValues(dst);
1854        dst.temperatureQualifier = temperatureQualifier == null ? null : temperatureQualifier.copy();
1855        dst.temperatureRange = temperatureRange == null ? null : temperatureRange.copy();
1856        dst.maxDuration = maxDuration == null ? null : maxDuration.copy();
1857        dst.instruction = instruction == null ? null : instruction.copy();
1858      }
1859
1860      @Override
1861      public boolean equalsDeep(Base other_) {
1862        if (!super.equalsDeep(other_))
1863          return false;
1864        if (!(other_ instanceof SpecimenDefinitionTypeTestedHandlingComponent))
1865          return false;
1866        SpecimenDefinitionTypeTestedHandlingComponent o = (SpecimenDefinitionTypeTestedHandlingComponent) other_;
1867        return compareDeep(temperatureQualifier, o.temperatureQualifier, true) && compareDeep(temperatureRange, o.temperatureRange, true)
1868           && compareDeep(maxDuration, o.maxDuration, true) && compareDeep(instruction, o.instruction, true)
1869          ;
1870      }
1871
1872      @Override
1873      public boolean equalsShallow(Base other_) {
1874        if (!super.equalsShallow(other_))
1875          return false;
1876        if (!(other_ instanceof SpecimenDefinitionTypeTestedHandlingComponent))
1877          return false;
1878        SpecimenDefinitionTypeTestedHandlingComponent o = (SpecimenDefinitionTypeTestedHandlingComponent) other_;
1879        return compareValues(instruction, o.instruction, true);
1880      }
1881
1882      public boolean isEmpty() {
1883        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(temperatureQualifier, temperatureRange
1884          , maxDuration, instruction);
1885      }
1886
1887  public String fhirType() {
1888    return "SpecimenDefinition.typeTested.handling";
1889
1890  }
1891
1892  }
1893
1894    /**
1895     * A business identifier associated with the kind of specimen.
1896     */
1897    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=1, modifier=false, summary=true)
1898    @Description(shortDefinition="Business identifier of a kind of specimen", formalDefinition="A business identifier associated with the kind of specimen." )
1899    protected Identifier identifier;
1900
1901    /**
1902     * The kind of material to be collected.
1903     */
1904    @Child(name = "typeCollected", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
1905    @Description(shortDefinition="Kind of material to collect", formalDefinition="The kind of material to be collected." )
1906    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://terminology.hl7.org/ValueSet/v2-0487")
1907    protected CodeableConcept typeCollected;
1908
1909    /**
1910     * Preparation of the patient for specimen collection.
1911     */
1912    @Child(name = "patientPreparation", type = {CodeableConcept.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1913    @Description(shortDefinition="Patient preparation for collection", formalDefinition="Preparation of the patient for specimen collection." )
1914    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/prepare-patient-prior-specimen-collection")
1915    protected List<CodeableConcept> patientPreparation;
1916
1917    /**
1918     * Time aspect of specimen collection (duration or offset).
1919     */
1920    @Child(name = "timeAspect", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true)
1921    @Description(shortDefinition="Time aspect for collection", formalDefinition="Time aspect of specimen collection (duration or offset)." )
1922    protected StringType timeAspect;
1923
1924    /**
1925     * The action to be performed for collecting the specimen.
1926     */
1927    @Child(name = "collection", type = {CodeableConcept.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1928    @Description(shortDefinition="Specimen collection procedure", formalDefinition="The action to be performed for collecting the specimen." )
1929    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/specimen-collection")
1930    protected List<CodeableConcept> collection;
1931
1932    /**
1933     * Specimen conditioned in a container as expected by the testing laboratory.
1934     */
1935    @Child(name = "typeTested", type = {}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1936    @Description(shortDefinition="Specimen in container intended for testing by lab", formalDefinition="Specimen conditioned in a container as expected by the testing laboratory." )
1937    protected List<SpecimenDefinitionTypeTestedComponent> typeTested;
1938
1939    private static final long serialVersionUID = -330188872L;
1940
1941  /**
1942   * Constructor
1943   */
1944    public SpecimenDefinition() {
1945      super();
1946    }
1947
1948    /**
1949     * @return {@link #identifier} (A business identifier associated with the kind of specimen.)
1950     */
1951    public Identifier getIdentifier() { 
1952      if (this.identifier == null)
1953        if (Configuration.errorOnAutoCreate())
1954          throw new Error("Attempt to auto-create SpecimenDefinition.identifier");
1955        else if (Configuration.doAutoCreate())
1956          this.identifier = new Identifier(); // cc
1957      return this.identifier;
1958    }
1959
1960    public boolean hasIdentifier() { 
1961      return this.identifier != null && !this.identifier.isEmpty();
1962    }
1963
1964    /**
1965     * @param value {@link #identifier} (A business identifier associated with the kind of specimen.)
1966     */
1967    public SpecimenDefinition setIdentifier(Identifier value) { 
1968      this.identifier = value;
1969      return this;
1970    }
1971
1972    /**
1973     * @return {@link #typeCollected} (The kind of material to be collected.)
1974     */
1975    public CodeableConcept getTypeCollected() { 
1976      if (this.typeCollected == null)
1977        if (Configuration.errorOnAutoCreate())
1978          throw new Error("Attempt to auto-create SpecimenDefinition.typeCollected");
1979        else if (Configuration.doAutoCreate())
1980          this.typeCollected = new CodeableConcept(); // cc
1981      return this.typeCollected;
1982    }
1983
1984    public boolean hasTypeCollected() { 
1985      return this.typeCollected != null && !this.typeCollected.isEmpty();
1986    }
1987
1988    /**
1989     * @param value {@link #typeCollected} (The kind of material to be collected.)
1990     */
1991    public SpecimenDefinition setTypeCollected(CodeableConcept value) { 
1992      this.typeCollected = value;
1993      return this;
1994    }
1995
1996    /**
1997     * @return {@link #patientPreparation} (Preparation of the patient for specimen collection.)
1998     */
1999    public List<CodeableConcept> getPatientPreparation() { 
2000      if (this.patientPreparation == null)
2001        this.patientPreparation = new ArrayList<CodeableConcept>();
2002      return this.patientPreparation;
2003    }
2004
2005    /**
2006     * @return Returns a reference to <code>this</code> for easy method chaining
2007     */
2008    public SpecimenDefinition setPatientPreparation(List<CodeableConcept> thePatientPreparation) { 
2009      this.patientPreparation = thePatientPreparation;
2010      return this;
2011    }
2012
2013    public boolean hasPatientPreparation() { 
2014      if (this.patientPreparation == null)
2015        return false;
2016      for (CodeableConcept item : this.patientPreparation)
2017        if (!item.isEmpty())
2018          return true;
2019      return false;
2020    }
2021
2022    public CodeableConcept addPatientPreparation() { //3
2023      CodeableConcept t = new CodeableConcept();
2024      if (this.patientPreparation == null)
2025        this.patientPreparation = new ArrayList<CodeableConcept>();
2026      this.patientPreparation.add(t);
2027      return t;
2028    }
2029
2030    public SpecimenDefinition addPatientPreparation(CodeableConcept t) { //3
2031      if (t == null)
2032        return this;
2033      if (this.patientPreparation == null)
2034        this.patientPreparation = new ArrayList<CodeableConcept>();
2035      this.patientPreparation.add(t);
2036      return this;
2037    }
2038
2039    /**
2040     * @return The first repetition of repeating field {@link #patientPreparation}, creating it if it does not already exist {3}
2041     */
2042    public CodeableConcept getPatientPreparationFirstRep() { 
2043      if (getPatientPreparation().isEmpty()) {
2044        addPatientPreparation();
2045      }
2046      return getPatientPreparation().get(0);
2047    }
2048
2049    /**
2050     * @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
2051     */
2052    public StringType getTimeAspectElement() { 
2053      if (this.timeAspect == null)
2054        if (Configuration.errorOnAutoCreate())
2055          throw new Error("Attempt to auto-create SpecimenDefinition.timeAspect");
2056        else if (Configuration.doAutoCreate())
2057          this.timeAspect = new StringType(); // bb
2058      return this.timeAspect;
2059    }
2060
2061    public boolean hasTimeAspectElement() { 
2062      return this.timeAspect != null && !this.timeAspect.isEmpty();
2063    }
2064
2065    public boolean hasTimeAspect() { 
2066      return this.timeAspect != null && !this.timeAspect.isEmpty();
2067    }
2068
2069    /**
2070     * @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
2071     */
2072    public SpecimenDefinition setTimeAspectElement(StringType value) { 
2073      this.timeAspect = value;
2074      return this;
2075    }
2076
2077    /**
2078     * @return Time aspect of specimen collection (duration or offset).
2079     */
2080    public String getTimeAspect() { 
2081      return this.timeAspect == null ? null : this.timeAspect.getValue();
2082    }
2083
2084    /**
2085     * @param value Time aspect of specimen collection (duration or offset).
2086     */
2087    public SpecimenDefinition setTimeAspect(String value) { 
2088      if (Utilities.noString(value))
2089        this.timeAspect = null;
2090      else {
2091        if (this.timeAspect == null)
2092          this.timeAspect = new StringType();
2093        this.timeAspect.setValue(value);
2094      }
2095      return this;
2096    }
2097
2098    /**
2099     * @return {@link #collection} (The action to be performed for collecting the specimen.)
2100     */
2101    public List<CodeableConcept> getCollection() { 
2102      if (this.collection == null)
2103        this.collection = new ArrayList<CodeableConcept>();
2104      return this.collection;
2105    }
2106
2107    /**
2108     * @return Returns a reference to <code>this</code> for easy method chaining
2109     */
2110    public SpecimenDefinition setCollection(List<CodeableConcept> theCollection) { 
2111      this.collection = theCollection;
2112      return this;
2113    }
2114
2115    public boolean hasCollection() { 
2116      if (this.collection == null)
2117        return false;
2118      for (CodeableConcept item : this.collection)
2119        if (!item.isEmpty())
2120          return true;
2121      return false;
2122    }
2123
2124    public CodeableConcept addCollection() { //3
2125      CodeableConcept t = new CodeableConcept();
2126      if (this.collection == null)
2127        this.collection = new ArrayList<CodeableConcept>();
2128      this.collection.add(t);
2129      return t;
2130    }
2131
2132    public SpecimenDefinition addCollection(CodeableConcept t) { //3
2133      if (t == null)
2134        return this;
2135      if (this.collection == null)
2136        this.collection = new ArrayList<CodeableConcept>();
2137      this.collection.add(t);
2138      return this;
2139    }
2140
2141    /**
2142     * @return The first repetition of repeating field {@link #collection}, creating it if it does not already exist {3}
2143     */
2144    public CodeableConcept getCollectionFirstRep() { 
2145      if (getCollection().isEmpty()) {
2146        addCollection();
2147      }
2148      return getCollection().get(0);
2149    }
2150
2151    /**
2152     * @return {@link #typeTested} (Specimen conditioned in a container as expected by the testing laboratory.)
2153     */
2154    public List<SpecimenDefinitionTypeTestedComponent> getTypeTested() { 
2155      if (this.typeTested == null)
2156        this.typeTested = new ArrayList<SpecimenDefinitionTypeTestedComponent>();
2157      return this.typeTested;
2158    }
2159
2160    /**
2161     * @return Returns a reference to <code>this</code> for easy method chaining
2162     */
2163    public SpecimenDefinition setTypeTested(List<SpecimenDefinitionTypeTestedComponent> theTypeTested) { 
2164      this.typeTested = theTypeTested;
2165      return this;
2166    }
2167
2168    public boolean hasTypeTested() { 
2169      if (this.typeTested == null)
2170        return false;
2171      for (SpecimenDefinitionTypeTestedComponent item : this.typeTested)
2172        if (!item.isEmpty())
2173          return true;
2174      return false;
2175    }
2176
2177    public SpecimenDefinitionTypeTestedComponent addTypeTested() { //3
2178      SpecimenDefinitionTypeTestedComponent t = new SpecimenDefinitionTypeTestedComponent();
2179      if (this.typeTested == null)
2180        this.typeTested = new ArrayList<SpecimenDefinitionTypeTestedComponent>();
2181      this.typeTested.add(t);
2182      return t;
2183    }
2184
2185    public SpecimenDefinition addTypeTested(SpecimenDefinitionTypeTestedComponent t) { //3
2186      if (t == null)
2187        return this;
2188      if (this.typeTested == null)
2189        this.typeTested = new ArrayList<SpecimenDefinitionTypeTestedComponent>();
2190      this.typeTested.add(t);
2191      return this;
2192    }
2193
2194    /**
2195     * @return The first repetition of repeating field {@link #typeTested}, creating it if it does not already exist {3}
2196     */
2197    public SpecimenDefinitionTypeTestedComponent getTypeTestedFirstRep() { 
2198      if (getTypeTested().isEmpty()) {
2199        addTypeTested();
2200      }
2201      return getTypeTested().get(0);
2202    }
2203
2204      protected void listChildren(List<Property> children) {
2205        super.listChildren(children);
2206        children.add(new Property("identifier", "Identifier", "A business identifier associated with the kind of specimen.", 0, 1, identifier));
2207        children.add(new Property("typeCollected", "CodeableConcept", "The kind of material to be collected.", 0, 1, typeCollected));
2208        children.add(new Property("patientPreparation", "CodeableConcept", "Preparation of the patient for specimen collection.", 0, java.lang.Integer.MAX_VALUE, patientPreparation));
2209        children.add(new Property("timeAspect", "string", "Time aspect of specimen collection (duration or offset).", 0, 1, timeAspect));
2210        children.add(new Property("collection", "CodeableConcept", "The action to be performed for collecting the specimen.", 0, java.lang.Integer.MAX_VALUE, collection));
2211        children.add(new Property("typeTested", "", "Specimen conditioned in a container as expected by the testing laboratory.", 0, java.lang.Integer.MAX_VALUE, typeTested));
2212      }
2213
2214      @Override
2215      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2216        switch (_hash) {
2217        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "A business identifier associated with the kind of specimen.", 0, 1, identifier);
2218        case 588504367: /*typeCollected*/  return new Property("typeCollected", "CodeableConcept", "The kind of material to be collected.", 0, 1, typeCollected);
2219        case -879411630: /*patientPreparation*/  return new Property("patientPreparation", "CodeableConcept", "Preparation of the patient for specimen collection.", 0, java.lang.Integer.MAX_VALUE, patientPreparation);
2220        case 276972933: /*timeAspect*/  return new Property("timeAspect", "string", "Time aspect of specimen collection (duration or offset).", 0, 1, timeAspect);
2221        case -1741312354: /*collection*/  return new Property("collection", "CodeableConcept", "The action to be performed for collecting the specimen.", 0, java.lang.Integer.MAX_VALUE, collection);
2222        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);
2223        default: return super.getNamedProperty(_hash, _name, _checkValid);
2224        }
2225
2226      }
2227
2228      @Override
2229      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2230        switch (hash) {
2231        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : new Base[] {this.identifier}; // Identifier
2232        case 588504367: /*typeCollected*/ return this.typeCollected == null ? new Base[0] : new Base[] {this.typeCollected}; // CodeableConcept
2233        case -879411630: /*patientPreparation*/ return this.patientPreparation == null ? new Base[0] : this.patientPreparation.toArray(new Base[this.patientPreparation.size()]); // CodeableConcept
2234        case 276972933: /*timeAspect*/ return this.timeAspect == null ? new Base[0] : new Base[] {this.timeAspect}; // StringType
2235        case -1741312354: /*collection*/ return this.collection == null ? new Base[0] : this.collection.toArray(new Base[this.collection.size()]); // CodeableConcept
2236        case -1407902581: /*typeTested*/ return this.typeTested == null ? new Base[0] : this.typeTested.toArray(new Base[this.typeTested.size()]); // SpecimenDefinitionTypeTestedComponent
2237        default: return super.getProperty(hash, name, checkValid);
2238        }
2239
2240      }
2241
2242      @Override
2243      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2244        switch (hash) {
2245        case -1618432855: // identifier
2246          this.identifier = TypeConvertor.castToIdentifier(value); // Identifier
2247          return value;
2248        case 588504367: // typeCollected
2249          this.typeCollected = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
2250          return value;
2251        case -879411630: // patientPreparation
2252          this.getPatientPreparation().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
2253          return value;
2254        case 276972933: // timeAspect
2255          this.timeAspect = TypeConvertor.castToString(value); // StringType
2256          return value;
2257        case -1741312354: // collection
2258          this.getCollection().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
2259          return value;
2260        case -1407902581: // typeTested
2261          this.getTypeTested().add((SpecimenDefinitionTypeTestedComponent) value); // SpecimenDefinitionTypeTestedComponent
2262          return value;
2263        default: return super.setProperty(hash, name, value);
2264        }
2265
2266      }
2267
2268      @Override
2269      public Base setProperty(String name, Base value) throws FHIRException {
2270        if (name.equals("identifier")) {
2271          this.identifier = TypeConvertor.castToIdentifier(value); // Identifier
2272        } else if (name.equals("typeCollected")) {
2273          this.typeCollected = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
2274        } else if (name.equals("patientPreparation")) {
2275          this.getPatientPreparation().add(TypeConvertor.castToCodeableConcept(value));
2276        } else if (name.equals("timeAspect")) {
2277          this.timeAspect = TypeConvertor.castToString(value); // StringType
2278        } else if (name.equals("collection")) {
2279          this.getCollection().add(TypeConvertor.castToCodeableConcept(value));
2280        } else if (name.equals("typeTested")) {
2281          this.getTypeTested().add((SpecimenDefinitionTypeTestedComponent) value);
2282        } else
2283          return super.setProperty(name, value);
2284        return value;
2285      }
2286
2287      @Override
2288      public Base makeProperty(int hash, String name) throws FHIRException {
2289        switch (hash) {
2290        case -1618432855:  return getIdentifier();
2291        case 588504367:  return getTypeCollected();
2292        case -879411630:  return addPatientPreparation(); 
2293        case 276972933:  return getTimeAspectElement();
2294        case -1741312354:  return addCollection(); 
2295        case -1407902581:  return addTypeTested(); 
2296        default: return super.makeProperty(hash, name);
2297        }
2298
2299      }
2300
2301      @Override
2302      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2303        switch (hash) {
2304        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
2305        case 588504367: /*typeCollected*/ return new String[] {"CodeableConcept"};
2306        case -879411630: /*patientPreparation*/ return new String[] {"CodeableConcept"};
2307        case 276972933: /*timeAspect*/ return new String[] {"string"};
2308        case -1741312354: /*collection*/ return new String[] {"CodeableConcept"};
2309        case -1407902581: /*typeTested*/ return new String[] {};
2310        default: return super.getTypesForProperty(hash, name);
2311        }
2312
2313      }
2314
2315      @Override
2316      public Base addChild(String name) throws FHIRException {
2317        if (name.equals("identifier")) {
2318          this.identifier = new Identifier();
2319          return this.identifier;
2320        }
2321        else if (name.equals("typeCollected")) {
2322          this.typeCollected = new CodeableConcept();
2323          return this.typeCollected;
2324        }
2325        else if (name.equals("patientPreparation")) {
2326          return addPatientPreparation();
2327        }
2328        else if (name.equals("timeAspect")) {
2329          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.timeAspect");
2330        }
2331        else if (name.equals("collection")) {
2332          return addCollection();
2333        }
2334        else if (name.equals("typeTested")) {
2335          return addTypeTested();
2336        }
2337        else
2338          return super.addChild(name);
2339      }
2340
2341  public String fhirType() {
2342    return "SpecimenDefinition";
2343
2344  }
2345
2346      public SpecimenDefinition copy() {
2347        SpecimenDefinition dst = new SpecimenDefinition();
2348        copyValues(dst);
2349        return dst;
2350      }
2351
2352      public void copyValues(SpecimenDefinition dst) {
2353        super.copyValues(dst);
2354        dst.identifier = identifier == null ? null : identifier.copy();
2355        dst.typeCollected = typeCollected == null ? null : typeCollected.copy();
2356        if (patientPreparation != null) {
2357          dst.patientPreparation = new ArrayList<CodeableConcept>();
2358          for (CodeableConcept i : patientPreparation)
2359            dst.patientPreparation.add(i.copy());
2360        };
2361        dst.timeAspect = timeAspect == null ? null : timeAspect.copy();
2362        if (collection != null) {
2363          dst.collection = new ArrayList<CodeableConcept>();
2364          for (CodeableConcept i : collection)
2365            dst.collection.add(i.copy());
2366        };
2367        if (typeTested != null) {
2368          dst.typeTested = new ArrayList<SpecimenDefinitionTypeTestedComponent>();
2369          for (SpecimenDefinitionTypeTestedComponent i : typeTested)
2370            dst.typeTested.add(i.copy());
2371        };
2372      }
2373
2374      protected SpecimenDefinition typedCopy() {
2375        return copy();
2376      }
2377
2378      @Override
2379      public boolean equalsDeep(Base other_) {
2380        if (!super.equalsDeep(other_))
2381          return false;
2382        if (!(other_ instanceof SpecimenDefinition))
2383          return false;
2384        SpecimenDefinition o = (SpecimenDefinition) other_;
2385        return compareDeep(identifier, o.identifier, true) && compareDeep(typeCollected, o.typeCollected, true)
2386           && compareDeep(patientPreparation, o.patientPreparation, true) && compareDeep(timeAspect, o.timeAspect, true)
2387           && compareDeep(collection, o.collection, true) && compareDeep(typeTested, o.typeTested, true);
2388      }
2389
2390      @Override
2391      public boolean equalsShallow(Base other_) {
2392        if (!super.equalsShallow(other_))
2393          return false;
2394        if (!(other_ instanceof SpecimenDefinition))
2395          return false;
2396        SpecimenDefinition o = (SpecimenDefinition) other_;
2397        return compareValues(timeAspect, o.timeAspect, true);
2398      }
2399
2400      public boolean isEmpty() {
2401        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, typeCollected
2402          , patientPreparation, timeAspect, collection, typeTested);
2403      }
2404
2405  @Override
2406  public ResourceType getResourceType() {
2407    return ResourceType.SpecimenDefinition;
2408   }
2409
2410 /**
2411   * Search parameter: <b>container</b>
2412   * <p>
2413   * Description: <b>The type of specimen conditioned in container expected by the lab</b><br>
2414   * Type: <b>token</b><br>
2415   * Path: <b>SpecimenDefinition.typeTested.container.type</b><br>
2416   * </p>
2417   */
2418  @SearchParamDefinition(name="container", path="SpecimenDefinition.typeTested.container.type", description="The type of specimen conditioned in container expected by the lab", type="token" )
2419  public static final String SP_CONTAINER = "container";
2420 /**
2421   * <b>Fluent Client</b> search parameter constant for <b>container</b>
2422   * <p>
2423   * Description: <b>The type of specimen conditioned in container expected by the lab</b><br>
2424   * Type: <b>token</b><br>
2425   * Path: <b>SpecimenDefinition.typeTested.container.type</b><br>
2426   * </p>
2427   */
2428  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CONTAINER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CONTAINER);
2429
2430 /**
2431   * Search parameter: <b>identifier</b>
2432   * <p>
2433   * Description: <b>The unique identifier associated with the specimen</b><br>
2434   * Type: <b>token</b><br>
2435   * Path: <b>SpecimenDefinition.identifier</b><br>
2436   * </p>
2437   */
2438  @SearchParamDefinition(name="identifier", path="SpecimenDefinition.identifier", description="The unique identifier associated with the specimen", type="token" )
2439  public static final String SP_IDENTIFIER = "identifier";
2440 /**
2441   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2442   * <p>
2443   * Description: <b>The unique identifier associated with the specimen</b><br>
2444   * Type: <b>token</b><br>
2445   * Path: <b>SpecimenDefinition.identifier</b><br>
2446   * </p>
2447   */
2448  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
2449
2450 /**
2451   * Search parameter: <b>type</b>
2452   * <p>
2453   * Description: <b>The type of collected specimen</b><br>
2454   * Type: <b>token</b><br>
2455   * Path: <b>SpecimenDefinition.typeCollected</b><br>
2456   * </p>
2457   */
2458  @SearchParamDefinition(name="type", path="SpecimenDefinition.typeCollected", description="The type of collected specimen", type="token" )
2459  public static final String SP_TYPE = "type";
2460 /**
2461   * <b>Fluent Client</b> search parameter constant for <b>type</b>
2462   * <p>
2463   * Description: <b>The type of collected specimen</b><br>
2464   * Type: <b>token</b><br>
2465   * Path: <b>SpecimenDefinition.typeCollected</b><br>
2466   * </p>
2467   */
2468  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_TYPE);
2469
2470
2471}
2472