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 * Use to record detailed information about conditions, problems or diagnoses recognized by a clinician. There are many uses including: recording a diagnosis during an encounter; populating a problem list or a summary statement, such as a discharge summary.
050 */
051@ResourceDef(name="Condition", profile="http://hl7.org/fhir/Profile/Condition")
052public class Condition extends DomainResource {
053
054    public enum ConditionVerificationStatus {
055        /**
056         * This is a tentative diagnosis - still a candidate that is under consideration.
057         */
058        PROVISIONAL, 
059        /**
060         * One of a set of potential (and typically mutually exclusive) diagnosis asserted to further guide the diagnostic process and preliminary treatment.
061         */
062        DIFFERENTIAL, 
063        /**
064         * There is sufficient diagnostic and/or clinical evidence to treat this as a confirmed condition.
065         */
066        CONFIRMED, 
067        /**
068         * This condition has been ruled out by diagnostic and clinical evidence.
069         */
070        REFUTED, 
071        /**
072         * The statement was entered in error and is not valid.
073         */
074        ENTEREDINERROR, 
075        /**
076         * The condition 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".
077         */
078        UNKNOWN, 
079        /**
080         * added to help the parsers
081         */
082        NULL;
083        public static ConditionVerificationStatus fromCode(String codeString) throws FHIRException {
084            if (codeString == null || "".equals(codeString))
085                return null;
086        if ("provisional".equals(codeString))
087          return PROVISIONAL;
088        if ("differential".equals(codeString))
089          return DIFFERENTIAL;
090        if ("confirmed".equals(codeString))
091          return CONFIRMED;
092        if ("refuted".equals(codeString))
093          return REFUTED;
094        if ("entered-in-error".equals(codeString))
095          return ENTEREDINERROR;
096        if ("unknown".equals(codeString))
097          return UNKNOWN;
098        throw new FHIRException("Unknown ConditionVerificationStatus code '"+codeString+"'");
099        }
100        public String toCode() {
101          switch (this) {
102            case PROVISIONAL: return "provisional";
103            case DIFFERENTIAL: return "differential";
104            case CONFIRMED: return "confirmed";
105            case REFUTED: return "refuted";
106            case ENTEREDINERROR: return "entered-in-error";
107            case UNKNOWN: return "unknown";
108            default: return "?";
109          }
110        }
111        public String getSystem() {
112          switch (this) {
113            case PROVISIONAL: return "http://hl7.org/fhir/condition-ver-status";
114            case DIFFERENTIAL: return "http://hl7.org/fhir/condition-ver-status";
115            case CONFIRMED: return "http://hl7.org/fhir/condition-ver-status";
116            case REFUTED: return "http://hl7.org/fhir/condition-ver-status";
117            case ENTEREDINERROR: return "http://hl7.org/fhir/condition-ver-status";
118            case UNKNOWN: return "http://hl7.org/fhir/condition-ver-status";
119            default: return "?";
120          }
121        }
122        public String getDefinition() {
123          switch (this) {
124            case PROVISIONAL: return "This is a tentative diagnosis - still a candidate that is under consideration.";
125            case DIFFERENTIAL: return "One of a set of potential (and typically mutually exclusive) diagnosis asserted to further guide the diagnostic process and preliminary treatment.";
126            case CONFIRMED: return "There is sufficient diagnostic and/or clinical evidence to treat this as a confirmed condition.";
127            case REFUTED: return "This condition has been ruled out by diagnostic and clinical evidence.";
128            case ENTEREDINERROR: return "The statement was entered in error and is not valid.";
129            case UNKNOWN: return "The condition 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\".";
130            default: return "?";
131          }
132        }
133        public String getDisplay() {
134          switch (this) {
135            case PROVISIONAL: return "Provisional";
136            case DIFFERENTIAL: return "Differential";
137            case CONFIRMED: return "Confirmed";
138            case REFUTED: return "Refuted";
139            case ENTEREDINERROR: return "Entered In Error";
140            case UNKNOWN: return "Unknown";
141            default: return "?";
142          }
143        }
144    }
145
146  public static class ConditionVerificationStatusEnumFactory implements EnumFactory<ConditionVerificationStatus> {
147    public ConditionVerificationStatus fromCode(String codeString) throws IllegalArgumentException {
148      if (codeString == null || "".equals(codeString))
149            if (codeString == null || "".equals(codeString))
150                return null;
151        if ("provisional".equals(codeString))
152          return ConditionVerificationStatus.PROVISIONAL;
153        if ("differential".equals(codeString))
154          return ConditionVerificationStatus.DIFFERENTIAL;
155        if ("confirmed".equals(codeString))
156          return ConditionVerificationStatus.CONFIRMED;
157        if ("refuted".equals(codeString))
158          return ConditionVerificationStatus.REFUTED;
159        if ("entered-in-error".equals(codeString))
160          return ConditionVerificationStatus.ENTEREDINERROR;
161        if ("unknown".equals(codeString))
162          return ConditionVerificationStatus.UNKNOWN;
163        throw new IllegalArgumentException("Unknown ConditionVerificationStatus code '"+codeString+"'");
164        }
165        public Enumeration<ConditionVerificationStatus> fromType(Base code) throws FHIRException {
166          if (code == null || code.isEmpty())
167            return null;
168          String codeString = ((PrimitiveType) code).asStringValue();
169          if (codeString == null || "".equals(codeString))
170            return null;
171        if ("provisional".equals(codeString))
172          return new Enumeration<ConditionVerificationStatus>(this, ConditionVerificationStatus.PROVISIONAL);
173        if ("differential".equals(codeString))
174          return new Enumeration<ConditionVerificationStatus>(this, ConditionVerificationStatus.DIFFERENTIAL);
175        if ("confirmed".equals(codeString))
176          return new Enumeration<ConditionVerificationStatus>(this, ConditionVerificationStatus.CONFIRMED);
177        if ("refuted".equals(codeString))
178          return new Enumeration<ConditionVerificationStatus>(this, ConditionVerificationStatus.REFUTED);
179        if ("entered-in-error".equals(codeString))
180          return new Enumeration<ConditionVerificationStatus>(this, ConditionVerificationStatus.ENTEREDINERROR);
181        if ("unknown".equals(codeString))
182          return new Enumeration<ConditionVerificationStatus>(this, ConditionVerificationStatus.UNKNOWN);
183        throw new FHIRException("Unknown ConditionVerificationStatus code '"+codeString+"'");
184        }
185    public String toCode(ConditionVerificationStatus code) {
186      if (code == ConditionVerificationStatus.PROVISIONAL)
187        return "provisional";
188      if (code == ConditionVerificationStatus.DIFFERENTIAL)
189        return "differential";
190      if (code == ConditionVerificationStatus.CONFIRMED)
191        return "confirmed";
192      if (code == ConditionVerificationStatus.REFUTED)
193        return "refuted";
194      if (code == ConditionVerificationStatus.ENTEREDINERROR)
195        return "entered-in-error";
196      if (code == ConditionVerificationStatus.UNKNOWN)
197        return "unknown";
198      return "?";
199      }
200    }
201
202    @Block()
203    public static class ConditionStageComponent extends BackboneElement implements IBaseBackboneElement {
204        /**
205         * A simple summary of the stage such as "Stage 3". The determination of the stage is disease-specific.
206         */
207        @Child(name = "summary", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
208        @Description(shortDefinition="Simple summary (disease specific)", formalDefinition="A simple summary of the stage such as \"Stage 3\". The determination of the stage is disease-specific." )
209        protected CodeableConcept summary;
210
211        /**
212         * Reference to a formal record of the evidence on which the staging assessment is based.
213         */
214        @Child(name = "assessment", type = {ClinicalImpression.class, DiagnosticReport.class, Observation.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
215        @Description(shortDefinition="Formal record of assessment", formalDefinition="Reference to a formal record of the evidence on which the staging assessment is based." )
216        protected List<Reference> assessment;
217        /**
218         * The actual objects that are the target of the reference (Reference to a formal record of the evidence on which the staging assessment is based.)
219         */
220        protected List<Resource> assessmentTarget;
221
222
223        private static final long serialVersionUID = -1961530405L;
224
225    /*
226     * Constructor
227     */
228      public ConditionStageComponent() {
229        super();
230      }
231
232        /**
233         * @return {@link #summary} (A simple summary of the stage such as "Stage 3". The determination of the stage is disease-specific.)
234         */
235        public CodeableConcept getSummary() { 
236          if (this.summary == null)
237            if (Configuration.errorOnAutoCreate())
238              throw new Error("Attempt to auto-create ConditionStageComponent.summary");
239            else if (Configuration.doAutoCreate())
240              this.summary = new CodeableConcept(); // cc
241          return this.summary;
242        }
243
244        public boolean hasSummary() { 
245          return this.summary != null && !this.summary.isEmpty();
246        }
247
248        /**
249         * @param value {@link #summary} (A simple summary of the stage such as "Stage 3". The determination of the stage is disease-specific.)
250         */
251        public ConditionStageComponent setSummary(CodeableConcept value) { 
252          this.summary = value;
253          return this;
254        }
255
256        /**
257         * @return {@link #assessment} (Reference to a formal record of the evidence on which the staging assessment is based.)
258         */
259        public List<Reference> getAssessment() { 
260          if (this.assessment == null)
261            this.assessment = new ArrayList<Reference>();
262          return this.assessment;
263        }
264
265        public boolean hasAssessment() { 
266          if (this.assessment == null)
267            return false;
268          for (Reference item : this.assessment)
269            if (!item.isEmpty())
270              return true;
271          return false;
272        }
273
274        /**
275         * @return {@link #assessment} (Reference to a formal record of the evidence on which the staging assessment is based.)
276         */
277    // syntactic sugar
278        public Reference addAssessment() { //3
279          Reference t = new Reference();
280          if (this.assessment == null)
281            this.assessment = new ArrayList<Reference>();
282          this.assessment.add(t);
283          return t;
284        }
285
286    // syntactic sugar
287        public ConditionStageComponent addAssessment(Reference t) { //3
288          if (t == null)
289            return this;
290          if (this.assessment == null)
291            this.assessment = new ArrayList<Reference>();
292          this.assessment.add(t);
293          return this;
294        }
295
296        /**
297         * @return {@link #assessment} (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. Reference to a formal record of the evidence on which the staging assessment is based.)
298         */
299        public List<Resource> getAssessmentTarget() { 
300          if (this.assessmentTarget == null)
301            this.assessmentTarget = new ArrayList<Resource>();
302          return this.assessmentTarget;
303        }
304
305        protected void listChildren(List<Property> childrenList) {
306          super.listChildren(childrenList);
307          childrenList.add(new Property("summary", "CodeableConcept", "A simple summary of the stage such as \"Stage 3\". The determination of the stage is disease-specific.", 0, java.lang.Integer.MAX_VALUE, summary));
308          childrenList.add(new Property("assessment", "Reference(ClinicalImpression|DiagnosticReport|Observation)", "Reference to a formal record of the evidence on which the staging assessment is based.", 0, java.lang.Integer.MAX_VALUE, assessment));
309        }
310
311      @Override
312      public void setProperty(String name, Base value) throws FHIRException {
313        if (name.equals("summary"))
314          this.summary = castToCodeableConcept(value); // CodeableConcept
315        else if (name.equals("assessment"))
316          this.getAssessment().add(castToReference(value));
317        else
318          super.setProperty(name, value);
319      }
320
321      @Override
322      public Base addChild(String name) throws FHIRException {
323        if (name.equals("summary")) {
324          this.summary = new CodeableConcept();
325          return this.summary;
326        }
327        else if (name.equals("assessment")) {
328          return addAssessment();
329        }
330        else
331          return super.addChild(name);
332      }
333
334      public ConditionStageComponent copy() {
335        ConditionStageComponent dst = new ConditionStageComponent();
336        copyValues(dst);
337        dst.summary = summary == null ? null : summary.copy();
338        if (assessment != null) {
339          dst.assessment = new ArrayList<Reference>();
340          for (Reference i : assessment)
341            dst.assessment.add(i.copy());
342        };
343        return dst;
344      }
345
346      @Override
347      public boolean equalsDeep(Base other) {
348        if (!super.equalsDeep(other))
349          return false;
350        if (!(other instanceof ConditionStageComponent))
351          return false;
352        ConditionStageComponent o = (ConditionStageComponent) other;
353        return compareDeep(summary, o.summary, true) && compareDeep(assessment, o.assessment, true);
354      }
355
356      @Override
357      public boolean equalsShallow(Base other) {
358        if (!super.equalsShallow(other))
359          return false;
360        if (!(other instanceof ConditionStageComponent))
361          return false;
362        ConditionStageComponent o = (ConditionStageComponent) other;
363        return true;
364      }
365
366      public boolean isEmpty() {
367        return super.isEmpty() && (summary == null || summary.isEmpty()) && (assessment == null || assessment.isEmpty())
368          ;
369      }
370
371  public String fhirType() {
372    return "Condition.stage";
373
374  }
375
376  }
377
378    @Block()
379    public static class ConditionEvidenceComponent extends BackboneElement implements IBaseBackboneElement {
380        /**
381         * A manifestation or symptom that led to the recording of this condition.
382         */
383        @Child(name = "code", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
384        @Description(shortDefinition="Manifestation/symptom", formalDefinition="A manifestation or symptom that led to the recording of this condition." )
385        protected CodeableConcept code;
386
387        /**
388         * Links to other relevant information, including pathology reports.
389         */
390        @Child(name = "detail", type = {}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
391        @Description(shortDefinition="Supporting information found elsewhere", formalDefinition="Links to other relevant information, including pathology reports." )
392        protected List<Reference> detail;
393        /**
394         * The actual objects that are the target of the reference (Links to other relevant information, including pathology reports.)
395         */
396        protected List<Resource> detailTarget;
397
398
399        private static final long serialVersionUID = 945689926L;
400
401    /*
402     * Constructor
403     */
404      public ConditionEvidenceComponent() {
405        super();
406      }
407
408        /**
409         * @return {@link #code} (A manifestation or symptom that led to the recording of this condition.)
410         */
411        public CodeableConcept getCode() { 
412          if (this.code == null)
413            if (Configuration.errorOnAutoCreate())
414              throw new Error("Attempt to auto-create ConditionEvidenceComponent.code");
415            else if (Configuration.doAutoCreate())
416              this.code = new CodeableConcept(); // cc
417          return this.code;
418        }
419
420        public boolean hasCode() { 
421          return this.code != null && !this.code.isEmpty();
422        }
423
424        /**
425         * @param value {@link #code} (A manifestation or symptom that led to the recording of this condition.)
426         */
427        public ConditionEvidenceComponent setCode(CodeableConcept value) { 
428          this.code = value;
429          return this;
430        }
431
432        /**
433         * @return {@link #detail} (Links to other relevant information, including pathology reports.)
434         */
435        public List<Reference> getDetail() { 
436          if (this.detail == null)
437            this.detail = new ArrayList<Reference>();
438          return this.detail;
439        }
440
441        public boolean hasDetail() { 
442          if (this.detail == null)
443            return false;
444          for (Reference item : this.detail)
445            if (!item.isEmpty())
446              return true;
447          return false;
448        }
449
450        /**
451         * @return {@link #detail} (Links to other relevant information, including pathology reports.)
452         */
453    // syntactic sugar
454        public Reference addDetail() { //3
455          Reference t = new Reference();
456          if (this.detail == null)
457            this.detail = new ArrayList<Reference>();
458          this.detail.add(t);
459          return t;
460        }
461
462    // syntactic sugar
463        public ConditionEvidenceComponent addDetail(Reference t) { //3
464          if (t == null)
465            return this;
466          if (this.detail == null)
467            this.detail = new ArrayList<Reference>();
468          this.detail.add(t);
469          return this;
470        }
471
472        /**
473         * @return {@link #detail} (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. Links to other relevant information, including pathology reports.)
474         */
475        public List<Resource> getDetailTarget() { 
476          if (this.detailTarget == null)
477            this.detailTarget = new ArrayList<Resource>();
478          return this.detailTarget;
479        }
480
481        protected void listChildren(List<Property> childrenList) {
482          super.listChildren(childrenList);
483          childrenList.add(new Property("code", "CodeableConcept", "A manifestation or symptom that led to the recording of this condition.", 0, java.lang.Integer.MAX_VALUE, code));
484          childrenList.add(new Property("detail", "Reference(Any)", "Links to other relevant information, including pathology reports.", 0, java.lang.Integer.MAX_VALUE, detail));
485        }
486
487      @Override
488      public void setProperty(String name, Base value) throws FHIRException {
489        if (name.equals("code"))
490          this.code = castToCodeableConcept(value); // CodeableConcept
491        else if (name.equals("detail"))
492          this.getDetail().add(castToReference(value));
493        else
494          super.setProperty(name, value);
495      }
496
497      @Override
498      public Base addChild(String name) throws FHIRException {
499        if (name.equals("code")) {
500          this.code = new CodeableConcept();
501          return this.code;
502        }
503        else if (name.equals("detail")) {
504          return addDetail();
505        }
506        else
507          return super.addChild(name);
508      }
509
510      public ConditionEvidenceComponent copy() {
511        ConditionEvidenceComponent dst = new ConditionEvidenceComponent();
512        copyValues(dst);
513        dst.code = code == null ? null : code.copy();
514        if (detail != null) {
515          dst.detail = new ArrayList<Reference>();
516          for (Reference i : detail)
517            dst.detail.add(i.copy());
518        };
519        return dst;
520      }
521
522      @Override
523      public boolean equalsDeep(Base other) {
524        if (!super.equalsDeep(other))
525          return false;
526        if (!(other instanceof ConditionEvidenceComponent))
527          return false;
528        ConditionEvidenceComponent o = (ConditionEvidenceComponent) other;
529        return compareDeep(code, o.code, true) && compareDeep(detail, o.detail, true);
530      }
531
532      @Override
533      public boolean equalsShallow(Base other) {
534        if (!super.equalsShallow(other))
535          return false;
536        if (!(other instanceof ConditionEvidenceComponent))
537          return false;
538        ConditionEvidenceComponent o = (ConditionEvidenceComponent) other;
539        return true;
540      }
541
542      public boolean isEmpty() {
543        return super.isEmpty() && (code == null || code.isEmpty()) && (detail == null || detail.isEmpty())
544          ;
545      }
546
547  public String fhirType() {
548    return "Condition.evidence";
549
550  }
551
552  }
553
554    /**
555     * This records identifiers associated with this condition that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).
556     */
557    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
558    @Description(shortDefinition="External Ids for this condition", formalDefinition="This records identifiers associated with this condition that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation)." )
559    protected List<Identifier> identifier;
560
561    /**
562     * Indicates the patient who the condition record is associated with.
563     */
564    @Child(name = "patient", type = {Patient.class}, order=1, min=1, max=1, modifier=false, summary=true)
565    @Description(shortDefinition="Who has the condition?", formalDefinition="Indicates the patient who the condition record is associated with." )
566    protected Reference patient;
567
568    /**
569     * The actual object that is the target of the reference (Indicates the patient who the condition record is associated with.)
570     */
571    protected Patient patientTarget;
572
573    /**
574     * Encounter during which the condition was first asserted.
575     */
576    @Child(name = "encounter", type = {Encounter.class}, order=2, min=0, max=1, modifier=false, summary=true)
577    @Description(shortDefinition="Encounter when condition first asserted", formalDefinition="Encounter during which the condition was first asserted." )
578    protected Reference encounter;
579
580    /**
581     * The actual object that is the target of the reference (Encounter during which the condition was first asserted.)
582     */
583    protected Encounter encounterTarget;
584
585    /**
586     * Individual who is making the condition statement.
587     */
588    @Child(name = "asserter", type = {Practitioner.class, Patient.class}, order=3, min=0, max=1, modifier=false, summary=true)
589    @Description(shortDefinition="Person who asserts this condition", formalDefinition="Individual who is making the condition statement." )
590    protected Reference asserter;
591
592    /**
593     * The actual object that is the target of the reference (Individual who is making the condition statement.)
594     */
595    protected Resource asserterTarget;
596
597    /**
598     * A date, when  the Condition statement was documented.
599     */
600    @Child(name = "dateRecorded", type = {DateType.class}, order=4, min=0, max=1, modifier=false, summary=true)
601    @Description(shortDefinition="When first entered", formalDefinition="A date, when  the Condition statement was documented." )
602    protected DateType dateRecorded;
603
604    /**
605     * Identification of the condition, problem or diagnosis.
606     */
607    @Child(name = "code", type = {CodeableConcept.class}, order=5, min=1, max=1, modifier=false, summary=true)
608    @Description(shortDefinition="Identification of the condition, problem or diagnosis", formalDefinition="Identification of the condition, problem or diagnosis." )
609    protected CodeableConcept code;
610
611    /**
612     * A category assigned to the condition.
613     */
614    @Child(name = "category", type = {CodeableConcept.class}, order=6, min=0, max=1, modifier=false, summary=true)
615    @Description(shortDefinition="complaint | symptom | finding | diagnosis", formalDefinition="A category assigned to the condition." )
616    protected CodeableConcept category;
617
618    /**
619     * The clinical status of the condition.
620     */
621    @Child(name = "clinicalStatus", type = {CodeType.class}, order=7, min=0, max=1, modifier=true, summary=true)
622    @Description(shortDefinition="active | relapse | remission | resolved", formalDefinition="The clinical status of the condition." )
623    protected CodeType clinicalStatus;
624
625    /**
626     * The verification status to support the clinical status of the condition.
627     */
628    @Child(name = "verificationStatus", type = {CodeType.class}, order=8, min=1, max=1, modifier=true, summary=true)
629    @Description(shortDefinition="provisional | differential | confirmed | refuted | entered-in-error | unknown", formalDefinition="The verification status to support the clinical status of the condition." )
630    protected Enumeration<ConditionVerificationStatus> verificationStatus;
631
632    /**
633     * A subjective assessment of the severity of the condition as evaluated by the clinician.
634     */
635    @Child(name = "severity", type = {CodeableConcept.class}, order=9, min=0, max=1, modifier=false, summary=true)
636    @Description(shortDefinition="Subjective severity of condition", formalDefinition="A subjective assessment of the severity of the condition as evaluated by the clinician." )
637    protected CodeableConcept severity;
638
639    /**
640     * Estimated or actual date or date-time  the condition began, in the opinion of the clinician.
641     */
642    @Child(name = "onset", type = {DateTimeType.class, Age.class, Period.class, Range.class, StringType.class}, order=10, min=0, max=1, modifier=false, summary=true)
643    @Description(shortDefinition="Estimated or actual date,  date-time, or age", formalDefinition="Estimated or actual date or date-time  the condition began, in the opinion of the clinician." )
644    protected Type onset;
645
646    /**
647     * The date or estimated date that the condition resolved or went into remission. This is called "abatement" because of the many overloaded connotations associated with "remission" or "resolution" - Conditions are never really resolved, but they can abate.
648     */
649    @Child(name = "abatement", type = {DateTimeType.class, Age.class, BooleanType.class, Period.class, Range.class, StringType.class}, order=11, min=0, max=1, modifier=false, summary=true)
650    @Description(shortDefinition="If/when in resolution/remission", formalDefinition="The date or estimated date that the condition resolved or went into remission. This is called \"abatement\" because of the many overloaded connotations associated with \"remission\" or \"resolution\" - Conditions are never really resolved, but they can abate." )
651    protected Type abatement;
652
653    /**
654     * Clinical stage or grade of a condition. May include formal severity assessments.
655     */
656    @Child(name = "stage", type = {}, order=12, min=0, max=1, modifier=false, summary=true)
657    @Description(shortDefinition="Stage/grade, usually assessed formally", formalDefinition="Clinical stage or grade of a condition. May include formal severity assessments." )
658    protected ConditionStageComponent stage;
659
660    /**
661     * Supporting Evidence / manifestations that are the basis on which this condition is suspected or confirmed.
662     */
663    @Child(name = "evidence", type = {}, order=13, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
664    @Description(shortDefinition="Supporting evidence", formalDefinition="Supporting Evidence / manifestations that are the basis on which this condition is suspected or confirmed." )
665    protected List<ConditionEvidenceComponent> evidence;
666
667    /**
668     * The anatomical location where this condition manifests itself.
669     */
670    @Child(name = "bodySite", type = {CodeableConcept.class}, order=14, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
671    @Description(shortDefinition="Anatomical location, if relevant", formalDefinition="The anatomical location where this condition manifests itself." )
672    protected List<CodeableConcept> bodySite;
673
674    /**
675     * Additional information about the Condition. This is a general notes/comments entry  for description of the Condition, its diagnosis and prognosis.
676     */
677    @Child(name = "notes", type = {StringType.class}, order=15, min=0, max=1, modifier=false, summary=true)
678    @Description(shortDefinition="Additional information about the Condition", formalDefinition="Additional information about the Condition. This is a general notes/comments entry  for description of the Condition, its diagnosis and prognosis." )
679    protected StringType notes;
680
681    private static final long serialVersionUID = -341227215L;
682
683  /*
684   * Constructor
685   */
686    public Condition() {
687      super();
688    }
689
690  /*
691   * Constructor
692   */
693    public Condition(Reference patient, CodeableConcept code, Enumeration<ConditionVerificationStatus> verificationStatus) {
694      super();
695      this.patient = patient;
696      this.code = code;
697      this.verificationStatus = verificationStatus;
698    }
699
700    /**
701     * @return {@link #identifier} (This records identifiers associated with this condition that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).)
702     */
703    public List<Identifier> getIdentifier() { 
704      if (this.identifier == null)
705        this.identifier = new ArrayList<Identifier>();
706      return this.identifier;
707    }
708
709    public boolean hasIdentifier() { 
710      if (this.identifier == null)
711        return false;
712      for (Identifier item : this.identifier)
713        if (!item.isEmpty())
714          return true;
715      return false;
716    }
717
718    /**
719     * @return {@link #identifier} (This records identifiers associated with this condition that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).)
720     */
721    // syntactic sugar
722    public Identifier addIdentifier() { //3
723      Identifier t = new Identifier();
724      if (this.identifier == null)
725        this.identifier = new ArrayList<Identifier>();
726      this.identifier.add(t);
727      return t;
728    }
729
730    // syntactic sugar
731    public Condition addIdentifier(Identifier t) { //3
732      if (t == null)
733        return this;
734      if (this.identifier == null)
735        this.identifier = new ArrayList<Identifier>();
736      this.identifier.add(t);
737      return this;
738    }
739
740    /**
741     * @return {@link #patient} (Indicates the patient who the condition record is associated with.)
742     */
743    public Reference getPatient() { 
744      if (this.patient == null)
745        if (Configuration.errorOnAutoCreate())
746          throw new Error("Attempt to auto-create Condition.patient");
747        else if (Configuration.doAutoCreate())
748          this.patient = new Reference(); // cc
749      return this.patient;
750    }
751
752    public boolean hasPatient() { 
753      return this.patient != null && !this.patient.isEmpty();
754    }
755
756    /**
757     * @param value {@link #patient} (Indicates the patient who the condition record is associated with.)
758     */
759    public Condition setPatient(Reference value) { 
760      this.patient = value;
761      return this;
762    }
763
764    /**
765     * @return {@link #patient} 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. (Indicates the patient who the condition record is associated with.)
766     */
767    public Patient getPatientTarget() { 
768      if (this.patientTarget == null)
769        if (Configuration.errorOnAutoCreate())
770          throw new Error("Attempt to auto-create Condition.patient");
771        else if (Configuration.doAutoCreate())
772          this.patientTarget = new Patient(); // aa
773      return this.patientTarget;
774    }
775
776    /**
777     * @param value {@link #patient} 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. (Indicates the patient who the condition record is associated with.)
778     */
779    public Condition setPatientTarget(Patient value) { 
780      this.patientTarget = value;
781      return this;
782    }
783
784    /**
785     * @return {@link #encounter} (Encounter during which the condition was first asserted.)
786     */
787    public Reference getEncounter() { 
788      if (this.encounter == null)
789        if (Configuration.errorOnAutoCreate())
790          throw new Error("Attempt to auto-create Condition.encounter");
791        else if (Configuration.doAutoCreate())
792          this.encounter = new Reference(); // cc
793      return this.encounter;
794    }
795
796    public boolean hasEncounter() { 
797      return this.encounter != null && !this.encounter.isEmpty();
798    }
799
800    /**
801     * @param value {@link #encounter} (Encounter during which the condition was first asserted.)
802     */
803    public Condition setEncounter(Reference value) { 
804      this.encounter = value;
805      return this;
806    }
807
808    /**
809     * @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. (Encounter during which the condition was first asserted.)
810     */
811    public Encounter getEncounterTarget() { 
812      if (this.encounterTarget == null)
813        if (Configuration.errorOnAutoCreate())
814          throw new Error("Attempt to auto-create Condition.encounter");
815        else if (Configuration.doAutoCreate())
816          this.encounterTarget = new Encounter(); // aa
817      return this.encounterTarget;
818    }
819
820    /**
821     * @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. (Encounter during which the condition was first asserted.)
822     */
823    public Condition setEncounterTarget(Encounter value) { 
824      this.encounterTarget = value;
825      return this;
826    }
827
828    /**
829     * @return {@link #asserter} (Individual who is making the condition statement.)
830     */
831    public Reference getAsserter() { 
832      if (this.asserter == null)
833        if (Configuration.errorOnAutoCreate())
834          throw new Error("Attempt to auto-create Condition.asserter");
835        else if (Configuration.doAutoCreate())
836          this.asserter = new Reference(); // cc
837      return this.asserter;
838    }
839
840    public boolean hasAsserter() { 
841      return this.asserter != null && !this.asserter.isEmpty();
842    }
843
844    /**
845     * @param value {@link #asserter} (Individual who is making the condition statement.)
846     */
847    public Condition setAsserter(Reference value) { 
848      this.asserter = value;
849      return this;
850    }
851
852    /**
853     * @return {@link #asserter} 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. (Individual who is making the condition statement.)
854     */
855    public Resource getAsserterTarget() { 
856      return this.asserterTarget;
857    }
858
859    /**
860     * @param value {@link #asserter} 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. (Individual who is making the condition statement.)
861     */
862    public Condition setAsserterTarget(Resource value) { 
863      this.asserterTarget = value;
864      return this;
865    }
866
867    /**
868     * @return {@link #dateRecorded} (A date, when  the Condition statement was documented.). This is the underlying object with id, value and extensions. The accessor "getDateRecorded" gives direct access to the value
869     */
870    public DateType getDateRecordedElement() { 
871      if (this.dateRecorded == null)
872        if (Configuration.errorOnAutoCreate())
873          throw new Error("Attempt to auto-create Condition.dateRecorded");
874        else if (Configuration.doAutoCreate())
875          this.dateRecorded = new DateType(); // bb
876      return this.dateRecorded;
877    }
878
879    public boolean hasDateRecordedElement() { 
880      return this.dateRecorded != null && !this.dateRecorded.isEmpty();
881    }
882
883    public boolean hasDateRecorded() { 
884      return this.dateRecorded != null && !this.dateRecorded.isEmpty();
885    }
886
887    /**
888     * @param value {@link #dateRecorded} (A date, when  the Condition statement was documented.). This is the underlying object with id, value and extensions. The accessor "getDateRecorded" gives direct access to the value
889     */
890    public Condition setDateRecordedElement(DateType value) { 
891      this.dateRecorded = value;
892      return this;
893    }
894
895    /**
896     * @return A date, when  the Condition statement was documented.
897     */
898    public Date getDateRecorded() { 
899      return this.dateRecorded == null ? null : this.dateRecorded.getValue();
900    }
901
902    /**
903     * @param value A date, when  the Condition statement was documented.
904     */
905    public Condition setDateRecorded(Date value) { 
906      if (value == null)
907        this.dateRecorded = null;
908      else {
909        if (this.dateRecorded == null)
910          this.dateRecorded = new DateType();
911        this.dateRecorded.setValue(value);
912      }
913      return this;
914    }
915
916    /**
917     * @return {@link #code} (Identification of the condition, problem or diagnosis.)
918     */
919    public CodeableConcept getCode() { 
920      if (this.code == null)
921        if (Configuration.errorOnAutoCreate())
922          throw new Error("Attempt to auto-create Condition.code");
923        else if (Configuration.doAutoCreate())
924          this.code = new CodeableConcept(); // cc
925      return this.code;
926    }
927
928    public boolean hasCode() { 
929      return this.code != null && !this.code.isEmpty();
930    }
931
932    /**
933     * @param value {@link #code} (Identification of the condition, problem or diagnosis.)
934     */
935    public Condition setCode(CodeableConcept value) { 
936      this.code = value;
937      return this;
938    }
939
940    /**
941     * @return {@link #category} (A category assigned to the condition.)
942     */
943    public CodeableConcept getCategory() { 
944      if (this.category == null)
945        if (Configuration.errorOnAutoCreate())
946          throw new Error("Attempt to auto-create Condition.category");
947        else if (Configuration.doAutoCreate())
948          this.category = new CodeableConcept(); // cc
949      return this.category;
950    }
951
952    public boolean hasCategory() { 
953      return this.category != null && !this.category.isEmpty();
954    }
955
956    /**
957     * @param value {@link #category} (A category assigned to the condition.)
958     */
959    public Condition setCategory(CodeableConcept value) { 
960      this.category = value;
961      return this;
962    }
963
964    /**
965     * @return {@link #clinicalStatus} (The clinical status of the condition.). This is the underlying object with id, value and extensions. The accessor "getClinicalStatus" gives direct access to the value
966     */
967    public CodeType getClinicalStatusElement() { 
968      if (this.clinicalStatus == null)
969        if (Configuration.errorOnAutoCreate())
970          throw new Error("Attempt to auto-create Condition.clinicalStatus");
971        else if (Configuration.doAutoCreate())
972          this.clinicalStatus = new CodeType(); // bb
973      return this.clinicalStatus;
974    }
975
976    public boolean hasClinicalStatusElement() { 
977      return this.clinicalStatus != null && !this.clinicalStatus.isEmpty();
978    }
979
980    public boolean hasClinicalStatus() { 
981      return this.clinicalStatus != null && !this.clinicalStatus.isEmpty();
982    }
983
984    /**
985     * @param value {@link #clinicalStatus} (The clinical status of the condition.). This is the underlying object with id, value and extensions. The accessor "getClinicalStatus" gives direct access to the value
986     */
987    public Condition setClinicalStatusElement(CodeType value) { 
988      this.clinicalStatus = value;
989      return this;
990    }
991
992    /**
993     * @return The clinical status of the condition.
994     */
995    public String getClinicalStatus() { 
996      return this.clinicalStatus == null ? null : this.clinicalStatus.getValue();
997    }
998
999    /**
1000     * @param value The clinical status of the condition.
1001     */
1002    public Condition setClinicalStatus(String value) { 
1003      if (Utilities.noString(value))
1004        this.clinicalStatus = null;
1005      else {
1006        if (this.clinicalStatus == null)
1007          this.clinicalStatus = new CodeType();
1008        this.clinicalStatus.setValue(value);
1009      }
1010      return this;
1011    }
1012
1013    /**
1014     * @return {@link #verificationStatus} (The verification status to support the clinical status of the condition.). This is the underlying object with id, value and extensions. The accessor "getVerificationStatus" gives direct access to the value
1015     */
1016    public Enumeration<ConditionVerificationStatus> getVerificationStatusElement() { 
1017      if (this.verificationStatus == null)
1018        if (Configuration.errorOnAutoCreate())
1019          throw new Error("Attempt to auto-create Condition.verificationStatus");
1020        else if (Configuration.doAutoCreate())
1021          this.verificationStatus = new Enumeration<ConditionVerificationStatus>(new ConditionVerificationStatusEnumFactory()); // bb
1022      return this.verificationStatus;
1023    }
1024
1025    public boolean hasVerificationStatusElement() { 
1026      return this.verificationStatus != null && !this.verificationStatus.isEmpty();
1027    }
1028
1029    public boolean hasVerificationStatus() { 
1030      return this.verificationStatus != null && !this.verificationStatus.isEmpty();
1031    }
1032
1033    /**
1034     * @param value {@link #verificationStatus} (The verification status to support the clinical status of the condition.). This is the underlying object with id, value and extensions. The accessor "getVerificationStatus" gives direct access to the value
1035     */
1036    public Condition setVerificationStatusElement(Enumeration<ConditionVerificationStatus> value) { 
1037      this.verificationStatus = value;
1038      return this;
1039    }
1040
1041    /**
1042     * @return The verification status to support the clinical status of the condition.
1043     */
1044    public ConditionVerificationStatus getVerificationStatus() { 
1045      return this.verificationStatus == null ? null : this.verificationStatus.getValue();
1046    }
1047
1048    /**
1049     * @param value The verification status to support the clinical status of the condition.
1050     */
1051    public Condition setVerificationStatus(ConditionVerificationStatus value) { 
1052        if (this.verificationStatus == null)
1053          this.verificationStatus = new Enumeration<ConditionVerificationStatus>(new ConditionVerificationStatusEnumFactory());
1054        this.verificationStatus.setValue(value);
1055      return this;
1056    }
1057
1058    /**
1059     * @return {@link #severity} (A subjective assessment of the severity of the condition as evaluated by the clinician.)
1060     */
1061    public CodeableConcept getSeverity() { 
1062      if (this.severity == null)
1063        if (Configuration.errorOnAutoCreate())
1064          throw new Error("Attempt to auto-create Condition.severity");
1065        else if (Configuration.doAutoCreate())
1066          this.severity = new CodeableConcept(); // cc
1067      return this.severity;
1068    }
1069
1070    public boolean hasSeverity() { 
1071      return this.severity != null && !this.severity.isEmpty();
1072    }
1073
1074    /**
1075     * @param value {@link #severity} (A subjective assessment of the severity of the condition as evaluated by the clinician.)
1076     */
1077    public Condition setSeverity(CodeableConcept value) { 
1078      this.severity = value;
1079      return this;
1080    }
1081
1082    /**
1083     * @return {@link #onset} (Estimated or actual date or date-time  the condition began, in the opinion of the clinician.)
1084     */
1085    public Type getOnset() { 
1086      return this.onset;
1087    }
1088
1089    /**
1090     * @return {@link #onset} (Estimated or actual date or date-time  the condition began, in the opinion of the clinician.)
1091     */
1092    public DateTimeType getOnsetDateTimeType() throws FHIRException { 
1093      if (!(this.onset instanceof DateTimeType))
1094        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.onset.getClass().getName()+" was encountered");
1095      return (DateTimeType) this.onset;
1096    }
1097
1098    public boolean hasOnsetDateTimeType() { 
1099      return this.onset instanceof DateTimeType;
1100    }
1101
1102    /**
1103     * @return {@link #onset} (Estimated or actual date or date-time  the condition began, in the opinion of the clinician.)
1104     */
1105    public Age getOnsetAge() throws FHIRException { 
1106      if (!(this.onset instanceof Age))
1107        throw new FHIRException("Type mismatch: the type Age was expected, but "+this.onset.getClass().getName()+" was encountered");
1108      return (Age) this.onset;
1109    }
1110
1111    public boolean hasOnsetAge() { 
1112      return this.onset instanceof Age;
1113    }
1114
1115    /**
1116     * @return {@link #onset} (Estimated or actual date or date-time  the condition began, in the opinion of the clinician.)
1117     */
1118    public Period getOnsetPeriod() throws FHIRException { 
1119      if (!(this.onset instanceof Period))
1120        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.onset.getClass().getName()+" was encountered");
1121      return (Period) this.onset;
1122    }
1123
1124    public boolean hasOnsetPeriod() { 
1125      return this.onset instanceof Period;
1126    }
1127
1128    /**
1129     * @return {@link #onset} (Estimated or actual date or date-time  the condition began, in the opinion of the clinician.)
1130     */
1131    public Range getOnsetRange() throws FHIRException { 
1132      if (!(this.onset instanceof Range))
1133        throw new FHIRException("Type mismatch: the type Range was expected, but "+this.onset.getClass().getName()+" was encountered");
1134      return (Range) this.onset;
1135    }
1136
1137    public boolean hasOnsetRange() { 
1138      return this.onset instanceof Range;
1139    }
1140
1141    /**
1142     * @return {@link #onset} (Estimated or actual date or date-time  the condition began, in the opinion of the clinician.)
1143     */
1144    public StringType getOnsetStringType() throws FHIRException { 
1145      if (!(this.onset instanceof StringType))
1146        throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.onset.getClass().getName()+" was encountered");
1147      return (StringType) this.onset;
1148    }
1149
1150    public boolean hasOnsetStringType() { 
1151      return this.onset instanceof StringType;
1152    }
1153
1154    public boolean hasOnset() { 
1155      return this.onset != null && !this.onset.isEmpty();
1156    }
1157
1158    /**
1159     * @param value {@link #onset} (Estimated or actual date or date-time  the condition began, in the opinion of the clinician.)
1160     */
1161    public Condition setOnset(Type value) { 
1162      this.onset = value;
1163      return this;
1164    }
1165
1166    /**
1167     * @return {@link #abatement} (The date or estimated date that the condition resolved or went into remission. This is called "abatement" because of the many overloaded connotations associated with "remission" or "resolution" - Conditions are never really resolved, but they can abate.)
1168     */
1169    public Type getAbatement() { 
1170      return this.abatement;
1171    }
1172
1173    /**
1174     * @return {@link #abatement} (The date or estimated date that the condition resolved or went into remission. This is called "abatement" because of the many overloaded connotations associated with "remission" or "resolution" - Conditions are never really resolved, but they can abate.)
1175     */
1176    public DateTimeType getAbatementDateTimeType() throws FHIRException { 
1177      if (!(this.abatement instanceof DateTimeType))
1178        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.abatement.getClass().getName()+" was encountered");
1179      return (DateTimeType) this.abatement;
1180    }
1181
1182    public boolean hasAbatementDateTimeType() { 
1183      return this.abatement instanceof DateTimeType;
1184    }
1185
1186    /**
1187     * @return {@link #abatement} (The date or estimated date that the condition resolved or went into remission. This is called "abatement" because of the many overloaded connotations associated with "remission" or "resolution" - Conditions are never really resolved, but they can abate.)
1188     */
1189    public Age getAbatementAge() throws FHIRException { 
1190      if (!(this.abatement instanceof Age))
1191        throw new FHIRException("Type mismatch: the type Age was expected, but "+this.abatement.getClass().getName()+" was encountered");
1192      return (Age) this.abatement;
1193    }
1194
1195    public boolean hasAbatementAge() { 
1196      return this.abatement instanceof Age;
1197    }
1198
1199    /**
1200     * @return {@link #abatement} (The date or estimated date that the condition resolved or went into remission. This is called "abatement" because of the many overloaded connotations associated with "remission" or "resolution" - Conditions are never really resolved, but they can abate.)
1201     */
1202    public BooleanType getAbatementBooleanType() throws FHIRException { 
1203      if (!(this.abatement instanceof BooleanType))
1204        throw new FHIRException("Type mismatch: the type BooleanType was expected, but "+this.abatement.getClass().getName()+" was encountered");
1205      return (BooleanType) this.abatement;
1206    }
1207
1208    public boolean hasAbatementBooleanType() { 
1209      return this.abatement instanceof BooleanType;
1210    }
1211
1212    /**
1213     * @return {@link #abatement} (The date or estimated date that the condition resolved or went into remission. This is called "abatement" because of the many overloaded connotations associated with "remission" or "resolution" - Conditions are never really resolved, but they can abate.)
1214     */
1215    public Period getAbatementPeriod() throws FHIRException { 
1216      if (!(this.abatement instanceof Period))
1217        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.abatement.getClass().getName()+" was encountered");
1218      return (Period) this.abatement;
1219    }
1220
1221    public boolean hasAbatementPeriod() { 
1222      return this.abatement instanceof Period;
1223    }
1224
1225    /**
1226     * @return {@link #abatement} (The date or estimated date that the condition resolved or went into remission. This is called "abatement" because of the many overloaded connotations associated with "remission" or "resolution" - Conditions are never really resolved, but they can abate.)
1227     */
1228    public Range getAbatementRange() throws FHIRException { 
1229      if (!(this.abatement instanceof Range))
1230        throw new FHIRException("Type mismatch: the type Range was expected, but "+this.abatement.getClass().getName()+" was encountered");
1231      return (Range) this.abatement;
1232    }
1233
1234    public boolean hasAbatementRange() { 
1235      return this.abatement instanceof Range;
1236    }
1237
1238    /**
1239     * @return {@link #abatement} (The date or estimated date that the condition resolved or went into remission. This is called "abatement" because of the many overloaded connotations associated with "remission" or "resolution" - Conditions are never really resolved, but they can abate.)
1240     */
1241    public StringType getAbatementStringType() throws FHIRException { 
1242      if (!(this.abatement instanceof StringType))
1243        throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.abatement.getClass().getName()+" was encountered");
1244      return (StringType) this.abatement;
1245    }
1246
1247    public boolean hasAbatementStringType() { 
1248      return this.abatement instanceof StringType;
1249    }
1250
1251    public boolean hasAbatement() { 
1252      return this.abatement != null && !this.abatement.isEmpty();
1253    }
1254
1255    /**
1256     * @param value {@link #abatement} (The date or estimated date that the condition resolved or went into remission. This is called "abatement" because of the many overloaded connotations associated with "remission" or "resolution" - Conditions are never really resolved, but they can abate.)
1257     */
1258    public Condition setAbatement(Type value) { 
1259      this.abatement = value;
1260      return this;
1261    }
1262
1263    /**
1264     * @return {@link #stage} (Clinical stage or grade of a condition. May include formal severity assessments.)
1265     */
1266    public ConditionStageComponent getStage() { 
1267      if (this.stage == null)
1268        if (Configuration.errorOnAutoCreate())
1269          throw new Error("Attempt to auto-create Condition.stage");
1270        else if (Configuration.doAutoCreate())
1271          this.stage = new ConditionStageComponent(); // cc
1272      return this.stage;
1273    }
1274
1275    public boolean hasStage() { 
1276      return this.stage != null && !this.stage.isEmpty();
1277    }
1278
1279    /**
1280     * @param value {@link #stage} (Clinical stage or grade of a condition. May include formal severity assessments.)
1281     */
1282    public Condition setStage(ConditionStageComponent value) { 
1283      this.stage = value;
1284      return this;
1285    }
1286
1287    /**
1288     * @return {@link #evidence} (Supporting Evidence / manifestations that are the basis on which this condition is suspected or confirmed.)
1289     */
1290    public List<ConditionEvidenceComponent> getEvidence() { 
1291      if (this.evidence == null)
1292        this.evidence = new ArrayList<ConditionEvidenceComponent>();
1293      return this.evidence;
1294    }
1295
1296    public boolean hasEvidence() { 
1297      if (this.evidence == null)
1298        return false;
1299      for (ConditionEvidenceComponent item : this.evidence)
1300        if (!item.isEmpty())
1301          return true;
1302      return false;
1303    }
1304
1305    /**
1306     * @return {@link #evidence} (Supporting Evidence / manifestations that are the basis on which this condition is suspected or confirmed.)
1307     */
1308    // syntactic sugar
1309    public ConditionEvidenceComponent addEvidence() { //3
1310      ConditionEvidenceComponent t = new ConditionEvidenceComponent();
1311      if (this.evidence == null)
1312        this.evidence = new ArrayList<ConditionEvidenceComponent>();
1313      this.evidence.add(t);
1314      return t;
1315    }
1316
1317    // syntactic sugar
1318    public Condition addEvidence(ConditionEvidenceComponent t) { //3
1319      if (t == null)
1320        return this;
1321      if (this.evidence == null)
1322        this.evidence = new ArrayList<ConditionEvidenceComponent>();
1323      this.evidence.add(t);
1324      return this;
1325    }
1326
1327    /**
1328     * @return {@link #bodySite} (The anatomical location where this condition manifests itself.)
1329     */
1330    public List<CodeableConcept> getBodySite() { 
1331      if (this.bodySite == null)
1332        this.bodySite = new ArrayList<CodeableConcept>();
1333      return this.bodySite;
1334    }
1335
1336    public boolean hasBodySite() { 
1337      if (this.bodySite == null)
1338        return false;
1339      for (CodeableConcept item : this.bodySite)
1340        if (!item.isEmpty())
1341          return true;
1342      return false;
1343    }
1344
1345    /**
1346     * @return {@link #bodySite} (The anatomical location where this condition manifests itself.)
1347     */
1348    // syntactic sugar
1349    public CodeableConcept addBodySite() { //3
1350      CodeableConcept t = new CodeableConcept();
1351      if (this.bodySite == null)
1352        this.bodySite = new ArrayList<CodeableConcept>();
1353      this.bodySite.add(t);
1354      return t;
1355    }
1356
1357    // syntactic sugar
1358    public Condition addBodySite(CodeableConcept t) { //3
1359      if (t == null)
1360        return this;
1361      if (this.bodySite == null)
1362        this.bodySite = new ArrayList<CodeableConcept>();
1363      this.bodySite.add(t);
1364      return this;
1365    }
1366
1367    /**
1368     * @return {@link #notes} (Additional information about the Condition. This is a general notes/comments entry  for description of the Condition, its diagnosis and prognosis.). This is the underlying object with id, value and extensions. The accessor "getNotes" gives direct access to the value
1369     */
1370    public StringType getNotesElement() { 
1371      if (this.notes == null)
1372        if (Configuration.errorOnAutoCreate())
1373          throw new Error("Attempt to auto-create Condition.notes");
1374        else if (Configuration.doAutoCreate())
1375          this.notes = new StringType(); // bb
1376      return this.notes;
1377    }
1378
1379    public boolean hasNotesElement() { 
1380      return this.notes != null && !this.notes.isEmpty();
1381    }
1382
1383    public boolean hasNotes() { 
1384      return this.notes != null && !this.notes.isEmpty();
1385    }
1386
1387    /**
1388     * @param value {@link #notes} (Additional information about the Condition. This is a general notes/comments entry  for description of the Condition, its diagnosis and prognosis.). This is the underlying object with id, value and extensions. The accessor "getNotes" gives direct access to the value
1389     */
1390    public Condition setNotesElement(StringType value) { 
1391      this.notes = value;
1392      return this;
1393    }
1394
1395    /**
1396     * @return Additional information about the Condition. This is a general notes/comments entry  for description of the Condition, its diagnosis and prognosis.
1397     */
1398    public String getNotes() { 
1399      return this.notes == null ? null : this.notes.getValue();
1400    }
1401
1402    /**
1403     * @param value Additional information about the Condition. This is a general notes/comments entry  for description of the Condition, its diagnosis and prognosis.
1404     */
1405    public Condition setNotes(String value) { 
1406      if (Utilities.noString(value))
1407        this.notes = null;
1408      else {
1409        if (this.notes == null)
1410          this.notes = new StringType();
1411        this.notes.setValue(value);
1412      }
1413      return this;
1414    }
1415
1416      protected void listChildren(List<Property> childrenList) {
1417        super.listChildren(childrenList);
1418        childrenList.add(new Property("identifier", "Identifier", "This records identifiers associated with this condition that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).", 0, java.lang.Integer.MAX_VALUE, identifier));
1419        childrenList.add(new Property("patient", "Reference(Patient)", "Indicates the patient who the condition record is associated with.", 0, java.lang.Integer.MAX_VALUE, patient));
1420        childrenList.add(new Property("encounter", "Reference(Encounter)", "Encounter during which the condition was first asserted.", 0, java.lang.Integer.MAX_VALUE, encounter));
1421        childrenList.add(new Property("asserter", "Reference(Practitioner|Patient)", "Individual who is making the condition statement.", 0, java.lang.Integer.MAX_VALUE, asserter));
1422        childrenList.add(new Property("dateRecorded", "date", "A date, when  the Condition statement was documented.", 0, java.lang.Integer.MAX_VALUE, dateRecorded));
1423        childrenList.add(new Property("code", "CodeableConcept", "Identification of the condition, problem or diagnosis.", 0, java.lang.Integer.MAX_VALUE, code));
1424        childrenList.add(new Property("category", "CodeableConcept", "A category assigned to the condition.", 0, java.lang.Integer.MAX_VALUE, category));
1425        childrenList.add(new Property("clinicalStatus", "code", "The clinical status of the condition.", 0, java.lang.Integer.MAX_VALUE, clinicalStatus));
1426        childrenList.add(new Property("verificationStatus", "code", "The verification status to support the clinical status of the condition.", 0, java.lang.Integer.MAX_VALUE, verificationStatus));
1427        childrenList.add(new Property("severity", "CodeableConcept", "A subjective assessment of the severity of the condition as evaluated by the clinician.", 0, java.lang.Integer.MAX_VALUE, severity));
1428        childrenList.add(new Property("onset[x]", "dateTime|Age|Period|Range|string", "Estimated or actual date or date-time  the condition began, in the opinion of the clinician.", 0, java.lang.Integer.MAX_VALUE, onset));
1429        childrenList.add(new Property("abatement[x]", "dateTime|Age|boolean|Period|Range|string", "The date or estimated date that the condition resolved or went into remission. This is called \"abatement\" because of the many overloaded connotations associated with \"remission\" or \"resolution\" - Conditions are never really resolved, but they can abate.", 0, java.lang.Integer.MAX_VALUE, abatement));
1430        childrenList.add(new Property("stage", "", "Clinical stage or grade of a condition. May include formal severity assessments.", 0, java.lang.Integer.MAX_VALUE, stage));
1431        childrenList.add(new Property("evidence", "", "Supporting Evidence / manifestations that are the basis on which this condition is suspected or confirmed.", 0, java.lang.Integer.MAX_VALUE, evidence));
1432        childrenList.add(new Property("bodySite", "CodeableConcept", "The anatomical location where this condition manifests itself.", 0, java.lang.Integer.MAX_VALUE, bodySite));
1433        childrenList.add(new Property("notes", "string", "Additional information about the Condition. This is a general notes/comments entry  for description of the Condition, its diagnosis and prognosis.", 0, java.lang.Integer.MAX_VALUE, notes));
1434      }
1435
1436      @Override
1437      public void setProperty(String name, Base value) throws FHIRException {
1438        if (name.equals("identifier"))
1439          this.getIdentifier().add(castToIdentifier(value));
1440        else if (name.equals("patient"))
1441          this.patient = castToReference(value); // Reference
1442        else if (name.equals("encounter"))
1443          this.encounter = castToReference(value); // Reference
1444        else if (name.equals("asserter"))
1445          this.asserter = castToReference(value); // Reference
1446        else if (name.equals("dateRecorded"))
1447          this.dateRecorded = castToDate(value); // DateType
1448        else if (name.equals("code"))
1449          this.code = castToCodeableConcept(value); // CodeableConcept
1450        else if (name.equals("category"))
1451          this.category = castToCodeableConcept(value); // CodeableConcept
1452        else if (name.equals("clinicalStatus"))
1453          this.clinicalStatus = castToCode(value); // CodeType
1454        else if (name.equals("verificationStatus"))
1455          this.verificationStatus = new ConditionVerificationStatusEnumFactory().fromType(value); // Enumeration<ConditionVerificationStatus>
1456        else if (name.equals("severity"))
1457          this.severity = castToCodeableConcept(value); // CodeableConcept
1458        else if (name.equals("onset[x]"))
1459          this.onset = (Type) value; // Type
1460        else if (name.equals("abatement[x]"))
1461          this.abatement = (Type) value; // Type
1462        else if (name.equals("stage"))
1463          this.stage = (ConditionStageComponent) value; // ConditionStageComponent
1464        else if (name.equals("evidence"))
1465          this.getEvidence().add((ConditionEvidenceComponent) value);
1466        else if (name.equals("bodySite"))
1467          this.getBodySite().add(castToCodeableConcept(value));
1468        else if (name.equals("notes"))
1469          this.notes = castToString(value); // StringType
1470        else
1471          super.setProperty(name, value);
1472      }
1473
1474      @Override
1475      public Base addChild(String name) throws FHIRException {
1476        if (name.equals("identifier")) {
1477          return addIdentifier();
1478        }
1479        else if (name.equals("patient")) {
1480          this.patient = new Reference();
1481          return this.patient;
1482        }
1483        else if (name.equals("encounter")) {
1484          this.encounter = new Reference();
1485          return this.encounter;
1486        }
1487        else if (name.equals("asserter")) {
1488          this.asserter = new Reference();
1489          return this.asserter;
1490        }
1491        else if (name.equals("dateRecorded")) {
1492          throw new FHIRException("Cannot call addChild on a primitive type Condition.dateRecorded");
1493        }
1494        else if (name.equals("code")) {
1495          this.code = new CodeableConcept();
1496          return this.code;
1497        }
1498        else if (name.equals("category")) {
1499          this.category = new CodeableConcept();
1500          return this.category;
1501        }
1502        else if (name.equals("clinicalStatus")) {
1503          throw new FHIRException("Cannot call addChild on a primitive type Condition.clinicalStatus");
1504        }
1505        else if (name.equals("verificationStatus")) {
1506          throw new FHIRException("Cannot call addChild on a primitive type Condition.verificationStatus");
1507        }
1508        else if (name.equals("severity")) {
1509          this.severity = new CodeableConcept();
1510          return this.severity;
1511        }
1512        else if (name.equals("onsetDateTime")) {
1513          this.onset = new DateTimeType();
1514          return this.onset;
1515        }
1516        else if (name.equals("onsetAge")) {
1517          this.onset = new Age();
1518          return this.onset;
1519        }
1520        else if (name.equals("onsetPeriod")) {
1521          this.onset = new Period();
1522          return this.onset;
1523        }
1524        else if (name.equals("onsetRange")) {
1525          this.onset = new Range();
1526          return this.onset;
1527        }
1528        else if (name.equals("onsetString")) {
1529          this.onset = new StringType();
1530          return this.onset;
1531        }
1532        else if (name.equals("abatementDateTime")) {
1533          this.abatement = new DateTimeType();
1534          return this.abatement;
1535        }
1536        else if (name.equals("abatementAge")) {
1537          this.abatement = new Age();
1538          return this.abatement;
1539        }
1540        else if (name.equals("abatementBoolean")) {
1541          this.abatement = new BooleanType();
1542          return this.abatement;
1543        }
1544        else if (name.equals("abatementPeriod")) {
1545          this.abatement = new Period();
1546          return this.abatement;
1547        }
1548        else if (name.equals("abatementRange")) {
1549          this.abatement = new Range();
1550          return this.abatement;
1551        }
1552        else if (name.equals("abatementString")) {
1553          this.abatement = new StringType();
1554          return this.abatement;
1555        }
1556        else if (name.equals("stage")) {
1557          this.stage = new ConditionStageComponent();
1558          return this.stage;
1559        }
1560        else if (name.equals("evidence")) {
1561          return addEvidence();
1562        }
1563        else if (name.equals("bodySite")) {
1564          return addBodySite();
1565        }
1566        else if (name.equals("notes")) {
1567          throw new FHIRException("Cannot call addChild on a primitive type Condition.notes");
1568        }
1569        else
1570          return super.addChild(name);
1571      }
1572
1573  public String fhirType() {
1574    return "Condition";
1575
1576  }
1577
1578      public Condition copy() {
1579        Condition dst = new Condition();
1580        copyValues(dst);
1581        if (identifier != null) {
1582          dst.identifier = new ArrayList<Identifier>();
1583          for (Identifier i : identifier)
1584            dst.identifier.add(i.copy());
1585        };
1586        dst.patient = patient == null ? null : patient.copy();
1587        dst.encounter = encounter == null ? null : encounter.copy();
1588        dst.asserter = asserter == null ? null : asserter.copy();
1589        dst.dateRecorded = dateRecorded == null ? null : dateRecorded.copy();
1590        dst.code = code == null ? null : code.copy();
1591        dst.category = category == null ? null : category.copy();
1592        dst.clinicalStatus = clinicalStatus == null ? null : clinicalStatus.copy();
1593        dst.verificationStatus = verificationStatus == null ? null : verificationStatus.copy();
1594        dst.severity = severity == null ? null : severity.copy();
1595        dst.onset = onset == null ? null : onset.copy();
1596        dst.abatement = abatement == null ? null : abatement.copy();
1597        dst.stage = stage == null ? null : stage.copy();
1598        if (evidence != null) {
1599          dst.evidence = new ArrayList<ConditionEvidenceComponent>();
1600          for (ConditionEvidenceComponent i : evidence)
1601            dst.evidence.add(i.copy());
1602        };
1603        if (bodySite != null) {
1604          dst.bodySite = new ArrayList<CodeableConcept>();
1605          for (CodeableConcept i : bodySite)
1606            dst.bodySite.add(i.copy());
1607        };
1608        dst.notes = notes == null ? null : notes.copy();
1609        return dst;
1610      }
1611
1612      protected Condition typedCopy() {
1613        return copy();
1614      }
1615
1616      @Override
1617      public boolean equalsDeep(Base other) {
1618        if (!super.equalsDeep(other))
1619          return false;
1620        if (!(other instanceof Condition))
1621          return false;
1622        Condition o = (Condition) other;
1623        return compareDeep(identifier, o.identifier, true) && compareDeep(patient, o.patient, true) && compareDeep(encounter, o.encounter, true)
1624           && compareDeep(asserter, o.asserter, true) && compareDeep(dateRecorded, o.dateRecorded, true) && compareDeep(code, o.code, true)
1625           && compareDeep(category, o.category, true) && compareDeep(clinicalStatus, o.clinicalStatus, true)
1626           && compareDeep(verificationStatus, o.verificationStatus, true) && compareDeep(severity, o.severity, true)
1627           && compareDeep(onset, o.onset, true) && compareDeep(abatement, o.abatement, true) && compareDeep(stage, o.stage, true)
1628           && compareDeep(evidence, o.evidence, true) && compareDeep(bodySite, o.bodySite, true) && compareDeep(notes, o.notes, true)
1629          ;
1630      }
1631
1632      @Override
1633      public boolean equalsShallow(Base other) {
1634        if (!super.equalsShallow(other))
1635          return false;
1636        if (!(other instanceof Condition))
1637          return false;
1638        Condition o = (Condition) other;
1639        return compareValues(dateRecorded, o.dateRecorded, true) && compareValues(clinicalStatus, o.clinicalStatus, true)
1640           && compareValues(verificationStatus, o.verificationStatus, true) && compareValues(notes, o.notes, true)
1641          ;
1642      }
1643
1644      public boolean isEmpty() {
1645        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (patient == null || patient.isEmpty())
1646           && (encounter == null || encounter.isEmpty()) && (asserter == null || asserter.isEmpty())
1647           && (dateRecorded == null || dateRecorded.isEmpty()) && (code == null || code.isEmpty()) && (category == null || category.isEmpty())
1648           && (clinicalStatus == null || clinicalStatus.isEmpty()) && (verificationStatus == null || verificationStatus.isEmpty())
1649           && (severity == null || severity.isEmpty()) && (onset == null || onset.isEmpty()) && (abatement == null || abatement.isEmpty())
1650           && (stage == null || stage.isEmpty()) && (evidence == null || evidence.isEmpty()) && (bodySite == null || bodySite.isEmpty())
1651           && (notes == null || notes.isEmpty());
1652      }
1653
1654  @Override
1655  public ResourceType getResourceType() {
1656    return ResourceType.Condition;
1657   }
1658
1659  @SearchParamDefinition(name="severity", path="Condition.severity", description="The severity of the condition", type="token" )
1660  public static final String SP_SEVERITY = "severity";
1661  @SearchParamDefinition(name="identifier", path="Condition.identifier", description="A unique identifier of the condition record", type="token" )
1662  public static final String SP_IDENTIFIER = "identifier";
1663  @SearchParamDefinition(name="clinicalstatus", path="Condition.clinicalStatus", description="The clinical status of the condition", type="token" )
1664  public static final String SP_CLINICALSTATUS = "clinicalstatus";
1665  @SearchParamDefinition(name="onset-info", path="Condition.onset[x]", description="Other onsets (boolean, age, range, string)", type="string" )
1666  public static final String SP_ONSETINFO = "onset-info";
1667  @SearchParamDefinition(name="code", path="Condition.code", description="Code for the condition", type="token" )
1668  public static final String SP_CODE = "code";
1669  @SearchParamDefinition(name="evidence", path="Condition.evidence.code", description="Manifestation/symptom", type="token" )
1670  public static final String SP_EVIDENCE = "evidence";
1671  @SearchParamDefinition(name="encounter", path="Condition.encounter", description="Encounter when condition first asserted", type="reference" )
1672  public static final String SP_ENCOUNTER = "encounter";
1673  @SearchParamDefinition(name="onset", path="Condition.onset[x]", description="Date related onsets (dateTime and Period)", type="date" )
1674  public static final String SP_ONSET = "onset";
1675  @SearchParamDefinition(name="asserter", path="Condition.asserter", description="Person who asserts this condition", type="reference" )
1676  public static final String SP_ASSERTER = "asserter";
1677  @SearchParamDefinition(name="date-recorded", path="Condition.dateRecorded", description="A date, when the Condition statement was documented", type="date" )
1678  public static final String SP_DATERECORDED = "date-recorded";
1679  @SearchParamDefinition(name="stage", path="Condition.stage.summary", description="Simple summary (disease specific)", type="token" )
1680  public static final String SP_STAGE = "stage";
1681  @SearchParamDefinition(name="patient", path="Condition.patient", description="Who has the condition?", type="reference" )
1682  public static final String SP_PATIENT = "patient";
1683  @SearchParamDefinition(name="category", path="Condition.category", description="The category of the condition", type="token" )
1684  public static final String SP_CATEGORY = "category";
1685  @SearchParamDefinition(name="body-site", path="Condition.bodySite", description="Anatomical location, if relevant", type="token" )
1686  public static final String SP_BODYSITE = "body-site";
1687
1688}