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