001package org.hl7.fhir.r4.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 Thu, Dec 27, 2018 10:06-0500 for FHIR v4.0.0
033
034import java.util.*;
035
036import org.hl7.fhir.utilities.Utilities;
037import org.hl7.fhir.r4.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/StructureDefinition/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> children) {
489          super.listChildren(children);
490          children.add(new Property("status", "code", "planned | arrived | triaged | in-progress | onleave | finished | cancelled +.", 0, 1, status));
491          children.add(new Property("period", "Period", "The time that the episode was in the specified status.", 0, 1, period));
492        }
493
494        @Override
495        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
496          switch (_hash) {
497          case -892481550: /*status*/  return new Property("status", "code", "planned | arrived | triaged | in-progress | onleave | finished | cancelled +.", 0, 1, status);
498          case -991726143: /*period*/  return new Property("period", "Period", "The time that the episode was in the specified status.", 0, 1, period);
499          default: return super.getNamedProperty(_hash, _name, _checkValid);
500          }
501
502        }
503
504      @Override
505      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
506        switch (hash) {
507        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<EncounterStatus>
508        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
509        default: return super.getProperty(hash, name, checkValid);
510        }
511
512      }
513
514      @Override
515      public Base setProperty(int hash, String name, Base value) throws FHIRException {
516        switch (hash) {
517        case -892481550: // status
518          value = new EncounterStatusEnumFactory().fromType(castToCode(value));
519          this.status = (Enumeration) value; // Enumeration<EncounterStatus>
520          return value;
521        case -991726143: // period
522          this.period = castToPeriod(value); // Period
523          return value;
524        default: return super.setProperty(hash, name, value);
525        }
526
527      }
528
529      @Override
530      public Base setProperty(String name, Base value) throws FHIRException {
531        if (name.equals("status")) {
532          value = new EncounterStatusEnumFactory().fromType(castToCode(value));
533          this.status = (Enumeration) value; // Enumeration<EncounterStatus>
534        } else if (name.equals("period")) {
535          this.period = castToPeriod(value); // Period
536        } else
537          return super.setProperty(name, value);
538        return value;
539      }
540
541      @Override
542      public Base makeProperty(int hash, String name) throws FHIRException {
543        switch (hash) {
544        case -892481550:  return getStatusElement();
545        case -991726143:  return getPeriod(); 
546        default: return super.makeProperty(hash, name);
547        }
548
549      }
550
551      @Override
552      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
553        switch (hash) {
554        case -892481550: /*status*/ return new String[] {"code"};
555        case -991726143: /*period*/ return new String[] {"Period"};
556        default: return super.getTypesForProperty(hash, name);
557        }
558
559      }
560
561      @Override
562      public Base addChild(String name) throws FHIRException {
563        if (name.equals("status")) {
564          throw new FHIRException("Cannot call addChild on a primitive type Encounter.status");
565        }
566        else if (name.equals("period")) {
567          this.period = new Period();
568          return this.period;
569        }
570        else
571          return super.addChild(name);
572      }
573
574      public StatusHistoryComponent copy() {
575        StatusHistoryComponent dst = new StatusHistoryComponent();
576        copyValues(dst);
577        dst.status = status == null ? null : status.copy();
578        dst.period = period == null ? null : period.copy();
579        return dst;
580      }
581
582      @Override
583      public boolean equalsDeep(Base other_) {
584        if (!super.equalsDeep(other_))
585          return false;
586        if (!(other_ instanceof StatusHistoryComponent))
587          return false;
588        StatusHistoryComponent o = (StatusHistoryComponent) other_;
589        return compareDeep(status, o.status, true) && compareDeep(period, o.period, true);
590      }
591
592      @Override
593      public boolean equalsShallow(Base other_) {
594        if (!super.equalsShallow(other_))
595          return false;
596        if (!(other_ instanceof StatusHistoryComponent))
597          return false;
598        StatusHistoryComponent o = (StatusHistoryComponent) other_;
599        return compareValues(status, o.status, true);
600      }
601
602      public boolean isEmpty() {
603        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(status, period);
604      }
605
606  public String fhirType() {
607    return "Encounter.statusHistory";
608
609  }
610
611  }
612
613    @Block()
614    public static class ClassHistoryComponent extends BackboneElement implements IBaseBackboneElement {
615        /**
616         * inpatient | outpatient | ambulatory | emergency +.
617         */
618        @Child(name = "class", type = {Coding.class}, order=1, min=1, max=1, modifier=false, summary=false)
619        @Description(shortDefinition="inpatient | outpatient | ambulatory | emergency +", formalDefinition="inpatient | outpatient | ambulatory | emergency +." )
620        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://terminology.hl7.org/ValueSet/v3-ActEncounterCode")
621        protected Coding class_;
622
623        /**
624         * The time that the episode was in the specified class.
625         */
626        @Child(name = "period", type = {Period.class}, order=2, min=1, max=1, modifier=false, summary=false)
627        @Description(shortDefinition="The time that the episode was in the specified class", formalDefinition="The time that the episode was in the specified class." )
628        protected Period period;
629
630        private static final long serialVersionUID = 1331020311L;
631
632    /**
633     * Constructor
634     */
635      public ClassHistoryComponent() {
636        super();
637      }
638
639    /**
640     * Constructor
641     */
642      public ClassHistoryComponent(Coding class_, Period period) {
643        super();
644        this.class_ = class_;
645        this.period = period;
646      }
647
648        /**
649         * @return {@link #class_} (inpatient | outpatient | ambulatory | emergency +.)
650         */
651        public Coding getClass_() { 
652          if (this.class_ == null)
653            if (Configuration.errorOnAutoCreate())
654              throw new Error("Attempt to auto-create ClassHistoryComponent.class_");
655            else if (Configuration.doAutoCreate())
656              this.class_ = new Coding(); // cc
657          return this.class_;
658        }
659
660        public boolean hasClass_() { 
661          return this.class_ != null && !this.class_.isEmpty();
662        }
663
664        /**
665         * @param value {@link #class_} (inpatient | outpatient | ambulatory | emergency +.)
666         */
667        public ClassHistoryComponent setClass_(Coding value) { 
668          this.class_ = value;
669          return this;
670        }
671
672        /**
673         * @return {@link #period} (The time that the episode was in the specified class.)
674         */
675        public Period getPeriod() { 
676          if (this.period == null)
677            if (Configuration.errorOnAutoCreate())
678              throw new Error("Attempt to auto-create ClassHistoryComponent.period");
679            else if (Configuration.doAutoCreate())
680              this.period = new Period(); // cc
681          return this.period;
682        }
683
684        public boolean hasPeriod() { 
685          return this.period != null && !this.period.isEmpty();
686        }
687
688        /**
689         * @param value {@link #period} (The time that the episode was in the specified class.)
690         */
691        public ClassHistoryComponent setPeriod(Period value) { 
692          this.period = value;
693          return this;
694        }
695
696        protected void listChildren(List<Property> children) {
697          super.listChildren(children);
698          children.add(new Property("class", "Coding", "inpatient | outpatient | ambulatory | emergency +.", 0, 1, class_));
699          children.add(new Property("period", "Period", "The time that the episode was in the specified class.", 0, 1, period));
700        }
701
702        @Override
703        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
704          switch (_hash) {
705          case 94742904: /*class*/  return new Property("class", "Coding", "inpatient | outpatient | ambulatory | emergency +.", 0, 1, class_);
706          case -991726143: /*period*/  return new Property("period", "Period", "The time that the episode was in the specified class.", 0, 1, period);
707          default: return super.getNamedProperty(_hash, _name, _checkValid);
708          }
709
710        }
711
712      @Override
713      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
714        switch (hash) {
715        case 94742904: /*class*/ return this.class_ == null ? new Base[0] : new Base[] {this.class_}; // Coding
716        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
717        default: return super.getProperty(hash, name, checkValid);
718        }
719
720      }
721
722      @Override
723      public Base setProperty(int hash, String name, Base value) throws FHIRException {
724        switch (hash) {
725        case 94742904: // class
726          this.class_ = castToCoding(value); // Coding
727          return value;
728        case -991726143: // period
729          this.period = castToPeriod(value); // Period
730          return value;
731        default: return super.setProperty(hash, name, value);
732        }
733
734      }
735
736      @Override
737      public Base setProperty(String name, Base value) throws FHIRException {
738        if (name.equals("class")) {
739          this.class_ = castToCoding(value); // Coding
740        } else if (name.equals("period")) {
741          this.period = castToPeriod(value); // Period
742        } else
743          return super.setProperty(name, value);
744        return value;
745      }
746
747      @Override
748      public Base makeProperty(int hash, String name) throws FHIRException {
749        switch (hash) {
750        case 94742904:  return getClass_(); 
751        case -991726143:  return getPeriod(); 
752        default: return super.makeProperty(hash, name);
753        }
754
755      }
756
757      @Override
758      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
759        switch (hash) {
760        case 94742904: /*class*/ return new String[] {"Coding"};
761        case -991726143: /*period*/ return new String[] {"Period"};
762        default: return super.getTypesForProperty(hash, name);
763        }
764
765      }
766
767      @Override
768      public Base addChild(String name) throws FHIRException {
769        if (name.equals("class")) {
770          this.class_ = new Coding();
771          return this.class_;
772        }
773        else if (name.equals("period")) {
774          this.period = new Period();
775          return this.period;
776        }
777        else
778          return super.addChild(name);
779      }
780
781      public ClassHistoryComponent copy() {
782        ClassHistoryComponent dst = new ClassHistoryComponent();
783        copyValues(dst);
784        dst.class_ = class_ == null ? null : class_.copy();
785        dst.period = period == null ? null : period.copy();
786        return dst;
787      }
788
789      @Override
790      public boolean equalsDeep(Base other_) {
791        if (!super.equalsDeep(other_))
792          return false;
793        if (!(other_ instanceof ClassHistoryComponent))
794          return false;
795        ClassHistoryComponent o = (ClassHistoryComponent) other_;
796        return compareDeep(class_, o.class_, true) && compareDeep(period, o.period, true);
797      }
798
799      @Override
800      public boolean equalsShallow(Base other_) {
801        if (!super.equalsShallow(other_))
802          return false;
803        if (!(other_ instanceof ClassHistoryComponent))
804          return false;
805        ClassHistoryComponent o = (ClassHistoryComponent) other_;
806        return true;
807      }
808
809      public boolean isEmpty() {
810        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(class_, period);
811      }
812
813  public String fhirType() {
814    return "Encounter.classHistory";
815
816  }
817
818  }
819
820    @Block()
821    public static class EncounterParticipantComponent extends BackboneElement implements IBaseBackboneElement {
822        /**
823         * Role of participant in encounter.
824         */
825        @Child(name = "type", type = {CodeableConcept.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
826        @Description(shortDefinition="Role of participant in encounter", formalDefinition="Role of participant in encounter." )
827        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/encounter-participant-type")
828        protected List<CodeableConcept> type;
829
830        /**
831         * 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.
832         */
833        @Child(name = "period", type = {Period.class}, order=2, min=0, max=1, modifier=false, summary=false)
834        @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." )
835        protected Period period;
836
837        /**
838         * Persons involved in the encounter other than the patient.
839         */
840        @Child(name = "individual", type = {Practitioner.class, PractitionerRole.class, RelatedPerson.class}, order=3, min=0, max=1, modifier=false, summary=true)
841        @Description(shortDefinition="Persons involved in the encounter other than the patient", formalDefinition="Persons involved in the encounter other than the patient." )
842        protected Reference individual;
843
844        /**
845         * The actual object that is the target of the reference (Persons involved in the encounter other than the patient.)
846         */
847        protected Resource individualTarget;
848
849        private static final long serialVersionUID = 317095765L;
850
851    /**
852     * Constructor
853     */
854      public EncounterParticipantComponent() {
855        super();
856      }
857
858        /**
859         * @return {@link #type} (Role of participant in encounter.)
860         */
861        public List<CodeableConcept> getType() { 
862          if (this.type == null)
863            this.type = new ArrayList<CodeableConcept>();
864          return this.type;
865        }
866
867        /**
868         * @return Returns a reference to <code>this</code> for easy method chaining
869         */
870        public EncounterParticipantComponent setType(List<CodeableConcept> theType) { 
871          this.type = theType;
872          return this;
873        }
874
875        public boolean hasType() { 
876          if (this.type == null)
877            return false;
878          for (CodeableConcept item : this.type)
879            if (!item.isEmpty())
880              return true;
881          return false;
882        }
883
884        public CodeableConcept addType() { //3
885          CodeableConcept t = new CodeableConcept();
886          if (this.type == null)
887            this.type = new ArrayList<CodeableConcept>();
888          this.type.add(t);
889          return t;
890        }
891
892        public EncounterParticipantComponent addType(CodeableConcept t) { //3
893          if (t == null)
894            return this;
895          if (this.type == null)
896            this.type = new ArrayList<CodeableConcept>();
897          this.type.add(t);
898          return this;
899        }
900
901        /**
902         * @return The first repetition of repeating field {@link #type}, creating it if it does not already exist
903         */
904        public CodeableConcept getTypeFirstRep() { 
905          if (getType().isEmpty()) {
906            addType();
907          }
908          return getType().get(0);
909        }
910
911        /**
912         * @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.)
913         */
914        public Period getPeriod() { 
915          if (this.period == null)
916            if (Configuration.errorOnAutoCreate())
917              throw new Error("Attempt to auto-create EncounterParticipantComponent.period");
918            else if (Configuration.doAutoCreate())
919              this.period = new Period(); // cc
920          return this.period;
921        }
922
923        public boolean hasPeriod() { 
924          return this.period != null && !this.period.isEmpty();
925        }
926
927        /**
928         * @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.)
929         */
930        public EncounterParticipantComponent setPeriod(Period value) { 
931          this.period = value;
932          return this;
933        }
934
935        /**
936         * @return {@link #individual} (Persons involved in the encounter other than the patient.)
937         */
938        public Reference getIndividual() { 
939          if (this.individual == null)
940            if (Configuration.errorOnAutoCreate())
941              throw new Error("Attempt to auto-create EncounterParticipantComponent.individual");
942            else if (Configuration.doAutoCreate())
943              this.individual = new Reference(); // cc
944          return this.individual;
945        }
946
947        public boolean hasIndividual() { 
948          return this.individual != null && !this.individual.isEmpty();
949        }
950
951        /**
952         * @param value {@link #individual} (Persons involved in the encounter other than the patient.)
953         */
954        public EncounterParticipantComponent setIndividual(Reference value) { 
955          this.individual = value;
956          return this;
957        }
958
959        /**
960         * @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.)
961         */
962        public Resource getIndividualTarget() { 
963          return this.individualTarget;
964        }
965
966        /**
967         * @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.)
968         */
969        public EncounterParticipantComponent setIndividualTarget(Resource value) { 
970          this.individualTarget = value;
971          return this;
972        }
973
974        protected void listChildren(List<Property> children) {
975          super.listChildren(children);
976          children.add(new Property("type", "CodeableConcept", "Role of participant in encounter.", 0, java.lang.Integer.MAX_VALUE, type));
977          children.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, 1, period));
978          children.add(new Property("individual", "Reference(Practitioner|PractitionerRole|RelatedPerson)", "Persons involved in the encounter other than the patient.", 0, 1, individual));
979        }
980
981        @Override
982        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
983          switch (_hash) {
984          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "Role of participant in encounter.", 0, java.lang.Integer.MAX_VALUE, type);
985          case -991726143: /*period*/  return 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, 1, period);
986          case -46292327: /*individual*/  return new Property("individual", "Reference(Practitioner|PractitionerRole|RelatedPerson)", "Persons involved in the encounter other than the patient.", 0, 1, individual);
987          default: return super.getNamedProperty(_hash, _name, _checkValid);
988          }
989
990        }
991
992      @Override
993      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
994        switch (hash) {
995        case 3575610: /*type*/ return this.type == null ? new Base[0] : this.type.toArray(new Base[this.type.size()]); // CodeableConcept
996        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
997        case -46292327: /*individual*/ return this.individual == null ? new Base[0] : new Base[] {this.individual}; // Reference
998        default: return super.getProperty(hash, name, checkValid);
999        }
1000
1001      }
1002
1003      @Override
1004      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1005        switch (hash) {
1006        case 3575610: // type
1007          this.getType().add(castToCodeableConcept(value)); // CodeableConcept
1008          return value;
1009        case -991726143: // period
1010          this.period = castToPeriod(value); // Period
1011          return value;
1012        case -46292327: // individual
1013          this.individual = castToReference(value); // Reference
1014          return value;
1015        default: return super.setProperty(hash, name, value);
1016        }
1017
1018      }
1019
1020      @Override
1021      public Base setProperty(String name, Base value) throws FHIRException {
1022        if (name.equals("type")) {
1023          this.getType().add(castToCodeableConcept(value));
1024        } else if (name.equals("period")) {
1025          this.period = castToPeriod(value); // Period
1026        } else if (name.equals("individual")) {
1027          this.individual = castToReference(value); // Reference
1028        } else
1029          return super.setProperty(name, value);
1030        return value;
1031      }
1032
1033      @Override
1034      public Base makeProperty(int hash, String name) throws FHIRException {
1035        switch (hash) {
1036        case 3575610:  return addType(); 
1037        case -991726143:  return getPeriod(); 
1038        case -46292327:  return getIndividual(); 
1039        default: return super.makeProperty(hash, name);
1040        }
1041
1042      }
1043
1044      @Override
1045      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1046        switch (hash) {
1047        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
1048        case -991726143: /*period*/ return new String[] {"Period"};
1049        case -46292327: /*individual*/ return new String[] {"Reference"};
1050        default: return super.getTypesForProperty(hash, name);
1051        }
1052
1053      }
1054
1055      @Override
1056      public Base addChild(String name) throws FHIRException {
1057        if (name.equals("type")) {
1058          return addType();
1059        }
1060        else if (name.equals("period")) {
1061          this.period = new Period();
1062          return this.period;
1063        }
1064        else if (name.equals("individual")) {
1065          this.individual = new Reference();
1066          return this.individual;
1067        }
1068        else
1069          return super.addChild(name);
1070      }
1071
1072      public EncounterParticipantComponent copy() {
1073        EncounterParticipantComponent dst = new EncounterParticipantComponent();
1074        copyValues(dst);
1075        if (type != null) {
1076          dst.type = new ArrayList<CodeableConcept>();
1077          for (CodeableConcept i : type)
1078            dst.type.add(i.copy());
1079        };
1080        dst.period = period == null ? null : period.copy();
1081        dst.individual = individual == null ? null : individual.copy();
1082        return dst;
1083      }
1084
1085      @Override
1086      public boolean equalsDeep(Base other_) {
1087        if (!super.equalsDeep(other_))
1088          return false;
1089        if (!(other_ instanceof EncounterParticipantComponent))
1090          return false;
1091        EncounterParticipantComponent o = (EncounterParticipantComponent) other_;
1092        return compareDeep(type, o.type, true) && compareDeep(period, o.period, true) && compareDeep(individual, o.individual, true)
1093          ;
1094      }
1095
1096      @Override
1097      public boolean equalsShallow(Base other_) {
1098        if (!super.equalsShallow(other_))
1099          return false;
1100        if (!(other_ instanceof EncounterParticipantComponent))
1101          return false;
1102        EncounterParticipantComponent o = (EncounterParticipantComponent) other_;
1103        return true;
1104      }
1105
1106      public boolean isEmpty() {
1107        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, period, individual
1108          );
1109      }
1110
1111  public String fhirType() {
1112    return "Encounter.participant";
1113
1114  }
1115
1116  }
1117
1118    @Block()
1119    public static class DiagnosisComponent extends BackboneElement implements IBaseBackboneElement {
1120        /**
1121         * 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.
1122         */
1123        @Child(name = "condition", type = {Condition.class, Procedure.class}, order=1, min=1, max=1, modifier=false, summary=true)
1124        @Description(shortDefinition="The diagnosis or procedure relevant to the encounter", 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." )
1125        protected Reference condition;
1126
1127        /**
1128         * 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.)
1129         */
1130        protected Resource conditionTarget;
1131
1132        /**
1133         * Role that this diagnosis has within the encounter (e.g. admission, billing, discharge …).
1134         */
1135        @Child(name = "use", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
1136        @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 …)." )
1137        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/diagnosis-role")
1138        protected CodeableConcept use;
1139
1140        /**
1141         * Ranking of the diagnosis (for each role type).
1142         */
1143        @Child(name = "rank", type = {PositiveIntType.class}, order=3, min=0, max=1, modifier=false, summary=false)
1144        @Description(shortDefinition="Ranking of the diagnosis (for each role type)", formalDefinition="Ranking of the diagnosis (for each role type)." )
1145        protected PositiveIntType rank;
1146
1147        private static final long serialVersionUID = 128213376L;
1148
1149    /**
1150     * Constructor
1151     */
1152      public DiagnosisComponent() {
1153        super();
1154      }
1155
1156    /**
1157     * Constructor
1158     */
1159      public DiagnosisComponent(Reference condition) {
1160        super();
1161        this.condition = condition;
1162      }
1163
1164        /**
1165         * @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.)
1166         */
1167        public Reference getCondition() { 
1168          if (this.condition == null)
1169            if (Configuration.errorOnAutoCreate())
1170              throw new Error("Attempt to auto-create DiagnosisComponent.condition");
1171            else if (Configuration.doAutoCreate())
1172              this.condition = new Reference(); // cc
1173          return this.condition;
1174        }
1175
1176        public boolean hasCondition() { 
1177          return this.condition != null && !this.condition.isEmpty();
1178        }
1179
1180        /**
1181         * @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.)
1182         */
1183        public DiagnosisComponent setCondition(Reference value) { 
1184          this.condition = value;
1185          return this;
1186        }
1187
1188        /**
1189         * @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.)
1190         */
1191        public Resource getConditionTarget() { 
1192          return this.conditionTarget;
1193        }
1194
1195        /**
1196         * @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.)
1197         */
1198        public DiagnosisComponent setConditionTarget(Resource value) { 
1199          this.conditionTarget = value;
1200          return this;
1201        }
1202
1203        /**
1204         * @return {@link #use} (Role that this diagnosis has within the encounter (e.g. admission, billing, discharge …).)
1205         */
1206        public CodeableConcept getUse() { 
1207          if (this.use == null)
1208            if (Configuration.errorOnAutoCreate())
1209              throw new Error("Attempt to auto-create DiagnosisComponent.use");
1210            else if (Configuration.doAutoCreate())
1211              this.use = new CodeableConcept(); // cc
1212          return this.use;
1213        }
1214
1215        public boolean hasUse() { 
1216          return this.use != null && !this.use.isEmpty();
1217        }
1218
1219        /**
1220         * @param value {@link #use} (Role that this diagnosis has within the encounter (e.g. admission, billing, discharge …).)
1221         */
1222        public DiagnosisComponent setUse(CodeableConcept value) { 
1223          this.use = value;
1224          return this;
1225        }
1226
1227        /**
1228         * @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
1229         */
1230        public PositiveIntType getRankElement() { 
1231          if (this.rank == null)
1232            if (Configuration.errorOnAutoCreate())
1233              throw new Error("Attempt to auto-create DiagnosisComponent.rank");
1234            else if (Configuration.doAutoCreate())
1235              this.rank = new PositiveIntType(); // bb
1236          return this.rank;
1237        }
1238
1239        public boolean hasRankElement() { 
1240          return this.rank != null && !this.rank.isEmpty();
1241        }
1242
1243        public boolean hasRank() { 
1244          return this.rank != null && !this.rank.isEmpty();
1245        }
1246
1247        /**
1248         * @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
1249         */
1250        public DiagnosisComponent setRankElement(PositiveIntType value) { 
1251          this.rank = value;
1252          return this;
1253        }
1254
1255        /**
1256         * @return Ranking of the diagnosis (for each role type).
1257         */
1258        public int getRank() { 
1259          return this.rank == null || this.rank.isEmpty() ? 0 : this.rank.getValue();
1260        }
1261
1262        /**
1263         * @param value Ranking of the diagnosis (for each role type).
1264         */
1265        public DiagnosisComponent setRank(int value) { 
1266            if (this.rank == null)
1267              this.rank = new PositiveIntType();
1268            this.rank.setValue(value);
1269          return this;
1270        }
1271
1272        protected void listChildren(List<Property> children) {
1273          super.listChildren(children);
1274          children.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, 1, condition));
1275          children.add(new Property("use", "CodeableConcept", "Role that this diagnosis has within the encounter (e.g. admission, billing, discharge …).", 0, 1, use));
1276          children.add(new Property("rank", "positiveInt", "Ranking of the diagnosis (for each role type).", 0, 1, rank));
1277        }
1278
1279        @Override
1280        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1281          switch (_hash) {
1282          case -861311717: /*condition*/  return 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, 1, condition);
1283          case 116103: /*use*/  return new Property("use", "CodeableConcept", "Role that this diagnosis has within the encounter (e.g. admission, billing, discharge …).", 0, 1, use);
1284          case 3492908: /*rank*/  return new Property("rank", "positiveInt", "Ranking of the diagnosis (for each role type).", 0, 1, rank);
1285          default: return super.getNamedProperty(_hash, _name, _checkValid);
1286          }
1287
1288        }
1289
1290      @Override
1291      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1292        switch (hash) {
1293        case -861311717: /*condition*/ return this.condition == null ? new Base[0] : new Base[] {this.condition}; // Reference
1294        case 116103: /*use*/ return this.use == null ? new Base[0] : new Base[] {this.use}; // CodeableConcept
1295        case 3492908: /*rank*/ return this.rank == null ? new Base[0] : new Base[] {this.rank}; // PositiveIntType
1296        default: return super.getProperty(hash, name, checkValid);
1297        }
1298
1299      }
1300
1301      @Override
1302      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1303        switch (hash) {
1304        case -861311717: // condition
1305          this.condition = castToReference(value); // Reference
1306          return value;
1307        case 116103: // use
1308          this.use = castToCodeableConcept(value); // CodeableConcept
1309          return value;
1310        case 3492908: // rank
1311          this.rank = castToPositiveInt(value); // PositiveIntType
1312          return value;
1313        default: return super.setProperty(hash, name, value);
1314        }
1315
1316      }
1317
1318      @Override
1319      public Base setProperty(String name, Base value) throws FHIRException {
1320        if (name.equals("condition")) {
1321          this.condition = castToReference(value); // Reference
1322        } else if (name.equals("use")) {
1323          this.use = castToCodeableConcept(value); // CodeableConcept
1324        } else if (name.equals("rank")) {
1325          this.rank = castToPositiveInt(value); // PositiveIntType
1326        } else
1327          return super.setProperty(name, value);
1328        return value;
1329      }
1330
1331      @Override
1332      public Base makeProperty(int hash, String name) throws FHIRException {
1333        switch (hash) {
1334        case -861311717:  return getCondition(); 
1335        case 116103:  return getUse(); 
1336        case 3492908:  return getRankElement();
1337        default: return super.makeProperty(hash, name);
1338        }
1339
1340      }
1341
1342      @Override
1343      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1344        switch (hash) {
1345        case -861311717: /*condition*/ return new String[] {"Reference"};
1346        case 116103: /*use*/ return new String[] {"CodeableConcept"};
1347        case 3492908: /*rank*/ return new String[] {"positiveInt"};
1348        default: return super.getTypesForProperty(hash, name);
1349        }
1350
1351      }
1352
1353      @Override
1354      public Base addChild(String name) throws FHIRException {
1355        if (name.equals("condition")) {
1356          this.condition = new Reference();
1357          return this.condition;
1358        }
1359        else if (name.equals("use")) {
1360          this.use = new CodeableConcept();
1361          return this.use;
1362        }
1363        else if (name.equals("rank")) {
1364          throw new FHIRException("Cannot call addChild on a primitive type Encounter.rank");
1365        }
1366        else
1367          return super.addChild(name);
1368      }
1369
1370      public DiagnosisComponent copy() {
1371        DiagnosisComponent dst = new DiagnosisComponent();
1372        copyValues(dst);
1373        dst.condition = condition == null ? null : condition.copy();
1374        dst.use = use == null ? null : use.copy();
1375        dst.rank = rank == null ? null : rank.copy();
1376        return dst;
1377      }
1378
1379      @Override
1380      public boolean equalsDeep(Base other_) {
1381        if (!super.equalsDeep(other_))
1382          return false;
1383        if (!(other_ instanceof DiagnosisComponent))
1384          return false;
1385        DiagnosisComponent o = (DiagnosisComponent) other_;
1386        return compareDeep(condition, o.condition, true) && compareDeep(use, o.use, true) && compareDeep(rank, o.rank, true)
1387          ;
1388      }
1389
1390      @Override
1391      public boolean equalsShallow(Base other_) {
1392        if (!super.equalsShallow(other_))
1393          return false;
1394        if (!(other_ instanceof DiagnosisComponent))
1395          return false;
1396        DiagnosisComponent o = (DiagnosisComponent) other_;
1397        return compareValues(rank, o.rank, true);
1398      }
1399
1400      public boolean isEmpty() {
1401        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(condition, use, rank);
1402      }
1403
1404  public String fhirType() {
1405    return "Encounter.diagnosis";
1406
1407  }
1408
1409  }
1410
1411    @Block()
1412    public static class EncounterHospitalizationComponent extends BackboneElement implements IBaseBackboneElement {
1413        /**
1414         * Pre-admission identifier.
1415         */
1416        @Child(name = "preAdmissionIdentifier", type = {Identifier.class}, order=1, min=0, max=1, modifier=false, summary=false)
1417        @Description(shortDefinition="Pre-admission identifier", formalDefinition="Pre-admission identifier." )
1418        protected Identifier preAdmissionIdentifier;
1419
1420        /**
1421         * The location/organization from which the patient came before admission.
1422         */
1423        @Child(name = "origin", type = {Location.class, Organization.class}, order=2, min=0, max=1, modifier=false, summary=false)
1424        @Description(shortDefinition="The location/organization from which the patient came before admission", formalDefinition="The location/organization from which the patient came before admission." )
1425        protected Reference origin;
1426
1427        /**
1428         * The actual object that is the target of the reference (The location/organization from which the patient came before admission.)
1429         */
1430        protected Resource originTarget;
1431
1432        /**
1433         * From where patient was admitted (physician referral, transfer).
1434         */
1435        @Child(name = "admitSource", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=false)
1436        @Description(shortDefinition="From where patient was admitted (physician referral, transfer)", formalDefinition="From where patient was admitted (physician referral, transfer)." )
1437        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/encounter-admit-source")
1438        protected CodeableConcept admitSource;
1439
1440        /**
1441         * Whether this hospitalization is a readmission and why if known.
1442         */
1443        @Child(name = "reAdmission", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=false)
1444        @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." )
1445        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://terminology.hl7.org/ValueSet/v2-0092")
1446        protected CodeableConcept reAdmission;
1447
1448        /**
1449         * Diet preferences reported by the patient.
1450         */
1451        @Child(name = "dietPreference", type = {CodeableConcept.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1452        @Description(shortDefinition="Diet preferences reported by the patient", formalDefinition="Diet preferences reported by the patient." )
1453        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/encounter-diet")
1454        protected List<CodeableConcept> dietPreference;
1455
1456        /**
1457         * Special courtesies (VIP, board member).
1458         */
1459        @Child(name = "specialCourtesy", type = {CodeableConcept.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1460        @Description(shortDefinition="Special courtesies (VIP, board member)", formalDefinition="Special courtesies (VIP, board member)." )
1461        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/encounter-special-courtesy")
1462        protected List<CodeableConcept> specialCourtesy;
1463
1464        /**
1465         * Any special requests that have been made for this hospitalization encounter, such as the provision of specific equipment or other things.
1466         */
1467        @Child(name = "specialArrangement", type = {CodeableConcept.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1468        @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." )
1469        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/encounter-special-arrangements")
1470        protected List<CodeableConcept> specialArrangement;
1471
1472        /**
1473         * Location/organization to which the patient is discharged.
1474         */
1475        @Child(name = "destination", type = {Location.class, Organization.class}, order=8, min=0, max=1, modifier=false, summary=false)
1476        @Description(shortDefinition="Location/organization to which the patient is discharged", formalDefinition="Location/organization to which the patient is discharged." )
1477        protected Reference destination;
1478
1479        /**
1480         * The actual object that is the target of the reference (Location/organization to which the patient is discharged.)
1481         */
1482        protected Resource destinationTarget;
1483
1484        /**
1485         * Category or kind of location after discharge.
1486         */
1487        @Child(name = "dischargeDisposition", type = {CodeableConcept.class}, order=9, min=0, max=1, modifier=false, summary=false)
1488        @Description(shortDefinition="Category or kind of location after discharge", formalDefinition="Category or kind of location after discharge." )
1489        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/encounter-discharge-disposition")
1490        protected CodeableConcept dischargeDisposition;
1491
1492        private static final long serialVersionUID = 1350555270L;
1493
1494    /**
1495     * Constructor
1496     */
1497      public EncounterHospitalizationComponent() {
1498        super();
1499      }
1500
1501        /**
1502         * @return {@link #preAdmissionIdentifier} (Pre-admission identifier.)
1503         */
1504        public Identifier getPreAdmissionIdentifier() { 
1505          if (this.preAdmissionIdentifier == null)
1506            if (Configuration.errorOnAutoCreate())
1507              throw new Error("Attempt to auto-create EncounterHospitalizationComponent.preAdmissionIdentifier");
1508            else if (Configuration.doAutoCreate())
1509              this.preAdmissionIdentifier = new Identifier(); // cc
1510          return this.preAdmissionIdentifier;
1511        }
1512
1513        public boolean hasPreAdmissionIdentifier() { 
1514          return this.preAdmissionIdentifier != null && !this.preAdmissionIdentifier.isEmpty();
1515        }
1516
1517        /**
1518         * @param value {@link #preAdmissionIdentifier} (Pre-admission identifier.)
1519         */
1520        public EncounterHospitalizationComponent setPreAdmissionIdentifier(Identifier value) { 
1521          this.preAdmissionIdentifier = value;
1522          return this;
1523        }
1524
1525        /**
1526         * @return {@link #origin} (The location/organization from which the patient came before admission.)
1527         */
1528        public Reference getOrigin() { 
1529          if (this.origin == null)
1530            if (Configuration.errorOnAutoCreate())
1531              throw new Error("Attempt to auto-create EncounterHospitalizationComponent.origin");
1532            else if (Configuration.doAutoCreate())
1533              this.origin = new Reference(); // cc
1534          return this.origin;
1535        }
1536
1537        public boolean hasOrigin() { 
1538          return this.origin != null && !this.origin.isEmpty();
1539        }
1540
1541        /**
1542         * @param value {@link #origin} (The location/organization from which the patient came before admission.)
1543         */
1544        public EncounterHospitalizationComponent setOrigin(Reference value) { 
1545          this.origin = value;
1546          return this;
1547        }
1548
1549        /**
1550         * @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/organization from which the patient came before admission.)
1551         */
1552        public Resource getOriginTarget() { 
1553          return this.originTarget;
1554        }
1555
1556        /**
1557         * @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/organization from which the patient came before admission.)
1558         */
1559        public EncounterHospitalizationComponent setOriginTarget(Resource value) { 
1560          this.originTarget = value;
1561          return this;
1562        }
1563
1564        /**
1565         * @return {@link #admitSource} (From where patient was admitted (physician referral, transfer).)
1566         */
1567        public CodeableConcept getAdmitSource() { 
1568          if (this.admitSource == null)
1569            if (Configuration.errorOnAutoCreate())
1570              throw new Error("Attempt to auto-create EncounterHospitalizationComponent.admitSource");
1571            else if (Configuration.doAutoCreate())
1572              this.admitSource = new CodeableConcept(); // cc
1573          return this.admitSource;
1574        }
1575
1576        public boolean hasAdmitSource() { 
1577          return this.admitSource != null && !this.admitSource.isEmpty();
1578        }
1579
1580        /**
1581         * @param value {@link #admitSource} (From where patient was admitted (physician referral, transfer).)
1582         */
1583        public EncounterHospitalizationComponent setAdmitSource(CodeableConcept value) { 
1584          this.admitSource = value;
1585          return this;
1586        }
1587
1588        /**
1589         * @return {@link #reAdmission} (Whether this hospitalization is a readmission and why if known.)
1590         */
1591        public CodeableConcept getReAdmission() { 
1592          if (this.reAdmission == null)
1593            if (Configuration.errorOnAutoCreate())
1594              throw new Error("Attempt to auto-create EncounterHospitalizationComponent.reAdmission");
1595            else if (Configuration.doAutoCreate())
1596              this.reAdmission = new CodeableConcept(); // cc
1597          return this.reAdmission;
1598        }
1599
1600        public boolean hasReAdmission() { 
1601          return this.reAdmission != null && !this.reAdmission.isEmpty();
1602        }
1603
1604        /**
1605         * @param value {@link #reAdmission} (Whether this hospitalization is a readmission and why if known.)
1606         */
1607        public EncounterHospitalizationComponent setReAdmission(CodeableConcept value) { 
1608          this.reAdmission = value;
1609          return this;
1610        }
1611
1612        /**
1613         * @return {@link #dietPreference} (Diet preferences reported by the patient.)
1614         */
1615        public List<CodeableConcept> getDietPreference() { 
1616          if (this.dietPreference == null)
1617            this.dietPreference = new ArrayList<CodeableConcept>();
1618          return this.dietPreference;
1619        }
1620
1621        /**
1622         * @return Returns a reference to <code>this</code> for easy method chaining
1623         */
1624        public EncounterHospitalizationComponent setDietPreference(List<CodeableConcept> theDietPreference) { 
1625          this.dietPreference = theDietPreference;
1626          return this;
1627        }
1628
1629        public boolean hasDietPreference() { 
1630          if (this.dietPreference == null)
1631            return false;
1632          for (CodeableConcept item : this.dietPreference)
1633            if (!item.isEmpty())
1634              return true;
1635          return false;
1636        }
1637
1638        public CodeableConcept addDietPreference() { //3
1639          CodeableConcept t = new CodeableConcept();
1640          if (this.dietPreference == null)
1641            this.dietPreference = new ArrayList<CodeableConcept>();
1642          this.dietPreference.add(t);
1643          return t;
1644        }
1645
1646        public EncounterHospitalizationComponent addDietPreference(CodeableConcept t) { //3
1647          if (t == null)
1648            return this;
1649          if (this.dietPreference == null)
1650            this.dietPreference = new ArrayList<CodeableConcept>();
1651          this.dietPreference.add(t);
1652          return this;
1653        }
1654
1655        /**
1656         * @return The first repetition of repeating field {@link #dietPreference}, creating it if it does not already exist
1657         */
1658        public CodeableConcept getDietPreferenceFirstRep() { 
1659          if (getDietPreference().isEmpty()) {
1660            addDietPreference();
1661          }
1662          return getDietPreference().get(0);
1663        }
1664
1665        /**
1666         * @return {@link #specialCourtesy} (Special courtesies (VIP, board member).)
1667         */
1668        public List<CodeableConcept> getSpecialCourtesy() { 
1669          if (this.specialCourtesy == null)
1670            this.specialCourtesy = new ArrayList<CodeableConcept>();
1671          return this.specialCourtesy;
1672        }
1673
1674        /**
1675         * @return Returns a reference to <code>this</code> for easy method chaining
1676         */
1677        public EncounterHospitalizationComponent setSpecialCourtesy(List<CodeableConcept> theSpecialCourtesy) { 
1678          this.specialCourtesy = theSpecialCourtesy;
1679          return this;
1680        }
1681
1682        public boolean hasSpecialCourtesy() { 
1683          if (this.specialCourtesy == null)
1684            return false;
1685          for (CodeableConcept item : this.specialCourtesy)
1686            if (!item.isEmpty())
1687              return true;
1688          return false;
1689        }
1690
1691        public CodeableConcept addSpecialCourtesy() { //3
1692          CodeableConcept t = new CodeableConcept();
1693          if (this.specialCourtesy == null)
1694            this.specialCourtesy = new ArrayList<CodeableConcept>();
1695          this.specialCourtesy.add(t);
1696          return t;
1697        }
1698
1699        public EncounterHospitalizationComponent addSpecialCourtesy(CodeableConcept t) { //3
1700          if (t == null)
1701            return this;
1702          if (this.specialCourtesy == null)
1703            this.specialCourtesy = new ArrayList<CodeableConcept>();
1704          this.specialCourtesy.add(t);
1705          return this;
1706        }
1707
1708        /**
1709         * @return The first repetition of repeating field {@link #specialCourtesy}, creating it if it does not already exist
1710         */
1711        public CodeableConcept getSpecialCourtesyFirstRep() { 
1712          if (getSpecialCourtesy().isEmpty()) {
1713            addSpecialCourtesy();
1714          }
1715          return getSpecialCourtesy().get(0);
1716        }
1717
1718        /**
1719         * @return {@link #specialArrangement} (Any special requests that have been made for this hospitalization encounter, such as the provision of specific equipment or other things.)
1720         */
1721        public List<CodeableConcept> getSpecialArrangement() { 
1722          if (this.specialArrangement == null)
1723            this.specialArrangement = new ArrayList<CodeableConcept>();
1724          return this.specialArrangement;
1725        }
1726
1727        /**
1728         * @return Returns a reference to <code>this</code> for easy method chaining
1729         */
1730        public EncounterHospitalizationComponent setSpecialArrangement(List<CodeableConcept> theSpecialArrangement) { 
1731          this.specialArrangement = theSpecialArrangement;
1732          return this;
1733        }
1734
1735        public boolean hasSpecialArrangement() { 
1736          if (this.specialArrangement == null)
1737            return false;
1738          for (CodeableConcept item : this.specialArrangement)
1739            if (!item.isEmpty())
1740              return true;
1741          return false;
1742        }
1743
1744        public CodeableConcept addSpecialArrangement() { //3
1745          CodeableConcept t = new CodeableConcept();
1746          if (this.specialArrangement == null)
1747            this.specialArrangement = new ArrayList<CodeableConcept>();
1748          this.specialArrangement.add(t);
1749          return t;
1750        }
1751
1752        public EncounterHospitalizationComponent addSpecialArrangement(CodeableConcept t) { //3
1753          if (t == null)
1754            return this;
1755          if (this.specialArrangement == null)
1756            this.specialArrangement = new ArrayList<CodeableConcept>();
1757          this.specialArrangement.add(t);
1758          return this;
1759        }
1760
1761        /**
1762         * @return The first repetition of repeating field {@link #specialArrangement}, creating it if it does not already exist
1763         */
1764        public CodeableConcept getSpecialArrangementFirstRep() { 
1765          if (getSpecialArrangement().isEmpty()) {
1766            addSpecialArrangement();
1767          }
1768          return getSpecialArrangement().get(0);
1769        }
1770
1771        /**
1772         * @return {@link #destination} (Location/organization to which the patient is discharged.)
1773         */
1774        public Reference getDestination() { 
1775          if (this.destination == null)
1776            if (Configuration.errorOnAutoCreate())
1777              throw new Error("Attempt to auto-create EncounterHospitalizationComponent.destination");
1778            else if (Configuration.doAutoCreate())
1779              this.destination = new Reference(); // cc
1780          return this.destination;
1781        }
1782
1783        public boolean hasDestination() { 
1784          return this.destination != null && !this.destination.isEmpty();
1785        }
1786
1787        /**
1788         * @param value {@link #destination} (Location/organization to which the patient is discharged.)
1789         */
1790        public EncounterHospitalizationComponent setDestination(Reference value) { 
1791          this.destination = value;
1792          return this;
1793        }
1794
1795        /**
1796         * @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/organization to which the patient is discharged.)
1797         */
1798        public Resource getDestinationTarget() { 
1799          return this.destinationTarget;
1800        }
1801
1802        /**
1803         * @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/organization to which the patient is discharged.)
1804         */
1805        public EncounterHospitalizationComponent setDestinationTarget(Resource value) { 
1806          this.destinationTarget = value;
1807          return this;
1808        }
1809
1810        /**
1811         * @return {@link #dischargeDisposition} (Category or kind of location after discharge.)
1812         */
1813        public CodeableConcept getDischargeDisposition() { 
1814          if (this.dischargeDisposition == null)
1815            if (Configuration.errorOnAutoCreate())
1816              throw new Error("Attempt to auto-create EncounterHospitalizationComponent.dischargeDisposition");
1817            else if (Configuration.doAutoCreate())
1818              this.dischargeDisposition = new CodeableConcept(); // cc
1819          return this.dischargeDisposition;
1820        }
1821
1822        public boolean hasDischargeDisposition() { 
1823          return this.dischargeDisposition != null && !this.dischargeDisposition.isEmpty();
1824        }
1825
1826        /**
1827         * @param value {@link #dischargeDisposition} (Category or kind of location after discharge.)
1828         */
1829        public EncounterHospitalizationComponent setDischargeDisposition(CodeableConcept value) { 
1830          this.dischargeDisposition = value;
1831          return this;
1832        }
1833
1834        protected void listChildren(List<Property> children) {
1835          super.listChildren(children);
1836          children.add(new Property("preAdmissionIdentifier", "Identifier", "Pre-admission identifier.", 0, 1, preAdmissionIdentifier));
1837          children.add(new Property("origin", "Reference(Location|Organization)", "The location/organization from which the patient came before admission.", 0, 1, origin));
1838          children.add(new Property("admitSource", "CodeableConcept", "From where patient was admitted (physician referral, transfer).", 0, 1, admitSource));
1839          children.add(new Property("reAdmission", "CodeableConcept", "Whether this hospitalization is a readmission and why if known.", 0, 1, reAdmission));
1840          children.add(new Property("dietPreference", "CodeableConcept", "Diet preferences reported by the patient.", 0, java.lang.Integer.MAX_VALUE, dietPreference));
1841          children.add(new Property("specialCourtesy", "CodeableConcept", "Special courtesies (VIP, board member).", 0, java.lang.Integer.MAX_VALUE, specialCourtesy));
1842          children.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));
1843          children.add(new Property("destination", "Reference(Location|Organization)", "Location/organization to which the patient is discharged.", 0, 1, destination));
1844          children.add(new Property("dischargeDisposition", "CodeableConcept", "Category or kind of location after discharge.", 0, 1, dischargeDisposition));
1845        }
1846
1847        @Override
1848        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1849          switch (_hash) {
1850          case -965394961: /*preAdmissionIdentifier*/  return new Property("preAdmissionIdentifier", "Identifier", "Pre-admission identifier.", 0, 1, preAdmissionIdentifier);
1851          case -1008619738: /*origin*/  return new Property("origin", "Reference(Location|Organization)", "The location/organization from which the patient came before admission.", 0, 1, origin);
1852          case 538887120: /*admitSource*/  return new Property("admitSource", "CodeableConcept", "From where patient was admitted (physician referral, transfer).", 0, 1, admitSource);
1853          case 669348630: /*reAdmission*/  return new Property("reAdmission", "CodeableConcept", "Whether this hospitalization is a readmission and why if known.", 0, 1, reAdmission);
1854          case -1360641041: /*dietPreference*/  return new Property("dietPreference", "CodeableConcept", "Diet preferences reported by the patient.", 0, java.lang.Integer.MAX_VALUE, dietPreference);
1855          case 1583588345: /*specialCourtesy*/  return new Property("specialCourtesy", "CodeableConcept", "Special courtesies (VIP, board member).", 0, java.lang.Integer.MAX_VALUE, specialCourtesy);
1856          case 47410321: /*specialArrangement*/  return 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);
1857          case -1429847026: /*destination*/  return new Property("destination", "Reference(Location|Organization)", "Location/organization to which the patient is discharged.", 0, 1, destination);
1858          case 528065941: /*dischargeDisposition*/  return new Property("dischargeDisposition", "CodeableConcept", "Category or kind of location after discharge.", 0, 1, dischargeDisposition);
1859          default: return super.getNamedProperty(_hash, _name, _checkValid);
1860          }
1861
1862        }
1863
1864      @Override
1865      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1866        switch (hash) {
1867        case -965394961: /*preAdmissionIdentifier*/ return this.preAdmissionIdentifier == null ? new Base[0] : new Base[] {this.preAdmissionIdentifier}; // Identifier
1868        case -1008619738: /*origin*/ return this.origin == null ? new Base[0] : new Base[] {this.origin}; // Reference
1869        case 538887120: /*admitSource*/ return this.admitSource == null ? new Base[0] : new Base[] {this.admitSource}; // CodeableConcept
1870        case 669348630: /*reAdmission*/ return this.reAdmission == null ? new Base[0] : new Base[] {this.reAdmission}; // CodeableConcept
1871        case -1360641041: /*dietPreference*/ return this.dietPreference == null ? new Base[0] : this.dietPreference.toArray(new Base[this.dietPreference.size()]); // CodeableConcept
1872        case 1583588345: /*specialCourtesy*/ return this.specialCourtesy == null ? new Base[0] : this.specialCourtesy.toArray(new Base[this.specialCourtesy.size()]); // CodeableConcept
1873        case 47410321: /*specialArrangement*/ return this.specialArrangement == null ? new Base[0] : this.specialArrangement.toArray(new Base[this.specialArrangement.size()]); // CodeableConcept
1874        case -1429847026: /*destination*/ return this.destination == null ? new Base[0] : new Base[] {this.destination}; // Reference
1875        case 528065941: /*dischargeDisposition*/ return this.dischargeDisposition == null ? new Base[0] : new Base[] {this.dischargeDisposition}; // CodeableConcept
1876        default: return super.getProperty(hash, name, checkValid);
1877        }
1878
1879      }
1880
1881      @Override
1882      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1883        switch (hash) {
1884        case -965394961: // preAdmissionIdentifier
1885          this.preAdmissionIdentifier = castToIdentifier(value); // Identifier
1886          return value;
1887        case -1008619738: // origin
1888          this.origin = castToReference(value); // Reference
1889          return value;
1890        case 538887120: // admitSource
1891          this.admitSource = castToCodeableConcept(value); // CodeableConcept
1892          return value;
1893        case 669348630: // reAdmission
1894          this.reAdmission = castToCodeableConcept(value); // CodeableConcept
1895          return value;
1896        case -1360641041: // dietPreference
1897          this.getDietPreference().add(castToCodeableConcept(value)); // CodeableConcept
1898          return value;
1899        case 1583588345: // specialCourtesy
1900          this.getSpecialCourtesy().add(castToCodeableConcept(value)); // CodeableConcept
1901          return value;
1902        case 47410321: // specialArrangement
1903          this.getSpecialArrangement().add(castToCodeableConcept(value)); // CodeableConcept
1904          return value;
1905        case -1429847026: // destination
1906          this.destination = castToReference(value); // Reference
1907          return value;
1908        case 528065941: // dischargeDisposition
1909          this.dischargeDisposition = castToCodeableConcept(value); // CodeableConcept
1910          return value;
1911        default: return super.setProperty(hash, name, value);
1912        }
1913
1914      }
1915
1916      @Override
1917      public Base setProperty(String name, Base value) throws FHIRException {
1918        if (name.equals("preAdmissionIdentifier")) {
1919          this.preAdmissionIdentifier = castToIdentifier(value); // Identifier
1920        } else if (name.equals("origin")) {
1921          this.origin = castToReference(value); // Reference
1922        } else if (name.equals("admitSource")) {
1923          this.admitSource = castToCodeableConcept(value); // CodeableConcept
1924        } else if (name.equals("reAdmission")) {
1925          this.reAdmission = castToCodeableConcept(value); // CodeableConcept
1926        } else if (name.equals("dietPreference")) {
1927          this.getDietPreference().add(castToCodeableConcept(value));
1928        } else if (name.equals("specialCourtesy")) {
1929          this.getSpecialCourtesy().add(castToCodeableConcept(value));
1930        } else if (name.equals("specialArrangement")) {
1931          this.getSpecialArrangement().add(castToCodeableConcept(value));
1932        } else if (name.equals("destination")) {
1933          this.destination = castToReference(value); // Reference
1934        } else if (name.equals("dischargeDisposition")) {
1935          this.dischargeDisposition = castToCodeableConcept(value); // CodeableConcept
1936        } else
1937          return super.setProperty(name, value);
1938        return value;
1939      }
1940
1941      @Override
1942      public Base makeProperty(int hash, String name) throws FHIRException {
1943        switch (hash) {
1944        case -965394961:  return getPreAdmissionIdentifier(); 
1945        case -1008619738:  return getOrigin(); 
1946        case 538887120:  return getAdmitSource(); 
1947        case 669348630:  return getReAdmission(); 
1948        case -1360641041:  return addDietPreference(); 
1949        case 1583588345:  return addSpecialCourtesy(); 
1950        case 47410321:  return addSpecialArrangement(); 
1951        case -1429847026:  return getDestination(); 
1952        case 528065941:  return getDischargeDisposition(); 
1953        default: return super.makeProperty(hash, name);
1954        }
1955
1956      }
1957
1958      @Override
1959      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1960        switch (hash) {
1961        case -965394961: /*preAdmissionIdentifier*/ return new String[] {"Identifier"};
1962        case -1008619738: /*origin*/ return new String[] {"Reference"};
1963        case 538887120: /*admitSource*/ return new String[] {"CodeableConcept"};
1964        case 669348630: /*reAdmission*/ return new String[] {"CodeableConcept"};
1965        case -1360641041: /*dietPreference*/ return new String[] {"CodeableConcept"};
1966        case 1583588345: /*specialCourtesy*/ return new String[] {"CodeableConcept"};
1967        case 47410321: /*specialArrangement*/ return new String[] {"CodeableConcept"};
1968        case -1429847026: /*destination*/ return new String[] {"Reference"};
1969        case 528065941: /*dischargeDisposition*/ return new String[] {"CodeableConcept"};
1970        default: return super.getTypesForProperty(hash, name);
1971        }
1972
1973      }
1974
1975      @Override
1976      public Base addChild(String name) throws FHIRException {
1977        if (name.equals("preAdmissionIdentifier")) {
1978          this.preAdmissionIdentifier = new Identifier();
1979          return this.preAdmissionIdentifier;
1980        }
1981        else if (name.equals("origin")) {
1982          this.origin = new Reference();
1983          return this.origin;
1984        }
1985        else if (name.equals("admitSource")) {
1986          this.admitSource = new CodeableConcept();
1987          return this.admitSource;
1988        }
1989        else if (name.equals("reAdmission")) {
1990          this.reAdmission = new CodeableConcept();
1991          return this.reAdmission;
1992        }
1993        else if (name.equals("dietPreference")) {
1994          return addDietPreference();
1995        }
1996        else if (name.equals("specialCourtesy")) {
1997          return addSpecialCourtesy();
1998        }
1999        else if (name.equals("specialArrangement")) {
2000          return addSpecialArrangement();
2001        }
2002        else if (name.equals("destination")) {
2003          this.destination = new Reference();
2004          return this.destination;
2005        }
2006        else if (name.equals("dischargeDisposition")) {
2007          this.dischargeDisposition = new CodeableConcept();
2008          return this.dischargeDisposition;
2009        }
2010        else
2011          return super.addChild(name);
2012      }
2013
2014      public EncounterHospitalizationComponent copy() {
2015        EncounterHospitalizationComponent dst = new EncounterHospitalizationComponent();
2016        copyValues(dst);
2017        dst.preAdmissionIdentifier = preAdmissionIdentifier == null ? null : preAdmissionIdentifier.copy();
2018        dst.origin = origin == null ? null : origin.copy();
2019        dst.admitSource = admitSource == null ? null : admitSource.copy();
2020        dst.reAdmission = reAdmission == null ? null : reAdmission.copy();
2021        if (dietPreference != null) {
2022          dst.dietPreference = new ArrayList<CodeableConcept>();
2023          for (CodeableConcept i : dietPreference)
2024            dst.dietPreference.add(i.copy());
2025        };
2026        if (specialCourtesy != null) {
2027          dst.specialCourtesy = new ArrayList<CodeableConcept>();
2028          for (CodeableConcept i : specialCourtesy)
2029            dst.specialCourtesy.add(i.copy());
2030        };
2031        if (specialArrangement != null) {
2032          dst.specialArrangement = new ArrayList<CodeableConcept>();
2033          for (CodeableConcept i : specialArrangement)
2034            dst.specialArrangement.add(i.copy());
2035        };
2036        dst.destination = destination == null ? null : destination.copy();
2037        dst.dischargeDisposition = dischargeDisposition == null ? null : dischargeDisposition.copy();
2038        return dst;
2039      }
2040
2041      @Override
2042      public boolean equalsDeep(Base other_) {
2043        if (!super.equalsDeep(other_))
2044          return false;
2045        if (!(other_ instanceof EncounterHospitalizationComponent))
2046          return false;
2047        EncounterHospitalizationComponent o = (EncounterHospitalizationComponent) other_;
2048        return compareDeep(preAdmissionIdentifier, o.preAdmissionIdentifier, true) && compareDeep(origin, o.origin, true)
2049           && compareDeep(admitSource, o.admitSource, true) && compareDeep(reAdmission, o.reAdmission, true)
2050           && compareDeep(dietPreference, o.dietPreference, true) && compareDeep(specialCourtesy, o.specialCourtesy, true)
2051           && compareDeep(specialArrangement, o.specialArrangement, true) && compareDeep(destination, o.destination, true)
2052           && compareDeep(dischargeDisposition, o.dischargeDisposition, true);
2053      }
2054
2055      @Override
2056      public boolean equalsShallow(Base other_) {
2057        if (!super.equalsShallow(other_))
2058          return false;
2059        if (!(other_ instanceof EncounterHospitalizationComponent))
2060          return false;
2061        EncounterHospitalizationComponent o = (EncounterHospitalizationComponent) other_;
2062        return true;
2063      }
2064
2065      public boolean isEmpty() {
2066        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(preAdmissionIdentifier, origin
2067          , admitSource, reAdmission, dietPreference, specialCourtesy, specialArrangement, destination
2068          , dischargeDisposition);
2069      }
2070
2071  public String fhirType() {
2072    return "Encounter.hospitalization";
2073
2074  }
2075
2076  }
2077
2078    @Block()
2079    public static class EncounterLocationComponent extends BackboneElement implements IBaseBackboneElement {
2080        /**
2081         * The location where the encounter takes place.
2082         */
2083        @Child(name = "location", type = {Location.class}, order=1, min=1, max=1, modifier=false, summary=false)
2084        @Description(shortDefinition="Location the encounter takes place", formalDefinition="The location where the encounter takes place." )
2085        protected Reference location;
2086
2087        /**
2088         * The actual object that is the target of the reference (The location where the encounter takes place.)
2089         */
2090        protected Location locationTarget;
2091
2092        /**
2093         * The status of the participants' presence at the specified location during the period specified. If the participant is no longer at the location, then the period will have an end date/time.
2094         */
2095        @Child(name = "status", type = {CodeType.class}, order=2, min=0, max=1, modifier=false, summary=false)
2096        @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 no longer at the location, then the period will have an end date/time." )
2097        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/encounter-location-status")
2098        protected Enumeration<EncounterLocationStatus> status;
2099
2100        /**
2101         * This will be used to specify the required levels (bed/ward/room/etc.) desired to be recorded to simplify either messaging or query.
2102         */
2103        @Child(name = "physicalType", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=false)
2104        @Description(shortDefinition="The physical type of the location (usually the level in the location hierachy - bed room ward etc.)", formalDefinition="This will be used to specify the required levels (bed/ward/room/etc.) desired to be recorded to simplify either messaging or query." )
2105        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/location-physical-type")
2106        protected CodeableConcept physicalType;
2107
2108        /**
2109         * Time period during which the patient was present at the location.
2110         */
2111        @Child(name = "period", type = {Period.class}, order=4, min=0, max=1, modifier=false, summary=false)
2112        @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." )
2113        protected Period period;
2114
2115        private static final long serialVersionUID = -755081862L;
2116
2117    /**
2118     * Constructor
2119     */
2120      public EncounterLocationComponent() {
2121        super();
2122      }
2123
2124    /**
2125     * Constructor
2126     */
2127      public EncounterLocationComponent(Reference location) {
2128        super();
2129        this.location = location;
2130      }
2131
2132        /**
2133         * @return {@link #location} (The location where the encounter takes place.)
2134         */
2135        public Reference getLocation() { 
2136          if (this.location == null)
2137            if (Configuration.errorOnAutoCreate())
2138              throw new Error("Attempt to auto-create EncounterLocationComponent.location");
2139            else if (Configuration.doAutoCreate())
2140              this.location = new Reference(); // cc
2141          return this.location;
2142        }
2143
2144        public boolean hasLocation() { 
2145          return this.location != null && !this.location.isEmpty();
2146        }
2147
2148        /**
2149         * @param value {@link #location} (The location where the encounter takes place.)
2150         */
2151        public EncounterLocationComponent setLocation(Reference value) { 
2152          this.location = value;
2153          return this;
2154        }
2155
2156        /**
2157         * @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.)
2158         */
2159        public Location getLocationTarget() { 
2160          if (this.locationTarget == null)
2161            if (Configuration.errorOnAutoCreate())
2162              throw new Error("Attempt to auto-create EncounterLocationComponent.location");
2163            else if (Configuration.doAutoCreate())
2164              this.locationTarget = new Location(); // aa
2165          return this.locationTarget;
2166        }
2167
2168        /**
2169         * @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.)
2170         */
2171        public EncounterLocationComponent setLocationTarget(Location value) { 
2172          this.locationTarget = value;
2173          return this;
2174        }
2175
2176        /**
2177         * @return {@link #status} (The status of the participants' presence at the specified location during the period specified. If the participant 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
2178         */
2179        public Enumeration<EncounterLocationStatus> getStatusElement() { 
2180          if (this.status == null)
2181            if (Configuration.errorOnAutoCreate())
2182              throw new Error("Attempt to auto-create EncounterLocationComponent.status");
2183            else if (Configuration.doAutoCreate())
2184              this.status = new Enumeration<EncounterLocationStatus>(new EncounterLocationStatusEnumFactory()); // bb
2185          return this.status;
2186        }
2187
2188        public boolean hasStatusElement() { 
2189          return this.status != null && !this.status.isEmpty();
2190        }
2191
2192        public boolean hasStatus() { 
2193          return this.status != null && !this.status.isEmpty();
2194        }
2195
2196        /**
2197         * @param value {@link #status} (The status of the participants' presence at the specified location during the period specified. If the participant 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
2198         */
2199        public EncounterLocationComponent setStatusElement(Enumeration<EncounterLocationStatus> value) { 
2200          this.status = value;
2201          return this;
2202        }
2203
2204        /**
2205         * @return The status of the participants' presence at the specified location during the period specified. If the participant is no longer at the location, then the period will have an end date/time.
2206         */
2207        public EncounterLocationStatus getStatus() { 
2208          return this.status == null ? null : this.status.getValue();
2209        }
2210
2211        /**
2212         * @param value The status of the participants' presence at the specified location during the period specified. If the participant is no longer at the location, then the period will have an end date/time.
2213         */
2214        public EncounterLocationComponent setStatus(EncounterLocationStatus value) { 
2215          if (value == null)
2216            this.status = null;
2217          else {
2218            if (this.status == null)
2219              this.status = new Enumeration<EncounterLocationStatus>(new EncounterLocationStatusEnumFactory());
2220            this.status.setValue(value);
2221          }
2222          return this;
2223        }
2224
2225        /**
2226         * @return {@link #physicalType} (This will be used to specify the required levels (bed/ward/room/etc.) desired to be recorded to simplify either messaging or query.)
2227         */
2228        public CodeableConcept getPhysicalType() { 
2229          if (this.physicalType == null)
2230            if (Configuration.errorOnAutoCreate())
2231              throw new Error("Attempt to auto-create EncounterLocationComponent.physicalType");
2232            else if (Configuration.doAutoCreate())
2233              this.physicalType = new CodeableConcept(); // cc
2234          return this.physicalType;
2235        }
2236
2237        public boolean hasPhysicalType() { 
2238          return this.physicalType != null && !this.physicalType.isEmpty();
2239        }
2240
2241        /**
2242         * @param value {@link #physicalType} (This will be used to specify the required levels (bed/ward/room/etc.) desired to be recorded to simplify either messaging or query.)
2243         */
2244        public EncounterLocationComponent setPhysicalType(CodeableConcept value) { 
2245          this.physicalType = value;
2246          return this;
2247        }
2248
2249        /**
2250         * @return {@link #period} (Time period during which the patient was present at the location.)
2251         */
2252        public Period getPeriod() { 
2253          if (this.period == null)
2254            if (Configuration.errorOnAutoCreate())
2255              throw new Error("Attempt to auto-create EncounterLocationComponent.period");
2256            else if (Configuration.doAutoCreate())
2257              this.period = new Period(); // cc
2258          return this.period;
2259        }
2260
2261        public boolean hasPeriod() { 
2262          return this.period != null && !this.period.isEmpty();
2263        }
2264
2265        /**
2266         * @param value {@link #period} (Time period during which the patient was present at the location.)
2267         */
2268        public EncounterLocationComponent setPeriod(Period value) { 
2269          this.period = value;
2270          return this;
2271        }
2272
2273        protected void listChildren(List<Property> children) {
2274          super.listChildren(children);
2275          children.add(new Property("location", "Reference(Location)", "The location where the encounter takes place.", 0, 1, location));
2276          children.add(new Property("status", "code", "The status of the participants' presence at the specified location during the period specified. If the participant is no longer at the location, then the period will have an end date/time.", 0, 1, status));
2277          children.add(new Property("physicalType", "CodeableConcept", "This will be used to specify the required levels (bed/ward/room/etc.) desired to be recorded to simplify either messaging or query.", 0, 1, physicalType));
2278          children.add(new Property("period", "Period", "Time period during which the patient was present at the location.", 0, 1, period));
2279        }
2280
2281        @Override
2282        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2283          switch (_hash) {
2284          case 1901043637: /*location*/  return new Property("location", "Reference(Location)", "The location where the encounter takes place.", 0, 1, location);
2285          case -892481550: /*status*/  return new Property("status", "code", "The status of the participants' presence at the specified location during the period specified. If the participant is no longer at the location, then the period will have an end date/time.", 0, 1, status);
2286          case -1474715471: /*physicalType*/  return new Property("physicalType", "CodeableConcept", "This will be used to specify the required levels (bed/ward/room/etc.) desired to be recorded to simplify either messaging or query.", 0, 1, physicalType);
2287          case -991726143: /*period*/  return new Property("period", "Period", "Time period during which the patient was present at the location.", 0, 1, period);
2288          default: return super.getNamedProperty(_hash, _name, _checkValid);
2289          }
2290
2291        }
2292
2293      @Override
2294      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2295        switch (hash) {
2296        case 1901043637: /*location*/ return this.location == null ? new Base[0] : new Base[] {this.location}; // Reference
2297        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<EncounterLocationStatus>
2298        case -1474715471: /*physicalType*/ return this.physicalType == null ? new Base[0] : new Base[] {this.physicalType}; // CodeableConcept
2299        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
2300        default: return super.getProperty(hash, name, checkValid);
2301        }
2302
2303      }
2304
2305      @Override
2306      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2307        switch (hash) {
2308        case 1901043637: // location
2309          this.location = castToReference(value); // Reference
2310          return value;
2311        case -892481550: // status
2312          value = new EncounterLocationStatusEnumFactory().fromType(castToCode(value));
2313          this.status = (Enumeration) value; // Enumeration<EncounterLocationStatus>
2314          return value;
2315        case -1474715471: // physicalType
2316          this.physicalType = castToCodeableConcept(value); // CodeableConcept
2317          return value;
2318        case -991726143: // period
2319          this.period = castToPeriod(value); // Period
2320          return value;
2321        default: return super.setProperty(hash, name, value);
2322        }
2323
2324      }
2325
2326      @Override
2327      public Base setProperty(String name, Base value) throws FHIRException {
2328        if (name.equals("location")) {
2329          this.location = castToReference(value); // Reference
2330        } else if (name.equals("status")) {
2331          value = new EncounterLocationStatusEnumFactory().fromType(castToCode(value));
2332          this.status = (Enumeration) value; // Enumeration<EncounterLocationStatus>
2333        } else if (name.equals("physicalType")) {
2334          this.physicalType = castToCodeableConcept(value); // CodeableConcept
2335        } else if (name.equals("period")) {
2336          this.period = castToPeriod(value); // Period
2337        } else
2338          return super.setProperty(name, value);
2339        return value;
2340      }
2341
2342      @Override
2343      public Base makeProperty(int hash, String name) throws FHIRException {
2344        switch (hash) {
2345        case 1901043637:  return getLocation(); 
2346        case -892481550:  return getStatusElement();
2347        case -1474715471:  return getPhysicalType(); 
2348        case -991726143:  return getPeriod(); 
2349        default: return super.makeProperty(hash, name);
2350        }
2351
2352      }
2353
2354      @Override
2355      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2356        switch (hash) {
2357        case 1901043637: /*location*/ return new String[] {"Reference"};
2358        case -892481550: /*status*/ return new String[] {"code"};
2359        case -1474715471: /*physicalType*/ return new String[] {"CodeableConcept"};
2360        case -991726143: /*period*/ return new String[] {"Period"};
2361        default: return super.getTypesForProperty(hash, name);
2362        }
2363
2364      }
2365
2366      @Override
2367      public Base addChild(String name) throws FHIRException {
2368        if (name.equals("location")) {
2369          this.location = new Reference();
2370          return this.location;
2371        }
2372        else if (name.equals("status")) {
2373          throw new FHIRException("Cannot call addChild on a primitive type Encounter.status");
2374        }
2375        else if (name.equals("physicalType")) {
2376          this.physicalType = new CodeableConcept();
2377          return this.physicalType;
2378        }
2379        else if (name.equals("period")) {
2380          this.period = new Period();
2381          return this.period;
2382        }
2383        else
2384          return super.addChild(name);
2385      }
2386
2387      public EncounterLocationComponent copy() {
2388        EncounterLocationComponent dst = new EncounterLocationComponent();
2389        copyValues(dst);
2390        dst.location = location == null ? null : location.copy();
2391        dst.status = status == null ? null : status.copy();
2392        dst.physicalType = physicalType == null ? null : physicalType.copy();
2393        dst.period = period == null ? null : period.copy();
2394        return dst;
2395      }
2396
2397      @Override
2398      public boolean equalsDeep(Base other_) {
2399        if (!super.equalsDeep(other_))
2400          return false;
2401        if (!(other_ instanceof EncounterLocationComponent))
2402          return false;
2403        EncounterLocationComponent o = (EncounterLocationComponent) other_;
2404        return compareDeep(location, o.location, true) && compareDeep(status, o.status, true) && compareDeep(physicalType, o.physicalType, true)
2405           && compareDeep(period, o.period, true);
2406      }
2407
2408      @Override
2409      public boolean equalsShallow(Base other_) {
2410        if (!super.equalsShallow(other_))
2411          return false;
2412        if (!(other_ instanceof EncounterLocationComponent))
2413          return false;
2414        EncounterLocationComponent o = (EncounterLocationComponent) other_;
2415        return compareValues(status, o.status, true);
2416      }
2417
2418      public boolean isEmpty() {
2419        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(location, status, physicalType
2420          , period);
2421      }
2422
2423  public String fhirType() {
2424    return "Encounter.location";
2425
2426  }
2427
2428  }
2429
2430    /**
2431     * Identifier(s) by which this encounter is known.
2432     */
2433    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2434    @Description(shortDefinition="Identifier(s) by which this encounter is known", formalDefinition="Identifier(s) by which this encounter is known." )
2435    protected List<Identifier> identifier;
2436
2437    /**
2438     * planned | arrived | triaged | in-progress | onleave | finished | cancelled +.
2439     */
2440    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
2441    @Description(shortDefinition="planned | arrived | triaged | in-progress | onleave | finished | cancelled +", formalDefinition="planned | arrived | triaged | in-progress | onleave | finished | cancelled +." )
2442    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/encounter-status")
2443    protected Enumeration<EncounterStatus> status;
2444
2445    /**
2446     * 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.
2447     */
2448    @Child(name = "statusHistory", type = {}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2449    @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." )
2450    protected List<StatusHistoryComponent> statusHistory;
2451
2452    /**
2453     * Concepts representing classification of patient encounter such as ambulatory (outpatient), inpatient, emergency, home health or others due to local variations.
2454     */
2455    @Child(name = "class", type = {Coding.class}, order=3, min=1, max=1, modifier=false, summary=true)
2456    @Description(shortDefinition="Classification of patient encounter", formalDefinition="Concepts representing classification of patient encounter such as ambulatory (outpatient), inpatient, emergency, home health or others due to local variations." )
2457    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://terminology.hl7.org/ValueSet/v3-ActEncounterCode")
2458    protected Coding class_;
2459
2460    /**
2461     * The class history permits the tracking of the encounters transitions without needing to go  through the resource history.  This would be used for a case where an admission starts of as an emergency encounter, then transitions 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 kind of discharge from emergency to inpatient.
2462     */
2463    @Child(name = "classHistory", type = {}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2464    @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.  This would be used for a case where an admission starts of as an emergency encounter, then transitions 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 kind of discharge from emergency to inpatient." )
2465    protected List<ClassHistoryComponent> classHistory;
2466
2467    /**
2468     * Specific type of encounter (e.g. e-mail consultation, surgical day-care, skilled nursing, rehabilitation).
2469     */
2470    @Child(name = "type", type = {CodeableConcept.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2471    @Description(shortDefinition="Specific type of encounter", formalDefinition="Specific type of encounter (e.g. e-mail consultation, surgical day-care, skilled nursing, rehabilitation)." )
2472    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/encounter-type")
2473    protected List<CodeableConcept> type;
2474
2475    /**
2476     * Broad categorization of the service that is to be provided (e.g. cardiology).
2477     */
2478    @Child(name = "serviceType", type = {CodeableConcept.class}, order=6, min=0, max=1, modifier=false, summary=true)
2479    @Description(shortDefinition="Specific type of service", formalDefinition="Broad categorization of the service that is to be provided (e.g. cardiology)." )
2480    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/service-type")
2481    protected CodeableConcept serviceType;
2482
2483    /**
2484     * Indicates the urgency of the encounter.
2485     */
2486    @Child(name = "priority", type = {CodeableConcept.class}, order=7, min=0, max=1, modifier=false, summary=false)
2487    @Description(shortDefinition="Indicates the urgency of the encounter", formalDefinition="Indicates the urgency of the encounter." )
2488    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://terminology.hl7.org/ValueSet/v3-ActPriority")
2489    protected CodeableConcept priority;
2490
2491    /**
2492     * The patient or group present at the encounter.
2493     */
2494    @Child(name = "subject", type = {Patient.class, Group.class}, order=8, min=0, max=1, modifier=false, summary=true)
2495    @Description(shortDefinition="The patient or group present at the encounter", formalDefinition="The patient or group present at the encounter." )
2496    protected Reference subject;
2497
2498    /**
2499     * The actual object that is the target of the reference (The patient or group present at the encounter.)
2500     */
2501    protected Resource subjectTarget;
2502
2503    /**
2504     * 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).
2505     */
2506    @Child(name = "episodeOfCare", type = {EpisodeOfCare.class}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2507    @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)." )
2508    protected List<Reference> episodeOfCare;
2509    /**
2510     * 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).)
2511     */
2512    protected List<EpisodeOfCare> episodeOfCareTarget;
2513
2514
2515    /**
2516     * The request this encounter satisfies (e.g. incoming referral or procedure request).
2517     */
2518    @Child(name = "basedOn", type = {ServiceRequest.class}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2519    @Description(shortDefinition="The ServiceRequest that initiated this encounter", formalDefinition="The request this encounter satisfies (e.g. incoming referral or procedure request)." )
2520    protected List<Reference> basedOn;
2521    /**
2522     * The actual objects that are the target of the reference (The request this encounter satisfies (e.g. incoming referral or procedure request).)
2523     */
2524    protected List<ServiceRequest> basedOnTarget;
2525
2526
2527    /**
2528     * The list of people responsible for providing the service.
2529     */
2530    @Child(name = "participant", type = {}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2531    @Description(shortDefinition="List of participants involved in the encounter", formalDefinition="The list of people responsible for providing the service." )
2532    protected List<EncounterParticipantComponent> participant;
2533
2534    /**
2535     * The appointment that scheduled this encounter.
2536     */
2537    @Child(name = "appointment", type = {Appointment.class}, order=12, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2538    @Description(shortDefinition="The appointment that scheduled this encounter", formalDefinition="The appointment that scheduled this encounter." )
2539    protected List<Reference> appointment;
2540    /**
2541     * The actual objects that are the target of the reference (The appointment that scheduled this encounter.)
2542     */
2543    protected List<Appointment> appointmentTarget;
2544
2545
2546    /**
2547     * The start and end time of the encounter.
2548     */
2549    @Child(name = "period", type = {Period.class}, order=13, min=0, max=1, modifier=false, summary=false)
2550    @Description(shortDefinition="The start and end time of the encounter", formalDefinition="The start and end time of the encounter." )
2551    protected Period period;
2552
2553    /**
2554     * Quantity of time the encounter lasted. This excludes the time during leaves of absence.
2555     */
2556    @Child(name = "length", type = {Duration.class}, order=14, min=0, max=1, modifier=false, summary=false)
2557    @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." )
2558    protected Duration length;
2559
2560    /**
2561     * Reason the encounter takes place, expressed as a code. For admissions, this can be used for a coded admission diagnosis.
2562     */
2563    @Child(name = "reasonCode", type = {CodeableConcept.class}, order=15, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2564    @Description(shortDefinition="Coded reason the encounter takes place", formalDefinition="Reason the encounter takes place, expressed as a code. For admissions, this can be used for a coded admission diagnosis." )
2565    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/encounter-reason")
2566    protected List<CodeableConcept> reasonCode;
2567
2568    /**
2569     * Reason the encounter takes place, expressed as a code. For admissions, this can be used for a coded admission diagnosis.
2570     */
2571    @Child(name = "reasonReference", type = {Condition.class, Procedure.class, Observation.class, ImmunizationRecommendation.class}, order=16, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2572    @Description(shortDefinition="Reason the encounter takes place (reference)", formalDefinition="Reason the encounter takes place, expressed as a code. For admissions, this can be used for a coded admission diagnosis." )
2573    protected List<Reference> reasonReference;
2574    /**
2575     * The actual objects that are the target of the reference (Reason the encounter takes place, expressed as a code. For admissions, this can be used for a coded admission diagnosis.)
2576     */
2577    protected List<Resource> reasonReferenceTarget;
2578
2579
2580    /**
2581     * The list of diagnosis relevant to this encounter.
2582     */
2583    @Child(name = "diagnosis", type = {}, order=17, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2584    @Description(shortDefinition="The list of diagnosis relevant to this encounter", formalDefinition="The list of diagnosis relevant to this encounter." )
2585    protected List<DiagnosisComponent> diagnosis;
2586
2587    /**
2588     * The set of accounts that may be used for billing for this Encounter.
2589     */
2590    @Child(name = "account", type = {Account.class}, order=18, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2591    @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." )
2592    protected List<Reference> account;
2593    /**
2594     * The actual objects that are the target of the reference (The set of accounts that may be used for billing for this Encounter.)
2595     */
2596    protected List<Account> accountTarget;
2597
2598
2599    /**
2600     * Details about the admission to a healthcare service.
2601     */
2602    @Child(name = "hospitalization", type = {}, order=19, min=0, max=1, modifier=false, summary=false)
2603    @Description(shortDefinition="Details about the admission to a healthcare service", formalDefinition="Details about the admission to a healthcare service." )
2604    protected EncounterHospitalizationComponent hospitalization;
2605
2606    /**
2607     * List of locations where  the patient has been during this encounter.
2608     */
2609    @Child(name = "location", type = {}, order=20, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2610    @Description(shortDefinition="List of locations where the patient has been", formalDefinition="List of locations where  the patient has been during this encounter." )
2611    protected List<EncounterLocationComponent> location;
2612
2613    /**
2614     * The organization that is primarily responsible for this Encounter's services. This MAY be the same as the organization on the Patient record, however it could be different, such as if the actor performing the services was from an external organization (which may be billed seperately) for an external consultation.  Refer to the example bundle showing an abbreviated set of Encounters for a colonoscopy.
2615     */
2616    @Child(name = "serviceProvider", type = {Organization.class}, order=21, min=0, max=1, modifier=false, summary=false)
2617    @Description(shortDefinition="The organization (facility) responsible for this encounter", formalDefinition="The organization that is primarily responsible for this Encounter's services. This MAY be the same as the organization on the Patient record, however it could be different, such as if the actor performing the services was from an external organization (which may be billed seperately) for an external consultation.  Refer to the example bundle showing an abbreviated set of Encounters for a colonoscopy." )
2618    protected Reference serviceProvider;
2619
2620    /**
2621     * The actual object that is the target of the reference (The organization that is primarily responsible for this Encounter's services. This MAY be the same as the organization on the Patient record, however it could be different, such as if the actor performing the services was from an external organization (which may be billed seperately) for an external consultation.  Refer to the example bundle showing an abbreviated set of Encounters for a colonoscopy.)
2622     */
2623    protected Organization serviceProviderTarget;
2624
2625    /**
2626     * Another Encounter of which this encounter is a part of (administratively or in time).
2627     */
2628    @Child(name = "partOf", type = {Encounter.class}, order=22, min=0, max=1, modifier=false, summary=false)
2629    @Description(shortDefinition="Another Encounter this encounter is part of", formalDefinition="Another Encounter of which this encounter is a part of (administratively or in time)." )
2630    protected Reference partOf;
2631
2632    /**
2633     * The actual object that is the target of the reference (Another Encounter of which this encounter is a part of (administratively or in time).)
2634     */
2635    protected Encounter partOfTarget;
2636
2637    private static final long serialVersionUID = 1358318037L;
2638
2639  /**
2640   * Constructor
2641   */
2642    public Encounter() {
2643      super();
2644    }
2645
2646  /**
2647   * Constructor
2648   */
2649    public Encounter(Enumeration<EncounterStatus> status, Coding class_) {
2650      super();
2651      this.status = status;
2652      this.class_ = class_;
2653    }
2654
2655    /**
2656     * @return {@link #identifier} (Identifier(s) by which this encounter is known.)
2657     */
2658    public List<Identifier> getIdentifier() { 
2659      if (this.identifier == null)
2660        this.identifier = new ArrayList<Identifier>();
2661      return this.identifier;
2662    }
2663
2664    /**
2665     * @return Returns a reference to <code>this</code> for easy method chaining
2666     */
2667    public Encounter setIdentifier(List<Identifier> theIdentifier) { 
2668      this.identifier = theIdentifier;
2669      return this;
2670    }
2671
2672    public boolean hasIdentifier() { 
2673      if (this.identifier == null)
2674        return false;
2675      for (Identifier item : this.identifier)
2676        if (!item.isEmpty())
2677          return true;
2678      return false;
2679    }
2680
2681    public Identifier addIdentifier() { //3
2682      Identifier t = new Identifier();
2683      if (this.identifier == null)
2684        this.identifier = new ArrayList<Identifier>();
2685      this.identifier.add(t);
2686      return t;
2687    }
2688
2689    public Encounter addIdentifier(Identifier t) { //3
2690      if (t == null)
2691        return this;
2692      if (this.identifier == null)
2693        this.identifier = new ArrayList<Identifier>();
2694      this.identifier.add(t);
2695      return this;
2696    }
2697
2698    /**
2699     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
2700     */
2701    public Identifier getIdentifierFirstRep() { 
2702      if (getIdentifier().isEmpty()) {
2703        addIdentifier();
2704      }
2705      return getIdentifier().get(0);
2706    }
2707
2708    /**
2709     * @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
2710     */
2711    public Enumeration<EncounterStatus> getStatusElement() { 
2712      if (this.status == null)
2713        if (Configuration.errorOnAutoCreate())
2714          throw new Error("Attempt to auto-create Encounter.status");
2715        else if (Configuration.doAutoCreate())
2716          this.status = new Enumeration<EncounterStatus>(new EncounterStatusEnumFactory()); // bb
2717      return this.status;
2718    }
2719
2720    public boolean hasStatusElement() { 
2721      return this.status != null && !this.status.isEmpty();
2722    }
2723
2724    public boolean hasStatus() { 
2725      return this.status != null && !this.status.isEmpty();
2726    }
2727
2728    /**
2729     * @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
2730     */
2731    public Encounter setStatusElement(Enumeration<EncounterStatus> value) { 
2732      this.status = value;
2733      return this;
2734    }
2735
2736    /**
2737     * @return planned | arrived | triaged | in-progress | onleave | finished | cancelled +.
2738     */
2739    public EncounterStatus getStatus() { 
2740      return this.status == null ? null : this.status.getValue();
2741    }
2742
2743    /**
2744     * @param value planned | arrived | triaged | in-progress | onleave | finished | cancelled +.
2745     */
2746    public Encounter setStatus(EncounterStatus value) { 
2747        if (this.status == null)
2748          this.status = new Enumeration<EncounterStatus>(new EncounterStatusEnumFactory());
2749        this.status.setValue(value);
2750      return this;
2751    }
2752
2753    /**
2754     * @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.)
2755     */
2756    public List<StatusHistoryComponent> getStatusHistory() { 
2757      if (this.statusHistory == null)
2758        this.statusHistory = new ArrayList<StatusHistoryComponent>();
2759      return this.statusHistory;
2760    }
2761
2762    /**
2763     * @return Returns a reference to <code>this</code> for easy method chaining
2764     */
2765    public Encounter setStatusHistory(List<StatusHistoryComponent> theStatusHistory) { 
2766      this.statusHistory = theStatusHistory;
2767      return this;
2768    }
2769
2770    public boolean hasStatusHistory() { 
2771      if (this.statusHistory == null)
2772        return false;
2773      for (StatusHistoryComponent item : this.statusHistory)
2774        if (!item.isEmpty())
2775          return true;
2776      return false;
2777    }
2778
2779    public StatusHistoryComponent addStatusHistory() { //3
2780      StatusHistoryComponent t = new StatusHistoryComponent();
2781      if (this.statusHistory == null)
2782        this.statusHistory = new ArrayList<StatusHistoryComponent>();
2783      this.statusHistory.add(t);
2784      return t;
2785    }
2786
2787    public Encounter addStatusHistory(StatusHistoryComponent t) { //3
2788      if (t == null)
2789        return this;
2790      if (this.statusHistory == null)
2791        this.statusHistory = new ArrayList<StatusHistoryComponent>();
2792      this.statusHistory.add(t);
2793      return this;
2794    }
2795
2796    /**
2797     * @return The first repetition of repeating field {@link #statusHistory}, creating it if it does not already exist
2798     */
2799    public StatusHistoryComponent getStatusHistoryFirstRep() { 
2800      if (getStatusHistory().isEmpty()) {
2801        addStatusHistory();
2802      }
2803      return getStatusHistory().get(0);
2804    }
2805
2806    /**
2807     * @return {@link #class_} (Concepts representing classification of patient encounter such as ambulatory (outpatient), inpatient, emergency, home health or others due to local variations.)
2808     */
2809    public Coding getClass_() { 
2810      if (this.class_ == null)
2811        if (Configuration.errorOnAutoCreate())
2812          throw new Error("Attempt to auto-create Encounter.class_");
2813        else if (Configuration.doAutoCreate())
2814          this.class_ = new Coding(); // cc
2815      return this.class_;
2816    }
2817
2818    public boolean hasClass_() { 
2819      return this.class_ != null && !this.class_.isEmpty();
2820    }
2821
2822    /**
2823     * @param value {@link #class_} (Concepts representing classification of patient encounter such as ambulatory (outpatient), inpatient, emergency, home health or others due to local variations.)
2824     */
2825    public Encounter setClass_(Coding value) { 
2826      this.class_ = value;
2827      return this;
2828    }
2829
2830    /**
2831     * @return {@link #classHistory} (The class history permits the tracking of the encounters transitions without needing to go  through the resource history.  This would be used for a case where an admission starts of as an emergency encounter, then transitions 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 kind of discharge from emergency to inpatient.)
2832     */
2833    public List<ClassHistoryComponent> getClassHistory() { 
2834      if (this.classHistory == null)
2835        this.classHistory = new ArrayList<ClassHistoryComponent>();
2836      return this.classHistory;
2837    }
2838
2839    /**
2840     * @return Returns a reference to <code>this</code> for easy method chaining
2841     */
2842    public Encounter setClassHistory(List<ClassHistoryComponent> theClassHistory) { 
2843      this.classHistory = theClassHistory;
2844      return this;
2845    }
2846
2847    public boolean hasClassHistory() { 
2848      if (this.classHistory == null)
2849        return false;
2850      for (ClassHistoryComponent item : this.classHistory)
2851        if (!item.isEmpty())
2852          return true;
2853      return false;
2854    }
2855
2856    public ClassHistoryComponent addClassHistory() { //3
2857      ClassHistoryComponent t = new ClassHistoryComponent();
2858      if (this.classHistory == null)
2859        this.classHistory = new ArrayList<ClassHistoryComponent>();
2860      this.classHistory.add(t);
2861      return t;
2862    }
2863
2864    public Encounter addClassHistory(ClassHistoryComponent t) { //3
2865      if (t == null)
2866        return this;
2867      if (this.classHistory == null)
2868        this.classHistory = new ArrayList<ClassHistoryComponent>();
2869      this.classHistory.add(t);
2870      return this;
2871    }
2872
2873    /**
2874     * @return The first repetition of repeating field {@link #classHistory}, creating it if it does not already exist
2875     */
2876    public ClassHistoryComponent getClassHistoryFirstRep() { 
2877      if (getClassHistory().isEmpty()) {
2878        addClassHistory();
2879      }
2880      return getClassHistory().get(0);
2881    }
2882
2883    /**
2884     * @return {@link #type} (Specific type of encounter (e.g. e-mail consultation, surgical day-care, skilled nursing, rehabilitation).)
2885     */
2886    public List<CodeableConcept> getType() { 
2887      if (this.type == null)
2888        this.type = new ArrayList<CodeableConcept>();
2889      return this.type;
2890    }
2891
2892    /**
2893     * @return Returns a reference to <code>this</code> for easy method chaining
2894     */
2895    public Encounter setType(List<CodeableConcept> theType) { 
2896      this.type = theType;
2897      return this;
2898    }
2899
2900    public boolean hasType() { 
2901      if (this.type == null)
2902        return false;
2903      for (CodeableConcept item : this.type)
2904        if (!item.isEmpty())
2905          return true;
2906      return false;
2907    }
2908
2909    public CodeableConcept addType() { //3
2910      CodeableConcept t = new CodeableConcept();
2911      if (this.type == null)
2912        this.type = new ArrayList<CodeableConcept>();
2913      this.type.add(t);
2914      return t;
2915    }
2916
2917    public Encounter addType(CodeableConcept t) { //3
2918      if (t == null)
2919        return this;
2920      if (this.type == null)
2921        this.type = new ArrayList<CodeableConcept>();
2922      this.type.add(t);
2923      return this;
2924    }
2925
2926    /**
2927     * @return The first repetition of repeating field {@link #type}, creating it if it does not already exist
2928     */
2929    public CodeableConcept getTypeFirstRep() { 
2930      if (getType().isEmpty()) {
2931        addType();
2932      }
2933      return getType().get(0);
2934    }
2935
2936    /**
2937     * @return {@link #serviceType} (Broad categorization of the service that is to be provided (e.g. cardiology).)
2938     */
2939    public CodeableConcept getServiceType() { 
2940      if (this.serviceType == null)
2941        if (Configuration.errorOnAutoCreate())
2942          throw new Error("Attempt to auto-create Encounter.serviceType");
2943        else if (Configuration.doAutoCreate())
2944          this.serviceType = new CodeableConcept(); // cc
2945      return this.serviceType;
2946    }
2947
2948    public boolean hasServiceType() { 
2949      return this.serviceType != null && !this.serviceType.isEmpty();
2950    }
2951
2952    /**
2953     * @param value {@link #serviceType} (Broad categorization of the service that is to be provided (e.g. cardiology).)
2954     */
2955    public Encounter setServiceType(CodeableConcept value) { 
2956      this.serviceType = value;
2957      return this;
2958    }
2959
2960    /**
2961     * @return {@link #priority} (Indicates the urgency of the encounter.)
2962     */
2963    public CodeableConcept getPriority() { 
2964      if (this.priority == null)
2965        if (Configuration.errorOnAutoCreate())
2966          throw new Error("Attempt to auto-create Encounter.priority");
2967        else if (Configuration.doAutoCreate())
2968          this.priority = new CodeableConcept(); // cc
2969      return this.priority;
2970    }
2971
2972    public boolean hasPriority() { 
2973      return this.priority != null && !this.priority.isEmpty();
2974    }
2975
2976    /**
2977     * @param value {@link #priority} (Indicates the urgency of the encounter.)
2978     */
2979    public Encounter setPriority(CodeableConcept value) { 
2980      this.priority = value;
2981      return this;
2982    }
2983
2984    /**
2985     * @return {@link #subject} (The patient or group present at the encounter.)
2986     */
2987    public Reference getSubject() { 
2988      if (this.subject == null)
2989        if (Configuration.errorOnAutoCreate())
2990          throw new Error("Attempt to auto-create Encounter.subject");
2991        else if (Configuration.doAutoCreate())
2992          this.subject = new Reference(); // cc
2993      return this.subject;
2994    }
2995
2996    public boolean hasSubject() { 
2997      return this.subject != null && !this.subject.isEmpty();
2998    }
2999
3000    /**
3001     * @param value {@link #subject} (The patient or group present at the encounter.)
3002     */
3003    public Encounter setSubject(Reference value) { 
3004      this.subject = value;
3005      return this;
3006    }
3007
3008    /**
3009     * @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 or group present at the encounter.)
3010     */
3011    public Resource getSubjectTarget() { 
3012      return this.subjectTarget;
3013    }
3014
3015    /**
3016     * @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 or group present at the encounter.)
3017     */
3018    public Encounter setSubjectTarget(Resource value) { 
3019      this.subjectTarget = value;
3020      return this;
3021    }
3022
3023    /**
3024     * @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).)
3025     */
3026    public List<Reference> getEpisodeOfCare() { 
3027      if (this.episodeOfCare == null)
3028        this.episodeOfCare = new ArrayList<Reference>();
3029      return this.episodeOfCare;
3030    }
3031
3032    /**
3033     * @return Returns a reference to <code>this</code> for easy method chaining
3034     */
3035    public Encounter setEpisodeOfCare(List<Reference> theEpisodeOfCare) { 
3036      this.episodeOfCare = theEpisodeOfCare;
3037      return this;
3038    }
3039
3040    public boolean hasEpisodeOfCare() { 
3041      if (this.episodeOfCare == null)
3042        return false;
3043      for (Reference item : this.episodeOfCare)
3044        if (!item.isEmpty())
3045          return true;
3046      return false;
3047    }
3048
3049    public Reference addEpisodeOfCare() { //3
3050      Reference t = new Reference();
3051      if (this.episodeOfCare == null)
3052        this.episodeOfCare = new ArrayList<Reference>();
3053      this.episodeOfCare.add(t);
3054      return t;
3055    }
3056
3057    public Encounter addEpisodeOfCare(Reference t) { //3
3058      if (t == null)
3059        return this;
3060      if (this.episodeOfCare == null)
3061        this.episodeOfCare = new ArrayList<Reference>();
3062      this.episodeOfCare.add(t);
3063      return this;
3064    }
3065
3066    /**
3067     * @return The first repetition of repeating field {@link #episodeOfCare}, creating it if it does not already exist
3068     */
3069    public Reference getEpisodeOfCareFirstRep() { 
3070      if (getEpisodeOfCare().isEmpty()) {
3071        addEpisodeOfCare();
3072      }
3073      return getEpisodeOfCare().get(0);
3074    }
3075
3076    /**
3077     * @deprecated Use Reference#setResource(IBaseResource) instead
3078     */
3079    @Deprecated
3080    public List<EpisodeOfCare> getEpisodeOfCareTarget() { 
3081      if (this.episodeOfCareTarget == null)
3082        this.episodeOfCareTarget = new ArrayList<EpisodeOfCare>();
3083      return this.episodeOfCareTarget;
3084    }
3085
3086    /**
3087     * @deprecated Use Reference#setResource(IBaseResource) instead
3088     */
3089    @Deprecated
3090    public EpisodeOfCare addEpisodeOfCareTarget() { 
3091      EpisodeOfCare r = new EpisodeOfCare();
3092      if (this.episodeOfCareTarget == null)
3093        this.episodeOfCareTarget = new ArrayList<EpisodeOfCare>();
3094      this.episodeOfCareTarget.add(r);
3095      return r;
3096    }
3097
3098    /**
3099     * @return {@link #basedOn} (The request this encounter satisfies (e.g. incoming referral or procedure request).)
3100     */
3101    public List<Reference> getBasedOn() { 
3102      if (this.basedOn == null)
3103        this.basedOn = new ArrayList<Reference>();
3104      return this.basedOn;
3105    }
3106
3107    /**
3108     * @return Returns a reference to <code>this</code> for easy method chaining
3109     */
3110    public Encounter setBasedOn(List<Reference> theBasedOn) { 
3111      this.basedOn = theBasedOn;
3112      return this;
3113    }
3114
3115    public boolean hasBasedOn() { 
3116      if (this.basedOn == null)
3117        return false;
3118      for (Reference item : this.basedOn)
3119        if (!item.isEmpty())
3120          return true;
3121      return false;
3122    }
3123
3124    public Reference addBasedOn() { //3
3125      Reference t = new Reference();
3126      if (this.basedOn == null)
3127        this.basedOn = new ArrayList<Reference>();
3128      this.basedOn.add(t);
3129      return t;
3130    }
3131
3132    public Encounter addBasedOn(Reference t) { //3
3133      if (t == null)
3134        return this;
3135      if (this.basedOn == null)
3136        this.basedOn = new ArrayList<Reference>();
3137      this.basedOn.add(t);
3138      return this;
3139    }
3140
3141    /**
3142     * @return The first repetition of repeating field {@link #basedOn}, creating it if it does not already exist
3143     */
3144    public Reference getBasedOnFirstRep() { 
3145      if (getBasedOn().isEmpty()) {
3146        addBasedOn();
3147      }
3148      return getBasedOn().get(0);
3149    }
3150
3151    /**
3152     * @deprecated Use Reference#setResource(IBaseResource) instead
3153     */
3154    @Deprecated
3155    public List<ServiceRequest> getBasedOnTarget() { 
3156      if (this.basedOnTarget == null)
3157        this.basedOnTarget = new ArrayList<ServiceRequest>();
3158      return this.basedOnTarget;
3159    }
3160
3161    /**
3162     * @deprecated Use Reference#setResource(IBaseResource) instead
3163     */
3164    @Deprecated
3165    public ServiceRequest addBasedOnTarget() { 
3166      ServiceRequest r = new ServiceRequest();
3167      if (this.basedOnTarget == null)
3168        this.basedOnTarget = new ArrayList<ServiceRequest>();
3169      this.basedOnTarget.add(r);
3170      return r;
3171    }
3172
3173    /**
3174     * @return {@link #participant} (The list of people responsible for providing the service.)
3175     */
3176    public List<EncounterParticipantComponent> getParticipant() { 
3177      if (this.participant == null)
3178        this.participant = new ArrayList<EncounterParticipantComponent>();
3179      return this.participant;
3180    }
3181
3182    /**
3183     * @return Returns a reference to <code>this</code> for easy method chaining
3184     */
3185    public Encounter setParticipant(List<EncounterParticipantComponent> theParticipant) { 
3186      this.participant = theParticipant;
3187      return this;
3188    }
3189
3190    public boolean hasParticipant() { 
3191      if (this.participant == null)
3192        return false;
3193      for (EncounterParticipantComponent item : this.participant)
3194        if (!item.isEmpty())
3195          return true;
3196      return false;
3197    }
3198
3199    public EncounterParticipantComponent addParticipant() { //3
3200      EncounterParticipantComponent t = new EncounterParticipantComponent();
3201      if (this.participant == null)
3202        this.participant = new ArrayList<EncounterParticipantComponent>();
3203      this.participant.add(t);
3204      return t;
3205    }
3206
3207    public Encounter addParticipant(EncounterParticipantComponent t) { //3
3208      if (t == null)
3209        return this;
3210      if (this.participant == null)
3211        this.participant = new ArrayList<EncounterParticipantComponent>();
3212      this.participant.add(t);
3213      return this;
3214    }
3215
3216    /**
3217     * @return The first repetition of repeating field {@link #participant}, creating it if it does not already exist
3218     */
3219    public EncounterParticipantComponent getParticipantFirstRep() { 
3220      if (getParticipant().isEmpty()) {
3221        addParticipant();
3222      }
3223      return getParticipant().get(0);
3224    }
3225
3226    /**
3227     * @return {@link #appointment} (The appointment that scheduled this encounter.)
3228     */
3229    public List<Reference> getAppointment() { 
3230      if (this.appointment == null)
3231        this.appointment = new ArrayList<Reference>();
3232      return this.appointment;
3233    }
3234
3235    /**
3236     * @return Returns a reference to <code>this</code> for easy method chaining
3237     */
3238    public Encounter setAppointment(List<Reference> theAppointment) { 
3239      this.appointment = theAppointment;
3240      return this;
3241    }
3242
3243    public boolean hasAppointment() { 
3244      if (this.appointment == null)
3245        return false;
3246      for (Reference item : this.appointment)
3247        if (!item.isEmpty())
3248          return true;
3249      return false;
3250    }
3251
3252    public Reference addAppointment() { //3
3253      Reference t = new Reference();
3254      if (this.appointment == null)
3255        this.appointment = new ArrayList<Reference>();
3256      this.appointment.add(t);
3257      return t;
3258    }
3259
3260    public Encounter addAppointment(Reference t) { //3
3261      if (t == null)
3262        return this;
3263      if (this.appointment == null)
3264        this.appointment = new ArrayList<Reference>();
3265      this.appointment.add(t);
3266      return this;
3267    }
3268
3269    /**
3270     * @return The first repetition of repeating field {@link #appointment}, creating it if it does not already exist
3271     */
3272    public Reference getAppointmentFirstRep() { 
3273      if (getAppointment().isEmpty()) {
3274        addAppointment();
3275      }
3276      return getAppointment().get(0);
3277    }
3278
3279    /**
3280     * @deprecated Use Reference#setResource(IBaseResource) instead
3281     */
3282    @Deprecated
3283    public List<Appointment> getAppointmentTarget() { 
3284      if (this.appointmentTarget == null)
3285        this.appointmentTarget = new ArrayList<Appointment>();
3286      return this.appointmentTarget;
3287    }
3288
3289    /**
3290     * @deprecated Use Reference#setResource(IBaseResource) instead
3291     */
3292    @Deprecated
3293    public Appointment addAppointmentTarget() { 
3294      Appointment r = new Appointment();
3295      if (this.appointmentTarget == null)
3296        this.appointmentTarget = new ArrayList<Appointment>();
3297      this.appointmentTarget.add(r);
3298      return r;
3299    }
3300
3301    /**
3302     * @return {@link #period} (The start and end time of the encounter.)
3303     */
3304    public Period getPeriod() { 
3305      if (this.period == null)
3306        if (Configuration.errorOnAutoCreate())
3307          throw new Error("Attempt to auto-create Encounter.period");
3308        else if (Configuration.doAutoCreate())
3309          this.period = new Period(); // cc
3310      return this.period;
3311    }
3312
3313    public boolean hasPeriod() { 
3314      return this.period != null && !this.period.isEmpty();
3315    }
3316
3317    /**
3318     * @param value {@link #period} (The start and end time of the encounter.)
3319     */
3320    public Encounter setPeriod(Period value) { 
3321      this.period = value;
3322      return this;
3323    }
3324
3325    /**
3326     * @return {@link #length} (Quantity of time the encounter lasted. This excludes the time during leaves of absence.)
3327     */
3328    public Duration getLength() { 
3329      if (this.length == null)
3330        if (Configuration.errorOnAutoCreate())
3331          throw new Error("Attempt to auto-create Encounter.length");
3332        else if (Configuration.doAutoCreate())
3333          this.length = new Duration(); // cc
3334      return this.length;
3335    }
3336
3337    public boolean hasLength() { 
3338      return this.length != null && !this.length.isEmpty();
3339    }
3340
3341    /**
3342     * @param value {@link #length} (Quantity of time the encounter lasted. This excludes the time during leaves of absence.)
3343     */
3344    public Encounter setLength(Duration value) { 
3345      this.length = value;
3346      return this;
3347    }
3348
3349    /**
3350     * @return {@link #reasonCode} (Reason the encounter takes place, expressed as a code. For admissions, this can be used for a coded admission diagnosis.)
3351     */
3352    public List<CodeableConcept> getReasonCode() { 
3353      if (this.reasonCode == null)
3354        this.reasonCode = new ArrayList<CodeableConcept>();
3355      return this.reasonCode;
3356    }
3357
3358    /**
3359     * @return Returns a reference to <code>this</code> for easy method chaining
3360     */
3361    public Encounter setReasonCode(List<CodeableConcept> theReasonCode) { 
3362      this.reasonCode = theReasonCode;
3363      return this;
3364    }
3365
3366    public boolean hasReasonCode() { 
3367      if (this.reasonCode == null)
3368        return false;
3369      for (CodeableConcept item : this.reasonCode)
3370        if (!item.isEmpty())
3371          return true;
3372      return false;
3373    }
3374
3375    public CodeableConcept addReasonCode() { //3
3376      CodeableConcept t = new CodeableConcept();
3377      if (this.reasonCode == null)
3378        this.reasonCode = new ArrayList<CodeableConcept>();
3379      this.reasonCode.add(t);
3380      return t;
3381    }
3382
3383    public Encounter addReasonCode(CodeableConcept t) { //3
3384      if (t == null)
3385        return this;
3386      if (this.reasonCode == null)
3387        this.reasonCode = new ArrayList<CodeableConcept>();
3388      this.reasonCode.add(t);
3389      return this;
3390    }
3391
3392    /**
3393     * @return The first repetition of repeating field {@link #reasonCode}, creating it if it does not already exist
3394     */
3395    public CodeableConcept getReasonCodeFirstRep() { 
3396      if (getReasonCode().isEmpty()) {
3397        addReasonCode();
3398      }
3399      return getReasonCode().get(0);
3400    }
3401
3402    /**
3403     * @return {@link #reasonReference} (Reason the encounter takes place, expressed as a code. For admissions, this can be used for a coded admission diagnosis.)
3404     */
3405    public List<Reference> getReasonReference() { 
3406      if (this.reasonReference == null)
3407        this.reasonReference = new ArrayList<Reference>();
3408      return this.reasonReference;
3409    }
3410
3411    /**
3412     * @return Returns a reference to <code>this</code> for easy method chaining
3413     */
3414    public Encounter setReasonReference(List<Reference> theReasonReference) { 
3415      this.reasonReference = theReasonReference;
3416      return this;
3417    }
3418
3419    public boolean hasReasonReference() { 
3420      if (this.reasonReference == null)
3421        return false;
3422      for (Reference item : this.reasonReference)
3423        if (!item.isEmpty())
3424          return true;
3425      return false;
3426    }
3427
3428    public Reference addReasonReference() { //3
3429      Reference t = new Reference();
3430      if (this.reasonReference == null)
3431        this.reasonReference = new ArrayList<Reference>();
3432      this.reasonReference.add(t);
3433      return t;
3434    }
3435
3436    public Encounter addReasonReference(Reference t) { //3
3437      if (t == null)
3438        return this;
3439      if (this.reasonReference == null)
3440        this.reasonReference = new ArrayList<Reference>();
3441      this.reasonReference.add(t);
3442      return this;
3443    }
3444
3445    /**
3446     * @return The first repetition of repeating field {@link #reasonReference}, creating it if it does not already exist
3447     */
3448    public Reference getReasonReferenceFirstRep() { 
3449      if (getReasonReference().isEmpty()) {
3450        addReasonReference();
3451      }
3452      return getReasonReference().get(0);
3453    }
3454
3455    /**
3456     * @deprecated Use Reference#setResource(IBaseResource) instead
3457     */
3458    @Deprecated
3459    public List<Resource> getReasonReferenceTarget() { 
3460      if (this.reasonReferenceTarget == null)
3461        this.reasonReferenceTarget = new ArrayList<Resource>();
3462      return this.reasonReferenceTarget;
3463    }
3464
3465    /**
3466     * @return {@link #diagnosis} (The list of diagnosis relevant to this encounter.)
3467     */
3468    public List<DiagnosisComponent> getDiagnosis() { 
3469      if (this.diagnosis == null)
3470        this.diagnosis = new ArrayList<DiagnosisComponent>();
3471      return this.diagnosis;
3472    }
3473
3474    /**
3475     * @return Returns a reference to <code>this</code> for easy method chaining
3476     */
3477    public Encounter setDiagnosis(List<DiagnosisComponent> theDiagnosis) { 
3478      this.diagnosis = theDiagnosis;
3479      return this;
3480    }
3481
3482    public boolean hasDiagnosis() { 
3483      if (this.diagnosis == null)
3484        return false;
3485      for (DiagnosisComponent item : this.diagnosis)
3486        if (!item.isEmpty())
3487          return true;
3488      return false;
3489    }
3490
3491    public DiagnosisComponent addDiagnosis() { //3
3492      DiagnosisComponent t = new DiagnosisComponent();
3493      if (this.diagnosis == null)
3494        this.diagnosis = new ArrayList<DiagnosisComponent>();
3495      this.diagnosis.add(t);
3496      return t;
3497    }
3498
3499    public Encounter addDiagnosis(DiagnosisComponent t) { //3
3500      if (t == null)
3501        return this;
3502      if (this.diagnosis == null)
3503        this.diagnosis = new ArrayList<DiagnosisComponent>();
3504      this.diagnosis.add(t);
3505      return this;
3506    }
3507
3508    /**
3509     * @return The first repetition of repeating field {@link #diagnosis}, creating it if it does not already exist
3510     */
3511    public DiagnosisComponent getDiagnosisFirstRep() { 
3512      if (getDiagnosis().isEmpty()) {
3513        addDiagnosis();
3514      }
3515      return getDiagnosis().get(0);
3516    }
3517
3518    /**
3519     * @return {@link #account} (The set of accounts that may be used for billing for this Encounter.)
3520     */
3521    public List<Reference> getAccount() { 
3522      if (this.account == null)
3523        this.account = new ArrayList<Reference>();
3524      return this.account;
3525    }
3526
3527    /**
3528     * @return Returns a reference to <code>this</code> for easy method chaining
3529     */
3530    public Encounter setAccount(List<Reference> theAccount) { 
3531      this.account = theAccount;
3532      return this;
3533    }
3534
3535    public boolean hasAccount() { 
3536      if (this.account == null)
3537        return false;
3538      for (Reference item : this.account)
3539        if (!item.isEmpty())
3540          return true;
3541      return false;
3542    }
3543
3544    public Reference addAccount() { //3
3545      Reference t = new Reference();
3546      if (this.account == null)
3547        this.account = new ArrayList<Reference>();
3548      this.account.add(t);
3549      return t;
3550    }
3551
3552    public Encounter addAccount(Reference t) { //3
3553      if (t == null)
3554        return this;
3555      if (this.account == null)
3556        this.account = new ArrayList<Reference>();
3557      this.account.add(t);
3558      return this;
3559    }
3560
3561    /**
3562     * @return The first repetition of repeating field {@link #account}, creating it if it does not already exist
3563     */
3564    public Reference getAccountFirstRep() { 
3565      if (getAccount().isEmpty()) {
3566        addAccount();
3567      }
3568      return getAccount().get(0);
3569    }
3570
3571    /**
3572     * @deprecated Use Reference#setResource(IBaseResource) instead
3573     */
3574    @Deprecated
3575    public List<Account> getAccountTarget() { 
3576      if (this.accountTarget == null)
3577        this.accountTarget = new ArrayList<Account>();
3578      return this.accountTarget;
3579    }
3580
3581    /**
3582     * @deprecated Use Reference#setResource(IBaseResource) instead
3583     */
3584    @Deprecated
3585    public Account addAccountTarget() { 
3586      Account r = new Account();
3587      if (this.accountTarget == null)
3588        this.accountTarget = new ArrayList<Account>();
3589      this.accountTarget.add(r);
3590      return r;
3591    }
3592
3593    /**
3594     * @return {@link #hospitalization} (Details about the admission to a healthcare service.)
3595     */
3596    public EncounterHospitalizationComponent getHospitalization() { 
3597      if (this.hospitalization == null)
3598        if (Configuration.errorOnAutoCreate())
3599          throw new Error("Attempt to auto-create Encounter.hospitalization");
3600        else if (Configuration.doAutoCreate())
3601          this.hospitalization = new EncounterHospitalizationComponent(); // cc
3602      return this.hospitalization;
3603    }
3604
3605    public boolean hasHospitalization() { 
3606      return this.hospitalization != null && !this.hospitalization.isEmpty();
3607    }
3608
3609    /**
3610     * @param value {@link #hospitalization} (Details about the admission to a healthcare service.)
3611     */
3612    public Encounter setHospitalization(EncounterHospitalizationComponent value) { 
3613      this.hospitalization = value;
3614      return this;
3615    }
3616
3617    /**
3618     * @return {@link #location} (List of locations where  the patient has been during this encounter.)
3619     */
3620    public List<EncounterLocationComponent> getLocation() { 
3621      if (this.location == null)
3622        this.location = new ArrayList<EncounterLocationComponent>();
3623      return this.location;
3624    }
3625
3626    /**
3627     * @return Returns a reference to <code>this</code> for easy method chaining
3628     */
3629    public Encounter setLocation(List<EncounterLocationComponent> theLocation) { 
3630      this.location = theLocation;
3631      return this;
3632    }
3633
3634    public boolean hasLocation() { 
3635      if (this.location == null)
3636        return false;
3637      for (EncounterLocationComponent item : this.location)
3638        if (!item.isEmpty())
3639          return true;
3640      return false;
3641    }
3642
3643    public EncounterLocationComponent addLocation() { //3
3644      EncounterLocationComponent t = new EncounterLocationComponent();
3645      if (this.location == null)
3646        this.location = new ArrayList<EncounterLocationComponent>();
3647      this.location.add(t);
3648      return t;
3649    }
3650
3651    public Encounter addLocation(EncounterLocationComponent t) { //3
3652      if (t == null)
3653        return this;
3654      if (this.location == null)
3655        this.location = new ArrayList<EncounterLocationComponent>();
3656      this.location.add(t);
3657      return this;
3658    }
3659
3660    /**
3661     * @return The first repetition of repeating field {@link #location}, creating it if it does not already exist
3662     */
3663    public EncounterLocationComponent getLocationFirstRep() { 
3664      if (getLocation().isEmpty()) {
3665        addLocation();
3666      }
3667      return getLocation().get(0);
3668    }
3669
3670    /**
3671     * @return {@link #serviceProvider} (The organization that is primarily responsible for this Encounter's services. This MAY be the same as the organization on the Patient record, however it could be different, such as if the actor performing the services was from an external organization (which may be billed seperately) for an external consultation.  Refer to the example bundle showing an abbreviated set of Encounters for a colonoscopy.)
3672     */
3673    public Reference getServiceProvider() { 
3674      if (this.serviceProvider == null)
3675        if (Configuration.errorOnAutoCreate())
3676          throw new Error("Attempt to auto-create Encounter.serviceProvider");
3677        else if (Configuration.doAutoCreate())
3678          this.serviceProvider = new Reference(); // cc
3679      return this.serviceProvider;
3680    }
3681
3682    public boolean hasServiceProvider() { 
3683      return this.serviceProvider != null && !this.serviceProvider.isEmpty();
3684    }
3685
3686    /**
3687     * @param value {@link #serviceProvider} (The organization that is primarily responsible for this Encounter's services. This MAY be the same as the organization on the Patient record, however it could be different, such as if the actor performing the services was from an external organization (which may be billed seperately) for an external consultation.  Refer to the example bundle showing an abbreviated set of Encounters for a colonoscopy.)
3688     */
3689    public Encounter setServiceProvider(Reference value) { 
3690      this.serviceProvider = value;
3691      return this;
3692    }
3693
3694    /**
3695     * @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. (The organization that is primarily responsible for this Encounter's services. This MAY be the same as the organization on the Patient record, however it could be different, such as if the actor performing the services was from an external organization (which may be billed seperately) for an external consultation.  Refer to the example bundle showing an abbreviated set of Encounters for a colonoscopy.)
3696     */
3697    public Organization getServiceProviderTarget() { 
3698      if (this.serviceProviderTarget == null)
3699        if (Configuration.errorOnAutoCreate())
3700          throw new Error("Attempt to auto-create Encounter.serviceProvider");
3701        else if (Configuration.doAutoCreate())
3702          this.serviceProviderTarget = new Organization(); // aa
3703      return this.serviceProviderTarget;
3704    }
3705
3706    /**
3707     * @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. (The organization that is primarily responsible for this Encounter's services. This MAY be the same as the organization on the Patient record, however it could be different, such as if the actor performing the services was from an external organization (which may be billed seperately) for an external consultation.  Refer to the example bundle showing an abbreviated set of Encounters for a colonoscopy.)
3708     */
3709    public Encounter setServiceProviderTarget(Organization value) { 
3710      this.serviceProviderTarget = value;
3711      return this;
3712    }
3713
3714    /**
3715     * @return {@link #partOf} (Another Encounter of which this encounter is a part of (administratively or in time).)
3716     */
3717    public Reference getPartOf() { 
3718      if (this.partOf == null)
3719        if (Configuration.errorOnAutoCreate())
3720          throw new Error("Attempt to auto-create Encounter.partOf");
3721        else if (Configuration.doAutoCreate())
3722          this.partOf = new Reference(); // cc
3723      return this.partOf;
3724    }
3725
3726    public boolean hasPartOf() { 
3727      return this.partOf != null && !this.partOf.isEmpty();
3728    }
3729
3730    /**
3731     * @param value {@link #partOf} (Another Encounter of which this encounter is a part of (administratively or in time).)
3732     */
3733    public Encounter setPartOf(Reference value) { 
3734      this.partOf = value;
3735      return this;
3736    }
3737
3738    /**
3739     * @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).)
3740     */
3741    public Encounter getPartOfTarget() { 
3742      if (this.partOfTarget == null)
3743        if (Configuration.errorOnAutoCreate())
3744          throw new Error("Attempt to auto-create Encounter.partOf");
3745        else if (Configuration.doAutoCreate())
3746          this.partOfTarget = new Encounter(); // aa
3747      return this.partOfTarget;
3748    }
3749
3750    /**
3751     * @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).)
3752     */
3753    public Encounter setPartOfTarget(Encounter value) { 
3754      this.partOfTarget = value;
3755      return this;
3756    }
3757
3758      protected void listChildren(List<Property> children) {
3759        super.listChildren(children);
3760        children.add(new Property("identifier", "Identifier", "Identifier(s) by which this encounter is known.", 0, java.lang.Integer.MAX_VALUE, identifier));
3761        children.add(new Property("status", "code", "planned | arrived | triaged | in-progress | onleave | finished | cancelled +.", 0, 1, status));
3762        children.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));
3763        children.add(new Property("class", "Coding", "Concepts representing classification of patient encounter such as ambulatory (outpatient), inpatient, emergency, home health or others due to local variations.", 0, 1, class_));
3764        children.add(new Property("classHistory", "", "The class history permits the tracking of the encounters transitions without needing to go  through the resource history.  This would be used for a case where an admission starts of as an emergency encounter, then transitions 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 kind of discharge from emergency to inpatient.", 0, java.lang.Integer.MAX_VALUE, classHistory));
3765        children.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));
3766        children.add(new Property("serviceType", "CodeableConcept", "Broad categorization of the service that is to be provided (e.g. cardiology).", 0, 1, serviceType));
3767        children.add(new Property("priority", "CodeableConcept", "Indicates the urgency of the encounter.", 0, 1, priority));
3768        children.add(new Property("subject", "Reference(Patient|Group)", "The patient or group present at the encounter.", 0, 1, subject));
3769        children.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));
3770        children.add(new Property("basedOn", "Reference(ServiceRequest)", "The request this encounter satisfies (e.g. incoming referral or procedure request).", 0, java.lang.Integer.MAX_VALUE, basedOn));
3771        children.add(new Property("participant", "", "The list of people responsible for providing the service.", 0, java.lang.Integer.MAX_VALUE, participant));
3772        children.add(new Property("appointment", "Reference(Appointment)", "The appointment that scheduled this encounter.", 0, java.lang.Integer.MAX_VALUE, appointment));
3773        children.add(new Property("period", "Period", "The start and end time of the encounter.", 0, 1, period));
3774        children.add(new Property("length", "Duration", "Quantity of time the encounter lasted. This excludes the time during leaves of absence.", 0, 1, length));
3775        children.add(new Property("reasonCode", "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, reasonCode));
3776        children.add(new Property("reasonReference", "Reference(Condition|Procedure|Observation|ImmunizationRecommendation)", "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, reasonReference));
3777        children.add(new Property("diagnosis", "", "The list of diagnosis relevant to this encounter.", 0, java.lang.Integer.MAX_VALUE, diagnosis));
3778        children.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));
3779        children.add(new Property("hospitalization", "", "Details about the admission to a healthcare service.", 0, 1, hospitalization));
3780        children.add(new Property("location", "", "List of locations where  the patient has been during this encounter.", 0, java.lang.Integer.MAX_VALUE, location));
3781        children.add(new Property("serviceProvider", "Reference(Organization)", "The organization that is primarily responsible for this Encounter's services. This MAY be the same as the organization on the Patient record, however it could be different, such as if the actor performing the services was from an external organization (which may be billed seperately) for an external consultation.  Refer to the example bundle showing an abbreviated set of Encounters for a colonoscopy.", 0, 1, serviceProvider));
3782        children.add(new Property("partOf", "Reference(Encounter)", "Another Encounter of which this encounter is a part of (administratively or in time).", 0, 1, partOf));
3783      }
3784
3785      @Override
3786      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
3787        switch (_hash) {
3788        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Identifier(s) by which this encounter is known.", 0, java.lang.Integer.MAX_VALUE, identifier);
3789        case -892481550: /*status*/  return new Property("status", "code", "planned | arrived | triaged | in-progress | onleave | finished | cancelled +.", 0, 1, status);
3790        case -986695614: /*statusHistory*/  return 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);
3791        case 94742904: /*class*/  return new Property("class", "Coding", "Concepts representing classification of patient encounter such as ambulatory (outpatient), inpatient, emergency, home health or others due to local variations.", 0, 1, class_);
3792        case 962575356: /*classHistory*/  return new Property("classHistory", "", "The class history permits the tracking of the encounters transitions without needing to go  through the resource history.  This would be used for a case where an admission starts of as an emergency encounter, then transitions 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 kind of discharge from emergency to inpatient.", 0, java.lang.Integer.MAX_VALUE, classHistory);
3793        case 3575610: /*type*/  return 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);
3794        case -1928370289: /*serviceType*/  return new Property("serviceType", "CodeableConcept", "Broad categorization of the service that is to be provided (e.g. cardiology).", 0, 1, serviceType);
3795        case -1165461084: /*priority*/  return new Property("priority", "CodeableConcept", "Indicates the urgency of the encounter.", 0, 1, priority);
3796        case -1867885268: /*subject*/  return new Property("subject", "Reference(Patient|Group)", "The patient or group present at the encounter.", 0, 1, subject);
3797        case -1892140189: /*episodeOfCare*/  return 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);
3798        case -332612366: /*basedOn*/  return new Property("basedOn", "Reference(ServiceRequest)", "The request this encounter satisfies (e.g. incoming referral or procedure request).", 0, java.lang.Integer.MAX_VALUE, basedOn);
3799        case 767422259: /*participant*/  return new Property("participant", "", "The list of people responsible for providing the service.", 0, java.lang.Integer.MAX_VALUE, participant);
3800        case -1474995297: /*appointment*/  return new Property("appointment", "Reference(Appointment)", "The appointment that scheduled this encounter.", 0, java.lang.Integer.MAX_VALUE, appointment);
3801        case -991726143: /*period*/  return new Property("period", "Period", "The start and end time of the encounter.", 0, 1, period);
3802        case -1106363674: /*length*/  return new Property("length", "Duration", "Quantity of time the encounter lasted. This excludes the time during leaves of absence.", 0, 1, length);
3803        case 722137681: /*reasonCode*/  return new Property("reasonCode", "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, reasonCode);
3804        case -1146218137: /*reasonReference*/  return new Property("reasonReference", "Reference(Condition|Procedure|Observation|ImmunizationRecommendation)", "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, reasonReference);
3805        case 1196993265: /*diagnosis*/  return new Property("diagnosis", "", "The list of diagnosis relevant to this encounter.", 0, java.lang.Integer.MAX_VALUE, diagnosis);
3806        case -1177318867: /*account*/  return 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);
3807        case 1057894634: /*hospitalization*/  return new Property("hospitalization", "", "Details about the admission to a healthcare service.", 0, 1, hospitalization);
3808        case 1901043637: /*location*/  return new Property("location", "", "List of locations where  the patient has been during this encounter.", 0, java.lang.Integer.MAX_VALUE, location);
3809        case 243182534: /*serviceProvider*/  return new Property("serviceProvider", "Reference(Organization)", "The organization that is primarily responsible for this Encounter's services. This MAY be the same as the organization on the Patient record, however it could be different, such as if the actor performing the services was from an external organization (which may be billed seperately) for an external consultation.  Refer to the example bundle showing an abbreviated set of Encounters for a colonoscopy.", 0, 1, serviceProvider);
3810        case -995410646: /*partOf*/  return new Property("partOf", "Reference(Encounter)", "Another Encounter of which this encounter is a part of (administratively or in time).", 0, 1, partOf);
3811        default: return super.getNamedProperty(_hash, _name, _checkValid);
3812        }
3813
3814      }
3815
3816      @Override
3817      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
3818        switch (hash) {
3819        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
3820        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<EncounterStatus>
3821        case -986695614: /*statusHistory*/ return this.statusHistory == null ? new Base[0] : this.statusHistory.toArray(new Base[this.statusHistory.size()]); // StatusHistoryComponent
3822        case 94742904: /*class*/ return this.class_ == null ? new Base[0] : new Base[] {this.class_}; // Coding
3823        case 962575356: /*classHistory*/ return this.classHistory == null ? new Base[0] : this.classHistory.toArray(new Base[this.classHistory.size()]); // ClassHistoryComponent
3824        case 3575610: /*type*/ return this.type == null ? new Base[0] : this.type.toArray(new Base[this.type.size()]); // CodeableConcept
3825        case -1928370289: /*serviceType*/ return this.serviceType == null ? new Base[0] : new Base[] {this.serviceType}; // CodeableConcept
3826        case -1165461084: /*priority*/ return this.priority == null ? new Base[0] : new Base[] {this.priority}; // CodeableConcept
3827        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
3828        case -1892140189: /*episodeOfCare*/ return this.episodeOfCare == null ? new Base[0] : this.episodeOfCare.toArray(new Base[this.episodeOfCare.size()]); // Reference
3829        case -332612366: /*basedOn*/ return this.basedOn == null ? new Base[0] : this.basedOn.toArray(new Base[this.basedOn.size()]); // Reference
3830        case 767422259: /*participant*/ return this.participant == null ? new Base[0] : this.participant.toArray(new Base[this.participant.size()]); // EncounterParticipantComponent
3831        case -1474995297: /*appointment*/ return this.appointment == null ? new Base[0] : this.appointment.toArray(new Base[this.appointment.size()]); // Reference
3832        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
3833        case -1106363674: /*length*/ return this.length == null ? new Base[0] : new Base[] {this.length}; // Duration
3834        case 722137681: /*reasonCode*/ return this.reasonCode == null ? new Base[0] : this.reasonCode.toArray(new Base[this.reasonCode.size()]); // CodeableConcept
3835        case -1146218137: /*reasonReference*/ return this.reasonReference == null ? new Base[0] : this.reasonReference.toArray(new Base[this.reasonReference.size()]); // Reference
3836        case 1196993265: /*diagnosis*/ return this.diagnosis == null ? new Base[0] : this.diagnosis.toArray(new Base[this.diagnosis.size()]); // DiagnosisComponent
3837        case -1177318867: /*account*/ return this.account == null ? new Base[0] : this.account.toArray(new Base[this.account.size()]); // Reference
3838        case 1057894634: /*hospitalization*/ return this.hospitalization == null ? new Base[0] : new Base[] {this.hospitalization}; // EncounterHospitalizationComponent
3839        case 1901043637: /*location*/ return this.location == null ? new Base[0] : this.location.toArray(new Base[this.location.size()]); // EncounterLocationComponent
3840        case 243182534: /*serviceProvider*/ return this.serviceProvider == null ? new Base[0] : new Base[] {this.serviceProvider}; // Reference
3841        case -995410646: /*partOf*/ return this.partOf == null ? new Base[0] : new Base[] {this.partOf}; // Reference
3842        default: return super.getProperty(hash, name, checkValid);
3843        }
3844
3845      }
3846
3847      @Override
3848      public Base setProperty(int hash, String name, Base value) throws FHIRException {
3849        switch (hash) {
3850        case -1618432855: // identifier
3851          this.getIdentifier().add(castToIdentifier(value)); // Identifier
3852          return value;
3853        case -892481550: // status
3854          value = new EncounterStatusEnumFactory().fromType(castToCode(value));
3855          this.status = (Enumeration) value; // Enumeration<EncounterStatus>
3856          return value;
3857        case -986695614: // statusHistory
3858          this.getStatusHistory().add((StatusHistoryComponent) value); // StatusHistoryComponent
3859          return value;
3860        case 94742904: // class
3861          this.class_ = castToCoding(value); // Coding
3862          return value;
3863        case 962575356: // classHistory
3864          this.getClassHistory().add((ClassHistoryComponent) value); // ClassHistoryComponent
3865          return value;
3866        case 3575610: // type
3867          this.getType().add(castToCodeableConcept(value)); // CodeableConcept
3868          return value;
3869        case -1928370289: // serviceType
3870          this.serviceType = castToCodeableConcept(value); // CodeableConcept
3871          return value;
3872        case -1165461084: // priority
3873          this.priority = castToCodeableConcept(value); // CodeableConcept
3874          return value;
3875        case -1867885268: // subject
3876          this.subject = castToReference(value); // Reference
3877          return value;
3878        case -1892140189: // episodeOfCare
3879          this.getEpisodeOfCare().add(castToReference(value)); // Reference
3880          return value;
3881        case -332612366: // basedOn
3882          this.getBasedOn().add(castToReference(value)); // Reference
3883          return value;
3884        case 767422259: // participant
3885          this.getParticipant().add((EncounterParticipantComponent) value); // EncounterParticipantComponent
3886          return value;
3887        case -1474995297: // appointment
3888          this.getAppointment().add(castToReference(value)); // Reference
3889          return value;
3890        case -991726143: // period
3891          this.period = castToPeriod(value); // Period
3892          return value;
3893        case -1106363674: // length
3894          this.length = castToDuration(value); // Duration
3895          return value;
3896        case 722137681: // reasonCode
3897          this.getReasonCode().add(castToCodeableConcept(value)); // CodeableConcept
3898          return value;
3899        case -1146218137: // reasonReference
3900          this.getReasonReference().add(castToReference(value)); // Reference
3901          return value;
3902        case 1196993265: // diagnosis
3903          this.getDiagnosis().add((DiagnosisComponent) value); // DiagnosisComponent
3904          return value;
3905        case -1177318867: // account
3906          this.getAccount().add(castToReference(value)); // Reference
3907          return value;
3908        case 1057894634: // hospitalization
3909          this.hospitalization = (EncounterHospitalizationComponent) value; // EncounterHospitalizationComponent
3910          return value;
3911        case 1901043637: // location
3912          this.getLocation().add((EncounterLocationComponent) value); // EncounterLocationComponent
3913          return value;
3914        case 243182534: // serviceProvider
3915          this.serviceProvider = castToReference(value); // Reference
3916          return value;
3917        case -995410646: // partOf
3918          this.partOf = castToReference(value); // Reference
3919          return value;
3920        default: return super.setProperty(hash, name, value);
3921        }
3922
3923      }
3924
3925      @Override
3926      public Base setProperty(String name, Base value) throws FHIRException {
3927        if (name.equals("identifier")) {
3928          this.getIdentifier().add(castToIdentifier(value));
3929        } else if (name.equals("status")) {
3930          value = new EncounterStatusEnumFactory().fromType(castToCode(value));
3931          this.status = (Enumeration) value; // Enumeration<EncounterStatus>
3932        } else if (name.equals("statusHistory")) {
3933          this.getStatusHistory().add((StatusHistoryComponent) value);
3934        } else if (name.equals("class")) {
3935          this.class_ = castToCoding(value); // Coding
3936        } else if (name.equals("classHistory")) {
3937          this.getClassHistory().add((ClassHistoryComponent) value);
3938        } else if (name.equals("type")) {
3939          this.getType().add(castToCodeableConcept(value));
3940        } else if (name.equals("serviceType")) {
3941          this.serviceType = castToCodeableConcept(value); // CodeableConcept
3942        } else if (name.equals("priority")) {
3943          this.priority = castToCodeableConcept(value); // CodeableConcept
3944        } else if (name.equals("subject")) {
3945          this.subject = castToReference(value); // Reference
3946        } else if (name.equals("episodeOfCare")) {
3947          this.getEpisodeOfCare().add(castToReference(value));
3948        } else if (name.equals("basedOn")) {
3949          this.getBasedOn().add(castToReference(value));
3950        } else if (name.equals("participant")) {
3951          this.getParticipant().add((EncounterParticipantComponent) value);
3952        } else if (name.equals("appointment")) {
3953          this.getAppointment().add(castToReference(value));
3954        } else if (name.equals("period")) {
3955          this.period = castToPeriod(value); // Period
3956        } else if (name.equals("length")) {
3957          this.length = castToDuration(value); // Duration
3958        } else if (name.equals("reasonCode")) {
3959          this.getReasonCode().add(castToCodeableConcept(value));
3960        } else if (name.equals("reasonReference")) {
3961          this.getReasonReference().add(castToReference(value));
3962        } else if (name.equals("diagnosis")) {
3963          this.getDiagnosis().add((DiagnosisComponent) value);
3964        } else if (name.equals("account")) {
3965          this.getAccount().add(castToReference(value));
3966        } else if (name.equals("hospitalization")) {
3967          this.hospitalization = (EncounterHospitalizationComponent) value; // EncounterHospitalizationComponent
3968        } else if (name.equals("location")) {
3969          this.getLocation().add((EncounterLocationComponent) value);
3970        } else if (name.equals("serviceProvider")) {
3971          this.serviceProvider = castToReference(value); // Reference
3972        } else if (name.equals("partOf")) {
3973          this.partOf = castToReference(value); // Reference
3974        } else
3975          return super.setProperty(name, value);
3976        return value;
3977      }
3978
3979      @Override
3980      public Base makeProperty(int hash, String name) throws FHIRException {
3981        switch (hash) {
3982        case -1618432855:  return addIdentifier(); 
3983        case -892481550:  return getStatusElement();
3984        case -986695614:  return addStatusHistory(); 
3985        case 94742904:  return getClass_(); 
3986        case 962575356:  return addClassHistory(); 
3987        case 3575610:  return addType(); 
3988        case -1928370289:  return getServiceType(); 
3989        case -1165461084:  return getPriority(); 
3990        case -1867885268:  return getSubject(); 
3991        case -1892140189:  return addEpisodeOfCare(); 
3992        case -332612366:  return addBasedOn(); 
3993        case 767422259:  return addParticipant(); 
3994        case -1474995297:  return addAppointment(); 
3995        case -991726143:  return getPeriod(); 
3996        case -1106363674:  return getLength(); 
3997        case 722137681:  return addReasonCode(); 
3998        case -1146218137:  return addReasonReference(); 
3999        case 1196993265:  return addDiagnosis(); 
4000        case -1177318867:  return addAccount(); 
4001        case 1057894634:  return getHospitalization(); 
4002        case 1901043637:  return addLocation(); 
4003        case 243182534:  return getServiceProvider(); 
4004        case -995410646:  return getPartOf(); 
4005        default: return super.makeProperty(hash, name);
4006        }
4007
4008      }
4009
4010      @Override
4011      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
4012        switch (hash) {
4013        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
4014        case -892481550: /*status*/ return new String[] {"code"};
4015        case -986695614: /*statusHistory*/ return new String[] {};
4016        case 94742904: /*class*/ return new String[] {"Coding"};
4017        case 962575356: /*classHistory*/ return new String[] {};
4018        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
4019        case -1928370289: /*serviceType*/ return new String[] {"CodeableConcept"};
4020        case -1165461084: /*priority*/ return new String[] {"CodeableConcept"};
4021        case -1867885268: /*subject*/ return new String[] {"Reference"};
4022        case -1892140189: /*episodeOfCare*/ return new String[] {"Reference"};
4023        case -332612366: /*basedOn*/ return new String[] {"Reference"};
4024        case 767422259: /*participant*/ return new String[] {};
4025        case -1474995297: /*appointment*/ return new String[] {"Reference"};
4026        case -991726143: /*period*/ return new String[] {"Period"};
4027        case -1106363674: /*length*/ return new String[] {"Duration"};
4028        case 722137681: /*reasonCode*/ return new String[] {"CodeableConcept"};
4029        case -1146218137: /*reasonReference*/ return new String[] {"Reference"};
4030        case 1196993265: /*diagnosis*/ return new String[] {};
4031        case -1177318867: /*account*/ return new String[] {"Reference"};
4032        case 1057894634: /*hospitalization*/ return new String[] {};
4033        case 1901043637: /*location*/ return new String[] {};
4034        case 243182534: /*serviceProvider*/ return new String[] {"Reference"};
4035        case -995410646: /*partOf*/ return new String[] {"Reference"};
4036        default: return super.getTypesForProperty(hash, name);
4037        }
4038
4039      }
4040
4041      @Override
4042      public Base addChild(String name) throws FHIRException {
4043        if (name.equals("identifier")) {
4044          return addIdentifier();
4045        }
4046        else if (name.equals("status")) {
4047          throw new FHIRException("Cannot call addChild on a primitive type Encounter.status");
4048        }
4049        else if (name.equals("statusHistory")) {
4050          return addStatusHistory();
4051        }
4052        else if (name.equals("class")) {
4053          this.class_ = new Coding();
4054          return this.class_;
4055        }
4056        else if (name.equals("classHistory")) {
4057          return addClassHistory();
4058        }
4059        else if (name.equals("type")) {
4060          return addType();
4061        }
4062        else if (name.equals("serviceType")) {
4063          this.serviceType = new CodeableConcept();
4064          return this.serviceType;
4065        }
4066        else if (name.equals("priority")) {
4067          this.priority = new CodeableConcept();
4068          return this.priority;
4069        }
4070        else if (name.equals("subject")) {
4071          this.subject = new Reference();
4072          return this.subject;
4073        }
4074        else if (name.equals("episodeOfCare")) {
4075          return addEpisodeOfCare();
4076        }
4077        else if (name.equals("basedOn")) {
4078          return addBasedOn();
4079        }
4080        else if (name.equals("participant")) {
4081          return addParticipant();
4082        }
4083        else if (name.equals("appointment")) {
4084          return addAppointment();
4085        }
4086        else if (name.equals("period")) {
4087          this.period = new Period();
4088          return this.period;
4089        }
4090        else if (name.equals("length")) {
4091          this.length = new Duration();
4092          return this.length;
4093        }
4094        else if (name.equals("reasonCode")) {
4095          return addReasonCode();
4096        }
4097        else if (name.equals("reasonReference")) {
4098          return addReasonReference();
4099        }
4100        else if (name.equals("diagnosis")) {
4101          return addDiagnosis();
4102        }
4103        else if (name.equals("account")) {
4104          return addAccount();
4105        }
4106        else if (name.equals("hospitalization")) {
4107          this.hospitalization = new EncounterHospitalizationComponent();
4108          return this.hospitalization;
4109        }
4110        else if (name.equals("location")) {
4111          return addLocation();
4112        }
4113        else if (name.equals("serviceProvider")) {
4114          this.serviceProvider = new Reference();
4115          return this.serviceProvider;
4116        }
4117        else if (name.equals("partOf")) {
4118          this.partOf = new Reference();
4119          return this.partOf;
4120        }
4121        else
4122          return super.addChild(name);
4123      }
4124
4125  public String fhirType() {
4126    return "Encounter";
4127
4128  }
4129
4130      public Encounter copy() {
4131        Encounter dst = new Encounter();
4132        copyValues(dst);
4133        if (identifier != null) {
4134          dst.identifier = new ArrayList<Identifier>();
4135          for (Identifier i : identifier)
4136            dst.identifier.add(i.copy());
4137        };
4138        dst.status = status == null ? null : status.copy();
4139        if (statusHistory != null) {
4140          dst.statusHistory = new ArrayList<StatusHistoryComponent>();
4141          for (StatusHistoryComponent i : statusHistory)
4142            dst.statusHistory.add(i.copy());
4143        };
4144        dst.class_ = class_ == null ? null : class_.copy();
4145        if (classHistory != null) {
4146          dst.classHistory = new ArrayList<ClassHistoryComponent>();
4147          for (ClassHistoryComponent i : classHistory)
4148            dst.classHistory.add(i.copy());
4149        };
4150        if (type != null) {
4151          dst.type = new ArrayList<CodeableConcept>();
4152          for (CodeableConcept i : type)
4153            dst.type.add(i.copy());
4154        };
4155        dst.serviceType = serviceType == null ? null : serviceType.copy();
4156        dst.priority = priority == null ? null : priority.copy();
4157        dst.subject = subject == null ? null : subject.copy();
4158        if (episodeOfCare != null) {
4159          dst.episodeOfCare = new ArrayList<Reference>();
4160          for (Reference i : episodeOfCare)
4161            dst.episodeOfCare.add(i.copy());
4162        };
4163        if (basedOn != null) {
4164          dst.basedOn = new ArrayList<Reference>();
4165          for (Reference i : basedOn)
4166            dst.basedOn.add(i.copy());
4167        };
4168        if (participant != null) {
4169          dst.participant = new ArrayList<EncounterParticipantComponent>();
4170          for (EncounterParticipantComponent i : participant)
4171            dst.participant.add(i.copy());
4172        };
4173        if (appointment != null) {
4174          dst.appointment = new ArrayList<Reference>();
4175          for (Reference i : appointment)
4176            dst.appointment.add(i.copy());
4177        };
4178        dst.period = period == null ? null : period.copy();
4179        dst.length = length == null ? null : length.copy();
4180        if (reasonCode != null) {
4181          dst.reasonCode = new ArrayList<CodeableConcept>();
4182          for (CodeableConcept i : reasonCode)
4183            dst.reasonCode.add(i.copy());
4184        };
4185        if (reasonReference != null) {
4186          dst.reasonReference = new ArrayList<Reference>();
4187          for (Reference i : reasonReference)
4188            dst.reasonReference.add(i.copy());
4189        };
4190        if (diagnosis != null) {
4191          dst.diagnosis = new ArrayList<DiagnosisComponent>();
4192          for (DiagnosisComponent i : diagnosis)
4193            dst.diagnosis.add(i.copy());
4194        };
4195        if (account != null) {
4196          dst.account = new ArrayList<Reference>();
4197          for (Reference i : account)
4198            dst.account.add(i.copy());
4199        };
4200        dst.hospitalization = hospitalization == null ? null : hospitalization.copy();
4201        if (location != null) {
4202          dst.location = new ArrayList<EncounterLocationComponent>();
4203          for (EncounterLocationComponent i : location)
4204            dst.location.add(i.copy());
4205        };
4206        dst.serviceProvider = serviceProvider == null ? null : serviceProvider.copy();
4207        dst.partOf = partOf == null ? null : partOf.copy();
4208        return dst;
4209      }
4210
4211      protected Encounter typedCopy() {
4212        return copy();
4213      }
4214
4215      @Override
4216      public boolean equalsDeep(Base other_) {
4217        if (!super.equalsDeep(other_))
4218          return false;
4219        if (!(other_ instanceof Encounter))
4220          return false;
4221        Encounter o = (Encounter) other_;
4222        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(statusHistory, o.statusHistory, true)
4223           && compareDeep(class_, o.class_, true) && compareDeep(classHistory, o.classHistory, true) && compareDeep(type, o.type, true)
4224           && compareDeep(serviceType, o.serviceType, true) && compareDeep(priority, o.priority, true) && compareDeep(subject, o.subject, true)
4225           && compareDeep(episodeOfCare, o.episodeOfCare, true) && compareDeep(basedOn, o.basedOn, true) && compareDeep(participant, o.participant, true)
4226           && compareDeep(appointment, o.appointment, true) && compareDeep(period, o.period, true) && compareDeep(length, o.length, true)
4227           && compareDeep(reasonCode, o.reasonCode, true) && compareDeep(reasonReference, o.reasonReference, true)
4228           && compareDeep(diagnosis, o.diagnosis, true) && compareDeep(account, o.account, true) && compareDeep(hospitalization, o.hospitalization, true)
4229           && compareDeep(location, o.location, true) && compareDeep(serviceProvider, o.serviceProvider, true)
4230           && compareDeep(partOf, o.partOf, true);
4231      }
4232
4233      @Override
4234      public boolean equalsShallow(Base other_) {
4235        if (!super.equalsShallow(other_))
4236          return false;
4237        if (!(other_ instanceof Encounter))
4238          return false;
4239        Encounter o = (Encounter) other_;
4240        return compareValues(status, o.status, true);
4241      }
4242
4243      public boolean isEmpty() {
4244        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, statusHistory
4245          , class_, classHistory, type, serviceType, priority, subject, episodeOfCare, basedOn
4246          , participant, appointment, period, length, reasonCode, reasonReference, diagnosis
4247          , account, hospitalization, location, serviceProvider, partOf);
4248      }
4249
4250  @Override
4251  public ResourceType getResourceType() {
4252    return ResourceType.Encounter;
4253   }
4254
4255 /**
4256   * Search parameter: <b>date</b>
4257   * <p>
4258   * Description: <b>A date within the period the Encounter lasted</b><br>
4259   * Type: <b>date</b><br>
4260   * Path: <b>Encounter.period</b><br>
4261   * </p>
4262   */
4263  @SearchParamDefinition(name="date", path="Encounter.period", description="A date within the period the Encounter lasted", type="date" )
4264  public static final String SP_DATE = "date";
4265 /**
4266   * <b>Fluent Client</b> search parameter constant for <b>date</b>
4267   * <p>
4268   * Description: <b>A date within the period the Encounter lasted</b><br>
4269   * Type: <b>date</b><br>
4270   * Path: <b>Encounter.period</b><br>
4271   * </p>
4272   */
4273  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
4274
4275 /**
4276   * Search parameter: <b>identifier</b>
4277   * <p>
4278   * Description: <b>Identifier(s) by which this encounter is known</b><br>
4279   * Type: <b>token</b><br>
4280   * Path: <b>Encounter.identifier</b><br>
4281   * </p>
4282   */
4283  @SearchParamDefinition(name="identifier", path="Encounter.identifier", description="Identifier(s) by which this encounter is known", type="token" )
4284  public static final String SP_IDENTIFIER = "identifier";
4285 /**
4286   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
4287   * <p>
4288   * Description: <b>Identifier(s) by which this encounter is known</b><br>
4289   * Type: <b>token</b><br>
4290   * Path: <b>Encounter.identifier</b><br>
4291   * </p>
4292   */
4293  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
4294
4295 /**
4296   * Search parameter: <b>participant-type</b>
4297   * <p>
4298   * Description: <b>Role of participant in encounter</b><br>
4299   * Type: <b>token</b><br>
4300   * Path: <b>Encounter.participant.type</b><br>
4301   * </p>
4302   */
4303  @SearchParamDefinition(name="participant-type", path="Encounter.participant.type", description="Role of participant in encounter", type="token" )
4304  public static final String SP_PARTICIPANT_TYPE = "participant-type";
4305 /**
4306   * <b>Fluent Client</b> search parameter constant for <b>participant-type</b>
4307   * <p>
4308   * Description: <b>Role of participant in encounter</b><br>
4309   * Type: <b>token</b><br>
4310   * Path: <b>Encounter.participant.type</b><br>
4311   * </p>
4312   */
4313  public static final ca.uhn.fhir.rest.gclient.TokenClientParam PARTICIPANT_TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_PARTICIPANT_TYPE);
4314
4315 /**
4316   * Search parameter: <b>practitioner</b>
4317   * <p>
4318   * Description: <b>Persons involved in the encounter other than the patient</b><br>
4319   * Type: <b>reference</b><br>
4320   * Path: <b>Encounter.participant.individual</b><br>
4321   * </p>
4322   */
4323  @SearchParamDefinition(name="practitioner", path="Encounter.participant.individual.where(resolve() is Practitioner)", 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 } )
4324  public static final String SP_PRACTITIONER = "practitioner";
4325 /**
4326   * <b>Fluent Client</b> search parameter constant for <b>practitioner</b>
4327   * <p>
4328   * Description: <b>Persons involved in the encounter other than the patient</b><br>
4329   * Type: <b>reference</b><br>
4330   * Path: <b>Encounter.participant.individual</b><br>
4331   * </p>
4332   */
4333  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PRACTITIONER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PRACTITIONER);
4334
4335/**
4336   * Constant for fluent queries to be used to add include statements. Specifies
4337   * the path value of "<b>Encounter:practitioner</b>".
4338   */
4339  public static final ca.uhn.fhir.model.api.Include INCLUDE_PRACTITIONER = new ca.uhn.fhir.model.api.Include("Encounter:practitioner").toLocked();
4340
4341 /**
4342   * Search parameter: <b>subject</b>
4343   * <p>
4344   * Description: <b>The patient or group present at the encounter</b><br>
4345   * Type: <b>reference</b><br>
4346   * Path: <b>Encounter.subject</b><br>
4347   * </p>
4348   */
4349  @SearchParamDefinition(name="subject", path="Encounter.subject", description="The patient or group present at the encounter", type="reference", target={Group.class, Patient.class } )
4350  public static final String SP_SUBJECT = "subject";
4351 /**
4352   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
4353   * <p>
4354   * Description: <b>The patient or group present at the encounter</b><br>
4355   * Type: <b>reference</b><br>
4356   * Path: <b>Encounter.subject</b><br>
4357   * </p>
4358   */
4359  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
4360
4361/**
4362   * Constant for fluent queries to be used to add include statements. Specifies
4363   * the path value of "<b>Encounter:subject</b>".
4364   */
4365  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("Encounter:subject").toLocked();
4366
4367 /**
4368   * Search parameter: <b>length</b>
4369   * <p>
4370   * Description: <b>Length of encounter in days</b><br>
4371   * Type: <b>quantity</b><br>
4372   * Path: <b>Encounter.length</b><br>
4373   * </p>
4374   */
4375  @SearchParamDefinition(name="length", path="Encounter.length", description="Length of encounter in days", type="quantity" )
4376  public static final String SP_LENGTH = "length";
4377 /**
4378   * <b>Fluent Client</b> search parameter constant for <b>length</b>
4379   * <p>
4380   * Description: <b>Length of encounter in days</b><br>
4381   * Type: <b>quantity</b><br>
4382   * Path: <b>Encounter.length</b><br>
4383   * </p>
4384   */
4385  public static final ca.uhn.fhir.rest.gclient.QuantityClientParam LENGTH = new ca.uhn.fhir.rest.gclient.QuantityClientParam(SP_LENGTH);
4386
4387 /**
4388   * Search parameter: <b>episode-of-care</b>
4389   * <p>
4390   * Description: <b>Episode(s) of care that this encounter should be recorded against</b><br>
4391   * Type: <b>reference</b><br>
4392   * Path: <b>Encounter.episodeOfCare</b><br>
4393   * </p>
4394   */
4395  @SearchParamDefinition(name="episode-of-care", path="Encounter.episodeOfCare", description="Episode(s) of care that this encounter should be recorded against", type="reference", target={EpisodeOfCare.class } )
4396  public static final String SP_EPISODE_OF_CARE = "episode-of-care";
4397 /**
4398   * <b>Fluent Client</b> search parameter constant for <b>episode-of-care</b>
4399   * <p>
4400   * Description: <b>Episode(s) of care that this encounter should be recorded against</b><br>
4401   * Type: <b>reference</b><br>
4402   * Path: <b>Encounter.episodeOfCare</b><br>
4403   * </p>
4404   */
4405  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam EPISODE_OF_CARE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_EPISODE_OF_CARE);
4406
4407/**
4408   * Constant for fluent queries to be used to add include statements. Specifies
4409   * the path value of "<b>Encounter:episode-of-care</b>".
4410   */
4411  public static final ca.uhn.fhir.model.api.Include INCLUDE_EPISODE_OF_CARE = new ca.uhn.fhir.model.api.Include("Encounter:episode-of-care").toLocked();
4412
4413 /**
4414   * Search parameter: <b>diagnosis</b>
4415   * <p>
4416   * Description: <b>The diagnosis or procedure relevant to the encounter</b><br>
4417   * Type: <b>reference</b><br>
4418   * Path: <b>Encounter.diagnosis.condition</b><br>
4419   * </p>
4420   */
4421  @SearchParamDefinition(name="diagnosis", path="Encounter.diagnosis.condition", description="The diagnosis or procedure relevant to the encounter", type="reference", target={Condition.class, Procedure.class } )
4422  public static final String SP_DIAGNOSIS = "diagnosis";
4423 /**
4424   * <b>Fluent Client</b> search parameter constant for <b>diagnosis</b>
4425   * <p>
4426   * Description: <b>The diagnosis or procedure relevant to the encounter</b><br>
4427   * Type: <b>reference</b><br>
4428   * Path: <b>Encounter.diagnosis.condition</b><br>
4429   * </p>
4430   */
4431  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam DIAGNOSIS = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_DIAGNOSIS);
4432
4433/**
4434   * Constant for fluent queries to be used to add include statements. Specifies
4435   * the path value of "<b>Encounter:diagnosis</b>".
4436   */
4437  public static final ca.uhn.fhir.model.api.Include INCLUDE_DIAGNOSIS = new ca.uhn.fhir.model.api.Include("Encounter:diagnosis").toLocked();
4438
4439 /**
4440   * Search parameter: <b>appointment</b>
4441   * <p>
4442   * Description: <b>The appointment that scheduled this encounter</b><br>
4443   * Type: <b>reference</b><br>
4444   * Path: <b>Encounter.appointment</b><br>
4445   * </p>
4446   */
4447  @SearchParamDefinition(name="appointment", path="Encounter.appointment", description="The appointment that scheduled this encounter", type="reference", target={Appointment.class } )
4448  public static final String SP_APPOINTMENT = "appointment";
4449 /**
4450   * <b>Fluent Client</b> search parameter constant for <b>appointment</b>
4451   * <p>
4452   * Description: <b>The appointment that scheduled this encounter</b><br>
4453   * Type: <b>reference</b><br>
4454   * Path: <b>Encounter.appointment</b><br>
4455   * </p>
4456   */
4457  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam APPOINTMENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_APPOINTMENT);
4458
4459/**
4460   * Constant for fluent queries to be used to add include statements. Specifies
4461   * the path value of "<b>Encounter:appointment</b>".
4462   */
4463  public static final ca.uhn.fhir.model.api.Include INCLUDE_APPOINTMENT = new ca.uhn.fhir.model.api.Include("Encounter:appointment").toLocked();
4464
4465 /**
4466   * Search parameter: <b>part-of</b>
4467   * <p>
4468   * Description: <b>Another Encounter this encounter is part of</b><br>
4469   * Type: <b>reference</b><br>
4470   * Path: <b>Encounter.partOf</b><br>
4471   * </p>
4472   */
4473  @SearchParamDefinition(name="part-of", path="Encounter.partOf", description="Another Encounter this encounter is part of", type="reference", target={Encounter.class } )
4474  public static final String SP_PART_OF = "part-of";
4475 /**
4476   * <b>Fluent Client</b> search parameter constant for <b>part-of</b>
4477   * <p>
4478   * Description: <b>Another Encounter this encounter is part of</b><br>
4479   * Type: <b>reference</b><br>
4480   * Path: <b>Encounter.partOf</b><br>
4481   * </p>
4482   */
4483  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PART_OF = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PART_OF);
4484
4485/**
4486   * Constant for fluent queries to be used to add include statements. Specifies
4487   * the path value of "<b>Encounter:part-of</b>".
4488   */
4489  public static final ca.uhn.fhir.model.api.Include INCLUDE_PART_OF = new ca.uhn.fhir.model.api.Include("Encounter:part-of").toLocked();
4490
4491 /**
4492   * Search parameter: <b>type</b>
4493   * <p>
4494   * Description: <b>Specific type of encounter</b><br>
4495   * Type: <b>token</b><br>
4496   * Path: <b>Encounter.type</b><br>
4497   * </p>
4498   */
4499  @SearchParamDefinition(name="type", path="Encounter.type", description="Specific type of encounter", type="token" )
4500  public static final String SP_TYPE = "type";
4501 /**
4502   * <b>Fluent Client</b> search parameter constant for <b>type</b>
4503   * <p>
4504   * Description: <b>Specific type of encounter</b><br>
4505   * Type: <b>token</b><br>
4506   * Path: <b>Encounter.type</b><br>
4507   * </p>
4508   */
4509  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_TYPE);
4510
4511 /**
4512   * Search parameter: <b>reason-code</b>
4513   * <p>
4514   * Description: <b>Coded reason the encounter takes place</b><br>
4515   * Type: <b>token</b><br>
4516   * Path: <b>Encounter.reasonCode</b><br>
4517   * </p>
4518   */
4519  @SearchParamDefinition(name="reason-code", path="Encounter.reasonCode", description="Coded reason the encounter takes place", type="token" )
4520  public static final String SP_REASON_CODE = "reason-code";
4521 /**
4522   * <b>Fluent Client</b> search parameter constant for <b>reason-code</b>
4523   * <p>
4524   * Description: <b>Coded reason the encounter takes place</b><br>
4525   * Type: <b>token</b><br>
4526   * Path: <b>Encounter.reasonCode</b><br>
4527   * </p>
4528   */
4529  public static final ca.uhn.fhir.rest.gclient.TokenClientParam REASON_CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_REASON_CODE);
4530
4531 /**
4532   * Search parameter: <b>participant</b>
4533   * <p>
4534   * Description: <b>Persons involved in the encounter other than the patient</b><br>
4535   * Type: <b>reference</b><br>
4536   * Path: <b>Encounter.participant.individual</b><br>
4537   * </p>
4538   */
4539  @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, PractitionerRole.class, RelatedPerson.class } )
4540  public static final String SP_PARTICIPANT = "participant";
4541 /**
4542   * <b>Fluent Client</b> search parameter constant for <b>participant</b>
4543   * <p>
4544   * Description: <b>Persons involved in the encounter other than the patient</b><br>
4545   * Type: <b>reference</b><br>
4546   * Path: <b>Encounter.participant.individual</b><br>
4547   * </p>
4548   */
4549  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PARTICIPANT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PARTICIPANT);
4550
4551/**
4552   * Constant for fluent queries to be used to add include statements. Specifies
4553   * the path value of "<b>Encounter:participant</b>".
4554   */
4555  public static final ca.uhn.fhir.model.api.Include INCLUDE_PARTICIPANT = new ca.uhn.fhir.model.api.Include("Encounter:participant").toLocked();
4556
4557 /**
4558   * Search parameter: <b>based-on</b>
4559   * <p>
4560   * Description: <b>The ServiceRequest that initiated this encounter</b><br>
4561   * Type: <b>reference</b><br>
4562   * Path: <b>Encounter.basedOn</b><br>
4563   * </p>
4564   */
4565  @SearchParamDefinition(name="based-on", path="Encounter.basedOn", description="The ServiceRequest that initiated this encounter", type="reference", target={ServiceRequest.class } )
4566  public static final String SP_BASED_ON = "based-on";
4567 /**
4568   * <b>Fluent Client</b> search parameter constant for <b>based-on</b>
4569   * <p>
4570   * Description: <b>The ServiceRequest that initiated this encounter</b><br>
4571   * Type: <b>reference</b><br>
4572   * Path: <b>Encounter.basedOn</b><br>
4573   * </p>
4574   */
4575  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam BASED_ON = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_BASED_ON);
4576
4577/**
4578   * Constant for fluent queries to be used to add include statements. Specifies
4579   * the path value of "<b>Encounter:based-on</b>".
4580   */
4581  public static final ca.uhn.fhir.model.api.Include INCLUDE_BASED_ON = new ca.uhn.fhir.model.api.Include("Encounter:based-on").toLocked();
4582
4583 /**
4584   * Search parameter: <b>patient</b>
4585   * <p>
4586   * Description: <b>The patient or group present at the encounter</b><br>
4587   * Type: <b>reference</b><br>
4588   * Path: <b>Encounter.subject</b><br>
4589   * </p>
4590   */
4591  @SearchParamDefinition(name="patient", path="Encounter.subject.where(resolve() is Patient)", description="The patient or group present at the encounter", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Patient.class } )
4592  public static final String SP_PATIENT = "patient";
4593 /**
4594   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
4595   * <p>
4596   * Description: <b>The patient or group present at the encounter</b><br>
4597   * Type: <b>reference</b><br>
4598   * Path: <b>Encounter.subject</b><br>
4599   * </p>
4600   */
4601  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
4602
4603/**
4604   * Constant for fluent queries to be used to add include statements. Specifies
4605   * the path value of "<b>Encounter:patient</b>".
4606   */
4607  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("Encounter:patient").toLocked();
4608
4609 /**
4610   * Search parameter: <b>reason-reference</b>
4611   * <p>
4612   * Description: <b>Reason the encounter takes place (reference)</b><br>
4613   * Type: <b>reference</b><br>
4614   * Path: <b>Encounter.reasonReference</b><br>
4615   * </p>
4616   */
4617  @SearchParamDefinition(name="reason-reference", path="Encounter.reasonReference", description="Reason the encounter takes place (reference)", type="reference", target={Condition.class, ImmunizationRecommendation.class, Observation.class, Procedure.class } )
4618  public static final String SP_REASON_REFERENCE = "reason-reference";
4619 /**
4620   * <b>Fluent Client</b> search parameter constant for <b>reason-reference</b>
4621   * <p>
4622   * Description: <b>Reason the encounter takes place (reference)</b><br>
4623   * Type: <b>reference</b><br>
4624   * Path: <b>Encounter.reasonReference</b><br>
4625   * </p>
4626   */
4627  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam REASON_REFERENCE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_REASON_REFERENCE);
4628
4629/**
4630   * Constant for fluent queries to be used to add include statements. Specifies
4631   * the path value of "<b>Encounter:reason-reference</b>".
4632   */
4633  public static final ca.uhn.fhir.model.api.Include INCLUDE_REASON_REFERENCE = new ca.uhn.fhir.model.api.Include("Encounter:reason-reference").toLocked();
4634
4635 /**
4636   * Search parameter: <b>location-period</b>
4637   * <p>
4638   * Description: <b>Time period during which the patient was present at the location</b><br>
4639   * Type: <b>date</b><br>
4640   * Path: <b>Encounter.location.period</b><br>
4641   * </p>
4642   */
4643  @SearchParamDefinition(name="location-period", path="Encounter.location.period", description="Time period during which the patient was present at the location", type="date" )
4644  public static final String SP_LOCATION_PERIOD = "location-period";
4645 /**
4646   * <b>Fluent Client</b> search parameter constant for <b>location-period</b>
4647   * <p>
4648   * Description: <b>Time period during which the patient was present at the location</b><br>
4649   * Type: <b>date</b><br>
4650   * Path: <b>Encounter.location.period</b><br>
4651   * </p>
4652   */
4653  public static final ca.uhn.fhir.rest.gclient.DateClientParam LOCATION_PERIOD = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_LOCATION_PERIOD);
4654
4655 /**
4656   * Search parameter: <b>location</b>
4657   * <p>
4658   * Description: <b>Location the encounter takes place</b><br>
4659   * Type: <b>reference</b><br>
4660   * Path: <b>Encounter.location.location</b><br>
4661   * </p>
4662   */
4663  @SearchParamDefinition(name="location", path="Encounter.location.location", description="Location the encounter takes place", type="reference", target={Location.class } )
4664  public static final String SP_LOCATION = "location";
4665 /**
4666   * <b>Fluent Client</b> search parameter constant for <b>location</b>
4667   * <p>
4668   * Description: <b>Location the encounter takes place</b><br>
4669   * Type: <b>reference</b><br>
4670   * Path: <b>Encounter.location.location</b><br>
4671   * </p>
4672   */
4673  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam LOCATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_LOCATION);
4674
4675/**
4676   * Constant for fluent queries to be used to add include statements. Specifies
4677   * the path value of "<b>Encounter:location</b>".
4678   */
4679  public static final ca.uhn.fhir.model.api.Include INCLUDE_LOCATION = new ca.uhn.fhir.model.api.Include("Encounter:location").toLocked();
4680
4681 /**
4682   * Search parameter: <b>service-provider</b>
4683   * <p>
4684   * Description: <b>The organization (facility) responsible for this encounter</b><br>
4685   * Type: <b>reference</b><br>
4686   * Path: <b>Encounter.serviceProvider</b><br>
4687   * </p>
4688   */
4689  @SearchParamDefinition(name="service-provider", path="Encounter.serviceProvider", description="The organization (facility) responsible for this encounter", type="reference", target={Organization.class } )
4690  public static final String SP_SERVICE_PROVIDER = "service-provider";
4691 /**
4692   * <b>Fluent Client</b> search parameter constant for <b>service-provider</b>
4693   * <p>
4694   * Description: <b>The organization (facility) responsible for this encounter</b><br>
4695   * Type: <b>reference</b><br>
4696   * Path: <b>Encounter.serviceProvider</b><br>
4697   * </p>
4698   */
4699  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SERVICE_PROVIDER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SERVICE_PROVIDER);
4700
4701/**
4702   * Constant for fluent queries to be used to add include statements. Specifies
4703   * the path value of "<b>Encounter:service-provider</b>".
4704   */
4705  public static final ca.uhn.fhir.model.api.Include INCLUDE_SERVICE_PROVIDER = new ca.uhn.fhir.model.api.Include("Encounter:service-provider").toLocked();
4706
4707 /**
4708   * Search parameter: <b>special-arrangement</b>
4709   * <p>
4710   * Description: <b>Wheelchair, translator, stretcher, etc.</b><br>
4711   * Type: <b>token</b><br>
4712   * Path: <b>Encounter.hospitalization.specialArrangement</b><br>
4713   * </p>
4714   */
4715  @SearchParamDefinition(name="special-arrangement", path="Encounter.hospitalization.specialArrangement", description="Wheelchair, translator, stretcher, etc.", type="token" )
4716  public static final String SP_SPECIAL_ARRANGEMENT = "special-arrangement";
4717 /**
4718   * <b>Fluent Client</b> search parameter constant for <b>special-arrangement</b>
4719   * <p>
4720   * Description: <b>Wheelchair, translator, stretcher, etc.</b><br>
4721   * Type: <b>token</b><br>
4722   * Path: <b>Encounter.hospitalization.specialArrangement</b><br>
4723   * </p>
4724   */
4725  public static final ca.uhn.fhir.rest.gclient.TokenClientParam SPECIAL_ARRANGEMENT = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_SPECIAL_ARRANGEMENT);
4726
4727 /**
4728   * Search parameter: <b>class</b>
4729   * <p>
4730   * Description: <b>Classification of patient encounter</b><br>
4731   * Type: <b>token</b><br>
4732   * Path: <b>Encounter.class</b><br>
4733   * </p>
4734   */
4735  @SearchParamDefinition(name="class", path="Encounter.class", description="Classification of patient encounter", type="token" )
4736  public static final String SP_CLASS = "class";
4737 /**
4738   * <b>Fluent Client</b> search parameter constant for <b>class</b>
4739   * <p>
4740   * Description: <b>Classification of patient encounter</b><br>
4741   * Type: <b>token</b><br>
4742   * Path: <b>Encounter.class</b><br>
4743   * </p>
4744   */
4745  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CLASS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CLASS);
4746
4747 /**
4748   * Search parameter: <b>account</b>
4749   * <p>
4750   * Description: <b>The set of accounts that may be used for billing for this Encounter</b><br>
4751   * Type: <b>reference</b><br>
4752   * Path: <b>Encounter.account</b><br>
4753   * </p>
4754   */
4755  @SearchParamDefinition(name="account", path="Encounter.account", description="The set of accounts that may be used for billing for this Encounter", type="reference", target={Account.class } )
4756  public static final String SP_ACCOUNT = "account";
4757 /**
4758   * <b>Fluent Client</b> search parameter constant for <b>account</b>
4759   * <p>
4760   * Description: <b>The set of accounts that may be used for billing for this Encounter</b><br>
4761   * Type: <b>reference</b><br>
4762   * Path: <b>Encounter.account</b><br>
4763   * </p>
4764   */
4765  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ACCOUNT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ACCOUNT);
4766
4767/**
4768   * Constant for fluent queries to be used to add include statements. Specifies
4769   * the path value of "<b>Encounter:account</b>".
4770   */
4771  public static final ca.uhn.fhir.model.api.Include INCLUDE_ACCOUNT = new ca.uhn.fhir.model.api.Include("Encounter:account").toLocked();
4772
4773 /**
4774   * Search parameter: <b>status</b>
4775   * <p>
4776   * Description: <b>planned | arrived | triaged | in-progress | onleave | finished | cancelled +</b><br>
4777   * Type: <b>token</b><br>
4778   * Path: <b>Encounter.status</b><br>
4779   * </p>
4780   */
4781  @SearchParamDefinition(name="status", path="Encounter.status", description="planned | arrived | triaged | in-progress | onleave | finished | cancelled +", type="token" )
4782  public static final String SP_STATUS = "status";
4783 /**
4784   * <b>Fluent Client</b> search parameter constant for <b>status</b>
4785   * <p>
4786   * Description: <b>planned | arrived | triaged | in-progress | onleave | finished | cancelled +</b><br>
4787   * Type: <b>token</b><br>
4788   * Path: <b>Encounter.status</b><br>
4789   * </p>
4790   */
4791  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
4792
4793
4794}
4795