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