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