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