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