001package org.hl7.fhir.dstu3.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 Mon, Apr 17, 2017 17:38-0400 for FHIR v3.0.1
033
034import java.util.*;
035
036import org.hl7.fhir.utilities.Utilities;
037import org.hl7.fhir.dstu3.model.Enumerations.*;
038import ca.uhn.fhir.model.api.annotation.ResourceDef;
039import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
040import ca.uhn.fhir.model.api.annotation.Child;
041import ca.uhn.fhir.model.api.annotation.ChildOrder;
042import ca.uhn.fhir.model.api.annotation.Description;
043import ca.uhn.fhir.model.api.annotation.Block;
044import org.hl7.fhir.instance.model.api.*;
045import org.hl7.fhir.exceptions.FHIRException;
046/**
047 * An interaction between a patient and healthcare provider(s) for the purpose of providing healthcare service(s) or assessing the health status of a patient.
048 */
049@ResourceDef(name="Encounter", profile="http://hl7.org/fhir/Profile/Encounter")
050public class Encounter extends DomainResource {
051
052    public enum EncounterStatus {
053        /**
054         * The Encounter has not yet started.
055         */
056        PLANNED, 
057        /**
058         * The Patient is present for the encounter, however is not currently meeting with a practitioner.
059         */
060        ARRIVED, 
061        /**
062         * The patient has been assessed for the priority of their treatment based on the severity of their condition.
063         */
064        TRIAGED, 
065        /**
066         * The Encounter has begun and the patient is present / the practitioner and the patient are meeting.
067         */
068        INPROGRESS, 
069        /**
070         * The Encounter has begun, but the patient is temporarily on leave.
071         */
072        ONLEAVE, 
073        /**
074         * The Encounter has ended.
075         */
076        FINISHED, 
077        /**
078         * The Encounter has ended before it has begun.
079         */
080        CANCELLED, 
081        /**
082         * This instance should not have been part of this patient's medical record.
083         */
084        ENTEREDINERROR, 
085        /**
086         * The encounter status is unknown. Note that "unknown" is a value of last resort and every attempt should be made to provide a meaningful value other than "unknown".
087         */
088        UNKNOWN, 
089        /**
090         * added to help the parsers with the generic types
091         */
092        NULL;
093        public static EncounterStatus fromCode(String codeString) throws FHIRException {
094            if (codeString == null || "".equals(codeString))
095                return null;
096        if ("planned".equals(codeString))
097          return PLANNED;
098        if ("arrived".equals(codeString))
099          return ARRIVED;
100        if ("triaged".equals(codeString))
101          return TRIAGED;
102        if ("in-progress".equals(codeString))
103          return INPROGRESS;
104        if ("onleave".equals(codeString))
105          return ONLEAVE;
106        if ("finished".equals(codeString))
107          return FINISHED;
108        if ("cancelled".equals(codeString))
109          return CANCELLED;
110        if ("entered-in-error".equals(codeString))
111          return ENTEREDINERROR;
112        if ("unknown".equals(codeString))
113          return UNKNOWN;
114        if (Configuration.isAcceptInvalidEnums())
115          return null;
116        else
117          throw new FHIRException("Unknown EncounterStatus code '"+codeString+"'");
118        }
119        public String toCode() {
120          switch (this) {
121            case PLANNED: return "planned";
122            case ARRIVED: return "arrived";
123            case TRIAGED: return "triaged";
124            case INPROGRESS: return "in-progress";
125            case ONLEAVE: return "onleave";
126            case FINISHED: return "finished";
127            case CANCELLED: return "cancelled";
128            case ENTEREDINERROR: return "entered-in-error";
129            case UNKNOWN: return "unknown";
130            default: return "?";
131          }
132        }
133        public String getSystem() {
134          switch (this) {
135            case PLANNED: return "http://hl7.org/fhir/encounter-status";
136            case ARRIVED: return "http://hl7.org/fhir/encounter-status";
137            case TRIAGED: return "http://hl7.org/fhir/encounter-status";
138            case INPROGRESS: return "http://hl7.org/fhir/encounter-status";
139            case ONLEAVE: return "http://hl7.org/fhir/encounter-status";
140            case FINISHED: return "http://hl7.org/fhir/encounter-status";
141            case CANCELLED: return "http://hl7.org/fhir/encounter-status";
142            case ENTEREDINERROR: return "http://hl7.org/fhir/encounter-status";
143            case UNKNOWN: return "http://hl7.org/fhir/encounter-status";
144            default: return "?";
145          }
146        }
147        public String getDefinition() {
148          switch (this) {
149            case PLANNED: return "The Encounter has not yet started.";
150            case ARRIVED: return "The Patient is present for the encounter, however is not currently meeting with a practitioner.";
151            case TRIAGED: return "The patient has been assessed for the priority of their treatment based on the severity of their condition.";
152            case INPROGRESS: return "The Encounter has begun and the patient is present / the practitioner and the patient are meeting.";
153            case ONLEAVE: return "The Encounter has begun, but the patient is temporarily on leave.";
154            case FINISHED: return "The Encounter has ended.";
155            case CANCELLED: return "The Encounter has ended before it has begun.";
156            case ENTEREDINERROR: return "This instance should not have been part of this patient's medical record.";
157            case UNKNOWN: return "The encounter status is unknown. Note that \"unknown\" is a value of last resort and every attempt should be made to provide a meaningful value other than \"unknown\".";
158            default: return "?";
159          }
160        }
161        public String getDisplay() {
162          switch (this) {
163            case PLANNED: return "Planned";
164            case ARRIVED: return "Arrived";
165            case TRIAGED: return "Triaged";
166            case INPROGRESS: return "In Progress";
167            case ONLEAVE: return "On Leave";
168            case FINISHED: return "Finished";
169            case CANCELLED: return "Cancelled";
170            case ENTEREDINERROR: return "Entered in Error";
171            case UNKNOWN: return "Unknown";
172            default: return "?";
173          }
174        }
175    }
176
177  public static class EncounterStatusEnumFactory implements EnumFactory<EncounterStatus> {
178    public EncounterStatus fromCode(String codeString) throws IllegalArgumentException {
179      if (codeString == null || "".equals(codeString))
180            if (codeString == null || "".equals(codeString))
181                return null;
182        if ("planned".equals(codeString))
183          return EncounterStatus.PLANNED;
184        if ("arrived".equals(codeString))
185          return EncounterStatus.ARRIVED;
186        if ("triaged".equals(codeString))
187          return EncounterStatus.TRIAGED;
188        if ("in-progress".equals(codeString))
189          return EncounterStatus.INPROGRESS;
190        if ("onleave".equals(codeString))
191          return EncounterStatus.ONLEAVE;
192        if ("finished".equals(codeString))
193          return EncounterStatus.FINISHED;
194        if ("cancelled".equals(codeString))
195          return EncounterStatus.CANCELLED;
196        if ("entered-in-error".equals(codeString))
197          return EncounterStatus.ENTEREDINERROR;
198        if ("unknown".equals(codeString))
199          return EncounterStatus.UNKNOWN;
200        throw new IllegalArgumentException("Unknown EncounterStatus code '"+codeString+"'");
201        }
202        public Enumeration<EncounterStatus> fromType(Base code) throws FHIRException {
203          if (code == null)
204            return null;
205          if (code.isEmpty())
206            return new Enumeration<EncounterStatus>(this);
207          String codeString = ((PrimitiveType) code).asStringValue();
208          if (codeString == null || "".equals(codeString))
209            return null;
210        if ("planned".equals(codeString))
211          return new Enumeration<EncounterStatus>(this, EncounterStatus.PLANNED);
212        if ("arrived".equals(codeString))
213          return new Enumeration<EncounterStatus>(this, EncounterStatus.ARRIVED);
214        if ("triaged".equals(codeString))
215          return new Enumeration<EncounterStatus>(this, EncounterStatus.TRIAGED);
216        if ("in-progress".equals(codeString))
217          return new Enumeration<EncounterStatus>(this, EncounterStatus.INPROGRESS);
218        if ("onleave".equals(codeString))
219          return new Enumeration<EncounterStatus>(this, EncounterStatus.ONLEAVE);
220        if ("finished".equals(codeString))
221          return new Enumeration<EncounterStatus>(this, EncounterStatus.FINISHED);
222        if ("cancelled".equals(codeString))
223          return new Enumeration<EncounterStatus>(this, EncounterStatus.CANCELLED);
224        if ("entered-in-error".equals(codeString))
225          return new Enumeration<EncounterStatus>(this, EncounterStatus.ENTEREDINERROR);
226        if ("unknown".equals(codeString))
227          return new Enumeration<EncounterStatus>(this, EncounterStatus.UNKNOWN);
228        throw new FHIRException("Unknown EncounterStatus code '"+codeString+"'");
229        }
230    public String toCode(EncounterStatus code) {
231      if (code == EncounterStatus.PLANNED)
232        return "planned";
233      if (code == EncounterStatus.ARRIVED)
234        return "arrived";
235      if (code == EncounterStatus.TRIAGED)
236        return "triaged";
237      if (code == EncounterStatus.INPROGRESS)
238        return "in-progress";
239      if (code == EncounterStatus.ONLEAVE)
240        return "onleave";
241      if (code == EncounterStatus.FINISHED)
242        return "finished";
243      if (code == EncounterStatus.CANCELLED)
244        return "cancelled";
245      if (code == EncounterStatus.ENTEREDINERROR)
246        return "entered-in-error";
247      if (code == EncounterStatus.UNKNOWN)
248        return "unknown";
249      return "?";
250      }
251    public String toSystem(EncounterStatus code) {
252      return code.getSystem();
253      }
254    }
255
256    public enum EncounterLocationStatus {
257        /**
258         * The patient is planned to be moved to this location at some point in the future.
259         */
260        PLANNED, 
261        /**
262         * The patient is currently at this location, or was between the period specified.
263
264A system may update these records when the patient leaves the location to either reserved, or completed
265         */
266        ACTIVE, 
267        /**
268         * This location is held empty for this patient.
269         */
270        RESERVED, 
271        /**
272         * The patient was at this location during the period specified.
273
274Not to be used when the patient is currently at the location
275         */
276        COMPLETED, 
277        /**
278         * added to help the parsers with the generic types
279         */
280        NULL;
281        public static EncounterLocationStatus fromCode(String codeString) throws FHIRException {
282            if (codeString == null || "".equals(codeString))
283                return null;
284        if ("planned".equals(codeString))
285          return PLANNED;
286        if ("active".equals(codeString))
287          return ACTIVE;
288        if ("reserved".equals(codeString))
289          return RESERVED;
290        if ("completed".equals(codeString))
291          return COMPLETED;
292        if (Configuration.isAcceptInvalidEnums())
293          return null;
294        else
295          throw new FHIRException("Unknown EncounterLocationStatus code '"+codeString+"'");
296        }
297        public String toCode() {
298          switch (this) {
299            case PLANNED: return "planned";
300            case ACTIVE: return "active";
301            case RESERVED: return "reserved";
302            case COMPLETED: return "completed";
303            default: return "?";
304          }
305        }
306        public String getSystem() {
307          switch (this) {
308            case PLANNED: return "http://hl7.org/fhir/encounter-location-status";
309            case ACTIVE: return "http://hl7.org/fhir/encounter-location-status";
310            case RESERVED: return "http://hl7.org/fhir/encounter-location-status";
311            case COMPLETED: return "http://hl7.org/fhir/encounter-location-status";
312            default: return "?";
313          }
314        }
315        public String getDefinition() {
316          switch (this) {
317            case PLANNED: return "The patient is planned to be moved to this location at some point in the future.";
318            case ACTIVE: return "The patient is currently at this location, or was between the period specified.\r\rA system may update these records when the patient leaves the location to either reserved, or completed";
319            case RESERVED: return "This location is held empty for this patient.";
320            case COMPLETED: return "The patient was at this location during the period specified.\r\rNot to be used when the patient is currently at the location";
321            default: return "?";
322          }
323        }
324        public String getDisplay() {
325          switch (this) {
326            case PLANNED: return "Planned";
327            case ACTIVE: return "Active";
328            case RESERVED: return "Reserved";
329            case COMPLETED: return "Completed";
330            default: return "?";
331          }
332        }
333    }
334
335  public static class EncounterLocationStatusEnumFactory implements EnumFactory<EncounterLocationStatus> {
336    public EncounterLocationStatus fromCode(String codeString) throws IllegalArgumentException {
337      if (codeString == null || "".equals(codeString))
338            if (codeString == null || "".equals(codeString))
339                return null;
340        if ("planned".equals(codeString))
341          return EncounterLocationStatus.PLANNED;
342        if ("active".equals(codeString))
343          return EncounterLocationStatus.ACTIVE;
344        if ("reserved".equals(codeString))
345          return EncounterLocationStatus.RESERVED;
346        if ("completed".equals(codeString))
347          return EncounterLocationStatus.COMPLETED;
348        throw new IllegalArgumentException("Unknown EncounterLocationStatus code '"+codeString+"'");
349        }
350        public Enumeration<EncounterLocationStatus> fromType(Base code) throws FHIRException {
351          if (code == null)
352            return null;
353          if (code.isEmpty())
354            return new Enumeration<EncounterLocationStatus>(this);
355          String codeString = ((PrimitiveType) code).asStringValue();
356          if (codeString == null || "".equals(codeString))
357            return null;
358        if ("planned".equals(codeString))
359          return new Enumeration<EncounterLocationStatus>(this, EncounterLocationStatus.PLANNED);
360        if ("active".equals(codeString))
361          return new Enumeration<EncounterLocationStatus>(this, EncounterLocationStatus.ACTIVE);
362        if ("reserved".equals(codeString))
363          return new Enumeration<EncounterLocationStatus>(this, EncounterLocationStatus.RESERVED);
364        if ("completed".equals(codeString))
365          return new Enumeration<EncounterLocationStatus>(this, EncounterLocationStatus.COMPLETED);
366        throw new FHIRException("Unknown EncounterLocationStatus code '"+codeString+"'");
367        }
368    public String toCode(EncounterLocationStatus code) {
369      if (code == EncounterLocationStatus.PLANNED)
370        return "planned";
371      if (code == EncounterLocationStatus.ACTIVE)
372        return "active";
373      if (code == EncounterLocationStatus.RESERVED)
374        return "reserved";
375      if (code == EncounterLocationStatus.COMPLETED)
376        return "completed";
377      return "?";
378      }
379    public String toSystem(EncounterLocationStatus code) {
380      return code.getSystem();
381      }
382    }
383
384    @Block()
385    public static class StatusHistoryComponent extends BackboneElement implements IBaseBackboneElement {
386        /**
387         * planned | arrived | triaged | in-progress | onleave | finished | cancelled +.
388         */
389        @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=false)
390        @Description(shortDefinition="planned | arrived | triaged | in-progress | onleave | finished | cancelled +", formalDefinition="planned | arrived | triaged | in-progress | onleave | finished | cancelled +." )
391        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/encounter-status")
392        protected Enumeration<EncounterStatus> status;
393
394        /**
395         * The time that the episode was in the specified status.
396         */
397        @Child(name = "period", type = {Period.class}, order=2, min=1, max=1, modifier=false, summary=false)
398        @Description(shortDefinition="The time that the episode was in the specified status", formalDefinition="The time that the episode was in the specified status." )
399        protected Period period;
400
401        private static final long serialVersionUID = -1893906736L;
402
403    /**
404     * Constructor
405     */
406      public StatusHistoryComponent() {
407        super();
408      }
409
410    /**
411     * Constructor
412     */
413      public StatusHistoryComponent(Enumeration<EncounterStatus> status, Period period) {
414        super();
415        this.status = status;
416        this.period = period;
417      }
418
419        /**
420         * @return {@link #status} (planned | arrived | triaged | in-progress | onleave | finished | cancelled +.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
421         */
422        public Enumeration<EncounterStatus> getStatusElement() { 
423          if (this.status == null)
424            if (Configuration.errorOnAutoCreate())
425              throw new Error("Attempt to auto-create StatusHistoryComponent.status");
426            else if (Configuration.doAutoCreate())
427              this.status = new Enumeration<EncounterStatus>(new EncounterStatusEnumFactory()); // bb
428          return this.status;
429        }
430
431        public boolean hasStatusElement() { 
432          return this.status != null && !this.status.isEmpty();
433        }
434
435        public boolean hasStatus() { 
436          return this.status != null && !this.status.isEmpty();
437        }
438
439        /**
440         * @param value {@link #status} (planned | arrived | triaged | in-progress | onleave | finished | cancelled +.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
441         */
442        public StatusHistoryComponent setStatusElement(Enumeration<EncounterStatus> value) { 
443          this.status = value;
444          return this;
445        }
446
447        /**
448         * @return planned | arrived | triaged | in-progress | onleave | finished | cancelled +.
449         */
450        public EncounterStatus getStatus() { 
451          return this.status == null ? null : this.status.getValue();
452        }
453
454        /**
455         * @param value planned | arrived | triaged | in-progress | onleave | finished | cancelled +.
456         */
457        public StatusHistoryComponent setStatus(EncounterStatus value) { 
458            if (this.status == null)
459              this.status = new Enumeration<EncounterStatus>(new EncounterStatusEnumFactory());
460            this.status.setValue(value);
461          return this;
462        }
463
464        /**
465         * @return {@link #period} (The time that the episode was in the specified status.)
466         */
467        public Period getPeriod() { 
468          if (this.period == null)
469            if (Configuration.errorOnAutoCreate())
470              throw new Error("Attempt to auto-create StatusHistoryComponent.period");
471            else if (Configuration.doAutoCreate())
472              this.period = new Period(); // cc
473          return this.period;
474        }
475
476        public boolean hasPeriod() { 
477          return this.period != null && !this.period.isEmpty();
478        }
479
480        /**
481         * @param value {@link #period} (The time that the episode was in the specified status.)
482         */
483        public StatusHistoryComponent setPeriod(Period value) { 
484          this.period = value;
485          return this;
486        }
487
488        protected void listChildren(List<Property> childrenList) {
489          super.listChildren(childrenList);
490          childrenList.add(new Property("status", "code", "planned | arrived | triaged | in-progress | onleave | finished | cancelled +.", 0, java.lang.Integer.MAX_VALUE, status));
491          childrenList.add(new Property("period", "Period", "The time that the episode was in the specified status.", 0, java.lang.Integer.MAX_VALUE, period));
492        }
493
494      @Override
495      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
496        switch (hash) {
497        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<EncounterStatus>
498        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
499        default: return super.getProperty(hash, name, checkValid);
500        }
501
502      }
503
504      @Override
505      public Base setProperty(int hash, String name, Base value) throws FHIRException {
506        switch (hash) {
507        case -892481550: // status
508          value = new EncounterStatusEnumFactory().fromType(castToCode(value));
509          this.status = (Enumeration) value; // Enumeration<EncounterStatus>
510          return value;
511        case -991726143: // period
512          this.period = castToPeriod(value); // Period
513          return value;
514        default: return super.setProperty(hash, name, value);
515        }
516
517      }
518
519      @Override
520      public Base setProperty(String name, Base value) throws FHIRException {
521        if (name.equals("status")) {
522          value = new EncounterStatusEnumFactory().fromType(castToCode(value));
523          this.status = (Enumeration) value; // Enumeration<EncounterStatus>
524        } else if (name.equals("period")) {
525          this.period = castToPeriod(value); // Period
526        } else
527          return super.setProperty(name, value);
528        return value;
529      }
530
531      @Override
532      public Base makeProperty(int hash, String name) throws FHIRException {
533        switch (hash) {
534        case -892481550:  return getStatusElement();
535        case -991726143:  return getPeriod(); 
536        default: return super.makeProperty(hash, name);
537        }
538
539      }
540
541      @Override
542      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
543        switch (hash) {
544        case -892481550: /*status*/ return new String[] {"code"};
545        case -991726143: /*period*/ return new String[] {"Period"};
546        default: return super.getTypesForProperty(hash, name);
547        }
548
549      }
550
551      @Override
552      public Base addChild(String name) throws FHIRException {
553        if (name.equals("status")) {
554          throw new FHIRException("Cannot call addChild on a primitive type Encounter.status");
555        }
556        else if (name.equals("period")) {
557          this.period = new Period();
558          return this.period;
559        }
560        else
561          return super.addChild(name);
562      }
563
564      public StatusHistoryComponent copy() {
565        StatusHistoryComponent dst = new StatusHistoryComponent();
566        copyValues(dst);
567        dst.status = status == null ? null : status.copy();
568        dst.period = period == null ? null : period.copy();
569        return dst;
570      }
571
572      @Override
573      public boolean equalsDeep(Base other) {
574        if (!super.equalsDeep(other))
575          return false;
576        if (!(other instanceof StatusHistoryComponent))
577          return false;
578        StatusHistoryComponent o = (StatusHistoryComponent) other;
579        return compareDeep(status, o.status, true) && compareDeep(period, o.period, true);
580      }
581
582      @Override
583      public boolean equalsShallow(Base other) {
584        if (!super.equalsShallow(other))
585          return false;
586        if (!(other instanceof StatusHistoryComponent))
587          return false;
588        StatusHistoryComponent o = (StatusHistoryComponent) other;
589        return compareValues(status, o.status, true);
590      }
591
592      public boolean isEmpty() {
593        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(status, period);
594      }
595
596  public String fhirType() {
597    return "Encounter.statusHistory";
598
599  }
600
601  }
602
603    @Block()
604    public static class ClassHistoryComponent extends BackboneElement implements IBaseBackboneElement {
605        /**
606         * inpatient | outpatient | ambulatory | emergency +.
607         */
608        @Child(name = "class", type = {Coding.class}, order=1, min=1, max=1, modifier=false, summary=false)
609        @Description(shortDefinition="inpatient | outpatient | ambulatory | emergency +", formalDefinition="inpatient | outpatient | ambulatory | emergency +." )
610        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/v3-ActEncounterCode")
611        protected Coding class_;
612
613        /**
614         * The time that the episode was in the specified class.
615         */
616        @Child(name = "period", type = {Period.class}, order=2, min=1, max=1, modifier=false, summary=false)
617        @Description(shortDefinition="The time that the episode was in the specified class", formalDefinition="The time that the episode was in the specified class." )
618        protected Period period;
619
620        private static final long serialVersionUID = 1331020311L;
621
622    /**
623     * Constructor
624     */
625      public ClassHistoryComponent() {
626        super();
627      }
628
629    /**
630     * Constructor
631     */
632      public ClassHistoryComponent(Coding class_, Period period) {
633        super();
634        this.class_ = class_;
635        this.period = period;
636      }
637
638        /**
639         * @return {@link #class_} (inpatient | outpatient | ambulatory | emergency +.)
640         */
641        public Coding getClass_() { 
642          if (this.class_ == null)
643            if (Configuration.errorOnAutoCreate())
644              throw new Error("Attempt to auto-create ClassHistoryComponent.class_");
645            else if (Configuration.doAutoCreate())
646              this.class_ = new Coding(); // cc
647          return this.class_;
648        }
649
650        public boolean hasClass_() { 
651          return this.class_ != null && !this.class_.isEmpty();
652        }
653
654        /**
655         * @param value {@link #class_} (inpatient | outpatient | ambulatory | emergency +.)
656         */
657        public ClassHistoryComponent setClass_(Coding value) { 
658          this.class_ = value;
659          return this;
660        }
661
662        /**
663         * @return {@link #period} (The time that the episode was in the specified class.)
664         */
665        public Period getPeriod() { 
666          if (this.period == null)
667            if (Configuration.errorOnAutoCreate())
668              throw new Error("Attempt to auto-create ClassHistoryComponent.period");
669            else if (Configuration.doAutoCreate())
670              this.period = new Period(); // cc
671          return this.period;
672        }
673
674        public boolean hasPeriod() { 
675          return this.period != null && !this.period.isEmpty();
676        }
677
678        /**
679         * @param value {@link #period} (The time that the episode was in the specified class.)
680         */
681        public ClassHistoryComponent setPeriod(Period value) { 
682          this.period = value;
683          return this;
684        }
685
686        protected void listChildren(List<Property> childrenList) {
687          super.listChildren(childrenList);
688          childrenList.add(new Property("class", "Coding", "inpatient | outpatient | ambulatory | emergency +.", 0, java.lang.Integer.MAX_VALUE, class_));
689          childrenList.add(new Property("period", "Period", "The time that the episode was in the specified class.", 0, java.lang.Integer.MAX_VALUE, period));
690        }
691
692      @Override
693      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
694        switch (hash) {
695        case 94742904: /*class*/ return this.class_ == null ? new Base[0] : new Base[] {this.class_}; // Coding
696        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
697        default: return super.getProperty(hash, name, checkValid);
698        }
699
700      }
701
702      @Override
703      public Base setProperty(int hash, String name, Base value) throws FHIRException {
704        switch (hash) {
705        case 94742904: // class
706          this.class_ = castToCoding(value); // Coding
707          return value;
708        case -991726143: // period
709          this.period = castToPeriod(value); // Period
710          return value;
711        default: return super.setProperty(hash, name, value);
712        }
713
714      }
715
716      @Override
717      public Base setProperty(String name, Base value) throws FHIRException {
718        if (name.equals("class")) {
719          this.class_ = castToCoding(value); // Coding
720        } else if (name.equals("period")) {
721          this.period = castToPeriod(value); // Period
722        } else
723          return super.setProperty(name, value);
724        return value;
725      }
726
727      @Override
728      public Base makeProperty(int hash, String name) throws FHIRException {
729        switch (hash) {
730        case 94742904:  return getClass_(); 
731        case -991726143:  return getPeriod(); 
732        default: return super.makeProperty(hash, name);
733        }
734
735      }
736
737      @Override
738      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
739        switch (hash) {
740        case 94742904: /*class*/ return new String[] {"Coding"};
741        case -991726143: /*period*/ return new String[] {"Period"};
742        default: return super.getTypesForProperty(hash, name);
743        }
744
745      }
746
747      @Override
748      public Base addChild(String name) throws FHIRException {
749        if (name.equals("class")) {
750          this.class_ = new Coding();
751          return this.class_;
752        }
753        else if (name.equals("period")) {
754          this.period = new Period();
755          return this.period;
756        }
757        else
758          return super.addChild(name);
759      }
760
761      public ClassHistoryComponent copy() {
762        ClassHistoryComponent dst = new ClassHistoryComponent();
763        copyValues(dst);
764        dst.class_ = class_ == null ? null : class_.copy();
765        dst.period = period == null ? null : period.copy();
766        return dst;
767      }
768
769      @Override
770      public boolean equalsDeep(Base other) {
771        if (!super.equalsDeep(other))
772          return false;
773        if (!(other instanceof ClassHistoryComponent))
774          return false;
775        ClassHistoryComponent o = (ClassHistoryComponent) other;
776        return compareDeep(class_, o.class_, true) && compareDeep(period, o.period, true);
777      }
778
779      @Override
780      public boolean equalsShallow(Base other) {
781        if (!super.equalsShallow(other))
782          return false;
783        if (!(other instanceof ClassHistoryComponent))
784          return false;
785        ClassHistoryComponent o = (ClassHistoryComponent) other;
786        return true;
787      }
788
789      public boolean isEmpty() {
790        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(class_, period);
791      }
792
793  public String fhirType() {
794    return "Encounter.classHistory";
795
796  }
797
798  }
799
800    @Block()
801    public static class EncounterParticipantComponent extends BackboneElement implements IBaseBackboneElement {
802        /**
803         * Role of participant in encounter.
804         */
805        @Child(name = "type", type = {CodeableConcept.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
806        @Description(shortDefinition="Role of participant in encounter", formalDefinition="Role of participant in encounter." )
807        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/encounter-participant-type")
808        protected List<CodeableConcept> type;
809
810        /**
811         * The period of time that the specified participant participated in the encounter. These can overlap or be sub-sets of the overall encounter's period.
812         */
813        @Child(name = "period", type = {Period.class}, order=2, min=0, max=1, modifier=false, summary=false)
814        @Description(shortDefinition="Period of time during the encounter that the participant participated", formalDefinition="The period of time that the specified participant participated in the encounter. These can overlap or be sub-sets of the overall encounter's period." )
815        protected Period period;
816
817        /**
818         * Persons involved in the encounter other than the patient.
819         */
820        @Child(name = "individual", type = {Practitioner.class, RelatedPerson.class}, order=3, min=0, max=1, modifier=false, summary=true)
821        @Description(shortDefinition="Persons involved in the encounter other than the patient", formalDefinition="Persons involved in the encounter other than the patient." )
822        protected Reference individual;
823
824        /**
825         * The actual object that is the target of the reference (Persons involved in the encounter other than the patient.)
826         */
827        protected Resource individualTarget;
828
829        private static final long serialVersionUID = 317095765L;
830
831    /**
832     * Constructor
833     */
834      public EncounterParticipantComponent() {
835        super();
836      }
837
838        /**
839         * @return {@link #type} (Role of participant in encounter.)
840         */
841        public List<CodeableConcept> getType() { 
842          if (this.type == null)
843            this.type = new ArrayList<CodeableConcept>();
844          return this.type;
845        }
846
847        /**
848         * @return Returns a reference to <code>this</code> for easy method chaining
849         */
850        public EncounterParticipantComponent setType(List<CodeableConcept> theType) { 
851          this.type = theType;
852          return this;
853        }
854
855        public boolean hasType() { 
856          if (this.type == null)
857            return false;
858          for (CodeableConcept item : this.type)
859            if (!item.isEmpty())
860              return true;
861          return false;
862        }
863
864        public CodeableConcept addType() { //3
865          CodeableConcept t = new CodeableConcept();
866          if (this.type == null)
867            this.type = new ArrayList<CodeableConcept>();
868          this.type.add(t);
869          return t;
870        }
871
872        public EncounterParticipantComponent addType(CodeableConcept t) { //3
873          if (t == null)
874            return this;
875          if (this.type == null)
876            this.type = new ArrayList<CodeableConcept>();
877          this.type.add(t);
878          return this;
879        }
880
881        /**
882         * @return The first repetition of repeating field {@link #type}, creating it if it does not already exist
883         */
884        public CodeableConcept getTypeFirstRep() { 
885          if (getType().isEmpty()) {
886            addType();
887          }
888          return getType().get(0);
889        }
890
891        /**
892         * @return {@link #period} (The period of time that the specified participant participated in the encounter. These can overlap or be sub-sets of the overall encounter's period.)
893         */
894        public Period getPeriod() { 
895          if (this.period == null)
896            if (Configuration.errorOnAutoCreate())
897              throw new Error("Attempt to auto-create EncounterParticipantComponent.period");
898            else if (Configuration.doAutoCreate())
899              this.period = new Period(); // cc
900          return this.period;
901        }
902
903        public boolean hasPeriod() { 
904          return this.period != null && !this.period.isEmpty();
905        }
906
907        /**
908         * @param value {@link #period} (The period of time that the specified participant participated in the encounter. These can overlap or be sub-sets of the overall encounter's period.)
909         */
910        public EncounterParticipantComponent setPeriod(Period value) { 
911          this.period = value;
912          return this;
913        }
914
915        /**
916         * @return {@link #individual} (Persons involved in the encounter other than the patient.)
917         */
918        public Reference getIndividual() { 
919          if (this.individual == null)
920            if (Configuration.errorOnAutoCreate())
921              throw new Error("Attempt to auto-create EncounterParticipantComponent.individual");
922            else if (Configuration.doAutoCreate())
923              this.individual = new Reference(); // cc
924          return this.individual;
925        }
926
927        public boolean hasIndividual() { 
928          return this.individual != null && !this.individual.isEmpty();
929        }
930
931        /**
932         * @param value {@link #individual} (Persons involved in the encounter other than the patient.)
933         */
934        public EncounterParticipantComponent setIndividual(Reference value) { 
935          this.individual = value;
936          return this;
937        }
938
939        /**
940         * @return {@link #individual} 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. (Persons involved in the encounter other than the patient.)
941         */
942        public Resource getIndividualTarget() { 
943          return this.individualTarget;
944        }
945
946        /**
947         * @param value {@link #individual} 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. (Persons involved in the encounter other than the patient.)
948         */
949        public EncounterParticipantComponent setIndividualTarget(Resource value) { 
950          this.individualTarget = value;
951          return this;
952        }
953
954        protected void listChildren(List<Property> childrenList) {
955          super.listChildren(childrenList);
956          childrenList.add(new Property("type", "CodeableConcept", "Role of participant in encounter.", 0, java.lang.Integer.MAX_VALUE, type));
957          childrenList.add(new Property("period", "Period", "The period of time that the specified participant participated in the encounter. These can overlap or be sub-sets of the overall encounter's period.", 0, java.lang.Integer.MAX_VALUE, period));
958          childrenList.add(new Property("individual", "Reference(Practitioner|RelatedPerson)", "Persons involved in the encounter other than the patient.", 0, java.lang.Integer.MAX_VALUE, individual));
959        }
960
961      @Override
962      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
963        switch (hash) {
964        case 3575610: /*type*/ return this.type == null ? new Base[0] : this.type.toArray(new Base[this.type.size()]); // CodeableConcept
965        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
966        case -46292327: /*individual*/ return this.individual == null ? new Base[0] : new Base[] {this.individual}; // Reference
967        default: return super.getProperty(hash, name, checkValid);
968        }
969
970      }
971
972      @Override
973      public Base setProperty(int hash, String name, Base value) throws FHIRException {
974        switch (hash) {
975        case 3575610: // type
976          this.getType().add(castToCodeableConcept(value)); // CodeableConcept
977          return value;
978        case -991726143: // period
979          this.period = castToPeriod(value); // Period
980          return value;
981        case -46292327: // individual
982          this.individual = castToReference(value); // Reference
983          return value;
984        default: return super.setProperty(hash, name, value);
985        }
986
987      }
988
989      @Override
990      public Base setProperty(String name, Base value) throws FHIRException {
991        if (name.equals("type")) {
992          this.getType().add(castToCodeableConcept(value));
993        } else if (name.equals("period")) {
994          this.period = castToPeriod(value); // Period
995        } else if (name.equals("individual")) {
996          this.individual = castToReference(value); // Reference
997        } else
998          return super.setProperty(name, value);
999        return value;
1000      }
1001
1002      @Override
1003      public Base makeProperty(int hash, String name) throws FHIRException {
1004        switch (hash) {
1005        case 3575610:  return addType(); 
1006        case -991726143:  return getPeriod(); 
1007        case -46292327:  return getIndividual(); 
1008        default: return super.makeProperty(hash, name);
1009        }
1010
1011      }
1012
1013      @Override
1014      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1015        switch (hash) {
1016        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
1017        case -991726143: /*period*/ return new String[] {"Period"};
1018        case -46292327: /*individual*/ return new String[] {"Reference"};
1019        default: return super.getTypesForProperty(hash, name);
1020        }
1021
1022      }
1023
1024      @Override
1025      public Base addChild(String name) throws FHIRException {
1026        if (name.equals("type")) {
1027          return addType();
1028        }
1029        else if (name.equals("period")) {
1030          this.period = new Period();
1031          return this.period;
1032        }
1033        else if (name.equals("individual")) {
1034          this.individual = new Reference();
1035          return this.individual;
1036        }
1037        else
1038          return super.addChild(name);
1039      }
1040
1041      public EncounterParticipantComponent copy() {
1042        EncounterParticipantComponent dst = new EncounterParticipantComponent();
1043        copyValues(dst);
1044        if (type != null) {
1045          dst.type = new ArrayList<CodeableConcept>();
1046          for (CodeableConcept i : type)
1047            dst.type.add(i.copy());
1048        };
1049        dst.period = period == null ? null : period.copy();
1050        dst.individual = individual == null ? null : individual.copy();
1051        return dst;
1052      }
1053
1054      @Override
1055      public boolean equalsDeep(Base other) {
1056        if (!super.equalsDeep(other))
1057          return false;
1058        if (!(other instanceof EncounterParticipantComponent))
1059          return false;
1060        EncounterParticipantComponent o = (EncounterParticipantComponent) other;
1061        return compareDeep(type, o.type, true) && compareDeep(period, o.period, true) && compareDeep(individual, o.individual, true)
1062          ;
1063      }
1064
1065      @Override
1066      public boolean equalsShallow(Base other) {
1067        if (!super.equalsShallow(other))
1068          return false;
1069        if (!(other instanceof EncounterParticipantComponent))
1070          return false;
1071        EncounterParticipantComponent o = (EncounterParticipantComponent) other;
1072        return true;
1073      }
1074
1075      public boolean isEmpty() {
1076        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, period, individual
1077          );
1078      }
1079
1080  public String fhirType() {
1081    return "Encounter.participant";
1082
1083  }
1084
1085  }
1086
1087    @Block()
1088    public static class DiagnosisComponent extends BackboneElement implements IBaseBackboneElement {
1089        /**
1090         * Reason the encounter takes place, as specified using information from another resource. For admissions, this is the admission diagnosis. The indication will typically be a Condition (with other resources referenced in the evidence.detail), or a Procedure.
1091         */
1092        @Child(name = "condition", type = {Condition.class, Procedure.class}, order=1, min=1, max=1, modifier=false, summary=false)
1093        @Description(shortDefinition="Reason the encounter takes place (resource)", formalDefinition="Reason the encounter takes place, as specified using information from another resource. For admissions, this is the admission diagnosis. The indication will typically be a Condition (with other resources referenced in the evidence.detail), or a Procedure." )
1094        protected Reference condition;
1095
1096        /**
1097         * The actual object that is the target of the reference (Reason the encounter takes place, as specified using information from another resource. For admissions, this is the admission diagnosis. The indication will typically be a Condition (with other resources referenced in the evidence.detail), or a Procedure.)
1098         */
1099        protected Resource conditionTarget;
1100
1101        /**
1102         * Role that this diagnosis has within the encounter (e.g. admission, billing, discharge …).
1103         */
1104        @Child(name = "role", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
1105        @Description(shortDefinition="Role that this diagnosis has within the encounter (e.g. admission, billing, discharge …)", formalDefinition="Role that this diagnosis has within the encounter (e.g. admission, billing, discharge …)." )
1106        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/diagnosis-role")
1107        protected CodeableConcept role;
1108
1109        /**
1110         * Ranking of the diagnosis (for each role type).
1111         */
1112        @Child(name = "rank", type = {PositiveIntType.class}, order=3, min=0, max=1, modifier=false, summary=false)
1113        @Description(shortDefinition="Ranking of the diagnosis (for each role type)", formalDefinition="Ranking of the diagnosis (for each role type)." )
1114        protected PositiveIntType rank;
1115
1116        private static final long serialVersionUID = 1005913665L;
1117
1118    /**
1119     * Constructor
1120     */
1121      public DiagnosisComponent() {
1122        super();
1123      }
1124
1125    /**
1126     * Constructor
1127     */
1128      public DiagnosisComponent(Reference condition) {
1129        super();
1130        this.condition = condition;
1131      }
1132
1133        /**
1134         * @return {@link #condition} (Reason the encounter takes place, as specified using information from another resource. For admissions, this is the admission diagnosis. The indication will typically be a Condition (with other resources referenced in the evidence.detail), or a Procedure.)
1135         */
1136        public Reference getCondition() { 
1137          if (this.condition == null)
1138            if (Configuration.errorOnAutoCreate())
1139              throw new Error("Attempt to auto-create DiagnosisComponent.condition");
1140            else if (Configuration.doAutoCreate())
1141              this.condition = new Reference(); // cc
1142          return this.condition;
1143        }
1144
1145        public boolean hasCondition() { 
1146          return this.condition != null && !this.condition.isEmpty();
1147        }
1148
1149        /**
1150         * @param value {@link #condition} (Reason the encounter takes place, as specified using information from another resource. For admissions, this is the admission diagnosis. The indication will typically be a Condition (with other resources referenced in the evidence.detail), or a Procedure.)
1151         */
1152        public DiagnosisComponent setCondition(Reference value) { 
1153          this.condition = value;
1154          return this;
1155        }
1156
1157        /**
1158         * @return {@link #condition} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Reason the encounter takes place, as specified using information from another resource. For admissions, this is the admission diagnosis. The indication will typically be a Condition (with other resources referenced in the evidence.detail), or a Procedure.)
1159         */
1160        public Resource getConditionTarget() { 
1161          return this.conditionTarget;
1162        }
1163
1164        /**
1165         * @param value {@link #condition} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Reason the encounter takes place, as specified using information from another resource. For admissions, this is the admission diagnosis. The indication will typically be a Condition (with other resources referenced in the evidence.detail), or a Procedure.)
1166         */
1167        public DiagnosisComponent setConditionTarget(Resource value) { 
1168          this.conditionTarget = value;
1169          return this;
1170        }
1171
1172        /**
1173         * @return {@link #role} (Role that this diagnosis has within the encounter (e.g. admission, billing, discharge …).)
1174         */
1175        public CodeableConcept getRole() { 
1176          if (this.role == null)
1177            if (Configuration.errorOnAutoCreate())
1178              throw new Error("Attempt to auto-create DiagnosisComponent.role");
1179            else if (Configuration.doAutoCreate())
1180              this.role = new CodeableConcept(); // cc
1181          return this.role;
1182        }
1183
1184        public boolean hasRole() { 
1185          return this.role != null && !this.role.isEmpty();
1186        }
1187
1188        /**
1189         * @param value {@link #role} (Role that this diagnosis has within the encounter (e.g. admission, billing, discharge …).)
1190         */
1191        public DiagnosisComponent setRole(CodeableConcept value) { 
1192          this.role = value;
1193          return this;
1194        }
1195
1196        /**
1197         * @return {@link #rank} (Ranking of the diagnosis (for each role type).). This is the underlying object with id, value and extensions. The accessor "getRank" gives direct access to the value
1198         */
1199        public PositiveIntType getRankElement() { 
1200          if (this.rank == null)
1201            if (Configuration.errorOnAutoCreate())
1202              throw new Error("Attempt to auto-create DiagnosisComponent.rank");
1203            else if (Configuration.doAutoCreate())
1204              this.rank = new PositiveIntType(); // bb
1205          return this.rank;
1206        }
1207
1208        public boolean hasRankElement() { 
1209          return this.rank != null && !this.rank.isEmpty();
1210        }
1211
1212        public boolean hasRank() { 
1213          return this.rank != null && !this.rank.isEmpty();
1214        }
1215
1216        /**
1217         * @param value {@link #rank} (Ranking of the diagnosis (for each role type).). This is the underlying object with id, value and extensions. The accessor "getRank" gives direct access to the value
1218         */
1219        public DiagnosisComponent setRankElement(PositiveIntType value) { 
1220          this.rank = value;
1221          return this;
1222        }
1223
1224        /**
1225         * @return Ranking of the diagnosis (for each role type).
1226         */
1227        public int getRank() { 
1228          return this.rank == null || this.rank.isEmpty() ? 0 : this.rank.getValue();
1229        }
1230
1231        /**
1232         * @param value Ranking of the diagnosis (for each role type).
1233         */
1234        public DiagnosisComponent setRank(int value) { 
1235            if (this.rank == null)
1236              this.rank = new PositiveIntType();
1237            this.rank.setValue(value);
1238          return this;
1239        }
1240
1241        protected void listChildren(List<Property> childrenList) {
1242          super.listChildren(childrenList);
1243          childrenList.add(new Property("condition", "Reference(Condition|Procedure)", "Reason the encounter takes place, as specified using information from another resource. For admissions, this is the admission diagnosis. The indication will typically be a Condition (with other resources referenced in the evidence.detail), or a Procedure.", 0, java.lang.Integer.MAX_VALUE, condition));
1244          childrenList.add(new Property("role", "CodeableConcept", "Role that this diagnosis has within the encounter (e.g. admission, billing, discharge …).", 0, java.lang.Integer.MAX_VALUE, role));
1245          childrenList.add(new Property("rank", "positiveInt", "Ranking of the diagnosis (for each role type).", 0, java.lang.Integer.MAX_VALUE, rank));
1246        }
1247
1248      @Override
1249      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1250        switch (hash) {
1251        case -861311717: /*condition*/ return this.condition == null ? new Base[0] : new Base[] {this.condition}; // Reference
1252        case 3506294: /*role*/ return this.role == null ? new Base[0] : new Base[] {this.role}; // CodeableConcept
1253        case 3492908: /*rank*/ return this.rank == null ? new Base[0] : new Base[] {this.rank}; // PositiveIntType
1254        default: return super.getProperty(hash, name, checkValid);
1255        }
1256
1257      }
1258
1259      @Override
1260      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1261        switch (hash) {
1262        case -861311717: // condition
1263          this.condition = castToReference(value); // Reference
1264          return value;
1265        case 3506294: // role
1266          this.role = castToCodeableConcept(value); // CodeableConcept
1267          return value;
1268        case 3492908: // rank
1269          this.rank = castToPositiveInt(value); // PositiveIntType
1270          return value;
1271        default: return super.setProperty(hash, name, value);
1272        }
1273
1274      }
1275
1276      @Override
1277      public Base setProperty(String name, Base value) throws FHIRException {
1278        if (name.equals("condition")) {
1279          this.condition = castToReference(value); // Reference
1280        } else if (name.equals("role")) {
1281          this.role = castToCodeableConcept(value); // CodeableConcept
1282        } else if (name.equals("rank")) {
1283          this.rank = castToPositiveInt(value); // PositiveIntType
1284        } else
1285          return super.setProperty(name, value);
1286        return value;
1287      }
1288
1289      @Override
1290      public Base makeProperty(int hash, String name) throws FHIRException {
1291        switch (hash) {
1292        case -861311717:  return getCondition(); 
1293        case 3506294:  return getRole(); 
1294        case 3492908:  return getRankElement();
1295        default: return super.makeProperty(hash, name);
1296        }
1297
1298      }
1299
1300      @Override
1301      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1302        switch (hash) {
1303        case -861311717: /*condition*/ return new String[] {"Reference"};
1304        case 3506294: /*role*/ return new String[] {"CodeableConcept"};
1305        case 3492908: /*rank*/ return new String[] {"positiveInt"};
1306        default: return super.getTypesForProperty(hash, name);
1307        }
1308
1309      }
1310
1311      @Override
1312      public Base addChild(String name) throws FHIRException {
1313        if (name.equals("condition")) {
1314          this.condition = new Reference();
1315          return this.condition;
1316        }
1317        else if (name.equals("role")) {
1318          this.role = new CodeableConcept();
1319          return this.role;
1320        }
1321        else if (name.equals("rank")) {
1322          throw new FHIRException("Cannot call addChild on a primitive type Encounter.rank");
1323        }
1324        else
1325          return super.addChild(name);
1326      }
1327
1328      public DiagnosisComponent copy() {
1329        DiagnosisComponent dst = new DiagnosisComponent();
1330        copyValues(dst);
1331        dst.condition = condition == null ? null : condition.copy();
1332        dst.role = role == null ? null : role.copy();
1333        dst.rank = rank == null ? null : rank.copy();
1334        return dst;
1335      }
1336
1337      @Override
1338      public boolean equalsDeep(Base other) {
1339        if (!super.equalsDeep(other))
1340          return false;
1341        if (!(other instanceof DiagnosisComponent))
1342          return false;
1343        DiagnosisComponent o = (DiagnosisComponent) other;
1344        return compareDeep(condition, o.condition, true) && compareDeep(role, o.role, true) && compareDeep(rank, o.rank, true)
1345          ;
1346      }
1347
1348      @Override
1349      public boolean equalsShallow(Base other) {
1350        if (!super.equalsShallow(other))
1351          return false;
1352        if (!(other instanceof DiagnosisComponent))
1353          return false;
1354        DiagnosisComponent o = (DiagnosisComponent) other;
1355        return compareValues(rank, o.rank, true);
1356      }
1357
1358      public boolean isEmpty() {
1359        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(condition, role, rank);
1360      }
1361
1362  public String fhirType() {
1363    return "Encounter.diagnosis";
1364
1365  }
1366
1367  }
1368
1369    @Block()
1370    public static class EncounterHospitalizationComponent extends BackboneElement implements IBaseBackboneElement {
1371        /**
1372         * Pre-admission identifier.
1373         */
1374        @Child(name = "preAdmissionIdentifier", type = {Identifier.class}, order=1, min=0, max=1, modifier=false, summary=false)
1375        @Description(shortDefinition="Pre-admission identifier", formalDefinition="Pre-admission identifier." )
1376        protected Identifier preAdmissionIdentifier;
1377
1378        /**
1379         * The location from which the patient came before admission.
1380         */
1381        @Child(name = "origin", type = {Location.class}, order=2, min=0, max=1, modifier=false, summary=false)
1382        @Description(shortDefinition="The location from which the patient came before admission", formalDefinition="The location from which the patient came before admission." )
1383        protected Reference origin;
1384
1385        /**
1386         * The actual object that is the target of the reference (The location from which the patient came before admission.)
1387         */
1388        protected Location originTarget;
1389
1390        /**
1391         * From where patient was admitted (physician referral, transfer).
1392         */
1393        @Child(name = "admitSource", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=false)
1394        @Description(shortDefinition="From where patient was admitted (physician referral, transfer)", formalDefinition="From where patient was admitted (physician referral, transfer)." )
1395        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/encounter-admit-source")
1396        protected CodeableConcept admitSource;
1397
1398        /**
1399         * Whether this hospitalization is a readmission and why if known.
1400         */
1401        @Child(name = "reAdmission", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=false)
1402        @Description(shortDefinition="The type of hospital re-admission that has occurred (if any). If the value is absent, then this is not identified as a readmission", formalDefinition="Whether this hospitalization is a readmission and why if known." )
1403        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/v2-0092")
1404        protected CodeableConcept reAdmission;
1405
1406        /**
1407         * Diet preferences reported by the patient.
1408         */
1409        @Child(name = "dietPreference", type = {CodeableConcept.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1410        @Description(shortDefinition="Diet preferences reported by the patient", formalDefinition="Diet preferences reported by the patient." )
1411        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/encounter-diet")
1412        protected List<CodeableConcept> dietPreference;
1413
1414        /**
1415         * Special courtesies (VIP, board member).
1416         */
1417        @Child(name = "specialCourtesy", type = {CodeableConcept.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1418        @Description(shortDefinition="Special courtesies (VIP, board member)", formalDefinition="Special courtesies (VIP, board member)." )
1419        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/encounter-special-courtesy")
1420        protected List<CodeableConcept> specialCourtesy;
1421
1422        /**
1423         * Any special requests that have been made for this hospitalization encounter, such as the provision of specific equipment or other things.
1424         */
1425        @Child(name = "specialArrangement", type = {CodeableConcept.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1426        @Description(shortDefinition="Wheelchair, translator, stretcher, etc.", formalDefinition="Any special requests that have been made for this hospitalization encounter, such as the provision of specific equipment or other things." )
1427        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/encounter-special-arrangements")
1428        protected List<CodeableConcept> specialArrangement;
1429
1430        /**
1431         * Location to which the patient is discharged.
1432         */
1433        @Child(name = "destination", type = {Location.class}, order=8, min=0, max=1, modifier=false, summary=false)
1434        @Description(shortDefinition="Location to which the patient is discharged", formalDefinition="Location to which the patient is discharged." )
1435        protected Reference destination;
1436
1437        /**
1438         * The actual object that is the target of the reference (Location to which the patient is discharged.)
1439         */
1440        protected Location destinationTarget;
1441
1442        /**
1443         * Category or kind of location after discharge.
1444         */
1445        @Child(name = "dischargeDisposition", type = {CodeableConcept.class}, order=9, min=0, max=1, modifier=false, summary=false)
1446        @Description(shortDefinition="Category or kind of location after discharge", formalDefinition="Category or kind of location after discharge." )
1447        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/encounter-discharge-disposition")
1448        protected CodeableConcept dischargeDisposition;
1449
1450        private static final long serialVersionUID = -1165804076L;
1451
1452    /**
1453     * Constructor
1454     */
1455      public EncounterHospitalizationComponent() {
1456        super();
1457      }
1458
1459        /**
1460         * @return {@link #preAdmissionIdentifier} (Pre-admission identifier.)
1461         */
1462        public Identifier getPreAdmissionIdentifier() { 
1463          if (this.preAdmissionIdentifier == null)
1464            if (Configuration.errorOnAutoCreate())
1465              throw new Error("Attempt to auto-create EncounterHospitalizationComponent.preAdmissionIdentifier");
1466            else if (Configuration.doAutoCreate())
1467              this.preAdmissionIdentifier = new Identifier(); // cc
1468          return this.preAdmissionIdentifier;
1469        }
1470
1471        public boolean hasPreAdmissionIdentifier() { 
1472          return this.preAdmissionIdentifier != null && !this.preAdmissionIdentifier.isEmpty();
1473        }
1474
1475        /**
1476         * @param value {@link #preAdmissionIdentifier} (Pre-admission identifier.)
1477         */
1478        public EncounterHospitalizationComponent setPreAdmissionIdentifier(Identifier value) { 
1479          this.preAdmissionIdentifier = value;
1480          return this;
1481        }
1482
1483        /**
1484         * @return {@link #origin} (The location from which the patient came before admission.)
1485         */
1486        public Reference getOrigin() { 
1487          if (this.origin == null)
1488            if (Configuration.errorOnAutoCreate())
1489              throw new Error("Attempt to auto-create EncounterHospitalizationComponent.origin");
1490            else if (Configuration.doAutoCreate())
1491              this.origin = new Reference(); // cc
1492          return this.origin;
1493        }
1494
1495        public boolean hasOrigin() { 
1496          return this.origin != null && !this.origin.isEmpty();
1497        }
1498
1499        /**
1500         * @param value {@link #origin} (The location from which the patient came before admission.)
1501         */
1502        public EncounterHospitalizationComponent setOrigin(Reference value) { 
1503          this.origin = value;
1504          return this;
1505        }
1506
1507        /**
1508         * @return {@link #origin} 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 location from which the patient came before admission.)
1509         */
1510        public Location getOriginTarget() { 
1511          if (this.originTarget == null)
1512            if (Configuration.errorOnAutoCreate())
1513              throw new Error("Attempt to auto-create EncounterHospitalizationComponent.origin");
1514            else if (Configuration.doAutoCreate())
1515              this.originTarget = new Location(); // aa
1516          return this.originTarget;
1517        }
1518
1519        /**
1520         * @param value {@link #origin} 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 location from which the patient came before admission.)
1521         */
1522        public EncounterHospitalizationComponent setOriginTarget(Location value) { 
1523          this.originTarget = value;
1524          return this;
1525        }
1526
1527        /**
1528         * @return {@link #admitSource} (From where patient was admitted (physician referral, transfer).)
1529         */
1530        public CodeableConcept getAdmitSource() { 
1531          if (this.admitSource == null)
1532            if (Configuration.errorOnAutoCreate())
1533              throw new Error("Attempt to auto-create EncounterHospitalizationComponent.admitSource");
1534            else if (Configuration.doAutoCreate())
1535              this.admitSource = new CodeableConcept(); // cc
1536          return this.admitSource;
1537        }
1538
1539        public boolean hasAdmitSource() { 
1540          return this.admitSource != null && !this.admitSource.isEmpty();
1541        }
1542
1543        /**
1544         * @param value {@link #admitSource} (From where patient was admitted (physician referral, transfer).)
1545         */
1546        public EncounterHospitalizationComponent setAdmitSource(CodeableConcept value) { 
1547          this.admitSource = value;
1548          return this;
1549        }
1550
1551        /**
1552         * @return {@link #reAdmission} (Whether this hospitalization is a readmission and why if known.)
1553         */
1554        public CodeableConcept getReAdmission() { 
1555          if (this.reAdmission == null)
1556            if (Configuration.errorOnAutoCreate())
1557              throw new Error("Attempt to auto-create EncounterHospitalizationComponent.reAdmission");
1558            else if (Configuration.doAutoCreate())
1559              this.reAdmission = new CodeableConcept(); // cc
1560          return this.reAdmission;
1561        }
1562
1563        public boolean hasReAdmission() { 
1564          return this.reAdmission != null && !this.reAdmission.isEmpty();
1565        }
1566
1567        /**
1568         * @param value {@link #reAdmission} (Whether this hospitalization is a readmission and why if known.)
1569         */
1570        public EncounterHospitalizationComponent setReAdmission(CodeableConcept value) { 
1571          this.reAdmission = value;
1572          return this;
1573        }
1574
1575        /**
1576         * @return {@link #dietPreference} (Diet preferences reported by the patient.)
1577         */
1578        public List<CodeableConcept> getDietPreference() { 
1579          if (this.dietPreference == null)
1580            this.dietPreference = new ArrayList<CodeableConcept>();
1581          return this.dietPreference;
1582        }
1583
1584        /**
1585         * @return Returns a reference to <code>this</code> for easy method chaining
1586         */
1587        public EncounterHospitalizationComponent setDietPreference(List<CodeableConcept> theDietPreference) { 
1588          this.dietPreference = theDietPreference;
1589          return this;
1590        }
1591
1592        public boolean hasDietPreference() { 
1593          if (this.dietPreference == null)
1594            return false;
1595          for (CodeableConcept item : this.dietPreference)
1596            if (!item.isEmpty())
1597              return true;
1598          return false;
1599        }
1600
1601        public CodeableConcept addDietPreference() { //3
1602          CodeableConcept t = new CodeableConcept();
1603          if (this.dietPreference == null)
1604            this.dietPreference = new ArrayList<CodeableConcept>();
1605          this.dietPreference.add(t);
1606          return t;
1607        }
1608
1609        public EncounterHospitalizationComponent addDietPreference(CodeableConcept t) { //3
1610          if (t == null)
1611            return this;
1612          if (this.dietPreference == null)
1613            this.dietPreference = new ArrayList<CodeableConcept>();
1614          this.dietPreference.add(t);
1615          return this;
1616        }
1617
1618        /**
1619         * @return The first repetition of repeating field {@link #dietPreference}, creating it if it does not already exist
1620         */
1621        public CodeableConcept getDietPreferenceFirstRep() { 
1622          if (getDietPreference().isEmpty()) {
1623            addDietPreference();
1624          }
1625          return getDietPreference().get(0);
1626        }
1627
1628        /**
1629         * @return {@link #specialCourtesy} (Special courtesies (VIP, board member).)
1630         */
1631        public List<CodeableConcept> getSpecialCourtesy() { 
1632          if (this.specialCourtesy == null)
1633            this.specialCourtesy = new ArrayList<CodeableConcept>();
1634          return this.specialCourtesy;
1635        }
1636
1637        /**
1638         * @return Returns a reference to <code>this</code> for easy method chaining
1639         */
1640        public EncounterHospitalizationComponent setSpecialCourtesy(List<CodeableConcept> theSpecialCourtesy) { 
1641          this.specialCourtesy = theSpecialCourtesy;
1642          return this;
1643        }
1644
1645        public boolean hasSpecialCourtesy() { 
1646          if (this.specialCourtesy == null)
1647            return false;
1648          for (CodeableConcept item : this.specialCourtesy)
1649            if (!item.isEmpty())
1650              return true;
1651          return false;
1652        }
1653
1654        public CodeableConcept addSpecialCourtesy() { //3
1655          CodeableConcept t = new CodeableConcept();
1656          if (this.specialCourtesy == null)
1657            this.specialCourtesy = new ArrayList<CodeableConcept>();
1658          this.specialCourtesy.add(t);
1659          return t;
1660        }
1661
1662        public EncounterHospitalizationComponent addSpecialCourtesy(CodeableConcept t) { //3
1663          if (t == null)
1664            return this;
1665          if (this.specialCourtesy == null)
1666            this.specialCourtesy = new ArrayList<CodeableConcept>();
1667          this.specialCourtesy.add(t);
1668          return this;
1669        }
1670
1671        /**
1672         * @return The first repetition of repeating field {@link #specialCourtesy}, creating it if it does not already exist
1673         */
1674        public CodeableConcept getSpecialCourtesyFirstRep() { 
1675          if (getSpecialCourtesy().isEmpty()) {
1676            addSpecialCourtesy();
1677          }
1678          return getSpecialCourtesy().get(0);
1679        }
1680
1681        /**
1682         * @return {@link #specialArrangement} (Any special requests that have been made for this hospitalization encounter, such as the provision of specific equipment or other things.)
1683         */
1684        public List<CodeableConcept> getSpecialArrangement() { 
1685          if (this.specialArrangement == null)
1686            this.specialArrangement = new ArrayList<CodeableConcept>();
1687          return this.specialArrangement;
1688        }
1689
1690        /**
1691         * @return Returns a reference to <code>this</code> for easy method chaining
1692         */
1693        public EncounterHospitalizationComponent setSpecialArrangement(List<CodeableConcept> theSpecialArrangement) { 
1694          this.specialArrangement = theSpecialArrangement;
1695          return this;
1696        }
1697
1698        public boolean hasSpecialArrangement() { 
1699          if (this.specialArrangement == null)
1700            return false;
1701          for (CodeableConcept item : this.specialArrangement)
1702            if (!item.isEmpty())
1703              return true;
1704          return false;
1705        }
1706
1707        public CodeableConcept addSpecialArrangement() { //3
1708          CodeableConcept t = new CodeableConcept();
1709          if (this.specialArrangement == null)
1710            this.specialArrangement = new ArrayList<CodeableConcept>();
1711          this.specialArrangement.add(t);
1712          return t;
1713        }
1714
1715        public EncounterHospitalizationComponent addSpecialArrangement(CodeableConcept t) { //3
1716          if (t == null)
1717            return this;
1718          if (this.specialArrangement == null)
1719            this.specialArrangement = new ArrayList<CodeableConcept>();
1720          this.specialArrangement.add(t);
1721          return this;
1722        }
1723
1724        /**
1725         * @return The first repetition of repeating field {@link #specialArrangement}, creating it if it does not already exist
1726         */
1727        public CodeableConcept getSpecialArrangementFirstRep() { 
1728          if (getSpecialArrangement().isEmpty()) {
1729            addSpecialArrangement();
1730          }
1731          return getSpecialArrangement().get(0);
1732        }
1733
1734        /**
1735         * @return {@link #destination} (Location to which the patient is discharged.)
1736         */
1737        public Reference getDestination() { 
1738          if (this.destination == null)
1739            if (Configuration.errorOnAutoCreate())
1740              throw new Error("Attempt to auto-create EncounterHospitalizationComponent.destination");
1741            else if (Configuration.doAutoCreate())
1742              this.destination = new Reference(); // cc
1743          return this.destination;
1744        }
1745
1746        public boolean hasDestination() { 
1747          return this.destination != null && !this.destination.isEmpty();
1748        }
1749
1750        /**
1751         * @param value {@link #destination} (Location to which the patient is discharged.)
1752         */
1753        public EncounterHospitalizationComponent setDestination(Reference value) { 
1754          this.destination = value;
1755          return this;
1756        }
1757
1758        /**
1759         * @return {@link #destination} 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. (Location to which the patient is discharged.)
1760         */
1761        public Location getDestinationTarget() { 
1762          if (this.destinationTarget == null)
1763            if (Configuration.errorOnAutoCreate())
1764              throw new Error("Attempt to auto-create EncounterHospitalizationComponent.destination");
1765            else if (Configuration.doAutoCreate())
1766              this.destinationTarget = new Location(); // aa
1767          return this.destinationTarget;
1768        }
1769
1770        /**
1771         * @param value {@link #destination} 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. (Location to which the patient is discharged.)
1772         */
1773        public EncounterHospitalizationComponent setDestinationTarget(Location value) { 
1774          this.destinationTarget = value;
1775          return this;
1776        }
1777
1778        /**
1779         * @return {@link #dischargeDisposition} (Category or kind of location after discharge.)
1780         */
1781        public CodeableConcept getDischargeDisposition() { 
1782          if (this.dischargeDisposition == null)
1783            if (Configuration.errorOnAutoCreate())
1784              throw new Error("Attempt to auto-create EncounterHospitalizationComponent.dischargeDisposition");
1785            else if (Configuration.doAutoCreate())
1786              this.dischargeDisposition = new CodeableConcept(); // cc
1787          return this.dischargeDisposition;
1788        }
1789
1790        public boolean hasDischargeDisposition() { 
1791          return this.dischargeDisposition != null && !this.dischargeDisposition.isEmpty();
1792        }
1793
1794        /**
1795         * @param value {@link #dischargeDisposition} (Category or kind of location after discharge.)
1796         */
1797        public EncounterHospitalizationComponent setDischargeDisposition(CodeableConcept value) { 
1798          this.dischargeDisposition = value;
1799          return this;
1800        }
1801
1802        protected void listChildren(List<Property> childrenList) {
1803          super.listChildren(childrenList);
1804          childrenList.add(new Property("preAdmissionIdentifier", "Identifier", "Pre-admission identifier.", 0, java.lang.Integer.MAX_VALUE, preAdmissionIdentifier));
1805          childrenList.add(new Property("origin", "Reference(Location)", "The location from which the patient came before admission.", 0, java.lang.Integer.MAX_VALUE, origin));
1806          childrenList.add(new Property("admitSource", "CodeableConcept", "From where patient was admitted (physician referral, transfer).", 0, java.lang.Integer.MAX_VALUE, admitSource));
1807          childrenList.add(new Property("reAdmission", "CodeableConcept", "Whether this hospitalization is a readmission and why if known.", 0, java.lang.Integer.MAX_VALUE, reAdmission));
1808          childrenList.add(new Property("dietPreference", "CodeableConcept", "Diet preferences reported by the patient.", 0, java.lang.Integer.MAX_VALUE, dietPreference));
1809          childrenList.add(new Property("specialCourtesy", "CodeableConcept", "Special courtesies (VIP, board member).", 0, java.lang.Integer.MAX_VALUE, specialCourtesy));
1810          childrenList.add(new Property("specialArrangement", "CodeableConcept", "Any special requests that have been made for this hospitalization encounter, such as the provision of specific equipment or other things.", 0, java.lang.Integer.MAX_VALUE, specialArrangement));
1811          childrenList.add(new Property("destination", "Reference(Location)", "Location to which the patient is discharged.", 0, java.lang.Integer.MAX_VALUE, destination));
1812          childrenList.add(new Property("dischargeDisposition", "CodeableConcept", "Category or kind of location after discharge.", 0, java.lang.Integer.MAX_VALUE, dischargeDisposition));
1813        }
1814
1815      @Override
1816      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1817        switch (hash) {
1818        case -965394961: /*preAdmissionIdentifier*/ return this.preAdmissionIdentifier == null ? new Base[0] : new Base[] {this.preAdmissionIdentifier}; // Identifier
1819        case -1008619738: /*origin*/ return this.origin == null ? new Base[0] : new Base[] {this.origin}; // Reference
1820        case 538887120: /*admitSource*/ return this.admitSource == null ? new Base[0] : new Base[] {this.admitSource}; // CodeableConcept
1821        case 669348630: /*reAdmission*/ return this.reAdmission == null ? new Base[0] : new Base[] {this.reAdmission}; // CodeableConcept
1822        case -1360641041: /*dietPreference*/ return this.dietPreference == null ? new Base[0] : this.dietPreference.toArray(new Base[this.dietPreference.size()]); // CodeableConcept
1823        case 1583588345: /*specialCourtesy*/ return this.specialCourtesy == null ? new Base[0] : this.specialCourtesy.toArray(new Base[this.specialCourtesy.size()]); // CodeableConcept
1824        case 47410321: /*specialArrangement*/ return this.specialArrangement == null ? new Base[0] : this.specialArrangement.toArray(new Base[this.specialArrangement.size()]); // CodeableConcept
1825        case -1429847026: /*destination*/ return this.destination == null ? new Base[0] : new Base[] {this.destination}; // Reference
1826        case 528065941: /*dischargeDisposition*/ return this.dischargeDisposition == null ? new Base[0] : new Base[] {this.dischargeDisposition}; // CodeableConcept
1827        default: return super.getProperty(hash, name, checkValid);
1828        }
1829
1830      }
1831
1832      @Override
1833      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1834        switch (hash) {
1835        case -965394961: // preAdmissionIdentifier
1836          this.preAdmissionIdentifier = castToIdentifier(value); // Identifier
1837          return value;
1838        case -1008619738: // origin
1839          this.origin = castToReference(value); // Reference
1840          return value;
1841        case 538887120: // admitSource
1842          this.admitSource = castToCodeableConcept(value); // CodeableConcept
1843          return value;
1844        case 669348630: // reAdmission
1845          this.reAdmission = castToCodeableConcept(value); // CodeableConcept
1846          return value;
1847        case -1360641041: // dietPreference
1848          this.getDietPreference().add(castToCodeableConcept(value)); // CodeableConcept
1849          return value;
1850        case 1583588345: // specialCourtesy
1851          this.getSpecialCourtesy().add(castToCodeableConcept(value)); // CodeableConcept
1852          return value;
1853        case 47410321: // specialArrangement
1854          this.getSpecialArrangement().add(castToCodeableConcept(value)); // CodeableConcept
1855          return value;
1856        case -1429847026: // destination
1857          this.destination = castToReference(value); // Reference
1858          return value;
1859        case 528065941: // dischargeDisposition
1860          this.dischargeDisposition = castToCodeableConcept(value); // CodeableConcept
1861          return value;
1862        default: return super.setProperty(hash, name, value);
1863        }
1864
1865      }
1866
1867      @Override
1868      public Base setProperty(String name, Base value) throws FHIRException {
1869        if (name.equals("preAdmissionIdentifier")) {
1870          this.preAdmissionIdentifier = castToIdentifier(value); // Identifier
1871        } else if (name.equals("origin")) {
1872          this.origin = castToReference(value); // Reference
1873        } else if (name.equals("admitSource")) {
1874          this.admitSource = castToCodeableConcept(value); // CodeableConcept
1875        } else if (name.equals("reAdmission")) {
1876          this.reAdmission = castToCodeableConcept(value); // CodeableConcept
1877        } else if (name.equals("dietPreference")) {
1878          this.getDietPreference().add(castToCodeableConcept(value));
1879        } else if (name.equals("specialCourtesy")) {
1880          this.getSpecialCourtesy().add(castToCodeableConcept(value));
1881        } else if (name.equals("specialArrangement")) {
1882          this.getSpecialArrangement().add(castToCodeableConcept(value));
1883        } else if (name.equals("destination")) {
1884          this.destination = castToReference(value); // Reference
1885        } else if (name.equals("dischargeDisposition")) {
1886          this.dischargeDisposition = castToCodeableConcept(value); // CodeableConcept
1887        } else
1888          return super.setProperty(name, value);
1889        return value;
1890      }
1891
1892      @Override
1893      public Base makeProperty(int hash, String name) throws FHIRException {
1894        switch (hash) {
1895        case -965394961:  return getPreAdmissionIdentifier(); 
1896        case -1008619738:  return getOrigin(); 
1897        case 538887120:  return getAdmitSource(); 
1898        case 669348630:  return getReAdmission(); 
1899        case -1360641041:  return addDietPreference(); 
1900        case 1583588345:  return addSpecialCourtesy(); 
1901        case 47410321:  return addSpecialArrangement(); 
1902        case -1429847026:  return getDestination(); 
1903        case 528065941:  return getDischargeDisposition(); 
1904        default: return super.makeProperty(hash, name);
1905        }
1906
1907      }
1908
1909      @Override
1910      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1911        switch (hash) {
1912        case -965394961: /*preAdmissionIdentifier*/ return new String[] {"Identifier"};
1913        case -1008619738: /*origin*/ return new String[] {"Reference"};
1914        case 538887120: /*admitSource*/ return new String[] {"CodeableConcept"};
1915        case 669348630: /*reAdmission*/ return new String[] {"CodeableConcept"};
1916        case -1360641041: /*dietPreference*/ return new String[] {"CodeableConcept"};
1917        case 1583588345: /*specialCourtesy*/ return new String[] {"CodeableConcept"};
1918        case 47410321: /*specialArrangement*/ return new String[] {"CodeableConcept"};
1919        case -1429847026: /*destination*/ return new String[] {"Reference"};
1920        case 528065941: /*dischargeDisposition*/ return new String[] {"CodeableConcept"};
1921        default: return super.getTypesForProperty(hash, name);
1922        }
1923
1924      }
1925
1926      @Override
1927      public Base addChild(String name) throws FHIRException {
1928        if (name.equals("preAdmissionIdentifier")) {
1929          this.preAdmissionIdentifier = new Identifier();
1930          return this.preAdmissionIdentifier;
1931        }
1932        else if (name.equals("origin")) {
1933          this.origin = new Reference();
1934          return this.origin;
1935        }
1936        else if (name.equals("admitSource")) {
1937          this.admitSource = new CodeableConcept();
1938          return this.admitSource;
1939        }
1940        else if (name.equals("reAdmission")) {
1941          this.reAdmission = new CodeableConcept();
1942          return this.reAdmission;
1943        }
1944        else if (name.equals("dietPreference")) {
1945          return addDietPreference();
1946        }
1947        else if (name.equals("specialCourtesy")) {
1948          return addSpecialCourtesy();
1949        }
1950        else if (name.equals("specialArrangement")) {
1951          return addSpecialArrangement();
1952        }
1953        else if (name.equals("destination")) {
1954          this.destination = new Reference();
1955          return this.destination;
1956        }
1957        else if (name.equals("dischargeDisposition")) {
1958          this.dischargeDisposition = new CodeableConcept();
1959          return this.dischargeDisposition;
1960        }
1961        else
1962          return super.addChild(name);
1963      }
1964
1965      public EncounterHospitalizationComponent copy() {
1966        EncounterHospitalizationComponent dst = new EncounterHospitalizationComponent();
1967        copyValues(dst);
1968        dst.preAdmissionIdentifier = preAdmissionIdentifier == null ? null : preAdmissionIdentifier.copy();
1969        dst.origin = origin == null ? null : origin.copy();
1970        dst.admitSource = admitSource == null ? null : admitSource.copy();
1971        dst.reAdmission = reAdmission == null ? null : reAdmission.copy();
1972        if (dietPreference != null) {
1973          dst.dietPreference = new ArrayList<CodeableConcept>();
1974          for (CodeableConcept i : dietPreference)
1975            dst.dietPreference.add(i.copy());
1976        };
1977        if (specialCourtesy != null) {
1978          dst.specialCourtesy = new ArrayList<CodeableConcept>();
1979          for (CodeableConcept i : specialCourtesy)
1980            dst.specialCourtesy.add(i.copy());
1981        };
1982        if (specialArrangement != null) {
1983          dst.specialArrangement = new ArrayList<CodeableConcept>();
1984          for (CodeableConcept i : specialArrangement)
1985            dst.specialArrangement.add(i.copy());
1986        };
1987        dst.destination = destination == null ? null : destination.copy();
1988        dst.dischargeDisposition = dischargeDisposition == null ? null : dischargeDisposition.copy();
1989        return dst;
1990      }
1991
1992      @Override
1993      public boolean equalsDeep(Base other) {
1994        if (!super.equalsDeep(other))
1995          return false;
1996        if (!(other instanceof EncounterHospitalizationComponent))
1997          return false;
1998        EncounterHospitalizationComponent o = (EncounterHospitalizationComponent) other;
1999        return compareDeep(preAdmissionIdentifier, o.preAdmissionIdentifier, true) && compareDeep(origin, o.origin, true)
2000           && compareDeep(admitSource, o.admitSource, true) && compareDeep(reAdmission, o.reAdmission, true)
2001           && compareDeep(dietPreference, o.dietPreference, true) && compareDeep(specialCourtesy, o.specialCourtesy, true)
2002           && compareDeep(specialArrangement, o.specialArrangement, true) && compareDeep(destination, o.destination, true)
2003           && compareDeep(dischargeDisposition, o.dischargeDisposition, true);
2004      }
2005
2006      @Override
2007      public boolean equalsShallow(Base other) {
2008        if (!super.equalsShallow(other))
2009          return false;
2010        if (!(other instanceof EncounterHospitalizationComponent))
2011          return false;
2012        EncounterHospitalizationComponent o = (EncounterHospitalizationComponent) other;
2013        return true;
2014      }
2015
2016      public boolean isEmpty() {
2017        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(preAdmissionIdentifier, origin
2018          , admitSource, reAdmission, dietPreference, specialCourtesy, specialArrangement, destination
2019          , dischargeDisposition);
2020      }
2021
2022  public String fhirType() {
2023    return "Encounter.hospitalization";
2024
2025  }
2026
2027  }
2028
2029    @Block()
2030    public static class EncounterLocationComponent extends BackboneElement implements IBaseBackboneElement {
2031        /**
2032         * The location where the encounter takes place.
2033         */
2034        @Child(name = "location", type = {Location.class}, order=1, min=1, max=1, modifier=false, summary=false)
2035        @Description(shortDefinition="Location the encounter takes place", formalDefinition="The location where the encounter takes place." )
2036        protected Reference location;
2037
2038        /**
2039         * The actual object that is the target of the reference (The location where the encounter takes place.)
2040         */
2041        protected Location locationTarget;
2042
2043        /**
2044         * The status of the participants' presence at the specified location during the period specified. If the participant is is no longer at the location, then the period will have an end date/time.
2045         */
2046        @Child(name = "status", type = {CodeType.class}, order=2, min=0, max=1, modifier=false, summary=false)
2047        @Description(shortDefinition="planned | active | reserved | completed", formalDefinition="The status of the participants' presence at the specified location during the period specified. If the participant is is no longer at the location, then the period will have an end date/time." )
2048        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/encounter-location-status")
2049        protected Enumeration<EncounterLocationStatus> status;
2050
2051        /**
2052         * Time period during which the patient was present at the location.
2053         */
2054        @Child(name = "period", type = {Period.class}, order=3, min=0, max=1, modifier=false, summary=false)
2055        @Description(shortDefinition="Time period during which the patient was present at the location", formalDefinition="Time period during which the patient was present at the location." )
2056        protected Period period;
2057
2058        private static final long serialVersionUID = -322984880L;
2059
2060    /**
2061     * Constructor
2062     */
2063      public EncounterLocationComponent() {
2064        super();
2065      }
2066
2067    /**
2068     * Constructor
2069     */
2070      public EncounterLocationComponent(Reference location) {
2071        super();
2072        this.location = location;
2073      }
2074
2075        /**
2076         * @return {@link #location} (The location where the encounter takes place.)
2077         */
2078        public Reference getLocation() { 
2079          if (this.location == null)
2080            if (Configuration.errorOnAutoCreate())
2081              throw new Error("Attempt to auto-create EncounterLocationComponent.location");
2082            else if (Configuration.doAutoCreate())
2083              this.location = new Reference(); // cc
2084          return this.location;
2085        }
2086
2087        public boolean hasLocation() { 
2088          return this.location != null && !this.location.isEmpty();
2089        }
2090
2091        /**
2092         * @param value {@link #location} (The location where the encounter takes place.)
2093         */
2094        public EncounterLocationComponent setLocation(Reference value) { 
2095          this.location = value;
2096          return this;
2097        }
2098
2099        /**
2100         * @return {@link #location} 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 location where the encounter takes place.)
2101         */
2102        public Location getLocationTarget() { 
2103          if (this.locationTarget == null)
2104            if (Configuration.errorOnAutoCreate())
2105              throw new Error("Attempt to auto-create EncounterLocationComponent.location");
2106            else if (Configuration.doAutoCreate())
2107              this.locationTarget = new Location(); // aa
2108          return this.locationTarget;
2109        }
2110
2111        /**
2112         * @param value {@link #location} 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 location where the encounter takes place.)
2113         */
2114        public EncounterLocationComponent setLocationTarget(Location value) { 
2115          this.locationTarget = value;
2116          return this;
2117        }
2118
2119        /**
2120         * @return {@link #status} (The status of the participants' presence at the specified location during the period specified. If the participant is is no longer at the location, then the period will have an end date/time.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
2121         */
2122        public Enumeration<EncounterLocationStatus> getStatusElement() { 
2123          if (this.status == null)
2124            if (Configuration.errorOnAutoCreate())
2125              throw new Error("Attempt to auto-create EncounterLocationComponent.status");
2126            else if (Configuration.doAutoCreate())
2127              this.status = new Enumeration<EncounterLocationStatus>(new EncounterLocationStatusEnumFactory()); // bb
2128          return this.status;
2129        }
2130
2131        public boolean hasStatusElement() { 
2132          return this.status != null && !this.status.isEmpty();
2133        }
2134
2135        public boolean hasStatus() { 
2136          return this.status != null && !this.status.isEmpty();
2137        }
2138
2139        /**
2140         * @param value {@link #status} (The status of the participants' presence at the specified location during the period specified. If the participant is is no longer at the location, then the period will have an end date/time.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
2141         */
2142        public EncounterLocationComponent setStatusElement(Enumeration<EncounterLocationStatus> value) { 
2143          this.status = value;
2144          return this;
2145        }
2146
2147        /**
2148         * @return The status of the participants' presence at the specified location during the period specified. If the participant is is no longer at the location, then the period will have an end date/time.
2149         */
2150        public EncounterLocationStatus getStatus() { 
2151          return this.status == null ? null : this.status.getValue();
2152        }
2153
2154        /**
2155         * @param value The status of the participants' presence at the specified location during the period specified. If the participant is is no longer at the location, then the period will have an end date/time.
2156         */
2157        public EncounterLocationComponent setStatus(EncounterLocationStatus value) { 
2158          if (value == null)
2159            this.status = null;
2160          else {
2161            if (this.status == null)
2162              this.status = new Enumeration<EncounterLocationStatus>(new EncounterLocationStatusEnumFactory());
2163            this.status.setValue(value);
2164          }
2165          return this;
2166        }
2167
2168        /**
2169         * @return {@link #period} (Time period during which the patient was present at the location.)
2170         */
2171        public Period getPeriod() { 
2172          if (this.period == null)
2173            if (Configuration.errorOnAutoCreate())
2174              throw new Error("Attempt to auto-create EncounterLocationComponent.period");
2175            else if (Configuration.doAutoCreate())
2176              this.period = new Period(); // cc
2177          return this.period;
2178        }
2179
2180        public boolean hasPeriod() { 
2181          return this.period != null && !this.period.isEmpty();
2182        }
2183
2184        /**
2185         * @param value {@link #period} (Time period during which the patient was present at the location.)
2186         */
2187        public EncounterLocationComponent setPeriod(Period value) { 
2188          this.period = value;
2189          return this;
2190        }
2191
2192        protected void listChildren(List<Property> childrenList) {
2193          super.listChildren(childrenList);
2194          childrenList.add(new Property("location", "Reference(Location)", "The location where the encounter takes place.", 0, java.lang.Integer.MAX_VALUE, location));
2195          childrenList.add(new Property("status", "code", "The status of the participants' presence at the specified location during the period specified. If the participant is is no longer at the location, then the period will have an end date/time.", 0, java.lang.Integer.MAX_VALUE, status));
2196          childrenList.add(new Property("period", "Period", "Time period during which the patient was present at the location.", 0, java.lang.Integer.MAX_VALUE, period));
2197        }
2198
2199      @Override
2200      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2201        switch (hash) {
2202        case 1901043637: /*location*/ return this.location == null ? new Base[0] : new Base[] {this.location}; // Reference
2203        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<EncounterLocationStatus>
2204        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
2205        default: return super.getProperty(hash, name, checkValid);
2206        }
2207
2208      }
2209
2210      @Override
2211      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2212        switch (hash) {
2213        case 1901043637: // location
2214          this.location = castToReference(value); // Reference
2215          return value;
2216        case -892481550: // status
2217          value = new EncounterLocationStatusEnumFactory().fromType(castToCode(value));
2218          this.status = (Enumeration) value; // Enumeration<EncounterLocationStatus>
2219          return value;
2220        case -991726143: // period
2221          this.period = castToPeriod(value); // Period
2222          return value;
2223        default: return super.setProperty(hash, name, value);
2224        }
2225
2226      }
2227
2228      @Override
2229      public Base setProperty(String name, Base value) throws FHIRException {
2230        if (name.equals("location")) {
2231          this.location = castToReference(value); // Reference
2232        } else if (name.equals("status")) {
2233          value = new EncounterLocationStatusEnumFactory().fromType(castToCode(value));
2234          this.status = (Enumeration) value; // Enumeration<EncounterLocationStatus>
2235        } else if (name.equals("period")) {
2236          this.period = castToPeriod(value); // Period
2237        } else
2238          return super.setProperty(name, value);
2239        return value;
2240      }
2241
2242      @Override
2243      public Base makeProperty(int hash, String name) throws FHIRException {
2244        switch (hash) {
2245        case 1901043637:  return getLocation(); 
2246        case -892481550:  return getStatusElement();
2247        case -991726143:  return getPeriod(); 
2248        default: return super.makeProperty(hash, name);
2249        }
2250
2251      }
2252
2253      @Override
2254      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2255        switch (hash) {
2256        case 1901043637: /*location*/ return new String[] {"Reference"};
2257        case -892481550: /*status*/ return new String[] {"code"};
2258        case -991726143: /*period*/ return new String[] {"Period"};
2259        default: return super.getTypesForProperty(hash, name);
2260        }
2261
2262      }
2263
2264      @Override
2265      public Base addChild(String name) throws FHIRException {
2266        if (name.equals("location")) {
2267          this.location = new Reference();
2268          return this.location;
2269        }
2270        else if (name.equals("status")) {
2271          throw new FHIRException("Cannot call addChild on a primitive type Encounter.status");
2272        }
2273        else if (name.equals("period")) {
2274          this.period = new Period();
2275          return this.period;
2276        }
2277        else
2278          return super.addChild(name);
2279      }
2280
2281      public EncounterLocationComponent copy() {
2282        EncounterLocationComponent dst = new EncounterLocationComponent();
2283        copyValues(dst);
2284        dst.location = location == null ? null : location.copy();
2285        dst.status = status == null ? null : status.copy();
2286        dst.period = period == null ? null : period.copy();
2287        return dst;
2288      }
2289
2290      @Override
2291      public boolean equalsDeep(Base other) {
2292        if (!super.equalsDeep(other))
2293          return false;
2294        if (!(other instanceof EncounterLocationComponent))
2295          return false;
2296        EncounterLocationComponent o = (EncounterLocationComponent) other;
2297        return compareDeep(location, o.location, true) && compareDeep(status, o.status, true) && compareDeep(period, o.period, true)
2298          ;
2299      }
2300
2301      @Override
2302      public boolean equalsShallow(Base other) {
2303        if (!super.equalsShallow(other))
2304          return false;
2305        if (!(other instanceof EncounterLocationComponent))
2306          return false;
2307        EncounterLocationComponent o = (EncounterLocationComponent) other;
2308        return compareValues(status, o.status, true);
2309      }
2310
2311      public boolean isEmpty() {
2312        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(location, status, period
2313          );
2314      }
2315
2316  public String fhirType() {
2317    return "Encounter.location";
2318
2319  }
2320
2321  }
2322
2323    /**
2324     * Identifier(s) by which this encounter is known.
2325     */
2326    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2327    @Description(shortDefinition="Identifier(s) by which this encounter is known", formalDefinition="Identifier(s) by which this encounter is known." )
2328    protected List<Identifier> identifier;
2329
2330    /**
2331     * planned | arrived | triaged | in-progress | onleave | finished | cancelled +.
2332     */
2333    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
2334    @Description(shortDefinition="planned | arrived | triaged | in-progress | onleave | finished | cancelled +", formalDefinition="planned | arrived | triaged | in-progress | onleave | finished | cancelled +." )
2335    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/encounter-status")
2336    protected Enumeration<EncounterStatus> status;
2337
2338    /**
2339     * The status history permits the encounter resource to contain the status history without needing to read through the historical versions of the resource, or even have the server store them.
2340     */
2341    @Child(name = "statusHistory", type = {}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2342    @Description(shortDefinition="List of past encounter statuses", formalDefinition="The status history permits the encounter resource to contain the status history without needing to read through the historical versions of the resource, or even have the server store them." )
2343    protected List<StatusHistoryComponent> statusHistory;
2344
2345    /**
2346     * inpatient | outpatient | ambulatory | emergency +.
2347     */
2348    @Child(name = "class", type = {Coding.class}, order=3, min=0, max=1, modifier=false, summary=true)
2349    @Description(shortDefinition="inpatient | outpatient | ambulatory | emergency +", formalDefinition="inpatient | outpatient | ambulatory | emergency +." )
2350    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/v3-ActEncounterCode")
2351    protected Coding class_;
2352
2353    /**
2354     * The class history permits the tracking of the encounters transitions without needing to go  through the resource history.
2355
2356This would be used for a case where an admission starts of as an emergency encounter, then transisions into an inpatient scenario. Doing this and not restarting a new encounter ensures that any lab/diagnostic results can more easily follow the patient and not require re-processing and not get lost or cancelled during a kindof discharge from emergency to inpatient.
2357     */
2358    @Child(name = "classHistory", type = {}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2359    @Description(shortDefinition="List of past encounter classes", formalDefinition="The class history permits the tracking of the encounters transitions without needing to go  through the resource history.\n\nThis would be used for a case where an admission starts of as an emergency encounter, then transisions into an inpatient scenario. Doing this and not restarting a new encounter ensures that any lab/diagnostic results can more easily follow the patient and not require re-processing and not get lost or cancelled during a kindof discharge from emergency to inpatient." )
2360    protected List<ClassHistoryComponent> classHistory;
2361
2362    /**
2363     * Specific type of encounter (e.g. e-mail consultation, surgical day-care, skilled nursing, rehabilitation).
2364     */
2365    @Child(name = "type", type = {CodeableConcept.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2366    @Description(shortDefinition="Specific type of encounter", formalDefinition="Specific type of encounter (e.g. e-mail consultation, surgical day-care, skilled nursing, rehabilitation)." )
2367    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/encounter-type")
2368    protected List<CodeableConcept> type;
2369
2370    /**
2371     * Indicates the urgency of the encounter.
2372     */
2373    @Child(name = "priority", type = {CodeableConcept.class}, order=6, min=0, max=1, modifier=false, summary=false)
2374    @Description(shortDefinition="Indicates the urgency of the encounter", formalDefinition="Indicates the urgency of the encounter." )
2375    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/v3-ActPriority")
2376    protected CodeableConcept priority;
2377
2378    /**
2379     * The patient ro group present at the encounter.
2380     */
2381    @Child(name = "subject", type = {Patient.class, Group.class}, order=7, min=0, max=1, modifier=false, summary=true)
2382    @Description(shortDefinition="The patient ro group present at the encounter", formalDefinition="The patient ro group present at the encounter." )
2383    protected Reference subject;
2384
2385    /**
2386     * The actual object that is the target of the reference (The patient ro group present at the encounter.)
2387     */
2388    protected Resource subjectTarget;
2389
2390    /**
2391     * Where a specific encounter should be classified as a part of a specific episode(s) of care this field should be used. This association can facilitate grouping of related encounters together for a specific purpose, such as government reporting, issue tracking, association via a common problem.  The association is recorded on the encounter as these are typically created after the episode of care, and grouped on entry rather than editing the episode of care to append another encounter to it (the episode of care could span years).
2392     */
2393    @Child(name = "episodeOfCare", type = {EpisodeOfCare.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2394    @Description(shortDefinition="Episode(s) of care that this encounter should be recorded against", formalDefinition="Where a specific encounter should be classified as a part of a specific episode(s) of care this field should be used. This association can facilitate grouping of related encounters together for a specific purpose, such as government reporting, issue tracking, association via a common problem.  The association is recorded on the encounter as these are typically created after the episode of care, and grouped on entry rather than editing the episode of care to append another encounter to it (the episode of care could span years)." )
2395    protected List<Reference> episodeOfCare;
2396    /**
2397     * The actual objects that are the target of the reference (Where a specific encounter should be classified as a part of a specific episode(s) of care this field should be used. This association can facilitate grouping of related encounters together for a specific purpose, such as government reporting, issue tracking, association via a common problem.  The association is recorded on the encounter as these are typically created after the episode of care, and grouped on entry rather than editing the episode of care to append another encounter to it (the episode of care could span years).)
2398     */
2399    protected List<EpisodeOfCare> episodeOfCareTarget;
2400
2401
2402    /**
2403     * The referral request this encounter satisfies (incoming referral).
2404     */
2405    @Child(name = "incomingReferral", type = {ReferralRequest.class}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2406    @Description(shortDefinition="The ReferralRequest that initiated this encounter", formalDefinition="The referral request this encounter satisfies (incoming referral)." )
2407    protected List<Reference> incomingReferral;
2408    /**
2409     * The actual objects that are the target of the reference (The referral request this encounter satisfies (incoming referral).)
2410     */
2411    protected List<ReferralRequest> incomingReferralTarget;
2412
2413
2414    /**
2415     * The list of people responsible for providing the service.
2416     */
2417    @Child(name = "participant", type = {}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2418    @Description(shortDefinition="List of participants involved in the encounter", formalDefinition="The list of people responsible for providing the service." )
2419    protected List<EncounterParticipantComponent> participant;
2420
2421    /**
2422     * The appointment that scheduled this encounter.
2423     */
2424    @Child(name = "appointment", type = {Appointment.class}, order=11, min=0, max=1, modifier=false, summary=true)
2425    @Description(shortDefinition="The appointment that scheduled this encounter", formalDefinition="The appointment that scheduled this encounter." )
2426    protected Reference appointment;
2427
2428    /**
2429     * The actual object that is the target of the reference (The appointment that scheduled this encounter.)
2430     */
2431    protected Appointment appointmentTarget;
2432
2433    /**
2434     * The start and end time of the encounter.
2435     */
2436    @Child(name = "period", type = {Period.class}, order=12, min=0, max=1, modifier=false, summary=false)
2437    @Description(shortDefinition="The start and end time of the encounter", formalDefinition="The start and end time of the encounter." )
2438    protected Period period;
2439
2440    /**
2441     * Quantity of time the encounter lasted. This excludes the time during leaves of absence.
2442     */
2443    @Child(name = "length", type = {Duration.class}, order=13, min=0, max=1, modifier=false, summary=false)
2444    @Description(shortDefinition="Quantity of time the encounter lasted (less time absent)", formalDefinition="Quantity of time the encounter lasted. This excludes the time during leaves of absence." )
2445    protected Duration length;
2446
2447    /**
2448     * Reason the encounter takes place, expressed as a code. For admissions, this can be used for a coded admission diagnosis.
2449     */
2450    @Child(name = "reason", type = {CodeableConcept.class}, order=14, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2451    @Description(shortDefinition="Reason the encounter takes place (code)", formalDefinition="Reason the encounter takes place, expressed as a code. For admissions, this can be used for a coded admission diagnosis." )
2452    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/encounter-reason")
2453    protected List<CodeableConcept> reason;
2454
2455    /**
2456     * The list of diagnosis relevant to this encounter.
2457     */
2458    @Child(name = "diagnosis", type = {}, order=15, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2459    @Description(shortDefinition="The list of diagnosis relevant to this encounter", formalDefinition="The list of diagnosis relevant to this encounter." )
2460    protected List<DiagnosisComponent> diagnosis;
2461
2462    /**
2463     * The set of accounts that may be used for billing for this Encounter.
2464     */
2465    @Child(name = "account", type = {Account.class}, order=16, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2466    @Description(shortDefinition="The set of accounts that may be used for billing for this Encounter", formalDefinition="The set of accounts that may be used for billing for this Encounter." )
2467    protected List<Reference> account;
2468    /**
2469     * The actual objects that are the target of the reference (The set of accounts that may be used for billing for this Encounter.)
2470     */
2471    protected List<Account> accountTarget;
2472
2473
2474    /**
2475     * Details about the admission to a healthcare service.
2476     */
2477    @Child(name = "hospitalization", type = {}, order=17, min=0, max=1, modifier=false, summary=false)
2478    @Description(shortDefinition="Details about the admission to a healthcare service", formalDefinition="Details about the admission to a healthcare service." )
2479    protected EncounterHospitalizationComponent hospitalization;
2480
2481    /**
2482     * List of locations where  the patient has been during this encounter.
2483     */
2484    @Child(name = "location", type = {}, order=18, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2485    @Description(shortDefinition="List of locations where the patient has been", formalDefinition="List of locations where  the patient has been during this encounter." )
2486    protected List<EncounterLocationComponent> location;
2487
2488    /**
2489     * An organization that is in charge of maintaining the information of this Encounter (e.g. who maintains the report or the master service catalog item, etc.). This MAY be the same as the organization on the Patient record, however it could be different. This MAY not be not the Service Delivery Location's Organization.
2490     */
2491    @Child(name = "serviceProvider", type = {Organization.class}, order=19, min=0, max=1, modifier=false, summary=false)
2492    @Description(shortDefinition="The custodian organization of this Encounter record", formalDefinition="An organization that is in charge of maintaining the information of this Encounter (e.g. who maintains the report or the master service catalog item, etc.). This MAY be the same as the organization on the Patient record, however it could be different. This MAY not be not the Service Delivery Location's Organization." )
2493    protected Reference serviceProvider;
2494
2495    /**
2496     * The actual object that is the target of the reference (An organization that is in charge of maintaining the information of this Encounter (e.g. who maintains the report or the master service catalog item, etc.). This MAY be the same as the organization on the Patient record, however it could be different. This MAY not be not the Service Delivery Location's Organization.)
2497     */
2498    protected Organization serviceProviderTarget;
2499
2500    /**
2501     * Another Encounter of which this encounter is a part of (administratively or in time).
2502     */
2503    @Child(name = "partOf", type = {Encounter.class}, order=20, min=0, max=1, modifier=false, summary=false)
2504    @Description(shortDefinition="Another Encounter this encounter is part of", formalDefinition="Another Encounter of which this encounter is a part of (administratively or in time)." )
2505    protected Reference partOf;
2506
2507    /**
2508     * The actual object that is the target of the reference (Another Encounter of which this encounter is a part of (administratively or in time).)
2509     */
2510    protected Encounter partOfTarget;
2511
2512    private static final long serialVersionUID = 2124102382L;
2513
2514  /**
2515   * Constructor
2516   */
2517    public Encounter() {
2518      super();
2519    }
2520
2521  /**
2522   * Constructor
2523   */
2524    public Encounter(Enumeration<EncounterStatus> status) {
2525      super();
2526      this.status = status;
2527    }
2528
2529    /**
2530     * @return {@link #identifier} (Identifier(s) by which this encounter is known.)
2531     */
2532    public List<Identifier> getIdentifier() { 
2533      if (this.identifier == null)
2534        this.identifier = new ArrayList<Identifier>();
2535      return this.identifier;
2536    }
2537
2538    /**
2539     * @return Returns a reference to <code>this</code> for easy method chaining
2540     */
2541    public Encounter setIdentifier(List<Identifier> theIdentifier) { 
2542      this.identifier = theIdentifier;
2543      return this;
2544    }
2545
2546    public boolean hasIdentifier() { 
2547      if (this.identifier == null)
2548        return false;
2549      for (Identifier item : this.identifier)
2550        if (!item.isEmpty())
2551          return true;
2552      return false;
2553    }
2554
2555    public Identifier addIdentifier() { //3
2556      Identifier t = new Identifier();
2557      if (this.identifier == null)
2558        this.identifier = new ArrayList<Identifier>();
2559      this.identifier.add(t);
2560      return t;
2561    }
2562
2563    public Encounter addIdentifier(Identifier t) { //3
2564      if (t == null)
2565        return this;
2566      if (this.identifier == null)
2567        this.identifier = new ArrayList<Identifier>();
2568      this.identifier.add(t);
2569      return this;
2570    }
2571
2572    /**
2573     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
2574     */
2575    public Identifier getIdentifierFirstRep() { 
2576      if (getIdentifier().isEmpty()) {
2577        addIdentifier();
2578      }
2579      return getIdentifier().get(0);
2580    }
2581
2582    /**
2583     * @return {@link #status} (planned | arrived | triaged | in-progress | onleave | finished | cancelled +.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
2584     */
2585    public Enumeration<EncounterStatus> getStatusElement() { 
2586      if (this.status == null)
2587        if (Configuration.errorOnAutoCreate())
2588          throw new Error("Attempt to auto-create Encounter.status");
2589        else if (Configuration.doAutoCreate())
2590          this.status = new Enumeration<EncounterStatus>(new EncounterStatusEnumFactory()); // bb
2591      return this.status;
2592    }
2593
2594    public boolean hasStatusElement() { 
2595      return this.status != null && !this.status.isEmpty();
2596    }
2597
2598    public boolean hasStatus() { 
2599      return this.status != null && !this.status.isEmpty();
2600    }
2601
2602    /**
2603     * @param value {@link #status} (planned | arrived | triaged | in-progress | onleave | finished | cancelled +.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
2604     */
2605    public Encounter setStatusElement(Enumeration<EncounterStatus> value) { 
2606      this.status = value;
2607      return this;
2608    }
2609
2610    /**
2611     * @return planned | arrived | triaged | in-progress | onleave | finished | cancelled +.
2612     */
2613    public EncounterStatus getStatus() { 
2614      return this.status == null ? null : this.status.getValue();
2615    }
2616
2617    /**
2618     * @param value planned | arrived | triaged | in-progress | onleave | finished | cancelled +.
2619     */
2620    public Encounter setStatus(EncounterStatus value) { 
2621        if (this.status == null)
2622          this.status = new Enumeration<EncounterStatus>(new EncounterStatusEnumFactory());
2623        this.status.setValue(value);
2624      return this;
2625    }
2626
2627    /**
2628     * @return {@link #statusHistory} (The status history permits the encounter resource to contain the status history without needing to read through the historical versions of the resource, or even have the server store them.)
2629     */
2630    public List<StatusHistoryComponent> getStatusHistory() { 
2631      if (this.statusHistory == null)
2632        this.statusHistory = new ArrayList<StatusHistoryComponent>();
2633      return this.statusHistory;
2634    }
2635
2636    /**
2637     * @return Returns a reference to <code>this</code> for easy method chaining
2638     */
2639    public Encounter setStatusHistory(List<StatusHistoryComponent> theStatusHistory) { 
2640      this.statusHistory = theStatusHistory;
2641      return this;
2642    }
2643
2644    public boolean hasStatusHistory() { 
2645      if (this.statusHistory == null)
2646        return false;
2647      for (StatusHistoryComponent item : this.statusHistory)
2648        if (!item.isEmpty())
2649          return true;
2650      return false;
2651    }
2652
2653    public StatusHistoryComponent addStatusHistory() { //3
2654      StatusHistoryComponent t = new StatusHistoryComponent();
2655      if (this.statusHistory == null)
2656        this.statusHistory = new ArrayList<StatusHistoryComponent>();
2657      this.statusHistory.add(t);
2658      return t;
2659    }
2660
2661    public Encounter addStatusHistory(StatusHistoryComponent t) { //3
2662      if (t == null)
2663        return this;
2664      if (this.statusHistory == null)
2665        this.statusHistory = new ArrayList<StatusHistoryComponent>();
2666      this.statusHistory.add(t);
2667      return this;
2668    }
2669
2670    /**
2671     * @return The first repetition of repeating field {@link #statusHistory}, creating it if it does not already exist
2672     */
2673    public StatusHistoryComponent getStatusHistoryFirstRep() { 
2674      if (getStatusHistory().isEmpty()) {
2675        addStatusHistory();
2676      }
2677      return getStatusHistory().get(0);
2678    }
2679
2680    /**
2681     * @return {@link #class_} (inpatient | outpatient | ambulatory | emergency +.)
2682     */
2683    public Coding getClass_() { 
2684      if (this.class_ == null)
2685        if (Configuration.errorOnAutoCreate())
2686          throw new Error("Attempt to auto-create Encounter.class_");
2687        else if (Configuration.doAutoCreate())
2688          this.class_ = new Coding(); // cc
2689      return this.class_;
2690    }
2691
2692    public boolean hasClass_() { 
2693      return this.class_ != null && !this.class_.isEmpty();
2694    }
2695
2696    /**
2697     * @param value {@link #class_} (inpatient | outpatient | ambulatory | emergency +.)
2698     */
2699    public Encounter setClass_(Coding value) { 
2700      this.class_ = value;
2701      return this;
2702    }
2703
2704    /**
2705     * @return {@link #classHistory} (The class history permits the tracking of the encounters transitions without needing to go  through the resource history.
2706
2707This would be used for a case where an admission starts of as an emergency encounter, then transisions into an inpatient scenario. Doing this and not restarting a new encounter ensures that any lab/diagnostic results can more easily follow the patient and not require re-processing and not get lost or cancelled during a kindof discharge from emergency to inpatient.)
2708     */
2709    public List<ClassHistoryComponent> getClassHistory() { 
2710      if (this.classHistory == null)
2711        this.classHistory = new ArrayList<ClassHistoryComponent>();
2712      return this.classHistory;
2713    }
2714
2715    /**
2716     * @return Returns a reference to <code>this</code> for easy method chaining
2717     */
2718    public Encounter setClassHistory(List<ClassHistoryComponent> theClassHistory) { 
2719      this.classHistory = theClassHistory;
2720      return this;
2721    }
2722
2723    public boolean hasClassHistory() { 
2724      if (this.classHistory == null)
2725        return false;
2726      for (ClassHistoryComponent item : this.classHistory)
2727        if (!item.isEmpty())
2728          return true;
2729      return false;
2730    }
2731
2732    public ClassHistoryComponent addClassHistory() { //3
2733      ClassHistoryComponent t = new ClassHistoryComponent();
2734      if (this.classHistory == null)
2735        this.classHistory = new ArrayList<ClassHistoryComponent>();
2736      this.classHistory.add(t);
2737      return t;
2738    }
2739
2740    public Encounter addClassHistory(ClassHistoryComponent t) { //3
2741      if (t == null)
2742        return this;
2743      if (this.classHistory == null)
2744        this.classHistory = new ArrayList<ClassHistoryComponent>();
2745      this.classHistory.add(t);
2746      return this;
2747    }
2748
2749    /**
2750     * @return The first repetition of repeating field {@link #classHistory}, creating it if it does not already exist
2751     */
2752    public ClassHistoryComponent getClassHistoryFirstRep() { 
2753      if (getClassHistory().isEmpty()) {
2754        addClassHistory();
2755      }
2756      return getClassHistory().get(0);
2757    }
2758
2759    /**
2760     * @return {@link #type} (Specific type of encounter (e.g. e-mail consultation, surgical day-care, skilled nursing, rehabilitation).)
2761     */
2762    public List<CodeableConcept> getType() { 
2763      if (this.type == null)
2764        this.type = new ArrayList<CodeableConcept>();
2765      return this.type;
2766    }
2767
2768    /**
2769     * @return Returns a reference to <code>this</code> for easy method chaining
2770     */
2771    public Encounter setType(List<CodeableConcept> theType) { 
2772      this.type = theType;
2773      return this;
2774    }
2775
2776    public boolean hasType() { 
2777      if (this.type == null)
2778        return false;
2779      for (CodeableConcept item : this.type)
2780        if (!item.isEmpty())
2781          return true;
2782      return false;
2783    }
2784
2785    public CodeableConcept addType() { //3
2786      CodeableConcept t = new CodeableConcept();
2787      if (this.type == null)
2788        this.type = new ArrayList<CodeableConcept>();
2789      this.type.add(t);
2790      return t;
2791    }
2792
2793    public Encounter addType(CodeableConcept t) { //3
2794      if (t == null)
2795        return this;
2796      if (this.type == null)
2797        this.type = new ArrayList<CodeableConcept>();
2798      this.type.add(t);
2799      return this;
2800    }
2801
2802    /**
2803     * @return The first repetition of repeating field {@link #type}, creating it if it does not already exist
2804     */
2805    public CodeableConcept getTypeFirstRep() { 
2806      if (getType().isEmpty()) {
2807        addType();
2808      }
2809      return getType().get(0);
2810    }
2811
2812    /**
2813     * @return {@link #priority} (Indicates the urgency of the encounter.)
2814     */
2815    public CodeableConcept getPriority() { 
2816      if (this.priority == null)
2817        if (Configuration.errorOnAutoCreate())
2818          throw new Error("Attempt to auto-create Encounter.priority");
2819        else if (Configuration.doAutoCreate())
2820          this.priority = new CodeableConcept(); // cc
2821      return this.priority;
2822    }
2823
2824    public boolean hasPriority() { 
2825      return this.priority != null && !this.priority.isEmpty();
2826    }
2827
2828    /**
2829     * @param value {@link #priority} (Indicates the urgency of the encounter.)
2830     */
2831    public Encounter setPriority(CodeableConcept value) { 
2832      this.priority = value;
2833      return this;
2834    }
2835
2836    /**
2837     * @return {@link #subject} (The patient ro group present at the encounter.)
2838     */
2839    public Reference getSubject() { 
2840      if (this.subject == null)
2841        if (Configuration.errorOnAutoCreate())
2842          throw new Error("Attempt to auto-create Encounter.subject");
2843        else if (Configuration.doAutoCreate())
2844          this.subject = new Reference(); // cc
2845      return this.subject;
2846    }
2847
2848    public boolean hasSubject() { 
2849      return this.subject != null && !this.subject.isEmpty();
2850    }
2851
2852    /**
2853     * @param value {@link #subject} (The patient ro group present at the encounter.)
2854     */
2855    public Encounter setSubject(Reference value) { 
2856      this.subject = value;
2857      return this;
2858    }
2859
2860    /**
2861     * @return {@link #subject} 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 ro group present at the encounter.)
2862     */
2863    public Resource getSubjectTarget() { 
2864      return this.subjectTarget;
2865    }
2866
2867    /**
2868     * @param value {@link #subject} 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 ro group present at the encounter.)
2869     */
2870    public Encounter setSubjectTarget(Resource value) { 
2871      this.subjectTarget = value;
2872      return this;
2873    }
2874
2875    /**
2876     * @return {@link #episodeOfCare} (Where a specific encounter should be classified as a part of a specific episode(s) of care this field should be used. This association can facilitate grouping of related encounters together for a specific purpose, such as government reporting, issue tracking, association via a common problem.  The association is recorded on the encounter as these are typically created after the episode of care, and grouped on entry rather than editing the episode of care to append another encounter to it (the episode of care could span years).)
2877     */
2878    public List<Reference> getEpisodeOfCare() { 
2879      if (this.episodeOfCare == null)
2880        this.episodeOfCare = new ArrayList<Reference>();
2881      return this.episodeOfCare;
2882    }
2883
2884    /**
2885     * @return Returns a reference to <code>this</code> for easy method chaining
2886     */
2887    public Encounter setEpisodeOfCare(List<Reference> theEpisodeOfCare) { 
2888      this.episodeOfCare = theEpisodeOfCare;
2889      return this;
2890    }
2891
2892    public boolean hasEpisodeOfCare() { 
2893      if (this.episodeOfCare == null)
2894        return false;
2895      for (Reference item : this.episodeOfCare)
2896        if (!item.isEmpty())
2897          return true;
2898      return false;
2899    }
2900
2901    public Reference addEpisodeOfCare() { //3
2902      Reference t = new Reference();
2903      if (this.episodeOfCare == null)
2904        this.episodeOfCare = new ArrayList<Reference>();
2905      this.episodeOfCare.add(t);
2906      return t;
2907    }
2908
2909    public Encounter addEpisodeOfCare(Reference t) { //3
2910      if (t == null)
2911        return this;
2912      if (this.episodeOfCare == null)
2913        this.episodeOfCare = new ArrayList<Reference>();
2914      this.episodeOfCare.add(t);
2915      return this;
2916    }
2917
2918    /**
2919     * @return The first repetition of repeating field {@link #episodeOfCare}, creating it if it does not already exist
2920     */
2921    public Reference getEpisodeOfCareFirstRep() { 
2922      if (getEpisodeOfCare().isEmpty()) {
2923        addEpisodeOfCare();
2924      }
2925      return getEpisodeOfCare().get(0);
2926    }
2927
2928    /**
2929     * @deprecated Use Reference#setResource(IBaseResource) instead
2930     */
2931    @Deprecated
2932    public List<EpisodeOfCare> getEpisodeOfCareTarget() { 
2933      if (this.episodeOfCareTarget == null)
2934        this.episodeOfCareTarget = new ArrayList<EpisodeOfCare>();
2935      return this.episodeOfCareTarget;
2936    }
2937
2938    /**
2939     * @deprecated Use Reference#setResource(IBaseResource) instead
2940     */
2941    @Deprecated
2942    public EpisodeOfCare addEpisodeOfCareTarget() { 
2943      EpisodeOfCare r = new EpisodeOfCare();
2944      if (this.episodeOfCareTarget == null)
2945        this.episodeOfCareTarget = new ArrayList<EpisodeOfCare>();
2946      this.episodeOfCareTarget.add(r);
2947      return r;
2948    }
2949
2950    /**
2951     * @return {@link #incomingReferral} (The referral request this encounter satisfies (incoming referral).)
2952     */
2953    public List<Reference> getIncomingReferral() { 
2954      if (this.incomingReferral == null)
2955        this.incomingReferral = new ArrayList<Reference>();
2956      return this.incomingReferral;
2957    }
2958
2959    /**
2960     * @return Returns a reference to <code>this</code> for easy method chaining
2961     */
2962    public Encounter setIncomingReferral(List<Reference> theIncomingReferral) { 
2963      this.incomingReferral = theIncomingReferral;
2964      return this;
2965    }
2966
2967    public boolean hasIncomingReferral() { 
2968      if (this.incomingReferral == null)
2969        return false;
2970      for (Reference item : this.incomingReferral)
2971        if (!item.isEmpty())
2972          return true;
2973      return false;
2974    }
2975
2976    public Reference addIncomingReferral() { //3
2977      Reference t = new Reference();
2978      if (this.incomingReferral == null)
2979        this.incomingReferral = new ArrayList<Reference>();
2980      this.incomingReferral.add(t);
2981      return t;
2982    }
2983
2984    public Encounter addIncomingReferral(Reference t) { //3
2985      if (t == null)
2986        return this;
2987      if (this.incomingReferral == null)
2988        this.incomingReferral = new ArrayList<Reference>();
2989      this.incomingReferral.add(t);
2990      return this;
2991    }
2992
2993    /**
2994     * @return The first repetition of repeating field {@link #incomingReferral}, creating it if it does not already exist
2995     */
2996    public Reference getIncomingReferralFirstRep() { 
2997      if (getIncomingReferral().isEmpty()) {
2998        addIncomingReferral();
2999      }
3000      return getIncomingReferral().get(0);
3001    }
3002
3003    /**
3004     * @deprecated Use Reference#setResource(IBaseResource) instead
3005     */
3006    @Deprecated
3007    public List<ReferralRequest> getIncomingReferralTarget() { 
3008      if (this.incomingReferralTarget == null)
3009        this.incomingReferralTarget = new ArrayList<ReferralRequest>();
3010      return this.incomingReferralTarget;
3011    }
3012
3013    /**
3014     * @deprecated Use Reference#setResource(IBaseResource) instead
3015     */
3016    @Deprecated
3017    public ReferralRequest addIncomingReferralTarget() { 
3018      ReferralRequest r = new ReferralRequest();
3019      if (this.incomingReferralTarget == null)
3020        this.incomingReferralTarget = new ArrayList<ReferralRequest>();
3021      this.incomingReferralTarget.add(r);
3022      return r;
3023    }
3024
3025    /**
3026     * @return {@link #participant} (The list of people responsible for providing the service.)
3027     */
3028    public List<EncounterParticipantComponent> getParticipant() { 
3029      if (this.participant == null)
3030        this.participant = new ArrayList<EncounterParticipantComponent>();
3031      return this.participant;
3032    }
3033
3034    /**
3035     * @return Returns a reference to <code>this</code> for easy method chaining
3036     */
3037    public Encounter setParticipant(List<EncounterParticipantComponent> theParticipant) { 
3038      this.participant = theParticipant;
3039      return this;
3040    }
3041
3042    public boolean hasParticipant() { 
3043      if (this.participant == null)
3044        return false;
3045      for (EncounterParticipantComponent item : this.participant)
3046        if (!item.isEmpty())
3047          return true;
3048      return false;
3049    }
3050
3051    public EncounterParticipantComponent addParticipant() { //3
3052      EncounterParticipantComponent t = new EncounterParticipantComponent();
3053      if (this.participant == null)
3054        this.participant = new ArrayList<EncounterParticipantComponent>();
3055      this.participant.add(t);
3056      return t;
3057    }
3058
3059    public Encounter addParticipant(EncounterParticipantComponent t) { //3
3060      if (t == null)
3061        return this;
3062      if (this.participant == null)
3063        this.participant = new ArrayList<EncounterParticipantComponent>();
3064      this.participant.add(t);
3065      return this;
3066    }
3067
3068    /**
3069     * @return The first repetition of repeating field {@link #participant}, creating it if it does not already exist
3070     */
3071    public EncounterParticipantComponent getParticipantFirstRep() { 
3072      if (getParticipant().isEmpty()) {
3073        addParticipant();
3074      }
3075      return getParticipant().get(0);
3076    }
3077
3078    /**
3079     * @return {@link #appointment} (The appointment that scheduled this encounter.)
3080     */
3081    public Reference getAppointment() { 
3082      if (this.appointment == null)
3083        if (Configuration.errorOnAutoCreate())
3084          throw new Error("Attempt to auto-create Encounter.appointment");
3085        else if (Configuration.doAutoCreate())
3086          this.appointment = new Reference(); // cc
3087      return this.appointment;
3088    }
3089
3090    public boolean hasAppointment() { 
3091      return this.appointment != null && !this.appointment.isEmpty();
3092    }
3093
3094    /**
3095     * @param value {@link #appointment} (The appointment that scheduled this encounter.)
3096     */
3097    public Encounter setAppointment(Reference value) { 
3098      this.appointment = value;
3099      return this;
3100    }
3101
3102    /**
3103     * @return {@link #appointment} 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 appointment that scheduled this encounter.)
3104     */
3105    public Appointment getAppointmentTarget() { 
3106      if (this.appointmentTarget == null)
3107        if (Configuration.errorOnAutoCreate())
3108          throw new Error("Attempt to auto-create Encounter.appointment");
3109        else if (Configuration.doAutoCreate())
3110          this.appointmentTarget = new Appointment(); // aa
3111      return this.appointmentTarget;
3112    }
3113
3114    /**
3115     * @param value {@link #appointment} 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 appointment that scheduled this encounter.)
3116     */
3117    public Encounter setAppointmentTarget(Appointment value) { 
3118      this.appointmentTarget = value;
3119      return this;
3120    }
3121
3122    /**
3123     * @return {@link #period} (The start and end time of the encounter.)
3124     */
3125    public Period getPeriod() { 
3126      if (this.period == null)
3127        if (Configuration.errorOnAutoCreate())
3128          throw new Error("Attempt to auto-create Encounter.period");
3129        else if (Configuration.doAutoCreate())
3130          this.period = new Period(); // cc
3131      return this.period;
3132    }
3133
3134    public boolean hasPeriod() { 
3135      return this.period != null && !this.period.isEmpty();
3136    }
3137
3138    /**
3139     * @param value {@link #period} (The start and end time of the encounter.)
3140     */
3141    public Encounter setPeriod(Period value) { 
3142      this.period = value;
3143      return this;
3144    }
3145
3146    /**
3147     * @return {@link #length} (Quantity of time the encounter lasted. This excludes the time during leaves of absence.)
3148     */
3149    public Duration getLength() { 
3150      if (this.length == null)
3151        if (Configuration.errorOnAutoCreate())
3152          throw new Error("Attempt to auto-create Encounter.length");
3153        else if (Configuration.doAutoCreate())
3154          this.length = new Duration(); // cc
3155      return this.length;
3156    }
3157
3158    public boolean hasLength() { 
3159      return this.length != null && !this.length.isEmpty();
3160    }
3161
3162    /**
3163     * @param value {@link #length} (Quantity of time the encounter lasted. This excludes the time during leaves of absence.)
3164     */
3165    public Encounter setLength(Duration value) { 
3166      this.length = value;
3167      return this;
3168    }
3169
3170    /**
3171     * @return {@link #reason} (Reason the encounter takes place, expressed as a code. For admissions, this can be used for a coded admission diagnosis.)
3172     */
3173    public List<CodeableConcept> getReason() { 
3174      if (this.reason == null)
3175        this.reason = new ArrayList<CodeableConcept>();
3176      return this.reason;
3177    }
3178
3179    /**
3180     * @return Returns a reference to <code>this</code> for easy method chaining
3181     */
3182    public Encounter setReason(List<CodeableConcept> theReason) { 
3183      this.reason = theReason;
3184      return this;
3185    }
3186
3187    public boolean hasReason() { 
3188      if (this.reason == null)
3189        return false;
3190      for (CodeableConcept item : this.reason)
3191        if (!item.isEmpty())
3192          return true;
3193      return false;
3194    }
3195
3196    public CodeableConcept addReason() { //3
3197      CodeableConcept t = new CodeableConcept();
3198      if (this.reason == null)
3199        this.reason = new ArrayList<CodeableConcept>();
3200      this.reason.add(t);
3201      return t;
3202    }
3203
3204    public Encounter addReason(CodeableConcept t) { //3
3205      if (t == null)
3206        return this;
3207      if (this.reason == null)
3208        this.reason = new ArrayList<CodeableConcept>();
3209      this.reason.add(t);
3210      return this;
3211    }
3212
3213    /**
3214     * @return The first repetition of repeating field {@link #reason}, creating it if it does not already exist
3215     */
3216    public CodeableConcept getReasonFirstRep() { 
3217      if (getReason().isEmpty()) {
3218        addReason();
3219      }
3220      return getReason().get(0);
3221    }
3222
3223    /**
3224     * @return {@link #diagnosis} (The list of diagnosis relevant to this encounter.)
3225     */
3226    public List<DiagnosisComponent> getDiagnosis() { 
3227      if (this.diagnosis == null)
3228        this.diagnosis = new ArrayList<DiagnosisComponent>();
3229      return this.diagnosis;
3230    }
3231
3232    /**
3233     * @return Returns a reference to <code>this</code> for easy method chaining
3234     */
3235    public Encounter setDiagnosis(List<DiagnosisComponent> theDiagnosis) { 
3236      this.diagnosis = theDiagnosis;
3237      return this;
3238    }
3239
3240    public boolean hasDiagnosis() { 
3241      if (this.diagnosis == null)
3242        return false;
3243      for (DiagnosisComponent item : this.diagnosis)
3244        if (!item.isEmpty())
3245          return true;
3246      return false;
3247    }
3248
3249    public DiagnosisComponent addDiagnosis() { //3
3250      DiagnosisComponent t = new DiagnosisComponent();
3251      if (this.diagnosis == null)
3252        this.diagnosis = new ArrayList<DiagnosisComponent>();
3253      this.diagnosis.add(t);
3254      return t;
3255    }
3256
3257    public Encounter addDiagnosis(DiagnosisComponent t) { //3
3258      if (t == null)
3259        return this;
3260      if (this.diagnosis == null)
3261        this.diagnosis = new ArrayList<DiagnosisComponent>();
3262      this.diagnosis.add(t);
3263      return this;
3264    }
3265
3266    /**
3267     * @return The first repetition of repeating field {@link #diagnosis}, creating it if it does not already exist
3268     */
3269    public DiagnosisComponent getDiagnosisFirstRep() { 
3270      if (getDiagnosis().isEmpty()) {
3271        addDiagnosis();
3272      }
3273      return getDiagnosis().get(0);
3274    }
3275
3276    /**
3277     * @return {@link #account} (The set of accounts that may be used for billing for this Encounter.)
3278     */
3279    public List<Reference> getAccount() { 
3280      if (this.account == null)
3281        this.account = new ArrayList<Reference>();
3282      return this.account;
3283    }
3284
3285    /**
3286     * @return Returns a reference to <code>this</code> for easy method chaining
3287     */
3288    public Encounter setAccount(List<Reference> theAccount) { 
3289      this.account = theAccount;
3290      return this;
3291    }
3292
3293    public boolean hasAccount() { 
3294      if (this.account == null)
3295        return false;
3296      for (Reference item : this.account)
3297        if (!item.isEmpty())
3298          return true;
3299      return false;
3300    }
3301
3302    public Reference addAccount() { //3
3303      Reference t = new Reference();
3304      if (this.account == null)
3305        this.account = new ArrayList<Reference>();
3306      this.account.add(t);
3307      return t;
3308    }
3309
3310    public Encounter addAccount(Reference t) { //3
3311      if (t == null)
3312        return this;
3313      if (this.account == null)
3314        this.account = new ArrayList<Reference>();
3315      this.account.add(t);
3316      return this;
3317    }
3318
3319    /**
3320     * @return The first repetition of repeating field {@link #account}, creating it if it does not already exist
3321     */
3322    public Reference getAccountFirstRep() { 
3323      if (getAccount().isEmpty()) {
3324        addAccount();
3325      }
3326      return getAccount().get(0);
3327    }
3328
3329    /**
3330     * @deprecated Use Reference#setResource(IBaseResource) instead
3331     */
3332    @Deprecated
3333    public List<Account> getAccountTarget() { 
3334      if (this.accountTarget == null)
3335        this.accountTarget = new ArrayList<Account>();
3336      return this.accountTarget;
3337    }
3338
3339    /**
3340     * @deprecated Use Reference#setResource(IBaseResource) instead
3341     */
3342    @Deprecated
3343    public Account addAccountTarget() { 
3344      Account r = new Account();
3345      if (this.accountTarget == null)
3346        this.accountTarget = new ArrayList<Account>();
3347      this.accountTarget.add(r);
3348      return r;
3349    }
3350
3351    /**
3352     * @return {@link #hospitalization} (Details about the admission to a healthcare service.)
3353     */
3354    public EncounterHospitalizationComponent getHospitalization() { 
3355      if (this.hospitalization == null)
3356        if (Configuration.errorOnAutoCreate())
3357          throw new Error("Attempt to auto-create Encounter.hospitalization");
3358        else if (Configuration.doAutoCreate())
3359          this.hospitalization = new EncounterHospitalizationComponent(); // cc
3360      return this.hospitalization;
3361    }
3362
3363    public boolean hasHospitalization() { 
3364      return this.hospitalization != null && !this.hospitalization.isEmpty();
3365    }
3366
3367    /**
3368     * @param value {@link #hospitalization} (Details about the admission to a healthcare service.)
3369     */
3370    public Encounter setHospitalization(EncounterHospitalizationComponent value) { 
3371      this.hospitalization = value;
3372      return this;
3373    }
3374
3375    /**
3376     * @return {@link #location} (List of locations where  the patient has been during this encounter.)
3377     */
3378    public List<EncounterLocationComponent> getLocation() { 
3379      if (this.location == null)
3380        this.location = new ArrayList<EncounterLocationComponent>();
3381      return this.location;
3382    }
3383
3384    /**
3385     * @return Returns a reference to <code>this</code> for easy method chaining
3386     */
3387    public Encounter setLocation(List<EncounterLocationComponent> theLocation) { 
3388      this.location = theLocation;
3389      return this;
3390    }
3391
3392    public boolean hasLocation() { 
3393      if (this.location == null)
3394        return false;
3395      for (EncounterLocationComponent item : this.location)
3396        if (!item.isEmpty())
3397          return true;
3398      return false;
3399    }
3400
3401    public EncounterLocationComponent addLocation() { //3
3402      EncounterLocationComponent t = new EncounterLocationComponent();
3403      if (this.location == null)
3404        this.location = new ArrayList<EncounterLocationComponent>();
3405      this.location.add(t);
3406      return t;
3407    }
3408
3409    public Encounter addLocation(EncounterLocationComponent t) { //3
3410      if (t == null)
3411        return this;
3412      if (this.location == null)
3413        this.location = new ArrayList<EncounterLocationComponent>();
3414      this.location.add(t);
3415      return this;
3416    }
3417
3418    /**
3419     * @return The first repetition of repeating field {@link #location}, creating it if it does not already exist
3420     */
3421    public EncounterLocationComponent getLocationFirstRep() { 
3422      if (getLocation().isEmpty()) {
3423        addLocation();
3424      }
3425      return getLocation().get(0);
3426    }
3427
3428    /**
3429     * @return {@link #serviceProvider} (An organization that is in charge of maintaining the information of this Encounter (e.g. who maintains the report or the master service catalog item, etc.). This MAY be the same as the organization on the Patient record, however it could be different. This MAY not be not the Service Delivery Location's Organization.)
3430     */
3431    public Reference getServiceProvider() { 
3432      if (this.serviceProvider == null)
3433        if (Configuration.errorOnAutoCreate())
3434          throw new Error("Attempt to auto-create Encounter.serviceProvider");
3435        else if (Configuration.doAutoCreate())
3436          this.serviceProvider = new Reference(); // cc
3437      return this.serviceProvider;
3438    }
3439
3440    public boolean hasServiceProvider() { 
3441      return this.serviceProvider != null && !this.serviceProvider.isEmpty();
3442    }
3443
3444    /**
3445     * @param value {@link #serviceProvider} (An organization that is in charge of maintaining the information of this Encounter (e.g. who maintains the report or the master service catalog item, etc.). This MAY be the same as the organization on the Patient record, however it could be different. This MAY not be not the Service Delivery Location's Organization.)
3446     */
3447    public Encounter setServiceProvider(Reference value) { 
3448      this.serviceProvider = value;
3449      return this;
3450    }
3451
3452    /**
3453     * @return {@link #serviceProvider} 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. (An organization that is in charge of maintaining the information of this Encounter (e.g. who maintains the report or the master service catalog item, etc.). This MAY be the same as the organization on the Patient record, however it could be different. This MAY not be not the Service Delivery Location's Organization.)
3454     */
3455    public Organization getServiceProviderTarget() { 
3456      if (this.serviceProviderTarget == null)
3457        if (Configuration.errorOnAutoCreate())
3458          throw new Error("Attempt to auto-create Encounter.serviceProvider");
3459        else if (Configuration.doAutoCreate())
3460          this.serviceProviderTarget = new Organization(); // aa
3461      return this.serviceProviderTarget;
3462    }
3463
3464    /**
3465     * @param value {@link #serviceProvider} 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. (An organization that is in charge of maintaining the information of this Encounter (e.g. who maintains the report or the master service catalog item, etc.). This MAY be the same as the organization on the Patient record, however it could be different. This MAY not be not the Service Delivery Location's Organization.)
3466     */
3467    public Encounter setServiceProviderTarget(Organization value) { 
3468      this.serviceProviderTarget = value;
3469      return this;
3470    }
3471
3472    /**
3473     * @return {@link #partOf} (Another Encounter of which this encounter is a part of (administratively or in time).)
3474     */
3475    public Reference getPartOf() { 
3476      if (this.partOf == null)
3477        if (Configuration.errorOnAutoCreate())
3478          throw new Error("Attempt to auto-create Encounter.partOf");
3479        else if (Configuration.doAutoCreate())
3480          this.partOf = new Reference(); // cc
3481      return this.partOf;
3482    }
3483
3484    public boolean hasPartOf() { 
3485      return this.partOf != null && !this.partOf.isEmpty();
3486    }
3487
3488    /**
3489     * @param value {@link #partOf} (Another Encounter of which this encounter is a part of (administratively or in time).)
3490     */
3491    public Encounter setPartOf(Reference value) { 
3492      this.partOf = value;
3493      return this;
3494    }
3495
3496    /**
3497     * @return {@link #partOf} 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. (Another Encounter of which this encounter is a part of (administratively or in time).)
3498     */
3499    public Encounter getPartOfTarget() { 
3500      if (this.partOfTarget == null)
3501        if (Configuration.errorOnAutoCreate())
3502          throw new Error("Attempt to auto-create Encounter.partOf");
3503        else if (Configuration.doAutoCreate())
3504          this.partOfTarget = new Encounter(); // aa
3505      return this.partOfTarget;
3506    }
3507
3508    /**
3509     * @param value {@link #partOf} 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. (Another Encounter of which this encounter is a part of (administratively or in time).)
3510     */
3511    public Encounter setPartOfTarget(Encounter value) { 
3512      this.partOfTarget = value;
3513      return this;
3514    }
3515
3516      protected void listChildren(List<Property> childrenList) {
3517        super.listChildren(childrenList);
3518        childrenList.add(new Property("identifier", "Identifier", "Identifier(s) by which this encounter is known.", 0, java.lang.Integer.MAX_VALUE, identifier));
3519        childrenList.add(new Property("status", "code", "planned | arrived | triaged | in-progress | onleave | finished | cancelled +.", 0, java.lang.Integer.MAX_VALUE, status));
3520        childrenList.add(new Property("statusHistory", "", "The status history permits the encounter resource to contain the status history without needing to read through the historical versions of the resource, or even have the server store them.", 0, java.lang.Integer.MAX_VALUE, statusHistory));
3521        childrenList.add(new Property("class", "Coding", "inpatient | outpatient | ambulatory | emergency +.", 0, java.lang.Integer.MAX_VALUE, class_));
3522        childrenList.add(new Property("classHistory", "", "The class history permits the tracking of the encounters transitions without needing to go  through the resource history.\n\nThis would be used for a case where an admission starts of as an emergency encounter, then transisions into an inpatient scenario. Doing this and not restarting a new encounter ensures that any lab/diagnostic results can more easily follow the patient and not require re-processing and not get lost or cancelled during a kindof discharge from emergency to inpatient.", 0, java.lang.Integer.MAX_VALUE, classHistory));
3523        childrenList.add(new Property("type", "CodeableConcept", "Specific type of encounter (e.g. e-mail consultation, surgical day-care, skilled nursing, rehabilitation).", 0, java.lang.Integer.MAX_VALUE, type));
3524        childrenList.add(new Property("priority", "CodeableConcept", "Indicates the urgency of the encounter.", 0, java.lang.Integer.MAX_VALUE, priority));
3525        childrenList.add(new Property("subject", "Reference(Patient|Group)", "The patient ro group present at the encounter.", 0, java.lang.Integer.MAX_VALUE, subject));
3526        childrenList.add(new Property("episodeOfCare", "Reference(EpisodeOfCare)", "Where a specific encounter should be classified as a part of a specific episode(s) of care this field should be used. This association can facilitate grouping of related encounters together for a specific purpose, such as government reporting, issue tracking, association via a common problem.  The association is recorded on the encounter as these are typically created after the episode of care, and grouped on entry rather than editing the episode of care to append another encounter to it (the episode of care could span years).", 0, java.lang.Integer.MAX_VALUE, episodeOfCare));
3527        childrenList.add(new Property("incomingReferral", "Reference(ReferralRequest)", "The referral request this encounter satisfies (incoming referral).", 0, java.lang.Integer.MAX_VALUE, incomingReferral));
3528        childrenList.add(new Property("participant", "", "The list of people responsible for providing the service.", 0, java.lang.Integer.MAX_VALUE, participant));
3529        childrenList.add(new Property("appointment", "Reference(Appointment)", "The appointment that scheduled this encounter.", 0, java.lang.Integer.MAX_VALUE, appointment));
3530        childrenList.add(new Property("period", "Period", "The start and end time of the encounter.", 0, java.lang.Integer.MAX_VALUE, period));
3531        childrenList.add(new Property("length", "Duration", "Quantity of time the encounter lasted. This excludes the time during leaves of absence.", 0, java.lang.Integer.MAX_VALUE, length));
3532        childrenList.add(new Property("reason", "CodeableConcept", "Reason the encounter takes place, expressed as a code. For admissions, this can be used for a coded admission diagnosis.", 0, java.lang.Integer.MAX_VALUE, reason));
3533        childrenList.add(new Property("diagnosis", "", "The list of diagnosis relevant to this encounter.", 0, java.lang.Integer.MAX_VALUE, diagnosis));
3534        childrenList.add(new Property("account", "Reference(Account)", "The set of accounts that may be used for billing for this Encounter.", 0, java.lang.Integer.MAX_VALUE, account));
3535        childrenList.add(new Property("hospitalization", "", "Details about the admission to a healthcare service.", 0, java.lang.Integer.MAX_VALUE, hospitalization));
3536        childrenList.add(new Property("location", "", "List of locations where  the patient has been during this encounter.", 0, java.lang.Integer.MAX_VALUE, location));
3537        childrenList.add(new Property("serviceProvider", "Reference(Organization)", "An organization that is in charge of maintaining the information of this Encounter (e.g. who maintains the report or the master service catalog item, etc.). This MAY be the same as the organization on the Patient record, however it could be different. This MAY not be not the Service Delivery Location's Organization.", 0, java.lang.Integer.MAX_VALUE, serviceProvider));
3538        childrenList.add(new Property("partOf", "Reference(Encounter)", "Another Encounter of which this encounter is a part of (administratively or in time).", 0, java.lang.Integer.MAX_VALUE, partOf));
3539      }
3540
3541      @Override
3542      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
3543        switch (hash) {
3544        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
3545        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<EncounterStatus>
3546        case -986695614: /*statusHistory*/ return this.statusHistory == null ? new Base[0] : this.statusHistory.toArray(new Base[this.statusHistory.size()]); // StatusHistoryComponent
3547        case 94742904: /*class*/ return this.class_ == null ? new Base[0] : new Base[] {this.class_}; // Coding
3548        case 962575356: /*classHistory*/ return this.classHistory == null ? new Base[0] : this.classHistory.toArray(new Base[this.classHistory.size()]); // ClassHistoryComponent
3549        case 3575610: /*type*/ return this.type == null ? new Base[0] : this.type.toArray(new Base[this.type.size()]); // CodeableConcept
3550        case -1165461084: /*priority*/ return this.priority == null ? new Base[0] : new Base[] {this.priority}; // CodeableConcept
3551        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
3552        case -1892140189: /*episodeOfCare*/ return this.episodeOfCare == null ? new Base[0] : this.episodeOfCare.toArray(new Base[this.episodeOfCare.size()]); // Reference
3553        case -1258204701: /*incomingReferral*/ return this.incomingReferral == null ? new Base[0] : this.incomingReferral.toArray(new Base[this.incomingReferral.size()]); // Reference
3554        case 767422259: /*participant*/ return this.participant == null ? new Base[0] : this.participant.toArray(new Base[this.participant.size()]); // EncounterParticipantComponent
3555        case -1474995297: /*appointment*/ return this.appointment == null ? new Base[0] : new Base[] {this.appointment}; // Reference
3556        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
3557        case -1106363674: /*length*/ return this.length == null ? new Base[0] : new Base[] {this.length}; // Duration
3558        case -934964668: /*reason*/ return this.reason == null ? new Base[0] : this.reason.toArray(new Base[this.reason.size()]); // CodeableConcept
3559        case 1196993265: /*diagnosis*/ return this.diagnosis == null ? new Base[0] : this.diagnosis.toArray(new Base[this.diagnosis.size()]); // DiagnosisComponent
3560        case -1177318867: /*account*/ return this.account == null ? new Base[0] : this.account.toArray(new Base[this.account.size()]); // Reference
3561        case 1057894634: /*hospitalization*/ return this.hospitalization == null ? new Base[0] : new Base[] {this.hospitalization}; // EncounterHospitalizationComponent
3562        case 1901043637: /*location*/ return this.location == null ? new Base[0] : this.location.toArray(new Base[this.location.size()]); // EncounterLocationComponent
3563        case 243182534: /*serviceProvider*/ return this.serviceProvider == null ? new Base[0] : new Base[] {this.serviceProvider}; // Reference
3564        case -995410646: /*partOf*/ return this.partOf == null ? new Base[0] : new Base[] {this.partOf}; // Reference
3565        default: return super.getProperty(hash, name, checkValid);
3566        }
3567
3568      }
3569
3570      @Override
3571      public Base setProperty(int hash, String name, Base value) throws FHIRException {
3572        switch (hash) {
3573        case -1618432855: // identifier
3574          this.getIdentifier().add(castToIdentifier(value)); // Identifier
3575          return value;
3576        case -892481550: // status
3577          value = new EncounterStatusEnumFactory().fromType(castToCode(value));
3578          this.status = (Enumeration) value; // Enumeration<EncounterStatus>
3579          return value;
3580        case -986695614: // statusHistory
3581          this.getStatusHistory().add((StatusHistoryComponent) value); // StatusHistoryComponent
3582          return value;
3583        case 94742904: // class
3584          this.class_ = castToCoding(value); // Coding
3585          return value;
3586        case 962575356: // classHistory
3587          this.getClassHistory().add((ClassHistoryComponent) value); // ClassHistoryComponent
3588          return value;
3589        case 3575610: // type
3590          this.getType().add(castToCodeableConcept(value)); // CodeableConcept
3591          return value;
3592        case -1165461084: // priority
3593          this.priority = castToCodeableConcept(value); // CodeableConcept
3594          return value;
3595        case -1867885268: // subject
3596          this.subject = castToReference(value); // Reference
3597          return value;
3598        case -1892140189: // episodeOfCare
3599          this.getEpisodeOfCare().add(castToReference(value)); // Reference
3600          return value;
3601        case -1258204701: // incomingReferral
3602          this.getIncomingReferral().add(castToReference(value)); // Reference
3603          return value;
3604        case 767422259: // participant
3605          this.getParticipant().add((EncounterParticipantComponent) value); // EncounterParticipantComponent
3606          return value;
3607        case -1474995297: // appointment
3608          this.appointment = castToReference(value); // Reference
3609          return value;
3610        case -991726143: // period
3611          this.period = castToPeriod(value); // Period
3612          return value;
3613        case -1106363674: // length
3614          this.length = castToDuration(value); // Duration
3615          return value;
3616        case -934964668: // reason
3617          this.getReason().add(castToCodeableConcept(value)); // CodeableConcept
3618          return value;
3619        case 1196993265: // diagnosis
3620          this.getDiagnosis().add((DiagnosisComponent) value); // DiagnosisComponent
3621          return value;
3622        case -1177318867: // account
3623          this.getAccount().add(castToReference(value)); // Reference
3624          return value;
3625        case 1057894634: // hospitalization
3626          this.hospitalization = (EncounterHospitalizationComponent) value; // EncounterHospitalizationComponent
3627          return value;
3628        case 1901043637: // location
3629          this.getLocation().add((EncounterLocationComponent) value); // EncounterLocationComponent
3630          return value;
3631        case 243182534: // serviceProvider
3632          this.serviceProvider = castToReference(value); // Reference
3633          return value;
3634        case -995410646: // partOf
3635          this.partOf = castToReference(value); // Reference
3636          return value;
3637        default: return super.setProperty(hash, name, value);
3638        }
3639
3640      }
3641
3642      @Override
3643      public Base setProperty(String name, Base value) throws FHIRException {
3644        if (name.equals("identifier")) {
3645          this.getIdentifier().add(castToIdentifier(value));
3646        } else if (name.equals("status")) {
3647          value = new EncounterStatusEnumFactory().fromType(castToCode(value));
3648          this.status = (Enumeration) value; // Enumeration<EncounterStatus>
3649        } else if (name.equals("statusHistory")) {
3650          this.getStatusHistory().add((StatusHistoryComponent) value);
3651        } else if (name.equals("class")) {
3652          this.class_ = castToCoding(value); // Coding
3653        } else if (name.equals("classHistory")) {
3654          this.getClassHistory().add((ClassHistoryComponent) value);
3655        } else if (name.equals("type")) {
3656          this.getType().add(castToCodeableConcept(value));
3657        } else if (name.equals("priority")) {
3658          this.priority = castToCodeableConcept(value); // CodeableConcept
3659        } else if (name.equals("subject")) {
3660          this.subject = castToReference(value); // Reference
3661        } else if (name.equals("episodeOfCare")) {
3662          this.getEpisodeOfCare().add(castToReference(value));
3663        } else if (name.equals("incomingReferral")) {
3664          this.getIncomingReferral().add(castToReference(value));
3665        } else if (name.equals("participant")) {
3666          this.getParticipant().add((EncounterParticipantComponent) value);
3667        } else if (name.equals("appointment")) {
3668          this.appointment = castToReference(value); // Reference
3669        } else if (name.equals("period")) {
3670          this.period = castToPeriod(value); // Period
3671        } else if (name.equals("length")) {
3672          this.length = castToDuration(value); // Duration
3673        } else if (name.equals("reason")) {
3674          this.getReason().add(castToCodeableConcept(value));
3675        } else if (name.equals("diagnosis")) {
3676          this.getDiagnosis().add((DiagnosisComponent) value);
3677        } else if (name.equals("account")) {
3678          this.getAccount().add(castToReference(value));
3679        } else if (name.equals("hospitalization")) {
3680          this.hospitalization = (EncounterHospitalizationComponent) value; // EncounterHospitalizationComponent
3681        } else if (name.equals("location")) {
3682          this.getLocation().add((EncounterLocationComponent) value);
3683        } else if (name.equals("serviceProvider")) {
3684          this.serviceProvider = castToReference(value); // Reference
3685        } else if (name.equals("partOf")) {
3686          this.partOf = castToReference(value); // Reference
3687        } else
3688          return super.setProperty(name, value);
3689        return value;
3690      }
3691
3692      @Override
3693      public Base makeProperty(int hash, String name) throws FHIRException {
3694        switch (hash) {
3695        case -1618432855:  return addIdentifier(); 
3696        case -892481550:  return getStatusElement();
3697        case -986695614:  return addStatusHistory(); 
3698        case 94742904:  return getClass_(); 
3699        case 962575356:  return addClassHistory(); 
3700        case 3575610:  return addType(); 
3701        case -1165461084:  return getPriority(); 
3702        case -1867885268:  return getSubject(); 
3703        case -1892140189:  return addEpisodeOfCare(); 
3704        case -1258204701:  return addIncomingReferral(); 
3705        case 767422259:  return addParticipant(); 
3706        case -1474995297:  return getAppointment(); 
3707        case -991726143:  return getPeriod(); 
3708        case -1106363674:  return getLength(); 
3709        case -934964668:  return addReason(); 
3710        case 1196993265:  return addDiagnosis(); 
3711        case -1177318867:  return addAccount(); 
3712        case 1057894634:  return getHospitalization(); 
3713        case 1901043637:  return addLocation(); 
3714        case 243182534:  return getServiceProvider(); 
3715        case -995410646:  return getPartOf(); 
3716        default: return super.makeProperty(hash, name);
3717        }
3718
3719      }
3720
3721      @Override
3722      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
3723        switch (hash) {
3724        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
3725        case -892481550: /*status*/ return new String[] {"code"};
3726        case -986695614: /*statusHistory*/ return new String[] {};
3727        case 94742904: /*class*/ return new String[] {"Coding"};
3728        case 962575356: /*classHistory*/ return new String[] {};
3729        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
3730        case -1165461084: /*priority*/ return new String[] {"CodeableConcept"};
3731        case -1867885268: /*subject*/ return new String[] {"Reference"};
3732        case -1892140189: /*episodeOfCare*/ return new String[] {"Reference"};
3733        case -1258204701: /*incomingReferral*/ return new String[] {"Reference"};
3734        case 767422259: /*participant*/ return new String[] {};
3735        case -1474995297: /*appointment*/ return new String[] {"Reference"};
3736        case -991726143: /*period*/ return new String[] {"Period"};
3737        case -1106363674: /*length*/ return new String[] {"Duration"};
3738        case -934964668: /*reason*/ return new String[] {"CodeableConcept"};
3739        case 1196993265: /*diagnosis*/ return new String[] {};
3740        case -1177318867: /*account*/ return new String[] {"Reference"};
3741        case 1057894634: /*hospitalization*/ return new String[] {};
3742        case 1901043637: /*location*/ return new String[] {};
3743        case 243182534: /*serviceProvider*/ return new String[] {"Reference"};
3744        case -995410646: /*partOf*/ return new String[] {"Reference"};
3745        default: return super.getTypesForProperty(hash, name);
3746        }
3747
3748      }
3749
3750      @Override
3751      public Base addChild(String name) throws FHIRException {
3752        if (name.equals("identifier")) {
3753          return addIdentifier();
3754        }
3755        else if (name.equals("status")) {
3756          throw new FHIRException("Cannot call addChild on a primitive type Encounter.status");
3757        }
3758        else if (name.equals("statusHistory")) {
3759          return addStatusHistory();
3760        }
3761        else if (name.equals("class")) {
3762          this.class_ = new Coding();
3763          return this.class_;
3764        }
3765        else if (name.equals("classHistory")) {
3766          return addClassHistory();
3767        }
3768        else if (name.equals("type")) {
3769          return addType();
3770        }
3771        else if (name.equals("priority")) {
3772          this.priority = new CodeableConcept();
3773          return this.priority;
3774        }
3775        else if (name.equals("subject")) {
3776          this.subject = new Reference();
3777          return this.subject;
3778        }
3779        else if (name.equals("episodeOfCare")) {
3780          return addEpisodeOfCare();
3781        }
3782        else if (name.equals("incomingReferral")) {
3783          return addIncomingReferral();
3784        }
3785        else if (name.equals("participant")) {
3786          return addParticipant();
3787        }
3788        else if (name.equals("appointment")) {
3789          this.appointment = new Reference();
3790          return this.appointment;
3791        }
3792        else if (name.equals("period")) {
3793          this.period = new Period();
3794          return this.period;
3795        }
3796        else if (name.equals("length")) {
3797          this.length = new Duration();
3798          return this.length;
3799        }
3800        else if (name.equals("reason")) {
3801          return addReason();
3802        }
3803        else if (name.equals("diagnosis")) {
3804          return addDiagnosis();
3805        }
3806        else if (name.equals("account")) {
3807          return addAccount();
3808        }
3809        else if (name.equals("hospitalization")) {
3810          this.hospitalization = new EncounterHospitalizationComponent();
3811          return this.hospitalization;
3812        }
3813        else if (name.equals("location")) {
3814          return addLocation();
3815        }
3816        else if (name.equals("serviceProvider")) {
3817          this.serviceProvider = new Reference();
3818          return this.serviceProvider;
3819        }
3820        else if (name.equals("partOf")) {
3821          this.partOf = new Reference();
3822          return this.partOf;
3823        }
3824        else
3825          return super.addChild(name);
3826      }
3827
3828  public String fhirType() {
3829    return "Encounter";
3830
3831  }
3832
3833      public Encounter copy() {
3834        Encounter dst = new Encounter();
3835        copyValues(dst);
3836        if (identifier != null) {
3837          dst.identifier = new ArrayList<Identifier>();
3838          for (Identifier i : identifier)
3839            dst.identifier.add(i.copy());
3840        };
3841        dst.status = status == null ? null : status.copy();
3842        if (statusHistory != null) {
3843          dst.statusHistory = new ArrayList<StatusHistoryComponent>();
3844          for (StatusHistoryComponent i : statusHistory)
3845            dst.statusHistory.add(i.copy());
3846        };
3847        dst.class_ = class_ == null ? null : class_.copy();
3848        if (classHistory != null) {
3849          dst.classHistory = new ArrayList<ClassHistoryComponent>();
3850          for (ClassHistoryComponent i : classHistory)
3851            dst.classHistory.add(i.copy());
3852        };
3853        if (type != null) {
3854          dst.type = new ArrayList<CodeableConcept>();
3855          for (CodeableConcept i : type)
3856            dst.type.add(i.copy());
3857        };
3858        dst.priority = priority == null ? null : priority.copy();
3859        dst.subject = subject == null ? null : subject.copy();
3860        if (episodeOfCare != null) {
3861          dst.episodeOfCare = new ArrayList<Reference>();
3862          for (Reference i : episodeOfCare)
3863            dst.episodeOfCare.add(i.copy());
3864        };
3865        if (incomingReferral != null) {
3866          dst.incomingReferral = new ArrayList<Reference>();
3867          for (Reference i : incomingReferral)
3868            dst.incomingReferral.add(i.copy());
3869        };
3870        if (participant != null) {
3871          dst.participant = new ArrayList<EncounterParticipantComponent>();
3872          for (EncounterParticipantComponent i : participant)
3873            dst.participant.add(i.copy());
3874        };
3875        dst.appointment = appointment == null ? null : appointment.copy();
3876        dst.period = period == null ? null : period.copy();
3877        dst.length = length == null ? null : length.copy();
3878        if (reason != null) {
3879          dst.reason = new ArrayList<CodeableConcept>();
3880          for (CodeableConcept i : reason)
3881            dst.reason.add(i.copy());
3882        };
3883        if (diagnosis != null) {
3884          dst.diagnosis = new ArrayList<DiagnosisComponent>();
3885          for (DiagnosisComponent i : diagnosis)
3886            dst.diagnosis.add(i.copy());
3887        };
3888        if (account != null) {
3889          dst.account = new ArrayList<Reference>();
3890          for (Reference i : account)
3891            dst.account.add(i.copy());
3892        };
3893        dst.hospitalization = hospitalization == null ? null : hospitalization.copy();
3894        if (location != null) {
3895          dst.location = new ArrayList<EncounterLocationComponent>();
3896          for (EncounterLocationComponent i : location)
3897            dst.location.add(i.copy());
3898        };
3899        dst.serviceProvider = serviceProvider == null ? null : serviceProvider.copy();
3900        dst.partOf = partOf == null ? null : partOf.copy();
3901        return dst;
3902      }
3903
3904      protected Encounter typedCopy() {
3905        return copy();
3906      }
3907
3908      @Override
3909      public boolean equalsDeep(Base other) {
3910        if (!super.equalsDeep(other))
3911          return false;
3912        if (!(other instanceof Encounter))
3913          return false;
3914        Encounter o = (Encounter) other;
3915        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(statusHistory, o.statusHistory, true)
3916           && compareDeep(class_, o.class_, true) && compareDeep(classHistory, o.classHistory, true) && compareDeep(type, o.type, true)
3917           && compareDeep(priority, o.priority, true) && compareDeep(subject, o.subject, true) && compareDeep(episodeOfCare, o.episodeOfCare, true)
3918           && compareDeep(incomingReferral, o.incomingReferral, true) && compareDeep(participant, o.participant, true)
3919           && compareDeep(appointment, o.appointment, true) && compareDeep(period, o.period, true) && compareDeep(length, o.length, true)
3920           && compareDeep(reason, o.reason, true) && compareDeep(diagnosis, o.diagnosis, true) && compareDeep(account, o.account, true)
3921           && compareDeep(hospitalization, o.hospitalization, true) && compareDeep(location, o.location, true)
3922           && compareDeep(serviceProvider, o.serviceProvider, true) && compareDeep(partOf, o.partOf, true)
3923          ;
3924      }
3925
3926      @Override
3927      public boolean equalsShallow(Base other) {
3928        if (!super.equalsShallow(other))
3929          return false;
3930        if (!(other instanceof Encounter))
3931          return false;
3932        Encounter o = (Encounter) other;
3933        return compareValues(status, o.status, true);
3934      }
3935
3936      public boolean isEmpty() {
3937        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, statusHistory
3938          , class_, classHistory, type, priority, subject, episodeOfCare, incomingReferral
3939          , participant, appointment, period, length, reason, diagnosis, account, hospitalization
3940          , location, serviceProvider, partOf);
3941      }
3942
3943  @Override
3944  public ResourceType getResourceType() {
3945    return ResourceType.Encounter;
3946   }
3947
3948 /**
3949   * Search parameter: <b>date</b>
3950   * <p>
3951   * Description: <b>A date within the period the Encounter lasted</b><br>
3952   * Type: <b>date</b><br>
3953   * Path: <b>Encounter.period</b><br>
3954   * </p>
3955   */
3956  @SearchParamDefinition(name="date", path="Encounter.period", description="A date within the period the Encounter lasted", type="date" )
3957  public static final String SP_DATE = "date";
3958 /**
3959   * <b>Fluent Client</b> search parameter constant for <b>date</b>
3960   * <p>
3961   * Description: <b>A date within the period the Encounter lasted</b><br>
3962   * Type: <b>date</b><br>
3963   * Path: <b>Encounter.period</b><br>
3964   * </p>
3965   */
3966  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
3967
3968 /**
3969   * Search parameter: <b>identifier</b>
3970   * <p>
3971   * Description: <b>Identifier(s) by which this encounter is known</b><br>
3972   * Type: <b>token</b><br>
3973   * Path: <b>Encounter.identifier</b><br>
3974   * </p>
3975   */
3976  @SearchParamDefinition(name="identifier", path="Encounter.identifier", description="Identifier(s) by which this encounter is known", type="token" )
3977  public static final String SP_IDENTIFIER = "identifier";
3978 /**
3979   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
3980   * <p>
3981   * Description: <b>Identifier(s) by which this encounter is known</b><br>
3982   * Type: <b>token</b><br>
3983   * Path: <b>Encounter.identifier</b><br>
3984   * </p>
3985   */
3986  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
3987
3988 /**
3989   * Search parameter: <b>reason</b>
3990   * <p>
3991   * Description: <b>Reason the encounter takes place (code)</b><br>
3992   * Type: <b>token</b><br>
3993   * Path: <b>Encounter.reason</b><br>
3994   * </p>
3995   */
3996  @SearchParamDefinition(name="reason", path="Encounter.reason", description="Reason the encounter takes place (code)", type="token" )
3997  public static final String SP_REASON = "reason";
3998 /**
3999   * <b>Fluent Client</b> search parameter constant for <b>reason</b>
4000   * <p>
4001   * Description: <b>Reason the encounter takes place (code)</b><br>
4002   * Type: <b>token</b><br>
4003   * Path: <b>Encounter.reason</b><br>
4004   * </p>
4005   */
4006  public static final ca.uhn.fhir.rest.gclient.TokenClientParam REASON = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_REASON);
4007
4008 /**
4009   * Search parameter: <b>episodeofcare</b>
4010   * <p>
4011   * Description: <b>Episode(s) of care that this encounter should be recorded against</b><br>
4012   * Type: <b>reference</b><br>
4013   * Path: <b>Encounter.episodeOfCare</b><br>
4014   * </p>
4015   */
4016  @SearchParamDefinition(name="episodeofcare", path="Encounter.episodeOfCare", description="Episode(s) of care that this encounter should be recorded against", type="reference", target={EpisodeOfCare.class } )
4017  public static final String SP_EPISODEOFCARE = "episodeofcare";
4018 /**
4019   * <b>Fluent Client</b> search parameter constant for <b>episodeofcare</b>
4020   * <p>
4021   * Description: <b>Episode(s) of care that this encounter should be recorded against</b><br>
4022   * Type: <b>reference</b><br>
4023   * Path: <b>Encounter.episodeOfCare</b><br>
4024   * </p>
4025   */
4026  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam EPISODEOFCARE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_EPISODEOFCARE);
4027
4028/**
4029   * Constant for fluent queries to be used to add include statements. Specifies
4030   * the path value of "<b>Encounter:episodeofcare</b>".
4031   */
4032  public static final ca.uhn.fhir.model.api.Include INCLUDE_EPISODEOFCARE = new ca.uhn.fhir.model.api.Include("Encounter:episodeofcare").toLocked();
4033
4034 /**
4035   * Search parameter: <b>participant-type</b>
4036   * <p>
4037   * Description: <b>Role of participant in encounter</b><br>
4038   * Type: <b>token</b><br>
4039   * Path: <b>Encounter.participant.type</b><br>
4040   * </p>
4041   */
4042  @SearchParamDefinition(name="participant-type", path="Encounter.participant.type", description="Role of participant in encounter", type="token" )
4043  public static final String SP_PARTICIPANT_TYPE = "participant-type";
4044 /**
4045   * <b>Fluent Client</b> search parameter constant for <b>participant-type</b>
4046   * <p>
4047   * Description: <b>Role of participant in encounter</b><br>
4048   * Type: <b>token</b><br>
4049   * Path: <b>Encounter.participant.type</b><br>
4050   * </p>
4051   */
4052  public static final ca.uhn.fhir.rest.gclient.TokenClientParam PARTICIPANT_TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_PARTICIPANT_TYPE);
4053
4054 /**
4055   * Search parameter: <b>incomingreferral</b>
4056   * <p>
4057   * Description: <b>The ReferralRequest that initiated this encounter</b><br>
4058   * Type: <b>reference</b><br>
4059   * Path: <b>Encounter.incomingReferral</b><br>
4060   * </p>
4061   */
4062  @SearchParamDefinition(name="incomingreferral", path="Encounter.incomingReferral", description="The ReferralRequest that initiated this encounter", type="reference", target={ReferralRequest.class } )
4063  public static final String SP_INCOMINGREFERRAL = "incomingreferral";
4064 /**
4065   * <b>Fluent Client</b> search parameter constant for <b>incomingreferral</b>
4066   * <p>
4067   * Description: <b>The ReferralRequest that initiated this encounter</b><br>
4068   * Type: <b>reference</b><br>
4069   * Path: <b>Encounter.incomingReferral</b><br>
4070   * </p>
4071   */
4072  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam INCOMINGREFERRAL = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_INCOMINGREFERRAL);
4073
4074/**
4075   * Constant for fluent queries to be used to add include statements. Specifies
4076   * the path value of "<b>Encounter:incomingreferral</b>".
4077   */
4078  public static final ca.uhn.fhir.model.api.Include INCLUDE_INCOMINGREFERRAL = new ca.uhn.fhir.model.api.Include("Encounter:incomingreferral").toLocked();
4079
4080 /**
4081   * Search parameter: <b>practitioner</b>
4082   * <p>
4083   * Description: <b>Persons involved in the encounter other than the patient</b><br>
4084   * Type: <b>reference</b><br>
4085   * Path: <b>Encounter.participant.individual</b><br>
4086   * </p>
4087   */
4088  @SearchParamDefinition(name="practitioner", path="Encounter.participant.individual", description="Persons involved in the encounter other than the patient", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner") }, target={Practitioner.class } )
4089  public static final String SP_PRACTITIONER = "practitioner";
4090 /**
4091   * <b>Fluent Client</b> search parameter constant for <b>practitioner</b>
4092   * <p>
4093   * Description: <b>Persons involved in the encounter other than the patient</b><br>
4094   * Type: <b>reference</b><br>
4095   * Path: <b>Encounter.participant.individual</b><br>
4096   * </p>
4097   */
4098  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PRACTITIONER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PRACTITIONER);
4099
4100/**
4101   * Constant for fluent queries to be used to add include statements. Specifies
4102   * the path value of "<b>Encounter:practitioner</b>".
4103   */
4104  public static final ca.uhn.fhir.model.api.Include INCLUDE_PRACTITIONER = new ca.uhn.fhir.model.api.Include("Encounter:practitioner").toLocked();
4105
4106 /**
4107   * Search parameter: <b>subject</b>
4108   * <p>
4109   * Description: <b>The patient ro group present at the encounter</b><br>
4110   * Type: <b>reference</b><br>
4111   * Path: <b>Encounter.subject</b><br>
4112   * </p>
4113   */
4114  @SearchParamDefinition(name="subject", path="Encounter.subject", description="The patient ro group present at the encounter", type="reference", target={Group.class, Patient.class } )
4115  public static final String SP_SUBJECT = "subject";
4116 /**
4117   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
4118   * <p>
4119   * Description: <b>The patient ro group present at the encounter</b><br>
4120   * Type: <b>reference</b><br>
4121   * Path: <b>Encounter.subject</b><br>
4122   * </p>
4123   */
4124  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
4125
4126/**
4127   * Constant for fluent queries to be used to add include statements. Specifies
4128   * the path value of "<b>Encounter:subject</b>".
4129   */
4130  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("Encounter:subject").toLocked();
4131
4132 /**
4133   * Search parameter: <b>length</b>
4134   * <p>
4135   * Description: <b>Length of encounter in days</b><br>
4136   * Type: <b>number</b><br>
4137   * Path: <b>Encounter.length</b><br>
4138   * </p>
4139   */
4140  @SearchParamDefinition(name="length", path="Encounter.length", description="Length of encounter in days", type="number" )
4141  public static final String SP_LENGTH = "length";
4142 /**
4143   * <b>Fluent Client</b> search parameter constant for <b>length</b>
4144   * <p>
4145   * Description: <b>Length of encounter in days</b><br>
4146   * Type: <b>number</b><br>
4147   * Path: <b>Encounter.length</b><br>
4148   * </p>
4149   */
4150  public static final ca.uhn.fhir.rest.gclient.NumberClientParam LENGTH = new ca.uhn.fhir.rest.gclient.NumberClientParam(SP_LENGTH);
4151
4152 /**
4153   * Search parameter: <b>diagnosis</b>
4154   * <p>
4155   * Description: <b>Reason the encounter takes place (resource)</b><br>
4156   * Type: <b>reference</b><br>
4157   * Path: <b>Encounter.diagnosis.condition</b><br>
4158   * </p>
4159   */
4160  @SearchParamDefinition(name="diagnosis", path="Encounter.diagnosis.condition", description="Reason the encounter takes place (resource)", type="reference", target={Condition.class, Procedure.class } )
4161  public static final String SP_DIAGNOSIS = "diagnosis";
4162 /**
4163   * <b>Fluent Client</b> search parameter constant for <b>diagnosis</b>
4164   * <p>
4165   * Description: <b>Reason the encounter takes place (resource)</b><br>
4166   * Type: <b>reference</b><br>
4167   * Path: <b>Encounter.diagnosis.condition</b><br>
4168   * </p>
4169   */
4170  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam DIAGNOSIS = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_DIAGNOSIS);
4171
4172/**
4173   * Constant for fluent queries to be used to add include statements. Specifies
4174   * the path value of "<b>Encounter:diagnosis</b>".
4175   */
4176  public static final ca.uhn.fhir.model.api.Include INCLUDE_DIAGNOSIS = new ca.uhn.fhir.model.api.Include("Encounter:diagnosis").toLocked();
4177
4178 /**
4179   * Search parameter: <b>appointment</b>
4180   * <p>
4181   * Description: <b>The appointment that scheduled this encounter</b><br>
4182   * Type: <b>reference</b><br>
4183   * Path: <b>Encounter.appointment</b><br>
4184   * </p>
4185   */
4186  @SearchParamDefinition(name="appointment", path="Encounter.appointment", description="The appointment that scheduled this encounter", type="reference", target={Appointment.class } )
4187  public static final String SP_APPOINTMENT = "appointment";
4188 /**
4189   * <b>Fluent Client</b> search parameter constant for <b>appointment</b>
4190   * <p>
4191   * Description: <b>The appointment that scheduled this encounter</b><br>
4192   * Type: <b>reference</b><br>
4193   * Path: <b>Encounter.appointment</b><br>
4194   * </p>
4195   */
4196  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam APPOINTMENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_APPOINTMENT);
4197
4198/**
4199   * Constant for fluent queries to be used to add include statements. Specifies
4200   * the path value of "<b>Encounter:appointment</b>".
4201   */
4202  public static final ca.uhn.fhir.model.api.Include INCLUDE_APPOINTMENT = new ca.uhn.fhir.model.api.Include("Encounter:appointment").toLocked();
4203
4204 /**
4205   * Search parameter: <b>part-of</b>
4206   * <p>
4207   * Description: <b>Another Encounter this encounter is part of</b><br>
4208   * Type: <b>reference</b><br>
4209   * Path: <b>Encounter.partOf</b><br>
4210   * </p>
4211   */
4212  @SearchParamDefinition(name="part-of", path="Encounter.partOf", description="Another Encounter this encounter is part of", type="reference", target={Encounter.class } )
4213  public static final String SP_PART_OF = "part-of";
4214 /**
4215   * <b>Fluent Client</b> search parameter constant for <b>part-of</b>
4216   * <p>
4217   * Description: <b>Another Encounter this encounter is part of</b><br>
4218   * Type: <b>reference</b><br>
4219   * Path: <b>Encounter.partOf</b><br>
4220   * </p>
4221   */
4222  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PART_OF = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PART_OF);
4223
4224/**
4225   * Constant for fluent queries to be used to add include statements. Specifies
4226   * the path value of "<b>Encounter:part-of</b>".
4227   */
4228  public static final ca.uhn.fhir.model.api.Include INCLUDE_PART_OF = new ca.uhn.fhir.model.api.Include("Encounter:part-of").toLocked();
4229
4230 /**
4231   * Search parameter: <b>type</b>
4232   * <p>
4233   * Description: <b>Specific type of encounter</b><br>
4234   * Type: <b>token</b><br>
4235   * Path: <b>Encounter.type</b><br>
4236   * </p>
4237   */
4238  @SearchParamDefinition(name="type", path="Encounter.type", description="Specific type of encounter", type="token" )
4239  public static final String SP_TYPE = "type";
4240 /**
4241   * <b>Fluent Client</b> search parameter constant for <b>type</b>
4242   * <p>
4243   * Description: <b>Specific type of encounter</b><br>
4244   * Type: <b>token</b><br>
4245   * Path: <b>Encounter.type</b><br>
4246   * </p>
4247   */
4248  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_TYPE);
4249
4250 /**
4251   * Search parameter: <b>participant</b>
4252   * <p>
4253   * Description: <b>Persons involved in the encounter other than the patient</b><br>
4254   * Type: <b>reference</b><br>
4255   * Path: <b>Encounter.participant.individual</b><br>
4256   * </p>
4257   */
4258  @SearchParamDefinition(name="participant", path="Encounter.participant.individual", description="Persons involved in the encounter other than the patient", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner"), @ca.uhn.fhir.model.api.annotation.Compartment(name="RelatedPerson") }, target={Practitioner.class, RelatedPerson.class } )
4259  public static final String SP_PARTICIPANT = "participant";
4260 /**
4261   * <b>Fluent Client</b> search parameter constant for <b>participant</b>
4262   * <p>
4263   * Description: <b>Persons involved in the encounter other than the patient</b><br>
4264   * Type: <b>reference</b><br>
4265   * Path: <b>Encounter.participant.individual</b><br>
4266   * </p>
4267   */
4268  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PARTICIPANT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PARTICIPANT);
4269
4270/**
4271   * Constant for fluent queries to be used to add include statements. Specifies
4272   * the path value of "<b>Encounter:participant</b>".
4273   */
4274  public static final ca.uhn.fhir.model.api.Include INCLUDE_PARTICIPANT = new ca.uhn.fhir.model.api.Include("Encounter:participant").toLocked();
4275
4276 /**
4277   * Search parameter: <b>patient</b>
4278   * <p>
4279   * Description: <b>The patient ro group present at the encounter</b><br>
4280   * Type: <b>reference</b><br>
4281   * Path: <b>Encounter.subject</b><br>
4282   * </p>
4283   */
4284  @SearchParamDefinition(name="patient", path="Encounter.subject", description="The patient ro group present at the encounter", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Patient.class } )
4285  public static final String SP_PATIENT = "patient";
4286 /**
4287   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
4288   * <p>
4289   * Description: <b>The patient ro group present at the encounter</b><br>
4290   * Type: <b>reference</b><br>
4291   * Path: <b>Encounter.subject</b><br>
4292   * </p>
4293   */
4294  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
4295
4296/**
4297   * Constant for fluent queries to be used to add include statements. Specifies
4298   * the path value of "<b>Encounter:patient</b>".
4299   */
4300  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("Encounter:patient").toLocked();
4301
4302 /**
4303   * Search parameter: <b>location-period</b>
4304   * <p>
4305   * Description: <b>Time period during which the patient was present at the location</b><br>
4306   * Type: <b>date</b><br>
4307   * Path: <b>Encounter.location.period</b><br>
4308   * </p>
4309   */
4310  @SearchParamDefinition(name="location-period", path="Encounter.location.period", description="Time period during which the patient was present at the location", type="date" )
4311  public static final String SP_LOCATION_PERIOD = "location-period";
4312 /**
4313   * <b>Fluent Client</b> search parameter constant for <b>location-period</b>
4314   * <p>
4315   * Description: <b>Time period during which the patient was present at the location</b><br>
4316   * Type: <b>date</b><br>
4317   * Path: <b>Encounter.location.period</b><br>
4318   * </p>
4319   */
4320  public static final ca.uhn.fhir.rest.gclient.DateClientParam LOCATION_PERIOD = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_LOCATION_PERIOD);
4321
4322 /**
4323   * Search parameter: <b>location</b>
4324   * <p>
4325   * Description: <b>Location the encounter takes place</b><br>
4326   * Type: <b>reference</b><br>
4327   * Path: <b>Encounter.location.location</b><br>
4328   * </p>
4329   */
4330  @SearchParamDefinition(name="location", path="Encounter.location.location", description="Location the encounter takes place", type="reference", target={Location.class } )
4331  public static final String SP_LOCATION = "location";
4332 /**
4333   * <b>Fluent Client</b> search parameter constant for <b>location</b>
4334   * <p>
4335   * Description: <b>Location the encounter takes place</b><br>
4336   * Type: <b>reference</b><br>
4337   * Path: <b>Encounter.location.location</b><br>
4338   * </p>
4339   */
4340  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam LOCATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_LOCATION);
4341
4342/**
4343   * Constant for fluent queries to be used to add include statements. Specifies
4344   * the path value of "<b>Encounter:location</b>".
4345   */
4346  public static final ca.uhn.fhir.model.api.Include INCLUDE_LOCATION = new ca.uhn.fhir.model.api.Include("Encounter:location").toLocked();
4347
4348 /**
4349   * Search parameter: <b>service-provider</b>
4350   * <p>
4351   * Description: <b>The custodian organization of this Encounter record</b><br>
4352   * Type: <b>reference</b><br>
4353   * Path: <b>Encounter.serviceProvider</b><br>
4354   * </p>
4355   */
4356  @SearchParamDefinition(name="service-provider", path="Encounter.serviceProvider", description="The custodian organization of this Encounter record", type="reference", target={Organization.class } )
4357  public static final String SP_SERVICE_PROVIDER = "service-provider";
4358 /**
4359   * <b>Fluent Client</b> search parameter constant for <b>service-provider</b>
4360   * <p>
4361   * Description: <b>The custodian organization of this Encounter record</b><br>
4362   * Type: <b>reference</b><br>
4363   * Path: <b>Encounter.serviceProvider</b><br>
4364   * </p>
4365   */
4366  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SERVICE_PROVIDER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SERVICE_PROVIDER);
4367
4368/**
4369   * Constant for fluent queries to be used to add include statements. Specifies
4370   * the path value of "<b>Encounter:service-provider</b>".
4371   */
4372  public static final ca.uhn.fhir.model.api.Include INCLUDE_SERVICE_PROVIDER = new ca.uhn.fhir.model.api.Include("Encounter:service-provider").toLocked();
4373
4374 /**
4375   * Search parameter: <b>special-arrangement</b>
4376   * <p>
4377   * Description: <b>Wheelchair, translator, stretcher, etc.</b><br>
4378   * Type: <b>token</b><br>
4379   * Path: <b>Encounter.hospitalization.specialArrangement</b><br>
4380   * </p>
4381   */
4382  @SearchParamDefinition(name="special-arrangement", path="Encounter.hospitalization.specialArrangement", description="Wheelchair, translator, stretcher, etc.", type="token" )
4383  public static final String SP_SPECIAL_ARRANGEMENT = "special-arrangement";
4384 /**
4385   * <b>Fluent Client</b> search parameter constant for <b>special-arrangement</b>
4386   * <p>
4387   * Description: <b>Wheelchair, translator, stretcher, etc.</b><br>
4388   * Type: <b>token</b><br>
4389   * Path: <b>Encounter.hospitalization.specialArrangement</b><br>
4390   * </p>
4391   */
4392  public static final ca.uhn.fhir.rest.gclient.TokenClientParam SPECIAL_ARRANGEMENT = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_SPECIAL_ARRANGEMENT);
4393
4394 /**
4395   * Search parameter: <b>class</b>
4396   * <p>
4397   * Description: <b>inpatient | outpatient | ambulatory | emergency +</b><br>
4398   * Type: <b>token</b><br>
4399   * Path: <b>Encounter.class</b><br>
4400   * </p>
4401   */
4402  @SearchParamDefinition(name="class", path="Encounter.class", description="inpatient | outpatient | ambulatory | emergency +", type="token" )
4403  public static final String SP_CLASS = "class";
4404 /**
4405   * <b>Fluent Client</b> search parameter constant for <b>class</b>
4406   * <p>
4407   * Description: <b>inpatient | outpatient | ambulatory | emergency +</b><br>
4408   * Type: <b>token</b><br>
4409   * Path: <b>Encounter.class</b><br>
4410   * </p>
4411   */
4412  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CLASS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CLASS);
4413
4414 /**
4415   * Search parameter: <b>status</b>
4416   * <p>
4417   * Description: <b>planned | arrived | triaged | in-progress | onleave | finished | cancelled +</b><br>
4418   * Type: <b>token</b><br>
4419   * Path: <b>Encounter.status</b><br>
4420   * </p>
4421   */
4422  @SearchParamDefinition(name="status", path="Encounter.status", description="planned | arrived | triaged | in-progress | onleave | finished | cancelled +", type="token" )
4423  public static final String SP_STATUS = "status";
4424 /**
4425   * <b>Fluent Client</b> search parameter constant for <b>status</b>
4426   * <p>
4427   * Description: <b>planned | arrived | triaged | in-progress | onleave | finished | cancelled +</b><br>
4428   * Type: <b>token</b><br>
4429   * Path: <b>Encounter.status</b><br>
4430   * </p>
4431   */
4432  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
4433
4434
4435}
4436