001package org.hl7.fhir.r4.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Thu, Sep 13, 2018 09:04-0400 for FHIR v3.5.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/StructureDefinition/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 range of the interval.
418         */
419        @Child(name = "range", type = {Range.class}, order=2, min=0, max=1, modifier=false, summary=false)
420        @Description(shortDefinition="The range of the interval", formalDefinition="The range of the interval." )
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 range of the interval.)
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 range of the interval.)
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 range of the interval.", 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 range of the interval.", 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 = {CodeableConcept.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 CodeableConcept category;
901
902    /**
903     * Describes what will be observed. Sometimes this is called the observation "name".
904     */
905    @Child(name = "code", type = {CodeableConcept.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 CodeableConcept code;
909
910    /**
911     * Unique identifier for this ObservationDefinition artifact.
912     */
913    @Child(name = "identifier", type = {Identifier.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
914    @Description(shortDefinition="Unique identifier for this ObservationDefinition artifact", formalDefinition="Unique identifier for this ObservationDefinition artifact." )
915    protected List<Identifier> identifier;
916
917    /**
918     * Data type allowed for the result of the observation.
919     */
920    @Child(name = "permittedDataType", type = {Coding.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
921    @Description(shortDefinition="Permitted data type for observation value", formalDefinition="Data type allowed for the result of the observation." )
922    protected List<Coding> permittedDataType;
923
924    /**
925     * Multiple results allowed for this kind of observation.
926     */
927    @Child(name = "multipleResultsAllowed", type = {BooleanType.class}, order=4, min=0, max=1, modifier=false, summary=false)
928    @Description(shortDefinition="Multiple results allowed", formalDefinition="Multiple results allowed for this kind of observation." )
929    protected BooleanType multipleResultsAllowed;
930
931    /**
932     * The method or technique used to perform the observation.
933     */
934    @Child(name = "method", type = {CodeableConcept.class}, order=5, min=0, max=1, modifier=false, summary=false)
935    @Description(shortDefinition="The method or technique used to perform the observation", formalDefinition="The method or technique used to perform the observation." )
936    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/observation-methods")
937    protected CodeableConcept method;
938
939    /**
940     * The preferred name to be used when reporting the results of this observation.
941     */
942    @Child(name = "preferredReportName", type = {StringType.class}, order=6, min=0, max=1, modifier=false, summary=false)
943    @Description(shortDefinition="Preferred report name", formalDefinition="The preferred name to be used when reporting the results of this observation." )
944    protected StringType preferredReportName;
945
946    /**
947     * Characteristics for quantitative results of this observation.
948     */
949    @Child(name = "quantitativeDetails", type = {}, order=7, min=0, max=1, modifier=false, summary=false)
950    @Description(shortDefinition="Characteristics of quantitative results", formalDefinition="Characteristics for quantitative results of this observation." )
951    protected ObservationDefinitionQuantitativeDetailsComponent quantitativeDetails;
952
953    /**
954     * Reference range for ordinal and continuous observations.
955     */
956    @Child(name = "qualifiedInterval", type = {}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
957    @Description(shortDefinition="Reference range for observation result", formalDefinition="Reference range for ordinal and continuous observations." )
958    protected List<ObservationDefinitionQualifiedIntervalComponent> qualifiedInterval;
959
960    /**
961     * The set of valid coded results for the observation.
962     */
963    @Child(name = "validCodedValueSet", type = {UriType.class}, order=9, min=0, max=1, modifier=false, summary=false)
964    @Description(shortDefinition="Value set of valid coded values for the observation", formalDefinition="The set of valid coded results for the observation." )
965    protected UriType validCodedValueSet;
966
967    /**
968     * The set of normal coded results for the observation.
969     */
970    @Child(name = "normalCodedValueSet", type = {UriType.class}, order=10, min=0, max=1, modifier=false, summary=false)
971    @Description(shortDefinition="Value set of normal coded values for the observation", formalDefinition="The set of normal coded results for the observation." )
972    protected UriType normalCodedValueSet;
973
974    /**
975     * The set of abnormal coded results for the observation.
976     */
977    @Child(name = "abnormalCodedValueSet", type = {UriType.class}, order=11, min=0, max=1, modifier=false, summary=false)
978    @Description(shortDefinition="Value set of abnormal coded values for the observation", formalDefinition="The set of abnormal coded results for the observation." )
979    protected UriType abnormalCodedValueSet;
980
981    /**
982     * The set of critical coded results for the observation.
983     */
984    @Child(name = "criticalCodedValueSet", type = {UriType.class}, order=12, min=0, max=1, modifier=false, summary=false)
985    @Description(shortDefinition="Value set of critical coded values for the observation", formalDefinition="The set of critical coded results for the observation." )
986    protected UriType criticalCodedValueSet;
987
988    private static final long serialVersionUID = 1248420796L;
989
990  /**
991   * Constructor
992   */
993    public ObservationDefinition() {
994      super();
995    }
996
997  /**
998   * Constructor
999   */
1000    public ObservationDefinition(CodeableConcept code) {
1001      super();
1002      this.code = code;
1003    }
1004
1005    /**
1006     * @return {@link #category} (A code that classifies the general type of observation.)
1007     */
1008    public CodeableConcept getCategory() { 
1009      if (this.category == null)
1010        if (Configuration.errorOnAutoCreate())
1011          throw new Error("Attempt to auto-create ObservationDefinition.category");
1012        else if (Configuration.doAutoCreate())
1013          this.category = new CodeableConcept(); // cc
1014      return this.category;
1015    }
1016
1017    public boolean hasCategory() { 
1018      return this.category != null && !this.category.isEmpty();
1019    }
1020
1021    /**
1022     * @param value {@link #category} (A code that classifies the general type of observation.)
1023     */
1024    public ObservationDefinition setCategory(CodeableConcept value) { 
1025      this.category = value;
1026      return this;
1027    }
1028
1029    /**
1030     * @return {@link #code} (Describes what will be observed. Sometimes this is called the observation "name".)
1031     */
1032    public CodeableConcept getCode() { 
1033      if (this.code == null)
1034        if (Configuration.errorOnAutoCreate())
1035          throw new Error("Attempt to auto-create ObservationDefinition.code");
1036        else if (Configuration.doAutoCreate())
1037          this.code = new CodeableConcept(); // cc
1038      return this.code;
1039    }
1040
1041    public boolean hasCode() { 
1042      return this.code != null && !this.code.isEmpty();
1043    }
1044
1045    /**
1046     * @param value {@link #code} (Describes what will be observed. Sometimes this is called the observation "name".)
1047     */
1048    public ObservationDefinition setCode(CodeableConcept value) { 
1049      this.code = value;
1050      return this;
1051    }
1052
1053    /**
1054     * @return {@link #identifier} (Unique identifier for this ObservationDefinition artifact.)
1055     */
1056    public List<Identifier> getIdentifier() { 
1057      if (this.identifier == null)
1058        this.identifier = new ArrayList<Identifier>();
1059      return this.identifier;
1060    }
1061
1062    /**
1063     * @return Returns a reference to <code>this</code> for easy method chaining
1064     */
1065    public ObservationDefinition setIdentifier(List<Identifier> theIdentifier) { 
1066      this.identifier = theIdentifier;
1067      return this;
1068    }
1069
1070    public boolean hasIdentifier() { 
1071      if (this.identifier == null)
1072        return false;
1073      for (Identifier item : this.identifier)
1074        if (!item.isEmpty())
1075          return true;
1076      return false;
1077    }
1078
1079    public Identifier addIdentifier() { //3
1080      Identifier t = new Identifier();
1081      if (this.identifier == null)
1082        this.identifier = new ArrayList<Identifier>();
1083      this.identifier.add(t);
1084      return t;
1085    }
1086
1087    public ObservationDefinition addIdentifier(Identifier t) { //3
1088      if (t == null)
1089        return this;
1090      if (this.identifier == null)
1091        this.identifier = new ArrayList<Identifier>();
1092      this.identifier.add(t);
1093      return this;
1094    }
1095
1096    /**
1097     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
1098     */
1099    public Identifier getIdentifierFirstRep() { 
1100      if (getIdentifier().isEmpty()) {
1101        addIdentifier();
1102      }
1103      return getIdentifier().get(0);
1104    }
1105
1106    /**
1107     * @return {@link #permittedDataType} (Data type allowed for the result of the observation.)
1108     */
1109    public List<Coding> getPermittedDataType() { 
1110      if (this.permittedDataType == null)
1111        this.permittedDataType = new ArrayList<Coding>();
1112      return this.permittedDataType;
1113    }
1114
1115    /**
1116     * @return Returns a reference to <code>this</code> for easy method chaining
1117     */
1118    public ObservationDefinition setPermittedDataType(List<Coding> thePermittedDataType) { 
1119      this.permittedDataType = thePermittedDataType;
1120      return this;
1121    }
1122
1123    public boolean hasPermittedDataType() { 
1124      if (this.permittedDataType == null)
1125        return false;
1126      for (Coding item : this.permittedDataType)
1127        if (!item.isEmpty())
1128          return true;
1129      return false;
1130    }
1131
1132    public Coding addPermittedDataType() { //3
1133      Coding t = new Coding();
1134      if (this.permittedDataType == null)
1135        this.permittedDataType = new ArrayList<Coding>();
1136      this.permittedDataType.add(t);
1137      return t;
1138    }
1139
1140    public ObservationDefinition addPermittedDataType(Coding t) { //3
1141      if (t == null)
1142        return this;
1143      if (this.permittedDataType == null)
1144        this.permittedDataType = new ArrayList<Coding>();
1145      this.permittedDataType.add(t);
1146      return this;
1147    }
1148
1149    /**
1150     * @return The first repetition of repeating field {@link #permittedDataType}, creating it if it does not already exist
1151     */
1152    public Coding getPermittedDataTypeFirstRep() { 
1153      if (getPermittedDataType().isEmpty()) {
1154        addPermittedDataType();
1155      }
1156      return getPermittedDataType().get(0);
1157    }
1158
1159    /**
1160     * @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
1161     */
1162    public BooleanType getMultipleResultsAllowedElement() { 
1163      if (this.multipleResultsAllowed == null)
1164        if (Configuration.errorOnAutoCreate())
1165          throw new Error("Attempt to auto-create ObservationDefinition.multipleResultsAllowed");
1166        else if (Configuration.doAutoCreate())
1167          this.multipleResultsAllowed = new BooleanType(); // bb
1168      return this.multipleResultsAllowed;
1169    }
1170
1171    public boolean hasMultipleResultsAllowedElement() { 
1172      return this.multipleResultsAllowed != null && !this.multipleResultsAllowed.isEmpty();
1173    }
1174
1175    public boolean hasMultipleResultsAllowed() { 
1176      return this.multipleResultsAllowed != null && !this.multipleResultsAllowed.isEmpty();
1177    }
1178
1179    /**
1180     * @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
1181     */
1182    public ObservationDefinition setMultipleResultsAllowedElement(BooleanType value) { 
1183      this.multipleResultsAllowed = value;
1184      return this;
1185    }
1186
1187    /**
1188     * @return Multiple results allowed for this kind of observation.
1189     */
1190    public boolean getMultipleResultsAllowed() { 
1191      return this.multipleResultsAllowed == null || this.multipleResultsAllowed.isEmpty() ? false : this.multipleResultsAllowed.getValue();
1192    }
1193
1194    /**
1195     * @param value Multiple results allowed for this kind of observation.
1196     */
1197    public ObservationDefinition setMultipleResultsAllowed(boolean value) { 
1198        if (this.multipleResultsAllowed == null)
1199          this.multipleResultsAllowed = new BooleanType();
1200        this.multipleResultsAllowed.setValue(value);
1201      return this;
1202    }
1203
1204    /**
1205     * @return {@link #method} (The method or technique used to perform the observation.)
1206     */
1207    public CodeableConcept getMethod() { 
1208      if (this.method == null)
1209        if (Configuration.errorOnAutoCreate())
1210          throw new Error("Attempt to auto-create ObservationDefinition.method");
1211        else if (Configuration.doAutoCreate())
1212          this.method = new CodeableConcept(); // cc
1213      return this.method;
1214    }
1215
1216    public boolean hasMethod() { 
1217      return this.method != null && !this.method.isEmpty();
1218    }
1219
1220    /**
1221     * @param value {@link #method} (The method or technique used to perform the observation.)
1222     */
1223    public ObservationDefinition setMethod(CodeableConcept value) { 
1224      this.method = value;
1225      return this;
1226    }
1227
1228    /**
1229     * @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
1230     */
1231    public StringType getPreferredReportNameElement() { 
1232      if (this.preferredReportName == null)
1233        if (Configuration.errorOnAutoCreate())
1234          throw new Error("Attempt to auto-create ObservationDefinition.preferredReportName");
1235        else if (Configuration.doAutoCreate())
1236          this.preferredReportName = new StringType(); // bb
1237      return this.preferredReportName;
1238    }
1239
1240    public boolean hasPreferredReportNameElement() { 
1241      return this.preferredReportName != null && !this.preferredReportName.isEmpty();
1242    }
1243
1244    public boolean hasPreferredReportName() { 
1245      return this.preferredReportName != null && !this.preferredReportName.isEmpty();
1246    }
1247
1248    /**
1249     * @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
1250     */
1251    public ObservationDefinition setPreferredReportNameElement(StringType value) { 
1252      this.preferredReportName = value;
1253      return this;
1254    }
1255
1256    /**
1257     * @return The preferred name to be used when reporting the results of this observation.
1258     */
1259    public String getPreferredReportName() { 
1260      return this.preferredReportName == null ? null : this.preferredReportName.getValue();
1261    }
1262
1263    /**
1264     * @param value The preferred name to be used when reporting the results of this observation.
1265     */
1266    public ObservationDefinition setPreferredReportName(String value) { 
1267      if (Utilities.noString(value))
1268        this.preferredReportName = null;
1269      else {
1270        if (this.preferredReportName == null)
1271          this.preferredReportName = new StringType();
1272        this.preferredReportName.setValue(value);
1273      }
1274      return this;
1275    }
1276
1277    /**
1278     * @return {@link #quantitativeDetails} (Characteristics for quantitative results of this observation.)
1279     */
1280    public ObservationDefinitionQuantitativeDetailsComponent getQuantitativeDetails() { 
1281      if (this.quantitativeDetails == null)
1282        if (Configuration.errorOnAutoCreate())
1283          throw new Error("Attempt to auto-create ObservationDefinition.quantitativeDetails");
1284        else if (Configuration.doAutoCreate())
1285          this.quantitativeDetails = new ObservationDefinitionQuantitativeDetailsComponent(); // cc
1286      return this.quantitativeDetails;
1287    }
1288
1289    public boolean hasQuantitativeDetails() { 
1290      return this.quantitativeDetails != null && !this.quantitativeDetails.isEmpty();
1291    }
1292
1293    /**
1294     * @param value {@link #quantitativeDetails} (Characteristics for quantitative results of this observation.)
1295     */
1296    public ObservationDefinition setQuantitativeDetails(ObservationDefinitionQuantitativeDetailsComponent value) { 
1297      this.quantitativeDetails = value;
1298      return this;
1299    }
1300
1301    /**
1302     * @return {@link #qualifiedInterval} (Reference range for ordinal and continuous observations.)
1303     */
1304    public List<ObservationDefinitionQualifiedIntervalComponent> getQualifiedInterval() { 
1305      if (this.qualifiedInterval == null)
1306        this.qualifiedInterval = new ArrayList<ObservationDefinitionQualifiedIntervalComponent>();
1307      return this.qualifiedInterval;
1308    }
1309
1310    /**
1311     * @return Returns a reference to <code>this</code> for easy method chaining
1312     */
1313    public ObservationDefinition setQualifiedInterval(List<ObservationDefinitionQualifiedIntervalComponent> theQualifiedInterval) { 
1314      this.qualifiedInterval = theQualifiedInterval;
1315      return this;
1316    }
1317
1318    public boolean hasQualifiedInterval() { 
1319      if (this.qualifiedInterval == null)
1320        return false;
1321      for (ObservationDefinitionQualifiedIntervalComponent item : this.qualifiedInterval)
1322        if (!item.isEmpty())
1323          return true;
1324      return false;
1325    }
1326
1327    public ObservationDefinitionQualifiedIntervalComponent addQualifiedInterval() { //3
1328      ObservationDefinitionQualifiedIntervalComponent t = new ObservationDefinitionQualifiedIntervalComponent();
1329      if (this.qualifiedInterval == null)
1330        this.qualifiedInterval = new ArrayList<ObservationDefinitionQualifiedIntervalComponent>();
1331      this.qualifiedInterval.add(t);
1332      return t;
1333    }
1334
1335    public ObservationDefinition addQualifiedInterval(ObservationDefinitionQualifiedIntervalComponent t) { //3
1336      if (t == null)
1337        return this;
1338      if (this.qualifiedInterval == null)
1339        this.qualifiedInterval = new ArrayList<ObservationDefinitionQualifiedIntervalComponent>();
1340      this.qualifiedInterval.add(t);
1341      return this;
1342    }
1343
1344    /**
1345     * @return The first repetition of repeating field {@link #qualifiedInterval}, creating it if it does not already exist
1346     */
1347    public ObservationDefinitionQualifiedIntervalComponent getQualifiedIntervalFirstRep() { 
1348      if (getQualifiedInterval().isEmpty()) {
1349        addQualifiedInterval();
1350      }
1351      return getQualifiedInterval().get(0);
1352    }
1353
1354    /**
1355     * @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
1356     */
1357    public UriType getValidCodedValueSetElement() { 
1358      if (this.validCodedValueSet == null)
1359        if (Configuration.errorOnAutoCreate())
1360          throw new Error("Attempt to auto-create ObservationDefinition.validCodedValueSet");
1361        else if (Configuration.doAutoCreate())
1362          this.validCodedValueSet = new UriType(); // bb
1363      return this.validCodedValueSet;
1364    }
1365
1366    public boolean hasValidCodedValueSetElement() { 
1367      return this.validCodedValueSet != null && !this.validCodedValueSet.isEmpty();
1368    }
1369
1370    public boolean hasValidCodedValueSet() { 
1371      return this.validCodedValueSet != null && !this.validCodedValueSet.isEmpty();
1372    }
1373
1374    /**
1375     * @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
1376     */
1377    public ObservationDefinition setValidCodedValueSetElement(UriType value) { 
1378      this.validCodedValueSet = value;
1379      return this;
1380    }
1381
1382    /**
1383     * @return The set of valid coded results for the observation.
1384     */
1385    public String getValidCodedValueSet() { 
1386      return this.validCodedValueSet == null ? null : this.validCodedValueSet.getValue();
1387    }
1388
1389    /**
1390     * @param value The set of valid coded results for the observation.
1391     */
1392    public ObservationDefinition setValidCodedValueSet(String value) { 
1393      if (Utilities.noString(value))
1394        this.validCodedValueSet = null;
1395      else {
1396        if (this.validCodedValueSet == null)
1397          this.validCodedValueSet = new UriType();
1398        this.validCodedValueSet.setValue(value);
1399      }
1400      return this;
1401    }
1402
1403    /**
1404     * @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
1405     */
1406    public UriType getNormalCodedValueSetElement() { 
1407      if (this.normalCodedValueSet == null)
1408        if (Configuration.errorOnAutoCreate())
1409          throw new Error("Attempt to auto-create ObservationDefinition.normalCodedValueSet");
1410        else if (Configuration.doAutoCreate())
1411          this.normalCodedValueSet = new UriType(); // bb
1412      return this.normalCodedValueSet;
1413    }
1414
1415    public boolean hasNormalCodedValueSetElement() { 
1416      return this.normalCodedValueSet != null && !this.normalCodedValueSet.isEmpty();
1417    }
1418
1419    public boolean hasNormalCodedValueSet() { 
1420      return this.normalCodedValueSet != null && !this.normalCodedValueSet.isEmpty();
1421    }
1422
1423    /**
1424     * @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
1425     */
1426    public ObservationDefinition setNormalCodedValueSetElement(UriType value) { 
1427      this.normalCodedValueSet = value;
1428      return this;
1429    }
1430
1431    /**
1432     * @return The set of normal coded results for the observation.
1433     */
1434    public String getNormalCodedValueSet() { 
1435      return this.normalCodedValueSet == null ? null : this.normalCodedValueSet.getValue();
1436    }
1437
1438    /**
1439     * @param value The set of normal coded results for the observation.
1440     */
1441    public ObservationDefinition setNormalCodedValueSet(String value) { 
1442      if (Utilities.noString(value))
1443        this.normalCodedValueSet = null;
1444      else {
1445        if (this.normalCodedValueSet == null)
1446          this.normalCodedValueSet = new UriType();
1447        this.normalCodedValueSet.setValue(value);
1448      }
1449      return this;
1450    }
1451
1452    /**
1453     * @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
1454     */
1455    public UriType getAbnormalCodedValueSetElement() { 
1456      if (this.abnormalCodedValueSet == null)
1457        if (Configuration.errorOnAutoCreate())
1458          throw new Error("Attempt to auto-create ObservationDefinition.abnormalCodedValueSet");
1459        else if (Configuration.doAutoCreate())
1460          this.abnormalCodedValueSet = new UriType(); // bb
1461      return this.abnormalCodedValueSet;
1462    }
1463
1464    public boolean hasAbnormalCodedValueSetElement() { 
1465      return this.abnormalCodedValueSet != null && !this.abnormalCodedValueSet.isEmpty();
1466    }
1467
1468    public boolean hasAbnormalCodedValueSet() { 
1469      return this.abnormalCodedValueSet != null && !this.abnormalCodedValueSet.isEmpty();
1470    }
1471
1472    /**
1473     * @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
1474     */
1475    public ObservationDefinition setAbnormalCodedValueSetElement(UriType value) { 
1476      this.abnormalCodedValueSet = value;
1477      return this;
1478    }
1479
1480    /**
1481     * @return The set of abnormal coded results for the observation.
1482     */
1483    public String getAbnormalCodedValueSet() { 
1484      return this.abnormalCodedValueSet == null ? null : this.abnormalCodedValueSet.getValue();
1485    }
1486
1487    /**
1488     * @param value The set of abnormal coded results for the observation.
1489     */
1490    public ObservationDefinition setAbnormalCodedValueSet(String value) { 
1491      if (Utilities.noString(value))
1492        this.abnormalCodedValueSet = null;
1493      else {
1494        if (this.abnormalCodedValueSet == null)
1495          this.abnormalCodedValueSet = new UriType();
1496        this.abnormalCodedValueSet.setValue(value);
1497      }
1498      return this;
1499    }
1500
1501    /**
1502     * @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
1503     */
1504    public UriType getCriticalCodedValueSetElement() { 
1505      if (this.criticalCodedValueSet == null)
1506        if (Configuration.errorOnAutoCreate())
1507          throw new Error("Attempt to auto-create ObservationDefinition.criticalCodedValueSet");
1508        else if (Configuration.doAutoCreate())
1509          this.criticalCodedValueSet = new UriType(); // bb
1510      return this.criticalCodedValueSet;
1511    }
1512
1513    public boolean hasCriticalCodedValueSetElement() { 
1514      return this.criticalCodedValueSet != null && !this.criticalCodedValueSet.isEmpty();
1515    }
1516
1517    public boolean hasCriticalCodedValueSet() { 
1518      return this.criticalCodedValueSet != null && !this.criticalCodedValueSet.isEmpty();
1519    }
1520
1521    /**
1522     * @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
1523     */
1524    public ObservationDefinition setCriticalCodedValueSetElement(UriType value) { 
1525      this.criticalCodedValueSet = value;
1526      return this;
1527    }
1528
1529    /**
1530     * @return The set of critical coded results for the observation.
1531     */
1532    public String getCriticalCodedValueSet() { 
1533      return this.criticalCodedValueSet == null ? null : this.criticalCodedValueSet.getValue();
1534    }
1535
1536    /**
1537     * @param value The set of critical coded results for the observation.
1538     */
1539    public ObservationDefinition setCriticalCodedValueSet(String value) { 
1540      if (Utilities.noString(value))
1541        this.criticalCodedValueSet = null;
1542      else {
1543        if (this.criticalCodedValueSet == null)
1544          this.criticalCodedValueSet = new UriType();
1545        this.criticalCodedValueSet.setValue(value);
1546      }
1547      return this;
1548    }
1549
1550      protected void listChildren(List<Property> children) {
1551        super.listChildren(children);
1552        children.add(new Property("category", "CodeableConcept", "A code that classifies the general type of observation.", 0, 1, category));
1553        children.add(new Property("code", "CodeableConcept", "Describes what will be observed. Sometimes this is called the observation \"name\".", 0, 1, code));
1554        children.add(new Property("identifier", "Identifier", "Unique identifier for this ObservationDefinition artifact.", 0, java.lang.Integer.MAX_VALUE, identifier));
1555        children.add(new Property("permittedDataType", "Coding", "Data type allowed for the result of the observation.", 0, java.lang.Integer.MAX_VALUE, permittedDataType));
1556        children.add(new Property("multipleResultsAllowed", "boolean", "Multiple results allowed for this kind of observation.", 0, 1, multipleResultsAllowed));
1557        children.add(new Property("method", "CodeableConcept", "The method or technique used to perform the observation.", 0, 1, method));
1558        children.add(new Property("preferredReportName", "string", "The preferred name to be used when reporting the results of this observation.", 0, 1, preferredReportName));
1559        children.add(new Property("quantitativeDetails", "", "Characteristics for quantitative results of this observation.", 0, 1, quantitativeDetails));
1560        children.add(new Property("qualifiedInterval", "", "Reference range for ordinal and continuous observations.", 0, java.lang.Integer.MAX_VALUE, qualifiedInterval));
1561        children.add(new Property("validCodedValueSet", "uri", "The set of valid coded results for the observation.", 0, 1, validCodedValueSet));
1562        children.add(new Property("normalCodedValueSet", "uri", "The set of normal coded results for the observation.", 0, 1, normalCodedValueSet));
1563        children.add(new Property("abnormalCodedValueSet", "uri", "The set of abnormal coded results for the observation.", 0, 1, abnormalCodedValueSet));
1564        children.add(new Property("criticalCodedValueSet", "uri", "The set of critical coded results for the observation.", 0, 1, criticalCodedValueSet));
1565      }
1566
1567      @Override
1568      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1569        switch (_hash) {
1570        case 50511102: /*category*/  return new Property("category", "CodeableConcept", "A code that classifies the general type of observation.", 0, 1, category);
1571        case 3059181: /*code*/  return new Property("code", "CodeableConcept", "Describes what will be observed. Sometimes this is called the observation \"name\".", 0, 1, code);
1572        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Unique identifier for this ObservationDefinition artifact.", 0, java.lang.Integer.MAX_VALUE, identifier);
1573        case -99492804: /*permittedDataType*/  return new Property("permittedDataType", "Coding", "Data type allowed for the result of the observation.", 0, java.lang.Integer.MAX_VALUE, permittedDataType);
1574        case -2102414590: /*multipleResultsAllowed*/  return new Property("multipleResultsAllowed", "boolean", "Multiple results allowed for this kind of observation.", 0, 1, multipleResultsAllowed);
1575        case -1077554975: /*method*/  return new Property("method", "CodeableConcept", "The method or technique used to perform the observation.", 0, 1, method);
1576        case -1851030208: /*preferredReportName*/  return new Property("preferredReportName", "string", "The preferred name to be used when reporting the results of this observation.", 0, 1, preferredReportName);
1577        case 842150763: /*quantitativeDetails*/  return new Property("quantitativeDetails", "", "Characteristics for quantitative results of this observation.", 0, 1, quantitativeDetails);
1578        case 1882971521: /*qualifiedInterval*/  return new Property("qualifiedInterval", "", "Reference range for ordinal and continuous observations.", 0, java.lang.Integer.MAX_VALUE, qualifiedInterval);
1579        case 1374640076: /*validCodedValueSet*/  return new Property("validCodedValueSet", "uri", "The set of valid coded results for the observation.", 0, 1, validCodedValueSet);
1580        case -837500735: /*normalCodedValueSet*/  return new Property("normalCodedValueSet", "uri", "The set of normal coded results for the observation.", 0, 1, normalCodedValueSet);
1581        case 1073600256: /*abnormalCodedValueSet*/  return new Property("abnormalCodedValueSet", "uri", "The set of abnormal coded results for the observation.", 0, 1, abnormalCodedValueSet);
1582        case 2568457: /*criticalCodedValueSet*/  return new Property("criticalCodedValueSet", "uri", "The set of critical coded results for the observation.", 0, 1, criticalCodedValueSet);
1583        default: return super.getNamedProperty(_hash, _name, _checkValid);
1584        }
1585
1586      }
1587
1588      @Override
1589      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1590        switch (hash) {
1591        case 50511102: /*category*/ return this.category == null ? new Base[0] : new Base[] {this.category}; // CodeableConcept
1592        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept
1593        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1594        case -99492804: /*permittedDataType*/ return this.permittedDataType == null ? new Base[0] : this.permittedDataType.toArray(new Base[this.permittedDataType.size()]); // Coding
1595        case -2102414590: /*multipleResultsAllowed*/ return this.multipleResultsAllowed == null ? new Base[0] : new Base[] {this.multipleResultsAllowed}; // BooleanType
1596        case -1077554975: /*method*/ return this.method == null ? new Base[0] : new Base[] {this.method}; // CodeableConcept
1597        case -1851030208: /*preferredReportName*/ return this.preferredReportName == null ? new Base[0] : new Base[] {this.preferredReportName}; // StringType
1598        case 842150763: /*quantitativeDetails*/ return this.quantitativeDetails == null ? new Base[0] : new Base[] {this.quantitativeDetails}; // ObservationDefinitionQuantitativeDetailsComponent
1599        case 1882971521: /*qualifiedInterval*/ return this.qualifiedInterval == null ? new Base[0] : this.qualifiedInterval.toArray(new Base[this.qualifiedInterval.size()]); // ObservationDefinitionQualifiedIntervalComponent
1600        case 1374640076: /*validCodedValueSet*/ return this.validCodedValueSet == null ? new Base[0] : new Base[] {this.validCodedValueSet}; // UriType
1601        case -837500735: /*normalCodedValueSet*/ return this.normalCodedValueSet == null ? new Base[0] : new Base[] {this.normalCodedValueSet}; // UriType
1602        case 1073600256: /*abnormalCodedValueSet*/ return this.abnormalCodedValueSet == null ? new Base[0] : new Base[] {this.abnormalCodedValueSet}; // UriType
1603        case 2568457: /*criticalCodedValueSet*/ return this.criticalCodedValueSet == null ? new Base[0] : new Base[] {this.criticalCodedValueSet}; // UriType
1604        default: return super.getProperty(hash, name, checkValid);
1605        }
1606
1607      }
1608
1609      @Override
1610      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1611        switch (hash) {
1612        case 50511102: // category
1613          this.category = castToCodeableConcept(value); // CodeableConcept
1614          return value;
1615        case 3059181: // code
1616          this.code = castToCodeableConcept(value); // CodeableConcept
1617          return value;
1618        case -1618432855: // identifier
1619          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1620          return value;
1621        case -99492804: // permittedDataType
1622          this.getPermittedDataType().add(castToCoding(value)); // Coding
1623          return value;
1624        case -2102414590: // multipleResultsAllowed
1625          this.multipleResultsAllowed = castToBoolean(value); // BooleanType
1626          return value;
1627        case -1077554975: // method
1628          this.method = castToCodeableConcept(value); // CodeableConcept
1629          return value;
1630        case -1851030208: // preferredReportName
1631          this.preferredReportName = castToString(value); // StringType
1632          return value;
1633        case 842150763: // quantitativeDetails
1634          this.quantitativeDetails = (ObservationDefinitionQuantitativeDetailsComponent) value; // ObservationDefinitionQuantitativeDetailsComponent
1635          return value;
1636        case 1882971521: // qualifiedInterval
1637          this.getQualifiedInterval().add((ObservationDefinitionQualifiedIntervalComponent) value); // ObservationDefinitionQualifiedIntervalComponent
1638          return value;
1639        case 1374640076: // validCodedValueSet
1640          this.validCodedValueSet = castToUri(value); // UriType
1641          return value;
1642        case -837500735: // normalCodedValueSet
1643          this.normalCodedValueSet = castToUri(value); // UriType
1644          return value;
1645        case 1073600256: // abnormalCodedValueSet
1646          this.abnormalCodedValueSet = castToUri(value); // UriType
1647          return value;
1648        case 2568457: // criticalCodedValueSet
1649          this.criticalCodedValueSet = castToUri(value); // UriType
1650          return value;
1651        default: return super.setProperty(hash, name, value);
1652        }
1653
1654      }
1655
1656      @Override
1657      public Base setProperty(String name, Base value) throws FHIRException {
1658        if (name.equals("category")) {
1659          this.category = castToCodeableConcept(value); // CodeableConcept
1660        } else if (name.equals("code")) {
1661          this.code = castToCodeableConcept(value); // CodeableConcept
1662        } else if (name.equals("identifier")) {
1663          this.getIdentifier().add(castToIdentifier(value));
1664        } else if (name.equals("permittedDataType")) {
1665          this.getPermittedDataType().add(castToCoding(value));
1666        } else if (name.equals("multipleResultsAllowed")) {
1667          this.multipleResultsAllowed = castToBoolean(value); // BooleanType
1668        } else if (name.equals("method")) {
1669          this.method = castToCodeableConcept(value); // CodeableConcept
1670        } else if (name.equals("preferredReportName")) {
1671          this.preferredReportName = castToString(value); // StringType
1672        } else if (name.equals("quantitativeDetails")) {
1673          this.quantitativeDetails = (ObservationDefinitionQuantitativeDetailsComponent) value; // ObservationDefinitionQuantitativeDetailsComponent
1674        } else if (name.equals("qualifiedInterval")) {
1675          this.getQualifiedInterval().add((ObservationDefinitionQualifiedIntervalComponent) value);
1676        } else if (name.equals("validCodedValueSet")) {
1677          this.validCodedValueSet = castToUri(value); // UriType
1678        } else if (name.equals("normalCodedValueSet")) {
1679          this.normalCodedValueSet = castToUri(value); // UriType
1680        } else if (name.equals("abnormalCodedValueSet")) {
1681          this.abnormalCodedValueSet = castToUri(value); // UriType
1682        } else if (name.equals("criticalCodedValueSet")) {
1683          this.criticalCodedValueSet = castToUri(value); // UriType
1684        } else
1685          return super.setProperty(name, value);
1686        return value;
1687      }
1688
1689      @Override
1690      public Base makeProperty(int hash, String name) throws FHIRException {
1691        switch (hash) {
1692        case 50511102:  return getCategory(); 
1693        case 3059181:  return getCode(); 
1694        case -1618432855:  return addIdentifier(); 
1695        case -99492804:  return addPermittedDataType(); 
1696        case -2102414590:  return getMultipleResultsAllowedElement();
1697        case -1077554975:  return getMethod(); 
1698        case -1851030208:  return getPreferredReportNameElement();
1699        case 842150763:  return getQuantitativeDetails(); 
1700        case 1882971521:  return addQualifiedInterval(); 
1701        case 1374640076:  return getValidCodedValueSetElement();
1702        case -837500735:  return getNormalCodedValueSetElement();
1703        case 1073600256:  return getAbnormalCodedValueSetElement();
1704        case 2568457:  return getCriticalCodedValueSetElement();
1705        default: return super.makeProperty(hash, name);
1706        }
1707
1708      }
1709
1710      @Override
1711      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1712        switch (hash) {
1713        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
1714        case 3059181: /*code*/ return new String[] {"CodeableConcept"};
1715        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
1716        case -99492804: /*permittedDataType*/ return new String[] {"Coding"};
1717        case -2102414590: /*multipleResultsAllowed*/ return new String[] {"boolean"};
1718        case -1077554975: /*method*/ return new String[] {"CodeableConcept"};
1719        case -1851030208: /*preferredReportName*/ return new String[] {"string"};
1720        case 842150763: /*quantitativeDetails*/ return new String[] {};
1721        case 1882971521: /*qualifiedInterval*/ return new String[] {};
1722        case 1374640076: /*validCodedValueSet*/ return new String[] {"uri"};
1723        case -837500735: /*normalCodedValueSet*/ return new String[] {"uri"};
1724        case 1073600256: /*abnormalCodedValueSet*/ return new String[] {"uri"};
1725        case 2568457: /*criticalCodedValueSet*/ return new String[] {"uri"};
1726        default: return super.getTypesForProperty(hash, name);
1727        }
1728
1729      }
1730
1731      @Override
1732      public Base addChild(String name) throws FHIRException {
1733        if (name.equals("category")) {
1734          this.category = new CodeableConcept();
1735          return this.category;
1736        }
1737        else if (name.equals("code")) {
1738          this.code = new CodeableConcept();
1739          return this.code;
1740        }
1741        else if (name.equals("identifier")) {
1742          return addIdentifier();
1743        }
1744        else if (name.equals("permittedDataType")) {
1745          return addPermittedDataType();
1746        }
1747        else if (name.equals("multipleResultsAllowed")) {
1748          throw new FHIRException("Cannot call addChild on a primitive type ObservationDefinition.multipleResultsAllowed");
1749        }
1750        else if (name.equals("method")) {
1751          this.method = new CodeableConcept();
1752          return this.method;
1753        }
1754        else if (name.equals("preferredReportName")) {
1755          throw new FHIRException("Cannot call addChild on a primitive type ObservationDefinition.preferredReportName");
1756        }
1757        else if (name.equals("quantitativeDetails")) {
1758          this.quantitativeDetails = new ObservationDefinitionQuantitativeDetailsComponent();
1759          return this.quantitativeDetails;
1760        }
1761        else if (name.equals("qualifiedInterval")) {
1762          return addQualifiedInterval();
1763        }
1764        else if (name.equals("validCodedValueSet")) {
1765          throw new FHIRException("Cannot call addChild on a primitive type ObservationDefinition.validCodedValueSet");
1766        }
1767        else if (name.equals("normalCodedValueSet")) {
1768          throw new FHIRException("Cannot call addChild on a primitive type ObservationDefinition.normalCodedValueSet");
1769        }
1770        else if (name.equals("abnormalCodedValueSet")) {
1771          throw new FHIRException("Cannot call addChild on a primitive type ObservationDefinition.abnormalCodedValueSet");
1772        }
1773        else if (name.equals("criticalCodedValueSet")) {
1774          throw new FHIRException("Cannot call addChild on a primitive type ObservationDefinition.criticalCodedValueSet");
1775        }
1776        else
1777          return super.addChild(name);
1778      }
1779
1780  public String fhirType() {
1781    return "ObservationDefinition";
1782
1783  }
1784
1785      public ObservationDefinition copy() {
1786        ObservationDefinition dst = new ObservationDefinition();
1787        copyValues(dst);
1788        dst.category = category == null ? null : category.copy();
1789        dst.code = code == null ? null : code.copy();
1790        if (identifier != null) {
1791          dst.identifier = new ArrayList<Identifier>();
1792          for (Identifier i : identifier)
1793            dst.identifier.add(i.copy());
1794        };
1795        if (permittedDataType != null) {
1796          dst.permittedDataType = new ArrayList<Coding>();
1797          for (Coding i : permittedDataType)
1798            dst.permittedDataType.add(i.copy());
1799        };
1800        dst.multipleResultsAllowed = multipleResultsAllowed == null ? null : multipleResultsAllowed.copy();
1801        dst.method = method == null ? null : method.copy();
1802        dst.preferredReportName = preferredReportName == null ? null : preferredReportName.copy();
1803        dst.quantitativeDetails = quantitativeDetails == null ? null : quantitativeDetails.copy();
1804        if (qualifiedInterval != null) {
1805          dst.qualifiedInterval = new ArrayList<ObservationDefinitionQualifiedIntervalComponent>();
1806          for (ObservationDefinitionQualifiedIntervalComponent i : qualifiedInterval)
1807            dst.qualifiedInterval.add(i.copy());
1808        };
1809        dst.validCodedValueSet = validCodedValueSet == null ? null : validCodedValueSet.copy();
1810        dst.normalCodedValueSet = normalCodedValueSet == null ? null : normalCodedValueSet.copy();
1811        dst.abnormalCodedValueSet = abnormalCodedValueSet == null ? null : abnormalCodedValueSet.copy();
1812        dst.criticalCodedValueSet = criticalCodedValueSet == null ? null : criticalCodedValueSet.copy();
1813        return dst;
1814      }
1815
1816      protected ObservationDefinition typedCopy() {
1817        return copy();
1818      }
1819
1820      @Override
1821      public boolean equalsDeep(Base other_) {
1822        if (!super.equalsDeep(other_))
1823          return false;
1824        if (!(other_ instanceof ObservationDefinition))
1825          return false;
1826        ObservationDefinition o = (ObservationDefinition) other_;
1827        return compareDeep(category, o.category, true) && compareDeep(code, o.code, true) && compareDeep(identifier, o.identifier, true)
1828           && compareDeep(permittedDataType, o.permittedDataType, true) && compareDeep(multipleResultsAllowed, o.multipleResultsAllowed, true)
1829           && compareDeep(method, o.method, true) && compareDeep(preferredReportName, o.preferredReportName, true)
1830           && compareDeep(quantitativeDetails, o.quantitativeDetails, true) && compareDeep(qualifiedInterval, o.qualifiedInterval, true)
1831           && compareDeep(validCodedValueSet, o.validCodedValueSet, true) && compareDeep(normalCodedValueSet, o.normalCodedValueSet, true)
1832           && compareDeep(abnormalCodedValueSet, o.abnormalCodedValueSet, true) && compareDeep(criticalCodedValueSet, o.criticalCodedValueSet, true)
1833          ;
1834      }
1835
1836      @Override
1837      public boolean equalsShallow(Base other_) {
1838        if (!super.equalsShallow(other_))
1839          return false;
1840        if (!(other_ instanceof ObservationDefinition))
1841          return false;
1842        ObservationDefinition o = (ObservationDefinition) other_;
1843        return compareValues(multipleResultsAllowed, o.multipleResultsAllowed, true) && compareValues(preferredReportName, o.preferredReportName, true)
1844           && compareValues(validCodedValueSet, o.validCodedValueSet, true) && compareValues(normalCodedValueSet, o.normalCodedValueSet, true)
1845           && compareValues(abnormalCodedValueSet, o.abnormalCodedValueSet, true) && compareValues(criticalCodedValueSet, o.criticalCodedValueSet, true)
1846          ;
1847      }
1848
1849      public boolean isEmpty() {
1850        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(category, code, identifier
1851          , permittedDataType, multipleResultsAllowed, method, preferredReportName, quantitativeDetails
1852          , qualifiedInterval, validCodedValueSet, normalCodedValueSet, abnormalCodedValueSet
1853          , criticalCodedValueSet);
1854      }
1855
1856  @Override
1857  public ResourceType getResourceType() {
1858    return ResourceType.ObservationDefinition;
1859   }
1860
1861
1862}
1863