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 org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender;
038import org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGenderEnumFactory;
039import ca.uhn.fhir.model.api.annotation.Block;
040import ca.uhn.fhir.model.api.annotation.Child;
041import ca.uhn.fhir.model.api.annotation.Description;
042import ca.uhn.fhir.model.api.annotation.ResourceDef;
043import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
044import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
045import org.hl7.fhir.exceptions.FHIRException;
046import org.hl7.fhir.utilities.Utilities;
047
048/**
049 * Significant health events and conditions for a person related to the patient
050 * relevant in the context of care for the patient.
051 */
052@ResourceDef(name = "FamilyMemberHistory", profile = "http://hl7.org/fhir/Profile/FamilyMemberHistory")
053public class FamilyMemberHistory extends DomainResource {
054
055  public enum FamilyHistoryStatus {
056    /**
057     * Some health information is known and captured, but not complete - see notes
058     * for details.
059     */
060    PARTIAL,
061    /**
062     * All relevant health information is known and captured.
063     */
064    COMPLETED,
065    /**
066     * This instance should not have been part of this patient's medical record.
067     */
068    ENTEREDINERROR,
069    /**
070     * Health information for this individual is unavailable/unknown.
071     */
072    HEALTHUNKNOWN,
073    /**
074     * added to help the parsers
075     */
076    NULL;
077
078    public static FamilyHistoryStatus fromCode(String codeString) throws FHIRException {
079      if (codeString == null || "".equals(codeString))
080        return null;
081      if ("partial".equals(codeString))
082        return PARTIAL;
083      if ("completed".equals(codeString))
084        return COMPLETED;
085      if ("entered-in-error".equals(codeString))
086        return ENTEREDINERROR;
087      if ("health-unknown".equals(codeString))
088        return HEALTHUNKNOWN;
089      throw new FHIRException("Unknown FamilyHistoryStatus code '" + codeString + "'");
090    }
091
092    public String toCode() {
093      switch (this) {
094      case PARTIAL:
095        return "partial";
096      case COMPLETED:
097        return "completed";
098      case ENTEREDINERROR:
099        return "entered-in-error";
100      case HEALTHUNKNOWN:
101        return "health-unknown";
102      case NULL:
103        return null;
104      default:
105        return "?";
106      }
107    }
108
109    public String getSystem() {
110      switch (this) {
111      case PARTIAL:
112        return "http://hl7.org/fhir/history-status";
113      case COMPLETED:
114        return "http://hl7.org/fhir/history-status";
115      case ENTEREDINERROR:
116        return "http://hl7.org/fhir/history-status";
117      case HEALTHUNKNOWN:
118        return "http://hl7.org/fhir/history-status";
119      case NULL:
120        return null;
121      default:
122        return "?";
123      }
124    }
125
126    public String getDefinition() {
127      switch (this) {
128      case PARTIAL:
129        return "Some health information is known and captured, but not complete - see notes for details.";
130      case COMPLETED:
131        return "All relevant health information is known and captured.";
132      case ENTEREDINERROR:
133        return "This instance should not have been part of this patient's medical record.";
134      case HEALTHUNKNOWN:
135        return "Health information for this individual is unavailable/unknown.";
136      case NULL:
137        return null;
138      default:
139        return "?";
140      }
141    }
142
143    public String getDisplay() {
144      switch (this) {
145      case PARTIAL:
146        return "Partial";
147      case COMPLETED:
148        return "Completed";
149      case ENTEREDINERROR:
150        return "Entered in error";
151      case HEALTHUNKNOWN:
152        return "Health unknown";
153      case NULL:
154        return null;
155      default:
156        return "?";
157      }
158    }
159  }
160
161  public static class FamilyHistoryStatusEnumFactory implements EnumFactory<FamilyHistoryStatus> {
162    public FamilyHistoryStatus fromCode(String codeString) throws IllegalArgumentException {
163      if (codeString == null || "".equals(codeString))
164        if (codeString == null || "".equals(codeString))
165          return null;
166      if ("partial".equals(codeString))
167        return FamilyHistoryStatus.PARTIAL;
168      if ("completed".equals(codeString))
169        return FamilyHistoryStatus.COMPLETED;
170      if ("entered-in-error".equals(codeString))
171        return FamilyHistoryStatus.ENTEREDINERROR;
172      if ("health-unknown".equals(codeString))
173        return FamilyHistoryStatus.HEALTHUNKNOWN;
174      throw new IllegalArgumentException("Unknown FamilyHistoryStatus code '" + codeString + "'");
175    }
176
177    public Enumeration<FamilyHistoryStatus> fromType(Base code) throws FHIRException {
178      if (code == null || code.isEmpty())
179        return null;
180      String codeString = ((PrimitiveType) code).asStringValue();
181      if (codeString == null || "".equals(codeString))
182        return null;
183      if ("partial".equals(codeString))
184        return new Enumeration<FamilyHistoryStatus>(this, FamilyHistoryStatus.PARTIAL);
185      if ("completed".equals(codeString))
186        return new Enumeration<FamilyHistoryStatus>(this, FamilyHistoryStatus.COMPLETED);
187      if ("entered-in-error".equals(codeString))
188        return new Enumeration<FamilyHistoryStatus>(this, FamilyHistoryStatus.ENTEREDINERROR);
189      if ("health-unknown".equals(codeString))
190        return new Enumeration<FamilyHistoryStatus>(this, FamilyHistoryStatus.HEALTHUNKNOWN);
191      throw new FHIRException("Unknown FamilyHistoryStatus code '" + codeString + "'");
192    }
193
194    public String toCode(FamilyHistoryStatus code)
195   {
196       if (code == FamilyHistoryStatus.NULL)
197           return null;
198       if (code == FamilyHistoryStatus.PARTIAL)
199        return "partial";
200      if (code == FamilyHistoryStatus.COMPLETED)
201        return "completed";
202      if (code == FamilyHistoryStatus.ENTEREDINERROR)
203        return "entered-in-error";
204      if (code == FamilyHistoryStatus.HEALTHUNKNOWN)
205        return "health-unknown";
206      return "?";
207   }
208  }
209
210  @Block()
211  public static class FamilyMemberHistoryConditionComponent extends BackboneElement implements IBaseBackboneElement {
212    /**
213     * The actual condition specified. Could be a coded condition (like MI or
214     * Diabetes) or a less specific string like 'cancer' depending on how much is
215     * known about the condition and the capabilities of the creating system.
216     */
217    @Child(name = "code", type = {
218        CodeableConcept.class }, order = 1, min = 1, max = 1, modifier = false, summary = false)
219    @Description(shortDefinition = "Condition suffered by relation", formalDefinition = "The actual condition specified. Could be a coded condition (like MI or Diabetes) or a less specific string like 'cancer' depending on how much is known about the condition and the capabilities of the creating system.")
220    protected CodeableConcept code;
221
222    /**
223     * Indicates what happened as a result of this condition. If the condition
224     * resulted in death, deceased date is captured on the relation.
225     */
226    @Child(name = "outcome", type = {
227        CodeableConcept.class }, order = 2, min = 0, max = 1, modifier = false, summary = false)
228    @Description(shortDefinition = "deceased | permanent disability | etc.", formalDefinition = "Indicates what happened as a result of this condition.  If the condition resulted in death, deceased date is captured on the relation.")
229    protected CodeableConcept outcome;
230
231    /**
232     * Either the age of onset, range of approximate age or descriptive string can
233     * be recorded. For conditions with multiple occurrences, this describes the
234     * first known occurrence.
235     */
236    @Child(name = "onset", type = { Age.class, Range.class, Period.class,
237        StringType.class }, order = 3, min = 0, max = 1, modifier = false, summary = false)
238    @Description(shortDefinition = "When condition first manifested", formalDefinition = "Either the age of onset, range of approximate age or descriptive string can be recorded.  For conditions with multiple occurrences, this describes the first known occurrence.")
239    protected Type onset;
240
241    /**
242     * An area where general notes can be placed about this specific condition.
243     */
244    @Child(name = "note", type = { Annotation.class }, order = 4, min = 0, max = 1, modifier = false, summary = false)
245    @Description(shortDefinition = "Extra information about condition", formalDefinition = "An area where general notes can be placed about this specific condition.")
246    protected Annotation note;
247
248    private static final long serialVersionUID = -1221569121L;
249
250    /*
251     * Constructor
252     */
253    public FamilyMemberHistoryConditionComponent() {
254      super();
255    }
256
257    /*
258     * Constructor
259     */
260    public FamilyMemberHistoryConditionComponent(CodeableConcept code) {
261      super();
262      this.code = code;
263    }
264
265    /**
266     * @return {@link #code} (The actual condition specified. Could be a coded
267     *         condition (like MI or Diabetes) or a less specific string like
268     *         'cancer' depending on how much is known about the condition and the
269     *         capabilities of the creating system.)
270     */
271    public CodeableConcept getCode() {
272      if (this.code == null)
273        if (Configuration.errorOnAutoCreate())
274          throw new Error("Attempt to auto-create FamilyMemberHistoryConditionComponent.code");
275        else if (Configuration.doAutoCreate())
276          this.code = new CodeableConcept(); // cc
277      return this.code;
278    }
279
280    public boolean hasCode() {
281      return this.code != null && !this.code.isEmpty();
282    }
283
284    /**
285     * @param value {@link #code} (The actual condition specified. Could be a coded
286     *              condition (like MI or Diabetes) or a less specific string like
287     *              'cancer' depending on how much is known about the condition and
288     *              the capabilities of the creating system.)
289     */
290    public FamilyMemberHistoryConditionComponent setCode(CodeableConcept value) {
291      this.code = value;
292      return this;
293    }
294
295    /**
296     * @return {@link #outcome} (Indicates what happened as a result of this
297     *         condition. If the condition resulted in death, deceased date is
298     *         captured on the relation.)
299     */
300    public CodeableConcept getOutcome() {
301      if (this.outcome == null)
302        if (Configuration.errorOnAutoCreate())
303          throw new Error("Attempt to auto-create FamilyMemberHistoryConditionComponent.outcome");
304        else if (Configuration.doAutoCreate())
305          this.outcome = new CodeableConcept(); // cc
306      return this.outcome;
307    }
308
309    public boolean hasOutcome() {
310      return this.outcome != null && !this.outcome.isEmpty();
311    }
312
313    /**
314     * @param value {@link #outcome} (Indicates what happened as a result of this
315     *              condition. If the condition resulted in death, deceased date is
316     *              captured on the relation.)
317     */
318    public FamilyMemberHistoryConditionComponent setOutcome(CodeableConcept value) {
319      this.outcome = value;
320      return this;
321    }
322
323    /**
324     * @return {@link #onset} (Either the age of onset, range of approximate age or
325     *         descriptive string can be recorded. For conditions with multiple
326     *         occurrences, this describes the first known occurrence.)
327     */
328    public Type getOnset() {
329      return this.onset;
330    }
331
332    /**
333     * @return {@link #onset} (Either the age of onset, range of approximate age or
334     *         descriptive string can be recorded. For conditions with multiple
335     *         occurrences, this describes the first known occurrence.)
336     */
337    public Age getOnsetAge() throws FHIRException {
338      if (!(this.onset instanceof Age))
339        throw new FHIRException(
340            "Type mismatch: the type Age was expected, but " + this.onset.getClass().getName() + " was encountered");
341      return (Age) this.onset;
342    }
343
344    public boolean hasOnsetAge() {
345      return this.onset instanceof Age;
346    }
347
348    /**
349     * @return {@link #onset} (Either the age of onset, range of approximate age or
350     *         descriptive string can be recorded. For conditions with multiple
351     *         occurrences, this describes the first known occurrence.)
352     */
353    public Range getOnsetRange() throws FHIRException {
354      if (!(this.onset instanceof Range))
355        throw new FHIRException(
356            "Type mismatch: the type Range was expected, but " + this.onset.getClass().getName() + " was encountered");
357      return (Range) this.onset;
358    }
359
360    public boolean hasOnsetRange() {
361      return this.onset instanceof Range;
362    }
363
364    /**
365     * @return {@link #onset} (Either the age of onset, range of approximate age or
366     *         descriptive string can be recorded. For conditions with multiple
367     *         occurrences, this describes the first known occurrence.)
368     */
369    public Period getOnsetPeriod() throws FHIRException {
370      if (!(this.onset instanceof Period))
371        throw new FHIRException(
372            "Type mismatch: the type Period was expected, but " + this.onset.getClass().getName() + " was encountered");
373      return (Period) this.onset;
374    }
375
376    public boolean hasOnsetPeriod() {
377      return this.onset instanceof Period;
378    }
379
380    /**
381     * @return {@link #onset} (Either the age of onset, range of approximate age or
382     *         descriptive string can be recorded. For conditions with multiple
383     *         occurrences, this describes the first known occurrence.)
384     */
385    public StringType getOnsetStringType() throws FHIRException {
386      if (!(this.onset instanceof StringType))
387        throw new FHIRException("Type mismatch: the type StringType was expected, but "
388            + this.onset.getClass().getName() + " was encountered");
389      return (StringType) this.onset;
390    }
391
392    public boolean hasOnsetStringType() {
393      return this.onset instanceof StringType;
394    }
395
396    public boolean hasOnset() {
397      return this.onset != null && !this.onset.isEmpty();
398    }
399
400    /**
401     * @param value {@link #onset} (Either the age of onset, range of approximate
402     *              age or descriptive string can be recorded. For conditions with
403     *              multiple occurrences, this describes the first known
404     *              occurrence.)
405     */
406    public FamilyMemberHistoryConditionComponent setOnset(Type value) {
407      this.onset = value;
408      return this;
409    }
410
411    /**
412     * @return {@link #note} (An area where general notes can be placed about this
413     *         specific condition.)
414     */
415    public Annotation getNote() {
416      if (this.note == null)
417        if (Configuration.errorOnAutoCreate())
418          throw new Error("Attempt to auto-create FamilyMemberHistoryConditionComponent.note");
419        else if (Configuration.doAutoCreate())
420          this.note = new Annotation(); // cc
421      return this.note;
422    }
423
424    public boolean hasNote() {
425      return this.note != null && !this.note.isEmpty();
426    }
427
428    /**
429     * @param value {@link #note} (An area where general notes can be placed about
430     *              this specific condition.)
431     */
432    public FamilyMemberHistoryConditionComponent setNote(Annotation value) {
433      this.note = value;
434      return this;
435    }
436
437    protected void listChildren(List<Property> childrenList) {
438      super.listChildren(childrenList);
439      childrenList.add(new Property("code", "CodeableConcept",
440          "The actual condition specified. Could be a coded condition (like MI or Diabetes) or a less specific string like 'cancer' depending on how much is known about the condition and the capabilities of the creating system.",
441          0, java.lang.Integer.MAX_VALUE, code));
442      childrenList.add(new Property("outcome", "CodeableConcept",
443          "Indicates what happened as a result of this condition.  If the condition resulted in death, deceased date is captured on the relation.",
444          0, java.lang.Integer.MAX_VALUE, outcome));
445      childrenList.add(new Property("onset[x]", "Age|Range|Period|string",
446          "Either the age of onset, range of approximate age or descriptive string can be recorded.  For conditions with multiple occurrences, this describes the first known occurrence.",
447          0, java.lang.Integer.MAX_VALUE, onset));
448      childrenList.add(
449          new Property("note", "Annotation", "An area where general notes can be placed about this specific condition.",
450              0, java.lang.Integer.MAX_VALUE, note));
451    }
452
453    @Override
454    public void setProperty(String name, Base value) throws FHIRException {
455      if (name.equals("code"))
456        this.code = castToCodeableConcept(value); // CodeableConcept
457      else if (name.equals("outcome"))
458        this.outcome = castToCodeableConcept(value); // CodeableConcept
459      else if (name.equals("onset[x]"))
460        this.onset = (Type) value; // Type
461      else if (name.equals("note"))
462        this.note = castToAnnotation(value); // Annotation
463      else
464        super.setProperty(name, value);
465    }
466
467    @Override
468    public Base addChild(String name) throws FHIRException {
469      if (name.equals("code")) {
470        this.code = new CodeableConcept();
471        return this.code;
472      } else if (name.equals("outcome")) {
473        this.outcome = new CodeableConcept();
474        return this.outcome;
475      } else if (name.equals("onsetAge")) {
476        this.onset = new Age();
477        return this.onset;
478      } else if (name.equals("onsetRange")) {
479        this.onset = new Range();
480        return this.onset;
481      } else if (name.equals("onsetPeriod")) {
482        this.onset = new Period();
483        return this.onset;
484      } else if (name.equals("onsetString")) {
485        this.onset = new StringType();
486        return this.onset;
487      } else if (name.equals("note")) {
488        this.note = new Annotation();
489        return this.note;
490      } else
491        return super.addChild(name);
492    }
493
494    public FamilyMemberHistoryConditionComponent copy() {
495      FamilyMemberHistoryConditionComponent dst = new FamilyMemberHistoryConditionComponent();
496      copyValues(dst);
497      dst.code = code == null ? null : code.copy();
498      dst.outcome = outcome == null ? null : outcome.copy();
499      dst.onset = onset == null ? null : onset.copy();
500      dst.note = note == null ? null : note.copy();
501      return dst;
502    }
503
504    @Override
505    public boolean equalsDeep(Base other) {
506      if (!super.equalsDeep(other))
507        return false;
508      if (!(other instanceof FamilyMemberHistoryConditionComponent))
509        return false;
510      FamilyMemberHistoryConditionComponent o = (FamilyMemberHistoryConditionComponent) other;
511      return compareDeep(code, o.code, true) && compareDeep(outcome, o.outcome, true)
512          && compareDeep(onset, o.onset, true) && compareDeep(note, o.note, true);
513    }
514
515    @Override
516    public boolean equalsShallow(Base other) {
517      if (!super.equalsShallow(other))
518        return false;
519      if (!(other instanceof FamilyMemberHistoryConditionComponent))
520        return false;
521      FamilyMemberHistoryConditionComponent o = (FamilyMemberHistoryConditionComponent) other;
522      return true;
523    }
524
525    public boolean isEmpty() {
526      return super.isEmpty() && (code == null || code.isEmpty()) && (outcome == null || outcome.isEmpty())
527          && (onset == null || onset.isEmpty()) && (note == null || note.isEmpty());
528    }
529
530    public String fhirType() {
531      return "FamilyMemberHistory.condition";
532
533    }
534
535  }
536
537  /**
538   * This records identifiers associated with this family member history record
539   * that are defined by business processes and/ or used to refer to it when a
540   * direct URL reference to the resource itself is not appropriate (e.g. in CDA
541   * documents, or in written / printed documentation).
542   */
543  @Child(name = "identifier", type = {
544      Identifier.class }, order = 0, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
545  @Description(shortDefinition = "External Id(s) for this record", formalDefinition = "This records identifiers associated with this family member history record 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).")
546  protected List<Identifier> identifier;
547
548  /**
549   * The person who this history concerns.
550   */
551  @Child(name = "patient", type = { Patient.class }, order = 1, min = 1, max = 1, modifier = false, summary = true)
552  @Description(shortDefinition = "Patient history is about", formalDefinition = "The person who this history concerns.")
553  protected Reference patient;
554
555  /**
556   * The actual object that is the target of the reference (The person who this
557   * history concerns.)
558   */
559  protected Patient patientTarget;
560
561  /**
562   * The date (and possibly time) when the family member history was taken.
563   */
564  @Child(name = "date", type = { DateTimeType.class }, order = 2, min = 0, max = 1, modifier = false, summary = true)
565  @Description(shortDefinition = "When history was captured/updated", formalDefinition = "The date (and possibly time) when the family member history was taken.")
566  protected DateTimeType date;
567
568  /**
569   * A code specifying a state of a Family Member History record.
570   */
571  @Child(name = "status", type = { CodeType.class }, order = 3, min = 1, max = 1, modifier = true, summary = true)
572  @Description(shortDefinition = "partial | completed | entered-in-error | health-unknown", formalDefinition = "A code specifying a state of a Family Member History record.")
573  protected Enumeration<FamilyHistoryStatus> status;
574
575  /**
576   * This will either be a name or a description; e.g. "Aunt Susan", "my cousin
577   * with the red hair".
578   */
579  @Child(name = "name", type = { StringType.class }, order = 4, min = 0, max = 1, modifier = false, summary = true)
580  @Description(shortDefinition = "The family member described", formalDefinition = "This will either be a name or a description; e.g. \"Aunt Susan\", \"my cousin with the red hair\".")
581  protected StringType name;
582
583  /**
584   * The type of relationship this person has to the patient (father, mother,
585   * brother etc.).
586   */
587  @Child(name = "relationship", type = {
588      CodeableConcept.class }, order = 5, min = 1, max = 1, modifier = false, summary = true)
589  @Description(shortDefinition = "Relationship to the subject", formalDefinition = "The type of relationship this person has to the patient (father, mother, brother etc.).")
590  protected CodeableConcept relationship;
591
592  /**
593   * Administrative Gender - the gender that the relative is considered to have
594   * for administration and record keeping purposes.
595   */
596  @Child(name = "gender", type = { CodeType.class }, order = 6, min = 0, max = 1, modifier = false, summary = true)
597  @Description(shortDefinition = "male | female | other | unknown", formalDefinition = "Administrative Gender - the gender that the relative is considered to have for administration and record keeping purposes.")
598  protected Enumeration<AdministrativeGender> gender;
599
600  /**
601   * The actual or approximate date of birth of the relative.
602   */
603  @Child(name = "born", type = { Period.class, DateType.class,
604      StringType.class }, order = 7, min = 0, max = 1, modifier = false, summary = false)
605  @Description(shortDefinition = "(approximate) date of birth", formalDefinition = "The actual or approximate date of birth of the relative.")
606  protected Type born;
607
608  /**
609   * The actual or approximate age of the relative at the time the family member
610   * history is recorded.
611   */
612  @Child(name = "age", type = { Age.class, Range.class,
613      StringType.class }, order = 8, min = 0, max = 1, modifier = false, summary = false)
614  @Description(shortDefinition = "(approximate) age", formalDefinition = "The actual or approximate age of the relative at the time the family member history is recorded.")
615  protected Type age;
616
617  /**
618   * Deceased flag or the actual or approximate age of the relative at the time of
619   * death for the family member history record.
620   */
621  @Child(name = "deceased", type = { BooleanType.class, Age.class, Range.class, DateType.class,
622      StringType.class }, order = 9, min = 0, max = 1, modifier = false, summary = false)
623  @Description(shortDefinition = "Dead? How old/when?", formalDefinition = "Deceased flag or the actual or approximate age of the relative at the time of death for the family member history record.")
624  protected Type deceased;
625
626  /**
627   * This property allows a non condition-specific note to the made about the
628   * related person. Ideally, the note would be in the condition property, but
629   * this is not always possible.
630   */
631  @Child(name = "note", type = { Annotation.class }, order = 10, min = 0, max = 1, modifier = false, summary = false)
632  @Description(shortDefinition = "General note about related person", formalDefinition = "This property allows a non condition-specific note to the made about the related person. Ideally, the note would be in the condition property, but this is not always possible.")
633  protected Annotation note;
634
635  /**
636   * The significant Conditions (or condition) that the family member had. This is
637   * a repeating section to allow a system to represent more than one condition
638   * per resource, though there is nothing stopping multiple resources - one per
639   * condition.
640   */
641  @Child(name = "condition", type = {}, order = 11, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
642  @Description(shortDefinition = "Condition that the related person had", formalDefinition = "The significant Conditions (or condition) that the family member had. This is a repeating section to allow a system to represent more than one condition per resource, though there is nothing stopping multiple resources - one per condition.")
643  protected List<FamilyMemberHistoryConditionComponent> condition;
644
645  private static final long serialVersionUID = -1799103041L;
646
647  /*
648   * Constructor
649   */
650  public FamilyMemberHistory() {
651    super();
652  }
653
654  /*
655   * Constructor
656   */
657  public FamilyMemberHistory(Reference patient, Enumeration<FamilyHistoryStatus> status, CodeableConcept relationship) {
658    super();
659    this.patient = patient;
660    this.status = status;
661    this.relationship = relationship;
662  }
663
664  /**
665   * @return {@link #identifier} (This records identifiers associated with this
666   *         family member history record that are defined by business processes
667   *         and/ or used to refer to it when a direct URL reference to the
668   *         resource itself is not appropriate (e.g. in CDA documents, or in
669   *         written / printed documentation).)
670   */
671  public List<Identifier> getIdentifier() {
672    if (this.identifier == null)
673      this.identifier = new ArrayList<Identifier>();
674    return this.identifier;
675  }
676
677  public boolean hasIdentifier() {
678    if (this.identifier == null)
679      return false;
680    for (Identifier item : this.identifier)
681      if (!item.isEmpty())
682        return true;
683    return false;
684  }
685
686  /**
687   * @return {@link #identifier} (This records identifiers associated with this
688   *         family member history record that are defined by business processes
689   *         and/ or used to refer to it when a direct URL reference to the
690   *         resource itself is not appropriate (e.g. in CDA documents, or in
691   *         written / printed documentation).)
692   */
693  // syntactic sugar
694  public Identifier addIdentifier() { // 3
695    Identifier t = new Identifier();
696    if (this.identifier == null)
697      this.identifier = new ArrayList<Identifier>();
698    this.identifier.add(t);
699    return t;
700  }
701
702  // syntactic sugar
703  public FamilyMemberHistory addIdentifier(Identifier t) { // 3
704    if (t == null)
705      return this;
706    if (this.identifier == null)
707      this.identifier = new ArrayList<Identifier>();
708    this.identifier.add(t);
709    return this;
710  }
711
712  /**
713   * @return {@link #patient} (The person who this history concerns.)
714   */
715  public Reference getPatient() {
716    if (this.patient == null)
717      if (Configuration.errorOnAutoCreate())
718        throw new Error("Attempt to auto-create FamilyMemberHistory.patient");
719      else if (Configuration.doAutoCreate())
720        this.patient = new Reference(); // cc
721    return this.patient;
722  }
723
724  public boolean hasPatient() {
725    return this.patient != null && !this.patient.isEmpty();
726  }
727
728  /**
729   * @param value {@link #patient} (The person who this history concerns.)
730   */
731  public FamilyMemberHistory setPatient(Reference value) {
732    this.patient = value;
733    return this;
734  }
735
736  /**
737   * @return {@link #patient} The actual object that is the target of the
738   *         reference. The reference library doesn't populate this, but you can
739   *         use it to hold the resource if you resolve it. (The person who this
740   *         history concerns.)
741   */
742  public Patient getPatientTarget() {
743    if (this.patientTarget == null)
744      if (Configuration.errorOnAutoCreate())
745        throw new Error("Attempt to auto-create FamilyMemberHistory.patient");
746      else if (Configuration.doAutoCreate())
747        this.patientTarget = new Patient(); // aa
748    return this.patientTarget;
749  }
750
751  /**
752   * @param value {@link #patient} The actual object that is the target of the
753   *              reference. The reference library doesn't use these, but you can
754   *              use it to hold the resource if you resolve it. (The person who
755   *              this history concerns.)
756   */
757  public FamilyMemberHistory setPatientTarget(Patient value) {
758    this.patientTarget = value;
759    return this;
760  }
761
762  /**
763   * @return {@link #date} (The date (and possibly time) when the family member
764   *         history was taken.). This is the underlying object with id, value and
765   *         extensions. The accessor "getDate" gives direct access to the value
766   */
767  public DateTimeType getDateElement() {
768    if (this.date == null)
769      if (Configuration.errorOnAutoCreate())
770        throw new Error("Attempt to auto-create FamilyMemberHistory.date");
771      else if (Configuration.doAutoCreate())
772        this.date = new DateTimeType(); // bb
773    return this.date;
774  }
775
776  public boolean hasDateElement() {
777    return this.date != null && !this.date.isEmpty();
778  }
779
780  public boolean hasDate() {
781    return this.date != null && !this.date.isEmpty();
782  }
783
784  /**
785   * @param value {@link #date} (The date (and possibly time) when the family
786   *              member history was taken.). This is the underlying object with
787   *              id, value and extensions. The accessor "getDate" gives direct
788   *              access to the value
789   */
790  public FamilyMemberHistory setDateElement(DateTimeType value) {
791    this.date = value;
792    return this;
793  }
794
795  /**
796   * @return The date (and possibly time) when the family member history was
797   *         taken.
798   */
799  public Date getDate() {
800    return this.date == null ? null : this.date.getValue();
801  }
802
803  /**
804   * @param value The date (and possibly time) when the family member history was
805   *              taken.
806   */
807  public FamilyMemberHistory setDate(Date value) {
808    if (value == null)
809      this.date = null;
810    else {
811      if (this.date == null)
812        this.date = new DateTimeType();
813      this.date.setValue(value);
814    }
815    return this;
816  }
817
818  /**
819   * @return {@link #status} (A code specifying a state of a Family Member History
820   *         record.). This is the underlying object with id, value and
821   *         extensions. The accessor "getStatus" gives direct access to the value
822   */
823  public Enumeration<FamilyHistoryStatus> getStatusElement() {
824    if (this.status == null)
825      if (Configuration.errorOnAutoCreate())
826        throw new Error("Attempt to auto-create FamilyMemberHistory.status");
827      else if (Configuration.doAutoCreate())
828        this.status = new Enumeration<FamilyHistoryStatus>(new FamilyHistoryStatusEnumFactory()); // bb
829    return this.status;
830  }
831
832  public boolean hasStatusElement() {
833    return this.status != null && !this.status.isEmpty();
834  }
835
836  public boolean hasStatus() {
837    return this.status != null && !this.status.isEmpty();
838  }
839
840  /**
841   * @param value {@link #status} (A code specifying a state of a Family Member
842   *              History record.). This is the underlying object with id, value
843   *              and extensions. The accessor "getStatus" gives direct access to
844   *              the value
845   */
846  public FamilyMemberHistory setStatusElement(Enumeration<FamilyHistoryStatus> value) {
847    this.status = value;
848    return this;
849  }
850
851  /**
852   * @return A code specifying a state of a Family Member History record.
853   */
854  public FamilyHistoryStatus getStatus() {
855    return this.status == null ? null : this.status.getValue();
856  }
857
858  /**
859   * @param value A code specifying a state of a Family Member History record.
860   */
861  public FamilyMemberHistory setStatus(FamilyHistoryStatus value) {
862    if (this.status == null)
863      this.status = new Enumeration<FamilyHistoryStatus>(new FamilyHistoryStatusEnumFactory());
864    this.status.setValue(value);
865    return this;
866  }
867
868  /**
869   * @return {@link #name} (This will either be a name or a description; e.g.
870   *         "Aunt Susan", "my cousin with the red hair".). This is the underlying
871   *         object with id, value and extensions. The accessor "getName" gives
872   *         direct access to the value
873   */
874  public StringType getNameElement() {
875    if (this.name == null)
876      if (Configuration.errorOnAutoCreate())
877        throw new Error("Attempt to auto-create FamilyMemberHistory.name");
878      else if (Configuration.doAutoCreate())
879        this.name = new StringType(); // bb
880    return this.name;
881  }
882
883  public boolean hasNameElement() {
884    return this.name != null && !this.name.isEmpty();
885  }
886
887  public boolean hasName() {
888    return this.name != null && !this.name.isEmpty();
889  }
890
891  /**
892   * @param value {@link #name} (This will either be a name or a description; e.g.
893   *              "Aunt Susan", "my cousin with the red hair".). This is the
894   *              underlying object with id, value and extensions. The accessor
895   *              "getName" gives direct access to the value
896   */
897  public FamilyMemberHistory setNameElement(StringType value) {
898    this.name = value;
899    return this;
900  }
901
902  /**
903   * @return This will either be a name or a description; e.g. "Aunt Susan", "my
904   *         cousin with the red hair".
905   */
906  public String getName() {
907    return this.name == null ? null : this.name.getValue();
908  }
909
910  /**
911   * @param value This will either be a name or a description; e.g. "Aunt Susan",
912   *              "my cousin with the red hair".
913   */
914  public FamilyMemberHistory setName(String value) {
915    if (Utilities.noString(value))
916      this.name = null;
917    else {
918      if (this.name == null)
919        this.name = new StringType();
920      this.name.setValue(value);
921    }
922    return this;
923  }
924
925  /**
926   * @return {@link #relationship} (The type of relationship this person has to
927   *         the patient (father, mother, brother etc.).)
928   */
929  public CodeableConcept getRelationship() {
930    if (this.relationship == null)
931      if (Configuration.errorOnAutoCreate())
932        throw new Error("Attempt to auto-create FamilyMemberHistory.relationship");
933      else if (Configuration.doAutoCreate())
934        this.relationship = new CodeableConcept(); // cc
935    return this.relationship;
936  }
937
938  public boolean hasRelationship() {
939    return this.relationship != null && !this.relationship.isEmpty();
940  }
941
942  /**
943   * @param value {@link #relationship} (The type of relationship this person has
944   *              to the patient (father, mother, brother etc.).)
945   */
946  public FamilyMemberHistory setRelationship(CodeableConcept value) {
947    this.relationship = value;
948    return this;
949  }
950
951  /**
952   * @return {@link #gender} (Administrative Gender - the gender that the relative
953   *         is considered to have for administration and record keeping
954   *         purposes.). This is the underlying object with id, value and
955   *         extensions. The accessor "getGender" gives direct access to the value
956   */
957  public Enumeration<AdministrativeGender> getGenderElement() {
958    if (this.gender == null)
959      if (Configuration.errorOnAutoCreate())
960        throw new Error("Attempt to auto-create FamilyMemberHistory.gender");
961      else if (Configuration.doAutoCreate())
962        this.gender = new Enumeration<AdministrativeGender>(new AdministrativeGenderEnumFactory()); // bb
963    return this.gender;
964  }
965
966  public boolean hasGenderElement() {
967    return this.gender != null && !this.gender.isEmpty();
968  }
969
970  public boolean hasGender() {
971    return this.gender != null && !this.gender.isEmpty();
972  }
973
974  /**
975   * @param value {@link #gender} (Administrative Gender - the gender that the
976   *              relative is considered to have for administration and record
977   *              keeping purposes.). This is the underlying object with id, value
978   *              and extensions. The accessor "getGender" gives direct access to
979   *              the value
980   */
981  public FamilyMemberHistory setGenderElement(Enumeration<AdministrativeGender> value) {
982    this.gender = value;
983    return this;
984  }
985
986  /**
987   * @return Administrative Gender - the gender that the relative is considered to
988   *         have for administration and record keeping purposes.
989   */
990  public AdministrativeGender getGender() {
991    return this.gender == null ? null : this.gender.getValue();
992  }
993
994  /**
995   * @param value Administrative Gender - the gender that the relative is
996   *              considered to have for administration and record keeping
997   *              purposes.
998   */
999  public FamilyMemberHistory setGender(AdministrativeGender value) {
1000    if (value == null)
1001      this.gender = null;
1002    else {
1003      if (this.gender == null)
1004        this.gender = new Enumeration<AdministrativeGender>(new AdministrativeGenderEnumFactory());
1005      this.gender.setValue(value);
1006    }
1007    return this;
1008  }
1009
1010  /**
1011   * @return {@link #born} (The actual or approximate date of birth of the
1012   *         relative.)
1013   */
1014  public Type getBorn() {
1015    return this.born;
1016  }
1017
1018  /**
1019   * @return {@link #born} (The actual or approximate date of birth of the
1020   *         relative.)
1021   */
1022  public Period getBornPeriod() throws FHIRException {
1023    if (!(this.born instanceof Period))
1024      throw new FHIRException(
1025          "Type mismatch: the type Period was expected, but " + this.born.getClass().getName() + " was encountered");
1026    return (Period) this.born;
1027  }
1028
1029  public boolean hasBornPeriod() {
1030    return this.born instanceof Period;
1031  }
1032
1033  /**
1034   * @return {@link #born} (The actual or approximate date of birth of the
1035   *         relative.)
1036   */
1037  public DateType getBornDateType() throws FHIRException {
1038    if (!(this.born instanceof DateType))
1039      throw new FHIRException(
1040          "Type mismatch: the type DateType was expected, but " + this.born.getClass().getName() + " was encountered");
1041    return (DateType) this.born;
1042  }
1043
1044  public boolean hasBornDateType() {
1045    return this.born instanceof DateType;
1046  }
1047
1048  /**
1049   * @return {@link #born} (The actual or approximate date of birth of the
1050   *         relative.)
1051   */
1052  public StringType getBornStringType() throws FHIRException {
1053    if (!(this.born instanceof StringType))
1054      throw new FHIRException("Type mismatch: the type StringType was expected, but " + this.born.getClass().getName()
1055          + " was encountered");
1056    return (StringType) this.born;
1057  }
1058
1059  public boolean hasBornStringType() {
1060    return this.born instanceof StringType;
1061  }
1062
1063  public boolean hasBorn() {
1064    return this.born != null && !this.born.isEmpty();
1065  }
1066
1067  /**
1068   * @param value {@link #born} (The actual or approximate date of birth of the
1069   *              relative.)
1070   */
1071  public FamilyMemberHistory setBorn(Type value) {
1072    this.born = value;
1073    return this;
1074  }
1075
1076  /**
1077   * @return {@link #age} (The actual or approximate age of the relative at the
1078   *         time the family member history is recorded.)
1079   */
1080  public Type getAge() {
1081    return this.age;
1082  }
1083
1084  /**
1085   * @return {@link #age} (The actual or approximate age of the relative at the
1086   *         time the family member history is recorded.)
1087   */
1088  public Age getAgeAge() throws FHIRException {
1089    if (!(this.age instanceof Age))
1090      throw new FHIRException(
1091          "Type mismatch: the type Age was expected, but " + this.age.getClass().getName() + " was encountered");
1092    return (Age) this.age;
1093  }
1094
1095  public boolean hasAgeAge() {
1096    return this.age instanceof Age;
1097  }
1098
1099  /**
1100   * @return {@link #age} (The actual or approximate age of the relative at the
1101   *         time the family member history is recorded.)
1102   */
1103  public Range getAgeRange() throws FHIRException {
1104    if (!(this.age instanceof Range))
1105      throw new FHIRException(
1106          "Type mismatch: the type Range was expected, but " + this.age.getClass().getName() + " was encountered");
1107    return (Range) this.age;
1108  }
1109
1110  public boolean hasAgeRange() {
1111    return this.age instanceof Range;
1112  }
1113
1114  /**
1115   * @return {@link #age} (The actual or approximate age of the relative at the
1116   *         time the family member history is recorded.)
1117   */
1118  public StringType getAgeStringType() throws FHIRException {
1119    if (!(this.age instanceof StringType))
1120      throw new FHIRException(
1121          "Type mismatch: the type StringType was expected, but " + this.age.getClass().getName() + " was encountered");
1122    return (StringType) this.age;
1123  }
1124
1125  public boolean hasAgeStringType() {
1126    return this.age instanceof StringType;
1127  }
1128
1129  public boolean hasAge() {
1130    return this.age != null && !this.age.isEmpty();
1131  }
1132
1133  /**
1134   * @param value {@link #age} (The actual or approximate age of the relative at
1135   *              the time the family member history is recorded.)
1136   */
1137  public FamilyMemberHistory setAge(Type value) {
1138    this.age = value;
1139    return this;
1140  }
1141
1142  /**
1143   * @return {@link #deceased} (Deceased flag or the actual or approximate age of
1144   *         the relative at the time of death for the family member history
1145   *         record.)
1146   */
1147  public Type getDeceased() {
1148    return this.deceased;
1149  }
1150
1151  /**
1152   * @return {@link #deceased} (Deceased flag or the actual or approximate age of
1153   *         the relative at the time of death for the family member history
1154   *         record.)
1155   */
1156  public BooleanType getDeceasedBooleanType() throws FHIRException {
1157    if (!(this.deceased instanceof BooleanType))
1158      throw new FHIRException("Type mismatch: the type BooleanType was expected, but "
1159          + this.deceased.getClass().getName() + " was encountered");
1160    return (BooleanType) this.deceased;
1161  }
1162
1163  public boolean hasDeceasedBooleanType() {
1164    return this.deceased instanceof BooleanType;
1165  }
1166
1167  /**
1168   * @return {@link #deceased} (Deceased flag or the actual or approximate age of
1169   *         the relative at the time of death for the family member history
1170   *         record.)
1171   */
1172  public Age getDeceasedAge() throws FHIRException {
1173    if (!(this.deceased instanceof Age))
1174      throw new FHIRException(
1175          "Type mismatch: the type Age was expected, but " + this.deceased.getClass().getName() + " was encountered");
1176    return (Age) this.deceased;
1177  }
1178
1179  public boolean hasDeceasedAge() {
1180    return this.deceased instanceof Age;
1181  }
1182
1183  /**
1184   * @return {@link #deceased} (Deceased flag or the actual or approximate age of
1185   *         the relative at the time of death for the family member history
1186   *         record.)
1187   */
1188  public Range getDeceasedRange() throws FHIRException {
1189    if (!(this.deceased instanceof Range))
1190      throw new FHIRException(
1191          "Type mismatch: the type Range was expected, but " + this.deceased.getClass().getName() + " was encountered");
1192    return (Range) this.deceased;
1193  }
1194
1195  public boolean hasDeceasedRange() {
1196    return this.deceased instanceof Range;
1197  }
1198
1199  /**
1200   * @return {@link #deceased} (Deceased flag or the actual or approximate age of
1201   *         the relative at the time of death for the family member history
1202   *         record.)
1203   */
1204  public DateType getDeceasedDateType() throws FHIRException {
1205    if (!(this.deceased instanceof DateType))
1206      throw new FHIRException("Type mismatch: the type DateType was expected, but " + this.deceased.getClass().getName()
1207          + " was encountered");
1208    return (DateType) this.deceased;
1209  }
1210
1211  public boolean hasDeceasedDateType() {
1212    return this.deceased instanceof DateType;
1213  }
1214
1215  /**
1216   * @return {@link #deceased} (Deceased flag or the actual or approximate age of
1217   *         the relative at the time of death for the family member history
1218   *         record.)
1219   */
1220  public StringType getDeceasedStringType() throws FHIRException {
1221    if (!(this.deceased instanceof StringType))
1222      throw new FHIRException("Type mismatch: the type StringType was expected, but "
1223          + this.deceased.getClass().getName() + " was encountered");
1224    return (StringType) this.deceased;
1225  }
1226
1227  public boolean hasDeceasedStringType() {
1228    return this.deceased instanceof StringType;
1229  }
1230
1231  public boolean hasDeceased() {
1232    return this.deceased != null && !this.deceased.isEmpty();
1233  }
1234
1235  /**
1236   * @param value {@link #deceased} (Deceased flag or the actual or approximate
1237   *              age of the relative at the time of death for the family member
1238   *              history record.)
1239   */
1240  public FamilyMemberHistory setDeceased(Type value) {
1241    this.deceased = value;
1242    return this;
1243  }
1244
1245  /**
1246   * @return {@link #note} (This property allows a non condition-specific note to
1247   *         the made about the related person. Ideally, the note would be in the
1248   *         condition property, but this is not always possible.)
1249   */
1250  public Annotation getNote() {
1251    if (this.note == null)
1252      if (Configuration.errorOnAutoCreate())
1253        throw new Error("Attempt to auto-create FamilyMemberHistory.note");
1254      else if (Configuration.doAutoCreate())
1255        this.note = new Annotation(); // cc
1256    return this.note;
1257  }
1258
1259  public boolean hasNote() {
1260    return this.note != null && !this.note.isEmpty();
1261  }
1262
1263  /**
1264   * @param value {@link #note} (This property allows a non condition-specific
1265   *              note to the made about the related person. Ideally, the note
1266   *              would be in the condition property, but this is not always
1267   *              possible.)
1268   */
1269  public FamilyMemberHistory setNote(Annotation value) {
1270    this.note = value;
1271    return this;
1272  }
1273
1274  /**
1275   * @return {@link #condition} (The significant Conditions (or condition) that
1276   *         the family member had. This is a repeating section to allow a system
1277   *         to represent more than one condition per resource, though there is
1278   *         nothing stopping multiple resources - one per condition.)
1279   */
1280  public List<FamilyMemberHistoryConditionComponent> getCondition() {
1281    if (this.condition == null)
1282      this.condition = new ArrayList<FamilyMemberHistoryConditionComponent>();
1283    return this.condition;
1284  }
1285
1286  public boolean hasCondition() {
1287    if (this.condition == null)
1288      return false;
1289    for (FamilyMemberHistoryConditionComponent item : this.condition)
1290      if (!item.isEmpty())
1291        return true;
1292    return false;
1293  }
1294
1295  /**
1296   * @return {@link #condition} (The significant Conditions (or condition) that
1297   *         the family member had. This is a repeating section to allow a system
1298   *         to represent more than one condition per resource, though there is
1299   *         nothing stopping multiple resources - one per condition.)
1300   */
1301  // syntactic sugar
1302  public FamilyMemberHistoryConditionComponent addCondition() { // 3
1303    FamilyMemberHistoryConditionComponent t = new FamilyMemberHistoryConditionComponent();
1304    if (this.condition == null)
1305      this.condition = new ArrayList<FamilyMemberHistoryConditionComponent>();
1306    this.condition.add(t);
1307    return t;
1308  }
1309
1310  // syntactic sugar
1311  public FamilyMemberHistory addCondition(FamilyMemberHistoryConditionComponent t) { // 3
1312    if (t == null)
1313      return this;
1314    if (this.condition == null)
1315      this.condition = new ArrayList<FamilyMemberHistoryConditionComponent>();
1316    this.condition.add(t);
1317    return this;
1318  }
1319
1320  protected void listChildren(List<Property> childrenList) {
1321    super.listChildren(childrenList);
1322    childrenList.add(new Property("identifier", "Identifier",
1323        "This records identifiers associated with this family member history record 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).",
1324        0, java.lang.Integer.MAX_VALUE, identifier));
1325    childrenList.add(new Property("patient", "Reference(Patient)", "The person who this history concerns.", 0,
1326        java.lang.Integer.MAX_VALUE, patient));
1327    childrenList
1328        .add(new Property("date", "dateTime", "The date (and possibly time) when the family member history was taken.",
1329            0, java.lang.Integer.MAX_VALUE, date));
1330    childrenList.add(new Property("status", "code", "A code specifying a state of a Family Member History record.", 0,
1331        java.lang.Integer.MAX_VALUE, status));
1332    childrenList.add(new Property("name", "string",
1333        "This will either be a name or a description; e.g. \"Aunt Susan\", \"my cousin with the red hair\".", 0,
1334        java.lang.Integer.MAX_VALUE, name));
1335    childrenList.add(new Property("relationship", "CodeableConcept",
1336        "The type of relationship this person has to the patient (father, mother, brother etc.).", 0,
1337        java.lang.Integer.MAX_VALUE, relationship));
1338    childrenList.add(new Property("gender", "code",
1339        "Administrative Gender - the gender that the relative is considered to have for administration and record keeping purposes.",
1340        0, java.lang.Integer.MAX_VALUE, gender));
1341    childrenList.add(new Property("born[x]", "Period|date|string",
1342        "The actual or approximate date of birth of the relative.", 0, java.lang.Integer.MAX_VALUE, born));
1343    childrenList.add(new Property("age[x]", "Age|Range|string",
1344        "The actual or approximate age of the relative at the time the family member history is recorded.", 0,
1345        java.lang.Integer.MAX_VALUE, age));
1346    childrenList.add(new Property("deceased[x]", "boolean|Age|Range|date|string",
1347        "Deceased flag or the actual or approximate age of the relative at the time of death for the family member history record.",
1348        0, java.lang.Integer.MAX_VALUE, deceased));
1349    childrenList.add(new Property("note", "Annotation",
1350        "This property allows a non condition-specific note to the made about the related person. Ideally, the note would be in the condition property, but this is not always possible.",
1351        0, java.lang.Integer.MAX_VALUE, note));
1352    childrenList.add(new Property("condition", "",
1353        "The significant Conditions (or condition) that the family member had. This is a repeating section to allow a system to represent more than one condition per resource, though there is nothing stopping multiple resources - one per condition.",
1354        0, java.lang.Integer.MAX_VALUE, condition));
1355  }
1356
1357  @Override
1358  public void setProperty(String name, Base value) throws FHIRException {
1359    if (name.equals("identifier"))
1360      this.getIdentifier().add(castToIdentifier(value));
1361    else if (name.equals("patient"))
1362      this.patient = castToReference(value); // Reference
1363    else if (name.equals("date"))
1364      this.date = castToDateTime(value); // DateTimeType
1365    else if (name.equals("status"))
1366      this.status = new FamilyHistoryStatusEnumFactory().fromType(value); // Enumeration<FamilyHistoryStatus>
1367    else if (name.equals("name"))
1368      this.name = castToString(value); // StringType
1369    else if (name.equals("relationship"))
1370      this.relationship = castToCodeableConcept(value); // CodeableConcept
1371    else if (name.equals("gender"))
1372      this.gender = new AdministrativeGenderEnumFactory().fromType(value); // Enumeration<AdministrativeGender>
1373    else if (name.equals("born[x]"))
1374      this.born = (Type) value; // Type
1375    else if (name.equals("age[x]"))
1376      this.age = (Type) value; // Type
1377    else if (name.equals("deceased[x]"))
1378      this.deceased = (Type) value; // Type
1379    else if (name.equals("note"))
1380      this.note = castToAnnotation(value); // Annotation
1381    else if (name.equals("condition"))
1382      this.getCondition().add((FamilyMemberHistoryConditionComponent) value);
1383    else
1384      super.setProperty(name, value);
1385  }
1386
1387  @Override
1388  public Base addChild(String name) throws FHIRException {
1389    if (name.equals("identifier")) {
1390      return addIdentifier();
1391    } else if (name.equals("patient")) {
1392      this.patient = new Reference();
1393      return this.patient;
1394    } else if (name.equals("date")) {
1395      throw new FHIRException("Cannot call addChild on a singleton property FamilyMemberHistory.date");
1396    } else if (name.equals("status")) {
1397      throw new FHIRException("Cannot call addChild on a singleton property FamilyMemberHistory.status");
1398    } else if (name.equals("name")) {
1399      throw new FHIRException("Cannot call addChild on a singleton property FamilyMemberHistory.name");
1400    } else if (name.equals("relationship")) {
1401      this.relationship = new CodeableConcept();
1402      return this.relationship;
1403    } else if (name.equals("gender")) {
1404      throw new FHIRException("Cannot call addChild on a singleton property FamilyMemberHistory.gender");
1405    } else if (name.equals("bornPeriod")) {
1406      this.born = new Period();
1407      return this.born;
1408    } else if (name.equals("bornDate")) {
1409      this.born = new DateType();
1410      return this.born;
1411    } else if (name.equals("bornString")) {
1412      this.born = new StringType();
1413      return this.born;
1414    } else if (name.equals("ageAge")) {
1415      this.age = new Age();
1416      return this.age;
1417    } else if (name.equals("ageRange")) {
1418      this.age = new Range();
1419      return this.age;
1420    } else if (name.equals("ageString")) {
1421      this.age = new StringType();
1422      return this.age;
1423    } else if (name.equals("deceasedBoolean")) {
1424      this.deceased = new BooleanType();
1425      return this.deceased;
1426    } else if (name.equals("deceasedAge")) {
1427      this.deceased = new Age();
1428      return this.deceased;
1429    } else if (name.equals("deceasedRange")) {
1430      this.deceased = new Range();
1431      return this.deceased;
1432    } else if (name.equals("deceasedDate")) {
1433      this.deceased = new DateType();
1434      return this.deceased;
1435    } else if (name.equals("deceasedString")) {
1436      this.deceased = new StringType();
1437      return this.deceased;
1438    } else if (name.equals("note")) {
1439      this.note = new Annotation();
1440      return this.note;
1441    } else if (name.equals("condition")) {
1442      return addCondition();
1443    } else
1444      return super.addChild(name);
1445  }
1446
1447  public String fhirType() {
1448    return "FamilyMemberHistory";
1449
1450  }
1451
1452  public FamilyMemberHistory copy() {
1453    FamilyMemberHistory dst = new FamilyMemberHistory();
1454    copyValues(dst);
1455    if (identifier != null) {
1456      dst.identifier = new ArrayList<Identifier>();
1457      for (Identifier i : identifier)
1458        dst.identifier.add(i.copy());
1459    }
1460    ;
1461    dst.patient = patient == null ? null : patient.copy();
1462    dst.date = date == null ? null : date.copy();
1463    dst.status = status == null ? null : status.copy();
1464    dst.name = name == null ? null : name.copy();
1465    dst.relationship = relationship == null ? null : relationship.copy();
1466    dst.gender = gender == null ? null : gender.copy();
1467    dst.born = born == null ? null : born.copy();
1468    dst.age = age == null ? null : age.copy();
1469    dst.deceased = deceased == null ? null : deceased.copy();
1470    dst.note = note == null ? null : note.copy();
1471    if (condition != null) {
1472      dst.condition = new ArrayList<FamilyMemberHistoryConditionComponent>();
1473      for (FamilyMemberHistoryConditionComponent i : condition)
1474        dst.condition.add(i.copy());
1475    }
1476    ;
1477    return dst;
1478  }
1479
1480  protected FamilyMemberHistory typedCopy() {
1481    return copy();
1482  }
1483
1484  @Override
1485  public boolean equalsDeep(Base other) {
1486    if (!super.equalsDeep(other))
1487      return false;
1488    if (!(other instanceof FamilyMemberHistory))
1489      return false;
1490    FamilyMemberHistory o = (FamilyMemberHistory) other;
1491    return compareDeep(identifier, o.identifier, true) && compareDeep(patient, o.patient, true)
1492        && compareDeep(date, o.date, true) && compareDeep(status, o.status, true) && compareDeep(name, o.name, true)
1493        && compareDeep(relationship, o.relationship, true) && compareDeep(gender, o.gender, true)
1494        && compareDeep(born, o.born, true) && compareDeep(age, o.age, true) && compareDeep(deceased, o.deceased, true)
1495        && compareDeep(note, o.note, true) && compareDeep(condition, o.condition, true);
1496  }
1497
1498  @Override
1499  public boolean equalsShallow(Base other) {
1500    if (!super.equalsShallow(other))
1501      return false;
1502    if (!(other instanceof FamilyMemberHistory))
1503      return false;
1504    FamilyMemberHistory o = (FamilyMemberHistory) other;
1505    return compareValues(date, o.date, true) && compareValues(status, o.status, true)
1506        && compareValues(name, o.name, true) && compareValues(gender, o.gender, true);
1507  }
1508
1509  public boolean isEmpty() {
1510    return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (patient == null || patient.isEmpty())
1511        && (date == null || date.isEmpty()) && (status == null || status.isEmpty()) && (name == null || name.isEmpty())
1512        && (relationship == null || relationship.isEmpty()) && (gender == null || gender.isEmpty())
1513        && (born == null || born.isEmpty()) && (age == null || age.isEmpty())
1514        && (deceased == null || deceased.isEmpty()) && (note == null || note.isEmpty())
1515        && (condition == null || condition.isEmpty());
1516  }
1517
1518  @Override
1519  public ResourceType getResourceType() {
1520    return ResourceType.FamilyMemberHistory;
1521  }
1522
1523  @SearchParamDefinition(name = "date", path = "FamilyMemberHistory.date", description = "When history was captured/updated", type = "date")
1524  public static final String SP_DATE = "date";
1525  @SearchParamDefinition(name = "identifier", path = "FamilyMemberHistory.identifier", description = "A search by a record identifier", type = "token")
1526  public static final String SP_IDENTIFIER = "identifier";
1527  @SearchParamDefinition(name = "code", path = "FamilyMemberHistory.condition.code", description = "A search by a condition code", type = "token")
1528  public static final String SP_CODE = "code";
1529  @SearchParamDefinition(name = "gender", path = "FamilyMemberHistory.gender", description = "A search by a gender code of a family member", type = "token")
1530  public static final String SP_GENDER = "gender";
1531  @SearchParamDefinition(name = "patient", path = "FamilyMemberHistory.patient", description = "The identity of a subject to list family member history items for", type = "reference")
1532  public static final String SP_PATIENT = "patient";
1533  @SearchParamDefinition(name = "relationship", path = "FamilyMemberHistory.relationship", description = "A search by a relationship type", type = "token")
1534  public static final String SP_RELATIONSHIP = "relationship";
1535
1536}