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