001package org.hl7.fhir.r5.model;
002
003
004/*
005  Copyright (c) 2011+, HL7, Inc.
006  All rights reserved.
007  
008  Redistribution and use in source and binary forms, with or without modification, \
009  are permitted provided that the following conditions are met:
010  
011   * Redistributions of source code must retain the above copyright notice, this \
012     list of conditions and the following disclaimer.
013   * Redistributions in binary form must reproduce the above copyright notice, \
014     this list of conditions and the following disclaimer in the documentation \
015     and/or other materials provided with the distribution.
016   * Neither the name of HL7 nor the names of its contributors may be used to 
017     endorse or promote products derived from this software without specific 
018     prior written permission.
019  
020  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
021  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
022  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
023  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
024  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
025  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
026  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
027  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
028  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
029  POSSIBILITY OF SUCH DAMAGE.
030  */
031
032// Generated on Tue, Dec 28, 2021 07:16+1100 for FHIR v5.0.0-snapshot1
033
034import java.util.ArrayList;
035import java.util.Date;
036import java.util.List;
037import org.hl7.fhir.utilities.Utilities;
038import org.hl7.fhir.r5.model.Enumerations.*;
039import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
040import org.hl7.fhir.exceptions.FHIRException;
041import org.hl7.fhir.instance.model.api.ICompositeType;
042import ca.uhn.fhir.model.api.annotation.ResourceDef;
043import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
044import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
045import ca.uhn.fhir.model.api.annotation.Child;
046import ca.uhn.fhir.model.api.annotation.ChildOrder;
047import ca.uhn.fhir.model.api.annotation.Description;
048import ca.uhn.fhir.model.api.annotation.Block;
049
050/**
051 * A kind of specimen with associated set of requirements.
052 */
053@ResourceDef(name="SpecimenDefinition", profile="http://hl7.org/fhir/StructureDefinition/SpecimenDefinition")
054public class SpecimenDefinition extends DomainResource {
055
056    public enum SpecimenContainedPreference {
057        /**
058         * This type of contained specimen is preferred to collect this kind of specimen.
059         */
060        PREFERRED, 
061        /**
062         * This type of conditioned specimen is an alternate.
063         */
064        ALTERNATE, 
065        /**
066         * added to help the parsers with the generic types
067         */
068        NULL;
069        public static SpecimenContainedPreference fromCode(String codeString) throws FHIRException {
070            if (codeString == null || "".equals(codeString))
071                return null;
072        if ("preferred".equals(codeString))
073          return PREFERRED;
074        if ("alternate".equals(codeString))
075          return ALTERNATE;
076        if (Configuration.isAcceptInvalidEnums())
077          return null;
078        else
079          throw new FHIRException("Unknown SpecimenContainedPreference code '"+codeString+"'");
080        }
081        public String toCode() {
082          switch (this) {
083            case PREFERRED: return "preferred";
084            case ALTERNATE: return "alternate";
085            default: return "?";
086          }
087        }
088        public String getSystem() {
089          switch (this) {
090            case PREFERRED: return "http://hl7.org/fhir/specimen-contained-preference";
091            case ALTERNATE: return "http://hl7.org/fhir/specimen-contained-preference";
092            default: return "?";
093          }
094        }
095        public String getDefinition() {
096          switch (this) {
097            case PREFERRED: return "This type of contained specimen is preferred to collect this kind of specimen.";
098            case ALTERNATE: return "This type of conditioned specimen is an alternate.";
099            default: return "?";
100          }
101        }
102        public String getDisplay() {
103          switch (this) {
104            case PREFERRED: return "Preferred";
105            case ALTERNATE: return "Alternate";
106            default: return "?";
107          }
108        }
109    }
110
111  public static class SpecimenContainedPreferenceEnumFactory implements EnumFactory<SpecimenContainedPreference> {
112    public SpecimenContainedPreference fromCode(String codeString) throws IllegalArgumentException {
113      if (codeString == null || "".equals(codeString))
114            if (codeString == null || "".equals(codeString))
115                return null;
116        if ("preferred".equals(codeString))
117          return SpecimenContainedPreference.PREFERRED;
118        if ("alternate".equals(codeString))
119          return SpecimenContainedPreference.ALTERNATE;
120        throw new IllegalArgumentException("Unknown SpecimenContainedPreference code '"+codeString+"'");
121        }
122        public Enumeration<SpecimenContainedPreference> fromType(Base code) throws FHIRException {
123          if (code == null)
124            return null;
125          if (code.isEmpty())
126            return new Enumeration<SpecimenContainedPreference>(this);
127          String codeString = ((PrimitiveType) code).asStringValue();
128          if (codeString == null || "".equals(codeString))
129            return null;
130        if ("preferred".equals(codeString))
131          return new Enumeration<SpecimenContainedPreference>(this, SpecimenContainedPreference.PREFERRED);
132        if ("alternate".equals(codeString))
133          return new Enumeration<SpecimenContainedPreference>(this, SpecimenContainedPreference.ALTERNATE);
134        throw new FHIRException("Unknown SpecimenContainedPreference code '"+codeString+"'");
135        }
136    public String toCode(SpecimenContainedPreference code) {
137      if (code == SpecimenContainedPreference.PREFERRED)
138        return "preferred";
139      if (code == SpecimenContainedPreference.ALTERNATE)
140        return "alternate";
141      return "?";
142      }
143    public String toSystem(SpecimenContainedPreference code) {
144      return code.getSystem();
145      }
146    }
147
148    @Block()
149    public static class SpecimenDefinitionTypeTestedComponent extends BackboneElement implements IBaseBackboneElement {
150        /**
151         * Primary of secondary specimen.
152         */
153        @Child(name = "isDerived", type = {BooleanType.class}, order=1, min=0, max=1, modifier=false, summary=false)
154        @Description(shortDefinition="Primary or secondary specimen", formalDefinition="Primary of secondary specimen." )
155        protected BooleanType isDerived;
156
157        /**
158         * The kind of specimen conditioned for testing expected by lab.
159         */
160        @Child(name = "type", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
161        @Description(shortDefinition="Type of intended specimen", formalDefinition="The kind of specimen conditioned for testing expected by lab." )
162        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://terminology.hl7.org/ValueSet/v2-0487")
163        protected CodeableConcept type;
164
165        /**
166         * The preference for this type of conditioned specimen.
167         */
168        @Child(name = "preference", type = {CodeType.class}, order=3, min=1, max=1, modifier=false, summary=false)
169        @Description(shortDefinition="preferred | alternate", formalDefinition="The preference for this type of conditioned specimen." )
170        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/specimen-contained-preference")
171        protected Enumeration<SpecimenContainedPreference> preference;
172
173        /**
174         * The specimen's container.
175         */
176        @Child(name = "container", type = {}, order=4, min=0, max=1, modifier=false, summary=false)
177        @Description(shortDefinition="The specimen's container", formalDefinition="The specimen's container." )
178        protected SpecimenDefinitionTypeTestedContainerComponent container;
179
180        /**
181         * Requirements for delivery and special handling of this kind of conditioned specimen.
182         */
183        @Child(name = "requirement", type = {StringType.class}, order=5, min=0, max=1, modifier=false, summary=false)
184        @Description(shortDefinition="Requirements for specimen delivery and special handling", formalDefinition="Requirements for delivery and special handling of this kind of conditioned specimen." )
185        protected StringType requirement;
186
187        /**
188         * The usual time that a specimen of this kind is retained after the ordered tests are completed, for the purpose of additional testing.
189         */
190        @Child(name = "retentionTime", type = {Duration.class}, order=6, min=0, max=1, modifier=false, summary=false)
191        @Description(shortDefinition="The usual time for retaining this kind of specimen", formalDefinition="The usual time that a specimen of this kind is retained after the ordered tests are completed, for the purpose of additional testing." )
192        protected Duration retentionTime;
193
194        /**
195         * Specimen can be used by only one test or panel if the value is "true".
196         */
197        @Child(name = "singleUse", type = {BooleanType.class}, order=7, min=0, max=1, modifier=false, summary=false)
198        @Description(shortDefinition="Specimen for single use only", formalDefinition="Specimen can be used by only one test or panel if the value is \"true\"." )
199        protected BooleanType singleUse;
200
201        /**
202         * Criterion for rejection of the specimen in its container by the laboratory.
203         */
204        @Child(name = "rejectionCriterion", type = {CodeableConcept.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
205        @Description(shortDefinition="Criterion specified for specimen rejection", formalDefinition="Criterion for rejection of the specimen in its container by the laboratory." )
206        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/rejection-criteria")
207        protected List<CodeableConcept> rejectionCriterion;
208
209        /**
210         * Set of instructions for preservation/transport of the specimen at a defined temperature interval, prior the testing process.
211         */
212        @Child(name = "handling", type = {}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
213        @Description(shortDefinition="Specimen handling before testing", formalDefinition="Set of instructions for preservation/transport of the specimen at a defined temperature interval, prior the testing process." )
214        protected List<SpecimenDefinitionTypeTestedHandlingComponent> handling;
215
216        /**
217         * Where the specimen will be tested: e.g., lab, sector, device or any combination of these.
218         */
219        @Child(name = "testingDestination", type = {CodeableConcept.class}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
220        @Description(shortDefinition="Where the specimen will be tested", formalDefinition="Where the specimen will be tested: e.g., lab, sector, device or any combination of these." )
221        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/diagnostic-service-sections")
222        protected List<CodeableConcept> testingDestination;
223
224        private static final long serialVersionUID = 1859673754L;
225
226    /**
227     * Constructor
228     */
229      public SpecimenDefinitionTypeTestedComponent() {
230        super();
231      }
232
233    /**
234     * Constructor
235     */
236      public SpecimenDefinitionTypeTestedComponent(SpecimenContainedPreference preference) {
237        super();
238        this.setPreference(preference);
239      }
240
241        /**
242         * @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
243         */
244        public BooleanType getIsDerivedElement() { 
245          if (this.isDerived == null)
246            if (Configuration.errorOnAutoCreate())
247              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedComponent.isDerived");
248            else if (Configuration.doAutoCreate())
249              this.isDerived = new BooleanType(); // bb
250          return this.isDerived;
251        }
252
253        public boolean hasIsDerivedElement() { 
254          return this.isDerived != null && !this.isDerived.isEmpty();
255        }
256
257        public boolean hasIsDerived() { 
258          return this.isDerived != null && !this.isDerived.isEmpty();
259        }
260
261        /**
262         * @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
263         */
264        public SpecimenDefinitionTypeTestedComponent setIsDerivedElement(BooleanType value) { 
265          this.isDerived = value;
266          return this;
267        }
268
269        /**
270         * @return Primary of secondary specimen.
271         */
272        public boolean getIsDerived() { 
273          return this.isDerived == null || this.isDerived.isEmpty() ? false : this.isDerived.getValue();
274        }
275
276        /**
277         * @param value Primary of secondary specimen.
278         */
279        public SpecimenDefinitionTypeTestedComponent setIsDerived(boolean value) { 
280            if (this.isDerived == null)
281              this.isDerived = new BooleanType();
282            this.isDerived.setValue(value);
283          return this;
284        }
285
286        /**
287         * @return {@link #type} (The kind of specimen conditioned for testing expected by lab.)
288         */
289        public CodeableConcept getType() { 
290          if (this.type == null)
291            if (Configuration.errorOnAutoCreate())
292              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedComponent.type");
293            else if (Configuration.doAutoCreate())
294              this.type = new CodeableConcept(); // cc
295          return this.type;
296        }
297
298        public boolean hasType() { 
299          return this.type != null && !this.type.isEmpty();
300        }
301
302        /**
303         * @param value {@link #type} (The kind of specimen conditioned for testing expected by lab.)
304         */
305        public SpecimenDefinitionTypeTestedComponent setType(CodeableConcept value) { 
306          this.type = value;
307          return this;
308        }
309
310        /**
311         * @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
312         */
313        public Enumeration<SpecimenContainedPreference> getPreferenceElement() { 
314          if (this.preference == null)
315            if (Configuration.errorOnAutoCreate())
316              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedComponent.preference");
317            else if (Configuration.doAutoCreate())
318              this.preference = new Enumeration<SpecimenContainedPreference>(new SpecimenContainedPreferenceEnumFactory()); // bb
319          return this.preference;
320        }
321
322        public boolean hasPreferenceElement() { 
323          return this.preference != null && !this.preference.isEmpty();
324        }
325
326        public boolean hasPreference() { 
327          return this.preference != null && !this.preference.isEmpty();
328        }
329
330        /**
331         * @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
332         */
333        public SpecimenDefinitionTypeTestedComponent setPreferenceElement(Enumeration<SpecimenContainedPreference> value) { 
334          this.preference = value;
335          return this;
336        }
337
338        /**
339         * @return The preference for this type of conditioned specimen.
340         */
341        public SpecimenContainedPreference getPreference() { 
342          return this.preference == null ? null : this.preference.getValue();
343        }
344
345        /**
346         * @param value The preference for this type of conditioned specimen.
347         */
348        public SpecimenDefinitionTypeTestedComponent setPreference(SpecimenContainedPreference value) { 
349            if (this.preference == null)
350              this.preference = new Enumeration<SpecimenContainedPreference>(new SpecimenContainedPreferenceEnumFactory());
351            this.preference.setValue(value);
352          return this;
353        }
354
355        /**
356         * @return {@link #container} (The specimen's container.)
357         */
358        public SpecimenDefinitionTypeTestedContainerComponent getContainer() { 
359          if (this.container == null)
360            if (Configuration.errorOnAutoCreate())
361              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedComponent.container");
362            else if (Configuration.doAutoCreate())
363              this.container = new SpecimenDefinitionTypeTestedContainerComponent(); // cc
364          return this.container;
365        }
366
367        public boolean hasContainer() { 
368          return this.container != null && !this.container.isEmpty();
369        }
370
371        /**
372         * @param value {@link #container} (The specimen's container.)
373         */
374        public SpecimenDefinitionTypeTestedComponent setContainer(SpecimenDefinitionTypeTestedContainerComponent value) { 
375          this.container = value;
376          return this;
377        }
378
379        /**
380         * @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
381         */
382        public StringType getRequirementElement() { 
383          if (this.requirement == null)
384            if (Configuration.errorOnAutoCreate())
385              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedComponent.requirement");
386            else if (Configuration.doAutoCreate())
387              this.requirement = new StringType(); // bb
388          return this.requirement;
389        }
390
391        public boolean hasRequirementElement() { 
392          return this.requirement != null && !this.requirement.isEmpty();
393        }
394
395        public boolean hasRequirement() { 
396          return this.requirement != null && !this.requirement.isEmpty();
397        }
398
399        /**
400         * @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
401         */
402        public SpecimenDefinitionTypeTestedComponent setRequirementElement(StringType value) { 
403          this.requirement = value;
404          return this;
405        }
406
407        /**
408         * @return Requirements for delivery and special handling of this kind of conditioned specimen.
409         */
410        public String getRequirement() { 
411          return this.requirement == null ? null : this.requirement.getValue();
412        }
413
414        /**
415         * @param value Requirements for delivery and special handling of this kind of conditioned specimen.
416         */
417        public SpecimenDefinitionTypeTestedComponent setRequirement(String value) { 
418          if (Utilities.noString(value))
419            this.requirement = null;
420          else {
421            if (this.requirement == null)
422              this.requirement = new StringType();
423            this.requirement.setValue(value);
424          }
425          return this;
426        }
427
428        /**
429         * @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.)
430         */
431        public Duration getRetentionTime() { 
432          if (this.retentionTime == null)
433            if (Configuration.errorOnAutoCreate())
434              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedComponent.retentionTime");
435            else if (Configuration.doAutoCreate())
436              this.retentionTime = new Duration(); // cc
437          return this.retentionTime;
438        }
439
440        public boolean hasRetentionTime() { 
441          return this.retentionTime != null && !this.retentionTime.isEmpty();
442        }
443
444        /**
445         * @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.)
446         */
447        public SpecimenDefinitionTypeTestedComponent setRetentionTime(Duration value) { 
448          this.retentionTime = value;
449          return this;
450        }
451
452        /**
453         * @return {@link #singleUse} (Specimen can be used by only one test or panel if the value is "true".). This is the underlying object with id, value and extensions. The accessor "getSingleUse" gives direct access to the value
454         */
455        public BooleanType getSingleUseElement() { 
456          if (this.singleUse == null)
457            if (Configuration.errorOnAutoCreate())
458              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedComponent.singleUse");
459            else if (Configuration.doAutoCreate())
460              this.singleUse = new BooleanType(); // bb
461          return this.singleUse;
462        }
463
464        public boolean hasSingleUseElement() { 
465          return this.singleUse != null && !this.singleUse.isEmpty();
466        }
467
468        public boolean hasSingleUse() { 
469          return this.singleUse != null && !this.singleUse.isEmpty();
470        }
471
472        /**
473         * @param value {@link #singleUse} (Specimen can be used by only one test or panel if the value is "true".). This is the underlying object with id, value and extensions. The accessor "getSingleUse" gives direct access to the value
474         */
475        public SpecimenDefinitionTypeTestedComponent setSingleUseElement(BooleanType value) { 
476          this.singleUse = value;
477          return this;
478        }
479
480        /**
481         * @return Specimen can be used by only one test or panel if the value is "true".
482         */
483        public boolean getSingleUse() { 
484          return this.singleUse == null || this.singleUse.isEmpty() ? false : this.singleUse.getValue();
485        }
486
487        /**
488         * @param value Specimen can be used by only one test or panel if the value is "true".
489         */
490        public SpecimenDefinitionTypeTestedComponent setSingleUse(boolean value) { 
491            if (this.singleUse == null)
492              this.singleUse = new BooleanType();
493            this.singleUse.setValue(value);
494          return this;
495        }
496
497        /**
498         * @return {@link #rejectionCriterion} (Criterion for rejection of the specimen in its container by the laboratory.)
499         */
500        public List<CodeableConcept> getRejectionCriterion() { 
501          if (this.rejectionCriterion == null)
502            this.rejectionCriterion = new ArrayList<CodeableConcept>();
503          return this.rejectionCriterion;
504        }
505
506        /**
507         * @return Returns a reference to <code>this</code> for easy method chaining
508         */
509        public SpecimenDefinitionTypeTestedComponent setRejectionCriterion(List<CodeableConcept> theRejectionCriterion) { 
510          this.rejectionCriterion = theRejectionCriterion;
511          return this;
512        }
513
514        public boolean hasRejectionCriterion() { 
515          if (this.rejectionCriterion == null)
516            return false;
517          for (CodeableConcept item : this.rejectionCriterion)
518            if (!item.isEmpty())
519              return true;
520          return false;
521        }
522
523        public CodeableConcept addRejectionCriterion() { //3
524          CodeableConcept t = new CodeableConcept();
525          if (this.rejectionCriterion == null)
526            this.rejectionCriterion = new ArrayList<CodeableConcept>();
527          this.rejectionCriterion.add(t);
528          return t;
529        }
530
531        public SpecimenDefinitionTypeTestedComponent addRejectionCriterion(CodeableConcept t) { //3
532          if (t == null)
533            return this;
534          if (this.rejectionCriterion == null)
535            this.rejectionCriterion = new ArrayList<CodeableConcept>();
536          this.rejectionCriterion.add(t);
537          return this;
538        }
539
540        /**
541         * @return The first repetition of repeating field {@link #rejectionCriterion}, creating it if it does not already exist {3}
542         */
543        public CodeableConcept getRejectionCriterionFirstRep() { 
544          if (getRejectionCriterion().isEmpty()) {
545            addRejectionCriterion();
546          }
547          return getRejectionCriterion().get(0);
548        }
549
550        /**
551         * @return {@link #handling} (Set of instructions for preservation/transport of the specimen at a defined temperature interval, prior the testing process.)
552         */
553        public List<SpecimenDefinitionTypeTestedHandlingComponent> getHandling() { 
554          if (this.handling == null)
555            this.handling = new ArrayList<SpecimenDefinitionTypeTestedHandlingComponent>();
556          return this.handling;
557        }
558
559        /**
560         * @return Returns a reference to <code>this</code> for easy method chaining
561         */
562        public SpecimenDefinitionTypeTestedComponent setHandling(List<SpecimenDefinitionTypeTestedHandlingComponent> theHandling) { 
563          this.handling = theHandling;
564          return this;
565        }
566
567        public boolean hasHandling() { 
568          if (this.handling == null)
569            return false;
570          for (SpecimenDefinitionTypeTestedHandlingComponent item : this.handling)
571            if (!item.isEmpty())
572              return true;
573          return false;
574        }
575
576        public SpecimenDefinitionTypeTestedHandlingComponent addHandling() { //3
577          SpecimenDefinitionTypeTestedHandlingComponent t = new SpecimenDefinitionTypeTestedHandlingComponent();
578          if (this.handling == null)
579            this.handling = new ArrayList<SpecimenDefinitionTypeTestedHandlingComponent>();
580          this.handling.add(t);
581          return t;
582        }
583
584        public SpecimenDefinitionTypeTestedComponent addHandling(SpecimenDefinitionTypeTestedHandlingComponent t) { //3
585          if (t == null)
586            return this;
587          if (this.handling == null)
588            this.handling = new ArrayList<SpecimenDefinitionTypeTestedHandlingComponent>();
589          this.handling.add(t);
590          return this;
591        }
592
593        /**
594         * @return The first repetition of repeating field {@link #handling}, creating it if it does not already exist {3}
595         */
596        public SpecimenDefinitionTypeTestedHandlingComponent getHandlingFirstRep() { 
597          if (getHandling().isEmpty()) {
598            addHandling();
599          }
600          return getHandling().get(0);
601        }
602
603        /**
604         * @return {@link #testingDestination} (Where the specimen will be tested: e.g., lab, sector, device or any combination of these.)
605         */
606        public List<CodeableConcept> getTestingDestination() { 
607          if (this.testingDestination == null)
608            this.testingDestination = new ArrayList<CodeableConcept>();
609          return this.testingDestination;
610        }
611
612        /**
613         * @return Returns a reference to <code>this</code> for easy method chaining
614         */
615        public SpecimenDefinitionTypeTestedComponent setTestingDestination(List<CodeableConcept> theTestingDestination) { 
616          this.testingDestination = theTestingDestination;
617          return this;
618        }
619
620        public boolean hasTestingDestination() { 
621          if (this.testingDestination == null)
622            return false;
623          for (CodeableConcept item : this.testingDestination)
624            if (!item.isEmpty())
625              return true;
626          return false;
627        }
628
629        public CodeableConcept addTestingDestination() { //3
630          CodeableConcept t = new CodeableConcept();
631          if (this.testingDestination == null)
632            this.testingDestination = new ArrayList<CodeableConcept>();
633          this.testingDestination.add(t);
634          return t;
635        }
636
637        public SpecimenDefinitionTypeTestedComponent addTestingDestination(CodeableConcept t) { //3
638          if (t == null)
639            return this;
640          if (this.testingDestination == null)
641            this.testingDestination = new ArrayList<CodeableConcept>();
642          this.testingDestination.add(t);
643          return this;
644        }
645
646        /**
647         * @return The first repetition of repeating field {@link #testingDestination}, creating it if it does not already exist {3}
648         */
649        public CodeableConcept getTestingDestinationFirstRep() { 
650          if (getTestingDestination().isEmpty()) {
651            addTestingDestination();
652          }
653          return getTestingDestination().get(0);
654        }
655
656        protected void listChildren(List<Property> children) {
657          super.listChildren(children);
658          children.add(new Property("isDerived", "boolean", "Primary of secondary specimen.", 0, 1, isDerived));
659          children.add(new Property("type", "CodeableConcept", "The kind of specimen conditioned for testing expected by lab.", 0, 1, type));
660          children.add(new Property("preference", "code", "The preference for this type of conditioned specimen.", 0, 1, preference));
661          children.add(new Property("container", "", "The specimen's container.", 0, 1, container));
662          children.add(new Property("requirement", "string", "Requirements for delivery and special handling of this kind of conditioned specimen.", 0, 1, requirement));
663          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));
664          children.add(new Property("singleUse", "boolean", "Specimen can be used by only one test or panel if the value is \"true\".", 0, 1, singleUse));
665          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));
666          children.add(new Property("handling", "", "Set of instructions for preservation/transport of the specimen at a defined temperature interval, prior the testing process.", 0, java.lang.Integer.MAX_VALUE, handling));
667          children.add(new Property("testingDestination", "CodeableConcept", "Where the specimen will be tested: e.g., lab, sector, device or any combination of these.", 0, java.lang.Integer.MAX_VALUE, testingDestination));
668        }
669
670        @Override
671        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
672          switch (_hash) {
673          case 976346515: /*isDerived*/  return new Property("isDerived", "boolean", "Primary of secondary specimen.", 0, 1, isDerived);
674          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "The kind of specimen conditioned for testing expected by lab.", 0, 1, type);
675          case -1459831589: /*preference*/  return new Property("preference", "code", "The preference for this type of conditioned specimen.", 0, 1, preference);
676          case -410956671: /*container*/  return new Property("container", "", "The specimen's container.", 0, 1, container);
677          case 363387971: /*requirement*/  return new Property("requirement", "string", "Requirements for delivery and special handling of this kind of conditioned specimen.", 0, 1, requirement);
678          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);
679          case -1494547425: /*singleUse*/  return new Property("singleUse", "boolean", "Specimen can be used by only one test or panel if the value is \"true\".", 0, 1, singleUse);
680          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);
681          case 2072805: /*handling*/  return new Property("handling", "", "Set of instructions for preservation/transport of the specimen at a defined temperature interval, prior the testing process.", 0, java.lang.Integer.MAX_VALUE, handling);
682          case 939511774: /*testingDestination*/  return new Property("testingDestination", "CodeableConcept", "Where the specimen will be tested: e.g., lab, sector, device or any combination of these.", 0, java.lang.Integer.MAX_VALUE, testingDestination);
683          default: return super.getNamedProperty(_hash, _name, _checkValid);
684          }
685
686        }
687
688      @Override
689      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
690        switch (hash) {
691        case 976346515: /*isDerived*/ return this.isDerived == null ? new Base[0] : new Base[] {this.isDerived}; // BooleanType
692        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
693        case -1459831589: /*preference*/ return this.preference == null ? new Base[0] : new Base[] {this.preference}; // Enumeration<SpecimenContainedPreference>
694        case -410956671: /*container*/ return this.container == null ? new Base[0] : new Base[] {this.container}; // SpecimenDefinitionTypeTestedContainerComponent
695        case 363387971: /*requirement*/ return this.requirement == null ? new Base[0] : new Base[] {this.requirement}; // StringType
696        case 1434969867: /*retentionTime*/ return this.retentionTime == null ? new Base[0] : new Base[] {this.retentionTime}; // Duration
697        case -1494547425: /*singleUse*/ return this.singleUse == null ? new Base[0] : new Base[] {this.singleUse}; // BooleanType
698        case -553706344: /*rejectionCriterion*/ return this.rejectionCriterion == null ? new Base[0] : this.rejectionCriterion.toArray(new Base[this.rejectionCriterion.size()]); // CodeableConcept
699        case 2072805: /*handling*/ return this.handling == null ? new Base[0] : this.handling.toArray(new Base[this.handling.size()]); // SpecimenDefinitionTypeTestedHandlingComponent
700        case 939511774: /*testingDestination*/ return this.testingDestination == null ? new Base[0] : this.testingDestination.toArray(new Base[this.testingDestination.size()]); // CodeableConcept
701        default: return super.getProperty(hash, name, checkValid);
702        }
703
704      }
705
706      @Override
707      public Base setProperty(int hash, String name, Base value) throws FHIRException {
708        switch (hash) {
709        case 976346515: // isDerived
710          this.isDerived = TypeConvertor.castToBoolean(value); // BooleanType
711          return value;
712        case 3575610: // type
713          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
714          return value;
715        case -1459831589: // preference
716          value = new SpecimenContainedPreferenceEnumFactory().fromType(TypeConvertor.castToCode(value));
717          this.preference = (Enumeration) value; // Enumeration<SpecimenContainedPreference>
718          return value;
719        case -410956671: // container
720          this.container = (SpecimenDefinitionTypeTestedContainerComponent) value; // SpecimenDefinitionTypeTestedContainerComponent
721          return value;
722        case 363387971: // requirement
723          this.requirement = TypeConvertor.castToString(value); // StringType
724          return value;
725        case 1434969867: // retentionTime
726          this.retentionTime = TypeConvertor.castToDuration(value); // Duration
727          return value;
728        case -1494547425: // singleUse
729          this.singleUse = TypeConvertor.castToBoolean(value); // BooleanType
730          return value;
731        case -553706344: // rejectionCriterion
732          this.getRejectionCriterion().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
733          return value;
734        case 2072805: // handling
735          this.getHandling().add((SpecimenDefinitionTypeTestedHandlingComponent) value); // SpecimenDefinitionTypeTestedHandlingComponent
736          return value;
737        case 939511774: // testingDestination
738          this.getTestingDestination().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
739          return value;
740        default: return super.setProperty(hash, name, value);
741        }
742
743      }
744
745      @Override
746      public Base setProperty(String name, Base value) throws FHIRException {
747        if (name.equals("isDerived")) {
748          this.isDerived = TypeConvertor.castToBoolean(value); // BooleanType
749        } else if (name.equals("type")) {
750          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
751        } else if (name.equals("preference")) {
752          value = new SpecimenContainedPreferenceEnumFactory().fromType(TypeConvertor.castToCode(value));
753          this.preference = (Enumeration) value; // Enumeration<SpecimenContainedPreference>
754        } else if (name.equals("container")) {
755          this.container = (SpecimenDefinitionTypeTestedContainerComponent) value; // SpecimenDefinitionTypeTestedContainerComponent
756        } else if (name.equals("requirement")) {
757          this.requirement = TypeConvertor.castToString(value); // StringType
758        } else if (name.equals("retentionTime")) {
759          this.retentionTime = TypeConvertor.castToDuration(value); // Duration
760        } else if (name.equals("singleUse")) {
761          this.singleUse = TypeConvertor.castToBoolean(value); // BooleanType
762        } else if (name.equals("rejectionCriterion")) {
763          this.getRejectionCriterion().add(TypeConvertor.castToCodeableConcept(value));
764        } else if (name.equals("handling")) {
765          this.getHandling().add((SpecimenDefinitionTypeTestedHandlingComponent) value);
766        } else if (name.equals("testingDestination")) {
767          this.getTestingDestination().add(TypeConvertor.castToCodeableConcept(value));
768        } else
769          return super.setProperty(name, value);
770        return value;
771      }
772
773      @Override
774      public Base makeProperty(int hash, String name) throws FHIRException {
775        switch (hash) {
776        case 976346515:  return getIsDerivedElement();
777        case 3575610:  return getType();
778        case -1459831589:  return getPreferenceElement();
779        case -410956671:  return getContainer();
780        case 363387971:  return getRequirementElement();
781        case 1434969867:  return getRetentionTime();
782        case -1494547425:  return getSingleUseElement();
783        case -553706344:  return addRejectionCriterion(); 
784        case 2072805:  return addHandling(); 
785        case 939511774:  return addTestingDestination(); 
786        default: return super.makeProperty(hash, name);
787        }
788
789      }
790
791      @Override
792      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
793        switch (hash) {
794        case 976346515: /*isDerived*/ return new String[] {"boolean"};
795        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
796        case -1459831589: /*preference*/ return new String[] {"code"};
797        case -410956671: /*container*/ return new String[] {};
798        case 363387971: /*requirement*/ return new String[] {"string"};
799        case 1434969867: /*retentionTime*/ return new String[] {"Duration"};
800        case -1494547425: /*singleUse*/ return new String[] {"boolean"};
801        case -553706344: /*rejectionCriterion*/ return new String[] {"CodeableConcept"};
802        case 2072805: /*handling*/ return new String[] {};
803        case 939511774: /*testingDestination*/ return new String[] {"CodeableConcept"};
804        default: return super.getTypesForProperty(hash, name);
805        }
806
807      }
808
809      @Override
810      public Base addChild(String name) throws FHIRException {
811        if (name.equals("isDerived")) {
812          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.typeTested.isDerived");
813        }
814        else if (name.equals("type")) {
815          this.type = new CodeableConcept();
816          return this.type;
817        }
818        else if (name.equals("preference")) {
819          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.typeTested.preference");
820        }
821        else if (name.equals("container")) {
822          this.container = new SpecimenDefinitionTypeTestedContainerComponent();
823          return this.container;
824        }
825        else if (name.equals("requirement")) {
826          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.typeTested.requirement");
827        }
828        else if (name.equals("retentionTime")) {
829          this.retentionTime = new Duration();
830          return this.retentionTime;
831        }
832        else if (name.equals("singleUse")) {
833          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.typeTested.singleUse");
834        }
835        else if (name.equals("rejectionCriterion")) {
836          return addRejectionCriterion();
837        }
838        else if (name.equals("handling")) {
839          return addHandling();
840        }
841        else if (name.equals("testingDestination")) {
842          return addTestingDestination();
843        }
844        else
845          return super.addChild(name);
846      }
847
848      public SpecimenDefinitionTypeTestedComponent copy() {
849        SpecimenDefinitionTypeTestedComponent dst = new SpecimenDefinitionTypeTestedComponent();
850        copyValues(dst);
851        return dst;
852      }
853
854      public void copyValues(SpecimenDefinitionTypeTestedComponent dst) {
855        super.copyValues(dst);
856        dst.isDerived = isDerived == null ? null : isDerived.copy();
857        dst.type = type == null ? null : type.copy();
858        dst.preference = preference == null ? null : preference.copy();
859        dst.container = container == null ? null : container.copy();
860        dst.requirement = requirement == null ? null : requirement.copy();
861        dst.retentionTime = retentionTime == null ? null : retentionTime.copy();
862        dst.singleUse = singleUse == null ? null : singleUse.copy();
863        if (rejectionCriterion != null) {
864          dst.rejectionCriterion = new ArrayList<CodeableConcept>();
865          for (CodeableConcept i : rejectionCriterion)
866            dst.rejectionCriterion.add(i.copy());
867        };
868        if (handling != null) {
869          dst.handling = new ArrayList<SpecimenDefinitionTypeTestedHandlingComponent>();
870          for (SpecimenDefinitionTypeTestedHandlingComponent i : handling)
871            dst.handling.add(i.copy());
872        };
873        if (testingDestination != null) {
874          dst.testingDestination = new ArrayList<CodeableConcept>();
875          for (CodeableConcept i : testingDestination)
876            dst.testingDestination.add(i.copy());
877        };
878      }
879
880      @Override
881      public boolean equalsDeep(Base other_) {
882        if (!super.equalsDeep(other_))
883          return false;
884        if (!(other_ instanceof SpecimenDefinitionTypeTestedComponent))
885          return false;
886        SpecimenDefinitionTypeTestedComponent o = (SpecimenDefinitionTypeTestedComponent) other_;
887        return compareDeep(isDerived, o.isDerived, true) && compareDeep(type, o.type, true) && compareDeep(preference, o.preference, true)
888           && compareDeep(container, o.container, true) && compareDeep(requirement, o.requirement, true) && compareDeep(retentionTime, o.retentionTime, true)
889           && compareDeep(singleUse, o.singleUse, true) && compareDeep(rejectionCriterion, o.rejectionCriterion, true)
890           && compareDeep(handling, o.handling, true) && compareDeep(testingDestination, o.testingDestination, true)
891          ;
892      }
893
894      @Override
895      public boolean equalsShallow(Base other_) {
896        if (!super.equalsShallow(other_))
897          return false;
898        if (!(other_ instanceof SpecimenDefinitionTypeTestedComponent))
899          return false;
900        SpecimenDefinitionTypeTestedComponent o = (SpecimenDefinitionTypeTestedComponent) other_;
901        return compareValues(isDerived, o.isDerived, true) && compareValues(preference, o.preference, true)
902           && compareValues(requirement, o.requirement, true) && compareValues(singleUse, o.singleUse, true);
903      }
904
905      public boolean isEmpty() {
906        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(isDerived, type, preference
907          , container, requirement, retentionTime, singleUse, rejectionCriterion, handling
908          , testingDestination);
909      }
910
911  public String fhirType() {
912    return "SpecimenDefinition.typeTested";
913
914  }
915
916  }
917
918    @Block()
919    public static class SpecimenDefinitionTypeTestedContainerComponent extends BackboneElement implements IBaseBackboneElement {
920        /**
921         * The type of material of the container.
922         */
923        @Child(name = "material", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=false)
924        @Description(shortDefinition="The material type used for the container", formalDefinition="The type of material of the container." )
925        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/container-material")
926        protected CodeableConcept material;
927
928        /**
929         * The type of container used to contain this kind of specimen.
930         */
931        @Child(name = "type", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
932        @Description(shortDefinition="Kind of container associated with the kind of specimen", formalDefinition="The type of container used to contain this kind of specimen." )
933        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/specimen-container-type")
934        protected CodeableConcept type;
935
936        /**
937         * Color of container cap.
938         */
939        @Child(name = "cap", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=false)
940        @Description(shortDefinition="Color of container cap", formalDefinition="Color of container cap." )
941        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/container-cap")
942        protected CodeableConcept cap;
943
944        /**
945         * The textual description of the kind of container.
946         */
947        @Child(name = "description", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=false)
948        @Description(shortDefinition="The description of the kind of container", formalDefinition="The textual description of the kind of container." )
949        protected StringType description;
950
951        /**
952         * The capacity (volume or other measure) of this kind of container.
953         */
954        @Child(name = "capacity", type = {Quantity.class}, order=5, min=0, max=1, modifier=false, summary=false)
955        @Description(shortDefinition="The capacity of this kind of container", formalDefinition="The capacity (volume or other measure) of this kind of container." )
956        protected Quantity capacity;
957
958        /**
959         * The minimum volume to be conditioned in the container.
960         */
961        @Child(name = "minimumVolume", type = {Quantity.class, StringType.class}, order=6, min=0, max=1, modifier=false, summary=false)
962        @Description(shortDefinition="Minimum volume", formalDefinition="The minimum volume to be conditioned in the container." )
963        protected DataType minimumVolume;
964
965        /**
966         * Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.
967         */
968        @Child(name = "additive", type = {}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
969        @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." )
970        protected List<SpecimenDefinitionTypeTestedContainerAdditiveComponent> additive;
971
972        /**
973         * Special processing that should be applied to the container for this kind of specimen.
974         */
975        @Child(name = "preparation", type = {StringType.class}, order=8, min=0, max=1, modifier=false, summary=false)
976        @Description(shortDefinition="Special processing applied to the container for this specimen type", formalDefinition="Special processing that should be applied to the container for this kind of specimen." )
977        protected StringType preparation;
978
979        private static final long serialVersionUID = -1498817064L;
980
981    /**
982     * Constructor
983     */
984      public SpecimenDefinitionTypeTestedContainerComponent() {
985        super();
986      }
987
988        /**
989         * @return {@link #material} (The type of material of the container.)
990         */
991        public CodeableConcept getMaterial() { 
992          if (this.material == null)
993            if (Configuration.errorOnAutoCreate())
994              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedContainerComponent.material");
995            else if (Configuration.doAutoCreate())
996              this.material = new CodeableConcept(); // cc
997          return this.material;
998        }
999
1000        public boolean hasMaterial() { 
1001          return this.material != null && !this.material.isEmpty();
1002        }
1003
1004        /**
1005         * @param value {@link #material} (The type of material of the container.)
1006         */
1007        public SpecimenDefinitionTypeTestedContainerComponent setMaterial(CodeableConcept value) { 
1008          this.material = value;
1009          return this;
1010        }
1011
1012        /**
1013         * @return {@link #type} (The type of container used to contain this kind of specimen.)
1014         */
1015        public CodeableConcept getType() { 
1016          if (this.type == null)
1017            if (Configuration.errorOnAutoCreate())
1018              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedContainerComponent.type");
1019            else if (Configuration.doAutoCreate())
1020              this.type = new CodeableConcept(); // cc
1021          return this.type;
1022        }
1023
1024        public boolean hasType() { 
1025          return this.type != null && !this.type.isEmpty();
1026        }
1027
1028        /**
1029         * @param value {@link #type} (The type of container used to contain this kind of specimen.)
1030         */
1031        public SpecimenDefinitionTypeTestedContainerComponent setType(CodeableConcept value) { 
1032          this.type = value;
1033          return this;
1034        }
1035
1036        /**
1037         * @return {@link #cap} (Color of container cap.)
1038         */
1039        public CodeableConcept getCap() { 
1040          if (this.cap == null)
1041            if (Configuration.errorOnAutoCreate())
1042              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedContainerComponent.cap");
1043            else if (Configuration.doAutoCreate())
1044              this.cap = new CodeableConcept(); // cc
1045          return this.cap;
1046        }
1047
1048        public boolean hasCap() { 
1049          return this.cap != null && !this.cap.isEmpty();
1050        }
1051
1052        /**
1053         * @param value {@link #cap} (Color of container cap.)
1054         */
1055        public SpecimenDefinitionTypeTestedContainerComponent setCap(CodeableConcept value) { 
1056          this.cap = value;
1057          return this;
1058        }
1059
1060        /**
1061         * @return {@link #description} (The textual description of the kind of container.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
1062         */
1063        public StringType getDescriptionElement() { 
1064          if (this.description == null)
1065            if (Configuration.errorOnAutoCreate())
1066              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedContainerComponent.description");
1067            else if (Configuration.doAutoCreate())
1068              this.description = new StringType(); // bb
1069          return this.description;
1070        }
1071
1072        public boolean hasDescriptionElement() { 
1073          return this.description != null && !this.description.isEmpty();
1074        }
1075
1076        public boolean hasDescription() { 
1077          return this.description != null && !this.description.isEmpty();
1078        }
1079
1080        /**
1081         * @param value {@link #description} (The textual description of the kind of container.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
1082         */
1083        public SpecimenDefinitionTypeTestedContainerComponent setDescriptionElement(StringType value) { 
1084          this.description = value;
1085          return this;
1086        }
1087
1088        /**
1089         * @return The textual description of the kind of container.
1090         */
1091        public String getDescription() { 
1092          return this.description == null ? null : this.description.getValue();
1093        }
1094
1095        /**
1096         * @param value The textual description of the kind of container.
1097         */
1098        public SpecimenDefinitionTypeTestedContainerComponent setDescription(String value) { 
1099          if (Utilities.noString(value))
1100            this.description = null;
1101          else {
1102            if (this.description == null)
1103              this.description = new StringType();
1104            this.description.setValue(value);
1105          }
1106          return this;
1107        }
1108
1109        /**
1110         * @return {@link #capacity} (The capacity (volume or other measure) of this kind of container.)
1111         */
1112        public Quantity getCapacity() { 
1113          if (this.capacity == null)
1114            if (Configuration.errorOnAutoCreate())
1115              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedContainerComponent.capacity");
1116            else if (Configuration.doAutoCreate())
1117              this.capacity = new Quantity(); // cc
1118          return this.capacity;
1119        }
1120
1121        public boolean hasCapacity() { 
1122          return this.capacity != null && !this.capacity.isEmpty();
1123        }
1124
1125        /**
1126         * @param value {@link #capacity} (The capacity (volume or other measure) of this kind of container.)
1127         */
1128        public SpecimenDefinitionTypeTestedContainerComponent setCapacity(Quantity value) { 
1129          this.capacity = value;
1130          return this;
1131        }
1132
1133        /**
1134         * @return {@link #minimumVolume} (The minimum volume to be conditioned in the container.)
1135         */
1136        public DataType getMinimumVolume() { 
1137          return this.minimumVolume;
1138        }
1139
1140        /**
1141         * @return {@link #minimumVolume} (The minimum volume to be conditioned in the container.)
1142         */
1143        public Quantity getMinimumVolumeQuantity() throws FHIRException { 
1144          if (this.minimumVolume == null)
1145            this.minimumVolume = new Quantity();
1146          if (!(this.minimumVolume instanceof Quantity))
1147            throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.minimumVolume.getClass().getName()+" was encountered");
1148          return (Quantity) this.minimumVolume;
1149        }
1150
1151        public boolean hasMinimumVolumeQuantity() { 
1152          return this != null && this.minimumVolume instanceof Quantity;
1153        }
1154
1155        /**
1156         * @return {@link #minimumVolume} (The minimum volume to be conditioned in the container.)
1157         */
1158        public StringType getMinimumVolumeStringType() throws FHIRException { 
1159          if (this.minimumVolume == null)
1160            this.minimumVolume = new StringType();
1161          if (!(this.minimumVolume instanceof StringType))
1162            throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.minimumVolume.getClass().getName()+" was encountered");
1163          return (StringType) this.minimumVolume;
1164        }
1165
1166        public boolean hasMinimumVolumeStringType() { 
1167          return this != null && this.minimumVolume instanceof StringType;
1168        }
1169
1170        public boolean hasMinimumVolume() { 
1171          return this.minimumVolume != null && !this.minimumVolume.isEmpty();
1172        }
1173
1174        /**
1175         * @param value {@link #minimumVolume} (The minimum volume to be conditioned in the container.)
1176         */
1177        public SpecimenDefinitionTypeTestedContainerComponent setMinimumVolume(DataType value) { 
1178          if (value != null && !(value instanceof Quantity || value instanceof StringType))
1179            throw new Error("Not the right type for SpecimenDefinition.typeTested.container.minimumVolume[x]: "+value.fhirType());
1180          this.minimumVolume = value;
1181          return this;
1182        }
1183
1184        /**
1185         * @return {@link #additive} (Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.)
1186         */
1187        public List<SpecimenDefinitionTypeTestedContainerAdditiveComponent> getAdditive() { 
1188          if (this.additive == null)
1189            this.additive = new ArrayList<SpecimenDefinitionTypeTestedContainerAdditiveComponent>();
1190          return this.additive;
1191        }
1192
1193        /**
1194         * @return Returns a reference to <code>this</code> for easy method chaining
1195         */
1196        public SpecimenDefinitionTypeTestedContainerComponent setAdditive(List<SpecimenDefinitionTypeTestedContainerAdditiveComponent> theAdditive) { 
1197          this.additive = theAdditive;
1198          return this;
1199        }
1200
1201        public boolean hasAdditive() { 
1202          if (this.additive == null)
1203            return false;
1204          for (SpecimenDefinitionTypeTestedContainerAdditiveComponent item : this.additive)
1205            if (!item.isEmpty())
1206              return true;
1207          return false;
1208        }
1209
1210        public SpecimenDefinitionTypeTestedContainerAdditiveComponent addAdditive() { //3
1211          SpecimenDefinitionTypeTestedContainerAdditiveComponent t = new SpecimenDefinitionTypeTestedContainerAdditiveComponent();
1212          if (this.additive == null)
1213            this.additive = new ArrayList<SpecimenDefinitionTypeTestedContainerAdditiveComponent>();
1214          this.additive.add(t);
1215          return t;
1216        }
1217
1218        public SpecimenDefinitionTypeTestedContainerComponent addAdditive(SpecimenDefinitionTypeTestedContainerAdditiveComponent t) { //3
1219          if (t == null)
1220            return this;
1221          if (this.additive == null)
1222            this.additive = new ArrayList<SpecimenDefinitionTypeTestedContainerAdditiveComponent>();
1223          this.additive.add(t);
1224          return this;
1225        }
1226
1227        /**
1228         * @return The first repetition of repeating field {@link #additive}, creating it if it does not already exist {3}
1229         */
1230        public SpecimenDefinitionTypeTestedContainerAdditiveComponent getAdditiveFirstRep() { 
1231          if (getAdditive().isEmpty()) {
1232            addAdditive();
1233          }
1234          return getAdditive().get(0);
1235        }
1236
1237        /**
1238         * @return {@link #preparation} (Special processing that should be applied to the container for this kind of specimen.). This is the underlying object with id, value and extensions. The accessor "getPreparation" gives direct access to the value
1239         */
1240        public StringType getPreparationElement() { 
1241          if (this.preparation == null)
1242            if (Configuration.errorOnAutoCreate())
1243              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedContainerComponent.preparation");
1244            else if (Configuration.doAutoCreate())
1245              this.preparation = new StringType(); // bb
1246          return this.preparation;
1247        }
1248
1249        public boolean hasPreparationElement() { 
1250          return this.preparation != null && !this.preparation.isEmpty();
1251        }
1252
1253        public boolean hasPreparation() { 
1254          return this.preparation != null && !this.preparation.isEmpty();
1255        }
1256
1257        /**
1258         * @param value {@link #preparation} (Special processing that should be applied to the container for this kind of specimen.). This is the underlying object with id, value and extensions. The accessor "getPreparation" gives direct access to the value
1259         */
1260        public SpecimenDefinitionTypeTestedContainerComponent setPreparationElement(StringType value) { 
1261          this.preparation = value;
1262          return this;
1263        }
1264
1265        /**
1266         * @return Special processing that should be applied to the container for this kind of specimen.
1267         */
1268        public String getPreparation() { 
1269          return this.preparation == null ? null : this.preparation.getValue();
1270        }
1271
1272        /**
1273         * @param value Special processing that should be applied to the container for this kind of specimen.
1274         */
1275        public SpecimenDefinitionTypeTestedContainerComponent setPreparation(String value) { 
1276          if (Utilities.noString(value))
1277            this.preparation = null;
1278          else {
1279            if (this.preparation == null)
1280              this.preparation = new StringType();
1281            this.preparation.setValue(value);
1282          }
1283          return this;
1284        }
1285
1286        protected void listChildren(List<Property> children) {
1287          super.listChildren(children);
1288          children.add(new Property("material", "CodeableConcept", "The type of material of the container.", 0, 1, material));
1289          children.add(new Property("type", "CodeableConcept", "The type of container used to contain this kind of specimen.", 0, 1, type));
1290          children.add(new Property("cap", "CodeableConcept", "Color of container cap.", 0, 1, cap));
1291          children.add(new Property("description", "string", "The textual description of the kind of container.", 0, 1, description));
1292          children.add(new Property("capacity", "Quantity", "The capacity (volume or other measure) of this kind of container.", 0, 1, capacity));
1293          children.add(new Property("minimumVolume[x]", "Quantity|string", "The minimum volume to be conditioned in the container.", 0, 1, minimumVolume));
1294          children.add(new Property("additive", "", "Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.", 0, java.lang.Integer.MAX_VALUE, additive));
1295          children.add(new Property("preparation", "string", "Special processing that should be applied to the container for this kind of specimen.", 0, 1, preparation));
1296        }
1297
1298        @Override
1299        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1300          switch (_hash) {
1301          case 299066663: /*material*/  return new Property("material", "CodeableConcept", "The type of material of the container.", 0, 1, material);
1302          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "The type of container used to contain this kind of specimen.", 0, 1, type);
1303          case 98258: /*cap*/  return new Property("cap", "CodeableConcept", "Color of container cap.", 0, 1, cap);
1304          case -1724546052: /*description*/  return new Property("description", "string", "The textual description of the kind of container.", 0, 1, description);
1305          case -67824454: /*capacity*/  return new Property("capacity", "Quantity", "The capacity (volume or other measure) of this kind of container.", 0, 1, capacity);
1306          case 371830456: /*minimumVolume[x]*/  return new Property("minimumVolume[x]", "Quantity|string", "The minimum volume to be conditioned in the container.", 0, 1, minimumVolume);
1307          case -1674665784: /*minimumVolume*/  return new Property("minimumVolume[x]", "Quantity|string", "The minimum volume to be conditioned in the container.", 0, 1, minimumVolume);
1308          case -532143757: /*minimumVolumeQuantity*/  return new Property("minimumVolume[x]", "Quantity", "The minimum volume to be conditioned in the container.", 0, 1, minimumVolume);
1309          case 248461049: /*minimumVolumeString*/  return new Property("minimumVolume[x]", "string", "The minimum volume to be conditioned in the container.", 0, 1, minimumVolume);
1310          case -1226589236: /*additive*/  return new Property("additive", "", "Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.", 0, java.lang.Integer.MAX_VALUE, additive);
1311          case -1315428713: /*preparation*/  return new Property("preparation", "string", "Special processing that should be applied to the container for this kind of specimen.", 0, 1, preparation);
1312          default: return super.getNamedProperty(_hash, _name, _checkValid);
1313          }
1314
1315        }
1316
1317      @Override
1318      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1319        switch (hash) {
1320        case 299066663: /*material*/ return this.material == null ? new Base[0] : new Base[] {this.material}; // CodeableConcept
1321        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
1322        case 98258: /*cap*/ return this.cap == null ? new Base[0] : new Base[] {this.cap}; // CodeableConcept
1323        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // StringType
1324        case -67824454: /*capacity*/ return this.capacity == null ? new Base[0] : new Base[] {this.capacity}; // Quantity
1325        case -1674665784: /*minimumVolume*/ return this.minimumVolume == null ? new Base[0] : new Base[] {this.minimumVolume}; // DataType
1326        case -1226589236: /*additive*/ return this.additive == null ? new Base[0] : this.additive.toArray(new Base[this.additive.size()]); // SpecimenDefinitionTypeTestedContainerAdditiveComponent
1327        case -1315428713: /*preparation*/ return this.preparation == null ? new Base[0] : new Base[] {this.preparation}; // StringType
1328        default: return super.getProperty(hash, name, checkValid);
1329        }
1330
1331      }
1332
1333      @Override
1334      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1335        switch (hash) {
1336        case 299066663: // material
1337          this.material = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1338          return value;
1339        case 3575610: // type
1340          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1341          return value;
1342        case 98258: // cap
1343          this.cap = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1344          return value;
1345        case -1724546052: // description
1346          this.description = TypeConvertor.castToString(value); // StringType
1347          return value;
1348        case -67824454: // capacity
1349          this.capacity = TypeConvertor.castToQuantity(value); // Quantity
1350          return value;
1351        case -1674665784: // minimumVolume
1352          this.minimumVolume = TypeConvertor.castToType(value); // DataType
1353          return value;
1354        case -1226589236: // additive
1355          this.getAdditive().add((SpecimenDefinitionTypeTestedContainerAdditiveComponent) value); // SpecimenDefinitionTypeTestedContainerAdditiveComponent
1356          return value;
1357        case -1315428713: // preparation
1358          this.preparation = TypeConvertor.castToString(value); // StringType
1359          return value;
1360        default: return super.setProperty(hash, name, value);
1361        }
1362
1363      }
1364
1365      @Override
1366      public Base setProperty(String name, Base value) throws FHIRException {
1367        if (name.equals("material")) {
1368          this.material = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1369        } else if (name.equals("type")) {
1370          this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1371        } else if (name.equals("cap")) {
1372          this.cap = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1373        } else if (name.equals("description")) {
1374          this.description = TypeConvertor.castToString(value); // StringType
1375        } else if (name.equals("capacity")) {
1376          this.capacity = TypeConvertor.castToQuantity(value); // Quantity
1377        } else if (name.equals("minimumVolume[x]")) {
1378          this.minimumVolume = TypeConvertor.castToType(value); // DataType
1379        } else if (name.equals("additive")) {
1380          this.getAdditive().add((SpecimenDefinitionTypeTestedContainerAdditiveComponent) value);
1381        } else if (name.equals("preparation")) {
1382          this.preparation = TypeConvertor.castToString(value); // StringType
1383        } else
1384          return super.setProperty(name, value);
1385        return value;
1386      }
1387
1388      @Override
1389      public Base makeProperty(int hash, String name) throws FHIRException {
1390        switch (hash) {
1391        case 299066663:  return getMaterial();
1392        case 3575610:  return getType();
1393        case 98258:  return getCap();
1394        case -1724546052:  return getDescriptionElement();
1395        case -67824454:  return getCapacity();
1396        case 371830456:  return getMinimumVolume();
1397        case -1674665784:  return getMinimumVolume();
1398        case -1226589236:  return addAdditive(); 
1399        case -1315428713:  return getPreparationElement();
1400        default: return super.makeProperty(hash, name);
1401        }
1402
1403      }
1404
1405      @Override
1406      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1407        switch (hash) {
1408        case 299066663: /*material*/ return new String[] {"CodeableConcept"};
1409        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
1410        case 98258: /*cap*/ return new String[] {"CodeableConcept"};
1411        case -1724546052: /*description*/ return new String[] {"string"};
1412        case -67824454: /*capacity*/ return new String[] {"Quantity"};
1413        case -1674665784: /*minimumVolume*/ return new String[] {"Quantity", "string"};
1414        case -1226589236: /*additive*/ return new String[] {};
1415        case -1315428713: /*preparation*/ return new String[] {"string"};
1416        default: return super.getTypesForProperty(hash, name);
1417        }
1418
1419      }
1420
1421      @Override
1422      public Base addChild(String name) throws FHIRException {
1423        if (name.equals("material")) {
1424          this.material = new CodeableConcept();
1425          return this.material;
1426        }
1427        else if (name.equals("type")) {
1428          this.type = new CodeableConcept();
1429          return this.type;
1430        }
1431        else if (name.equals("cap")) {
1432          this.cap = new CodeableConcept();
1433          return this.cap;
1434        }
1435        else if (name.equals("description")) {
1436          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.typeTested.container.description");
1437        }
1438        else if (name.equals("capacity")) {
1439          this.capacity = new Quantity();
1440          return this.capacity;
1441        }
1442        else if (name.equals("minimumVolumeQuantity")) {
1443          this.minimumVolume = new Quantity();
1444          return this.minimumVolume;
1445        }
1446        else if (name.equals("minimumVolumeString")) {
1447          this.minimumVolume = new StringType();
1448          return this.minimumVolume;
1449        }
1450        else if (name.equals("additive")) {
1451          return addAdditive();
1452        }
1453        else if (name.equals("preparation")) {
1454          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.typeTested.container.preparation");
1455        }
1456        else
1457          return super.addChild(name);
1458      }
1459
1460      public SpecimenDefinitionTypeTestedContainerComponent copy() {
1461        SpecimenDefinitionTypeTestedContainerComponent dst = new SpecimenDefinitionTypeTestedContainerComponent();
1462        copyValues(dst);
1463        return dst;
1464      }
1465
1466      public void copyValues(SpecimenDefinitionTypeTestedContainerComponent dst) {
1467        super.copyValues(dst);
1468        dst.material = material == null ? null : material.copy();
1469        dst.type = type == null ? null : type.copy();
1470        dst.cap = cap == null ? null : cap.copy();
1471        dst.description = description == null ? null : description.copy();
1472        dst.capacity = capacity == null ? null : capacity.copy();
1473        dst.minimumVolume = minimumVolume == null ? null : minimumVolume.copy();
1474        if (additive != null) {
1475          dst.additive = new ArrayList<SpecimenDefinitionTypeTestedContainerAdditiveComponent>();
1476          for (SpecimenDefinitionTypeTestedContainerAdditiveComponent i : additive)
1477            dst.additive.add(i.copy());
1478        };
1479        dst.preparation = preparation == null ? null : preparation.copy();
1480      }
1481
1482      @Override
1483      public boolean equalsDeep(Base other_) {
1484        if (!super.equalsDeep(other_))
1485          return false;
1486        if (!(other_ instanceof SpecimenDefinitionTypeTestedContainerComponent))
1487          return false;
1488        SpecimenDefinitionTypeTestedContainerComponent o = (SpecimenDefinitionTypeTestedContainerComponent) other_;
1489        return compareDeep(material, o.material, true) && compareDeep(type, o.type, true) && compareDeep(cap, o.cap, true)
1490           && compareDeep(description, o.description, true) && compareDeep(capacity, o.capacity, true) && compareDeep(minimumVolume, o.minimumVolume, true)
1491           && compareDeep(additive, o.additive, true) && compareDeep(preparation, o.preparation, true);
1492      }
1493
1494      @Override
1495      public boolean equalsShallow(Base other_) {
1496        if (!super.equalsShallow(other_))
1497          return false;
1498        if (!(other_ instanceof SpecimenDefinitionTypeTestedContainerComponent))
1499          return false;
1500        SpecimenDefinitionTypeTestedContainerComponent o = (SpecimenDefinitionTypeTestedContainerComponent) other_;
1501        return compareValues(description, o.description, true) && compareValues(preparation, o.preparation, true)
1502          ;
1503      }
1504
1505      public boolean isEmpty() {
1506        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(material, type, cap, description
1507          , capacity, minimumVolume, additive, preparation);
1508      }
1509
1510  public String fhirType() {
1511    return "SpecimenDefinition.typeTested.container";
1512
1513  }
1514
1515  }
1516
1517    @Block()
1518    public static class SpecimenDefinitionTypeTestedContainerAdditiveComponent extends BackboneElement implements IBaseBackboneElement {
1519        /**
1520         * Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.
1521         */
1522        @Child(name = "additive", type = {CodeableConcept.class, SubstanceDefinition.class}, order=1, min=1, max=1, modifier=false, summary=false)
1523        @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." )
1524        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://terminology.hl7.org/ValueSet/v2-0371")
1525        protected DataType additive;
1526
1527        private static final long serialVersionUID = 201856258L;
1528
1529    /**
1530     * Constructor
1531     */
1532      public SpecimenDefinitionTypeTestedContainerAdditiveComponent() {
1533        super();
1534      }
1535
1536    /**
1537     * Constructor
1538     */
1539      public SpecimenDefinitionTypeTestedContainerAdditiveComponent(DataType additive) {
1540        super();
1541        this.setAdditive(additive);
1542      }
1543
1544        /**
1545         * @return {@link #additive} (Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.)
1546         */
1547        public DataType getAdditive() { 
1548          return this.additive;
1549        }
1550
1551        /**
1552         * @return {@link #additive} (Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.)
1553         */
1554        public CodeableConcept getAdditiveCodeableConcept() throws FHIRException { 
1555          if (this.additive == null)
1556            this.additive = new CodeableConcept();
1557          if (!(this.additive instanceof CodeableConcept))
1558            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.additive.getClass().getName()+" was encountered");
1559          return (CodeableConcept) this.additive;
1560        }
1561
1562        public boolean hasAdditiveCodeableConcept() { 
1563          return this != null && this.additive instanceof CodeableConcept;
1564        }
1565
1566        /**
1567         * @return {@link #additive} (Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.)
1568         */
1569        public Reference getAdditiveReference() throws FHIRException { 
1570          if (this.additive == null)
1571            this.additive = new Reference();
1572          if (!(this.additive instanceof Reference))
1573            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.additive.getClass().getName()+" was encountered");
1574          return (Reference) this.additive;
1575        }
1576
1577        public boolean hasAdditiveReference() { 
1578          return this != null && this.additive instanceof Reference;
1579        }
1580
1581        public boolean hasAdditive() { 
1582          return this.additive != null && !this.additive.isEmpty();
1583        }
1584
1585        /**
1586         * @param value {@link #additive} (Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.)
1587         */
1588        public SpecimenDefinitionTypeTestedContainerAdditiveComponent setAdditive(DataType value) { 
1589          if (value != null && !(value instanceof CodeableConcept || value instanceof Reference))
1590            throw new Error("Not the right type for SpecimenDefinition.typeTested.container.additive.additive[x]: "+value.fhirType());
1591          this.additive = value;
1592          return this;
1593        }
1594
1595        protected void listChildren(List<Property> children) {
1596          super.listChildren(children);
1597          children.add(new Property("additive[x]", "CodeableConcept|Reference(SubstanceDefinition)", "Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.", 0, 1, additive));
1598        }
1599
1600        @Override
1601        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1602          switch (_hash) {
1603          case 261915956: /*additive[x]*/  return new Property("additive[x]", "CodeableConcept|Reference(SubstanceDefinition)", "Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.", 0, 1, additive);
1604          case -1226589236: /*additive*/  return new Property("additive[x]", "CodeableConcept|Reference(SubstanceDefinition)", "Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.", 0, 1, additive);
1605          case 1330272821: /*additiveCodeableConcept*/  return new Property("additive[x]", "CodeableConcept", "Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.", 0, 1, additive);
1606          case -386783009: /*additiveReference*/  return new Property("additive[x]", "Reference(SubstanceDefinition)", "Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.", 0, 1, additive);
1607          default: return super.getNamedProperty(_hash, _name, _checkValid);
1608          }
1609
1610        }
1611
1612      @Override
1613      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1614        switch (hash) {
1615        case -1226589236: /*additive*/ return this.additive == null ? new Base[0] : new Base[] {this.additive}; // DataType
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 -1226589236: // additive
1625          this.additive = TypeConvertor.castToType(value); // DataType
1626          return value;
1627        default: return super.setProperty(hash, name, value);
1628        }
1629
1630      }
1631
1632      @Override
1633      public Base setProperty(String name, Base value) throws FHIRException {
1634        if (name.equals("additive[x]")) {
1635          this.additive = TypeConvertor.castToType(value); // DataType
1636        } else
1637          return super.setProperty(name, value);
1638        return value;
1639      }
1640
1641      @Override
1642      public Base makeProperty(int hash, String name) throws FHIRException {
1643        switch (hash) {
1644        case 261915956:  return getAdditive();
1645        case -1226589236:  return getAdditive();
1646        default: return super.makeProperty(hash, name);
1647        }
1648
1649      }
1650
1651      @Override
1652      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1653        switch (hash) {
1654        case -1226589236: /*additive*/ return new String[] {"CodeableConcept", "Reference"};
1655        default: return super.getTypesForProperty(hash, name);
1656        }
1657
1658      }
1659
1660      @Override
1661      public Base addChild(String name) throws FHIRException {
1662        if (name.equals("additiveCodeableConcept")) {
1663          this.additive = new CodeableConcept();
1664          return this.additive;
1665        }
1666        else if (name.equals("additiveReference")) {
1667          this.additive = new Reference();
1668          return this.additive;
1669        }
1670        else
1671          return super.addChild(name);
1672      }
1673
1674      public SpecimenDefinitionTypeTestedContainerAdditiveComponent copy() {
1675        SpecimenDefinitionTypeTestedContainerAdditiveComponent dst = new SpecimenDefinitionTypeTestedContainerAdditiveComponent();
1676        copyValues(dst);
1677        return dst;
1678      }
1679
1680      public void copyValues(SpecimenDefinitionTypeTestedContainerAdditiveComponent dst) {
1681        super.copyValues(dst);
1682        dst.additive = additive == null ? null : additive.copy();
1683      }
1684
1685      @Override
1686      public boolean equalsDeep(Base other_) {
1687        if (!super.equalsDeep(other_))
1688          return false;
1689        if (!(other_ instanceof SpecimenDefinitionTypeTestedContainerAdditiveComponent))
1690          return false;
1691        SpecimenDefinitionTypeTestedContainerAdditiveComponent o = (SpecimenDefinitionTypeTestedContainerAdditiveComponent) other_;
1692        return compareDeep(additive, o.additive, true);
1693      }
1694
1695      @Override
1696      public boolean equalsShallow(Base other_) {
1697        if (!super.equalsShallow(other_))
1698          return false;
1699        if (!(other_ instanceof SpecimenDefinitionTypeTestedContainerAdditiveComponent))
1700          return false;
1701        SpecimenDefinitionTypeTestedContainerAdditiveComponent o = (SpecimenDefinitionTypeTestedContainerAdditiveComponent) other_;
1702        return true;
1703      }
1704
1705      public boolean isEmpty() {
1706        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(additive);
1707      }
1708
1709  public String fhirType() {
1710    return "SpecimenDefinition.typeTested.container.additive";
1711
1712  }
1713
1714  }
1715
1716    @Block()
1717    public static class SpecimenDefinitionTypeTestedHandlingComponent extends BackboneElement implements IBaseBackboneElement {
1718        /**
1719         * It qualifies the interval of temperature, which characterizes an occurrence of handling. Conditions that are not related to temperature may be handled in the instruction element.
1720         */
1721        @Child(name = "temperatureQualifier", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=false)
1722        @Description(shortDefinition="Qualifies the interval of temperature", formalDefinition="It qualifies the interval of temperature, which characterizes an occurrence of handling. Conditions that are not related to temperature may be handled in the instruction element." )
1723        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/handling-condition")
1724        protected CodeableConcept temperatureQualifier;
1725
1726        /**
1727         * The temperature interval for this set of handling instructions.
1728         */
1729        @Child(name = "temperatureRange", type = {Range.class}, order=2, min=0, max=1, modifier=false, summary=false)
1730        @Description(shortDefinition="Temperature range for these handling instructions", formalDefinition="The temperature interval for this set of handling instructions." )
1731        protected Range temperatureRange;
1732
1733        /**
1734         * The maximum time interval of preservation of the specimen with these conditions.
1735         */
1736        @Child(name = "maxDuration", type = {Duration.class}, order=3, min=0, max=1, modifier=false, summary=false)
1737        @Description(shortDefinition="Maximum preservation time", formalDefinition="The maximum time interval of preservation of the specimen with these conditions." )
1738        protected Duration maxDuration;
1739
1740        /**
1741         * Additional textual instructions for the preservation or transport of the specimen. For instance, 'Protect from light exposure'.
1742         */
1743        @Child(name = "instruction", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=false)
1744        @Description(shortDefinition="Preservation instruction", formalDefinition="Additional textual instructions for the preservation or transport of the specimen. For instance, 'Protect from light exposure'." )
1745        protected StringType instruction;
1746
1747        private static final long serialVersionUID = 2130906844L;
1748
1749    /**
1750     * Constructor
1751     */
1752      public SpecimenDefinitionTypeTestedHandlingComponent() {
1753        super();
1754      }
1755
1756        /**
1757         * @return {@link #temperatureQualifier} (It qualifies the interval of temperature, which characterizes an occurrence of handling. Conditions that are not related to temperature may be handled in the instruction element.)
1758         */
1759        public CodeableConcept getTemperatureQualifier() { 
1760          if (this.temperatureQualifier == null)
1761            if (Configuration.errorOnAutoCreate())
1762              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedHandlingComponent.temperatureQualifier");
1763            else if (Configuration.doAutoCreate())
1764              this.temperatureQualifier = new CodeableConcept(); // cc
1765          return this.temperatureQualifier;
1766        }
1767
1768        public boolean hasTemperatureQualifier() { 
1769          return this.temperatureQualifier != null && !this.temperatureQualifier.isEmpty();
1770        }
1771
1772        /**
1773         * @param value {@link #temperatureQualifier} (It qualifies the interval of temperature, which characterizes an occurrence of handling. Conditions that are not related to temperature may be handled in the instruction element.)
1774         */
1775        public SpecimenDefinitionTypeTestedHandlingComponent setTemperatureQualifier(CodeableConcept value) { 
1776          this.temperatureQualifier = value;
1777          return this;
1778        }
1779
1780        /**
1781         * @return {@link #temperatureRange} (The temperature interval for this set of handling instructions.)
1782         */
1783        public Range getTemperatureRange() { 
1784          if (this.temperatureRange == null)
1785            if (Configuration.errorOnAutoCreate())
1786              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedHandlingComponent.temperatureRange");
1787            else if (Configuration.doAutoCreate())
1788              this.temperatureRange = new Range(); // cc
1789          return this.temperatureRange;
1790        }
1791
1792        public boolean hasTemperatureRange() { 
1793          return this.temperatureRange != null && !this.temperatureRange.isEmpty();
1794        }
1795
1796        /**
1797         * @param value {@link #temperatureRange} (The temperature interval for this set of handling instructions.)
1798         */
1799        public SpecimenDefinitionTypeTestedHandlingComponent setTemperatureRange(Range value) { 
1800          this.temperatureRange = value;
1801          return this;
1802        }
1803
1804        /**
1805         * @return {@link #maxDuration} (The maximum time interval of preservation of the specimen with these conditions.)
1806         */
1807        public Duration getMaxDuration() { 
1808          if (this.maxDuration == null)
1809            if (Configuration.errorOnAutoCreate())
1810              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedHandlingComponent.maxDuration");
1811            else if (Configuration.doAutoCreate())
1812              this.maxDuration = new Duration(); // cc
1813          return this.maxDuration;
1814        }
1815
1816        public boolean hasMaxDuration() { 
1817          return this.maxDuration != null && !this.maxDuration.isEmpty();
1818        }
1819
1820        /**
1821         * @param value {@link #maxDuration} (The maximum time interval of preservation of the specimen with these conditions.)
1822         */
1823        public SpecimenDefinitionTypeTestedHandlingComponent setMaxDuration(Duration value) { 
1824          this.maxDuration = value;
1825          return this;
1826        }
1827
1828        /**
1829         * @return {@link #instruction} (Additional textual instructions for the preservation or transport of the specimen. For instance, 'Protect from light exposure'.). This is the underlying object with id, value and extensions. The accessor "getInstruction" gives direct access to the value
1830         */
1831        public StringType getInstructionElement() { 
1832          if (this.instruction == null)
1833            if (Configuration.errorOnAutoCreate())
1834              throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedHandlingComponent.instruction");
1835            else if (Configuration.doAutoCreate())
1836              this.instruction = new StringType(); // bb
1837          return this.instruction;
1838        }
1839
1840        public boolean hasInstructionElement() { 
1841          return this.instruction != null && !this.instruction.isEmpty();
1842        }
1843
1844        public boolean hasInstruction() { 
1845          return this.instruction != null && !this.instruction.isEmpty();
1846        }
1847
1848        /**
1849         * @param value {@link #instruction} (Additional textual instructions for the preservation or transport of the specimen. For instance, 'Protect from light exposure'.). This is the underlying object with id, value and extensions. The accessor "getInstruction" gives direct access to the value
1850         */
1851        public SpecimenDefinitionTypeTestedHandlingComponent setInstructionElement(StringType value) { 
1852          this.instruction = value;
1853          return this;
1854        }
1855
1856        /**
1857         * @return Additional textual instructions for the preservation or transport of the specimen. For instance, 'Protect from light exposure'.
1858         */
1859        public String getInstruction() { 
1860          return this.instruction == null ? null : this.instruction.getValue();
1861        }
1862
1863        /**
1864         * @param value Additional textual instructions for the preservation or transport of the specimen. For instance, 'Protect from light exposure'.
1865         */
1866        public SpecimenDefinitionTypeTestedHandlingComponent setInstruction(String value) { 
1867          if (Utilities.noString(value))
1868            this.instruction = null;
1869          else {
1870            if (this.instruction == null)
1871              this.instruction = new StringType();
1872            this.instruction.setValue(value);
1873          }
1874          return this;
1875        }
1876
1877        protected void listChildren(List<Property> children) {
1878          super.listChildren(children);
1879          children.add(new Property("temperatureQualifier", "CodeableConcept", "It qualifies the interval of temperature, which characterizes an occurrence of handling. Conditions that are not related to temperature may be handled in the instruction element.", 0, 1, temperatureQualifier));
1880          children.add(new Property("temperatureRange", "Range", "The temperature interval for this set of handling instructions.", 0, 1, temperatureRange));
1881          children.add(new Property("maxDuration", "Duration", "The maximum time interval of preservation of the specimen with these conditions.", 0, 1, maxDuration));
1882          children.add(new Property("instruction", "string", "Additional textual instructions for the preservation or transport of the specimen. For instance, 'Protect from light exposure'.", 0, 1, instruction));
1883        }
1884
1885        @Override
1886        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1887          switch (_hash) {
1888          case 548941206: /*temperatureQualifier*/  return new Property("temperatureQualifier", "CodeableConcept", "It qualifies the interval of temperature, which characterizes an occurrence of handling. Conditions that are not related to temperature may be handled in the instruction element.", 0, 1, temperatureQualifier);
1889          case -39203799: /*temperatureRange*/  return new Property("temperatureRange", "Range", "The temperature interval for this set of handling instructions.", 0, 1, temperatureRange);
1890          case 40284952: /*maxDuration*/  return new Property("maxDuration", "Duration", "The maximum time interval of preservation of the specimen with these conditions.", 0, 1, maxDuration);
1891          case 301526158: /*instruction*/  return new Property("instruction", "string", "Additional textual instructions for the preservation or transport of the specimen. For instance, 'Protect from light exposure'.", 0, 1, instruction);
1892          default: return super.getNamedProperty(_hash, _name, _checkValid);
1893          }
1894
1895        }
1896
1897      @Override
1898      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1899        switch (hash) {
1900        case 548941206: /*temperatureQualifier*/ return this.temperatureQualifier == null ? new Base[0] : new Base[] {this.temperatureQualifier}; // CodeableConcept
1901        case -39203799: /*temperatureRange*/ return this.temperatureRange == null ? new Base[0] : new Base[] {this.temperatureRange}; // Range
1902        case 40284952: /*maxDuration*/ return this.maxDuration == null ? new Base[0] : new Base[] {this.maxDuration}; // Duration
1903        case 301526158: /*instruction*/ return this.instruction == null ? new Base[0] : new Base[] {this.instruction}; // StringType
1904        default: return super.getProperty(hash, name, checkValid);
1905        }
1906
1907      }
1908
1909      @Override
1910      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1911        switch (hash) {
1912        case 548941206: // temperatureQualifier
1913          this.temperatureQualifier = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1914          return value;
1915        case -39203799: // temperatureRange
1916          this.temperatureRange = TypeConvertor.castToRange(value); // Range
1917          return value;
1918        case 40284952: // maxDuration
1919          this.maxDuration = TypeConvertor.castToDuration(value); // Duration
1920          return value;
1921        case 301526158: // instruction
1922          this.instruction = TypeConvertor.castToString(value); // StringType
1923          return value;
1924        default: return super.setProperty(hash, name, value);
1925        }
1926
1927      }
1928
1929      @Override
1930      public Base setProperty(String name, Base value) throws FHIRException {
1931        if (name.equals("temperatureQualifier")) {
1932          this.temperatureQualifier = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1933        } else if (name.equals("temperatureRange")) {
1934          this.temperatureRange = TypeConvertor.castToRange(value); // Range
1935        } else if (name.equals("maxDuration")) {
1936          this.maxDuration = TypeConvertor.castToDuration(value); // Duration
1937        } else if (name.equals("instruction")) {
1938          this.instruction = TypeConvertor.castToString(value); // StringType
1939        } else
1940          return super.setProperty(name, value);
1941        return value;
1942      }
1943
1944      @Override
1945      public Base makeProperty(int hash, String name) throws FHIRException {
1946        switch (hash) {
1947        case 548941206:  return getTemperatureQualifier();
1948        case -39203799:  return getTemperatureRange();
1949        case 40284952:  return getMaxDuration();
1950        case 301526158:  return getInstructionElement();
1951        default: return super.makeProperty(hash, name);
1952        }
1953
1954      }
1955
1956      @Override
1957      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1958        switch (hash) {
1959        case 548941206: /*temperatureQualifier*/ return new String[] {"CodeableConcept"};
1960        case -39203799: /*temperatureRange*/ return new String[] {"Range"};
1961        case 40284952: /*maxDuration*/ return new String[] {"Duration"};
1962        case 301526158: /*instruction*/ return new String[] {"string"};
1963        default: return super.getTypesForProperty(hash, name);
1964        }
1965
1966      }
1967
1968      @Override
1969      public Base addChild(String name) throws FHIRException {
1970        if (name.equals("temperatureQualifier")) {
1971          this.temperatureQualifier = new CodeableConcept();
1972          return this.temperatureQualifier;
1973        }
1974        else if (name.equals("temperatureRange")) {
1975          this.temperatureRange = new Range();
1976          return this.temperatureRange;
1977        }
1978        else if (name.equals("maxDuration")) {
1979          this.maxDuration = new Duration();
1980          return this.maxDuration;
1981        }
1982        else if (name.equals("instruction")) {
1983          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.typeTested.handling.instruction");
1984        }
1985        else
1986          return super.addChild(name);
1987      }
1988
1989      public SpecimenDefinitionTypeTestedHandlingComponent copy() {
1990        SpecimenDefinitionTypeTestedHandlingComponent dst = new SpecimenDefinitionTypeTestedHandlingComponent();
1991        copyValues(dst);
1992        return dst;
1993      }
1994
1995      public void copyValues(SpecimenDefinitionTypeTestedHandlingComponent dst) {
1996        super.copyValues(dst);
1997        dst.temperatureQualifier = temperatureQualifier == null ? null : temperatureQualifier.copy();
1998        dst.temperatureRange = temperatureRange == null ? null : temperatureRange.copy();
1999        dst.maxDuration = maxDuration == null ? null : maxDuration.copy();
2000        dst.instruction = instruction == null ? null : instruction.copy();
2001      }
2002
2003      @Override
2004      public boolean equalsDeep(Base other_) {
2005        if (!super.equalsDeep(other_))
2006          return false;
2007        if (!(other_ instanceof SpecimenDefinitionTypeTestedHandlingComponent))
2008          return false;
2009        SpecimenDefinitionTypeTestedHandlingComponent o = (SpecimenDefinitionTypeTestedHandlingComponent) other_;
2010        return compareDeep(temperatureQualifier, o.temperatureQualifier, true) && compareDeep(temperatureRange, o.temperatureRange, true)
2011           && compareDeep(maxDuration, o.maxDuration, true) && compareDeep(instruction, o.instruction, true)
2012          ;
2013      }
2014
2015      @Override
2016      public boolean equalsShallow(Base other_) {
2017        if (!super.equalsShallow(other_))
2018          return false;
2019        if (!(other_ instanceof SpecimenDefinitionTypeTestedHandlingComponent))
2020          return false;
2021        SpecimenDefinitionTypeTestedHandlingComponent o = (SpecimenDefinitionTypeTestedHandlingComponent) other_;
2022        return compareValues(instruction, o.instruction, true);
2023      }
2024
2025      public boolean isEmpty() {
2026        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(temperatureQualifier, temperatureRange
2027          , maxDuration, instruction);
2028      }
2029
2030  public String fhirType() {
2031    return "SpecimenDefinition.typeTested.handling";
2032
2033  }
2034
2035  }
2036
2037    /**
2038     * An absolute URL that is used to identify this SpecimenDefinition when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this SpecimenDefinition is (or will be) published. The URL SHOULD include the major version of the SpecimenDefinition. For more information see Technical and Business Versions.
2039     */
2040    @Child(name = "url", type = {UriType.class}, order=0, min=0, max=1, modifier=false, summary=true)
2041    @Description(shortDefinition="Logical canonical URL to reference this SpecimenDefinition (globally unique)", formalDefinition="An absolute URL that is used to identify this SpecimenDefinition when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this SpecimenDefinition is (or will be) published. The URL SHOULD include the major version of the SpecimenDefinition. For more information see Technical and Business Versions." )
2042    protected UriType url;
2043
2044    /**
2045     * A business identifier assigned to this SpecimenDefinition.
2046     */
2047    @Child(name = "identifier", type = {Identifier.class}, order=1, min=0, max=1, modifier=false, summary=true)
2048    @Description(shortDefinition="Business identifier", formalDefinition="A business identifier assigned to this SpecimenDefinition." )
2049    protected Identifier identifier;
2050
2051    /**
2052     * The identifier that is used to identify this version of the SpecimenDefinition when it is referenced in a specification, model, design or instance. This is an arbitrary value managed by the SpecimenDefinition author and is not expected to be globally unique.
2053     */
2054    @Child(name = "version", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=true)
2055    @Description(shortDefinition="Business version of the SpecimenDefinition", formalDefinition="The identifier that is used to identify this version of the SpecimenDefinition when it is referenced in a specification, model, design or instance. This is an arbitrary value managed by the SpecimenDefinition author and is not expected to be globally unique." )
2056    protected StringType version;
2057
2058    /**
2059     * A short, descriptive, user-friendly title for the SpecimenDefinition.
2060     */
2061    @Child(name = "title", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true)
2062    @Description(shortDefinition="Name for this SpecimenDefinition (Human friendly)", formalDefinition="A short, descriptive, user-friendly title for the SpecimenDefinition." )
2063    protected StringType title;
2064
2065    /**
2066     * The canonical URL pointing to another FHIR-defined SpecimenDefinition that is adhered to in whole or in part by this definition.
2067     */
2068    @Child(name = "derivedFromCanonical", type = {CanonicalType.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2069    @Description(shortDefinition="Based on FHIR definition of another SpecimenDefinition", formalDefinition="The canonical URL pointing to another FHIR-defined SpecimenDefinition that is adhered to in whole or in part by this definition." )
2070    protected List<CanonicalType> derivedFromCanonical;
2071
2072    /**
2073     * The URL pointing to an externally-defined type of specimen, guideline or other definition that is adhered to in whole or in part by this definition.
2074     */
2075    @Child(name = "derivedFromUri", type = {UriType.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2076    @Description(shortDefinition="Based on external definition", formalDefinition="The URL pointing to an externally-defined type of specimen, guideline or other definition that is adhered to in whole or in part by this definition." )
2077    protected List<UriType> derivedFromUri;
2078
2079    /**
2080     * The current state of theSpecimenDefinition.
2081     */
2082    @Child(name = "status", type = {CodeType.class}, order=6, min=1, max=1, modifier=true, summary=true)
2083    @Description(shortDefinition="draft | active | retired | unknown", formalDefinition="The current state of theSpecimenDefinition." )
2084    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/publication-status")
2085    protected Enumeration<PublicationStatus> status;
2086
2087    /**
2088     * A flag to indicate that this SpecimenDefinition is not authored for  genuine usage.
2089     */
2090    @Child(name = "experimental", type = {BooleanType.class}, order=7, min=0, max=1, modifier=true, summary=true)
2091    @Description(shortDefinition="If this SpecimenDefinition is not for real usage", formalDefinition="A flag to indicate that this SpecimenDefinition is not authored for  genuine usage." )
2092    protected BooleanType experimental;
2093
2094    /**
2095     * A code or group definition that describes the intended subject  from which this kind of specimen is to be collected.
2096     */
2097    @Child(name = "subject", type = {CodeableConcept.class, Group.class}, order=8, min=0, max=1, modifier=false, summary=true)
2098    @Description(shortDefinition="Type of subject for specimen collection", formalDefinition="A code or group definition that describes the intended subject  from which this kind of specimen is to be collected." )
2099    protected DataType subject;
2100
2101    /**
2102     * For draft definitions, indicates the date of initial creation. For active definitions, represents the date of activation. For withdrawn definitions, indicates the date of withdrawal.
2103     */
2104    @Child(name = "date", type = {DateTimeType.class}, order=9, min=0, max=1, modifier=false, summary=true)
2105    @Description(shortDefinition="Date status first applied", formalDefinition="For draft definitions, indicates the date of initial creation. For active definitions, represents the date of activation. For withdrawn definitions, indicates the date of withdrawal." )
2106    protected DateTimeType date;
2107
2108    /**
2109     * Helps establish the "authority/credibility" of the SpecimenDefinition. May also allow for contact.
2110     */
2111    @Child(name = "publisher", type = {Practitioner.class, PractitionerRole.class, Organization.class}, order=10, min=0, max=1, modifier=false, summary=true)
2112    @Description(shortDefinition="The name of the individual or organization that published the SpecimenDefinition", formalDefinition="Helps establish the \"authority/credibility\" of the SpecimenDefinition. May also allow for contact." )
2113    protected Reference publisher;
2114
2115    /**
2116     * Contact details to assist a user in finding and communicating with the publisher.
2117     */
2118    @Child(name = "contact", type = {ContactDetail.class}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2119    @Description(shortDefinition="Contact details for the publisher", formalDefinition="Contact details to assist a user in finding and communicating with the publisher." )
2120    protected List<ContactDetail> contact;
2121
2122    /**
2123     * A free text natural language description of the SpecimenDefinition from the consumer's perspective.
2124     */
2125    @Child(name = "description", type = {MarkdownType.class}, order=12, min=0, max=1, modifier=false, summary=false)
2126    @Description(shortDefinition="Natural language description of the SpecimenDefinition", formalDefinition="A free text natural language description of the SpecimenDefinition from the consumer's perspective." )
2127    protected MarkdownType description;
2128
2129    /**
2130     * The content was developed with a focus and intent of supporting the contexts that are listed. These terms may be used to assist with indexing and searching of specimen definitions.
2131     */
2132    @Child(name = "useContext", type = {UsageContext.class}, order=13, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2133    @Description(shortDefinition="Content intends to support these contexts", formalDefinition="The content was developed with a focus and intent of supporting the contexts that are listed. These terms may be used to assist with indexing and searching of specimen definitions." )
2134    protected List<UsageContext> useContext;
2135
2136    /**
2137     * A jurisdiction in which the SpecimenDefinition is intended to be used.
2138     */
2139    @Child(name = "jurisdiction", type = {CodeableConcept.class}, order=14, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2140    @Description(shortDefinition="Intended jurisdiction for this SpecimenDefinition (if applicable)", formalDefinition="A jurisdiction in which the SpecimenDefinition is intended to be used." )
2141    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/jurisdiction")
2142    protected List<CodeableConcept> jurisdiction;
2143
2144    /**
2145     * Explains why this SpecimeDefinition is needed and why it has been designed as it has.
2146     */
2147    @Child(name = "purpose", type = {MarkdownType.class}, order=15, min=0, max=1, modifier=false, summary=false)
2148    @Description(shortDefinition="Why this SpecimenDefinition is defined", formalDefinition="Explains why this SpecimeDefinition is needed and why it has been designed as it has." )
2149    protected MarkdownType purpose;
2150
2151    /**
2152     * Copyright statement relating to the SpecimenDefinition and/or its contents. Copyright statements are generally legal restrictions on the use and publishing of the SpecimenDefinition.
2153     */
2154    @Child(name = "copyright", type = {MarkdownType.class}, order=16, min=0, max=1, modifier=false, summary=false)
2155    @Description(shortDefinition="Use and/or publishing restrictions", formalDefinition="Copyright statement relating to the SpecimenDefinition and/or its contents. Copyright statements are generally legal restrictions on the use and publishing of the SpecimenDefinition." )
2156    protected MarkdownType copyright;
2157
2158    /**
2159     * The date on which the asset content was approved by the publisher. Approval happens once when the content is officially approved for usage.
2160     */
2161    @Child(name = "approvalDate", type = {DateType.class}, order=17, min=0, max=1, modifier=false, summary=false)
2162    @Description(shortDefinition="When SpecimenDefinition was approved by publisher", formalDefinition="The date on which the asset content was approved by the publisher. Approval happens once when the content is officially approved for usage." )
2163    protected DateType approvalDate;
2164
2165    /**
2166     * The date on which the asset content was last reviewed. Review happens periodically after that, but doesn't change the original approval date.
2167     */
2168    @Child(name = "lastReviewDate", type = {DateType.class}, order=18, min=0, max=1, modifier=false, summary=false)
2169    @Description(shortDefinition="The date on which the asset content was last reviewed", formalDefinition="The date on which the asset content was last reviewed. Review happens periodically after that, but doesn't change the original approval date." )
2170    protected DateType lastReviewDate;
2171
2172    /**
2173     * The period during which the SpecimenDefinition content was or is planned to be effective.
2174     */
2175    @Child(name = "effectivePeriod", type = {Period.class}, order=19, min=0, max=1, modifier=false, summary=true)
2176    @Description(shortDefinition="The effective date range for the SpecimenDefinition", formalDefinition="The period during which the SpecimenDefinition content was or is planned to be effective." )
2177    protected Period effectivePeriod;
2178
2179    /**
2180     * The kind of material to be collected.
2181     */
2182    @Child(name = "typeCollected", type = {CodeableConcept.class}, order=20, min=0, max=1, modifier=false, summary=true)
2183    @Description(shortDefinition="Kind of material to collect", formalDefinition="The kind of material to be collected." )
2184    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://terminology.hl7.org/ValueSet/v2-0487")
2185    protected CodeableConcept typeCollected;
2186
2187    /**
2188     * Preparation of the patient for specimen collection.
2189     */
2190    @Child(name = "patientPreparation", type = {CodeableConcept.class}, order=21, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2191    @Description(shortDefinition="Patient preparation for collection", formalDefinition="Preparation of the patient for specimen collection." )
2192    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/prepare-patient-prior-specimen-collection")
2193    protected List<CodeableConcept> patientPreparation;
2194
2195    /**
2196     * Time aspect of specimen collection (duration or offset).
2197     */
2198    @Child(name = "timeAspect", type = {StringType.class}, order=22, min=0, max=1, modifier=false, summary=true)
2199    @Description(shortDefinition="Time aspect for collection", formalDefinition="Time aspect of specimen collection (duration or offset)." )
2200    protected StringType timeAspect;
2201
2202    /**
2203     * The action to be performed for collecting the specimen.
2204     */
2205    @Child(name = "collection", type = {CodeableConcept.class}, order=23, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2206    @Description(shortDefinition="Specimen collection procedure", formalDefinition="The action to be performed for collecting the specimen." )
2207    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/specimen-collection")
2208    protected List<CodeableConcept> collection;
2209
2210    /**
2211     * Specimen conditioned in a container as expected by the testing laboratory.
2212     */
2213    @Child(name = "typeTested", type = {}, order=24, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2214    @Description(shortDefinition="Specimen in container intended for testing by lab", formalDefinition="Specimen conditioned in a container as expected by the testing laboratory." )
2215    protected List<SpecimenDefinitionTypeTestedComponent> typeTested;
2216
2217    private static final long serialVersionUID = 830184995L;
2218
2219  /**
2220   * Constructor
2221   */
2222    public SpecimenDefinition() {
2223      super();
2224    }
2225
2226  /**
2227   * Constructor
2228   */
2229    public SpecimenDefinition(PublicationStatus status) {
2230      super();
2231      this.setStatus(status);
2232    }
2233
2234    /**
2235     * @return {@link #url} (An absolute URL that is used to identify this SpecimenDefinition when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this SpecimenDefinition is (or will be) published. The URL SHOULD include the major version of the SpecimenDefinition. For more information see Technical and Business Versions.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value
2236     */
2237    public UriType getUrlElement() { 
2238      if (this.url == null)
2239        if (Configuration.errorOnAutoCreate())
2240          throw new Error("Attempt to auto-create SpecimenDefinition.url");
2241        else if (Configuration.doAutoCreate())
2242          this.url = new UriType(); // bb
2243      return this.url;
2244    }
2245
2246    public boolean hasUrlElement() { 
2247      return this.url != null && !this.url.isEmpty();
2248    }
2249
2250    public boolean hasUrl() { 
2251      return this.url != null && !this.url.isEmpty();
2252    }
2253
2254    /**
2255     * @param value {@link #url} (An absolute URL that is used to identify this SpecimenDefinition when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this SpecimenDefinition is (or will be) published. The URL SHOULD include the major version of the SpecimenDefinition. For more information see Technical and Business Versions.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value
2256     */
2257    public SpecimenDefinition setUrlElement(UriType value) { 
2258      this.url = value;
2259      return this;
2260    }
2261
2262    /**
2263     * @return An absolute URL that is used to identify this SpecimenDefinition when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this SpecimenDefinition is (or will be) published. The URL SHOULD include the major version of the SpecimenDefinition. For more information see Technical and Business Versions.
2264     */
2265    public String getUrl() { 
2266      return this.url == null ? null : this.url.getValue();
2267    }
2268
2269    /**
2270     * @param value An absolute URL that is used to identify this SpecimenDefinition when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this SpecimenDefinition is (or will be) published. The URL SHOULD include the major version of the SpecimenDefinition. For more information see Technical and Business Versions.
2271     */
2272    public SpecimenDefinition setUrl(String value) { 
2273      if (Utilities.noString(value))
2274        this.url = null;
2275      else {
2276        if (this.url == null)
2277          this.url = new UriType();
2278        this.url.setValue(value);
2279      }
2280      return this;
2281    }
2282
2283    /**
2284     * @return {@link #identifier} (A business identifier assigned to this SpecimenDefinition.)
2285     */
2286    public Identifier getIdentifier() { 
2287      if (this.identifier == null)
2288        if (Configuration.errorOnAutoCreate())
2289          throw new Error("Attempt to auto-create SpecimenDefinition.identifier");
2290        else if (Configuration.doAutoCreate())
2291          this.identifier = new Identifier(); // cc
2292      return this.identifier;
2293    }
2294
2295    public boolean hasIdentifier() { 
2296      return this.identifier != null && !this.identifier.isEmpty();
2297    }
2298
2299    /**
2300     * @param value {@link #identifier} (A business identifier assigned to this SpecimenDefinition.)
2301     */
2302    public SpecimenDefinition setIdentifier(Identifier value) { 
2303      this.identifier = value;
2304      return this;
2305    }
2306
2307    /**
2308     * @return {@link #version} (The identifier that is used to identify this version of the SpecimenDefinition when it is referenced in a specification, model, design or instance. This is an arbitrary value managed by the SpecimenDefinition author and is not expected to be globally unique.). This is the underlying object with id, value and extensions. The accessor "getVersion" gives direct access to the value
2309     */
2310    public StringType getVersionElement() { 
2311      if (this.version == null)
2312        if (Configuration.errorOnAutoCreate())
2313          throw new Error("Attempt to auto-create SpecimenDefinition.version");
2314        else if (Configuration.doAutoCreate())
2315          this.version = new StringType(); // bb
2316      return this.version;
2317    }
2318
2319    public boolean hasVersionElement() { 
2320      return this.version != null && !this.version.isEmpty();
2321    }
2322
2323    public boolean hasVersion() { 
2324      return this.version != null && !this.version.isEmpty();
2325    }
2326
2327    /**
2328     * @param value {@link #version} (The identifier that is used to identify this version of the SpecimenDefinition when it is referenced in a specification, model, design or instance. This is an arbitrary value managed by the SpecimenDefinition author and is not expected to be globally unique.). This is the underlying object with id, value and extensions. The accessor "getVersion" gives direct access to the value
2329     */
2330    public SpecimenDefinition setVersionElement(StringType value) { 
2331      this.version = value;
2332      return this;
2333    }
2334
2335    /**
2336     * @return The identifier that is used to identify this version of the SpecimenDefinition when it is referenced in a specification, model, design or instance. This is an arbitrary value managed by the SpecimenDefinition author and is not expected to be globally unique.
2337     */
2338    public String getVersion() { 
2339      return this.version == null ? null : this.version.getValue();
2340    }
2341
2342    /**
2343     * @param value The identifier that is used to identify this version of the SpecimenDefinition when it is referenced in a specification, model, design or instance. This is an arbitrary value managed by the SpecimenDefinition author and is not expected to be globally unique.
2344     */
2345    public SpecimenDefinition setVersion(String value) { 
2346      if (Utilities.noString(value))
2347        this.version = null;
2348      else {
2349        if (this.version == null)
2350          this.version = new StringType();
2351        this.version.setValue(value);
2352      }
2353      return this;
2354    }
2355
2356    /**
2357     * @return {@link #title} (A short, descriptive, user-friendly title for the SpecimenDefinition.). This is the underlying object with id, value and extensions. The accessor "getTitle" gives direct access to the value
2358     */
2359    public StringType getTitleElement() { 
2360      if (this.title == null)
2361        if (Configuration.errorOnAutoCreate())
2362          throw new Error("Attempt to auto-create SpecimenDefinition.title");
2363        else if (Configuration.doAutoCreate())
2364          this.title = new StringType(); // bb
2365      return this.title;
2366    }
2367
2368    public boolean hasTitleElement() { 
2369      return this.title != null && !this.title.isEmpty();
2370    }
2371
2372    public boolean hasTitle() { 
2373      return this.title != null && !this.title.isEmpty();
2374    }
2375
2376    /**
2377     * @param value {@link #title} (A short, descriptive, user-friendly title for the SpecimenDefinition.). This is the underlying object with id, value and extensions. The accessor "getTitle" gives direct access to the value
2378     */
2379    public SpecimenDefinition setTitleElement(StringType value) { 
2380      this.title = value;
2381      return this;
2382    }
2383
2384    /**
2385     * @return A short, descriptive, user-friendly title for the SpecimenDefinition.
2386     */
2387    public String getTitle() { 
2388      return this.title == null ? null : this.title.getValue();
2389    }
2390
2391    /**
2392     * @param value A short, descriptive, user-friendly title for the SpecimenDefinition.
2393     */
2394    public SpecimenDefinition setTitle(String value) { 
2395      if (Utilities.noString(value))
2396        this.title = null;
2397      else {
2398        if (this.title == null)
2399          this.title = new StringType();
2400        this.title.setValue(value);
2401      }
2402      return this;
2403    }
2404
2405    /**
2406     * @return {@link #derivedFromCanonical} (The canonical URL pointing to another FHIR-defined SpecimenDefinition that is adhered to in whole or in part by this definition.)
2407     */
2408    public List<CanonicalType> getDerivedFromCanonical() { 
2409      if (this.derivedFromCanonical == null)
2410        this.derivedFromCanonical = new ArrayList<CanonicalType>();
2411      return this.derivedFromCanonical;
2412    }
2413
2414    /**
2415     * @return Returns a reference to <code>this</code> for easy method chaining
2416     */
2417    public SpecimenDefinition setDerivedFromCanonical(List<CanonicalType> theDerivedFromCanonical) { 
2418      this.derivedFromCanonical = theDerivedFromCanonical;
2419      return this;
2420    }
2421
2422    public boolean hasDerivedFromCanonical() { 
2423      if (this.derivedFromCanonical == null)
2424        return false;
2425      for (CanonicalType item : this.derivedFromCanonical)
2426        if (!item.isEmpty())
2427          return true;
2428      return false;
2429    }
2430
2431    /**
2432     * @return {@link #derivedFromCanonical} (The canonical URL pointing to another FHIR-defined SpecimenDefinition that is adhered to in whole or in part by this definition.)
2433     */
2434    public CanonicalType addDerivedFromCanonicalElement() {//2 
2435      CanonicalType t = new CanonicalType();
2436      if (this.derivedFromCanonical == null)
2437        this.derivedFromCanonical = new ArrayList<CanonicalType>();
2438      this.derivedFromCanonical.add(t);
2439      return t;
2440    }
2441
2442    /**
2443     * @param value {@link #derivedFromCanonical} (The canonical URL pointing to another FHIR-defined SpecimenDefinition that is adhered to in whole or in part by this definition.)
2444     */
2445    public SpecimenDefinition addDerivedFromCanonical(String value) { //1
2446      CanonicalType t = new CanonicalType();
2447      t.setValue(value);
2448      if (this.derivedFromCanonical == null)
2449        this.derivedFromCanonical = new ArrayList<CanonicalType>();
2450      this.derivedFromCanonical.add(t);
2451      return this;
2452    }
2453
2454    /**
2455     * @param value {@link #derivedFromCanonical} (The canonical URL pointing to another FHIR-defined SpecimenDefinition that is adhered to in whole or in part by this definition.)
2456     */
2457    public boolean hasDerivedFromCanonical(String value) { 
2458      if (this.derivedFromCanonical == null)
2459        return false;
2460      for (CanonicalType v : this.derivedFromCanonical)
2461        if (v.getValue().equals(value)) // canonical
2462          return true;
2463      return false;
2464    }
2465
2466    /**
2467     * @return {@link #derivedFromUri} (The URL pointing to an externally-defined type of specimen, guideline or other definition that is adhered to in whole or in part by this definition.)
2468     */
2469    public List<UriType> getDerivedFromUri() { 
2470      if (this.derivedFromUri == null)
2471        this.derivedFromUri = new ArrayList<UriType>();
2472      return this.derivedFromUri;
2473    }
2474
2475    /**
2476     * @return Returns a reference to <code>this</code> for easy method chaining
2477     */
2478    public SpecimenDefinition setDerivedFromUri(List<UriType> theDerivedFromUri) { 
2479      this.derivedFromUri = theDerivedFromUri;
2480      return this;
2481    }
2482
2483    public boolean hasDerivedFromUri() { 
2484      if (this.derivedFromUri == null)
2485        return false;
2486      for (UriType item : this.derivedFromUri)
2487        if (!item.isEmpty())
2488          return true;
2489      return false;
2490    }
2491
2492    /**
2493     * @return {@link #derivedFromUri} (The URL pointing to an externally-defined type of specimen, guideline or other definition that is adhered to in whole or in part by this definition.)
2494     */
2495    public UriType addDerivedFromUriElement() {//2 
2496      UriType t = new UriType();
2497      if (this.derivedFromUri == null)
2498        this.derivedFromUri = new ArrayList<UriType>();
2499      this.derivedFromUri.add(t);
2500      return t;
2501    }
2502
2503    /**
2504     * @param value {@link #derivedFromUri} (The URL pointing to an externally-defined type of specimen, guideline or other definition that is adhered to in whole or in part by this definition.)
2505     */
2506    public SpecimenDefinition addDerivedFromUri(String value) { //1
2507      UriType t = new UriType();
2508      t.setValue(value);
2509      if (this.derivedFromUri == null)
2510        this.derivedFromUri = new ArrayList<UriType>();
2511      this.derivedFromUri.add(t);
2512      return this;
2513    }
2514
2515    /**
2516     * @param value {@link #derivedFromUri} (The URL pointing to an externally-defined type of specimen, guideline or other definition that is adhered to in whole or in part by this definition.)
2517     */
2518    public boolean hasDerivedFromUri(String value) { 
2519      if (this.derivedFromUri == null)
2520        return false;
2521      for (UriType v : this.derivedFromUri)
2522        if (v.getValue().equals(value)) // uri
2523          return true;
2524      return false;
2525    }
2526
2527    /**
2528     * @return {@link #status} (The current state of theSpecimenDefinition.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
2529     */
2530    public Enumeration<PublicationStatus> getStatusElement() { 
2531      if (this.status == null)
2532        if (Configuration.errorOnAutoCreate())
2533          throw new Error("Attempt to auto-create SpecimenDefinition.status");
2534        else if (Configuration.doAutoCreate())
2535          this.status = new Enumeration<PublicationStatus>(new PublicationStatusEnumFactory()); // bb
2536      return this.status;
2537    }
2538
2539    public boolean hasStatusElement() { 
2540      return this.status != null && !this.status.isEmpty();
2541    }
2542
2543    public boolean hasStatus() { 
2544      return this.status != null && !this.status.isEmpty();
2545    }
2546
2547    /**
2548     * @param value {@link #status} (The current state of theSpecimenDefinition.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
2549     */
2550    public SpecimenDefinition setStatusElement(Enumeration<PublicationStatus> value) { 
2551      this.status = value;
2552      return this;
2553    }
2554
2555    /**
2556     * @return The current state of theSpecimenDefinition.
2557     */
2558    public PublicationStatus getStatus() { 
2559      return this.status == null ? null : this.status.getValue();
2560    }
2561
2562    /**
2563     * @param value The current state of theSpecimenDefinition.
2564     */
2565    public SpecimenDefinition setStatus(PublicationStatus value) { 
2566        if (this.status == null)
2567          this.status = new Enumeration<PublicationStatus>(new PublicationStatusEnumFactory());
2568        this.status.setValue(value);
2569      return this;
2570    }
2571
2572    /**
2573     * @return {@link #experimental} (A flag to indicate that this SpecimenDefinition is not authored for  genuine usage.). This is the underlying object with id, value and extensions. The accessor "getExperimental" gives direct access to the value
2574     */
2575    public BooleanType getExperimentalElement() { 
2576      if (this.experimental == null)
2577        if (Configuration.errorOnAutoCreate())
2578          throw new Error("Attempt to auto-create SpecimenDefinition.experimental");
2579        else if (Configuration.doAutoCreate())
2580          this.experimental = new BooleanType(); // bb
2581      return this.experimental;
2582    }
2583
2584    public boolean hasExperimentalElement() { 
2585      return this.experimental != null && !this.experimental.isEmpty();
2586    }
2587
2588    public boolean hasExperimental() { 
2589      return this.experimental != null && !this.experimental.isEmpty();
2590    }
2591
2592    /**
2593     * @param value {@link #experimental} (A flag to indicate that this SpecimenDefinition is not authored for  genuine usage.). This is the underlying object with id, value and extensions. The accessor "getExperimental" gives direct access to the value
2594     */
2595    public SpecimenDefinition setExperimentalElement(BooleanType value) { 
2596      this.experimental = value;
2597      return this;
2598    }
2599
2600    /**
2601     * @return A flag to indicate that this SpecimenDefinition is not authored for  genuine usage.
2602     */
2603    public boolean getExperimental() { 
2604      return this.experimental == null || this.experimental.isEmpty() ? false : this.experimental.getValue();
2605    }
2606
2607    /**
2608     * @param value A flag to indicate that this SpecimenDefinition is not authored for  genuine usage.
2609     */
2610    public SpecimenDefinition setExperimental(boolean value) { 
2611        if (this.experimental == null)
2612          this.experimental = new BooleanType();
2613        this.experimental.setValue(value);
2614      return this;
2615    }
2616
2617    /**
2618     * @return {@link #subject} (A code or group definition that describes the intended subject  from which this kind of specimen is to be collected.)
2619     */
2620    public DataType getSubject() { 
2621      return this.subject;
2622    }
2623
2624    /**
2625     * @return {@link #subject} (A code or group definition that describes the intended subject  from which this kind of specimen is to be collected.)
2626     */
2627    public CodeableConcept getSubjectCodeableConcept() throws FHIRException { 
2628      if (this.subject == null)
2629        this.subject = new CodeableConcept();
2630      if (!(this.subject instanceof CodeableConcept))
2631        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.subject.getClass().getName()+" was encountered");
2632      return (CodeableConcept) this.subject;
2633    }
2634
2635    public boolean hasSubjectCodeableConcept() { 
2636      return this != null && this.subject instanceof CodeableConcept;
2637    }
2638
2639    /**
2640     * @return {@link #subject} (A code or group definition that describes the intended subject  from which this kind of specimen is to be collected.)
2641     */
2642    public Reference getSubjectReference() throws FHIRException { 
2643      if (this.subject == null)
2644        this.subject = new Reference();
2645      if (!(this.subject instanceof Reference))
2646        throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.subject.getClass().getName()+" was encountered");
2647      return (Reference) this.subject;
2648    }
2649
2650    public boolean hasSubjectReference() { 
2651      return this != null && this.subject instanceof Reference;
2652    }
2653
2654    public boolean hasSubject() { 
2655      return this.subject != null && !this.subject.isEmpty();
2656    }
2657
2658    /**
2659     * @param value {@link #subject} (A code or group definition that describes the intended subject  from which this kind of specimen is to be collected.)
2660     */
2661    public SpecimenDefinition setSubject(DataType value) { 
2662      if (value != null && !(value instanceof CodeableConcept || value instanceof Reference))
2663        throw new Error("Not the right type for SpecimenDefinition.subject[x]: "+value.fhirType());
2664      this.subject = value;
2665      return this;
2666    }
2667
2668    /**
2669     * @return {@link #date} (For draft definitions, indicates the date of initial creation. For active definitions, represents the date of activation. For withdrawn definitions, indicates the date of withdrawal.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
2670     */
2671    public DateTimeType getDateElement() { 
2672      if (this.date == null)
2673        if (Configuration.errorOnAutoCreate())
2674          throw new Error("Attempt to auto-create SpecimenDefinition.date");
2675        else if (Configuration.doAutoCreate())
2676          this.date = new DateTimeType(); // bb
2677      return this.date;
2678    }
2679
2680    public boolean hasDateElement() { 
2681      return this.date != null && !this.date.isEmpty();
2682    }
2683
2684    public boolean hasDate() { 
2685      return this.date != null && !this.date.isEmpty();
2686    }
2687
2688    /**
2689     * @param value {@link #date} (For draft definitions, indicates the date of initial creation. For active definitions, represents the date of activation. For withdrawn definitions, indicates the date of withdrawal.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
2690     */
2691    public SpecimenDefinition setDateElement(DateTimeType value) { 
2692      this.date = value;
2693      return this;
2694    }
2695
2696    /**
2697     * @return For draft definitions, indicates the date of initial creation. For active definitions, represents the date of activation. For withdrawn definitions, indicates the date of withdrawal.
2698     */
2699    public Date getDate() { 
2700      return this.date == null ? null : this.date.getValue();
2701    }
2702
2703    /**
2704     * @param value For draft definitions, indicates the date of initial creation. For active definitions, represents the date of activation. For withdrawn definitions, indicates the date of withdrawal.
2705     */
2706    public SpecimenDefinition setDate(Date value) { 
2707      if (value == null)
2708        this.date = null;
2709      else {
2710        if (this.date == null)
2711          this.date = new DateTimeType();
2712        this.date.setValue(value);
2713      }
2714      return this;
2715    }
2716
2717    /**
2718     * @return {@link #publisher} (Helps establish the "authority/credibility" of the SpecimenDefinition. May also allow for contact.)
2719     */
2720    public Reference getPublisher() { 
2721      if (this.publisher == null)
2722        if (Configuration.errorOnAutoCreate())
2723          throw new Error("Attempt to auto-create SpecimenDefinition.publisher");
2724        else if (Configuration.doAutoCreate())
2725          this.publisher = new Reference(); // cc
2726      return this.publisher;
2727    }
2728
2729    public boolean hasPublisher() { 
2730      return this.publisher != null && !this.publisher.isEmpty();
2731    }
2732
2733    /**
2734     * @param value {@link #publisher} (Helps establish the "authority/credibility" of the SpecimenDefinition. May also allow for contact.)
2735     */
2736    public SpecimenDefinition setPublisher(Reference value) { 
2737      this.publisher = value;
2738      return this;
2739    }
2740
2741    /**
2742     * @return {@link #contact} (Contact details to assist a user in finding and communicating with the publisher.)
2743     */
2744    public List<ContactDetail> getContact() { 
2745      if (this.contact == null)
2746        this.contact = new ArrayList<ContactDetail>();
2747      return this.contact;
2748    }
2749
2750    /**
2751     * @return Returns a reference to <code>this</code> for easy method chaining
2752     */
2753    public SpecimenDefinition setContact(List<ContactDetail> theContact) { 
2754      this.contact = theContact;
2755      return this;
2756    }
2757
2758    public boolean hasContact() { 
2759      if (this.contact == null)
2760        return false;
2761      for (ContactDetail item : this.contact)
2762        if (!item.isEmpty())
2763          return true;
2764      return false;
2765    }
2766
2767    public ContactDetail addContact() { //3
2768      ContactDetail t = new ContactDetail();
2769      if (this.contact == null)
2770        this.contact = new ArrayList<ContactDetail>();
2771      this.contact.add(t);
2772      return t;
2773    }
2774
2775    public SpecimenDefinition addContact(ContactDetail t) { //3
2776      if (t == null)
2777        return this;
2778      if (this.contact == null)
2779        this.contact = new ArrayList<ContactDetail>();
2780      this.contact.add(t);
2781      return this;
2782    }
2783
2784    /**
2785     * @return The first repetition of repeating field {@link #contact}, creating it if it does not already exist {3}
2786     */
2787    public ContactDetail getContactFirstRep() { 
2788      if (getContact().isEmpty()) {
2789        addContact();
2790      }
2791      return getContact().get(0);
2792    }
2793
2794    /**
2795     * @return {@link #description} (A free text natural language description of the SpecimenDefinition from the consumer's perspective.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
2796     */
2797    public MarkdownType getDescriptionElement() { 
2798      if (this.description == null)
2799        if (Configuration.errorOnAutoCreate())
2800          throw new Error("Attempt to auto-create SpecimenDefinition.description");
2801        else if (Configuration.doAutoCreate())
2802          this.description = new MarkdownType(); // bb
2803      return this.description;
2804    }
2805
2806    public boolean hasDescriptionElement() { 
2807      return this.description != null && !this.description.isEmpty();
2808    }
2809
2810    public boolean hasDescription() { 
2811      return this.description != null && !this.description.isEmpty();
2812    }
2813
2814    /**
2815     * @param value {@link #description} (A free text natural language description of the SpecimenDefinition from the consumer's perspective.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
2816     */
2817    public SpecimenDefinition setDescriptionElement(MarkdownType value) { 
2818      this.description = value;
2819      return this;
2820    }
2821
2822    /**
2823     * @return A free text natural language description of the SpecimenDefinition from the consumer's perspective.
2824     */
2825    public String getDescription() { 
2826      return this.description == null ? null : this.description.getValue();
2827    }
2828
2829    /**
2830     * @param value A free text natural language description of the SpecimenDefinition from the consumer's perspective.
2831     */
2832    public SpecimenDefinition setDescription(String value) { 
2833      if (value == null)
2834        this.description = null;
2835      else {
2836        if (this.description == null)
2837          this.description = new MarkdownType();
2838        this.description.setValue(value);
2839      }
2840      return this;
2841    }
2842
2843    /**
2844     * @return {@link #useContext} (The content was developed with a focus and intent of supporting the contexts that are listed. These terms may be used to assist with indexing and searching of specimen definitions.)
2845     */
2846    public List<UsageContext> getUseContext() { 
2847      if (this.useContext == null)
2848        this.useContext = new ArrayList<UsageContext>();
2849      return this.useContext;
2850    }
2851
2852    /**
2853     * @return Returns a reference to <code>this</code> for easy method chaining
2854     */
2855    public SpecimenDefinition setUseContext(List<UsageContext> theUseContext) { 
2856      this.useContext = theUseContext;
2857      return this;
2858    }
2859
2860    public boolean hasUseContext() { 
2861      if (this.useContext == null)
2862        return false;
2863      for (UsageContext item : this.useContext)
2864        if (!item.isEmpty())
2865          return true;
2866      return false;
2867    }
2868
2869    public UsageContext addUseContext() { //3
2870      UsageContext t = new UsageContext();
2871      if (this.useContext == null)
2872        this.useContext = new ArrayList<UsageContext>();
2873      this.useContext.add(t);
2874      return t;
2875    }
2876
2877    public SpecimenDefinition addUseContext(UsageContext t) { //3
2878      if (t == null)
2879        return this;
2880      if (this.useContext == null)
2881        this.useContext = new ArrayList<UsageContext>();
2882      this.useContext.add(t);
2883      return this;
2884    }
2885
2886    /**
2887     * @return The first repetition of repeating field {@link #useContext}, creating it if it does not already exist {3}
2888     */
2889    public UsageContext getUseContextFirstRep() { 
2890      if (getUseContext().isEmpty()) {
2891        addUseContext();
2892      }
2893      return getUseContext().get(0);
2894    }
2895
2896    /**
2897     * @return {@link #jurisdiction} (A jurisdiction in which the SpecimenDefinition is intended to be used.)
2898     */
2899    public List<CodeableConcept> getJurisdiction() { 
2900      if (this.jurisdiction == null)
2901        this.jurisdiction = new ArrayList<CodeableConcept>();
2902      return this.jurisdiction;
2903    }
2904
2905    /**
2906     * @return Returns a reference to <code>this</code> for easy method chaining
2907     */
2908    public SpecimenDefinition setJurisdiction(List<CodeableConcept> theJurisdiction) { 
2909      this.jurisdiction = theJurisdiction;
2910      return this;
2911    }
2912
2913    public boolean hasJurisdiction() { 
2914      if (this.jurisdiction == null)
2915        return false;
2916      for (CodeableConcept item : this.jurisdiction)
2917        if (!item.isEmpty())
2918          return true;
2919      return false;
2920    }
2921
2922    public CodeableConcept addJurisdiction() { //3
2923      CodeableConcept t = new CodeableConcept();
2924      if (this.jurisdiction == null)
2925        this.jurisdiction = new ArrayList<CodeableConcept>();
2926      this.jurisdiction.add(t);
2927      return t;
2928    }
2929
2930    public SpecimenDefinition addJurisdiction(CodeableConcept t) { //3
2931      if (t == null)
2932        return this;
2933      if (this.jurisdiction == null)
2934        this.jurisdiction = new ArrayList<CodeableConcept>();
2935      this.jurisdiction.add(t);
2936      return this;
2937    }
2938
2939    /**
2940     * @return The first repetition of repeating field {@link #jurisdiction}, creating it if it does not already exist {3}
2941     */
2942    public CodeableConcept getJurisdictionFirstRep() { 
2943      if (getJurisdiction().isEmpty()) {
2944        addJurisdiction();
2945      }
2946      return getJurisdiction().get(0);
2947    }
2948
2949    /**
2950     * @return {@link #purpose} (Explains why this SpecimeDefinition is needed and why it has been designed as it has.). This is the underlying object with id, value and extensions. The accessor "getPurpose" gives direct access to the value
2951     */
2952    public MarkdownType getPurposeElement() { 
2953      if (this.purpose == null)
2954        if (Configuration.errorOnAutoCreate())
2955          throw new Error("Attempt to auto-create SpecimenDefinition.purpose");
2956        else if (Configuration.doAutoCreate())
2957          this.purpose = new MarkdownType(); // bb
2958      return this.purpose;
2959    }
2960
2961    public boolean hasPurposeElement() { 
2962      return this.purpose != null && !this.purpose.isEmpty();
2963    }
2964
2965    public boolean hasPurpose() { 
2966      return this.purpose != null && !this.purpose.isEmpty();
2967    }
2968
2969    /**
2970     * @param value {@link #purpose} (Explains why this SpecimeDefinition is needed and why it has been designed as it has.). This is the underlying object with id, value and extensions. The accessor "getPurpose" gives direct access to the value
2971     */
2972    public SpecimenDefinition setPurposeElement(MarkdownType value) { 
2973      this.purpose = value;
2974      return this;
2975    }
2976
2977    /**
2978     * @return Explains why this SpecimeDefinition is needed and why it has been designed as it has.
2979     */
2980    public String getPurpose() { 
2981      return this.purpose == null ? null : this.purpose.getValue();
2982    }
2983
2984    /**
2985     * @param value Explains why this SpecimeDefinition is needed and why it has been designed as it has.
2986     */
2987    public SpecimenDefinition setPurpose(String value) { 
2988      if (value == null)
2989        this.purpose = null;
2990      else {
2991        if (this.purpose == null)
2992          this.purpose = new MarkdownType();
2993        this.purpose.setValue(value);
2994      }
2995      return this;
2996    }
2997
2998    /**
2999     * @return {@link #copyright} (Copyright statement relating to the SpecimenDefinition and/or its contents. Copyright statements are generally legal restrictions on the use and publishing of the SpecimenDefinition.). This is the underlying object with id, value and extensions. The accessor "getCopyright" gives direct access to the value
3000     */
3001    public MarkdownType getCopyrightElement() { 
3002      if (this.copyright == null)
3003        if (Configuration.errorOnAutoCreate())
3004          throw new Error("Attempt to auto-create SpecimenDefinition.copyright");
3005        else if (Configuration.doAutoCreate())
3006          this.copyright = new MarkdownType(); // bb
3007      return this.copyright;
3008    }
3009
3010    public boolean hasCopyrightElement() { 
3011      return this.copyright != null && !this.copyright.isEmpty();
3012    }
3013
3014    public boolean hasCopyright() { 
3015      return this.copyright != null && !this.copyright.isEmpty();
3016    }
3017
3018    /**
3019     * @param value {@link #copyright} (Copyright statement relating to the SpecimenDefinition and/or its contents. Copyright statements are generally legal restrictions on the use and publishing of the SpecimenDefinition.). This is the underlying object with id, value and extensions. The accessor "getCopyright" gives direct access to the value
3020     */
3021    public SpecimenDefinition setCopyrightElement(MarkdownType value) { 
3022      this.copyright = value;
3023      return this;
3024    }
3025
3026    /**
3027     * @return Copyright statement relating to the SpecimenDefinition and/or its contents. Copyright statements are generally legal restrictions on the use and publishing of the SpecimenDefinition.
3028     */
3029    public String getCopyright() { 
3030      return this.copyright == null ? null : this.copyright.getValue();
3031    }
3032
3033    /**
3034     * @param value Copyright statement relating to the SpecimenDefinition and/or its contents. Copyright statements are generally legal restrictions on the use and publishing of the SpecimenDefinition.
3035     */
3036    public SpecimenDefinition setCopyright(String value) { 
3037      if (value == null)
3038        this.copyright = null;
3039      else {
3040        if (this.copyright == null)
3041          this.copyright = new MarkdownType();
3042        this.copyright.setValue(value);
3043      }
3044      return this;
3045    }
3046
3047    /**
3048     * @return {@link #approvalDate} (The date on which the asset content was approved by the publisher. Approval happens once when the content is officially approved for usage.). This is the underlying object with id, value and extensions. The accessor "getApprovalDate" gives direct access to the value
3049     */
3050    public DateType getApprovalDateElement() { 
3051      if (this.approvalDate == null)
3052        if (Configuration.errorOnAutoCreate())
3053          throw new Error("Attempt to auto-create SpecimenDefinition.approvalDate");
3054        else if (Configuration.doAutoCreate())
3055          this.approvalDate = new DateType(); // bb
3056      return this.approvalDate;
3057    }
3058
3059    public boolean hasApprovalDateElement() { 
3060      return this.approvalDate != null && !this.approvalDate.isEmpty();
3061    }
3062
3063    public boolean hasApprovalDate() { 
3064      return this.approvalDate != null && !this.approvalDate.isEmpty();
3065    }
3066
3067    /**
3068     * @param value {@link #approvalDate} (The date on which the asset content was approved by the publisher. Approval happens once when the content is officially approved for usage.). This is the underlying object with id, value and extensions. The accessor "getApprovalDate" gives direct access to the value
3069     */
3070    public SpecimenDefinition setApprovalDateElement(DateType value) { 
3071      this.approvalDate = value;
3072      return this;
3073    }
3074
3075    /**
3076     * @return The date on which the asset content was approved by the publisher. Approval happens once when the content is officially approved for usage.
3077     */
3078    public Date getApprovalDate() { 
3079      return this.approvalDate == null ? null : this.approvalDate.getValue();
3080    }
3081
3082    /**
3083     * @param value The date on which the asset content was approved by the publisher. Approval happens once when the content is officially approved for usage.
3084     */
3085    public SpecimenDefinition setApprovalDate(Date value) { 
3086      if (value == null)
3087        this.approvalDate = null;
3088      else {
3089        if (this.approvalDate == null)
3090          this.approvalDate = new DateType();
3091        this.approvalDate.setValue(value);
3092      }
3093      return this;
3094    }
3095
3096    /**
3097     * @return {@link #lastReviewDate} (The date on which the asset content was last reviewed. Review happens periodically after that, but doesn't change the original approval date.). This is the underlying object with id, value and extensions. The accessor "getLastReviewDate" gives direct access to the value
3098     */
3099    public DateType getLastReviewDateElement() { 
3100      if (this.lastReviewDate == null)
3101        if (Configuration.errorOnAutoCreate())
3102          throw new Error("Attempt to auto-create SpecimenDefinition.lastReviewDate");
3103        else if (Configuration.doAutoCreate())
3104          this.lastReviewDate = new DateType(); // bb
3105      return this.lastReviewDate;
3106    }
3107
3108    public boolean hasLastReviewDateElement() { 
3109      return this.lastReviewDate != null && !this.lastReviewDate.isEmpty();
3110    }
3111
3112    public boolean hasLastReviewDate() { 
3113      return this.lastReviewDate != null && !this.lastReviewDate.isEmpty();
3114    }
3115
3116    /**
3117     * @param value {@link #lastReviewDate} (The date on which the asset content was last reviewed. Review happens periodically after that, but doesn't change the original approval date.). This is the underlying object with id, value and extensions. The accessor "getLastReviewDate" gives direct access to the value
3118     */
3119    public SpecimenDefinition setLastReviewDateElement(DateType value) { 
3120      this.lastReviewDate = value;
3121      return this;
3122    }
3123
3124    /**
3125     * @return The date on which the asset content was last reviewed. Review happens periodically after that, but doesn't change the original approval date.
3126     */
3127    public Date getLastReviewDate() { 
3128      return this.lastReviewDate == null ? null : this.lastReviewDate.getValue();
3129    }
3130
3131    /**
3132     * @param value The date on which the asset content was last reviewed. Review happens periodically after that, but doesn't change the original approval date.
3133     */
3134    public SpecimenDefinition setLastReviewDate(Date value) { 
3135      if (value == null)
3136        this.lastReviewDate = null;
3137      else {
3138        if (this.lastReviewDate == null)
3139          this.lastReviewDate = new DateType();
3140        this.lastReviewDate.setValue(value);
3141      }
3142      return this;
3143    }
3144
3145    /**
3146     * @return {@link #effectivePeriod} (The period during which the SpecimenDefinition content was or is planned to be effective.)
3147     */
3148    public Period getEffectivePeriod() { 
3149      if (this.effectivePeriod == null)
3150        if (Configuration.errorOnAutoCreate())
3151          throw new Error("Attempt to auto-create SpecimenDefinition.effectivePeriod");
3152        else if (Configuration.doAutoCreate())
3153          this.effectivePeriod = new Period(); // cc
3154      return this.effectivePeriod;
3155    }
3156
3157    public boolean hasEffectivePeriod() { 
3158      return this.effectivePeriod != null && !this.effectivePeriod.isEmpty();
3159    }
3160
3161    /**
3162     * @param value {@link #effectivePeriod} (The period during which the SpecimenDefinition content was or is planned to be effective.)
3163     */
3164    public SpecimenDefinition setEffectivePeriod(Period value) { 
3165      this.effectivePeriod = value;
3166      return this;
3167    }
3168
3169    /**
3170     * @return {@link #typeCollected} (The kind of material to be collected.)
3171     */
3172    public CodeableConcept getTypeCollected() { 
3173      if (this.typeCollected == null)
3174        if (Configuration.errorOnAutoCreate())
3175          throw new Error("Attempt to auto-create SpecimenDefinition.typeCollected");
3176        else if (Configuration.doAutoCreate())
3177          this.typeCollected = new CodeableConcept(); // cc
3178      return this.typeCollected;
3179    }
3180
3181    public boolean hasTypeCollected() { 
3182      return this.typeCollected != null && !this.typeCollected.isEmpty();
3183    }
3184
3185    /**
3186     * @param value {@link #typeCollected} (The kind of material to be collected.)
3187     */
3188    public SpecimenDefinition setTypeCollected(CodeableConcept value) { 
3189      this.typeCollected = value;
3190      return this;
3191    }
3192
3193    /**
3194     * @return {@link #patientPreparation} (Preparation of the patient for specimen collection.)
3195     */
3196    public List<CodeableConcept> getPatientPreparation() { 
3197      if (this.patientPreparation == null)
3198        this.patientPreparation = new ArrayList<CodeableConcept>();
3199      return this.patientPreparation;
3200    }
3201
3202    /**
3203     * @return Returns a reference to <code>this</code> for easy method chaining
3204     */
3205    public SpecimenDefinition setPatientPreparation(List<CodeableConcept> thePatientPreparation) { 
3206      this.patientPreparation = thePatientPreparation;
3207      return this;
3208    }
3209
3210    public boolean hasPatientPreparation() { 
3211      if (this.patientPreparation == null)
3212        return false;
3213      for (CodeableConcept item : this.patientPreparation)
3214        if (!item.isEmpty())
3215          return true;
3216      return false;
3217    }
3218
3219    public CodeableConcept addPatientPreparation() { //3
3220      CodeableConcept t = new CodeableConcept();
3221      if (this.patientPreparation == null)
3222        this.patientPreparation = new ArrayList<CodeableConcept>();
3223      this.patientPreparation.add(t);
3224      return t;
3225    }
3226
3227    public SpecimenDefinition addPatientPreparation(CodeableConcept t) { //3
3228      if (t == null)
3229        return this;
3230      if (this.patientPreparation == null)
3231        this.patientPreparation = new ArrayList<CodeableConcept>();
3232      this.patientPreparation.add(t);
3233      return this;
3234    }
3235
3236    /**
3237     * @return The first repetition of repeating field {@link #patientPreparation}, creating it if it does not already exist {3}
3238     */
3239    public CodeableConcept getPatientPreparationFirstRep() { 
3240      if (getPatientPreparation().isEmpty()) {
3241        addPatientPreparation();
3242      }
3243      return getPatientPreparation().get(0);
3244    }
3245
3246    /**
3247     * @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
3248     */
3249    public StringType getTimeAspectElement() { 
3250      if (this.timeAspect == null)
3251        if (Configuration.errorOnAutoCreate())
3252          throw new Error("Attempt to auto-create SpecimenDefinition.timeAspect");
3253        else if (Configuration.doAutoCreate())
3254          this.timeAspect = new StringType(); // bb
3255      return this.timeAspect;
3256    }
3257
3258    public boolean hasTimeAspectElement() { 
3259      return this.timeAspect != null && !this.timeAspect.isEmpty();
3260    }
3261
3262    public boolean hasTimeAspect() { 
3263      return this.timeAspect != null && !this.timeAspect.isEmpty();
3264    }
3265
3266    /**
3267     * @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
3268     */
3269    public SpecimenDefinition setTimeAspectElement(StringType value) { 
3270      this.timeAspect = value;
3271      return this;
3272    }
3273
3274    /**
3275     * @return Time aspect of specimen collection (duration or offset).
3276     */
3277    public String getTimeAspect() { 
3278      return this.timeAspect == null ? null : this.timeAspect.getValue();
3279    }
3280
3281    /**
3282     * @param value Time aspect of specimen collection (duration or offset).
3283     */
3284    public SpecimenDefinition setTimeAspect(String value) { 
3285      if (Utilities.noString(value))
3286        this.timeAspect = null;
3287      else {
3288        if (this.timeAspect == null)
3289          this.timeAspect = new StringType();
3290        this.timeAspect.setValue(value);
3291      }
3292      return this;
3293    }
3294
3295    /**
3296     * @return {@link #collection} (The action to be performed for collecting the specimen.)
3297     */
3298    public List<CodeableConcept> getCollection() { 
3299      if (this.collection == null)
3300        this.collection = new ArrayList<CodeableConcept>();
3301      return this.collection;
3302    }
3303
3304    /**
3305     * @return Returns a reference to <code>this</code> for easy method chaining
3306     */
3307    public SpecimenDefinition setCollection(List<CodeableConcept> theCollection) { 
3308      this.collection = theCollection;
3309      return this;
3310    }
3311
3312    public boolean hasCollection() { 
3313      if (this.collection == null)
3314        return false;
3315      for (CodeableConcept item : this.collection)
3316        if (!item.isEmpty())
3317          return true;
3318      return false;
3319    }
3320
3321    public CodeableConcept addCollection() { //3
3322      CodeableConcept t = new CodeableConcept();
3323      if (this.collection == null)
3324        this.collection = new ArrayList<CodeableConcept>();
3325      this.collection.add(t);
3326      return t;
3327    }
3328
3329    public SpecimenDefinition addCollection(CodeableConcept t) { //3
3330      if (t == null)
3331        return this;
3332      if (this.collection == null)
3333        this.collection = new ArrayList<CodeableConcept>();
3334      this.collection.add(t);
3335      return this;
3336    }
3337
3338    /**
3339     * @return The first repetition of repeating field {@link #collection}, creating it if it does not already exist {3}
3340     */
3341    public CodeableConcept getCollectionFirstRep() { 
3342      if (getCollection().isEmpty()) {
3343        addCollection();
3344      }
3345      return getCollection().get(0);
3346    }
3347
3348    /**
3349     * @return {@link #typeTested} (Specimen conditioned in a container as expected by the testing laboratory.)
3350     */
3351    public List<SpecimenDefinitionTypeTestedComponent> getTypeTested() { 
3352      if (this.typeTested == null)
3353        this.typeTested = new ArrayList<SpecimenDefinitionTypeTestedComponent>();
3354      return this.typeTested;
3355    }
3356
3357    /**
3358     * @return Returns a reference to <code>this</code> for easy method chaining
3359     */
3360    public SpecimenDefinition setTypeTested(List<SpecimenDefinitionTypeTestedComponent> theTypeTested) { 
3361      this.typeTested = theTypeTested;
3362      return this;
3363    }
3364
3365    public boolean hasTypeTested() { 
3366      if (this.typeTested == null)
3367        return false;
3368      for (SpecimenDefinitionTypeTestedComponent item : this.typeTested)
3369        if (!item.isEmpty())
3370          return true;
3371      return false;
3372    }
3373
3374    public SpecimenDefinitionTypeTestedComponent addTypeTested() { //3
3375      SpecimenDefinitionTypeTestedComponent t = new SpecimenDefinitionTypeTestedComponent();
3376      if (this.typeTested == null)
3377        this.typeTested = new ArrayList<SpecimenDefinitionTypeTestedComponent>();
3378      this.typeTested.add(t);
3379      return t;
3380    }
3381
3382    public SpecimenDefinition addTypeTested(SpecimenDefinitionTypeTestedComponent t) { //3
3383      if (t == null)
3384        return this;
3385      if (this.typeTested == null)
3386        this.typeTested = new ArrayList<SpecimenDefinitionTypeTestedComponent>();
3387      this.typeTested.add(t);
3388      return this;
3389    }
3390
3391    /**
3392     * @return The first repetition of repeating field {@link #typeTested}, creating it if it does not already exist {3}
3393     */
3394    public SpecimenDefinitionTypeTestedComponent getTypeTestedFirstRep() { 
3395      if (getTypeTested().isEmpty()) {
3396        addTypeTested();
3397      }
3398      return getTypeTested().get(0);
3399    }
3400
3401      protected void listChildren(List<Property> children) {
3402        super.listChildren(children);
3403        children.add(new Property("url", "uri", "An absolute URL that is used to identify this SpecimenDefinition when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this SpecimenDefinition is (or will be) published. The URL SHOULD include the major version of the SpecimenDefinition. For more information see Technical and Business Versions.", 0, 1, url));
3404        children.add(new Property("identifier", "Identifier", "A business identifier assigned to this SpecimenDefinition.", 0, 1, identifier));
3405        children.add(new Property("version", "string", "The identifier that is used to identify this version of the SpecimenDefinition when it is referenced in a specification, model, design or instance. This is an arbitrary value managed by the SpecimenDefinition author and is not expected to be globally unique.", 0, 1, version));
3406        children.add(new Property("title", "string", "A short, descriptive, user-friendly title for the SpecimenDefinition.", 0, 1, title));
3407        children.add(new Property("derivedFromCanonical", "canonical(SpecimenDefinition)", "The canonical URL pointing to another FHIR-defined SpecimenDefinition that is adhered to in whole or in part by this definition.", 0, java.lang.Integer.MAX_VALUE, derivedFromCanonical));
3408        children.add(new Property("derivedFromUri", "uri", "The URL pointing to an externally-defined type of specimen, guideline or other definition that is adhered to in whole or in part by this definition.", 0, java.lang.Integer.MAX_VALUE, derivedFromUri));
3409        children.add(new Property("status", "code", "The current state of theSpecimenDefinition.", 0, 1, status));
3410        children.add(new Property("experimental", "boolean", "A flag to indicate that this SpecimenDefinition is not authored for  genuine usage.", 0, 1, experimental));
3411        children.add(new Property("subject[x]", "CodeableConcept|Reference(Group)", "A code or group definition that describes the intended subject  from which this kind of specimen is to be collected.", 0, 1, subject));
3412        children.add(new Property("date", "dateTime", "For draft definitions, indicates the date of initial creation. For active definitions, represents the date of activation. For withdrawn definitions, indicates the date of withdrawal.", 0, 1, date));
3413        children.add(new Property("publisher", "Reference(Practitioner|PractitionerRole|Organization)", "Helps establish the \"authority/credibility\" of the SpecimenDefinition. May also allow for contact.", 0, 1, publisher));
3414        children.add(new Property("contact", "ContactDetail", "Contact details to assist a user in finding and communicating with the publisher.", 0, java.lang.Integer.MAX_VALUE, contact));
3415        children.add(new Property("description", "markdown", "A free text natural language description of the SpecimenDefinition from the consumer's perspective.", 0, 1, description));
3416        children.add(new Property("useContext", "UsageContext", "The content was developed with a focus and intent of supporting the contexts that are listed. These terms may be used to assist with indexing and searching of specimen definitions.", 0, java.lang.Integer.MAX_VALUE, useContext));
3417        children.add(new Property("jurisdiction", "CodeableConcept", "A jurisdiction in which the SpecimenDefinition is intended to be used.", 0, java.lang.Integer.MAX_VALUE, jurisdiction));
3418        children.add(new Property("purpose", "markdown", "Explains why this SpecimeDefinition is needed and why it has been designed as it has.", 0, 1, purpose));
3419        children.add(new Property("copyright", "markdown", "Copyright statement relating to the SpecimenDefinition and/or its contents. Copyright statements are generally legal restrictions on the use and publishing of the SpecimenDefinition.", 0, 1, copyright));
3420        children.add(new Property("approvalDate", "date", "The date on which the asset content was approved by the publisher. Approval happens once when the content is officially approved for usage.", 0, 1, approvalDate));
3421        children.add(new Property("lastReviewDate", "date", "The date on which the asset content was last reviewed. Review happens periodically after that, but doesn't change the original approval date.", 0, 1, lastReviewDate));
3422        children.add(new Property("effectivePeriod", "Period", "The period during which the SpecimenDefinition content was or is planned to be effective.", 0, 1, effectivePeriod));
3423        children.add(new Property("typeCollected", "CodeableConcept", "The kind of material to be collected.", 0, 1, typeCollected));
3424        children.add(new Property("patientPreparation", "CodeableConcept", "Preparation of the patient for specimen collection.", 0, java.lang.Integer.MAX_VALUE, patientPreparation));
3425        children.add(new Property("timeAspect", "string", "Time aspect of specimen collection (duration or offset).", 0, 1, timeAspect));
3426        children.add(new Property("collection", "CodeableConcept", "The action to be performed for collecting the specimen.", 0, java.lang.Integer.MAX_VALUE, collection));
3427        children.add(new Property("typeTested", "", "Specimen conditioned in a container as expected by the testing laboratory.", 0, java.lang.Integer.MAX_VALUE, typeTested));
3428      }
3429
3430      @Override
3431      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
3432        switch (_hash) {
3433        case 116079: /*url*/  return new Property("url", "uri", "An absolute URL that is used to identify this SpecimenDefinition when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this SpecimenDefinition is (or will be) published. The URL SHOULD include the major version of the SpecimenDefinition. For more information see Technical and Business Versions.", 0, 1, url);
3434        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "A business identifier assigned to this SpecimenDefinition.", 0, 1, identifier);
3435        case 351608024: /*version*/  return new Property("version", "string", "The identifier that is used to identify this version of the SpecimenDefinition when it is referenced in a specification, model, design or instance. This is an arbitrary value managed by the SpecimenDefinition author and is not expected to be globally unique.", 0, 1, version);
3436        case 110371416: /*title*/  return new Property("title", "string", "A short, descriptive, user-friendly title for the SpecimenDefinition.", 0, 1, title);
3437        case -978133683: /*derivedFromCanonical*/  return new Property("derivedFromCanonical", "canonical(SpecimenDefinition)", "The canonical URL pointing to another FHIR-defined SpecimenDefinition that is adhered to in whole or in part by this definition.", 0, java.lang.Integer.MAX_VALUE, derivedFromCanonical);
3438        case -1076333435: /*derivedFromUri*/  return new Property("derivedFromUri", "uri", "The URL pointing to an externally-defined type of specimen, guideline or other definition that is adhered to in whole or in part by this definition.", 0, java.lang.Integer.MAX_VALUE, derivedFromUri);
3439        case -892481550: /*status*/  return new Property("status", "code", "The current state of theSpecimenDefinition.", 0, 1, status);
3440        case -404562712: /*experimental*/  return new Property("experimental", "boolean", "A flag to indicate that this SpecimenDefinition is not authored for  genuine usage.", 0, 1, experimental);
3441        case -573640748: /*subject[x]*/  return new Property("subject[x]", "CodeableConcept|Reference(Group)", "A code or group definition that describes the intended subject  from which this kind of specimen is to be collected.", 0, 1, subject);
3442        case -1867885268: /*subject*/  return new Property("subject[x]", "CodeableConcept|Reference(Group)", "A code or group definition that describes the intended subject  from which this kind of specimen is to be collected.", 0, 1, subject);
3443        case -1257122603: /*subjectCodeableConcept*/  return new Property("subject[x]", "CodeableConcept", "A code or group definition that describes the intended subject  from which this kind of specimen is to be collected.", 0, 1, subject);
3444        case 772938623: /*subjectReference*/  return new Property("subject[x]", "Reference(Group)", "A code or group definition that describes the intended subject  from which this kind of specimen is to be collected.", 0, 1, subject);
3445        case 3076014: /*date*/  return new Property("date", "dateTime", "For draft definitions, indicates the date of initial creation. For active definitions, represents the date of activation. For withdrawn definitions, indicates the date of withdrawal.", 0, 1, date);
3446        case 1447404028: /*publisher*/  return new Property("publisher", "Reference(Practitioner|PractitionerRole|Organization)", "Helps establish the \"authority/credibility\" of the SpecimenDefinition. May also allow for contact.", 0, 1, publisher);
3447        case 951526432: /*contact*/  return new Property("contact", "ContactDetail", "Contact details to assist a user in finding and communicating with the publisher.", 0, java.lang.Integer.MAX_VALUE, contact);
3448        case -1724546052: /*description*/  return new Property("description", "markdown", "A free text natural language description of the SpecimenDefinition from the consumer's perspective.", 0, 1, description);
3449        case -669707736: /*useContext*/  return new Property("useContext", "UsageContext", "The content was developed with a focus and intent of supporting the contexts that are listed. These terms may be used to assist with indexing and searching of specimen definitions.", 0, java.lang.Integer.MAX_VALUE, useContext);
3450        case -507075711: /*jurisdiction*/  return new Property("jurisdiction", "CodeableConcept", "A jurisdiction in which the SpecimenDefinition is intended to be used.", 0, java.lang.Integer.MAX_VALUE, jurisdiction);
3451        case -220463842: /*purpose*/  return new Property("purpose", "markdown", "Explains why this SpecimeDefinition is needed and why it has been designed as it has.", 0, 1, purpose);
3452        case 1522889671: /*copyright*/  return new Property("copyright", "markdown", "Copyright statement relating to the SpecimenDefinition and/or its contents. Copyright statements are generally legal restrictions on the use and publishing of the SpecimenDefinition.", 0, 1, copyright);
3453        case 223539345: /*approvalDate*/  return new Property("approvalDate", "date", "The date on which the asset content was approved by the publisher. Approval happens once when the content is officially approved for usage.", 0, 1, approvalDate);
3454        case -1687512484: /*lastReviewDate*/  return new Property("lastReviewDate", "date", "The date on which the asset content was last reviewed. Review happens periodically after that, but doesn't change the original approval date.", 0, 1, lastReviewDate);
3455        case -403934648: /*effectivePeriod*/  return new Property("effectivePeriod", "Period", "The period during which the SpecimenDefinition content was or is planned to be effective.", 0, 1, effectivePeriod);
3456        case 588504367: /*typeCollected*/  return new Property("typeCollected", "CodeableConcept", "The kind of material to be collected.", 0, 1, typeCollected);
3457        case -879411630: /*patientPreparation*/  return new Property("patientPreparation", "CodeableConcept", "Preparation of the patient for specimen collection.", 0, java.lang.Integer.MAX_VALUE, patientPreparation);
3458        case 276972933: /*timeAspect*/  return new Property("timeAspect", "string", "Time aspect of specimen collection (duration or offset).", 0, 1, timeAspect);
3459        case -1741312354: /*collection*/  return new Property("collection", "CodeableConcept", "The action to be performed for collecting the specimen.", 0, java.lang.Integer.MAX_VALUE, collection);
3460        case -1407902581: /*typeTested*/  return new Property("typeTested", "", "Specimen conditioned in a container as expected by the testing laboratory.", 0, java.lang.Integer.MAX_VALUE, typeTested);
3461        default: return super.getNamedProperty(_hash, _name, _checkValid);
3462        }
3463
3464      }
3465
3466      @Override
3467      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
3468        switch (hash) {
3469        case 116079: /*url*/ return this.url == null ? new Base[0] : new Base[] {this.url}; // UriType
3470        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : new Base[] {this.identifier}; // Identifier
3471        case 351608024: /*version*/ return this.version == null ? new Base[0] : new Base[] {this.version}; // StringType
3472        case 110371416: /*title*/ return this.title == null ? new Base[0] : new Base[] {this.title}; // StringType
3473        case -978133683: /*derivedFromCanonical*/ return this.derivedFromCanonical == null ? new Base[0] : this.derivedFromCanonical.toArray(new Base[this.derivedFromCanonical.size()]); // CanonicalType
3474        case -1076333435: /*derivedFromUri*/ return this.derivedFromUri == null ? new Base[0] : this.derivedFromUri.toArray(new Base[this.derivedFromUri.size()]); // UriType
3475        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<PublicationStatus>
3476        case -404562712: /*experimental*/ return this.experimental == null ? new Base[0] : new Base[] {this.experimental}; // BooleanType
3477        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // DataType
3478        case 3076014: /*date*/ return this.date == null ? new Base[0] : new Base[] {this.date}; // DateTimeType
3479        case 1447404028: /*publisher*/ return this.publisher == null ? new Base[0] : new Base[] {this.publisher}; // Reference
3480        case 951526432: /*contact*/ return this.contact == null ? new Base[0] : this.contact.toArray(new Base[this.contact.size()]); // ContactDetail
3481        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // MarkdownType
3482        case -669707736: /*useContext*/ return this.useContext == null ? new Base[0] : this.useContext.toArray(new Base[this.useContext.size()]); // UsageContext
3483        case -507075711: /*jurisdiction*/ return this.jurisdiction == null ? new Base[0] : this.jurisdiction.toArray(new Base[this.jurisdiction.size()]); // CodeableConcept
3484        case -220463842: /*purpose*/ return this.purpose == null ? new Base[0] : new Base[] {this.purpose}; // MarkdownType
3485        case 1522889671: /*copyright*/ return this.copyright == null ? new Base[0] : new Base[] {this.copyright}; // MarkdownType
3486        case 223539345: /*approvalDate*/ return this.approvalDate == null ? new Base[0] : new Base[] {this.approvalDate}; // DateType
3487        case -1687512484: /*lastReviewDate*/ return this.lastReviewDate == null ? new Base[0] : new Base[] {this.lastReviewDate}; // DateType
3488        case -403934648: /*effectivePeriod*/ return this.effectivePeriod == null ? new Base[0] : new Base[] {this.effectivePeriod}; // Period
3489        case 588504367: /*typeCollected*/ return this.typeCollected == null ? new Base[0] : new Base[] {this.typeCollected}; // CodeableConcept
3490        case -879411630: /*patientPreparation*/ return this.patientPreparation == null ? new Base[0] : this.patientPreparation.toArray(new Base[this.patientPreparation.size()]); // CodeableConcept
3491        case 276972933: /*timeAspect*/ return this.timeAspect == null ? new Base[0] : new Base[] {this.timeAspect}; // StringType
3492        case -1741312354: /*collection*/ return this.collection == null ? new Base[0] : this.collection.toArray(new Base[this.collection.size()]); // CodeableConcept
3493        case -1407902581: /*typeTested*/ return this.typeTested == null ? new Base[0] : this.typeTested.toArray(new Base[this.typeTested.size()]); // SpecimenDefinitionTypeTestedComponent
3494        default: return super.getProperty(hash, name, checkValid);
3495        }
3496
3497      }
3498
3499      @Override
3500      public Base setProperty(int hash, String name, Base value) throws FHIRException {
3501        switch (hash) {
3502        case 116079: // url
3503          this.url = TypeConvertor.castToUri(value); // UriType
3504          return value;
3505        case -1618432855: // identifier
3506          this.identifier = TypeConvertor.castToIdentifier(value); // Identifier
3507          return value;
3508        case 351608024: // version
3509          this.version = TypeConvertor.castToString(value); // StringType
3510          return value;
3511        case 110371416: // title
3512          this.title = TypeConvertor.castToString(value); // StringType
3513          return value;
3514        case -978133683: // derivedFromCanonical
3515          this.getDerivedFromCanonical().add(TypeConvertor.castToCanonical(value)); // CanonicalType
3516          return value;
3517        case -1076333435: // derivedFromUri
3518          this.getDerivedFromUri().add(TypeConvertor.castToUri(value)); // UriType
3519          return value;
3520        case -892481550: // status
3521          value = new PublicationStatusEnumFactory().fromType(TypeConvertor.castToCode(value));
3522          this.status = (Enumeration) value; // Enumeration<PublicationStatus>
3523          return value;
3524        case -404562712: // experimental
3525          this.experimental = TypeConvertor.castToBoolean(value); // BooleanType
3526          return value;
3527        case -1867885268: // subject
3528          this.subject = TypeConvertor.castToType(value); // DataType
3529          return value;
3530        case 3076014: // date
3531          this.date = TypeConvertor.castToDateTime(value); // DateTimeType
3532          return value;
3533        case 1447404028: // publisher
3534          this.publisher = TypeConvertor.castToReference(value); // Reference
3535          return value;
3536        case 951526432: // contact
3537          this.getContact().add(TypeConvertor.castToContactDetail(value)); // ContactDetail
3538          return value;
3539        case -1724546052: // description
3540          this.description = TypeConvertor.castToMarkdown(value); // MarkdownType
3541          return value;
3542        case -669707736: // useContext
3543          this.getUseContext().add(TypeConvertor.castToUsageContext(value)); // UsageContext
3544          return value;
3545        case -507075711: // jurisdiction
3546          this.getJurisdiction().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
3547          return value;
3548        case -220463842: // purpose
3549          this.purpose = TypeConvertor.castToMarkdown(value); // MarkdownType
3550          return value;
3551        case 1522889671: // copyright
3552          this.copyright = TypeConvertor.castToMarkdown(value); // MarkdownType
3553          return value;
3554        case 223539345: // approvalDate
3555          this.approvalDate = TypeConvertor.castToDate(value); // DateType
3556          return value;
3557        case -1687512484: // lastReviewDate
3558          this.lastReviewDate = TypeConvertor.castToDate(value); // DateType
3559          return value;
3560        case -403934648: // effectivePeriod
3561          this.effectivePeriod = TypeConvertor.castToPeriod(value); // Period
3562          return value;
3563        case 588504367: // typeCollected
3564          this.typeCollected = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
3565          return value;
3566        case -879411630: // patientPreparation
3567          this.getPatientPreparation().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
3568          return value;
3569        case 276972933: // timeAspect
3570          this.timeAspect = TypeConvertor.castToString(value); // StringType
3571          return value;
3572        case -1741312354: // collection
3573          this.getCollection().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
3574          return value;
3575        case -1407902581: // typeTested
3576          this.getTypeTested().add((SpecimenDefinitionTypeTestedComponent) value); // SpecimenDefinitionTypeTestedComponent
3577          return value;
3578        default: return super.setProperty(hash, name, value);
3579        }
3580
3581      }
3582
3583      @Override
3584      public Base setProperty(String name, Base value) throws FHIRException {
3585        if (name.equals("url")) {
3586          this.url = TypeConvertor.castToUri(value); // UriType
3587        } else if (name.equals("identifier")) {
3588          this.identifier = TypeConvertor.castToIdentifier(value); // Identifier
3589        } else if (name.equals("version")) {
3590          this.version = TypeConvertor.castToString(value); // StringType
3591        } else if (name.equals("title")) {
3592          this.title = TypeConvertor.castToString(value); // StringType
3593        } else if (name.equals("derivedFromCanonical")) {
3594          this.getDerivedFromCanonical().add(TypeConvertor.castToCanonical(value));
3595        } else if (name.equals("derivedFromUri")) {
3596          this.getDerivedFromUri().add(TypeConvertor.castToUri(value));
3597        } else if (name.equals("status")) {
3598          value = new PublicationStatusEnumFactory().fromType(TypeConvertor.castToCode(value));
3599          this.status = (Enumeration) value; // Enumeration<PublicationStatus>
3600        } else if (name.equals("experimental")) {
3601          this.experimental = TypeConvertor.castToBoolean(value); // BooleanType
3602        } else if (name.equals("subject[x]")) {
3603          this.subject = TypeConvertor.castToType(value); // DataType
3604        } else if (name.equals("date")) {
3605          this.date = TypeConvertor.castToDateTime(value); // DateTimeType
3606        } else if (name.equals("publisher")) {
3607          this.publisher = TypeConvertor.castToReference(value); // Reference
3608        } else if (name.equals("contact")) {
3609          this.getContact().add(TypeConvertor.castToContactDetail(value));
3610        } else if (name.equals("description")) {
3611          this.description = TypeConvertor.castToMarkdown(value); // MarkdownType
3612        } else if (name.equals("useContext")) {
3613          this.getUseContext().add(TypeConvertor.castToUsageContext(value));
3614        } else if (name.equals("jurisdiction")) {
3615          this.getJurisdiction().add(TypeConvertor.castToCodeableConcept(value));
3616        } else if (name.equals("purpose")) {
3617          this.purpose = TypeConvertor.castToMarkdown(value); // MarkdownType
3618        } else if (name.equals("copyright")) {
3619          this.copyright = TypeConvertor.castToMarkdown(value); // MarkdownType
3620        } else if (name.equals("approvalDate")) {
3621          this.approvalDate = TypeConvertor.castToDate(value); // DateType
3622        } else if (name.equals("lastReviewDate")) {
3623          this.lastReviewDate = TypeConvertor.castToDate(value); // DateType
3624        } else if (name.equals("effectivePeriod")) {
3625          this.effectivePeriod = TypeConvertor.castToPeriod(value); // Period
3626        } else if (name.equals("typeCollected")) {
3627          this.typeCollected = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
3628        } else if (name.equals("patientPreparation")) {
3629          this.getPatientPreparation().add(TypeConvertor.castToCodeableConcept(value));
3630        } else if (name.equals("timeAspect")) {
3631          this.timeAspect = TypeConvertor.castToString(value); // StringType
3632        } else if (name.equals("collection")) {
3633          this.getCollection().add(TypeConvertor.castToCodeableConcept(value));
3634        } else if (name.equals("typeTested")) {
3635          this.getTypeTested().add((SpecimenDefinitionTypeTestedComponent) value);
3636        } else
3637          return super.setProperty(name, value);
3638        return value;
3639      }
3640
3641      @Override
3642      public Base makeProperty(int hash, String name) throws FHIRException {
3643        switch (hash) {
3644        case 116079:  return getUrlElement();
3645        case -1618432855:  return getIdentifier();
3646        case 351608024:  return getVersionElement();
3647        case 110371416:  return getTitleElement();
3648        case -978133683:  return addDerivedFromCanonicalElement();
3649        case -1076333435:  return addDerivedFromUriElement();
3650        case -892481550:  return getStatusElement();
3651        case -404562712:  return getExperimentalElement();
3652        case -573640748:  return getSubject();
3653        case -1867885268:  return getSubject();
3654        case 3076014:  return getDateElement();
3655        case 1447404028:  return getPublisher();
3656        case 951526432:  return addContact(); 
3657        case -1724546052:  return getDescriptionElement();
3658        case -669707736:  return addUseContext(); 
3659        case -507075711:  return addJurisdiction(); 
3660        case -220463842:  return getPurposeElement();
3661        case 1522889671:  return getCopyrightElement();
3662        case 223539345:  return getApprovalDateElement();
3663        case -1687512484:  return getLastReviewDateElement();
3664        case -403934648:  return getEffectivePeriod();
3665        case 588504367:  return getTypeCollected();
3666        case -879411630:  return addPatientPreparation(); 
3667        case 276972933:  return getTimeAspectElement();
3668        case -1741312354:  return addCollection(); 
3669        case -1407902581:  return addTypeTested(); 
3670        default: return super.makeProperty(hash, name);
3671        }
3672
3673      }
3674
3675      @Override
3676      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
3677        switch (hash) {
3678        case 116079: /*url*/ return new String[] {"uri"};
3679        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
3680        case 351608024: /*version*/ return new String[] {"string"};
3681        case 110371416: /*title*/ return new String[] {"string"};
3682        case -978133683: /*derivedFromCanonical*/ return new String[] {"canonical"};
3683        case -1076333435: /*derivedFromUri*/ return new String[] {"uri"};
3684        case -892481550: /*status*/ return new String[] {"code"};
3685        case -404562712: /*experimental*/ return new String[] {"boolean"};
3686        case -1867885268: /*subject*/ return new String[] {"CodeableConcept", "Reference"};
3687        case 3076014: /*date*/ return new String[] {"dateTime"};
3688        case 1447404028: /*publisher*/ return new String[] {"Reference"};
3689        case 951526432: /*contact*/ return new String[] {"ContactDetail"};
3690        case -1724546052: /*description*/ return new String[] {"markdown"};
3691        case -669707736: /*useContext*/ return new String[] {"UsageContext"};
3692        case -507075711: /*jurisdiction*/ return new String[] {"CodeableConcept"};
3693        case -220463842: /*purpose*/ return new String[] {"markdown"};
3694        case 1522889671: /*copyright*/ return new String[] {"markdown"};
3695        case 223539345: /*approvalDate*/ return new String[] {"date"};
3696        case -1687512484: /*lastReviewDate*/ return new String[] {"date"};
3697        case -403934648: /*effectivePeriod*/ return new String[] {"Period"};
3698        case 588504367: /*typeCollected*/ return new String[] {"CodeableConcept"};
3699        case -879411630: /*patientPreparation*/ return new String[] {"CodeableConcept"};
3700        case 276972933: /*timeAspect*/ return new String[] {"string"};
3701        case -1741312354: /*collection*/ return new String[] {"CodeableConcept"};
3702        case -1407902581: /*typeTested*/ return new String[] {};
3703        default: return super.getTypesForProperty(hash, name);
3704        }
3705
3706      }
3707
3708      @Override
3709      public Base addChild(String name) throws FHIRException {
3710        if (name.equals("url")) {
3711          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.url");
3712        }
3713        else if (name.equals("identifier")) {
3714          this.identifier = new Identifier();
3715          return this.identifier;
3716        }
3717        else if (name.equals("version")) {
3718          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.version");
3719        }
3720        else if (name.equals("title")) {
3721          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.title");
3722        }
3723        else if (name.equals("derivedFromCanonical")) {
3724          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.derivedFromCanonical");
3725        }
3726        else if (name.equals("derivedFromUri")) {
3727          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.derivedFromUri");
3728        }
3729        else if (name.equals("status")) {
3730          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.status");
3731        }
3732        else if (name.equals("experimental")) {
3733          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.experimental");
3734        }
3735        else if (name.equals("subjectCodeableConcept")) {
3736          this.subject = new CodeableConcept();
3737          return this.subject;
3738        }
3739        else if (name.equals("subjectReference")) {
3740          this.subject = new Reference();
3741          return this.subject;
3742        }
3743        else if (name.equals("date")) {
3744          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.date");
3745        }
3746        else if (name.equals("publisher")) {
3747          this.publisher = new Reference();
3748          return this.publisher;
3749        }
3750        else if (name.equals("contact")) {
3751          return addContact();
3752        }
3753        else if (name.equals("description")) {
3754          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.description");
3755        }
3756        else if (name.equals("useContext")) {
3757          return addUseContext();
3758        }
3759        else if (name.equals("jurisdiction")) {
3760          return addJurisdiction();
3761        }
3762        else if (name.equals("purpose")) {
3763          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.purpose");
3764        }
3765        else if (name.equals("copyright")) {
3766          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.copyright");
3767        }
3768        else if (name.equals("approvalDate")) {
3769          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.approvalDate");
3770        }
3771        else if (name.equals("lastReviewDate")) {
3772          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.lastReviewDate");
3773        }
3774        else if (name.equals("effectivePeriod")) {
3775          this.effectivePeriod = new Period();
3776          return this.effectivePeriod;
3777        }
3778        else if (name.equals("typeCollected")) {
3779          this.typeCollected = new CodeableConcept();
3780          return this.typeCollected;
3781        }
3782        else if (name.equals("patientPreparation")) {
3783          return addPatientPreparation();
3784        }
3785        else if (name.equals("timeAspect")) {
3786          throw new FHIRException("Cannot call addChild on a primitive type SpecimenDefinition.timeAspect");
3787        }
3788        else if (name.equals("collection")) {
3789          return addCollection();
3790        }
3791        else if (name.equals("typeTested")) {
3792          return addTypeTested();
3793        }
3794        else
3795          return super.addChild(name);
3796      }
3797
3798  public String fhirType() {
3799    return "SpecimenDefinition";
3800
3801  }
3802
3803      public SpecimenDefinition copy() {
3804        SpecimenDefinition dst = new SpecimenDefinition();
3805        copyValues(dst);
3806        return dst;
3807      }
3808
3809      public void copyValues(SpecimenDefinition dst) {
3810        super.copyValues(dst);
3811        dst.url = url == null ? null : url.copy();
3812        dst.identifier = identifier == null ? null : identifier.copy();
3813        dst.version = version == null ? null : version.copy();
3814        dst.title = title == null ? null : title.copy();
3815        if (derivedFromCanonical != null) {
3816          dst.derivedFromCanonical = new ArrayList<CanonicalType>();
3817          for (CanonicalType i : derivedFromCanonical)
3818            dst.derivedFromCanonical.add(i.copy());
3819        };
3820        if (derivedFromUri != null) {
3821          dst.derivedFromUri = new ArrayList<UriType>();
3822          for (UriType i : derivedFromUri)
3823            dst.derivedFromUri.add(i.copy());
3824        };
3825        dst.status = status == null ? null : status.copy();
3826        dst.experimental = experimental == null ? null : experimental.copy();
3827        dst.subject = subject == null ? null : subject.copy();
3828        dst.date = date == null ? null : date.copy();
3829        dst.publisher = publisher == null ? null : publisher.copy();
3830        if (contact != null) {
3831          dst.contact = new ArrayList<ContactDetail>();
3832          for (ContactDetail i : contact)
3833            dst.contact.add(i.copy());
3834        };
3835        dst.description = description == null ? null : description.copy();
3836        if (useContext != null) {
3837          dst.useContext = new ArrayList<UsageContext>();
3838          for (UsageContext i : useContext)
3839            dst.useContext.add(i.copy());
3840        };
3841        if (jurisdiction != null) {
3842          dst.jurisdiction = new ArrayList<CodeableConcept>();
3843          for (CodeableConcept i : jurisdiction)
3844            dst.jurisdiction.add(i.copy());
3845        };
3846        dst.purpose = purpose == null ? null : purpose.copy();
3847        dst.copyright = copyright == null ? null : copyright.copy();
3848        dst.approvalDate = approvalDate == null ? null : approvalDate.copy();
3849        dst.lastReviewDate = lastReviewDate == null ? null : lastReviewDate.copy();
3850        dst.effectivePeriod = effectivePeriod == null ? null : effectivePeriod.copy();
3851        dst.typeCollected = typeCollected == null ? null : typeCollected.copy();
3852        if (patientPreparation != null) {
3853          dst.patientPreparation = new ArrayList<CodeableConcept>();
3854          for (CodeableConcept i : patientPreparation)
3855            dst.patientPreparation.add(i.copy());
3856        };
3857        dst.timeAspect = timeAspect == null ? null : timeAspect.copy();
3858        if (collection != null) {
3859          dst.collection = new ArrayList<CodeableConcept>();
3860          for (CodeableConcept i : collection)
3861            dst.collection.add(i.copy());
3862        };
3863        if (typeTested != null) {
3864          dst.typeTested = new ArrayList<SpecimenDefinitionTypeTestedComponent>();
3865          for (SpecimenDefinitionTypeTestedComponent i : typeTested)
3866            dst.typeTested.add(i.copy());
3867        };
3868      }
3869
3870      protected SpecimenDefinition typedCopy() {
3871        return copy();
3872      }
3873
3874      @Override
3875      public boolean equalsDeep(Base other_) {
3876        if (!super.equalsDeep(other_))
3877          return false;
3878        if (!(other_ instanceof SpecimenDefinition))
3879          return false;
3880        SpecimenDefinition o = (SpecimenDefinition) other_;
3881        return compareDeep(url, o.url, true) && compareDeep(identifier, o.identifier, true) && compareDeep(version, o.version, true)
3882           && compareDeep(title, o.title, true) && compareDeep(derivedFromCanonical, o.derivedFromCanonical, true)
3883           && compareDeep(derivedFromUri, o.derivedFromUri, true) && compareDeep(status, o.status, true) && compareDeep(experimental, o.experimental, true)
3884           && compareDeep(subject, o.subject, true) && compareDeep(date, o.date, true) && compareDeep(publisher, o.publisher, true)
3885           && compareDeep(contact, o.contact, true) && compareDeep(description, o.description, true) && compareDeep(useContext, o.useContext, true)
3886           && compareDeep(jurisdiction, o.jurisdiction, true) && compareDeep(purpose, o.purpose, true) && compareDeep(copyright, o.copyright, true)
3887           && compareDeep(approvalDate, o.approvalDate, true) && compareDeep(lastReviewDate, o.lastReviewDate, true)
3888           && compareDeep(effectivePeriod, o.effectivePeriod, true) && compareDeep(typeCollected, o.typeCollected, true)
3889           && compareDeep(patientPreparation, o.patientPreparation, true) && compareDeep(timeAspect, o.timeAspect, true)
3890           && compareDeep(collection, o.collection, true) && compareDeep(typeTested, o.typeTested, true);
3891      }
3892
3893      @Override
3894      public boolean equalsShallow(Base other_) {
3895        if (!super.equalsShallow(other_))
3896          return false;
3897        if (!(other_ instanceof SpecimenDefinition))
3898          return false;
3899        SpecimenDefinition o = (SpecimenDefinition) other_;
3900        return compareValues(url, o.url, true) && compareValues(version, o.version, true) && compareValues(title, o.title, true)
3901           && compareValues(derivedFromCanonical, o.derivedFromCanonical, true) && compareValues(derivedFromUri, o.derivedFromUri, true)
3902           && compareValues(status, o.status, true) && compareValues(experimental, o.experimental, true) && compareValues(date, o.date, true)
3903           && compareValues(description, o.description, true) && compareValues(purpose, o.purpose, true) && compareValues(copyright, o.copyright, true)
3904           && compareValues(approvalDate, o.approvalDate, true) && compareValues(lastReviewDate, o.lastReviewDate, true)
3905           && compareValues(timeAspect, o.timeAspect, true);
3906      }
3907
3908      public boolean isEmpty() {
3909        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(url, identifier, version
3910          , title, derivedFromCanonical, derivedFromUri, status, experimental, subject, date
3911          , publisher, contact, description, useContext, jurisdiction, purpose, copyright
3912          , approvalDate, lastReviewDate, effectivePeriod, typeCollected, patientPreparation
3913          , timeAspect, collection, typeTested);
3914      }
3915
3916  @Override
3917  public ResourceType getResourceType() {
3918    return ResourceType.SpecimenDefinition;
3919   }
3920
3921 /**
3922   * Search parameter: <b>container</b>
3923   * <p>
3924   * Description: <b>The type of specimen conditioned in container expected by the lab</b><br>
3925   * Type: <b>token</b><br>
3926   * Path: <b>SpecimenDefinition.typeTested.container.type</b><br>
3927   * </p>
3928   */
3929  @SearchParamDefinition(name="container", path="SpecimenDefinition.typeTested.container.type", description="The type of specimen conditioned in container expected by the lab", type="token" )
3930  public static final String SP_CONTAINER = "container";
3931 /**
3932   * <b>Fluent Client</b> search parameter constant for <b>container</b>
3933   * <p>
3934   * Description: <b>The type of specimen conditioned in container expected by the lab</b><br>
3935   * Type: <b>token</b><br>
3936   * Path: <b>SpecimenDefinition.typeTested.container.type</b><br>
3937   * </p>
3938   */
3939  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CONTAINER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CONTAINER);
3940
3941 /**
3942   * Search parameter: <b>experimental</b>
3943   * <p>
3944   * Description: <b>Not for genuine usage (true)</b><br>
3945   * Type: <b>token</b><br>
3946   * Path: <b>SpecimenDefinition.experimental</b><br>
3947   * </p>
3948   */
3949  @SearchParamDefinition(name="experimental", path="SpecimenDefinition.experimental", description="Not for genuine usage (true)", type="token" )
3950  public static final String SP_EXPERIMENTAL = "experimental";
3951 /**
3952   * <b>Fluent Client</b> search parameter constant for <b>experimental</b>
3953   * <p>
3954   * Description: <b>Not for genuine usage (true)</b><br>
3955   * Type: <b>token</b><br>
3956   * Path: <b>SpecimenDefinition.experimental</b><br>
3957   * </p>
3958   */
3959  public static final ca.uhn.fhir.rest.gclient.TokenClientParam EXPERIMENTAL = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_EXPERIMENTAL);
3960
3961 /**
3962   * Search parameter: <b>identifier</b>
3963   * <p>
3964   * Description: <b>The unique identifier associated with the SpecimenDefinition</b><br>
3965   * Type: <b>token</b><br>
3966   * Path: <b>SpecimenDefinition.identifier</b><br>
3967   * </p>
3968   */
3969  @SearchParamDefinition(name="identifier", path="SpecimenDefinition.identifier", description="The unique identifier associated with the SpecimenDefinition", type="token" )
3970  public static final String SP_IDENTIFIER = "identifier";
3971 /**
3972   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
3973   * <p>
3974   * Description: <b>The unique identifier associated with the SpecimenDefinition</b><br>
3975   * Type: <b>token</b><br>
3976   * Path: <b>SpecimenDefinition.identifier</b><br>
3977   * </p>
3978   */
3979  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
3980
3981 /**
3982   * Search parameter: <b>is-derived</b>
3983   * <p>
3984   * Description: <b>Primary specimen (false) or derived specimen (true)</b><br>
3985   * Type: <b>token</b><br>
3986   * Path: <b>SpecimenDefinition.typeTested.isDerived</b><br>
3987   * </p>
3988   */
3989  @SearchParamDefinition(name="is-derived", path="SpecimenDefinition.typeTested.isDerived", description="Primary specimen (false) or derived specimen (true)", type="token" )
3990  public static final String SP_IS_DERIVED = "is-derived";
3991 /**
3992   * <b>Fluent Client</b> search parameter constant for <b>is-derived</b>
3993   * <p>
3994   * Description: <b>Primary specimen (false) or derived specimen (true)</b><br>
3995   * Type: <b>token</b><br>
3996   * Path: <b>SpecimenDefinition.typeTested.isDerived</b><br>
3997   * </p>
3998   */
3999  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IS_DERIVED = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IS_DERIVED);
4000
4001 /**
4002   * Search parameter: <b>status</b>
4003   * <p>
4004   * Description: <b>Publication status of the SpecimenDefinition: draft, active, retired, unknown</b><br>
4005   * Type: <b>token</b><br>
4006   * Path: <b>SpecimenDefinition.status</b><br>
4007   * </p>
4008   */
4009  @SearchParamDefinition(name="status", path="SpecimenDefinition.status", description="Publication status of the SpecimenDefinition: draft, active, retired, unknown", type="token" )
4010  public static final String SP_STATUS = "status";
4011 /**
4012   * <b>Fluent Client</b> search parameter constant for <b>status</b>
4013   * <p>
4014   * Description: <b>Publication status of the SpecimenDefinition: draft, active, retired, unknown</b><br>
4015   * Type: <b>token</b><br>
4016   * Path: <b>SpecimenDefinition.status</b><br>
4017   * </p>
4018   */
4019  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
4020
4021 /**
4022   * Search parameter: <b>title</b>
4023   * <p>
4024   * Description: <b>Human-friendly name of the SpecimenDefinition</b><br>
4025   * Type: <b>string</b><br>
4026   * Path: <b>SpecimenDefinition.title</b><br>
4027   * </p>
4028   */
4029  @SearchParamDefinition(name="title", path="SpecimenDefinition.title", description="Human-friendly name of the SpecimenDefinition", type="string" )
4030  public static final String SP_TITLE = "title";
4031 /**
4032   * <b>Fluent Client</b> search parameter constant for <b>title</b>
4033   * <p>
4034   * Description: <b>Human-friendly name of the SpecimenDefinition</b><br>
4035   * Type: <b>string</b><br>
4036   * Path: <b>SpecimenDefinition.title</b><br>
4037   * </p>
4038   */
4039  public static final ca.uhn.fhir.rest.gclient.StringClientParam TITLE = new ca.uhn.fhir.rest.gclient.StringClientParam(SP_TITLE);
4040
4041 /**
4042   * Search parameter: <b>type-tested</b>
4043   * <p>
4044   * Description: <b>The type of specimen conditioned for testing</b><br>
4045   * Type: <b>token</b><br>
4046   * Path: <b>SpecimenDefinition.typeTested.type</b><br>
4047   * </p>
4048   */
4049  @SearchParamDefinition(name="type-tested", path="SpecimenDefinition.typeTested.type", description="The type of specimen conditioned for testing", type="token" )
4050  public static final String SP_TYPE_TESTED = "type-tested";
4051 /**
4052   * <b>Fluent Client</b> search parameter constant for <b>type-tested</b>
4053   * <p>
4054   * Description: <b>The type of specimen conditioned for testing</b><br>
4055   * Type: <b>token</b><br>
4056   * Path: <b>SpecimenDefinition.typeTested.type</b><br>
4057   * </p>
4058   */
4059  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE_TESTED = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_TYPE_TESTED);
4060
4061 /**
4062   * Search parameter: <b>type</b>
4063   * <p>
4064   * Description: <b>The type of collected specimen</b><br>
4065   * Type: <b>token</b><br>
4066   * Path: <b>SpecimenDefinition.typeCollected</b><br>
4067   * </p>
4068   */
4069  @SearchParamDefinition(name="type", path="SpecimenDefinition.typeCollected", description="The type of collected specimen", type="token" )
4070  public static final String SP_TYPE = "type";
4071 /**
4072   * <b>Fluent Client</b> search parameter constant for <b>type</b>
4073   * <p>
4074   * Description: <b>The type of collected specimen</b><br>
4075   * Type: <b>token</b><br>
4076   * Path: <b>SpecimenDefinition.typeCollected</b><br>
4077   * </p>
4078   */
4079  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_TYPE);
4080
4081 /**
4082   * Search parameter: <b>url</b>
4083   * <p>
4084   * Description: <b>The uri that identifies the specimen definition</b><br>
4085   * Type: <b>uri</b><br>
4086   * Path: <b>SpecimenDefinition.url</b><br>
4087   * </p>
4088   */
4089  @SearchParamDefinition(name="url", path="SpecimenDefinition.url", description="The uri that identifies the specimen definition", type="uri" )
4090  public static final String SP_URL = "url";
4091 /**
4092   * <b>Fluent Client</b> search parameter constant for <b>url</b>
4093   * <p>
4094   * Description: <b>The uri that identifies the specimen definition</b><br>
4095   * Type: <b>uri</b><br>
4096   * Path: <b>SpecimenDefinition.url</b><br>
4097   * </p>
4098   */
4099  public static final ca.uhn.fhir.rest.gclient.UriClientParam URL = new ca.uhn.fhir.rest.gclient.UriClientParam(SP_URL);
4100
4101
4102}
4103