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