001package org.hl7.fhir.dstu2016may.model;
002
003
004
005
006/*
007  Copyright (c) 2011+, HL7, Inc.
008  All rights reserved.
009  
010  Redistribution and use in source and binary forms, with or without modification, 
011  are permitted provided that the following conditions are met:
012  
013   * Redistributions of source code must retain the above copyright notice, this 
014     list of conditions and the following disclaimer.
015   * Redistributions in binary form must reproduce the above copyright notice, 
016     this list of conditions and the following disclaimer in the documentation 
017     and/or other materials provided with the distribution.
018   * Neither the name of HL7 nor the names of its contributors may be used to 
019     endorse or promote products derived from this software without specific 
020     prior written permission.
021  
022  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
023  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
024  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
025  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
026  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
027  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
028  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
029  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
030  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
031  POSSIBILITY OF SUCH DAMAGE.
032  
033*/
034
035// Generated on Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
036import java.util.ArrayList;
037import java.util.Date;
038import java.util.List;
039
040import org.hl7.fhir.exceptions.FHIRException;
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
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        throw new FHIRException("Unknown SpecimenStatus code '"+codeString+"'");
088        }
089        public String toCode() {
090          switch (this) {
091            case AVAILABLE: return "available";
092            case UNAVAILABLE: return "unavailable";
093            case UNSATISFACTORY: return "unsatisfactory";
094            case ENTEREDINERROR: return "entered-in-error";
095            case NULL: return null;
096            default: return "?";
097          }
098        }
099        public String getSystem() {
100          switch (this) {
101            case AVAILABLE: return "http://hl7.org/fhir/specimen-status";
102            case UNAVAILABLE: return "http://hl7.org/fhir/specimen-status";
103            case UNSATISFACTORY: return "http://hl7.org/fhir/specimen-status";
104            case ENTEREDINERROR: return "http://hl7.org/fhir/specimen-status";
105            case NULL: return null;
106            default: return "?";
107          }
108        }
109        public String getDefinition() {
110          switch (this) {
111            case AVAILABLE: return "The physical specimen is present and in good condition.";
112            case UNAVAILABLE: return "There is no physical specimen because it is either lost, destroyed or consumed.";
113            case UNSATISFACTORY: return "The specimen cannot be used because of a quality issue such as a broken container, contamination, or too old.";
114            case ENTEREDINERROR: return "The specimen was entered in error and therefore nullified.";
115            case NULL: return null;
116            default: return "?";
117          }
118        }
119        public String getDisplay() {
120          switch (this) {
121            case AVAILABLE: return "Available";
122            case UNAVAILABLE: return "Unavailable";
123            case UNSATISFACTORY: return "Unsatisfactory";
124            case ENTEREDINERROR: return "Entered-in-error";
125            case NULL: return null;
126            default: return "?";
127          }
128        }
129    }
130
131  public static class SpecimenStatusEnumFactory implements EnumFactory<SpecimenStatus> {
132    public SpecimenStatus fromCode(String codeString) throws IllegalArgumentException {
133      if (codeString == null || "".equals(codeString))
134            if (codeString == null || "".equals(codeString))
135                return null;
136        if ("available".equals(codeString))
137          return SpecimenStatus.AVAILABLE;
138        if ("unavailable".equals(codeString))
139          return SpecimenStatus.UNAVAILABLE;
140        if ("unsatisfactory".equals(codeString))
141          return SpecimenStatus.UNSATISFACTORY;
142        if ("entered-in-error".equals(codeString))
143          return SpecimenStatus.ENTEREDINERROR;
144        throw new IllegalArgumentException("Unknown SpecimenStatus code '"+codeString+"'");
145        }
146        public Enumeration<SpecimenStatus> fromType(Base code) throws FHIRException {
147          if (code == null || code.isEmpty())
148            return null;
149          String codeString = ((PrimitiveType) code).asStringValue();
150          if (codeString == null || "".equals(codeString))
151            return null;
152        if ("available".equals(codeString))
153          return new Enumeration<SpecimenStatus>(this, SpecimenStatus.AVAILABLE);
154        if ("unavailable".equals(codeString))
155          return new Enumeration<SpecimenStatus>(this, SpecimenStatus.UNAVAILABLE);
156        if ("unsatisfactory".equals(codeString))
157          return new Enumeration<SpecimenStatus>(this, SpecimenStatus.UNSATISFACTORY);
158        if ("entered-in-error".equals(codeString))
159          return new Enumeration<SpecimenStatus>(this, SpecimenStatus.ENTEREDINERROR);
160        throw new FHIRException("Unknown SpecimenStatus code '"+codeString+"'");
161        }
162    public String toCode(SpecimenStatus code) {
163      if (code == SpecimenStatus.AVAILABLE)
164        return "available";
165      if (code == SpecimenStatus.UNAVAILABLE)
166        return "unavailable";
167      if (code == SpecimenStatus.UNSATISFACTORY)
168        return "unsatisfactory";
169      if (code == SpecimenStatus.ENTEREDINERROR)
170        return "entered-in-error";
171      return "?";
172      }
173    public String toSystem(SpecimenStatus code) {
174      return code.getSystem();
175      }
176    }
177
178    @Block()
179    public static class SpecimenCollectionComponent extends BackboneElement implements IBaseBackboneElement {
180        /**
181         * Person who collected the specimen.
182         */
183        @Child(name = "collector", type = {Practitioner.class}, order=1, min=0, max=1, modifier=false, summary=true)
184        @Description(shortDefinition="Who collected the specimen", formalDefinition="Person who collected the specimen." )
185        protected Reference collector;
186
187        /**
188         * The actual object that is the target of the reference (Person who collected the specimen.)
189         */
190        protected Practitioner collectorTarget;
191
192        /**
193         * To communicate any details or issues encountered during the specimen collection procedure.
194         */
195        @Child(name = "comment", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=false)
196        @Description(shortDefinition="Collector comments", formalDefinition="To communicate any details or issues encountered during the specimen collection procedure." )
197        protected StringType comment;
198
199        /**
200         * Time when specimen was collected from subject - the physiologically relevant time.
201         */
202        @Child(name = "collected", type = {DateTimeType.class, Period.class}, order=3, min=0, max=1, modifier=false, summary=true)
203        @Description(shortDefinition="Collection time", formalDefinition="Time when specimen was collected from subject - the physiologically relevant time." )
204        protected Type collected;
205
206        /**
207         * The quantity of specimen collected; for instance the volume of a blood sample, or the physical measurement of an anatomic pathology sample.
208         */
209        @Child(name = "quantity", type = {SimpleQuantity.class}, order=4, min=0, max=1, modifier=false, summary=false)
210        @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." )
211        protected SimpleQuantity quantity;
212
213        /**
214         * A coded value specifying the technique that is used to perform the procedure.
215         */
216        @Child(name = "method", type = {CodeableConcept.class}, order=5, min=0, max=1, modifier=false, summary=false)
217        @Description(shortDefinition="Technique used to perform collection", formalDefinition="A coded value specifying the technique that is used to perform the procedure." )
218        protected CodeableConcept method;
219
220        /**
221         * 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.
222         */
223        @Child(name = "bodySite", type = {CodeableConcept.class}, order=6, min=0, max=1, modifier=false, summary=false)
224        @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." )
225        protected CodeableConcept bodySite;
226
227        private static final long serialVersionUID = 2083688215L;
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 #comment} (To communicate any details or issues encountered during the specimen collection procedure.). This is the underlying object with id, value and extensions. The accessor "getComment" gives direct access to the value
282         */
283        public StringType getCommentElement() { 
284          if (this.comment == null)
285            if (Configuration.errorOnAutoCreate())
286              throw new Error("Attempt to auto-create SpecimenCollectionComponent.comment");
287            else if (Configuration.doAutoCreate())
288              this.comment = new StringType(); // bb
289          return this.comment;
290        }
291
292        public boolean hasCommentElement() { 
293          return this.comment != null && !this.comment.isEmpty();
294        }
295
296        public boolean hasComment() { 
297          return this.comment != null && !this.comment.isEmpty();
298        }
299
300        /**
301         * @param value {@link #comment} (To communicate any details or issues encountered during the specimen collection procedure.). This is the underlying object with id, value and extensions. The accessor "getComment" gives direct access to the value
302         */
303        public SpecimenCollectionComponent setCommentElement(StringType value) { 
304          this.comment = value;
305          return this;
306        }
307
308        /**
309         * @return To communicate any details or issues encountered during the specimen collection procedure.
310         */
311        public String getComment() { 
312          return this.comment == null ? null : this.comment.getValue();
313        }
314
315        /**
316         * @param value To communicate any details or issues encountered during the specimen collection procedure.
317         */
318        public SpecimenCollectionComponent setComment(String value) { 
319          if (Utilities.noString(value))
320            this.comment = null;
321          else {
322            if (this.comment == null)
323              this.comment = new StringType();
324            this.comment.setValue(value);
325          }
326          return this;
327        }
328
329        /**
330         * @return {@link #collected} (Time when specimen was collected from subject - the physiologically relevant time.)
331         */
332        public Type getCollected() { 
333          return this.collected;
334        }
335
336        /**
337         * @return {@link #collected} (Time when specimen was collected from subject - the physiologically relevant time.)
338         */
339        public DateTimeType getCollectedDateTimeType() throws FHIRException { 
340          if (!(this.collected instanceof DateTimeType))
341            throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.collected.getClass().getName()+" was encountered");
342          return (DateTimeType) this.collected;
343        }
344
345        public boolean hasCollectedDateTimeType() { 
346          return this.collected instanceof DateTimeType;
347        }
348
349        /**
350         * @return {@link #collected} (Time when specimen was collected from subject - the physiologically relevant time.)
351         */
352        public Period getCollectedPeriod() throws FHIRException { 
353          if (!(this.collected instanceof Period))
354            throw new FHIRException("Type mismatch: the type Period was expected, but "+this.collected.getClass().getName()+" was encountered");
355          return (Period) this.collected;
356        }
357
358        public boolean hasCollectedPeriod() { 
359          return this.collected instanceof Period;
360        }
361
362        public boolean hasCollected() { 
363          return this.collected != null && !this.collected.isEmpty();
364        }
365
366        /**
367         * @param value {@link #collected} (Time when specimen was collected from subject - the physiologically relevant time.)
368         */
369        public SpecimenCollectionComponent setCollected(Type value) { 
370          this.collected = value;
371          return this;
372        }
373
374        /**
375         * @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.)
376         */
377        public SimpleQuantity getQuantity() { 
378          if (this.quantity == null)
379            if (Configuration.errorOnAutoCreate())
380              throw new Error("Attempt to auto-create SpecimenCollectionComponent.quantity");
381            else if (Configuration.doAutoCreate())
382              this.quantity = new SimpleQuantity(); // cc
383          return this.quantity;
384        }
385
386        public boolean hasQuantity() { 
387          return this.quantity != null && !this.quantity.isEmpty();
388        }
389
390        /**
391         * @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.)
392         */
393        public SpecimenCollectionComponent setQuantity(SimpleQuantity value) { 
394          this.quantity = value;
395          return this;
396        }
397
398        /**
399         * @return {@link #method} (A coded value specifying the technique that is used to perform the procedure.)
400         */
401        public CodeableConcept getMethod() { 
402          if (this.method == null)
403            if (Configuration.errorOnAutoCreate())
404              throw new Error("Attempt to auto-create SpecimenCollectionComponent.method");
405            else if (Configuration.doAutoCreate())
406              this.method = new CodeableConcept(); // cc
407          return this.method;
408        }
409
410        public boolean hasMethod() { 
411          return this.method != null && !this.method.isEmpty();
412        }
413
414        /**
415         * @param value {@link #method} (A coded value specifying the technique that is used to perform the procedure.)
416         */
417        public SpecimenCollectionComponent setMethod(CodeableConcept value) { 
418          this.method = value;
419          return this;
420        }
421
422        /**
423         * @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.)
424         */
425        public CodeableConcept getBodySite() { 
426          if (this.bodySite == null)
427            if (Configuration.errorOnAutoCreate())
428              throw new Error("Attempt to auto-create SpecimenCollectionComponent.bodySite");
429            else if (Configuration.doAutoCreate())
430              this.bodySite = new CodeableConcept(); // cc
431          return this.bodySite;
432        }
433
434        public boolean hasBodySite() { 
435          return this.bodySite != null && !this.bodySite.isEmpty();
436        }
437
438        /**
439         * @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.)
440         */
441        public SpecimenCollectionComponent setBodySite(CodeableConcept value) { 
442          this.bodySite = value;
443          return this;
444        }
445
446        protected void listChildren(List<Property> childrenList) {
447          super.listChildren(childrenList);
448          childrenList.add(new Property("collector", "Reference(Practitioner)", "Person who collected the specimen.", 0, java.lang.Integer.MAX_VALUE, collector));
449          childrenList.add(new Property("comment", "string", "To communicate any details or issues encountered during the specimen collection procedure.", 0, java.lang.Integer.MAX_VALUE, comment));
450          childrenList.add(new Property("collected[x]", "dateTime|Period", "Time when specimen was collected from subject - the physiologically relevant time.", 0, java.lang.Integer.MAX_VALUE, collected));
451          childrenList.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, java.lang.Integer.MAX_VALUE, quantity));
452          childrenList.add(new Property("method", "CodeableConcept", "A coded value specifying the technique that is used to perform the procedure.", 0, java.lang.Integer.MAX_VALUE, method));
453          childrenList.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, java.lang.Integer.MAX_VALUE, bodySite));
454        }
455
456      @Override
457      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
458        switch (hash) {
459        case 1883491469: /*collector*/ return this.collector == null ? new Base[0] : new Base[] {this.collector}; // Reference
460        case 950398559: /*comment*/ return this.comment == null ? new Base[0] : new Base[] {this.comment}; // StringType
461        case 1883491145: /*collected*/ return this.collected == null ? new Base[0] : new Base[] {this.collected}; // Type
462        case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // SimpleQuantity
463        case -1077554975: /*method*/ return this.method == null ? new Base[0] : new Base[] {this.method}; // CodeableConcept
464        case 1702620169: /*bodySite*/ return this.bodySite == null ? new Base[0] : new Base[] {this.bodySite}; // CodeableConcept
465        default: return super.getProperty(hash, name, checkValid);
466        }
467
468      }
469
470      @Override
471      public void setProperty(int hash, String name, Base value) throws FHIRException {
472        switch (hash) {
473        case 1883491469: // collector
474          this.collector = castToReference(value); // Reference
475          break;
476        case 950398559: // comment
477          this.comment = castToString(value); // StringType
478          break;
479        case 1883491145: // collected
480          this.collected = (Type) value; // Type
481          break;
482        case -1285004149: // quantity
483          this.quantity = castToSimpleQuantity(value); // SimpleQuantity
484          break;
485        case -1077554975: // method
486          this.method = castToCodeableConcept(value); // CodeableConcept
487          break;
488        case 1702620169: // bodySite
489          this.bodySite = castToCodeableConcept(value); // CodeableConcept
490          break;
491        default: super.setProperty(hash, name, value);
492        }
493
494      }
495
496      @Override
497      public void setProperty(String name, Base value) throws FHIRException {
498        if (name.equals("collector"))
499          this.collector = castToReference(value); // Reference
500        else if (name.equals("comment"))
501          this.comment = castToString(value); // StringType
502        else if (name.equals("collected[x]"))
503          this.collected = (Type) value; // Type
504        else if (name.equals("quantity"))
505          this.quantity = castToSimpleQuantity(value); // SimpleQuantity
506        else if (name.equals("method"))
507          this.method = castToCodeableConcept(value); // CodeableConcept
508        else if (name.equals("bodySite"))
509          this.bodySite = castToCodeableConcept(value); // CodeableConcept
510        else
511          super.setProperty(name, value);
512      }
513
514      @Override
515      public Base makeProperty(int hash, String name) throws FHIRException {
516        switch (hash) {
517        case 1883491469:  return getCollector(); // Reference
518        case 950398559: throw new FHIRException("Cannot make property comment as it is not a complex type"); // StringType
519        case 1632037015:  return getCollected(); // Type
520        case -1285004149:  return getQuantity(); // SimpleQuantity
521        case -1077554975:  return getMethod(); // CodeableConcept
522        case 1702620169:  return getBodySite(); // CodeableConcept
523        default: return super.makeProperty(hash, name);
524        }
525
526      }
527
528      @Override
529      public Base addChild(String name) throws FHIRException {
530        if (name.equals("collector")) {
531          this.collector = new Reference();
532          return this.collector;
533        }
534        else if (name.equals("comment")) {
535          throw new FHIRException("Cannot call addChild on a primitive type Specimen.comment");
536        }
537        else if (name.equals("collectedDateTime")) {
538          this.collected = new DateTimeType();
539          return this.collected;
540        }
541        else if (name.equals("collectedPeriod")) {
542          this.collected = new Period();
543          return this.collected;
544        }
545        else if (name.equals("quantity")) {
546          this.quantity = new SimpleQuantity();
547          return this.quantity;
548        }
549        else if (name.equals("method")) {
550          this.method = new CodeableConcept();
551          return this.method;
552        }
553        else if (name.equals("bodySite")) {
554          this.bodySite = new CodeableConcept();
555          return this.bodySite;
556        }
557        else
558          return super.addChild(name);
559      }
560
561      public SpecimenCollectionComponent copy() {
562        SpecimenCollectionComponent dst = new SpecimenCollectionComponent();
563        copyValues(dst);
564        dst.collector = collector == null ? null : collector.copy();
565        dst.comment = comment == null ? null : comment.copy();
566        dst.collected = collected == null ? null : collected.copy();
567        dst.quantity = quantity == null ? null : quantity.copy();
568        dst.method = method == null ? null : method.copy();
569        dst.bodySite = bodySite == null ? null : bodySite.copy();
570        return dst;
571      }
572
573      @Override
574      public boolean equalsDeep(Base other) {
575        if (!super.equalsDeep(other))
576          return false;
577        if (!(other instanceof SpecimenCollectionComponent))
578          return false;
579        SpecimenCollectionComponent o = (SpecimenCollectionComponent) other;
580        return compareDeep(collector, o.collector, true) && compareDeep(comment, o.comment, true) && compareDeep(collected, o.collected, true)
581           && compareDeep(quantity, o.quantity, true) && compareDeep(method, o.method, true) && compareDeep(bodySite, o.bodySite, true)
582          ;
583      }
584
585      @Override
586      public boolean equalsShallow(Base other) {
587        if (!super.equalsShallow(other))
588          return false;
589        if (!(other instanceof SpecimenCollectionComponent))
590          return false;
591        SpecimenCollectionComponent o = (SpecimenCollectionComponent) other;
592        return compareValues(comment, o.comment, true);
593      }
594
595      public boolean isEmpty() {
596        return super.isEmpty() && (collector == null || collector.isEmpty()) && (comment == null || comment.isEmpty())
597           && (collected == null || collected.isEmpty()) && (quantity == null || quantity.isEmpty())
598           && (method == null || method.isEmpty()) && (bodySite == null || bodySite.isEmpty());
599      }
600
601  public String fhirType() {
602    return "Specimen.collection";
603
604  }
605
606  }
607
608    @Block()
609    public static class SpecimenTreatmentComponent extends BackboneElement implements IBaseBackboneElement {
610        /**
611         * Textual description of procedure.
612         */
613        @Child(name = "description", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=false)
614        @Description(shortDefinition="Textual description of procedure", formalDefinition="Textual description of procedure." )
615        protected StringType description;
616
617        /**
618         * A coded value specifying the procedure used to process the specimen.
619         */
620        @Child(name = "procedure", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
621        @Description(shortDefinition="Indicates the treatment or processing step  applied to the specimen", formalDefinition="A coded value specifying the procedure used to process the specimen." )
622        protected CodeableConcept procedure;
623
624        /**
625         * Material used in the processing step.
626         */
627        @Child(name = "additive", type = {Substance.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
628        @Description(shortDefinition="Material used in the processing step", formalDefinition="Material used in the processing step." )
629        protected List<Reference> additive;
630        /**
631         * The actual objects that are the target of the reference (Material used in the processing step.)
632         */
633        protected List<Substance> additiveTarget;
634
635
636        private static final long serialVersionUID = -373251521L;
637
638    /**
639     * Constructor
640     */
641      public SpecimenTreatmentComponent() {
642        super();
643      }
644
645        /**
646         * @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
647         */
648        public StringType getDescriptionElement() { 
649          if (this.description == null)
650            if (Configuration.errorOnAutoCreate())
651              throw new Error("Attempt to auto-create SpecimenTreatmentComponent.description");
652            else if (Configuration.doAutoCreate())
653              this.description = new StringType(); // bb
654          return this.description;
655        }
656
657        public boolean hasDescriptionElement() { 
658          return this.description != null && !this.description.isEmpty();
659        }
660
661        public boolean hasDescription() { 
662          return this.description != null && !this.description.isEmpty();
663        }
664
665        /**
666         * @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
667         */
668        public SpecimenTreatmentComponent setDescriptionElement(StringType value) { 
669          this.description = value;
670          return this;
671        }
672
673        /**
674         * @return Textual description of procedure.
675         */
676        public String getDescription() { 
677          return this.description == null ? null : this.description.getValue();
678        }
679
680        /**
681         * @param value Textual description of procedure.
682         */
683        public SpecimenTreatmentComponent setDescription(String value) { 
684          if (Utilities.noString(value))
685            this.description = null;
686          else {
687            if (this.description == null)
688              this.description = new StringType();
689            this.description.setValue(value);
690          }
691          return this;
692        }
693
694        /**
695         * @return {@link #procedure} (A coded value specifying the procedure used to process the specimen.)
696         */
697        public CodeableConcept getProcedure() { 
698          if (this.procedure == null)
699            if (Configuration.errorOnAutoCreate())
700              throw new Error("Attempt to auto-create SpecimenTreatmentComponent.procedure");
701            else if (Configuration.doAutoCreate())
702              this.procedure = new CodeableConcept(); // cc
703          return this.procedure;
704        }
705
706        public boolean hasProcedure() { 
707          return this.procedure != null && !this.procedure.isEmpty();
708        }
709
710        /**
711         * @param value {@link #procedure} (A coded value specifying the procedure used to process the specimen.)
712         */
713        public SpecimenTreatmentComponent setProcedure(CodeableConcept value) { 
714          this.procedure = value;
715          return this;
716        }
717
718        /**
719         * @return {@link #additive} (Material used in the processing step.)
720         */
721        public List<Reference> getAdditive() { 
722          if (this.additive == null)
723            this.additive = new ArrayList<Reference>();
724          return this.additive;
725        }
726
727        public boolean hasAdditive() { 
728          if (this.additive == null)
729            return false;
730          for (Reference item : this.additive)
731            if (!item.isEmpty())
732              return true;
733          return false;
734        }
735
736        /**
737         * @return {@link #additive} (Material used in the processing step.)
738         */
739    // syntactic sugar
740        public Reference addAdditive() { //3
741          Reference t = new Reference();
742          if (this.additive == null)
743            this.additive = new ArrayList<Reference>();
744          this.additive.add(t);
745          return t;
746        }
747
748    // syntactic sugar
749        public SpecimenTreatmentComponent addAdditive(Reference t) { //3
750          if (t == null)
751            return this;
752          if (this.additive == null)
753            this.additive = new ArrayList<Reference>();
754          this.additive.add(t);
755          return this;
756        }
757
758        /**
759         * @return {@link #additive} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. Material used in the processing step.)
760         */
761        public List<Substance> getAdditiveTarget() { 
762          if (this.additiveTarget == null)
763            this.additiveTarget = new ArrayList<Substance>();
764          return this.additiveTarget;
765        }
766
767    // syntactic sugar
768        /**
769         * @return {@link #additive} (Add an actual object that is the target of the reference. The reference library doesn't use these, but you can use this to hold the resources if you resolvethemt. Material used in the processing step.)
770         */
771        public Substance addAdditiveTarget() { 
772          Substance r = new Substance();
773          if (this.additiveTarget == null)
774            this.additiveTarget = new ArrayList<Substance>();
775          this.additiveTarget.add(r);
776          return r;
777        }
778
779        protected void listChildren(List<Property> childrenList) {
780          super.listChildren(childrenList);
781          childrenList.add(new Property("description", "string", "Textual description of procedure.", 0, java.lang.Integer.MAX_VALUE, description));
782          childrenList.add(new Property("procedure", "CodeableConcept", "A coded value specifying the procedure used to process the specimen.", 0, java.lang.Integer.MAX_VALUE, procedure));
783          childrenList.add(new Property("additive", "Reference(Substance)", "Material used in the processing step.", 0, java.lang.Integer.MAX_VALUE, additive));
784        }
785
786      @Override
787      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
788        switch (hash) {
789        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // StringType
790        case -1095204141: /*procedure*/ return this.procedure == null ? new Base[0] : new Base[] {this.procedure}; // CodeableConcept
791        case -1226589236: /*additive*/ return this.additive == null ? new Base[0] : this.additive.toArray(new Base[this.additive.size()]); // Reference
792        default: return super.getProperty(hash, name, checkValid);
793        }
794
795      }
796
797      @Override
798      public void setProperty(int hash, String name, Base value) throws FHIRException {
799        switch (hash) {
800        case -1724546052: // description
801          this.description = castToString(value); // StringType
802          break;
803        case -1095204141: // procedure
804          this.procedure = castToCodeableConcept(value); // CodeableConcept
805          break;
806        case -1226589236: // additive
807          this.getAdditive().add(castToReference(value)); // Reference
808          break;
809        default: super.setProperty(hash, name, value);
810        }
811
812      }
813
814      @Override
815      public void setProperty(String name, Base value) throws FHIRException {
816        if (name.equals("description"))
817          this.description = castToString(value); // StringType
818        else if (name.equals("procedure"))
819          this.procedure = castToCodeableConcept(value); // CodeableConcept
820        else if (name.equals("additive"))
821          this.getAdditive().add(castToReference(value));
822        else
823          super.setProperty(name, value);
824      }
825
826      @Override
827      public Base makeProperty(int hash, String name) throws FHIRException {
828        switch (hash) {
829        case -1724546052: throw new FHIRException("Cannot make property description as it is not a complex type"); // StringType
830        case -1095204141:  return getProcedure(); // CodeableConcept
831        case -1226589236:  return addAdditive(); // Reference
832        default: return super.makeProperty(hash, name);
833        }
834
835      }
836
837      @Override
838      public Base addChild(String name) throws FHIRException {
839        if (name.equals("description")) {
840          throw new FHIRException("Cannot call addChild on a primitive type Specimen.description");
841        }
842        else if (name.equals("procedure")) {
843          this.procedure = new CodeableConcept();
844          return this.procedure;
845        }
846        else if (name.equals("additive")) {
847          return addAdditive();
848        }
849        else
850          return super.addChild(name);
851      }
852
853      public SpecimenTreatmentComponent copy() {
854        SpecimenTreatmentComponent dst = new SpecimenTreatmentComponent();
855        copyValues(dst);
856        dst.description = description == null ? null : description.copy();
857        dst.procedure = procedure == null ? null : procedure.copy();
858        if (additive != null) {
859          dst.additive = new ArrayList<Reference>();
860          for (Reference i : additive)
861            dst.additive.add(i.copy());
862        };
863        return dst;
864      }
865
866      @Override
867      public boolean equalsDeep(Base other) {
868        if (!super.equalsDeep(other))
869          return false;
870        if (!(other instanceof SpecimenTreatmentComponent))
871          return false;
872        SpecimenTreatmentComponent o = (SpecimenTreatmentComponent) other;
873        return compareDeep(description, o.description, true) && compareDeep(procedure, o.procedure, true)
874           && compareDeep(additive, o.additive, true);
875      }
876
877      @Override
878      public boolean equalsShallow(Base other) {
879        if (!super.equalsShallow(other))
880          return false;
881        if (!(other instanceof SpecimenTreatmentComponent))
882          return false;
883        SpecimenTreatmentComponent o = (SpecimenTreatmentComponent) other;
884        return compareValues(description, o.description, true);
885      }
886
887      public boolean isEmpty() {
888        return super.isEmpty() && (description == null || description.isEmpty()) && (procedure == null || procedure.isEmpty())
889           && (additive == null || additive.isEmpty());
890      }
891
892  public String fhirType() {
893    return "Specimen.treatment";
894
895  }
896
897  }
898
899    @Block()
900    public static class SpecimenContainerComponent extends BackboneElement implements IBaseBackboneElement {
901        /**
902         * 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.
903         */
904        @Child(name = "identifier", type = {Identifier.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
905        @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." )
906        protected List<Identifier> identifier;
907
908        /**
909         * Textual description of the container.
910         */
911        @Child(name = "description", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=false)
912        @Description(shortDefinition="Textual description of the container", formalDefinition="Textual description of the container." )
913        protected StringType description;
914
915        /**
916         * The type of container associated with the specimen (e.g. slide, aliquot, etc.).
917         */
918        @Child(name = "type", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=false)
919        @Description(shortDefinition="Kind of container directly associated with specimen", formalDefinition="The type of container associated with the specimen (e.g. slide, aliquot, etc.)." )
920        protected CodeableConcept type;
921
922        /**
923         * The capacity (volume or other measure) the container may contain.
924         */
925        @Child(name = "capacity", type = {SimpleQuantity.class}, order=4, min=0, max=1, modifier=false, summary=false)
926        @Description(shortDefinition="Container volume or size", formalDefinition="The capacity (volume or other measure) the container may contain." )
927        protected SimpleQuantity capacity;
928
929        /**
930         * The quantity of specimen in the container; may be volume, dimensions, or other appropriate measurements, depending on the specimen type.
931         */
932        @Child(name = "specimenQuantity", type = {SimpleQuantity.class}, order=5, min=0, max=1, modifier=false, summary=false)
933        @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." )
934        protected SimpleQuantity specimenQuantity;
935
936        /**
937         * Introduced substance to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.
938         */
939        @Child(name = "additive", type = {CodeableConcept.class, Substance.class}, order=6, min=0, max=1, modifier=false, summary=false)
940        @Description(shortDefinition="Additive associated with container", formalDefinition="Introduced substance to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA." )
941        protected Type additive;
942
943        private static final long serialVersionUID = 187274879L;
944
945    /**
946     * Constructor
947     */
948      public SpecimenContainerComponent() {
949        super();
950      }
951
952        /**
953         * @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.)
954         */
955        public List<Identifier> getIdentifier() { 
956          if (this.identifier == null)
957            this.identifier = new ArrayList<Identifier>();
958          return this.identifier;
959        }
960
961        public boolean hasIdentifier() { 
962          if (this.identifier == null)
963            return false;
964          for (Identifier item : this.identifier)
965            if (!item.isEmpty())
966              return true;
967          return false;
968        }
969
970        /**
971         * @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.)
972         */
973    // syntactic sugar
974        public Identifier addIdentifier() { //3
975          Identifier t = new Identifier();
976          if (this.identifier == null)
977            this.identifier = new ArrayList<Identifier>();
978          this.identifier.add(t);
979          return t;
980        }
981
982    // syntactic sugar
983        public SpecimenContainerComponent addIdentifier(Identifier t) { //3
984          if (t == null)
985            return this;
986          if (this.identifier == null)
987            this.identifier = new ArrayList<Identifier>();
988          this.identifier.add(t);
989          return this;
990        }
991
992        /**
993         * @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
994         */
995        public StringType getDescriptionElement() { 
996          if (this.description == null)
997            if (Configuration.errorOnAutoCreate())
998              throw new Error("Attempt to auto-create SpecimenContainerComponent.description");
999            else if (Configuration.doAutoCreate())
1000              this.description = new StringType(); // bb
1001          return this.description;
1002        }
1003
1004        public boolean hasDescriptionElement() { 
1005          return this.description != null && !this.description.isEmpty();
1006        }
1007
1008        public boolean hasDescription() { 
1009          return this.description != null && !this.description.isEmpty();
1010        }
1011
1012        /**
1013         * @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
1014         */
1015        public SpecimenContainerComponent setDescriptionElement(StringType value) { 
1016          this.description = value;
1017          return this;
1018        }
1019
1020        /**
1021         * @return Textual description of the container.
1022         */
1023        public String getDescription() { 
1024          return this.description == null ? null : this.description.getValue();
1025        }
1026
1027        /**
1028         * @param value Textual description of the container.
1029         */
1030        public SpecimenContainerComponent setDescription(String value) { 
1031          if (Utilities.noString(value))
1032            this.description = null;
1033          else {
1034            if (this.description == null)
1035              this.description = new StringType();
1036            this.description.setValue(value);
1037          }
1038          return this;
1039        }
1040
1041        /**
1042         * @return {@link #type} (The type of container associated with the specimen (e.g. slide, aliquot, etc.).)
1043         */
1044        public CodeableConcept getType() { 
1045          if (this.type == null)
1046            if (Configuration.errorOnAutoCreate())
1047              throw new Error("Attempt to auto-create SpecimenContainerComponent.type");
1048            else if (Configuration.doAutoCreate())
1049              this.type = new CodeableConcept(); // cc
1050          return this.type;
1051        }
1052
1053        public boolean hasType() { 
1054          return this.type != null && !this.type.isEmpty();
1055        }
1056
1057        /**
1058         * @param value {@link #type} (The type of container associated with the specimen (e.g. slide, aliquot, etc.).)
1059         */
1060        public SpecimenContainerComponent setType(CodeableConcept value) { 
1061          this.type = value;
1062          return this;
1063        }
1064
1065        /**
1066         * @return {@link #capacity} (The capacity (volume or other measure) the container may contain.)
1067         */
1068        public SimpleQuantity getCapacity() { 
1069          if (this.capacity == null)
1070            if (Configuration.errorOnAutoCreate())
1071              throw new Error("Attempt to auto-create SpecimenContainerComponent.capacity");
1072            else if (Configuration.doAutoCreate())
1073              this.capacity = new SimpleQuantity(); // cc
1074          return this.capacity;
1075        }
1076
1077        public boolean hasCapacity() { 
1078          return this.capacity != null && !this.capacity.isEmpty();
1079        }
1080
1081        /**
1082         * @param value {@link #capacity} (The capacity (volume or other measure) the container may contain.)
1083         */
1084        public SpecimenContainerComponent setCapacity(SimpleQuantity value) { 
1085          this.capacity = value;
1086          return this;
1087        }
1088
1089        /**
1090         * @return {@link #specimenQuantity} (The quantity of specimen in the container; may be volume, dimensions, or other appropriate measurements, depending on the specimen type.)
1091         */
1092        public SimpleQuantity getSpecimenQuantity() { 
1093          if (this.specimenQuantity == null)
1094            if (Configuration.errorOnAutoCreate())
1095              throw new Error("Attempt to auto-create SpecimenContainerComponent.specimenQuantity");
1096            else if (Configuration.doAutoCreate())
1097              this.specimenQuantity = new SimpleQuantity(); // cc
1098          return this.specimenQuantity;
1099        }
1100
1101        public boolean hasSpecimenQuantity() { 
1102          return this.specimenQuantity != null && !this.specimenQuantity.isEmpty();
1103        }
1104
1105        /**
1106         * @param value {@link #specimenQuantity} (The quantity of specimen in the container; may be volume, dimensions, or other appropriate measurements, depending on the specimen type.)
1107         */
1108        public SpecimenContainerComponent setSpecimenQuantity(SimpleQuantity value) { 
1109          this.specimenQuantity = value;
1110          return this;
1111        }
1112
1113        /**
1114         * @return {@link #additive} (Introduced substance to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.)
1115         */
1116        public Type getAdditive() { 
1117          return this.additive;
1118        }
1119
1120        /**
1121         * @return {@link #additive} (Introduced substance to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.)
1122         */
1123        public CodeableConcept getAdditiveCodeableConcept() throws FHIRException { 
1124          if (!(this.additive instanceof CodeableConcept))
1125            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.additive.getClass().getName()+" was encountered");
1126          return (CodeableConcept) this.additive;
1127        }
1128
1129        public boolean hasAdditiveCodeableConcept() { 
1130          return this.additive instanceof CodeableConcept;
1131        }
1132
1133        /**
1134         * @return {@link #additive} (Introduced substance to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.)
1135         */
1136        public Reference getAdditiveReference() throws FHIRException { 
1137          if (!(this.additive instanceof Reference))
1138            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.additive.getClass().getName()+" was encountered");
1139          return (Reference) this.additive;
1140        }
1141
1142        public boolean hasAdditiveReference() { 
1143          return this.additive instanceof Reference;
1144        }
1145
1146        public boolean hasAdditive() { 
1147          return this.additive != null && !this.additive.isEmpty();
1148        }
1149
1150        /**
1151         * @param value {@link #additive} (Introduced substance to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.)
1152         */
1153        public SpecimenContainerComponent setAdditive(Type value) { 
1154          this.additive = value;
1155          return this;
1156        }
1157
1158        protected void listChildren(List<Property> childrenList) {
1159          super.listChildren(childrenList);
1160          childrenList.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));
1161          childrenList.add(new Property("description", "string", "Textual description of the container.", 0, java.lang.Integer.MAX_VALUE, description));
1162          childrenList.add(new Property("type", "CodeableConcept", "The type of container associated with the specimen (e.g. slide, aliquot, etc.).", 0, java.lang.Integer.MAX_VALUE, type));
1163          childrenList.add(new Property("capacity", "SimpleQuantity", "The capacity (volume or other measure) the container may contain.", 0, java.lang.Integer.MAX_VALUE, capacity));
1164          childrenList.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, java.lang.Integer.MAX_VALUE, specimenQuantity));
1165          childrenList.add(new Property("additive[x]", "CodeableConcept|Reference(Substance)", "Introduced substance to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.", 0, java.lang.Integer.MAX_VALUE, additive));
1166        }
1167
1168      @Override
1169      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1170        switch (hash) {
1171        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1172        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // StringType
1173        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
1174        case -67824454: /*capacity*/ return this.capacity == null ? new Base[0] : new Base[] {this.capacity}; // SimpleQuantity
1175        case 1485980595: /*specimenQuantity*/ return this.specimenQuantity == null ? new Base[0] : new Base[] {this.specimenQuantity}; // SimpleQuantity
1176        case -1226589236: /*additive*/ return this.additive == null ? new Base[0] : new Base[] {this.additive}; // Type
1177        default: return super.getProperty(hash, name, checkValid);
1178        }
1179
1180      }
1181
1182      @Override
1183      public void setProperty(int hash, String name, Base value) throws FHIRException {
1184        switch (hash) {
1185        case -1618432855: // identifier
1186          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1187          break;
1188        case -1724546052: // description
1189          this.description = castToString(value); // StringType
1190          break;
1191        case 3575610: // type
1192          this.type = castToCodeableConcept(value); // CodeableConcept
1193          break;
1194        case -67824454: // capacity
1195          this.capacity = castToSimpleQuantity(value); // SimpleQuantity
1196          break;
1197        case 1485980595: // specimenQuantity
1198          this.specimenQuantity = castToSimpleQuantity(value); // SimpleQuantity
1199          break;
1200        case -1226589236: // additive
1201          this.additive = (Type) value; // Type
1202          break;
1203        default: super.setProperty(hash, name, value);
1204        }
1205
1206      }
1207
1208      @Override
1209      public void setProperty(String name, Base value) throws FHIRException {
1210        if (name.equals("identifier"))
1211          this.getIdentifier().add(castToIdentifier(value));
1212        else if (name.equals("description"))
1213          this.description = castToString(value); // StringType
1214        else if (name.equals("type"))
1215          this.type = castToCodeableConcept(value); // CodeableConcept
1216        else if (name.equals("capacity"))
1217          this.capacity = castToSimpleQuantity(value); // SimpleQuantity
1218        else if (name.equals("specimenQuantity"))
1219          this.specimenQuantity = castToSimpleQuantity(value); // SimpleQuantity
1220        else if (name.equals("additive[x]"))
1221          this.additive = (Type) value; // Type
1222        else
1223          super.setProperty(name, value);
1224      }
1225
1226      @Override
1227      public Base makeProperty(int hash, String name) throws FHIRException {
1228        switch (hash) {
1229        case -1618432855:  return addIdentifier(); // Identifier
1230        case -1724546052: throw new FHIRException("Cannot make property description as it is not a complex type"); // StringType
1231        case 3575610:  return getType(); // CodeableConcept
1232        case -67824454:  return getCapacity(); // SimpleQuantity
1233        case 1485980595:  return getSpecimenQuantity(); // SimpleQuantity
1234        case 261915956:  return getAdditive(); // Type
1235        default: return super.makeProperty(hash, name);
1236        }
1237
1238      }
1239
1240      @Override
1241      public Base addChild(String name) throws FHIRException {
1242        if (name.equals("identifier")) {
1243          return addIdentifier();
1244        }
1245        else if (name.equals("description")) {
1246          throw new FHIRException("Cannot call addChild on a primitive type Specimen.description");
1247        }
1248        else if (name.equals("type")) {
1249          this.type = new CodeableConcept();
1250          return this.type;
1251        }
1252        else if (name.equals("capacity")) {
1253          this.capacity = new SimpleQuantity();
1254          return this.capacity;
1255        }
1256        else if (name.equals("specimenQuantity")) {
1257          this.specimenQuantity = new SimpleQuantity();
1258          return this.specimenQuantity;
1259        }
1260        else if (name.equals("additiveCodeableConcept")) {
1261          this.additive = new CodeableConcept();
1262          return this.additive;
1263        }
1264        else if (name.equals("additiveReference")) {
1265          this.additive = new Reference();
1266          return this.additive;
1267        }
1268        else
1269          return super.addChild(name);
1270      }
1271
1272      public SpecimenContainerComponent copy() {
1273        SpecimenContainerComponent dst = new SpecimenContainerComponent();
1274        copyValues(dst);
1275        if (identifier != null) {
1276          dst.identifier = new ArrayList<Identifier>();
1277          for (Identifier i : identifier)
1278            dst.identifier.add(i.copy());
1279        };
1280        dst.description = description == null ? null : description.copy();
1281        dst.type = type == null ? null : type.copy();
1282        dst.capacity = capacity == null ? null : capacity.copy();
1283        dst.specimenQuantity = specimenQuantity == null ? null : specimenQuantity.copy();
1284        dst.additive = additive == null ? null : additive.copy();
1285        return dst;
1286      }
1287
1288      @Override
1289      public boolean equalsDeep(Base other) {
1290        if (!super.equalsDeep(other))
1291          return false;
1292        if (!(other instanceof SpecimenContainerComponent))
1293          return false;
1294        SpecimenContainerComponent o = (SpecimenContainerComponent) other;
1295        return compareDeep(identifier, o.identifier, true) && compareDeep(description, o.description, true)
1296           && compareDeep(type, o.type, true) && compareDeep(capacity, o.capacity, true) && compareDeep(specimenQuantity, o.specimenQuantity, true)
1297           && compareDeep(additive, o.additive, true);
1298      }
1299
1300      @Override
1301      public boolean equalsShallow(Base other) {
1302        if (!super.equalsShallow(other))
1303          return false;
1304        if (!(other instanceof SpecimenContainerComponent))
1305          return false;
1306        SpecimenContainerComponent o = (SpecimenContainerComponent) other;
1307        return compareValues(description, o.description, true);
1308      }
1309
1310      public boolean isEmpty() {
1311        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (description == null || description.isEmpty())
1312           && (type == null || type.isEmpty()) && (capacity == null || capacity.isEmpty()) && (specimenQuantity == null || specimenQuantity.isEmpty())
1313           && (additive == null || additive.isEmpty());
1314      }
1315
1316  public String fhirType() {
1317    return "Specimen.container";
1318
1319  }
1320
1321  }
1322
1323    /**
1324     * Id for specimen.
1325     */
1326    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1327    @Description(shortDefinition="External Identifier", formalDefinition="Id for specimen." )
1328    protected List<Identifier> identifier;
1329
1330    /**
1331     * 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.
1332     */
1333    @Child(name = "accessionIdentifier", type = {Identifier.class}, order=1, min=0, max=1, modifier=false, summary=true)
1334    @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." )
1335    protected Identifier accessionIdentifier;
1336
1337    /**
1338     * The availability of the specimen.
1339     */
1340    @Child(name = "status", type = {CodeType.class}, order=2, min=0, max=1, modifier=true, summary=true)
1341    @Description(shortDefinition="available | unavailable | unsatisfactory | entered-in-error", formalDefinition="The availability of the specimen." )
1342    protected Enumeration<SpecimenStatus> status;
1343
1344    /**
1345     * The kind of material that forms the specimen.
1346     */
1347    @Child(name = "type", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true)
1348    @Description(shortDefinition="Kind of material that forms the specimen", formalDefinition="The kind of material that forms the specimen." )
1349    protected CodeableConcept type;
1350
1351    /**
1352     * Where the specimen came from. This may be from the patient(s) or from the environment or a device.
1353     */
1354    @Child(name = "subject", type = {Patient.class, Group.class, Device.class, Substance.class}, order=4, min=1, max=1, modifier=false, summary=true)
1355    @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." )
1356    protected Reference subject;
1357
1358    /**
1359     * 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.)
1360     */
1361    protected Resource subjectTarget;
1362
1363    /**
1364     * Time when specimen was received for processing or testing.
1365     */
1366    @Child(name = "receivedTime", type = {DateTimeType.class}, order=5, min=0, max=1, modifier=false, summary=true)
1367    @Description(shortDefinition="The time when specimen was received for processing", formalDefinition="Time when specimen was received for processing or testing." )
1368    protected DateTimeType receivedTime;
1369
1370    /**
1371     * Reference to the parent (source) specimen which is used when the specimen was either derived from or a component of another specimen.
1372     */
1373    @Child(name = "parent", type = {Specimen.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1374    @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." )
1375    protected List<Reference> parent;
1376    /**
1377     * 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.)
1378     */
1379    protected List<Specimen> parentTarget;
1380
1381
1382    /**
1383     * Details concerning the specimen collection.
1384     */
1385    @Child(name = "collection", type = {}, order=7, min=0, max=1, modifier=false, summary=false)
1386    @Description(shortDefinition="Collection details", formalDefinition="Details concerning the specimen collection." )
1387    protected SpecimenCollectionComponent collection;
1388
1389    /**
1390     * Details concerning treatment and processing steps for the specimen.
1391     */
1392    @Child(name = "treatment", type = {}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1393    @Description(shortDefinition="Treatment and processing step details", formalDefinition="Details concerning treatment and processing steps for the specimen." )
1394    protected List<SpecimenTreatmentComponent> treatment;
1395
1396    /**
1397     * The container holding the specimen.  The recursive nature of containers; i.e. blood in tube in tray in rack is not addressed here.
1398     */
1399    @Child(name = "container", type = {}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1400    @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." )
1401    protected List<SpecimenContainerComponent> container;
1402
1403    private static final long serialVersionUID = -374913648L;
1404
1405  /**
1406   * Constructor
1407   */
1408    public Specimen() {
1409      super();
1410    }
1411
1412  /**
1413   * Constructor
1414   */
1415    public Specimen(Reference subject) {
1416      super();
1417      this.subject = subject;
1418    }
1419
1420    /**
1421     * @return {@link #identifier} (Id for specimen.)
1422     */
1423    public List<Identifier> getIdentifier() { 
1424      if (this.identifier == null)
1425        this.identifier = new ArrayList<Identifier>();
1426      return this.identifier;
1427    }
1428
1429    public boolean hasIdentifier() { 
1430      if (this.identifier == null)
1431        return false;
1432      for (Identifier item : this.identifier)
1433        if (!item.isEmpty())
1434          return true;
1435      return false;
1436    }
1437
1438    /**
1439     * @return {@link #identifier} (Id for specimen.)
1440     */
1441    // syntactic sugar
1442    public Identifier addIdentifier() { //3
1443      Identifier t = new Identifier();
1444      if (this.identifier == null)
1445        this.identifier = new ArrayList<Identifier>();
1446      this.identifier.add(t);
1447      return t;
1448    }
1449
1450    // syntactic sugar
1451    public Specimen addIdentifier(Identifier t) { //3
1452      if (t == null)
1453        return this;
1454      if (this.identifier == null)
1455        this.identifier = new ArrayList<Identifier>();
1456      this.identifier.add(t);
1457      return this;
1458    }
1459
1460    /**
1461     * @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.)
1462     */
1463    public Identifier getAccessionIdentifier() { 
1464      if (this.accessionIdentifier == null)
1465        if (Configuration.errorOnAutoCreate())
1466          throw new Error("Attempt to auto-create Specimen.accessionIdentifier");
1467        else if (Configuration.doAutoCreate())
1468          this.accessionIdentifier = new Identifier(); // cc
1469      return this.accessionIdentifier;
1470    }
1471
1472    public boolean hasAccessionIdentifier() { 
1473      return this.accessionIdentifier != null && !this.accessionIdentifier.isEmpty();
1474    }
1475
1476    /**
1477     * @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.)
1478     */
1479    public Specimen setAccessionIdentifier(Identifier value) { 
1480      this.accessionIdentifier = value;
1481      return this;
1482    }
1483
1484    /**
1485     * @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
1486     */
1487    public Enumeration<SpecimenStatus> getStatusElement() { 
1488      if (this.status == null)
1489        if (Configuration.errorOnAutoCreate())
1490          throw new Error("Attempt to auto-create Specimen.status");
1491        else if (Configuration.doAutoCreate())
1492          this.status = new Enumeration<SpecimenStatus>(new SpecimenStatusEnumFactory()); // bb
1493      return this.status;
1494    }
1495
1496    public boolean hasStatusElement() { 
1497      return this.status != null && !this.status.isEmpty();
1498    }
1499
1500    public boolean hasStatus() { 
1501      return this.status != null && !this.status.isEmpty();
1502    }
1503
1504    /**
1505     * @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
1506     */
1507    public Specimen setStatusElement(Enumeration<SpecimenStatus> value) { 
1508      this.status = value;
1509      return this;
1510    }
1511
1512    /**
1513     * @return The availability of the specimen.
1514     */
1515    public SpecimenStatus getStatus() { 
1516      return this.status == null ? null : this.status.getValue();
1517    }
1518
1519    /**
1520     * @param value The availability of the specimen.
1521     */
1522    public Specimen setStatus(SpecimenStatus value) { 
1523      if (value == null)
1524        this.status = null;
1525      else {
1526        if (this.status == null)
1527          this.status = new Enumeration<SpecimenStatus>(new SpecimenStatusEnumFactory());
1528        this.status.setValue(value);
1529      }
1530      return this;
1531    }
1532
1533    /**
1534     * @return {@link #type} (The kind of material that forms the specimen.)
1535     */
1536    public CodeableConcept getType() { 
1537      if (this.type == null)
1538        if (Configuration.errorOnAutoCreate())
1539          throw new Error("Attempt to auto-create Specimen.type");
1540        else if (Configuration.doAutoCreate())
1541          this.type = new CodeableConcept(); // cc
1542      return this.type;
1543    }
1544
1545    public boolean hasType() { 
1546      return this.type != null && !this.type.isEmpty();
1547    }
1548
1549    /**
1550     * @param value {@link #type} (The kind of material that forms the specimen.)
1551     */
1552    public Specimen setType(CodeableConcept value) { 
1553      this.type = value;
1554      return this;
1555    }
1556
1557    /**
1558     * @return {@link #subject} (Where the specimen came from. This may be from the patient(s) or from the environment or a device.)
1559     */
1560    public Reference getSubject() { 
1561      if (this.subject == null)
1562        if (Configuration.errorOnAutoCreate())
1563          throw new Error("Attempt to auto-create Specimen.subject");
1564        else if (Configuration.doAutoCreate())
1565          this.subject = new Reference(); // cc
1566      return this.subject;
1567    }
1568
1569    public boolean hasSubject() { 
1570      return this.subject != null && !this.subject.isEmpty();
1571    }
1572
1573    /**
1574     * @param value {@link #subject} (Where the specimen came from. This may be from the patient(s) or from the environment or a device.)
1575     */
1576    public Specimen setSubject(Reference value) { 
1577      this.subject = value;
1578      return this;
1579    }
1580
1581    /**
1582     * @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.)
1583     */
1584    public Resource getSubjectTarget() { 
1585      return this.subjectTarget;
1586    }
1587
1588    /**
1589     * @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.)
1590     */
1591    public Specimen setSubjectTarget(Resource value) { 
1592      this.subjectTarget = value;
1593      return this;
1594    }
1595
1596    /**
1597     * @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
1598     */
1599    public DateTimeType getReceivedTimeElement() { 
1600      if (this.receivedTime == null)
1601        if (Configuration.errorOnAutoCreate())
1602          throw new Error("Attempt to auto-create Specimen.receivedTime");
1603        else if (Configuration.doAutoCreate())
1604          this.receivedTime = new DateTimeType(); // bb
1605      return this.receivedTime;
1606    }
1607
1608    public boolean hasReceivedTimeElement() { 
1609      return this.receivedTime != null && !this.receivedTime.isEmpty();
1610    }
1611
1612    public boolean hasReceivedTime() { 
1613      return this.receivedTime != null && !this.receivedTime.isEmpty();
1614    }
1615
1616    /**
1617     * @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
1618     */
1619    public Specimen setReceivedTimeElement(DateTimeType value) { 
1620      this.receivedTime = value;
1621      return this;
1622    }
1623
1624    /**
1625     * @return Time when specimen was received for processing or testing.
1626     */
1627    public Date getReceivedTime() { 
1628      return this.receivedTime == null ? null : this.receivedTime.getValue();
1629    }
1630
1631    /**
1632     * @param value Time when specimen was received for processing or testing.
1633     */
1634    public Specimen setReceivedTime(Date value) { 
1635      if (value == null)
1636        this.receivedTime = null;
1637      else {
1638        if (this.receivedTime == null)
1639          this.receivedTime = new DateTimeType();
1640        this.receivedTime.setValue(value);
1641      }
1642      return this;
1643    }
1644
1645    /**
1646     * @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.)
1647     */
1648    public List<Reference> getParent() { 
1649      if (this.parent == null)
1650        this.parent = new ArrayList<Reference>();
1651      return this.parent;
1652    }
1653
1654    public boolean hasParent() { 
1655      if (this.parent == null)
1656        return false;
1657      for (Reference item : this.parent)
1658        if (!item.isEmpty())
1659          return true;
1660      return false;
1661    }
1662
1663    /**
1664     * @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.)
1665     */
1666    // syntactic sugar
1667    public Reference addParent() { //3
1668      Reference t = new Reference();
1669      if (this.parent == null)
1670        this.parent = new ArrayList<Reference>();
1671      this.parent.add(t);
1672      return t;
1673    }
1674
1675    // syntactic sugar
1676    public Specimen addParent(Reference t) { //3
1677      if (t == null)
1678        return this;
1679      if (this.parent == null)
1680        this.parent = new ArrayList<Reference>();
1681      this.parent.add(t);
1682      return this;
1683    }
1684
1685    /**
1686     * @return {@link #parent} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. Reference to the parent (source) specimen which is used when the specimen was either derived from or a component of another specimen.)
1687     */
1688    public List<Specimen> getParentTarget() { 
1689      if (this.parentTarget == null)
1690        this.parentTarget = new ArrayList<Specimen>();
1691      return this.parentTarget;
1692    }
1693
1694    // syntactic sugar
1695    /**
1696     * @return {@link #parent} (Add an actual object that is the target of the reference. The reference library doesn't use these, but you can use this to hold the resources if you resolvethemt. Reference to the parent (source) specimen which is used when the specimen was either derived from or a component of another specimen.)
1697     */
1698    public Specimen addParentTarget() { 
1699      Specimen r = new Specimen();
1700      if (this.parentTarget == null)
1701        this.parentTarget = new ArrayList<Specimen>();
1702      this.parentTarget.add(r);
1703      return r;
1704    }
1705
1706    /**
1707     * @return {@link #collection} (Details concerning the specimen collection.)
1708     */
1709    public SpecimenCollectionComponent getCollection() { 
1710      if (this.collection == null)
1711        if (Configuration.errorOnAutoCreate())
1712          throw new Error("Attempt to auto-create Specimen.collection");
1713        else if (Configuration.doAutoCreate())
1714          this.collection = new SpecimenCollectionComponent(); // cc
1715      return this.collection;
1716    }
1717
1718    public boolean hasCollection() { 
1719      return this.collection != null && !this.collection.isEmpty();
1720    }
1721
1722    /**
1723     * @param value {@link #collection} (Details concerning the specimen collection.)
1724     */
1725    public Specimen setCollection(SpecimenCollectionComponent value) { 
1726      this.collection = value;
1727      return this;
1728    }
1729
1730    /**
1731     * @return {@link #treatment} (Details concerning treatment and processing steps for the specimen.)
1732     */
1733    public List<SpecimenTreatmentComponent> getTreatment() { 
1734      if (this.treatment == null)
1735        this.treatment = new ArrayList<SpecimenTreatmentComponent>();
1736      return this.treatment;
1737    }
1738
1739    public boolean hasTreatment() { 
1740      if (this.treatment == null)
1741        return false;
1742      for (SpecimenTreatmentComponent item : this.treatment)
1743        if (!item.isEmpty())
1744          return true;
1745      return false;
1746    }
1747
1748    /**
1749     * @return {@link #treatment} (Details concerning treatment and processing steps for the specimen.)
1750     */
1751    // syntactic sugar
1752    public SpecimenTreatmentComponent addTreatment() { //3
1753      SpecimenTreatmentComponent t = new SpecimenTreatmentComponent();
1754      if (this.treatment == null)
1755        this.treatment = new ArrayList<SpecimenTreatmentComponent>();
1756      this.treatment.add(t);
1757      return t;
1758    }
1759
1760    // syntactic sugar
1761    public Specimen addTreatment(SpecimenTreatmentComponent t) { //3
1762      if (t == null)
1763        return this;
1764      if (this.treatment == null)
1765        this.treatment = new ArrayList<SpecimenTreatmentComponent>();
1766      this.treatment.add(t);
1767      return this;
1768    }
1769
1770    /**
1771     * @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.)
1772     */
1773    public List<SpecimenContainerComponent> getContainer() { 
1774      if (this.container == null)
1775        this.container = new ArrayList<SpecimenContainerComponent>();
1776      return this.container;
1777    }
1778
1779    public boolean hasContainer() { 
1780      if (this.container == null)
1781        return false;
1782      for (SpecimenContainerComponent item : this.container)
1783        if (!item.isEmpty())
1784          return true;
1785      return false;
1786    }
1787
1788    /**
1789     * @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.)
1790     */
1791    // syntactic sugar
1792    public SpecimenContainerComponent addContainer() { //3
1793      SpecimenContainerComponent t = new SpecimenContainerComponent();
1794      if (this.container == null)
1795        this.container = new ArrayList<SpecimenContainerComponent>();
1796      this.container.add(t);
1797      return t;
1798    }
1799
1800    // syntactic sugar
1801    public Specimen addContainer(SpecimenContainerComponent t) { //3
1802      if (t == null)
1803        return this;
1804      if (this.container == null)
1805        this.container = new ArrayList<SpecimenContainerComponent>();
1806      this.container.add(t);
1807      return this;
1808    }
1809
1810      protected void listChildren(List<Property> childrenList) {
1811        super.listChildren(childrenList);
1812        childrenList.add(new Property("identifier", "Identifier", "Id for specimen.", 0, java.lang.Integer.MAX_VALUE, identifier));
1813        childrenList.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, java.lang.Integer.MAX_VALUE, accessionIdentifier));
1814        childrenList.add(new Property("status", "code", "The availability of the specimen.", 0, java.lang.Integer.MAX_VALUE, status));
1815        childrenList.add(new Property("type", "CodeableConcept", "The kind of material that forms the specimen.", 0, java.lang.Integer.MAX_VALUE, type));
1816        childrenList.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, java.lang.Integer.MAX_VALUE, subject));
1817        childrenList.add(new Property("receivedTime", "dateTime", "Time when specimen was received for processing or testing.", 0, java.lang.Integer.MAX_VALUE, receivedTime));
1818        childrenList.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));
1819        childrenList.add(new Property("collection", "", "Details concerning the specimen collection.", 0, java.lang.Integer.MAX_VALUE, collection));
1820        childrenList.add(new Property("treatment", "", "Details concerning treatment and processing steps for the specimen.", 0, java.lang.Integer.MAX_VALUE, treatment));
1821        childrenList.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));
1822      }
1823
1824      @Override
1825      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1826        switch (hash) {
1827        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1828        case 818734061: /*accessionIdentifier*/ return this.accessionIdentifier == null ? new Base[0] : new Base[] {this.accessionIdentifier}; // Identifier
1829        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<SpecimenStatus>
1830        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
1831        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
1832        case -767961010: /*receivedTime*/ return this.receivedTime == null ? new Base[0] : new Base[] {this.receivedTime}; // DateTimeType
1833        case -995424086: /*parent*/ return this.parent == null ? new Base[0] : this.parent.toArray(new Base[this.parent.size()]); // Reference
1834        case -1741312354: /*collection*/ return this.collection == null ? new Base[0] : new Base[] {this.collection}; // SpecimenCollectionComponent
1835        case -63342472: /*treatment*/ return this.treatment == null ? new Base[0] : this.treatment.toArray(new Base[this.treatment.size()]); // SpecimenTreatmentComponent
1836        case -410956671: /*container*/ return this.container == null ? new Base[0] : this.container.toArray(new Base[this.container.size()]); // SpecimenContainerComponent
1837        default: return super.getProperty(hash, name, checkValid);
1838        }
1839
1840      }
1841
1842      @Override
1843      public void setProperty(int hash, String name, Base value) throws FHIRException {
1844        switch (hash) {
1845        case -1618432855: // identifier
1846          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1847          break;
1848        case 818734061: // accessionIdentifier
1849          this.accessionIdentifier = castToIdentifier(value); // Identifier
1850          break;
1851        case -892481550: // status
1852          this.status = new SpecimenStatusEnumFactory().fromType(value); // Enumeration<SpecimenStatus>
1853          break;
1854        case 3575610: // type
1855          this.type = castToCodeableConcept(value); // CodeableConcept
1856          break;
1857        case -1867885268: // subject
1858          this.subject = castToReference(value); // Reference
1859          break;
1860        case -767961010: // receivedTime
1861          this.receivedTime = castToDateTime(value); // DateTimeType
1862          break;
1863        case -995424086: // parent
1864          this.getParent().add(castToReference(value)); // Reference
1865          break;
1866        case -1741312354: // collection
1867          this.collection = (SpecimenCollectionComponent) value; // SpecimenCollectionComponent
1868          break;
1869        case -63342472: // treatment
1870          this.getTreatment().add((SpecimenTreatmentComponent) value); // SpecimenTreatmentComponent
1871          break;
1872        case -410956671: // container
1873          this.getContainer().add((SpecimenContainerComponent) value); // SpecimenContainerComponent
1874          break;
1875        default: super.setProperty(hash, name, value);
1876        }
1877
1878      }
1879
1880      @Override
1881      public void setProperty(String name, Base value) throws FHIRException {
1882        if (name.equals("identifier"))
1883          this.getIdentifier().add(castToIdentifier(value));
1884        else if (name.equals("accessionIdentifier"))
1885          this.accessionIdentifier = castToIdentifier(value); // Identifier
1886        else if (name.equals("status"))
1887          this.status = new SpecimenStatusEnumFactory().fromType(value); // Enumeration<SpecimenStatus>
1888        else if (name.equals("type"))
1889          this.type = castToCodeableConcept(value); // CodeableConcept
1890        else if (name.equals("subject"))
1891          this.subject = castToReference(value); // Reference
1892        else if (name.equals("receivedTime"))
1893          this.receivedTime = castToDateTime(value); // DateTimeType
1894        else if (name.equals("parent"))
1895          this.getParent().add(castToReference(value));
1896        else if (name.equals("collection"))
1897          this.collection = (SpecimenCollectionComponent) value; // SpecimenCollectionComponent
1898        else if (name.equals("treatment"))
1899          this.getTreatment().add((SpecimenTreatmentComponent) value);
1900        else if (name.equals("container"))
1901          this.getContainer().add((SpecimenContainerComponent) value);
1902        else
1903          super.setProperty(name, value);
1904      }
1905
1906      @Override
1907      public Base makeProperty(int hash, String name) throws FHIRException {
1908        switch (hash) {
1909        case -1618432855:  return addIdentifier(); // Identifier
1910        case 818734061:  return getAccessionIdentifier(); // Identifier
1911        case -892481550: throw new FHIRException("Cannot make property status as it is not a complex type"); // Enumeration<SpecimenStatus>
1912        case 3575610:  return getType(); // CodeableConcept
1913        case -1867885268:  return getSubject(); // Reference
1914        case -767961010: throw new FHIRException("Cannot make property receivedTime as it is not a complex type"); // DateTimeType
1915        case -995424086:  return addParent(); // Reference
1916        case -1741312354:  return getCollection(); // SpecimenCollectionComponent
1917        case -63342472:  return addTreatment(); // SpecimenTreatmentComponent
1918        case -410956671:  return addContainer(); // SpecimenContainerComponent
1919        default: return super.makeProperty(hash, name);
1920        }
1921
1922      }
1923
1924      @Override
1925      public Base addChild(String name) throws FHIRException {
1926        if (name.equals("identifier")) {
1927          return addIdentifier();
1928        }
1929        else if (name.equals("accessionIdentifier")) {
1930          this.accessionIdentifier = new Identifier();
1931          return this.accessionIdentifier;
1932        }
1933        else if (name.equals("status")) {
1934          throw new FHIRException("Cannot call addChild on a primitive type Specimen.status");
1935        }
1936        else if (name.equals("type")) {
1937          this.type = new CodeableConcept();
1938          return this.type;
1939        }
1940        else if (name.equals("subject")) {
1941          this.subject = new Reference();
1942          return this.subject;
1943        }
1944        else if (name.equals("receivedTime")) {
1945          throw new FHIRException("Cannot call addChild on a primitive type Specimen.receivedTime");
1946        }
1947        else if (name.equals("parent")) {
1948          return addParent();
1949        }
1950        else if (name.equals("collection")) {
1951          this.collection = new SpecimenCollectionComponent();
1952          return this.collection;
1953        }
1954        else if (name.equals("treatment")) {
1955          return addTreatment();
1956        }
1957        else if (name.equals("container")) {
1958          return addContainer();
1959        }
1960        else
1961          return super.addChild(name);
1962      }
1963
1964  public String fhirType() {
1965    return "Specimen";
1966
1967  }
1968
1969      public Specimen copy() {
1970        Specimen dst = new Specimen();
1971        copyValues(dst);
1972        if (identifier != null) {
1973          dst.identifier = new ArrayList<Identifier>();
1974          for (Identifier i : identifier)
1975            dst.identifier.add(i.copy());
1976        };
1977        dst.accessionIdentifier = accessionIdentifier == null ? null : accessionIdentifier.copy();
1978        dst.status = status == null ? null : status.copy();
1979        dst.type = type == null ? null : type.copy();
1980        dst.subject = subject == null ? null : subject.copy();
1981        dst.receivedTime = receivedTime == null ? null : receivedTime.copy();
1982        if (parent != null) {
1983          dst.parent = new ArrayList<Reference>();
1984          for (Reference i : parent)
1985            dst.parent.add(i.copy());
1986        };
1987        dst.collection = collection == null ? null : collection.copy();
1988        if (treatment != null) {
1989          dst.treatment = new ArrayList<SpecimenTreatmentComponent>();
1990          for (SpecimenTreatmentComponent i : treatment)
1991            dst.treatment.add(i.copy());
1992        };
1993        if (container != null) {
1994          dst.container = new ArrayList<SpecimenContainerComponent>();
1995          for (SpecimenContainerComponent i : container)
1996            dst.container.add(i.copy());
1997        };
1998        return dst;
1999      }
2000
2001      protected Specimen typedCopy() {
2002        return copy();
2003      }
2004
2005      @Override
2006      public boolean equalsDeep(Base other) {
2007        if (!super.equalsDeep(other))
2008          return false;
2009        if (!(other instanceof Specimen))
2010          return false;
2011        Specimen o = (Specimen) other;
2012        return compareDeep(identifier, o.identifier, true) && compareDeep(accessionIdentifier, o.accessionIdentifier, true)
2013           && compareDeep(status, o.status, true) && compareDeep(type, o.type, true) && compareDeep(subject, o.subject, true)
2014           && compareDeep(receivedTime, o.receivedTime, true) && compareDeep(parent, o.parent, true) && compareDeep(collection, o.collection, true)
2015           && compareDeep(treatment, o.treatment, true) && compareDeep(container, o.container, true);
2016      }
2017
2018      @Override
2019      public boolean equalsShallow(Base other) {
2020        if (!super.equalsShallow(other))
2021          return false;
2022        if (!(other instanceof Specimen))
2023          return false;
2024        Specimen o = (Specimen) other;
2025        return compareValues(status, o.status, true) && compareValues(receivedTime, o.receivedTime, true);
2026      }
2027
2028      public boolean isEmpty() {
2029        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (accessionIdentifier == null || accessionIdentifier.isEmpty())
2030           && (status == null || status.isEmpty()) && (type == null || type.isEmpty()) && (subject == null || subject.isEmpty())
2031           && (receivedTime == null || receivedTime.isEmpty()) && (parent == null || parent.isEmpty())
2032           && (collection == null || collection.isEmpty()) && (treatment == null || treatment.isEmpty())
2033           && (container == null || container.isEmpty());
2034      }
2035
2036  @Override
2037  public ResourceType getResourceType() {
2038    return ResourceType.Specimen;
2039   }
2040
2041 /**
2042   * Search parameter: <b>collector</b>
2043   * <p>
2044   * Description: <b>Who collected the specimen</b><br>
2045   * Type: <b>reference</b><br>
2046   * Path: <b>Specimen.collection.collector</b><br>
2047   * </p>
2048   */
2049  @SearchParamDefinition(name="collector", path="Specimen.collection.collector", description="Who collected the specimen", type="reference" )
2050  public static final String SP_COLLECTOR = "collector";
2051 /**
2052   * <b>Fluent Client</b> search parameter constant for <b>collector</b>
2053   * <p>
2054   * Description: <b>Who collected the specimen</b><br>
2055   * Type: <b>reference</b><br>
2056   * Path: <b>Specimen.collection.collector</b><br>
2057   * </p>
2058   */
2059  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam COLLECTOR = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_COLLECTOR);
2060
2061/**
2062   * Constant for fluent queries to be used to add include statements. Specifies
2063   * the path value of "<b>Specimen:collector</b>".
2064   */
2065  public static final ca.uhn.fhir.model.api.Include INCLUDE_COLLECTOR = new ca.uhn.fhir.model.api.Include("Specimen:collector").toLocked();
2066
2067 /**
2068   * Search parameter: <b>container-id</b>
2069   * <p>
2070   * Description: <b>The unique identifier associated with the specimen container</b><br>
2071   * Type: <b>token</b><br>
2072   * Path: <b>Specimen.container.identifier</b><br>
2073   * </p>
2074   */
2075  @SearchParamDefinition(name="container-id", path="Specimen.container.identifier", description="The unique identifier associated with the specimen container", type="token" )
2076  public static final String SP_CONTAINER_ID = "container-id";
2077 /**
2078   * <b>Fluent Client</b> search parameter constant for <b>container-id</b>
2079   * <p>
2080   * Description: <b>The unique identifier associated with the specimen container</b><br>
2081   * Type: <b>token</b><br>
2082   * Path: <b>Specimen.container.identifier</b><br>
2083   * </p>
2084   */
2085  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CONTAINER_ID = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CONTAINER_ID);
2086
2087 /**
2088   * Search parameter: <b>patient</b>
2089   * <p>
2090   * Description: <b>The patient the specimen comes from</b><br>
2091   * Type: <b>reference</b><br>
2092   * Path: <b>Specimen.subject</b><br>
2093   * </p>
2094   */
2095  @SearchParamDefinition(name="patient", path="Specimen.subject", description="The patient the specimen comes from", type="reference" )
2096  public static final String SP_PATIENT = "patient";
2097 /**
2098   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
2099   * <p>
2100   * Description: <b>The patient the specimen comes from</b><br>
2101   * Type: <b>reference</b><br>
2102   * Path: <b>Specimen.subject</b><br>
2103   * </p>
2104   */
2105  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
2106
2107/**
2108   * Constant for fluent queries to be used to add include statements. Specifies
2109   * the path value of "<b>Specimen:patient</b>".
2110   */
2111  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("Specimen:patient").toLocked();
2112
2113 /**
2114   * Search parameter: <b>bodysite</b>
2115   * <p>
2116   * Description: <b>The code for the body site from where the specimen originated</b><br>
2117   * Type: <b>token</b><br>
2118   * Path: <b>Specimen.collection.bodySite</b><br>
2119   * </p>
2120   */
2121  @SearchParamDefinition(name="bodysite", path="Specimen.collection.bodySite", description="The code for the body site from where the specimen originated", type="token" )
2122  public static final String SP_BODYSITE = "bodysite";
2123 /**
2124   * <b>Fluent Client</b> search parameter constant for <b>bodysite</b>
2125   * <p>
2126   * Description: <b>The code for the body site from where the specimen originated</b><br>
2127   * Type: <b>token</b><br>
2128   * Path: <b>Specimen.collection.bodySite</b><br>
2129   * </p>
2130   */
2131  public static final ca.uhn.fhir.rest.gclient.TokenClientParam BODYSITE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_BODYSITE);
2132
2133 /**
2134   * Search parameter: <b>container</b>
2135   * <p>
2136   * Description: <b>The kind of specimen container</b><br>
2137   * Type: <b>token</b><br>
2138   * Path: <b>Specimen.container.type</b><br>
2139   * </p>
2140   */
2141  @SearchParamDefinition(name="container", path="Specimen.container.type", description="The kind of specimen container", type="token" )
2142  public static final String SP_CONTAINER = "container";
2143 /**
2144   * <b>Fluent Client</b> search parameter constant for <b>container</b>
2145   * <p>
2146   * Description: <b>The kind of specimen container</b><br>
2147   * Type: <b>token</b><br>
2148   * Path: <b>Specimen.container.type</b><br>
2149   * </p>
2150   */
2151  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CONTAINER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CONTAINER);
2152
2153 /**
2154   * Search parameter: <b>collected</b>
2155   * <p>
2156   * Description: <b>The date the specimen was collected</b><br>
2157   * Type: <b>date</b><br>
2158   * Path: <b>Specimen.collection.collected[x]</b><br>
2159   * </p>
2160   */
2161  @SearchParamDefinition(name="collected", path="Specimen.collection.collected", description="The date the specimen was collected", type="date" )
2162  public static final String SP_COLLECTED = "collected";
2163 /**
2164   * <b>Fluent Client</b> search parameter constant for <b>collected</b>
2165   * <p>
2166   * Description: <b>The date the specimen was collected</b><br>
2167   * Type: <b>date</b><br>
2168   * Path: <b>Specimen.collection.collected[x]</b><br>
2169   * </p>
2170   */
2171  public static final ca.uhn.fhir.rest.gclient.DateClientParam COLLECTED = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_COLLECTED);
2172
2173 /**
2174   * Search parameter: <b>subject</b>
2175   * <p>
2176   * Description: <b>The subject of the specimen</b><br>
2177   * Type: <b>reference</b><br>
2178   * Path: <b>Specimen.subject</b><br>
2179   * </p>
2180   */
2181  @SearchParamDefinition(name="subject", path="Specimen.subject", description="The subject of the specimen", type="reference" )
2182  public static final String SP_SUBJECT = "subject";
2183 /**
2184   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
2185   * <p>
2186   * Description: <b>The subject of the specimen</b><br>
2187   * Type: <b>reference</b><br>
2188   * Path: <b>Specimen.subject</b><br>
2189   * </p>
2190   */
2191  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
2192
2193/**
2194   * Constant for fluent queries to be used to add include statements. Specifies
2195   * the path value of "<b>Specimen:subject</b>".
2196   */
2197  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("Specimen:subject").toLocked();
2198
2199 /**
2200   * Search parameter: <b>accession</b>
2201   * <p>
2202   * Description: <b>The accession number associated with the specimen</b><br>
2203   * Type: <b>token</b><br>
2204   * Path: <b>Specimen.accessionIdentifier</b><br>
2205   * </p>
2206   */
2207  @SearchParamDefinition(name="accession", path="Specimen.accessionIdentifier", description="The accession number associated with the specimen", type="token" )
2208  public static final String SP_ACCESSION = "accession";
2209 /**
2210   * <b>Fluent Client</b> search parameter constant for <b>accession</b>
2211   * <p>
2212   * Description: <b>The accession number associated with the specimen</b><br>
2213   * Type: <b>token</b><br>
2214   * Path: <b>Specimen.accessionIdentifier</b><br>
2215   * </p>
2216   */
2217  public static final ca.uhn.fhir.rest.gclient.TokenClientParam ACCESSION = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_ACCESSION);
2218
2219 /**
2220   * Search parameter: <b>parent</b>
2221   * <p>
2222   * Description: <b>The parent of the specimen</b><br>
2223   * Type: <b>reference</b><br>
2224   * Path: <b>Specimen.parent</b><br>
2225   * </p>
2226   */
2227  @SearchParamDefinition(name="parent", path="Specimen.parent", description="The parent of the specimen", type="reference" )
2228  public static final String SP_PARENT = "parent";
2229 /**
2230   * <b>Fluent Client</b> search parameter constant for <b>parent</b>
2231   * <p>
2232   * Description: <b>The parent of the specimen</b><br>
2233   * Type: <b>reference</b><br>
2234   * Path: <b>Specimen.parent</b><br>
2235   * </p>
2236   */
2237  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PARENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PARENT);
2238
2239/**
2240   * Constant for fluent queries to be used to add include statements. Specifies
2241   * the path value of "<b>Specimen:parent</b>".
2242   */
2243  public static final ca.uhn.fhir.model.api.Include INCLUDE_PARENT = new ca.uhn.fhir.model.api.Include("Specimen:parent").toLocked();
2244
2245 /**
2246   * Search parameter: <b>type</b>
2247   * <p>
2248   * Description: <b>The specimen type</b><br>
2249   * Type: <b>token</b><br>
2250   * Path: <b>Specimen.type</b><br>
2251   * </p>
2252   */
2253  @SearchParamDefinition(name="type", path="Specimen.type", description="The specimen type", type="token" )
2254  public static final String SP_TYPE = "type";
2255 /**
2256   * <b>Fluent Client</b> search parameter constant for <b>type</b>
2257   * <p>
2258   * Description: <b>The specimen type</b><br>
2259   * Type: <b>token</b><br>
2260   * Path: <b>Specimen.type</b><br>
2261   * </p>
2262   */
2263  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_TYPE);
2264
2265 /**
2266   * Search parameter: <b>identifier</b>
2267   * <p>
2268   * Description: <b>The unique identifier associated with the specimen</b><br>
2269   * Type: <b>token</b><br>
2270   * Path: <b>Specimen.identifier</b><br>
2271   * </p>
2272   */
2273  @SearchParamDefinition(name="identifier", path="Specimen.identifier", description="The unique identifier associated with the specimen", type="token" )
2274  public static final String SP_IDENTIFIER = "identifier";
2275 /**
2276   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2277   * <p>
2278   * Description: <b>The unique identifier associated with the specimen</b><br>
2279   * Type: <b>token</b><br>
2280   * Path: <b>Specimen.identifier</b><br>
2281   * </p>
2282   */
2283  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
2284
2285
2286}