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