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