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