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