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