001package org.hl7.fhir.dstu3.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 Mon, Apr 17, 2017 17:38-0400 for FHIR v3.0.1
033
034import java.util.*;
035
036import org.hl7.fhir.utilities.Utilities;
037import org.hl7.fhir.dstu3.model.Enumerations.*;
038import ca.uhn.fhir.model.api.annotation.ResourceDef;
039import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
040import ca.uhn.fhir.model.api.annotation.Child;
041import ca.uhn.fhir.model.api.annotation.ChildOrder;
042import ca.uhn.fhir.model.api.annotation.Description;
043import ca.uhn.fhir.model.api.annotation.Block;
044import org.hl7.fhir.instance.model.api.*;
045import org.hl7.fhir.exceptions.FHIRException;
046/**
047 * Significant health events and conditions for a person related to the patient relevant in the context of care for the patient.
048 */
049@ResourceDef(name="FamilyMemberHistory", profile="http://hl7.org/fhir/Profile/FamilyMemberHistory")
050public class FamilyMemberHistory extends DomainResource {
051
052    public enum FamilyHistoryStatus {
053        /**
054         * Some health information is known and captured, but not complete - see notes for details.
055         */
056        PARTIAL, 
057        /**
058         * All available related health information is captured as of the date (and possibly time) when the family member history was taken.
059         */
060        COMPLETED, 
061        /**
062         * This instance should not have been part of this patient's medical record.
063         */
064        ENTEREDINERROR, 
065        /**
066         * Health information for this individual is unavailable/unknown.
067         */
068        HEALTHUNKNOWN, 
069        /**
070         * added to help the parsers with the generic types
071         */
072        NULL;
073        public static FamilyHistoryStatus fromCode(String codeString) throws FHIRException {
074            if (codeString == null || "".equals(codeString))
075                return null;
076        if ("partial".equals(codeString))
077          return PARTIAL;
078        if ("completed".equals(codeString))
079          return COMPLETED;
080        if ("entered-in-error".equals(codeString))
081          return ENTEREDINERROR;
082        if ("health-unknown".equals(codeString))
083          return HEALTHUNKNOWN;
084        if (Configuration.isAcceptInvalidEnums())
085          return null;
086        else
087          throw new FHIRException("Unknown FamilyHistoryStatus code '"+codeString+"'");
088        }
089        public String toCode() {
090          switch (this) {
091            case PARTIAL: return "partial";
092            case COMPLETED: return "completed";
093            case ENTEREDINERROR: return "entered-in-error";
094            case HEALTHUNKNOWN: return "health-unknown";
095            default: return "?";
096          }
097        }
098        public String getSystem() {
099          switch (this) {
100            case PARTIAL: return "http://hl7.org/fhir/history-status";
101            case COMPLETED: return "http://hl7.org/fhir/history-status";
102            case ENTEREDINERROR: return "http://hl7.org/fhir/history-status";
103            case HEALTHUNKNOWN: return "http://hl7.org/fhir/history-status";
104            default: return "?";
105          }
106        }
107        public String getDefinition() {
108          switch (this) {
109            case PARTIAL: return "Some health information is known and captured, but not complete - see notes for details.";
110            case COMPLETED: return "All available related health information is captured as of the date (and possibly time) when the family member history was taken.";
111            case ENTEREDINERROR: return "This instance should not have been part of this patient's medical record.";
112            case HEALTHUNKNOWN: return "Health information for this individual is unavailable/unknown.";
113            default: return "?";
114          }
115        }
116        public String getDisplay() {
117          switch (this) {
118            case PARTIAL: return "Partial";
119            case COMPLETED: return "Completed";
120            case ENTEREDINERROR: return "Entered in error";
121            case HEALTHUNKNOWN: return "Health unknown";
122            default: return "?";
123          }
124        }
125    }
126
127  public static class FamilyHistoryStatusEnumFactory implements EnumFactory<FamilyHistoryStatus> {
128    public FamilyHistoryStatus fromCode(String codeString) throws IllegalArgumentException {
129      if (codeString == null || "".equals(codeString))
130            if (codeString == null || "".equals(codeString))
131                return null;
132        if ("partial".equals(codeString))
133          return FamilyHistoryStatus.PARTIAL;
134        if ("completed".equals(codeString))
135          return FamilyHistoryStatus.COMPLETED;
136        if ("entered-in-error".equals(codeString))
137          return FamilyHistoryStatus.ENTEREDINERROR;
138        if ("health-unknown".equals(codeString))
139          return FamilyHistoryStatus.HEALTHUNKNOWN;
140        throw new IllegalArgumentException("Unknown FamilyHistoryStatus code '"+codeString+"'");
141        }
142        public Enumeration<FamilyHistoryStatus> fromType(Base code) throws FHIRException {
143          if (code == null)
144            return null;
145          if (code.isEmpty())
146            return new Enumeration<FamilyHistoryStatus>(this);
147          String codeString = ((PrimitiveType) code).asStringValue();
148          if (codeString == null || "".equals(codeString))
149            return null;
150        if ("partial".equals(codeString))
151          return new Enumeration<FamilyHistoryStatus>(this, FamilyHistoryStatus.PARTIAL);
152        if ("completed".equals(codeString))
153          return new Enumeration<FamilyHistoryStatus>(this, FamilyHistoryStatus.COMPLETED);
154        if ("entered-in-error".equals(codeString))
155          return new Enumeration<FamilyHistoryStatus>(this, FamilyHistoryStatus.ENTEREDINERROR);
156        if ("health-unknown".equals(codeString))
157          return new Enumeration<FamilyHistoryStatus>(this, FamilyHistoryStatus.HEALTHUNKNOWN);
158        throw new FHIRException("Unknown FamilyHistoryStatus code '"+codeString+"'");
159        }
160    public String toCode(FamilyHistoryStatus code) {
161      if (code == FamilyHistoryStatus.PARTIAL)
162        return "partial";
163      if (code == FamilyHistoryStatus.COMPLETED)
164        return "completed";
165      if (code == FamilyHistoryStatus.ENTEREDINERROR)
166        return "entered-in-error";
167      if (code == FamilyHistoryStatus.HEALTHUNKNOWN)
168        return "health-unknown";
169      return "?";
170      }
171    public String toSystem(FamilyHistoryStatus code) {
172      return code.getSystem();
173      }
174    }
175
176    @Block()
177    public static class FamilyMemberHistoryConditionComponent extends BackboneElement implements IBaseBackboneElement {
178        /**
179         * 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.
180         */
181        @Child(name = "code", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=false)
182        @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." )
183        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/condition-code")
184        protected CodeableConcept code;
185
186        /**
187         * Indicates what happened as a result of this condition.  If the condition resulted in death, deceased date is captured on the relation.
188         */
189        @Child(name = "outcome", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
190        @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." )
191        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/condition-outcome")
192        protected CodeableConcept outcome;
193
194        /**
195         * 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.
196         */
197        @Child(name = "onset", type = {Age.class, Range.class, Period.class, StringType.class}, order=3, min=0, max=1, modifier=false, summary=false)
198        @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." )
199        protected Type onset;
200
201        /**
202         * An area where general notes can be placed about this specific condition.
203         */
204        @Child(name = "note", type = {Annotation.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
205        @Description(shortDefinition="Extra information about condition", formalDefinition="An area where general notes can be placed about this specific condition." )
206        protected List<Annotation> note;
207
208        private static final long serialVersionUID = 598309281L;
209
210    /**
211     * Constructor
212     */
213      public FamilyMemberHistoryConditionComponent() {
214        super();
215      }
216
217    /**
218     * Constructor
219     */
220      public FamilyMemberHistoryConditionComponent(CodeableConcept code) {
221        super();
222        this.code = code;
223      }
224
225        /**
226         * @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.)
227         */
228        public CodeableConcept getCode() { 
229          if (this.code == null)
230            if (Configuration.errorOnAutoCreate())
231              throw new Error("Attempt to auto-create FamilyMemberHistoryConditionComponent.code");
232            else if (Configuration.doAutoCreate())
233              this.code = new CodeableConcept(); // cc
234          return this.code;
235        }
236
237        public boolean hasCode() { 
238          return this.code != null && !this.code.isEmpty();
239        }
240
241        /**
242         * @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.)
243         */
244        public FamilyMemberHistoryConditionComponent setCode(CodeableConcept value) { 
245          this.code = value;
246          return this;
247        }
248
249        /**
250         * @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.)
251         */
252        public CodeableConcept getOutcome() { 
253          if (this.outcome == null)
254            if (Configuration.errorOnAutoCreate())
255              throw new Error("Attempt to auto-create FamilyMemberHistoryConditionComponent.outcome");
256            else if (Configuration.doAutoCreate())
257              this.outcome = new CodeableConcept(); // cc
258          return this.outcome;
259        }
260
261        public boolean hasOutcome() { 
262          return this.outcome != null && !this.outcome.isEmpty();
263        }
264
265        /**
266         * @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.)
267         */
268        public FamilyMemberHistoryConditionComponent setOutcome(CodeableConcept value) { 
269          this.outcome = value;
270          return this;
271        }
272
273        /**
274         * @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.)
275         */
276        public Type getOnset() { 
277          return this.onset;
278        }
279
280        /**
281         * @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.)
282         */
283        public Age getOnsetAge() throws FHIRException { 
284          if (!(this.onset instanceof Age))
285            throw new FHIRException("Type mismatch: the type Age was expected, but "+this.onset.getClass().getName()+" was encountered");
286          return (Age) this.onset;
287        }
288
289        public boolean hasOnsetAge() { 
290          return this.onset instanceof Age;
291        }
292
293        /**
294         * @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.)
295         */
296        public Range getOnsetRange() throws FHIRException { 
297          if (!(this.onset instanceof Range))
298            throw new FHIRException("Type mismatch: the type Range was expected, but "+this.onset.getClass().getName()+" was encountered");
299          return (Range) this.onset;
300        }
301
302        public boolean hasOnsetRange() { 
303          return this.onset instanceof Range;
304        }
305
306        /**
307         * @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.)
308         */
309        public Period getOnsetPeriod() throws FHIRException { 
310          if (!(this.onset instanceof Period))
311            throw new FHIRException("Type mismatch: the type Period was expected, but "+this.onset.getClass().getName()+" was encountered");
312          return (Period) this.onset;
313        }
314
315        public boolean hasOnsetPeriod() { 
316          return this.onset instanceof Period;
317        }
318
319        /**
320         * @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.)
321         */
322        public StringType getOnsetStringType() throws FHIRException { 
323          if (!(this.onset instanceof StringType))
324            throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.onset.getClass().getName()+" was encountered");
325          return (StringType) this.onset;
326        }
327
328        public boolean hasOnsetStringType() { 
329          return this.onset instanceof StringType;
330        }
331
332        public boolean hasOnset() { 
333          return this.onset != null && !this.onset.isEmpty();
334        }
335
336        /**
337         * @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.)
338         */
339        public FamilyMemberHistoryConditionComponent setOnset(Type value) { 
340          this.onset = value;
341          return this;
342        }
343
344        /**
345         * @return {@link #note} (An area where general notes can be placed about this specific condition.)
346         */
347        public List<Annotation> getNote() { 
348          if (this.note == null)
349            this.note = new ArrayList<Annotation>();
350          return this.note;
351        }
352
353        /**
354         * @return Returns a reference to <code>this</code> for easy method chaining
355         */
356        public FamilyMemberHistoryConditionComponent setNote(List<Annotation> theNote) { 
357          this.note = theNote;
358          return this;
359        }
360
361        public boolean hasNote() { 
362          if (this.note == null)
363            return false;
364          for (Annotation item : this.note)
365            if (!item.isEmpty())
366              return true;
367          return false;
368        }
369
370        public Annotation addNote() { //3
371          Annotation t = new Annotation();
372          if (this.note == null)
373            this.note = new ArrayList<Annotation>();
374          this.note.add(t);
375          return t;
376        }
377
378        public FamilyMemberHistoryConditionComponent addNote(Annotation t) { //3
379          if (t == null)
380            return this;
381          if (this.note == null)
382            this.note = new ArrayList<Annotation>();
383          this.note.add(t);
384          return this;
385        }
386
387        /**
388         * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist
389         */
390        public Annotation getNoteFirstRep() { 
391          if (getNote().isEmpty()) {
392            addNote();
393          }
394          return getNote().get(0);
395        }
396
397        protected void listChildren(List<Property> childrenList) {
398          super.listChildren(childrenList);
399          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));
400          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));
401          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));
402          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));
403        }
404
405      @Override
406      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
407        switch (hash) {
408        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept
409        case -1106507950: /*outcome*/ return this.outcome == null ? new Base[0] : new Base[] {this.outcome}; // CodeableConcept
410        case 105901603: /*onset*/ return this.onset == null ? new Base[0] : new Base[] {this.onset}; // Type
411        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
412        default: return super.getProperty(hash, name, checkValid);
413        }
414
415      }
416
417      @Override
418      public Base setProperty(int hash, String name, Base value) throws FHIRException {
419        switch (hash) {
420        case 3059181: // code
421          this.code = castToCodeableConcept(value); // CodeableConcept
422          return value;
423        case -1106507950: // outcome
424          this.outcome = castToCodeableConcept(value); // CodeableConcept
425          return value;
426        case 105901603: // onset
427          this.onset = castToType(value); // Type
428          return value;
429        case 3387378: // note
430          this.getNote().add(castToAnnotation(value)); // Annotation
431          return value;
432        default: return super.setProperty(hash, name, value);
433        }
434
435      }
436
437      @Override
438      public Base setProperty(String name, Base value) throws FHIRException {
439        if (name.equals("code")) {
440          this.code = castToCodeableConcept(value); // CodeableConcept
441        } else if (name.equals("outcome")) {
442          this.outcome = castToCodeableConcept(value); // CodeableConcept
443        } else if (name.equals("onset[x]")) {
444          this.onset = castToType(value); // Type
445        } else if (name.equals("note")) {
446          this.getNote().add(castToAnnotation(value));
447        } else
448          return super.setProperty(name, value);
449        return value;
450      }
451
452      @Override
453      public Base makeProperty(int hash, String name) throws FHIRException {
454        switch (hash) {
455        case 3059181:  return getCode(); 
456        case -1106507950:  return getOutcome(); 
457        case -1886216323:  return getOnset(); 
458        case 105901603:  return getOnset(); 
459        case 3387378:  return addNote(); 
460        default: return super.makeProperty(hash, name);
461        }
462
463      }
464
465      @Override
466      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
467        switch (hash) {
468        case 3059181: /*code*/ return new String[] {"CodeableConcept"};
469        case -1106507950: /*outcome*/ return new String[] {"CodeableConcept"};
470        case 105901603: /*onset*/ return new String[] {"Age", "Range", "Period", "string"};
471        case 3387378: /*note*/ return new String[] {"Annotation"};
472        default: return super.getTypesForProperty(hash, name);
473        }
474
475      }
476
477      @Override
478      public Base addChild(String name) throws FHIRException {
479        if (name.equals("code")) {
480          this.code = new CodeableConcept();
481          return this.code;
482        }
483        else if (name.equals("outcome")) {
484          this.outcome = new CodeableConcept();
485          return this.outcome;
486        }
487        else if (name.equals("onsetAge")) {
488          this.onset = new Age();
489          return this.onset;
490        }
491        else if (name.equals("onsetRange")) {
492          this.onset = new Range();
493          return this.onset;
494        }
495        else if (name.equals("onsetPeriod")) {
496          this.onset = new Period();
497          return this.onset;
498        }
499        else if (name.equals("onsetString")) {
500          this.onset = new StringType();
501          return this.onset;
502        }
503        else if (name.equals("note")) {
504          return addNote();
505        }
506        else
507          return super.addChild(name);
508      }
509
510      public FamilyMemberHistoryConditionComponent copy() {
511        FamilyMemberHistoryConditionComponent dst = new FamilyMemberHistoryConditionComponent();
512        copyValues(dst);
513        dst.code = code == null ? null : code.copy();
514        dst.outcome = outcome == null ? null : outcome.copy();
515        dst.onset = onset == null ? null : onset.copy();
516        if (note != null) {
517          dst.note = new ArrayList<Annotation>();
518          for (Annotation i : note)
519            dst.note.add(i.copy());
520        };
521        return dst;
522      }
523
524      @Override
525      public boolean equalsDeep(Base other) {
526        if (!super.equalsDeep(other))
527          return false;
528        if (!(other instanceof FamilyMemberHistoryConditionComponent))
529          return false;
530        FamilyMemberHistoryConditionComponent o = (FamilyMemberHistoryConditionComponent) other;
531        return compareDeep(code, o.code, true) && compareDeep(outcome, o.outcome, true) && compareDeep(onset, o.onset, true)
532           && compareDeep(note, o.note, true);
533      }
534
535      @Override
536      public boolean equalsShallow(Base other) {
537        if (!super.equalsShallow(other))
538          return false;
539        if (!(other instanceof FamilyMemberHistoryConditionComponent))
540          return false;
541        FamilyMemberHistoryConditionComponent o = (FamilyMemberHistoryConditionComponent) other;
542        return true;
543      }
544
545      public boolean isEmpty() {
546        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(code, outcome, onset, note
547          );
548      }
549
550  public String fhirType() {
551    return "FamilyMemberHistory.condition";
552
553  }
554
555  }
556
557    /**
558     * 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).
559     */
560    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
561    @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)." )
562    protected List<Identifier> identifier;
563
564    /**
565     * A protocol or questionnaire that was adhered to in whole or in part by this event.
566     */
567    @Child(name = "definition", type = {PlanDefinition.class, Questionnaire.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
568    @Description(shortDefinition="Instantiates protocol or definition", formalDefinition="A protocol or questionnaire that was adhered to in whole or in part by this event." )
569    protected List<Reference> definition;
570    /**
571     * The actual objects that are the target of the reference (A protocol or questionnaire that was adhered to in whole or in part by this event.)
572     */
573    protected List<Resource> definitionTarget;
574
575
576    /**
577     * A code specifying the status of the record of the family history of a specific family member.
578     */
579    @Child(name = "status", type = {CodeType.class}, order=2, min=1, max=1, modifier=true, summary=true)
580    @Description(shortDefinition="partial | completed | entered-in-error | health-unknown", formalDefinition="A code specifying the status of the record of the family history of a specific family member." )
581    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/history-status")
582    protected Enumeration<FamilyHistoryStatus> status;
583
584    /**
585     * If true, indicates the taking of an individual family member's history did not occur. The notDone element should not be used to document negated conditions, such as a family member that did not have a condition.
586     */
587    @Child(name = "notDone", type = {BooleanType.class}, order=3, min=0, max=1, modifier=true, summary=true)
588    @Description(shortDefinition="The taking of a family member's history did not occur", formalDefinition="If true, indicates the taking of an individual family member's history did not occur. The notDone element should not be used to document negated conditions, such as a family member that did not have a condition." )
589    protected BooleanType notDone;
590
591    /**
592     * Describes why the family member's history is absent.
593     */
594    @Child(name = "notDoneReason", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=true)
595    @Description(shortDefinition="subject-unknown | withheld | unable-to-obtain | deferred", formalDefinition="Describes why the family member's history is absent." )
596    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/history-not-done-reason")
597    protected CodeableConcept notDoneReason;
598
599    /**
600     * The person who this history concerns.
601     */
602    @Child(name = "patient", type = {Patient.class}, order=5, min=1, max=1, modifier=false, summary=true)
603    @Description(shortDefinition="Patient history is about", formalDefinition="The person who this history concerns." )
604    protected Reference patient;
605
606    /**
607     * The actual object that is the target of the reference (The person who this history concerns.)
608     */
609    protected Patient patientTarget;
610
611    /**
612     * The date (and possibly time) when the family member history was taken.
613     */
614    @Child(name = "date", type = {DateTimeType.class}, order=6, min=0, max=1, modifier=false, summary=true)
615    @Description(shortDefinition="When history was captured/updated", formalDefinition="The date (and possibly time) when the family member history was taken." )
616    protected DateTimeType date;
617
618    /**
619     * This will either be a name or a description; e.g. "Aunt Susan", "my cousin with the red hair".
620     */
621    @Child(name = "name", type = {StringType.class}, order=7, min=0, max=1, modifier=false, summary=true)
622    @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\"." )
623    protected StringType name;
624
625    /**
626     * The type of relationship this person has to the patient (father, mother, brother etc.).
627     */
628    @Child(name = "relationship", type = {CodeableConcept.class}, order=8, min=1, max=1, modifier=false, summary=true)
629    @Description(shortDefinition="Relationship to the subject", formalDefinition="The type of relationship this person has to the patient (father, mother, brother etc.)." )
630    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/v3-FamilyMember")
631    protected CodeableConcept relationship;
632
633    /**
634     * Administrative Gender - the gender that the relative is considered to have for administration and record keeping purposes.
635     */
636    @Child(name = "gender", type = {CodeType.class}, order=9, min=0, max=1, modifier=false, summary=true)
637    @Description(shortDefinition="male | female | other | unknown", formalDefinition="Administrative Gender - the gender that the relative is considered to have for administration and record keeping purposes." )
638    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/administrative-gender")
639    protected Enumeration<AdministrativeGender> gender;
640
641    /**
642     * The actual or approximate date of birth of the relative.
643     */
644    @Child(name = "born", type = {Period.class, DateType.class, StringType.class}, order=10, min=0, max=1, modifier=false, summary=false)
645    @Description(shortDefinition="(approximate) date of birth", formalDefinition="The actual or approximate date of birth of the relative." )
646    protected Type born;
647
648    /**
649     * The age of the relative at the time the family member history is recorded.
650     */
651    @Child(name = "age", type = {Age.class, Range.class, StringType.class}, order=11, min=0, max=1, modifier=false, summary=true)
652    @Description(shortDefinition="(approximate) age", formalDefinition="The age of the relative at the time the family member history is recorded." )
653    protected Type age;
654
655    /**
656     * If true, indicates that the age value specified is an estimated value.
657     */
658    @Child(name = "estimatedAge", type = {BooleanType.class}, order=12, min=0, max=1, modifier=true, summary=true)
659    @Description(shortDefinition="Age is estimated?", formalDefinition="If true, indicates that the age value specified is an estimated value." )
660    protected BooleanType estimatedAge;
661
662    /**
663     * Deceased flag or the actual or approximate age of the relative at the time of death for the family member history record.
664     */
665    @Child(name = "deceased", type = {BooleanType.class, Age.class, Range.class, DateType.class, StringType.class}, order=13, min=0, max=1, modifier=false, summary=true)
666    @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." )
667    protected Type deceased;
668
669    /**
670     * Describes why the family member history occurred in coded or textual form.
671     */
672    @Child(name = "reasonCode", type = {CodeableConcept.class}, order=14, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
673    @Description(shortDefinition="Why was family member history performed?", formalDefinition="Describes why the family member history occurred in coded or textual form." )
674    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/clinical-findings")
675    protected List<CodeableConcept> reasonCode;
676
677    /**
678     * Indicates a Condition, Observation, AllergyIntolerance, or QuestionnaireResponse that justifies this family member history event.
679     */
680    @Child(name = "reasonReference", type = {Condition.class, Observation.class, AllergyIntolerance.class, QuestionnaireResponse.class}, order=15, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
681    @Description(shortDefinition="Why was family member history performed?", formalDefinition="Indicates a Condition, Observation, AllergyIntolerance, or QuestionnaireResponse that justifies this family member history event." )
682    protected List<Reference> reasonReference;
683    /**
684     * The actual objects that are the target of the reference (Indicates a Condition, Observation, AllergyIntolerance, or QuestionnaireResponse that justifies this family member history event.)
685     */
686    protected List<Resource> reasonReferenceTarget;
687
688
689    /**
690     * 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.
691     */
692    @Child(name = "note", type = {Annotation.class}, order=16, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
693    @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." )
694    protected List<Annotation> note;
695
696    /**
697     * 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.
698     */
699    @Child(name = "condition", type = {}, order=17, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
700    @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." )
701    protected List<FamilyMemberHistoryConditionComponent> condition;
702
703    private static final long serialVersionUID = 388742645L;
704
705  /**
706   * Constructor
707   */
708    public FamilyMemberHistory() {
709      super();
710    }
711
712  /**
713   * Constructor
714   */
715    public FamilyMemberHistory(Enumeration<FamilyHistoryStatus> status, Reference patient, CodeableConcept relationship) {
716      super();
717      this.status = status;
718      this.patient = patient;
719      this.relationship = relationship;
720    }
721
722    /**
723     * @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).)
724     */
725    public List<Identifier> getIdentifier() { 
726      if (this.identifier == null)
727        this.identifier = new ArrayList<Identifier>();
728      return this.identifier;
729    }
730
731    /**
732     * @return Returns a reference to <code>this</code> for easy method chaining
733     */
734    public FamilyMemberHistory setIdentifier(List<Identifier> theIdentifier) { 
735      this.identifier = theIdentifier;
736      return this;
737    }
738
739    public boolean hasIdentifier() { 
740      if (this.identifier == null)
741        return false;
742      for (Identifier item : this.identifier)
743        if (!item.isEmpty())
744          return true;
745      return false;
746    }
747
748    public Identifier addIdentifier() { //3
749      Identifier t = new Identifier();
750      if (this.identifier == null)
751        this.identifier = new ArrayList<Identifier>();
752      this.identifier.add(t);
753      return t;
754    }
755
756    public FamilyMemberHistory addIdentifier(Identifier t) { //3
757      if (t == null)
758        return this;
759      if (this.identifier == null)
760        this.identifier = new ArrayList<Identifier>();
761      this.identifier.add(t);
762      return this;
763    }
764
765    /**
766     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
767     */
768    public Identifier getIdentifierFirstRep() { 
769      if (getIdentifier().isEmpty()) {
770        addIdentifier();
771      }
772      return getIdentifier().get(0);
773    }
774
775    /**
776     * @return {@link #definition} (A protocol or questionnaire that was adhered to in whole or in part by this event.)
777     */
778    public List<Reference> getDefinition() { 
779      if (this.definition == null)
780        this.definition = new ArrayList<Reference>();
781      return this.definition;
782    }
783
784    /**
785     * @return Returns a reference to <code>this</code> for easy method chaining
786     */
787    public FamilyMemberHistory setDefinition(List<Reference> theDefinition) { 
788      this.definition = theDefinition;
789      return this;
790    }
791
792    public boolean hasDefinition() { 
793      if (this.definition == null)
794        return false;
795      for (Reference item : this.definition)
796        if (!item.isEmpty())
797          return true;
798      return false;
799    }
800
801    public Reference addDefinition() { //3
802      Reference t = new Reference();
803      if (this.definition == null)
804        this.definition = new ArrayList<Reference>();
805      this.definition.add(t);
806      return t;
807    }
808
809    public FamilyMemberHistory addDefinition(Reference t) { //3
810      if (t == null)
811        return this;
812      if (this.definition == null)
813        this.definition = new ArrayList<Reference>();
814      this.definition.add(t);
815      return this;
816    }
817
818    /**
819     * @return The first repetition of repeating field {@link #definition}, creating it if it does not already exist
820     */
821    public Reference getDefinitionFirstRep() { 
822      if (getDefinition().isEmpty()) {
823        addDefinition();
824      }
825      return getDefinition().get(0);
826    }
827
828    /**
829     * @deprecated Use Reference#setResource(IBaseResource) instead
830     */
831    @Deprecated
832    public List<Resource> getDefinitionTarget() { 
833      if (this.definitionTarget == null)
834        this.definitionTarget = new ArrayList<Resource>();
835      return this.definitionTarget;
836    }
837
838    /**
839     * @return {@link #status} (A code specifying the status of the record of the family history of a specific family member.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
840     */
841    public Enumeration<FamilyHistoryStatus> getStatusElement() { 
842      if (this.status == null)
843        if (Configuration.errorOnAutoCreate())
844          throw new Error("Attempt to auto-create FamilyMemberHistory.status");
845        else if (Configuration.doAutoCreate())
846          this.status = new Enumeration<FamilyHistoryStatus>(new FamilyHistoryStatusEnumFactory()); // bb
847      return this.status;
848    }
849
850    public boolean hasStatusElement() { 
851      return this.status != null && !this.status.isEmpty();
852    }
853
854    public boolean hasStatus() { 
855      return this.status != null && !this.status.isEmpty();
856    }
857
858    /**
859     * @param value {@link #status} (A code specifying the status of the record of the family history of a specific family member.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
860     */
861    public FamilyMemberHistory setStatusElement(Enumeration<FamilyHistoryStatus> value) { 
862      this.status = value;
863      return this;
864    }
865
866    /**
867     * @return A code specifying the status of the record of the family history of a specific family member.
868     */
869    public FamilyHistoryStatus getStatus() { 
870      return this.status == null ? null : this.status.getValue();
871    }
872
873    /**
874     * @param value A code specifying the status of the record of the family history of a specific family member.
875     */
876    public FamilyMemberHistory setStatus(FamilyHistoryStatus value) { 
877        if (this.status == null)
878          this.status = new Enumeration<FamilyHistoryStatus>(new FamilyHistoryStatusEnumFactory());
879        this.status.setValue(value);
880      return this;
881    }
882
883    /**
884     * @return {@link #notDone} (If true, indicates the taking of an individual family member's history did not occur. The notDone element should not be used to document negated conditions, such as a family member that did not have a condition.). This is the underlying object with id, value and extensions. The accessor "getNotDone" gives direct access to the value
885     */
886    public BooleanType getNotDoneElement() { 
887      if (this.notDone == null)
888        if (Configuration.errorOnAutoCreate())
889          throw new Error("Attempt to auto-create FamilyMemberHistory.notDone");
890        else if (Configuration.doAutoCreate())
891          this.notDone = new BooleanType(); // bb
892      return this.notDone;
893    }
894
895    public boolean hasNotDoneElement() { 
896      return this.notDone != null && !this.notDone.isEmpty();
897    }
898
899    public boolean hasNotDone() { 
900      return this.notDone != null && !this.notDone.isEmpty();
901    }
902
903    /**
904     * @param value {@link #notDone} (If true, indicates the taking of an individual family member's history did not occur. The notDone element should not be used to document negated conditions, such as a family member that did not have a condition.). This is the underlying object with id, value and extensions. The accessor "getNotDone" gives direct access to the value
905     */
906    public FamilyMemberHistory setNotDoneElement(BooleanType value) { 
907      this.notDone = value;
908      return this;
909    }
910
911    /**
912     * @return If true, indicates the taking of an individual family member's history did not occur. The notDone element should not be used to document negated conditions, such as a family member that did not have a condition.
913     */
914    public boolean getNotDone() { 
915      return this.notDone == null || this.notDone.isEmpty() ? false : this.notDone.getValue();
916    }
917
918    /**
919     * @param value If true, indicates the taking of an individual family member's history did not occur. The notDone element should not be used to document negated conditions, such as a family member that did not have a condition.
920     */
921    public FamilyMemberHistory setNotDone(boolean value) { 
922        if (this.notDone == null)
923          this.notDone = new BooleanType();
924        this.notDone.setValue(value);
925      return this;
926    }
927
928    /**
929     * @return {@link #notDoneReason} (Describes why the family member's history is absent.)
930     */
931    public CodeableConcept getNotDoneReason() { 
932      if (this.notDoneReason == null)
933        if (Configuration.errorOnAutoCreate())
934          throw new Error("Attempt to auto-create FamilyMemberHistory.notDoneReason");
935        else if (Configuration.doAutoCreate())
936          this.notDoneReason = new CodeableConcept(); // cc
937      return this.notDoneReason;
938    }
939
940    public boolean hasNotDoneReason() { 
941      return this.notDoneReason != null && !this.notDoneReason.isEmpty();
942    }
943
944    /**
945     * @param value {@link #notDoneReason} (Describes why the family member's history is absent.)
946     */
947    public FamilyMemberHistory setNotDoneReason(CodeableConcept value) { 
948      this.notDoneReason = value;
949      return this;
950    }
951
952    /**
953     * @return {@link #patient} (The person who this history concerns.)
954     */
955    public Reference getPatient() { 
956      if (this.patient == null)
957        if (Configuration.errorOnAutoCreate())
958          throw new Error("Attempt to auto-create FamilyMemberHistory.patient");
959        else if (Configuration.doAutoCreate())
960          this.patient = new Reference(); // cc
961      return this.patient;
962    }
963
964    public boolean hasPatient() { 
965      return this.patient != null && !this.patient.isEmpty();
966    }
967
968    /**
969     * @param value {@link #patient} (The person who this history concerns.)
970     */
971    public FamilyMemberHistory setPatient(Reference value) { 
972      this.patient = value;
973      return this;
974    }
975
976    /**
977     * @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.)
978     */
979    public Patient getPatientTarget() { 
980      if (this.patientTarget == null)
981        if (Configuration.errorOnAutoCreate())
982          throw new Error("Attempt to auto-create FamilyMemberHistory.patient");
983        else if (Configuration.doAutoCreate())
984          this.patientTarget = new Patient(); // aa
985      return this.patientTarget;
986    }
987
988    /**
989     * @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.)
990     */
991    public FamilyMemberHistory setPatientTarget(Patient value) { 
992      this.patientTarget = value;
993      return this;
994    }
995
996    /**
997     * @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
998     */
999    public DateTimeType getDateElement() { 
1000      if (this.date == null)
1001        if (Configuration.errorOnAutoCreate())
1002          throw new Error("Attempt to auto-create FamilyMemberHistory.date");
1003        else if (Configuration.doAutoCreate())
1004          this.date = new DateTimeType(); // bb
1005      return this.date;
1006    }
1007
1008    public boolean hasDateElement() { 
1009      return this.date != null && !this.date.isEmpty();
1010    }
1011
1012    public boolean hasDate() { 
1013      return this.date != null && !this.date.isEmpty();
1014    }
1015
1016    /**
1017     * @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
1018     */
1019    public FamilyMemberHistory setDateElement(DateTimeType value) { 
1020      this.date = value;
1021      return this;
1022    }
1023
1024    /**
1025     * @return The date (and possibly time) when the family member history was taken.
1026     */
1027    public Date getDate() { 
1028      return this.date == null ? null : this.date.getValue();
1029    }
1030
1031    /**
1032     * @param value The date (and possibly time) when the family member history was taken.
1033     */
1034    public FamilyMemberHistory setDate(Date value) { 
1035      if (value == null)
1036        this.date = null;
1037      else {
1038        if (this.date == null)
1039          this.date = new DateTimeType();
1040        this.date.setValue(value);
1041      }
1042      return this;
1043    }
1044
1045    /**
1046     * @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
1047     */
1048    public StringType getNameElement() { 
1049      if (this.name == null)
1050        if (Configuration.errorOnAutoCreate())
1051          throw new Error("Attempt to auto-create FamilyMemberHistory.name");
1052        else if (Configuration.doAutoCreate())
1053          this.name = new StringType(); // bb
1054      return this.name;
1055    }
1056
1057    public boolean hasNameElement() { 
1058      return this.name != null && !this.name.isEmpty();
1059    }
1060
1061    public boolean hasName() { 
1062      return this.name != null && !this.name.isEmpty();
1063    }
1064
1065    /**
1066     * @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
1067     */
1068    public FamilyMemberHistory setNameElement(StringType value) { 
1069      this.name = value;
1070      return this;
1071    }
1072
1073    /**
1074     * @return This will either be a name or a description; e.g. "Aunt Susan", "my cousin with the red hair".
1075     */
1076    public String getName() { 
1077      return this.name == null ? null : this.name.getValue();
1078    }
1079
1080    /**
1081     * @param value This will either be a name or a description; e.g. "Aunt Susan", "my cousin with the red hair".
1082     */
1083    public FamilyMemberHistory setName(String value) { 
1084      if (Utilities.noString(value))
1085        this.name = null;
1086      else {
1087        if (this.name == null)
1088          this.name = new StringType();
1089        this.name.setValue(value);
1090      }
1091      return this;
1092    }
1093
1094    /**
1095     * @return {@link #relationship} (The type of relationship this person has to the patient (father, mother, brother etc.).)
1096     */
1097    public CodeableConcept getRelationship() { 
1098      if (this.relationship == null)
1099        if (Configuration.errorOnAutoCreate())
1100          throw new Error("Attempt to auto-create FamilyMemberHistory.relationship");
1101        else if (Configuration.doAutoCreate())
1102          this.relationship = new CodeableConcept(); // cc
1103      return this.relationship;
1104    }
1105
1106    public boolean hasRelationship() { 
1107      return this.relationship != null && !this.relationship.isEmpty();
1108    }
1109
1110    /**
1111     * @param value {@link #relationship} (The type of relationship this person has to the patient (father, mother, brother etc.).)
1112     */
1113    public FamilyMemberHistory setRelationship(CodeableConcept value) { 
1114      this.relationship = value;
1115      return this;
1116    }
1117
1118    /**
1119     * @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
1120     */
1121    public Enumeration<AdministrativeGender> getGenderElement() { 
1122      if (this.gender == null)
1123        if (Configuration.errorOnAutoCreate())
1124          throw new Error("Attempt to auto-create FamilyMemberHistory.gender");
1125        else if (Configuration.doAutoCreate())
1126          this.gender = new Enumeration<AdministrativeGender>(new AdministrativeGenderEnumFactory()); // bb
1127      return this.gender;
1128    }
1129
1130    public boolean hasGenderElement() { 
1131      return this.gender != null && !this.gender.isEmpty();
1132    }
1133
1134    public boolean hasGender() { 
1135      return this.gender != null && !this.gender.isEmpty();
1136    }
1137
1138    /**
1139     * @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
1140     */
1141    public FamilyMemberHistory setGenderElement(Enumeration<AdministrativeGender> value) { 
1142      this.gender = value;
1143      return this;
1144    }
1145
1146    /**
1147     * @return Administrative Gender - the gender that the relative is considered to have for administration and record keeping purposes.
1148     */
1149    public AdministrativeGender getGender() { 
1150      return this.gender == null ? null : this.gender.getValue();
1151    }
1152
1153    /**
1154     * @param value Administrative Gender - the gender that the relative is considered to have for administration and record keeping purposes.
1155     */
1156    public FamilyMemberHistory setGender(AdministrativeGender value) { 
1157      if (value == null)
1158        this.gender = null;
1159      else {
1160        if (this.gender == null)
1161          this.gender = new Enumeration<AdministrativeGender>(new AdministrativeGenderEnumFactory());
1162        this.gender.setValue(value);
1163      }
1164      return this;
1165    }
1166
1167    /**
1168     * @return {@link #born} (The actual or approximate date of birth of the relative.)
1169     */
1170    public Type getBorn() { 
1171      return this.born;
1172    }
1173
1174    /**
1175     * @return {@link #born} (The actual or approximate date of birth of the relative.)
1176     */
1177    public Period getBornPeriod() throws FHIRException { 
1178      if (!(this.born instanceof Period))
1179        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.born.getClass().getName()+" was encountered");
1180      return (Period) this.born;
1181    }
1182
1183    public boolean hasBornPeriod() { 
1184      return this.born instanceof Period;
1185    }
1186
1187    /**
1188     * @return {@link #born} (The actual or approximate date of birth of the relative.)
1189     */
1190    public DateType getBornDateType() throws FHIRException { 
1191      if (!(this.born instanceof DateType))
1192        throw new FHIRException("Type mismatch: the type DateType was expected, but "+this.born.getClass().getName()+" was encountered");
1193      return (DateType) this.born;
1194    }
1195
1196    public boolean hasBornDateType() { 
1197      return this.born instanceof DateType;
1198    }
1199
1200    /**
1201     * @return {@link #born} (The actual or approximate date of birth of the relative.)
1202     */
1203    public StringType getBornStringType() throws FHIRException { 
1204      if (!(this.born instanceof StringType))
1205        throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.born.getClass().getName()+" was encountered");
1206      return (StringType) this.born;
1207    }
1208
1209    public boolean hasBornStringType() { 
1210      return this.born instanceof StringType;
1211    }
1212
1213    public boolean hasBorn() { 
1214      return this.born != null && !this.born.isEmpty();
1215    }
1216
1217    /**
1218     * @param value {@link #born} (The actual or approximate date of birth of the relative.)
1219     */
1220    public FamilyMemberHistory setBorn(Type value) { 
1221      this.born = value;
1222      return this;
1223    }
1224
1225    /**
1226     * @return {@link #age} (The age of the relative at the time the family member history is recorded.)
1227     */
1228    public Type getAge() { 
1229      return this.age;
1230    }
1231
1232    /**
1233     * @return {@link #age} (The age of the relative at the time the family member history is recorded.)
1234     */
1235    public Age getAgeAge() throws FHIRException { 
1236      if (!(this.age instanceof Age))
1237        throw new FHIRException("Type mismatch: the type Age was expected, but "+this.age.getClass().getName()+" was encountered");
1238      return (Age) this.age;
1239    }
1240
1241    public boolean hasAgeAge() { 
1242      return this.age instanceof Age;
1243    }
1244
1245    /**
1246     * @return {@link #age} (The age of the relative at the time the family member history is recorded.)
1247     */
1248    public Range getAgeRange() throws FHIRException { 
1249      if (!(this.age instanceof Range))
1250        throw new FHIRException("Type mismatch: the type Range was expected, but "+this.age.getClass().getName()+" was encountered");
1251      return (Range) this.age;
1252    }
1253
1254    public boolean hasAgeRange() { 
1255      return this.age instanceof Range;
1256    }
1257
1258    /**
1259     * @return {@link #age} (The age of the relative at the time the family member history is recorded.)
1260     */
1261    public StringType getAgeStringType() throws FHIRException { 
1262      if (!(this.age instanceof StringType))
1263        throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.age.getClass().getName()+" was encountered");
1264      return (StringType) this.age;
1265    }
1266
1267    public boolean hasAgeStringType() { 
1268      return this.age instanceof StringType;
1269    }
1270
1271    public boolean hasAge() { 
1272      return this.age != null && !this.age.isEmpty();
1273    }
1274
1275    /**
1276     * @param value {@link #age} (The age of the relative at the time the family member history is recorded.)
1277     */
1278    public FamilyMemberHistory setAge(Type value) { 
1279      this.age = value;
1280      return this;
1281    }
1282
1283    /**
1284     * @return {@link #estimatedAge} (If true, indicates that the age value specified is an estimated value.). This is the underlying object with id, value and extensions. The accessor "getEstimatedAge" gives direct access to the value
1285     */
1286    public BooleanType getEstimatedAgeElement() { 
1287      if (this.estimatedAge == null)
1288        if (Configuration.errorOnAutoCreate())
1289          throw new Error("Attempt to auto-create FamilyMemberHistory.estimatedAge");
1290        else if (Configuration.doAutoCreate())
1291          this.estimatedAge = new BooleanType(); // bb
1292      return this.estimatedAge;
1293    }
1294
1295    public boolean hasEstimatedAgeElement() { 
1296      return this.estimatedAge != null && !this.estimatedAge.isEmpty();
1297    }
1298
1299    public boolean hasEstimatedAge() { 
1300      return this.estimatedAge != null && !this.estimatedAge.isEmpty();
1301    }
1302
1303    /**
1304     * @param value {@link #estimatedAge} (If true, indicates that the age value specified is an estimated value.). This is the underlying object with id, value and extensions. The accessor "getEstimatedAge" gives direct access to the value
1305     */
1306    public FamilyMemberHistory setEstimatedAgeElement(BooleanType value) { 
1307      this.estimatedAge = value;
1308      return this;
1309    }
1310
1311    /**
1312     * @return If true, indicates that the age value specified is an estimated value.
1313     */
1314    public boolean getEstimatedAge() { 
1315      return this.estimatedAge == null || this.estimatedAge.isEmpty() ? false : this.estimatedAge.getValue();
1316    }
1317
1318    /**
1319     * @param value If true, indicates that the age value specified is an estimated value.
1320     */
1321    public FamilyMemberHistory setEstimatedAge(boolean value) { 
1322        if (this.estimatedAge == null)
1323          this.estimatedAge = new BooleanType();
1324        this.estimatedAge.setValue(value);
1325      return this;
1326    }
1327
1328    /**
1329     * @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.)
1330     */
1331    public Type getDeceased() { 
1332      return this.deceased;
1333    }
1334
1335    /**
1336     * @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.)
1337     */
1338    public BooleanType getDeceasedBooleanType() throws FHIRException { 
1339      if (!(this.deceased instanceof BooleanType))
1340        throw new FHIRException("Type mismatch: the type BooleanType was expected, but "+this.deceased.getClass().getName()+" was encountered");
1341      return (BooleanType) this.deceased;
1342    }
1343
1344    public boolean hasDeceasedBooleanType() { 
1345      return this.deceased instanceof BooleanType;
1346    }
1347
1348    /**
1349     * @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.)
1350     */
1351    public Age getDeceasedAge() throws FHIRException { 
1352      if (!(this.deceased instanceof Age))
1353        throw new FHIRException("Type mismatch: the type Age was expected, but "+this.deceased.getClass().getName()+" was encountered");
1354      return (Age) this.deceased;
1355    }
1356
1357    public boolean hasDeceasedAge() { 
1358      return this.deceased instanceof Age;
1359    }
1360
1361    /**
1362     * @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.)
1363     */
1364    public Range getDeceasedRange() throws FHIRException { 
1365      if (!(this.deceased instanceof Range))
1366        throw new FHIRException("Type mismatch: the type Range was expected, but "+this.deceased.getClass().getName()+" was encountered");
1367      return (Range) this.deceased;
1368    }
1369
1370    public boolean hasDeceasedRange() { 
1371      return this.deceased instanceof Range;
1372    }
1373
1374    /**
1375     * @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.)
1376     */
1377    public DateType getDeceasedDateType() throws FHIRException { 
1378      if (!(this.deceased instanceof DateType))
1379        throw new FHIRException("Type mismatch: the type DateType was expected, but "+this.deceased.getClass().getName()+" was encountered");
1380      return (DateType) this.deceased;
1381    }
1382
1383    public boolean hasDeceasedDateType() { 
1384      return this.deceased instanceof DateType;
1385    }
1386
1387    /**
1388     * @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.)
1389     */
1390    public StringType getDeceasedStringType() throws FHIRException { 
1391      if (!(this.deceased instanceof StringType))
1392        throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.deceased.getClass().getName()+" was encountered");
1393      return (StringType) this.deceased;
1394    }
1395
1396    public boolean hasDeceasedStringType() { 
1397      return this.deceased instanceof StringType;
1398    }
1399
1400    public boolean hasDeceased() { 
1401      return this.deceased != null && !this.deceased.isEmpty();
1402    }
1403
1404    /**
1405     * @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.)
1406     */
1407    public FamilyMemberHistory setDeceased(Type value) { 
1408      this.deceased = value;
1409      return this;
1410    }
1411
1412    /**
1413     * @return {@link #reasonCode} (Describes why the family member history occurred in coded or textual form.)
1414     */
1415    public List<CodeableConcept> getReasonCode() { 
1416      if (this.reasonCode == null)
1417        this.reasonCode = new ArrayList<CodeableConcept>();
1418      return this.reasonCode;
1419    }
1420
1421    /**
1422     * @return Returns a reference to <code>this</code> for easy method chaining
1423     */
1424    public FamilyMemberHistory setReasonCode(List<CodeableConcept> theReasonCode) { 
1425      this.reasonCode = theReasonCode;
1426      return this;
1427    }
1428
1429    public boolean hasReasonCode() { 
1430      if (this.reasonCode == null)
1431        return false;
1432      for (CodeableConcept item : this.reasonCode)
1433        if (!item.isEmpty())
1434          return true;
1435      return false;
1436    }
1437
1438    public CodeableConcept addReasonCode() { //3
1439      CodeableConcept t = new CodeableConcept();
1440      if (this.reasonCode == null)
1441        this.reasonCode = new ArrayList<CodeableConcept>();
1442      this.reasonCode.add(t);
1443      return t;
1444    }
1445
1446    public FamilyMemberHistory addReasonCode(CodeableConcept t) { //3
1447      if (t == null)
1448        return this;
1449      if (this.reasonCode == null)
1450        this.reasonCode = new ArrayList<CodeableConcept>();
1451      this.reasonCode.add(t);
1452      return this;
1453    }
1454
1455    /**
1456     * @return The first repetition of repeating field {@link #reasonCode}, creating it if it does not already exist
1457     */
1458    public CodeableConcept getReasonCodeFirstRep() { 
1459      if (getReasonCode().isEmpty()) {
1460        addReasonCode();
1461      }
1462      return getReasonCode().get(0);
1463    }
1464
1465    /**
1466     * @return {@link #reasonReference} (Indicates a Condition, Observation, AllergyIntolerance, or QuestionnaireResponse that justifies this family member history event.)
1467     */
1468    public List<Reference> getReasonReference() { 
1469      if (this.reasonReference == null)
1470        this.reasonReference = new ArrayList<Reference>();
1471      return this.reasonReference;
1472    }
1473
1474    /**
1475     * @return Returns a reference to <code>this</code> for easy method chaining
1476     */
1477    public FamilyMemberHistory setReasonReference(List<Reference> theReasonReference) { 
1478      this.reasonReference = theReasonReference;
1479      return this;
1480    }
1481
1482    public boolean hasReasonReference() { 
1483      if (this.reasonReference == null)
1484        return false;
1485      for (Reference item : this.reasonReference)
1486        if (!item.isEmpty())
1487          return true;
1488      return false;
1489    }
1490
1491    public Reference addReasonReference() { //3
1492      Reference t = new Reference();
1493      if (this.reasonReference == null)
1494        this.reasonReference = new ArrayList<Reference>();
1495      this.reasonReference.add(t);
1496      return t;
1497    }
1498
1499    public FamilyMemberHistory addReasonReference(Reference t) { //3
1500      if (t == null)
1501        return this;
1502      if (this.reasonReference == null)
1503        this.reasonReference = new ArrayList<Reference>();
1504      this.reasonReference.add(t);
1505      return this;
1506    }
1507
1508    /**
1509     * @return The first repetition of repeating field {@link #reasonReference}, creating it if it does not already exist
1510     */
1511    public Reference getReasonReferenceFirstRep() { 
1512      if (getReasonReference().isEmpty()) {
1513        addReasonReference();
1514      }
1515      return getReasonReference().get(0);
1516    }
1517
1518    /**
1519     * @deprecated Use Reference#setResource(IBaseResource) instead
1520     */
1521    @Deprecated
1522    public List<Resource> getReasonReferenceTarget() { 
1523      if (this.reasonReferenceTarget == null)
1524        this.reasonReferenceTarget = new ArrayList<Resource>();
1525      return this.reasonReferenceTarget;
1526    }
1527
1528    /**
1529     * @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.)
1530     */
1531    public List<Annotation> getNote() { 
1532      if (this.note == null)
1533        this.note = new ArrayList<Annotation>();
1534      return this.note;
1535    }
1536
1537    /**
1538     * @return Returns a reference to <code>this</code> for easy method chaining
1539     */
1540    public FamilyMemberHistory setNote(List<Annotation> theNote) { 
1541      this.note = theNote;
1542      return this;
1543    }
1544
1545    public boolean hasNote() { 
1546      if (this.note == null)
1547        return false;
1548      for (Annotation item : this.note)
1549        if (!item.isEmpty())
1550          return true;
1551      return false;
1552    }
1553
1554    public Annotation addNote() { //3
1555      Annotation t = new Annotation();
1556      if (this.note == null)
1557        this.note = new ArrayList<Annotation>();
1558      this.note.add(t);
1559      return t;
1560    }
1561
1562    public FamilyMemberHistory addNote(Annotation t) { //3
1563      if (t == null)
1564        return this;
1565      if (this.note == null)
1566        this.note = new ArrayList<Annotation>();
1567      this.note.add(t);
1568      return this;
1569    }
1570
1571    /**
1572     * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist
1573     */
1574    public Annotation getNoteFirstRep() { 
1575      if (getNote().isEmpty()) {
1576        addNote();
1577      }
1578      return getNote().get(0);
1579    }
1580
1581    /**
1582     * @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.)
1583     */
1584    public List<FamilyMemberHistoryConditionComponent> getCondition() { 
1585      if (this.condition == null)
1586        this.condition = new ArrayList<FamilyMemberHistoryConditionComponent>();
1587      return this.condition;
1588    }
1589
1590    /**
1591     * @return Returns a reference to <code>this</code> for easy method chaining
1592     */
1593    public FamilyMemberHistory setCondition(List<FamilyMemberHistoryConditionComponent> theCondition) { 
1594      this.condition = theCondition;
1595      return this;
1596    }
1597
1598    public boolean hasCondition() { 
1599      if (this.condition == null)
1600        return false;
1601      for (FamilyMemberHistoryConditionComponent item : this.condition)
1602        if (!item.isEmpty())
1603          return true;
1604      return false;
1605    }
1606
1607    public FamilyMemberHistoryConditionComponent addCondition() { //3
1608      FamilyMemberHistoryConditionComponent t = new FamilyMemberHistoryConditionComponent();
1609      if (this.condition == null)
1610        this.condition = new ArrayList<FamilyMemberHistoryConditionComponent>();
1611      this.condition.add(t);
1612      return t;
1613    }
1614
1615    public FamilyMemberHistory addCondition(FamilyMemberHistoryConditionComponent t) { //3
1616      if (t == null)
1617        return this;
1618      if (this.condition == null)
1619        this.condition = new ArrayList<FamilyMemberHistoryConditionComponent>();
1620      this.condition.add(t);
1621      return this;
1622    }
1623
1624    /**
1625     * @return The first repetition of repeating field {@link #condition}, creating it if it does not already exist
1626     */
1627    public FamilyMemberHistoryConditionComponent getConditionFirstRep() { 
1628      if (getCondition().isEmpty()) {
1629        addCondition();
1630      }
1631      return getCondition().get(0);
1632    }
1633
1634      protected void listChildren(List<Property> childrenList) {
1635        super.listChildren(childrenList);
1636        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));
1637        childrenList.add(new Property("definition", "Reference(PlanDefinition|Questionnaire)", "A protocol or questionnaire that was adhered to in whole or in part by this event.", 0, java.lang.Integer.MAX_VALUE, definition));
1638        childrenList.add(new Property("status", "code", "A code specifying the status of the record of the family history of a specific family member.", 0, java.lang.Integer.MAX_VALUE, status));
1639        childrenList.add(new Property("notDone", "boolean", "If true, indicates the taking of an individual family member's history did not occur. The notDone element should not be used to document negated conditions, such as a family member that did not have a condition.", 0, java.lang.Integer.MAX_VALUE, notDone));
1640        childrenList.add(new Property("notDoneReason", "CodeableConcept", "Describes why the family member's history is absent.", 0, java.lang.Integer.MAX_VALUE, notDoneReason));
1641        childrenList.add(new Property("patient", "Reference(Patient)", "The person who this history concerns.", 0, java.lang.Integer.MAX_VALUE, patient));
1642        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));
1643        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));
1644        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));
1645        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));
1646        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));
1647        childrenList.add(new Property("age[x]", "Age|Range|string", "The age of the relative at the time the family member history is recorded.", 0, java.lang.Integer.MAX_VALUE, age));
1648        childrenList.add(new Property("estimatedAge", "boolean", "If true, indicates that the age value specified is an estimated value.", 0, java.lang.Integer.MAX_VALUE, estimatedAge));
1649        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));
1650        childrenList.add(new Property("reasonCode", "CodeableConcept", "Describes why the family member history occurred in coded or textual form.", 0, java.lang.Integer.MAX_VALUE, reasonCode));
1651        childrenList.add(new Property("reasonReference", "Reference(Condition|Observation|AllergyIntolerance|QuestionnaireResponse)", "Indicates a Condition, Observation, AllergyIntolerance, or QuestionnaireResponse that justifies this family member history event.", 0, java.lang.Integer.MAX_VALUE, reasonReference));
1652        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));
1653        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));
1654      }
1655
1656      @Override
1657      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1658        switch (hash) {
1659        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1660        case -1014418093: /*definition*/ return this.definition == null ? new Base[0] : this.definition.toArray(new Base[this.definition.size()]); // Reference
1661        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<FamilyHistoryStatus>
1662        case 2128257269: /*notDone*/ return this.notDone == null ? new Base[0] : new Base[] {this.notDone}; // BooleanType
1663        case -1973169255: /*notDoneReason*/ return this.notDoneReason == null ? new Base[0] : new Base[] {this.notDoneReason}; // CodeableConcept
1664        case -791418107: /*patient*/ return this.patient == null ? new Base[0] : new Base[] {this.patient}; // Reference
1665        case 3076014: /*date*/ return this.date == null ? new Base[0] : new Base[] {this.date}; // DateTimeType
1666        case 3373707: /*name*/ return this.name == null ? new Base[0] : new Base[] {this.name}; // StringType
1667        case -261851592: /*relationship*/ return this.relationship == null ? new Base[0] : new Base[] {this.relationship}; // CodeableConcept
1668        case -1249512767: /*gender*/ return this.gender == null ? new Base[0] : new Base[] {this.gender}; // Enumeration<AdministrativeGender>
1669        case 3029833: /*born*/ return this.born == null ? new Base[0] : new Base[] {this.born}; // Type
1670        case 96511: /*age*/ return this.age == null ? new Base[0] : new Base[] {this.age}; // Type
1671        case 2130167587: /*estimatedAge*/ return this.estimatedAge == null ? new Base[0] : new Base[] {this.estimatedAge}; // BooleanType
1672        case 561497972: /*deceased*/ return this.deceased == null ? new Base[0] : new Base[] {this.deceased}; // Type
1673        case 722137681: /*reasonCode*/ return this.reasonCode == null ? new Base[0] : this.reasonCode.toArray(new Base[this.reasonCode.size()]); // CodeableConcept
1674        case -1146218137: /*reasonReference*/ return this.reasonReference == null ? new Base[0] : this.reasonReference.toArray(new Base[this.reasonReference.size()]); // Reference
1675        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
1676        case -861311717: /*condition*/ return this.condition == null ? new Base[0] : this.condition.toArray(new Base[this.condition.size()]); // FamilyMemberHistoryConditionComponent
1677        default: return super.getProperty(hash, name, checkValid);
1678        }
1679
1680      }
1681
1682      @Override
1683      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1684        switch (hash) {
1685        case -1618432855: // identifier
1686          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1687          return value;
1688        case -1014418093: // definition
1689          this.getDefinition().add(castToReference(value)); // Reference
1690          return value;
1691        case -892481550: // status
1692          value = new FamilyHistoryStatusEnumFactory().fromType(castToCode(value));
1693          this.status = (Enumeration) value; // Enumeration<FamilyHistoryStatus>
1694          return value;
1695        case 2128257269: // notDone
1696          this.notDone = castToBoolean(value); // BooleanType
1697          return value;
1698        case -1973169255: // notDoneReason
1699          this.notDoneReason = castToCodeableConcept(value); // CodeableConcept
1700          return value;
1701        case -791418107: // patient
1702          this.patient = castToReference(value); // Reference
1703          return value;
1704        case 3076014: // date
1705          this.date = castToDateTime(value); // DateTimeType
1706          return value;
1707        case 3373707: // name
1708          this.name = castToString(value); // StringType
1709          return value;
1710        case -261851592: // relationship
1711          this.relationship = castToCodeableConcept(value); // CodeableConcept
1712          return value;
1713        case -1249512767: // gender
1714          value = new AdministrativeGenderEnumFactory().fromType(castToCode(value));
1715          this.gender = (Enumeration) value; // Enumeration<AdministrativeGender>
1716          return value;
1717        case 3029833: // born
1718          this.born = castToType(value); // Type
1719          return value;
1720        case 96511: // age
1721          this.age = castToType(value); // Type
1722          return value;
1723        case 2130167587: // estimatedAge
1724          this.estimatedAge = castToBoolean(value); // BooleanType
1725          return value;
1726        case 561497972: // deceased
1727          this.deceased = castToType(value); // Type
1728          return value;
1729        case 722137681: // reasonCode
1730          this.getReasonCode().add(castToCodeableConcept(value)); // CodeableConcept
1731          return value;
1732        case -1146218137: // reasonReference
1733          this.getReasonReference().add(castToReference(value)); // Reference
1734          return value;
1735        case 3387378: // note
1736          this.getNote().add(castToAnnotation(value)); // Annotation
1737          return value;
1738        case -861311717: // condition
1739          this.getCondition().add((FamilyMemberHistoryConditionComponent) value); // FamilyMemberHistoryConditionComponent
1740          return value;
1741        default: return super.setProperty(hash, name, value);
1742        }
1743
1744      }
1745
1746      @Override
1747      public Base setProperty(String name, Base value) throws FHIRException {
1748        if (name.equals("identifier")) {
1749          this.getIdentifier().add(castToIdentifier(value));
1750        } else if (name.equals("definition")) {
1751          this.getDefinition().add(castToReference(value));
1752        } else if (name.equals("status")) {
1753          value = new FamilyHistoryStatusEnumFactory().fromType(castToCode(value));
1754          this.status = (Enumeration) value; // Enumeration<FamilyHistoryStatus>
1755        } else if (name.equals("notDone")) {
1756          this.notDone = castToBoolean(value); // BooleanType
1757        } else if (name.equals("notDoneReason")) {
1758          this.notDoneReason = castToCodeableConcept(value); // CodeableConcept
1759        } else if (name.equals("patient")) {
1760          this.patient = castToReference(value); // Reference
1761        } else if (name.equals("date")) {
1762          this.date = castToDateTime(value); // DateTimeType
1763        } else if (name.equals("name")) {
1764          this.name = castToString(value); // StringType
1765        } else if (name.equals("relationship")) {
1766          this.relationship = castToCodeableConcept(value); // CodeableConcept
1767        } else if (name.equals("gender")) {
1768          value = new AdministrativeGenderEnumFactory().fromType(castToCode(value));
1769          this.gender = (Enumeration) value; // Enumeration<AdministrativeGender>
1770        } else if (name.equals("born[x]")) {
1771          this.born = castToType(value); // Type
1772        } else if (name.equals("age[x]")) {
1773          this.age = castToType(value); // Type
1774        } else if (name.equals("estimatedAge")) {
1775          this.estimatedAge = castToBoolean(value); // BooleanType
1776        } else if (name.equals("deceased[x]")) {
1777          this.deceased = castToType(value); // Type
1778        } else if (name.equals("reasonCode")) {
1779          this.getReasonCode().add(castToCodeableConcept(value));
1780        } else if (name.equals("reasonReference")) {
1781          this.getReasonReference().add(castToReference(value));
1782        } else if (name.equals("note")) {
1783          this.getNote().add(castToAnnotation(value));
1784        } else if (name.equals("condition")) {
1785          this.getCondition().add((FamilyMemberHistoryConditionComponent) value);
1786        } else
1787          return super.setProperty(name, value);
1788        return value;
1789      }
1790
1791      @Override
1792      public Base makeProperty(int hash, String name) throws FHIRException {
1793        switch (hash) {
1794        case -1618432855:  return addIdentifier(); 
1795        case -1014418093:  return addDefinition(); 
1796        case -892481550:  return getStatusElement();
1797        case 2128257269:  return getNotDoneElement();
1798        case -1973169255:  return getNotDoneReason(); 
1799        case -791418107:  return getPatient(); 
1800        case 3076014:  return getDateElement();
1801        case 3373707:  return getNameElement();
1802        case -261851592:  return getRelationship(); 
1803        case -1249512767:  return getGenderElement();
1804        case 67532951:  return getBorn(); 
1805        case 3029833:  return getBorn(); 
1806        case -1419716831:  return getAge(); 
1807        case 96511:  return getAge(); 
1808        case 2130167587:  return getEstimatedAgeElement();
1809        case -1311442804:  return getDeceased(); 
1810        case 561497972:  return getDeceased(); 
1811        case 722137681:  return addReasonCode(); 
1812        case -1146218137:  return addReasonReference(); 
1813        case 3387378:  return addNote(); 
1814        case -861311717:  return addCondition(); 
1815        default: return super.makeProperty(hash, name);
1816        }
1817
1818      }
1819
1820      @Override
1821      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1822        switch (hash) {
1823        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
1824        case -1014418093: /*definition*/ return new String[] {"Reference"};
1825        case -892481550: /*status*/ return new String[] {"code"};
1826        case 2128257269: /*notDone*/ return new String[] {"boolean"};
1827        case -1973169255: /*notDoneReason*/ return new String[] {"CodeableConcept"};
1828        case -791418107: /*patient*/ return new String[] {"Reference"};
1829        case 3076014: /*date*/ return new String[] {"dateTime"};
1830        case 3373707: /*name*/ return new String[] {"string"};
1831        case -261851592: /*relationship*/ return new String[] {"CodeableConcept"};
1832        case -1249512767: /*gender*/ return new String[] {"code"};
1833        case 3029833: /*born*/ return new String[] {"Period", "date", "string"};
1834        case 96511: /*age*/ return new String[] {"Age", "Range", "string"};
1835        case 2130167587: /*estimatedAge*/ return new String[] {"boolean"};
1836        case 561497972: /*deceased*/ return new String[] {"boolean", "Age", "Range", "date", "string"};
1837        case 722137681: /*reasonCode*/ return new String[] {"CodeableConcept"};
1838        case -1146218137: /*reasonReference*/ return new String[] {"Reference"};
1839        case 3387378: /*note*/ return new String[] {"Annotation"};
1840        case -861311717: /*condition*/ return new String[] {};
1841        default: return super.getTypesForProperty(hash, name);
1842        }
1843
1844      }
1845
1846      @Override
1847      public Base addChild(String name) throws FHIRException {
1848        if (name.equals("identifier")) {
1849          return addIdentifier();
1850        }
1851        else if (name.equals("definition")) {
1852          return addDefinition();
1853        }
1854        else if (name.equals("status")) {
1855          throw new FHIRException("Cannot call addChild on a primitive type FamilyMemberHistory.status");
1856        }
1857        else if (name.equals("notDone")) {
1858          throw new FHIRException("Cannot call addChild on a primitive type FamilyMemberHistory.notDone");
1859        }
1860        else if (name.equals("notDoneReason")) {
1861          this.notDoneReason = new CodeableConcept();
1862          return this.notDoneReason;
1863        }
1864        else if (name.equals("patient")) {
1865          this.patient = new Reference();
1866          return this.patient;
1867        }
1868        else if (name.equals("date")) {
1869          throw new FHIRException("Cannot call addChild on a primitive type FamilyMemberHistory.date");
1870        }
1871        else if (name.equals("name")) {
1872          throw new FHIRException("Cannot call addChild on a primitive type FamilyMemberHistory.name");
1873        }
1874        else if (name.equals("relationship")) {
1875          this.relationship = new CodeableConcept();
1876          return this.relationship;
1877        }
1878        else if (name.equals("gender")) {
1879          throw new FHIRException("Cannot call addChild on a primitive type FamilyMemberHistory.gender");
1880        }
1881        else if (name.equals("bornPeriod")) {
1882          this.born = new Period();
1883          return this.born;
1884        }
1885        else if (name.equals("bornDate")) {
1886          this.born = new DateType();
1887          return this.born;
1888        }
1889        else if (name.equals("bornString")) {
1890          this.born = new StringType();
1891          return this.born;
1892        }
1893        else if (name.equals("ageAge")) {
1894          this.age = new Age();
1895          return this.age;
1896        }
1897        else if (name.equals("ageRange")) {
1898          this.age = new Range();
1899          return this.age;
1900        }
1901        else if (name.equals("ageString")) {
1902          this.age = new StringType();
1903          return this.age;
1904        }
1905        else if (name.equals("estimatedAge")) {
1906          throw new FHIRException("Cannot call addChild on a primitive type FamilyMemberHistory.estimatedAge");
1907        }
1908        else if (name.equals("deceasedBoolean")) {
1909          this.deceased = new BooleanType();
1910          return this.deceased;
1911        }
1912        else if (name.equals("deceasedAge")) {
1913          this.deceased = new Age();
1914          return this.deceased;
1915        }
1916        else if (name.equals("deceasedRange")) {
1917          this.deceased = new Range();
1918          return this.deceased;
1919        }
1920        else if (name.equals("deceasedDate")) {
1921          this.deceased = new DateType();
1922          return this.deceased;
1923        }
1924        else if (name.equals("deceasedString")) {
1925          this.deceased = new StringType();
1926          return this.deceased;
1927        }
1928        else if (name.equals("reasonCode")) {
1929          return addReasonCode();
1930        }
1931        else if (name.equals("reasonReference")) {
1932          return addReasonReference();
1933        }
1934        else if (name.equals("note")) {
1935          return addNote();
1936        }
1937        else if (name.equals("condition")) {
1938          return addCondition();
1939        }
1940        else
1941          return super.addChild(name);
1942      }
1943
1944  public String fhirType() {
1945    return "FamilyMemberHistory";
1946
1947  }
1948
1949      public FamilyMemberHistory copy() {
1950        FamilyMemberHistory dst = new FamilyMemberHistory();
1951        copyValues(dst);
1952        if (identifier != null) {
1953          dst.identifier = new ArrayList<Identifier>();
1954          for (Identifier i : identifier)
1955            dst.identifier.add(i.copy());
1956        };
1957        if (definition != null) {
1958          dst.definition = new ArrayList<Reference>();
1959          for (Reference i : definition)
1960            dst.definition.add(i.copy());
1961        };
1962        dst.status = status == null ? null : status.copy();
1963        dst.notDone = notDone == null ? null : notDone.copy();
1964        dst.notDoneReason = notDoneReason == null ? null : notDoneReason.copy();
1965        dst.patient = patient == null ? null : patient.copy();
1966        dst.date = date == null ? null : date.copy();
1967        dst.name = name == null ? null : name.copy();
1968        dst.relationship = relationship == null ? null : relationship.copy();
1969        dst.gender = gender == null ? null : gender.copy();
1970        dst.born = born == null ? null : born.copy();
1971        dst.age = age == null ? null : age.copy();
1972        dst.estimatedAge = estimatedAge == null ? null : estimatedAge.copy();
1973        dst.deceased = deceased == null ? null : deceased.copy();
1974        if (reasonCode != null) {
1975          dst.reasonCode = new ArrayList<CodeableConcept>();
1976          for (CodeableConcept i : reasonCode)
1977            dst.reasonCode.add(i.copy());
1978        };
1979        if (reasonReference != null) {
1980          dst.reasonReference = new ArrayList<Reference>();
1981          for (Reference i : reasonReference)
1982            dst.reasonReference.add(i.copy());
1983        };
1984        if (note != null) {
1985          dst.note = new ArrayList<Annotation>();
1986          for (Annotation i : note)
1987            dst.note.add(i.copy());
1988        };
1989        if (condition != null) {
1990          dst.condition = new ArrayList<FamilyMemberHistoryConditionComponent>();
1991          for (FamilyMemberHistoryConditionComponent i : condition)
1992            dst.condition.add(i.copy());
1993        };
1994        return dst;
1995      }
1996
1997      protected FamilyMemberHistory typedCopy() {
1998        return copy();
1999      }
2000
2001      @Override
2002      public boolean equalsDeep(Base other) {
2003        if (!super.equalsDeep(other))
2004          return false;
2005        if (!(other instanceof FamilyMemberHistory))
2006          return false;
2007        FamilyMemberHistory o = (FamilyMemberHistory) other;
2008        return compareDeep(identifier, o.identifier, true) && compareDeep(definition, o.definition, true)
2009           && compareDeep(status, o.status, true) && compareDeep(notDone, o.notDone, true) && compareDeep(notDoneReason, o.notDoneReason, true)
2010           && compareDeep(patient, o.patient, true) && compareDeep(date, o.date, true) && compareDeep(name, o.name, true)
2011           && compareDeep(relationship, o.relationship, true) && compareDeep(gender, o.gender, true) && compareDeep(born, o.born, true)
2012           && compareDeep(age, o.age, true) && compareDeep(estimatedAge, o.estimatedAge, true) && compareDeep(deceased, o.deceased, true)
2013           && compareDeep(reasonCode, o.reasonCode, true) && compareDeep(reasonReference, o.reasonReference, true)
2014           && compareDeep(note, o.note, true) && compareDeep(condition, o.condition, true);
2015      }
2016
2017      @Override
2018      public boolean equalsShallow(Base other) {
2019        if (!super.equalsShallow(other))
2020          return false;
2021        if (!(other instanceof FamilyMemberHistory))
2022          return false;
2023        FamilyMemberHistory o = (FamilyMemberHistory) other;
2024        return compareValues(status, o.status, true) && compareValues(notDone, o.notDone, true) && compareValues(date, o.date, true)
2025           && compareValues(name, o.name, true) && compareValues(gender, o.gender, true) && compareValues(estimatedAge, o.estimatedAge, true)
2026          ;
2027      }
2028
2029      public boolean isEmpty() {
2030        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, definition, status
2031          , notDone, notDoneReason, patient, date, name, relationship, gender, born, age
2032          , estimatedAge, deceased, reasonCode, reasonReference, note, condition);
2033      }
2034
2035  @Override
2036  public ResourceType getResourceType() {
2037    return ResourceType.FamilyMemberHistory;
2038   }
2039
2040 /**
2041   * Search parameter: <b>date</b>
2042   * <p>
2043   * Description: <b>When history was captured/updated</b><br>
2044   * Type: <b>date</b><br>
2045   * Path: <b>FamilyMemberHistory.date</b><br>
2046   * </p>
2047   */
2048  @SearchParamDefinition(name="date", path="FamilyMemberHistory.date", description="When history was captured/updated", type="date" )
2049  public static final String SP_DATE = "date";
2050 /**
2051   * <b>Fluent Client</b> search parameter constant for <b>date</b>
2052   * <p>
2053   * Description: <b>When history was captured/updated</b><br>
2054   * Type: <b>date</b><br>
2055   * Path: <b>FamilyMemberHistory.date</b><br>
2056   * </p>
2057   */
2058  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
2059
2060 /**
2061   * Search parameter: <b>identifier</b>
2062   * <p>
2063   * Description: <b>A search by a record identifier</b><br>
2064   * Type: <b>token</b><br>
2065   * Path: <b>FamilyMemberHistory.identifier</b><br>
2066   * </p>
2067   */
2068  @SearchParamDefinition(name="identifier", path="FamilyMemberHistory.identifier", description="A search by a record identifier", type="token" )
2069  public static final String SP_IDENTIFIER = "identifier";
2070 /**
2071   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2072   * <p>
2073   * Description: <b>A search by a record identifier</b><br>
2074   * Type: <b>token</b><br>
2075   * Path: <b>FamilyMemberHistory.identifier</b><br>
2076   * </p>
2077   */
2078  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
2079
2080 /**
2081   * Search parameter: <b>code</b>
2082   * <p>
2083   * Description: <b>A search by a condition code</b><br>
2084   * Type: <b>token</b><br>
2085   * Path: <b>FamilyMemberHistory.condition.code</b><br>
2086   * </p>
2087   */
2088  @SearchParamDefinition(name="code", path="FamilyMemberHistory.condition.code", description="A search by a condition code", type="token" )
2089  public static final String SP_CODE = "code";
2090 /**
2091   * <b>Fluent Client</b> search parameter constant for <b>code</b>
2092   * <p>
2093   * Description: <b>A search by a condition code</b><br>
2094   * Type: <b>token</b><br>
2095   * Path: <b>FamilyMemberHistory.condition.code</b><br>
2096   * </p>
2097   */
2098  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CODE);
2099
2100 /**
2101   * Search parameter: <b>gender</b>
2102   * <p>
2103   * Description: <b>A search by a gender code of a family member</b><br>
2104   * Type: <b>token</b><br>
2105   * Path: <b>FamilyMemberHistory.gender</b><br>
2106   * </p>
2107   */
2108  @SearchParamDefinition(name="gender", path="FamilyMemberHistory.gender", description="A search by a gender code of a family member", type="token" )
2109  public static final String SP_GENDER = "gender";
2110 /**
2111   * <b>Fluent Client</b> search parameter constant for <b>gender</b>
2112   * <p>
2113   * Description: <b>A search by a gender code of a family member</b><br>
2114   * Type: <b>token</b><br>
2115   * Path: <b>FamilyMemberHistory.gender</b><br>
2116   * </p>
2117   */
2118  public static final ca.uhn.fhir.rest.gclient.TokenClientParam GENDER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_GENDER);
2119
2120 /**
2121   * Search parameter: <b>patient</b>
2122   * <p>
2123   * Description: <b>The identity of a subject to list family member history items for</b><br>
2124   * Type: <b>reference</b><br>
2125   * Path: <b>FamilyMemberHistory.patient</b><br>
2126   * </p>
2127   */
2128  @SearchParamDefinition(name="patient", path="FamilyMemberHistory.patient", description="The identity of a subject to list family member history items for", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Patient.class } )
2129  public static final String SP_PATIENT = "patient";
2130 /**
2131   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
2132   * <p>
2133   * Description: <b>The identity of a subject to list family member history items for</b><br>
2134   * Type: <b>reference</b><br>
2135   * Path: <b>FamilyMemberHistory.patient</b><br>
2136   * </p>
2137   */
2138  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
2139
2140/**
2141   * Constant for fluent queries to be used to add include statements. Specifies
2142   * the path value of "<b>FamilyMemberHistory:patient</b>".
2143   */
2144  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("FamilyMemberHistory:patient").toLocked();
2145
2146 /**
2147   * Search parameter: <b>definition</b>
2148   * <p>
2149   * Description: <b>Instantiates protocol or definition</b><br>
2150   * Type: <b>reference</b><br>
2151   * Path: <b>FamilyMemberHistory.definition</b><br>
2152   * </p>
2153   */
2154  @SearchParamDefinition(name="definition", path="FamilyMemberHistory.definition", description="Instantiates protocol or definition", type="reference", target={PlanDefinition.class, Questionnaire.class } )
2155  public static final String SP_DEFINITION = "definition";
2156 /**
2157   * <b>Fluent Client</b> search parameter constant for <b>definition</b>
2158   * <p>
2159   * Description: <b>Instantiates protocol or definition</b><br>
2160   * Type: <b>reference</b><br>
2161   * Path: <b>FamilyMemberHistory.definition</b><br>
2162   * </p>
2163   */
2164  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam DEFINITION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_DEFINITION);
2165
2166/**
2167   * Constant for fluent queries to be used to add include statements. Specifies
2168   * the path value of "<b>FamilyMemberHistory:definition</b>".
2169   */
2170  public static final ca.uhn.fhir.model.api.Include INCLUDE_DEFINITION = new ca.uhn.fhir.model.api.Include("FamilyMemberHistory:definition").toLocked();
2171
2172 /**
2173   * Search parameter: <b>relationship</b>
2174   * <p>
2175   * Description: <b>A search by a relationship type</b><br>
2176   * Type: <b>token</b><br>
2177   * Path: <b>FamilyMemberHistory.relationship</b><br>
2178   * </p>
2179   */
2180  @SearchParamDefinition(name="relationship", path="FamilyMemberHistory.relationship", description="A search by a relationship type", type="token" )
2181  public static final String SP_RELATIONSHIP = "relationship";
2182 /**
2183   * <b>Fluent Client</b> search parameter constant for <b>relationship</b>
2184   * <p>
2185   * Description: <b>A search by a relationship type</b><br>
2186   * Type: <b>token</b><br>
2187   * Path: <b>FamilyMemberHistory.relationship</b><br>
2188   * </p>
2189   */
2190  public static final ca.uhn.fhir.rest.gclient.TokenClientParam RELATIONSHIP = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_RELATIONSHIP);
2191
2192 /**
2193   * Search parameter: <b>status</b>
2194   * <p>
2195   * Description: <b>partial | completed | entered-in-error | health-unknown</b><br>
2196   * Type: <b>token</b><br>
2197   * Path: <b>FamilyMemberHistory.status</b><br>
2198   * </p>
2199   */
2200  @SearchParamDefinition(name="status", path="FamilyMemberHistory.status", description="partial | completed | entered-in-error | health-unknown", type="token" )
2201  public static final String SP_STATUS = "status";
2202 /**
2203   * <b>Fluent Client</b> search parameter constant for <b>status</b>
2204   * <p>
2205   * Description: <b>partial | completed | entered-in-error | health-unknown</b><br>
2206   * Type: <b>token</b><br>
2207   * Path: <b>FamilyMemberHistory.status</b><br>
2208   * </p>
2209   */
2210  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
2211
2212
2213}
2214