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