001package org.hl7.fhir.r4.model;
002
003import java.math.BigDecimal;
004
005/*
006  Copyright (c) 2011+, HL7, Inc.
007  All rights reserved.
008  
009  Redistribution and use in source and binary forms, with or without modification, 
010  are permitted provided that the following conditions are met:
011  
012   * Redistributions of source code must retain the above copyright notice, this 
013     list of conditions and the following disclaimer.
014   * Redistributions in binary form must reproduce the above copyright notice, 
015     this list of conditions and the following disclaimer in the documentation 
016     and/or other materials provided with the distribution.
017   * Neither the name of HL7 nor the names of its contributors may be used to 
018     endorse or promote products derived from this software without specific 
019     prior written permission.
020  
021  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
022  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
023  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
024  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
025  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
026  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
027  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
028  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
029  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
030  POSSIBILITY OF SUCH DAMAGE.
031  
032*/
033
034// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1
035import java.util.ArrayList;
036import java.util.List;
037
038import org.hl7.fhir.exceptions.FHIRException;
039import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
040import org.hl7.fhir.utilities.Utilities;
041
042import ca.uhn.fhir.model.api.annotation.Block;
043import ca.uhn.fhir.model.api.annotation.Child;
044import ca.uhn.fhir.model.api.annotation.Description;
045import ca.uhn.fhir.model.api.annotation.ResourceDef;
046
047/**
048 * A material substance originating from a biological entity intended to be
049 * transplanted or infused into another (possibly the same) biological entity.
050 */
051@ResourceDef(name = "BiologicallyDerivedProduct", profile = "http://hl7.org/fhir/StructureDefinition/BiologicallyDerivedProduct")
052public class BiologicallyDerivedProduct extends DomainResource {
053
054  public enum BiologicallyDerivedProductCategory {
055    /**
056     * A collection of tissues joined in a structural unit to serve a common
057     * function.
058     */
059    ORGAN,
060    /**
061     * An ensemble of similar cells and their extracellular matrix from the same
062     * origin that together carry out a specific function.
063     */
064    TISSUE,
065    /**
066     * Body fluid.
067     */
068    FLUID,
069    /**
070     * Collection of cells.
071     */
072    CELLS,
073    /**
074     * Biological agent of unspecified type.
075     */
076    BIOLOGICALAGENT,
077    /**
078     * added to help the parsers with the generic types
079     */
080    NULL;
081
082    public static BiologicallyDerivedProductCategory fromCode(String codeString) throws FHIRException {
083      if (codeString == null || "".equals(codeString))
084        return null;
085      if ("organ".equals(codeString))
086        return ORGAN;
087      if ("tissue".equals(codeString))
088        return TISSUE;
089      if ("fluid".equals(codeString))
090        return FLUID;
091      if ("cells".equals(codeString))
092        return CELLS;
093      if ("biologicalAgent".equals(codeString))
094        return BIOLOGICALAGENT;
095      if (Configuration.isAcceptInvalidEnums())
096        return null;
097      else
098        throw new FHIRException("Unknown BiologicallyDerivedProductCategory code '" + codeString + "'");
099    }
100
101    public String toCode() {
102      switch (this) {
103      case ORGAN:
104        return "organ";
105      case TISSUE:
106        return "tissue";
107      case FLUID:
108        return "fluid";
109      case CELLS:
110        return "cells";
111      case BIOLOGICALAGENT:
112        return "biologicalAgent";
113      case NULL:
114        return null;
115      default:
116        return "?";
117      }
118    }
119
120    public String getSystem() {
121      switch (this) {
122      case ORGAN:
123        return "http://hl7.org/fhir/product-category";
124      case TISSUE:
125        return "http://hl7.org/fhir/product-category";
126      case FLUID:
127        return "http://hl7.org/fhir/product-category";
128      case CELLS:
129        return "http://hl7.org/fhir/product-category";
130      case BIOLOGICALAGENT:
131        return "http://hl7.org/fhir/product-category";
132      case NULL:
133        return null;
134      default:
135        return "?";
136      }
137    }
138
139    public String getDefinition() {
140      switch (this) {
141      case ORGAN:
142        return "A collection of tissues joined in a structural unit to serve a common function.";
143      case TISSUE:
144        return "An ensemble of similar cells and their extracellular matrix from the same origin that together carry out a specific function.";
145      case FLUID:
146        return "Body fluid.";
147      case CELLS:
148        return "Collection of cells.";
149      case BIOLOGICALAGENT:
150        return "Biological agent of unspecified type.";
151      case NULL:
152        return null;
153      default:
154        return "?";
155      }
156    }
157
158    public String getDisplay() {
159      switch (this) {
160      case ORGAN:
161        return "Organ";
162      case TISSUE:
163        return "Tissue";
164      case FLUID:
165        return "Fluid";
166      case CELLS:
167        return "Cells";
168      case BIOLOGICALAGENT:
169        return "BiologicalAgent";
170      case NULL:
171        return null;
172      default:
173        return "?";
174      }
175    }
176  }
177
178  public static class BiologicallyDerivedProductCategoryEnumFactory
179      implements EnumFactory<BiologicallyDerivedProductCategory> {
180    public BiologicallyDerivedProductCategory fromCode(String codeString) throws IllegalArgumentException {
181      if (codeString == null || "".equals(codeString))
182        if (codeString == null || "".equals(codeString))
183          return null;
184      if ("organ".equals(codeString))
185        return BiologicallyDerivedProductCategory.ORGAN;
186      if ("tissue".equals(codeString))
187        return BiologicallyDerivedProductCategory.TISSUE;
188      if ("fluid".equals(codeString))
189        return BiologicallyDerivedProductCategory.FLUID;
190      if ("cells".equals(codeString))
191        return BiologicallyDerivedProductCategory.CELLS;
192      if ("biologicalAgent".equals(codeString))
193        return BiologicallyDerivedProductCategory.BIOLOGICALAGENT;
194      throw new IllegalArgumentException("Unknown BiologicallyDerivedProductCategory code '" + codeString + "'");
195    }
196
197    public Enumeration<BiologicallyDerivedProductCategory> fromType(PrimitiveType<?> code) throws FHIRException {
198      if (code == null)
199        return null;
200      if (code.isEmpty())
201        return new Enumeration<BiologicallyDerivedProductCategory>(this, BiologicallyDerivedProductCategory.NULL, code);
202      String codeString = code.asStringValue();
203      if (codeString == null || "".equals(codeString))
204        return new Enumeration<BiologicallyDerivedProductCategory>(this, BiologicallyDerivedProductCategory.NULL, code);
205      if ("organ".equals(codeString))
206        return new Enumeration<BiologicallyDerivedProductCategory>(this, BiologicallyDerivedProductCategory.ORGAN,
207            code);
208      if ("tissue".equals(codeString))
209        return new Enumeration<BiologicallyDerivedProductCategory>(this, BiologicallyDerivedProductCategory.TISSUE,
210            code);
211      if ("fluid".equals(codeString))
212        return new Enumeration<BiologicallyDerivedProductCategory>(this, BiologicallyDerivedProductCategory.FLUID,
213            code);
214      if ("cells".equals(codeString))
215        return new Enumeration<BiologicallyDerivedProductCategory>(this, BiologicallyDerivedProductCategory.CELLS,
216            code);
217      if ("biologicalAgent".equals(codeString))
218        return new Enumeration<BiologicallyDerivedProductCategory>(this,
219            BiologicallyDerivedProductCategory.BIOLOGICALAGENT, code);
220      throw new FHIRException("Unknown BiologicallyDerivedProductCategory code '" + codeString + "'");
221    }
222
223    public String toCode(BiologicallyDerivedProductCategory code) {
224      if (code == BiologicallyDerivedProductCategory.ORGAN)
225        return "organ";
226      if (code == BiologicallyDerivedProductCategory.TISSUE)
227        return "tissue";
228      if (code == BiologicallyDerivedProductCategory.FLUID)
229        return "fluid";
230      if (code == BiologicallyDerivedProductCategory.CELLS)
231        return "cells";
232      if (code == BiologicallyDerivedProductCategory.BIOLOGICALAGENT)
233        return "biologicalAgent";
234      return "?";
235    }
236
237    public String toSystem(BiologicallyDerivedProductCategory code) {
238      return code.getSystem();
239    }
240  }
241
242  public enum BiologicallyDerivedProductStatus {
243    /**
244     * Product is currently available for use.
245     */
246    AVAILABLE,
247    /**
248     * Product is not currently available for use.
249     */
250    UNAVAILABLE,
251    /**
252     * added to help the parsers with the generic types
253     */
254    NULL;
255
256    public static BiologicallyDerivedProductStatus fromCode(String codeString) throws FHIRException {
257      if (codeString == null || "".equals(codeString))
258        return null;
259      if ("available".equals(codeString))
260        return AVAILABLE;
261      if ("unavailable".equals(codeString))
262        return UNAVAILABLE;
263      if (Configuration.isAcceptInvalidEnums())
264        return null;
265      else
266        throw new FHIRException("Unknown BiologicallyDerivedProductStatus code '" + codeString + "'");
267    }
268
269    public String toCode() {
270      switch (this) {
271      case AVAILABLE:
272        return "available";
273      case UNAVAILABLE:
274        return "unavailable";
275      case NULL:
276        return null;
277      default:
278        return "?";
279      }
280    }
281
282    public String getSystem() {
283      switch (this) {
284      case AVAILABLE:
285        return "http://hl7.org/fhir/product-status";
286      case UNAVAILABLE:
287        return "http://hl7.org/fhir/product-status";
288      case NULL:
289        return null;
290      default:
291        return "?";
292      }
293    }
294
295    public String getDefinition() {
296      switch (this) {
297      case AVAILABLE:
298        return "Product is currently available for use.";
299      case UNAVAILABLE:
300        return "Product is not currently available for use.";
301      case NULL:
302        return null;
303      default:
304        return "?";
305      }
306    }
307
308    public String getDisplay() {
309      switch (this) {
310      case AVAILABLE:
311        return "Available";
312      case UNAVAILABLE:
313        return "Unavailable";
314      case NULL:
315        return null;
316      default:
317        return "?";
318      }
319    }
320  }
321
322  public static class BiologicallyDerivedProductStatusEnumFactory
323      implements EnumFactory<BiologicallyDerivedProductStatus> {
324    public BiologicallyDerivedProductStatus fromCode(String codeString) throws IllegalArgumentException {
325      if (codeString == null || "".equals(codeString))
326        if (codeString == null || "".equals(codeString))
327          return null;
328      if ("available".equals(codeString))
329        return BiologicallyDerivedProductStatus.AVAILABLE;
330      if ("unavailable".equals(codeString))
331        return BiologicallyDerivedProductStatus.UNAVAILABLE;
332      throw new IllegalArgumentException("Unknown BiologicallyDerivedProductStatus code '" + codeString + "'");
333    }
334
335    public Enumeration<BiologicallyDerivedProductStatus> fromType(PrimitiveType<?> code) throws FHIRException {
336      if (code == null)
337        return null;
338      if (code.isEmpty())
339        return new Enumeration<BiologicallyDerivedProductStatus>(this, BiologicallyDerivedProductStatus.NULL, code);
340      String codeString = code.asStringValue();
341      if (codeString == null || "".equals(codeString))
342        return new Enumeration<BiologicallyDerivedProductStatus>(this, BiologicallyDerivedProductStatus.NULL, code);
343      if ("available".equals(codeString))
344        return new Enumeration<BiologicallyDerivedProductStatus>(this, BiologicallyDerivedProductStatus.AVAILABLE,
345            code);
346      if ("unavailable".equals(codeString))
347        return new Enumeration<BiologicallyDerivedProductStatus>(this, BiologicallyDerivedProductStatus.UNAVAILABLE,
348            code);
349      throw new FHIRException("Unknown BiologicallyDerivedProductStatus code '" + codeString + "'");
350    }
351
352    public String toCode(BiologicallyDerivedProductStatus code) {
353      if (code == BiologicallyDerivedProductStatus.AVAILABLE)
354        return "available";
355      if (code == BiologicallyDerivedProductStatus.UNAVAILABLE)
356        return "unavailable";
357      return "?";
358    }
359
360    public String toSystem(BiologicallyDerivedProductStatus code) {
361      return code.getSystem();
362    }
363  }
364
365  public enum BiologicallyDerivedProductStorageScale {
366    /**
367     * Fahrenheit temperature scale.
368     */
369    FARENHEIT,
370    /**
371     * Celsius or centigrade temperature scale.
372     */
373    CELSIUS,
374    /**
375     * Kelvin absolute thermodynamic temperature scale.
376     */
377    KELVIN,
378    /**
379     * added to help the parsers with the generic types
380     */
381    NULL;
382
383    public static BiologicallyDerivedProductStorageScale fromCode(String codeString) throws FHIRException {
384      if (codeString == null || "".equals(codeString))
385        return null;
386      if ("farenheit".equals(codeString))
387        return FARENHEIT;
388      if ("celsius".equals(codeString))
389        return CELSIUS;
390      if ("kelvin".equals(codeString))
391        return KELVIN;
392      if (Configuration.isAcceptInvalidEnums())
393        return null;
394      else
395        throw new FHIRException("Unknown BiologicallyDerivedProductStorageScale code '" + codeString + "'");
396    }
397
398    public String toCode() {
399      switch (this) {
400      case FARENHEIT:
401        return "farenheit";
402      case CELSIUS:
403        return "celsius";
404      case KELVIN:
405        return "kelvin";
406      case NULL:
407        return null;
408      default:
409        return "?";
410      }
411    }
412
413    public String getSystem() {
414      switch (this) {
415      case FARENHEIT:
416        return "http://hl7.org/fhir/product-storage-scale";
417      case CELSIUS:
418        return "http://hl7.org/fhir/product-storage-scale";
419      case KELVIN:
420        return "http://hl7.org/fhir/product-storage-scale";
421      case NULL:
422        return null;
423      default:
424        return "?";
425      }
426    }
427
428    public String getDefinition() {
429      switch (this) {
430      case FARENHEIT:
431        return "Fahrenheit temperature scale.";
432      case CELSIUS:
433        return "Celsius or centigrade temperature scale.";
434      case KELVIN:
435        return "Kelvin absolute thermodynamic temperature scale.";
436      case NULL:
437        return null;
438      default:
439        return "?";
440      }
441    }
442
443    public String getDisplay() {
444      switch (this) {
445      case FARENHEIT:
446        return "Fahrenheit";
447      case CELSIUS:
448        return "Celsius";
449      case KELVIN:
450        return "Kelvin";
451      case NULL:
452        return null;
453      default:
454        return "?";
455      }
456    }
457  }
458
459  public static class BiologicallyDerivedProductStorageScaleEnumFactory
460      implements EnumFactory<BiologicallyDerivedProductStorageScale> {
461    public BiologicallyDerivedProductStorageScale fromCode(String codeString) throws IllegalArgumentException {
462      if (codeString == null || "".equals(codeString))
463        if (codeString == null || "".equals(codeString))
464          return null;
465      if ("farenheit".equals(codeString))
466        return BiologicallyDerivedProductStorageScale.FARENHEIT;
467      if ("celsius".equals(codeString))
468        return BiologicallyDerivedProductStorageScale.CELSIUS;
469      if ("kelvin".equals(codeString))
470        return BiologicallyDerivedProductStorageScale.KELVIN;
471      throw new IllegalArgumentException("Unknown BiologicallyDerivedProductStorageScale code '" + codeString + "'");
472    }
473
474    public Enumeration<BiologicallyDerivedProductStorageScale> fromType(PrimitiveType<?> code) throws FHIRException {
475      if (code == null)
476        return null;
477      if (code.isEmpty())
478        return new Enumeration<BiologicallyDerivedProductStorageScale>(this,
479            BiologicallyDerivedProductStorageScale.NULL, code);
480      String codeString = code.asStringValue();
481      if (codeString == null || "".equals(codeString))
482        return new Enumeration<BiologicallyDerivedProductStorageScale>(this,
483            BiologicallyDerivedProductStorageScale.NULL, code);
484      if ("farenheit".equals(codeString))
485        return new Enumeration<BiologicallyDerivedProductStorageScale>(this,
486            BiologicallyDerivedProductStorageScale.FARENHEIT, code);
487      if ("celsius".equals(codeString))
488        return new Enumeration<BiologicallyDerivedProductStorageScale>(this,
489            BiologicallyDerivedProductStorageScale.CELSIUS, code);
490      if ("kelvin".equals(codeString))
491        return new Enumeration<BiologicallyDerivedProductStorageScale>(this,
492            BiologicallyDerivedProductStorageScale.KELVIN, code);
493      throw new FHIRException("Unknown BiologicallyDerivedProductStorageScale code '" + codeString + "'");
494    }
495
496    public String toCode(BiologicallyDerivedProductStorageScale code) {
497      if (code == BiologicallyDerivedProductStorageScale.FARENHEIT)
498        return "farenheit";
499      if (code == BiologicallyDerivedProductStorageScale.CELSIUS)
500        return "celsius";
501      if (code == BiologicallyDerivedProductStorageScale.KELVIN)
502        return "kelvin";
503      return "?";
504    }
505
506    public String toSystem(BiologicallyDerivedProductStorageScale code) {
507      return code.getSystem();
508    }
509  }
510
511  @Block()
512  public static class BiologicallyDerivedProductCollectionComponent extends BackboneElement
513      implements IBaseBackboneElement {
514    /**
515     * Healthcare professional who is performing the collection.
516     */
517    @Child(name = "collector", type = { Practitioner.class,
518        PractitionerRole.class }, order = 1, min = 0, max = 1, modifier = false, summary = false)
519    @Description(shortDefinition = "Individual performing collection", formalDefinition = "Healthcare professional who is performing the collection.")
520    protected Reference collector;
521
522    /**
523     * The actual object that is the target of the reference (Healthcare
524     * professional who is performing the collection.)
525     */
526    protected Resource collectorTarget;
527
528    /**
529     * The patient or entity, such as a hospital or vendor in the case of a
530     * processed/manipulated/manufactured product, providing the product.
531     */
532    @Child(name = "source", type = { Patient.class,
533        Organization.class }, order = 2, min = 0, max = 1, modifier = false, summary = false)
534    @Description(shortDefinition = "Who is product from", formalDefinition = "The patient or entity, such as a hospital or vendor in the case of a processed/manipulated/manufactured product, providing the product.")
535    protected Reference source;
536
537    /**
538     * The actual object that is the target of the reference (The patient or entity,
539     * such as a hospital or vendor in the case of a
540     * processed/manipulated/manufactured product, providing the product.)
541     */
542    protected Resource sourceTarget;
543
544    /**
545     * Time of product collection.
546     */
547    @Child(name = "collected", type = { DateTimeType.class,
548        Period.class }, order = 3, min = 0, max = 1, modifier = false, summary = false)
549    @Description(shortDefinition = "Time of product collection", formalDefinition = "Time of product collection.")
550    protected Type collected;
551
552    private static final long serialVersionUID = 892130089L;
553
554    /**
555     * Constructor
556     */
557    public BiologicallyDerivedProductCollectionComponent() {
558      super();
559    }
560
561    /**
562     * @return {@link #collector} (Healthcare professional who is performing the
563     *         collection.)
564     */
565    public Reference getCollector() {
566      if (this.collector == null)
567        if (Configuration.errorOnAutoCreate())
568          throw new Error("Attempt to auto-create BiologicallyDerivedProductCollectionComponent.collector");
569        else if (Configuration.doAutoCreate())
570          this.collector = new Reference(); // cc
571      return this.collector;
572    }
573
574    public boolean hasCollector() {
575      return this.collector != null && !this.collector.isEmpty();
576    }
577
578    /**
579     * @param value {@link #collector} (Healthcare professional who is performing
580     *              the collection.)
581     */
582    public BiologicallyDerivedProductCollectionComponent setCollector(Reference value) {
583      this.collector = value;
584      return this;
585    }
586
587    /**
588     * @return {@link #collector} The actual object that is the target of the
589     *         reference. The reference library doesn't populate this, but you can
590     *         use it to hold the resource if you resolve it. (Healthcare
591     *         professional who is performing the collection.)
592     */
593    public Resource getCollectorTarget() {
594      return this.collectorTarget;
595    }
596
597    /**
598     * @param value {@link #collector} The actual object that is the target of the
599     *              reference. The reference library doesn't use these, but you can
600     *              use it to hold the resource if you resolve it. (Healthcare
601     *              professional who is performing the collection.)
602     */
603    public BiologicallyDerivedProductCollectionComponent setCollectorTarget(Resource value) {
604      this.collectorTarget = value;
605      return this;
606    }
607
608    /**
609     * @return {@link #source} (The patient or entity, such as a hospital or vendor
610     *         in the case of a processed/manipulated/manufactured product,
611     *         providing the product.)
612     */
613    public Reference getSource() {
614      if (this.source == null)
615        if (Configuration.errorOnAutoCreate())
616          throw new Error("Attempt to auto-create BiologicallyDerivedProductCollectionComponent.source");
617        else if (Configuration.doAutoCreate())
618          this.source = new Reference(); // cc
619      return this.source;
620    }
621
622    public boolean hasSource() {
623      return this.source != null && !this.source.isEmpty();
624    }
625
626    /**
627     * @param value {@link #source} (The patient or entity, such as a hospital or
628     *              vendor in the case of a processed/manipulated/manufactured
629     *              product, providing the product.)
630     */
631    public BiologicallyDerivedProductCollectionComponent setSource(Reference value) {
632      this.source = value;
633      return this;
634    }
635
636    /**
637     * @return {@link #source} The actual object that is the target of the
638     *         reference. The reference library doesn't populate this, but you can
639     *         use it to hold the resource if you resolve it. (The patient or
640     *         entity, such as a hospital or vendor in the case of a
641     *         processed/manipulated/manufactured product, providing the product.)
642     */
643    public Resource getSourceTarget() {
644      return this.sourceTarget;
645    }
646
647    /**
648     * @param value {@link #source} The actual object that is the target of the
649     *              reference. The reference library doesn't use these, but you can
650     *              use it to hold the resource if you resolve it. (The patient or
651     *              entity, such as a hospital or vendor in the case of a
652     *              processed/manipulated/manufactured product, providing the
653     *              product.)
654     */
655    public BiologicallyDerivedProductCollectionComponent setSourceTarget(Resource value) {
656      this.sourceTarget = value;
657      return this;
658    }
659
660    /**
661     * @return {@link #collected} (Time of product collection.)
662     */
663    public Type getCollected() {
664      return this.collected;
665    }
666
667    /**
668     * @return {@link #collected} (Time of product collection.)
669     */
670    public DateTimeType getCollectedDateTimeType() throws FHIRException {
671      if (this.collected == null)
672        this.collected = new DateTimeType();
673      if (!(this.collected instanceof DateTimeType))
674        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "
675            + this.collected.getClass().getName() + " was encountered");
676      return (DateTimeType) this.collected;
677    }
678
679    public boolean hasCollectedDateTimeType() {
680      return this != null && this.collected instanceof DateTimeType;
681    }
682
683    /**
684     * @return {@link #collected} (Time of product collection.)
685     */
686    public Period getCollectedPeriod() throws FHIRException {
687      if (this.collected == null)
688        this.collected = new Period();
689      if (!(this.collected instanceof Period))
690        throw new FHIRException("Type mismatch: the type Period was expected, but "
691            + this.collected.getClass().getName() + " was encountered");
692      return (Period) this.collected;
693    }
694
695    public boolean hasCollectedPeriod() {
696      return this != null && this.collected instanceof Period;
697    }
698
699    public boolean hasCollected() {
700      return this.collected != null && !this.collected.isEmpty();
701    }
702
703    /**
704     * @param value {@link #collected} (Time of product collection.)
705     */
706    public BiologicallyDerivedProductCollectionComponent setCollected(Type value) {
707      if (value != null && !(value instanceof DateTimeType || value instanceof Period))
708        throw new Error(
709            "Not the right type for BiologicallyDerivedProduct.collection.collected[x]: " + value.fhirType());
710      this.collected = value;
711      return this;
712    }
713
714    protected void listChildren(List<Property> children) {
715      super.listChildren(children);
716      children.add(new Property("collector", "Reference(Practitioner|PractitionerRole)",
717          "Healthcare professional who is performing the collection.", 0, 1, collector));
718      children.add(new Property("source", "Reference(Patient|Organization)",
719          "The patient or entity, such as a hospital or vendor in the case of a processed/manipulated/manufactured product, providing the product.",
720          0, 1, source));
721      children.add(new Property("collected[x]", "dateTime|Period", "Time of product collection.", 0, 1, collected));
722    }
723
724    @Override
725    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
726      switch (_hash) {
727      case 1883491469:
728        /* collector */ return new Property("collector", "Reference(Practitioner|PractitionerRole)",
729            "Healthcare professional who is performing the collection.", 0, 1, collector);
730      case -896505829:
731        /* source */ return new Property("source", "Reference(Patient|Organization)",
732            "The patient or entity, such as a hospital or vendor in the case of a processed/manipulated/manufactured product, providing the product.",
733            0, 1, source);
734      case 1632037015:
735        /* collected[x] */ return new Property("collected[x]", "dateTime|Period", "Time of product collection.", 0, 1,
736            collected);
737      case 1883491145:
738        /* collected */ return new Property("collected[x]", "dateTime|Period", "Time of product collection.", 0, 1,
739            collected);
740      case 2005009924:
741        /* collectedDateTime */ return new Property("collected[x]", "dateTime|Period", "Time of product collection.", 0,
742            1, collected);
743      case 653185642:
744        /* collectedPeriod */ return new Property("collected[x]", "dateTime|Period", "Time of product collection.", 0,
745            1, collected);
746      default:
747        return super.getNamedProperty(_hash, _name, _checkValid);
748      }
749
750    }
751
752    @Override
753    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
754      switch (hash) {
755      case 1883491469:
756        /* collector */ return this.collector == null ? new Base[0] : new Base[] { this.collector }; // Reference
757      case -896505829:
758        /* source */ return this.source == null ? new Base[0] : new Base[] { this.source }; // Reference
759      case 1883491145:
760        /* collected */ return this.collected == null ? new Base[0] : new Base[] { this.collected }; // Type
761      default:
762        return super.getProperty(hash, name, checkValid);
763      }
764
765    }
766
767    @Override
768    public Base setProperty(int hash, String name, Base value) throws FHIRException {
769      switch (hash) {
770      case 1883491469: // collector
771        this.collector = castToReference(value); // Reference
772        return value;
773      case -896505829: // source
774        this.source = castToReference(value); // Reference
775        return value;
776      case 1883491145: // collected
777        this.collected = castToType(value); // Type
778        return value;
779      default:
780        return super.setProperty(hash, name, value);
781      }
782
783    }
784
785    @Override
786    public Base setProperty(String name, Base value) throws FHIRException {
787      if (name.equals("collector")) {
788        this.collector = castToReference(value); // Reference
789      } else if (name.equals("source")) {
790        this.source = castToReference(value); // Reference
791      } else if (name.equals("collected[x]")) {
792        this.collected = castToType(value); // Type
793      } else
794        return super.setProperty(name, value);
795      return value;
796    }
797
798    @Override
799    public Base makeProperty(int hash, String name) throws FHIRException {
800      switch (hash) {
801      case 1883491469:
802        return getCollector();
803      case -896505829:
804        return getSource();
805      case 1632037015:
806        return getCollected();
807      case 1883491145:
808        return getCollected();
809      default:
810        return super.makeProperty(hash, name);
811      }
812
813    }
814
815    @Override
816    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
817      switch (hash) {
818      case 1883491469:
819        /* collector */ return new String[] { "Reference" };
820      case -896505829:
821        /* source */ return new String[] { "Reference" };
822      case 1883491145:
823        /* collected */ return new String[] { "dateTime", "Period" };
824      default:
825        return super.getTypesForProperty(hash, name);
826      }
827
828    }
829
830    @Override
831    public Base addChild(String name) throws FHIRException {
832      if (name.equals("collector")) {
833        this.collector = new Reference();
834        return this.collector;
835      } else if (name.equals("source")) {
836        this.source = new Reference();
837        return this.source;
838      } else if (name.equals("collectedDateTime")) {
839        this.collected = new DateTimeType();
840        return this.collected;
841      } else if (name.equals("collectedPeriod")) {
842        this.collected = new Period();
843        return this.collected;
844      } else
845        return super.addChild(name);
846    }
847
848    public BiologicallyDerivedProductCollectionComponent copy() {
849      BiologicallyDerivedProductCollectionComponent dst = new BiologicallyDerivedProductCollectionComponent();
850      copyValues(dst);
851      return dst;
852    }
853
854    public void copyValues(BiologicallyDerivedProductCollectionComponent dst) {
855      super.copyValues(dst);
856      dst.collector = collector == null ? null : collector.copy();
857      dst.source = source == null ? null : source.copy();
858      dst.collected = collected == null ? null : collected.copy();
859    }
860
861    @Override
862    public boolean equalsDeep(Base other_) {
863      if (!super.equalsDeep(other_))
864        return false;
865      if (!(other_ instanceof BiologicallyDerivedProductCollectionComponent))
866        return false;
867      BiologicallyDerivedProductCollectionComponent o = (BiologicallyDerivedProductCollectionComponent) other_;
868      return compareDeep(collector, o.collector, true) && compareDeep(source, o.source, true)
869          && compareDeep(collected, o.collected, true);
870    }
871
872    @Override
873    public boolean equalsShallow(Base other_) {
874      if (!super.equalsShallow(other_))
875        return false;
876      if (!(other_ instanceof BiologicallyDerivedProductCollectionComponent))
877        return false;
878      BiologicallyDerivedProductCollectionComponent o = (BiologicallyDerivedProductCollectionComponent) other_;
879      return true;
880    }
881
882    public boolean isEmpty() {
883      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(collector, source, collected);
884    }
885
886    public String fhirType() {
887      return "BiologicallyDerivedProduct.collection";
888
889    }
890
891  }
892
893  @Block()
894  public static class BiologicallyDerivedProductProcessingComponent extends BackboneElement
895      implements IBaseBackboneElement {
896    /**
897     * Description of of processing.
898     */
899    @Child(name = "description", type = {
900        StringType.class }, order = 1, min = 0, max = 1, modifier = false, summary = false)
901    @Description(shortDefinition = "Description of of processing", formalDefinition = "Description of of processing.")
902    protected StringType description;
903
904    /**
905     * Procesing code.
906     */
907    @Child(name = "procedure", type = {
908        CodeableConcept.class }, order = 2, min = 0, max = 1, modifier = false, summary = false)
909    @Description(shortDefinition = "Procesing code", formalDefinition = "Procesing code.")
910    @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/procedure-code")
911    protected CodeableConcept procedure;
912
913    /**
914     * Substance added during processing.
915     */
916    @Child(name = "additive", type = {
917        Substance.class }, order = 3, min = 0, max = 1, modifier = false, summary = false)
918    @Description(shortDefinition = "Substance added during processing", formalDefinition = "Substance added during processing.")
919    protected Reference additive;
920
921    /**
922     * The actual object that is the target of the reference (Substance added during
923     * processing.)
924     */
925    protected Substance additiveTarget;
926
927    /**
928     * Time of processing.
929     */
930    @Child(name = "time", type = { DateTimeType.class,
931        Period.class }, order = 4, min = 0, max = 1, modifier = false, summary = false)
932    @Description(shortDefinition = "Time of processing", formalDefinition = "Time of processing.")
933    protected Type time;
934
935    private static final long serialVersionUID = -1007041216L;
936
937    /**
938     * Constructor
939     */
940    public BiologicallyDerivedProductProcessingComponent() {
941      super();
942    }
943
944    /**
945     * @return {@link #description} (Description of of processing.). This is the
946     *         underlying object with id, value and extensions. The accessor
947     *         "getDescription" gives direct access to the value
948     */
949    public StringType getDescriptionElement() {
950      if (this.description == null)
951        if (Configuration.errorOnAutoCreate())
952          throw new Error("Attempt to auto-create BiologicallyDerivedProductProcessingComponent.description");
953        else if (Configuration.doAutoCreate())
954          this.description = new StringType(); // bb
955      return this.description;
956    }
957
958    public boolean hasDescriptionElement() {
959      return this.description != null && !this.description.isEmpty();
960    }
961
962    public boolean hasDescription() {
963      return this.description != null && !this.description.isEmpty();
964    }
965
966    /**
967     * @param value {@link #description} (Description of of processing.). This is
968     *              the underlying object with id, value and extensions. The
969     *              accessor "getDescription" gives direct access to the value
970     */
971    public BiologicallyDerivedProductProcessingComponent setDescriptionElement(StringType value) {
972      this.description = value;
973      return this;
974    }
975
976    /**
977     * @return Description of of processing.
978     */
979    public String getDescription() {
980      return this.description == null ? null : this.description.getValue();
981    }
982
983    /**
984     * @param value Description of of processing.
985     */
986    public BiologicallyDerivedProductProcessingComponent setDescription(String value) {
987      if (Utilities.noString(value))
988        this.description = null;
989      else {
990        if (this.description == null)
991          this.description = new StringType();
992        this.description.setValue(value);
993      }
994      return this;
995    }
996
997    /**
998     * @return {@link #procedure} (Procesing code.)
999     */
1000    public CodeableConcept getProcedure() {
1001      if (this.procedure == null)
1002        if (Configuration.errorOnAutoCreate())
1003          throw new Error("Attempt to auto-create BiologicallyDerivedProductProcessingComponent.procedure");
1004        else if (Configuration.doAutoCreate())
1005          this.procedure = new CodeableConcept(); // cc
1006      return this.procedure;
1007    }
1008
1009    public boolean hasProcedure() {
1010      return this.procedure != null && !this.procedure.isEmpty();
1011    }
1012
1013    /**
1014     * @param value {@link #procedure} (Procesing code.)
1015     */
1016    public BiologicallyDerivedProductProcessingComponent setProcedure(CodeableConcept value) {
1017      this.procedure = value;
1018      return this;
1019    }
1020
1021    /**
1022     * @return {@link #additive} (Substance added during processing.)
1023     */
1024    public Reference getAdditive() {
1025      if (this.additive == null)
1026        if (Configuration.errorOnAutoCreate())
1027          throw new Error("Attempt to auto-create BiologicallyDerivedProductProcessingComponent.additive");
1028        else if (Configuration.doAutoCreate())
1029          this.additive = new Reference(); // cc
1030      return this.additive;
1031    }
1032
1033    public boolean hasAdditive() {
1034      return this.additive != null && !this.additive.isEmpty();
1035    }
1036
1037    /**
1038     * @param value {@link #additive} (Substance added during processing.)
1039     */
1040    public BiologicallyDerivedProductProcessingComponent setAdditive(Reference value) {
1041      this.additive = value;
1042      return this;
1043    }
1044
1045    /**
1046     * @return {@link #additive} The actual object that is the target of the
1047     *         reference. The reference library doesn't populate this, but you can
1048     *         use it to hold the resource if you resolve it. (Substance added
1049     *         during processing.)
1050     */
1051    public Substance getAdditiveTarget() {
1052      if (this.additiveTarget == null)
1053        if (Configuration.errorOnAutoCreate())
1054          throw new Error("Attempt to auto-create BiologicallyDerivedProductProcessingComponent.additive");
1055        else if (Configuration.doAutoCreate())
1056          this.additiveTarget = new Substance(); // aa
1057      return this.additiveTarget;
1058    }
1059
1060    /**
1061     * @param value {@link #additive} The actual object that is the target of the
1062     *              reference. The reference library doesn't use these, but you can
1063     *              use it to hold the resource if you resolve it. (Substance added
1064     *              during processing.)
1065     */
1066    public BiologicallyDerivedProductProcessingComponent setAdditiveTarget(Substance value) {
1067      this.additiveTarget = value;
1068      return this;
1069    }
1070
1071    /**
1072     * @return {@link #time} (Time of processing.)
1073     */
1074    public Type getTime() {
1075      return this.time;
1076    }
1077
1078    /**
1079     * @return {@link #time} (Time of processing.)
1080     */
1081    public DateTimeType getTimeDateTimeType() throws FHIRException {
1082      if (this.time == null)
1083        this.time = new DateTimeType();
1084      if (!(this.time instanceof DateTimeType))
1085        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "
1086            + this.time.getClass().getName() + " was encountered");
1087      return (DateTimeType) this.time;
1088    }
1089
1090    public boolean hasTimeDateTimeType() {
1091      return this != null && this.time instanceof DateTimeType;
1092    }
1093
1094    /**
1095     * @return {@link #time} (Time of processing.)
1096     */
1097    public Period getTimePeriod() throws FHIRException {
1098      if (this.time == null)
1099        this.time = new Period();
1100      if (!(this.time instanceof Period))
1101        throw new FHIRException(
1102            "Type mismatch: the type Period was expected, but " + this.time.getClass().getName() + " was encountered");
1103      return (Period) this.time;
1104    }
1105
1106    public boolean hasTimePeriod() {
1107      return this != null && this.time instanceof Period;
1108    }
1109
1110    public boolean hasTime() {
1111      return this.time != null && !this.time.isEmpty();
1112    }
1113
1114    /**
1115     * @param value {@link #time} (Time of processing.)
1116     */
1117    public BiologicallyDerivedProductProcessingComponent setTime(Type value) {
1118      if (value != null && !(value instanceof DateTimeType || value instanceof Period))
1119        throw new Error("Not the right type for BiologicallyDerivedProduct.processing.time[x]: " + value.fhirType());
1120      this.time = value;
1121      return this;
1122    }
1123
1124    protected void listChildren(List<Property> children) {
1125      super.listChildren(children);
1126      children.add(new Property("description", "string", "Description of of processing.", 0, 1, description));
1127      children.add(new Property("procedure", "CodeableConcept", "Procesing code.", 0, 1, procedure));
1128      children
1129          .add(new Property("additive", "Reference(Substance)", "Substance added during processing.", 0, 1, additive));
1130      children.add(new Property("time[x]", "dateTime|Period", "Time of processing.", 0, 1, time));
1131    }
1132
1133    @Override
1134    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1135      switch (_hash) {
1136      case -1724546052:
1137        /* description */ return new Property("description", "string", "Description of of processing.", 0, 1,
1138            description);
1139      case -1095204141:
1140        /* procedure */ return new Property("procedure", "CodeableConcept", "Procesing code.", 0, 1, procedure);
1141      case -1226589236:
1142        /* additive */ return new Property("additive", "Reference(Substance)", "Substance added during processing.", 0,
1143            1, additive);
1144      case -1313930605:
1145        /* time[x] */ return new Property("time[x]", "dateTime|Period", "Time of processing.", 0, 1, time);
1146      case 3560141:
1147        /* time */ return new Property("time[x]", "dateTime|Period", "Time of processing.", 0, 1, time);
1148      case 2135345544:
1149        /* timeDateTime */ return new Property("time[x]", "dateTime|Period", "Time of processing.", 0, 1, time);
1150      case 693544686:
1151        /* timePeriod */ return new Property("time[x]", "dateTime|Period", "Time of processing.", 0, 1, time);
1152      default:
1153        return super.getNamedProperty(_hash, _name, _checkValid);
1154      }
1155
1156    }
1157
1158    @Override
1159    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1160      switch (hash) {
1161      case -1724546052:
1162        /* description */ return this.description == null ? new Base[0] : new Base[] { this.description }; // StringType
1163      case -1095204141:
1164        /* procedure */ return this.procedure == null ? new Base[0] : new Base[] { this.procedure }; // CodeableConcept
1165      case -1226589236:
1166        /* additive */ return this.additive == null ? new Base[0] : new Base[] { this.additive }; // Reference
1167      case 3560141:
1168        /* time */ return this.time == null ? new Base[0] : new Base[] { this.time }; // Type
1169      default:
1170        return super.getProperty(hash, name, checkValid);
1171      }
1172
1173    }
1174
1175    @Override
1176    public Base setProperty(int hash, String name, Base value) throws FHIRException {
1177      switch (hash) {
1178      case -1724546052: // description
1179        this.description = castToString(value); // StringType
1180        return value;
1181      case -1095204141: // procedure
1182        this.procedure = castToCodeableConcept(value); // CodeableConcept
1183        return value;
1184      case -1226589236: // additive
1185        this.additive = castToReference(value); // Reference
1186        return value;
1187      case 3560141: // time
1188        this.time = castToType(value); // Type
1189        return value;
1190      default:
1191        return super.setProperty(hash, name, value);
1192      }
1193
1194    }
1195
1196    @Override
1197    public Base setProperty(String name, Base value) throws FHIRException {
1198      if (name.equals("description")) {
1199        this.description = castToString(value); // StringType
1200      } else if (name.equals("procedure")) {
1201        this.procedure = castToCodeableConcept(value); // CodeableConcept
1202      } else if (name.equals("additive")) {
1203        this.additive = castToReference(value); // Reference
1204      } else if (name.equals("time[x]")) {
1205        this.time = castToType(value); // Type
1206      } else
1207        return super.setProperty(name, value);
1208      return value;
1209    }
1210
1211    @Override
1212    public Base makeProperty(int hash, String name) throws FHIRException {
1213      switch (hash) {
1214      case -1724546052:
1215        return getDescriptionElement();
1216      case -1095204141:
1217        return getProcedure();
1218      case -1226589236:
1219        return getAdditive();
1220      case -1313930605:
1221        return getTime();
1222      case 3560141:
1223        return getTime();
1224      default:
1225        return super.makeProperty(hash, name);
1226      }
1227
1228    }
1229
1230    @Override
1231    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1232      switch (hash) {
1233      case -1724546052:
1234        /* description */ return new String[] { "string" };
1235      case -1095204141:
1236        /* procedure */ return new String[] { "CodeableConcept" };
1237      case -1226589236:
1238        /* additive */ return new String[] { "Reference" };
1239      case 3560141:
1240        /* time */ return new String[] { "dateTime", "Period" };
1241      default:
1242        return super.getTypesForProperty(hash, name);
1243      }
1244
1245    }
1246
1247    @Override
1248    public Base addChild(String name) throws FHIRException {
1249      if (name.equals("description")) {
1250        throw new FHIRException("Cannot call addChild on a singleton property BiologicallyDerivedProduct.description");
1251      } else if (name.equals("procedure")) {
1252        this.procedure = new CodeableConcept();
1253        return this.procedure;
1254      } else if (name.equals("additive")) {
1255        this.additive = new Reference();
1256        return this.additive;
1257      } else if (name.equals("timeDateTime")) {
1258        this.time = new DateTimeType();
1259        return this.time;
1260      } else if (name.equals("timePeriod")) {
1261        this.time = new Period();
1262        return this.time;
1263      } else
1264        return super.addChild(name);
1265    }
1266
1267    public BiologicallyDerivedProductProcessingComponent copy() {
1268      BiologicallyDerivedProductProcessingComponent dst = new BiologicallyDerivedProductProcessingComponent();
1269      copyValues(dst);
1270      return dst;
1271    }
1272
1273    public void copyValues(BiologicallyDerivedProductProcessingComponent dst) {
1274      super.copyValues(dst);
1275      dst.description = description == null ? null : description.copy();
1276      dst.procedure = procedure == null ? null : procedure.copy();
1277      dst.additive = additive == null ? null : additive.copy();
1278      dst.time = time == null ? null : time.copy();
1279    }
1280
1281    @Override
1282    public boolean equalsDeep(Base other_) {
1283      if (!super.equalsDeep(other_))
1284        return false;
1285      if (!(other_ instanceof BiologicallyDerivedProductProcessingComponent))
1286        return false;
1287      BiologicallyDerivedProductProcessingComponent o = (BiologicallyDerivedProductProcessingComponent) other_;
1288      return compareDeep(description, o.description, true) && compareDeep(procedure, o.procedure, true)
1289          && compareDeep(additive, o.additive, true) && compareDeep(time, o.time, true);
1290    }
1291
1292    @Override
1293    public boolean equalsShallow(Base other_) {
1294      if (!super.equalsShallow(other_))
1295        return false;
1296      if (!(other_ instanceof BiologicallyDerivedProductProcessingComponent))
1297        return false;
1298      BiologicallyDerivedProductProcessingComponent o = (BiologicallyDerivedProductProcessingComponent) other_;
1299      return compareValues(description, o.description, true);
1300    }
1301
1302    public boolean isEmpty() {
1303      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(description, procedure, additive, time);
1304    }
1305
1306    public String fhirType() {
1307      return "BiologicallyDerivedProduct.processing";
1308
1309    }
1310
1311  }
1312
1313  @Block()
1314  public static class BiologicallyDerivedProductManipulationComponent extends BackboneElement
1315      implements IBaseBackboneElement {
1316    /**
1317     * Description of manipulation.
1318     */
1319    @Child(name = "description", type = {
1320        StringType.class }, order = 1, min = 0, max = 1, modifier = false, summary = false)
1321    @Description(shortDefinition = "Description of manipulation", formalDefinition = "Description of manipulation.")
1322    protected StringType description;
1323
1324    /**
1325     * Time of manipulation.
1326     */
1327    @Child(name = "time", type = { DateTimeType.class,
1328        Period.class }, order = 2, min = 0, max = 1, modifier = false, summary = false)
1329    @Description(shortDefinition = "Time of manipulation", formalDefinition = "Time of manipulation.")
1330    protected Type time;
1331
1332    private static final long serialVersionUID = 717201078L;
1333
1334    /**
1335     * Constructor
1336     */
1337    public BiologicallyDerivedProductManipulationComponent() {
1338      super();
1339    }
1340
1341    /**
1342     * @return {@link #description} (Description of manipulation.). This is the
1343     *         underlying object with id, value and extensions. The accessor
1344     *         "getDescription" gives direct access to the value
1345     */
1346    public StringType getDescriptionElement() {
1347      if (this.description == null)
1348        if (Configuration.errorOnAutoCreate())
1349          throw new Error("Attempt to auto-create BiologicallyDerivedProductManipulationComponent.description");
1350        else if (Configuration.doAutoCreate())
1351          this.description = new StringType(); // bb
1352      return this.description;
1353    }
1354
1355    public boolean hasDescriptionElement() {
1356      return this.description != null && !this.description.isEmpty();
1357    }
1358
1359    public boolean hasDescription() {
1360      return this.description != null && !this.description.isEmpty();
1361    }
1362
1363    /**
1364     * @param value {@link #description} (Description of manipulation.). This is the
1365     *              underlying object with id, value and extensions. The accessor
1366     *              "getDescription" gives direct access to the value
1367     */
1368    public BiologicallyDerivedProductManipulationComponent setDescriptionElement(StringType value) {
1369      this.description = value;
1370      return this;
1371    }
1372
1373    /**
1374     * @return Description of manipulation.
1375     */
1376    public String getDescription() {
1377      return this.description == null ? null : this.description.getValue();
1378    }
1379
1380    /**
1381     * @param value Description of manipulation.
1382     */
1383    public BiologicallyDerivedProductManipulationComponent setDescription(String value) {
1384      if (Utilities.noString(value))
1385        this.description = null;
1386      else {
1387        if (this.description == null)
1388          this.description = new StringType();
1389        this.description.setValue(value);
1390      }
1391      return this;
1392    }
1393
1394    /**
1395     * @return {@link #time} (Time of manipulation.)
1396     */
1397    public Type getTime() {
1398      return this.time;
1399    }
1400
1401    /**
1402     * @return {@link #time} (Time of manipulation.)
1403     */
1404    public DateTimeType getTimeDateTimeType() throws FHIRException {
1405      if (this.time == null)
1406        this.time = new DateTimeType();
1407      if (!(this.time instanceof DateTimeType))
1408        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "
1409            + this.time.getClass().getName() + " was encountered");
1410      return (DateTimeType) this.time;
1411    }
1412
1413    public boolean hasTimeDateTimeType() {
1414      return this != null && this.time instanceof DateTimeType;
1415    }
1416
1417    /**
1418     * @return {@link #time} (Time of manipulation.)
1419     */
1420    public Period getTimePeriod() throws FHIRException {
1421      if (this.time == null)
1422        this.time = new Period();
1423      if (!(this.time instanceof Period))
1424        throw new FHIRException(
1425            "Type mismatch: the type Period was expected, but " + this.time.getClass().getName() + " was encountered");
1426      return (Period) this.time;
1427    }
1428
1429    public boolean hasTimePeriod() {
1430      return this != null && this.time instanceof Period;
1431    }
1432
1433    public boolean hasTime() {
1434      return this.time != null && !this.time.isEmpty();
1435    }
1436
1437    /**
1438     * @param value {@link #time} (Time of manipulation.)
1439     */
1440    public BiologicallyDerivedProductManipulationComponent setTime(Type value) {
1441      if (value != null && !(value instanceof DateTimeType || value instanceof Period))
1442        throw new Error("Not the right type for BiologicallyDerivedProduct.manipulation.time[x]: " + value.fhirType());
1443      this.time = value;
1444      return this;
1445    }
1446
1447    protected void listChildren(List<Property> children) {
1448      super.listChildren(children);
1449      children.add(new Property("description", "string", "Description of manipulation.", 0, 1, description));
1450      children.add(new Property("time[x]", "dateTime|Period", "Time of manipulation.", 0, 1, time));
1451    }
1452
1453    @Override
1454    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1455      switch (_hash) {
1456      case -1724546052:
1457        /* description */ return new Property("description", "string", "Description of manipulation.", 0, 1,
1458            description);
1459      case -1313930605:
1460        /* time[x] */ return new Property("time[x]", "dateTime|Period", "Time of manipulation.", 0, 1, time);
1461      case 3560141:
1462        /* time */ return new Property("time[x]", "dateTime|Period", "Time of manipulation.", 0, 1, time);
1463      case 2135345544:
1464        /* timeDateTime */ return new Property("time[x]", "dateTime|Period", "Time of manipulation.", 0, 1, time);
1465      case 693544686:
1466        /* timePeriod */ return new Property("time[x]", "dateTime|Period", "Time of manipulation.", 0, 1, time);
1467      default:
1468        return super.getNamedProperty(_hash, _name, _checkValid);
1469      }
1470
1471    }
1472
1473    @Override
1474    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1475      switch (hash) {
1476      case -1724546052:
1477        /* description */ return this.description == null ? new Base[0] : new Base[] { this.description }; // StringType
1478      case 3560141:
1479        /* time */ return this.time == null ? new Base[0] : new Base[] { this.time }; // Type
1480      default:
1481        return super.getProperty(hash, name, checkValid);
1482      }
1483
1484    }
1485
1486    @Override
1487    public Base setProperty(int hash, String name, Base value) throws FHIRException {
1488      switch (hash) {
1489      case -1724546052: // description
1490        this.description = castToString(value); // StringType
1491        return value;
1492      case 3560141: // time
1493        this.time = castToType(value); // Type
1494        return value;
1495      default:
1496        return super.setProperty(hash, name, value);
1497      }
1498
1499    }
1500
1501    @Override
1502    public Base setProperty(String name, Base value) throws FHIRException {
1503      if (name.equals("description")) {
1504        this.description = castToString(value); // StringType
1505      } else if (name.equals("time[x]")) {
1506        this.time = castToType(value); // Type
1507      } else
1508        return super.setProperty(name, value);
1509      return value;
1510    }
1511
1512    @Override
1513    public Base makeProperty(int hash, String name) throws FHIRException {
1514      switch (hash) {
1515      case -1724546052:
1516        return getDescriptionElement();
1517      case -1313930605:
1518        return getTime();
1519      case 3560141:
1520        return getTime();
1521      default:
1522        return super.makeProperty(hash, name);
1523      }
1524
1525    }
1526
1527    @Override
1528    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1529      switch (hash) {
1530      case -1724546052:
1531        /* description */ return new String[] { "string" };
1532      case 3560141:
1533        /* time */ return new String[] { "dateTime", "Period" };
1534      default:
1535        return super.getTypesForProperty(hash, name);
1536      }
1537
1538    }
1539
1540    @Override
1541    public Base addChild(String name) throws FHIRException {
1542      if (name.equals("description")) {
1543        throw new FHIRException("Cannot call addChild on a singleton property BiologicallyDerivedProduct.description");
1544      } else if (name.equals("timeDateTime")) {
1545        this.time = new DateTimeType();
1546        return this.time;
1547      } else if (name.equals("timePeriod")) {
1548        this.time = new Period();
1549        return this.time;
1550      } else
1551        return super.addChild(name);
1552    }
1553
1554    public BiologicallyDerivedProductManipulationComponent copy() {
1555      BiologicallyDerivedProductManipulationComponent dst = new BiologicallyDerivedProductManipulationComponent();
1556      copyValues(dst);
1557      return dst;
1558    }
1559
1560    public void copyValues(BiologicallyDerivedProductManipulationComponent dst) {
1561      super.copyValues(dst);
1562      dst.description = description == null ? null : description.copy();
1563      dst.time = time == null ? null : time.copy();
1564    }
1565
1566    @Override
1567    public boolean equalsDeep(Base other_) {
1568      if (!super.equalsDeep(other_))
1569        return false;
1570      if (!(other_ instanceof BiologicallyDerivedProductManipulationComponent))
1571        return false;
1572      BiologicallyDerivedProductManipulationComponent o = (BiologicallyDerivedProductManipulationComponent) other_;
1573      return compareDeep(description, o.description, true) && compareDeep(time, o.time, true);
1574    }
1575
1576    @Override
1577    public boolean equalsShallow(Base other_) {
1578      if (!super.equalsShallow(other_))
1579        return false;
1580      if (!(other_ instanceof BiologicallyDerivedProductManipulationComponent))
1581        return false;
1582      BiologicallyDerivedProductManipulationComponent o = (BiologicallyDerivedProductManipulationComponent) other_;
1583      return compareValues(description, o.description, true);
1584    }
1585
1586    public boolean isEmpty() {
1587      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(description, time);
1588    }
1589
1590    public String fhirType() {
1591      return "BiologicallyDerivedProduct.manipulation";
1592
1593    }
1594
1595  }
1596
1597  @Block()
1598  public static class BiologicallyDerivedProductStorageComponent extends BackboneElement
1599      implements IBaseBackboneElement {
1600    /**
1601     * Description of storage.
1602     */
1603    @Child(name = "description", type = {
1604        StringType.class }, order = 1, min = 0, max = 1, modifier = false, summary = false)
1605    @Description(shortDefinition = "Description of storage", formalDefinition = "Description of storage.")
1606    protected StringType description;
1607
1608    /**
1609     * Storage temperature.
1610     */
1611    @Child(name = "temperature", type = {
1612        DecimalType.class }, order = 2, min = 0, max = 1, modifier = false, summary = false)
1613    @Description(shortDefinition = "Storage temperature", formalDefinition = "Storage temperature.")
1614    protected DecimalType temperature;
1615
1616    /**
1617     * Temperature scale used.
1618     */
1619    @Child(name = "scale", type = { CodeType.class }, order = 3, min = 0, max = 1, modifier = false, summary = false)
1620    @Description(shortDefinition = "farenheit | celsius | kelvin", formalDefinition = "Temperature scale used.")
1621    @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/product-storage-scale")
1622    protected Enumeration<BiologicallyDerivedProductStorageScale> scale;
1623
1624    /**
1625     * Storage timeperiod.
1626     */
1627    @Child(name = "duration", type = { Period.class }, order = 4, min = 0, max = 1, modifier = false, summary = false)
1628    @Description(shortDefinition = "Storage timeperiod", formalDefinition = "Storage timeperiod.")
1629    protected Period duration;
1630
1631    private static final long serialVersionUID = 1509141319L;
1632
1633    /**
1634     * Constructor
1635     */
1636    public BiologicallyDerivedProductStorageComponent() {
1637      super();
1638    }
1639
1640    /**
1641     * @return {@link #description} (Description of storage.). This is the
1642     *         underlying object with id, value and extensions. The accessor
1643     *         "getDescription" gives direct access to the value
1644     */
1645    public StringType getDescriptionElement() {
1646      if (this.description == null)
1647        if (Configuration.errorOnAutoCreate())
1648          throw new Error("Attempt to auto-create BiologicallyDerivedProductStorageComponent.description");
1649        else if (Configuration.doAutoCreate())
1650          this.description = new StringType(); // bb
1651      return this.description;
1652    }
1653
1654    public boolean hasDescriptionElement() {
1655      return this.description != null && !this.description.isEmpty();
1656    }
1657
1658    public boolean hasDescription() {
1659      return this.description != null && !this.description.isEmpty();
1660    }
1661
1662    /**
1663     * @param value {@link #description} (Description of storage.). This is the
1664     *              underlying object with id, value and extensions. The accessor
1665     *              "getDescription" gives direct access to the value
1666     */
1667    public BiologicallyDerivedProductStorageComponent setDescriptionElement(StringType value) {
1668      this.description = value;
1669      return this;
1670    }
1671
1672    /**
1673     * @return Description of storage.
1674     */
1675    public String getDescription() {
1676      return this.description == null ? null : this.description.getValue();
1677    }
1678
1679    /**
1680     * @param value Description of storage.
1681     */
1682    public BiologicallyDerivedProductStorageComponent setDescription(String value) {
1683      if (Utilities.noString(value))
1684        this.description = null;
1685      else {
1686        if (this.description == null)
1687          this.description = new StringType();
1688        this.description.setValue(value);
1689      }
1690      return this;
1691    }
1692
1693    /**
1694     * @return {@link #temperature} (Storage temperature.). This is the underlying
1695     *         object with id, value and extensions. The accessor "getTemperature"
1696     *         gives direct access to the value
1697     */
1698    public DecimalType getTemperatureElement() {
1699      if (this.temperature == null)
1700        if (Configuration.errorOnAutoCreate())
1701          throw new Error("Attempt to auto-create BiologicallyDerivedProductStorageComponent.temperature");
1702        else if (Configuration.doAutoCreate())
1703          this.temperature = new DecimalType(); // bb
1704      return this.temperature;
1705    }
1706
1707    public boolean hasTemperatureElement() {
1708      return this.temperature != null && !this.temperature.isEmpty();
1709    }
1710
1711    public boolean hasTemperature() {
1712      return this.temperature != null && !this.temperature.isEmpty();
1713    }
1714
1715    /**
1716     * @param value {@link #temperature} (Storage temperature.). This is the
1717     *              underlying object with id, value and extensions. The accessor
1718     *              "getTemperature" gives direct access to the value
1719     */
1720    public BiologicallyDerivedProductStorageComponent setTemperatureElement(DecimalType value) {
1721      this.temperature = value;
1722      return this;
1723    }
1724
1725    /**
1726     * @return Storage temperature.
1727     */
1728    public BigDecimal getTemperature() {
1729      return this.temperature == null ? null : this.temperature.getValue();
1730    }
1731
1732    /**
1733     * @param value Storage temperature.
1734     */
1735    public BiologicallyDerivedProductStorageComponent setTemperature(BigDecimal value) {
1736      if (value == null)
1737        this.temperature = null;
1738      else {
1739        if (this.temperature == null)
1740          this.temperature = new DecimalType();
1741        this.temperature.setValue(value);
1742      }
1743      return this;
1744    }
1745
1746    /**
1747     * @param value Storage temperature.
1748     */
1749    public BiologicallyDerivedProductStorageComponent setTemperature(long value) {
1750      this.temperature = new DecimalType();
1751      this.temperature.setValue(value);
1752      return this;
1753    }
1754
1755    /**
1756     * @param value Storage temperature.
1757     */
1758    public BiologicallyDerivedProductStorageComponent setTemperature(double value) {
1759      this.temperature = new DecimalType();
1760      this.temperature.setValue(value);
1761      return this;
1762    }
1763
1764    /**
1765     * @return {@link #scale} (Temperature scale used.). This is the underlying
1766     *         object with id, value and extensions. The accessor "getScale" gives
1767     *         direct access to the value
1768     */
1769    public Enumeration<BiologicallyDerivedProductStorageScale> getScaleElement() {
1770      if (this.scale == null)
1771        if (Configuration.errorOnAutoCreate())
1772          throw new Error("Attempt to auto-create BiologicallyDerivedProductStorageComponent.scale");
1773        else if (Configuration.doAutoCreate())
1774          this.scale = new Enumeration<BiologicallyDerivedProductStorageScale>(
1775              new BiologicallyDerivedProductStorageScaleEnumFactory()); // bb
1776      return this.scale;
1777    }
1778
1779    public boolean hasScaleElement() {
1780      return this.scale != null && !this.scale.isEmpty();
1781    }
1782
1783    public boolean hasScale() {
1784      return this.scale != null && !this.scale.isEmpty();
1785    }
1786
1787    /**
1788     * @param value {@link #scale} (Temperature scale used.). This is the underlying
1789     *              object with id, value and extensions. The accessor "getScale"
1790     *              gives direct access to the value
1791     */
1792    public BiologicallyDerivedProductStorageComponent setScaleElement(
1793        Enumeration<BiologicallyDerivedProductStorageScale> value) {
1794      this.scale = value;
1795      return this;
1796    }
1797
1798    /**
1799     * @return Temperature scale used.
1800     */
1801    public BiologicallyDerivedProductStorageScale getScale() {
1802      return this.scale == null ? null : this.scale.getValue();
1803    }
1804
1805    /**
1806     * @param value Temperature scale used.
1807     */
1808    public BiologicallyDerivedProductStorageComponent setScale(BiologicallyDerivedProductStorageScale value) {
1809      if (value == null)
1810        this.scale = null;
1811      else {
1812        if (this.scale == null)
1813          this.scale = new Enumeration<BiologicallyDerivedProductStorageScale>(
1814              new BiologicallyDerivedProductStorageScaleEnumFactory());
1815        this.scale.setValue(value);
1816      }
1817      return this;
1818    }
1819
1820    /**
1821     * @return {@link #duration} (Storage timeperiod.)
1822     */
1823    public Period getDuration() {
1824      if (this.duration == null)
1825        if (Configuration.errorOnAutoCreate())
1826          throw new Error("Attempt to auto-create BiologicallyDerivedProductStorageComponent.duration");
1827        else if (Configuration.doAutoCreate())
1828          this.duration = new Period(); // cc
1829      return this.duration;
1830    }
1831
1832    public boolean hasDuration() {
1833      return this.duration != null && !this.duration.isEmpty();
1834    }
1835
1836    /**
1837     * @param value {@link #duration} (Storage timeperiod.)
1838     */
1839    public BiologicallyDerivedProductStorageComponent setDuration(Period value) {
1840      this.duration = value;
1841      return this;
1842    }
1843
1844    protected void listChildren(List<Property> children) {
1845      super.listChildren(children);
1846      children.add(new Property("description", "string", "Description of storage.", 0, 1, description));
1847      children.add(new Property("temperature", "decimal", "Storage temperature.", 0, 1, temperature));
1848      children.add(new Property("scale", "code", "Temperature scale used.", 0, 1, scale));
1849      children.add(new Property("duration", "Period", "Storage timeperiod.", 0, 1, duration));
1850    }
1851
1852    @Override
1853    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1854      switch (_hash) {
1855      case -1724546052:
1856        /* description */ return new Property("description", "string", "Description of storage.", 0, 1, description);
1857      case 321701236:
1858        /* temperature */ return new Property("temperature", "decimal", "Storage temperature.", 0, 1, temperature);
1859      case 109250890:
1860        /* scale */ return new Property("scale", "code", "Temperature scale used.", 0, 1, scale);
1861      case -1992012396:
1862        /* duration */ return new Property("duration", "Period", "Storage timeperiod.", 0, 1, duration);
1863      default:
1864        return super.getNamedProperty(_hash, _name, _checkValid);
1865      }
1866
1867    }
1868
1869    @Override
1870    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1871      switch (hash) {
1872      case -1724546052:
1873        /* description */ return this.description == null ? new Base[0] : new Base[] { this.description }; // StringType
1874      case 321701236:
1875        /* temperature */ return this.temperature == null ? new Base[0] : new Base[] { this.temperature }; // DecimalType
1876      case 109250890:
1877        /* scale */ return this.scale == null ? new Base[0] : new Base[] { this.scale }; // Enumeration<BiologicallyDerivedProductStorageScale>
1878      case -1992012396:
1879        /* duration */ return this.duration == null ? new Base[0] : new Base[] { this.duration }; // Period
1880      default:
1881        return super.getProperty(hash, name, checkValid);
1882      }
1883
1884    }
1885
1886    @Override
1887    public Base setProperty(int hash, String name, Base value) throws FHIRException {
1888      switch (hash) {
1889      case -1724546052: // description
1890        this.description = castToString(value); // StringType
1891        return value;
1892      case 321701236: // temperature
1893        this.temperature = castToDecimal(value); // DecimalType
1894        return value;
1895      case 109250890: // scale
1896        value = new BiologicallyDerivedProductStorageScaleEnumFactory().fromType(castToCode(value));
1897        this.scale = (Enumeration) value; // Enumeration<BiologicallyDerivedProductStorageScale>
1898        return value;
1899      case -1992012396: // duration
1900        this.duration = castToPeriod(value); // Period
1901        return value;
1902      default:
1903        return super.setProperty(hash, name, value);
1904      }
1905
1906    }
1907
1908    @Override
1909    public Base setProperty(String name, Base value) throws FHIRException {
1910      if (name.equals("description")) {
1911        this.description = castToString(value); // StringType
1912      } else if (name.equals("temperature")) {
1913        this.temperature = castToDecimal(value); // DecimalType
1914      } else if (name.equals("scale")) {
1915        value = new BiologicallyDerivedProductStorageScaleEnumFactory().fromType(castToCode(value));
1916        this.scale = (Enumeration) value; // Enumeration<BiologicallyDerivedProductStorageScale>
1917      } else if (name.equals("duration")) {
1918        this.duration = castToPeriod(value); // Period
1919      } else
1920        return super.setProperty(name, value);
1921      return value;
1922    }
1923
1924    @Override
1925    public Base makeProperty(int hash, String name) throws FHIRException {
1926      switch (hash) {
1927      case -1724546052:
1928        return getDescriptionElement();
1929      case 321701236:
1930        return getTemperatureElement();
1931      case 109250890:
1932        return getScaleElement();
1933      case -1992012396:
1934        return getDuration();
1935      default:
1936        return super.makeProperty(hash, name);
1937      }
1938
1939    }
1940
1941    @Override
1942    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1943      switch (hash) {
1944      case -1724546052:
1945        /* description */ return new String[] { "string" };
1946      case 321701236:
1947        /* temperature */ return new String[] { "decimal" };
1948      case 109250890:
1949        /* scale */ return new String[] { "code" };
1950      case -1992012396:
1951        /* duration */ return new String[] { "Period" };
1952      default:
1953        return super.getTypesForProperty(hash, name);
1954      }
1955
1956    }
1957
1958    @Override
1959    public Base addChild(String name) throws FHIRException {
1960      if (name.equals("description")) {
1961        throw new FHIRException("Cannot call addChild on a singleton property BiologicallyDerivedProduct.description");
1962      } else if (name.equals("temperature")) {
1963        throw new FHIRException("Cannot call addChild on a singleton property BiologicallyDerivedProduct.temperature");
1964      } else if (name.equals("scale")) {
1965        throw new FHIRException("Cannot call addChild on a singleton property BiologicallyDerivedProduct.scale");
1966      } else if (name.equals("duration")) {
1967        this.duration = new Period();
1968        return this.duration;
1969      } else
1970        return super.addChild(name);
1971    }
1972
1973    public BiologicallyDerivedProductStorageComponent copy() {
1974      BiologicallyDerivedProductStorageComponent dst = new BiologicallyDerivedProductStorageComponent();
1975      copyValues(dst);
1976      return dst;
1977    }
1978
1979    public void copyValues(BiologicallyDerivedProductStorageComponent dst) {
1980      super.copyValues(dst);
1981      dst.description = description == null ? null : description.copy();
1982      dst.temperature = temperature == null ? null : temperature.copy();
1983      dst.scale = scale == null ? null : scale.copy();
1984      dst.duration = duration == null ? null : duration.copy();
1985    }
1986
1987    @Override
1988    public boolean equalsDeep(Base other_) {
1989      if (!super.equalsDeep(other_))
1990        return false;
1991      if (!(other_ instanceof BiologicallyDerivedProductStorageComponent))
1992        return false;
1993      BiologicallyDerivedProductStorageComponent o = (BiologicallyDerivedProductStorageComponent) other_;
1994      return compareDeep(description, o.description, true) && compareDeep(temperature, o.temperature, true)
1995          && compareDeep(scale, o.scale, true) && compareDeep(duration, o.duration, true);
1996    }
1997
1998    @Override
1999    public boolean equalsShallow(Base other_) {
2000      if (!super.equalsShallow(other_))
2001        return false;
2002      if (!(other_ instanceof BiologicallyDerivedProductStorageComponent))
2003        return false;
2004      BiologicallyDerivedProductStorageComponent o = (BiologicallyDerivedProductStorageComponent) other_;
2005      return compareValues(description, o.description, true) && compareValues(temperature, o.temperature, true)
2006          && compareValues(scale, o.scale, true);
2007    }
2008
2009    public boolean isEmpty() {
2010      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(description, temperature, scale, duration);
2011    }
2012
2013    public String fhirType() {
2014      return "BiologicallyDerivedProduct.storage";
2015
2016    }
2017
2018  }
2019
2020  /**
2021   * This records identifiers associated with this biologically derived product
2022   * instance that are defined by business processes and/or used to refer to it
2023   * when a direct URL reference to the resource itself is not appropriate (e.g.
2024   * in CDA documents, or in written / printed documentation).
2025   */
2026  @Child(name = "identifier", type = {
2027      Identifier.class }, order = 0, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
2028  @Description(shortDefinition = "External ids for this item", formalDefinition = "This records identifiers associated with this biologically derived product instance that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).")
2029  protected List<Identifier> identifier;
2030
2031  /**
2032   * Broad category of this product.
2033   */
2034  @Child(name = "productCategory", type = {
2035      CodeType.class }, order = 1, min = 0, max = 1, modifier = false, summary = false)
2036  @Description(shortDefinition = "organ | tissue | fluid | cells | biologicalAgent", formalDefinition = "Broad category of this product.")
2037  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/product-category")
2038  protected Enumeration<BiologicallyDerivedProductCategory> productCategory;
2039
2040  /**
2041   * A code that identifies the kind of this biologically derived product (SNOMED
2042   * Ctcode).
2043   */
2044  @Child(name = "productCode", type = {
2045      CodeableConcept.class }, order = 2, min = 0, max = 1, modifier = false, summary = false)
2046  @Description(shortDefinition = "What this biologically derived product is", formalDefinition = "A code that identifies the kind of this biologically derived product (SNOMED Ctcode).")
2047  protected CodeableConcept productCode;
2048
2049  /**
2050   * Whether the product is currently available.
2051   */
2052  @Child(name = "status", type = { CodeType.class }, order = 3, min = 0, max = 1, modifier = false, summary = false)
2053  @Description(shortDefinition = "available | unavailable", formalDefinition = "Whether the product is currently available.")
2054  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/product-status")
2055  protected Enumeration<BiologicallyDerivedProductStatus> status;
2056
2057  /**
2058   * Procedure request to obtain this biologically derived product.
2059   */
2060  @Child(name = "request", type = {
2061      ServiceRequest.class }, order = 4, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
2062  @Description(shortDefinition = "Procedure request", formalDefinition = "Procedure request to obtain this biologically derived product.")
2063  protected List<Reference> request;
2064  /**
2065   * The actual objects that are the target of the reference (Procedure request to
2066   * obtain this biologically derived product.)
2067   */
2068  protected List<ServiceRequest> requestTarget;
2069
2070  /**
2071   * Number of discrete units within this product.
2072   */
2073  @Child(name = "quantity", type = {
2074      IntegerType.class }, order = 5, min = 0, max = 1, modifier = false, summary = false)
2075  @Description(shortDefinition = "The amount of this biologically derived product", formalDefinition = "Number of discrete units within this product.")
2076  protected IntegerType quantity;
2077
2078  /**
2079   * Parent product (if any).
2080   */
2081  @Child(name = "parent", type = {
2082      BiologicallyDerivedProduct.class }, order = 6, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
2083  @Description(shortDefinition = "BiologicallyDerivedProduct parent", formalDefinition = "Parent product (if any).")
2084  protected List<Reference> parent;
2085  /**
2086   * The actual objects that are the target of the reference (Parent product (if
2087   * any).)
2088   */
2089  protected List<BiologicallyDerivedProduct> parentTarget;
2090
2091  /**
2092   * How this product was collected.
2093   */
2094  @Child(name = "collection", type = {}, order = 7, min = 0, max = 1, modifier = false, summary = false)
2095  @Description(shortDefinition = "How this product was collected", formalDefinition = "How this product was collected.")
2096  protected BiologicallyDerivedProductCollectionComponent collection;
2097
2098  /**
2099   * Any processing of the product during collection that does not change the
2100   * fundamental nature of the product. For example adding anti-coagulants during
2101   * the collection of Peripheral Blood Stem Cells.
2102   */
2103  @Child(name = "processing", type = {}, order = 8, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
2104  @Description(shortDefinition = "Any processing of the product during collection", formalDefinition = "Any processing of the product during collection that does not change the fundamental nature of the product. For example adding anti-coagulants during the collection of Peripheral Blood Stem Cells.")
2105  protected List<BiologicallyDerivedProductProcessingComponent> processing;
2106
2107  /**
2108   * Any manipulation of product post-collection that is intended to alter the
2109   * product. For example a buffy-coat enrichment or CD8 reduction of Peripheral
2110   * Blood Stem Cells to make it more suitable for infusion.
2111   */
2112  @Child(name = "manipulation", type = {}, order = 9, min = 0, max = 1, modifier = false, summary = false)
2113  @Description(shortDefinition = "Any manipulation of product post-collection", formalDefinition = "Any manipulation of product post-collection that is intended to alter the product.  For example a buffy-coat enrichment or CD8 reduction of Peripheral Blood Stem Cells to make it more suitable for infusion.")
2114  protected BiologicallyDerivedProductManipulationComponent manipulation;
2115
2116  /**
2117   * Product storage.
2118   */
2119  @Child(name = "storage", type = {}, order = 10, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
2120  @Description(shortDefinition = "Product storage", formalDefinition = "Product storage.")
2121  protected List<BiologicallyDerivedProductStorageComponent> storage;
2122
2123  private static final long serialVersionUID = -1367034547L;
2124
2125  /**
2126   * Constructor
2127   */
2128  public BiologicallyDerivedProduct() {
2129    super();
2130  }
2131
2132  /**
2133   * @return {@link #identifier} (This records identifiers associated with this
2134   *         biologically derived product instance that are defined by business
2135   *         processes and/or used to refer to it when a direct URL reference to
2136   *         the resource itself is not appropriate (e.g. in CDA documents, or in
2137   *         written / printed documentation).)
2138   */
2139  public List<Identifier> getIdentifier() {
2140    if (this.identifier == null)
2141      this.identifier = new ArrayList<Identifier>();
2142    return this.identifier;
2143  }
2144
2145  /**
2146   * @return Returns a reference to <code>this</code> for easy method chaining
2147   */
2148  public BiologicallyDerivedProduct setIdentifier(List<Identifier> theIdentifier) {
2149    this.identifier = theIdentifier;
2150    return this;
2151  }
2152
2153  public boolean hasIdentifier() {
2154    if (this.identifier == null)
2155      return false;
2156    for (Identifier item : this.identifier)
2157      if (!item.isEmpty())
2158        return true;
2159    return false;
2160  }
2161
2162  public Identifier addIdentifier() { // 3
2163    Identifier t = new Identifier();
2164    if (this.identifier == null)
2165      this.identifier = new ArrayList<Identifier>();
2166    this.identifier.add(t);
2167    return t;
2168  }
2169
2170  public BiologicallyDerivedProduct addIdentifier(Identifier t) { // 3
2171    if (t == null)
2172      return this;
2173    if (this.identifier == null)
2174      this.identifier = new ArrayList<Identifier>();
2175    this.identifier.add(t);
2176    return this;
2177  }
2178
2179  /**
2180   * @return The first repetition of repeating field {@link #identifier}, creating
2181   *         it if it does not already exist
2182   */
2183  public Identifier getIdentifierFirstRep() {
2184    if (getIdentifier().isEmpty()) {
2185      addIdentifier();
2186    }
2187    return getIdentifier().get(0);
2188  }
2189
2190  /**
2191   * @return {@link #productCategory} (Broad category of this product.). This is
2192   *         the underlying object with id, value and extensions. The accessor
2193   *         "getProductCategory" gives direct access to the value
2194   */
2195  public Enumeration<BiologicallyDerivedProductCategory> getProductCategoryElement() {
2196    if (this.productCategory == null)
2197      if (Configuration.errorOnAutoCreate())
2198        throw new Error("Attempt to auto-create BiologicallyDerivedProduct.productCategory");
2199      else if (Configuration.doAutoCreate())
2200        this.productCategory = new Enumeration<BiologicallyDerivedProductCategory>(
2201            new BiologicallyDerivedProductCategoryEnumFactory()); // bb
2202    return this.productCategory;
2203  }
2204
2205  public boolean hasProductCategoryElement() {
2206    return this.productCategory != null && !this.productCategory.isEmpty();
2207  }
2208
2209  public boolean hasProductCategory() {
2210    return this.productCategory != null && !this.productCategory.isEmpty();
2211  }
2212
2213  /**
2214   * @param value {@link #productCategory} (Broad category of this product.). This
2215   *              is the underlying object with id, value and extensions. The
2216   *              accessor "getProductCategory" gives direct access to the value
2217   */
2218  public BiologicallyDerivedProduct setProductCategoryElement(Enumeration<BiologicallyDerivedProductCategory> value) {
2219    this.productCategory = value;
2220    return this;
2221  }
2222
2223  /**
2224   * @return Broad category of this product.
2225   */
2226  public BiologicallyDerivedProductCategory getProductCategory() {
2227    return this.productCategory == null ? null : this.productCategory.getValue();
2228  }
2229
2230  /**
2231   * @param value Broad category of this product.
2232   */
2233  public BiologicallyDerivedProduct setProductCategory(BiologicallyDerivedProductCategory value) {
2234    if (value == null)
2235      this.productCategory = null;
2236    else {
2237      if (this.productCategory == null)
2238        this.productCategory = new Enumeration<BiologicallyDerivedProductCategory>(
2239            new BiologicallyDerivedProductCategoryEnumFactory());
2240      this.productCategory.setValue(value);
2241    }
2242    return this;
2243  }
2244
2245  /**
2246   * @return {@link #productCode} (A code that identifies the kind of this
2247   *         biologically derived product (SNOMED Ctcode).)
2248   */
2249  public CodeableConcept getProductCode() {
2250    if (this.productCode == null)
2251      if (Configuration.errorOnAutoCreate())
2252        throw new Error("Attempt to auto-create BiologicallyDerivedProduct.productCode");
2253      else if (Configuration.doAutoCreate())
2254        this.productCode = new CodeableConcept(); // cc
2255    return this.productCode;
2256  }
2257
2258  public boolean hasProductCode() {
2259    return this.productCode != null && !this.productCode.isEmpty();
2260  }
2261
2262  /**
2263   * @param value {@link #productCode} (A code that identifies the kind of this
2264   *              biologically derived product (SNOMED Ctcode).)
2265   */
2266  public BiologicallyDerivedProduct setProductCode(CodeableConcept value) {
2267    this.productCode = value;
2268    return this;
2269  }
2270
2271  /**
2272   * @return {@link #status} (Whether the product is currently available.). This
2273   *         is the underlying object with id, value and extensions. The accessor
2274   *         "getStatus" gives direct access to the value
2275   */
2276  public Enumeration<BiologicallyDerivedProductStatus> getStatusElement() {
2277    if (this.status == null)
2278      if (Configuration.errorOnAutoCreate())
2279        throw new Error("Attempt to auto-create BiologicallyDerivedProduct.status");
2280      else if (Configuration.doAutoCreate())
2281        this.status = new Enumeration<BiologicallyDerivedProductStatus>(
2282            new BiologicallyDerivedProductStatusEnumFactory()); // bb
2283    return this.status;
2284  }
2285
2286  public boolean hasStatusElement() {
2287    return this.status != null && !this.status.isEmpty();
2288  }
2289
2290  public boolean hasStatus() {
2291    return this.status != null && !this.status.isEmpty();
2292  }
2293
2294  /**
2295   * @param value {@link #status} (Whether the product is currently available.).
2296   *              This is the underlying object with id, value and extensions. The
2297   *              accessor "getStatus" gives direct access to the value
2298   */
2299  public BiologicallyDerivedProduct setStatusElement(Enumeration<BiologicallyDerivedProductStatus> value) {
2300    this.status = value;
2301    return this;
2302  }
2303
2304  /**
2305   * @return Whether the product is currently available.
2306   */
2307  public BiologicallyDerivedProductStatus getStatus() {
2308    return this.status == null ? null : this.status.getValue();
2309  }
2310
2311  /**
2312   * @param value Whether the product is currently available.
2313   */
2314  public BiologicallyDerivedProduct setStatus(BiologicallyDerivedProductStatus value) {
2315    if (value == null)
2316      this.status = null;
2317    else {
2318      if (this.status == null)
2319        this.status = new Enumeration<BiologicallyDerivedProductStatus>(
2320            new BiologicallyDerivedProductStatusEnumFactory());
2321      this.status.setValue(value);
2322    }
2323    return this;
2324  }
2325
2326  /**
2327   * @return {@link #request} (Procedure request to obtain this biologically
2328   *         derived product.)
2329   */
2330  public List<Reference> getRequest() {
2331    if (this.request == null)
2332      this.request = new ArrayList<Reference>();
2333    return this.request;
2334  }
2335
2336  /**
2337   * @return Returns a reference to <code>this</code> for easy method chaining
2338   */
2339  public BiologicallyDerivedProduct setRequest(List<Reference> theRequest) {
2340    this.request = theRequest;
2341    return this;
2342  }
2343
2344  public boolean hasRequest() {
2345    if (this.request == null)
2346      return false;
2347    for (Reference item : this.request)
2348      if (!item.isEmpty())
2349        return true;
2350    return false;
2351  }
2352
2353  public Reference addRequest() { // 3
2354    Reference t = new Reference();
2355    if (this.request == null)
2356      this.request = new ArrayList<Reference>();
2357    this.request.add(t);
2358    return t;
2359  }
2360
2361  public BiologicallyDerivedProduct addRequest(Reference t) { // 3
2362    if (t == null)
2363      return this;
2364    if (this.request == null)
2365      this.request = new ArrayList<Reference>();
2366    this.request.add(t);
2367    return this;
2368  }
2369
2370  /**
2371   * @return The first repetition of repeating field {@link #request}, creating it
2372   *         if it does not already exist
2373   */
2374  public Reference getRequestFirstRep() {
2375    if (getRequest().isEmpty()) {
2376      addRequest();
2377    }
2378    return getRequest().get(0);
2379  }
2380
2381  /**
2382   * @deprecated Use Reference#setResource(IBaseResource) instead
2383   */
2384  @Deprecated
2385  public List<ServiceRequest> getRequestTarget() {
2386    if (this.requestTarget == null)
2387      this.requestTarget = new ArrayList<ServiceRequest>();
2388    return this.requestTarget;
2389  }
2390
2391  /**
2392   * @deprecated Use Reference#setResource(IBaseResource) instead
2393   */
2394  @Deprecated
2395  public ServiceRequest addRequestTarget() {
2396    ServiceRequest r = new ServiceRequest();
2397    if (this.requestTarget == null)
2398      this.requestTarget = new ArrayList<ServiceRequest>();
2399    this.requestTarget.add(r);
2400    return r;
2401  }
2402
2403  /**
2404   * @return {@link #quantity} (Number of discrete units within this product.).
2405   *         This is the underlying object with id, value and extensions. The
2406   *         accessor "getQuantity" gives direct access to the value
2407   */
2408  public IntegerType getQuantityElement() {
2409    if (this.quantity == null)
2410      if (Configuration.errorOnAutoCreate())
2411        throw new Error("Attempt to auto-create BiologicallyDerivedProduct.quantity");
2412      else if (Configuration.doAutoCreate())
2413        this.quantity = new IntegerType(); // bb
2414    return this.quantity;
2415  }
2416
2417  public boolean hasQuantityElement() {
2418    return this.quantity != null && !this.quantity.isEmpty();
2419  }
2420
2421  public boolean hasQuantity() {
2422    return this.quantity != null && !this.quantity.isEmpty();
2423  }
2424
2425  /**
2426   * @param value {@link #quantity} (Number of discrete units within this
2427   *              product.). This is the underlying object with id, value and
2428   *              extensions. The accessor "getQuantity" gives direct access to
2429   *              the value
2430   */
2431  public BiologicallyDerivedProduct setQuantityElement(IntegerType value) {
2432    this.quantity = value;
2433    return this;
2434  }
2435
2436  /**
2437   * @return Number of discrete units within this product.
2438   */
2439  public int getQuantity() {
2440    return this.quantity == null || this.quantity.isEmpty() ? 0 : this.quantity.getValue();
2441  }
2442
2443  /**
2444   * @param value Number of discrete units within this product.
2445   */
2446  public BiologicallyDerivedProduct setQuantity(int value) {
2447    if (this.quantity == null)
2448      this.quantity = new IntegerType();
2449    this.quantity.setValue(value);
2450    return this;
2451  }
2452
2453  /**
2454   * @return {@link #parent} (Parent product (if any).)
2455   */
2456  public List<Reference> getParent() {
2457    if (this.parent == null)
2458      this.parent = new ArrayList<Reference>();
2459    return this.parent;
2460  }
2461
2462  /**
2463   * @return Returns a reference to <code>this</code> for easy method chaining
2464   */
2465  public BiologicallyDerivedProduct setParent(List<Reference> theParent) {
2466    this.parent = theParent;
2467    return this;
2468  }
2469
2470  public boolean hasParent() {
2471    if (this.parent == null)
2472      return false;
2473    for (Reference item : this.parent)
2474      if (!item.isEmpty())
2475        return true;
2476    return false;
2477  }
2478
2479  public Reference addParent() { // 3
2480    Reference t = new Reference();
2481    if (this.parent == null)
2482      this.parent = new ArrayList<Reference>();
2483    this.parent.add(t);
2484    return t;
2485  }
2486
2487  public BiologicallyDerivedProduct addParent(Reference t) { // 3
2488    if (t == null)
2489      return this;
2490    if (this.parent == null)
2491      this.parent = new ArrayList<Reference>();
2492    this.parent.add(t);
2493    return this;
2494  }
2495
2496  /**
2497   * @return The first repetition of repeating field {@link #parent}, creating it
2498   *         if it does not already exist
2499   */
2500  public Reference getParentFirstRep() {
2501    if (getParent().isEmpty()) {
2502      addParent();
2503    }
2504    return getParent().get(0);
2505  }
2506
2507  /**
2508   * @deprecated Use Reference#setResource(IBaseResource) instead
2509   */
2510  @Deprecated
2511  public List<BiologicallyDerivedProduct> getParentTarget() {
2512    if (this.parentTarget == null)
2513      this.parentTarget = new ArrayList<BiologicallyDerivedProduct>();
2514    return this.parentTarget;
2515  }
2516
2517  /**
2518   * @deprecated Use Reference#setResource(IBaseResource) instead
2519   */
2520  @Deprecated
2521  public BiologicallyDerivedProduct addParentTarget() {
2522    BiologicallyDerivedProduct r = new BiologicallyDerivedProduct();
2523    if (this.parentTarget == null)
2524      this.parentTarget = new ArrayList<BiologicallyDerivedProduct>();
2525    this.parentTarget.add(r);
2526    return r;
2527  }
2528
2529  /**
2530   * @return {@link #collection} (How this product was collected.)
2531   */
2532  public BiologicallyDerivedProductCollectionComponent getCollection() {
2533    if (this.collection == null)
2534      if (Configuration.errorOnAutoCreate())
2535        throw new Error("Attempt to auto-create BiologicallyDerivedProduct.collection");
2536      else if (Configuration.doAutoCreate())
2537        this.collection = new BiologicallyDerivedProductCollectionComponent(); // cc
2538    return this.collection;
2539  }
2540
2541  public boolean hasCollection() {
2542    return this.collection != null && !this.collection.isEmpty();
2543  }
2544
2545  /**
2546   * @param value {@link #collection} (How this product was collected.)
2547   */
2548  public BiologicallyDerivedProduct setCollection(BiologicallyDerivedProductCollectionComponent value) {
2549    this.collection = value;
2550    return this;
2551  }
2552
2553  /**
2554   * @return {@link #processing} (Any processing of the product during collection
2555   *         that does not change the fundamental nature of the product. For
2556   *         example adding anti-coagulants during the collection of Peripheral
2557   *         Blood Stem Cells.)
2558   */
2559  public List<BiologicallyDerivedProductProcessingComponent> getProcessing() {
2560    if (this.processing == null)
2561      this.processing = new ArrayList<BiologicallyDerivedProductProcessingComponent>();
2562    return this.processing;
2563  }
2564
2565  /**
2566   * @return Returns a reference to <code>this</code> for easy method chaining
2567   */
2568  public BiologicallyDerivedProduct setProcessing(List<BiologicallyDerivedProductProcessingComponent> theProcessing) {
2569    this.processing = theProcessing;
2570    return this;
2571  }
2572
2573  public boolean hasProcessing() {
2574    if (this.processing == null)
2575      return false;
2576    for (BiologicallyDerivedProductProcessingComponent item : this.processing)
2577      if (!item.isEmpty())
2578        return true;
2579    return false;
2580  }
2581
2582  public BiologicallyDerivedProductProcessingComponent addProcessing() { // 3
2583    BiologicallyDerivedProductProcessingComponent t = new BiologicallyDerivedProductProcessingComponent();
2584    if (this.processing == null)
2585      this.processing = new ArrayList<BiologicallyDerivedProductProcessingComponent>();
2586    this.processing.add(t);
2587    return t;
2588  }
2589
2590  public BiologicallyDerivedProduct addProcessing(BiologicallyDerivedProductProcessingComponent t) { // 3
2591    if (t == null)
2592      return this;
2593    if (this.processing == null)
2594      this.processing = new ArrayList<BiologicallyDerivedProductProcessingComponent>();
2595    this.processing.add(t);
2596    return this;
2597  }
2598
2599  /**
2600   * @return The first repetition of repeating field {@link #processing}, creating
2601   *         it if it does not already exist
2602   */
2603  public BiologicallyDerivedProductProcessingComponent getProcessingFirstRep() {
2604    if (getProcessing().isEmpty()) {
2605      addProcessing();
2606    }
2607    return getProcessing().get(0);
2608  }
2609
2610  /**
2611   * @return {@link #manipulation} (Any manipulation of product post-collection
2612   *         that is intended to alter the product. For example a buffy-coat
2613   *         enrichment or CD8 reduction of Peripheral Blood Stem Cells to make it
2614   *         more suitable for infusion.)
2615   */
2616  public BiologicallyDerivedProductManipulationComponent getManipulation() {
2617    if (this.manipulation == null)
2618      if (Configuration.errorOnAutoCreate())
2619        throw new Error("Attempt to auto-create BiologicallyDerivedProduct.manipulation");
2620      else if (Configuration.doAutoCreate())
2621        this.manipulation = new BiologicallyDerivedProductManipulationComponent(); // cc
2622    return this.manipulation;
2623  }
2624
2625  public boolean hasManipulation() {
2626    return this.manipulation != null && !this.manipulation.isEmpty();
2627  }
2628
2629  /**
2630   * @param value {@link #manipulation} (Any manipulation of product
2631   *              post-collection that is intended to alter the product. For
2632   *              example a buffy-coat enrichment or CD8 reduction of Peripheral
2633   *              Blood Stem Cells to make it more suitable for infusion.)
2634   */
2635  public BiologicallyDerivedProduct setManipulation(BiologicallyDerivedProductManipulationComponent value) {
2636    this.manipulation = value;
2637    return this;
2638  }
2639
2640  /**
2641   * @return {@link #storage} (Product storage.)
2642   */
2643  public List<BiologicallyDerivedProductStorageComponent> getStorage() {
2644    if (this.storage == null)
2645      this.storage = new ArrayList<BiologicallyDerivedProductStorageComponent>();
2646    return this.storage;
2647  }
2648
2649  /**
2650   * @return Returns a reference to <code>this</code> for easy method chaining
2651   */
2652  public BiologicallyDerivedProduct setStorage(List<BiologicallyDerivedProductStorageComponent> theStorage) {
2653    this.storage = theStorage;
2654    return this;
2655  }
2656
2657  public boolean hasStorage() {
2658    if (this.storage == null)
2659      return false;
2660    for (BiologicallyDerivedProductStorageComponent item : this.storage)
2661      if (!item.isEmpty())
2662        return true;
2663    return false;
2664  }
2665
2666  public BiologicallyDerivedProductStorageComponent addStorage() { // 3
2667    BiologicallyDerivedProductStorageComponent t = new BiologicallyDerivedProductStorageComponent();
2668    if (this.storage == null)
2669      this.storage = new ArrayList<BiologicallyDerivedProductStorageComponent>();
2670    this.storage.add(t);
2671    return t;
2672  }
2673
2674  public BiologicallyDerivedProduct addStorage(BiologicallyDerivedProductStorageComponent t) { // 3
2675    if (t == null)
2676      return this;
2677    if (this.storage == null)
2678      this.storage = new ArrayList<BiologicallyDerivedProductStorageComponent>();
2679    this.storage.add(t);
2680    return this;
2681  }
2682
2683  /**
2684   * @return The first repetition of repeating field {@link #storage}, creating it
2685   *         if it does not already exist
2686   */
2687  public BiologicallyDerivedProductStorageComponent getStorageFirstRep() {
2688    if (getStorage().isEmpty()) {
2689      addStorage();
2690    }
2691    return getStorage().get(0);
2692  }
2693
2694  protected void listChildren(List<Property> children) {
2695    super.listChildren(children);
2696    children.add(new Property("identifier", "Identifier",
2697        "This records identifiers associated with this biologically derived product instance that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).",
2698        0, java.lang.Integer.MAX_VALUE, identifier));
2699    children.add(new Property("productCategory", "code", "Broad category of this product.", 0, 1, productCategory));
2700    children.add(new Property("productCode", "CodeableConcept",
2701        "A code that identifies the kind of this biologically derived product (SNOMED Ctcode).", 0, 1, productCode));
2702    children.add(new Property("status", "code", "Whether the product is currently available.", 0, 1, status));
2703    children.add(new Property("request", "Reference(ServiceRequest)",
2704        "Procedure request to obtain this biologically derived product.", 0, java.lang.Integer.MAX_VALUE, request));
2705    children.add(new Property("quantity", "integer", "Number of discrete units within this product.", 0, 1, quantity));
2706    children.add(new Property("parent", "Reference(BiologicallyDerivedProduct)", "Parent product (if any).", 0,
2707        java.lang.Integer.MAX_VALUE, parent));
2708    children.add(new Property("collection", "", "How this product was collected.", 0, 1, collection));
2709    children.add(new Property("processing", "",
2710        "Any processing of the product during collection that does not change the fundamental nature of the product. For example adding anti-coagulants during the collection of Peripheral Blood Stem Cells.",
2711        0, java.lang.Integer.MAX_VALUE, processing));
2712    children.add(new Property("manipulation", "",
2713        "Any manipulation of product post-collection that is intended to alter the product.  For example a buffy-coat enrichment or CD8 reduction of Peripheral Blood Stem Cells to make it more suitable for infusion.",
2714        0, 1, manipulation));
2715    children.add(new Property("storage", "", "Product storage.", 0, java.lang.Integer.MAX_VALUE, storage));
2716  }
2717
2718  @Override
2719  public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2720    switch (_hash) {
2721    case -1618432855:
2722      /* identifier */ return new Property("identifier", "Identifier",
2723          "This records identifiers associated with this biologically derived product instance that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).",
2724          0, java.lang.Integer.MAX_VALUE, identifier);
2725    case 197299981:
2726      /* productCategory */ return new Property("productCategory", "code", "Broad category of this product.", 0, 1,
2727          productCategory);
2728    case -1492131972:
2729      /* productCode */ return new Property("productCode", "CodeableConcept",
2730          "A code that identifies the kind of this biologically derived product (SNOMED Ctcode).", 0, 1, productCode);
2731    case -892481550:
2732      /* status */ return new Property("status", "code", "Whether the product is currently available.", 0, 1, status);
2733    case 1095692943:
2734      /* request */ return new Property("request", "Reference(ServiceRequest)",
2735          "Procedure request to obtain this biologically derived product.", 0, java.lang.Integer.MAX_VALUE, request);
2736    case -1285004149:
2737      /* quantity */ return new Property("quantity", "integer", "Number of discrete units within this product.", 0, 1,
2738          quantity);
2739    case -995424086:
2740      /* parent */ return new Property("parent", "Reference(BiologicallyDerivedProduct)", "Parent product (if any).", 0,
2741          java.lang.Integer.MAX_VALUE, parent);
2742    case -1741312354:
2743      /* collection */ return new Property("collection", "", "How this product was collected.", 0, 1, collection);
2744    case 422194963:
2745      /* processing */ return new Property("processing", "",
2746          "Any processing of the product during collection that does not change the fundamental nature of the product. For example adding anti-coagulants during the collection of Peripheral Blood Stem Cells.",
2747          0, java.lang.Integer.MAX_VALUE, processing);
2748    case -696214627:
2749      /* manipulation */ return new Property("manipulation", "",
2750          "Any manipulation of product post-collection that is intended to alter the product.  For example a buffy-coat enrichment or CD8 reduction of Peripheral Blood Stem Cells to make it more suitable for infusion.",
2751          0, 1, manipulation);
2752    case -1884274053:
2753      /* storage */ return new Property("storage", "", "Product storage.", 0, java.lang.Integer.MAX_VALUE, storage);
2754    default:
2755      return super.getNamedProperty(_hash, _name, _checkValid);
2756    }
2757
2758  }
2759
2760  @Override
2761  public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2762    switch (hash) {
2763    case -1618432855:
2764      /* identifier */ return this.identifier == null ? new Base[0]
2765          : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
2766    case 197299981:
2767      /* productCategory */ return this.productCategory == null ? new Base[0] : new Base[] { this.productCategory }; // Enumeration<BiologicallyDerivedProductCategory>
2768    case -1492131972:
2769      /* productCode */ return this.productCode == null ? new Base[0] : new Base[] { this.productCode }; // CodeableConcept
2770    case -892481550:
2771      /* status */ return this.status == null ? new Base[0] : new Base[] { this.status }; // Enumeration<BiologicallyDerivedProductStatus>
2772    case 1095692943:
2773      /* request */ return this.request == null ? new Base[0] : this.request.toArray(new Base[this.request.size()]); // Reference
2774    case -1285004149:
2775      /* quantity */ return this.quantity == null ? new Base[0] : new Base[] { this.quantity }; // IntegerType
2776    case -995424086:
2777      /* parent */ return this.parent == null ? new Base[0] : this.parent.toArray(new Base[this.parent.size()]); // Reference
2778    case -1741312354:
2779      /* collection */ return this.collection == null ? new Base[0] : new Base[] { this.collection }; // BiologicallyDerivedProductCollectionComponent
2780    case 422194963:
2781      /* processing */ return this.processing == null ? new Base[0]
2782          : this.processing.toArray(new Base[this.processing.size()]); // BiologicallyDerivedProductProcessingComponent
2783    case -696214627:
2784      /* manipulation */ return this.manipulation == null ? new Base[0] : new Base[] { this.manipulation }; // BiologicallyDerivedProductManipulationComponent
2785    case -1884274053:
2786      /* storage */ return this.storage == null ? new Base[0] : this.storage.toArray(new Base[this.storage.size()]); // BiologicallyDerivedProductStorageComponent
2787    default:
2788      return super.getProperty(hash, name, checkValid);
2789    }
2790
2791  }
2792
2793  @Override
2794  public Base setProperty(int hash, String name, Base value) throws FHIRException {
2795    switch (hash) {
2796    case -1618432855: // identifier
2797      this.getIdentifier().add(castToIdentifier(value)); // Identifier
2798      return value;
2799    case 197299981: // productCategory
2800      value = new BiologicallyDerivedProductCategoryEnumFactory().fromType(castToCode(value));
2801      this.productCategory = (Enumeration) value; // Enumeration<BiologicallyDerivedProductCategory>
2802      return value;
2803    case -1492131972: // productCode
2804      this.productCode = castToCodeableConcept(value); // CodeableConcept
2805      return value;
2806    case -892481550: // status
2807      value = new BiologicallyDerivedProductStatusEnumFactory().fromType(castToCode(value));
2808      this.status = (Enumeration) value; // Enumeration<BiologicallyDerivedProductStatus>
2809      return value;
2810    case 1095692943: // request
2811      this.getRequest().add(castToReference(value)); // Reference
2812      return value;
2813    case -1285004149: // quantity
2814      this.quantity = castToInteger(value); // IntegerType
2815      return value;
2816    case -995424086: // parent
2817      this.getParent().add(castToReference(value)); // Reference
2818      return value;
2819    case -1741312354: // collection
2820      this.collection = (BiologicallyDerivedProductCollectionComponent) value; // BiologicallyDerivedProductCollectionComponent
2821      return value;
2822    case 422194963: // processing
2823      this.getProcessing().add((BiologicallyDerivedProductProcessingComponent) value); // BiologicallyDerivedProductProcessingComponent
2824      return value;
2825    case -696214627: // manipulation
2826      this.manipulation = (BiologicallyDerivedProductManipulationComponent) value; // BiologicallyDerivedProductManipulationComponent
2827      return value;
2828    case -1884274053: // storage
2829      this.getStorage().add((BiologicallyDerivedProductStorageComponent) value); // BiologicallyDerivedProductStorageComponent
2830      return value;
2831    default:
2832      return super.setProperty(hash, name, value);
2833    }
2834
2835  }
2836
2837  @Override
2838  public Base setProperty(String name, Base value) throws FHIRException {
2839    if (name.equals("identifier")) {
2840      this.getIdentifier().add(castToIdentifier(value));
2841    } else if (name.equals("productCategory")) {
2842      value = new BiologicallyDerivedProductCategoryEnumFactory().fromType(castToCode(value));
2843      this.productCategory = (Enumeration) value; // Enumeration<BiologicallyDerivedProductCategory>
2844    } else if (name.equals("productCode")) {
2845      this.productCode = castToCodeableConcept(value); // CodeableConcept
2846    } else if (name.equals("status")) {
2847      value = new BiologicallyDerivedProductStatusEnumFactory().fromType(castToCode(value));
2848      this.status = (Enumeration) value; // Enumeration<BiologicallyDerivedProductStatus>
2849    } else if (name.equals("request")) {
2850      this.getRequest().add(castToReference(value));
2851    } else if (name.equals("quantity")) {
2852      this.quantity = castToInteger(value); // IntegerType
2853    } else if (name.equals("parent")) {
2854      this.getParent().add(castToReference(value));
2855    } else if (name.equals("collection")) {
2856      this.collection = (BiologicallyDerivedProductCollectionComponent) value; // BiologicallyDerivedProductCollectionComponent
2857    } else if (name.equals("processing")) {
2858      this.getProcessing().add((BiologicallyDerivedProductProcessingComponent) value);
2859    } else if (name.equals("manipulation")) {
2860      this.manipulation = (BiologicallyDerivedProductManipulationComponent) value; // BiologicallyDerivedProductManipulationComponent
2861    } else if (name.equals("storage")) {
2862      this.getStorage().add((BiologicallyDerivedProductStorageComponent) value);
2863    } else
2864      return super.setProperty(name, value);
2865    return value;
2866  }
2867
2868  @Override
2869  public Base makeProperty(int hash, String name) throws FHIRException {
2870    switch (hash) {
2871    case -1618432855:
2872      return addIdentifier();
2873    case 197299981:
2874      return getProductCategoryElement();
2875    case -1492131972:
2876      return getProductCode();
2877    case -892481550:
2878      return getStatusElement();
2879    case 1095692943:
2880      return addRequest();
2881    case -1285004149:
2882      return getQuantityElement();
2883    case -995424086:
2884      return addParent();
2885    case -1741312354:
2886      return getCollection();
2887    case 422194963:
2888      return addProcessing();
2889    case -696214627:
2890      return getManipulation();
2891    case -1884274053:
2892      return addStorage();
2893    default:
2894      return super.makeProperty(hash, name);
2895    }
2896
2897  }
2898
2899  @Override
2900  public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2901    switch (hash) {
2902    case -1618432855:
2903      /* identifier */ return new String[] { "Identifier" };
2904    case 197299981:
2905      /* productCategory */ return new String[] { "code" };
2906    case -1492131972:
2907      /* productCode */ return new String[] { "CodeableConcept" };
2908    case -892481550:
2909      /* status */ return new String[] { "code" };
2910    case 1095692943:
2911      /* request */ return new String[] { "Reference" };
2912    case -1285004149:
2913      /* quantity */ return new String[] { "integer" };
2914    case -995424086:
2915      /* parent */ return new String[] { "Reference" };
2916    case -1741312354:
2917      /* collection */ return new String[] {};
2918    case 422194963:
2919      /* processing */ return new String[] {};
2920    case -696214627:
2921      /* manipulation */ return new String[] {};
2922    case -1884274053:
2923      /* storage */ return new String[] {};
2924    default:
2925      return super.getTypesForProperty(hash, name);
2926    }
2927
2928  }
2929
2930  @Override
2931  public Base addChild(String name) throws FHIRException {
2932    if (name.equals("identifier")) {
2933      return addIdentifier();
2934    } else if (name.equals("productCategory")) {
2935      throw new FHIRException("Cannot call addChild on a singleton property BiologicallyDerivedProduct.productCategory");
2936    } else if (name.equals("productCode")) {
2937      this.productCode = new CodeableConcept();
2938      return this.productCode;
2939    } else if (name.equals("status")) {
2940      throw new FHIRException("Cannot call addChild on a singleton property BiologicallyDerivedProduct.status");
2941    } else if (name.equals("request")) {
2942      return addRequest();
2943    } else if (name.equals("quantity")) {
2944      throw new FHIRException("Cannot call addChild on a singleton property BiologicallyDerivedProduct.quantity");
2945    } else if (name.equals("parent")) {
2946      return addParent();
2947    } else if (name.equals("collection")) {
2948      this.collection = new BiologicallyDerivedProductCollectionComponent();
2949      return this.collection;
2950    } else if (name.equals("processing")) {
2951      return addProcessing();
2952    } else if (name.equals("manipulation")) {
2953      this.manipulation = new BiologicallyDerivedProductManipulationComponent();
2954      return this.manipulation;
2955    } else if (name.equals("storage")) {
2956      return addStorage();
2957    } else
2958      return super.addChild(name);
2959  }
2960
2961  public String fhirType() {
2962    return "BiologicallyDerivedProduct";
2963
2964  }
2965
2966  public BiologicallyDerivedProduct copy() {
2967    BiologicallyDerivedProduct dst = new BiologicallyDerivedProduct();
2968    copyValues(dst);
2969    return dst;
2970  }
2971
2972  public void copyValues(BiologicallyDerivedProduct dst) {
2973    super.copyValues(dst);
2974    if (identifier != null) {
2975      dst.identifier = new ArrayList<Identifier>();
2976      for (Identifier i : identifier)
2977        dst.identifier.add(i.copy());
2978    }
2979    ;
2980    dst.productCategory = productCategory == null ? null : productCategory.copy();
2981    dst.productCode = productCode == null ? null : productCode.copy();
2982    dst.status = status == null ? null : status.copy();
2983    if (request != null) {
2984      dst.request = new ArrayList<Reference>();
2985      for (Reference i : request)
2986        dst.request.add(i.copy());
2987    }
2988    ;
2989    dst.quantity = quantity == null ? null : quantity.copy();
2990    if (parent != null) {
2991      dst.parent = new ArrayList<Reference>();
2992      for (Reference i : parent)
2993        dst.parent.add(i.copy());
2994    }
2995    ;
2996    dst.collection = collection == null ? null : collection.copy();
2997    if (processing != null) {
2998      dst.processing = new ArrayList<BiologicallyDerivedProductProcessingComponent>();
2999      for (BiologicallyDerivedProductProcessingComponent i : processing)
3000        dst.processing.add(i.copy());
3001    }
3002    ;
3003    dst.manipulation = manipulation == null ? null : manipulation.copy();
3004    if (storage != null) {
3005      dst.storage = new ArrayList<BiologicallyDerivedProductStorageComponent>();
3006      for (BiologicallyDerivedProductStorageComponent i : storage)
3007        dst.storage.add(i.copy());
3008    }
3009    ;
3010  }
3011
3012  protected BiologicallyDerivedProduct typedCopy() {
3013    return copy();
3014  }
3015
3016  @Override
3017  public boolean equalsDeep(Base other_) {
3018    if (!super.equalsDeep(other_))
3019      return false;
3020    if (!(other_ instanceof BiologicallyDerivedProduct))
3021      return false;
3022    BiologicallyDerivedProduct o = (BiologicallyDerivedProduct) other_;
3023    return compareDeep(identifier, o.identifier, true) && compareDeep(productCategory, o.productCategory, true)
3024        && compareDeep(productCode, o.productCode, true) && compareDeep(status, o.status, true)
3025        && compareDeep(request, o.request, true) && compareDeep(quantity, o.quantity, true)
3026        && compareDeep(parent, o.parent, true) && compareDeep(collection, o.collection, true)
3027        && compareDeep(processing, o.processing, true) && compareDeep(manipulation, o.manipulation, true)
3028        && compareDeep(storage, o.storage, true);
3029  }
3030
3031  @Override
3032  public boolean equalsShallow(Base other_) {
3033    if (!super.equalsShallow(other_))
3034      return false;
3035    if (!(other_ instanceof BiologicallyDerivedProduct))
3036      return false;
3037    BiologicallyDerivedProduct o = (BiologicallyDerivedProduct) other_;
3038    return compareValues(productCategory, o.productCategory, true) && compareValues(status, o.status, true)
3039        && compareValues(quantity, o.quantity, true);
3040  }
3041
3042  public boolean isEmpty() {
3043    return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, productCategory, productCode, status,
3044        request, quantity, parent, collection, processing, manipulation, storage);
3045  }
3046
3047  @Override
3048  public ResourceType getResourceType() {
3049    return ResourceType.BiologicallyDerivedProduct;
3050  }
3051
3052}