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