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