001package org.hl7.fhir.dstu2.model;
002
003
004
005
006/*
007  Copyright (c) 2011+, HL7, Inc.
008  All rights reserved.
009  
010  Redistribution and use in source and binary forms, with or without modification, 
011  are permitted provided that the following conditions are met:
012  
013   * Redistributions of source code must retain the above copyright notice, this 
014     list of conditions and the following disclaimer.
015   * Redistributions in binary form must reproduce the above copyright notice, 
016     this list of conditions and the following disclaimer in the documentation 
017     and/or other materials provided with the distribution.
018   * Neither the name of HL7 nor the names of its contributors may be used to 
019     endorse or promote products derived from this software without specific 
020     prior written permission.
021  
022  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
023  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
024  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
025  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
026  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
027  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
028  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
029  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
030  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
031  POSSIBILITY OF SUCH DAMAGE.
032  
033*/
034
035// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
036import java.util.ArrayList;
037import java.util.Date;
038import java.util.List;
039
040import ca.uhn.fhir.model.api.annotation.Block;
041import ca.uhn.fhir.model.api.annotation.Child;
042import ca.uhn.fhir.model.api.annotation.Description;
043import ca.uhn.fhir.model.api.annotation.ResourceDef;
044import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
045import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
046import org.hl7.fhir.exceptions.FHIRException;
047import org.hl7.fhir.utilities.Utilities;
048/**
049 * Measurements and simple assertions made about a patient, device or other subject.
050 */
051@ResourceDef(name="Observation", profile="http://hl7.org/fhir/Profile/Observation")
052public class Observation extends DomainResource {
053
054    public enum ObservationStatus {
055        /**
056         * The existence of the observation is registered, but there is no result yet available.
057         */
058        REGISTERED, 
059        /**
060         * This is an initial or interim observation: data may be incomplete or unverified.
061         */
062        PRELIMINARY, 
063        /**
064         * The observation is complete and verified by an authorized person.
065         */
066        FINAL, 
067        /**
068         * The observation has been modified subsequent to being Final, and is complete and verified by an authorized person.
069         */
070        AMENDED, 
071        /**
072         * The observation is unavailable because the measurement was not started or not completed (also sometimes called "aborted").
073         */
074        CANCELLED, 
075        /**
076         * The observation has been withdrawn following previous final release.
077         */
078        ENTEREDINERROR, 
079        /**
080         * The observation status is unknown.  Note that "unknown" is a value of last resort and every attempt should be made to provide a meaningful value other than "unknown".
081         */
082        UNKNOWN, 
083        /**
084         * added to help the parsers
085         */
086        NULL;
087        public static ObservationStatus fromCode(String codeString) throws FHIRException {
088            if (codeString == null || "".equals(codeString))
089                return null;
090        if ("registered".equals(codeString))
091          return REGISTERED;
092        if ("preliminary".equals(codeString))
093          return PRELIMINARY;
094        if ("final".equals(codeString))
095          return FINAL;
096        if ("amended".equals(codeString))
097          return AMENDED;
098        if ("cancelled".equals(codeString))
099          return CANCELLED;
100        if ("entered-in-error".equals(codeString))
101          return ENTEREDINERROR;
102        if ("unknown".equals(codeString))
103          return UNKNOWN;
104        throw new FHIRException("Unknown ObservationStatus code '"+codeString+"'");
105        }
106        public String toCode() {
107          switch (this) {
108            case REGISTERED: return "registered";
109            case PRELIMINARY: return "preliminary";
110            case FINAL: return "final";
111            case AMENDED: return "amended";
112            case CANCELLED: return "cancelled";
113            case ENTEREDINERROR: return "entered-in-error";
114            case UNKNOWN: return "unknown";
115            case NULL: return null;
116            default: return "?";
117          }
118        }
119        public String getSystem() {
120          switch (this) {
121            case REGISTERED: return "http://hl7.org/fhir/observation-status";
122            case PRELIMINARY: return "http://hl7.org/fhir/observation-status";
123            case FINAL: return "http://hl7.org/fhir/observation-status";
124            case AMENDED: return "http://hl7.org/fhir/observation-status";
125            case CANCELLED: return "http://hl7.org/fhir/observation-status";
126            case ENTEREDINERROR: return "http://hl7.org/fhir/observation-status";
127            case UNKNOWN: return "http://hl7.org/fhir/observation-status";
128            case NULL: return null;
129            default: return "?";
130          }
131        }
132        public String getDefinition() {
133          switch (this) {
134            case REGISTERED: return "The existence of the observation is registered, but there is no result yet available.";
135            case PRELIMINARY: return "This is an initial or interim observation: data may be incomplete or unverified.";
136            case FINAL: return "The observation is complete and verified by an authorized person.";
137            case AMENDED: return "The observation has been modified subsequent to being Final, and is complete and verified by an authorized person.";
138            case CANCELLED: return "The observation is unavailable because the measurement was not started or not completed (also sometimes called \"aborted\").";
139            case ENTEREDINERROR: return "The observation has been withdrawn following previous final release.";
140            case UNKNOWN: return "The observation status is unknown.  Note that \"unknown\" is a value of last resort and every attempt should be made to provide a meaningful value other than \"unknown\".";
141            case NULL: return null;
142            default: return "?";
143          }
144        }
145        public String getDisplay() {
146          switch (this) {
147            case REGISTERED: return "Registered";
148            case PRELIMINARY: return "Preliminary";
149            case FINAL: return "Final";
150            case AMENDED: return "Amended";
151            case CANCELLED: return "cancelled";
152            case ENTEREDINERROR: return "Entered in Error";
153            case UNKNOWN: return "Unknown Status";
154            case NULL: return null;
155            default: return "?";
156          }
157        }
158    }
159
160  public static class ObservationStatusEnumFactory implements EnumFactory<ObservationStatus> {
161    public ObservationStatus fromCode(String codeString) throws IllegalArgumentException {
162      if (codeString == null || "".equals(codeString))
163            if (codeString == null || "".equals(codeString))
164                return null;
165        if ("registered".equals(codeString))
166          return ObservationStatus.REGISTERED;
167        if ("preliminary".equals(codeString))
168          return ObservationStatus.PRELIMINARY;
169        if ("final".equals(codeString))
170          return ObservationStatus.FINAL;
171        if ("amended".equals(codeString))
172          return ObservationStatus.AMENDED;
173        if ("cancelled".equals(codeString))
174          return ObservationStatus.CANCELLED;
175        if ("entered-in-error".equals(codeString))
176          return ObservationStatus.ENTEREDINERROR;
177        if ("unknown".equals(codeString))
178          return ObservationStatus.UNKNOWN;
179        throw new IllegalArgumentException("Unknown ObservationStatus code '"+codeString+"'");
180        }
181        public Enumeration<ObservationStatus> fromType(Base code) throws FHIRException {
182          if (code == null || code.isEmpty())
183            return null;
184          String codeString = ((PrimitiveType) code).asStringValue();
185          if (codeString == null || "".equals(codeString))
186            return null;
187        if ("registered".equals(codeString))
188          return new Enumeration<ObservationStatus>(this, ObservationStatus.REGISTERED);
189        if ("preliminary".equals(codeString))
190          return new Enumeration<ObservationStatus>(this, ObservationStatus.PRELIMINARY);
191        if ("final".equals(codeString))
192          return new Enumeration<ObservationStatus>(this, ObservationStatus.FINAL);
193        if ("amended".equals(codeString))
194          return new Enumeration<ObservationStatus>(this, ObservationStatus.AMENDED);
195        if ("cancelled".equals(codeString))
196          return new Enumeration<ObservationStatus>(this, ObservationStatus.CANCELLED);
197        if ("entered-in-error".equals(codeString))
198          return new Enumeration<ObservationStatus>(this, ObservationStatus.ENTEREDINERROR);
199        if ("unknown".equals(codeString))
200          return new Enumeration<ObservationStatus>(this, ObservationStatus.UNKNOWN);
201        throw new FHIRException("Unknown ObservationStatus code '"+codeString+"'");
202        }
203    public String toCode(ObservationStatus code) {
204      if (code == ObservationStatus.REGISTERED)
205        return "registered";
206      if (code == ObservationStatus.PRELIMINARY)
207        return "preliminary";
208      if (code == ObservationStatus.FINAL)
209        return "final";
210      if (code == ObservationStatus.AMENDED)
211        return "amended";
212      if (code == ObservationStatus.CANCELLED)
213        return "cancelled";
214      if (code == ObservationStatus.ENTEREDINERROR)
215        return "entered-in-error";
216      if (code == ObservationStatus.UNKNOWN)
217        return "unknown";
218      return "?";
219      }
220    }
221
222    public enum ObservationRelationshipType {
223        /**
224         * This observation is a group observation (e.g. a battery, a panel of tests, a set of vital sign measurements) that includes the target as a member of the group.
225         */
226        HASMEMBER, 
227        /**
228         * The target resource (Observation or QuestionnaireResponse) is part of the information from which this observation value is derived. (e.g. calculated anion gap, Apgar score)  NOTE:  "derived-from" is only logical choice when referencing QuestionnaireResponse.
229         */
230        DERIVEDFROM, 
231        /**
232         * This observation follows the target observation (e.g. timed tests such as Glucose Tolerance Test).
233         */
234        SEQUELTO, 
235        /**
236         * This observation replaces a previous observation (i.e. a revised value). The target observation is now obsolete.
237         */
238        REPLACES, 
239        /**
240         * The value of the target observation qualifies (refines) the semantics of the source observation (e.g. a lipemia measure target from a plasma measure).
241         */
242        QUALIFIEDBY, 
243        /**
244         * The value of the target observation interferes (degrades quality, or prevents valid observation) with the semantics of the source observation (e.g. a hemolysis measure target from a plasma potassium measure which has no value).
245         */
246        INTERFEREDBY, 
247        /**
248         * added to help the parsers
249         */
250        NULL;
251        public static ObservationRelationshipType fromCode(String codeString) throws FHIRException {
252            if (codeString == null || "".equals(codeString))
253                return null;
254        if ("has-member".equals(codeString))
255          return HASMEMBER;
256        if ("derived-from".equals(codeString))
257          return DERIVEDFROM;
258        if ("sequel-to".equals(codeString))
259          return SEQUELTO;
260        if ("replaces".equals(codeString))
261          return REPLACES;
262        if ("qualified-by".equals(codeString))
263          return QUALIFIEDBY;
264        if ("interfered-by".equals(codeString))
265          return INTERFEREDBY;
266        throw new FHIRException("Unknown ObservationRelationshipType code '"+codeString+"'");
267        }
268        public String toCode() {
269          switch (this) {
270            case HASMEMBER: return "has-member";
271            case DERIVEDFROM: return "derived-from";
272            case SEQUELTO: return "sequel-to";
273            case REPLACES: return "replaces";
274            case QUALIFIEDBY: return "qualified-by";
275            case INTERFEREDBY: return "interfered-by";
276            case NULL: return null;
277            default: return "?";
278          }
279        }
280        public String getSystem() {
281          switch (this) {
282            case HASMEMBER: return "http://hl7.org/fhir/observation-relationshiptypes";
283            case DERIVEDFROM: return "http://hl7.org/fhir/observation-relationshiptypes";
284            case SEQUELTO: return "http://hl7.org/fhir/observation-relationshiptypes";
285            case REPLACES: return "http://hl7.org/fhir/observation-relationshiptypes";
286            case QUALIFIEDBY: return "http://hl7.org/fhir/observation-relationshiptypes";
287            case INTERFEREDBY: return "http://hl7.org/fhir/observation-relationshiptypes";
288            case NULL: return null;
289            default: return "?";
290          }
291        }
292        public String getDefinition() {
293          switch (this) {
294            case HASMEMBER: return "This observation is a group observation (e.g. a battery, a panel of tests, a set of vital sign measurements) that includes the target as a member of the group.";
295            case DERIVEDFROM: return "The target resource (Observation or QuestionnaireResponse) is part of the information from which this observation value is derived. (e.g. calculated anion gap, Apgar score)  NOTE:  \"derived-from\" is only logical choice when referencing QuestionnaireResponse.";
296            case SEQUELTO: return "This observation follows the target observation (e.g. timed tests such as Glucose Tolerance Test).";
297            case REPLACES: return "This observation replaces a previous observation (i.e. a revised value). The target observation is now obsolete.";
298            case QUALIFIEDBY: return "The value of the target observation qualifies (refines) the semantics of the source observation (e.g. a lipemia measure target from a plasma measure).";
299            case INTERFEREDBY: return "The value of the target observation interferes (degrades quality, or prevents valid observation) with the semantics of the source observation (e.g. a hemolysis measure target from a plasma potassium measure which has no value).";
300            case NULL: return null;
301            default: return "?";
302          }
303        }
304        public String getDisplay() {
305          switch (this) {
306            case HASMEMBER: return "Has Member";
307            case DERIVEDFROM: return "Derived From";
308            case SEQUELTO: return "Sequel To";
309            case REPLACES: return "Replaces";
310            case QUALIFIEDBY: return "Qualified By";
311            case INTERFEREDBY: return "Interfered By";
312            case NULL: return null;
313            default: return "?";
314          }
315        }
316    }
317
318  public static class ObservationRelationshipTypeEnumFactory implements EnumFactory<ObservationRelationshipType> {
319    public ObservationRelationshipType fromCode(String codeString) throws IllegalArgumentException {
320      if (codeString == null || "".equals(codeString))
321            if (codeString == null || "".equals(codeString))
322                return null;
323        if ("has-member".equals(codeString))
324          return ObservationRelationshipType.HASMEMBER;
325        if ("derived-from".equals(codeString))
326          return ObservationRelationshipType.DERIVEDFROM;
327        if ("sequel-to".equals(codeString))
328          return ObservationRelationshipType.SEQUELTO;
329        if ("replaces".equals(codeString))
330          return ObservationRelationshipType.REPLACES;
331        if ("qualified-by".equals(codeString))
332          return ObservationRelationshipType.QUALIFIEDBY;
333        if ("interfered-by".equals(codeString))
334          return ObservationRelationshipType.INTERFEREDBY;
335        throw new IllegalArgumentException("Unknown ObservationRelationshipType code '"+codeString+"'");
336        }
337        public Enumeration<ObservationRelationshipType> fromType(Base code) throws FHIRException {
338          if (code == null || code.isEmpty())
339            return null;
340          String codeString = ((PrimitiveType) code).asStringValue();
341          if (codeString == null || "".equals(codeString))
342            return null;
343        if ("has-member".equals(codeString))
344          return new Enumeration<ObservationRelationshipType>(this, ObservationRelationshipType.HASMEMBER);
345        if ("derived-from".equals(codeString))
346          return new Enumeration<ObservationRelationshipType>(this, ObservationRelationshipType.DERIVEDFROM);
347        if ("sequel-to".equals(codeString))
348          return new Enumeration<ObservationRelationshipType>(this, ObservationRelationshipType.SEQUELTO);
349        if ("replaces".equals(codeString))
350          return new Enumeration<ObservationRelationshipType>(this, ObservationRelationshipType.REPLACES);
351        if ("qualified-by".equals(codeString))
352          return new Enumeration<ObservationRelationshipType>(this, ObservationRelationshipType.QUALIFIEDBY);
353        if ("interfered-by".equals(codeString))
354          return new Enumeration<ObservationRelationshipType>(this, ObservationRelationshipType.INTERFEREDBY);
355        throw new FHIRException("Unknown ObservationRelationshipType code '"+codeString+"'");
356        }
357    public String toCode(ObservationRelationshipType code) {
358      if (code == ObservationRelationshipType.HASMEMBER)
359        return "has-member";
360      if (code == ObservationRelationshipType.DERIVEDFROM)
361        return "derived-from";
362      if (code == ObservationRelationshipType.SEQUELTO)
363        return "sequel-to";
364      if (code == ObservationRelationshipType.REPLACES)
365        return "replaces";
366      if (code == ObservationRelationshipType.QUALIFIEDBY)
367        return "qualified-by";
368      if (code == ObservationRelationshipType.INTERFEREDBY)
369        return "interfered-by";
370      return "?";
371      }
372    }
373
374    @Block()
375    public static class ObservationReferenceRangeComponent extends BackboneElement implements IBaseBackboneElement {
376        /**
377         * The value of the low bound of the reference range.  The low bound of the reference range endpoint is inclusive of the value (e.g.  reference range is >=5 - <=9).   If the low bound is omitted,  it is assumed to be meaningless (e.g. reference range is <=2.3).
378         */
379        @Child(name = "low", type = {SimpleQuantity.class}, order=1, min=0, max=1, modifier=false, summary=false)
380        @Description(shortDefinition="Low Range, if relevant", formalDefinition="The value of the low bound of the reference range.  The low bound of the reference range endpoint is inclusive of the value (e.g.  reference range is >=5 - <=9).   If the low bound is omitted,  it is assumed to be meaningless (e.g. reference range is <=2.3)." )
381        protected SimpleQuantity low;
382
383        /**
384         * The value of the high bound of the reference range.  The high bound of the reference range endpoint is inclusive of the value (e.g.  reference range is >=5 - <=9).   If the high bound is omitted,  it is assumed to be meaningless (e.g. reference range is >= 2.3).
385         */
386        @Child(name = "high", type = {SimpleQuantity.class}, order=2, min=0, max=1, modifier=false, summary=false)
387        @Description(shortDefinition="High Range, if relevant", formalDefinition="The value of the high bound of the reference range.  The high bound of the reference range endpoint is inclusive of the value (e.g.  reference range is >=5 - <=9).   If the high bound is omitted,  it is assumed to be meaningless (e.g. reference range is >= 2.3)." )
388        protected SimpleQuantity high;
389
390        /**
391         * Code for the meaning of the reference range.
392         */
393        @Child(name = "meaning", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=false)
394        @Description(shortDefinition="Indicates the meaning/use of this range of this range", formalDefinition="Code for the meaning of the reference range." )
395        protected CodeableConcept meaning;
396
397        /**
398         * 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.
399         */
400        @Child(name = "age", type = {Range.class}, order=4, min=0, max=1, modifier=false, summary=false)
401        @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." )
402        protected Range age;
403
404        /**
405         * Text based reference range in an observation which may be used when a quantitative range is not appropriate for an observation.  An example would be a reference value of "Negative" or a list or table of 'normals'.
406         */
407        @Child(name = "text", type = {StringType.class}, order=5, min=0, max=1, modifier=false, summary=false)
408        @Description(shortDefinition="Text based reference range in an observation", formalDefinition="Text based reference range in an observation which may be used when a quantitative range is not appropriate for an observation.  An example would be a reference value of \"Negative\" or a list or table of 'normals'." )
409        protected StringType text;
410
411        private static final long serialVersionUID = -238694788L;
412
413    /*
414     * Constructor
415     */
416      public ObservationReferenceRangeComponent() {
417        super();
418      }
419
420        /**
421         * @return {@link #low} (The value of the low bound of the reference range.  The low bound of the reference range endpoint is inclusive of the value (e.g.  reference range is >=5 - <=9).   If the low bound is omitted,  it is assumed to be meaningless (e.g. reference range is <=2.3).)
422         */
423        public SimpleQuantity getLow() { 
424          if (this.low == null)
425            if (Configuration.errorOnAutoCreate())
426              throw new Error("Attempt to auto-create ObservationReferenceRangeComponent.low");
427            else if (Configuration.doAutoCreate())
428              this.low = new SimpleQuantity(); // cc
429          return this.low;
430        }
431
432        public boolean hasLow() { 
433          return this.low != null && !this.low.isEmpty();
434        }
435
436        /**
437         * @param value {@link #low} (The value of the low bound of the reference range.  The low bound of the reference range endpoint is inclusive of the value (e.g.  reference range is >=5 - <=9).   If the low bound is omitted,  it is assumed to be meaningless (e.g. reference range is <=2.3).)
438         */
439        public ObservationReferenceRangeComponent setLow(SimpleQuantity value) { 
440          this.low = value;
441          return this;
442        }
443
444        /**
445         * @return {@link #high} (The value of the high bound of the reference range.  The high bound of the reference range endpoint is inclusive of the value (e.g.  reference range is >=5 - <=9).   If the high bound is omitted,  it is assumed to be meaningless (e.g. reference range is >= 2.3).)
446         */
447        public SimpleQuantity getHigh() { 
448          if (this.high == null)
449            if (Configuration.errorOnAutoCreate())
450              throw new Error("Attempt to auto-create ObservationReferenceRangeComponent.high");
451            else if (Configuration.doAutoCreate())
452              this.high = new SimpleQuantity(); // cc
453          return this.high;
454        }
455
456        public boolean hasHigh() { 
457          return this.high != null && !this.high.isEmpty();
458        }
459
460        /**
461         * @param value {@link #high} (The value of the high bound of the reference range.  The high bound of the reference range endpoint is inclusive of the value (e.g.  reference range is >=5 - <=9).   If the high bound is omitted,  it is assumed to be meaningless (e.g. reference range is >= 2.3).)
462         */
463        public ObservationReferenceRangeComponent setHigh(SimpleQuantity value) { 
464          this.high = value;
465          return this;
466        }
467
468        /**
469         * @return {@link #meaning} (Code for the meaning of the reference range.)
470         */
471        public CodeableConcept getMeaning() { 
472          if (this.meaning == null)
473            if (Configuration.errorOnAutoCreate())
474              throw new Error("Attempt to auto-create ObservationReferenceRangeComponent.meaning");
475            else if (Configuration.doAutoCreate())
476              this.meaning = new CodeableConcept(); // cc
477          return this.meaning;
478        }
479
480        public boolean hasMeaning() { 
481          return this.meaning != null && !this.meaning.isEmpty();
482        }
483
484        /**
485         * @param value {@link #meaning} (Code for the meaning of the reference range.)
486         */
487        public ObservationReferenceRangeComponent setMeaning(CodeableConcept value) { 
488          this.meaning = value;
489          return this;
490        }
491
492        /**
493         * @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.)
494         */
495        public Range getAge() { 
496          if (this.age == null)
497            if (Configuration.errorOnAutoCreate())
498              throw new Error("Attempt to auto-create ObservationReferenceRangeComponent.age");
499            else if (Configuration.doAutoCreate())
500              this.age = new Range(); // cc
501          return this.age;
502        }
503
504        public boolean hasAge() { 
505          return this.age != null && !this.age.isEmpty();
506        }
507
508        /**
509         * @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.)
510         */
511        public ObservationReferenceRangeComponent setAge(Range value) { 
512          this.age = value;
513          return this;
514        }
515
516        /**
517         * @return {@link #text} (Text based reference range in an observation which may be used when a quantitative range is not appropriate for an observation.  An example would be a reference value of "Negative" or a list or table of 'normals'.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value
518         */
519        public StringType getTextElement() { 
520          if (this.text == null)
521            if (Configuration.errorOnAutoCreate())
522              throw new Error("Attempt to auto-create ObservationReferenceRangeComponent.text");
523            else if (Configuration.doAutoCreate())
524              this.text = new StringType(); // bb
525          return this.text;
526        }
527
528        public boolean hasTextElement() { 
529          return this.text != null && !this.text.isEmpty();
530        }
531
532        public boolean hasText() { 
533          return this.text != null && !this.text.isEmpty();
534        }
535
536        /**
537         * @param value {@link #text} (Text based reference range in an observation which may be used when a quantitative range is not appropriate for an observation.  An example would be a reference value of "Negative" or a list or table of 'normals'.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value
538         */
539        public ObservationReferenceRangeComponent setTextElement(StringType value) { 
540          this.text = value;
541          return this;
542        }
543
544        /**
545         * @return Text based reference range in an observation which may be used when a quantitative range is not appropriate for an observation.  An example would be a reference value of "Negative" or a list or table of 'normals'.
546         */
547        public String getText() { 
548          return this.text == null ? null : this.text.getValue();
549        }
550
551        /**
552         * @param value Text based reference range in an observation which may be used when a quantitative range is not appropriate for an observation.  An example would be a reference value of "Negative" or a list or table of 'normals'.
553         */
554        public ObservationReferenceRangeComponent setText(String value) { 
555          if (Utilities.noString(value))
556            this.text = null;
557          else {
558            if (this.text == null)
559              this.text = new StringType();
560            this.text.setValue(value);
561          }
562          return this;
563        }
564
565        protected void listChildren(List<Property> childrenList) {
566          super.listChildren(childrenList);
567          childrenList.add(new Property("low", "SimpleQuantity", "The value of the low bound of the reference range.  The low bound of the reference range endpoint is inclusive of the value (e.g.  reference range is >=5 - <=9).   If the low bound is omitted,  it is assumed to be meaningless (e.g. reference range is <=2.3).", 0, java.lang.Integer.MAX_VALUE, low));
568          childrenList.add(new Property("high", "SimpleQuantity", "The value of the high bound of the reference range.  The high bound of the reference range endpoint is inclusive of the value (e.g.  reference range is >=5 - <=9).   If the high bound is omitted,  it is assumed to be meaningless (e.g. reference range is >= 2.3).", 0, java.lang.Integer.MAX_VALUE, high));
569          childrenList.add(new Property("meaning", "CodeableConcept", "Code for the meaning of the reference range.", 0, java.lang.Integer.MAX_VALUE, meaning));
570          childrenList.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, java.lang.Integer.MAX_VALUE, age));
571          childrenList.add(new Property("text", "string", "Text based reference range in an observation which may be used when a quantitative range is not appropriate for an observation.  An example would be a reference value of \"Negative\" or a list or table of 'normals'.", 0, java.lang.Integer.MAX_VALUE, text));
572        }
573
574      @Override
575      public void setProperty(String name, Base value) throws FHIRException {
576        if (name.equals("low"))
577          this.low = castToSimpleQuantity(value); // SimpleQuantity
578        else if (name.equals("high"))
579          this.high = castToSimpleQuantity(value); // SimpleQuantity
580        else if (name.equals("meaning"))
581          this.meaning = castToCodeableConcept(value); // CodeableConcept
582        else if (name.equals("age"))
583          this.age = castToRange(value); // Range
584        else if (name.equals("text"))
585          this.text = castToString(value); // StringType
586        else
587          super.setProperty(name, value);
588      }
589
590      @Override
591      public Base addChild(String name) throws FHIRException {
592        if (name.equals("low")) {
593          this.low = new SimpleQuantity();
594          return this.low;
595        }
596        else if (name.equals("high")) {
597          this.high = new SimpleQuantity();
598          return this.high;
599        }
600        else if (name.equals("meaning")) {
601          this.meaning = new CodeableConcept();
602          return this.meaning;
603        }
604        else if (name.equals("age")) {
605          this.age = new Range();
606          return this.age;
607        }
608        else if (name.equals("text")) {
609          throw new FHIRException("Cannot call addChild on a primitive type Observation.text");
610        }
611        else
612          return super.addChild(name);
613      }
614
615      public ObservationReferenceRangeComponent copy() {
616        ObservationReferenceRangeComponent dst = new ObservationReferenceRangeComponent();
617        copyValues(dst);
618        dst.low = low == null ? null : low.copy();
619        dst.high = high == null ? null : high.copy();
620        dst.meaning = meaning == null ? null : meaning.copy();
621        dst.age = age == null ? null : age.copy();
622        dst.text = text == null ? null : text.copy();
623        return dst;
624      }
625
626      @Override
627      public boolean equalsDeep(Base other) {
628        if (!super.equalsDeep(other))
629          return false;
630        if (!(other instanceof ObservationReferenceRangeComponent))
631          return false;
632        ObservationReferenceRangeComponent o = (ObservationReferenceRangeComponent) other;
633        return compareDeep(low, o.low, true) && compareDeep(high, o.high, true) && compareDeep(meaning, o.meaning, true)
634           && compareDeep(age, o.age, true) && compareDeep(text, o.text, true);
635      }
636
637      @Override
638      public boolean equalsShallow(Base other) {
639        if (!super.equalsShallow(other))
640          return false;
641        if (!(other instanceof ObservationReferenceRangeComponent))
642          return false;
643        ObservationReferenceRangeComponent o = (ObservationReferenceRangeComponent) other;
644        return compareValues(text, o.text, true);
645      }
646
647      public boolean isEmpty() {
648        return super.isEmpty() && (low == null || low.isEmpty()) && (high == null || high.isEmpty())
649           && (meaning == null || meaning.isEmpty()) && (age == null || age.isEmpty()) && (text == null || text.isEmpty())
650          ;
651      }
652
653  public String fhirType() {
654    return "Observation.referenceRange";
655
656  }
657
658  }
659
660    @Block()
661    public static class ObservationRelatedComponent extends BackboneElement implements IBaseBackboneElement {
662        /**
663         * A code specifying the kind of relationship that exists with the target resource.
664         */
665        @Child(name = "type", type = {CodeType.class}, order=1, min=0, max=1, modifier=false, summary=false)
666        @Description(shortDefinition="has-member | derived-from | sequel-to | replaces | qualified-by | interfered-by", formalDefinition="A code specifying the kind of relationship that exists with the target resource." )
667        protected Enumeration<ObservationRelationshipType> type;
668
669        /**
670         * A reference to the observation or [[[QuestionnaireResponse]]] resource that is related to this observation.
671         */
672        @Child(name = "target", type = {Observation.class, QuestionnaireResponse.class}, order=2, min=1, max=1, modifier=false, summary=false)
673        @Description(shortDefinition="Resource that is related to this one", formalDefinition="A reference to the observation or [[[QuestionnaireResponse]]] resource that is related to this observation." )
674        protected Reference target;
675
676        /**
677         * The actual object that is the target of the reference (A reference to the observation or [[[QuestionnaireResponse]]] resource that is related to this observation.)
678         */
679        protected Resource targetTarget;
680
681        private static final long serialVersionUID = 1541802577L;
682
683    /*
684     * Constructor
685     */
686      public ObservationRelatedComponent() {
687        super();
688      }
689
690    /*
691     * Constructor
692     */
693      public ObservationRelatedComponent(Reference target) {
694        super();
695        this.target = target;
696      }
697
698        /**
699         * @return {@link #type} (A code specifying the kind of relationship that exists with the target resource.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
700         */
701        public Enumeration<ObservationRelationshipType> getTypeElement() { 
702          if (this.type == null)
703            if (Configuration.errorOnAutoCreate())
704              throw new Error("Attempt to auto-create ObservationRelatedComponent.type");
705            else if (Configuration.doAutoCreate())
706              this.type = new Enumeration<ObservationRelationshipType>(new ObservationRelationshipTypeEnumFactory()); // bb
707          return this.type;
708        }
709
710        public boolean hasTypeElement() { 
711          return this.type != null && !this.type.isEmpty();
712        }
713
714        public boolean hasType() { 
715          return this.type != null && !this.type.isEmpty();
716        }
717
718        /**
719         * @param value {@link #type} (A code specifying the kind of relationship that exists with the target resource.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
720         */
721        public ObservationRelatedComponent setTypeElement(Enumeration<ObservationRelationshipType> value) { 
722          this.type = value;
723          return this;
724        }
725
726        /**
727         * @return A code specifying the kind of relationship that exists with the target resource.
728         */
729        public ObservationRelationshipType getType() { 
730          return this.type == null ? null : this.type.getValue();
731        }
732
733        /**
734         * @param value A code specifying the kind of relationship that exists with the target resource.
735         */
736        public ObservationRelatedComponent setType(ObservationRelationshipType value) { 
737          if (value == null)
738            this.type = null;
739          else {
740            if (this.type == null)
741              this.type = new Enumeration<ObservationRelationshipType>(new ObservationRelationshipTypeEnumFactory());
742            this.type.setValue(value);
743          }
744          return this;
745        }
746
747        /**
748         * @return {@link #target} (A reference to the observation or [[[QuestionnaireResponse]]] resource that is related to this observation.)
749         */
750        public Reference getTarget() { 
751          if (this.target == null)
752            if (Configuration.errorOnAutoCreate())
753              throw new Error("Attempt to auto-create ObservationRelatedComponent.target");
754            else if (Configuration.doAutoCreate())
755              this.target = new Reference(); // cc
756          return this.target;
757        }
758
759        public boolean hasTarget() { 
760          return this.target != null && !this.target.isEmpty();
761        }
762
763        /**
764         * @param value {@link #target} (A reference to the observation or [[[QuestionnaireResponse]]] resource that is related to this observation.)
765         */
766        public ObservationRelatedComponent setTarget(Reference value) { 
767          this.target = value;
768          return this;
769        }
770
771        /**
772         * @return {@link #target} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (A reference to the observation or [[[QuestionnaireResponse]]] resource that is related to this observation.)
773         */
774        public Resource getTargetTarget() { 
775          return this.targetTarget;
776        }
777
778        /**
779         * @param value {@link #target} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (A reference to the observation or [[[QuestionnaireResponse]]] resource that is related to this observation.)
780         */
781        public ObservationRelatedComponent setTargetTarget(Resource value) { 
782          this.targetTarget = value;
783          return this;
784        }
785
786        protected void listChildren(List<Property> childrenList) {
787          super.listChildren(childrenList);
788          childrenList.add(new Property("type", "code", "A code specifying the kind of relationship that exists with the target resource.", 0, java.lang.Integer.MAX_VALUE, type));
789          childrenList.add(new Property("target", "Reference(Observation|QuestionnaireResponse)", "A reference to the observation or [[[QuestionnaireResponse]]] resource that is related to this observation.", 0, java.lang.Integer.MAX_VALUE, target));
790        }
791
792      @Override
793      public void setProperty(String name, Base value) throws FHIRException {
794        if (name.equals("type"))
795          this.type = new ObservationRelationshipTypeEnumFactory().fromType(value); // Enumeration<ObservationRelationshipType>
796        else if (name.equals("target"))
797          this.target = castToReference(value); // Reference
798        else
799          super.setProperty(name, value);
800      }
801
802      @Override
803      public Base addChild(String name) throws FHIRException {
804        if (name.equals("type")) {
805          throw new FHIRException("Cannot call addChild on a primitive type Observation.type");
806        }
807        else if (name.equals("target")) {
808          this.target = new Reference();
809          return this.target;
810        }
811        else
812          return super.addChild(name);
813      }
814
815      public ObservationRelatedComponent copy() {
816        ObservationRelatedComponent dst = new ObservationRelatedComponent();
817        copyValues(dst);
818        dst.type = type == null ? null : type.copy();
819        dst.target = target == null ? null : target.copy();
820        return dst;
821      }
822
823      @Override
824      public boolean equalsDeep(Base other) {
825        if (!super.equalsDeep(other))
826          return false;
827        if (!(other instanceof ObservationRelatedComponent))
828          return false;
829        ObservationRelatedComponent o = (ObservationRelatedComponent) other;
830        return compareDeep(type, o.type, true) && compareDeep(target, o.target, true);
831      }
832
833      @Override
834      public boolean equalsShallow(Base other) {
835        if (!super.equalsShallow(other))
836          return false;
837        if (!(other instanceof ObservationRelatedComponent))
838          return false;
839        ObservationRelatedComponent o = (ObservationRelatedComponent) other;
840        return compareValues(type, o.type, true);
841      }
842
843      public boolean isEmpty() {
844        return super.isEmpty() && (type == null || type.isEmpty()) && (target == null || target.isEmpty())
845          ;
846      }
847
848  public String fhirType() {
849    return "Observation.related";
850
851  }
852
853  }
854
855    @Block()
856    public static class ObservationComponentComponent extends BackboneElement implements IBaseBackboneElement {
857        /**
858         * Describes what was observed. Sometimes this is called the observation "code".
859         */
860        @Child(name = "code", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=true)
861        @Description(shortDefinition="Type of component observation (code / type)", formalDefinition="Describes what was observed. Sometimes this is called the observation \"code\"." )
862        protected CodeableConcept code;
863
864        /**
865         * The information determined as a result of making the observation, if the information has a simple value.
866         */
867        @Child(name = "value", type = {Quantity.class, CodeableConcept.class, StringType.class, Range.class, Ratio.class, SampledData.class, Attachment.class, TimeType.class, DateTimeType.class, Period.class}, order=2, min=0, max=1, modifier=false, summary=true)
868        @Description(shortDefinition="Actual component result", formalDefinition="The information determined as a result of making the observation, if the information has a simple value." )
869        protected Type value;
870
871        /**
872         * Provides a reason why the expected value in the element Observation.value[x] is missing.
873         */
874        @Child(name = "dataAbsentReason", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=false)
875        @Description(shortDefinition="Why the component result is missing", formalDefinition="Provides a reason why the expected value in the element Observation.value[x] is missing." )
876        protected CodeableConcept dataAbsentReason;
877
878        /**
879         * Guidance on how to interpret the value by comparison to a normal or recommended range.
880         */
881        @Child(name = "referenceRange", type = {ObservationReferenceRangeComponent.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
882        @Description(shortDefinition="Provides guide for interpretation of component result", formalDefinition="Guidance on how to interpret the value by comparison to a normal or recommended range." )
883        protected List<ObservationReferenceRangeComponent> referenceRange;
884
885        private static final long serialVersionUID = 946602904L;
886
887    /*
888     * Constructor
889     */
890      public ObservationComponentComponent() {
891        super();
892      }
893
894    /*
895     * Constructor
896     */
897      public ObservationComponentComponent(CodeableConcept code) {
898        super();
899        this.code = code;
900      }
901
902        /**
903         * @return {@link #code} (Describes what was observed. Sometimes this is called the observation "code".)
904         */
905        public CodeableConcept getCode() { 
906          if (this.code == null)
907            if (Configuration.errorOnAutoCreate())
908              throw new Error("Attempt to auto-create ObservationComponentComponent.code");
909            else if (Configuration.doAutoCreate())
910              this.code = new CodeableConcept(); // cc
911          return this.code;
912        }
913
914        public boolean hasCode() { 
915          return this.code != null && !this.code.isEmpty();
916        }
917
918        /**
919         * @param value {@link #code} (Describes what was observed. Sometimes this is called the observation "code".)
920         */
921        public ObservationComponentComponent setCode(CodeableConcept value) { 
922          this.code = value;
923          return this;
924        }
925
926        /**
927         * @return {@link #value} (The information determined as a result of making the observation, if the information has a simple value.)
928         */
929        public Type getValue() { 
930          return this.value;
931        }
932
933        /**
934         * @return {@link #value} (The information determined as a result of making the observation, if the information has a simple value.)
935         */
936        public Quantity getValueQuantity() throws FHIRException { 
937          if (!(this.value instanceof Quantity))
938            throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.value.getClass().getName()+" was encountered");
939          return (Quantity) this.value;
940        }
941
942        public boolean hasValueQuantity() { 
943          return this.value instanceof Quantity;
944        }
945
946        /**
947         * @return {@link #value} (The information determined as a result of making the observation, if the information has a simple value.)
948         */
949        public CodeableConcept getValueCodeableConcept() throws FHIRException { 
950          if (!(this.value instanceof CodeableConcept))
951            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.value.getClass().getName()+" was encountered");
952          return (CodeableConcept) this.value;
953        }
954
955        public boolean hasValueCodeableConcept() { 
956          return this.value instanceof CodeableConcept;
957        }
958
959        /**
960         * @return {@link #value} (The information determined as a result of making the observation, if the information has a simple value.)
961         */
962        public StringType getValueStringType() throws FHIRException { 
963          if (!(this.value instanceof StringType))
964            throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.value.getClass().getName()+" was encountered");
965          return (StringType) this.value;
966        }
967
968        public boolean hasValueStringType() { 
969          return this.value instanceof StringType;
970        }
971
972        /**
973         * @return {@link #value} (The information determined as a result of making the observation, if the information has a simple value.)
974         */
975        public Range getValueRange() throws FHIRException { 
976          if (!(this.value instanceof Range))
977            throw new FHIRException("Type mismatch: the type Range was expected, but "+this.value.getClass().getName()+" was encountered");
978          return (Range) this.value;
979        }
980
981        public boolean hasValueRange() { 
982          return this.value instanceof Range;
983        }
984
985        /**
986         * @return {@link #value} (The information determined as a result of making the observation, if the information has a simple value.)
987         */
988        public Ratio getValueRatio() throws FHIRException { 
989          if (!(this.value instanceof Ratio))
990            throw new FHIRException("Type mismatch: the type Ratio was expected, but "+this.value.getClass().getName()+" was encountered");
991          return (Ratio) this.value;
992        }
993
994        public boolean hasValueRatio() { 
995          return this.value instanceof Ratio;
996        }
997
998        /**
999         * @return {@link #value} (The information determined as a result of making the observation, if the information has a simple value.)
1000         */
1001        public SampledData getValueSampledData() throws FHIRException { 
1002          if (!(this.value instanceof SampledData))
1003            throw new FHIRException("Type mismatch: the type SampledData was expected, but "+this.value.getClass().getName()+" was encountered");
1004          return (SampledData) this.value;
1005        }
1006
1007        public boolean hasValueSampledData() { 
1008          return this.value instanceof SampledData;
1009        }
1010
1011        /**
1012         * @return {@link #value} (The information determined as a result of making the observation, if the information has a simple value.)
1013         */
1014        public Attachment getValueAttachment() throws FHIRException { 
1015          if (!(this.value instanceof Attachment))
1016            throw new FHIRException("Type mismatch: the type Attachment was expected, but "+this.value.getClass().getName()+" was encountered");
1017          return (Attachment) this.value;
1018        }
1019
1020        public boolean hasValueAttachment() { 
1021          return this.value instanceof Attachment;
1022        }
1023
1024        /**
1025         * @return {@link #value} (The information determined as a result of making the observation, if the information has a simple value.)
1026         */
1027        public TimeType getValueTimeType() throws FHIRException { 
1028          if (!(this.value instanceof TimeType))
1029            throw new FHIRException("Type mismatch: the type TimeType was expected, but "+this.value.getClass().getName()+" was encountered");
1030          return (TimeType) this.value;
1031        }
1032
1033        public boolean hasValueTimeType() { 
1034          return this.value instanceof TimeType;
1035        }
1036
1037        /**
1038         * @return {@link #value} (The information determined as a result of making the observation, if the information has a simple value.)
1039         */
1040        public DateTimeType getValueDateTimeType() throws FHIRException { 
1041          if (!(this.value instanceof DateTimeType))
1042            throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.value.getClass().getName()+" was encountered");
1043          return (DateTimeType) this.value;
1044        }
1045
1046        public boolean hasValueDateTimeType() { 
1047          return this.value instanceof DateTimeType;
1048        }
1049
1050        /**
1051         * @return {@link #value} (The information determined as a result of making the observation, if the information has a simple value.)
1052         */
1053        public Period getValuePeriod() throws FHIRException { 
1054          if (!(this.value instanceof Period))
1055            throw new FHIRException("Type mismatch: the type Period was expected, but "+this.value.getClass().getName()+" was encountered");
1056          return (Period) this.value;
1057        }
1058
1059        public boolean hasValuePeriod() { 
1060          return this.value instanceof Period;
1061        }
1062
1063        public boolean hasValue() { 
1064          return this.value != null && !this.value.isEmpty();
1065        }
1066
1067        /**
1068         * @param value {@link #value} (The information determined as a result of making the observation, if the information has a simple value.)
1069         */
1070        public ObservationComponentComponent setValue(Type value) { 
1071          this.value = value;
1072          return this;
1073        }
1074
1075        /**
1076         * @return {@link #dataAbsentReason} (Provides a reason why the expected value in the element Observation.value[x] is missing.)
1077         */
1078        public CodeableConcept getDataAbsentReason() { 
1079          if (this.dataAbsentReason == null)
1080            if (Configuration.errorOnAutoCreate())
1081              throw new Error("Attempt to auto-create ObservationComponentComponent.dataAbsentReason");
1082            else if (Configuration.doAutoCreate())
1083              this.dataAbsentReason = new CodeableConcept(); // cc
1084          return this.dataAbsentReason;
1085        }
1086
1087        public boolean hasDataAbsentReason() { 
1088          return this.dataAbsentReason != null && !this.dataAbsentReason.isEmpty();
1089        }
1090
1091        /**
1092         * @param value {@link #dataAbsentReason} (Provides a reason why the expected value in the element Observation.value[x] is missing.)
1093         */
1094        public ObservationComponentComponent setDataAbsentReason(CodeableConcept value) { 
1095          this.dataAbsentReason = value;
1096          return this;
1097        }
1098
1099        /**
1100         * @return {@link #referenceRange} (Guidance on how to interpret the value by comparison to a normal or recommended range.)
1101         */
1102        public List<ObservationReferenceRangeComponent> getReferenceRange() { 
1103          if (this.referenceRange == null)
1104            this.referenceRange = new ArrayList<ObservationReferenceRangeComponent>();
1105          return this.referenceRange;
1106        }
1107
1108        public boolean hasReferenceRange() { 
1109          if (this.referenceRange == null)
1110            return false;
1111          for (ObservationReferenceRangeComponent item : this.referenceRange)
1112            if (!item.isEmpty())
1113              return true;
1114          return false;
1115        }
1116
1117        /**
1118         * @return {@link #referenceRange} (Guidance on how to interpret the value by comparison to a normal or recommended range.)
1119         */
1120    // syntactic sugar
1121        public ObservationReferenceRangeComponent addReferenceRange() { //3
1122          ObservationReferenceRangeComponent t = new ObservationReferenceRangeComponent();
1123          if (this.referenceRange == null)
1124            this.referenceRange = new ArrayList<ObservationReferenceRangeComponent>();
1125          this.referenceRange.add(t);
1126          return t;
1127        }
1128
1129    // syntactic sugar
1130        public ObservationComponentComponent addReferenceRange(ObservationReferenceRangeComponent t) { //3
1131          if (t == null)
1132            return this;
1133          if (this.referenceRange == null)
1134            this.referenceRange = new ArrayList<ObservationReferenceRangeComponent>();
1135          this.referenceRange.add(t);
1136          return this;
1137        }
1138
1139        protected void listChildren(List<Property> childrenList) {
1140          super.listChildren(childrenList);
1141          childrenList.add(new Property("code", "CodeableConcept", "Describes what was observed. Sometimes this is called the observation \"code\".", 0, java.lang.Integer.MAX_VALUE, code));
1142          childrenList.add(new Property("value[x]", "Quantity|CodeableConcept|string|Range|Ratio|SampledData|Attachment|time|dateTime|Period", "The information determined as a result of making the observation, if the information has a simple value.", 0, java.lang.Integer.MAX_VALUE, value));
1143          childrenList.add(new Property("dataAbsentReason", "CodeableConcept", "Provides a reason why the expected value in the element Observation.value[x] is missing.", 0, java.lang.Integer.MAX_VALUE, dataAbsentReason));
1144          childrenList.add(new Property("referenceRange", "@Observation.referenceRange", "Guidance on how to interpret the value by comparison to a normal or recommended range.", 0, java.lang.Integer.MAX_VALUE, referenceRange));
1145        }
1146
1147      @Override
1148      public void setProperty(String name, Base value) throws FHIRException {
1149        if (name.equals("code"))
1150          this.code = castToCodeableConcept(value); // CodeableConcept
1151        else if (name.equals("value[x]"))
1152          this.value = (Type) value; // Type
1153        else if (name.equals("dataAbsentReason"))
1154          this.dataAbsentReason = castToCodeableConcept(value); // CodeableConcept
1155        else if (name.equals("referenceRange"))
1156          this.getReferenceRange().add((ObservationReferenceRangeComponent) value);
1157        else
1158          super.setProperty(name, value);
1159      }
1160
1161      @Override
1162      public Base addChild(String name) throws FHIRException {
1163        if (name.equals("code")) {
1164          this.code = new CodeableConcept();
1165          return this.code;
1166        }
1167        else if (name.equals("valueQuantity")) {
1168          this.value = new Quantity();
1169          return this.value;
1170        }
1171        else if (name.equals("valueCodeableConcept")) {
1172          this.value = new CodeableConcept();
1173          return this.value;
1174        }
1175        else if (name.equals("valueString")) {
1176          this.value = new StringType();
1177          return this.value;
1178        }
1179        else if (name.equals("valueRange")) {
1180          this.value = new Range();
1181          return this.value;
1182        }
1183        else if (name.equals("valueRatio")) {
1184          this.value = new Ratio();
1185          return this.value;
1186        }
1187        else if (name.equals("valueSampledData")) {
1188          this.value = new SampledData();
1189          return this.value;
1190        }
1191        else if (name.equals("valueAttachment")) {
1192          this.value = new Attachment();
1193          return this.value;
1194        }
1195        else if (name.equals("valueTime")) {
1196          this.value = new TimeType();
1197          return this.value;
1198        }
1199        else if (name.equals("valueDateTime")) {
1200          this.value = new DateTimeType();
1201          return this.value;
1202        }
1203        else if (name.equals("valuePeriod")) {
1204          this.value = new Period();
1205          return this.value;
1206        }
1207        else if (name.equals("dataAbsentReason")) {
1208          this.dataAbsentReason = new CodeableConcept();
1209          return this.dataAbsentReason;
1210        }
1211        else if (name.equals("referenceRange")) {
1212          return addReferenceRange();
1213        }
1214        else
1215          return super.addChild(name);
1216      }
1217
1218      public ObservationComponentComponent copy() {
1219        ObservationComponentComponent dst = new ObservationComponentComponent();
1220        copyValues(dst);
1221        dst.code = code == null ? null : code.copy();
1222        dst.value = value == null ? null : value.copy();
1223        dst.dataAbsentReason = dataAbsentReason == null ? null : dataAbsentReason.copy();
1224        if (referenceRange != null) {
1225          dst.referenceRange = new ArrayList<ObservationReferenceRangeComponent>();
1226          for (ObservationReferenceRangeComponent i : referenceRange)
1227            dst.referenceRange.add(i.copy());
1228        };
1229        return dst;
1230      }
1231
1232      @Override
1233      public boolean equalsDeep(Base other) {
1234        if (!super.equalsDeep(other))
1235          return false;
1236        if (!(other instanceof ObservationComponentComponent))
1237          return false;
1238        ObservationComponentComponent o = (ObservationComponentComponent) other;
1239        return compareDeep(code, o.code, true) && compareDeep(value, o.value, true) && compareDeep(dataAbsentReason, o.dataAbsentReason, true)
1240           && compareDeep(referenceRange, o.referenceRange, true);
1241      }
1242
1243      @Override
1244      public boolean equalsShallow(Base other) {
1245        if (!super.equalsShallow(other))
1246          return false;
1247        if (!(other instanceof ObservationComponentComponent))
1248          return false;
1249        ObservationComponentComponent o = (ObservationComponentComponent) other;
1250        return true;
1251      }
1252
1253      public boolean isEmpty() {
1254        return super.isEmpty() && (code == null || code.isEmpty()) && (value == null || value.isEmpty())
1255           && (dataAbsentReason == null || dataAbsentReason.isEmpty()) && (referenceRange == null || referenceRange.isEmpty())
1256          ;
1257      }
1258
1259  public String fhirType() {
1260    return "Observation.component";
1261
1262  }
1263
1264  }
1265
1266    /**
1267     * A unique identifier for the simple observation instance.
1268     */
1269    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1270    @Description(shortDefinition="Unique Id for this particular observation", formalDefinition="A unique identifier for the simple observation instance." )
1271    protected List<Identifier> identifier;
1272
1273    /**
1274     * The status of the result value.
1275     */
1276    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
1277    @Description(shortDefinition="registered | preliminary | final | amended +", formalDefinition="The status of the result value." )
1278    protected Enumeration<ObservationStatus> status;
1279
1280    /**
1281     * A code that classifies the general type of observation being made.  This is used  for searching, sorting and display purposes.
1282     */
1283    @Child(name = "category", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
1284    @Description(shortDefinition="Classification of  type of observation", formalDefinition="A code that classifies the general type of observation being made.  This is used  for searching, sorting and display purposes." )
1285    protected CodeableConcept category;
1286
1287    /**
1288     * Describes what was observed. Sometimes this is called the observation "name".
1289     */
1290    @Child(name = "code", type = {CodeableConcept.class}, order=3, min=1, max=1, modifier=false, summary=true)
1291    @Description(shortDefinition="Type of observation (code / type)", formalDefinition="Describes what was observed. Sometimes this is called the observation \"name\"." )
1292    protected CodeableConcept code;
1293
1294    /**
1295     * The patient, or group of patients, location, or device whose characteristics (direct or indirect) are described by the observation and into whose record the observation is placed.  Comments: Indirect characteristics may be those of a specimen, fetus, donor,  other observer (for example a relative or EMT), or any observation made about the subject.
1296     */
1297    @Child(name = "subject", type = {Patient.class, Group.class, Device.class, Location.class}, order=4, min=0, max=1, modifier=false, summary=true)
1298    @Description(shortDefinition="Who and/or what this is about", formalDefinition="The patient, or group of patients, location, or device whose characteristics (direct or indirect) are described by the observation and into whose record the observation is placed.  Comments: Indirect characteristics may be those of a specimen, fetus, donor,  other observer (for example a relative or EMT), or any observation made about the subject." )
1299    protected Reference subject;
1300
1301    /**
1302     * The actual object that is the target of the reference (The patient, or group of patients, location, or device whose characteristics (direct or indirect) are described by the observation and into whose record the observation is placed.  Comments: Indirect characteristics may be those of a specimen, fetus, donor,  other observer (for example a relative or EMT), or any observation made about the subject.)
1303     */
1304    protected Resource subjectTarget;
1305
1306    /**
1307     * The healthcare event  (e.g. a patient and healthcare provider interaction) during which this observation is made.
1308     */
1309    @Child(name = "encounter", type = {Encounter.class}, order=5, min=0, max=1, modifier=false, summary=false)
1310    @Description(shortDefinition="Healthcare event during which this observation is made", formalDefinition="The healthcare event  (e.g. a patient and healthcare provider interaction) during which this observation is made." )
1311    protected Reference encounter;
1312
1313    /**
1314     * The actual object that is the target of the reference (The healthcare event  (e.g. a patient and healthcare provider interaction) during which this observation is made.)
1315     */
1316    protected Encounter encounterTarget;
1317
1318    /**
1319     * The time or time-period the observed value is asserted as being true. For biological subjects - e.g. human patients - this is usually called the "physiologically relevant time". This is usually either the time of the procedure or of specimen collection, but very often the source of the date/time is not known, only the date/time itself.
1320     */
1321    @Child(name = "effective", type = {DateTimeType.class, Period.class}, order=6, min=0, max=1, modifier=false, summary=true)
1322    @Description(shortDefinition="Clinically relevant time/time-period for observation", formalDefinition="The time or time-period the observed value is asserted as being true. For biological subjects - e.g. human patients - this is usually called the \"physiologically relevant time\". This is usually either the time of the procedure or of specimen collection, but very often the source of the date/time is not known, only the date/time itself." )
1323    protected Type effective;
1324
1325    /**
1326     * The date and time this observation was made available to providers, typically after the results have been reviewed and verified.
1327     */
1328    @Child(name = "issued", type = {InstantType.class}, order=7, min=0, max=1, modifier=false, summary=true)
1329    @Description(shortDefinition="Date/Time this was made available", formalDefinition="The date and time this observation was made available to providers, typically after the results have been reviewed and verified." )
1330    protected InstantType issued;
1331
1332    /**
1333     * Who was responsible for asserting the observed value as "true".
1334     */
1335    @Child(name = "performer", type = {Practitioner.class, Organization.class, Patient.class, RelatedPerson.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1336    @Description(shortDefinition="Who is responsible for the observation", formalDefinition="Who was responsible for asserting the observed value as \"true\"." )
1337    protected List<Reference> performer;
1338    /**
1339     * The actual objects that are the target of the reference (Who was responsible for asserting the observed value as "true".)
1340     */
1341    protected List<Resource> performerTarget;
1342
1343
1344    /**
1345     * The information determined as a result of making the observation, if the information has a simple value.
1346     */
1347    @Child(name = "value", type = {Quantity.class, CodeableConcept.class, StringType.class, Range.class, Ratio.class, SampledData.class, Attachment.class, TimeType.class, DateTimeType.class, Period.class}, order=9, min=0, max=1, modifier=false, summary=true)
1348    @Description(shortDefinition="Actual result", formalDefinition="The information determined as a result of making the observation, if the information has a simple value." )
1349    protected Type value;
1350
1351    /**
1352     * Provides a reason why the expected value in the element Observation.value[x] is missing.
1353     */
1354    @Child(name = "dataAbsentReason", type = {CodeableConcept.class}, order=10, min=0, max=1, modifier=false, summary=false)
1355    @Description(shortDefinition="Why the result is missing", formalDefinition="Provides a reason why the expected value in the element Observation.value[x] is missing." )
1356    protected CodeableConcept dataAbsentReason;
1357
1358    /**
1359     * The assessment made based on the result of the observation.  Intended as a simple compact code often placed adjacent to the result value in reports and flow sheets to signal the meaning/normalcy status of the result. Otherwise known as abnormal flag.
1360     */
1361    @Child(name = "interpretation", type = {CodeableConcept.class}, order=11, min=0, max=1, modifier=false, summary=false)
1362    @Description(shortDefinition="High, low, normal, etc.", formalDefinition="The assessment made based on the result of the observation.  Intended as a simple compact code often placed adjacent to the result value in reports and flow sheets to signal the meaning/normalcy status of the result. Otherwise known as abnormal flag." )
1363    protected CodeableConcept interpretation;
1364
1365    /**
1366     * May include statements about significant, unexpected or unreliable values, or information about the source of the value where this may be relevant to the interpretation of the result.
1367     */
1368    @Child(name = "comments", type = {StringType.class}, order=12, min=0, max=1, modifier=false, summary=false)
1369    @Description(shortDefinition="Comments about result", formalDefinition="May include statements about significant, unexpected or unreliable values, or information about the source of the value where this may be relevant to the interpretation of the result." )
1370    protected StringType comments;
1371
1372    /**
1373     * Indicates the site on the subject's body where the observation was made (i.e. the target site).
1374     */
1375    @Child(name = "bodySite", type = {CodeableConcept.class}, order=13, min=0, max=1, modifier=false, summary=false)
1376    @Description(shortDefinition="Observed body part", formalDefinition="Indicates the site on the subject's body where the observation was made (i.e. the target site)." )
1377    protected CodeableConcept bodySite;
1378
1379    /**
1380     * Indicates the mechanism used to perform the observation.
1381     */
1382    @Child(name = "method", type = {CodeableConcept.class}, order=14, min=0, max=1, modifier=false, summary=false)
1383    @Description(shortDefinition="How it was done", formalDefinition="Indicates the mechanism used to perform the observation." )
1384    protected CodeableConcept method;
1385
1386    /**
1387     * The specimen that was used when this observation was made.
1388     */
1389    @Child(name = "specimen", type = {Specimen.class}, order=15, min=0, max=1, modifier=false, summary=false)
1390    @Description(shortDefinition="Specimen used for this observation", formalDefinition="The specimen that was used when this observation was made." )
1391    protected Reference specimen;
1392
1393    /**
1394     * The actual object that is the target of the reference (The specimen that was used when this observation was made.)
1395     */
1396    protected Specimen specimenTarget;
1397
1398    /**
1399     * The device used to generate the observation data.
1400     */
1401    @Child(name = "device", type = {Device.class, DeviceMetric.class}, order=16, min=0, max=1, modifier=false, summary=false)
1402    @Description(shortDefinition="(Measurement) Device", formalDefinition="The device used to generate the observation data." )
1403    protected Reference device;
1404
1405    /**
1406     * The actual object that is the target of the reference (The device used to generate the observation data.)
1407     */
1408    protected Resource deviceTarget;
1409
1410    /**
1411     * Guidance on how to interpret the value by comparison to a normal or recommended range.
1412     */
1413    @Child(name = "referenceRange", type = {}, order=17, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1414    @Description(shortDefinition="Provides guide for interpretation", formalDefinition="Guidance on how to interpret the value by comparison to a normal or recommended range." )
1415    protected List<ObservationReferenceRangeComponent> referenceRange;
1416
1417    /**
1418     * A  reference to another resource (usually another Observation but could  also be a QuestionnaireAnswer) whose relationship is defined by the relationship type code.
1419     */
1420    @Child(name = "related", type = {}, order=18, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1421    @Description(shortDefinition="Resource related to this observation", formalDefinition="A  reference to another resource (usually another Observation but could  also be a QuestionnaireAnswer) whose relationship is defined by the relationship type code." )
1422    protected List<ObservationRelatedComponent> related;
1423
1424    /**
1425     * Some observations have multiple component observations.  These component observations are expressed as separate code value pairs that share the same attributes.  Examples include systolic and diastolic component observations for blood pressure measurement and multiple component observations for genetics observations.
1426     */
1427    @Child(name = "component", type = {}, order=19, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1428    @Description(shortDefinition="Component results", formalDefinition="Some observations have multiple component observations.  These component observations are expressed as separate code value pairs that share the same attributes.  Examples include systolic and diastolic component observations for blood pressure measurement and multiple component observations for genetics observations." )
1429    protected List<ObservationComponentComponent> component;
1430
1431    private static final long serialVersionUID = -931593572L;
1432
1433  /*
1434   * Constructor
1435   */
1436    public Observation() {
1437      super();
1438    }
1439
1440  /*
1441   * Constructor
1442   */
1443    public Observation(Enumeration<ObservationStatus> status, CodeableConcept code) {
1444      super();
1445      this.status = status;
1446      this.code = code;
1447    }
1448
1449    /**
1450     * @return {@link #identifier} (A unique identifier for the simple observation instance.)
1451     */
1452    public List<Identifier> getIdentifier() { 
1453      if (this.identifier == null)
1454        this.identifier = new ArrayList<Identifier>();
1455      return this.identifier;
1456    }
1457
1458    public boolean hasIdentifier() { 
1459      if (this.identifier == null)
1460        return false;
1461      for (Identifier item : this.identifier)
1462        if (!item.isEmpty())
1463          return true;
1464      return false;
1465    }
1466
1467    /**
1468     * @return {@link #identifier} (A unique identifier for the simple observation instance.)
1469     */
1470    // syntactic sugar
1471    public Identifier addIdentifier() { //3
1472      Identifier t = new Identifier();
1473      if (this.identifier == null)
1474        this.identifier = new ArrayList<Identifier>();
1475      this.identifier.add(t);
1476      return t;
1477    }
1478
1479    // syntactic sugar
1480    public Observation addIdentifier(Identifier t) { //3
1481      if (t == null)
1482        return this;
1483      if (this.identifier == null)
1484        this.identifier = new ArrayList<Identifier>();
1485      this.identifier.add(t);
1486      return this;
1487    }
1488
1489    /**
1490     * @return {@link #status} (The status of the result value.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1491     */
1492    public Enumeration<ObservationStatus> getStatusElement() { 
1493      if (this.status == null)
1494        if (Configuration.errorOnAutoCreate())
1495          throw new Error("Attempt to auto-create Observation.status");
1496        else if (Configuration.doAutoCreate())
1497          this.status = new Enumeration<ObservationStatus>(new ObservationStatusEnumFactory()); // bb
1498      return this.status;
1499    }
1500
1501    public boolean hasStatusElement() { 
1502      return this.status != null && !this.status.isEmpty();
1503    }
1504
1505    public boolean hasStatus() { 
1506      return this.status != null && !this.status.isEmpty();
1507    }
1508
1509    /**
1510     * @param value {@link #status} (The status of the result value.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1511     */
1512    public Observation setStatusElement(Enumeration<ObservationStatus> value) { 
1513      this.status = value;
1514      return this;
1515    }
1516
1517    /**
1518     * @return The status of the result value.
1519     */
1520    public ObservationStatus getStatus() { 
1521      return this.status == null ? null : this.status.getValue();
1522    }
1523
1524    /**
1525     * @param value The status of the result value.
1526     */
1527    public Observation setStatus(ObservationStatus value) { 
1528        if (this.status == null)
1529          this.status = new Enumeration<ObservationStatus>(new ObservationStatusEnumFactory());
1530        this.status.setValue(value);
1531      return this;
1532    }
1533
1534    /**
1535     * @return {@link #category} (A code that classifies the general type of observation being made.  This is used  for searching, sorting and display purposes.)
1536     */
1537    public CodeableConcept getCategory() { 
1538      if (this.category == null)
1539        if (Configuration.errorOnAutoCreate())
1540          throw new Error("Attempt to auto-create Observation.category");
1541        else if (Configuration.doAutoCreate())
1542          this.category = new CodeableConcept(); // cc
1543      return this.category;
1544    }
1545
1546    public boolean hasCategory() { 
1547      return this.category != null && !this.category.isEmpty();
1548    }
1549
1550    /**
1551     * @param value {@link #category} (A code that classifies the general type of observation being made.  This is used  for searching, sorting and display purposes.)
1552     */
1553    public Observation setCategory(CodeableConcept value) { 
1554      this.category = value;
1555      return this;
1556    }
1557
1558    /**
1559     * @return {@link #code} (Describes what was observed. Sometimes this is called the observation "name".)
1560     */
1561    public CodeableConcept getCode() { 
1562      if (this.code == null)
1563        if (Configuration.errorOnAutoCreate())
1564          throw new Error("Attempt to auto-create Observation.code");
1565        else if (Configuration.doAutoCreate())
1566          this.code = new CodeableConcept(); // cc
1567      return this.code;
1568    }
1569
1570    public boolean hasCode() { 
1571      return this.code != null && !this.code.isEmpty();
1572    }
1573
1574    /**
1575     * @param value {@link #code} (Describes what was observed. Sometimes this is called the observation "name".)
1576     */
1577    public Observation setCode(CodeableConcept value) { 
1578      this.code = value;
1579      return this;
1580    }
1581
1582    /**
1583     * @return {@link #subject} (The patient, or group of patients, location, or device whose characteristics (direct or indirect) are described by the observation and into whose record the observation is placed.  Comments: Indirect characteristics may be those of a specimen, fetus, donor,  other observer (for example a relative or EMT), or any observation made about the subject.)
1584     */
1585    public Reference getSubject() { 
1586      if (this.subject == null)
1587        if (Configuration.errorOnAutoCreate())
1588          throw new Error("Attempt to auto-create Observation.subject");
1589        else if (Configuration.doAutoCreate())
1590          this.subject = new Reference(); // cc
1591      return this.subject;
1592    }
1593
1594    public boolean hasSubject() { 
1595      return this.subject != null && !this.subject.isEmpty();
1596    }
1597
1598    /**
1599     * @param value {@link #subject} (The patient, or group of patients, location, or device whose characteristics (direct or indirect) are described by the observation and into whose record the observation is placed.  Comments: Indirect characteristics may be those of a specimen, fetus, donor,  other observer (for example a relative or EMT), or any observation made about the subject.)
1600     */
1601    public Observation setSubject(Reference value) { 
1602      this.subject = value;
1603      return this;
1604    }
1605
1606    /**
1607     * @return {@link #subject} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The patient, or group of patients, location, or device whose characteristics (direct or indirect) are described by the observation and into whose record the observation is placed.  Comments: Indirect characteristics may be those of a specimen, fetus, donor,  other observer (for example a relative or EMT), or any observation made about the subject.)
1608     */
1609    public Resource getSubjectTarget() { 
1610      return this.subjectTarget;
1611    }
1612
1613    /**
1614     * @param value {@link #subject} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The patient, or group of patients, location, or device whose characteristics (direct or indirect) are described by the observation and into whose record the observation is placed.  Comments: Indirect characteristics may be those of a specimen, fetus, donor,  other observer (for example a relative or EMT), or any observation made about the subject.)
1615     */
1616    public Observation setSubjectTarget(Resource value) { 
1617      this.subjectTarget = value;
1618      return this;
1619    }
1620
1621    /**
1622     * @return {@link #encounter} (The healthcare event  (e.g. a patient and healthcare provider interaction) during which this observation is made.)
1623     */
1624    public Reference getEncounter() { 
1625      if (this.encounter == null)
1626        if (Configuration.errorOnAutoCreate())
1627          throw new Error("Attempt to auto-create Observation.encounter");
1628        else if (Configuration.doAutoCreate())
1629          this.encounter = new Reference(); // cc
1630      return this.encounter;
1631    }
1632
1633    public boolean hasEncounter() { 
1634      return this.encounter != null && !this.encounter.isEmpty();
1635    }
1636
1637    /**
1638     * @param value {@link #encounter} (The healthcare event  (e.g. a patient and healthcare provider interaction) during which this observation is made.)
1639     */
1640    public Observation setEncounter(Reference value) { 
1641      this.encounter = value;
1642      return this;
1643    }
1644
1645    /**
1646     * @return {@link #encounter} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The healthcare event  (e.g. a patient and healthcare provider interaction) during which this observation is made.)
1647     */
1648    public Encounter getEncounterTarget() { 
1649      if (this.encounterTarget == null)
1650        if (Configuration.errorOnAutoCreate())
1651          throw new Error("Attempt to auto-create Observation.encounter");
1652        else if (Configuration.doAutoCreate())
1653          this.encounterTarget = new Encounter(); // aa
1654      return this.encounterTarget;
1655    }
1656
1657    /**
1658     * @param value {@link #encounter} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The healthcare event  (e.g. a patient and healthcare provider interaction) during which this observation is made.)
1659     */
1660    public Observation setEncounterTarget(Encounter value) { 
1661      this.encounterTarget = value;
1662      return this;
1663    }
1664
1665    /**
1666     * @return {@link #effective} (The time or time-period the observed value is asserted as being true. For biological subjects - e.g. human patients - this is usually called the "physiologically relevant time". This is usually either the time of the procedure or of specimen collection, but very often the source of the date/time is not known, only the date/time itself.)
1667     */
1668    public Type getEffective() { 
1669      return this.effective;
1670    }
1671
1672    /**
1673     * @return {@link #effective} (The time or time-period the observed value is asserted as being true. For biological subjects - e.g. human patients - this is usually called the "physiologically relevant time". This is usually either the time of the procedure or of specimen collection, but very often the source of the date/time is not known, only the date/time itself.)
1674     */
1675    public DateTimeType getEffectiveDateTimeType() throws FHIRException { 
1676      if (!(this.effective instanceof DateTimeType))
1677        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.effective.getClass().getName()+" was encountered");
1678      return (DateTimeType) this.effective;
1679    }
1680
1681    public boolean hasEffectiveDateTimeType() { 
1682      return this.effective instanceof DateTimeType;
1683    }
1684
1685    /**
1686     * @return {@link #effective} (The time or time-period the observed value is asserted as being true. For biological subjects - e.g. human patients - this is usually called the "physiologically relevant time". This is usually either the time of the procedure or of specimen collection, but very often the source of the date/time is not known, only the date/time itself.)
1687     */
1688    public Period getEffectivePeriod() throws FHIRException { 
1689      if (!(this.effective instanceof Period))
1690        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.effective.getClass().getName()+" was encountered");
1691      return (Period) this.effective;
1692    }
1693
1694    public boolean hasEffectivePeriod() { 
1695      return this.effective instanceof Period;
1696    }
1697
1698    public boolean hasEffective() { 
1699      return this.effective != null && !this.effective.isEmpty();
1700    }
1701
1702    /**
1703     * @param value {@link #effective} (The time or time-period the observed value is asserted as being true. For biological subjects - e.g. human patients - this is usually called the "physiologically relevant time". This is usually either the time of the procedure or of specimen collection, but very often the source of the date/time is not known, only the date/time itself.)
1704     */
1705    public Observation setEffective(Type value) { 
1706      this.effective = value;
1707      return this;
1708    }
1709
1710    /**
1711     * @return {@link #issued} (The date and time this observation was made available to providers, typically after the results have been reviewed and verified.). This is the underlying object with id, value and extensions. The accessor "getIssued" gives direct access to the value
1712     */
1713    public InstantType getIssuedElement() { 
1714      if (this.issued == null)
1715        if (Configuration.errorOnAutoCreate())
1716          throw new Error("Attempt to auto-create Observation.issued");
1717        else if (Configuration.doAutoCreate())
1718          this.issued = new InstantType(); // bb
1719      return this.issued;
1720    }
1721
1722    public boolean hasIssuedElement() { 
1723      return this.issued != null && !this.issued.isEmpty();
1724    }
1725
1726    public boolean hasIssued() { 
1727      return this.issued != null && !this.issued.isEmpty();
1728    }
1729
1730    /**
1731     * @param value {@link #issued} (The date and time this observation was made available to providers, typically after the results have been reviewed and verified.). This is the underlying object with id, value and extensions. The accessor "getIssued" gives direct access to the value
1732     */
1733    public Observation setIssuedElement(InstantType value) { 
1734      this.issued = value;
1735      return this;
1736    }
1737
1738    /**
1739     * @return The date and time this observation was made available to providers, typically after the results have been reviewed and verified.
1740     */
1741    public Date getIssued() { 
1742      return this.issued == null ? null : this.issued.getValue();
1743    }
1744
1745    /**
1746     * @param value The date and time this observation was made available to providers, typically after the results have been reviewed and verified.
1747     */
1748    public Observation setIssued(Date value) { 
1749      if (value == null)
1750        this.issued = null;
1751      else {
1752        if (this.issued == null)
1753          this.issued = new InstantType();
1754        this.issued.setValue(value);
1755      }
1756      return this;
1757    }
1758
1759    /**
1760     * @return {@link #performer} (Who was responsible for asserting the observed value as "true".)
1761     */
1762    public List<Reference> getPerformer() { 
1763      if (this.performer == null)
1764        this.performer = new ArrayList<Reference>();
1765      return this.performer;
1766    }
1767
1768    public boolean hasPerformer() { 
1769      if (this.performer == null)
1770        return false;
1771      for (Reference item : this.performer)
1772        if (!item.isEmpty())
1773          return true;
1774      return false;
1775    }
1776
1777    /**
1778     * @return {@link #performer} (Who was responsible for asserting the observed value as "true".)
1779     */
1780    // syntactic sugar
1781    public Reference addPerformer() { //3
1782      Reference t = new Reference();
1783      if (this.performer == null)
1784        this.performer = new ArrayList<Reference>();
1785      this.performer.add(t);
1786      return t;
1787    }
1788
1789    // syntactic sugar
1790    public Observation addPerformer(Reference t) { //3
1791      if (t == null)
1792        return this;
1793      if (this.performer == null)
1794        this.performer = new ArrayList<Reference>();
1795      this.performer.add(t);
1796      return this;
1797    }
1798
1799    /**
1800     * @return {@link #performer} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. Who was responsible for asserting the observed value as "true".)
1801     */
1802    public List<Resource> getPerformerTarget() { 
1803      if (this.performerTarget == null)
1804        this.performerTarget = new ArrayList<Resource>();
1805      return this.performerTarget;
1806    }
1807
1808    /**
1809     * @return {@link #value} (The information determined as a result of making the observation, if the information has a simple value.)
1810     */
1811    public Type getValue() { 
1812      return this.value;
1813    }
1814
1815    /**
1816     * @return {@link #value} (The information determined as a result of making the observation, if the information has a simple value.)
1817     */
1818    public Quantity getValueQuantity() throws FHIRException { 
1819      if (!(this.value instanceof Quantity))
1820        throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.value.getClass().getName()+" was encountered");
1821      return (Quantity) this.value;
1822    }
1823
1824    public boolean hasValueQuantity() { 
1825      return this.value instanceof Quantity;
1826    }
1827
1828    /**
1829     * @return {@link #value} (The information determined as a result of making the observation, if the information has a simple value.)
1830     */
1831    public CodeableConcept getValueCodeableConcept() throws FHIRException { 
1832      if (!(this.value instanceof CodeableConcept))
1833        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.value.getClass().getName()+" was encountered");
1834      return (CodeableConcept) this.value;
1835    }
1836
1837    public boolean hasValueCodeableConcept() { 
1838      return this.value instanceof CodeableConcept;
1839    }
1840
1841    /**
1842     * @return {@link #value} (The information determined as a result of making the observation, if the information has a simple value.)
1843     */
1844    public StringType getValueStringType() throws FHIRException { 
1845      if (!(this.value instanceof StringType))
1846        throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.value.getClass().getName()+" was encountered");
1847      return (StringType) this.value;
1848    }
1849
1850    public boolean hasValueStringType() { 
1851      return this.value instanceof StringType;
1852    }
1853
1854    /**
1855     * @return {@link #value} (The information determined as a result of making the observation, if the information has a simple value.)
1856     */
1857    public Range getValueRange() throws FHIRException { 
1858      if (!(this.value instanceof Range))
1859        throw new FHIRException("Type mismatch: the type Range was expected, but "+this.value.getClass().getName()+" was encountered");
1860      return (Range) this.value;
1861    }
1862
1863    public boolean hasValueRange() { 
1864      return this.value instanceof Range;
1865    }
1866
1867    /**
1868     * @return {@link #value} (The information determined as a result of making the observation, if the information has a simple value.)
1869     */
1870    public Ratio getValueRatio() throws FHIRException { 
1871      if (!(this.value instanceof Ratio))
1872        throw new FHIRException("Type mismatch: the type Ratio was expected, but "+this.value.getClass().getName()+" was encountered");
1873      return (Ratio) this.value;
1874    }
1875
1876    public boolean hasValueRatio() { 
1877      return this.value instanceof Ratio;
1878    }
1879
1880    /**
1881     * @return {@link #value} (The information determined as a result of making the observation, if the information has a simple value.)
1882     */
1883    public SampledData getValueSampledData() throws FHIRException { 
1884      if (!(this.value instanceof SampledData))
1885        throw new FHIRException("Type mismatch: the type SampledData was expected, but "+this.value.getClass().getName()+" was encountered");
1886      return (SampledData) this.value;
1887    }
1888
1889    public boolean hasValueSampledData() { 
1890      return this.value instanceof SampledData;
1891    }
1892
1893    /**
1894     * @return {@link #value} (The information determined as a result of making the observation, if the information has a simple value.)
1895     */
1896    public Attachment getValueAttachment() throws FHIRException { 
1897      if (!(this.value instanceof Attachment))
1898        throw new FHIRException("Type mismatch: the type Attachment was expected, but "+this.value.getClass().getName()+" was encountered");
1899      return (Attachment) this.value;
1900    }
1901
1902    public boolean hasValueAttachment() { 
1903      return this.value instanceof Attachment;
1904    }
1905
1906    /**
1907     * @return {@link #value} (The information determined as a result of making the observation, if the information has a simple value.)
1908     */
1909    public TimeType getValueTimeType() throws FHIRException { 
1910      if (!(this.value instanceof TimeType))
1911        throw new FHIRException("Type mismatch: the type TimeType was expected, but "+this.value.getClass().getName()+" was encountered");
1912      return (TimeType) this.value;
1913    }
1914
1915    public boolean hasValueTimeType() { 
1916      return this.value instanceof TimeType;
1917    }
1918
1919    /**
1920     * @return {@link #value} (The information determined as a result of making the observation, if the information has a simple value.)
1921     */
1922    public DateTimeType getValueDateTimeType() throws FHIRException { 
1923      if (!(this.value instanceof DateTimeType))
1924        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.value.getClass().getName()+" was encountered");
1925      return (DateTimeType) this.value;
1926    }
1927
1928    public boolean hasValueDateTimeType() { 
1929      return this.value instanceof DateTimeType;
1930    }
1931
1932    /**
1933     * @return {@link #value} (The information determined as a result of making the observation, if the information has a simple value.)
1934     */
1935    public Period getValuePeriod() throws FHIRException { 
1936      if (!(this.value instanceof Period))
1937        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.value.getClass().getName()+" was encountered");
1938      return (Period) this.value;
1939    }
1940
1941    public boolean hasValuePeriod() { 
1942      return this.value instanceof Period;
1943    }
1944
1945    public boolean hasValue() { 
1946      return this.value != null && !this.value.isEmpty();
1947    }
1948
1949    /**
1950     * @param value {@link #value} (The information determined as a result of making the observation, if the information has a simple value.)
1951     */
1952    public Observation setValue(Type value) { 
1953      this.value = value;
1954      return this;
1955    }
1956
1957    /**
1958     * @return {@link #dataAbsentReason} (Provides a reason why the expected value in the element Observation.value[x] is missing.)
1959     */
1960    public CodeableConcept getDataAbsentReason() { 
1961      if (this.dataAbsentReason == null)
1962        if (Configuration.errorOnAutoCreate())
1963          throw new Error("Attempt to auto-create Observation.dataAbsentReason");
1964        else if (Configuration.doAutoCreate())
1965          this.dataAbsentReason = new CodeableConcept(); // cc
1966      return this.dataAbsentReason;
1967    }
1968
1969    public boolean hasDataAbsentReason() { 
1970      return this.dataAbsentReason != null && !this.dataAbsentReason.isEmpty();
1971    }
1972
1973    /**
1974     * @param value {@link #dataAbsentReason} (Provides a reason why the expected value in the element Observation.value[x] is missing.)
1975     */
1976    public Observation setDataAbsentReason(CodeableConcept value) { 
1977      this.dataAbsentReason = value;
1978      return this;
1979    }
1980
1981    /**
1982     * @return {@link #interpretation} (The assessment made based on the result of the observation.  Intended as a simple compact code often placed adjacent to the result value in reports and flow sheets to signal the meaning/normalcy status of the result. Otherwise known as abnormal flag.)
1983     */
1984    public CodeableConcept getInterpretation() { 
1985      if (this.interpretation == null)
1986        if (Configuration.errorOnAutoCreate())
1987          throw new Error("Attempt to auto-create Observation.interpretation");
1988        else if (Configuration.doAutoCreate())
1989          this.interpretation = new CodeableConcept(); // cc
1990      return this.interpretation;
1991    }
1992
1993    public boolean hasInterpretation() { 
1994      return this.interpretation != null && !this.interpretation.isEmpty();
1995    }
1996
1997    /**
1998     * @param value {@link #interpretation} (The assessment made based on the result of the observation.  Intended as a simple compact code often placed adjacent to the result value in reports and flow sheets to signal the meaning/normalcy status of the result. Otherwise known as abnormal flag.)
1999     */
2000    public Observation setInterpretation(CodeableConcept value) { 
2001      this.interpretation = value;
2002      return this;
2003    }
2004
2005    /**
2006     * @return {@link #comments} (May include statements about significant, unexpected or unreliable values, or information about the source of the value where this may be relevant to the interpretation of the result.). This is the underlying object with id, value and extensions. The accessor "getComments" gives direct access to the value
2007     */
2008    public StringType getCommentsElement() { 
2009      if (this.comments == null)
2010        if (Configuration.errorOnAutoCreate())
2011          throw new Error("Attempt to auto-create Observation.comments");
2012        else if (Configuration.doAutoCreate())
2013          this.comments = new StringType(); // bb
2014      return this.comments;
2015    }
2016
2017    public boolean hasCommentsElement() { 
2018      return this.comments != null && !this.comments.isEmpty();
2019    }
2020
2021    public boolean hasComments() { 
2022      return this.comments != null && !this.comments.isEmpty();
2023    }
2024
2025    /**
2026     * @param value {@link #comments} (May include statements about significant, unexpected or unreliable values, or information about the source of the value where this may be relevant to the interpretation of the result.). This is the underlying object with id, value and extensions. The accessor "getComments" gives direct access to the value
2027     */
2028    public Observation setCommentsElement(StringType value) { 
2029      this.comments = value;
2030      return this;
2031    }
2032
2033    /**
2034     * @return May include statements about significant, unexpected or unreliable values, or information about the source of the value where this may be relevant to the interpretation of the result.
2035     */
2036    public String getComments() { 
2037      return this.comments == null ? null : this.comments.getValue();
2038    }
2039
2040    /**
2041     * @param value May include statements about significant, unexpected or unreliable values, or information about the source of the value where this may be relevant to the interpretation of the result.
2042     */
2043    public Observation setComments(String value) { 
2044      if (Utilities.noString(value))
2045        this.comments = null;
2046      else {
2047        if (this.comments == null)
2048          this.comments = new StringType();
2049        this.comments.setValue(value);
2050      }
2051      return this;
2052    }
2053
2054    /**
2055     * @return {@link #bodySite} (Indicates the site on the subject's body where the observation was made (i.e. the target site).)
2056     */
2057    public CodeableConcept getBodySite() { 
2058      if (this.bodySite == null)
2059        if (Configuration.errorOnAutoCreate())
2060          throw new Error("Attempt to auto-create Observation.bodySite");
2061        else if (Configuration.doAutoCreate())
2062          this.bodySite = new CodeableConcept(); // cc
2063      return this.bodySite;
2064    }
2065
2066    public boolean hasBodySite() { 
2067      return this.bodySite != null && !this.bodySite.isEmpty();
2068    }
2069
2070    /**
2071     * @param value {@link #bodySite} (Indicates the site on the subject's body where the observation was made (i.e. the target site).)
2072     */
2073    public Observation setBodySite(CodeableConcept value) { 
2074      this.bodySite = value;
2075      return this;
2076    }
2077
2078    /**
2079     * @return {@link #method} (Indicates the mechanism used to perform the observation.)
2080     */
2081    public CodeableConcept getMethod() { 
2082      if (this.method == null)
2083        if (Configuration.errorOnAutoCreate())
2084          throw new Error("Attempt to auto-create Observation.method");
2085        else if (Configuration.doAutoCreate())
2086          this.method = new CodeableConcept(); // cc
2087      return this.method;
2088    }
2089
2090    public boolean hasMethod() { 
2091      return this.method != null && !this.method.isEmpty();
2092    }
2093
2094    /**
2095     * @param value {@link #method} (Indicates the mechanism used to perform the observation.)
2096     */
2097    public Observation setMethod(CodeableConcept value) { 
2098      this.method = value;
2099      return this;
2100    }
2101
2102    /**
2103     * @return {@link #specimen} (The specimen that was used when this observation was made.)
2104     */
2105    public Reference getSpecimen() { 
2106      if (this.specimen == null)
2107        if (Configuration.errorOnAutoCreate())
2108          throw new Error("Attempt to auto-create Observation.specimen");
2109        else if (Configuration.doAutoCreate())
2110          this.specimen = new Reference(); // cc
2111      return this.specimen;
2112    }
2113
2114    public boolean hasSpecimen() { 
2115      return this.specimen != null && !this.specimen.isEmpty();
2116    }
2117
2118    /**
2119     * @param value {@link #specimen} (The specimen that was used when this observation was made.)
2120     */
2121    public Observation setSpecimen(Reference value) { 
2122      this.specimen = value;
2123      return this;
2124    }
2125
2126    /**
2127     * @return {@link #specimen} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The specimen that was used when this observation was made.)
2128     */
2129    public Specimen getSpecimenTarget() { 
2130      if (this.specimenTarget == null)
2131        if (Configuration.errorOnAutoCreate())
2132          throw new Error("Attempt to auto-create Observation.specimen");
2133        else if (Configuration.doAutoCreate())
2134          this.specimenTarget = new Specimen(); // aa
2135      return this.specimenTarget;
2136    }
2137
2138    /**
2139     * @param value {@link #specimen} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The specimen that was used when this observation was made.)
2140     */
2141    public Observation setSpecimenTarget(Specimen value) { 
2142      this.specimenTarget = value;
2143      return this;
2144    }
2145
2146    /**
2147     * @return {@link #device} (The device used to generate the observation data.)
2148     */
2149    public Reference getDevice() { 
2150      if (this.device == null)
2151        if (Configuration.errorOnAutoCreate())
2152          throw new Error("Attempt to auto-create Observation.device");
2153        else if (Configuration.doAutoCreate())
2154          this.device = new Reference(); // cc
2155      return this.device;
2156    }
2157
2158    public boolean hasDevice() { 
2159      return this.device != null && !this.device.isEmpty();
2160    }
2161
2162    /**
2163     * @param value {@link #device} (The device used to generate the observation data.)
2164     */
2165    public Observation setDevice(Reference value) { 
2166      this.device = value;
2167      return this;
2168    }
2169
2170    /**
2171     * @return {@link #device} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The device used to generate the observation data.)
2172     */
2173    public Resource getDeviceTarget() { 
2174      return this.deviceTarget;
2175    }
2176
2177    /**
2178     * @param value {@link #device} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The device used to generate the observation data.)
2179     */
2180    public Observation setDeviceTarget(Resource value) { 
2181      this.deviceTarget = value;
2182      return this;
2183    }
2184
2185    /**
2186     * @return {@link #referenceRange} (Guidance on how to interpret the value by comparison to a normal or recommended range.)
2187     */
2188    public List<ObservationReferenceRangeComponent> getReferenceRange() { 
2189      if (this.referenceRange == null)
2190        this.referenceRange = new ArrayList<ObservationReferenceRangeComponent>();
2191      return this.referenceRange;
2192    }
2193
2194    public boolean hasReferenceRange() { 
2195      if (this.referenceRange == null)
2196        return false;
2197      for (ObservationReferenceRangeComponent item : this.referenceRange)
2198        if (!item.isEmpty())
2199          return true;
2200      return false;
2201    }
2202
2203    /**
2204     * @return {@link #referenceRange} (Guidance on how to interpret the value by comparison to a normal or recommended range.)
2205     */
2206    // syntactic sugar
2207    public ObservationReferenceRangeComponent addReferenceRange() { //3
2208      ObservationReferenceRangeComponent t = new ObservationReferenceRangeComponent();
2209      if (this.referenceRange == null)
2210        this.referenceRange = new ArrayList<ObservationReferenceRangeComponent>();
2211      this.referenceRange.add(t);
2212      return t;
2213    }
2214
2215    // syntactic sugar
2216    public Observation addReferenceRange(ObservationReferenceRangeComponent t) { //3
2217      if (t == null)
2218        return this;
2219      if (this.referenceRange == null)
2220        this.referenceRange = new ArrayList<ObservationReferenceRangeComponent>();
2221      this.referenceRange.add(t);
2222      return this;
2223    }
2224
2225    /**
2226     * @return {@link #related} (A  reference to another resource (usually another Observation but could  also be a QuestionnaireAnswer) whose relationship is defined by the relationship type code.)
2227     */
2228    public List<ObservationRelatedComponent> getRelated() { 
2229      if (this.related == null)
2230        this.related = new ArrayList<ObservationRelatedComponent>();
2231      return this.related;
2232    }
2233
2234    public boolean hasRelated() { 
2235      if (this.related == null)
2236        return false;
2237      for (ObservationRelatedComponent item : this.related)
2238        if (!item.isEmpty())
2239          return true;
2240      return false;
2241    }
2242
2243    /**
2244     * @return {@link #related} (A  reference to another resource (usually another Observation but could  also be a QuestionnaireAnswer) whose relationship is defined by the relationship type code.)
2245     */
2246    // syntactic sugar
2247    public ObservationRelatedComponent addRelated() { //3
2248      ObservationRelatedComponent t = new ObservationRelatedComponent();
2249      if (this.related == null)
2250        this.related = new ArrayList<ObservationRelatedComponent>();
2251      this.related.add(t);
2252      return t;
2253    }
2254
2255    // syntactic sugar
2256    public Observation addRelated(ObservationRelatedComponent t) { //3
2257      if (t == null)
2258        return this;
2259      if (this.related == null)
2260        this.related = new ArrayList<ObservationRelatedComponent>();
2261      this.related.add(t);
2262      return this;
2263    }
2264
2265    /**
2266     * @return {@link #component} (Some observations have multiple component observations.  These component observations are expressed as separate code value pairs that share the same attributes.  Examples include systolic and diastolic component observations for blood pressure measurement and multiple component observations for genetics observations.)
2267     */
2268    public List<ObservationComponentComponent> getComponent() { 
2269      if (this.component == null)
2270        this.component = new ArrayList<ObservationComponentComponent>();
2271      return this.component;
2272    }
2273
2274    public boolean hasComponent() { 
2275      if (this.component == null)
2276        return false;
2277      for (ObservationComponentComponent item : this.component)
2278        if (!item.isEmpty())
2279          return true;
2280      return false;
2281    }
2282
2283    /**
2284     * @return {@link #component} (Some observations have multiple component observations.  These component observations are expressed as separate code value pairs that share the same attributes.  Examples include systolic and diastolic component observations for blood pressure measurement and multiple component observations for genetics observations.)
2285     */
2286    // syntactic sugar
2287    public ObservationComponentComponent addComponent() { //3
2288      ObservationComponentComponent t = new ObservationComponentComponent();
2289      if (this.component == null)
2290        this.component = new ArrayList<ObservationComponentComponent>();
2291      this.component.add(t);
2292      return t;
2293    }
2294
2295    // syntactic sugar
2296    public Observation addComponent(ObservationComponentComponent t) { //3
2297      if (t == null)
2298        return this;
2299      if (this.component == null)
2300        this.component = new ArrayList<ObservationComponentComponent>();
2301      this.component.add(t);
2302      return this;
2303    }
2304
2305      protected void listChildren(List<Property> childrenList) {
2306        super.listChildren(childrenList);
2307        childrenList.add(new Property("identifier", "Identifier", "A unique identifier for the simple observation instance.", 0, java.lang.Integer.MAX_VALUE, identifier));
2308        childrenList.add(new Property("status", "code", "The status of the result value.", 0, java.lang.Integer.MAX_VALUE, status));
2309        childrenList.add(new Property("category", "CodeableConcept", "A code that classifies the general type of observation being made.  This is used  for searching, sorting and display purposes.", 0, java.lang.Integer.MAX_VALUE, category));
2310        childrenList.add(new Property("code", "CodeableConcept", "Describes what was observed. Sometimes this is called the observation \"name\".", 0, java.lang.Integer.MAX_VALUE, code));
2311        childrenList.add(new Property("subject", "Reference(Patient|Group|Device|Location)", "The patient, or group of patients, location, or device whose characteristics (direct or indirect) are described by the observation and into whose record the observation is placed.  Comments: Indirect characteristics may be those of a specimen, fetus, donor,  other observer (for example a relative or EMT), or any observation made about the subject.", 0, java.lang.Integer.MAX_VALUE, subject));
2312        childrenList.add(new Property("encounter", "Reference(Encounter)", "The healthcare event  (e.g. a patient and healthcare provider interaction) during which this observation is made.", 0, java.lang.Integer.MAX_VALUE, encounter));
2313        childrenList.add(new Property("effective[x]", "dateTime|Period", "The time or time-period the observed value is asserted as being true. For biological subjects - e.g. human patients - this is usually called the \"physiologically relevant time\". This is usually either the time of the procedure or of specimen collection, but very often the source of the date/time is not known, only the date/time itself.", 0, java.lang.Integer.MAX_VALUE, effective));
2314        childrenList.add(new Property("issued", "instant", "The date and time this observation was made available to providers, typically after the results have been reviewed and verified.", 0, java.lang.Integer.MAX_VALUE, issued));
2315        childrenList.add(new Property("performer", "Reference(Practitioner|Organization|Patient|RelatedPerson)", "Who was responsible for asserting the observed value as \"true\".", 0, java.lang.Integer.MAX_VALUE, performer));
2316        childrenList.add(new Property("value[x]", "Quantity|CodeableConcept|string|Range|Ratio|SampledData|Attachment|time|dateTime|Period", "The information determined as a result of making the observation, if the information has a simple value.", 0, java.lang.Integer.MAX_VALUE, value));
2317        childrenList.add(new Property("dataAbsentReason", "CodeableConcept", "Provides a reason why the expected value in the element Observation.value[x] is missing.", 0, java.lang.Integer.MAX_VALUE, dataAbsentReason));
2318        childrenList.add(new Property("interpretation", "CodeableConcept", "The assessment made based on the result of the observation.  Intended as a simple compact code often placed adjacent to the result value in reports and flow sheets to signal the meaning/normalcy status of the result. Otherwise known as abnormal flag.", 0, java.lang.Integer.MAX_VALUE, interpretation));
2319        childrenList.add(new Property("comments", "string", "May include statements about significant, unexpected or unreliable values, or information about the source of the value where this may be relevant to the interpretation of the result.", 0, java.lang.Integer.MAX_VALUE, comments));
2320        childrenList.add(new Property("bodySite", "CodeableConcept", "Indicates the site on the subject's body where the observation was made (i.e. the target site).", 0, java.lang.Integer.MAX_VALUE, bodySite));
2321        childrenList.add(new Property("method", "CodeableConcept", "Indicates the mechanism used to perform the observation.", 0, java.lang.Integer.MAX_VALUE, method));
2322        childrenList.add(new Property("specimen", "Reference(Specimen)", "The specimen that was used when this observation was made.", 0, java.lang.Integer.MAX_VALUE, specimen));
2323        childrenList.add(new Property("device", "Reference(Device|DeviceMetric)", "The device used to generate the observation data.", 0, java.lang.Integer.MAX_VALUE, device));
2324        childrenList.add(new Property("referenceRange", "", "Guidance on how to interpret the value by comparison to a normal or recommended range.", 0, java.lang.Integer.MAX_VALUE, referenceRange));
2325        childrenList.add(new Property("related", "", "A  reference to another resource (usually another Observation but could  also be a QuestionnaireAnswer) whose relationship is defined by the relationship type code.", 0, java.lang.Integer.MAX_VALUE, related));
2326        childrenList.add(new Property("component", "", "Some observations have multiple component observations.  These component observations are expressed as separate code value pairs that share the same attributes.  Examples include systolic and diastolic component observations for blood pressure measurement and multiple component observations for genetics observations.", 0, java.lang.Integer.MAX_VALUE, component));
2327      }
2328
2329      @Override
2330      public void setProperty(String name, Base value) throws FHIRException {
2331        if (name.equals("identifier"))
2332          this.getIdentifier().add(castToIdentifier(value));
2333        else if (name.equals("status"))
2334          this.status = new ObservationStatusEnumFactory().fromType(value); // Enumeration<ObservationStatus>
2335        else if (name.equals("category"))
2336          this.category = castToCodeableConcept(value); // CodeableConcept
2337        else if (name.equals("code"))
2338          this.code = castToCodeableConcept(value); // CodeableConcept
2339        else if (name.equals("subject"))
2340          this.subject = castToReference(value); // Reference
2341        else if (name.equals("encounter"))
2342          this.encounter = castToReference(value); // Reference
2343        else if (name.equals("effective[x]"))
2344          this.effective = (Type) value; // Type
2345        else if (name.equals("issued"))
2346          this.issued = castToInstant(value); // InstantType
2347        else if (name.equals("performer"))
2348          this.getPerformer().add(castToReference(value));
2349        else if (name.equals("value[x]"))
2350          this.value = (Type) value; // Type
2351        else if (name.equals("dataAbsentReason"))
2352          this.dataAbsentReason = castToCodeableConcept(value); // CodeableConcept
2353        else if (name.equals("interpretation"))
2354          this.interpretation = castToCodeableConcept(value); // CodeableConcept
2355        else if (name.equals("comments"))
2356          this.comments = castToString(value); // StringType
2357        else if (name.equals("bodySite"))
2358          this.bodySite = castToCodeableConcept(value); // CodeableConcept
2359        else if (name.equals("method"))
2360          this.method = castToCodeableConcept(value); // CodeableConcept
2361        else if (name.equals("specimen"))
2362          this.specimen = castToReference(value); // Reference
2363        else if (name.equals("device"))
2364          this.device = castToReference(value); // Reference
2365        else if (name.equals("referenceRange"))
2366          this.getReferenceRange().add((ObservationReferenceRangeComponent) value);
2367        else if (name.equals("related"))
2368          this.getRelated().add((ObservationRelatedComponent) value);
2369        else if (name.equals("component"))
2370          this.getComponent().add((ObservationComponentComponent) value);
2371        else
2372          super.setProperty(name, value);
2373      }
2374
2375      @Override
2376      public Base addChild(String name) throws FHIRException {
2377        if (name.equals("identifier")) {
2378          return addIdentifier();
2379        }
2380        else if (name.equals("status")) {
2381          throw new FHIRException("Cannot call addChild on a primitive type Observation.status");
2382        }
2383        else if (name.equals("category")) {
2384          this.category = new CodeableConcept();
2385          return this.category;
2386        }
2387        else if (name.equals("code")) {
2388          this.code = new CodeableConcept();
2389          return this.code;
2390        }
2391        else if (name.equals("subject")) {
2392          this.subject = new Reference();
2393          return this.subject;
2394        }
2395        else if (name.equals("encounter")) {
2396          this.encounter = new Reference();
2397          return this.encounter;
2398        }
2399        else if (name.equals("effectiveDateTime")) {
2400          this.effective = new DateTimeType();
2401          return this.effective;
2402        }
2403        else if (name.equals("effectivePeriod")) {
2404          this.effective = new Period();
2405          return this.effective;
2406        }
2407        else if (name.equals("issued")) {
2408          throw new FHIRException("Cannot call addChild on a primitive type Observation.issued");
2409        }
2410        else if (name.equals("performer")) {
2411          return addPerformer();
2412        }
2413        else if (name.equals("valueQuantity")) {
2414          this.value = new Quantity();
2415          return this.value;
2416        }
2417        else if (name.equals("valueCodeableConcept")) {
2418          this.value = new CodeableConcept();
2419          return this.value;
2420        }
2421        else if (name.equals("valueString")) {
2422          this.value = new StringType();
2423          return this.value;
2424        }
2425        else if (name.equals("valueRange")) {
2426          this.value = new Range();
2427          return this.value;
2428        }
2429        else if (name.equals("valueRatio")) {
2430          this.value = new Ratio();
2431          return this.value;
2432        }
2433        else if (name.equals("valueSampledData")) {
2434          this.value = new SampledData();
2435          return this.value;
2436        }
2437        else if (name.equals("valueAttachment")) {
2438          this.value = new Attachment();
2439          return this.value;
2440        }
2441        else if (name.equals("valueTime")) {
2442          this.value = new TimeType();
2443          return this.value;
2444        }
2445        else if (name.equals("valueDateTime")) {
2446          this.value = new DateTimeType();
2447          return this.value;
2448        }
2449        else if (name.equals("valuePeriod")) {
2450          this.value = new Period();
2451          return this.value;
2452        }
2453        else if (name.equals("dataAbsentReason")) {
2454          this.dataAbsentReason = new CodeableConcept();
2455          return this.dataAbsentReason;
2456        }
2457        else if (name.equals("interpretation")) {
2458          this.interpretation = new CodeableConcept();
2459          return this.interpretation;
2460        }
2461        else if (name.equals("comments")) {
2462          throw new FHIRException("Cannot call addChild on a primitive type Observation.comments");
2463        }
2464        else if (name.equals("bodySite")) {
2465          this.bodySite = new CodeableConcept();
2466          return this.bodySite;
2467        }
2468        else if (name.equals("method")) {
2469          this.method = new CodeableConcept();
2470          return this.method;
2471        }
2472        else if (name.equals("specimen")) {
2473          this.specimen = new Reference();
2474          return this.specimen;
2475        }
2476        else if (name.equals("device")) {
2477          this.device = new Reference();
2478          return this.device;
2479        }
2480        else if (name.equals("referenceRange")) {
2481          return addReferenceRange();
2482        }
2483        else if (name.equals("related")) {
2484          return addRelated();
2485        }
2486        else if (name.equals("component")) {
2487          return addComponent();
2488        }
2489        else
2490          return super.addChild(name);
2491      }
2492
2493  public String fhirType() {
2494    return "Observation";
2495
2496  }
2497
2498      public Observation copy() {
2499        Observation dst = new Observation();
2500        copyValues(dst);
2501        if (identifier != null) {
2502          dst.identifier = new ArrayList<Identifier>();
2503          for (Identifier i : identifier)
2504            dst.identifier.add(i.copy());
2505        };
2506        dst.status = status == null ? null : status.copy();
2507        dst.category = category == null ? null : category.copy();
2508        dst.code = code == null ? null : code.copy();
2509        dst.subject = subject == null ? null : subject.copy();
2510        dst.encounter = encounter == null ? null : encounter.copy();
2511        dst.effective = effective == null ? null : effective.copy();
2512        dst.issued = issued == null ? null : issued.copy();
2513        if (performer != null) {
2514          dst.performer = new ArrayList<Reference>();
2515          for (Reference i : performer)
2516            dst.performer.add(i.copy());
2517        };
2518        dst.value = value == null ? null : value.copy();
2519        dst.dataAbsentReason = dataAbsentReason == null ? null : dataAbsentReason.copy();
2520        dst.interpretation = interpretation == null ? null : interpretation.copy();
2521        dst.comments = comments == null ? null : comments.copy();
2522        dst.bodySite = bodySite == null ? null : bodySite.copy();
2523        dst.method = method == null ? null : method.copy();
2524        dst.specimen = specimen == null ? null : specimen.copy();
2525        dst.device = device == null ? null : device.copy();
2526        if (referenceRange != null) {
2527          dst.referenceRange = new ArrayList<ObservationReferenceRangeComponent>();
2528          for (ObservationReferenceRangeComponent i : referenceRange)
2529            dst.referenceRange.add(i.copy());
2530        };
2531        if (related != null) {
2532          dst.related = new ArrayList<ObservationRelatedComponent>();
2533          for (ObservationRelatedComponent i : related)
2534            dst.related.add(i.copy());
2535        };
2536        if (component != null) {
2537          dst.component = new ArrayList<ObservationComponentComponent>();
2538          for (ObservationComponentComponent i : component)
2539            dst.component.add(i.copy());
2540        };
2541        return dst;
2542      }
2543
2544      protected Observation typedCopy() {
2545        return copy();
2546      }
2547
2548      @Override
2549      public boolean equalsDeep(Base other) {
2550        if (!super.equalsDeep(other))
2551          return false;
2552        if (!(other instanceof Observation))
2553          return false;
2554        Observation o = (Observation) other;
2555        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(category, o.category, true)
2556           && compareDeep(code, o.code, true) && compareDeep(subject, o.subject, true) && compareDeep(encounter, o.encounter, true)
2557           && compareDeep(effective, o.effective, true) && compareDeep(issued, o.issued, true) && compareDeep(performer, o.performer, true)
2558           && compareDeep(value, o.value, true) && compareDeep(dataAbsentReason, o.dataAbsentReason, true)
2559           && compareDeep(interpretation, o.interpretation, true) && compareDeep(comments, o.comments, true)
2560           && compareDeep(bodySite, o.bodySite, true) && compareDeep(method, o.method, true) && compareDeep(specimen, o.specimen, true)
2561           && compareDeep(device, o.device, true) && compareDeep(referenceRange, o.referenceRange, true) && compareDeep(related, o.related, true)
2562           && compareDeep(component, o.component, true);
2563      }
2564
2565      @Override
2566      public boolean equalsShallow(Base other) {
2567        if (!super.equalsShallow(other))
2568          return false;
2569        if (!(other instanceof Observation))
2570          return false;
2571        Observation o = (Observation) other;
2572        return compareValues(status, o.status, true) && compareValues(issued, o.issued, true) && compareValues(comments, o.comments, true)
2573          ;
2574      }
2575
2576      public boolean isEmpty() {
2577        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (status == null || status.isEmpty())
2578           && (category == null || category.isEmpty()) && (code == null || code.isEmpty()) && (subject == null || subject.isEmpty())
2579           && (encounter == null || encounter.isEmpty()) && (effective == null || effective.isEmpty())
2580           && (issued == null || issued.isEmpty()) && (performer == null || performer.isEmpty()) && (value == null || value.isEmpty())
2581           && (dataAbsentReason == null || dataAbsentReason.isEmpty()) && (interpretation == null || interpretation.isEmpty())
2582           && (comments == null || comments.isEmpty()) && (bodySite == null || bodySite.isEmpty()) && (method == null || method.isEmpty())
2583           && (specimen == null || specimen.isEmpty()) && (device == null || device.isEmpty()) && (referenceRange == null || referenceRange.isEmpty())
2584           && (related == null || related.isEmpty()) && (component == null || component.isEmpty());
2585      }
2586
2587  @Override
2588  public ResourceType getResourceType() {
2589    return ResourceType.Observation;
2590   }
2591
2592  @SearchParamDefinition(name="date", path="Observation.effective[x]", description="Obtained date/time. If the obtained element is a period, a date that falls in the period", type="date" )
2593  public static final String SP_DATE = "date";
2594  @SearchParamDefinition(name="code", path="Observation.code", description="The code of the observation type", type="token" )
2595  public static final String SP_CODE = "code";
2596  @SearchParamDefinition(name="subject", path="Observation.subject", description="The subject that the observation is about", type="reference" )
2597  public static final String SP_SUBJECT = "subject";
2598  @SearchParamDefinition(name="component-data-absent-reason", path="Observation.component.dataAbsentReason", description="The reason why the expected value in the element Observation.component.value[x] is missing.", type="token" )
2599  public static final String SP_COMPONENTDATAABSENTREASON = "component-data-absent-reason";
2600  @SearchParamDefinition(name="value-concept", path="Observation.valueCodeableConcept", description="The value of the observation, if the value is a CodeableConcept", type="token" )
2601  public static final String SP_VALUECONCEPT = "value-concept";
2602  @SearchParamDefinition(name="value-date", path="Observation.valueDateTime | Observation.valuePeriod", description="The value of the observation, if the value is a date or period of time", type="date" )
2603  public static final String SP_VALUEDATE = "value-date";
2604  @SearchParamDefinition(name="related", path="null", description="Related Observations - search on related-type and related-target together", type="composite" )
2605  public static final String SP_RELATED = "related";
2606  @SearchParamDefinition(name="patient", path="Observation.subject", description="The subject that the observation is about (if patient)", type="reference" )
2607  public static final String SP_PATIENT = "patient";
2608  @SearchParamDefinition(name="specimen", path="Observation.specimen", description="Specimen used for this observation", type="reference" )
2609  public static final String SP_SPECIMEN = "specimen";
2610  @SearchParamDefinition(name="component-code", path="Observation.component.code", description="The component code of the observation type", type="token" )
2611  public static final String SP_COMPONENTCODE = "component-code";
2612  @SearchParamDefinition(name="value-string", path="Observation.valueString", description="The value of the observation, if the value is a string, and also searches in CodeableConcept.text", type="string" )
2613  public static final String SP_VALUESTRING = "value-string";
2614  @SearchParamDefinition(name="identifier", path="Observation.identifier", description="The unique id for a particular observation", type="token" )
2615  public static final String SP_IDENTIFIER = "identifier";
2616  @SearchParamDefinition(name="component-code-value-[x]", path="null", description="Both component code and one of the component value parameters", type="composite" )
2617  public static final String SP_COMPONENTCODEVALUEX = "component-code-value-[x]";
2618  @SearchParamDefinition(name="code-value-[x]", path="null", description="Both code and one of the value parameters", type="composite" )
2619  public static final String SP_CODEVALUEX = "code-value-[x]";
2620  @SearchParamDefinition(name="performer", path="Observation.performer", description="Who performed the observation", type="reference" )
2621  public static final String SP_PERFORMER = "performer";
2622  @SearchParamDefinition(name="value-quantity", path="Observation.valueQuantity", description="The value of the observation, if the value is a Quantity, or a SampledData (just search on the bounds of the values in sampled data)", type="quantity" )
2623  public static final String SP_VALUEQUANTITY = "value-quantity";
2624  @SearchParamDefinition(name="component-value-quantity", path="Observation.component.valueQuantity", description="The value of the component observation, if the value is a Quantity, or a SampledData (just search on the bounds of the values in sampled data)", type="quantity" )
2625  public static final String SP_COMPONENTVALUEQUANTITY = "component-value-quantity";
2626  @SearchParamDefinition(name="data-absent-reason", path="Observation.dataAbsentReason", description="The reason why the expected value in the element Observation.value[x] is missing.", type="token" )
2627  public static final String SP_DATAABSENTREASON = "data-absent-reason";
2628  @SearchParamDefinition(name="encounter", path="Observation.encounter", description="Healthcare event related to the observation", type="reference" )
2629  public static final String SP_ENCOUNTER = "encounter";
2630  @SearchParamDefinition(name="related-type", path="Observation.related.type", description="has-member | derived-from | sequel-to | replaces | qualified-by | interfered-by", type="token" )
2631  public static final String SP_RELATEDTYPE = "related-type";
2632  @SearchParamDefinition(name="related-target", path="Observation.related.target", description="Resource that is related to this one", type="reference" )
2633  public static final String SP_RELATEDTARGET = "related-target";
2634  @SearchParamDefinition(name="component-value-string", path="Observation.component.valueString", description="The value of the component observation, if the value is a string, and also searches in CodeableConcept.text", type="string" )
2635  public static final String SP_COMPONENTVALUESTRING = "component-value-string";
2636  @SearchParamDefinition(name="component-value-concept", path="Observation.component.valueCodeableConcept", description="The value of the component observation, if the value is a CodeableConcept", type="token" )
2637  public static final String SP_COMPONENTVALUECONCEPT = "component-value-concept";
2638  @SearchParamDefinition(name="category", path="Observation.category", description="The classification of the type of observation", type="token" )
2639  public static final String SP_CATEGORY = "category";
2640  @SearchParamDefinition(name="device", path="Observation.device", description="The Device that generated the observation data.", type="reference" )
2641  public static final String SP_DEVICE = "device";
2642  @SearchParamDefinition(name="status", path="Observation.status", description="The status of the observation", type="token" )
2643  public static final String SP_STATUS = "status";
2644
2645}