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