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