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