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 void removeChild(String name, Base value) throws FHIRException {
749      if (name.equals("isDerived")) {
750        this.isDerived = null;
751      } else if (name.equals("type")) {
752        this.type = null;
753      } else if (name.equals("preference")) {
754        this.preference = null;
755      } else if (name.equals("container")) {
756        this.container = (SpecimenDefinitionTypeTestedContainerComponent) value; // SpecimenDefinitionTypeTestedContainerComponent
757      } else if (name.equals("requirement")) {
758        this.requirement = null;
759      } else if (name.equals("retentionTime")) {
760        this.retentionTime = null;
761      } else if (name.equals("rejectionCriterion")) {
762        this.getRejectionCriterion().remove(castToCodeableConcept(value));
763      } else if (name.equals("handling")) {
764        this.getHandling().remove((SpecimenDefinitionTypeTestedHandlingComponent) value);
765      } else
766        super.removeChild(name, value);
767      
768    }
769
770    @Override
771    public Base makeProperty(int hash, String name) throws FHIRException {
772      switch (hash) {
773      case 976346515:
774        return getIsDerivedElement();
775      case 3575610:
776        return getType();
777      case -1459831589:
778        return getPreferenceElement();
779      case -410956671:
780        return getContainer();
781      case 363387971:
782        return getRequirementElement();
783      case 1434969867:
784        return getRetentionTime();
785      case -553706344:
786        return addRejectionCriterion();
787      case 2072805:
788        return addHandling();
789      default:
790        return super.makeProperty(hash, name);
791      }
792
793    }
794
795    @Override
796    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
797      switch (hash) {
798      case 976346515:
799        /* isDerived */ return new String[] { "boolean" };
800      case 3575610:
801        /* type */ return new String[] { "CodeableConcept" };
802      case -1459831589:
803        /* preference */ return new String[] { "code" };
804      case -410956671:
805        /* container */ return new String[] {};
806      case 363387971:
807        /* requirement */ return new String[] { "string" };
808      case 1434969867:
809        /* retentionTime */ return new String[] { "Duration" };
810      case -553706344:
811        /* rejectionCriterion */ return new String[] { "CodeableConcept" };
812      case 2072805:
813        /* handling */ return new String[] {};
814      default:
815        return super.getTypesForProperty(hash, name);
816      }
817
818    }
819
820    @Override
821    public Base addChild(String name) throws FHIRException {
822      if (name.equals("isDerived")) {
823        throw new FHIRException("Cannot call addChild on a singleton property SpecimenDefinition.isDerived");
824      } else if (name.equals("type")) {
825        this.type = new CodeableConcept();
826        return this.type;
827      } else if (name.equals("preference")) {
828        throw new FHIRException("Cannot call addChild on a singleton property SpecimenDefinition.preference");
829      } else if (name.equals("container")) {
830        this.container = new SpecimenDefinitionTypeTestedContainerComponent();
831        return this.container;
832      } else if (name.equals("requirement")) {
833        throw new FHIRException("Cannot call addChild on a singleton property SpecimenDefinition.requirement");
834      } else if (name.equals("retentionTime")) {
835        this.retentionTime = new Duration();
836        return this.retentionTime;
837      } else if (name.equals("rejectionCriterion")) {
838        return addRejectionCriterion();
839      } else if (name.equals("handling")) {
840        return addHandling();
841      } else
842        return super.addChild(name);
843    }
844
845    public SpecimenDefinitionTypeTestedComponent copy() {
846      SpecimenDefinitionTypeTestedComponent dst = new SpecimenDefinitionTypeTestedComponent();
847      copyValues(dst);
848      return dst;
849    }
850
851    public void copyValues(SpecimenDefinitionTypeTestedComponent dst) {
852      super.copyValues(dst);
853      dst.isDerived = isDerived == null ? null : isDerived.copy();
854      dst.type = type == null ? null : type.copy();
855      dst.preference = preference == null ? null : preference.copy();
856      dst.container = container == null ? null : container.copy();
857      dst.requirement = requirement == null ? null : requirement.copy();
858      dst.retentionTime = retentionTime == null ? null : retentionTime.copy();
859      if (rejectionCriterion != null) {
860        dst.rejectionCriterion = new ArrayList<CodeableConcept>();
861        for (CodeableConcept i : rejectionCriterion)
862          dst.rejectionCriterion.add(i.copy());
863      }
864      ;
865      if (handling != null) {
866        dst.handling = new ArrayList<SpecimenDefinitionTypeTestedHandlingComponent>();
867        for (SpecimenDefinitionTypeTestedHandlingComponent i : handling)
868          dst.handling.add(i.copy());
869      }
870      ;
871    }
872
873    @Override
874    public boolean equalsDeep(Base other_) {
875      if (!super.equalsDeep(other_))
876        return false;
877      if (!(other_ instanceof SpecimenDefinitionTypeTestedComponent))
878        return false;
879      SpecimenDefinitionTypeTestedComponent o = (SpecimenDefinitionTypeTestedComponent) other_;
880      return compareDeep(isDerived, o.isDerived, true) && compareDeep(type, o.type, true)
881          && compareDeep(preference, o.preference, true) && compareDeep(container, o.container, true)
882          && compareDeep(requirement, o.requirement, true) && compareDeep(retentionTime, o.retentionTime, true)
883          && compareDeep(rejectionCriterion, o.rejectionCriterion, true) && compareDeep(handling, o.handling, true);
884    }
885
886    @Override
887    public boolean equalsShallow(Base other_) {
888      if (!super.equalsShallow(other_))
889        return false;
890      if (!(other_ instanceof SpecimenDefinitionTypeTestedComponent))
891        return false;
892      SpecimenDefinitionTypeTestedComponent o = (SpecimenDefinitionTypeTestedComponent) other_;
893      return compareValues(isDerived, o.isDerived, true) && compareValues(preference, o.preference, true)
894          && compareValues(requirement, o.requirement, true);
895    }
896
897    public boolean isEmpty() {
898      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(isDerived, type, preference, container,
899          requirement, retentionTime, rejectionCriterion, handling);
900    }
901
902    public String fhirType() {
903      return "SpecimenDefinition.typeTested";
904
905    }
906
907  }
908
909  @Block()
910  public static class SpecimenDefinitionTypeTestedContainerComponent extends BackboneElement
911      implements IBaseBackboneElement {
912    /**
913     * The type of material of the container.
914     */
915    @Child(name = "material", type = {
916        CodeableConcept.class }, order = 1, min = 0, max = 1, modifier = false, summary = false)
917    @Description(shortDefinition = "Container material", formalDefinition = "The type of material of the container.")
918    @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/container-material")
919    protected CodeableConcept material;
920
921    /**
922     * The type of container used to contain this kind of specimen.
923     */
924    @Child(name = "type", type = {
925        CodeableConcept.class }, order = 2, min = 0, max = 1, modifier = false, summary = false)
926    @Description(shortDefinition = "Kind of container associated with the kind of specimen", formalDefinition = "The type of container used to contain this kind of specimen.")
927    @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/specimen-container-type")
928    protected CodeableConcept type;
929
930    /**
931     * Color of container cap.
932     */
933    @Child(name = "cap", type = {
934        CodeableConcept.class }, order = 3, min = 0, max = 1, modifier = false, summary = false)
935    @Description(shortDefinition = "Color of container cap", formalDefinition = "Color of container cap.")
936    @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/container-cap")
937    protected CodeableConcept cap;
938
939    /**
940     * The textual description of the kind of container.
941     */
942    @Child(name = "description", type = {
943        StringType.class }, order = 4, min = 0, max = 1, modifier = false, summary = false)
944    @Description(shortDefinition = "Container description", formalDefinition = "The textual description of the kind of container.")
945    protected StringType description;
946
947    /**
948     * The capacity (volume or other measure) of this kind of container.
949     */
950    @Child(name = "capacity", type = { Quantity.class }, order = 5, min = 0, max = 1, modifier = false, summary = false)
951    @Description(shortDefinition = "Container capacity", formalDefinition = "The capacity (volume or other measure) of this kind of container.")
952    protected Quantity capacity;
953
954    /**
955     * The minimum volume to be conditioned in the container.
956     */
957    @Child(name = "minimumVolume", type = { Quantity.class,
958        StringType.class }, order = 6, min = 0, max = 1, modifier = false, summary = false)
959    @Description(shortDefinition = "Minimum volume", formalDefinition = "The minimum volume to be conditioned in the container.")
960    protected Type minimumVolume;
961
962    /**
963     * Substance introduced in the kind of container to preserve, maintain or
964     * enhance the specimen. Examples: Formalin, Citrate, EDTA.
965     */
966    @Child(name = "additive", type = {}, order = 7, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
967    @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.")
968    protected List<SpecimenDefinitionTypeTestedContainerAdditiveComponent> additive;
969
970    /**
971     * Special processing that should be applied to the container for this kind of
972     * specimen.
973     */
974    @Child(name = "preparation", type = {
975        StringType.class }, order = 8, min = 0, max = 1, modifier = false, summary = false)
976    @Description(shortDefinition = "Specimen container preparation", formalDefinition = "Special processing that should be applied to the container for this kind of specimen.")
977    protected StringType preparation;
978
979    private static final long serialVersionUID = 175789710L;
980
981    /**
982     * Constructor
983     */
984    public SpecimenDefinitionTypeTestedContainerComponent() {
985      super();
986    }
987
988    /**
989     * @return {@link #material} (The type of material of the container.)
990     */
991    public CodeableConcept getMaterial() {
992      if (this.material == null)
993        if (Configuration.errorOnAutoCreate())
994          throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedContainerComponent.material");
995        else if (Configuration.doAutoCreate())
996          this.material = new CodeableConcept(); // cc
997      return this.material;
998    }
999
1000    public boolean hasMaterial() {
1001      return this.material != null && !this.material.isEmpty();
1002    }
1003
1004    /**
1005     * @param value {@link #material} (The type of material of the container.)
1006     */
1007    public SpecimenDefinitionTypeTestedContainerComponent setMaterial(CodeableConcept value) {
1008      this.material = value;
1009      return this;
1010    }
1011
1012    /**
1013     * @return {@link #type} (The type of container used to contain this kind of
1014     *         specimen.)
1015     */
1016    public CodeableConcept getType() {
1017      if (this.type == null)
1018        if (Configuration.errorOnAutoCreate())
1019          throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedContainerComponent.type");
1020        else if (Configuration.doAutoCreate())
1021          this.type = new CodeableConcept(); // cc
1022      return this.type;
1023    }
1024
1025    public boolean hasType() {
1026      return this.type != null && !this.type.isEmpty();
1027    }
1028
1029    /**
1030     * @param value {@link #type} (The type of container used to contain this kind
1031     *              of specimen.)
1032     */
1033    public SpecimenDefinitionTypeTestedContainerComponent setType(CodeableConcept value) {
1034      this.type = value;
1035      return this;
1036    }
1037
1038    /**
1039     * @return {@link #cap} (Color of container cap.)
1040     */
1041    public CodeableConcept getCap() {
1042      if (this.cap == null)
1043        if (Configuration.errorOnAutoCreate())
1044          throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedContainerComponent.cap");
1045        else if (Configuration.doAutoCreate())
1046          this.cap = new CodeableConcept(); // cc
1047      return this.cap;
1048    }
1049
1050    public boolean hasCap() {
1051      return this.cap != null && !this.cap.isEmpty();
1052    }
1053
1054    /**
1055     * @param value {@link #cap} (Color of container cap.)
1056     */
1057    public SpecimenDefinitionTypeTestedContainerComponent setCap(CodeableConcept value) {
1058      this.cap = value;
1059      return this;
1060    }
1061
1062    /**
1063     * @return {@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 the
1066     *         value
1067     */
1068    public StringType getDescriptionElement() {
1069      if (this.description == null)
1070        if (Configuration.errorOnAutoCreate())
1071          throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedContainerComponent.description");
1072        else if (Configuration.doAutoCreate())
1073          this.description = new StringType(); // bb
1074      return this.description;
1075    }
1076
1077    public boolean hasDescriptionElement() {
1078      return this.description != null && !this.description.isEmpty();
1079    }
1080
1081    public boolean hasDescription() {
1082      return this.description != null && !this.description.isEmpty();
1083    }
1084
1085    /**
1086     * @param value {@link #description} (The textual description of the kind of
1087     *              container.). This is the underlying object with id, value and
1088     *              extensions. The accessor "getDescription" gives direct access to
1089     *              the value
1090     */
1091    public SpecimenDefinitionTypeTestedContainerComponent setDescriptionElement(StringType value) {
1092      this.description = value;
1093      return this;
1094    }
1095
1096    /**
1097     * @return The textual description of the kind of container.
1098     */
1099    public String getDescription() {
1100      return this.description == null ? null : this.description.getValue();
1101    }
1102
1103    /**
1104     * @param value The textual description of the kind of container.
1105     */
1106    public SpecimenDefinitionTypeTestedContainerComponent setDescription(String value) {
1107      if (Utilities.noString(value))
1108        this.description = null;
1109      else {
1110        if (this.description == null)
1111          this.description = new StringType();
1112        this.description.setValue(value);
1113      }
1114      return this;
1115    }
1116
1117    /**
1118     * @return {@link #capacity} (The capacity (volume or other measure) of this
1119     *         kind of container.)
1120     */
1121    public Quantity getCapacity() {
1122      if (this.capacity == null)
1123        if (Configuration.errorOnAutoCreate())
1124          throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedContainerComponent.capacity");
1125        else if (Configuration.doAutoCreate())
1126          this.capacity = new Quantity(); // cc
1127      return this.capacity;
1128    }
1129
1130    public boolean hasCapacity() {
1131      return this.capacity != null && !this.capacity.isEmpty();
1132    }
1133
1134    /**
1135     * @param value {@link #capacity} (The capacity (volume or other measure) of
1136     *              this kind of container.)
1137     */
1138    public SpecimenDefinitionTypeTestedContainerComponent setCapacity(Quantity value) {
1139      this.capacity = value;
1140      return this;
1141    }
1142
1143    /**
1144     * @return {@link #minimumVolume} (The minimum volume to be conditioned in the
1145     *         container.)
1146     */
1147    public Type getMinimumVolume() {
1148      return this.minimumVolume;
1149    }
1150
1151    /**
1152     * @return {@link #minimumVolume} (The minimum volume to be conditioned in the
1153     *         container.)
1154     */
1155    public Quantity getMinimumVolumeQuantity() throws FHIRException {
1156      if (this.minimumVolume == null)
1157        this.minimumVolume = new Quantity();
1158      if (!(this.minimumVolume instanceof Quantity))
1159        throw new FHIRException("Type mismatch: the type Quantity was expected, but "
1160            + this.minimumVolume.getClass().getName() + " was encountered");
1161      return (Quantity) this.minimumVolume;
1162    }
1163
1164    public boolean hasMinimumVolumeQuantity() {
1165      return this != null && this.minimumVolume instanceof Quantity;
1166    }
1167
1168    /**
1169     * @return {@link #minimumVolume} (The minimum volume to be conditioned in the
1170     *         container.)
1171     */
1172    public StringType getMinimumVolumeStringType() throws FHIRException {
1173      if (this.minimumVolume == null)
1174        this.minimumVolume = new StringType();
1175      if (!(this.minimumVolume instanceof StringType))
1176        throw new FHIRException("Type mismatch: the type StringType was expected, but "
1177            + this.minimumVolume.getClass().getName() + " was encountered");
1178      return (StringType) this.minimumVolume;
1179    }
1180
1181    public boolean hasMinimumVolumeStringType() {
1182      return this != null && this.minimumVolume instanceof StringType;
1183    }
1184
1185    public boolean hasMinimumVolume() {
1186      return this.minimumVolume != null && !this.minimumVolume.isEmpty();
1187    }
1188
1189    /**
1190     * @param value {@link #minimumVolume} (The minimum volume to be conditioned in
1191     *              the container.)
1192     */
1193    public SpecimenDefinitionTypeTestedContainerComponent setMinimumVolume(Type value) {
1194      if (value != null && !(value instanceof Quantity || value instanceof StringType))
1195        throw new Error(
1196            "Not the right type for SpecimenDefinition.typeTested.container.minimumVolume[x]: " + value.fhirType());
1197      this.minimumVolume = value;
1198      return this;
1199    }
1200
1201    /**
1202     * @return {@link #additive} (Substance introduced in the kind of container to
1203     *         preserve, maintain or enhance the specimen. Examples: Formalin,
1204     *         Citrate, EDTA.)
1205     */
1206    public List<SpecimenDefinitionTypeTestedContainerAdditiveComponent> getAdditive() {
1207      if (this.additive == null)
1208        this.additive = new ArrayList<SpecimenDefinitionTypeTestedContainerAdditiveComponent>();
1209      return this.additive;
1210    }
1211
1212    /**
1213     * @return Returns a reference to <code>this</code> for easy method chaining
1214     */
1215    public SpecimenDefinitionTypeTestedContainerComponent setAdditive(
1216        List<SpecimenDefinitionTypeTestedContainerAdditiveComponent> theAdditive) {
1217      this.additive = theAdditive;
1218      return this;
1219    }
1220
1221    public boolean hasAdditive() {
1222      if (this.additive == null)
1223        return false;
1224      for (SpecimenDefinitionTypeTestedContainerAdditiveComponent item : this.additive)
1225        if (!item.isEmpty())
1226          return true;
1227      return false;
1228    }
1229
1230    public SpecimenDefinitionTypeTestedContainerAdditiveComponent addAdditive() { // 3
1231      SpecimenDefinitionTypeTestedContainerAdditiveComponent t = new SpecimenDefinitionTypeTestedContainerAdditiveComponent();
1232      if (this.additive == null)
1233        this.additive = new ArrayList<SpecimenDefinitionTypeTestedContainerAdditiveComponent>();
1234      this.additive.add(t);
1235      return t;
1236    }
1237
1238    public SpecimenDefinitionTypeTestedContainerComponent addAdditive(
1239        SpecimenDefinitionTypeTestedContainerAdditiveComponent t) { // 3
1240      if (t == null)
1241        return this;
1242      if (this.additive == null)
1243        this.additive = new ArrayList<SpecimenDefinitionTypeTestedContainerAdditiveComponent>();
1244      this.additive.add(t);
1245      return this;
1246    }
1247
1248    /**
1249     * @return The first repetition of repeating field {@link #additive}, creating
1250     *         it if it does not already exist
1251     */
1252    public SpecimenDefinitionTypeTestedContainerAdditiveComponent getAdditiveFirstRep() {
1253      if (getAdditive().isEmpty()) {
1254        addAdditive();
1255      }
1256      return getAdditive().get(0);
1257    }
1258
1259    /**
1260     * @return {@link #preparation} (Special processing that should be applied to
1261     *         the container for this kind of specimen.). This is the underlying
1262     *         object with id, value and extensions. The accessor "getPreparation"
1263     *         gives direct access to the value
1264     */
1265    public StringType getPreparationElement() {
1266      if (this.preparation == null)
1267        if (Configuration.errorOnAutoCreate())
1268          throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedContainerComponent.preparation");
1269        else if (Configuration.doAutoCreate())
1270          this.preparation = new StringType(); // bb
1271      return this.preparation;
1272    }
1273
1274    public boolean hasPreparationElement() {
1275      return this.preparation != null && !this.preparation.isEmpty();
1276    }
1277
1278    public boolean hasPreparation() {
1279      return this.preparation != null && !this.preparation.isEmpty();
1280    }
1281
1282    /**
1283     * @param value {@link #preparation} (Special processing that should be applied
1284     *              to the container for this kind of specimen.). This is the
1285     *              underlying object with id, value and extensions. The accessor
1286     *              "getPreparation" gives direct access to the value
1287     */
1288    public SpecimenDefinitionTypeTestedContainerComponent setPreparationElement(StringType value) {
1289      this.preparation = value;
1290      return this;
1291    }
1292
1293    /**
1294     * @return Special processing that should be applied to the container for this
1295     *         kind of specimen.
1296     */
1297    public String getPreparation() {
1298      return this.preparation == null ? null : this.preparation.getValue();
1299    }
1300
1301    /**
1302     * @param value Special processing that should be applied to the container for
1303     *              this kind of specimen.
1304     */
1305    public SpecimenDefinitionTypeTestedContainerComponent setPreparation(String value) {
1306      if (Utilities.noString(value))
1307        this.preparation = null;
1308      else {
1309        if (this.preparation == null)
1310          this.preparation = new StringType();
1311        this.preparation.setValue(value);
1312      }
1313      return this;
1314    }
1315
1316    protected void listChildren(List<Property> children) {
1317      super.listChildren(children);
1318      children
1319          .add(new Property("material", "CodeableConcept", "The type of material of the container.", 0, 1, material));
1320      children.add(new Property("type", "CodeableConcept",
1321          "The type of container used to contain this kind of specimen.", 0, 1, type));
1322      children.add(new Property("cap", "CodeableConcept", "Color of container cap.", 0, 1, cap));
1323      children.add(new Property("description", "string", "The textual description of the kind of container.", 0, 1,
1324          description));
1325      children.add(new Property("capacity", "SimpleQuantity",
1326          "The capacity (volume or other measure) of this kind of container.", 0, 1, capacity));
1327      children.add(new Property("minimumVolume[x]", "SimpleQuantity|string",
1328          "The minimum volume to be conditioned in the container.", 0, 1, minimumVolume));
1329      children.add(new Property("additive", "",
1330          "Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.",
1331          0, java.lang.Integer.MAX_VALUE, additive));
1332      children.add(new Property("preparation", "string",
1333          "Special processing that should be applied to the container for this kind of specimen.", 0, 1, preparation));
1334    }
1335
1336    @Override
1337    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1338      switch (_hash) {
1339      case 299066663:
1340        /* material */ return new Property("material", "CodeableConcept", "The type of material of the container.", 0,
1341            1, material);
1342      case 3575610:
1343        /* type */ return new Property("type", "CodeableConcept",
1344            "The type of container used to contain this kind of specimen.", 0, 1, type);
1345      case 98258:
1346        /* cap */ return new Property("cap", "CodeableConcept", "Color of container cap.", 0, 1, cap);
1347      case -1724546052:
1348        /* description */ return new Property("description", "string",
1349            "The textual description of the kind of container.", 0, 1, description);
1350      case -67824454:
1351        /* capacity */ return new Property("capacity", "SimpleQuantity",
1352            "The capacity (volume or other measure) of this kind of container.", 0, 1, capacity);
1353      case 371830456:
1354        /* minimumVolume[x] */ return new Property("minimumVolume[x]", "SimpleQuantity|string",
1355            "The minimum volume to be conditioned in the container.", 0, 1, minimumVolume);
1356      case -1674665784:
1357        /* minimumVolume */ return new Property("minimumVolume[x]", "SimpleQuantity|string",
1358            "The minimum volume to be conditioned in the container.", 0, 1, minimumVolume);
1359      case -532143757:
1360        /* minimumVolumeQuantity */ return new Property("minimumVolume[x]", "SimpleQuantity|string",
1361            "The minimum volume to be conditioned in the container.", 0, 1, minimumVolume);
1362      case 248461049:
1363        /* minimumVolumeString */ return new Property("minimumVolume[x]", "SimpleQuantity|string",
1364            "The minimum volume to be conditioned in the container.", 0, 1, minimumVolume);
1365      case -1226589236:
1366        /* additive */ return new Property("additive", "",
1367            "Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.",
1368            0, java.lang.Integer.MAX_VALUE, additive);
1369      case -1315428713:
1370        /* preparation */ return new Property("preparation", "string",
1371            "Special processing that should be applied to the container for this kind of specimen.", 0, 1, preparation);
1372      default:
1373        return super.getNamedProperty(_hash, _name, _checkValid);
1374      }
1375
1376    }
1377
1378    @Override
1379    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1380      switch (hash) {
1381      case 299066663:
1382        /* material */ return this.material == null ? new Base[0] : new Base[] { this.material }; // CodeableConcept
1383      case 3575610:
1384        /* type */ return this.type == null ? new Base[0] : new Base[] { this.type }; // CodeableConcept
1385      case 98258:
1386        /* cap */ return this.cap == null ? new Base[0] : new Base[] { this.cap }; // CodeableConcept
1387      case -1724546052:
1388        /* description */ return this.description == null ? new Base[0] : new Base[] { this.description }; // StringType
1389      case -67824454:
1390        /* capacity */ return this.capacity == null ? new Base[0] : new Base[] { this.capacity }; // Quantity
1391      case -1674665784:
1392        /* minimumVolume */ return this.minimumVolume == null ? new Base[0] : new Base[] { this.minimumVolume }; // Type
1393      case -1226589236:
1394        /* additive */ return this.additive == null ? new Base[0]
1395            : this.additive.toArray(new Base[this.additive.size()]); // SpecimenDefinitionTypeTestedContainerAdditiveComponent
1396      case -1315428713:
1397        /* preparation */ return this.preparation == null ? new Base[0] : new Base[] { this.preparation }; // StringType
1398      default:
1399        return super.getProperty(hash, name, checkValid);
1400      }
1401
1402    }
1403
1404    @Override
1405    public Base setProperty(int hash, String name, Base value) throws FHIRException {
1406      switch (hash) {
1407      case 299066663: // material
1408        this.material = castToCodeableConcept(value); // CodeableConcept
1409        return value;
1410      case 3575610: // type
1411        this.type = castToCodeableConcept(value); // CodeableConcept
1412        return value;
1413      case 98258: // cap
1414        this.cap = castToCodeableConcept(value); // CodeableConcept
1415        return value;
1416      case -1724546052: // description
1417        this.description = castToString(value); // StringType
1418        return value;
1419      case -67824454: // capacity
1420        this.capacity = castToQuantity(value); // Quantity
1421        return value;
1422      case -1674665784: // minimumVolume
1423        this.minimumVolume = castToType(value); // Type
1424        return value;
1425      case -1226589236: // additive
1426        this.getAdditive().add((SpecimenDefinitionTypeTestedContainerAdditiveComponent) value); // SpecimenDefinitionTypeTestedContainerAdditiveComponent
1427        return value;
1428      case -1315428713: // preparation
1429        this.preparation = castToString(value); // StringType
1430        return value;
1431      default:
1432        return super.setProperty(hash, name, value);
1433      }
1434
1435    }
1436
1437    @Override
1438    public Base setProperty(String name, Base value) throws FHIRException {
1439      if (name.equals("material")) {
1440        this.material = castToCodeableConcept(value); // CodeableConcept
1441      } else if (name.equals("type")) {
1442        this.type = castToCodeableConcept(value); // CodeableConcept
1443      } else if (name.equals("cap")) {
1444        this.cap = castToCodeableConcept(value); // CodeableConcept
1445      } else if (name.equals("description")) {
1446        this.description = castToString(value); // StringType
1447      } else if (name.equals("capacity")) {
1448        this.capacity = castToQuantity(value); // Quantity
1449      } else if (name.equals("minimumVolume[x]")) {
1450        this.minimumVolume = castToType(value); // Type
1451      } else if (name.equals("additive")) {
1452        this.getAdditive().add((SpecimenDefinitionTypeTestedContainerAdditiveComponent) value);
1453      } else if (name.equals("preparation")) {
1454        this.preparation = castToString(value); // StringType
1455      } else
1456        return super.setProperty(name, value);
1457      return value;
1458    }
1459
1460  @Override
1461  public void removeChild(String name, Base value) throws FHIRException {
1462      if (name.equals("material")) {
1463        this.material = null;
1464      } else if (name.equals("type")) {
1465        this.type = null;
1466      } else if (name.equals("cap")) {
1467        this.cap = null;
1468      } else if (name.equals("description")) {
1469        this.description = null;
1470      } else if (name.equals("capacity")) {
1471        this.capacity = null;
1472      } else if (name.equals("minimumVolume[x]")) {
1473        this.minimumVolume = null;
1474      } else if (name.equals("additive")) {
1475        this.getAdditive().remove((SpecimenDefinitionTypeTestedContainerAdditiveComponent) value);
1476      } else if (name.equals("preparation")) {
1477        this.preparation = null;
1478      } else
1479        super.removeChild(name, value);
1480      
1481    }
1482
1483    @Override
1484    public Base makeProperty(int hash, String name) throws FHIRException {
1485      switch (hash) {
1486      case 299066663:
1487        return getMaterial();
1488      case 3575610:
1489        return getType();
1490      case 98258:
1491        return getCap();
1492      case -1724546052:
1493        return getDescriptionElement();
1494      case -67824454:
1495        return getCapacity();
1496      case 371830456:
1497        return getMinimumVolume();
1498      case -1674665784:
1499        return getMinimumVolume();
1500      case -1226589236:
1501        return addAdditive();
1502      case -1315428713:
1503        return getPreparationElement();
1504      default:
1505        return super.makeProperty(hash, name);
1506      }
1507
1508    }
1509
1510    @Override
1511    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1512      switch (hash) {
1513      case 299066663:
1514        /* material */ return new String[] { "CodeableConcept" };
1515      case 3575610:
1516        /* type */ return new String[] { "CodeableConcept" };
1517      case 98258:
1518        /* cap */ return new String[] { "CodeableConcept" };
1519      case -1724546052:
1520        /* description */ return new String[] { "string" };
1521      case -67824454:
1522        /* capacity */ return new String[] { "SimpleQuantity" };
1523      case -1674665784:
1524        /* minimumVolume */ return new String[] { "SimpleQuantity", "string" };
1525      case -1226589236:
1526        /* additive */ return new String[] {};
1527      case -1315428713:
1528        /* preparation */ return new String[] { "string" };
1529      default:
1530        return super.getTypesForProperty(hash, name);
1531      }
1532
1533    }
1534
1535    @Override
1536    public Base addChild(String name) throws FHIRException {
1537      if (name.equals("material")) {
1538        this.material = new CodeableConcept();
1539        return this.material;
1540      } else if (name.equals("type")) {
1541        this.type = new CodeableConcept();
1542        return this.type;
1543      } else if (name.equals("cap")) {
1544        this.cap = new CodeableConcept();
1545        return this.cap;
1546      } else if (name.equals("description")) {
1547        throw new FHIRException("Cannot call addChild on a singleton property SpecimenDefinition.description");
1548      } else if (name.equals("capacity")) {
1549        this.capacity = new Quantity();
1550        return this.capacity;
1551      } else if (name.equals("minimumVolumeQuantity")) {
1552        this.minimumVolume = new Quantity();
1553        return this.minimumVolume;
1554      } else if (name.equals("minimumVolumeString")) {
1555        this.minimumVolume = new StringType();
1556        return this.minimumVolume;
1557      } else if (name.equals("additive")) {
1558        return addAdditive();
1559      } else if (name.equals("preparation")) {
1560        throw new FHIRException("Cannot call addChild on a singleton property SpecimenDefinition.preparation");
1561      } else
1562        return super.addChild(name);
1563    }
1564
1565    public SpecimenDefinitionTypeTestedContainerComponent copy() {
1566      SpecimenDefinitionTypeTestedContainerComponent dst = new SpecimenDefinitionTypeTestedContainerComponent();
1567      copyValues(dst);
1568      return dst;
1569    }
1570
1571    public void copyValues(SpecimenDefinitionTypeTestedContainerComponent dst) {
1572      super.copyValues(dst);
1573      dst.material = material == null ? null : material.copy();
1574      dst.type = type == null ? null : type.copy();
1575      dst.cap = cap == null ? null : cap.copy();
1576      dst.description = description == null ? null : description.copy();
1577      dst.capacity = capacity == null ? null : capacity.copy();
1578      dst.minimumVolume = minimumVolume == null ? null : minimumVolume.copy();
1579      if (additive != null) {
1580        dst.additive = new ArrayList<SpecimenDefinitionTypeTestedContainerAdditiveComponent>();
1581        for (SpecimenDefinitionTypeTestedContainerAdditiveComponent i : additive)
1582          dst.additive.add(i.copy());
1583      }
1584      ;
1585      dst.preparation = preparation == null ? null : preparation.copy();
1586    }
1587
1588    @Override
1589    public boolean equalsDeep(Base other_) {
1590      if (!super.equalsDeep(other_))
1591        return false;
1592      if (!(other_ instanceof SpecimenDefinitionTypeTestedContainerComponent))
1593        return false;
1594      SpecimenDefinitionTypeTestedContainerComponent o = (SpecimenDefinitionTypeTestedContainerComponent) other_;
1595      return compareDeep(material, o.material, true) && compareDeep(type, o.type, true) && compareDeep(cap, o.cap, true)
1596          && compareDeep(description, o.description, true) && compareDeep(capacity, o.capacity, true)
1597          && compareDeep(minimumVolume, o.minimumVolume, true) && compareDeep(additive, o.additive, true)
1598          && compareDeep(preparation, o.preparation, true);
1599    }
1600
1601    @Override
1602    public boolean equalsShallow(Base other_) {
1603      if (!super.equalsShallow(other_))
1604        return false;
1605      if (!(other_ instanceof SpecimenDefinitionTypeTestedContainerComponent))
1606        return false;
1607      SpecimenDefinitionTypeTestedContainerComponent o = (SpecimenDefinitionTypeTestedContainerComponent) other_;
1608      return compareValues(description, o.description, true) && compareValues(preparation, o.preparation, true);
1609    }
1610
1611    public boolean isEmpty() {
1612      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(material, type, cap, description, capacity,
1613          minimumVolume, additive, preparation);
1614    }
1615
1616    public String fhirType() {
1617      return "SpecimenDefinition.typeTested.container";
1618
1619    }
1620
1621  }
1622
1623  @Block()
1624  public static class SpecimenDefinitionTypeTestedContainerAdditiveComponent extends BackboneElement
1625      implements IBaseBackboneElement {
1626    /**
1627     * Substance introduced in the kind of container to preserve, maintain or
1628     * enhance the specimen. Examples: Formalin, Citrate, EDTA.
1629     */
1630    @Child(name = "additive", type = { CodeableConcept.class,
1631        Substance.class }, order = 1, min = 1, max = 1, modifier = false, summary = false)
1632    @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.")
1633    @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://terminology.hl7.org/ValueSet/v2-0371")
1634    protected Type additive;
1635
1636    private static final long serialVersionUID = 1819209272L;
1637
1638    /**
1639     * Constructor
1640     */
1641    public SpecimenDefinitionTypeTestedContainerAdditiveComponent() {
1642      super();
1643    }
1644
1645    /**
1646     * Constructor
1647     */
1648    public SpecimenDefinitionTypeTestedContainerAdditiveComponent(Type additive) {
1649      super();
1650      this.additive = additive;
1651    }
1652
1653    /**
1654     * @return {@link #additive} (Substance introduced in the kind of container to
1655     *         preserve, maintain or enhance the specimen. Examples: Formalin,
1656     *         Citrate, EDTA.)
1657     */
1658    public Type getAdditive() {
1659      return this.additive;
1660    }
1661
1662    /**
1663     * @return {@link #additive} (Substance introduced in the kind of container to
1664     *         preserve, maintain or enhance the specimen. Examples: Formalin,
1665     *         Citrate, EDTA.)
1666     */
1667    public CodeableConcept getAdditiveCodeableConcept() throws FHIRException {
1668      if (this.additive == null)
1669        this.additive = new CodeableConcept();
1670      if (!(this.additive instanceof CodeableConcept))
1671        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "
1672            + this.additive.getClass().getName() + " was encountered");
1673      return (CodeableConcept) this.additive;
1674    }
1675
1676    public boolean hasAdditiveCodeableConcept() {
1677      return this != null && this.additive instanceof CodeableConcept;
1678    }
1679
1680    /**
1681     * @return {@link #additive} (Substance introduced in the kind of container to
1682     *         preserve, maintain or enhance the specimen. Examples: Formalin,
1683     *         Citrate, EDTA.)
1684     */
1685    public Reference getAdditiveReference() throws FHIRException {
1686      if (this.additive == null)
1687        this.additive = new Reference();
1688      if (!(this.additive instanceof Reference))
1689        throw new FHIRException("Type mismatch: the type Reference was expected, but "
1690            + this.additive.getClass().getName() + " was encountered");
1691      return (Reference) this.additive;
1692    }
1693
1694    public boolean hasAdditiveReference() {
1695      return this != null && this.additive instanceof Reference;
1696    }
1697
1698    public boolean hasAdditive() {
1699      return this.additive != null && !this.additive.isEmpty();
1700    }
1701
1702    /**
1703     * @param value {@link #additive} (Substance introduced in the kind of container
1704     *              to preserve, maintain or enhance the specimen. Examples:
1705     *              Formalin, Citrate, EDTA.)
1706     */
1707    public SpecimenDefinitionTypeTestedContainerAdditiveComponent setAdditive(Type value) {
1708      if (value != null && !(value instanceof CodeableConcept || value instanceof Reference))
1709        throw new Error(
1710            "Not the right type for SpecimenDefinition.typeTested.container.additive.additive[x]: " + value.fhirType());
1711      this.additive = value;
1712      return this;
1713    }
1714
1715    protected void listChildren(List<Property> children) {
1716      super.listChildren(children);
1717      children.add(new Property("additive[x]", "CodeableConcept|Reference(Substance)",
1718          "Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.",
1719          0, 1, additive));
1720    }
1721
1722    @Override
1723    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1724      switch (_hash) {
1725      case 261915956:
1726        /* additive[x] */ return new Property("additive[x]", "CodeableConcept|Reference(Substance)",
1727            "Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.",
1728            0, 1, additive);
1729      case -1226589236:
1730        /* additive */ return new Property("additive[x]", "CodeableConcept|Reference(Substance)",
1731            "Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.",
1732            0, 1, additive);
1733      case 1330272821:
1734        /* additiveCodeableConcept */ return new Property("additive[x]", "CodeableConcept|Reference(Substance)",
1735            "Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.",
1736            0, 1, additive);
1737      case -386783009:
1738        /* additiveReference */ return new Property("additive[x]", "CodeableConcept|Reference(Substance)",
1739            "Substance introduced in the kind of container to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.",
1740            0, 1, additive);
1741      default:
1742        return super.getNamedProperty(_hash, _name, _checkValid);
1743      }
1744
1745    }
1746
1747    @Override
1748    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1749      switch (hash) {
1750      case -1226589236:
1751        /* additive */ return this.additive == null ? new Base[0] : new Base[] { this.additive }; // Type
1752      default:
1753        return super.getProperty(hash, name, checkValid);
1754      }
1755
1756    }
1757
1758    @Override
1759    public Base setProperty(int hash, String name, Base value) throws FHIRException {
1760      switch (hash) {
1761      case -1226589236: // additive
1762        this.additive = castToType(value); // Type
1763        return value;
1764      default:
1765        return super.setProperty(hash, name, value);
1766      }
1767
1768    }
1769
1770    @Override
1771    public Base setProperty(String name, Base value) throws FHIRException {
1772      if (name.equals("additive[x]")) {
1773        this.additive = castToType(value); // Type
1774      } else
1775        return super.setProperty(name, value);
1776      return value;
1777    }
1778
1779  @Override
1780  public void removeChild(String name, Base value) throws FHIRException {
1781      if (name.equals("additive[x]")) {
1782        this.additive = null;
1783      } else
1784        super.removeChild(name, value);
1785      
1786    }
1787
1788    @Override
1789    public Base makeProperty(int hash, String name) throws FHIRException {
1790      switch (hash) {
1791      case 261915956:
1792        return getAdditive();
1793      case -1226589236:
1794        return getAdditive();
1795      default:
1796        return super.makeProperty(hash, name);
1797      }
1798
1799    }
1800
1801    @Override
1802    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1803      switch (hash) {
1804      case -1226589236:
1805        /* additive */ return new String[] { "CodeableConcept", "Reference" };
1806      default:
1807        return super.getTypesForProperty(hash, name);
1808      }
1809
1810    }
1811
1812    @Override
1813    public Base addChild(String name) throws FHIRException {
1814      if (name.equals("additiveCodeableConcept")) {
1815        this.additive = new CodeableConcept();
1816        return this.additive;
1817      } else if (name.equals("additiveReference")) {
1818        this.additive = new Reference();
1819        return this.additive;
1820      } else
1821        return super.addChild(name);
1822    }
1823
1824    public SpecimenDefinitionTypeTestedContainerAdditiveComponent copy() {
1825      SpecimenDefinitionTypeTestedContainerAdditiveComponent dst = new SpecimenDefinitionTypeTestedContainerAdditiveComponent();
1826      copyValues(dst);
1827      return dst;
1828    }
1829
1830    public void copyValues(SpecimenDefinitionTypeTestedContainerAdditiveComponent dst) {
1831      super.copyValues(dst);
1832      dst.additive = additive == null ? null : additive.copy();
1833    }
1834
1835    @Override
1836    public boolean equalsDeep(Base other_) {
1837      if (!super.equalsDeep(other_))
1838        return false;
1839      if (!(other_ instanceof SpecimenDefinitionTypeTestedContainerAdditiveComponent))
1840        return false;
1841      SpecimenDefinitionTypeTestedContainerAdditiveComponent o = (SpecimenDefinitionTypeTestedContainerAdditiveComponent) other_;
1842      return compareDeep(additive, o.additive, true);
1843    }
1844
1845    @Override
1846    public boolean equalsShallow(Base other_) {
1847      if (!super.equalsShallow(other_))
1848        return false;
1849      if (!(other_ instanceof SpecimenDefinitionTypeTestedContainerAdditiveComponent))
1850        return false;
1851      SpecimenDefinitionTypeTestedContainerAdditiveComponent o = (SpecimenDefinitionTypeTestedContainerAdditiveComponent) other_;
1852      return true;
1853    }
1854
1855    public boolean isEmpty() {
1856      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(additive);
1857    }
1858
1859    public String fhirType() {
1860      return "SpecimenDefinition.typeTested.container.additive";
1861
1862    }
1863
1864  }
1865
1866  @Block()
1867  public static class SpecimenDefinitionTypeTestedHandlingComponent extends BackboneElement
1868      implements IBaseBackboneElement {
1869    /**
1870     * It qualifies the interval of temperature, which characterizes an occurrence
1871     * of handling. Conditions that are not related to temperature may be handled in
1872     * the instruction element.
1873     */
1874    @Child(name = "temperatureQualifier", type = {
1875        CodeableConcept.class }, order = 1, min = 0, max = 1, modifier = false, summary = false)
1876    @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.")
1877    @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/handling-condition")
1878    protected CodeableConcept temperatureQualifier;
1879
1880    /**
1881     * The temperature interval for this set of handling instructions.
1882     */
1883    @Child(name = "temperatureRange", type = {
1884        Range.class }, order = 2, min = 0, max = 1, modifier = false, summary = false)
1885    @Description(shortDefinition = "Temperature range", formalDefinition = "The temperature interval for this set of handling instructions.")
1886    protected Range temperatureRange;
1887
1888    /**
1889     * The maximum time interval of preservation of the specimen with these
1890     * conditions.
1891     */
1892    @Child(name = "maxDuration", type = {
1893        Duration.class }, order = 3, min = 0, max = 1, modifier = false, summary = false)
1894    @Description(shortDefinition = "Maximum preservation time", formalDefinition = "The maximum time interval of preservation of the specimen with these conditions.")
1895    protected Duration maxDuration;
1896
1897    /**
1898     * Additional textual instructions for the preservation or transport of the
1899     * specimen. For instance, 'Protect from light exposure'.
1900     */
1901    @Child(name = "instruction", type = {
1902        StringType.class }, order = 4, min = 0, max = 1, modifier = false, summary = false)
1903    @Description(shortDefinition = "Preservation instruction", formalDefinition = "Additional textual instructions for the preservation or transport of the specimen. For instance, 'Protect from light exposure'.")
1904    protected StringType instruction;
1905
1906    private static final long serialVersionUID = 2130906844L;
1907
1908    /**
1909     * Constructor
1910     */
1911    public SpecimenDefinitionTypeTestedHandlingComponent() {
1912      super();
1913    }
1914
1915    /**
1916     * @return {@link #temperatureQualifier} (It qualifies the interval of
1917     *         temperature, which characterizes an occurrence of handling.
1918     *         Conditions that are not related to temperature may be handled in the
1919     *         instruction element.)
1920     */
1921    public CodeableConcept getTemperatureQualifier() {
1922      if (this.temperatureQualifier == null)
1923        if (Configuration.errorOnAutoCreate())
1924          throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedHandlingComponent.temperatureQualifier");
1925        else if (Configuration.doAutoCreate())
1926          this.temperatureQualifier = new CodeableConcept(); // cc
1927      return this.temperatureQualifier;
1928    }
1929
1930    public boolean hasTemperatureQualifier() {
1931      return this.temperatureQualifier != null && !this.temperatureQualifier.isEmpty();
1932    }
1933
1934    /**
1935     * @param value {@link #temperatureQualifier} (It qualifies the interval of
1936     *              temperature, which characterizes an occurrence of handling.
1937     *              Conditions that are not related to temperature may be handled in
1938     *              the instruction element.)
1939     */
1940    public SpecimenDefinitionTypeTestedHandlingComponent setTemperatureQualifier(CodeableConcept value) {
1941      this.temperatureQualifier = value;
1942      return this;
1943    }
1944
1945    /**
1946     * @return {@link #temperatureRange} (The temperature interval for this set of
1947     *         handling instructions.)
1948     */
1949    public Range getTemperatureRange() {
1950      if (this.temperatureRange == null)
1951        if (Configuration.errorOnAutoCreate())
1952          throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedHandlingComponent.temperatureRange");
1953        else if (Configuration.doAutoCreate())
1954          this.temperatureRange = new Range(); // cc
1955      return this.temperatureRange;
1956    }
1957
1958    public boolean hasTemperatureRange() {
1959      return this.temperatureRange != null && !this.temperatureRange.isEmpty();
1960    }
1961
1962    /**
1963     * @param value {@link #temperatureRange} (The temperature interval for this set
1964     *              of handling instructions.)
1965     */
1966    public SpecimenDefinitionTypeTestedHandlingComponent setTemperatureRange(Range value) {
1967      this.temperatureRange = value;
1968      return this;
1969    }
1970
1971    /**
1972     * @return {@link #maxDuration} (The maximum time interval of preservation of
1973     *         the specimen with these conditions.)
1974     */
1975    public Duration getMaxDuration() {
1976      if (this.maxDuration == null)
1977        if (Configuration.errorOnAutoCreate())
1978          throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedHandlingComponent.maxDuration");
1979        else if (Configuration.doAutoCreate())
1980          this.maxDuration = new Duration(); // cc
1981      return this.maxDuration;
1982    }
1983
1984    public boolean hasMaxDuration() {
1985      return this.maxDuration != null && !this.maxDuration.isEmpty();
1986    }
1987
1988    /**
1989     * @param value {@link #maxDuration} (The maximum time interval of preservation
1990     *              of the specimen with these conditions.)
1991     */
1992    public SpecimenDefinitionTypeTestedHandlingComponent setMaxDuration(Duration value) {
1993      this.maxDuration = value;
1994      return this;
1995    }
1996
1997    /**
1998     * @return {@link #instruction} (Additional textual instructions for the
1999     *         preservation or transport of the specimen. For instance, 'Protect
2000     *         from light exposure'.). This is the underlying object with id, value
2001     *         and extensions. The accessor "getInstruction" gives direct access to
2002     *         the value
2003     */
2004    public StringType getInstructionElement() {
2005      if (this.instruction == null)
2006        if (Configuration.errorOnAutoCreate())
2007          throw new Error("Attempt to auto-create SpecimenDefinitionTypeTestedHandlingComponent.instruction");
2008        else if (Configuration.doAutoCreate())
2009          this.instruction = new StringType(); // bb
2010      return this.instruction;
2011    }
2012
2013    public boolean hasInstructionElement() {
2014      return this.instruction != null && !this.instruction.isEmpty();
2015    }
2016
2017    public boolean hasInstruction() {
2018      return this.instruction != null && !this.instruction.isEmpty();
2019    }
2020
2021    /**
2022     * @param value {@link #instruction} (Additional textual instructions for the
2023     *              preservation or transport of the specimen. For instance,
2024     *              'Protect from light exposure'.). This is the underlying object
2025     *              with id, value and extensions. The accessor "getInstruction"
2026     *              gives direct access to the value
2027     */
2028    public SpecimenDefinitionTypeTestedHandlingComponent setInstructionElement(StringType value) {
2029      this.instruction = value;
2030      return this;
2031    }
2032
2033    /**
2034     * @return Additional textual instructions for the preservation or transport of
2035     *         the specimen. For instance, 'Protect from light exposure'.
2036     */
2037    public String getInstruction() {
2038      return this.instruction == null ? null : this.instruction.getValue();
2039    }
2040
2041    /**
2042     * @param value Additional textual instructions for the preservation or
2043     *              transport of the specimen. For instance, 'Protect from light
2044     *              exposure'.
2045     */
2046    public SpecimenDefinitionTypeTestedHandlingComponent setInstruction(String value) {
2047      if (Utilities.noString(value))
2048        this.instruction = null;
2049      else {
2050        if (this.instruction == null)
2051          this.instruction = new StringType();
2052        this.instruction.setValue(value);
2053      }
2054      return this;
2055    }
2056
2057    protected void listChildren(List<Property> children) {
2058      super.listChildren(children);
2059      children.add(new Property("temperatureQualifier", "CodeableConcept",
2060          "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.",
2061          0, 1, temperatureQualifier));
2062      children.add(new Property("temperatureRange", "Range",
2063          "The temperature interval for this set of handling instructions.", 0, 1, temperatureRange));
2064      children.add(new Property("maxDuration", "Duration",
2065          "The maximum time interval of preservation of the specimen with these conditions.", 0, 1, maxDuration));
2066      children.add(new Property("instruction", "string",
2067          "Additional textual instructions for the preservation or transport of the specimen. For instance, 'Protect from light exposure'.",
2068          0, 1, instruction));
2069    }
2070
2071    @Override
2072    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2073      switch (_hash) {
2074      case 548941206:
2075        /* temperatureQualifier */ return new Property("temperatureQualifier", "CodeableConcept",
2076            "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.",
2077            0, 1, temperatureQualifier);
2078      case -39203799:
2079        /* temperatureRange */ return new Property("temperatureRange", "Range",
2080            "The temperature interval for this set of handling instructions.", 0, 1, temperatureRange);
2081      case 40284952:
2082        /* maxDuration */ return new Property("maxDuration", "Duration",
2083            "The maximum time interval of preservation of the specimen with these conditions.", 0, 1, maxDuration);
2084      case 301526158:
2085        /* instruction */ return new Property("instruction", "string",
2086            "Additional textual instructions for the preservation or transport of the specimen. For instance, 'Protect from light exposure'.",
2087            0, 1, instruction);
2088      default:
2089        return super.getNamedProperty(_hash, _name, _checkValid);
2090      }
2091
2092    }
2093
2094    @Override
2095    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2096      switch (hash) {
2097      case 548941206:
2098        /* temperatureQualifier */ return this.temperatureQualifier == null ? new Base[0]
2099            : new Base[] { this.temperatureQualifier }; // CodeableConcept
2100      case -39203799:
2101        /* temperatureRange */ return this.temperatureRange == null ? new Base[0]
2102            : new Base[] { this.temperatureRange }; // Range
2103      case 40284952:
2104        /* maxDuration */ return this.maxDuration == null ? new Base[0] : new Base[] { this.maxDuration }; // Duration
2105      case 301526158:
2106        /* instruction */ return this.instruction == null ? new Base[0] : new Base[] { this.instruction }; // StringType
2107      default:
2108        return super.getProperty(hash, name, checkValid);
2109      }
2110
2111    }
2112
2113    @Override
2114    public Base setProperty(int hash, String name, Base value) throws FHIRException {
2115      switch (hash) {
2116      case 548941206: // temperatureQualifier
2117        this.temperatureQualifier = castToCodeableConcept(value); // CodeableConcept
2118        return value;
2119      case -39203799: // temperatureRange
2120        this.temperatureRange = castToRange(value); // Range
2121        return value;
2122      case 40284952: // maxDuration
2123        this.maxDuration = castToDuration(value); // Duration
2124        return value;
2125      case 301526158: // instruction
2126        this.instruction = castToString(value); // StringType
2127        return value;
2128      default:
2129        return super.setProperty(hash, name, value);
2130      }
2131
2132    }
2133
2134    @Override
2135    public Base setProperty(String name, Base value) throws FHIRException {
2136      if (name.equals("temperatureQualifier")) {
2137        this.temperatureQualifier = castToCodeableConcept(value); // CodeableConcept
2138      } else if (name.equals("temperatureRange")) {
2139        this.temperatureRange = castToRange(value); // Range
2140      } else if (name.equals("maxDuration")) {
2141        this.maxDuration = castToDuration(value); // Duration
2142      } else if (name.equals("instruction")) {
2143        this.instruction = castToString(value); // StringType
2144      } else
2145        return super.setProperty(name, value);
2146      return value;
2147    }
2148
2149  @Override
2150  public void removeChild(String name, Base value) throws FHIRException {
2151      if (name.equals("temperatureQualifier")) {
2152        this.temperatureQualifier = null;
2153      } else if (name.equals("temperatureRange")) {
2154        this.temperatureRange = null;
2155      } else if (name.equals("maxDuration")) {
2156        this.maxDuration = null;
2157      } else if (name.equals("instruction")) {
2158        this.instruction = null;
2159      } else
2160        super.removeChild(name, value);
2161      
2162    }
2163
2164    @Override
2165    public Base makeProperty(int hash, String name) throws FHIRException {
2166      switch (hash) {
2167      case 548941206:
2168        return getTemperatureQualifier();
2169      case -39203799:
2170        return getTemperatureRange();
2171      case 40284952:
2172        return getMaxDuration();
2173      case 301526158:
2174        return getInstructionElement();
2175      default:
2176        return super.makeProperty(hash, name);
2177      }
2178
2179    }
2180
2181    @Override
2182    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2183      switch (hash) {
2184      case 548941206:
2185        /* temperatureQualifier */ return new String[] { "CodeableConcept" };
2186      case -39203799:
2187        /* temperatureRange */ return new String[] { "Range" };
2188      case 40284952:
2189        /* maxDuration */ return new String[] { "Duration" };
2190      case 301526158:
2191        /* instruction */ return new String[] { "string" };
2192      default:
2193        return super.getTypesForProperty(hash, name);
2194      }
2195
2196    }
2197
2198    @Override
2199    public Base addChild(String name) throws FHIRException {
2200      if (name.equals("temperatureQualifier")) {
2201        this.temperatureQualifier = new CodeableConcept();
2202        return this.temperatureQualifier;
2203      } else if (name.equals("temperatureRange")) {
2204        this.temperatureRange = new Range();
2205        return this.temperatureRange;
2206      } else if (name.equals("maxDuration")) {
2207        this.maxDuration = new Duration();
2208        return this.maxDuration;
2209      } else if (name.equals("instruction")) {
2210        throw new FHIRException("Cannot call addChild on a singleton property SpecimenDefinition.instruction");
2211      } else
2212        return super.addChild(name);
2213    }
2214
2215    public SpecimenDefinitionTypeTestedHandlingComponent copy() {
2216      SpecimenDefinitionTypeTestedHandlingComponent dst = new SpecimenDefinitionTypeTestedHandlingComponent();
2217      copyValues(dst);
2218      return dst;
2219    }
2220
2221    public void copyValues(SpecimenDefinitionTypeTestedHandlingComponent dst) {
2222      super.copyValues(dst);
2223      dst.temperatureQualifier = temperatureQualifier == null ? null : temperatureQualifier.copy();
2224      dst.temperatureRange = temperatureRange == null ? null : temperatureRange.copy();
2225      dst.maxDuration = maxDuration == null ? null : maxDuration.copy();
2226      dst.instruction = instruction == null ? null : instruction.copy();
2227    }
2228
2229    @Override
2230    public boolean equalsDeep(Base other_) {
2231      if (!super.equalsDeep(other_))
2232        return false;
2233      if (!(other_ instanceof SpecimenDefinitionTypeTestedHandlingComponent))
2234        return false;
2235      SpecimenDefinitionTypeTestedHandlingComponent o = (SpecimenDefinitionTypeTestedHandlingComponent) other_;
2236      return compareDeep(temperatureQualifier, o.temperatureQualifier, true)
2237          && compareDeep(temperatureRange, o.temperatureRange, true) && compareDeep(maxDuration, o.maxDuration, true)
2238          && compareDeep(instruction, o.instruction, true);
2239    }
2240
2241    @Override
2242    public boolean equalsShallow(Base other_) {
2243      if (!super.equalsShallow(other_))
2244        return false;
2245      if (!(other_ instanceof SpecimenDefinitionTypeTestedHandlingComponent))
2246        return false;
2247      SpecimenDefinitionTypeTestedHandlingComponent o = (SpecimenDefinitionTypeTestedHandlingComponent) other_;
2248      return compareValues(instruction, o.instruction, true);
2249    }
2250
2251    public boolean isEmpty() {
2252      return super.isEmpty()
2253          && ca.uhn.fhir.util.ElementUtil.isEmpty(temperatureQualifier, temperatureRange, maxDuration, instruction);
2254    }
2255
2256    public String fhirType() {
2257      return "SpecimenDefinition.typeTested.handling";
2258
2259    }
2260
2261  }
2262
2263  /**
2264   * A business identifier associated with the kind of specimen.
2265   */
2266  @Child(name = "identifier", type = {
2267      Identifier.class }, order = 0, min = 0, max = 1, modifier = false, summary = true)
2268  @Description(shortDefinition = "Business identifier of a kind of specimen", formalDefinition = "A business identifier associated with the kind of specimen.")
2269  protected Identifier identifier;
2270
2271  /**
2272   * The kind of material to be collected.
2273   */
2274  @Child(name = "typeCollected", type = {
2275      CodeableConcept.class }, order = 1, min = 0, max = 1, modifier = false, summary = true)
2276  @Description(shortDefinition = "Kind of material to collect", formalDefinition = "The kind of material to be collected.")
2277  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://terminology.hl7.org/ValueSet/v2-0487")
2278  protected CodeableConcept typeCollected;
2279
2280  /**
2281   * Preparation of the patient for specimen collection.
2282   */
2283  @Child(name = "patientPreparation", type = {
2284      CodeableConcept.class }, order = 2, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
2285  @Description(shortDefinition = "Patient preparation for collection", formalDefinition = "Preparation of the patient for specimen collection.")
2286  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/prepare-patient-prior-specimen-collection")
2287  protected List<CodeableConcept> patientPreparation;
2288
2289  /**
2290   * Time aspect of specimen collection (duration or offset).
2291   */
2292  @Child(name = "timeAspect", type = {
2293      StringType.class }, order = 3, min = 0, max = 1, modifier = false, summary = true)
2294  @Description(shortDefinition = "Time aspect for collection", formalDefinition = "Time aspect of specimen collection (duration or offset).")
2295  protected StringType timeAspect;
2296
2297  /**
2298   * The action to be performed for collecting the specimen.
2299   */
2300  @Child(name = "collection", type = {
2301      CodeableConcept.class }, order = 4, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
2302  @Description(shortDefinition = "Specimen collection procedure", formalDefinition = "The action to be performed for collecting the specimen.")
2303  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/specimen-collection")
2304  protected List<CodeableConcept> collection;
2305
2306  /**
2307   * Specimen conditioned in a container as expected by the testing laboratory.
2308   */
2309  @Child(name = "typeTested", type = {}, order = 5, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
2310  @Description(shortDefinition = "Specimen in container intended for testing by lab", formalDefinition = "Specimen conditioned in a container as expected by the testing laboratory.")
2311  protected List<SpecimenDefinitionTypeTestedComponent> typeTested;
2312
2313  private static final long serialVersionUID = -330188872L;
2314
2315  /**
2316   * Constructor
2317   */
2318  public SpecimenDefinition() {
2319    super();
2320  }
2321
2322  /**
2323   * @return {@link #identifier} (A business identifier associated with the kind
2324   *         of specimen.)
2325   */
2326  public Identifier getIdentifier() {
2327    if (this.identifier == null)
2328      if (Configuration.errorOnAutoCreate())
2329        throw new Error("Attempt to auto-create SpecimenDefinition.identifier");
2330      else if (Configuration.doAutoCreate())
2331        this.identifier = new Identifier(); // cc
2332    return this.identifier;
2333  }
2334
2335  public boolean hasIdentifier() {
2336    return this.identifier != null && !this.identifier.isEmpty();
2337  }
2338
2339  /**
2340   * @param value {@link #identifier} (A business identifier associated with the
2341   *              kind of specimen.)
2342   */
2343  public SpecimenDefinition setIdentifier(Identifier value) {
2344    this.identifier = value;
2345    return this;
2346  }
2347
2348  /**
2349   * @return {@link #typeCollected} (The kind of material to be collected.)
2350   */
2351  public CodeableConcept getTypeCollected() {
2352    if (this.typeCollected == null)
2353      if (Configuration.errorOnAutoCreate())
2354        throw new Error("Attempt to auto-create SpecimenDefinition.typeCollected");
2355      else if (Configuration.doAutoCreate())
2356        this.typeCollected = new CodeableConcept(); // cc
2357    return this.typeCollected;
2358  }
2359
2360  public boolean hasTypeCollected() {
2361    return this.typeCollected != null && !this.typeCollected.isEmpty();
2362  }
2363
2364  /**
2365   * @param value {@link #typeCollected} (The kind of material to be collected.)
2366   */
2367  public SpecimenDefinition setTypeCollected(CodeableConcept value) {
2368    this.typeCollected = value;
2369    return this;
2370  }
2371
2372  /**
2373   * @return {@link #patientPreparation} (Preparation of the patient for specimen
2374   *         collection.)
2375   */
2376  public List<CodeableConcept> getPatientPreparation() {
2377    if (this.patientPreparation == null)
2378      this.patientPreparation = new ArrayList<CodeableConcept>();
2379    return this.patientPreparation;
2380  }
2381
2382  /**
2383   * @return Returns a reference to <code>this</code> for easy method chaining
2384   */
2385  public SpecimenDefinition setPatientPreparation(List<CodeableConcept> thePatientPreparation) {
2386    this.patientPreparation = thePatientPreparation;
2387    return this;
2388  }
2389
2390  public boolean hasPatientPreparation() {
2391    if (this.patientPreparation == null)
2392      return false;
2393    for (CodeableConcept item : this.patientPreparation)
2394      if (!item.isEmpty())
2395        return true;
2396    return false;
2397  }
2398
2399  public CodeableConcept addPatientPreparation() { // 3
2400    CodeableConcept t = new CodeableConcept();
2401    if (this.patientPreparation == null)
2402      this.patientPreparation = new ArrayList<CodeableConcept>();
2403    this.patientPreparation.add(t);
2404    return t;
2405  }
2406
2407  public SpecimenDefinition addPatientPreparation(CodeableConcept t) { // 3
2408    if (t == null)
2409      return this;
2410    if (this.patientPreparation == null)
2411      this.patientPreparation = new ArrayList<CodeableConcept>();
2412    this.patientPreparation.add(t);
2413    return this;
2414  }
2415
2416  /**
2417   * @return The first repetition of repeating field {@link #patientPreparation},
2418   *         creating it if it does not already exist
2419   */
2420  public CodeableConcept getPatientPreparationFirstRep() {
2421    if (getPatientPreparation().isEmpty()) {
2422      addPatientPreparation();
2423    }
2424    return getPatientPreparation().get(0);
2425  }
2426
2427  /**
2428   * @return {@link #timeAspect} (Time aspect of specimen collection (duration or
2429   *         offset).). This is the underlying object with id, value and
2430   *         extensions. The accessor "getTimeAspect" gives direct access to the
2431   *         value
2432   */
2433  public StringType getTimeAspectElement() {
2434    if (this.timeAspect == null)
2435      if (Configuration.errorOnAutoCreate())
2436        throw new Error("Attempt to auto-create SpecimenDefinition.timeAspect");
2437      else if (Configuration.doAutoCreate())
2438        this.timeAspect = new StringType(); // bb
2439    return this.timeAspect;
2440  }
2441
2442  public boolean hasTimeAspectElement() {
2443    return this.timeAspect != null && !this.timeAspect.isEmpty();
2444  }
2445
2446  public boolean hasTimeAspect() {
2447    return this.timeAspect != null && !this.timeAspect.isEmpty();
2448  }
2449
2450  /**
2451   * @param value {@link #timeAspect} (Time aspect of specimen collection
2452   *              (duration or offset).). This is the underlying object with id,
2453   *              value and extensions. The accessor "getTimeAspect" gives direct
2454   *              access to the value
2455   */
2456  public SpecimenDefinition setTimeAspectElement(StringType value) {
2457    this.timeAspect = value;
2458    return this;
2459  }
2460
2461  /**
2462   * @return Time aspect of specimen collection (duration or offset).
2463   */
2464  public String getTimeAspect() {
2465    return this.timeAspect == null ? null : this.timeAspect.getValue();
2466  }
2467
2468  /**
2469   * @param value Time aspect of specimen collection (duration or offset).
2470   */
2471  public SpecimenDefinition setTimeAspect(String value) {
2472    if (Utilities.noString(value))
2473      this.timeAspect = null;
2474    else {
2475      if (this.timeAspect == null)
2476        this.timeAspect = new StringType();
2477      this.timeAspect.setValue(value);
2478    }
2479    return this;
2480  }
2481
2482  /**
2483   * @return {@link #collection} (The action to be performed for collecting the
2484   *         specimen.)
2485   */
2486  public List<CodeableConcept> getCollection() {
2487    if (this.collection == null)
2488      this.collection = new ArrayList<CodeableConcept>();
2489    return this.collection;
2490  }
2491
2492  /**
2493   * @return Returns a reference to <code>this</code> for easy method chaining
2494   */
2495  public SpecimenDefinition setCollection(List<CodeableConcept> theCollection) {
2496    this.collection = theCollection;
2497    return this;
2498  }
2499
2500  public boolean hasCollection() {
2501    if (this.collection == null)
2502      return false;
2503    for (CodeableConcept item : this.collection)
2504      if (!item.isEmpty())
2505        return true;
2506    return false;
2507  }
2508
2509  public CodeableConcept addCollection() { // 3
2510    CodeableConcept t = new CodeableConcept();
2511    if (this.collection == null)
2512      this.collection = new ArrayList<CodeableConcept>();
2513    this.collection.add(t);
2514    return t;
2515  }
2516
2517  public SpecimenDefinition addCollection(CodeableConcept t) { // 3
2518    if (t == null)
2519      return this;
2520    if (this.collection == null)
2521      this.collection = new ArrayList<CodeableConcept>();
2522    this.collection.add(t);
2523    return this;
2524  }
2525
2526  /**
2527   * @return The first repetition of repeating field {@link #collection}, creating
2528   *         it if it does not already exist
2529   */
2530  public CodeableConcept getCollectionFirstRep() {
2531    if (getCollection().isEmpty()) {
2532      addCollection();
2533    }
2534    return getCollection().get(0);
2535  }
2536
2537  /**
2538   * @return {@link #typeTested} (Specimen conditioned in a container as expected
2539   *         by the testing laboratory.)
2540   */
2541  public List<SpecimenDefinitionTypeTestedComponent> getTypeTested() {
2542    if (this.typeTested == null)
2543      this.typeTested = new ArrayList<SpecimenDefinitionTypeTestedComponent>();
2544    return this.typeTested;
2545  }
2546
2547  /**
2548   * @return Returns a reference to <code>this</code> for easy method chaining
2549   */
2550  public SpecimenDefinition setTypeTested(List<SpecimenDefinitionTypeTestedComponent> theTypeTested) {
2551    this.typeTested = theTypeTested;
2552    return this;
2553  }
2554
2555  public boolean hasTypeTested() {
2556    if (this.typeTested == null)
2557      return false;
2558    for (SpecimenDefinitionTypeTestedComponent item : this.typeTested)
2559      if (!item.isEmpty())
2560        return true;
2561    return false;
2562  }
2563
2564  public SpecimenDefinitionTypeTestedComponent addTypeTested() { // 3
2565    SpecimenDefinitionTypeTestedComponent t = new SpecimenDefinitionTypeTestedComponent();
2566    if (this.typeTested == null)
2567      this.typeTested = new ArrayList<SpecimenDefinitionTypeTestedComponent>();
2568    this.typeTested.add(t);
2569    return t;
2570  }
2571
2572  public SpecimenDefinition addTypeTested(SpecimenDefinitionTypeTestedComponent t) { // 3
2573    if (t == null)
2574      return this;
2575    if (this.typeTested == null)
2576      this.typeTested = new ArrayList<SpecimenDefinitionTypeTestedComponent>();
2577    this.typeTested.add(t);
2578    return this;
2579  }
2580
2581  /**
2582   * @return The first repetition of repeating field {@link #typeTested}, creating
2583   *         it if it does not already exist
2584   */
2585  public SpecimenDefinitionTypeTestedComponent getTypeTestedFirstRep() {
2586    if (getTypeTested().isEmpty()) {
2587      addTypeTested();
2588    }
2589    return getTypeTested().get(0);
2590  }
2591
2592  protected void listChildren(List<Property> children) {
2593    super.listChildren(children);
2594    children.add(new Property("identifier", "Identifier", "A business identifier associated with the kind of specimen.",
2595        0, 1, identifier));
2596    children.add(
2597        new Property("typeCollected", "CodeableConcept", "The kind of material to be collected.", 0, 1, typeCollected));
2598    children.add(new Property("patientPreparation", "CodeableConcept",
2599        "Preparation of the patient for specimen collection.", 0, java.lang.Integer.MAX_VALUE, patientPreparation));
2600    children.add(new Property("timeAspect", "string", "Time aspect of specimen collection (duration or offset).", 0, 1,
2601        timeAspect));
2602    children.add(new Property("collection", "CodeableConcept",
2603        "The action to be performed for collecting the specimen.", 0, java.lang.Integer.MAX_VALUE, collection));
2604    children.add(
2605        new Property("typeTested", "", "Specimen conditioned in a container as expected by the testing laboratory.", 0,
2606            java.lang.Integer.MAX_VALUE, typeTested));
2607  }
2608
2609  @Override
2610  public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2611    switch (_hash) {
2612    case -1618432855:
2613      /* identifier */ return new Property("identifier", "Identifier",
2614          "A business identifier associated with the kind of specimen.", 0, 1, identifier);
2615    case 588504367:
2616      /* typeCollected */ return new Property("typeCollected", "CodeableConcept",
2617          "The kind of material to be collected.", 0, 1, typeCollected);
2618    case -879411630:
2619      /* patientPreparation */ return new Property("patientPreparation", "CodeableConcept",
2620          "Preparation of the patient for specimen collection.", 0, java.lang.Integer.MAX_VALUE, patientPreparation);
2621    case 276972933:
2622      /* timeAspect */ return new Property("timeAspect", "string",
2623          "Time aspect of specimen collection (duration or offset).", 0, 1, timeAspect);
2624    case -1741312354:
2625      /* collection */ return new Property("collection", "CodeableConcept",
2626          "The action to be performed for collecting the specimen.", 0, java.lang.Integer.MAX_VALUE, collection);
2627    case -1407902581:
2628      /* typeTested */ return new Property("typeTested", "",
2629          "Specimen conditioned in a container as expected by the testing laboratory.", 0, java.lang.Integer.MAX_VALUE,
2630          typeTested);
2631    default:
2632      return super.getNamedProperty(_hash, _name, _checkValid);
2633    }
2634
2635  }
2636
2637  @Override
2638  public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2639    switch (hash) {
2640    case -1618432855:
2641      /* identifier */ return this.identifier == null ? new Base[0] : new Base[] { this.identifier }; // Identifier
2642    case 588504367:
2643      /* typeCollected */ return this.typeCollected == null ? new Base[0] : new Base[] { this.typeCollected }; // CodeableConcept
2644    case -879411630:
2645      /* patientPreparation */ return this.patientPreparation == null ? new Base[0]
2646          : this.patientPreparation.toArray(new Base[this.patientPreparation.size()]); // CodeableConcept
2647    case 276972933:
2648      /* timeAspect */ return this.timeAspect == null ? new Base[0] : new Base[] { this.timeAspect }; // StringType
2649    case -1741312354:
2650      /* collection */ return this.collection == null ? new Base[0]
2651          : this.collection.toArray(new Base[this.collection.size()]); // CodeableConcept
2652    case -1407902581:
2653      /* typeTested */ return this.typeTested == null ? new Base[0]
2654          : this.typeTested.toArray(new Base[this.typeTested.size()]); // SpecimenDefinitionTypeTestedComponent
2655    default:
2656      return super.getProperty(hash, name, checkValid);
2657    }
2658
2659  }
2660
2661  @Override
2662  public Base setProperty(int hash, String name, Base value) throws FHIRException {
2663    switch (hash) {
2664    case -1618432855: // identifier
2665      this.identifier = castToIdentifier(value); // Identifier
2666      return value;
2667    case 588504367: // typeCollected
2668      this.typeCollected = castToCodeableConcept(value); // CodeableConcept
2669      return value;
2670    case -879411630: // patientPreparation
2671      this.getPatientPreparation().add(castToCodeableConcept(value)); // CodeableConcept
2672      return value;
2673    case 276972933: // timeAspect
2674      this.timeAspect = castToString(value); // StringType
2675      return value;
2676    case -1741312354: // collection
2677      this.getCollection().add(castToCodeableConcept(value)); // CodeableConcept
2678      return value;
2679    case -1407902581: // typeTested
2680      this.getTypeTested().add((SpecimenDefinitionTypeTestedComponent) value); // SpecimenDefinitionTypeTestedComponent
2681      return value;
2682    default:
2683      return super.setProperty(hash, name, value);
2684    }
2685
2686  }
2687
2688  @Override
2689  public Base setProperty(String name, Base value) throws FHIRException {
2690    if (name.equals("identifier")) {
2691      this.identifier = castToIdentifier(value); // Identifier
2692    } else if (name.equals("typeCollected")) {
2693      this.typeCollected = castToCodeableConcept(value); // CodeableConcept
2694    } else if (name.equals("patientPreparation")) {
2695      this.getPatientPreparation().add(castToCodeableConcept(value));
2696    } else if (name.equals("timeAspect")) {
2697      this.timeAspect = castToString(value); // StringType
2698    } else if (name.equals("collection")) {
2699      this.getCollection().add(castToCodeableConcept(value));
2700    } else if (name.equals("typeTested")) {
2701      this.getTypeTested().add((SpecimenDefinitionTypeTestedComponent) value);
2702    } else
2703      return super.setProperty(name, value);
2704    return value;
2705  }
2706
2707  @Override
2708  public void removeChild(String name, Base value) throws FHIRException {
2709    if (name.equals("identifier")) {
2710      this.identifier = null;
2711    } else if (name.equals("typeCollected")) {
2712      this.typeCollected = null;
2713    } else if (name.equals("patientPreparation")) {
2714      this.getPatientPreparation().remove(castToCodeableConcept(value));
2715    } else if (name.equals("timeAspect")) {
2716      this.timeAspect = null;
2717    } else if (name.equals("collection")) {
2718      this.getCollection().remove(castToCodeableConcept(value));
2719    } else if (name.equals("typeTested")) {
2720      this.getTypeTested().remove((SpecimenDefinitionTypeTestedComponent) value);
2721    } else
2722      super.removeChild(name, value);
2723    
2724  }
2725
2726  @Override
2727  public Base makeProperty(int hash, String name) throws FHIRException {
2728    switch (hash) {
2729    case -1618432855:
2730      return getIdentifier();
2731    case 588504367:
2732      return getTypeCollected();
2733    case -879411630:
2734      return addPatientPreparation();
2735    case 276972933:
2736      return getTimeAspectElement();
2737    case -1741312354:
2738      return addCollection();
2739    case -1407902581:
2740      return addTypeTested();
2741    default:
2742      return super.makeProperty(hash, name);
2743    }
2744
2745  }
2746
2747  @Override
2748  public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2749    switch (hash) {
2750    case -1618432855:
2751      /* identifier */ return new String[] { "Identifier" };
2752    case 588504367:
2753      /* typeCollected */ return new String[] { "CodeableConcept" };
2754    case -879411630:
2755      /* patientPreparation */ return new String[] { "CodeableConcept" };
2756    case 276972933:
2757      /* timeAspect */ return new String[] { "string" };
2758    case -1741312354:
2759      /* collection */ return new String[] { "CodeableConcept" };
2760    case -1407902581:
2761      /* typeTested */ return new String[] {};
2762    default:
2763      return super.getTypesForProperty(hash, name);
2764    }
2765
2766  }
2767
2768  @Override
2769  public Base addChild(String name) throws FHIRException {
2770    if (name.equals("identifier")) {
2771      this.identifier = new Identifier();
2772      return this.identifier;
2773    } else if (name.equals("typeCollected")) {
2774      this.typeCollected = new CodeableConcept();
2775      return this.typeCollected;
2776    } else if (name.equals("patientPreparation")) {
2777      return addPatientPreparation();
2778    } else if (name.equals("timeAspect")) {
2779      throw new FHIRException("Cannot call addChild on a singleton property SpecimenDefinition.timeAspect");
2780    } else if (name.equals("collection")) {
2781      return addCollection();
2782    } else if (name.equals("typeTested")) {
2783      return addTypeTested();
2784    } else
2785      return super.addChild(name);
2786  }
2787
2788  public String fhirType() {
2789    return "SpecimenDefinition";
2790
2791  }
2792
2793  public SpecimenDefinition copy() {
2794    SpecimenDefinition dst = new SpecimenDefinition();
2795    copyValues(dst);
2796    return dst;
2797  }
2798
2799  public void copyValues(SpecimenDefinition dst) {
2800    super.copyValues(dst);
2801    dst.identifier = identifier == null ? null : identifier.copy();
2802    dst.typeCollected = typeCollected == null ? null : typeCollected.copy();
2803    if (patientPreparation != null) {
2804      dst.patientPreparation = new ArrayList<CodeableConcept>();
2805      for (CodeableConcept i : patientPreparation)
2806        dst.patientPreparation.add(i.copy());
2807    }
2808    ;
2809    dst.timeAspect = timeAspect == null ? null : timeAspect.copy();
2810    if (collection != null) {
2811      dst.collection = new ArrayList<CodeableConcept>();
2812      for (CodeableConcept i : collection)
2813        dst.collection.add(i.copy());
2814    }
2815    ;
2816    if (typeTested != null) {
2817      dst.typeTested = new ArrayList<SpecimenDefinitionTypeTestedComponent>();
2818      for (SpecimenDefinitionTypeTestedComponent i : typeTested)
2819        dst.typeTested.add(i.copy());
2820    }
2821    ;
2822  }
2823
2824  protected SpecimenDefinition typedCopy() {
2825    return copy();
2826  }
2827
2828  @Override
2829  public boolean equalsDeep(Base other_) {
2830    if (!super.equalsDeep(other_))
2831      return false;
2832    if (!(other_ instanceof SpecimenDefinition))
2833      return false;
2834    SpecimenDefinition o = (SpecimenDefinition) other_;
2835    return compareDeep(identifier, o.identifier, true) && compareDeep(typeCollected, o.typeCollected, true)
2836        && compareDeep(patientPreparation, o.patientPreparation, true) && compareDeep(timeAspect, o.timeAspect, true)
2837        && compareDeep(collection, o.collection, true) && compareDeep(typeTested, o.typeTested, true);
2838  }
2839
2840  @Override
2841  public boolean equalsShallow(Base other_) {
2842    if (!super.equalsShallow(other_))
2843      return false;
2844    if (!(other_ instanceof SpecimenDefinition))
2845      return false;
2846    SpecimenDefinition o = (SpecimenDefinition) other_;
2847    return compareValues(timeAspect, o.timeAspect, true);
2848  }
2849
2850  public boolean isEmpty() {
2851    return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, typeCollected, patientPreparation,
2852        timeAspect, collection, typeTested);
2853  }
2854
2855  @Override
2856  public ResourceType getResourceType() {
2857    return ResourceType.SpecimenDefinition;
2858  }
2859
2860  /**
2861   * Search parameter: <b>container</b>
2862   * <p>
2863   * Description: <b>The type of specimen conditioned in container expected by the
2864   * lab</b><br>
2865   * Type: <b>token</b><br>
2866   * Path: <b>SpecimenDefinition.typeTested.container.type</b><br>
2867   * </p>
2868   */
2869  @SearchParamDefinition(name = "container", path = "SpecimenDefinition.typeTested.container.type", description = "The type of specimen conditioned in container expected by the lab", type = "token")
2870  public static final String SP_CONTAINER = "container";
2871  /**
2872   * <b>Fluent Client</b> search parameter constant for <b>container</b>
2873   * <p>
2874   * Description: <b>The type of specimen conditioned in container expected by the
2875   * lab</b><br>
2876   * Type: <b>token</b><br>
2877   * Path: <b>SpecimenDefinition.typeTested.container.type</b><br>
2878   * </p>
2879   */
2880  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CONTAINER = new ca.uhn.fhir.rest.gclient.TokenClientParam(
2881      SP_CONTAINER);
2882
2883  /**
2884   * Search parameter: <b>identifier</b>
2885   * <p>
2886   * Description: <b>The unique identifier associated with the specimen</b><br>
2887   * Type: <b>token</b><br>
2888   * Path: <b>SpecimenDefinition.identifier</b><br>
2889   * </p>
2890   */
2891  @SearchParamDefinition(name = "identifier", path = "SpecimenDefinition.identifier", description = "The unique identifier associated with the specimen", type = "token")
2892  public static final String SP_IDENTIFIER = "identifier";
2893  /**
2894   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2895   * <p>
2896   * Description: <b>The unique identifier associated with the specimen</b><br>
2897   * Type: <b>token</b><br>
2898   * Path: <b>SpecimenDefinition.identifier</b><br>
2899   * </p>
2900   */
2901  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(
2902      SP_IDENTIFIER);
2903
2904  /**
2905   * Search parameter: <b>type</b>
2906   * <p>
2907   * Description: <b>The type of collected specimen</b><br>
2908   * Type: <b>token</b><br>
2909   * Path: <b>SpecimenDefinition.typeCollected</b><br>
2910   * </p>
2911   */
2912  @SearchParamDefinition(name = "type", path = "SpecimenDefinition.typeCollected", description = "The type of collected specimen", type = "token")
2913  public static final String SP_TYPE = "type";
2914  /**
2915   * <b>Fluent Client</b> search parameter constant for <b>type</b>
2916   * <p>
2917   * Description: <b>The type of collected specimen</b><br>
2918   * Type: <b>token</b><br>
2919   * Path: <b>SpecimenDefinition.typeCollected</b><br>
2920   * </p>
2921   */
2922  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(
2923      SP_TYPE);
2924
2925}