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