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