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