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