001package org.hl7.fhir.r4.model;
002
003
004
005/*
006  Copyright (c) 2011+, HL7, Inc.
007  All rights reserved.
008  
009  Redistribution and use in source and binary forms, with or without modification, 
010  are permitted provided that the following conditions are met:
011  
012   * Redistributions of source code must retain the above copyright notice, this 
013     list of conditions and the following disclaimer.
014   * Redistributions in binary form must reproduce the above copyright notice, 
015     this list of conditions and the following disclaimer in the documentation 
016     and/or other materials provided with the distribution.
017   * Neither the name of HL7 nor the names of its contributors may be used to 
018     endorse or promote products derived from this software without specific 
019     prior written permission.
020  
021  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
022  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
023  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
024  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
025  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
026  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
027  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
028  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
029  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
030  POSSIBILITY OF SUCH DAMAGE.
031  
032*/
033
034
035// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1
036
037import java.util.*;
038
039import java.math.*;
040import org.hl7.fhir.utilities.Utilities;
041import org.hl7.fhir.r4.model.Enumerations.*;
042import ca.uhn.fhir.model.api.annotation.ResourceDef;
043import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
044import ca.uhn.fhir.model.api.annotation.Child;
045import ca.uhn.fhir.model.api.annotation.ChildOrder;
046import ca.uhn.fhir.model.api.annotation.Description;
047import ca.uhn.fhir.model.api.annotation.Block;
048import org.hl7.fhir.instance.model.api.*;
049import org.hl7.fhir.exceptions.FHIRException;
050/**
051 * Set of definitional characteristics for a kind of observation or measurement produced or consumed by an orderable health care service.
052 */
053@ResourceDef(name="ObservationDefinition", profile="http://hl7.org/fhir/StructureDefinition/ObservationDefinition")
054public class ObservationDefinition extends DomainResource {
055
056    public enum ObservationDataType {
057        /**
058         * A measured amount.
059         */
060        QUANTITY, 
061        /**
062         * A coded concept from a reference terminology and/or text.
063         */
064        CODEABLECONCEPT, 
065        /**
066         * A sequence of Unicode characters.
067         */
068        STRING, 
069        /**
070         * true or false.
071         */
072        BOOLEAN, 
073        /**
074         * A signed integer.
075         */
076        INTEGER, 
077        /**
078         * A set of values bounded by low and high.
079         */
080        RANGE, 
081        /**
082         * A ratio of two Quantity values - a numerator and a denominator.
083         */
084        RATIO, 
085        /**
086         * A series of measurements taken by a device.
087         */
088        SAMPLEDDATA, 
089        /**
090         * A time during the day, in the format hh:mm:ss.
091         */
092        TIME, 
093        /**
094         * A date, date-time or partial date (e.g. just year or year + month) as used in human communication.
095         */
096        DATETIME, 
097        /**
098         * A time range defined by start and end date/time.
099         */
100        PERIOD, 
101        /**
102         * added to help the parsers with the generic types
103         */
104        NULL;
105        public static ObservationDataType fromCode(String codeString) throws FHIRException {
106            if (codeString == null || "".equals(codeString))
107                return null;
108        if ("Quantity".equals(codeString))
109          return QUANTITY;
110        if ("CodeableConcept".equals(codeString))
111          return CODEABLECONCEPT;
112        if ("string".equals(codeString))
113          return STRING;
114        if ("boolean".equals(codeString))
115          return BOOLEAN;
116        if ("integer".equals(codeString))
117          return INTEGER;
118        if ("Range".equals(codeString))
119          return RANGE;
120        if ("Ratio".equals(codeString))
121          return RATIO;
122        if ("SampledData".equals(codeString))
123          return SAMPLEDDATA;
124        if ("time".equals(codeString))
125          return TIME;
126        if ("dateTime".equals(codeString))
127          return DATETIME;
128        if ("Period".equals(codeString))
129          return PERIOD;
130        if (Configuration.isAcceptInvalidEnums())
131          return null;
132        else
133          throw new FHIRException("Unknown ObservationDataType code '"+codeString+"'");
134        }
135        public String toCode() {
136          switch (this) {
137            case QUANTITY: return "Quantity";
138            case CODEABLECONCEPT: return "CodeableConcept";
139            case STRING: return "string";
140            case BOOLEAN: return "boolean";
141            case INTEGER: return "integer";
142            case RANGE: return "Range";
143            case RATIO: return "Ratio";
144            case SAMPLEDDATA: return "SampledData";
145            case TIME: return "time";
146            case DATETIME: return "dateTime";
147            case PERIOD: return "Period";
148            default: return "?";
149          }
150        }
151        public String getSystem() {
152          switch (this) {
153            case QUANTITY: return "http://hl7.org/fhir/permitted-data-type";
154            case CODEABLECONCEPT: return "http://hl7.org/fhir/permitted-data-type";
155            case STRING: return "http://hl7.org/fhir/permitted-data-type";
156            case BOOLEAN: return "http://hl7.org/fhir/permitted-data-type";
157            case INTEGER: return "http://hl7.org/fhir/permitted-data-type";
158            case RANGE: return "http://hl7.org/fhir/permitted-data-type";
159            case RATIO: return "http://hl7.org/fhir/permitted-data-type";
160            case SAMPLEDDATA: return "http://hl7.org/fhir/permitted-data-type";
161            case TIME: return "http://hl7.org/fhir/permitted-data-type";
162            case DATETIME: return "http://hl7.org/fhir/permitted-data-type";
163            case PERIOD: return "http://hl7.org/fhir/permitted-data-type";
164            default: return "?";
165          }
166        }
167        public String getDefinition() {
168          switch (this) {
169            case QUANTITY: return "A measured amount.";
170            case CODEABLECONCEPT: return "A coded concept from a reference terminology and/or text.";
171            case STRING: return "A sequence of Unicode characters.";
172            case BOOLEAN: return "true or false.";
173            case INTEGER: return "A signed integer.";
174            case RANGE: return "A set of values bounded by low and high.";
175            case RATIO: return "A ratio of two Quantity values - a numerator and a denominator.";
176            case SAMPLEDDATA: return "A series of measurements taken by a device.";
177            case TIME: return "A time during the day, in the format hh:mm:ss.";
178            case DATETIME: return "A date, date-time or partial date (e.g. just year or year + month) as used in human communication.";
179            case PERIOD: return "A time range defined by start and end date/time.";
180            default: return "?";
181          }
182        }
183        public String getDisplay() {
184          switch (this) {
185            case QUANTITY: return "Quantity";
186            case CODEABLECONCEPT: return "CodeableConcept";
187            case STRING: return "string";
188            case BOOLEAN: return "boolean";
189            case INTEGER: return "integer";
190            case RANGE: return "Range";
191            case RATIO: return "Ratio";
192            case SAMPLEDDATA: return "SampledData";
193            case TIME: return "time";
194            case DATETIME: return "dateTime";
195            case PERIOD: return "Period";
196            default: return "?";
197          }
198        }
199    }
200
201  public static class ObservationDataTypeEnumFactory implements EnumFactory<ObservationDataType> {
202    public ObservationDataType fromCode(String codeString) throws IllegalArgumentException {
203      if (codeString == null || "".equals(codeString))
204            if (codeString == null || "".equals(codeString))
205                return null;
206        if ("Quantity".equals(codeString))
207          return ObservationDataType.QUANTITY;
208        if ("CodeableConcept".equals(codeString))
209          return ObservationDataType.CODEABLECONCEPT;
210        if ("string".equals(codeString))
211          return ObservationDataType.STRING;
212        if ("boolean".equals(codeString))
213          return ObservationDataType.BOOLEAN;
214        if ("integer".equals(codeString))
215          return ObservationDataType.INTEGER;
216        if ("Range".equals(codeString))
217          return ObservationDataType.RANGE;
218        if ("Ratio".equals(codeString))
219          return ObservationDataType.RATIO;
220        if ("SampledData".equals(codeString))
221          return ObservationDataType.SAMPLEDDATA;
222        if ("time".equals(codeString))
223          return ObservationDataType.TIME;
224        if ("dateTime".equals(codeString))
225          return ObservationDataType.DATETIME;
226        if ("Period".equals(codeString))
227          return ObservationDataType.PERIOD;
228        throw new IllegalArgumentException("Unknown ObservationDataType code '"+codeString+"'");
229        }
230        public Enumeration<ObservationDataType> fromType(Base code) throws FHIRException {
231          if (code == null)
232            return null;
233          if (code.isEmpty())
234            return new Enumeration<ObservationDataType>(this);
235          String codeString = ((PrimitiveType) code).asStringValue();
236          if (codeString == null || "".equals(codeString))
237            return null;
238        if ("Quantity".equals(codeString))
239          return new Enumeration<ObservationDataType>(this, ObservationDataType.QUANTITY);
240        if ("CodeableConcept".equals(codeString))
241          return new Enumeration<ObservationDataType>(this, ObservationDataType.CODEABLECONCEPT);
242        if ("string".equals(codeString))
243          return new Enumeration<ObservationDataType>(this, ObservationDataType.STRING);
244        if ("boolean".equals(codeString))
245          return new Enumeration<ObservationDataType>(this, ObservationDataType.BOOLEAN);
246        if ("integer".equals(codeString))
247          return new Enumeration<ObservationDataType>(this, ObservationDataType.INTEGER);
248        if ("Range".equals(codeString))
249          return new Enumeration<ObservationDataType>(this, ObservationDataType.RANGE);
250        if ("Ratio".equals(codeString))
251          return new Enumeration<ObservationDataType>(this, ObservationDataType.RATIO);
252        if ("SampledData".equals(codeString))
253          return new Enumeration<ObservationDataType>(this, ObservationDataType.SAMPLEDDATA);
254        if ("time".equals(codeString))
255          return new Enumeration<ObservationDataType>(this, ObservationDataType.TIME);
256        if ("dateTime".equals(codeString))
257          return new Enumeration<ObservationDataType>(this, ObservationDataType.DATETIME);
258        if ("Period".equals(codeString))
259          return new Enumeration<ObservationDataType>(this, ObservationDataType.PERIOD);
260        throw new FHIRException("Unknown ObservationDataType code '"+codeString+"'");
261        }
262    public String toCode(ObservationDataType code) {
263      if (code == ObservationDataType.QUANTITY)
264        return "Quantity";
265      if (code == ObservationDataType.CODEABLECONCEPT)
266        return "CodeableConcept";
267      if (code == ObservationDataType.STRING)
268        return "string";
269      if (code == ObservationDataType.BOOLEAN)
270        return "boolean";
271      if (code == ObservationDataType.INTEGER)
272        return "integer";
273      if (code == ObservationDataType.RANGE)
274        return "Range";
275      if (code == ObservationDataType.RATIO)
276        return "Ratio";
277      if (code == ObservationDataType.SAMPLEDDATA)
278        return "SampledData";
279      if (code == ObservationDataType.TIME)
280        return "time";
281      if (code == ObservationDataType.DATETIME)
282        return "dateTime";
283      if (code == ObservationDataType.PERIOD)
284        return "Period";
285      return "?";
286      }
287    public String toSystem(ObservationDataType code) {
288      return code.getSystem();
289      }
290    }
291
292    public enum ObservationRangeCategory {
293        /**
294         * Reference (Normal) Range for Ordinal and Continuous Observations.
295         */
296        REFERENCE, 
297        /**
298         * Critical Range for Ordinal and Continuous Observations.
299         */
300        CRITICAL, 
301        /**
302         * Absolute Range for Ordinal and Continuous Observations. Results outside this range are not possible.
303         */
304        ABSOLUTE, 
305        /**
306         * added to help the parsers with the generic types
307         */
308        NULL;
309        public static ObservationRangeCategory fromCode(String codeString) throws FHIRException {
310            if (codeString == null || "".equals(codeString))
311                return null;
312        if ("reference".equals(codeString))
313          return REFERENCE;
314        if ("critical".equals(codeString))
315          return CRITICAL;
316        if ("absolute".equals(codeString))
317          return ABSOLUTE;
318        if (Configuration.isAcceptInvalidEnums())
319          return null;
320        else
321          throw new FHIRException("Unknown ObservationRangeCategory code '"+codeString+"'");
322        }
323        public String toCode() {
324          switch (this) {
325            case REFERENCE: return "reference";
326            case CRITICAL: return "critical";
327            case ABSOLUTE: return "absolute";
328            default: return "?";
329          }
330        }
331        public String getSystem() {
332          switch (this) {
333            case REFERENCE: return "http://hl7.org/fhir/observation-range-category";
334            case CRITICAL: return "http://hl7.org/fhir/observation-range-category";
335            case ABSOLUTE: return "http://hl7.org/fhir/observation-range-category";
336            default: return "?";
337          }
338        }
339        public String getDefinition() {
340          switch (this) {
341            case REFERENCE: return "Reference (Normal) Range for Ordinal and Continuous Observations.";
342            case CRITICAL: return "Critical Range for Ordinal and Continuous Observations.";
343            case ABSOLUTE: return "Absolute Range for Ordinal and Continuous Observations. Results outside this range are not possible.";
344            default: return "?";
345          }
346        }
347        public String getDisplay() {
348          switch (this) {
349            case REFERENCE: return "reference range";
350            case CRITICAL: return "critical range";
351            case ABSOLUTE: return "absolute range";
352            default: return "?";
353          }
354        }
355    }
356
357  public static class ObservationRangeCategoryEnumFactory implements EnumFactory<ObservationRangeCategory> {
358    public ObservationRangeCategory fromCode(String codeString) throws IllegalArgumentException {
359      if (codeString == null || "".equals(codeString))
360            if (codeString == null || "".equals(codeString))
361                return null;
362        if ("reference".equals(codeString))
363          return ObservationRangeCategory.REFERENCE;
364        if ("critical".equals(codeString))
365          return ObservationRangeCategory.CRITICAL;
366        if ("absolute".equals(codeString))
367          return ObservationRangeCategory.ABSOLUTE;
368        throw new IllegalArgumentException("Unknown ObservationRangeCategory code '"+codeString+"'");
369        }
370        public Enumeration<ObservationRangeCategory> fromType(Base code) throws FHIRException {
371          if (code == null)
372            return null;
373          if (code.isEmpty())
374            return new Enumeration<ObservationRangeCategory>(this);
375          String codeString = ((PrimitiveType) code).asStringValue();
376          if (codeString == null || "".equals(codeString))
377            return null;
378        if ("reference".equals(codeString))
379          return new Enumeration<ObservationRangeCategory>(this, ObservationRangeCategory.REFERENCE);
380        if ("critical".equals(codeString))
381          return new Enumeration<ObservationRangeCategory>(this, ObservationRangeCategory.CRITICAL);
382        if ("absolute".equals(codeString))
383          return new Enumeration<ObservationRangeCategory>(this, ObservationRangeCategory.ABSOLUTE);
384        throw new FHIRException("Unknown ObservationRangeCategory code '"+codeString+"'");
385        }
386    public String toCode(ObservationRangeCategory code) {
387      if (code == ObservationRangeCategory.REFERENCE)
388        return "reference";
389      if (code == ObservationRangeCategory.CRITICAL)
390        return "critical";
391      if (code == ObservationRangeCategory.ABSOLUTE)
392        return "absolute";
393      return "?";
394      }
395    public String toSystem(ObservationRangeCategory code) {
396      return code.getSystem();
397      }
398    }
399
400    @Block()
401    public static class ObservationDefinitionQuantitativeDetailsComponent extends BackboneElement implements IBaseBackboneElement {
402        /**
403         * Customary unit used to report quantitative results of observations conforming to this ObservationDefinition.
404         */
405        @Child(name = "customaryUnit", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=false)
406        @Description(shortDefinition="Customary unit for quantitative results", formalDefinition="Customary unit used to report quantitative results of observations conforming to this ObservationDefinition." )
407        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/ucum-units")
408        protected CodeableConcept customaryUnit;
409
410        /**
411         * SI unit used to report quantitative results of observations conforming to this ObservationDefinition.
412         */
413        @Child(name = "unit", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
414        @Description(shortDefinition="SI unit for quantitative results", formalDefinition="SI unit used to report quantitative results of observations conforming to this ObservationDefinition." )
415        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/ucum-units")
416        protected CodeableConcept unit;
417
418        /**
419         * Factor for converting value expressed with SI unit to value expressed with customary unit.
420         */
421        @Child(name = "conversionFactor", type = {DecimalType.class}, order=3, min=0, max=1, modifier=false, summary=false)
422        @Description(shortDefinition="SI to Customary unit conversion factor", formalDefinition="Factor for converting value expressed with SI unit to value expressed with customary unit." )
423        protected DecimalType conversionFactor;
424
425        /**
426         * Number of digits after decimal separator when the results of such observations are of type Quantity.
427         */
428        @Child(name = "decimalPrecision", type = {IntegerType.class}, order=4, min=0, max=1, modifier=false, summary=false)
429        @Description(shortDefinition="Decimal precision of observation quantitative results", formalDefinition="Number of digits after decimal separator when the results of such observations are of type Quantity." )
430        protected IntegerType decimalPrecision;
431
432        private static final long serialVersionUID = 1790019610L;
433
434    /**
435     * Constructor
436     */
437      public ObservationDefinitionQuantitativeDetailsComponent() {
438        super();
439      }
440
441        /**
442         * @return {@link #customaryUnit} (Customary unit used to report quantitative results of observations conforming to this ObservationDefinition.)
443         */
444        public CodeableConcept getCustomaryUnit() { 
445          if (this.customaryUnit == null)
446            if (Configuration.errorOnAutoCreate())
447              throw new Error("Attempt to auto-create ObservationDefinitionQuantitativeDetailsComponent.customaryUnit");
448            else if (Configuration.doAutoCreate())
449              this.customaryUnit = new CodeableConcept(); // cc
450          return this.customaryUnit;
451        }
452
453        public boolean hasCustomaryUnit() { 
454          return this.customaryUnit != null && !this.customaryUnit.isEmpty();
455        }
456
457        /**
458         * @param value {@link #customaryUnit} (Customary unit used to report quantitative results of observations conforming to this ObservationDefinition.)
459         */
460        public ObservationDefinitionQuantitativeDetailsComponent setCustomaryUnit(CodeableConcept value) { 
461          this.customaryUnit = value;
462          return this;
463        }
464
465        /**
466         * @return {@link #unit} (SI unit used to report quantitative results of observations conforming to this ObservationDefinition.)
467         */
468        public CodeableConcept getUnit() { 
469          if (this.unit == null)
470            if (Configuration.errorOnAutoCreate())
471              throw new Error("Attempt to auto-create ObservationDefinitionQuantitativeDetailsComponent.unit");
472            else if (Configuration.doAutoCreate())
473              this.unit = new CodeableConcept(); // cc
474          return this.unit;
475        }
476
477        public boolean hasUnit() { 
478          return this.unit != null && !this.unit.isEmpty();
479        }
480
481        /**
482         * @param value {@link #unit} (SI unit used to report quantitative results of observations conforming to this ObservationDefinition.)
483         */
484        public ObservationDefinitionQuantitativeDetailsComponent setUnit(CodeableConcept value) { 
485          this.unit = value;
486          return this;
487        }
488
489        /**
490         * @return {@link #conversionFactor} (Factor for converting value expressed with SI unit to value expressed with customary unit.). This is the underlying object with id, value and extensions. The accessor "getConversionFactor" gives direct access to the value
491         */
492        public DecimalType getConversionFactorElement() { 
493          if (this.conversionFactor == null)
494            if (Configuration.errorOnAutoCreate())
495              throw new Error("Attempt to auto-create ObservationDefinitionQuantitativeDetailsComponent.conversionFactor");
496            else if (Configuration.doAutoCreate())
497              this.conversionFactor = new DecimalType(); // bb
498          return this.conversionFactor;
499        }
500
501        public boolean hasConversionFactorElement() { 
502          return this.conversionFactor != null && !this.conversionFactor.isEmpty();
503        }
504
505        public boolean hasConversionFactor() { 
506          return this.conversionFactor != null && !this.conversionFactor.isEmpty();
507        }
508
509        /**
510         * @param value {@link #conversionFactor} (Factor for converting value expressed with SI unit to value expressed with customary unit.). This is the underlying object with id, value and extensions. The accessor "getConversionFactor" gives direct access to the value
511         */
512        public ObservationDefinitionQuantitativeDetailsComponent setConversionFactorElement(DecimalType value) { 
513          this.conversionFactor = value;
514          return this;
515        }
516
517        /**
518         * @return Factor for converting value expressed with SI unit to value expressed with customary unit.
519         */
520        public BigDecimal getConversionFactor() { 
521          return this.conversionFactor == null ? null : this.conversionFactor.getValue();
522        }
523
524        /**
525         * @param value Factor for converting value expressed with SI unit to value expressed with customary unit.
526         */
527        public ObservationDefinitionQuantitativeDetailsComponent setConversionFactor(BigDecimal value) { 
528          if (value == null)
529            this.conversionFactor = null;
530          else {
531            if (this.conversionFactor == null)
532              this.conversionFactor = new DecimalType();
533            this.conversionFactor.setValue(value);
534          }
535          return this;
536        }
537
538        /**
539         * @param value Factor for converting value expressed with SI unit to value expressed with customary unit.
540         */
541        public ObservationDefinitionQuantitativeDetailsComponent setConversionFactor(long value) { 
542              this.conversionFactor = new DecimalType();
543            this.conversionFactor.setValue(value);
544          return this;
545        }
546
547        /**
548         * @param value Factor for converting value expressed with SI unit to value expressed with customary unit.
549         */
550        public ObservationDefinitionQuantitativeDetailsComponent setConversionFactor(double value) { 
551              this.conversionFactor = new DecimalType();
552            this.conversionFactor.setValue(value);
553          return this;
554        }
555
556        /**
557         * @return {@link #decimalPrecision} (Number of digits after decimal separator when the results of such observations are of type Quantity.). This is the underlying object with id, value and extensions. The accessor "getDecimalPrecision" gives direct access to the value
558         */
559        public IntegerType getDecimalPrecisionElement() { 
560          if (this.decimalPrecision == null)
561            if (Configuration.errorOnAutoCreate())
562              throw new Error("Attempt to auto-create ObservationDefinitionQuantitativeDetailsComponent.decimalPrecision");
563            else if (Configuration.doAutoCreate())
564              this.decimalPrecision = new IntegerType(); // bb
565          return this.decimalPrecision;
566        }
567
568        public boolean hasDecimalPrecisionElement() { 
569          return this.decimalPrecision != null && !this.decimalPrecision.isEmpty();
570        }
571
572        public boolean hasDecimalPrecision() { 
573          return this.decimalPrecision != null && !this.decimalPrecision.isEmpty();
574        }
575
576        /**
577         * @param value {@link #decimalPrecision} (Number of digits after decimal separator when the results of such observations are of type Quantity.). This is the underlying object with id, value and extensions. The accessor "getDecimalPrecision" gives direct access to the value
578         */
579        public ObservationDefinitionQuantitativeDetailsComponent setDecimalPrecisionElement(IntegerType value) { 
580          this.decimalPrecision = value;
581          return this;
582        }
583
584        /**
585         * @return Number of digits after decimal separator when the results of such observations are of type Quantity.
586         */
587        public int getDecimalPrecision() { 
588          return this.decimalPrecision == null || this.decimalPrecision.isEmpty() ? 0 : this.decimalPrecision.getValue();
589        }
590
591        /**
592         * @param value Number of digits after decimal separator when the results of such observations are of type Quantity.
593         */
594        public ObservationDefinitionQuantitativeDetailsComponent setDecimalPrecision(int value) { 
595            if (this.decimalPrecision == null)
596              this.decimalPrecision = new IntegerType();
597            this.decimalPrecision.setValue(value);
598          return this;
599        }
600
601        protected void listChildren(List<Property> children) {
602          super.listChildren(children);
603          children.add(new Property("customaryUnit", "CodeableConcept", "Customary unit used to report quantitative results of observations conforming to this ObservationDefinition.", 0, 1, customaryUnit));
604          children.add(new Property("unit", "CodeableConcept", "SI unit used to report quantitative results of observations conforming to this ObservationDefinition.", 0, 1, unit));
605          children.add(new Property("conversionFactor", "decimal", "Factor for converting value expressed with SI unit to value expressed with customary unit.", 0, 1, conversionFactor));
606          children.add(new Property("decimalPrecision", "integer", "Number of digits after decimal separator when the results of such observations are of type Quantity.", 0, 1, decimalPrecision));
607        }
608
609        @Override
610        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
611          switch (_hash) {
612          case -1375586437: /*customaryUnit*/  return new Property("customaryUnit", "CodeableConcept", "Customary unit used to report quantitative results of observations conforming to this ObservationDefinition.", 0, 1, customaryUnit);
613          case 3594628: /*unit*/  return new Property("unit", "CodeableConcept", "SI unit used to report quantitative results of observations conforming to this ObservationDefinition.", 0, 1, unit);
614          case 1438876165: /*conversionFactor*/  return new Property("conversionFactor", "decimal", "Factor for converting value expressed with SI unit to value expressed with customary unit.", 0, 1, conversionFactor);
615          case -1564447699: /*decimalPrecision*/  return new Property("decimalPrecision", "integer", "Number of digits after decimal separator when the results of such observations are of type Quantity.", 0, 1, decimalPrecision);
616          default: return super.getNamedProperty(_hash, _name, _checkValid);
617          }
618
619        }
620
621      @Override
622      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
623        switch (hash) {
624        case -1375586437: /*customaryUnit*/ return this.customaryUnit == null ? new Base[0] : new Base[] {this.customaryUnit}; // CodeableConcept
625        case 3594628: /*unit*/ return this.unit == null ? new Base[0] : new Base[] {this.unit}; // CodeableConcept
626        case 1438876165: /*conversionFactor*/ return this.conversionFactor == null ? new Base[0] : new Base[] {this.conversionFactor}; // DecimalType
627        case -1564447699: /*decimalPrecision*/ return this.decimalPrecision == null ? new Base[0] : new Base[] {this.decimalPrecision}; // IntegerType
628        default: return super.getProperty(hash, name, checkValid);
629        }
630
631      }
632
633      @Override
634      public Base setProperty(int hash, String name, Base value) throws FHIRException {
635        switch (hash) {
636        case -1375586437: // customaryUnit
637          this.customaryUnit = castToCodeableConcept(value); // CodeableConcept
638          return value;
639        case 3594628: // unit
640          this.unit = castToCodeableConcept(value); // CodeableConcept
641          return value;
642        case 1438876165: // conversionFactor
643          this.conversionFactor = castToDecimal(value); // DecimalType
644          return value;
645        case -1564447699: // decimalPrecision
646          this.decimalPrecision = castToInteger(value); // IntegerType
647          return value;
648        default: return super.setProperty(hash, name, value);
649        }
650
651      }
652
653      @Override
654      public Base setProperty(String name, Base value) throws FHIRException {
655        if (name.equals("customaryUnit")) {
656          this.customaryUnit = castToCodeableConcept(value); // CodeableConcept
657        } else if (name.equals("unit")) {
658          this.unit = castToCodeableConcept(value); // CodeableConcept
659        } else if (name.equals("conversionFactor")) {
660          this.conversionFactor = castToDecimal(value); // DecimalType
661        } else if (name.equals("decimalPrecision")) {
662          this.decimalPrecision = castToInteger(value); // IntegerType
663        } else
664          return super.setProperty(name, value);
665        return value;
666      }
667
668      @Override
669      public Base makeProperty(int hash, String name) throws FHIRException {
670        switch (hash) {
671        case -1375586437:  return getCustomaryUnit(); 
672        case 3594628:  return getUnit(); 
673        case 1438876165:  return getConversionFactorElement();
674        case -1564447699:  return getDecimalPrecisionElement();
675        default: return super.makeProperty(hash, name);
676        }
677
678      }
679
680      @Override
681      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
682        switch (hash) {
683        case -1375586437: /*customaryUnit*/ return new String[] {"CodeableConcept"};
684        case 3594628: /*unit*/ return new String[] {"CodeableConcept"};
685        case 1438876165: /*conversionFactor*/ return new String[] {"decimal"};
686        case -1564447699: /*decimalPrecision*/ return new String[] {"integer"};
687        default: return super.getTypesForProperty(hash, name);
688        }
689
690      }
691
692      @Override
693      public Base addChild(String name) throws FHIRException {
694        if (name.equals("customaryUnit")) {
695          this.customaryUnit = new CodeableConcept();
696          return this.customaryUnit;
697        }
698        else if (name.equals("unit")) {
699          this.unit = new CodeableConcept();
700          return this.unit;
701        }
702        else if (name.equals("conversionFactor")) {
703          throw new FHIRException("Cannot call addChild on a primitive type ObservationDefinition.conversionFactor");
704        }
705        else if (name.equals("decimalPrecision")) {
706          throw new FHIRException("Cannot call addChild on a primitive type ObservationDefinition.decimalPrecision");
707        }
708        else
709          return super.addChild(name);
710      }
711
712      public ObservationDefinitionQuantitativeDetailsComponent copy() {
713        ObservationDefinitionQuantitativeDetailsComponent dst = new ObservationDefinitionQuantitativeDetailsComponent();
714        copyValues(dst);
715        return dst;
716      }
717
718      public void copyValues(ObservationDefinitionQuantitativeDetailsComponent dst) {
719        super.copyValues(dst);
720        dst.customaryUnit = customaryUnit == null ? null : customaryUnit.copy();
721        dst.unit = unit == null ? null : unit.copy();
722        dst.conversionFactor = conversionFactor == null ? null : conversionFactor.copy();
723        dst.decimalPrecision = decimalPrecision == null ? null : decimalPrecision.copy();
724      }
725
726      @Override
727      public boolean equalsDeep(Base other_) {
728        if (!super.equalsDeep(other_))
729          return false;
730        if (!(other_ instanceof ObservationDefinitionQuantitativeDetailsComponent))
731          return false;
732        ObservationDefinitionQuantitativeDetailsComponent o = (ObservationDefinitionQuantitativeDetailsComponent) other_;
733        return compareDeep(customaryUnit, o.customaryUnit, true) && compareDeep(unit, o.unit, true) && compareDeep(conversionFactor, o.conversionFactor, true)
734           && compareDeep(decimalPrecision, o.decimalPrecision, true);
735      }
736
737      @Override
738      public boolean equalsShallow(Base other_) {
739        if (!super.equalsShallow(other_))
740          return false;
741        if (!(other_ instanceof ObservationDefinitionQuantitativeDetailsComponent))
742          return false;
743        ObservationDefinitionQuantitativeDetailsComponent o = (ObservationDefinitionQuantitativeDetailsComponent) other_;
744        return compareValues(conversionFactor, o.conversionFactor, true) && compareValues(decimalPrecision, o.decimalPrecision, true)
745          ;
746      }
747
748      public boolean isEmpty() {
749        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(customaryUnit, unit, conversionFactor
750          , decimalPrecision);
751      }
752
753  public String fhirType() {
754    return "ObservationDefinition.quantitativeDetails";
755
756  }
757
758  }
759
760    @Block()
761    public static class ObservationDefinitionQualifiedIntervalComponent extends BackboneElement implements IBaseBackboneElement {
762        /**
763         * The category of interval of values for continuous or ordinal observations conforming to this ObservationDefinition.
764         */
765        @Child(name = "category", type = {CodeType.class}, order=1, min=0, max=1, modifier=false, summary=false)
766        @Description(shortDefinition="reference | critical | absolute", formalDefinition="The category of interval of values for continuous or ordinal observations conforming to this ObservationDefinition." )
767        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/observation-range-category")
768        protected Enumeration<ObservationRangeCategory> category;
769
770        /**
771         * The low and high values determining the interval. There may be only one of the two.
772         */
773        @Child(name = "range", type = {Range.class}, order=2, min=0, max=1, modifier=false, summary=false)
774        @Description(shortDefinition="The interval itself, for continuous or ordinal observations", formalDefinition="The low and high values determining the interval. There may be only one of the two." )
775        protected Range range;
776
777        /**
778         * Codes to indicate the health context the range applies to. For example, the normal or therapeutic range.
779         */
780        @Child(name = "context", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=false)
781        @Description(shortDefinition="Range context qualifier", formalDefinition="Codes to indicate the health context the range applies to. For example, the normal or therapeutic range." )
782        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/referencerange-meaning")
783        protected CodeableConcept context;
784
785        /**
786         * Codes to indicate the target population this reference range applies to.
787         */
788        @Child(name = "appliesTo", type = {CodeableConcept.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
789        @Description(shortDefinition="Targetted population of the range", formalDefinition="Codes to indicate the target population this reference range applies to." )
790        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/referencerange-appliesto")
791        protected List<CodeableConcept> appliesTo;
792
793        /**
794         * Sex of the population the range applies to.
795         */
796        @Child(name = "gender", type = {CodeType.class}, order=5, min=0, max=1, modifier=false, summary=false)
797        @Description(shortDefinition="male | female | other | unknown", formalDefinition="Sex of the population the range applies to." )
798        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/administrative-gender")
799        protected Enumeration<AdministrativeGender> gender;
800
801        /**
802         * The age at which this reference range is applicable. This is a neonatal age (e.g. number of weeks at term) if the meaning says so.
803         */
804        @Child(name = "age", type = {Range.class}, order=6, min=0, max=1, modifier=false, summary=false)
805        @Description(shortDefinition="Applicable age range, if relevant", formalDefinition="The age at which this reference range is applicable. This is a neonatal age (e.g. number of weeks at term) if the meaning says so." )
806        protected Range age;
807
808        /**
809         * The gestational age to which this reference range is applicable, in the context of pregnancy.
810         */
811        @Child(name = "gestationalAge", type = {Range.class}, order=7, min=0, max=1, modifier=false, summary=false)
812        @Description(shortDefinition="Applicable gestational age range, if relevant", formalDefinition="The gestational age to which this reference range is applicable, in the context of pregnancy." )
813        protected Range gestationalAge;
814
815        /**
816         * Text based condition for which the reference range is valid.
817         */
818        @Child(name = "condition", type = {StringType.class}, order=8, min=0, max=1, modifier=false, summary=false)
819        @Description(shortDefinition="Condition associated with the reference range", formalDefinition="Text based condition for which the reference range is valid." )
820        protected StringType condition;
821
822        private static final long serialVersionUID = -416423468L;
823
824    /**
825     * Constructor
826     */
827      public ObservationDefinitionQualifiedIntervalComponent() {
828        super();
829      }
830
831        /**
832         * @return {@link #category} (The category of interval of values for continuous or ordinal observations conforming to this ObservationDefinition.). This is the underlying object with id, value and extensions. The accessor "getCategory" gives direct access to the value
833         */
834        public Enumeration<ObservationRangeCategory> getCategoryElement() { 
835          if (this.category == null)
836            if (Configuration.errorOnAutoCreate())
837              throw new Error("Attempt to auto-create ObservationDefinitionQualifiedIntervalComponent.category");
838            else if (Configuration.doAutoCreate())
839              this.category = new Enumeration<ObservationRangeCategory>(new ObservationRangeCategoryEnumFactory()); // bb
840          return this.category;
841        }
842
843        public boolean hasCategoryElement() { 
844          return this.category != null && !this.category.isEmpty();
845        }
846
847        public boolean hasCategory() { 
848          return this.category != null && !this.category.isEmpty();
849        }
850
851        /**
852         * @param value {@link #category} (The category of interval of values for continuous or ordinal observations conforming to this ObservationDefinition.). This is the underlying object with id, value and extensions. The accessor "getCategory" gives direct access to the value
853         */
854        public ObservationDefinitionQualifiedIntervalComponent setCategoryElement(Enumeration<ObservationRangeCategory> value) { 
855          this.category = value;
856          return this;
857        }
858
859        /**
860         * @return The category of interval of values for continuous or ordinal observations conforming to this ObservationDefinition.
861         */
862        public ObservationRangeCategory getCategory() { 
863          return this.category == null ? null : this.category.getValue();
864        }
865
866        /**
867         * @param value The category of interval of values for continuous or ordinal observations conforming to this ObservationDefinition.
868         */
869        public ObservationDefinitionQualifiedIntervalComponent setCategory(ObservationRangeCategory value) { 
870          if (value == null)
871            this.category = null;
872          else {
873            if (this.category == null)
874              this.category = new Enumeration<ObservationRangeCategory>(new ObservationRangeCategoryEnumFactory());
875            this.category.setValue(value);
876          }
877          return this;
878        }
879
880        /**
881         * @return {@link #range} (The low and high values determining the interval. There may be only one of the two.)
882         */
883        public Range getRange() { 
884          if (this.range == null)
885            if (Configuration.errorOnAutoCreate())
886              throw new Error("Attempt to auto-create ObservationDefinitionQualifiedIntervalComponent.range");
887            else if (Configuration.doAutoCreate())
888              this.range = new Range(); // cc
889          return this.range;
890        }
891
892        public boolean hasRange() { 
893          return this.range != null && !this.range.isEmpty();
894        }
895
896        /**
897         * @param value {@link #range} (The low and high values determining the interval. There may be only one of the two.)
898         */
899        public ObservationDefinitionQualifiedIntervalComponent setRange(Range value) { 
900          this.range = value;
901          return this;
902        }
903
904        /**
905         * @return {@link #context} (Codes to indicate the health context the range applies to. For example, the normal or therapeutic range.)
906         */
907        public CodeableConcept getContext() { 
908          if (this.context == null)
909            if (Configuration.errorOnAutoCreate())
910              throw new Error("Attempt to auto-create ObservationDefinitionQualifiedIntervalComponent.context");
911            else if (Configuration.doAutoCreate())
912              this.context = new CodeableConcept(); // cc
913          return this.context;
914        }
915
916        public boolean hasContext() { 
917          return this.context != null && !this.context.isEmpty();
918        }
919
920        /**
921         * @param value {@link #context} (Codes to indicate the health context the range applies to. For example, the normal or therapeutic range.)
922         */
923        public ObservationDefinitionQualifiedIntervalComponent setContext(CodeableConcept value) { 
924          this.context = value;
925          return this;
926        }
927
928        /**
929         * @return {@link #appliesTo} (Codes to indicate the target population this reference range applies to.)
930         */
931        public List<CodeableConcept> getAppliesTo() { 
932          if (this.appliesTo == null)
933            this.appliesTo = new ArrayList<CodeableConcept>();
934          return this.appliesTo;
935        }
936
937        /**
938         * @return Returns a reference to <code>this</code> for easy method chaining
939         */
940        public ObservationDefinitionQualifiedIntervalComponent setAppliesTo(List<CodeableConcept> theAppliesTo) { 
941          this.appliesTo = theAppliesTo;
942          return this;
943        }
944
945        public boolean hasAppliesTo() { 
946          if (this.appliesTo == null)
947            return false;
948          for (CodeableConcept item : this.appliesTo)
949            if (!item.isEmpty())
950              return true;
951          return false;
952        }
953
954        public CodeableConcept addAppliesTo() { //3
955          CodeableConcept t = new CodeableConcept();
956          if (this.appliesTo == null)
957            this.appliesTo = new ArrayList<CodeableConcept>();
958          this.appliesTo.add(t);
959          return t;
960        }
961
962        public ObservationDefinitionQualifiedIntervalComponent addAppliesTo(CodeableConcept t) { //3
963          if (t == null)
964            return this;
965          if (this.appliesTo == null)
966            this.appliesTo = new ArrayList<CodeableConcept>();
967          this.appliesTo.add(t);
968          return this;
969        }
970
971        /**
972         * @return The first repetition of repeating field {@link #appliesTo}, creating it if it does not already exist
973         */
974        public CodeableConcept getAppliesToFirstRep() { 
975          if (getAppliesTo().isEmpty()) {
976            addAppliesTo();
977          }
978          return getAppliesTo().get(0);
979        }
980
981        /**
982         * @return {@link #gender} (Sex of the population the range applies to.). This is the underlying object with id, value and extensions. The accessor "getGender" gives direct access to the value
983         */
984        public Enumeration<AdministrativeGender> getGenderElement() { 
985          if (this.gender == null)
986            if (Configuration.errorOnAutoCreate())
987              throw new Error("Attempt to auto-create ObservationDefinitionQualifiedIntervalComponent.gender");
988            else if (Configuration.doAutoCreate())
989              this.gender = new Enumeration<AdministrativeGender>(new AdministrativeGenderEnumFactory()); // bb
990          return this.gender;
991        }
992
993        public boolean hasGenderElement() { 
994          return this.gender != null && !this.gender.isEmpty();
995        }
996
997        public boolean hasGender() { 
998          return this.gender != null && !this.gender.isEmpty();
999        }
1000
1001        /**
1002         * @param value {@link #gender} (Sex of the population the range applies to.). This is the underlying object with id, value and extensions. The accessor "getGender" gives direct access to the value
1003         */
1004        public ObservationDefinitionQualifiedIntervalComponent setGenderElement(Enumeration<AdministrativeGender> value) { 
1005          this.gender = value;
1006          return this;
1007        }
1008
1009        /**
1010         * @return Sex of the population the range applies to.
1011         */
1012        public AdministrativeGender getGender() { 
1013          return this.gender == null ? null : this.gender.getValue();
1014        }
1015
1016        /**
1017         * @param value Sex of the population the range applies to.
1018         */
1019        public ObservationDefinitionQualifiedIntervalComponent setGender(AdministrativeGender value) { 
1020          if (value == null)
1021            this.gender = null;
1022          else {
1023            if (this.gender == null)
1024              this.gender = new Enumeration<AdministrativeGender>(new AdministrativeGenderEnumFactory());
1025            this.gender.setValue(value);
1026          }
1027          return this;
1028        }
1029
1030        /**
1031         * @return {@link #age} (The age at which this reference range is applicable. This is a neonatal age (e.g. number of weeks at term) if the meaning says so.)
1032         */
1033        public Range getAge() { 
1034          if (this.age == null)
1035            if (Configuration.errorOnAutoCreate())
1036              throw new Error("Attempt to auto-create ObservationDefinitionQualifiedIntervalComponent.age");
1037            else if (Configuration.doAutoCreate())
1038              this.age = new Range(); // cc
1039          return this.age;
1040        }
1041
1042        public boolean hasAge() { 
1043          return this.age != null && !this.age.isEmpty();
1044        }
1045
1046        /**
1047         * @param value {@link #age} (The age at which this reference range is applicable. This is a neonatal age (e.g. number of weeks at term) if the meaning says so.)
1048         */
1049        public ObservationDefinitionQualifiedIntervalComponent setAge(Range value) { 
1050          this.age = value;
1051          return this;
1052        }
1053
1054        /**
1055         * @return {@link #gestationalAge} (The gestational age to which this reference range is applicable, in the context of pregnancy.)
1056         */
1057        public Range getGestationalAge() { 
1058          if (this.gestationalAge == null)
1059            if (Configuration.errorOnAutoCreate())
1060              throw new Error("Attempt to auto-create ObservationDefinitionQualifiedIntervalComponent.gestationalAge");
1061            else if (Configuration.doAutoCreate())
1062              this.gestationalAge = new Range(); // cc
1063          return this.gestationalAge;
1064        }
1065
1066        public boolean hasGestationalAge() { 
1067          return this.gestationalAge != null && !this.gestationalAge.isEmpty();
1068        }
1069
1070        /**
1071         * @param value {@link #gestationalAge} (The gestational age to which this reference range is applicable, in the context of pregnancy.)
1072         */
1073        public ObservationDefinitionQualifiedIntervalComponent setGestationalAge(Range value) { 
1074          this.gestationalAge = value;
1075          return this;
1076        }
1077
1078        /**
1079         * @return {@link #condition} (Text based condition for which the reference range is valid.). This is the underlying object with id, value and extensions. The accessor "getCondition" gives direct access to the value
1080         */
1081        public StringType getConditionElement() { 
1082          if (this.condition == null)
1083            if (Configuration.errorOnAutoCreate())
1084              throw new Error("Attempt to auto-create ObservationDefinitionQualifiedIntervalComponent.condition");
1085            else if (Configuration.doAutoCreate())
1086              this.condition = new StringType(); // bb
1087          return this.condition;
1088        }
1089
1090        public boolean hasConditionElement() { 
1091          return this.condition != null && !this.condition.isEmpty();
1092        }
1093
1094        public boolean hasCondition() { 
1095          return this.condition != null && !this.condition.isEmpty();
1096        }
1097
1098        /**
1099         * @param value {@link #condition} (Text based condition for which the reference range is valid.). This is the underlying object with id, value and extensions. The accessor "getCondition" gives direct access to the value
1100         */
1101        public ObservationDefinitionQualifiedIntervalComponent setConditionElement(StringType value) { 
1102          this.condition = value;
1103          return this;
1104        }
1105
1106        /**
1107         * @return Text based condition for which the reference range is valid.
1108         */
1109        public String getCondition() { 
1110          return this.condition == null ? null : this.condition.getValue();
1111        }
1112
1113        /**
1114         * @param value Text based condition for which the reference range is valid.
1115         */
1116        public ObservationDefinitionQualifiedIntervalComponent setCondition(String value) { 
1117          if (Utilities.noString(value))
1118            this.condition = null;
1119          else {
1120            if (this.condition == null)
1121              this.condition = new StringType();
1122            this.condition.setValue(value);
1123          }
1124          return this;
1125        }
1126
1127        protected void listChildren(List<Property> children) {
1128          super.listChildren(children);
1129          children.add(new Property("category", "code", "The category of interval of values for continuous or ordinal observations conforming to this ObservationDefinition.", 0, 1, category));
1130          children.add(new Property("range", "Range", "The low and high values determining the interval. There may be only one of the two.", 0, 1, range));
1131          children.add(new Property("context", "CodeableConcept", "Codes to indicate the health context the range applies to. For example, the normal or therapeutic range.", 0, 1, context));
1132          children.add(new Property("appliesTo", "CodeableConcept", "Codes to indicate the target population this reference range applies to.", 0, java.lang.Integer.MAX_VALUE, appliesTo));
1133          children.add(new Property("gender", "code", "Sex of the population the range applies to.", 0, 1, gender));
1134          children.add(new Property("age", "Range", "The age at which this reference range is applicable. This is a neonatal age (e.g. number of weeks at term) if the meaning says so.", 0, 1, age));
1135          children.add(new Property("gestationalAge", "Range", "The gestational age to which this reference range is applicable, in the context of pregnancy.", 0, 1, gestationalAge));
1136          children.add(new Property("condition", "string", "Text based condition for which the reference range is valid.", 0, 1, condition));
1137        }
1138
1139        @Override
1140        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1141          switch (_hash) {
1142          case 50511102: /*category*/  return new Property("category", "code", "The category of interval of values for continuous or ordinal observations conforming to this ObservationDefinition.", 0, 1, category);
1143          case 108280125: /*range*/  return new Property("range", "Range", "The low and high values determining the interval. There may be only one of the two.", 0, 1, range);
1144          case 951530927: /*context*/  return new Property("context", "CodeableConcept", "Codes to indicate the health context the range applies to. For example, the normal or therapeutic range.", 0, 1, context);
1145          case -2089924569: /*appliesTo*/  return new Property("appliesTo", "CodeableConcept", "Codes to indicate the target population this reference range applies to.", 0, java.lang.Integer.MAX_VALUE, appliesTo);
1146          case -1249512767: /*gender*/  return new Property("gender", "code", "Sex of the population the range applies to.", 0, 1, gender);
1147          case 96511: /*age*/  return new Property("age", "Range", "The age at which this reference range is applicable. This is a neonatal age (e.g. number of weeks at term) if the meaning says so.", 0, 1, age);
1148          case -241217538: /*gestationalAge*/  return new Property("gestationalAge", "Range", "The gestational age to which this reference range is applicable, in the context of pregnancy.", 0, 1, gestationalAge);
1149          case -861311717: /*condition*/  return new Property("condition", "string", "Text based condition for which the reference range is valid.", 0, 1, condition);
1150          default: return super.getNamedProperty(_hash, _name, _checkValid);
1151          }
1152
1153        }
1154
1155      @Override
1156      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1157        switch (hash) {
1158        case 50511102: /*category*/ return this.category == null ? new Base[0] : new Base[] {this.category}; // Enumeration<ObservationRangeCategory>
1159        case 108280125: /*range*/ return this.range == null ? new Base[0] : new Base[] {this.range}; // Range
1160        case 951530927: /*context*/ return this.context == null ? new Base[0] : new Base[] {this.context}; // CodeableConcept
1161        case -2089924569: /*appliesTo*/ return this.appliesTo == null ? new Base[0] : this.appliesTo.toArray(new Base[this.appliesTo.size()]); // CodeableConcept
1162        case -1249512767: /*gender*/ return this.gender == null ? new Base[0] : new Base[] {this.gender}; // Enumeration<AdministrativeGender>
1163        case 96511: /*age*/ return this.age == null ? new Base[0] : new Base[] {this.age}; // Range
1164        case -241217538: /*gestationalAge*/ return this.gestationalAge == null ? new Base[0] : new Base[] {this.gestationalAge}; // Range
1165        case -861311717: /*condition*/ return this.condition == null ? new Base[0] : new Base[] {this.condition}; // StringType
1166        default: return super.getProperty(hash, name, checkValid);
1167        }
1168
1169      }
1170
1171      @Override
1172      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1173        switch (hash) {
1174        case 50511102: // category
1175          value = new ObservationRangeCategoryEnumFactory().fromType(castToCode(value));
1176          this.category = (Enumeration) value; // Enumeration<ObservationRangeCategory>
1177          return value;
1178        case 108280125: // range
1179          this.range = castToRange(value); // Range
1180          return value;
1181        case 951530927: // context
1182          this.context = castToCodeableConcept(value); // CodeableConcept
1183          return value;
1184        case -2089924569: // appliesTo
1185          this.getAppliesTo().add(castToCodeableConcept(value)); // CodeableConcept
1186          return value;
1187        case -1249512767: // gender
1188          value = new AdministrativeGenderEnumFactory().fromType(castToCode(value));
1189          this.gender = (Enumeration) value; // Enumeration<AdministrativeGender>
1190          return value;
1191        case 96511: // age
1192          this.age = castToRange(value); // Range
1193          return value;
1194        case -241217538: // gestationalAge
1195          this.gestationalAge = castToRange(value); // Range
1196          return value;
1197        case -861311717: // condition
1198          this.condition = castToString(value); // StringType
1199          return value;
1200        default: return super.setProperty(hash, name, value);
1201        }
1202
1203      }
1204
1205      @Override
1206      public Base setProperty(String name, Base value) throws FHIRException {
1207        if (name.equals("category")) {
1208          value = new ObservationRangeCategoryEnumFactory().fromType(castToCode(value));
1209          this.category = (Enumeration) value; // Enumeration<ObservationRangeCategory>
1210        } else if (name.equals("range")) {
1211          this.range = castToRange(value); // Range
1212        } else if (name.equals("context")) {
1213          this.context = castToCodeableConcept(value); // CodeableConcept
1214        } else if (name.equals("appliesTo")) {
1215          this.getAppliesTo().add(castToCodeableConcept(value));
1216        } else if (name.equals("gender")) {
1217          value = new AdministrativeGenderEnumFactory().fromType(castToCode(value));
1218          this.gender = (Enumeration) value; // Enumeration<AdministrativeGender>
1219        } else if (name.equals("age")) {
1220          this.age = castToRange(value); // Range
1221        } else if (name.equals("gestationalAge")) {
1222          this.gestationalAge = castToRange(value); // Range
1223        } else if (name.equals("condition")) {
1224          this.condition = castToString(value); // StringType
1225        } else
1226          return super.setProperty(name, value);
1227        return value;
1228      }
1229
1230      @Override
1231      public Base makeProperty(int hash, String name) throws FHIRException {
1232        switch (hash) {
1233        case 50511102:  return getCategoryElement();
1234        case 108280125:  return getRange(); 
1235        case 951530927:  return getContext(); 
1236        case -2089924569:  return addAppliesTo(); 
1237        case -1249512767:  return getGenderElement();
1238        case 96511:  return getAge(); 
1239        case -241217538:  return getGestationalAge(); 
1240        case -861311717:  return getConditionElement();
1241        default: return super.makeProperty(hash, name);
1242        }
1243
1244      }
1245
1246      @Override
1247      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1248        switch (hash) {
1249        case 50511102: /*category*/ return new String[] {"code"};
1250        case 108280125: /*range*/ return new String[] {"Range"};
1251        case 951530927: /*context*/ return new String[] {"CodeableConcept"};
1252        case -2089924569: /*appliesTo*/ return new String[] {"CodeableConcept"};
1253        case -1249512767: /*gender*/ return new String[] {"code"};
1254        case 96511: /*age*/ return new String[] {"Range"};
1255        case -241217538: /*gestationalAge*/ return new String[] {"Range"};
1256        case -861311717: /*condition*/ return new String[] {"string"};
1257        default: return super.getTypesForProperty(hash, name);
1258        }
1259
1260      }
1261
1262      @Override
1263      public Base addChild(String name) throws FHIRException {
1264        if (name.equals("category")) {
1265          throw new FHIRException("Cannot call addChild on a primitive type ObservationDefinition.category");
1266        }
1267        else if (name.equals("range")) {
1268          this.range = new Range();
1269          return this.range;
1270        }
1271        else if (name.equals("context")) {
1272          this.context = new CodeableConcept();
1273          return this.context;
1274        }
1275        else if (name.equals("appliesTo")) {
1276          return addAppliesTo();
1277        }
1278        else if (name.equals("gender")) {
1279          throw new FHIRException("Cannot call addChild on a primitive type ObservationDefinition.gender");
1280        }
1281        else if (name.equals("age")) {
1282          this.age = new Range();
1283          return this.age;
1284        }
1285        else if (name.equals("gestationalAge")) {
1286          this.gestationalAge = new Range();
1287          return this.gestationalAge;
1288        }
1289        else if (name.equals("condition")) {
1290          throw new FHIRException("Cannot call addChild on a primitive type ObservationDefinition.condition");
1291        }
1292        else
1293          return super.addChild(name);
1294      }
1295
1296      public ObservationDefinitionQualifiedIntervalComponent copy() {
1297        ObservationDefinitionQualifiedIntervalComponent dst = new ObservationDefinitionQualifiedIntervalComponent();
1298        copyValues(dst);
1299        return dst;
1300      }
1301
1302      public void copyValues(ObservationDefinitionQualifiedIntervalComponent dst) {
1303        super.copyValues(dst);
1304        dst.category = category == null ? null : category.copy();
1305        dst.range = range == null ? null : range.copy();
1306        dst.context = context == null ? null : context.copy();
1307        if (appliesTo != null) {
1308          dst.appliesTo = new ArrayList<CodeableConcept>();
1309          for (CodeableConcept i : appliesTo)
1310            dst.appliesTo.add(i.copy());
1311        };
1312        dst.gender = gender == null ? null : gender.copy();
1313        dst.age = age == null ? null : age.copy();
1314        dst.gestationalAge = gestationalAge == null ? null : gestationalAge.copy();
1315        dst.condition = condition == null ? null : condition.copy();
1316      }
1317
1318      @Override
1319      public boolean equalsDeep(Base other_) {
1320        if (!super.equalsDeep(other_))
1321          return false;
1322        if (!(other_ instanceof ObservationDefinitionQualifiedIntervalComponent))
1323          return false;
1324        ObservationDefinitionQualifiedIntervalComponent o = (ObservationDefinitionQualifiedIntervalComponent) other_;
1325        return compareDeep(category, o.category, true) && compareDeep(range, o.range, true) && compareDeep(context, o.context, true)
1326           && compareDeep(appliesTo, o.appliesTo, true) && compareDeep(gender, o.gender, true) && compareDeep(age, o.age, true)
1327           && compareDeep(gestationalAge, o.gestationalAge, true) && compareDeep(condition, o.condition, true)
1328          ;
1329      }
1330
1331      @Override
1332      public boolean equalsShallow(Base other_) {
1333        if (!super.equalsShallow(other_))
1334          return false;
1335        if (!(other_ instanceof ObservationDefinitionQualifiedIntervalComponent))
1336          return false;
1337        ObservationDefinitionQualifiedIntervalComponent o = (ObservationDefinitionQualifiedIntervalComponent) other_;
1338        return compareValues(category, o.category, true) && compareValues(gender, o.gender, true) && compareValues(condition, o.condition, true)
1339          ;
1340      }
1341
1342      public boolean isEmpty() {
1343        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(category, range, context
1344          , appliesTo, gender, age, gestationalAge, condition);
1345      }
1346
1347  public String fhirType() {
1348    return "ObservationDefinition.qualifiedInterval";
1349
1350  }
1351
1352  }
1353
1354    /**
1355     * A code that classifies the general type of observation.
1356     */
1357    @Child(name = "category", type = {CodeableConcept.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1358    @Description(shortDefinition="Category of observation", formalDefinition="A code that classifies the general type of observation." )
1359    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/observation-category")
1360    protected List<CodeableConcept> category;
1361
1362    /**
1363     * Describes what will be observed. Sometimes this is called the observation "name".
1364     */
1365    @Child(name = "code", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=true)
1366    @Description(shortDefinition="Type of observation (code / type)", formalDefinition="Describes what will be observed. Sometimes this is called the observation \"name\"." )
1367    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/observation-codes")
1368    protected CodeableConcept code;
1369
1370    /**
1371     * A unique identifier assigned to this ObservationDefinition artifact.
1372     */
1373    @Child(name = "identifier", type = {Identifier.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1374    @Description(shortDefinition="Business identifier for this ObservationDefinition instance", formalDefinition="A unique identifier assigned to this ObservationDefinition artifact." )
1375    protected List<Identifier> identifier;
1376
1377    /**
1378     * The data types allowed for the value element of the instance observations conforming to this ObservationDefinition.
1379     */
1380    @Child(name = "permittedDataType", type = {CodeType.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1381    @Description(shortDefinition="Quantity | CodeableConcept | string | boolean | integer | Range | Ratio | SampledData | time | dateTime | Period", formalDefinition="The data types allowed for the value element of the instance observations conforming to this ObservationDefinition." )
1382    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/permitted-data-type")
1383    protected List<Enumeration<ObservationDataType>> permittedDataType;
1384
1385    /**
1386     * Multiple results allowed for observations conforming to this ObservationDefinition.
1387     */
1388    @Child(name = "multipleResultsAllowed", type = {BooleanType.class}, order=4, min=0, max=1, modifier=false, summary=false)
1389    @Description(shortDefinition="Multiple results allowed", formalDefinition="Multiple results allowed for observations conforming to this ObservationDefinition." )
1390    protected BooleanType multipleResultsAllowed;
1391
1392    /**
1393     * The method or technique used to perform the observation.
1394     */
1395    @Child(name = "method", type = {CodeableConcept.class}, order=5, min=0, max=1, modifier=false, summary=false)
1396    @Description(shortDefinition="Method used to produce the observation", formalDefinition="The method or technique used to perform the observation." )
1397    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/observation-methods")
1398    protected CodeableConcept method;
1399
1400    /**
1401     * The preferred name to be used when reporting the results of observations conforming to this ObservationDefinition.
1402     */
1403    @Child(name = "preferredReportName", type = {StringType.class}, order=6, min=0, max=1, modifier=false, summary=false)
1404    @Description(shortDefinition="Preferred report name", formalDefinition="The preferred name to be used when reporting the results of observations conforming to this ObservationDefinition." )
1405    protected StringType preferredReportName;
1406
1407    /**
1408     * Characteristics for quantitative results of this observation.
1409     */
1410    @Child(name = "quantitativeDetails", type = {}, order=7, min=0, max=1, modifier=false, summary=false)
1411    @Description(shortDefinition="Characteristics of quantitative results", formalDefinition="Characteristics for quantitative results of this observation." )
1412    protected ObservationDefinitionQuantitativeDetailsComponent quantitativeDetails;
1413
1414    /**
1415     * Multiple  ranges of results qualified by different contexts for ordinal or continuous observations conforming to this ObservationDefinition.
1416     */
1417    @Child(name = "qualifiedInterval", type = {}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1418    @Description(shortDefinition="Qualified range for continuous and ordinal observation results", formalDefinition="Multiple  ranges of results qualified by different contexts for ordinal or continuous observations conforming to this ObservationDefinition." )
1419    protected List<ObservationDefinitionQualifiedIntervalComponent> qualifiedInterval;
1420
1421    /**
1422     * The set of valid coded results for the observations  conforming to this ObservationDefinition.
1423     */
1424    @Child(name = "validCodedValueSet", type = {ValueSet.class}, order=9, min=0, max=1, modifier=false, summary=false)
1425    @Description(shortDefinition="Value set of valid coded values for the observations conforming to this ObservationDefinition", formalDefinition="The set of valid coded results for the observations  conforming to this ObservationDefinition." )
1426    protected Reference validCodedValueSet;
1427
1428    /**
1429     * The actual object that is the target of the reference (The set of valid coded results for the observations  conforming to this ObservationDefinition.)
1430     */
1431    protected ValueSet validCodedValueSetTarget;
1432
1433    /**
1434     * The set of normal coded results for the observations conforming to this ObservationDefinition.
1435     */
1436    @Child(name = "normalCodedValueSet", type = {ValueSet.class}, order=10, min=0, max=1, modifier=false, summary=false)
1437    @Description(shortDefinition="Value set of normal coded values for the observations conforming to this ObservationDefinition", formalDefinition="The set of normal coded results for the observations conforming to this ObservationDefinition." )
1438    protected Reference normalCodedValueSet;
1439
1440    /**
1441     * The actual object that is the target of the reference (The set of normal coded results for the observations conforming to this ObservationDefinition.)
1442     */
1443    protected ValueSet normalCodedValueSetTarget;
1444
1445    /**
1446     * The set of abnormal coded results for the observation conforming to this ObservationDefinition.
1447     */
1448    @Child(name = "abnormalCodedValueSet", type = {ValueSet.class}, order=11, min=0, max=1, modifier=false, summary=false)
1449    @Description(shortDefinition="Value set of abnormal coded values for the observations conforming to this ObservationDefinition", formalDefinition="The set of abnormal coded results for the observation conforming to this ObservationDefinition." )
1450    protected Reference abnormalCodedValueSet;
1451
1452    /**
1453     * The actual object that is the target of the reference (The set of abnormal coded results for the observation conforming to this ObservationDefinition.)
1454     */
1455    protected ValueSet abnormalCodedValueSetTarget;
1456
1457    /**
1458     * The set of critical coded results for the observation conforming to this ObservationDefinition.
1459     */
1460    @Child(name = "criticalCodedValueSet", type = {ValueSet.class}, order=12, min=0, max=1, modifier=false, summary=false)
1461    @Description(shortDefinition="Value set of critical coded values for the observations conforming to this ObservationDefinition", formalDefinition="The set of critical coded results for the observation conforming to this ObservationDefinition." )
1462    protected Reference criticalCodedValueSet;
1463
1464    /**
1465     * The actual object that is the target of the reference (The set of critical coded results for the observation conforming to this ObservationDefinition.)
1466     */
1467    protected ValueSet criticalCodedValueSetTarget;
1468
1469    private static final long serialVersionUID = 2136752757L;
1470
1471  /**
1472   * Constructor
1473   */
1474    public ObservationDefinition() {
1475      super();
1476    }
1477
1478  /**
1479   * Constructor
1480   */
1481    public ObservationDefinition(CodeableConcept code) {
1482      super();
1483      this.code = code;
1484    }
1485
1486    /**
1487     * @return {@link #category} (A code that classifies the general type of observation.)
1488     */
1489    public List<CodeableConcept> getCategory() { 
1490      if (this.category == null)
1491        this.category = new ArrayList<CodeableConcept>();
1492      return this.category;
1493    }
1494
1495    /**
1496     * @return Returns a reference to <code>this</code> for easy method chaining
1497     */
1498    public ObservationDefinition setCategory(List<CodeableConcept> theCategory) { 
1499      this.category = theCategory;
1500      return this;
1501    }
1502
1503    public boolean hasCategory() { 
1504      if (this.category == null)
1505        return false;
1506      for (CodeableConcept item : this.category)
1507        if (!item.isEmpty())
1508          return true;
1509      return false;
1510    }
1511
1512    public CodeableConcept addCategory() { //3
1513      CodeableConcept t = new CodeableConcept();
1514      if (this.category == null)
1515        this.category = new ArrayList<CodeableConcept>();
1516      this.category.add(t);
1517      return t;
1518    }
1519
1520    public ObservationDefinition addCategory(CodeableConcept t) { //3
1521      if (t == null)
1522        return this;
1523      if (this.category == null)
1524        this.category = new ArrayList<CodeableConcept>();
1525      this.category.add(t);
1526      return this;
1527    }
1528
1529    /**
1530     * @return The first repetition of repeating field {@link #category}, creating it if it does not already exist
1531     */
1532    public CodeableConcept getCategoryFirstRep() { 
1533      if (getCategory().isEmpty()) {
1534        addCategory();
1535      }
1536      return getCategory().get(0);
1537    }
1538
1539    /**
1540     * @return {@link #code} (Describes what will be observed. Sometimes this is called the observation "name".)
1541     */
1542    public CodeableConcept getCode() { 
1543      if (this.code == null)
1544        if (Configuration.errorOnAutoCreate())
1545          throw new Error("Attempt to auto-create ObservationDefinition.code");
1546        else if (Configuration.doAutoCreate())
1547          this.code = new CodeableConcept(); // cc
1548      return this.code;
1549    }
1550
1551    public boolean hasCode() { 
1552      return this.code != null && !this.code.isEmpty();
1553    }
1554
1555    /**
1556     * @param value {@link #code} (Describes what will be observed. Sometimes this is called the observation "name".)
1557     */
1558    public ObservationDefinition setCode(CodeableConcept value) { 
1559      this.code = value;
1560      return this;
1561    }
1562
1563    /**
1564     * @return {@link #identifier} (A unique identifier assigned to this ObservationDefinition artifact.)
1565     */
1566    public List<Identifier> getIdentifier() { 
1567      if (this.identifier == null)
1568        this.identifier = new ArrayList<Identifier>();
1569      return this.identifier;
1570    }
1571
1572    /**
1573     * @return Returns a reference to <code>this</code> for easy method chaining
1574     */
1575    public ObservationDefinition setIdentifier(List<Identifier> theIdentifier) { 
1576      this.identifier = theIdentifier;
1577      return this;
1578    }
1579
1580    public boolean hasIdentifier() { 
1581      if (this.identifier == null)
1582        return false;
1583      for (Identifier item : this.identifier)
1584        if (!item.isEmpty())
1585          return true;
1586      return false;
1587    }
1588
1589    public Identifier addIdentifier() { //3
1590      Identifier t = new Identifier();
1591      if (this.identifier == null)
1592        this.identifier = new ArrayList<Identifier>();
1593      this.identifier.add(t);
1594      return t;
1595    }
1596
1597    public ObservationDefinition addIdentifier(Identifier t) { //3
1598      if (t == null)
1599        return this;
1600      if (this.identifier == null)
1601        this.identifier = new ArrayList<Identifier>();
1602      this.identifier.add(t);
1603      return this;
1604    }
1605
1606    /**
1607     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
1608     */
1609    public Identifier getIdentifierFirstRep() { 
1610      if (getIdentifier().isEmpty()) {
1611        addIdentifier();
1612      }
1613      return getIdentifier().get(0);
1614    }
1615
1616    /**
1617     * @return {@link #permittedDataType} (The data types allowed for the value element of the instance observations conforming to this ObservationDefinition.)
1618     */
1619    public List<Enumeration<ObservationDataType>> getPermittedDataType() { 
1620      if (this.permittedDataType == null)
1621        this.permittedDataType = new ArrayList<Enumeration<ObservationDataType>>();
1622      return this.permittedDataType;
1623    }
1624
1625    /**
1626     * @return Returns a reference to <code>this</code> for easy method chaining
1627     */
1628    public ObservationDefinition setPermittedDataType(List<Enumeration<ObservationDataType>> thePermittedDataType) { 
1629      this.permittedDataType = thePermittedDataType;
1630      return this;
1631    }
1632
1633    public boolean hasPermittedDataType() { 
1634      if (this.permittedDataType == null)
1635        return false;
1636      for (Enumeration<ObservationDataType> item : this.permittedDataType)
1637        if (!item.isEmpty())
1638          return true;
1639      return false;
1640    }
1641
1642    /**
1643     * @return {@link #permittedDataType} (The data types allowed for the value element of the instance observations conforming to this ObservationDefinition.)
1644     */
1645    public Enumeration<ObservationDataType> addPermittedDataTypeElement() {//2 
1646      Enumeration<ObservationDataType> t = new Enumeration<ObservationDataType>(new ObservationDataTypeEnumFactory());
1647      if (this.permittedDataType == null)
1648        this.permittedDataType = new ArrayList<Enumeration<ObservationDataType>>();
1649      this.permittedDataType.add(t);
1650      return t;
1651    }
1652
1653    /**
1654     * @param value {@link #permittedDataType} (The data types allowed for the value element of the instance observations conforming to this ObservationDefinition.)
1655     */
1656    public ObservationDefinition addPermittedDataType(ObservationDataType value) { //1
1657      Enumeration<ObservationDataType> t = new Enumeration<ObservationDataType>(new ObservationDataTypeEnumFactory());
1658      t.setValue(value);
1659      if (this.permittedDataType == null)
1660        this.permittedDataType = new ArrayList<Enumeration<ObservationDataType>>();
1661      this.permittedDataType.add(t);
1662      return this;
1663    }
1664
1665    /**
1666     * @param value {@link #permittedDataType} (The data types allowed for the value element of the instance observations conforming to this ObservationDefinition.)
1667     */
1668    public boolean hasPermittedDataType(ObservationDataType value) { 
1669      if (this.permittedDataType == null)
1670        return false;
1671      for (Enumeration<ObservationDataType> v : this.permittedDataType)
1672        if (v.getValue().equals(value)) // code
1673          return true;
1674      return false;
1675    }
1676
1677    /**
1678     * @return {@link #multipleResultsAllowed} (Multiple results allowed for observations conforming to this ObservationDefinition.). This is the underlying object with id, value and extensions. The accessor "getMultipleResultsAllowed" gives direct access to the value
1679     */
1680    public BooleanType getMultipleResultsAllowedElement() { 
1681      if (this.multipleResultsAllowed == null)
1682        if (Configuration.errorOnAutoCreate())
1683          throw new Error("Attempt to auto-create ObservationDefinition.multipleResultsAllowed");
1684        else if (Configuration.doAutoCreate())
1685          this.multipleResultsAllowed = new BooleanType(); // bb
1686      return this.multipleResultsAllowed;
1687    }
1688
1689    public boolean hasMultipleResultsAllowedElement() { 
1690      return this.multipleResultsAllowed != null && !this.multipleResultsAllowed.isEmpty();
1691    }
1692
1693    public boolean hasMultipleResultsAllowed() { 
1694      return this.multipleResultsAllowed != null && !this.multipleResultsAllowed.isEmpty();
1695    }
1696
1697    /**
1698     * @param value {@link #multipleResultsAllowed} (Multiple results allowed for observations conforming to this ObservationDefinition.). This is the underlying object with id, value and extensions. The accessor "getMultipleResultsAllowed" gives direct access to the value
1699     */
1700    public ObservationDefinition setMultipleResultsAllowedElement(BooleanType value) { 
1701      this.multipleResultsAllowed = value;
1702      return this;
1703    }
1704
1705    /**
1706     * @return Multiple results allowed for observations conforming to this ObservationDefinition.
1707     */
1708    public boolean getMultipleResultsAllowed() { 
1709      return this.multipleResultsAllowed == null || this.multipleResultsAllowed.isEmpty() ? false : this.multipleResultsAllowed.getValue();
1710    }
1711
1712    /**
1713     * @param value Multiple results allowed for observations conforming to this ObservationDefinition.
1714     */
1715    public ObservationDefinition setMultipleResultsAllowed(boolean value) { 
1716        if (this.multipleResultsAllowed == null)
1717          this.multipleResultsAllowed = new BooleanType();
1718        this.multipleResultsAllowed.setValue(value);
1719      return this;
1720    }
1721
1722    /**
1723     * @return {@link #method} (The method or technique used to perform the observation.)
1724     */
1725    public CodeableConcept getMethod() { 
1726      if (this.method == null)
1727        if (Configuration.errorOnAutoCreate())
1728          throw new Error("Attempt to auto-create ObservationDefinition.method");
1729        else if (Configuration.doAutoCreate())
1730          this.method = new CodeableConcept(); // cc
1731      return this.method;
1732    }
1733
1734    public boolean hasMethod() { 
1735      return this.method != null && !this.method.isEmpty();
1736    }
1737
1738    /**
1739     * @param value {@link #method} (The method or technique used to perform the observation.)
1740     */
1741    public ObservationDefinition setMethod(CodeableConcept value) { 
1742      this.method = value;
1743      return this;
1744    }
1745
1746    /**
1747     * @return {@link #preferredReportName} (The preferred name to be used when reporting the results of observations conforming to this ObservationDefinition.). This is the underlying object with id, value and extensions. The accessor "getPreferredReportName" gives direct access to the value
1748     */
1749    public StringType getPreferredReportNameElement() { 
1750      if (this.preferredReportName == null)
1751        if (Configuration.errorOnAutoCreate())
1752          throw new Error("Attempt to auto-create ObservationDefinition.preferredReportName");
1753        else if (Configuration.doAutoCreate())
1754          this.preferredReportName = new StringType(); // bb
1755      return this.preferredReportName;
1756    }
1757
1758    public boolean hasPreferredReportNameElement() { 
1759      return this.preferredReportName != null && !this.preferredReportName.isEmpty();
1760    }
1761
1762    public boolean hasPreferredReportName() { 
1763      return this.preferredReportName != null && !this.preferredReportName.isEmpty();
1764    }
1765
1766    /**
1767     * @param value {@link #preferredReportName} (The preferred name to be used when reporting the results of observations conforming to this ObservationDefinition.). This is the underlying object with id, value and extensions. The accessor "getPreferredReportName" gives direct access to the value
1768     */
1769    public ObservationDefinition setPreferredReportNameElement(StringType value) { 
1770      this.preferredReportName = value;
1771      return this;
1772    }
1773
1774    /**
1775     * @return The preferred name to be used when reporting the results of observations conforming to this ObservationDefinition.
1776     */
1777    public String getPreferredReportName() { 
1778      return this.preferredReportName == null ? null : this.preferredReportName.getValue();
1779    }
1780
1781    /**
1782     * @param value The preferred name to be used when reporting the results of observations conforming to this ObservationDefinition.
1783     */
1784    public ObservationDefinition setPreferredReportName(String value) { 
1785      if (Utilities.noString(value))
1786        this.preferredReportName = null;
1787      else {
1788        if (this.preferredReportName == null)
1789          this.preferredReportName = new StringType();
1790        this.preferredReportName.setValue(value);
1791      }
1792      return this;
1793    }
1794
1795    /**
1796     * @return {@link #quantitativeDetails} (Characteristics for quantitative results of this observation.)
1797     */
1798    public ObservationDefinitionQuantitativeDetailsComponent getQuantitativeDetails() { 
1799      if (this.quantitativeDetails == null)
1800        if (Configuration.errorOnAutoCreate())
1801          throw new Error("Attempt to auto-create ObservationDefinition.quantitativeDetails");
1802        else if (Configuration.doAutoCreate())
1803          this.quantitativeDetails = new ObservationDefinitionQuantitativeDetailsComponent(); // cc
1804      return this.quantitativeDetails;
1805    }
1806
1807    public boolean hasQuantitativeDetails() { 
1808      return this.quantitativeDetails != null && !this.quantitativeDetails.isEmpty();
1809    }
1810
1811    /**
1812     * @param value {@link #quantitativeDetails} (Characteristics for quantitative results of this observation.)
1813     */
1814    public ObservationDefinition setQuantitativeDetails(ObservationDefinitionQuantitativeDetailsComponent value) { 
1815      this.quantitativeDetails = value;
1816      return this;
1817    }
1818
1819    /**
1820     * @return {@link #qualifiedInterval} (Multiple  ranges of results qualified by different contexts for ordinal or continuous observations conforming to this ObservationDefinition.)
1821     */
1822    public List<ObservationDefinitionQualifiedIntervalComponent> getQualifiedInterval() { 
1823      if (this.qualifiedInterval == null)
1824        this.qualifiedInterval = new ArrayList<ObservationDefinitionQualifiedIntervalComponent>();
1825      return this.qualifiedInterval;
1826    }
1827
1828    /**
1829     * @return Returns a reference to <code>this</code> for easy method chaining
1830     */
1831    public ObservationDefinition setQualifiedInterval(List<ObservationDefinitionQualifiedIntervalComponent> theQualifiedInterval) { 
1832      this.qualifiedInterval = theQualifiedInterval;
1833      return this;
1834    }
1835
1836    public boolean hasQualifiedInterval() { 
1837      if (this.qualifiedInterval == null)
1838        return false;
1839      for (ObservationDefinitionQualifiedIntervalComponent item : this.qualifiedInterval)
1840        if (!item.isEmpty())
1841          return true;
1842      return false;
1843    }
1844
1845    public ObservationDefinitionQualifiedIntervalComponent addQualifiedInterval() { //3
1846      ObservationDefinitionQualifiedIntervalComponent t = new ObservationDefinitionQualifiedIntervalComponent();
1847      if (this.qualifiedInterval == null)
1848        this.qualifiedInterval = new ArrayList<ObservationDefinitionQualifiedIntervalComponent>();
1849      this.qualifiedInterval.add(t);
1850      return t;
1851    }
1852
1853    public ObservationDefinition addQualifiedInterval(ObservationDefinitionQualifiedIntervalComponent t) { //3
1854      if (t == null)
1855        return this;
1856      if (this.qualifiedInterval == null)
1857        this.qualifiedInterval = new ArrayList<ObservationDefinitionQualifiedIntervalComponent>();
1858      this.qualifiedInterval.add(t);
1859      return this;
1860    }
1861
1862    /**
1863     * @return The first repetition of repeating field {@link #qualifiedInterval}, creating it if it does not already exist
1864     */
1865    public ObservationDefinitionQualifiedIntervalComponent getQualifiedIntervalFirstRep() { 
1866      if (getQualifiedInterval().isEmpty()) {
1867        addQualifiedInterval();
1868      }
1869      return getQualifiedInterval().get(0);
1870    }
1871
1872    /**
1873     * @return {@link #validCodedValueSet} (The set of valid coded results for the observations  conforming to this ObservationDefinition.)
1874     */
1875    public Reference getValidCodedValueSet() { 
1876      if (this.validCodedValueSet == null)
1877        if (Configuration.errorOnAutoCreate())
1878          throw new Error("Attempt to auto-create ObservationDefinition.validCodedValueSet");
1879        else if (Configuration.doAutoCreate())
1880          this.validCodedValueSet = new Reference(); // cc
1881      return this.validCodedValueSet;
1882    }
1883
1884    public boolean hasValidCodedValueSet() { 
1885      return this.validCodedValueSet != null && !this.validCodedValueSet.isEmpty();
1886    }
1887
1888    /**
1889     * @param value {@link #validCodedValueSet} (The set of valid coded results for the observations  conforming to this ObservationDefinition.)
1890     */
1891    public ObservationDefinition setValidCodedValueSet(Reference value) { 
1892      this.validCodedValueSet = value;
1893      return this;
1894    }
1895
1896    /**
1897     * @return {@link #validCodedValueSet} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The set of valid coded results for the observations  conforming to this ObservationDefinition.)
1898     */
1899    public ValueSet getValidCodedValueSetTarget() { 
1900      if (this.validCodedValueSetTarget == null)
1901        if (Configuration.errorOnAutoCreate())
1902          throw new Error("Attempt to auto-create ObservationDefinition.validCodedValueSet");
1903        else if (Configuration.doAutoCreate())
1904          this.validCodedValueSetTarget = new ValueSet(); // aa
1905      return this.validCodedValueSetTarget;
1906    }
1907
1908    /**
1909     * @param value {@link #validCodedValueSet} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The set of valid coded results for the observations  conforming to this ObservationDefinition.)
1910     */
1911    public ObservationDefinition setValidCodedValueSetTarget(ValueSet value) { 
1912      this.validCodedValueSetTarget = value;
1913      return this;
1914    }
1915
1916    /**
1917     * @return {@link #normalCodedValueSet} (The set of normal coded results for the observations conforming to this ObservationDefinition.)
1918     */
1919    public Reference getNormalCodedValueSet() { 
1920      if (this.normalCodedValueSet == null)
1921        if (Configuration.errorOnAutoCreate())
1922          throw new Error("Attempt to auto-create ObservationDefinition.normalCodedValueSet");
1923        else if (Configuration.doAutoCreate())
1924          this.normalCodedValueSet = new Reference(); // cc
1925      return this.normalCodedValueSet;
1926    }
1927
1928    public boolean hasNormalCodedValueSet() { 
1929      return this.normalCodedValueSet != null && !this.normalCodedValueSet.isEmpty();
1930    }
1931
1932    /**
1933     * @param value {@link #normalCodedValueSet} (The set of normal coded results for the observations conforming to this ObservationDefinition.)
1934     */
1935    public ObservationDefinition setNormalCodedValueSet(Reference value) { 
1936      this.normalCodedValueSet = value;
1937      return this;
1938    }
1939
1940    /**
1941     * @return {@link #normalCodedValueSet} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The set of normal coded results for the observations conforming to this ObservationDefinition.)
1942     */
1943    public ValueSet getNormalCodedValueSetTarget() { 
1944      if (this.normalCodedValueSetTarget == null)
1945        if (Configuration.errorOnAutoCreate())
1946          throw new Error("Attempt to auto-create ObservationDefinition.normalCodedValueSet");
1947        else if (Configuration.doAutoCreate())
1948          this.normalCodedValueSetTarget = new ValueSet(); // aa
1949      return this.normalCodedValueSetTarget;
1950    }
1951
1952    /**
1953     * @param value {@link #normalCodedValueSet} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The set of normal coded results for the observations conforming to this ObservationDefinition.)
1954     */
1955    public ObservationDefinition setNormalCodedValueSetTarget(ValueSet value) { 
1956      this.normalCodedValueSetTarget = value;
1957      return this;
1958    }
1959
1960    /**
1961     * @return {@link #abnormalCodedValueSet} (The set of abnormal coded results for the observation conforming to this ObservationDefinition.)
1962     */
1963    public Reference getAbnormalCodedValueSet() { 
1964      if (this.abnormalCodedValueSet == null)
1965        if (Configuration.errorOnAutoCreate())
1966          throw new Error("Attempt to auto-create ObservationDefinition.abnormalCodedValueSet");
1967        else if (Configuration.doAutoCreate())
1968          this.abnormalCodedValueSet = new Reference(); // cc
1969      return this.abnormalCodedValueSet;
1970    }
1971
1972    public boolean hasAbnormalCodedValueSet() { 
1973      return this.abnormalCodedValueSet != null && !this.abnormalCodedValueSet.isEmpty();
1974    }
1975
1976    /**
1977     * @param value {@link #abnormalCodedValueSet} (The set of abnormal coded results for the observation conforming to this ObservationDefinition.)
1978     */
1979    public ObservationDefinition setAbnormalCodedValueSet(Reference value) { 
1980      this.abnormalCodedValueSet = value;
1981      return this;
1982    }
1983
1984    /**
1985     * @return {@link #abnormalCodedValueSet} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The set of abnormal coded results for the observation conforming to this ObservationDefinition.)
1986     */
1987    public ValueSet getAbnormalCodedValueSetTarget() { 
1988      if (this.abnormalCodedValueSetTarget == null)
1989        if (Configuration.errorOnAutoCreate())
1990          throw new Error("Attempt to auto-create ObservationDefinition.abnormalCodedValueSet");
1991        else if (Configuration.doAutoCreate())
1992          this.abnormalCodedValueSetTarget = new ValueSet(); // aa
1993      return this.abnormalCodedValueSetTarget;
1994    }
1995
1996    /**
1997     * @param value {@link #abnormalCodedValueSet} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The set of abnormal coded results for the observation conforming to this ObservationDefinition.)
1998     */
1999    public ObservationDefinition setAbnormalCodedValueSetTarget(ValueSet value) { 
2000      this.abnormalCodedValueSetTarget = value;
2001      return this;
2002    }
2003
2004    /**
2005     * @return {@link #criticalCodedValueSet} (The set of critical coded results for the observation conforming to this ObservationDefinition.)
2006     */
2007    public Reference getCriticalCodedValueSet() { 
2008      if (this.criticalCodedValueSet == null)
2009        if (Configuration.errorOnAutoCreate())
2010          throw new Error("Attempt to auto-create ObservationDefinition.criticalCodedValueSet");
2011        else if (Configuration.doAutoCreate())
2012          this.criticalCodedValueSet = new Reference(); // cc
2013      return this.criticalCodedValueSet;
2014    }
2015
2016    public boolean hasCriticalCodedValueSet() { 
2017      return this.criticalCodedValueSet != null && !this.criticalCodedValueSet.isEmpty();
2018    }
2019
2020    /**
2021     * @param value {@link #criticalCodedValueSet} (The set of critical coded results for the observation conforming to this ObservationDefinition.)
2022     */
2023    public ObservationDefinition setCriticalCodedValueSet(Reference value) { 
2024      this.criticalCodedValueSet = value;
2025      return this;
2026    }
2027
2028    /**
2029     * @return {@link #criticalCodedValueSet} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The set of critical coded results for the observation conforming to this ObservationDefinition.)
2030     */
2031    public ValueSet getCriticalCodedValueSetTarget() { 
2032      if (this.criticalCodedValueSetTarget == null)
2033        if (Configuration.errorOnAutoCreate())
2034          throw new Error("Attempt to auto-create ObservationDefinition.criticalCodedValueSet");
2035        else if (Configuration.doAutoCreate())
2036          this.criticalCodedValueSetTarget = new ValueSet(); // aa
2037      return this.criticalCodedValueSetTarget;
2038    }
2039
2040    /**
2041     * @param value {@link #criticalCodedValueSet} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The set of critical coded results for the observation conforming to this ObservationDefinition.)
2042     */
2043    public ObservationDefinition setCriticalCodedValueSetTarget(ValueSet value) { 
2044      this.criticalCodedValueSetTarget = value;
2045      return this;
2046    }
2047
2048      protected void listChildren(List<Property> children) {
2049        super.listChildren(children);
2050        children.add(new Property("category", "CodeableConcept", "A code that classifies the general type of observation.", 0, java.lang.Integer.MAX_VALUE, category));
2051        children.add(new Property("code", "CodeableConcept", "Describes what will be observed. Sometimes this is called the observation \"name\".", 0, 1, code));
2052        children.add(new Property("identifier", "Identifier", "A unique identifier assigned to this ObservationDefinition artifact.", 0, java.lang.Integer.MAX_VALUE, identifier));
2053        children.add(new Property("permittedDataType", "code", "The data types allowed for the value element of the instance observations conforming to this ObservationDefinition.", 0, java.lang.Integer.MAX_VALUE, permittedDataType));
2054        children.add(new Property("multipleResultsAllowed", "boolean", "Multiple results allowed for observations conforming to this ObservationDefinition.", 0, 1, multipleResultsAllowed));
2055        children.add(new Property("method", "CodeableConcept", "The method or technique used to perform the observation.", 0, 1, method));
2056        children.add(new Property("preferredReportName", "string", "The preferred name to be used when reporting the results of observations conforming to this ObservationDefinition.", 0, 1, preferredReportName));
2057        children.add(new Property("quantitativeDetails", "", "Characteristics for quantitative results of this observation.", 0, 1, quantitativeDetails));
2058        children.add(new Property("qualifiedInterval", "", "Multiple  ranges of results qualified by different contexts for ordinal or continuous observations conforming to this ObservationDefinition.", 0, java.lang.Integer.MAX_VALUE, qualifiedInterval));
2059        children.add(new Property("validCodedValueSet", "Reference(ValueSet)", "The set of valid coded results for the observations  conforming to this ObservationDefinition.", 0, 1, validCodedValueSet));
2060        children.add(new Property("normalCodedValueSet", "Reference(ValueSet)", "The set of normal coded results for the observations conforming to this ObservationDefinition.", 0, 1, normalCodedValueSet));
2061        children.add(new Property("abnormalCodedValueSet", "Reference(ValueSet)", "The set of abnormal coded results for the observation conforming to this ObservationDefinition.", 0, 1, abnormalCodedValueSet));
2062        children.add(new Property("criticalCodedValueSet", "Reference(ValueSet)", "The set of critical coded results for the observation conforming to this ObservationDefinition.", 0, 1, criticalCodedValueSet));
2063      }
2064
2065      @Override
2066      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2067        switch (_hash) {
2068        case 50511102: /*category*/  return new Property("category", "CodeableConcept", "A code that classifies the general type of observation.", 0, java.lang.Integer.MAX_VALUE, category);
2069        case 3059181: /*code*/  return new Property("code", "CodeableConcept", "Describes what will be observed. Sometimes this is called the observation \"name\".", 0, 1, code);
2070        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "A unique identifier assigned to this ObservationDefinition artifact.", 0, java.lang.Integer.MAX_VALUE, identifier);
2071        case -99492804: /*permittedDataType*/  return new Property("permittedDataType", "code", "The data types allowed for the value element of the instance observations conforming to this ObservationDefinition.", 0, java.lang.Integer.MAX_VALUE, permittedDataType);
2072        case -2102414590: /*multipleResultsAllowed*/  return new Property("multipleResultsAllowed", "boolean", "Multiple results allowed for observations conforming to this ObservationDefinition.", 0, 1, multipleResultsAllowed);
2073        case -1077554975: /*method*/  return new Property("method", "CodeableConcept", "The method or technique used to perform the observation.", 0, 1, method);
2074        case -1851030208: /*preferredReportName*/  return new Property("preferredReportName", "string", "The preferred name to be used when reporting the results of observations conforming to this ObservationDefinition.", 0, 1, preferredReportName);
2075        case 842150763: /*quantitativeDetails*/  return new Property("quantitativeDetails", "", "Characteristics for quantitative results of this observation.", 0, 1, quantitativeDetails);
2076        case 1882971521: /*qualifiedInterval*/  return new Property("qualifiedInterval", "", "Multiple  ranges of results qualified by different contexts for ordinal or continuous observations conforming to this ObservationDefinition.", 0, java.lang.Integer.MAX_VALUE, qualifiedInterval);
2077        case 1374640076: /*validCodedValueSet*/  return new Property("validCodedValueSet", "Reference(ValueSet)", "The set of valid coded results for the observations  conforming to this ObservationDefinition.", 0, 1, validCodedValueSet);
2078        case -837500735: /*normalCodedValueSet*/  return new Property("normalCodedValueSet", "Reference(ValueSet)", "The set of normal coded results for the observations conforming to this ObservationDefinition.", 0, 1, normalCodedValueSet);
2079        case 1073600256: /*abnormalCodedValueSet*/  return new Property("abnormalCodedValueSet", "Reference(ValueSet)", "The set of abnormal coded results for the observation conforming to this ObservationDefinition.", 0, 1, abnormalCodedValueSet);
2080        case 2568457: /*criticalCodedValueSet*/  return new Property("criticalCodedValueSet", "Reference(ValueSet)", "The set of critical coded results for the observation conforming to this ObservationDefinition.", 0, 1, criticalCodedValueSet);
2081        default: return super.getNamedProperty(_hash, _name, _checkValid);
2082        }
2083
2084      }
2085
2086      @Override
2087      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2088        switch (hash) {
2089        case 50511102: /*category*/ return this.category == null ? new Base[0] : this.category.toArray(new Base[this.category.size()]); // CodeableConcept
2090        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept
2091        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
2092        case -99492804: /*permittedDataType*/ return this.permittedDataType == null ? new Base[0] : this.permittedDataType.toArray(new Base[this.permittedDataType.size()]); // Enumeration<ObservationDataType>
2093        case -2102414590: /*multipleResultsAllowed*/ return this.multipleResultsAllowed == null ? new Base[0] : new Base[] {this.multipleResultsAllowed}; // BooleanType
2094        case -1077554975: /*method*/ return this.method == null ? new Base[0] : new Base[] {this.method}; // CodeableConcept
2095        case -1851030208: /*preferredReportName*/ return this.preferredReportName == null ? new Base[0] : new Base[] {this.preferredReportName}; // StringType
2096        case 842150763: /*quantitativeDetails*/ return this.quantitativeDetails == null ? new Base[0] : new Base[] {this.quantitativeDetails}; // ObservationDefinitionQuantitativeDetailsComponent
2097        case 1882971521: /*qualifiedInterval*/ return this.qualifiedInterval == null ? new Base[0] : this.qualifiedInterval.toArray(new Base[this.qualifiedInterval.size()]); // ObservationDefinitionQualifiedIntervalComponent
2098        case 1374640076: /*validCodedValueSet*/ return this.validCodedValueSet == null ? new Base[0] : new Base[] {this.validCodedValueSet}; // Reference
2099        case -837500735: /*normalCodedValueSet*/ return this.normalCodedValueSet == null ? new Base[0] : new Base[] {this.normalCodedValueSet}; // Reference
2100        case 1073600256: /*abnormalCodedValueSet*/ return this.abnormalCodedValueSet == null ? new Base[0] : new Base[] {this.abnormalCodedValueSet}; // Reference
2101        case 2568457: /*criticalCodedValueSet*/ return this.criticalCodedValueSet == null ? new Base[0] : new Base[] {this.criticalCodedValueSet}; // Reference
2102        default: return super.getProperty(hash, name, checkValid);
2103        }
2104
2105      }
2106
2107      @Override
2108      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2109        switch (hash) {
2110        case 50511102: // category
2111          this.getCategory().add(castToCodeableConcept(value)); // CodeableConcept
2112          return value;
2113        case 3059181: // code
2114          this.code = castToCodeableConcept(value); // CodeableConcept
2115          return value;
2116        case -1618432855: // identifier
2117          this.getIdentifier().add(castToIdentifier(value)); // Identifier
2118          return value;
2119        case -99492804: // permittedDataType
2120          value = new ObservationDataTypeEnumFactory().fromType(castToCode(value));
2121          this.getPermittedDataType().add((Enumeration) value); // Enumeration<ObservationDataType>
2122          return value;
2123        case -2102414590: // multipleResultsAllowed
2124          this.multipleResultsAllowed = castToBoolean(value); // BooleanType
2125          return value;
2126        case -1077554975: // method
2127          this.method = castToCodeableConcept(value); // CodeableConcept
2128          return value;
2129        case -1851030208: // preferredReportName
2130          this.preferredReportName = castToString(value); // StringType
2131          return value;
2132        case 842150763: // quantitativeDetails
2133          this.quantitativeDetails = (ObservationDefinitionQuantitativeDetailsComponent) value; // ObservationDefinitionQuantitativeDetailsComponent
2134          return value;
2135        case 1882971521: // qualifiedInterval
2136          this.getQualifiedInterval().add((ObservationDefinitionQualifiedIntervalComponent) value); // ObservationDefinitionQualifiedIntervalComponent
2137          return value;
2138        case 1374640076: // validCodedValueSet
2139          this.validCodedValueSet = castToReference(value); // Reference
2140          return value;
2141        case -837500735: // normalCodedValueSet
2142          this.normalCodedValueSet = castToReference(value); // Reference
2143          return value;
2144        case 1073600256: // abnormalCodedValueSet
2145          this.abnormalCodedValueSet = castToReference(value); // Reference
2146          return value;
2147        case 2568457: // criticalCodedValueSet
2148          this.criticalCodedValueSet = castToReference(value); // Reference
2149          return value;
2150        default: return super.setProperty(hash, name, value);
2151        }
2152
2153      }
2154
2155      @Override
2156      public Base setProperty(String name, Base value) throws FHIRException {
2157        if (name.equals("category")) {
2158          this.getCategory().add(castToCodeableConcept(value));
2159        } else if (name.equals("code")) {
2160          this.code = castToCodeableConcept(value); // CodeableConcept
2161        } else if (name.equals("identifier")) {
2162          this.getIdentifier().add(castToIdentifier(value));
2163        } else if (name.equals("permittedDataType")) {
2164          value = new ObservationDataTypeEnumFactory().fromType(castToCode(value));
2165          this.getPermittedDataType().add((Enumeration) value);
2166        } else if (name.equals("multipleResultsAllowed")) {
2167          this.multipleResultsAllowed = castToBoolean(value); // BooleanType
2168        } else if (name.equals("method")) {
2169          this.method = castToCodeableConcept(value); // CodeableConcept
2170        } else if (name.equals("preferredReportName")) {
2171          this.preferredReportName = castToString(value); // StringType
2172        } else if (name.equals("quantitativeDetails")) {
2173          this.quantitativeDetails = (ObservationDefinitionQuantitativeDetailsComponent) value; // ObservationDefinitionQuantitativeDetailsComponent
2174        } else if (name.equals("qualifiedInterval")) {
2175          this.getQualifiedInterval().add((ObservationDefinitionQualifiedIntervalComponent) value);
2176        } else if (name.equals("validCodedValueSet")) {
2177          this.validCodedValueSet = castToReference(value); // Reference
2178        } else if (name.equals("normalCodedValueSet")) {
2179          this.normalCodedValueSet = castToReference(value); // Reference
2180        } else if (name.equals("abnormalCodedValueSet")) {
2181          this.abnormalCodedValueSet = castToReference(value); // Reference
2182        } else if (name.equals("criticalCodedValueSet")) {
2183          this.criticalCodedValueSet = castToReference(value); // Reference
2184        } else
2185          return super.setProperty(name, value);
2186        return value;
2187      }
2188
2189      @Override
2190      public Base makeProperty(int hash, String name) throws FHIRException {
2191        switch (hash) {
2192        case 50511102:  return addCategory(); 
2193        case 3059181:  return getCode(); 
2194        case -1618432855:  return addIdentifier(); 
2195        case -99492804:  return addPermittedDataTypeElement();
2196        case -2102414590:  return getMultipleResultsAllowedElement();
2197        case -1077554975:  return getMethod(); 
2198        case -1851030208:  return getPreferredReportNameElement();
2199        case 842150763:  return getQuantitativeDetails(); 
2200        case 1882971521:  return addQualifiedInterval(); 
2201        case 1374640076:  return getValidCodedValueSet(); 
2202        case -837500735:  return getNormalCodedValueSet(); 
2203        case 1073600256:  return getAbnormalCodedValueSet(); 
2204        case 2568457:  return getCriticalCodedValueSet(); 
2205        default: return super.makeProperty(hash, name);
2206        }
2207
2208      }
2209
2210      @Override
2211      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2212        switch (hash) {
2213        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
2214        case 3059181: /*code*/ return new String[] {"CodeableConcept"};
2215        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
2216        case -99492804: /*permittedDataType*/ return new String[] {"code"};
2217        case -2102414590: /*multipleResultsAllowed*/ return new String[] {"boolean"};
2218        case -1077554975: /*method*/ return new String[] {"CodeableConcept"};
2219        case -1851030208: /*preferredReportName*/ return new String[] {"string"};
2220        case 842150763: /*quantitativeDetails*/ return new String[] {};
2221        case 1882971521: /*qualifiedInterval*/ return new String[] {};
2222        case 1374640076: /*validCodedValueSet*/ return new String[] {"Reference"};
2223        case -837500735: /*normalCodedValueSet*/ return new String[] {"Reference"};
2224        case 1073600256: /*abnormalCodedValueSet*/ return new String[] {"Reference"};
2225        case 2568457: /*criticalCodedValueSet*/ return new String[] {"Reference"};
2226        default: return super.getTypesForProperty(hash, name);
2227        }
2228
2229      }
2230
2231      @Override
2232      public Base addChild(String name) throws FHIRException {
2233        if (name.equals("category")) {
2234          return addCategory();
2235        }
2236        else if (name.equals("code")) {
2237          this.code = new CodeableConcept();
2238          return this.code;
2239        }
2240        else if (name.equals("identifier")) {
2241          return addIdentifier();
2242        }
2243        else if (name.equals("permittedDataType")) {
2244          throw new FHIRException("Cannot call addChild on a primitive type ObservationDefinition.permittedDataType");
2245        }
2246        else if (name.equals("multipleResultsAllowed")) {
2247          throw new FHIRException("Cannot call addChild on a primitive type ObservationDefinition.multipleResultsAllowed");
2248        }
2249        else if (name.equals("method")) {
2250          this.method = new CodeableConcept();
2251          return this.method;
2252        }
2253        else if (name.equals("preferredReportName")) {
2254          throw new FHIRException("Cannot call addChild on a primitive type ObservationDefinition.preferredReportName");
2255        }
2256        else if (name.equals("quantitativeDetails")) {
2257          this.quantitativeDetails = new ObservationDefinitionQuantitativeDetailsComponent();
2258          return this.quantitativeDetails;
2259        }
2260        else if (name.equals("qualifiedInterval")) {
2261          return addQualifiedInterval();
2262        }
2263        else if (name.equals("validCodedValueSet")) {
2264          this.validCodedValueSet = new Reference();
2265          return this.validCodedValueSet;
2266        }
2267        else if (name.equals("normalCodedValueSet")) {
2268          this.normalCodedValueSet = new Reference();
2269          return this.normalCodedValueSet;
2270        }
2271        else if (name.equals("abnormalCodedValueSet")) {
2272          this.abnormalCodedValueSet = new Reference();
2273          return this.abnormalCodedValueSet;
2274        }
2275        else if (name.equals("criticalCodedValueSet")) {
2276          this.criticalCodedValueSet = new Reference();
2277          return this.criticalCodedValueSet;
2278        }
2279        else
2280          return super.addChild(name);
2281      }
2282
2283  public String fhirType() {
2284    return "ObservationDefinition";
2285
2286  }
2287
2288      public ObservationDefinition copy() {
2289        ObservationDefinition dst = new ObservationDefinition();
2290        copyValues(dst);
2291        return dst;
2292      }
2293
2294      public void copyValues(ObservationDefinition dst) {
2295        super.copyValues(dst);
2296        if (category != null) {
2297          dst.category = new ArrayList<CodeableConcept>();
2298          for (CodeableConcept i : category)
2299            dst.category.add(i.copy());
2300        };
2301        dst.code = code == null ? null : code.copy();
2302        if (identifier != null) {
2303          dst.identifier = new ArrayList<Identifier>();
2304          for (Identifier i : identifier)
2305            dst.identifier.add(i.copy());
2306        };
2307        if (permittedDataType != null) {
2308          dst.permittedDataType = new ArrayList<Enumeration<ObservationDataType>>();
2309          for (Enumeration<ObservationDataType> i : permittedDataType)
2310            dst.permittedDataType.add(i.copy());
2311        };
2312        dst.multipleResultsAllowed = multipleResultsAllowed == null ? null : multipleResultsAllowed.copy();
2313        dst.method = method == null ? null : method.copy();
2314        dst.preferredReportName = preferredReportName == null ? null : preferredReportName.copy();
2315        dst.quantitativeDetails = quantitativeDetails == null ? null : quantitativeDetails.copy();
2316        if (qualifiedInterval != null) {
2317          dst.qualifiedInterval = new ArrayList<ObservationDefinitionQualifiedIntervalComponent>();
2318          for (ObservationDefinitionQualifiedIntervalComponent i : qualifiedInterval)
2319            dst.qualifiedInterval.add(i.copy());
2320        };
2321        dst.validCodedValueSet = validCodedValueSet == null ? null : validCodedValueSet.copy();
2322        dst.normalCodedValueSet = normalCodedValueSet == null ? null : normalCodedValueSet.copy();
2323        dst.abnormalCodedValueSet = abnormalCodedValueSet == null ? null : abnormalCodedValueSet.copy();
2324        dst.criticalCodedValueSet = criticalCodedValueSet == null ? null : criticalCodedValueSet.copy();
2325      }
2326
2327      protected ObservationDefinition typedCopy() {
2328        return copy();
2329      }
2330
2331      @Override
2332      public boolean equalsDeep(Base other_) {
2333        if (!super.equalsDeep(other_))
2334          return false;
2335        if (!(other_ instanceof ObservationDefinition))
2336          return false;
2337        ObservationDefinition o = (ObservationDefinition) other_;
2338        return compareDeep(category, o.category, true) && compareDeep(code, o.code, true) && compareDeep(identifier, o.identifier, true)
2339           && compareDeep(permittedDataType, o.permittedDataType, true) && compareDeep(multipleResultsAllowed, o.multipleResultsAllowed, true)
2340           && compareDeep(method, o.method, true) && compareDeep(preferredReportName, o.preferredReportName, true)
2341           && compareDeep(quantitativeDetails, o.quantitativeDetails, true) && compareDeep(qualifiedInterval, o.qualifiedInterval, true)
2342           && compareDeep(validCodedValueSet, o.validCodedValueSet, true) && compareDeep(normalCodedValueSet, o.normalCodedValueSet, true)
2343           && compareDeep(abnormalCodedValueSet, o.abnormalCodedValueSet, true) && compareDeep(criticalCodedValueSet, o.criticalCodedValueSet, true)
2344          ;
2345      }
2346
2347      @Override
2348      public boolean equalsShallow(Base other_) {
2349        if (!super.equalsShallow(other_))
2350          return false;
2351        if (!(other_ instanceof ObservationDefinition))
2352          return false;
2353        ObservationDefinition o = (ObservationDefinition) other_;
2354        return compareValues(permittedDataType, o.permittedDataType, true) && compareValues(multipleResultsAllowed, o.multipleResultsAllowed, true)
2355           && compareValues(preferredReportName, o.preferredReportName, true);
2356      }
2357
2358      public boolean isEmpty() {
2359        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(category, code, identifier
2360          , permittedDataType, multipleResultsAllowed, method, preferredReportName, quantitativeDetails
2361          , qualifiedInterval, validCodedValueSet, normalCodedValueSet, abnormalCodedValueSet
2362          , criticalCodedValueSet);
2363      }
2364
2365  @Override
2366  public ResourceType getResourceType() {
2367    return ResourceType.ObservationDefinition;
2368   }
2369
2370
2371}