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