001package org.hl7.fhir.r4.model;
002
003
004
005/*
006  Copyright (c) 2011+, HL7, Inc.
007  All rights reserved.
008  
009  Redistribution and use in source and binary forms, with or without modification, 
010  are permitted provided that the following conditions are met:
011  
012   * Redistributions of source code must retain the above copyright notice, this 
013     list of conditions and the following disclaimer.
014   * Redistributions in binary form must reproduce the above copyright notice, 
015     this list of conditions and the following disclaimer in the documentation 
016     and/or other materials provided with the distribution.
017   * Neither the name of HL7 nor the names of its contributors may be used to 
018     endorse or promote products derived from this software without specific 
019     prior written permission.
020  
021  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
022  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
023  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
024  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
025  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
026  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
027  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
028  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
029  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
030  POSSIBILITY OF SUCH DAMAGE.
031  
032*/
033
034
035// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1
036
037import java.util.*;
038
039import org.hl7.fhir.utilities.Utilities;
040import org.hl7.fhir.r4.model.Enumerations.*;
041import ca.uhn.fhir.model.api.annotation.ResourceDef;
042import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
043import ca.uhn.fhir.model.api.annotation.Child;
044import ca.uhn.fhir.model.api.annotation.ChildOrder;
045import ca.uhn.fhir.model.api.annotation.Description;
046import ca.uhn.fhir.model.api.annotation.Block;
047import org.hl7.fhir.instance.model.api.*;
048import org.hl7.fhir.exceptions.FHIRException;
049/**
050 * 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.
051 */
052@ResourceDef(name="EpisodeOfCare", profile="http://hl7.org/fhir/StructureDefinition/EpisodeOfCare")
053public class EpisodeOfCare extends DomainResource {
054
055    public enum EpisodeOfCareStatus {
056        /**
057         * 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 the patient is eligible to receive services, or be organizing to make resources available to provide care services.
058         */
059        PLANNED, 
060        /**
061         * This episode has been placed on a waitlist, pending the episode being made active (or cancelled).
062         */
063        WAITLIST, 
064        /**
065         * This episode of care is current.
066         */
067        ACTIVE, 
068        /**
069         * This episode of care is on hold; the organization has limited responsibility for the patient (such as while on respite).
070         */
071        ONHOLD, 
072        /**
073         * This episode of care is finished and the organization is not expecting to be providing further care to the patient. Can also be known as "closed", "completed" or other similar terms.
074         */
075        FINISHED, 
076        /**
077         * 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.
078         */
079        CANCELLED, 
080        /**
081         * This instance should not have been part of this patient's medical record.
082         */
083        ENTEREDINERROR, 
084        /**
085         * added to help the parsers with the generic types
086         */
087        NULL;
088        public static EpisodeOfCareStatus fromCode(String codeString) throws FHIRException {
089            if (codeString == null || "".equals(codeString))
090                return null;
091        if ("planned".equals(codeString))
092          return PLANNED;
093        if ("waitlist".equals(codeString))
094          return WAITLIST;
095        if ("active".equals(codeString))
096          return ACTIVE;
097        if ("onhold".equals(codeString))
098          return ONHOLD;
099        if ("finished".equals(codeString))
100          return FINISHED;
101        if ("cancelled".equals(codeString))
102          return CANCELLED;
103        if ("entered-in-error".equals(codeString))
104          return ENTEREDINERROR;
105        if (Configuration.isAcceptInvalidEnums())
106          return null;
107        else
108          throw new FHIRException("Unknown EpisodeOfCareStatus code '"+codeString+"'");
109        }
110        public String toCode() {
111          switch (this) {
112            case PLANNED: return "planned";
113            case WAITLIST: return "waitlist";
114            case ACTIVE: return "active";
115            case ONHOLD: return "onhold";
116            case FINISHED: return "finished";
117            case CANCELLED: return "cancelled";
118            case ENTEREDINERROR: return "entered-in-error";
119            case NULL: return null;
120            default: return "?";
121          }
122        }
123        public String getSystem() {
124          switch (this) {
125            case PLANNED: return "http://hl7.org/fhir/episode-of-care-status";
126            case WAITLIST: return "http://hl7.org/fhir/episode-of-care-status";
127            case ACTIVE: return "http://hl7.org/fhir/episode-of-care-status";
128            case ONHOLD: return "http://hl7.org/fhir/episode-of-care-status";
129            case FINISHED: return "http://hl7.org/fhir/episode-of-care-status";
130            case CANCELLED: return "http://hl7.org/fhir/episode-of-care-status";
131            case ENTEREDINERROR: return "http://hl7.org/fhir/episode-of-care-status";
132            case NULL: return null;
133            default: return "?";
134          }
135        }
136        public String getDefinition() {
137          switch (this) {
138            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 the patient is eligible to receive services, or be organizing to make resources available to provide care services.";
139            case WAITLIST: return "This episode has been placed on a waitlist, pending the episode being made active (or cancelled).";
140            case ACTIVE: return "This episode of care is current.";
141            case ONHOLD: return "This episode of care is on hold; the organization has limited responsibility for the patient (such as while on respite).";
142            case FINISHED: return "This episode of care is finished and the organization is not expecting to be providing further care to the patient. Can also be known as \"closed\", \"completed\" or other similar terms.";
143            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.";
144            case ENTEREDINERROR: return "This instance should not have been part of this patient's medical record.";
145            case NULL: return null;
146            default: return "?";
147          }
148        }
149        public String getDisplay() {
150          switch (this) {
151            case PLANNED: return "Planned";
152            case WAITLIST: return "Waitlist";
153            case ACTIVE: return "Active";
154            case ONHOLD: return "On Hold";
155            case FINISHED: return "Finished";
156            case CANCELLED: return "Cancelled";
157            case ENTEREDINERROR: return "Entered in Error";
158            case NULL: return null;
159            default: return "?";
160          }
161        }
162    }
163
164  public static class EpisodeOfCareStatusEnumFactory implements EnumFactory<EpisodeOfCareStatus> {
165    public EpisodeOfCareStatus fromCode(String codeString) throws IllegalArgumentException {
166      if (codeString == null || "".equals(codeString))
167            if (codeString == null || "".equals(codeString))
168                return null;
169        if ("planned".equals(codeString))
170          return EpisodeOfCareStatus.PLANNED;
171        if ("waitlist".equals(codeString))
172          return EpisodeOfCareStatus.WAITLIST;
173        if ("active".equals(codeString))
174          return EpisodeOfCareStatus.ACTIVE;
175        if ("onhold".equals(codeString))
176          return EpisodeOfCareStatus.ONHOLD;
177        if ("finished".equals(codeString))
178          return EpisodeOfCareStatus.FINISHED;
179        if ("cancelled".equals(codeString))
180          return EpisodeOfCareStatus.CANCELLED;
181        if ("entered-in-error".equals(codeString))
182          return EpisodeOfCareStatus.ENTEREDINERROR;
183        throw new IllegalArgumentException("Unknown EpisodeOfCareStatus code '"+codeString+"'");
184        }
185        public Enumeration<EpisodeOfCareStatus> fromType(Base code) throws FHIRException {
186          if (code == null)
187            return null;
188          if (code.isEmpty())
189            return new Enumeration<EpisodeOfCareStatus>(this);
190          String codeString = ((PrimitiveType) code).asStringValue();
191          if (codeString == null || "".equals(codeString))
192            return null;
193        if ("planned".equals(codeString))
194          return new Enumeration<EpisodeOfCareStatus>(this, EpisodeOfCareStatus.PLANNED);
195        if ("waitlist".equals(codeString))
196          return new Enumeration<EpisodeOfCareStatus>(this, EpisodeOfCareStatus.WAITLIST);
197        if ("active".equals(codeString))
198          return new Enumeration<EpisodeOfCareStatus>(this, EpisodeOfCareStatus.ACTIVE);
199        if ("onhold".equals(codeString))
200          return new Enumeration<EpisodeOfCareStatus>(this, EpisodeOfCareStatus.ONHOLD);
201        if ("finished".equals(codeString))
202          return new Enumeration<EpisodeOfCareStatus>(this, EpisodeOfCareStatus.FINISHED);
203        if ("cancelled".equals(codeString))
204          return new Enumeration<EpisodeOfCareStatus>(this, EpisodeOfCareStatus.CANCELLED);
205        if ("entered-in-error".equals(codeString))
206          return new Enumeration<EpisodeOfCareStatus>(this, EpisodeOfCareStatus.ENTEREDINERROR);
207        throw new FHIRException("Unknown EpisodeOfCareStatus code '"+codeString+"'");
208        }
209    public String toCode(EpisodeOfCareStatus code) {
210      if (code == EpisodeOfCareStatus.PLANNED)
211        return "planned";
212      if (code == EpisodeOfCareStatus.WAITLIST)
213        return "waitlist";
214      if (code == EpisodeOfCareStatus.ACTIVE)
215        return "active";
216      if (code == EpisodeOfCareStatus.ONHOLD)
217        return "onhold";
218      if (code == EpisodeOfCareStatus.FINISHED)
219        return "finished";
220      if (code == EpisodeOfCareStatus.CANCELLED)
221        return "cancelled";
222      if (code == EpisodeOfCareStatus.ENTEREDINERROR)
223        return "entered-in-error";
224      return "?";
225      }
226    public String toSystem(EpisodeOfCareStatus code) {
227      return code.getSystem();
228      }
229    }
230
231    @Block()
232    public static class EpisodeOfCareStatusHistoryComponent extends BackboneElement implements IBaseBackboneElement {
233        /**
234         * planned | waitlist | active | onhold | finished | cancelled.
235         */
236        @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=false)
237        @Description(shortDefinition="planned | waitlist | active | onhold | finished | cancelled | entered-in-error", formalDefinition="planned | waitlist | active | onhold | finished | cancelled." )
238        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/episode-of-care-status")
239        protected Enumeration<EpisodeOfCareStatus> status;
240
241        /**
242         * The period during this EpisodeOfCare that the specific status applied.
243         */
244        @Child(name = "period", type = {Period.class}, order=2, min=1, max=1, modifier=false, summary=false)
245        @Description(shortDefinition="Duration the EpisodeOfCare was in the specified status", formalDefinition="The period during this EpisodeOfCare that the specific status applied." )
246        protected Period period;
247
248        private static final long serialVersionUID = -1192432864L;
249
250    /**
251     * Constructor
252     */
253      public EpisodeOfCareStatusHistoryComponent() {
254        super();
255      }
256
257    /**
258     * Constructor
259     */
260      public EpisodeOfCareStatusHistoryComponent(Enumeration<EpisodeOfCareStatus> status, Period period) {
261        super();
262        this.status = status;
263        this.period = period;
264      }
265
266        /**
267         * @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
268         */
269        public Enumeration<EpisodeOfCareStatus> getStatusElement() { 
270          if (this.status == null)
271            if (Configuration.errorOnAutoCreate())
272              throw new Error("Attempt to auto-create EpisodeOfCareStatusHistoryComponent.status");
273            else if (Configuration.doAutoCreate())
274              this.status = new Enumeration<EpisodeOfCareStatus>(new EpisodeOfCareStatusEnumFactory()); // bb
275          return this.status;
276        }
277
278        public boolean hasStatusElement() { 
279          return this.status != null && !this.status.isEmpty();
280        }
281
282        public boolean hasStatus() { 
283          return this.status != null && !this.status.isEmpty();
284        }
285
286        /**
287         * @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
288         */
289        public EpisodeOfCareStatusHistoryComponent setStatusElement(Enumeration<EpisodeOfCareStatus> value) { 
290          this.status = value;
291          return this;
292        }
293
294        /**
295         * @return planned | waitlist | active | onhold | finished | cancelled.
296         */
297        public EpisodeOfCareStatus getStatus() { 
298          return this.status == null ? null : this.status.getValue();
299        }
300
301        /**
302         * @param value planned | waitlist | active | onhold | finished | cancelled.
303         */
304        public EpisodeOfCareStatusHistoryComponent setStatus(EpisodeOfCareStatus value) { 
305            if (this.status == null)
306              this.status = new Enumeration<EpisodeOfCareStatus>(new EpisodeOfCareStatusEnumFactory());
307            this.status.setValue(value);
308          return this;
309        }
310
311        /**
312         * @return {@link #period} (The period during this EpisodeOfCare that the specific status applied.)
313         */
314        public Period getPeriod() { 
315          if (this.period == null)
316            if (Configuration.errorOnAutoCreate())
317              throw new Error("Attempt to auto-create EpisodeOfCareStatusHistoryComponent.period");
318            else if (Configuration.doAutoCreate())
319              this.period = new Period(); // cc
320          return this.period;
321        }
322
323        public boolean hasPeriod() { 
324          return this.period != null && !this.period.isEmpty();
325        }
326
327        /**
328         * @param value {@link #period} (The period during this EpisodeOfCare that the specific status applied.)
329         */
330        public EpisodeOfCareStatusHistoryComponent setPeriod(Period value) { 
331          this.period = value;
332          return this;
333        }
334
335        protected void listChildren(List<Property> children) {
336          super.listChildren(children);
337          children.add(new Property("status", "code", "planned | waitlist | active | onhold | finished | cancelled.", 0, 1, status));
338          children.add(new Property("period", "Period", "The period during this EpisodeOfCare that the specific status applied.", 0, 1, period));
339        }
340
341        @Override
342        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
343          switch (_hash) {
344          case -892481550: /*status*/  return new Property("status", "code", "planned | waitlist | active | onhold | finished | cancelled.", 0, 1, status);
345          case -991726143: /*period*/  return new Property("period", "Period", "The period during this EpisodeOfCare that the specific status applied.", 0, 1, period);
346          default: return super.getNamedProperty(_hash, _name, _checkValid);
347          }
348
349        }
350
351      @Override
352      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
353        switch (hash) {
354        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<EpisodeOfCareStatus>
355        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
356        default: return super.getProperty(hash, name, checkValid);
357        }
358
359      }
360
361      @Override
362      public Base setProperty(int hash, String name, Base value) throws FHIRException {
363        switch (hash) {
364        case -892481550: // status
365          value = new EpisodeOfCareStatusEnumFactory().fromType(castToCode(value));
366          this.status = (Enumeration) value; // Enumeration<EpisodeOfCareStatus>
367          return value;
368        case -991726143: // period
369          this.period = castToPeriod(value); // Period
370          return value;
371        default: return super.setProperty(hash, name, value);
372        }
373
374      }
375
376      @Override
377      public Base setProperty(String name, Base value) throws FHIRException {
378        if (name.equals("status")) {
379          value = new EpisodeOfCareStatusEnumFactory().fromType(castToCode(value));
380          this.status = (Enumeration) value; // Enumeration<EpisodeOfCareStatus>
381        } else if (name.equals("period")) {
382          this.period = castToPeriod(value); // Period
383        } else
384          return super.setProperty(name, value);
385        return value;
386      }
387
388      @Override
389      public Base makeProperty(int hash, String name) throws FHIRException {
390        switch (hash) {
391        case -892481550:  return getStatusElement();
392        case -991726143:  return getPeriod(); 
393        default: return super.makeProperty(hash, name);
394        }
395
396      }
397
398      @Override
399      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
400        switch (hash) {
401        case -892481550: /*status*/ return new String[] {"code"};
402        case -991726143: /*period*/ return new String[] {"Period"};
403        default: return super.getTypesForProperty(hash, name);
404        }
405
406      }
407
408      @Override
409      public Base addChild(String name) throws FHIRException {
410        if (name.equals("status")) {
411          throw new FHIRException("Cannot call addChild on a primitive type EpisodeOfCare.status");
412        }
413        else if (name.equals("period")) {
414          this.period = new Period();
415          return this.period;
416        }
417        else
418          return super.addChild(name);
419      }
420
421      public EpisodeOfCareStatusHistoryComponent copy() {
422        EpisodeOfCareStatusHistoryComponent dst = new EpisodeOfCareStatusHistoryComponent();
423        copyValues(dst);
424        return dst;
425      }
426
427      public void copyValues(EpisodeOfCareStatusHistoryComponent dst) {
428        super.copyValues(dst);
429        dst.status = status == null ? null : status.copy();
430        dst.period = period == null ? null : period.copy();
431      }
432
433      @Override
434      public boolean equalsDeep(Base other_) {
435        if (!super.equalsDeep(other_))
436          return false;
437        if (!(other_ instanceof EpisodeOfCareStatusHistoryComponent))
438          return false;
439        EpisodeOfCareStatusHistoryComponent o = (EpisodeOfCareStatusHistoryComponent) other_;
440        return compareDeep(status, o.status, true) && compareDeep(period, o.period, true);
441      }
442
443      @Override
444      public boolean equalsShallow(Base other_) {
445        if (!super.equalsShallow(other_))
446          return false;
447        if (!(other_ instanceof EpisodeOfCareStatusHistoryComponent))
448          return false;
449        EpisodeOfCareStatusHistoryComponent o = (EpisodeOfCareStatusHistoryComponent) other_;
450        return compareValues(status, o.status, true);
451      }
452
453      public boolean isEmpty() {
454        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(status, period);
455      }
456
457  public String fhirType() {
458    return "EpisodeOfCare.statusHistory";
459
460  }
461
462  }
463
464    @Block()
465    public static class DiagnosisComponent extends BackboneElement implements IBaseBackboneElement {
466        /**
467         * A list of conditions/problems/diagnoses that this episode of care is intended to be providing care for.
468         */
469        @Child(name = "condition", type = {Condition.class}, order=1, min=1, max=1, modifier=false, summary=true)
470        @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." )
471        protected Reference condition;
472
473        /**
474         * The actual object that is the target of the reference (A list of conditions/problems/diagnoses that this episode of care is intended to be providing care for.)
475         */
476        protected Condition conditionTarget;
477
478        /**
479         * Role that this diagnosis has within the episode of care (e.g. admission, billing, discharge …).
480         */
481        @Child(name = "role", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
482        @Description(shortDefinition="Role that this diagnosis has within the episode of care (e.g. admission, billing, discharge …)", formalDefinition="Role that this diagnosis has within the episode of care (e.g. admission, billing, discharge …)." )
483        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/diagnosis-role")
484        protected CodeableConcept role;
485
486        /**
487         * Ranking of the diagnosis (for each role type).
488         */
489        @Child(name = "rank", type = {PositiveIntType.class}, order=3, min=0, max=1, modifier=false, summary=true)
490        @Description(shortDefinition="Ranking of the diagnosis (for each role type)", formalDefinition="Ranking of the diagnosis (for each role type)." )
491        protected PositiveIntType rank;
492
493        private static final long serialVersionUID = 249445632L;
494
495    /**
496     * Constructor
497     */
498      public DiagnosisComponent() {
499        super();
500      }
501
502    /**
503     * Constructor
504     */
505      public DiagnosisComponent(Reference condition) {
506        super();
507        this.condition = condition;
508      }
509
510        /**
511         * @return {@link #condition} (A list of conditions/problems/diagnoses that this episode of care is intended to be providing care for.)
512         */
513        public Reference getCondition() { 
514          if (this.condition == null)
515            if (Configuration.errorOnAutoCreate())
516              throw new Error("Attempt to auto-create DiagnosisComponent.condition");
517            else if (Configuration.doAutoCreate())
518              this.condition = new Reference(); // cc
519          return this.condition;
520        }
521
522        public boolean hasCondition() { 
523          return this.condition != null && !this.condition.isEmpty();
524        }
525
526        /**
527         * @param value {@link #condition} (A list of conditions/problems/diagnoses that this episode of care is intended to be providing care for.)
528         */
529        public DiagnosisComponent setCondition(Reference value) { 
530          this.condition = value;
531          return this;
532        }
533
534        /**
535         * @return {@link #condition} 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. (A list of conditions/problems/diagnoses that this episode of care is intended to be providing care for.)
536         */
537        public Condition getConditionTarget() { 
538          if (this.conditionTarget == null)
539            if (Configuration.errorOnAutoCreate())
540              throw new Error("Attempt to auto-create DiagnosisComponent.condition");
541            else if (Configuration.doAutoCreate())
542              this.conditionTarget = new Condition(); // aa
543          return this.conditionTarget;
544        }
545
546        /**
547         * @param value {@link #condition} 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. (A list of conditions/problems/diagnoses that this episode of care is intended to be providing care for.)
548         */
549        public DiagnosisComponent setConditionTarget(Condition value) { 
550          this.conditionTarget = value;
551          return this;
552        }
553
554        /**
555         * @return {@link #role} (Role that this diagnosis has within the episode of care (e.g. admission, billing, discharge …).)
556         */
557        public CodeableConcept getRole() { 
558          if (this.role == null)
559            if (Configuration.errorOnAutoCreate())
560              throw new Error("Attempt to auto-create DiagnosisComponent.role");
561            else if (Configuration.doAutoCreate())
562              this.role = new CodeableConcept(); // cc
563          return this.role;
564        }
565
566        public boolean hasRole() { 
567          return this.role != null && !this.role.isEmpty();
568        }
569
570        /**
571         * @param value {@link #role} (Role that this diagnosis has within the episode of care (e.g. admission, billing, discharge …).)
572         */
573        public DiagnosisComponent setRole(CodeableConcept value) { 
574          this.role = value;
575          return this;
576        }
577
578        /**
579         * @return {@link #rank} (Ranking of the diagnosis (for each role type).). This is the underlying object with id, value and extensions. The accessor "getRank" gives direct access to the value
580         */
581        public PositiveIntType getRankElement() { 
582          if (this.rank == null)
583            if (Configuration.errorOnAutoCreate())
584              throw new Error("Attempt to auto-create DiagnosisComponent.rank");
585            else if (Configuration.doAutoCreate())
586              this.rank = new PositiveIntType(); // bb
587          return this.rank;
588        }
589
590        public boolean hasRankElement() { 
591          return this.rank != null && !this.rank.isEmpty();
592        }
593
594        public boolean hasRank() { 
595          return this.rank != null && !this.rank.isEmpty();
596        }
597
598        /**
599         * @param value {@link #rank} (Ranking of the diagnosis (for each role type).). This is the underlying object with id, value and extensions. The accessor "getRank" gives direct access to the value
600         */
601        public DiagnosisComponent setRankElement(PositiveIntType value) { 
602          this.rank = value;
603          return this;
604        }
605
606        /**
607         * @return Ranking of the diagnosis (for each role type).
608         */
609        public int getRank() { 
610          return this.rank == null || this.rank.isEmpty() ? 0 : this.rank.getValue();
611        }
612
613        /**
614         * @param value Ranking of the diagnosis (for each role type).
615         */
616        public DiagnosisComponent setRank(int value) { 
617            if (this.rank == null)
618              this.rank = new PositiveIntType();
619            this.rank.setValue(value);
620          return this;
621        }
622
623        protected void listChildren(List<Property> children) {
624          super.listChildren(children);
625          children.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, 1, condition));
626          children.add(new Property("role", "CodeableConcept", "Role that this diagnosis has within the episode of care (e.g. admission, billing, discharge …).", 0, 1, role));
627          children.add(new Property("rank", "positiveInt", "Ranking of the diagnosis (for each role type).", 0, 1, rank));
628        }
629
630        @Override
631        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
632          switch (_hash) {
633          case -861311717: /*condition*/  return new Property("condition", "Reference(Condition)", "A list of conditions/problems/diagnoses that this episode of care is intended to be providing care for.", 0, 1, condition);
634          case 3506294: /*role*/  return new Property("role", "CodeableConcept", "Role that this diagnosis has within the episode of care (e.g. admission, billing, discharge …).", 0, 1, role);
635          case 3492908: /*rank*/  return new Property("rank", "positiveInt", "Ranking of the diagnosis (for each role type).", 0, 1, rank);
636          default: return super.getNamedProperty(_hash, _name, _checkValid);
637          }
638
639        }
640
641      @Override
642      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
643        switch (hash) {
644        case -861311717: /*condition*/ return this.condition == null ? new Base[0] : new Base[] {this.condition}; // Reference
645        case 3506294: /*role*/ return this.role == null ? new Base[0] : new Base[] {this.role}; // CodeableConcept
646        case 3492908: /*rank*/ return this.rank == null ? new Base[0] : new Base[] {this.rank}; // PositiveIntType
647        default: return super.getProperty(hash, name, checkValid);
648        }
649
650      }
651
652      @Override
653      public Base setProperty(int hash, String name, Base value) throws FHIRException {
654        switch (hash) {
655        case -861311717: // condition
656          this.condition = castToReference(value); // Reference
657          return value;
658        case 3506294: // role
659          this.role = castToCodeableConcept(value); // CodeableConcept
660          return value;
661        case 3492908: // rank
662          this.rank = castToPositiveInt(value); // PositiveIntType
663          return value;
664        default: return super.setProperty(hash, name, value);
665        }
666
667      }
668
669      @Override
670      public Base setProperty(String name, Base value) throws FHIRException {
671        if (name.equals("condition")) {
672          this.condition = castToReference(value); // Reference
673        } else if (name.equals("role")) {
674          this.role = castToCodeableConcept(value); // CodeableConcept
675        } else if (name.equals("rank")) {
676          this.rank = castToPositiveInt(value); // PositiveIntType
677        } else
678          return super.setProperty(name, value);
679        return value;
680      }
681
682      @Override
683      public Base makeProperty(int hash, String name) throws FHIRException {
684        switch (hash) {
685        case -861311717:  return getCondition(); 
686        case 3506294:  return getRole(); 
687        case 3492908:  return getRankElement();
688        default: return super.makeProperty(hash, name);
689        }
690
691      }
692
693      @Override
694      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
695        switch (hash) {
696        case -861311717: /*condition*/ return new String[] {"Reference"};
697        case 3506294: /*role*/ return new String[] {"CodeableConcept"};
698        case 3492908: /*rank*/ return new String[] {"positiveInt"};
699        default: return super.getTypesForProperty(hash, name);
700        }
701
702      }
703
704      @Override
705      public Base addChild(String name) throws FHIRException {
706        if (name.equals("condition")) {
707          this.condition = new Reference();
708          return this.condition;
709        }
710        else if (name.equals("role")) {
711          this.role = new CodeableConcept();
712          return this.role;
713        }
714        else if (name.equals("rank")) {
715          throw new FHIRException("Cannot call addChild on a primitive type EpisodeOfCare.rank");
716        }
717        else
718          return super.addChild(name);
719      }
720
721      public DiagnosisComponent copy() {
722        DiagnosisComponent dst = new DiagnosisComponent();
723        copyValues(dst);
724        return dst;
725      }
726
727      public void copyValues(DiagnosisComponent dst) {
728        super.copyValues(dst);
729        dst.condition = condition == null ? null : condition.copy();
730        dst.role = role == null ? null : role.copy();
731        dst.rank = rank == null ? null : rank.copy();
732      }
733
734      @Override
735      public boolean equalsDeep(Base other_) {
736        if (!super.equalsDeep(other_))
737          return false;
738        if (!(other_ instanceof DiagnosisComponent))
739          return false;
740        DiagnosisComponent o = (DiagnosisComponent) other_;
741        return compareDeep(condition, o.condition, true) && compareDeep(role, o.role, true) && compareDeep(rank, o.rank, true)
742          ;
743      }
744
745      @Override
746      public boolean equalsShallow(Base other_) {
747        if (!super.equalsShallow(other_))
748          return false;
749        if (!(other_ instanceof DiagnosisComponent))
750          return false;
751        DiagnosisComponent o = (DiagnosisComponent) other_;
752        return compareValues(rank, o.rank, true);
753      }
754
755      public boolean isEmpty() {
756        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(condition, role, rank);
757      }
758
759  public String fhirType() {
760    return "EpisodeOfCare.diagnosis";
761
762  }
763
764  }
765
766    /**
767     * The EpisodeOfCare may be known by different identifiers for different contexts of use, such as when an external agency is tracking the Episode for funding purposes.
768     */
769    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
770    @Description(shortDefinition="Business Identifier(s) relevant for this EpisodeOfCare", formalDefinition="The EpisodeOfCare may be known by different identifiers for different contexts of use, such as when an external agency is tracking the Episode for funding purposes." )
771    protected List<Identifier> identifier;
772
773    /**
774     * planned | waitlist | active | onhold | finished | cancelled.
775     */
776    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
777    @Description(shortDefinition="planned | waitlist | active | onhold | finished | cancelled | entered-in-error", formalDefinition="planned | waitlist | active | onhold | finished | cancelled." )
778    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/episode-of-care-status")
779    protected Enumeration<EpisodeOfCareStatus> status;
780
781    /**
782     * The history of statuses that the EpisodeOfCare has been through (without requiring processing the history of the resource).
783     */
784    @Child(name = "statusHistory", type = {}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
785    @Description(shortDefinition="Past list of status codes (the current status may be included to cover the start date of the status)", formalDefinition="The history of statuses that the EpisodeOfCare has been through (without requiring processing the history of the resource)." )
786    protected List<EpisodeOfCareStatusHistoryComponent> statusHistory;
787
788    /**
789     * A classification of the type of episode of care; e.g. specialist referral, disease management, type of funded care.
790     */
791    @Child(name = "type", type = {CodeableConcept.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
792    @Description(shortDefinition="Type/class  - e.g. specialist referral, disease management", formalDefinition="A classification of the type of episode of care; e.g. specialist referral, disease management, type of funded care." )
793    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/episodeofcare-type")
794    protected List<CodeableConcept> type;
795
796    /**
797     * The list of diagnosis relevant to this episode of care.
798     */
799    @Child(name = "diagnosis", type = {}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
800    @Description(shortDefinition="The list of diagnosis relevant to this episode of care", formalDefinition="The list of diagnosis relevant to this episode of care." )
801    protected List<DiagnosisComponent> diagnosis;
802
803    /**
804     * The patient who is the focus of this episode of care.
805     */
806    @Child(name = "patient", type = {Patient.class}, order=5, min=1, max=1, modifier=false, summary=true)
807    @Description(shortDefinition="The patient who is the focus of this episode of care", formalDefinition="The patient who is the focus of this episode of care." )
808    protected Reference patient;
809
810    /**
811     * The actual object that is the target of the reference (The patient who is the focus of this episode of care.)
812     */
813    protected Patient patientTarget;
814
815    /**
816     * The organization that has assumed the specific responsibilities for the specified duration.
817     */
818    @Child(name = "managingOrganization", type = {Organization.class}, order=6, min=0, max=1, modifier=false, summary=true)
819    @Description(shortDefinition="Organization that assumes care", formalDefinition="The organization that has assumed the specific responsibilities for the specified duration." )
820    protected Reference managingOrganization;
821
822    /**
823     * The actual object that is the target of the reference (The organization that has assumed the specific responsibilities for the specified duration.)
824     */
825    protected Organization managingOrganizationTarget;
826
827    /**
828     * The interval during which the managing organization assumes the defined responsibility.
829     */
830    @Child(name = "period", type = {Period.class}, order=7, min=0, max=1, modifier=false, summary=true)
831    @Description(shortDefinition="Interval during responsibility is assumed", formalDefinition="The interval during which the managing organization assumes the defined responsibility." )
832    protected Period period;
833
834    /**
835     * Referral Request(s) that are fulfilled by this EpisodeOfCare, incoming referrals.
836     */
837    @Child(name = "referralRequest", type = {ServiceRequest.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
838    @Description(shortDefinition="Originating Referral Request(s)", formalDefinition="Referral Request(s) that are fulfilled by this EpisodeOfCare, incoming referrals." )
839    protected List<Reference> referralRequest;
840    /**
841     * The actual objects that are the target of the reference (Referral Request(s) that are fulfilled by this EpisodeOfCare, incoming referrals.)
842     */
843    protected List<ServiceRequest> referralRequestTarget;
844
845
846    /**
847     * The practitioner that is the care manager/care coordinator for this patient.
848     */
849    @Child(name = "careManager", type = {Practitioner.class, PractitionerRole.class}, order=9, min=0, max=1, modifier=false, summary=false)
850    @Description(shortDefinition="Care manager/care coordinator for the patient", formalDefinition="The practitioner that is the care manager/care coordinator for this patient." )
851    protected Reference careManager;
852
853    /**
854     * The actual object that is the target of the reference (The practitioner that is the care manager/care coordinator for this patient.)
855     */
856    protected Resource careManagerTarget;
857
858    /**
859     * The list of practitioners that may be facilitating this episode of care for specific purposes.
860     */
861    @Child(name = "team", type = {CareTeam.class}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
862    @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." )
863    protected List<Reference> team;
864    /**
865     * The actual objects that are the target of the reference (The list of practitioners that may be facilitating this episode of care for specific purposes.)
866     */
867    protected List<CareTeam> teamTarget;
868
869
870    /**
871     * The set of accounts that may be used for billing for this EpisodeOfCare.
872     */
873    @Child(name = "account", type = {Account.class}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
874    @Description(shortDefinition="The set of accounts that may be used for billing for this EpisodeOfCare", formalDefinition="The set of accounts that may be used for billing for this EpisodeOfCare." )
875    protected List<Reference> account;
876    /**
877     * The actual objects that are the target of the reference (The set of accounts that may be used for billing for this EpisodeOfCare.)
878     */
879    protected List<Account> accountTarget;
880
881
882    private static final long serialVersionUID = 548033949L;
883
884  /**
885   * Constructor
886   */
887    public EpisodeOfCare() {
888      super();
889    }
890
891  /**
892   * Constructor
893   */
894    public EpisodeOfCare(Enumeration<EpisodeOfCareStatus> status, Reference patient) {
895      super();
896      this.status = status;
897      this.patient = patient;
898    }
899
900    /**
901     * @return {@link #identifier} (The EpisodeOfCare may be known by different identifiers for different contexts of use, such as when an external agency is tracking the Episode for funding purposes.)
902     */
903    public List<Identifier> getIdentifier() { 
904      if (this.identifier == null)
905        this.identifier = new ArrayList<Identifier>();
906      return this.identifier;
907    }
908
909    /**
910     * @return Returns a reference to <code>this</code> for easy method chaining
911     */
912    public EpisodeOfCare setIdentifier(List<Identifier> theIdentifier) { 
913      this.identifier = theIdentifier;
914      return this;
915    }
916
917    public boolean hasIdentifier() { 
918      if (this.identifier == null)
919        return false;
920      for (Identifier item : this.identifier)
921        if (!item.isEmpty())
922          return true;
923      return false;
924    }
925
926    public Identifier addIdentifier() { //3
927      Identifier t = new Identifier();
928      if (this.identifier == null)
929        this.identifier = new ArrayList<Identifier>();
930      this.identifier.add(t);
931      return t;
932    }
933
934    public EpisodeOfCare addIdentifier(Identifier t) { //3
935      if (t == null)
936        return this;
937      if (this.identifier == null)
938        this.identifier = new ArrayList<Identifier>();
939      this.identifier.add(t);
940      return this;
941    }
942
943    /**
944     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
945     */
946    public Identifier getIdentifierFirstRep() { 
947      if (getIdentifier().isEmpty()) {
948        addIdentifier();
949      }
950      return getIdentifier().get(0);
951    }
952
953    /**
954     * @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
955     */
956    public Enumeration<EpisodeOfCareStatus> getStatusElement() { 
957      if (this.status == null)
958        if (Configuration.errorOnAutoCreate())
959          throw new Error("Attempt to auto-create EpisodeOfCare.status");
960        else if (Configuration.doAutoCreate())
961          this.status = new Enumeration<EpisodeOfCareStatus>(new EpisodeOfCareStatusEnumFactory()); // bb
962      return this.status;
963    }
964
965    public boolean hasStatusElement() { 
966      return this.status != null && !this.status.isEmpty();
967    }
968
969    public boolean hasStatus() { 
970      return this.status != null && !this.status.isEmpty();
971    }
972
973    /**
974     * @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
975     */
976    public EpisodeOfCare setStatusElement(Enumeration<EpisodeOfCareStatus> value) { 
977      this.status = value;
978      return this;
979    }
980
981    /**
982     * @return planned | waitlist | active | onhold | finished | cancelled.
983     */
984    public EpisodeOfCareStatus getStatus() { 
985      return this.status == null ? null : this.status.getValue();
986    }
987
988    /**
989     * @param value planned | waitlist | active | onhold | finished | cancelled.
990     */
991    public EpisodeOfCare setStatus(EpisodeOfCareStatus value) { 
992        if (this.status == null)
993          this.status = new Enumeration<EpisodeOfCareStatus>(new EpisodeOfCareStatusEnumFactory());
994        this.status.setValue(value);
995      return this;
996    }
997
998    /**
999     * @return {@link #statusHistory} (The history of statuses that the EpisodeOfCare has been through (without requiring processing the history of the resource).)
1000     */
1001    public List<EpisodeOfCareStatusHistoryComponent> getStatusHistory() { 
1002      if (this.statusHistory == null)
1003        this.statusHistory = new ArrayList<EpisodeOfCareStatusHistoryComponent>();
1004      return this.statusHistory;
1005    }
1006
1007    /**
1008     * @return Returns a reference to <code>this</code> for easy method chaining
1009     */
1010    public EpisodeOfCare setStatusHistory(List<EpisodeOfCareStatusHistoryComponent> theStatusHistory) { 
1011      this.statusHistory = theStatusHistory;
1012      return this;
1013    }
1014
1015    public boolean hasStatusHistory() { 
1016      if (this.statusHistory == null)
1017        return false;
1018      for (EpisodeOfCareStatusHistoryComponent item : this.statusHistory)
1019        if (!item.isEmpty())
1020          return true;
1021      return false;
1022    }
1023
1024    public EpisodeOfCareStatusHistoryComponent addStatusHistory() { //3
1025      EpisodeOfCareStatusHistoryComponent t = new EpisodeOfCareStatusHistoryComponent();
1026      if (this.statusHistory == null)
1027        this.statusHistory = new ArrayList<EpisodeOfCareStatusHistoryComponent>();
1028      this.statusHistory.add(t);
1029      return t;
1030    }
1031
1032    public EpisodeOfCare addStatusHistory(EpisodeOfCareStatusHistoryComponent t) { //3
1033      if (t == null)
1034        return this;
1035      if (this.statusHistory == null)
1036        this.statusHistory = new ArrayList<EpisodeOfCareStatusHistoryComponent>();
1037      this.statusHistory.add(t);
1038      return this;
1039    }
1040
1041    /**
1042     * @return The first repetition of repeating field {@link #statusHistory}, creating it if it does not already exist
1043     */
1044    public EpisodeOfCareStatusHistoryComponent getStatusHistoryFirstRep() { 
1045      if (getStatusHistory().isEmpty()) {
1046        addStatusHistory();
1047      }
1048      return getStatusHistory().get(0);
1049    }
1050
1051    /**
1052     * @return {@link #type} (A classification of the type of episode of care; e.g. specialist referral, disease management, type of funded care.)
1053     */
1054    public List<CodeableConcept> getType() { 
1055      if (this.type == null)
1056        this.type = new ArrayList<CodeableConcept>();
1057      return this.type;
1058    }
1059
1060    /**
1061     * @return Returns a reference to <code>this</code> for easy method chaining
1062     */
1063    public EpisodeOfCare setType(List<CodeableConcept> theType) { 
1064      this.type = theType;
1065      return this;
1066    }
1067
1068    public boolean hasType() { 
1069      if (this.type == null)
1070        return false;
1071      for (CodeableConcept item : this.type)
1072        if (!item.isEmpty())
1073          return true;
1074      return false;
1075    }
1076
1077    public CodeableConcept addType() { //3
1078      CodeableConcept t = new CodeableConcept();
1079      if (this.type == null)
1080        this.type = new ArrayList<CodeableConcept>();
1081      this.type.add(t);
1082      return t;
1083    }
1084
1085    public EpisodeOfCare addType(CodeableConcept t) { //3
1086      if (t == null)
1087        return this;
1088      if (this.type == null)
1089        this.type = new ArrayList<CodeableConcept>();
1090      this.type.add(t);
1091      return this;
1092    }
1093
1094    /**
1095     * @return The first repetition of repeating field {@link #type}, creating it if it does not already exist
1096     */
1097    public CodeableConcept getTypeFirstRep() { 
1098      if (getType().isEmpty()) {
1099        addType();
1100      }
1101      return getType().get(0);
1102    }
1103
1104    /**
1105     * @return {@link #diagnosis} (The list of diagnosis relevant to this episode of care.)
1106     */
1107    public List<DiagnosisComponent> getDiagnosis() { 
1108      if (this.diagnosis == null)
1109        this.diagnosis = new ArrayList<DiagnosisComponent>();
1110      return this.diagnosis;
1111    }
1112
1113    /**
1114     * @return Returns a reference to <code>this</code> for easy method chaining
1115     */
1116    public EpisodeOfCare setDiagnosis(List<DiagnosisComponent> theDiagnosis) { 
1117      this.diagnosis = theDiagnosis;
1118      return this;
1119    }
1120
1121    public boolean hasDiagnosis() { 
1122      if (this.diagnosis == null)
1123        return false;
1124      for (DiagnosisComponent item : this.diagnosis)
1125        if (!item.isEmpty())
1126          return true;
1127      return false;
1128    }
1129
1130    public DiagnosisComponent addDiagnosis() { //3
1131      DiagnosisComponent t = new DiagnosisComponent();
1132      if (this.diagnosis == null)
1133        this.diagnosis = new ArrayList<DiagnosisComponent>();
1134      this.diagnosis.add(t);
1135      return t;
1136    }
1137
1138    public EpisodeOfCare addDiagnosis(DiagnosisComponent t) { //3
1139      if (t == null)
1140        return this;
1141      if (this.diagnosis == null)
1142        this.diagnosis = new ArrayList<DiagnosisComponent>();
1143      this.diagnosis.add(t);
1144      return this;
1145    }
1146
1147    /**
1148     * @return The first repetition of repeating field {@link #diagnosis}, creating it if it does not already exist
1149     */
1150    public DiagnosisComponent getDiagnosisFirstRep() { 
1151      if (getDiagnosis().isEmpty()) {
1152        addDiagnosis();
1153      }
1154      return getDiagnosis().get(0);
1155    }
1156
1157    /**
1158     * @return {@link #patient} (The patient who is the focus of this episode of care.)
1159     */
1160    public Reference getPatient() { 
1161      if (this.patient == null)
1162        if (Configuration.errorOnAutoCreate())
1163          throw new Error("Attempt to auto-create EpisodeOfCare.patient");
1164        else if (Configuration.doAutoCreate())
1165          this.patient = new Reference(); // cc
1166      return this.patient;
1167    }
1168
1169    public boolean hasPatient() { 
1170      return this.patient != null && !this.patient.isEmpty();
1171    }
1172
1173    /**
1174     * @param value {@link #patient} (The patient who is the focus of this episode of care.)
1175     */
1176    public EpisodeOfCare setPatient(Reference value) { 
1177      this.patient = value;
1178      return this;
1179    }
1180
1181    /**
1182     * @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 who is the focus of this episode of care.)
1183     */
1184    public Patient getPatientTarget() { 
1185      if (this.patientTarget == null)
1186        if (Configuration.errorOnAutoCreate())
1187          throw new Error("Attempt to auto-create EpisodeOfCare.patient");
1188        else if (Configuration.doAutoCreate())
1189          this.patientTarget = new Patient(); // aa
1190      return this.patientTarget;
1191    }
1192
1193    /**
1194     * @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 who is the focus of this episode of care.)
1195     */
1196    public EpisodeOfCare setPatientTarget(Patient value) { 
1197      this.patientTarget = value;
1198      return this;
1199    }
1200
1201    /**
1202     * @return {@link #managingOrganization} (The organization that has assumed the specific responsibilities for the specified duration.)
1203     */
1204    public Reference getManagingOrganization() { 
1205      if (this.managingOrganization == null)
1206        if (Configuration.errorOnAutoCreate())
1207          throw new Error("Attempt to auto-create EpisodeOfCare.managingOrganization");
1208        else if (Configuration.doAutoCreate())
1209          this.managingOrganization = new Reference(); // cc
1210      return this.managingOrganization;
1211    }
1212
1213    public boolean hasManagingOrganization() { 
1214      return this.managingOrganization != null && !this.managingOrganization.isEmpty();
1215    }
1216
1217    /**
1218     * @param value {@link #managingOrganization} (The organization that has assumed the specific responsibilities for the specified duration.)
1219     */
1220    public EpisodeOfCare setManagingOrganization(Reference value) { 
1221      this.managingOrganization = value;
1222      return this;
1223    }
1224
1225    /**
1226     * @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.)
1227     */
1228    public Organization getManagingOrganizationTarget() { 
1229      if (this.managingOrganizationTarget == null)
1230        if (Configuration.errorOnAutoCreate())
1231          throw new Error("Attempt to auto-create EpisodeOfCare.managingOrganization");
1232        else if (Configuration.doAutoCreate())
1233          this.managingOrganizationTarget = new Organization(); // aa
1234      return this.managingOrganizationTarget;
1235    }
1236
1237    /**
1238     * @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.)
1239     */
1240    public EpisodeOfCare setManagingOrganizationTarget(Organization value) { 
1241      this.managingOrganizationTarget = value;
1242      return this;
1243    }
1244
1245    /**
1246     * @return {@link #period} (The interval during which the managing organization assumes the defined responsibility.)
1247     */
1248    public Period getPeriod() { 
1249      if (this.period == null)
1250        if (Configuration.errorOnAutoCreate())
1251          throw new Error("Attempt to auto-create EpisodeOfCare.period");
1252        else if (Configuration.doAutoCreate())
1253          this.period = new Period(); // cc
1254      return this.period;
1255    }
1256
1257    public boolean hasPeriod() { 
1258      return this.period != null && !this.period.isEmpty();
1259    }
1260
1261    /**
1262     * @param value {@link #period} (The interval during which the managing organization assumes the defined responsibility.)
1263     */
1264    public EpisodeOfCare setPeriod(Period value) { 
1265      this.period = value;
1266      return this;
1267    }
1268
1269    /**
1270     * @return {@link #referralRequest} (Referral Request(s) that are fulfilled by this EpisodeOfCare, incoming referrals.)
1271     */
1272    public List<Reference> getReferralRequest() { 
1273      if (this.referralRequest == null)
1274        this.referralRequest = new ArrayList<Reference>();
1275      return this.referralRequest;
1276    }
1277
1278    /**
1279     * @return Returns a reference to <code>this</code> for easy method chaining
1280     */
1281    public EpisodeOfCare setReferralRequest(List<Reference> theReferralRequest) { 
1282      this.referralRequest = theReferralRequest;
1283      return this;
1284    }
1285
1286    public boolean hasReferralRequest() { 
1287      if (this.referralRequest == null)
1288        return false;
1289      for (Reference item : this.referralRequest)
1290        if (!item.isEmpty())
1291          return true;
1292      return false;
1293    }
1294
1295    public Reference addReferralRequest() { //3
1296      Reference t = new Reference();
1297      if (this.referralRequest == null)
1298        this.referralRequest = new ArrayList<Reference>();
1299      this.referralRequest.add(t);
1300      return t;
1301    }
1302
1303    public EpisodeOfCare addReferralRequest(Reference t) { //3
1304      if (t == null)
1305        return this;
1306      if (this.referralRequest == null)
1307        this.referralRequest = new ArrayList<Reference>();
1308      this.referralRequest.add(t);
1309      return this;
1310    }
1311
1312    /**
1313     * @return The first repetition of repeating field {@link #referralRequest}, creating it if it does not already exist
1314     */
1315    public Reference getReferralRequestFirstRep() { 
1316      if (getReferralRequest().isEmpty()) {
1317        addReferralRequest();
1318      }
1319      return getReferralRequest().get(0);
1320    }
1321
1322    /**
1323     * @deprecated Use Reference#setResource(IBaseResource) instead
1324     */
1325    @Deprecated
1326    public List<ServiceRequest> getReferralRequestTarget() { 
1327      if (this.referralRequestTarget == null)
1328        this.referralRequestTarget = new ArrayList<ServiceRequest>();
1329      return this.referralRequestTarget;
1330    }
1331
1332    /**
1333     * @deprecated Use Reference#setResource(IBaseResource) instead
1334     */
1335    @Deprecated
1336    public ServiceRequest addReferralRequestTarget() { 
1337      ServiceRequest r = new ServiceRequest();
1338      if (this.referralRequestTarget == null)
1339        this.referralRequestTarget = new ArrayList<ServiceRequest>();
1340      this.referralRequestTarget.add(r);
1341      return r;
1342    }
1343
1344    /**
1345     * @return {@link #careManager} (The practitioner that is the care manager/care coordinator for this patient.)
1346     */
1347    public Reference getCareManager() { 
1348      if (this.careManager == null)
1349        if (Configuration.errorOnAutoCreate())
1350          throw new Error("Attempt to auto-create EpisodeOfCare.careManager");
1351        else if (Configuration.doAutoCreate())
1352          this.careManager = new Reference(); // cc
1353      return this.careManager;
1354    }
1355
1356    public boolean hasCareManager() { 
1357      return this.careManager != null && !this.careManager.isEmpty();
1358    }
1359
1360    /**
1361     * @param value {@link #careManager} (The practitioner that is the care manager/care coordinator for this patient.)
1362     */
1363    public EpisodeOfCare setCareManager(Reference value) { 
1364      this.careManager = value;
1365      return this;
1366    }
1367
1368    /**
1369     * @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 coordinator for this patient.)
1370     */
1371    public Resource getCareManagerTarget() { 
1372      return this.careManagerTarget;
1373    }
1374
1375    /**
1376     * @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 coordinator for this patient.)
1377     */
1378    public EpisodeOfCare setCareManagerTarget(Resource value) { 
1379      this.careManagerTarget = value;
1380      return this;
1381    }
1382
1383    /**
1384     * @return {@link #team} (The list of practitioners that may be facilitating this episode of care for specific purposes.)
1385     */
1386    public List<Reference> getTeam() { 
1387      if (this.team == null)
1388        this.team = new ArrayList<Reference>();
1389      return this.team;
1390    }
1391
1392    /**
1393     * @return Returns a reference to <code>this</code> for easy method chaining
1394     */
1395    public EpisodeOfCare setTeam(List<Reference> theTeam) { 
1396      this.team = theTeam;
1397      return this;
1398    }
1399
1400    public boolean hasTeam() { 
1401      if (this.team == null)
1402        return false;
1403      for (Reference item : this.team)
1404        if (!item.isEmpty())
1405          return true;
1406      return false;
1407    }
1408
1409    public Reference addTeam() { //3
1410      Reference t = new Reference();
1411      if (this.team == null)
1412        this.team = new ArrayList<Reference>();
1413      this.team.add(t);
1414      return t;
1415    }
1416
1417    public EpisodeOfCare addTeam(Reference t) { //3
1418      if (t == null)
1419        return this;
1420      if (this.team == null)
1421        this.team = new ArrayList<Reference>();
1422      this.team.add(t);
1423      return this;
1424    }
1425
1426    /**
1427     * @return The first repetition of repeating field {@link #team}, creating it if it does not already exist
1428     */
1429    public Reference getTeamFirstRep() { 
1430      if (getTeam().isEmpty()) {
1431        addTeam();
1432      }
1433      return getTeam().get(0);
1434    }
1435
1436    /**
1437     * @deprecated Use Reference#setResource(IBaseResource) instead
1438     */
1439    @Deprecated
1440    public List<CareTeam> getTeamTarget() { 
1441      if (this.teamTarget == null)
1442        this.teamTarget = new ArrayList<CareTeam>();
1443      return this.teamTarget;
1444    }
1445
1446    /**
1447     * @deprecated Use Reference#setResource(IBaseResource) instead
1448     */
1449    @Deprecated
1450    public CareTeam addTeamTarget() { 
1451      CareTeam r = new CareTeam();
1452      if (this.teamTarget == null)
1453        this.teamTarget = new ArrayList<CareTeam>();
1454      this.teamTarget.add(r);
1455      return r;
1456    }
1457
1458    /**
1459     * @return {@link #account} (The set of accounts that may be used for billing for this EpisodeOfCare.)
1460     */
1461    public List<Reference> getAccount() { 
1462      if (this.account == null)
1463        this.account = new ArrayList<Reference>();
1464      return this.account;
1465    }
1466
1467    /**
1468     * @return Returns a reference to <code>this</code> for easy method chaining
1469     */
1470    public EpisodeOfCare setAccount(List<Reference> theAccount) { 
1471      this.account = theAccount;
1472      return this;
1473    }
1474
1475    public boolean hasAccount() { 
1476      if (this.account == null)
1477        return false;
1478      for (Reference item : this.account)
1479        if (!item.isEmpty())
1480          return true;
1481      return false;
1482    }
1483
1484    public Reference addAccount() { //3
1485      Reference t = new Reference();
1486      if (this.account == null)
1487        this.account = new ArrayList<Reference>();
1488      this.account.add(t);
1489      return t;
1490    }
1491
1492    public EpisodeOfCare addAccount(Reference t) { //3
1493      if (t == null)
1494        return this;
1495      if (this.account == null)
1496        this.account = new ArrayList<Reference>();
1497      this.account.add(t);
1498      return this;
1499    }
1500
1501    /**
1502     * @return The first repetition of repeating field {@link #account}, creating it if it does not already exist
1503     */
1504    public Reference getAccountFirstRep() { 
1505      if (getAccount().isEmpty()) {
1506        addAccount();
1507      }
1508      return getAccount().get(0);
1509    }
1510
1511    /**
1512     * @deprecated Use Reference#setResource(IBaseResource) instead
1513     */
1514    @Deprecated
1515    public List<Account> getAccountTarget() { 
1516      if (this.accountTarget == null)
1517        this.accountTarget = new ArrayList<Account>();
1518      return this.accountTarget;
1519    }
1520
1521    /**
1522     * @deprecated Use Reference#setResource(IBaseResource) instead
1523     */
1524    @Deprecated
1525    public Account addAccountTarget() { 
1526      Account r = new Account();
1527      if (this.accountTarget == null)
1528        this.accountTarget = new ArrayList<Account>();
1529      this.accountTarget.add(r);
1530      return r;
1531    }
1532
1533      protected void listChildren(List<Property> children) {
1534        super.listChildren(children);
1535        children.add(new Property("identifier", "Identifier", "The EpisodeOfCare may be known by different identifiers for different contexts of use, such as when an external agency is tracking the Episode for funding purposes.", 0, java.lang.Integer.MAX_VALUE, identifier));
1536        children.add(new Property("status", "code", "planned | waitlist | active | onhold | finished | cancelled.", 0, 1, status));
1537        children.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));
1538        children.add(new Property("type", "CodeableConcept", "A classification of the type of episode of care; e.g. specialist referral, disease management, type of funded care.", 0, java.lang.Integer.MAX_VALUE, type));
1539        children.add(new Property("diagnosis", "", "The list of diagnosis relevant to this episode of care.", 0, java.lang.Integer.MAX_VALUE, diagnosis));
1540        children.add(new Property("patient", "Reference(Patient)", "The patient who is the focus of this episode of care.", 0, 1, patient));
1541        children.add(new Property("managingOrganization", "Reference(Organization)", "The organization that has assumed the specific responsibilities for the specified duration.", 0, 1, managingOrganization));
1542        children.add(new Property("period", "Period", "The interval during which the managing organization assumes the defined responsibility.", 0, 1, period));
1543        children.add(new Property("referralRequest", "Reference(ServiceRequest)", "Referral Request(s) that are fulfilled by this EpisodeOfCare, incoming referrals.", 0, java.lang.Integer.MAX_VALUE, referralRequest));
1544        children.add(new Property("careManager", "Reference(Practitioner|PractitionerRole)", "The practitioner that is the care manager/care coordinator for this patient.", 0, 1, careManager));
1545        children.add(new Property("team", "Reference(CareTeam)", "The list of practitioners that may be facilitating this episode of care for specific purposes.", 0, java.lang.Integer.MAX_VALUE, team));
1546        children.add(new Property("account", "Reference(Account)", "The set of accounts that may be used for billing for this EpisodeOfCare.", 0, java.lang.Integer.MAX_VALUE, account));
1547      }
1548
1549      @Override
1550      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1551        switch (_hash) {
1552        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "The EpisodeOfCare may be known by different identifiers for different contexts of use, such as when an external agency is tracking the Episode for funding purposes.", 0, java.lang.Integer.MAX_VALUE, identifier);
1553        case -892481550: /*status*/  return new Property("status", "code", "planned | waitlist | active | onhold | finished | cancelled.", 0, 1, status);
1554        case -986695614: /*statusHistory*/  return 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);
1555        case 3575610: /*type*/  return new Property("type", "CodeableConcept", "A classification of the type of episode of care; e.g. specialist referral, disease management, type of funded care.", 0, java.lang.Integer.MAX_VALUE, type);
1556        case 1196993265: /*diagnosis*/  return new Property("diagnosis", "", "The list of diagnosis relevant to this episode of care.", 0, java.lang.Integer.MAX_VALUE, diagnosis);
1557        case -791418107: /*patient*/  return new Property("patient", "Reference(Patient)", "The patient who is the focus of this episode of care.", 0, 1, patient);
1558        case -2058947787: /*managingOrganization*/  return new Property("managingOrganization", "Reference(Organization)", "The organization that has assumed the specific responsibilities for the specified duration.", 0, 1, managingOrganization);
1559        case -991726143: /*period*/  return new Property("period", "Period", "The interval during which the managing organization assumes the defined responsibility.", 0, 1, period);
1560        case -310299598: /*referralRequest*/  return new Property("referralRequest", "Reference(ServiceRequest)", "Referral Request(s) that are fulfilled by this EpisodeOfCare, incoming referrals.", 0, java.lang.Integer.MAX_VALUE, referralRequest);
1561        case -1147746468: /*careManager*/  return new Property("careManager", "Reference(Practitioner|PractitionerRole)", "The practitioner that is the care manager/care coordinator for this patient.", 0, 1, careManager);
1562        case 3555933: /*team*/  return new Property("team", "Reference(CareTeam)", "The list of practitioners that may be facilitating this episode of care for specific purposes.", 0, java.lang.Integer.MAX_VALUE, team);
1563        case -1177318867: /*account*/  return new Property("account", "Reference(Account)", "The set of accounts that may be used for billing for this EpisodeOfCare.", 0, java.lang.Integer.MAX_VALUE, account);
1564        default: return super.getNamedProperty(_hash, _name, _checkValid);
1565        }
1566
1567      }
1568
1569      @Override
1570      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1571        switch (hash) {
1572        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1573        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<EpisodeOfCareStatus>
1574        case -986695614: /*statusHistory*/ return this.statusHistory == null ? new Base[0] : this.statusHistory.toArray(new Base[this.statusHistory.size()]); // EpisodeOfCareStatusHistoryComponent
1575        case 3575610: /*type*/ return this.type == null ? new Base[0] : this.type.toArray(new Base[this.type.size()]); // CodeableConcept
1576        case 1196993265: /*diagnosis*/ return this.diagnosis == null ? new Base[0] : this.diagnosis.toArray(new Base[this.diagnosis.size()]); // DiagnosisComponent
1577        case -791418107: /*patient*/ return this.patient == null ? new Base[0] : new Base[] {this.patient}; // Reference
1578        case -2058947787: /*managingOrganization*/ return this.managingOrganization == null ? new Base[0] : new Base[] {this.managingOrganization}; // Reference
1579        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
1580        case -310299598: /*referralRequest*/ return this.referralRequest == null ? new Base[0] : this.referralRequest.toArray(new Base[this.referralRequest.size()]); // Reference
1581        case -1147746468: /*careManager*/ return this.careManager == null ? new Base[0] : new Base[] {this.careManager}; // Reference
1582        case 3555933: /*team*/ return this.team == null ? new Base[0] : this.team.toArray(new Base[this.team.size()]); // Reference
1583        case -1177318867: /*account*/ return this.account == null ? new Base[0] : this.account.toArray(new Base[this.account.size()]); // Reference
1584        default: return super.getProperty(hash, name, checkValid);
1585        }
1586
1587      }
1588
1589      @Override
1590      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1591        switch (hash) {
1592        case -1618432855: // identifier
1593          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1594          return value;
1595        case -892481550: // status
1596          value = new EpisodeOfCareStatusEnumFactory().fromType(castToCode(value));
1597          this.status = (Enumeration) value; // Enumeration<EpisodeOfCareStatus>
1598          return value;
1599        case -986695614: // statusHistory
1600          this.getStatusHistory().add((EpisodeOfCareStatusHistoryComponent) value); // EpisodeOfCareStatusHistoryComponent
1601          return value;
1602        case 3575610: // type
1603          this.getType().add(castToCodeableConcept(value)); // CodeableConcept
1604          return value;
1605        case 1196993265: // diagnosis
1606          this.getDiagnosis().add((DiagnosisComponent) value); // DiagnosisComponent
1607          return value;
1608        case -791418107: // patient
1609          this.patient = castToReference(value); // Reference
1610          return value;
1611        case -2058947787: // managingOrganization
1612          this.managingOrganization = castToReference(value); // Reference
1613          return value;
1614        case -991726143: // period
1615          this.period = castToPeriod(value); // Period
1616          return value;
1617        case -310299598: // referralRequest
1618          this.getReferralRequest().add(castToReference(value)); // Reference
1619          return value;
1620        case -1147746468: // careManager
1621          this.careManager = castToReference(value); // Reference
1622          return value;
1623        case 3555933: // team
1624          this.getTeam().add(castToReference(value)); // Reference
1625          return value;
1626        case -1177318867: // account
1627          this.getAccount().add(castToReference(value)); // Reference
1628          return value;
1629        default: return super.setProperty(hash, name, value);
1630        }
1631
1632      }
1633
1634      @Override
1635      public Base setProperty(String name, Base value) throws FHIRException {
1636        if (name.equals("identifier")) {
1637          this.getIdentifier().add(castToIdentifier(value));
1638        } else if (name.equals("status")) {
1639          value = new EpisodeOfCareStatusEnumFactory().fromType(castToCode(value));
1640          this.status = (Enumeration) value; // Enumeration<EpisodeOfCareStatus>
1641        } else if (name.equals("statusHistory")) {
1642          this.getStatusHistory().add((EpisodeOfCareStatusHistoryComponent) value);
1643        } else if (name.equals("type")) {
1644          this.getType().add(castToCodeableConcept(value));
1645        } else if (name.equals("diagnosis")) {
1646          this.getDiagnosis().add((DiagnosisComponent) value);
1647        } else if (name.equals("patient")) {
1648          this.patient = castToReference(value); // Reference
1649        } else if (name.equals("managingOrganization")) {
1650          this.managingOrganization = castToReference(value); // Reference
1651        } else if (name.equals("period")) {
1652          this.period = castToPeriod(value); // Period
1653        } else if (name.equals("referralRequest")) {
1654          this.getReferralRequest().add(castToReference(value));
1655        } else if (name.equals("careManager")) {
1656          this.careManager = castToReference(value); // Reference
1657        } else if (name.equals("team")) {
1658          this.getTeam().add(castToReference(value));
1659        } else if (name.equals("account")) {
1660          this.getAccount().add(castToReference(value));
1661        } else
1662          return super.setProperty(name, value);
1663        return value;
1664      }
1665
1666      @Override
1667      public Base makeProperty(int hash, String name) throws FHIRException {
1668        switch (hash) {
1669        case -1618432855:  return addIdentifier(); 
1670        case -892481550:  return getStatusElement();
1671        case -986695614:  return addStatusHistory(); 
1672        case 3575610:  return addType(); 
1673        case 1196993265:  return addDiagnosis(); 
1674        case -791418107:  return getPatient(); 
1675        case -2058947787:  return getManagingOrganization(); 
1676        case -991726143:  return getPeriod(); 
1677        case -310299598:  return addReferralRequest(); 
1678        case -1147746468:  return getCareManager(); 
1679        case 3555933:  return addTeam(); 
1680        case -1177318867:  return addAccount(); 
1681        default: return super.makeProperty(hash, name);
1682        }
1683
1684      }
1685
1686      @Override
1687      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1688        switch (hash) {
1689        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
1690        case -892481550: /*status*/ return new String[] {"code"};
1691        case -986695614: /*statusHistory*/ return new String[] {};
1692        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
1693        case 1196993265: /*diagnosis*/ return new String[] {};
1694        case -791418107: /*patient*/ return new String[] {"Reference"};
1695        case -2058947787: /*managingOrganization*/ return new String[] {"Reference"};
1696        case -991726143: /*period*/ return new String[] {"Period"};
1697        case -310299598: /*referralRequest*/ return new String[] {"Reference"};
1698        case -1147746468: /*careManager*/ return new String[] {"Reference"};
1699        case 3555933: /*team*/ return new String[] {"Reference"};
1700        case -1177318867: /*account*/ return new String[] {"Reference"};
1701        default: return super.getTypesForProperty(hash, name);
1702        }
1703
1704      }
1705
1706      @Override
1707      public Base addChild(String name) throws FHIRException {
1708        if (name.equals("identifier")) {
1709          return addIdentifier();
1710        }
1711        else if (name.equals("status")) {
1712          throw new FHIRException("Cannot call addChild on a primitive type EpisodeOfCare.status");
1713        }
1714        else if (name.equals("statusHistory")) {
1715          return addStatusHistory();
1716        }
1717        else if (name.equals("type")) {
1718          return addType();
1719        }
1720        else if (name.equals("diagnosis")) {
1721          return addDiagnosis();
1722        }
1723        else if (name.equals("patient")) {
1724          this.patient = new Reference();
1725          return this.patient;
1726        }
1727        else if (name.equals("managingOrganization")) {
1728          this.managingOrganization = new Reference();
1729          return this.managingOrganization;
1730        }
1731        else if (name.equals("period")) {
1732          this.period = new Period();
1733          return this.period;
1734        }
1735        else if (name.equals("referralRequest")) {
1736          return addReferralRequest();
1737        }
1738        else if (name.equals("careManager")) {
1739          this.careManager = new Reference();
1740          return this.careManager;
1741        }
1742        else if (name.equals("team")) {
1743          return addTeam();
1744        }
1745        else if (name.equals("account")) {
1746          return addAccount();
1747        }
1748        else
1749          return super.addChild(name);
1750      }
1751
1752  public String fhirType() {
1753    return "EpisodeOfCare";
1754
1755  }
1756
1757      public EpisodeOfCare copy() {
1758        EpisodeOfCare dst = new EpisodeOfCare();
1759        copyValues(dst);
1760        return dst;
1761      }
1762
1763      public void copyValues(EpisodeOfCare dst) {
1764        super.copyValues(dst);
1765        if (identifier != null) {
1766          dst.identifier = new ArrayList<Identifier>();
1767          for (Identifier i : identifier)
1768            dst.identifier.add(i.copy());
1769        };
1770        dst.status = status == null ? null : status.copy();
1771        if (statusHistory != null) {
1772          dst.statusHistory = new ArrayList<EpisodeOfCareStatusHistoryComponent>();
1773          for (EpisodeOfCareStatusHistoryComponent i : statusHistory)
1774            dst.statusHistory.add(i.copy());
1775        };
1776        if (type != null) {
1777          dst.type = new ArrayList<CodeableConcept>();
1778          for (CodeableConcept i : type)
1779            dst.type.add(i.copy());
1780        };
1781        if (diagnosis != null) {
1782          dst.diagnosis = new ArrayList<DiagnosisComponent>();
1783          for (DiagnosisComponent i : diagnosis)
1784            dst.diagnosis.add(i.copy());
1785        };
1786        dst.patient = patient == null ? null : patient.copy();
1787        dst.managingOrganization = managingOrganization == null ? null : managingOrganization.copy();
1788        dst.period = period == null ? null : period.copy();
1789        if (referralRequest != null) {
1790          dst.referralRequest = new ArrayList<Reference>();
1791          for (Reference i : referralRequest)
1792            dst.referralRequest.add(i.copy());
1793        };
1794        dst.careManager = careManager == null ? null : careManager.copy();
1795        if (team != null) {
1796          dst.team = new ArrayList<Reference>();
1797          for (Reference i : team)
1798            dst.team.add(i.copy());
1799        };
1800        if (account != null) {
1801          dst.account = new ArrayList<Reference>();
1802          for (Reference i : account)
1803            dst.account.add(i.copy());
1804        };
1805      }
1806
1807      protected EpisodeOfCare typedCopy() {
1808        return copy();
1809      }
1810
1811      @Override
1812      public boolean equalsDeep(Base other_) {
1813        if (!super.equalsDeep(other_))
1814          return false;
1815        if (!(other_ instanceof EpisodeOfCare))
1816          return false;
1817        EpisodeOfCare o = (EpisodeOfCare) other_;
1818        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(statusHistory, o.statusHistory, true)
1819           && compareDeep(type, o.type, true) && compareDeep(diagnosis, o.diagnosis, true) && compareDeep(patient, o.patient, true)
1820           && compareDeep(managingOrganization, o.managingOrganization, true) && compareDeep(period, o.period, true)
1821           && compareDeep(referralRequest, o.referralRequest, true) && compareDeep(careManager, o.careManager, true)
1822           && compareDeep(team, o.team, true) && compareDeep(account, o.account, true);
1823      }
1824
1825      @Override
1826      public boolean equalsShallow(Base other_) {
1827        if (!super.equalsShallow(other_))
1828          return false;
1829        if (!(other_ instanceof EpisodeOfCare))
1830          return false;
1831        EpisodeOfCare o = (EpisodeOfCare) other_;
1832        return compareValues(status, o.status, true);
1833      }
1834
1835      public boolean isEmpty() {
1836        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, statusHistory
1837          , type, diagnosis, patient, managingOrganization, period, referralRequest, careManager
1838          , team, account);
1839      }
1840
1841  @Override
1842  public ResourceType getResourceType() {
1843    return ResourceType.EpisodeOfCare;
1844   }
1845
1846 /**
1847   * Search parameter: <b>date</b>
1848   * <p>
1849   * Description: <b>The provided date search value falls within the episode of care's period</b><br>
1850   * Type: <b>date</b><br>
1851   * Path: <b>EpisodeOfCare.period</b><br>
1852   * </p>
1853   */
1854  @SearchParamDefinition(name="date", path="EpisodeOfCare.period", description="The provided date search value falls within the episode of care's period", type="date" )
1855  public static final String SP_DATE = "date";
1856 /**
1857   * <b>Fluent Client</b> search parameter constant for <b>date</b>
1858   * <p>
1859   * Description: <b>The provided date search value falls within the episode of care's period</b><br>
1860   * Type: <b>date</b><br>
1861   * Path: <b>EpisodeOfCare.period</b><br>
1862   * </p>
1863   */
1864  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
1865
1866 /**
1867   * Search parameter: <b>identifier</b>
1868   * <p>
1869   * Description: <b>Business Identifier(s) relevant for this EpisodeOfCare</b><br>
1870   * Type: <b>token</b><br>
1871   * Path: <b>EpisodeOfCare.identifier</b><br>
1872   * </p>
1873   */
1874  @SearchParamDefinition(name="identifier", path="EpisodeOfCare.identifier", description="Business Identifier(s) relevant for this EpisodeOfCare", type="token" )
1875  public static final String SP_IDENTIFIER = "identifier";
1876 /**
1877   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
1878   * <p>
1879   * Description: <b>Business Identifier(s) relevant for this EpisodeOfCare</b><br>
1880   * Type: <b>token</b><br>
1881   * Path: <b>EpisodeOfCare.identifier</b><br>
1882   * </p>
1883   */
1884  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
1885
1886 /**
1887   * Search parameter: <b>condition</b>
1888   * <p>
1889   * Description: <b>Conditions/problems/diagnoses this episode of care is for</b><br>
1890   * Type: <b>reference</b><br>
1891   * Path: <b>EpisodeOfCare.diagnosis.condition</b><br>
1892   * </p>
1893   */
1894  @SearchParamDefinition(name="condition", path="EpisodeOfCare.diagnosis.condition", description="Conditions/problems/diagnoses this episode of care is for", type="reference", target={Condition.class } )
1895  public static final String SP_CONDITION = "condition";
1896 /**
1897   * <b>Fluent Client</b> search parameter constant for <b>condition</b>
1898   * <p>
1899   * Description: <b>Conditions/problems/diagnoses this episode of care is for</b><br>
1900   * Type: <b>reference</b><br>
1901   * Path: <b>EpisodeOfCare.diagnosis.condition</b><br>
1902   * </p>
1903   */
1904  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam CONDITION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_CONDITION);
1905
1906/**
1907   * Constant for fluent queries to be used to add include statements. Specifies
1908   * the path value of "<b>EpisodeOfCare:condition</b>".
1909   */
1910  public static final ca.uhn.fhir.model.api.Include INCLUDE_CONDITION = new ca.uhn.fhir.model.api.Include("EpisodeOfCare:condition").toLocked();
1911
1912 /**
1913   * Search parameter: <b>patient</b>
1914   * <p>
1915   * Description: <b>The patient who is the focus of this episode of care</b><br>
1916   * Type: <b>reference</b><br>
1917   * Path: <b>EpisodeOfCare.patient</b><br>
1918   * </p>
1919   */
1920  @SearchParamDefinition(name="patient", path="EpisodeOfCare.patient", description="The patient who is the focus of this episode of care", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Patient.class } )
1921  public static final String SP_PATIENT = "patient";
1922 /**
1923   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
1924   * <p>
1925   * Description: <b>The patient who is the focus of this episode of care</b><br>
1926   * Type: <b>reference</b><br>
1927   * Path: <b>EpisodeOfCare.patient</b><br>
1928   * </p>
1929   */
1930  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
1931
1932/**
1933   * Constant for fluent queries to be used to add include statements. Specifies
1934   * the path value of "<b>EpisodeOfCare:patient</b>".
1935   */
1936  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("EpisodeOfCare:patient").toLocked();
1937
1938 /**
1939   * Search parameter: <b>organization</b>
1940   * <p>
1941   * Description: <b>The organization that has assumed the specific responsibilities of this EpisodeOfCare</b><br>
1942   * Type: <b>reference</b><br>
1943   * Path: <b>EpisodeOfCare.managingOrganization</b><br>
1944   * </p>
1945   */
1946  @SearchParamDefinition(name="organization", path="EpisodeOfCare.managingOrganization", description="The organization that has assumed the specific responsibilities of this EpisodeOfCare", type="reference", target={Organization.class } )
1947  public static final String SP_ORGANIZATION = "organization";
1948 /**
1949   * <b>Fluent Client</b> search parameter constant for <b>organization</b>
1950   * <p>
1951   * Description: <b>The organization that has assumed the specific responsibilities of this EpisodeOfCare</b><br>
1952   * Type: <b>reference</b><br>
1953   * Path: <b>EpisodeOfCare.managingOrganization</b><br>
1954   * </p>
1955   */
1956  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ORGANIZATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ORGANIZATION);
1957
1958/**
1959   * Constant for fluent queries to be used to add include statements. Specifies
1960   * the path value of "<b>EpisodeOfCare:organization</b>".
1961   */
1962  public static final ca.uhn.fhir.model.api.Include INCLUDE_ORGANIZATION = new ca.uhn.fhir.model.api.Include("EpisodeOfCare:organization").toLocked();
1963
1964 /**
1965   * Search parameter: <b>type</b>
1966   * <p>
1967   * Description: <b>Type/class  - e.g. specialist referral, disease management</b><br>
1968   * Type: <b>token</b><br>
1969   * Path: <b>EpisodeOfCare.type</b><br>
1970   * </p>
1971   */
1972  @SearchParamDefinition(name="type", path="EpisodeOfCare.type", description="Type/class  - e.g. specialist referral, disease management", type="token" )
1973  public static final String SP_TYPE = "type";
1974 /**
1975   * <b>Fluent Client</b> search parameter constant for <b>type</b>
1976   * <p>
1977   * Description: <b>Type/class  - e.g. specialist referral, disease management</b><br>
1978   * Type: <b>token</b><br>
1979   * Path: <b>EpisodeOfCare.type</b><br>
1980   * </p>
1981   */
1982  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_TYPE);
1983
1984 /**
1985   * Search parameter: <b>care-manager</b>
1986   * <p>
1987   * Description: <b>Care manager/care coordinator for the patient</b><br>
1988   * Type: <b>reference</b><br>
1989   * Path: <b>EpisodeOfCare.careManager</b><br>
1990   * </p>
1991   */
1992  @SearchParamDefinition(name="care-manager", path="EpisodeOfCare.careManager.where(resolve() is Practitioner)", description="Care manager/care coordinator for the patient", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner") }, target={Practitioner.class } )
1993  public static final String SP_CARE_MANAGER = "care-manager";
1994 /**
1995   * <b>Fluent Client</b> search parameter constant for <b>care-manager</b>
1996   * <p>
1997   * Description: <b>Care manager/care coordinator for the patient</b><br>
1998   * Type: <b>reference</b><br>
1999   * Path: <b>EpisodeOfCare.careManager</b><br>
2000   * </p>
2001   */
2002  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam CARE_MANAGER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_CARE_MANAGER);
2003
2004/**
2005   * Constant for fluent queries to be used to add include statements. Specifies
2006   * the path value of "<b>EpisodeOfCare:care-manager</b>".
2007   */
2008  public static final ca.uhn.fhir.model.api.Include INCLUDE_CARE_MANAGER = new ca.uhn.fhir.model.api.Include("EpisodeOfCare:care-manager").toLocked();
2009
2010 /**
2011   * Search parameter: <b>status</b>
2012   * <p>
2013   * Description: <b>The current status of the Episode of Care as provided (does not check the status history collection)</b><br>
2014   * Type: <b>token</b><br>
2015   * Path: <b>EpisodeOfCare.status</b><br>
2016   * </p>
2017   */
2018  @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" )
2019  public static final String SP_STATUS = "status";
2020 /**
2021   * <b>Fluent Client</b> search parameter constant for <b>status</b>
2022   * <p>
2023   * Description: <b>The current status of the Episode of Care as provided (does not check the status history collection)</b><br>
2024   * Type: <b>token</b><br>
2025   * Path: <b>EpisodeOfCare.status</b><br>
2026   * </p>
2027   */
2028  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
2029
2030 /**
2031   * Search parameter: <b>incoming-referral</b>
2032   * <p>
2033   * Description: <b>Incoming Referral Request</b><br>
2034   * Type: <b>reference</b><br>
2035   * Path: <b>EpisodeOfCare.referralRequest</b><br>
2036   * </p>
2037   */
2038  @SearchParamDefinition(name="incoming-referral", path="EpisodeOfCare.referralRequest", description="Incoming Referral Request", type="reference", target={ServiceRequest.class } )
2039  public static final String SP_INCOMING_REFERRAL = "incoming-referral";
2040 /**
2041   * <b>Fluent Client</b> search parameter constant for <b>incoming-referral</b>
2042   * <p>
2043   * Description: <b>Incoming Referral Request</b><br>
2044   * Type: <b>reference</b><br>
2045   * Path: <b>EpisodeOfCare.referralRequest</b><br>
2046   * </p>
2047   */
2048  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam INCOMING_REFERRAL = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_INCOMING_REFERRAL);
2049
2050/**
2051   * Constant for fluent queries to be used to add include statements. Specifies
2052   * the path value of "<b>EpisodeOfCare:incoming-referral</b>".
2053   */
2054  public static final ca.uhn.fhir.model.api.Include INCLUDE_INCOMING_REFERRAL = new ca.uhn.fhir.model.api.Include("EpisodeOfCare:incoming-referral").toLocked();
2055
2056
2057}