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