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