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