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