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