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