001package org.hl7.fhir.instance.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
033import java.util.ArrayList;
034import java.util.List;
035
036import org.hl7.fhir.exceptions.FHIRException;
037import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
038
039import ca.uhn.fhir.model.api.annotation.*;
040/**
041 * An association between a patient and an organization / healthcare provider(s) during which time encounters may occur. The managing organization assumes a level of responsibility for the patient during this time.
042 */
043@ResourceDef(name="EpisodeOfCare", profile="http://hl7.org/fhir/Profile/EpisodeOfCare")
044public class EpisodeOfCare extends DomainResource {
045
046    public enum EpisodeOfCareStatus {
047        /**
048         * This episode of care is planned to start at the date specified in the period.start. During this status an organization may perform assessments to determine if they are eligible to receive services, or be organizing to make resources available to provide care services.
049         */
050        PLANNED, 
051        /**
052         * This episode has been placed on a waitlist, pending the episode being made active (or cancelled).
053         */
054        WAITLIST, 
055        /**
056         * This episode of care is current.
057         */
058        ACTIVE, 
059        /**
060         * This episode of care is on hold, the organization has limited responsibility for the patient (such as while on respite).
061         */
062        ONHOLD, 
063        /**
064         * This episode of care is finished at the organization is not expecting to be providing care to the patient. Can also be known as "closed", "completed" or other similar terms.
065         */
066        FINISHED, 
067        /**
068         * The episode of care was cancelled, or withdrawn from service, often selected during the planned stage as the patient may have gone elsewhere, or the circumstances have changed and the organization is unable to provide the care. It indicates that services terminated outside the planned/expected workflow.
069         */
070        CANCELLED, 
071        /**
072         * added to help the parsers
073         */
074        NULL;
075        public static EpisodeOfCareStatus fromCode(String codeString) throws FHIRException {
076            if (codeString == null || "".equals(codeString))
077                return null;
078        if ("planned".equals(codeString))
079          return PLANNED;
080        if ("waitlist".equals(codeString))
081          return WAITLIST;
082        if ("active".equals(codeString))
083          return ACTIVE;
084        if ("onhold".equals(codeString))
085          return ONHOLD;
086        if ("finished".equals(codeString))
087          return FINISHED;
088        if ("cancelled".equals(codeString))
089          return CANCELLED;
090        throw new FHIRException("Unknown EpisodeOfCareStatus code '"+codeString+"'");
091        }
092        public String toCode() {
093          switch (this) {
094            case PLANNED: return "planned";
095            case WAITLIST: return "waitlist";
096            case ACTIVE: return "active";
097            case ONHOLD: return "onhold";
098            case FINISHED: return "finished";
099            case CANCELLED: return "cancelled";
100            default: return "?";
101          }
102        }
103        public String getSystem() {
104          switch (this) {
105            case PLANNED: return "http://hl7.org/fhir/episode-of-care-status";
106            case WAITLIST: return "http://hl7.org/fhir/episode-of-care-status";
107            case ACTIVE: return "http://hl7.org/fhir/episode-of-care-status";
108            case ONHOLD: return "http://hl7.org/fhir/episode-of-care-status";
109            case FINISHED: return "http://hl7.org/fhir/episode-of-care-status";
110            case CANCELLED: return "http://hl7.org/fhir/episode-of-care-status";
111            default: return "?";
112          }
113        }
114        public String getDefinition() {
115          switch (this) {
116            case PLANNED: return "This episode of care is planned to start at the date specified in the period.start. During this status an organization may perform assessments to determine if they are eligible to receive services, or be organizing to make resources available to provide care services.";
117            case WAITLIST: return "This episode has been placed on a waitlist, pending the episode being made active (or cancelled).";
118            case ACTIVE: return "This episode of care is current.";
119            case ONHOLD: return "This episode of care is on hold, the organization has limited responsibility for the patient (such as while on respite).";
120            case FINISHED: return "This episode of care is finished at the organization is not expecting to be providing care to the patient. Can also be known as \"closed\", \"completed\" or other similar terms.";
121            case CANCELLED: return "The episode of care was cancelled, or withdrawn from service, often selected during the planned stage as the patient may have gone elsewhere, or the circumstances have changed and the organization is unable to provide the care. It indicates that services terminated outside the planned/expected workflow.";
122            default: return "?";
123          }
124        }
125        public String getDisplay() {
126          switch (this) {
127            case PLANNED: return "Planned";
128            case WAITLIST: return "Waitlist";
129            case ACTIVE: return "Active";
130            case ONHOLD: return "On Hold";
131            case FINISHED: return "Finished";
132            case CANCELLED: return "Cancelled";
133            default: return "?";
134          }
135        }
136    }
137
138  public static class EpisodeOfCareStatusEnumFactory implements EnumFactory<EpisodeOfCareStatus> {
139    public EpisodeOfCareStatus fromCode(String codeString) throws IllegalArgumentException {
140      if (codeString == null || "".equals(codeString))
141            if (codeString == null || "".equals(codeString))
142                return null;
143        if ("planned".equals(codeString))
144          return EpisodeOfCareStatus.PLANNED;
145        if ("waitlist".equals(codeString))
146          return EpisodeOfCareStatus.WAITLIST;
147        if ("active".equals(codeString))
148          return EpisodeOfCareStatus.ACTIVE;
149        if ("onhold".equals(codeString))
150          return EpisodeOfCareStatus.ONHOLD;
151        if ("finished".equals(codeString))
152          return EpisodeOfCareStatus.FINISHED;
153        if ("cancelled".equals(codeString))
154          return EpisodeOfCareStatus.CANCELLED;
155        throw new IllegalArgumentException("Unknown EpisodeOfCareStatus code '"+codeString+"'");
156        }
157        public Enumeration<EpisodeOfCareStatus> fromType(Base code) throws FHIRException {
158          if (code == null || code.isEmpty())
159            return null;
160          String codeString = ((PrimitiveType) code).asStringValue();
161          if (codeString == null || "".equals(codeString))
162            return null;
163        if ("planned".equals(codeString))
164          return new Enumeration<EpisodeOfCareStatus>(this, EpisodeOfCareStatus.PLANNED);
165        if ("waitlist".equals(codeString))
166          return new Enumeration<EpisodeOfCareStatus>(this, EpisodeOfCareStatus.WAITLIST);
167        if ("active".equals(codeString))
168          return new Enumeration<EpisodeOfCareStatus>(this, EpisodeOfCareStatus.ACTIVE);
169        if ("onhold".equals(codeString))
170          return new Enumeration<EpisodeOfCareStatus>(this, EpisodeOfCareStatus.ONHOLD);
171        if ("finished".equals(codeString))
172          return new Enumeration<EpisodeOfCareStatus>(this, EpisodeOfCareStatus.FINISHED);
173        if ("cancelled".equals(codeString))
174          return new Enumeration<EpisodeOfCareStatus>(this, EpisodeOfCareStatus.CANCELLED);
175        throw new FHIRException("Unknown EpisodeOfCareStatus code '"+codeString+"'");
176        }
177    public String toCode(EpisodeOfCareStatus code) {
178      if (code == EpisodeOfCareStatus.PLANNED)
179        return "planned";
180      if (code == EpisodeOfCareStatus.WAITLIST)
181        return "waitlist";
182      if (code == EpisodeOfCareStatus.ACTIVE)
183        return "active";
184      if (code == EpisodeOfCareStatus.ONHOLD)
185        return "onhold";
186      if (code == EpisodeOfCareStatus.FINISHED)
187        return "finished";
188      if (code == EpisodeOfCareStatus.CANCELLED)
189        return "cancelled";
190      return "?";
191      }
192    }
193
194    @Block()
195    public static class EpisodeOfCareStatusHistoryComponent extends BackboneElement implements IBaseBackboneElement {
196        /**
197         * planned | waitlist | active | onhold | finished | cancelled.
198         */
199        @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=false)
200        @Description(shortDefinition="planned | waitlist | active | onhold | finished | cancelled", formalDefinition="planned | waitlist | active | onhold | finished | cancelled." )
201        protected Enumeration<EpisodeOfCareStatus> status;
202
203        /**
204         * The period during this EpisodeOfCare that the specific status applied.
205         */
206        @Child(name = "period", type = {Period.class}, order=2, min=1, max=1, modifier=false, summary=false)
207        @Description(shortDefinition="Period for the status", formalDefinition="The period during this EpisodeOfCare that the specific status applied." )
208        protected Period period;
209
210        private static final long serialVersionUID = -1192432864L;
211
212    /*
213     * Constructor
214     */
215      public EpisodeOfCareStatusHistoryComponent() {
216        super();
217      }
218
219    /*
220     * Constructor
221     */
222      public EpisodeOfCareStatusHistoryComponent(Enumeration<EpisodeOfCareStatus> status, Period period) {
223        super();
224        this.status = status;
225        this.period = period;
226      }
227
228        /**
229         * @return {@link #status} (planned | waitlist | active | onhold | finished | cancelled.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
230         */
231        public Enumeration<EpisodeOfCareStatus> getStatusElement() { 
232          if (this.status == null)
233            if (Configuration.errorOnAutoCreate())
234              throw new Error("Attempt to auto-create EpisodeOfCareStatusHistoryComponent.status");
235            else if (Configuration.doAutoCreate())
236              this.status = new Enumeration<EpisodeOfCareStatus>(new EpisodeOfCareStatusEnumFactory()); // bb
237          return this.status;
238        }
239
240        public boolean hasStatusElement() { 
241          return this.status != null && !this.status.isEmpty();
242        }
243
244        public boolean hasStatus() { 
245          return this.status != null && !this.status.isEmpty();
246        }
247
248        /**
249         * @param value {@link #status} (planned | waitlist | active | onhold | finished | cancelled.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
250         */
251        public EpisodeOfCareStatusHistoryComponent setStatusElement(Enumeration<EpisodeOfCareStatus> value) { 
252          this.status = value;
253          return this;
254        }
255
256        /**
257         * @return planned | waitlist | active | onhold | finished | cancelled.
258         */
259        public EpisodeOfCareStatus getStatus() { 
260          return this.status == null ? null : this.status.getValue();
261        }
262
263        /**
264         * @param value planned | waitlist | active | onhold | finished | cancelled.
265         */
266        public EpisodeOfCareStatusHistoryComponent setStatus(EpisodeOfCareStatus value) { 
267            if (this.status == null)
268              this.status = new Enumeration<EpisodeOfCareStatus>(new EpisodeOfCareStatusEnumFactory());
269            this.status.setValue(value);
270          return this;
271        }
272
273        /**
274         * @return {@link #period} (The period during this EpisodeOfCare that the specific status applied.)
275         */
276        public Period getPeriod() { 
277          if (this.period == null)
278            if (Configuration.errorOnAutoCreate())
279              throw new Error("Attempt to auto-create EpisodeOfCareStatusHistoryComponent.period");
280            else if (Configuration.doAutoCreate())
281              this.period = new Period(); // cc
282          return this.period;
283        }
284
285        public boolean hasPeriod() { 
286          return this.period != null && !this.period.isEmpty();
287        }
288
289        /**
290         * @param value {@link #period} (The period during this EpisodeOfCare that the specific status applied.)
291         */
292        public EpisodeOfCareStatusHistoryComponent setPeriod(Period value) { 
293          this.period = value;
294          return this;
295        }
296
297        protected void listChildren(List<Property> childrenList) {
298          super.listChildren(childrenList);
299          childrenList.add(new Property("status", "code", "planned | waitlist | active | onhold | finished | cancelled.", 0, java.lang.Integer.MAX_VALUE, status));
300          childrenList.add(new Property("period", "Period", "The period during this EpisodeOfCare that the specific status applied.", 0, java.lang.Integer.MAX_VALUE, period));
301        }
302
303      @Override
304      public void setProperty(String name, Base value) throws FHIRException {
305        if (name.equals("status"))
306          this.status = new EpisodeOfCareStatusEnumFactory().fromType(value); // Enumeration<EpisodeOfCareStatus>
307        else if (name.equals("period"))
308          this.period = castToPeriod(value); // Period
309        else
310          super.setProperty(name, value);
311      }
312
313      @Override
314      public Base addChild(String name) throws FHIRException {
315        if (name.equals("status")) {
316          throw new FHIRException("Cannot call addChild on a primitive type EpisodeOfCare.status");
317        }
318        else if (name.equals("period")) {
319          this.period = new Period();
320          return this.period;
321        }
322        else
323          return super.addChild(name);
324      }
325
326      public EpisodeOfCareStatusHistoryComponent copy() {
327        EpisodeOfCareStatusHistoryComponent dst = new EpisodeOfCareStatusHistoryComponent();
328        copyValues(dst);
329        dst.status = status == null ? null : status.copy();
330        dst.period = period == null ? null : period.copy();
331        return dst;
332      }
333
334      @Override
335      public boolean equalsDeep(Base other) {
336        if (!super.equalsDeep(other))
337          return false;
338        if (!(other instanceof EpisodeOfCareStatusHistoryComponent))
339          return false;
340        EpisodeOfCareStatusHistoryComponent o = (EpisodeOfCareStatusHistoryComponent) other;
341        return compareDeep(status, o.status, true) && compareDeep(period, o.period, true);
342      }
343
344      @Override
345      public boolean equalsShallow(Base other) {
346        if (!super.equalsShallow(other))
347          return false;
348        if (!(other instanceof EpisodeOfCareStatusHistoryComponent))
349          return false;
350        EpisodeOfCareStatusHistoryComponent o = (EpisodeOfCareStatusHistoryComponent) other;
351        return compareValues(status, o.status, true);
352      }
353
354      public boolean isEmpty() {
355        return super.isEmpty() && (status == null || status.isEmpty()) && (period == null || period.isEmpty())
356          ;
357      }
358
359  public String fhirType() {
360    return "EpisodeOfCare.statusHistory";
361
362  }
363
364  }
365
366    @Block()
367    public static class EpisodeOfCareCareTeamComponent extends BackboneElement implements IBaseBackboneElement {
368        /**
369         * The role this team member is taking within this episode of care.
370         */
371        @Child(name = "role", type = {CodeableConcept.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
372        @Description(shortDefinition="Role taken by this team member", formalDefinition="The role this team member is taking within this episode of care." )
373        protected List<CodeableConcept> role;
374
375        /**
376         * The period of time this practitioner is performing some role within the episode of care.
377         */
378        @Child(name = "period", type = {Period.class}, order=2, min=0, max=1, modifier=false, summary=false)
379        @Description(shortDefinition="Period of time for this role", formalDefinition="The period of time this practitioner is performing some role within the episode of care." )
380        protected Period period;
381
382        /**
383         * The practitioner (or Organization) within the team.
384         */
385        @Child(name = "member", type = {Practitioner.class, Organization.class}, order=3, min=0, max=1, modifier=false, summary=false)
386        @Description(shortDefinition="The practitioner (or Organization) within the team", formalDefinition="The practitioner (or Organization) within the team." )
387        protected Reference member;
388
389        /**
390         * The actual object that is the target of the reference (The practitioner (or Organization) within the team.)
391         */
392        protected Resource memberTarget;
393
394        private static final long serialVersionUID = -437303089L;
395
396    /*
397     * Constructor
398     */
399      public EpisodeOfCareCareTeamComponent() {
400        super();
401      }
402
403        /**
404         * @return {@link #role} (The role this team member is taking within this episode of care.)
405         */
406        public List<CodeableConcept> getRole() { 
407          if (this.role == null)
408            this.role = new ArrayList<CodeableConcept>();
409          return this.role;
410        }
411
412        public boolean hasRole() { 
413          if (this.role == null)
414            return false;
415          for (CodeableConcept item : this.role)
416            if (!item.isEmpty())
417              return true;
418          return false;
419        }
420
421        /**
422         * @return {@link #role} (The role this team member is taking within this episode of care.)
423         */
424    // syntactic sugar
425        public CodeableConcept addRole() { //3
426          CodeableConcept t = new CodeableConcept();
427          if (this.role == null)
428            this.role = new ArrayList<CodeableConcept>();
429          this.role.add(t);
430          return t;
431        }
432
433    // syntactic sugar
434        public EpisodeOfCareCareTeamComponent addRole(CodeableConcept t) { //3
435          if (t == null)
436            return this;
437          if (this.role == null)
438            this.role = new ArrayList<CodeableConcept>();
439          this.role.add(t);
440          return this;
441        }
442
443        /**
444         * @return {@link #period} (The period of time this practitioner is performing some role within the episode of care.)
445         */
446        public Period getPeriod() { 
447          if (this.period == null)
448            if (Configuration.errorOnAutoCreate())
449              throw new Error("Attempt to auto-create EpisodeOfCareCareTeamComponent.period");
450            else if (Configuration.doAutoCreate())
451              this.period = new Period(); // cc
452          return this.period;
453        }
454
455        public boolean hasPeriod() { 
456          return this.period != null && !this.period.isEmpty();
457        }
458
459        /**
460         * @param value {@link #period} (The period of time this practitioner is performing some role within the episode of care.)
461         */
462        public EpisodeOfCareCareTeamComponent setPeriod(Period value) { 
463          this.period = value;
464          return this;
465        }
466
467        /**
468         * @return {@link #member} (The practitioner (or Organization) within the team.)
469         */
470        public Reference getMember() { 
471          if (this.member == null)
472            if (Configuration.errorOnAutoCreate())
473              throw new Error("Attempt to auto-create EpisodeOfCareCareTeamComponent.member");
474            else if (Configuration.doAutoCreate())
475              this.member = new Reference(); // cc
476          return this.member;
477        }
478
479        public boolean hasMember() { 
480          return this.member != null && !this.member.isEmpty();
481        }
482
483        /**
484         * @param value {@link #member} (The practitioner (or Organization) within the team.)
485         */
486        public EpisodeOfCareCareTeamComponent setMember(Reference value) { 
487          this.member = value;
488          return this;
489        }
490
491        /**
492         * @return {@link #member} 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 practitioner (or Organization) within the team.)
493         */
494        public Resource getMemberTarget() { 
495          return this.memberTarget;
496        }
497
498        /**
499         * @param value {@link #member} 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 practitioner (or Organization) within the team.)
500         */
501        public EpisodeOfCareCareTeamComponent setMemberTarget(Resource value) { 
502          this.memberTarget = value;
503          return this;
504        }
505
506        protected void listChildren(List<Property> childrenList) {
507          super.listChildren(childrenList);
508          childrenList.add(new Property("role", "CodeableConcept", "The role this team member is taking within this episode of care.", 0, java.lang.Integer.MAX_VALUE, role));
509          childrenList.add(new Property("period", "Period", "The period of time this practitioner is performing some role within the episode of care.", 0, java.lang.Integer.MAX_VALUE, period));
510          childrenList.add(new Property("member", "Reference(Practitioner|Organization)", "The practitioner (or Organization) within the team.", 0, java.lang.Integer.MAX_VALUE, member));
511        }
512
513      @Override
514      public void setProperty(String name, Base value) throws FHIRException {
515        if (name.equals("role"))
516          this.getRole().add(castToCodeableConcept(value));
517        else if (name.equals("period"))
518          this.period = castToPeriod(value); // Period
519        else if (name.equals("member"))
520          this.member = castToReference(value); // Reference
521        else
522          super.setProperty(name, value);
523      }
524
525      @Override
526      public Base addChild(String name) throws FHIRException {
527        if (name.equals("role")) {
528          return addRole();
529        }
530        else if (name.equals("period")) {
531          this.period = new Period();
532          return this.period;
533        }
534        else if (name.equals("member")) {
535          this.member = new Reference();
536          return this.member;
537        }
538        else
539          return super.addChild(name);
540      }
541
542      public EpisodeOfCareCareTeamComponent copy() {
543        EpisodeOfCareCareTeamComponent dst = new EpisodeOfCareCareTeamComponent();
544        copyValues(dst);
545        if (role != null) {
546          dst.role = new ArrayList<CodeableConcept>();
547          for (CodeableConcept i : role)
548            dst.role.add(i.copy());
549        };
550        dst.period = period == null ? null : period.copy();
551        dst.member = member == null ? null : member.copy();
552        return dst;
553      }
554
555      @Override
556      public boolean equalsDeep(Base other) {
557        if (!super.equalsDeep(other))
558          return false;
559        if (!(other instanceof EpisodeOfCareCareTeamComponent))
560          return false;
561        EpisodeOfCareCareTeamComponent o = (EpisodeOfCareCareTeamComponent) other;
562        return compareDeep(role, o.role, true) && compareDeep(period, o.period, true) && compareDeep(member, o.member, true)
563          ;
564      }
565
566      @Override
567      public boolean equalsShallow(Base other) {
568        if (!super.equalsShallow(other))
569          return false;
570        if (!(other instanceof EpisodeOfCareCareTeamComponent))
571          return false;
572        EpisodeOfCareCareTeamComponent o = (EpisodeOfCareCareTeamComponent) other;
573        return true;
574      }
575
576      public boolean isEmpty() {
577        return super.isEmpty() && (role == null || role.isEmpty()) && (period == null || period.isEmpty())
578           && (member == null || member.isEmpty());
579      }
580
581  public String fhirType() {
582    return "EpisodeOfCare.careTeam";
583
584  }
585
586  }
587
588    /**
589     * Identifier(s) by which this EpisodeOfCare is known.
590     */
591    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
592    @Description(shortDefinition="Identifier(s) for the EpisodeOfCare", formalDefinition="Identifier(s) by which this EpisodeOfCare is known." )
593    protected List<Identifier> identifier;
594
595    /**
596     * planned | waitlist | active | onhold | finished | cancelled.
597     */
598    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
599    @Description(shortDefinition="planned | waitlist | active | onhold | finished | cancelled", formalDefinition="planned | waitlist | active | onhold | finished | cancelled." )
600    protected Enumeration<EpisodeOfCareStatus> status;
601
602    /**
603     * The history of statuses that the EpisodeOfCare has been through (without requiring processing the history of the resource).
604     */
605    @Child(name = "statusHistory", type = {}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
606    @Description(shortDefinition="Past list of status codes", formalDefinition="The history of statuses that the EpisodeOfCare has been through (without requiring processing the history of the resource)." )
607    protected List<EpisodeOfCareStatusHistoryComponent> statusHistory;
608
609    /**
610     * A classification of the type of encounter; e.g. specialist referral, disease management, type of funded care.
611     */
612    @Child(name = "type", type = {CodeableConcept.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
613    @Description(shortDefinition="Type/class  - e.g. specialist referral, disease management", formalDefinition="A classification of the type of encounter; e.g. specialist referral, disease management, type of funded care." )
614    protected List<CodeableConcept> type;
615
616    /**
617     * A list of conditions/problems/diagnoses that this episode of care is intended to be providing care for.
618     */
619    @Child(name = "condition", type = {Condition.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
620    @Description(shortDefinition="Conditions/problems/diagnoses this episode of care is for", formalDefinition="A list of conditions/problems/diagnoses that this episode of care is intended to be providing care for." )
621    protected List<Reference> condition;
622    /**
623     * The actual objects that are the target of the reference (A list of conditions/problems/diagnoses that this episode of care is intended to be providing care for.)
624     */
625    protected List<Condition> conditionTarget;
626
627
628    /**
629     * The patient that this EpisodeOfCare applies to.
630     */
631    @Child(name = "patient", type = {Patient.class}, order=5, min=1, max=1, modifier=false, summary=true)
632    @Description(shortDefinition="Patient for this episode of care", formalDefinition="The patient that this EpisodeOfCare applies to." )
633    protected Reference patient;
634
635    /**
636     * The actual object that is the target of the reference (The patient that this EpisodeOfCare applies to.)
637     */
638    protected Patient patientTarget;
639
640    /**
641     * The organization that has assumed the specific responsibilities for the specified duration.
642     */
643    @Child(name = "managingOrganization", type = {Organization.class}, order=6, min=0, max=1, modifier=false, summary=true)
644    @Description(shortDefinition="Organization that assumes care", formalDefinition="The organization that has assumed the specific responsibilities for the specified duration." )
645    protected Reference managingOrganization;
646
647    /**
648     * The actual object that is the target of the reference (The organization that has assumed the specific responsibilities for the specified duration.)
649     */
650    protected Organization managingOrganizationTarget;
651
652    /**
653     * The interval during which the managing organization assumes the defined responsibility.
654     */
655    @Child(name = "period", type = {Period.class}, order=7, min=0, max=1, modifier=false, summary=true)
656    @Description(shortDefinition="Interval during responsibility is assumed", formalDefinition="The interval during which the managing organization assumes the defined responsibility." )
657    protected Period period;
658
659    /**
660     * Referral Request(s) that are fulfilled by this EpisodeOfCare, incoming referrals.
661     */
662    @Child(name = "referralRequest", type = {ReferralRequest.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
663    @Description(shortDefinition="Originating Referral Request(s)", formalDefinition="Referral Request(s) that are fulfilled by this EpisodeOfCare, incoming referrals." )
664    protected List<Reference> referralRequest;
665    /**
666     * The actual objects that are the target of the reference (Referral Request(s) that are fulfilled by this EpisodeOfCare, incoming referrals.)
667     */
668    protected List<ReferralRequest> referralRequestTarget;
669
670
671    /**
672     * The practitioner that is the care manager/care co-ordinator for this patient.
673     */
674    @Child(name = "careManager", type = {Practitioner.class}, order=9, min=0, max=1, modifier=false, summary=false)
675    @Description(shortDefinition="Care manager/care co-ordinator for the patient", formalDefinition="The practitioner that is the care manager/care co-ordinator for this patient." )
676    protected Reference careManager;
677
678    /**
679     * The actual object that is the target of the reference (The practitioner that is the care manager/care co-ordinator for this patient.)
680     */
681    protected Practitioner careManagerTarget;
682
683    /**
684     * The list of practitioners that may be facilitating this episode of care for specific purposes.
685     */
686    @Child(name = "careTeam", type = {}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
687    @Description(shortDefinition="Other practitioners facilitating this episode of care", formalDefinition="The list of practitioners that may be facilitating this episode of care for specific purposes." )
688    protected List<EpisodeOfCareCareTeamComponent> careTeam;
689
690    private static final long serialVersionUID = 1652653406L;
691
692  /*
693   * Constructor
694   */
695    public EpisodeOfCare() {
696      super();
697    }
698
699  /*
700   * Constructor
701   */
702    public EpisodeOfCare(Enumeration<EpisodeOfCareStatus> status, Reference patient) {
703      super();
704      this.status = status;
705      this.patient = patient;
706    }
707
708    /**
709     * @return {@link #identifier} (Identifier(s) by which this EpisodeOfCare is known.)
710     */
711    public List<Identifier> getIdentifier() { 
712      if (this.identifier == null)
713        this.identifier = new ArrayList<Identifier>();
714      return this.identifier;
715    }
716
717    public boolean hasIdentifier() { 
718      if (this.identifier == null)
719        return false;
720      for (Identifier item : this.identifier)
721        if (!item.isEmpty())
722          return true;
723      return false;
724    }
725
726    /**
727     * @return {@link #identifier} (Identifier(s) by which this EpisodeOfCare is known.)
728     */
729    // syntactic sugar
730    public Identifier addIdentifier() { //3
731      Identifier t = new Identifier();
732      if (this.identifier == null)
733        this.identifier = new ArrayList<Identifier>();
734      this.identifier.add(t);
735      return t;
736    }
737
738    // syntactic sugar
739    public EpisodeOfCare addIdentifier(Identifier t) { //3
740      if (t == null)
741        return this;
742      if (this.identifier == null)
743        this.identifier = new ArrayList<Identifier>();
744      this.identifier.add(t);
745      return this;
746    }
747
748    /**
749     * @return {@link #status} (planned | waitlist | active | onhold | finished | cancelled.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
750     */
751    public Enumeration<EpisodeOfCareStatus> getStatusElement() { 
752      if (this.status == null)
753        if (Configuration.errorOnAutoCreate())
754          throw new Error("Attempt to auto-create EpisodeOfCare.status");
755        else if (Configuration.doAutoCreate())
756          this.status = new Enumeration<EpisodeOfCareStatus>(new EpisodeOfCareStatusEnumFactory()); // bb
757      return this.status;
758    }
759
760    public boolean hasStatusElement() { 
761      return this.status != null && !this.status.isEmpty();
762    }
763
764    public boolean hasStatus() { 
765      return this.status != null && !this.status.isEmpty();
766    }
767
768    /**
769     * @param value {@link #status} (planned | waitlist | active | onhold | finished | cancelled.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
770     */
771    public EpisodeOfCare setStatusElement(Enumeration<EpisodeOfCareStatus> value) { 
772      this.status = value;
773      return this;
774    }
775
776    /**
777     * @return planned | waitlist | active | onhold | finished | cancelled.
778     */
779    public EpisodeOfCareStatus getStatus() { 
780      return this.status == null ? null : this.status.getValue();
781    }
782
783    /**
784     * @param value planned | waitlist | active | onhold | finished | cancelled.
785     */
786    public EpisodeOfCare setStatus(EpisodeOfCareStatus value) { 
787        if (this.status == null)
788          this.status = new Enumeration<EpisodeOfCareStatus>(new EpisodeOfCareStatusEnumFactory());
789        this.status.setValue(value);
790      return this;
791    }
792
793    /**
794     * @return {@link #statusHistory} (The history of statuses that the EpisodeOfCare has been through (without requiring processing the history of the resource).)
795     */
796    public List<EpisodeOfCareStatusHistoryComponent> getStatusHistory() { 
797      if (this.statusHistory == null)
798        this.statusHistory = new ArrayList<EpisodeOfCareStatusHistoryComponent>();
799      return this.statusHistory;
800    }
801
802    public boolean hasStatusHistory() { 
803      if (this.statusHistory == null)
804        return false;
805      for (EpisodeOfCareStatusHistoryComponent item : this.statusHistory)
806        if (!item.isEmpty())
807          return true;
808      return false;
809    }
810
811    /**
812     * @return {@link #statusHistory} (The history of statuses that the EpisodeOfCare has been through (without requiring processing the history of the resource).)
813     */
814    // syntactic sugar
815    public EpisodeOfCareStatusHistoryComponent addStatusHistory() { //3
816      EpisodeOfCareStatusHistoryComponent t = new EpisodeOfCareStatusHistoryComponent();
817      if (this.statusHistory == null)
818        this.statusHistory = new ArrayList<EpisodeOfCareStatusHistoryComponent>();
819      this.statusHistory.add(t);
820      return t;
821    }
822
823    // syntactic sugar
824    public EpisodeOfCare addStatusHistory(EpisodeOfCareStatusHistoryComponent t) { //3
825      if (t == null)
826        return this;
827      if (this.statusHistory == null)
828        this.statusHistory = new ArrayList<EpisodeOfCareStatusHistoryComponent>();
829      this.statusHistory.add(t);
830      return this;
831    }
832
833    /**
834     * @return {@link #type} (A classification of the type of encounter; e.g. specialist referral, disease management, type of funded care.)
835     */
836    public List<CodeableConcept> getType() { 
837      if (this.type == null)
838        this.type = new ArrayList<CodeableConcept>();
839      return this.type;
840    }
841
842    public boolean hasType() { 
843      if (this.type == null)
844        return false;
845      for (CodeableConcept item : this.type)
846        if (!item.isEmpty())
847          return true;
848      return false;
849    }
850
851    /**
852     * @return {@link #type} (A classification of the type of encounter; e.g. specialist referral, disease management, type of funded care.)
853     */
854    // syntactic sugar
855    public CodeableConcept addType() { //3
856      CodeableConcept t = new CodeableConcept();
857      if (this.type == null)
858        this.type = new ArrayList<CodeableConcept>();
859      this.type.add(t);
860      return t;
861    }
862
863    // syntactic sugar
864    public EpisodeOfCare addType(CodeableConcept t) { //3
865      if (t == null)
866        return this;
867      if (this.type == null)
868        this.type = new ArrayList<CodeableConcept>();
869      this.type.add(t);
870      return this;
871    }
872
873    /**
874     * @return {@link #condition} (A list of conditions/problems/diagnoses that this episode of care is intended to be providing care for.)
875     */
876    public List<Reference> getCondition() { 
877      if (this.condition == null)
878        this.condition = new ArrayList<Reference>();
879      return this.condition;
880    }
881
882    public boolean hasCondition() { 
883      if (this.condition == null)
884        return false;
885      for (Reference item : this.condition)
886        if (!item.isEmpty())
887          return true;
888      return false;
889    }
890
891    /**
892     * @return {@link #condition} (A list of conditions/problems/diagnoses that this episode of care is intended to be providing care for.)
893     */
894    // syntactic sugar
895    public Reference addCondition() { //3
896      Reference t = new Reference();
897      if (this.condition == null)
898        this.condition = new ArrayList<Reference>();
899      this.condition.add(t);
900      return t;
901    }
902
903    // syntactic sugar
904    public EpisodeOfCare addCondition(Reference t) { //3
905      if (t == null)
906        return this;
907      if (this.condition == null)
908        this.condition = new ArrayList<Reference>();
909      this.condition.add(t);
910      return this;
911    }
912
913    /**
914     * @return {@link #condition} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. A list of conditions/problems/diagnoses that this episode of care is intended to be providing care for.)
915     */
916    public List<Condition> getConditionTarget() { 
917      if (this.conditionTarget == null)
918        this.conditionTarget = new ArrayList<Condition>();
919      return this.conditionTarget;
920    }
921
922    // syntactic sugar
923    /**
924     * @return {@link #condition} (Add an actual object that is the target of the reference. The reference library doesn't use these, but you can use this to hold the resources if you resolvethemt. A list of conditions/problems/diagnoses that this episode of care is intended to be providing care for.)
925     */
926    public Condition addConditionTarget() { 
927      Condition r = new Condition();
928      if (this.conditionTarget == null)
929        this.conditionTarget = new ArrayList<Condition>();
930      this.conditionTarget.add(r);
931      return r;
932    }
933
934    /**
935     * @return {@link #patient} (The patient that this EpisodeOfCare applies to.)
936     */
937    public Reference getPatient() { 
938      if (this.patient == null)
939        if (Configuration.errorOnAutoCreate())
940          throw new Error("Attempt to auto-create EpisodeOfCare.patient");
941        else if (Configuration.doAutoCreate())
942          this.patient = new Reference(); // cc
943      return this.patient;
944    }
945
946    public boolean hasPatient() { 
947      return this.patient != null && !this.patient.isEmpty();
948    }
949
950    /**
951     * @param value {@link #patient} (The patient that this EpisodeOfCare applies to.)
952     */
953    public EpisodeOfCare setPatient(Reference value) { 
954      this.patient = value;
955      return this;
956    }
957
958    /**
959     * @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 patient that this EpisodeOfCare applies to.)
960     */
961    public Patient getPatientTarget() { 
962      if (this.patientTarget == null)
963        if (Configuration.errorOnAutoCreate())
964          throw new Error("Attempt to auto-create EpisodeOfCare.patient");
965        else if (Configuration.doAutoCreate())
966          this.patientTarget = new Patient(); // aa
967      return this.patientTarget;
968    }
969
970    /**
971     * @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 patient that this EpisodeOfCare applies to.)
972     */
973    public EpisodeOfCare setPatientTarget(Patient value) { 
974      this.patientTarget = value;
975      return this;
976    }
977
978    /**
979     * @return {@link #managingOrganization} (The organization that has assumed the specific responsibilities for the specified duration.)
980     */
981    public Reference getManagingOrganization() { 
982      if (this.managingOrganization == null)
983        if (Configuration.errorOnAutoCreate())
984          throw new Error("Attempt to auto-create EpisodeOfCare.managingOrganization");
985        else if (Configuration.doAutoCreate())
986          this.managingOrganization = new Reference(); // cc
987      return this.managingOrganization;
988    }
989
990    public boolean hasManagingOrganization() { 
991      return this.managingOrganization != null && !this.managingOrganization.isEmpty();
992    }
993
994    /**
995     * @param value {@link #managingOrganization} (The organization that has assumed the specific responsibilities for the specified duration.)
996     */
997    public EpisodeOfCare setManagingOrganization(Reference value) { 
998      this.managingOrganization = value;
999      return this;
1000    }
1001
1002    /**
1003     * @return {@link #managingOrganization} 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 organization that has assumed the specific responsibilities for the specified duration.)
1004     */
1005    public Organization getManagingOrganizationTarget() { 
1006      if (this.managingOrganizationTarget == null)
1007        if (Configuration.errorOnAutoCreate())
1008          throw new Error("Attempt to auto-create EpisodeOfCare.managingOrganization");
1009        else if (Configuration.doAutoCreate())
1010          this.managingOrganizationTarget = new Organization(); // aa
1011      return this.managingOrganizationTarget;
1012    }
1013
1014    /**
1015     * @param value {@link #managingOrganization} 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 organization that has assumed the specific responsibilities for the specified duration.)
1016     */
1017    public EpisodeOfCare setManagingOrganizationTarget(Organization value) { 
1018      this.managingOrganizationTarget = value;
1019      return this;
1020    }
1021
1022    /**
1023     * @return {@link #period} (The interval during which the managing organization assumes the defined responsibility.)
1024     */
1025    public Period getPeriod() { 
1026      if (this.period == null)
1027        if (Configuration.errorOnAutoCreate())
1028          throw new Error("Attempt to auto-create EpisodeOfCare.period");
1029        else if (Configuration.doAutoCreate())
1030          this.period = new Period(); // cc
1031      return this.period;
1032    }
1033
1034    public boolean hasPeriod() { 
1035      return this.period != null && !this.period.isEmpty();
1036    }
1037
1038    /**
1039     * @param value {@link #period} (The interval during which the managing organization assumes the defined responsibility.)
1040     */
1041    public EpisodeOfCare setPeriod(Period value) { 
1042      this.period = value;
1043      return this;
1044    }
1045
1046    /**
1047     * @return {@link #referralRequest} (Referral Request(s) that are fulfilled by this EpisodeOfCare, incoming referrals.)
1048     */
1049    public List<Reference> getReferralRequest() { 
1050      if (this.referralRequest == null)
1051        this.referralRequest = new ArrayList<Reference>();
1052      return this.referralRequest;
1053    }
1054
1055    public boolean hasReferralRequest() { 
1056      if (this.referralRequest == null)
1057        return false;
1058      for (Reference item : this.referralRequest)
1059        if (!item.isEmpty())
1060          return true;
1061      return false;
1062    }
1063
1064    /**
1065     * @return {@link #referralRequest} (Referral Request(s) that are fulfilled by this EpisodeOfCare, incoming referrals.)
1066     */
1067    // syntactic sugar
1068    public Reference addReferralRequest() { //3
1069      Reference t = new Reference();
1070      if (this.referralRequest == null)
1071        this.referralRequest = new ArrayList<Reference>();
1072      this.referralRequest.add(t);
1073      return t;
1074    }
1075
1076    // syntactic sugar
1077    public EpisodeOfCare addReferralRequest(Reference t) { //3
1078      if (t == null)
1079        return this;
1080      if (this.referralRequest == null)
1081        this.referralRequest = new ArrayList<Reference>();
1082      this.referralRequest.add(t);
1083      return this;
1084    }
1085
1086    /**
1087     * @return {@link #referralRequest} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. Referral Request(s) that are fulfilled by this EpisodeOfCare, incoming referrals.)
1088     */
1089    public List<ReferralRequest> getReferralRequestTarget() { 
1090      if (this.referralRequestTarget == null)
1091        this.referralRequestTarget = new ArrayList<ReferralRequest>();
1092      return this.referralRequestTarget;
1093    }
1094
1095    // syntactic sugar
1096    /**
1097     * @return {@link #referralRequest} (Add an actual object that is the target of the reference. The reference library doesn't use these, but you can use this to hold the resources if you resolvethemt. Referral Request(s) that are fulfilled by this EpisodeOfCare, incoming referrals.)
1098     */
1099    public ReferralRequest addReferralRequestTarget() { 
1100      ReferralRequest r = new ReferralRequest();
1101      if (this.referralRequestTarget == null)
1102        this.referralRequestTarget = new ArrayList<ReferralRequest>();
1103      this.referralRequestTarget.add(r);
1104      return r;
1105    }
1106
1107    /**
1108     * @return {@link #careManager} (The practitioner that is the care manager/care co-ordinator for this patient.)
1109     */
1110    public Reference getCareManager() { 
1111      if (this.careManager == null)
1112        if (Configuration.errorOnAutoCreate())
1113          throw new Error("Attempt to auto-create EpisodeOfCare.careManager");
1114        else if (Configuration.doAutoCreate())
1115          this.careManager = new Reference(); // cc
1116      return this.careManager;
1117    }
1118
1119    public boolean hasCareManager() { 
1120      return this.careManager != null && !this.careManager.isEmpty();
1121    }
1122
1123    /**
1124     * @param value {@link #careManager} (The practitioner that is the care manager/care co-ordinator for this patient.)
1125     */
1126    public EpisodeOfCare setCareManager(Reference value) { 
1127      this.careManager = value;
1128      return this;
1129    }
1130
1131    /**
1132     * @return {@link #careManager} 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 practitioner that is the care manager/care co-ordinator for this patient.)
1133     */
1134    public Practitioner getCareManagerTarget() { 
1135      if (this.careManagerTarget == null)
1136        if (Configuration.errorOnAutoCreate())
1137          throw new Error("Attempt to auto-create EpisodeOfCare.careManager");
1138        else if (Configuration.doAutoCreate())
1139          this.careManagerTarget = new Practitioner(); // aa
1140      return this.careManagerTarget;
1141    }
1142
1143    /**
1144     * @param value {@link #careManager} 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 practitioner that is the care manager/care co-ordinator for this patient.)
1145     */
1146    public EpisodeOfCare setCareManagerTarget(Practitioner value) { 
1147      this.careManagerTarget = value;
1148      return this;
1149    }
1150
1151    /**
1152     * @return {@link #careTeam} (The list of practitioners that may be facilitating this episode of care for specific purposes.)
1153     */
1154    public List<EpisodeOfCareCareTeamComponent> getCareTeam() { 
1155      if (this.careTeam == null)
1156        this.careTeam = new ArrayList<EpisodeOfCareCareTeamComponent>();
1157      return this.careTeam;
1158    }
1159
1160    public boolean hasCareTeam() { 
1161      if (this.careTeam == null)
1162        return false;
1163      for (EpisodeOfCareCareTeamComponent item : this.careTeam)
1164        if (!item.isEmpty())
1165          return true;
1166      return false;
1167    }
1168
1169    /**
1170     * @return {@link #careTeam} (The list of practitioners that may be facilitating this episode of care for specific purposes.)
1171     */
1172    // syntactic sugar
1173    public EpisodeOfCareCareTeamComponent addCareTeam() { //3
1174      EpisodeOfCareCareTeamComponent t = new EpisodeOfCareCareTeamComponent();
1175      if (this.careTeam == null)
1176        this.careTeam = new ArrayList<EpisodeOfCareCareTeamComponent>();
1177      this.careTeam.add(t);
1178      return t;
1179    }
1180
1181    // syntactic sugar
1182    public EpisodeOfCare addCareTeam(EpisodeOfCareCareTeamComponent t) { //3
1183      if (t == null)
1184        return this;
1185      if (this.careTeam == null)
1186        this.careTeam = new ArrayList<EpisodeOfCareCareTeamComponent>();
1187      this.careTeam.add(t);
1188      return this;
1189    }
1190
1191      protected void listChildren(List<Property> childrenList) {
1192        super.listChildren(childrenList);
1193        childrenList.add(new Property("identifier", "Identifier", "Identifier(s) by which this EpisodeOfCare is known.", 0, java.lang.Integer.MAX_VALUE, identifier));
1194        childrenList.add(new Property("status", "code", "planned | waitlist | active | onhold | finished | cancelled.", 0, java.lang.Integer.MAX_VALUE, status));
1195        childrenList.add(new Property("statusHistory", "", "The history of statuses that the EpisodeOfCare has been through (without requiring processing the history of the resource).", 0, java.lang.Integer.MAX_VALUE, statusHistory));
1196        childrenList.add(new Property("type", "CodeableConcept", "A classification of the type of encounter; e.g. specialist referral, disease management, type of funded care.", 0, java.lang.Integer.MAX_VALUE, type));
1197        childrenList.add(new Property("condition", "Reference(Condition)", "A list of conditions/problems/diagnoses that this episode of care is intended to be providing care for.", 0, java.lang.Integer.MAX_VALUE, condition));
1198        childrenList.add(new Property("patient", "Reference(Patient)", "The patient that this EpisodeOfCare applies to.", 0, java.lang.Integer.MAX_VALUE, patient));
1199        childrenList.add(new Property("managingOrganization", "Reference(Organization)", "The organization that has assumed the specific responsibilities for the specified duration.", 0, java.lang.Integer.MAX_VALUE, managingOrganization));
1200        childrenList.add(new Property("period", "Period", "The interval during which the managing organization assumes the defined responsibility.", 0, java.lang.Integer.MAX_VALUE, period));
1201        childrenList.add(new Property("referralRequest", "Reference(ReferralRequest)", "Referral Request(s) that are fulfilled by this EpisodeOfCare, incoming referrals.", 0, java.lang.Integer.MAX_VALUE, referralRequest));
1202        childrenList.add(new Property("careManager", "Reference(Practitioner)", "The practitioner that is the care manager/care co-ordinator for this patient.", 0, java.lang.Integer.MAX_VALUE, careManager));
1203        childrenList.add(new Property("careTeam", "", "The list of practitioners that may be facilitating this episode of care for specific purposes.", 0, java.lang.Integer.MAX_VALUE, careTeam));
1204      }
1205
1206      @Override
1207      public void setProperty(String name, Base value) throws FHIRException {
1208        if (name.equals("identifier"))
1209          this.getIdentifier().add(castToIdentifier(value));
1210        else if (name.equals("status"))
1211          this.status = new EpisodeOfCareStatusEnumFactory().fromType(value); // Enumeration<EpisodeOfCareStatus>
1212        else if (name.equals("statusHistory"))
1213          this.getStatusHistory().add((EpisodeOfCareStatusHistoryComponent) value);
1214        else if (name.equals("type"))
1215          this.getType().add(castToCodeableConcept(value));
1216        else if (name.equals("condition"))
1217          this.getCondition().add(castToReference(value));
1218        else if (name.equals("patient"))
1219          this.patient = castToReference(value); // Reference
1220        else if (name.equals("managingOrganization"))
1221          this.managingOrganization = castToReference(value); // Reference
1222        else if (name.equals("period"))
1223          this.period = castToPeriod(value); // Period
1224        else if (name.equals("referralRequest"))
1225          this.getReferralRequest().add(castToReference(value));
1226        else if (name.equals("careManager"))
1227          this.careManager = castToReference(value); // Reference
1228        else if (name.equals("careTeam"))
1229          this.getCareTeam().add((EpisodeOfCareCareTeamComponent) value);
1230        else
1231          super.setProperty(name, value);
1232      }
1233
1234      @Override
1235      public Base addChild(String name) throws FHIRException {
1236        if (name.equals("identifier")) {
1237          return addIdentifier();
1238        }
1239        else if (name.equals("status")) {
1240          throw new FHIRException("Cannot call addChild on a primitive type EpisodeOfCare.status");
1241        }
1242        else if (name.equals("statusHistory")) {
1243          return addStatusHistory();
1244        }
1245        else if (name.equals("type")) {
1246          return addType();
1247        }
1248        else if (name.equals("condition")) {
1249          return addCondition();
1250        }
1251        else if (name.equals("patient")) {
1252          this.patient = new Reference();
1253          return this.patient;
1254        }
1255        else if (name.equals("managingOrganization")) {
1256          this.managingOrganization = new Reference();
1257          return this.managingOrganization;
1258        }
1259        else if (name.equals("period")) {
1260          this.period = new Period();
1261          return this.period;
1262        }
1263        else if (name.equals("referralRequest")) {
1264          return addReferralRequest();
1265        }
1266        else if (name.equals("careManager")) {
1267          this.careManager = new Reference();
1268          return this.careManager;
1269        }
1270        else if (name.equals("careTeam")) {
1271          return addCareTeam();
1272        }
1273        else
1274          return super.addChild(name);
1275      }
1276
1277  public String fhirType() {
1278    return "EpisodeOfCare";
1279
1280  }
1281
1282      public EpisodeOfCare copy() {
1283        EpisodeOfCare dst = new EpisodeOfCare();
1284        copyValues(dst);
1285        if (identifier != null) {
1286          dst.identifier = new ArrayList<Identifier>();
1287          for (Identifier i : identifier)
1288            dst.identifier.add(i.copy());
1289        };
1290        dst.status = status == null ? null : status.copy();
1291        if (statusHistory != null) {
1292          dst.statusHistory = new ArrayList<EpisodeOfCareStatusHistoryComponent>();
1293          for (EpisodeOfCareStatusHistoryComponent i : statusHistory)
1294            dst.statusHistory.add(i.copy());
1295        };
1296        if (type != null) {
1297          dst.type = new ArrayList<CodeableConcept>();
1298          for (CodeableConcept i : type)
1299            dst.type.add(i.copy());
1300        };
1301        if (condition != null) {
1302          dst.condition = new ArrayList<Reference>();
1303          for (Reference i : condition)
1304            dst.condition.add(i.copy());
1305        };
1306        dst.patient = patient == null ? null : patient.copy();
1307        dst.managingOrganization = managingOrganization == null ? null : managingOrganization.copy();
1308        dst.period = period == null ? null : period.copy();
1309        if (referralRequest != null) {
1310          dst.referralRequest = new ArrayList<Reference>();
1311          for (Reference i : referralRequest)
1312            dst.referralRequest.add(i.copy());
1313        };
1314        dst.careManager = careManager == null ? null : careManager.copy();
1315        if (careTeam != null) {
1316          dst.careTeam = new ArrayList<EpisodeOfCareCareTeamComponent>();
1317          for (EpisodeOfCareCareTeamComponent i : careTeam)
1318            dst.careTeam.add(i.copy());
1319        };
1320        return dst;
1321      }
1322
1323      protected EpisodeOfCare typedCopy() {
1324        return copy();
1325      }
1326
1327      @Override
1328      public boolean equalsDeep(Base other) {
1329        if (!super.equalsDeep(other))
1330          return false;
1331        if (!(other instanceof EpisodeOfCare))
1332          return false;
1333        EpisodeOfCare o = (EpisodeOfCare) other;
1334        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(statusHistory, o.statusHistory, true)
1335           && compareDeep(type, o.type, true) && compareDeep(condition, o.condition, true) && compareDeep(patient, o.patient, true)
1336           && compareDeep(managingOrganization, o.managingOrganization, true) && compareDeep(period, o.period, true)
1337           && compareDeep(referralRequest, o.referralRequest, true) && compareDeep(careManager, o.careManager, true)
1338           && compareDeep(careTeam, o.careTeam, true);
1339      }
1340
1341      @Override
1342      public boolean equalsShallow(Base other) {
1343        if (!super.equalsShallow(other))
1344          return false;
1345        if (!(other instanceof EpisodeOfCare))
1346          return false;
1347        EpisodeOfCare o = (EpisodeOfCare) other;
1348        return compareValues(status, o.status, true);
1349      }
1350
1351      public boolean isEmpty() {
1352        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (status == null || status.isEmpty())
1353           && (statusHistory == null || statusHistory.isEmpty()) && (type == null || type.isEmpty())
1354           && (condition == null || condition.isEmpty()) && (patient == null || patient.isEmpty()) && (managingOrganization == null || managingOrganization.isEmpty())
1355           && (period == null || period.isEmpty()) && (referralRequest == null || referralRequest.isEmpty())
1356           && (careManager == null || careManager.isEmpty()) && (careTeam == null || careTeam.isEmpty())
1357          ;
1358      }
1359
1360  @Override
1361  public ResourceType getResourceType() {
1362    return ResourceType.EpisodeOfCare;
1363   }
1364
1365  @SearchParamDefinition(name="date", path="EpisodeOfCare.period", description="The provided date search value falls within the episode of care's period", type="date" )
1366  public static final String SP_DATE = "date";
1367  @SearchParamDefinition(name="identifier", path="EpisodeOfCare.identifier", description="Identifier(s) for the EpisodeOfCare", type="token" )
1368  public static final String SP_IDENTIFIER = "identifier";
1369  @SearchParamDefinition(name="condition", path="EpisodeOfCare.condition", description="Conditions/problems/diagnoses this episode of care is for", type="reference" )
1370  public static final String SP_CONDITION = "condition";
1371  @SearchParamDefinition(name="incomingreferral", path="EpisodeOfCare.referralRequest", description="Incoming Referral Request", type="reference" )
1372  public static final String SP_INCOMINGREFERRAL = "incomingreferral";
1373  @SearchParamDefinition(name="patient", path="EpisodeOfCare.patient", description="Patient for this episode of care", type="reference" )
1374  public static final String SP_PATIENT = "patient";
1375  @SearchParamDefinition(name="organization", path="EpisodeOfCare.managingOrganization", description="The organization that has assumed the specific responsibilities of this EpisodeOfCare", type="reference" )
1376  public static final String SP_ORGANIZATION = "organization";
1377  @SearchParamDefinition(name="team-member", path="EpisodeOfCare.careTeam.member", description="A Practitioner or Organization allocated to the care team for this EpisodeOfCare", type="reference" )
1378  public static final String SP_TEAMMEMBER = "team-member";
1379  @SearchParamDefinition(name="type", path="EpisodeOfCare.type", description="Type/class  - e.g. specialist referral, disease management", type="token" )
1380  public static final String SP_TYPE = "type";
1381  @SearchParamDefinition(name="care-manager", path="EpisodeOfCare.careManager", description="Care manager/care co-ordinator for the patient", type="reference" )
1382  public static final String SP_CAREMANAGER = "care-manager";
1383  @SearchParamDefinition(name="status", path="EpisodeOfCare.status", description="The current status of the Episode of Care as provided (does not check the status history collection)", type="token" )
1384  public static final String SP_STATUS = "status";
1385
1386}
1387