001package org.hl7.fhir.r4.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Sun, May 6, 2018 17:51-0400 for FHIR v3.4.0
033
034import java.util.*;
035
036import java.math.*;
037import org.hl7.fhir.utilities.Utilities;
038import ca.uhn.fhir.model.api.annotation.ResourceDef;
039import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
040import ca.uhn.fhir.model.api.annotation.Child;
041import ca.uhn.fhir.model.api.annotation.ChildOrder;
042import ca.uhn.fhir.model.api.annotation.Description;
043import ca.uhn.fhir.model.api.annotation.Block;
044import org.hl7.fhir.instance.model.api.*;
045import org.hl7.fhir.exceptions.FHIRException;
046/**
047 * Set of definitional characteristics for a kind of observation or measurement produced or consumed by an orderable health care service.
048 */
049@ResourceDef(name="ObservationDefinition", profile="http://hl7.org/fhir/Profile/ObservationDefinition")
050public class ObservationDefinition extends DomainResource {
051
052    @Block()
053    public static class ObservationDefinitionQuantitativeDetailsComponent extends BackboneElement implements IBaseBackboneElement {
054        /**
055         * Customary unit used to report quantitative results of this observation.
056         */
057        @Child(name = "customaryUnit", type = {Coding.class}, order=1, min=0, max=1, modifier=false, summary=false)
058        @Description(shortDefinition="Customary unit for quantitative results", formalDefinition="Customary unit used to report quantitative results of this observation." )
059        protected Coding customaryUnit;
060
061        /**
062         * SI unit used to report quantitative results of this observation.
063         */
064        @Child(name = "unit", type = {Coding.class}, order=2, min=0, max=1, modifier=false, summary=false)
065        @Description(shortDefinition="SI unit for quantitative results", formalDefinition="SI unit used to report quantitative results of this observation." )
066        protected Coding unit;
067
068        /**
069         * Factor for converting value expressed with SI unit to value expressed with customary unit.
070         */
071        @Child(name = "conversionFactor", type = {DecimalType.class}, order=3, min=0, max=1, modifier=false, summary=false)
072        @Description(shortDefinition="SI to Customary unit conversion factor", formalDefinition="Factor for converting value expressed with SI unit to value expressed with customary unit." )
073        protected DecimalType conversionFactor;
074
075        /**
076         * Number of digits after decimal separator when the results of this observation are of type Quantity.
077         */
078        @Child(name = "decimalPrecision", type = {IntegerType.class}, order=4, min=0, max=1, modifier=false, summary=false)
079        @Description(shortDefinition="Decimal precision of observation quantitative results", formalDefinition="Number of digits after decimal separator when the results of this observation are of type Quantity." )
080        protected IntegerType decimalPrecision;
081
082        private static final long serialVersionUID = -1533265578L;
083
084    /**
085     * Constructor
086     */
087      public ObservationDefinitionQuantitativeDetailsComponent() {
088        super();
089      }
090
091        /**
092         * @return {@link #customaryUnit} (Customary unit used to report quantitative results of this observation.)
093         */
094        public Coding getCustomaryUnit() { 
095          if (this.customaryUnit == null)
096            if (Configuration.errorOnAutoCreate())
097              throw new Error("Attempt to auto-create ObservationDefinitionQuantitativeDetailsComponent.customaryUnit");
098            else if (Configuration.doAutoCreate())
099              this.customaryUnit = new Coding(); // cc
100          return this.customaryUnit;
101        }
102
103        public boolean hasCustomaryUnit() { 
104          return this.customaryUnit != null && !this.customaryUnit.isEmpty();
105        }
106
107        /**
108         * @param value {@link #customaryUnit} (Customary unit used to report quantitative results of this observation.)
109         */
110        public ObservationDefinitionQuantitativeDetailsComponent setCustomaryUnit(Coding value) { 
111          this.customaryUnit = value;
112          return this;
113        }
114
115        /**
116         * @return {@link #unit} (SI unit used to report quantitative results of this observation.)
117         */
118        public Coding getUnit() { 
119          if (this.unit == null)
120            if (Configuration.errorOnAutoCreate())
121              throw new Error("Attempt to auto-create ObservationDefinitionQuantitativeDetailsComponent.unit");
122            else if (Configuration.doAutoCreate())
123              this.unit = new Coding(); // cc
124          return this.unit;
125        }
126
127        public boolean hasUnit() { 
128          return this.unit != null && !this.unit.isEmpty();
129        }
130
131        /**
132         * @param value {@link #unit} (SI unit used to report quantitative results of this observation.)
133         */
134        public ObservationDefinitionQuantitativeDetailsComponent setUnit(Coding value) { 
135          this.unit = value;
136          return this;
137        }
138
139        /**
140         * @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
141         */
142        public DecimalType getConversionFactorElement() { 
143          if (this.conversionFactor == null)
144            if (Configuration.errorOnAutoCreate())
145              throw new Error("Attempt to auto-create ObservationDefinitionQuantitativeDetailsComponent.conversionFactor");
146            else if (Configuration.doAutoCreate())
147              this.conversionFactor = new DecimalType(); // bb
148          return this.conversionFactor;
149        }
150
151        public boolean hasConversionFactorElement() { 
152          return this.conversionFactor != null && !this.conversionFactor.isEmpty();
153        }
154
155        public boolean hasConversionFactor() { 
156          return this.conversionFactor != null && !this.conversionFactor.isEmpty();
157        }
158
159        /**
160         * @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
161         */
162        public ObservationDefinitionQuantitativeDetailsComponent setConversionFactorElement(DecimalType value) { 
163          this.conversionFactor = value;
164          return this;
165        }
166
167        /**
168         * @return Factor for converting value expressed with SI unit to value expressed with customary unit.
169         */
170        public BigDecimal getConversionFactor() { 
171          return this.conversionFactor == null ? null : this.conversionFactor.getValue();
172        }
173
174        /**
175         * @param value Factor for converting value expressed with SI unit to value expressed with customary unit.
176         */
177        public ObservationDefinitionQuantitativeDetailsComponent setConversionFactor(BigDecimal value) { 
178          if (value == null)
179            this.conversionFactor = null;
180          else {
181            if (this.conversionFactor == null)
182              this.conversionFactor = new DecimalType();
183            this.conversionFactor.setValue(value);
184          }
185          return this;
186        }
187
188        /**
189         * @param value Factor for converting value expressed with SI unit to value expressed with customary unit.
190         */
191        public ObservationDefinitionQuantitativeDetailsComponent setConversionFactor(long value) { 
192              this.conversionFactor = new DecimalType();
193            this.conversionFactor.setValue(value);
194          return this;
195        }
196
197        /**
198         * @param value Factor for converting value expressed with SI unit to value expressed with customary unit.
199         */
200        public ObservationDefinitionQuantitativeDetailsComponent setConversionFactor(double value) { 
201              this.conversionFactor = new DecimalType();
202            this.conversionFactor.setValue(value);
203          return this;
204        }
205
206        /**
207         * @return {@link #decimalPrecision} (Number of digits after decimal separator when the results of this observation are of type Quantity.). This is the underlying object with id, value and extensions. The accessor "getDecimalPrecision" gives direct access to the value
208         */
209        public IntegerType getDecimalPrecisionElement() { 
210          if (this.decimalPrecision == null)
211            if (Configuration.errorOnAutoCreate())
212              throw new Error("Attempt to auto-create ObservationDefinitionQuantitativeDetailsComponent.decimalPrecision");
213            else if (Configuration.doAutoCreate())
214              this.decimalPrecision = new IntegerType(); // bb
215          return this.decimalPrecision;
216        }
217
218        public boolean hasDecimalPrecisionElement() { 
219          return this.decimalPrecision != null && !this.decimalPrecision.isEmpty();
220        }
221
222        public boolean hasDecimalPrecision() { 
223          return this.decimalPrecision != null && !this.decimalPrecision.isEmpty();
224        }
225
226        /**
227         * @param value {@link #decimalPrecision} (Number of digits after decimal separator when the results of this observation are of type Quantity.). This is the underlying object with id, value and extensions. The accessor "getDecimalPrecision" gives direct access to the value
228         */
229        public ObservationDefinitionQuantitativeDetailsComponent setDecimalPrecisionElement(IntegerType value) { 
230          this.decimalPrecision = value;
231          return this;
232        }
233
234        /**
235         * @return Number of digits after decimal separator when the results of this observation are of type Quantity.
236         */
237        public int getDecimalPrecision() { 
238          return this.decimalPrecision == null || this.decimalPrecision.isEmpty() ? 0 : this.decimalPrecision.getValue();
239        }
240
241        /**
242         * @param value Number of digits after decimal separator when the results of this observation are of type Quantity.
243         */
244        public ObservationDefinitionQuantitativeDetailsComponent setDecimalPrecision(int value) { 
245            if (this.decimalPrecision == null)
246              this.decimalPrecision = new IntegerType();
247            this.decimalPrecision.setValue(value);
248          return this;
249        }
250
251        protected void listChildren(List<Property> children) {
252          super.listChildren(children);
253          children.add(new Property("customaryUnit", "Coding", "Customary unit used to report quantitative results of this observation.", 0, 1, customaryUnit));
254          children.add(new Property("unit", "Coding", "SI unit used to report quantitative results of this observation.", 0, 1, unit));
255          children.add(new Property("conversionFactor", "decimal", "Factor for converting value expressed with SI unit to value expressed with customary unit.", 0, 1, conversionFactor));
256          children.add(new Property("decimalPrecision", "integer", "Number of digits after decimal separator when the results of this observation are of type Quantity.", 0, 1, decimalPrecision));
257        }
258
259        @Override
260        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
261          switch (_hash) {
262          case -1375586437: /*customaryUnit*/  return new Property("customaryUnit", "Coding", "Customary unit used to report quantitative results of this observation.", 0, 1, customaryUnit);
263          case 3594628: /*unit*/  return new Property("unit", "Coding", "SI unit used to report quantitative results of this observation.", 0, 1, unit);
264          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);
265          case -1564447699: /*decimalPrecision*/  return new Property("decimalPrecision", "integer", "Number of digits after decimal separator when the results of this observation are of type Quantity.", 0, 1, decimalPrecision);
266          default: return super.getNamedProperty(_hash, _name, _checkValid);
267          }
268
269        }
270
271      @Override
272      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
273        switch (hash) {
274        case -1375586437: /*customaryUnit*/ return this.customaryUnit == null ? new Base[0] : new Base[] {this.customaryUnit}; // Coding
275        case 3594628: /*unit*/ return this.unit == null ? new Base[0] : new Base[] {this.unit}; // Coding
276        case 1438876165: /*conversionFactor*/ return this.conversionFactor == null ? new Base[0] : new Base[] {this.conversionFactor}; // DecimalType
277        case -1564447699: /*decimalPrecision*/ return this.decimalPrecision == null ? new Base[0] : new Base[] {this.decimalPrecision}; // IntegerType
278        default: return super.getProperty(hash, name, checkValid);
279        }
280
281      }
282
283      @Override
284      public Base setProperty(int hash, String name, Base value) throws FHIRException {
285        switch (hash) {
286        case -1375586437: // customaryUnit
287          this.customaryUnit = castToCoding(value); // Coding
288          return value;
289        case 3594628: // unit
290          this.unit = castToCoding(value); // Coding
291          return value;
292        case 1438876165: // conversionFactor
293          this.conversionFactor = castToDecimal(value); // DecimalType
294          return value;
295        case -1564447699: // decimalPrecision
296          this.decimalPrecision = castToInteger(value); // IntegerType
297          return value;
298        default: return super.setProperty(hash, name, value);
299        }
300
301      }
302
303      @Override
304      public Base setProperty(String name, Base value) throws FHIRException {
305        if (name.equals("customaryUnit")) {
306          this.customaryUnit = castToCoding(value); // Coding
307        } else if (name.equals("unit")) {
308          this.unit = castToCoding(value); // Coding
309        } else if (name.equals("conversionFactor")) {
310          this.conversionFactor = castToDecimal(value); // DecimalType
311        } else if (name.equals("decimalPrecision")) {
312          this.decimalPrecision = castToInteger(value); // IntegerType
313        } else
314          return super.setProperty(name, value);
315        return value;
316      }
317
318      @Override
319      public Base makeProperty(int hash, String name) throws FHIRException {
320        switch (hash) {
321        case -1375586437:  return getCustomaryUnit(); 
322        case 3594628:  return getUnit(); 
323        case 1438876165:  return getConversionFactorElement();
324        case -1564447699:  return getDecimalPrecisionElement();
325        default: return super.makeProperty(hash, name);
326        }
327
328      }
329
330      @Override
331      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
332        switch (hash) {
333        case -1375586437: /*customaryUnit*/ return new String[] {"Coding"};
334        case 3594628: /*unit*/ return new String[] {"Coding"};
335        case 1438876165: /*conversionFactor*/ return new String[] {"decimal"};
336        case -1564447699: /*decimalPrecision*/ return new String[] {"integer"};
337        default: return super.getTypesForProperty(hash, name);
338        }
339
340      }
341
342      @Override
343      public Base addChild(String name) throws FHIRException {
344        if (name.equals("customaryUnit")) {
345          this.customaryUnit = new Coding();
346          return this.customaryUnit;
347        }
348        else if (name.equals("unit")) {
349          this.unit = new Coding();
350          return this.unit;
351        }
352        else if (name.equals("conversionFactor")) {
353          throw new FHIRException("Cannot call addChild on a primitive type ObservationDefinition.conversionFactor");
354        }
355        else if (name.equals("decimalPrecision")) {
356          throw new FHIRException("Cannot call addChild on a primitive type ObservationDefinition.decimalPrecision");
357        }
358        else
359          return super.addChild(name);
360      }
361
362      public ObservationDefinitionQuantitativeDetailsComponent copy() {
363        ObservationDefinitionQuantitativeDetailsComponent dst = new ObservationDefinitionQuantitativeDetailsComponent();
364        copyValues(dst);
365        dst.customaryUnit = customaryUnit == null ? null : customaryUnit.copy();
366        dst.unit = unit == null ? null : unit.copy();
367        dst.conversionFactor = conversionFactor == null ? null : conversionFactor.copy();
368        dst.decimalPrecision = decimalPrecision == null ? null : decimalPrecision.copy();
369        return dst;
370      }
371
372      @Override
373      public boolean equalsDeep(Base other_) {
374        if (!super.equalsDeep(other_))
375          return false;
376        if (!(other_ instanceof ObservationDefinitionQuantitativeDetailsComponent))
377          return false;
378        ObservationDefinitionQuantitativeDetailsComponent o = (ObservationDefinitionQuantitativeDetailsComponent) other_;
379        return compareDeep(customaryUnit, o.customaryUnit, true) && compareDeep(unit, o.unit, true) && compareDeep(conversionFactor, o.conversionFactor, true)
380           && compareDeep(decimalPrecision, o.decimalPrecision, true);
381      }
382
383      @Override
384      public boolean equalsShallow(Base other_) {
385        if (!super.equalsShallow(other_))
386          return false;
387        if (!(other_ instanceof ObservationDefinitionQuantitativeDetailsComponent))
388          return false;
389        ObservationDefinitionQuantitativeDetailsComponent o = (ObservationDefinitionQuantitativeDetailsComponent) other_;
390        return compareValues(conversionFactor, o.conversionFactor, true) && compareValues(decimalPrecision, o.decimalPrecision, true)
391          ;
392      }
393
394      public boolean isEmpty() {
395        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(customaryUnit, unit, conversionFactor
396          , decimalPrecision);
397      }
398
399  public String fhirType() {
400    return "ObservationDefinition.quantitativeDetails";
401
402  }
403
404  }
405
406    @Block()
407    public static class ObservationDefinitionQualifiedIntervalComponent extends BackboneElement implements IBaseBackboneElement {
408        /**
409         * The category or type of interval.
410         */
411        @Child(name = "category", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=false)
412        @Description(shortDefinition="The category or type of interval", formalDefinition="The category or type of interval." )
413        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/observation-category")
414        protected CodeableConcept category;
415
416        /**
417         * The value and associated unit of the low bound (inclusive) of the reference range.
418         */
419        @Child(name = "range", type = {Range.class}, order=2, min=0, max=1, modifier=false, summary=false)
420        @Description(shortDefinition="Low bound of reference range, if relevant", formalDefinition="The value and associated unit of the low bound (inclusive) of the reference range." )
421        protected Range range;
422
423        /**
424         * Codes to indicate what part of the targeted reference population it applies to. For example, the normal or therapeutic range.
425         */
426        @Child(name = "type", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=false)
427        @Description(shortDefinition="Reference range qualifier", formalDefinition="Codes to indicate what part of the targeted reference population it applies to. For example, the normal or therapeutic range." )
428        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/referencerange-meaning")
429        protected CodeableConcept type;
430
431        /**
432         * Codes to indicate the target population this reference range applies to.
433         */
434        @Child(name = "appliesTo", type = {CodeableConcept.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
435        @Description(shortDefinition="Reference range population", formalDefinition="Codes to indicate the target population this reference range applies to." )
436        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/referencerange-appliesto")
437        protected List<CodeableConcept> appliesTo;
438
439        /**
440         * 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.
441         */
442        @Child(name = "age", type = {Range.class}, order=5, min=0, max=1, modifier=false, summary=false)
443        @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." )
444        protected Range age;
445
446        /**
447         * The gestational age at which this reference range is applicable, in the context of pregnancy.
448         */
449        @Child(name = "gestationalAge", type = {Range.class}, order=6, min=0, max=1, modifier=false, summary=false)
450        @Description(shortDefinition="Applicable gestational age range, if relevant", formalDefinition="The gestational age at which this reference range is applicable, in the context of pregnancy." )
451        protected Range gestationalAge;
452
453        /**
454         * Text based condition for which the reference range is valid.
455         */
456        @Child(name = "condition", type = {StringType.class}, order=7, min=0, max=1, modifier=false, summary=false)
457        @Description(shortDefinition="Condition associated with the reference range", formalDefinition="Text based condition for which the reference range is valid." )
458        protected StringType condition;
459
460        private static final long serialVersionUID = 1566527077L;
461
462    /**
463     * Constructor
464     */
465      public ObservationDefinitionQualifiedIntervalComponent() {
466        super();
467      }
468
469        /**
470         * @return {@link #category} (The category or type of interval.)
471         */
472        public CodeableConcept getCategory() { 
473          if (this.category == null)
474            if (Configuration.errorOnAutoCreate())
475              throw new Error("Attempt to auto-create ObservationDefinitionQualifiedIntervalComponent.category");
476            else if (Configuration.doAutoCreate())
477              this.category = new CodeableConcept(); // cc
478          return this.category;
479        }
480
481        public boolean hasCategory() { 
482          return this.category != null && !this.category.isEmpty();
483        }
484
485        /**
486         * @param value {@link #category} (The category or type of interval.)
487         */
488        public ObservationDefinitionQualifiedIntervalComponent setCategory(CodeableConcept value) { 
489          this.category = value;
490          return this;
491        }
492
493        /**
494         * @return {@link #range} (The value and associated unit of the low bound (inclusive) of the reference range.)
495         */
496        public Range getRange() { 
497          if (this.range == null)
498            if (Configuration.errorOnAutoCreate())
499              throw new Error("Attempt to auto-create ObservationDefinitionQualifiedIntervalComponent.range");
500            else if (Configuration.doAutoCreate())
501              this.range = new Range(); // cc
502          return this.range;
503        }
504
505        public boolean hasRange() { 
506          return this.range != null && !this.range.isEmpty();
507        }
508
509        /**
510         * @param value {@link #range} (The value and associated unit of the low bound (inclusive) of the reference range.)
511         */
512        public ObservationDefinitionQualifiedIntervalComponent setRange(Range value) { 
513          this.range = value;
514          return this;
515        }
516
517        /**
518         * @return {@link #type} (Codes to indicate what part of the targeted reference population it applies to. For example, the normal or therapeutic range.)
519         */
520        public CodeableConcept getType() { 
521          if (this.type == null)
522            if (Configuration.errorOnAutoCreate())
523              throw new Error("Attempt to auto-create ObservationDefinitionQualifiedIntervalComponent.type");
524            else if (Configuration.doAutoCreate())
525              this.type = new CodeableConcept(); // cc
526          return this.type;
527        }
528
529        public boolean hasType() { 
530          return this.type != null && !this.type.isEmpty();
531        }
532
533        /**
534         * @param value {@link #type} (Codes to indicate what part of the targeted reference population it applies to. For example, the normal or therapeutic range.)
535         */
536        public ObservationDefinitionQualifiedIntervalComponent setType(CodeableConcept value) { 
537          this.type = value;
538          return this;
539        }
540
541        /**
542         * @return {@link #appliesTo} (Codes to indicate the target population this reference range applies to.)
543         */
544        public List<CodeableConcept> getAppliesTo() { 
545          if (this.appliesTo == null)
546            this.appliesTo = new ArrayList<CodeableConcept>();
547          return this.appliesTo;
548        }
549
550        /**
551         * @return Returns a reference to <code>this</code> for easy method chaining
552         */
553        public ObservationDefinitionQualifiedIntervalComponent setAppliesTo(List<CodeableConcept> theAppliesTo) { 
554          this.appliesTo = theAppliesTo;
555          return this;
556        }
557
558        public boolean hasAppliesTo() { 
559          if (this.appliesTo == null)
560            return false;
561          for (CodeableConcept item : this.appliesTo)
562            if (!item.isEmpty())
563              return true;
564          return false;
565        }
566
567        public CodeableConcept addAppliesTo() { //3
568          CodeableConcept t = new CodeableConcept();
569          if (this.appliesTo == null)
570            this.appliesTo = new ArrayList<CodeableConcept>();
571          this.appliesTo.add(t);
572          return t;
573        }
574
575        public ObservationDefinitionQualifiedIntervalComponent addAppliesTo(CodeableConcept t) { //3
576          if (t == null)
577            return this;
578          if (this.appliesTo == null)
579            this.appliesTo = new ArrayList<CodeableConcept>();
580          this.appliesTo.add(t);
581          return this;
582        }
583
584        /**
585         * @return The first repetition of repeating field {@link #appliesTo}, creating it if it does not already exist
586         */
587        public CodeableConcept getAppliesToFirstRep() { 
588          if (getAppliesTo().isEmpty()) {
589            addAppliesTo();
590          }
591          return getAppliesTo().get(0);
592        }
593
594        /**
595         * @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.)
596         */
597        public Range getAge() { 
598          if (this.age == null)
599            if (Configuration.errorOnAutoCreate())
600              throw new Error("Attempt to auto-create ObservationDefinitionQualifiedIntervalComponent.age");
601            else if (Configuration.doAutoCreate())
602              this.age = new Range(); // cc
603          return this.age;
604        }
605
606        public boolean hasAge() { 
607          return this.age != null && !this.age.isEmpty();
608        }
609
610        /**
611         * @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.)
612         */
613        public ObservationDefinitionQualifiedIntervalComponent setAge(Range value) { 
614          this.age = value;
615          return this;
616        }
617
618        /**
619         * @return {@link #gestationalAge} (The gestational age at which this reference range is applicable, in the context of pregnancy.)
620         */
621        public Range getGestationalAge() { 
622          if (this.gestationalAge == null)
623            if (Configuration.errorOnAutoCreate())
624              throw new Error("Attempt to auto-create ObservationDefinitionQualifiedIntervalComponent.gestationalAge");
625            else if (Configuration.doAutoCreate())
626              this.gestationalAge = new Range(); // cc
627          return this.gestationalAge;
628        }
629
630        public boolean hasGestationalAge() { 
631          return this.gestationalAge != null && !this.gestationalAge.isEmpty();
632        }
633
634        /**
635         * @param value {@link #gestationalAge} (The gestational age at which this reference range is applicable, in the context of pregnancy.)
636         */
637        public ObservationDefinitionQualifiedIntervalComponent setGestationalAge(Range value) { 
638          this.gestationalAge = value;
639          return this;
640        }
641
642        /**
643         * @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
644         */
645        public StringType getConditionElement() { 
646          if (this.condition == null)
647            if (Configuration.errorOnAutoCreate())
648              throw new Error("Attempt to auto-create ObservationDefinitionQualifiedIntervalComponent.condition");
649            else if (Configuration.doAutoCreate())
650              this.condition = new StringType(); // bb
651          return this.condition;
652        }
653
654        public boolean hasConditionElement() { 
655          return this.condition != null && !this.condition.isEmpty();
656        }
657
658        public boolean hasCondition() { 
659          return this.condition != null && !this.condition.isEmpty();
660        }
661
662        /**
663         * @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
664         */
665        public ObservationDefinitionQualifiedIntervalComponent setConditionElement(StringType value) { 
666          this.condition = value;
667          return this;
668        }
669
670        /**
671         * @return Text based condition for which the reference range is valid.
672         */
673        public String getCondition() { 
674          return this.condition == null ? null : this.condition.getValue();
675        }
676
677        /**
678         * @param value Text based condition for which the reference range is valid.
679         */
680        public ObservationDefinitionQualifiedIntervalComponent setCondition(String value) { 
681          if (Utilities.noString(value))
682            this.condition = null;
683          else {
684            if (this.condition == null)
685              this.condition = new StringType();
686            this.condition.setValue(value);
687          }
688          return this;
689        }
690
691        protected void listChildren(List<Property> children) {
692          super.listChildren(children);
693          children.add(new Property("category", "CodeableConcept", "The category or type of interval.", 0, 1, category));
694          children.add(new Property("range", "Range", "The value and associated unit of the low bound (inclusive) of the reference range.", 0, 1, range));
695          children.add(new Property("type", "CodeableConcept", "Codes to indicate what part of the targeted reference population it applies to. For example, the normal or therapeutic range.", 0, 1, type));
696          children.add(new Property("appliesTo", "CodeableConcept", "Codes to indicate the target population this reference range applies to.", 0, java.lang.Integer.MAX_VALUE, appliesTo));
697          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));
698          children.add(new Property("gestationalAge", "Range", "The gestational age at which this reference range is applicable, in the context of pregnancy.", 0, 1, gestationalAge));
699          children.add(new Property("condition", "string", "Text based condition for which the reference range is valid.", 0, 1, condition));
700        }
701
702        @Override
703        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
704          switch (_hash) {
705          case 50511102: /*category*/  return new Property("category", "CodeableConcept", "The category or type of interval.", 0, 1, category);
706          case 108280125: /*range*/  return new Property("range", "Range", "The value and associated unit of the low bound (inclusive) of the reference range.", 0, 1, range);
707          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "Codes to indicate what part of the targeted reference population it applies to. For example, the normal or therapeutic range.", 0, 1, type);
708          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);
709          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);
710          case -241217538: /*gestationalAge*/  return new Property("gestationalAge", "Range", "The gestational age at which this reference range is applicable, in the context of pregnancy.", 0, 1, gestationalAge);
711          case -861311717: /*condition*/  return new Property("condition", "string", "Text based condition for which the reference range is valid.", 0, 1, condition);
712          default: return super.getNamedProperty(_hash, _name, _checkValid);
713          }
714
715        }
716
717      @Override
718      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
719        switch (hash) {
720        case 50511102: /*category*/ return this.category == null ? new Base[0] : new Base[] {this.category}; // CodeableConcept
721        case 108280125: /*range*/ return this.range == null ? new Base[0] : new Base[] {this.range}; // Range
722        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
723        case -2089924569: /*appliesTo*/ return this.appliesTo == null ? new Base[0] : this.appliesTo.toArray(new Base[this.appliesTo.size()]); // CodeableConcept
724        case 96511: /*age*/ return this.age == null ? new Base[0] : new Base[] {this.age}; // Range
725        case -241217538: /*gestationalAge*/ return this.gestationalAge == null ? new Base[0] : new Base[] {this.gestationalAge}; // Range
726        case -861311717: /*condition*/ return this.condition == null ? new Base[0] : new Base[] {this.condition}; // StringType
727        default: return super.getProperty(hash, name, checkValid);
728        }
729
730      }
731
732      @Override
733      public Base setProperty(int hash, String name, Base value) throws FHIRException {
734        switch (hash) {
735        case 50511102: // category
736          this.category = castToCodeableConcept(value); // CodeableConcept
737          return value;
738        case 108280125: // range
739          this.range = castToRange(value); // Range
740          return value;
741        case 3575610: // type
742          this.type = castToCodeableConcept(value); // CodeableConcept
743          return value;
744        case -2089924569: // appliesTo
745          this.getAppliesTo().add(castToCodeableConcept(value)); // CodeableConcept
746          return value;
747        case 96511: // age
748          this.age = castToRange(value); // Range
749          return value;
750        case -241217538: // gestationalAge
751          this.gestationalAge = castToRange(value); // Range
752          return value;
753        case -861311717: // condition
754          this.condition = castToString(value); // StringType
755          return value;
756        default: return super.setProperty(hash, name, value);
757        }
758
759      }
760
761      @Override
762      public Base setProperty(String name, Base value) throws FHIRException {
763        if (name.equals("category")) {
764          this.category = castToCodeableConcept(value); // CodeableConcept
765        } else if (name.equals("range")) {
766          this.range = castToRange(value); // Range
767        } else if (name.equals("type")) {
768          this.type = castToCodeableConcept(value); // CodeableConcept
769        } else if (name.equals("appliesTo")) {
770          this.getAppliesTo().add(castToCodeableConcept(value));
771        } else if (name.equals("age")) {
772          this.age = castToRange(value); // Range
773        } else if (name.equals("gestationalAge")) {
774          this.gestationalAge = castToRange(value); // Range
775        } else if (name.equals("condition")) {
776          this.condition = castToString(value); // StringType
777        } else
778          return super.setProperty(name, value);
779        return value;
780      }
781
782      @Override
783      public Base makeProperty(int hash, String name) throws FHIRException {
784        switch (hash) {
785        case 50511102:  return getCategory(); 
786        case 108280125:  return getRange(); 
787        case 3575610:  return getType(); 
788        case -2089924569:  return addAppliesTo(); 
789        case 96511:  return getAge(); 
790        case -241217538:  return getGestationalAge(); 
791        case -861311717:  return getConditionElement();
792        default: return super.makeProperty(hash, name);
793        }
794
795      }
796
797      @Override
798      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
799        switch (hash) {
800        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
801        case 108280125: /*range*/ return new String[] {"Range"};
802        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
803        case -2089924569: /*appliesTo*/ return new String[] {"CodeableConcept"};
804        case 96511: /*age*/ return new String[] {"Range"};
805        case -241217538: /*gestationalAge*/ return new String[] {"Range"};
806        case -861311717: /*condition*/ return new String[] {"string"};
807        default: return super.getTypesForProperty(hash, name);
808        }
809
810      }
811
812      @Override
813      public Base addChild(String name) throws FHIRException {
814        if (name.equals("category")) {
815          this.category = new CodeableConcept();
816          return this.category;
817        }
818        else if (name.equals("range")) {
819          this.range = new Range();
820          return this.range;
821        }
822        else if (name.equals("type")) {
823          this.type = new CodeableConcept();
824          return this.type;
825        }
826        else if (name.equals("appliesTo")) {
827          return addAppliesTo();
828        }
829        else if (name.equals("age")) {
830          this.age = new Range();
831          return this.age;
832        }
833        else if (name.equals("gestationalAge")) {
834          this.gestationalAge = new Range();
835          return this.gestationalAge;
836        }
837        else if (name.equals("condition")) {
838          throw new FHIRException("Cannot call addChild on a primitive type ObservationDefinition.condition");
839        }
840        else
841          return super.addChild(name);
842      }
843
844      public ObservationDefinitionQualifiedIntervalComponent copy() {
845        ObservationDefinitionQualifiedIntervalComponent dst = new ObservationDefinitionQualifiedIntervalComponent();
846        copyValues(dst);
847        dst.category = category == null ? null : category.copy();
848        dst.range = range == null ? null : range.copy();
849        dst.type = type == null ? null : type.copy();
850        if (appliesTo != null) {
851          dst.appliesTo = new ArrayList<CodeableConcept>();
852          for (CodeableConcept i : appliesTo)
853            dst.appliesTo.add(i.copy());
854        };
855        dst.age = age == null ? null : age.copy();
856        dst.gestationalAge = gestationalAge == null ? null : gestationalAge.copy();
857        dst.condition = condition == null ? null : condition.copy();
858        return dst;
859      }
860
861      @Override
862      public boolean equalsDeep(Base other_) {
863        if (!super.equalsDeep(other_))
864          return false;
865        if (!(other_ instanceof ObservationDefinitionQualifiedIntervalComponent))
866          return false;
867        ObservationDefinitionQualifiedIntervalComponent o = (ObservationDefinitionQualifiedIntervalComponent) other_;
868        return compareDeep(category, o.category, true) && compareDeep(range, o.range, true) && compareDeep(type, o.type, true)
869           && compareDeep(appliesTo, o.appliesTo, true) && compareDeep(age, o.age, true) && compareDeep(gestationalAge, o.gestationalAge, true)
870           && compareDeep(condition, o.condition, true);
871      }
872
873      @Override
874      public boolean equalsShallow(Base other_) {
875        if (!super.equalsShallow(other_))
876          return false;
877        if (!(other_ instanceof ObservationDefinitionQualifiedIntervalComponent))
878          return false;
879        ObservationDefinitionQualifiedIntervalComponent o = (ObservationDefinitionQualifiedIntervalComponent) other_;
880        return compareValues(condition, o.condition, true);
881      }
882
883      public boolean isEmpty() {
884        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(category, range, type, appliesTo
885          , age, gestationalAge, condition);
886      }
887
888  public String fhirType() {
889    return "ObservationDefinition.qualifiedInterval";
890
891  }
892
893  }
894
895    /**
896     * A code that classifies the general type of observation.
897     */
898    @Child(name = "category", type = {Coding.class}, order=0, min=0, max=1, modifier=false, summary=true)
899    @Description(shortDefinition="Category of observation", formalDefinition="A code that classifies the general type of observation." )
900    protected Coding category;
901
902    /**
903     * Describes what will be observed. Sometimes this is called the observation "name".
904     */
905    @Child(name = "code", type = {Coding.class}, order=1, min=1, max=1, modifier=false, summary=true)
906    @Description(shortDefinition="Type of observation (code / type)", formalDefinition="Describes what will be observed. Sometimes this is called the observation \"name\"." )
907    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/observation-codes")
908    protected Coding code;
909
910    /**
911     * Data type allowed for the result of the observation.
912     */
913    @Child(name = "permittedDataType", type = {Coding.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
914    @Description(shortDefinition="Permitted data type for observation value", formalDefinition="Data type allowed for the result of the observation." )
915    protected List<Coding> permittedDataType;
916
917    /**
918     * Multiple results allowed for this kind of observation.
919     */
920    @Child(name = "multipleResultsAllowed", type = {BooleanType.class}, order=3, min=0, max=1, modifier=false, summary=false)
921    @Description(shortDefinition="Multiple results allowed", formalDefinition="Multiple results allowed for this kind of observation." )
922    protected BooleanType multipleResultsAllowed;
923
924    /**
925     * The method or technique used to perform the observation.
926     */
927    @Child(name = "method", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=false)
928    @Description(shortDefinition="The method or technique used to perform the observation", formalDefinition="The method or technique used to perform the observation." )
929    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/observation-methods")
930    protected CodeableConcept method;
931
932    /**
933     * The preferred name to be used when reporting the results of this observation.
934     */
935    @Child(name = "preferredReportName", type = {StringType.class}, order=5, min=0, max=1, modifier=false, summary=false)
936    @Description(shortDefinition="Preferred report name", formalDefinition="The preferred name to be used when reporting the results of this observation." )
937    protected StringType preferredReportName;
938
939    /**
940     * Characteristics for quantitative results of this observation.
941     */
942    @Child(name = "quantitativeDetails", type = {}, order=6, min=0, max=1, modifier=false, summary=false)
943    @Description(shortDefinition="Characteristics of quantitative results", formalDefinition="Characteristics for quantitative results of this observation." )
944    protected ObservationDefinitionQuantitativeDetailsComponent quantitativeDetails;
945
946    /**
947     * Reference range for ordinal and continuous observations.
948     */
949    @Child(name = "qualifiedInterval", type = {}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
950    @Description(shortDefinition="Reference range for observation result", formalDefinition="Reference range for ordinal and continuous observations." )
951    protected List<ObservationDefinitionQualifiedIntervalComponent> qualifiedInterval;
952
953    /**
954     * The set of valid coded results for the observation.
955     */
956    @Child(name = "validCodedValueSet", type = {UriType.class}, order=8, min=0, max=1, modifier=false, summary=false)
957    @Description(shortDefinition="Value set of valid coded values for the observation", formalDefinition="The set of valid coded results for the observation." )
958    protected UriType validCodedValueSet;
959
960    /**
961     * The set of normal coded results for the observation.
962     */
963    @Child(name = "normalCodedValueSet", type = {UriType.class}, order=9, min=0, max=1, modifier=false, summary=false)
964    @Description(shortDefinition="Value set of normal coded values for the observation", formalDefinition="The set of normal coded results for the observation." )
965    protected UriType normalCodedValueSet;
966
967    /**
968     * The set of abnormal coded results for the observation.
969     */
970    @Child(name = "abnormalCodedValueSet", type = {UriType.class}, order=10, min=0, max=1, modifier=false, summary=false)
971    @Description(shortDefinition="Value set of abnormal coded values for the observation", formalDefinition="The set of abnormal coded results for the observation." )
972    protected UriType abnormalCodedValueSet;
973
974    /**
975     * The set of critical coded results for the observation.
976     */
977    @Child(name = "criticalCodedValueSet", type = {UriType.class}, order=11, min=0, max=1, modifier=false, summary=false)
978    @Description(shortDefinition="Value set of critical coded values for the observation", formalDefinition="The set of critical coded results for the observation." )
979    protected UriType criticalCodedValueSet;
980
981    private static final long serialVersionUID = 1678075048L;
982
983  /**
984   * Constructor
985   */
986    public ObservationDefinition() {
987      super();
988    }
989
990  /**
991   * Constructor
992   */
993    public ObservationDefinition(Coding code) {
994      super();
995      this.code = code;
996    }
997
998    /**
999     * @return {@link #category} (A code that classifies the general type of observation.)
1000     */
1001    public Coding getCategory() { 
1002      if (this.category == null)
1003        if (Configuration.errorOnAutoCreate())
1004          throw new Error("Attempt to auto-create ObservationDefinition.category");
1005        else if (Configuration.doAutoCreate())
1006          this.category = new Coding(); // cc
1007      return this.category;
1008    }
1009
1010    public boolean hasCategory() { 
1011      return this.category != null && !this.category.isEmpty();
1012    }
1013
1014    /**
1015     * @param value {@link #category} (A code that classifies the general type of observation.)
1016     */
1017    public ObservationDefinition setCategory(Coding value) { 
1018      this.category = value;
1019      return this;
1020    }
1021
1022    /**
1023     * @return {@link #code} (Describes what will be observed. Sometimes this is called the observation "name".)
1024     */
1025    public Coding getCode() { 
1026      if (this.code == null)
1027        if (Configuration.errorOnAutoCreate())
1028          throw new Error("Attempt to auto-create ObservationDefinition.code");
1029        else if (Configuration.doAutoCreate())
1030          this.code = new Coding(); // cc
1031      return this.code;
1032    }
1033
1034    public boolean hasCode() { 
1035      return this.code != null && !this.code.isEmpty();
1036    }
1037
1038    /**
1039     * @param value {@link #code} (Describes what will be observed. Sometimes this is called the observation "name".)
1040     */
1041    public ObservationDefinition setCode(Coding value) { 
1042      this.code = value;
1043      return this;
1044    }
1045
1046    /**
1047     * @return {@link #permittedDataType} (Data type allowed for the result of the observation.)
1048     */
1049    public List<Coding> getPermittedDataType() { 
1050      if (this.permittedDataType == null)
1051        this.permittedDataType = new ArrayList<Coding>();
1052      return this.permittedDataType;
1053    }
1054
1055    /**
1056     * @return Returns a reference to <code>this</code> for easy method chaining
1057     */
1058    public ObservationDefinition setPermittedDataType(List<Coding> thePermittedDataType) { 
1059      this.permittedDataType = thePermittedDataType;
1060      return this;
1061    }
1062
1063    public boolean hasPermittedDataType() { 
1064      if (this.permittedDataType == null)
1065        return false;
1066      for (Coding item : this.permittedDataType)
1067        if (!item.isEmpty())
1068          return true;
1069      return false;
1070    }
1071
1072    public Coding addPermittedDataType() { //3
1073      Coding t = new Coding();
1074      if (this.permittedDataType == null)
1075        this.permittedDataType = new ArrayList<Coding>();
1076      this.permittedDataType.add(t);
1077      return t;
1078    }
1079
1080    public ObservationDefinition addPermittedDataType(Coding t) { //3
1081      if (t == null)
1082        return this;
1083      if (this.permittedDataType == null)
1084        this.permittedDataType = new ArrayList<Coding>();
1085      this.permittedDataType.add(t);
1086      return this;
1087    }
1088
1089    /**
1090     * @return The first repetition of repeating field {@link #permittedDataType}, creating it if it does not already exist
1091     */
1092    public Coding getPermittedDataTypeFirstRep() { 
1093      if (getPermittedDataType().isEmpty()) {
1094        addPermittedDataType();
1095      }
1096      return getPermittedDataType().get(0);
1097    }
1098
1099    /**
1100     * @return {@link #multipleResultsAllowed} (Multiple results allowed for this kind of observation.). This is the underlying object with id, value and extensions. The accessor "getMultipleResultsAllowed" gives direct access to the value
1101     */
1102    public BooleanType getMultipleResultsAllowedElement() { 
1103      if (this.multipleResultsAllowed == null)
1104        if (Configuration.errorOnAutoCreate())
1105          throw new Error("Attempt to auto-create ObservationDefinition.multipleResultsAllowed");
1106        else if (Configuration.doAutoCreate())
1107          this.multipleResultsAllowed = new BooleanType(); // bb
1108      return this.multipleResultsAllowed;
1109    }
1110
1111    public boolean hasMultipleResultsAllowedElement() { 
1112      return this.multipleResultsAllowed != null && !this.multipleResultsAllowed.isEmpty();
1113    }
1114
1115    public boolean hasMultipleResultsAllowed() { 
1116      return this.multipleResultsAllowed != null && !this.multipleResultsAllowed.isEmpty();
1117    }
1118
1119    /**
1120     * @param value {@link #multipleResultsAllowed} (Multiple results allowed for this kind of observation.). This is the underlying object with id, value and extensions. The accessor "getMultipleResultsAllowed" gives direct access to the value
1121     */
1122    public ObservationDefinition setMultipleResultsAllowedElement(BooleanType value) { 
1123      this.multipleResultsAllowed = value;
1124      return this;
1125    }
1126
1127    /**
1128     * @return Multiple results allowed for this kind of observation.
1129     */
1130    public boolean getMultipleResultsAllowed() { 
1131      return this.multipleResultsAllowed == null || this.multipleResultsAllowed.isEmpty() ? false : this.multipleResultsAllowed.getValue();
1132    }
1133
1134    /**
1135     * @param value Multiple results allowed for this kind of observation.
1136     */
1137    public ObservationDefinition setMultipleResultsAllowed(boolean value) { 
1138        if (this.multipleResultsAllowed == null)
1139          this.multipleResultsAllowed = new BooleanType();
1140        this.multipleResultsAllowed.setValue(value);
1141      return this;
1142    }
1143
1144    /**
1145     * @return {@link #method} (The method or technique used to perform the observation.)
1146     */
1147    public CodeableConcept getMethod() { 
1148      if (this.method == null)
1149        if (Configuration.errorOnAutoCreate())
1150          throw new Error("Attempt to auto-create ObservationDefinition.method");
1151        else if (Configuration.doAutoCreate())
1152          this.method = new CodeableConcept(); // cc
1153      return this.method;
1154    }
1155
1156    public boolean hasMethod() { 
1157      return this.method != null && !this.method.isEmpty();
1158    }
1159
1160    /**
1161     * @param value {@link #method} (The method or technique used to perform the observation.)
1162     */
1163    public ObservationDefinition setMethod(CodeableConcept value) { 
1164      this.method = value;
1165      return this;
1166    }
1167
1168    /**
1169     * @return {@link #preferredReportName} (The preferred name to be used when reporting the results of this observation.). This is the underlying object with id, value and extensions. The accessor "getPreferredReportName" gives direct access to the value
1170     */
1171    public StringType getPreferredReportNameElement() { 
1172      if (this.preferredReportName == null)
1173        if (Configuration.errorOnAutoCreate())
1174          throw new Error("Attempt to auto-create ObservationDefinition.preferredReportName");
1175        else if (Configuration.doAutoCreate())
1176          this.preferredReportName = new StringType(); // bb
1177      return this.preferredReportName;
1178    }
1179
1180    public boolean hasPreferredReportNameElement() { 
1181      return this.preferredReportName != null && !this.preferredReportName.isEmpty();
1182    }
1183
1184    public boolean hasPreferredReportName() { 
1185      return this.preferredReportName != null && !this.preferredReportName.isEmpty();
1186    }
1187
1188    /**
1189     * @param value {@link #preferredReportName} (The preferred name to be used when reporting the results of this observation.). This is the underlying object with id, value and extensions. The accessor "getPreferredReportName" gives direct access to the value
1190     */
1191    public ObservationDefinition setPreferredReportNameElement(StringType value) { 
1192      this.preferredReportName = value;
1193      return this;
1194    }
1195
1196    /**
1197     * @return The preferred name to be used when reporting the results of this observation.
1198     */
1199    public String getPreferredReportName() { 
1200      return this.preferredReportName == null ? null : this.preferredReportName.getValue();
1201    }
1202
1203    /**
1204     * @param value The preferred name to be used when reporting the results of this observation.
1205     */
1206    public ObservationDefinition setPreferredReportName(String value) { 
1207      if (Utilities.noString(value))
1208        this.preferredReportName = null;
1209      else {
1210        if (this.preferredReportName == null)
1211          this.preferredReportName = new StringType();
1212        this.preferredReportName.setValue(value);
1213      }
1214      return this;
1215    }
1216
1217    /**
1218     * @return {@link #quantitativeDetails} (Characteristics for quantitative results of this observation.)
1219     */
1220    public ObservationDefinitionQuantitativeDetailsComponent getQuantitativeDetails() { 
1221      if (this.quantitativeDetails == null)
1222        if (Configuration.errorOnAutoCreate())
1223          throw new Error("Attempt to auto-create ObservationDefinition.quantitativeDetails");
1224        else if (Configuration.doAutoCreate())
1225          this.quantitativeDetails = new ObservationDefinitionQuantitativeDetailsComponent(); // cc
1226      return this.quantitativeDetails;
1227    }
1228
1229    public boolean hasQuantitativeDetails() { 
1230      return this.quantitativeDetails != null && !this.quantitativeDetails.isEmpty();
1231    }
1232
1233    /**
1234     * @param value {@link #quantitativeDetails} (Characteristics for quantitative results of this observation.)
1235     */
1236    public ObservationDefinition setQuantitativeDetails(ObservationDefinitionQuantitativeDetailsComponent value) { 
1237      this.quantitativeDetails = value;
1238      return this;
1239    }
1240
1241    /**
1242     * @return {@link #qualifiedInterval} (Reference range for ordinal and continuous observations.)
1243     */
1244    public List<ObservationDefinitionQualifiedIntervalComponent> getQualifiedInterval() { 
1245      if (this.qualifiedInterval == null)
1246        this.qualifiedInterval = new ArrayList<ObservationDefinitionQualifiedIntervalComponent>();
1247      return this.qualifiedInterval;
1248    }
1249
1250    /**
1251     * @return Returns a reference to <code>this</code> for easy method chaining
1252     */
1253    public ObservationDefinition setQualifiedInterval(List<ObservationDefinitionQualifiedIntervalComponent> theQualifiedInterval) { 
1254      this.qualifiedInterval = theQualifiedInterval;
1255      return this;
1256    }
1257
1258    public boolean hasQualifiedInterval() { 
1259      if (this.qualifiedInterval == null)
1260        return false;
1261      for (ObservationDefinitionQualifiedIntervalComponent item : this.qualifiedInterval)
1262        if (!item.isEmpty())
1263          return true;
1264      return false;
1265    }
1266
1267    public ObservationDefinitionQualifiedIntervalComponent addQualifiedInterval() { //3
1268      ObservationDefinitionQualifiedIntervalComponent t = new ObservationDefinitionQualifiedIntervalComponent();
1269      if (this.qualifiedInterval == null)
1270        this.qualifiedInterval = new ArrayList<ObservationDefinitionQualifiedIntervalComponent>();
1271      this.qualifiedInterval.add(t);
1272      return t;
1273    }
1274
1275    public ObservationDefinition addQualifiedInterval(ObservationDefinitionQualifiedIntervalComponent t) { //3
1276      if (t == null)
1277        return this;
1278      if (this.qualifiedInterval == null)
1279        this.qualifiedInterval = new ArrayList<ObservationDefinitionQualifiedIntervalComponent>();
1280      this.qualifiedInterval.add(t);
1281      return this;
1282    }
1283
1284    /**
1285     * @return The first repetition of repeating field {@link #qualifiedInterval}, creating it if it does not already exist
1286     */
1287    public ObservationDefinitionQualifiedIntervalComponent getQualifiedIntervalFirstRep() { 
1288      if (getQualifiedInterval().isEmpty()) {
1289        addQualifiedInterval();
1290      }
1291      return getQualifiedInterval().get(0);
1292    }
1293
1294    /**
1295     * @return {@link #validCodedValueSet} (The set of valid coded results for the observation.). This is the underlying object with id, value and extensions. The accessor "getValidCodedValueSet" gives direct access to the value
1296     */
1297    public UriType getValidCodedValueSetElement() { 
1298      if (this.validCodedValueSet == null)
1299        if (Configuration.errorOnAutoCreate())
1300          throw new Error("Attempt to auto-create ObservationDefinition.validCodedValueSet");
1301        else if (Configuration.doAutoCreate())
1302          this.validCodedValueSet = new UriType(); // bb
1303      return this.validCodedValueSet;
1304    }
1305
1306    public boolean hasValidCodedValueSetElement() { 
1307      return this.validCodedValueSet != null && !this.validCodedValueSet.isEmpty();
1308    }
1309
1310    public boolean hasValidCodedValueSet() { 
1311      return this.validCodedValueSet != null && !this.validCodedValueSet.isEmpty();
1312    }
1313
1314    /**
1315     * @param value {@link #validCodedValueSet} (The set of valid coded results for the observation.). This is the underlying object with id, value and extensions. The accessor "getValidCodedValueSet" gives direct access to the value
1316     */
1317    public ObservationDefinition setValidCodedValueSetElement(UriType value) { 
1318      this.validCodedValueSet = value;
1319      return this;
1320    }
1321
1322    /**
1323     * @return The set of valid coded results for the observation.
1324     */
1325    public String getValidCodedValueSet() { 
1326      return this.validCodedValueSet == null ? null : this.validCodedValueSet.getValue();
1327    }
1328
1329    /**
1330     * @param value The set of valid coded results for the observation.
1331     */
1332    public ObservationDefinition setValidCodedValueSet(String value) { 
1333      if (Utilities.noString(value))
1334        this.validCodedValueSet = null;
1335      else {
1336        if (this.validCodedValueSet == null)
1337          this.validCodedValueSet = new UriType();
1338        this.validCodedValueSet.setValue(value);
1339      }
1340      return this;
1341    }
1342
1343    /**
1344     * @return {@link #normalCodedValueSet} (The set of normal coded results for the observation.). This is the underlying object with id, value and extensions. The accessor "getNormalCodedValueSet" gives direct access to the value
1345     */
1346    public UriType getNormalCodedValueSetElement() { 
1347      if (this.normalCodedValueSet == null)
1348        if (Configuration.errorOnAutoCreate())
1349          throw new Error("Attempt to auto-create ObservationDefinition.normalCodedValueSet");
1350        else if (Configuration.doAutoCreate())
1351          this.normalCodedValueSet = new UriType(); // bb
1352      return this.normalCodedValueSet;
1353    }
1354
1355    public boolean hasNormalCodedValueSetElement() { 
1356      return this.normalCodedValueSet != null && !this.normalCodedValueSet.isEmpty();
1357    }
1358
1359    public boolean hasNormalCodedValueSet() { 
1360      return this.normalCodedValueSet != null && !this.normalCodedValueSet.isEmpty();
1361    }
1362
1363    /**
1364     * @param value {@link #normalCodedValueSet} (The set of normal coded results for the observation.). This is the underlying object with id, value and extensions. The accessor "getNormalCodedValueSet" gives direct access to the value
1365     */
1366    public ObservationDefinition setNormalCodedValueSetElement(UriType value) { 
1367      this.normalCodedValueSet = value;
1368      return this;
1369    }
1370
1371    /**
1372     * @return The set of normal coded results for the observation.
1373     */
1374    public String getNormalCodedValueSet() { 
1375      return this.normalCodedValueSet == null ? null : this.normalCodedValueSet.getValue();
1376    }
1377
1378    /**
1379     * @param value The set of normal coded results for the observation.
1380     */
1381    public ObservationDefinition setNormalCodedValueSet(String value) { 
1382      if (Utilities.noString(value))
1383        this.normalCodedValueSet = null;
1384      else {
1385        if (this.normalCodedValueSet == null)
1386          this.normalCodedValueSet = new UriType();
1387        this.normalCodedValueSet.setValue(value);
1388      }
1389      return this;
1390    }
1391
1392    /**
1393     * @return {@link #abnormalCodedValueSet} (The set of abnormal coded results for the observation.). This is the underlying object with id, value and extensions. The accessor "getAbnormalCodedValueSet" gives direct access to the value
1394     */
1395    public UriType getAbnormalCodedValueSetElement() { 
1396      if (this.abnormalCodedValueSet == null)
1397        if (Configuration.errorOnAutoCreate())
1398          throw new Error("Attempt to auto-create ObservationDefinition.abnormalCodedValueSet");
1399        else if (Configuration.doAutoCreate())
1400          this.abnormalCodedValueSet = new UriType(); // bb
1401      return this.abnormalCodedValueSet;
1402    }
1403
1404    public boolean hasAbnormalCodedValueSetElement() { 
1405      return this.abnormalCodedValueSet != null && !this.abnormalCodedValueSet.isEmpty();
1406    }
1407
1408    public boolean hasAbnormalCodedValueSet() { 
1409      return this.abnormalCodedValueSet != null && !this.abnormalCodedValueSet.isEmpty();
1410    }
1411
1412    /**
1413     * @param value {@link #abnormalCodedValueSet} (The set of abnormal coded results for the observation.). This is the underlying object with id, value and extensions. The accessor "getAbnormalCodedValueSet" gives direct access to the value
1414     */
1415    public ObservationDefinition setAbnormalCodedValueSetElement(UriType value) { 
1416      this.abnormalCodedValueSet = value;
1417      return this;
1418    }
1419
1420    /**
1421     * @return The set of abnormal coded results for the observation.
1422     */
1423    public String getAbnormalCodedValueSet() { 
1424      return this.abnormalCodedValueSet == null ? null : this.abnormalCodedValueSet.getValue();
1425    }
1426
1427    /**
1428     * @param value The set of abnormal coded results for the observation.
1429     */
1430    public ObservationDefinition setAbnormalCodedValueSet(String value) { 
1431      if (Utilities.noString(value))
1432        this.abnormalCodedValueSet = null;
1433      else {
1434        if (this.abnormalCodedValueSet == null)
1435          this.abnormalCodedValueSet = new UriType();
1436        this.abnormalCodedValueSet.setValue(value);
1437      }
1438      return this;
1439    }
1440
1441    /**
1442     * @return {@link #criticalCodedValueSet} (The set of critical coded results for the observation.). This is the underlying object with id, value and extensions. The accessor "getCriticalCodedValueSet" gives direct access to the value
1443     */
1444    public UriType getCriticalCodedValueSetElement() { 
1445      if (this.criticalCodedValueSet == null)
1446        if (Configuration.errorOnAutoCreate())
1447          throw new Error("Attempt to auto-create ObservationDefinition.criticalCodedValueSet");
1448        else if (Configuration.doAutoCreate())
1449          this.criticalCodedValueSet = new UriType(); // bb
1450      return this.criticalCodedValueSet;
1451    }
1452
1453    public boolean hasCriticalCodedValueSetElement() { 
1454      return this.criticalCodedValueSet != null && !this.criticalCodedValueSet.isEmpty();
1455    }
1456
1457    public boolean hasCriticalCodedValueSet() { 
1458      return this.criticalCodedValueSet != null && !this.criticalCodedValueSet.isEmpty();
1459    }
1460
1461    /**
1462     * @param value {@link #criticalCodedValueSet} (The set of critical coded results for the observation.). This is the underlying object with id, value and extensions. The accessor "getCriticalCodedValueSet" gives direct access to the value
1463     */
1464    public ObservationDefinition setCriticalCodedValueSetElement(UriType value) { 
1465      this.criticalCodedValueSet = value;
1466      return this;
1467    }
1468
1469    /**
1470     * @return The set of critical coded results for the observation.
1471     */
1472    public String getCriticalCodedValueSet() { 
1473      return this.criticalCodedValueSet == null ? null : this.criticalCodedValueSet.getValue();
1474    }
1475
1476    /**
1477     * @param value The set of critical coded results for the observation.
1478     */
1479    public ObservationDefinition setCriticalCodedValueSet(String value) { 
1480      if (Utilities.noString(value))
1481        this.criticalCodedValueSet = null;
1482      else {
1483        if (this.criticalCodedValueSet == null)
1484          this.criticalCodedValueSet = new UriType();
1485        this.criticalCodedValueSet.setValue(value);
1486      }
1487      return this;
1488    }
1489
1490      protected void listChildren(List<Property> children) {
1491        super.listChildren(children);
1492        children.add(new Property("category", "Coding", "A code that classifies the general type of observation.", 0, 1, category));
1493        children.add(new Property("code", "Coding", "Describes what will be observed. Sometimes this is called the observation \"name\".", 0, 1, code));
1494        children.add(new Property("permittedDataType", "Coding", "Data type allowed for the result of the observation.", 0, java.lang.Integer.MAX_VALUE, permittedDataType));
1495        children.add(new Property("multipleResultsAllowed", "boolean", "Multiple results allowed for this kind of observation.", 0, 1, multipleResultsAllowed));
1496        children.add(new Property("method", "CodeableConcept", "The method or technique used to perform the observation.", 0, 1, method));
1497        children.add(new Property("preferredReportName", "string", "The preferred name to be used when reporting the results of this observation.", 0, 1, preferredReportName));
1498        children.add(new Property("quantitativeDetails", "", "Characteristics for quantitative results of this observation.", 0, 1, quantitativeDetails));
1499        children.add(new Property("qualifiedInterval", "", "Reference range for ordinal and continuous observations.", 0, java.lang.Integer.MAX_VALUE, qualifiedInterval));
1500        children.add(new Property("validCodedValueSet", "uri", "The set of valid coded results for the observation.", 0, 1, validCodedValueSet));
1501        children.add(new Property("normalCodedValueSet", "uri", "The set of normal coded results for the observation.", 0, 1, normalCodedValueSet));
1502        children.add(new Property("abnormalCodedValueSet", "uri", "The set of abnormal coded results for the observation.", 0, 1, abnormalCodedValueSet));
1503        children.add(new Property("criticalCodedValueSet", "uri", "The set of critical coded results for the observation.", 0, 1, criticalCodedValueSet));
1504      }
1505
1506      @Override
1507      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1508        switch (_hash) {
1509        case 50511102: /*category*/  return new Property("category", "Coding", "A code that classifies the general type of observation.", 0, 1, category);
1510        case 3059181: /*code*/  return new Property("code", "Coding", "Describes what will be observed. Sometimes this is called the observation \"name\".", 0, 1, code);
1511        case -99492804: /*permittedDataType*/  return new Property("permittedDataType", "Coding", "Data type allowed for the result of the observation.", 0, java.lang.Integer.MAX_VALUE, permittedDataType);
1512        case -2102414590: /*multipleResultsAllowed*/  return new Property("multipleResultsAllowed", "boolean", "Multiple results allowed for this kind of observation.", 0, 1, multipleResultsAllowed);
1513        case -1077554975: /*method*/  return new Property("method", "CodeableConcept", "The method or technique used to perform the observation.", 0, 1, method);
1514        case -1851030208: /*preferredReportName*/  return new Property("preferredReportName", "string", "The preferred name to be used when reporting the results of this observation.", 0, 1, preferredReportName);
1515        case 842150763: /*quantitativeDetails*/  return new Property("quantitativeDetails", "", "Characteristics for quantitative results of this observation.", 0, 1, quantitativeDetails);
1516        case 1882971521: /*qualifiedInterval*/  return new Property("qualifiedInterval", "", "Reference range for ordinal and continuous observations.", 0, java.lang.Integer.MAX_VALUE, qualifiedInterval);
1517        case 1374640076: /*validCodedValueSet*/  return new Property("validCodedValueSet", "uri", "The set of valid coded results for the observation.", 0, 1, validCodedValueSet);
1518        case -837500735: /*normalCodedValueSet*/  return new Property("normalCodedValueSet", "uri", "The set of normal coded results for the observation.", 0, 1, normalCodedValueSet);
1519        case 1073600256: /*abnormalCodedValueSet*/  return new Property("abnormalCodedValueSet", "uri", "The set of abnormal coded results for the observation.", 0, 1, abnormalCodedValueSet);
1520        case 2568457: /*criticalCodedValueSet*/  return new Property("criticalCodedValueSet", "uri", "The set of critical coded results for the observation.", 0, 1, criticalCodedValueSet);
1521        default: return super.getNamedProperty(_hash, _name, _checkValid);
1522        }
1523
1524      }
1525
1526      @Override
1527      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1528        switch (hash) {
1529        case 50511102: /*category*/ return this.category == null ? new Base[0] : new Base[] {this.category}; // Coding
1530        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // Coding
1531        case -99492804: /*permittedDataType*/ return this.permittedDataType == null ? new Base[0] : this.permittedDataType.toArray(new Base[this.permittedDataType.size()]); // Coding
1532        case -2102414590: /*multipleResultsAllowed*/ return this.multipleResultsAllowed == null ? new Base[0] : new Base[] {this.multipleResultsAllowed}; // BooleanType
1533        case -1077554975: /*method*/ return this.method == null ? new Base[0] : new Base[] {this.method}; // CodeableConcept
1534        case -1851030208: /*preferredReportName*/ return this.preferredReportName == null ? new Base[0] : new Base[] {this.preferredReportName}; // StringType
1535        case 842150763: /*quantitativeDetails*/ return this.quantitativeDetails == null ? new Base[0] : new Base[] {this.quantitativeDetails}; // ObservationDefinitionQuantitativeDetailsComponent
1536        case 1882971521: /*qualifiedInterval*/ return this.qualifiedInterval == null ? new Base[0] : this.qualifiedInterval.toArray(new Base[this.qualifiedInterval.size()]); // ObservationDefinitionQualifiedIntervalComponent
1537        case 1374640076: /*validCodedValueSet*/ return this.validCodedValueSet == null ? new Base[0] : new Base[] {this.validCodedValueSet}; // UriType
1538        case -837500735: /*normalCodedValueSet*/ return this.normalCodedValueSet == null ? new Base[0] : new Base[] {this.normalCodedValueSet}; // UriType
1539        case 1073600256: /*abnormalCodedValueSet*/ return this.abnormalCodedValueSet == null ? new Base[0] : new Base[] {this.abnormalCodedValueSet}; // UriType
1540        case 2568457: /*criticalCodedValueSet*/ return this.criticalCodedValueSet == null ? new Base[0] : new Base[] {this.criticalCodedValueSet}; // UriType
1541        default: return super.getProperty(hash, name, checkValid);
1542        }
1543
1544      }
1545
1546      @Override
1547      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1548        switch (hash) {
1549        case 50511102: // category
1550          this.category = castToCoding(value); // Coding
1551          return value;
1552        case 3059181: // code
1553          this.code = castToCoding(value); // Coding
1554          return value;
1555        case -99492804: // permittedDataType
1556          this.getPermittedDataType().add(castToCoding(value)); // Coding
1557          return value;
1558        case -2102414590: // multipleResultsAllowed
1559          this.multipleResultsAllowed = castToBoolean(value); // BooleanType
1560          return value;
1561        case -1077554975: // method
1562          this.method = castToCodeableConcept(value); // CodeableConcept
1563          return value;
1564        case -1851030208: // preferredReportName
1565          this.preferredReportName = castToString(value); // StringType
1566          return value;
1567        case 842150763: // quantitativeDetails
1568          this.quantitativeDetails = (ObservationDefinitionQuantitativeDetailsComponent) value; // ObservationDefinitionQuantitativeDetailsComponent
1569          return value;
1570        case 1882971521: // qualifiedInterval
1571          this.getQualifiedInterval().add((ObservationDefinitionQualifiedIntervalComponent) value); // ObservationDefinitionQualifiedIntervalComponent
1572          return value;
1573        case 1374640076: // validCodedValueSet
1574          this.validCodedValueSet = castToUri(value); // UriType
1575          return value;
1576        case -837500735: // normalCodedValueSet
1577          this.normalCodedValueSet = castToUri(value); // UriType
1578          return value;
1579        case 1073600256: // abnormalCodedValueSet
1580          this.abnormalCodedValueSet = castToUri(value); // UriType
1581          return value;
1582        case 2568457: // criticalCodedValueSet
1583          this.criticalCodedValueSet = castToUri(value); // UriType
1584          return value;
1585        default: return super.setProperty(hash, name, value);
1586        }
1587
1588      }
1589
1590      @Override
1591      public Base setProperty(String name, Base value) throws FHIRException {
1592        if (name.equals("category")) {
1593          this.category = castToCoding(value); // Coding
1594        } else if (name.equals("code")) {
1595          this.code = castToCoding(value); // Coding
1596        } else if (name.equals("permittedDataType")) {
1597          this.getPermittedDataType().add(castToCoding(value));
1598        } else if (name.equals("multipleResultsAllowed")) {
1599          this.multipleResultsAllowed = castToBoolean(value); // BooleanType
1600        } else if (name.equals("method")) {
1601          this.method = castToCodeableConcept(value); // CodeableConcept
1602        } else if (name.equals("preferredReportName")) {
1603          this.preferredReportName = castToString(value); // StringType
1604        } else if (name.equals("quantitativeDetails")) {
1605          this.quantitativeDetails = (ObservationDefinitionQuantitativeDetailsComponent) value; // ObservationDefinitionQuantitativeDetailsComponent
1606        } else if (name.equals("qualifiedInterval")) {
1607          this.getQualifiedInterval().add((ObservationDefinitionQualifiedIntervalComponent) value);
1608        } else if (name.equals("validCodedValueSet")) {
1609          this.validCodedValueSet = castToUri(value); // UriType
1610        } else if (name.equals("normalCodedValueSet")) {
1611          this.normalCodedValueSet = castToUri(value); // UriType
1612        } else if (name.equals("abnormalCodedValueSet")) {
1613          this.abnormalCodedValueSet = castToUri(value); // UriType
1614        } else if (name.equals("criticalCodedValueSet")) {
1615          this.criticalCodedValueSet = castToUri(value); // UriType
1616        } else
1617          return super.setProperty(name, value);
1618        return value;
1619      }
1620
1621      @Override
1622      public Base makeProperty(int hash, String name) throws FHIRException {
1623        switch (hash) {
1624        case 50511102:  return getCategory(); 
1625        case 3059181:  return getCode(); 
1626        case -99492804:  return addPermittedDataType(); 
1627        case -2102414590:  return getMultipleResultsAllowedElement();
1628        case -1077554975:  return getMethod(); 
1629        case -1851030208:  return getPreferredReportNameElement();
1630        case 842150763:  return getQuantitativeDetails(); 
1631        case 1882971521:  return addQualifiedInterval(); 
1632        case 1374640076:  return getValidCodedValueSetElement();
1633        case -837500735:  return getNormalCodedValueSetElement();
1634        case 1073600256:  return getAbnormalCodedValueSetElement();
1635        case 2568457:  return getCriticalCodedValueSetElement();
1636        default: return super.makeProperty(hash, name);
1637        }
1638
1639      }
1640
1641      @Override
1642      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1643        switch (hash) {
1644        case 50511102: /*category*/ return new String[] {"Coding"};
1645        case 3059181: /*code*/ return new String[] {"Coding"};
1646        case -99492804: /*permittedDataType*/ return new String[] {"Coding"};
1647        case -2102414590: /*multipleResultsAllowed*/ return new String[] {"boolean"};
1648        case -1077554975: /*method*/ return new String[] {"CodeableConcept"};
1649        case -1851030208: /*preferredReportName*/ return new String[] {"string"};
1650        case 842150763: /*quantitativeDetails*/ return new String[] {};
1651        case 1882971521: /*qualifiedInterval*/ return new String[] {};
1652        case 1374640076: /*validCodedValueSet*/ return new String[] {"uri"};
1653        case -837500735: /*normalCodedValueSet*/ return new String[] {"uri"};
1654        case 1073600256: /*abnormalCodedValueSet*/ return new String[] {"uri"};
1655        case 2568457: /*criticalCodedValueSet*/ return new String[] {"uri"};
1656        default: return super.getTypesForProperty(hash, name);
1657        }
1658
1659      }
1660
1661      @Override
1662      public Base addChild(String name) throws FHIRException {
1663        if (name.equals("category")) {
1664          this.category = new Coding();
1665          return this.category;
1666        }
1667        else if (name.equals("code")) {
1668          this.code = new Coding();
1669          return this.code;
1670        }
1671        else if (name.equals("permittedDataType")) {
1672          return addPermittedDataType();
1673        }
1674        else if (name.equals("multipleResultsAllowed")) {
1675          throw new FHIRException("Cannot call addChild on a primitive type ObservationDefinition.multipleResultsAllowed");
1676        }
1677        else if (name.equals("method")) {
1678          this.method = new CodeableConcept();
1679          return this.method;
1680        }
1681        else if (name.equals("preferredReportName")) {
1682          throw new FHIRException("Cannot call addChild on a primitive type ObservationDefinition.preferredReportName");
1683        }
1684        else if (name.equals("quantitativeDetails")) {
1685          this.quantitativeDetails = new ObservationDefinitionQuantitativeDetailsComponent();
1686          return this.quantitativeDetails;
1687        }
1688        else if (name.equals("qualifiedInterval")) {
1689          return addQualifiedInterval();
1690        }
1691        else if (name.equals("validCodedValueSet")) {
1692          throw new FHIRException("Cannot call addChild on a primitive type ObservationDefinition.validCodedValueSet");
1693        }
1694        else if (name.equals("normalCodedValueSet")) {
1695          throw new FHIRException("Cannot call addChild on a primitive type ObservationDefinition.normalCodedValueSet");
1696        }
1697        else if (name.equals("abnormalCodedValueSet")) {
1698          throw new FHIRException("Cannot call addChild on a primitive type ObservationDefinition.abnormalCodedValueSet");
1699        }
1700        else if (name.equals("criticalCodedValueSet")) {
1701          throw new FHIRException("Cannot call addChild on a primitive type ObservationDefinition.criticalCodedValueSet");
1702        }
1703        else
1704          return super.addChild(name);
1705      }
1706
1707  public String fhirType() {
1708    return "ObservationDefinition";
1709
1710  }
1711
1712      public ObservationDefinition copy() {
1713        ObservationDefinition dst = new ObservationDefinition();
1714        copyValues(dst);
1715        dst.category = category == null ? null : category.copy();
1716        dst.code = code == null ? null : code.copy();
1717        if (permittedDataType != null) {
1718          dst.permittedDataType = new ArrayList<Coding>();
1719          for (Coding i : permittedDataType)
1720            dst.permittedDataType.add(i.copy());
1721        };
1722        dst.multipleResultsAllowed = multipleResultsAllowed == null ? null : multipleResultsAllowed.copy();
1723        dst.method = method == null ? null : method.copy();
1724        dst.preferredReportName = preferredReportName == null ? null : preferredReportName.copy();
1725        dst.quantitativeDetails = quantitativeDetails == null ? null : quantitativeDetails.copy();
1726        if (qualifiedInterval != null) {
1727          dst.qualifiedInterval = new ArrayList<ObservationDefinitionQualifiedIntervalComponent>();
1728          for (ObservationDefinitionQualifiedIntervalComponent i : qualifiedInterval)
1729            dst.qualifiedInterval.add(i.copy());
1730        };
1731        dst.validCodedValueSet = validCodedValueSet == null ? null : validCodedValueSet.copy();
1732        dst.normalCodedValueSet = normalCodedValueSet == null ? null : normalCodedValueSet.copy();
1733        dst.abnormalCodedValueSet = abnormalCodedValueSet == null ? null : abnormalCodedValueSet.copy();
1734        dst.criticalCodedValueSet = criticalCodedValueSet == null ? null : criticalCodedValueSet.copy();
1735        return dst;
1736      }
1737
1738      protected ObservationDefinition typedCopy() {
1739        return copy();
1740      }
1741
1742      @Override
1743      public boolean equalsDeep(Base other_) {
1744        if (!super.equalsDeep(other_))
1745          return false;
1746        if (!(other_ instanceof ObservationDefinition))
1747          return false;
1748        ObservationDefinition o = (ObservationDefinition) other_;
1749        return compareDeep(category, o.category, true) && compareDeep(code, o.code, true) && compareDeep(permittedDataType, o.permittedDataType, true)
1750           && compareDeep(multipleResultsAllowed, o.multipleResultsAllowed, true) && compareDeep(method, o.method, true)
1751           && compareDeep(preferredReportName, o.preferredReportName, true) && compareDeep(quantitativeDetails, o.quantitativeDetails, true)
1752           && compareDeep(qualifiedInterval, o.qualifiedInterval, true) && compareDeep(validCodedValueSet, o.validCodedValueSet, true)
1753           && compareDeep(normalCodedValueSet, o.normalCodedValueSet, true) && compareDeep(abnormalCodedValueSet, o.abnormalCodedValueSet, true)
1754           && compareDeep(criticalCodedValueSet, o.criticalCodedValueSet, true);
1755      }
1756
1757      @Override
1758      public boolean equalsShallow(Base other_) {
1759        if (!super.equalsShallow(other_))
1760          return false;
1761        if (!(other_ instanceof ObservationDefinition))
1762          return false;
1763        ObservationDefinition o = (ObservationDefinition) other_;
1764        return compareValues(multipleResultsAllowed, o.multipleResultsAllowed, true) && compareValues(preferredReportName, o.preferredReportName, true)
1765           && compareValues(validCodedValueSet, o.validCodedValueSet, true) && compareValues(normalCodedValueSet, o.normalCodedValueSet, true)
1766           && compareValues(abnormalCodedValueSet, o.abnormalCodedValueSet, true) && compareValues(criticalCodedValueSet, o.criticalCodedValueSet, true)
1767          ;
1768      }
1769
1770      public boolean isEmpty() {
1771        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(category, code, permittedDataType
1772          , multipleResultsAllowed, method, preferredReportName, quantitativeDetails, qualifiedInterval
1773          , validCodedValueSet, normalCodedValueSet, abnormalCodedValueSet, criticalCodedValueSet
1774          );
1775      }
1776
1777  @Override
1778  public ResourceType getResourceType() {
1779    return ResourceType.ObservationDefinition;
1780   }
1781
1782
1783}
1784