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