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