001package org.hl7.fhir.dstu2016may.model;
002
003
004
005
006/*
007  Copyright (c) 2011+, HL7, Inc.
008  All rights reserved.
009  
010  Redistribution and use in source and binary forms, with or without modification, 
011  are permitted provided that the following conditions are met:
012  
013   * Redistributions of source code must retain the above copyright notice, this 
014     list of conditions and the following disclaimer.
015   * Redistributions in binary form must reproduce the above copyright notice, 
016     this list of conditions and the following disclaimer in the documentation 
017     and/or other materials provided with the distribution.
018   * Neither the name of HL7 nor the names of its contributors may be used to 
019     endorse or promote products derived from this software without specific 
020     prior written permission.
021  
022  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
023  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
024  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
025  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
026  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
027  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
028  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
029  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
030  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
031  POSSIBILITY OF SUCH DAMAGE.
032  
033*/
034
035// Generated on Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
036import java.util.ArrayList;
037import java.util.List;
038
039import org.hl7.fhir.exceptions.FHIRException;
040import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
041
042import ca.uhn.fhir.model.api.annotation.Block;
043import ca.uhn.fhir.model.api.annotation.Child;
044import ca.uhn.fhir.model.api.annotation.Description;
045import ca.uhn.fhir.model.api.annotation.ResourceDef;
046import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
047/**
048 * 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.
049 */
050@ResourceDef(name="Encounter", profile="http://hl7.org/fhir/Profile/Encounter")
051public class Encounter extends DomainResource {
052
053    public enum EncounterState {
054        /**
055         * The Encounter has not yet started.
056         */
057        PLANNED, 
058        /**
059         * The Patient is present for the encounter, however is not currently meeting with a practitioner.
060         */
061        ARRIVED, 
062        /**
063         * The Encounter has begun and the patient is present / the practitioner and the patient are meeting.
064         */
065        INPROGRESS, 
066        /**
067         * The Encounter has begun, but the patient is temporarily on leave.
068         */
069        ONLEAVE, 
070        /**
071         * The Encounter has ended.
072         */
073        FINISHED, 
074        /**
075         * The Encounter has ended before it has begun.
076         */
077        CANCELLED, 
078        /**
079         * added to help the parsers
080         */
081        NULL;
082        public static EncounterState fromCode(String codeString) throws FHIRException {
083            if (codeString == null || "".equals(codeString))
084                return null;
085        if ("planned".equals(codeString))
086          return PLANNED;
087        if ("arrived".equals(codeString))
088          return ARRIVED;
089        if ("in-progress".equals(codeString))
090          return INPROGRESS;
091        if ("onleave".equals(codeString))
092          return ONLEAVE;
093        if ("finished".equals(codeString))
094          return FINISHED;
095        if ("cancelled".equals(codeString))
096          return CANCELLED;
097        throw new FHIRException("Unknown EncounterState code '"+codeString+"'");
098        }
099        public String toCode() {
100          switch (this) {
101            case PLANNED: return "planned";
102            case ARRIVED: return "arrived";
103            case INPROGRESS: return "in-progress";
104            case ONLEAVE: return "onleave";
105            case FINISHED: return "finished";
106            case CANCELLED: return "cancelled";
107            case NULL: return null;
108            default: return "?";
109          }
110        }
111        public String getSystem() {
112          switch (this) {
113            case PLANNED: return "http://hl7.org/fhir/encounter-state";
114            case ARRIVED: return "http://hl7.org/fhir/encounter-state";
115            case INPROGRESS: return "http://hl7.org/fhir/encounter-state";
116            case ONLEAVE: return "http://hl7.org/fhir/encounter-state";
117            case FINISHED: return "http://hl7.org/fhir/encounter-state";
118            case CANCELLED: return "http://hl7.org/fhir/encounter-state";
119            case NULL: return null;
120            default: return "?";
121          }
122        }
123        public String getDefinition() {
124          switch (this) {
125            case PLANNED: return "The Encounter has not yet started.";
126            case ARRIVED: return "The Patient is present for the encounter, however is not currently meeting with a practitioner.";
127            case INPROGRESS: return "The Encounter has begun and the patient is present / the practitioner and the patient are meeting.";
128            case ONLEAVE: return "The Encounter has begun, but the patient is temporarily on leave.";
129            case FINISHED: return "The Encounter has ended.";
130            case CANCELLED: return "The Encounter has ended before it has begun.";
131            case NULL: return null;
132            default: return "?";
133          }
134        }
135        public String getDisplay() {
136          switch (this) {
137            case PLANNED: return "Planned";
138            case ARRIVED: return "Arrived";
139            case INPROGRESS: return "in Progress";
140            case ONLEAVE: return "On Leave";
141            case FINISHED: return "Finished";
142            case CANCELLED: return "Cancelled";
143            case NULL: return null;
144            default: return "?";
145          }
146        }
147    }
148
149  public static class EncounterStateEnumFactory implements EnumFactory<EncounterState> {
150    public EncounterState fromCode(String codeString) throws IllegalArgumentException {
151      if (codeString == null || "".equals(codeString))
152            if (codeString == null || "".equals(codeString))
153                return null;
154        if ("planned".equals(codeString))
155          return EncounterState.PLANNED;
156        if ("arrived".equals(codeString))
157          return EncounterState.ARRIVED;
158        if ("in-progress".equals(codeString))
159          return EncounterState.INPROGRESS;
160        if ("onleave".equals(codeString))
161          return EncounterState.ONLEAVE;
162        if ("finished".equals(codeString))
163          return EncounterState.FINISHED;
164        if ("cancelled".equals(codeString))
165          return EncounterState.CANCELLED;
166        throw new IllegalArgumentException("Unknown EncounterState code '"+codeString+"'");
167        }
168        public Enumeration<EncounterState> fromType(Base code) throws FHIRException {
169          if (code == null || code.isEmpty())
170            return null;
171          String codeString = ((PrimitiveType) code).asStringValue();
172          if (codeString == null || "".equals(codeString))
173            return null;
174        if ("planned".equals(codeString))
175          return new Enumeration<EncounterState>(this, EncounterState.PLANNED);
176        if ("arrived".equals(codeString))
177          return new Enumeration<EncounterState>(this, EncounterState.ARRIVED);
178        if ("in-progress".equals(codeString))
179          return new Enumeration<EncounterState>(this, EncounterState.INPROGRESS);
180        if ("onleave".equals(codeString))
181          return new Enumeration<EncounterState>(this, EncounterState.ONLEAVE);
182        if ("finished".equals(codeString))
183          return new Enumeration<EncounterState>(this, EncounterState.FINISHED);
184        if ("cancelled".equals(codeString))
185          return new Enumeration<EncounterState>(this, EncounterState.CANCELLED);
186        throw new FHIRException("Unknown EncounterState code '"+codeString+"'");
187        }
188    public String toCode(EncounterState code) {
189      if (code == EncounterState.PLANNED)
190        return "planned";
191      if (code == EncounterState.ARRIVED)
192        return "arrived";
193      if (code == EncounterState.INPROGRESS)
194        return "in-progress";
195      if (code == EncounterState.ONLEAVE)
196        return "onleave";
197      if (code == EncounterState.FINISHED)
198        return "finished";
199      if (code == EncounterState.CANCELLED)
200        return "cancelled";
201      return "?";
202      }
203    public String toSystem(EncounterState code) {
204      return code.getSystem();
205      }
206    }
207
208    public enum EncounterClass {
209        /**
210         * An encounter during which the patient is hospitalized and stays overnight.
211         */
212        INPATIENT, 
213        /**
214         * An encounter during which the patient is not hospitalized overnight.
215         */
216        OUTPATIENT, 
217        /**
218         * An encounter where the patient visits the practitioner in his/her office, e.g. a G.P. visit.
219         */
220        AMBULATORY, 
221        /**
222         * An encounter in the Emergency Care Department.
223         */
224        EMERGENCY, 
225        /**
226         * An encounter where the practitioner visits the patient at his/her home.
227         */
228        HOME, 
229        /**
230         * An encounter taking place outside the regular environment for giving care.
231         */
232        FIELD, 
233        /**
234         * An encounter where the patient needs more prolonged treatment or investigations than outpatients, but who do not need to stay in the hospital overnight.
235         */
236        DAYTIME, 
237        /**
238         * An encounter that takes place where the patient and practitioner do not physically meet but use electronic means for contact.
239         */
240        VIRTUAL, 
241        /**
242         * Any other encounter type that is not described by one of the other values. Where this is used it is expected that an implementer will include an extension value to define what the actual other type is.
243         */
244        OTHER, 
245        /**
246         * added to help the parsers
247         */
248        NULL;
249        public static EncounterClass fromCode(String codeString) throws FHIRException {
250            if (codeString == null || "".equals(codeString))
251                return null;
252        if ("inpatient".equals(codeString))
253          return INPATIENT;
254        if ("outpatient".equals(codeString))
255          return OUTPATIENT;
256        if ("ambulatory".equals(codeString))
257          return AMBULATORY;
258        if ("emergency".equals(codeString))
259          return EMERGENCY;
260        if ("home".equals(codeString))
261          return HOME;
262        if ("field".equals(codeString))
263          return FIELD;
264        if ("daytime".equals(codeString))
265          return DAYTIME;
266        if ("virtual".equals(codeString))
267          return VIRTUAL;
268        if ("other".equals(codeString))
269          return OTHER;
270        throw new FHIRException("Unknown EncounterClass code '"+codeString+"'");
271        }
272        public String toCode() {
273          switch (this) {
274            case INPATIENT: return "inpatient";
275            case OUTPATIENT: return "outpatient";
276            case AMBULATORY: return "ambulatory";
277            case EMERGENCY: return "emergency";
278            case HOME: return "home";
279            case FIELD: return "field";
280            case DAYTIME: return "daytime";
281            case VIRTUAL: return "virtual";
282            case OTHER: return "other";
283            case NULL: return null;
284            default: return "?";
285          }
286        }
287        public String getSystem() {
288          switch (this) {
289            case INPATIENT: return "http://hl7.org/fhir/encounter-class";
290            case OUTPATIENT: return "http://hl7.org/fhir/encounter-class";
291            case AMBULATORY: return "http://hl7.org/fhir/encounter-class";
292            case EMERGENCY: return "http://hl7.org/fhir/encounter-class";
293            case HOME: return "http://hl7.org/fhir/encounter-class";
294            case FIELD: return "http://hl7.org/fhir/encounter-class";
295            case DAYTIME: return "http://hl7.org/fhir/encounter-class";
296            case VIRTUAL: return "http://hl7.org/fhir/encounter-class";
297            case OTHER: return "http://hl7.org/fhir/encounter-class";
298            case NULL: return null;
299            default: return "?";
300          }
301        }
302        public String getDefinition() {
303          switch (this) {
304            case INPATIENT: return "An encounter during which the patient is hospitalized and stays overnight.";
305            case OUTPATIENT: return "An encounter during which the patient is not hospitalized overnight.";
306            case AMBULATORY: return "An encounter where the patient visits the practitioner in his/her office, e.g. a G.P. visit.";
307            case EMERGENCY: return "An encounter in the Emergency Care Department.";
308            case HOME: return "An encounter where the practitioner visits the patient at his/her home.";
309            case FIELD: return "An encounter taking place outside the regular environment for giving care.";
310            case DAYTIME: return "An encounter where the patient needs more prolonged treatment or investigations than outpatients, but who do not need to stay in the hospital overnight.";
311            case VIRTUAL: return "An encounter that takes place where the patient and practitioner do not physically meet but use electronic means for contact.";
312            case OTHER: return "Any other encounter type that is not described by one of the other values. Where this is used it is expected that an implementer will include an extension value to define what the actual other type is.";
313            case NULL: return null;
314            default: return "?";
315          }
316        }
317        public String getDisplay() {
318          switch (this) {
319            case INPATIENT: return "Inpatient";
320            case OUTPATIENT: return "Outpatient";
321            case AMBULATORY: return "Ambulatory";
322            case EMERGENCY: return "Emergency";
323            case HOME: return "Home";
324            case FIELD: return "Field";
325            case DAYTIME: return "Daytime";
326            case VIRTUAL: return "Virtual";
327            case OTHER: return "Other";
328            case NULL: return null;
329            default: return "?";
330          }
331        }
332    }
333
334  public static class EncounterClassEnumFactory implements EnumFactory<EncounterClass> {
335    public EncounterClass fromCode(String codeString) throws IllegalArgumentException {
336      if (codeString == null || "".equals(codeString))
337            if (codeString == null || "".equals(codeString))
338                return null;
339        if ("inpatient".equals(codeString))
340          return EncounterClass.INPATIENT;
341        if ("outpatient".equals(codeString))
342          return EncounterClass.OUTPATIENT;
343        if ("ambulatory".equals(codeString))
344          return EncounterClass.AMBULATORY;
345        if ("emergency".equals(codeString))
346          return EncounterClass.EMERGENCY;
347        if ("home".equals(codeString))
348          return EncounterClass.HOME;
349        if ("field".equals(codeString))
350          return EncounterClass.FIELD;
351        if ("daytime".equals(codeString))
352          return EncounterClass.DAYTIME;
353        if ("virtual".equals(codeString))
354          return EncounterClass.VIRTUAL;
355        if ("other".equals(codeString))
356          return EncounterClass.OTHER;
357        throw new IllegalArgumentException("Unknown EncounterClass code '"+codeString+"'");
358        }
359        public Enumeration<EncounterClass> fromType(Base code) throws FHIRException {
360          if (code == null || code.isEmpty())
361            return null;
362          String codeString = ((PrimitiveType) code).asStringValue();
363          if (codeString == null || "".equals(codeString))
364            return null;
365        if ("inpatient".equals(codeString))
366          return new Enumeration<EncounterClass>(this, EncounterClass.INPATIENT);
367        if ("outpatient".equals(codeString))
368          return new Enumeration<EncounterClass>(this, EncounterClass.OUTPATIENT);
369        if ("ambulatory".equals(codeString))
370          return new Enumeration<EncounterClass>(this, EncounterClass.AMBULATORY);
371        if ("emergency".equals(codeString))
372          return new Enumeration<EncounterClass>(this, EncounterClass.EMERGENCY);
373        if ("home".equals(codeString))
374          return new Enumeration<EncounterClass>(this, EncounterClass.HOME);
375        if ("field".equals(codeString))
376          return new Enumeration<EncounterClass>(this, EncounterClass.FIELD);
377        if ("daytime".equals(codeString))
378          return new Enumeration<EncounterClass>(this, EncounterClass.DAYTIME);
379        if ("virtual".equals(codeString))
380          return new Enumeration<EncounterClass>(this, EncounterClass.VIRTUAL);
381        if ("other".equals(codeString))
382          return new Enumeration<EncounterClass>(this, EncounterClass.OTHER);
383        throw new FHIRException("Unknown EncounterClass code '"+codeString+"'");
384        }
385    public String toCode(EncounterClass code) {
386      if (code == EncounterClass.INPATIENT)
387        return "inpatient";
388      if (code == EncounterClass.OUTPATIENT)
389        return "outpatient";
390      if (code == EncounterClass.AMBULATORY)
391        return "ambulatory";
392      if (code == EncounterClass.EMERGENCY)
393        return "emergency";
394      if (code == EncounterClass.HOME)
395        return "home";
396      if (code == EncounterClass.FIELD)
397        return "field";
398      if (code == EncounterClass.DAYTIME)
399        return "daytime";
400      if (code == EncounterClass.VIRTUAL)
401        return "virtual";
402      if (code == EncounterClass.OTHER)
403        return "other";
404      return "?";
405      }
406    public String toSystem(EncounterClass code) {
407      return code.getSystem();
408      }
409    }
410
411    public enum EncounterLocationStatus {
412        /**
413         * The patient is planned to be moved to this location at some point in the future.
414         */
415        PLANNED, 
416        /**
417         * The patient is currently at this location, or was between the period specified.
418
419A system may update these records when the patient leaves the location to either reserved, or completed
420         */
421        ACTIVE, 
422        /**
423         * This location is held empty for this patient.
424         */
425        RESERVED, 
426        /**
427         * The patient was at this location during the period specified.
428
429Not to be used when the patient is currently at the location
430         */
431        COMPLETED, 
432        /**
433         * added to help the parsers
434         */
435        NULL;
436        public static EncounterLocationStatus fromCode(String codeString) throws FHIRException {
437            if (codeString == null || "".equals(codeString))
438                return null;
439        if ("planned".equals(codeString))
440          return PLANNED;
441        if ("active".equals(codeString))
442          return ACTIVE;
443        if ("reserved".equals(codeString))
444          return RESERVED;
445        if ("completed".equals(codeString))
446          return COMPLETED;
447        throw new FHIRException("Unknown EncounterLocationStatus code '"+codeString+"'");
448        }
449        public String toCode() {
450          switch (this) {
451            case PLANNED: return "planned";
452            case ACTIVE: return "active";
453            case RESERVED: return "reserved";
454            case COMPLETED: return "completed";
455            case NULL: return null;
456            default: return "?";
457          }
458        }
459        public String getSystem() {
460          switch (this) {
461            case PLANNED: return "http://hl7.org/fhir/encounter-location-status";
462            case ACTIVE: return "http://hl7.org/fhir/encounter-location-status";
463            case RESERVED: return "http://hl7.org/fhir/encounter-location-status";
464            case COMPLETED: return "http://hl7.org/fhir/encounter-location-status";
465            case NULL: return null;
466            default: return "?";
467          }
468        }
469        public String getDefinition() {
470          switch (this) {
471            case PLANNED: return "The patient is planned to be moved to this location at some point in the future.";
472            case ACTIVE: return "The patient is currently at this location, or was between the period specified.\n\nA system may update these records when the patient leaves the location to either reserved, or completed";
473            case RESERVED: return "This location is held empty for this patient.";
474            case COMPLETED: return "The patient was at this location during the period specified.\n\nNot to be used when the patient is currently at the location";
475            case NULL: return null;
476            default: return "?";
477          }
478        }
479        public String getDisplay() {
480          switch (this) {
481            case PLANNED: return "Planned";
482            case ACTIVE: return "Active";
483            case RESERVED: return "Reserved";
484            case COMPLETED: return "Completed";
485            case NULL: return null;
486            default: return "?";
487          }
488        }
489    }
490
491  public static class EncounterLocationStatusEnumFactory implements EnumFactory<EncounterLocationStatus> {
492    public EncounterLocationStatus fromCode(String codeString) throws IllegalArgumentException {
493      if (codeString == null || "".equals(codeString))
494            if (codeString == null || "".equals(codeString))
495                return null;
496        if ("planned".equals(codeString))
497          return EncounterLocationStatus.PLANNED;
498        if ("active".equals(codeString))
499          return EncounterLocationStatus.ACTIVE;
500        if ("reserved".equals(codeString))
501          return EncounterLocationStatus.RESERVED;
502        if ("completed".equals(codeString))
503          return EncounterLocationStatus.COMPLETED;
504        throw new IllegalArgumentException("Unknown EncounterLocationStatus code '"+codeString+"'");
505        }
506        public Enumeration<EncounterLocationStatus> fromType(Base code) throws FHIRException {
507          if (code == null || code.isEmpty())
508            return null;
509          String codeString = ((PrimitiveType) code).asStringValue();
510          if (codeString == null || "".equals(codeString))
511            return null;
512        if ("planned".equals(codeString))
513          return new Enumeration<EncounterLocationStatus>(this, EncounterLocationStatus.PLANNED);
514        if ("active".equals(codeString))
515          return new Enumeration<EncounterLocationStatus>(this, EncounterLocationStatus.ACTIVE);
516        if ("reserved".equals(codeString))
517          return new Enumeration<EncounterLocationStatus>(this, EncounterLocationStatus.RESERVED);
518        if ("completed".equals(codeString))
519          return new Enumeration<EncounterLocationStatus>(this, EncounterLocationStatus.COMPLETED);
520        throw new FHIRException("Unknown EncounterLocationStatus code '"+codeString+"'");
521        }
522    public String toCode(EncounterLocationStatus code) {
523      if (code == EncounterLocationStatus.PLANNED)
524        return "planned";
525      if (code == EncounterLocationStatus.ACTIVE)
526        return "active";
527      if (code == EncounterLocationStatus.RESERVED)
528        return "reserved";
529      if (code == EncounterLocationStatus.COMPLETED)
530        return "completed";
531      return "?";
532      }
533    public String toSystem(EncounterLocationStatus code) {
534      return code.getSystem();
535      }
536    }
537
538    @Block()
539    public static class EncounterStatusHistoryComponent extends BackboneElement implements IBaseBackboneElement {
540        /**
541         * planned | arrived | in-progress | onleave | finished | cancelled.
542         */
543        @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=false)
544        @Description(shortDefinition="planned | arrived | in-progress | onleave | finished | cancelled", formalDefinition="planned | arrived | in-progress | onleave | finished | cancelled." )
545        protected Enumeration<EncounterState> status;
546
547        /**
548         * The time that the episode was in the specified status.
549         */
550        @Child(name = "period", type = {Period.class}, order=2, min=1, max=1, modifier=false, summary=false)
551        @Description(shortDefinition="The time that the episode was in the specified status", formalDefinition="The time that the episode was in the specified status." )
552        protected Period period;
553
554        private static final long serialVersionUID = 919229161L;
555
556    /**
557     * Constructor
558     */
559      public EncounterStatusHistoryComponent() {
560        super();
561      }
562
563    /**
564     * Constructor
565     */
566      public EncounterStatusHistoryComponent(Enumeration<EncounterState> status, Period period) {
567        super();
568        this.status = status;
569        this.period = period;
570      }
571
572        /**
573         * @return {@link #status} (planned | arrived | in-progress | onleave | finished | cancelled.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
574         */
575        public Enumeration<EncounterState> getStatusElement() { 
576          if (this.status == null)
577            if (Configuration.errorOnAutoCreate())
578              throw new Error("Attempt to auto-create EncounterStatusHistoryComponent.status");
579            else if (Configuration.doAutoCreate())
580              this.status = new Enumeration<EncounterState>(new EncounterStateEnumFactory()); // bb
581          return this.status;
582        }
583
584        public boolean hasStatusElement() { 
585          return this.status != null && !this.status.isEmpty();
586        }
587
588        public boolean hasStatus() { 
589          return this.status != null && !this.status.isEmpty();
590        }
591
592        /**
593         * @param value {@link #status} (planned | arrived | in-progress | onleave | finished | cancelled.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
594         */
595        public EncounterStatusHistoryComponent setStatusElement(Enumeration<EncounterState> value) { 
596          this.status = value;
597          return this;
598        }
599
600        /**
601         * @return planned | arrived | in-progress | onleave | finished | cancelled.
602         */
603        public EncounterState getStatus() { 
604          return this.status == null ? null : this.status.getValue();
605        }
606
607        /**
608         * @param value planned | arrived | in-progress | onleave | finished | cancelled.
609         */
610        public EncounterStatusHistoryComponent setStatus(EncounterState value) { 
611            if (this.status == null)
612              this.status = new Enumeration<EncounterState>(new EncounterStateEnumFactory());
613            this.status.setValue(value);
614          return this;
615        }
616
617        /**
618         * @return {@link #period} (The time that the episode was in the specified status.)
619         */
620        public Period getPeriod() { 
621          if (this.period == null)
622            if (Configuration.errorOnAutoCreate())
623              throw new Error("Attempt to auto-create EncounterStatusHistoryComponent.period");
624            else if (Configuration.doAutoCreate())
625              this.period = new Period(); // cc
626          return this.period;
627        }
628
629        public boolean hasPeriod() { 
630          return this.period != null && !this.period.isEmpty();
631        }
632
633        /**
634         * @param value {@link #period} (The time that the episode was in the specified status.)
635         */
636        public EncounterStatusHistoryComponent setPeriod(Period value) { 
637          this.period = value;
638          return this;
639        }
640
641        protected void listChildren(List<Property> childrenList) {
642          super.listChildren(childrenList);
643          childrenList.add(new Property("status", "code", "planned | arrived | in-progress | onleave | finished | cancelled.", 0, java.lang.Integer.MAX_VALUE, status));
644          childrenList.add(new Property("period", "Period", "The time that the episode was in the specified status.", 0, java.lang.Integer.MAX_VALUE, period));
645        }
646
647      @Override
648      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
649        switch (hash) {
650        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<EncounterState>
651        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
652        default: return super.getProperty(hash, name, checkValid);
653        }
654
655      }
656
657      @Override
658      public void setProperty(int hash, String name, Base value) throws FHIRException {
659        switch (hash) {
660        case -892481550: // status
661          this.status = new EncounterStateEnumFactory().fromType(value); // Enumeration<EncounterState>
662          break;
663        case -991726143: // period
664          this.period = castToPeriod(value); // Period
665          break;
666        default: super.setProperty(hash, name, value);
667        }
668
669      }
670
671      @Override
672      public void setProperty(String name, Base value) throws FHIRException {
673        if (name.equals("status"))
674          this.status = new EncounterStateEnumFactory().fromType(value); // Enumeration<EncounterState>
675        else if (name.equals("period"))
676          this.period = castToPeriod(value); // Period
677        else
678          super.setProperty(name, value);
679      }
680
681      @Override
682      public Base makeProperty(int hash, String name) throws FHIRException {
683        switch (hash) {
684        case -892481550: throw new FHIRException("Cannot make property status as it is not a complex type"); // Enumeration<EncounterState>
685        case -991726143:  return getPeriod(); // Period
686        default: return super.makeProperty(hash, name);
687        }
688
689      }
690
691      @Override
692      public Base addChild(String name) throws FHIRException {
693        if (name.equals("status")) {
694          throw new FHIRException("Cannot call addChild on a primitive type Encounter.status");
695        }
696        else if (name.equals("period")) {
697          this.period = new Period();
698          return this.period;
699        }
700        else
701          return super.addChild(name);
702      }
703
704      public EncounterStatusHistoryComponent copy() {
705        EncounterStatusHistoryComponent dst = new EncounterStatusHistoryComponent();
706        copyValues(dst);
707        dst.status = status == null ? null : status.copy();
708        dst.period = period == null ? null : period.copy();
709        return dst;
710      }
711
712      @Override
713      public boolean equalsDeep(Base other) {
714        if (!super.equalsDeep(other))
715          return false;
716        if (!(other instanceof EncounterStatusHistoryComponent))
717          return false;
718        EncounterStatusHistoryComponent o = (EncounterStatusHistoryComponent) other;
719        return compareDeep(status, o.status, true) && compareDeep(period, o.period, true);
720      }
721
722      @Override
723      public boolean equalsShallow(Base other) {
724        if (!super.equalsShallow(other))
725          return false;
726        if (!(other instanceof EncounterStatusHistoryComponent))
727          return false;
728        EncounterStatusHistoryComponent o = (EncounterStatusHistoryComponent) other;
729        return compareValues(status, o.status, true);
730      }
731
732      public boolean isEmpty() {
733        return super.isEmpty() && (status == null || status.isEmpty()) && (period == null || period.isEmpty())
734          ;
735      }
736
737  public String fhirType() {
738    return "Encounter.statusHistory";
739
740  }
741
742  }
743
744    @Block()
745    public static class EncounterParticipantComponent extends BackboneElement implements IBaseBackboneElement {
746        /**
747         * Role of participant in encounter.
748         */
749        @Child(name = "type", type = {CodeableConcept.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
750        @Description(shortDefinition="Role of participant in encounter", formalDefinition="Role of participant in encounter." )
751        protected List<CodeableConcept> type;
752
753        /**
754         * The period of time that the specified participant was present during the encounter. These can overlap or be sub-sets of the overall encounters period.
755         */
756        @Child(name = "period", type = {Period.class}, order=2, min=0, max=1, modifier=false, summary=false)
757        @Description(shortDefinition="Period of time during the encounter participant was present", formalDefinition="The period of time that the specified participant was present during the encounter. These can overlap or be sub-sets of the overall encounters period." )
758        protected Period period;
759
760        /**
761         * Persons involved in the encounter other than the patient.
762         */
763        @Child(name = "individual", type = {Practitioner.class, RelatedPerson.class}, order=3, min=0, max=1, modifier=false, summary=true)
764        @Description(shortDefinition="Persons involved in the encounter other than the patient", formalDefinition="Persons involved in the encounter other than the patient." )
765        protected Reference individual;
766
767        /**
768         * The actual object that is the target of the reference (Persons involved in the encounter other than the patient.)
769         */
770        protected Resource individualTarget;
771
772        private static final long serialVersionUID = 317095765L;
773
774    /**
775     * Constructor
776     */
777      public EncounterParticipantComponent() {
778        super();
779      }
780
781        /**
782         * @return {@link #type} (Role of participant in encounter.)
783         */
784        public List<CodeableConcept> getType() { 
785          if (this.type == null)
786            this.type = new ArrayList<CodeableConcept>();
787          return this.type;
788        }
789
790        public boolean hasType() { 
791          if (this.type == null)
792            return false;
793          for (CodeableConcept item : this.type)
794            if (!item.isEmpty())
795              return true;
796          return false;
797        }
798
799        /**
800         * @return {@link #type} (Role of participant in encounter.)
801         */
802    // syntactic sugar
803        public CodeableConcept addType() { //3
804          CodeableConcept t = new CodeableConcept();
805          if (this.type == null)
806            this.type = new ArrayList<CodeableConcept>();
807          this.type.add(t);
808          return t;
809        }
810
811    // syntactic sugar
812        public EncounterParticipantComponent addType(CodeableConcept t) { //3
813          if (t == null)
814            return this;
815          if (this.type == null)
816            this.type = new ArrayList<CodeableConcept>();
817          this.type.add(t);
818          return this;
819        }
820
821        /**
822         * @return {@link #period} (The period of time that the specified participant was present during the encounter. These can overlap or be sub-sets of the overall encounters period.)
823         */
824        public Period getPeriod() { 
825          if (this.period == null)
826            if (Configuration.errorOnAutoCreate())
827              throw new Error("Attempt to auto-create EncounterParticipantComponent.period");
828            else if (Configuration.doAutoCreate())
829              this.period = new Period(); // cc
830          return this.period;
831        }
832
833        public boolean hasPeriod() { 
834          return this.period != null && !this.period.isEmpty();
835        }
836
837        /**
838         * @param value {@link #period} (The period of time that the specified participant was present during the encounter. These can overlap or be sub-sets of the overall encounters period.)
839         */
840        public EncounterParticipantComponent setPeriod(Period value) { 
841          this.period = value;
842          return this;
843        }
844
845        /**
846         * @return {@link #individual} (Persons involved in the encounter other than the patient.)
847         */
848        public Reference getIndividual() { 
849          if (this.individual == null)
850            if (Configuration.errorOnAutoCreate())
851              throw new Error("Attempt to auto-create EncounterParticipantComponent.individual");
852            else if (Configuration.doAutoCreate())
853              this.individual = new Reference(); // cc
854          return this.individual;
855        }
856
857        public boolean hasIndividual() { 
858          return this.individual != null && !this.individual.isEmpty();
859        }
860
861        /**
862         * @param value {@link #individual} (Persons involved in the encounter other than the patient.)
863         */
864        public EncounterParticipantComponent setIndividual(Reference value) { 
865          this.individual = value;
866          return this;
867        }
868
869        /**
870         * @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.)
871         */
872        public Resource getIndividualTarget() { 
873          return this.individualTarget;
874        }
875
876        /**
877         * @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.)
878         */
879        public EncounterParticipantComponent setIndividualTarget(Resource value) { 
880          this.individualTarget = value;
881          return this;
882        }
883
884        protected void listChildren(List<Property> childrenList) {
885          super.listChildren(childrenList);
886          childrenList.add(new Property("type", "CodeableConcept", "Role of participant in encounter.", 0, java.lang.Integer.MAX_VALUE, type));
887          childrenList.add(new Property("period", "Period", "The period of time that the specified participant was present during the encounter. These can overlap or be sub-sets of the overall encounters period.", 0, java.lang.Integer.MAX_VALUE, period));
888          childrenList.add(new Property("individual", "Reference(Practitioner|RelatedPerson)", "Persons involved in the encounter other than the patient.", 0, java.lang.Integer.MAX_VALUE, individual));
889        }
890
891      @Override
892      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
893        switch (hash) {
894        case 3575610: /*type*/ return this.type == null ? new Base[0] : this.type.toArray(new Base[this.type.size()]); // CodeableConcept
895        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
896        case -46292327: /*individual*/ return this.individual == null ? new Base[0] : new Base[] {this.individual}; // Reference
897        default: return super.getProperty(hash, name, checkValid);
898        }
899
900      }
901
902      @Override
903      public void setProperty(int hash, String name, Base value) throws FHIRException {
904        switch (hash) {
905        case 3575610: // type
906          this.getType().add(castToCodeableConcept(value)); // CodeableConcept
907          break;
908        case -991726143: // period
909          this.period = castToPeriod(value); // Period
910          break;
911        case -46292327: // individual
912          this.individual = castToReference(value); // Reference
913          break;
914        default: super.setProperty(hash, name, value);
915        }
916
917      }
918
919      @Override
920      public void setProperty(String name, Base value) throws FHIRException {
921        if (name.equals("type"))
922          this.getType().add(castToCodeableConcept(value));
923        else if (name.equals("period"))
924          this.period = castToPeriod(value); // Period
925        else if (name.equals("individual"))
926          this.individual = castToReference(value); // Reference
927        else
928          super.setProperty(name, value);
929      }
930
931      @Override
932      public Base makeProperty(int hash, String name) throws FHIRException {
933        switch (hash) {
934        case 3575610:  return addType(); // CodeableConcept
935        case -991726143:  return getPeriod(); // Period
936        case -46292327:  return getIndividual(); // Reference
937        default: return super.makeProperty(hash, name);
938        }
939
940      }
941
942      @Override
943      public Base addChild(String name) throws FHIRException {
944        if (name.equals("type")) {
945          return addType();
946        }
947        else if (name.equals("period")) {
948          this.period = new Period();
949          return this.period;
950        }
951        else if (name.equals("individual")) {
952          this.individual = new Reference();
953          return this.individual;
954        }
955        else
956          return super.addChild(name);
957      }
958
959      public EncounterParticipantComponent copy() {
960        EncounterParticipantComponent dst = new EncounterParticipantComponent();
961        copyValues(dst);
962        if (type != null) {
963          dst.type = new ArrayList<CodeableConcept>();
964          for (CodeableConcept i : type)
965            dst.type.add(i.copy());
966        };
967        dst.period = period == null ? null : period.copy();
968        dst.individual = individual == null ? null : individual.copy();
969        return dst;
970      }
971
972      @Override
973      public boolean equalsDeep(Base other) {
974        if (!super.equalsDeep(other))
975          return false;
976        if (!(other instanceof EncounterParticipantComponent))
977          return false;
978        EncounterParticipantComponent o = (EncounterParticipantComponent) other;
979        return compareDeep(type, o.type, true) && compareDeep(period, o.period, true) && compareDeep(individual, o.individual, true)
980          ;
981      }
982
983      @Override
984      public boolean equalsShallow(Base other) {
985        if (!super.equalsShallow(other))
986          return false;
987        if (!(other instanceof EncounterParticipantComponent))
988          return false;
989        EncounterParticipantComponent o = (EncounterParticipantComponent) other;
990        return true;
991      }
992
993      public boolean isEmpty() {
994        return super.isEmpty() && (type == null || type.isEmpty()) && (period == null || period.isEmpty())
995           && (individual == null || individual.isEmpty());
996      }
997
998  public String fhirType() {
999    return "Encounter.participant";
1000
1001  }
1002
1003  }
1004
1005    @Block()
1006    public static class EncounterHospitalizationComponent extends BackboneElement implements IBaseBackboneElement {
1007        /**
1008         * Pre-admission identifier.
1009         */
1010        @Child(name = "preAdmissionIdentifier", type = {Identifier.class}, order=1, min=0, max=1, modifier=false, summary=false)
1011        @Description(shortDefinition="Pre-admission identifier", formalDefinition="Pre-admission identifier." )
1012        protected Identifier preAdmissionIdentifier;
1013
1014        /**
1015         * The location from which the patient came before admission.
1016         */
1017        @Child(name = "origin", type = {Location.class}, order=2, min=0, max=1, modifier=false, summary=false)
1018        @Description(shortDefinition="The location from which the patient came before admission", formalDefinition="The location from which the patient came before admission." )
1019        protected Reference origin;
1020
1021        /**
1022         * The actual object that is the target of the reference (The location from which the patient came before admission.)
1023         */
1024        protected Location originTarget;
1025
1026        /**
1027         * From where patient was admitted (physician referral, transfer).
1028         */
1029        @Child(name = "admitSource", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=false)
1030        @Description(shortDefinition="From where patient was admitted (physician referral, transfer)", formalDefinition="From where patient was admitted (physician referral, transfer)." )
1031        protected CodeableConcept admitSource;
1032
1033        /**
1034         * The admitting diagnosis field is used to record the diagnosis codes as reported by admitting practitioner. This could be different or in addition to the conditions reported as reason-condition(s) for the encounter.
1035         */
1036        @Child(name = "admittingDiagnosis", type = {Condition.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1037        @Description(shortDefinition="The admitting diagnosis as reported by admitting practitioner", formalDefinition="The admitting diagnosis field is used to record the diagnosis codes as reported by admitting practitioner. This could be different or in addition to the conditions reported as reason-condition(s) for the encounter." )
1038        protected List<Reference> admittingDiagnosis;
1039        /**
1040         * The actual objects that are the target of the reference (The admitting diagnosis field is used to record the diagnosis codes as reported by admitting practitioner. This could be different or in addition to the conditions reported as reason-condition(s) for the encounter.)
1041         */
1042        protected List<Condition> admittingDiagnosisTarget;
1043
1044
1045        /**
1046         * Whether this hospitalization is a readmission and why if known.
1047         */
1048        @Child(name = "reAdmission", type = {CodeableConcept.class}, order=5, min=0, max=1, modifier=false, summary=false)
1049        @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." )
1050        protected CodeableConcept reAdmission;
1051
1052        /**
1053         * Diet preferences reported by the patient.
1054         */
1055        @Child(name = "dietPreference", type = {CodeableConcept.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1056        @Description(shortDefinition="Diet preferences reported by the patient", formalDefinition="Diet preferences reported by the patient." )
1057        protected List<CodeableConcept> dietPreference;
1058
1059        /**
1060         * Special courtesies (VIP, board member).
1061         */
1062        @Child(name = "specialCourtesy", type = {CodeableConcept.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1063        @Description(shortDefinition="Special courtesies (VIP, board member)", formalDefinition="Special courtesies (VIP, board member)." )
1064        protected List<CodeableConcept> specialCourtesy;
1065
1066        /**
1067         * Wheelchair, translator, stretcher, etc.
1068         */
1069        @Child(name = "specialArrangement", type = {CodeableConcept.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1070        @Description(shortDefinition="Wheelchair, translator, stretcher, etc.", formalDefinition="Wheelchair, translator, stretcher, etc." )
1071        protected List<CodeableConcept> specialArrangement;
1072
1073        /**
1074         * Location to which the patient is discharged.
1075         */
1076        @Child(name = "destination", type = {Location.class}, order=9, min=0, max=1, modifier=false, summary=false)
1077        @Description(shortDefinition="Location to which the patient is discharged", formalDefinition="Location to which the patient is discharged." )
1078        protected Reference destination;
1079
1080        /**
1081         * The actual object that is the target of the reference (Location to which the patient is discharged.)
1082         */
1083        protected Location destinationTarget;
1084
1085        /**
1086         * Category or kind of location after discharge.
1087         */
1088        @Child(name = "dischargeDisposition", type = {CodeableConcept.class}, order=10, min=0, max=1, modifier=false, summary=false)
1089        @Description(shortDefinition="Category or kind of location after discharge", formalDefinition="Category or kind of location after discharge." )
1090        protected CodeableConcept dischargeDisposition;
1091
1092        /**
1093         * The final diagnosis given a patient before release from the hospital after all testing, surgery, and workup are complete.
1094         */
1095        @Child(name = "dischargeDiagnosis", type = {Condition.class}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1096        @Description(shortDefinition="The final diagnosis given a patient before release from the hospital after all testing, surgery, and workup are complete", formalDefinition="The final diagnosis given a patient before release from the hospital after all testing, surgery, and workup are complete." )
1097        protected List<Reference> dischargeDiagnosis;
1098        /**
1099         * The actual objects that are the target of the reference (The final diagnosis given a patient before release from the hospital after all testing, surgery, and workup are complete.)
1100         */
1101        protected List<Condition> dischargeDiagnosisTarget;
1102
1103
1104        private static final long serialVersionUID = 164618034L;
1105
1106    /**
1107     * Constructor
1108     */
1109      public EncounterHospitalizationComponent() {
1110        super();
1111      }
1112
1113        /**
1114         * @return {@link #preAdmissionIdentifier} (Pre-admission identifier.)
1115         */
1116        public Identifier getPreAdmissionIdentifier() { 
1117          if (this.preAdmissionIdentifier == null)
1118            if (Configuration.errorOnAutoCreate())
1119              throw new Error("Attempt to auto-create EncounterHospitalizationComponent.preAdmissionIdentifier");
1120            else if (Configuration.doAutoCreate())
1121              this.preAdmissionIdentifier = new Identifier(); // cc
1122          return this.preAdmissionIdentifier;
1123        }
1124
1125        public boolean hasPreAdmissionIdentifier() { 
1126          return this.preAdmissionIdentifier != null && !this.preAdmissionIdentifier.isEmpty();
1127        }
1128
1129        /**
1130         * @param value {@link #preAdmissionIdentifier} (Pre-admission identifier.)
1131         */
1132        public EncounterHospitalizationComponent setPreAdmissionIdentifier(Identifier value) { 
1133          this.preAdmissionIdentifier = value;
1134          return this;
1135        }
1136
1137        /**
1138         * @return {@link #origin} (The location from which the patient came before admission.)
1139         */
1140        public Reference getOrigin() { 
1141          if (this.origin == null)
1142            if (Configuration.errorOnAutoCreate())
1143              throw new Error("Attempt to auto-create EncounterHospitalizationComponent.origin");
1144            else if (Configuration.doAutoCreate())
1145              this.origin = new Reference(); // cc
1146          return this.origin;
1147        }
1148
1149        public boolean hasOrigin() { 
1150          return this.origin != null && !this.origin.isEmpty();
1151        }
1152
1153        /**
1154         * @param value {@link #origin} (The location from which the patient came before admission.)
1155         */
1156        public EncounterHospitalizationComponent setOrigin(Reference value) { 
1157          this.origin = value;
1158          return this;
1159        }
1160
1161        /**
1162         * @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 from which the patient came before admission.)
1163         */
1164        public Location getOriginTarget() { 
1165          if (this.originTarget == null)
1166            if (Configuration.errorOnAutoCreate())
1167              throw new Error("Attempt to auto-create EncounterHospitalizationComponent.origin");
1168            else if (Configuration.doAutoCreate())
1169              this.originTarget = new Location(); // aa
1170          return this.originTarget;
1171        }
1172
1173        /**
1174         * @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 from which the patient came before admission.)
1175         */
1176        public EncounterHospitalizationComponent setOriginTarget(Location value) { 
1177          this.originTarget = value;
1178          return this;
1179        }
1180
1181        /**
1182         * @return {@link #admitSource} (From where patient was admitted (physician referral, transfer).)
1183         */
1184        public CodeableConcept getAdmitSource() { 
1185          if (this.admitSource == null)
1186            if (Configuration.errorOnAutoCreate())
1187              throw new Error("Attempt to auto-create EncounterHospitalizationComponent.admitSource");
1188            else if (Configuration.doAutoCreate())
1189              this.admitSource = new CodeableConcept(); // cc
1190          return this.admitSource;
1191        }
1192
1193        public boolean hasAdmitSource() { 
1194          return this.admitSource != null && !this.admitSource.isEmpty();
1195        }
1196
1197        /**
1198         * @param value {@link #admitSource} (From where patient was admitted (physician referral, transfer).)
1199         */
1200        public EncounterHospitalizationComponent setAdmitSource(CodeableConcept value) { 
1201          this.admitSource = value;
1202          return this;
1203        }
1204
1205        /**
1206         * @return {@link #admittingDiagnosis} (The admitting diagnosis field is used to record the diagnosis codes as reported by admitting practitioner. This could be different or in addition to the conditions reported as reason-condition(s) for the encounter.)
1207         */
1208        public List<Reference> getAdmittingDiagnosis() { 
1209          if (this.admittingDiagnosis == null)
1210            this.admittingDiagnosis = new ArrayList<Reference>();
1211          return this.admittingDiagnosis;
1212        }
1213
1214        public boolean hasAdmittingDiagnosis() { 
1215          if (this.admittingDiagnosis == null)
1216            return false;
1217          for (Reference item : this.admittingDiagnosis)
1218            if (!item.isEmpty())
1219              return true;
1220          return false;
1221        }
1222
1223        /**
1224         * @return {@link #admittingDiagnosis} (The admitting diagnosis field is used to record the diagnosis codes as reported by admitting practitioner. This could be different or in addition to the conditions reported as reason-condition(s) for the encounter.)
1225         */
1226    // syntactic sugar
1227        public Reference addAdmittingDiagnosis() { //3
1228          Reference t = new Reference();
1229          if (this.admittingDiagnosis == null)
1230            this.admittingDiagnosis = new ArrayList<Reference>();
1231          this.admittingDiagnosis.add(t);
1232          return t;
1233        }
1234
1235    // syntactic sugar
1236        public EncounterHospitalizationComponent addAdmittingDiagnosis(Reference t) { //3
1237          if (t == null)
1238            return this;
1239          if (this.admittingDiagnosis == null)
1240            this.admittingDiagnosis = new ArrayList<Reference>();
1241          this.admittingDiagnosis.add(t);
1242          return this;
1243        }
1244
1245        /**
1246         * @return {@link #admittingDiagnosis} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. The admitting diagnosis field is used to record the diagnosis codes as reported by admitting practitioner. This could be different or in addition to the conditions reported as reason-condition(s) for the encounter.)
1247         */
1248        public List<Condition> getAdmittingDiagnosisTarget() { 
1249          if (this.admittingDiagnosisTarget == null)
1250            this.admittingDiagnosisTarget = new ArrayList<Condition>();
1251          return this.admittingDiagnosisTarget;
1252        }
1253
1254    // syntactic sugar
1255        /**
1256         * @return {@link #admittingDiagnosis} (Add an actual object that is the target of the reference. The reference library doesn't use these, but you can use this to hold the resources if you resolvethemt. The admitting diagnosis field is used to record the diagnosis codes as reported by admitting practitioner. This could be different or in addition to the conditions reported as reason-condition(s) for the encounter.)
1257         */
1258        public Condition addAdmittingDiagnosisTarget() { 
1259          Condition r = new Condition();
1260          if (this.admittingDiagnosisTarget == null)
1261            this.admittingDiagnosisTarget = new ArrayList<Condition>();
1262          this.admittingDiagnosisTarget.add(r);
1263          return r;
1264        }
1265
1266        /**
1267         * @return {@link #reAdmission} (Whether this hospitalization is a readmission and why if known.)
1268         */
1269        public CodeableConcept getReAdmission() { 
1270          if (this.reAdmission == null)
1271            if (Configuration.errorOnAutoCreate())
1272              throw new Error("Attempt to auto-create EncounterHospitalizationComponent.reAdmission");
1273            else if (Configuration.doAutoCreate())
1274              this.reAdmission = new CodeableConcept(); // cc
1275          return this.reAdmission;
1276        }
1277
1278        public boolean hasReAdmission() { 
1279          return this.reAdmission != null && !this.reAdmission.isEmpty();
1280        }
1281
1282        /**
1283         * @param value {@link #reAdmission} (Whether this hospitalization is a readmission and why if known.)
1284         */
1285        public EncounterHospitalizationComponent setReAdmission(CodeableConcept value) { 
1286          this.reAdmission = value;
1287          return this;
1288        }
1289
1290        /**
1291         * @return {@link #dietPreference} (Diet preferences reported by the patient.)
1292         */
1293        public List<CodeableConcept> getDietPreference() { 
1294          if (this.dietPreference == null)
1295            this.dietPreference = new ArrayList<CodeableConcept>();
1296          return this.dietPreference;
1297        }
1298
1299        public boolean hasDietPreference() { 
1300          if (this.dietPreference == null)
1301            return false;
1302          for (CodeableConcept item : this.dietPreference)
1303            if (!item.isEmpty())
1304              return true;
1305          return false;
1306        }
1307
1308        /**
1309         * @return {@link #dietPreference} (Diet preferences reported by the patient.)
1310         */
1311    // syntactic sugar
1312        public CodeableConcept addDietPreference() { //3
1313          CodeableConcept t = new CodeableConcept();
1314          if (this.dietPreference == null)
1315            this.dietPreference = new ArrayList<CodeableConcept>();
1316          this.dietPreference.add(t);
1317          return t;
1318        }
1319
1320    // syntactic sugar
1321        public EncounterHospitalizationComponent addDietPreference(CodeableConcept t) { //3
1322          if (t == null)
1323            return this;
1324          if (this.dietPreference == null)
1325            this.dietPreference = new ArrayList<CodeableConcept>();
1326          this.dietPreference.add(t);
1327          return this;
1328        }
1329
1330        /**
1331         * @return {@link #specialCourtesy} (Special courtesies (VIP, board member).)
1332         */
1333        public List<CodeableConcept> getSpecialCourtesy() { 
1334          if (this.specialCourtesy == null)
1335            this.specialCourtesy = new ArrayList<CodeableConcept>();
1336          return this.specialCourtesy;
1337        }
1338
1339        public boolean hasSpecialCourtesy() { 
1340          if (this.specialCourtesy == null)
1341            return false;
1342          for (CodeableConcept item : this.specialCourtesy)
1343            if (!item.isEmpty())
1344              return true;
1345          return false;
1346        }
1347
1348        /**
1349         * @return {@link #specialCourtesy} (Special courtesies (VIP, board member).)
1350         */
1351    // syntactic sugar
1352        public CodeableConcept addSpecialCourtesy() { //3
1353          CodeableConcept t = new CodeableConcept();
1354          if (this.specialCourtesy == null)
1355            this.specialCourtesy = new ArrayList<CodeableConcept>();
1356          this.specialCourtesy.add(t);
1357          return t;
1358        }
1359
1360    // syntactic sugar
1361        public EncounterHospitalizationComponent addSpecialCourtesy(CodeableConcept t) { //3
1362          if (t == null)
1363            return this;
1364          if (this.specialCourtesy == null)
1365            this.specialCourtesy = new ArrayList<CodeableConcept>();
1366          this.specialCourtesy.add(t);
1367          return this;
1368        }
1369
1370        /**
1371         * @return {@link #specialArrangement} (Wheelchair, translator, stretcher, etc.)
1372         */
1373        public List<CodeableConcept> getSpecialArrangement() { 
1374          if (this.specialArrangement == null)
1375            this.specialArrangement = new ArrayList<CodeableConcept>();
1376          return this.specialArrangement;
1377        }
1378
1379        public boolean hasSpecialArrangement() { 
1380          if (this.specialArrangement == null)
1381            return false;
1382          for (CodeableConcept item : this.specialArrangement)
1383            if (!item.isEmpty())
1384              return true;
1385          return false;
1386        }
1387
1388        /**
1389         * @return {@link #specialArrangement} (Wheelchair, translator, stretcher, etc.)
1390         */
1391    // syntactic sugar
1392        public CodeableConcept addSpecialArrangement() { //3
1393          CodeableConcept t = new CodeableConcept();
1394          if (this.specialArrangement == null)
1395            this.specialArrangement = new ArrayList<CodeableConcept>();
1396          this.specialArrangement.add(t);
1397          return t;
1398        }
1399
1400    // syntactic sugar
1401        public EncounterHospitalizationComponent addSpecialArrangement(CodeableConcept t) { //3
1402          if (t == null)
1403            return this;
1404          if (this.specialArrangement == null)
1405            this.specialArrangement = new ArrayList<CodeableConcept>();
1406          this.specialArrangement.add(t);
1407          return this;
1408        }
1409
1410        /**
1411         * @return {@link #destination} (Location to which the patient is discharged.)
1412         */
1413        public Reference getDestination() { 
1414          if (this.destination == null)
1415            if (Configuration.errorOnAutoCreate())
1416              throw new Error("Attempt to auto-create EncounterHospitalizationComponent.destination");
1417            else if (Configuration.doAutoCreate())
1418              this.destination = new Reference(); // cc
1419          return this.destination;
1420        }
1421
1422        public boolean hasDestination() { 
1423          return this.destination != null && !this.destination.isEmpty();
1424        }
1425
1426        /**
1427         * @param value {@link #destination} (Location to which the patient is discharged.)
1428         */
1429        public EncounterHospitalizationComponent setDestination(Reference value) { 
1430          this.destination = value;
1431          return this;
1432        }
1433
1434        /**
1435         * @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 to which the patient is discharged.)
1436         */
1437        public Location getDestinationTarget() { 
1438          if (this.destinationTarget == null)
1439            if (Configuration.errorOnAutoCreate())
1440              throw new Error("Attempt to auto-create EncounterHospitalizationComponent.destination");
1441            else if (Configuration.doAutoCreate())
1442              this.destinationTarget = new Location(); // aa
1443          return this.destinationTarget;
1444        }
1445
1446        /**
1447         * @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 to which the patient is discharged.)
1448         */
1449        public EncounterHospitalizationComponent setDestinationTarget(Location value) { 
1450          this.destinationTarget = value;
1451          return this;
1452        }
1453
1454        /**
1455         * @return {@link #dischargeDisposition} (Category or kind of location after discharge.)
1456         */
1457        public CodeableConcept getDischargeDisposition() { 
1458          if (this.dischargeDisposition == null)
1459            if (Configuration.errorOnAutoCreate())
1460              throw new Error("Attempt to auto-create EncounterHospitalizationComponent.dischargeDisposition");
1461            else if (Configuration.doAutoCreate())
1462              this.dischargeDisposition = new CodeableConcept(); // cc
1463          return this.dischargeDisposition;
1464        }
1465
1466        public boolean hasDischargeDisposition() { 
1467          return this.dischargeDisposition != null && !this.dischargeDisposition.isEmpty();
1468        }
1469
1470        /**
1471         * @param value {@link #dischargeDisposition} (Category or kind of location after discharge.)
1472         */
1473        public EncounterHospitalizationComponent setDischargeDisposition(CodeableConcept value) { 
1474          this.dischargeDisposition = value;
1475          return this;
1476        }
1477
1478        /**
1479         * @return {@link #dischargeDiagnosis} (The final diagnosis given a patient before release from the hospital after all testing, surgery, and workup are complete.)
1480         */
1481        public List<Reference> getDischargeDiagnosis() { 
1482          if (this.dischargeDiagnosis == null)
1483            this.dischargeDiagnosis = new ArrayList<Reference>();
1484          return this.dischargeDiagnosis;
1485        }
1486
1487        public boolean hasDischargeDiagnosis() { 
1488          if (this.dischargeDiagnosis == null)
1489            return false;
1490          for (Reference item : this.dischargeDiagnosis)
1491            if (!item.isEmpty())
1492              return true;
1493          return false;
1494        }
1495
1496        /**
1497         * @return {@link #dischargeDiagnosis} (The final diagnosis given a patient before release from the hospital after all testing, surgery, and workup are complete.)
1498         */
1499    // syntactic sugar
1500        public Reference addDischargeDiagnosis() { //3
1501          Reference t = new Reference();
1502          if (this.dischargeDiagnosis == null)
1503            this.dischargeDiagnosis = new ArrayList<Reference>();
1504          this.dischargeDiagnosis.add(t);
1505          return t;
1506        }
1507
1508    // syntactic sugar
1509        public EncounterHospitalizationComponent addDischargeDiagnosis(Reference t) { //3
1510          if (t == null)
1511            return this;
1512          if (this.dischargeDiagnosis == null)
1513            this.dischargeDiagnosis = new ArrayList<Reference>();
1514          this.dischargeDiagnosis.add(t);
1515          return this;
1516        }
1517
1518        /**
1519         * @return {@link #dischargeDiagnosis} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. The final diagnosis given a patient before release from the hospital after all testing, surgery, and workup are complete.)
1520         */
1521        public List<Condition> getDischargeDiagnosisTarget() { 
1522          if (this.dischargeDiagnosisTarget == null)
1523            this.dischargeDiagnosisTarget = new ArrayList<Condition>();
1524          return this.dischargeDiagnosisTarget;
1525        }
1526
1527    // syntactic sugar
1528        /**
1529         * @return {@link #dischargeDiagnosis} (Add an actual object that is the target of the reference. The reference library doesn't use these, but you can use this to hold the resources if you resolvethemt. The final diagnosis given a patient before release from the hospital after all testing, surgery, and workup are complete.)
1530         */
1531        public Condition addDischargeDiagnosisTarget() { 
1532          Condition r = new Condition();
1533          if (this.dischargeDiagnosisTarget == null)
1534            this.dischargeDiagnosisTarget = new ArrayList<Condition>();
1535          this.dischargeDiagnosisTarget.add(r);
1536          return r;
1537        }
1538
1539        protected void listChildren(List<Property> childrenList) {
1540          super.listChildren(childrenList);
1541          childrenList.add(new Property("preAdmissionIdentifier", "Identifier", "Pre-admission identifier.", 0, java.lang.Integer.MAX_VALUE, preAdmissionIdentifier));
1542          childrenList.add(new Property("origin", "Reference(Location)", "The location from which the patient came before admission.", 0, java.lang.Integer.MAX_VALUE, origin));
1543          childrenList.add(new Property("admitSource", "CodeableConcept", "From where patient was admitted (physician referral, transfer).", 0, java.lang.Integer.MAX_VALUE, admitSource));
1544          childrenList.add(new Property("admittingDiagnosis", "Reference(Condition)", "The admitting diagnosis field is used to record the diagnosis codes as reported by admitting practitioner. This could be different or in addition to the conditions reported as reason-condition(s) for the encounter.", 0, java.lang.Integer.MAX_VALUE, admittingDiagnosis));
1545          childrenList.add(new Property("reAdmission", "CodeableConcept", "Whether this hospitalization is a readmission and why if known.", 0, java.lang.Integer.MAX_VALUE, reAdmission));
1546          childrenList.add(new Property("dietPreference", "CodeableConcept", "Diet preferences reported by the patient.", 0, java.lang.Integer.MAX_VALUE, dietPreference));
1547          childrenList.add(new Property("specialCourtesy", "CodeableConcept", "Special courtesies (VIP, board member).", 0, java.lang.Integer.MAX_VALUE, specialCourtesy));
1548          childrenList.add(new Property("specialArrangement", "CodeableConcept", "Wheelchair, translator, stretcher, etc.", 0, java.lang.Integer.MAX_VALUE, specialArrangement));
1549          childrenList.add(new Property("destination", "Reference(Location)", "Location to which the patient is discharged.", 0, java.lang.Integer.MAX_VALUE, destination));
1550          childrenList.add(new Property("dischargeDisposition", "CodeableConcept", "Category or kind of location after discharge.", 0, java.lang.Integer.MAX_VALUE, dischargeDisposition));
1551          childrenList.add(new Property("dischargeDiagnosis", "Reference(Condition)", "The final diagnosis given a patient before release from the hospital after all testing, surgery, and workup are complete.", 0, java.lang.Integer.MAX_VALUE, dischargeDiagnosis));
1552        }
1553
1554      @Override
1555      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1556        switch (hash) {
1557        case -965394961: /*preAdmissionIdentifier*/ return this.preAdmissionIdentifier == null ? new Base[0] : new Base[] {this.preAdmissionIdentifier}; // Identifier
1558        case -1008619738: /*origin*/ return this.origin == null ? new Base[0] : new Base[] {this.origin}; // Reference
1559        case 538887120: /*admitSource*/ return this.admitSource == null ? new Base[0] : new Base[] {this.admitSource}; // CodeableConcept
1560        case 2048045678: /*admittingDiagnosis*/ return this.admittingDiagnosis == null ? new Base[0] : this.admittingDiagnosis.toArray(new Base[this.admittingDiagnosis.size()]); // Reference
1561        case 669348630: /*reAdmission*/ return this.reAdmission == null ? new Base[0] : new Base[] {this.reAdmission}; // CodeableConcept
1562        case -1360641041: /*dietPreference*/ return this.dietPreference == null ? new Base[0] : this.dietPreference.toArray(new Base[this.dietPreference.size()]); // CodeableConcept
1563        case 1583588345: /*specialCourtesy*/ return this.specialCourtesy == null ? new Base[0] : this.specialCourtesy.toArray(new Base[this.specialCourtesy.size()]); // CodeableConcept
1564        case 47410321: /*specialArrangement*/ return this.specialArrangement == null ? new Base[0] : this.specialArrangement.toArray(new Base[this.specialArrangement.size()]); // CodeableConcept
1565        case -1429847026: /*destination*/ return this.destination == null ? new Base[0] : new Base[] {this.destination}; // Reference
1566        case 528065941: /*dischargeDisposition*/ return this.dischargeDisposition == null ? new Base[0] : new Base[] {this.dischargeDisposition}; // CodeableConcept
1567        case -1985183665: /*dischargeDiagnosis*/ return this.dischargeDiagnosis == null ? new Base[0] : this.dischargeDiagnosis.toArray(new Base[this.dischargeDiagnosis.size()]); // Reference
1568        default: return super.getProperty(hash, name, checkValid);
1569        }
1570
1571      }
1572
1573      @Override
1574      public void setProperty(int hash, String name, Base value) throws FHIRException {
1575        switch (hash) {
1576        case -965394961: // preAdmissionIdentifier
1577          this.preAdmissionIdentifier = castToIdentifier(value); // Identifier
1578          break;
1579        case -1008619738: // origin
1580          this.origin = castToReference(value); // Reference
1581          break;
1582        case 538887120: // admitSource
1583          this.admitSource = castToCodeableConcept(value); // CodeableConcept
1584          break;
1585        case 2048045678: // admittingDiagnosis
1586          this.getAdmittingDiagnosis().add(castToReference(value)); // Reference
1587          break;
1588        case 669348630: // reAdmission
1589          this.reAdmission = castToCodeableConcept(value); // CodeableConcept
1590          break;
1591        case -1360641041: // dietPreference
1592          this.getDietPreference().add(castToCodeableConcept(value)); // CodeableConcept
1593          break;
1594        case 1583588345: // specialCourtesy
1595          this.getSpecialCourtesy().add(castToCodeableConcept(value)); // CodeableConcept
1596          break;
1597        case 47410321: // specialArrangement
1598          this.getSpecialArrangement().add(castToCodeableConcept(value)); // CodeableConcept
1599          break;
1600        case -1429847026: // destination
1601          this.destination = castToReference(value); // Reference
1602          break;
1603        case 528065941: // dischargeDisposition
1604          this.dischargeDisposition = castToCodeableConcept(value); // CodeableConcept
1605          break;
1606        case -1985183665: // dischargeDiagnosis
1607          this.getDischargeDiagnosis().add(castToReference(value)); // Reference
1608          break;
1609        default: super.setProperty(hash, name, value);
1610        }
1611
1612      }
1613
1614      @Override
1615      public void setProperty(String name, Base value) throws FHIRException {
1616        if (name.equals("preAdmissionIdentifier"))
1617          this.preAdmissionIdentifier = castToIdentifier(value); // Identifier
1618        else if (name.equals("origin"))
1619          this.origin = castToReference(value); // Reference
1620        else if (name.equals("admitSource"))
1621          this.admitSource = castToCodeableConcept(value); // CodeableConcept
1622        else if (name.equals("admittingDiagnosis"))
1623          this.getAdmittingDiagnosis().add(castToReference(value));
1624        else if (name.equals("reAdmission"))
1625          this.reAdmission = castToCodeableConcept(value); // CodeableConcept
1626        else if (name.equals("dietPreference"))
1627          this.getDietPreference().add(castToCodeableConcept(value));
1628        else if (name.equals("specialCourtesy"))
1629          this.getSpecialCourtesy().add(castToCodeableConcept(value));
1630        else if (name.equals("specialArrangement"))
1631          this.getSpecialArrangement().add(castToCodeableConcept(value));
1632        else if (name.equals("destination"))
1633          this.destination = castToReference(value); // Reference
1634        else if (name.equals("dischargeDisposition"))
1635          this.dischargeDisposition = castToCodeableConcept(value); // CodeableConcept
1636        else if (name.equals("dischargeDiagnosis"))
1637          this.getDischargeDiagnosis().add(castToReference(value));
1638        else
1639          super.setProperty(name, value);
1640      }
1641
1642      @Override
1643      public Base makeProperty(int hash, String name) throws FHIRException {
1644        switch (hash) {
1645        case -965394961:  return getPreAdmissionIdentifier(); // Identifier
1646        case -1008619738:  return getOrigin(); // Reference
1647        case 538887120:  return getAdmitSource(); // CodeableConcept
1648        case 2048045678:  return addAdmittingDiagnosis(); // Reference
1649        case 669348630:  return getReAdmission(); // CodeableConcept
1650        case -1360641041:  return addDietPreference(); // CodeableConcept
1651        case 1583588345:  return addSpecialCourtesy(); // CodeableConcept
1652        case 47410321:  return addSpecialArrangement(); // CodeableConcept
1653        case -1429847026:  return getDestination(); // Reference
1654        case 528065941:  return getDischargeDisposition(); // CodeableConcept
1655        case -1985183665:  return addDischargeDiagnosis(); // Reference
1656        default: return super.makeProperty(hash, name);
1657        }
1658
1659      }
1660
1661      @Override
1662      public Base addChild(String name) throws FHIRException {
1663        if (name.equals("preAdmissionIdentifier")) {
1664          this.preAdmissionIdentifier = new Identifier();
1665          return this.preAdmissionIdentifier;
1666        }
1667        else if (name.equals("origin")) {
1668          this.origin = new Reference();
1669          return this.origin;
1670        }
1671        else if (name.equals("admitSource")) {
1672          this.admitSource = new CodeableConcept();
1673          return this.admitSource;
1674        }
1675        else if (name.equals("admittingDiagnosis")) {
1676          return addAdmittingDiagnosis();
1677        }
1678        else if (name.equals("reAdmission")) {
1679          this.reAdmission = new CodeableConcept();
1680          return this.reAdmission;
1681        }
1682        else if (name.equals("dietPreference")) {
1683          return addDietPreference();
1684        }
1685        else if (name.equals("specialCourtesy")) {
1686          return addSpecialCourtesy();
1687        }
1688        else if (name.equals("specialArrangement")) {
1689          return addSpecialArrangement();
1690        }
1691        else if (name.equals("destination")) {
1692          this.destination = new Reference();
1693          return this.destination;
1694        }
1695        else if (name.equals("dischargeDisposition")) {
1696          this.dischargeDisposition = new CodeableConcept();
1697          return this.dischargeDisposition;
1698        }
1699        else if (name.equals("dischargeDiagnosis")) {
1700          return addDischargeDiagnosis();
1701        }
1702        else
1703          return super.addChild(name);
1704      }
1705
1706      public EncounterHospitalizationComponent copy() {
1707        EncounterHospitalizationComponent dst = new EncounterHospitalizationComponent();
1708        copyValues(dst);
1709        dst.preAdmissionIdentifier = preAdmissionIdentifier == null ? null : preAdmissionIdentifier.copy();
1710        dst.origin = origin == null ? null : origin.copy();
1711        dst.admitSource = admitSource == null ? null : admitSource.copy();
1712        if (admittingDiagnosis != null) {
1713          dst.admittingDiagnosis = new ArrayList<Reference>();
1714          for (Reference i : admittingDiagnosis)
1715            dst.admittingDiagnosis.add(i.copy());
1716        };
1717        dst.reAdmission = reAdmission == null ? null : reAdmission.copy();
1718        if (dietPreference != null) {
1719          dst.dietPreference = new ArrayList<CodeableConcept>();
1720          for (CodeableConcept i : dietPreference)
1721            dst.dietPreference.add(i.copy());
1722        };
1723        if (specialCourtesy != null) {
1724          dst.specialCourtesy = new ArrayList<CodeableConcept>();
1725          for (CodeableConcept i : specialCourtesy)
1726            dst.specialCourtesy.add(i.copy());
1727        };
1728        if (specialArrangement != null) {
1729          dst.specialArrangement = new ArrayList<CodeableConcept>();
1730          for (CodeableConcept i : specialArrangement)
1731            dst.specialArrangement.add(i.copy());
1732        };
1733        dst.destination = destination == null ? null : destination.copy();
1734        dst.dischargeDisposition = dischargeDisposition == null ? null : dischargeDisposition.copy();
1735        if (dischargeDiagnosis != null) {
1736          dst.dischargeDiagnosis = new ArrayList<Reference>();
1737          for (Reference i : dischargeDiagnosis)
1738            dst.dischargeDiagnosis.add(i.copy());
1739        };
1740        return dst;
1741      }
1742
1743      @Override
1744      public boolean equalsDeep(Base other) {
1745        if (!super.equalsDeep(other))
1746          return false;
1747        if (!(other instanceof EncounterHospitalizationComponent))
1748          return false;
1749        EncounterHospitalizationComponent o = (EncounterHospitalizationComponent) other;
1750        return compareDeep(preAdmissionIdentifier, o.preAdmissionIdentifier, true) && compareDeep(origin, o.origin, true)
1751           && compareDeep(admitSource, o.admitSource, true) && compareDeep(admittingDiagnosis, o.admittingDiagnosis, true)
1752           && compareDeep(reAdmission, o.reAdmission, true) && compareDeep(dietPreference, o.dietPreference, true)
1753           && compareDeep(specialCourtesy, o.specialCourtesy, true) && compareDeep(specialArrangement, o.specialArrangement, true)
1754           && compareDeep(destination, o.destination, true) && compareDeep(dischargeDisposition, o.dischargeDisposition, true)
1755           && compareDeep(dischargeDiagnosis, o.dischargeDiagnosis, true);
1756      }
1757
1758      @Override
1759      public boolean equalsShallow(Base other) {
1760        if (!super.equalsShallow(other))
1761          return false;
1762        if (!(other instanceof EncounterHospitalizationComponent))
1763          return false;
1764        EncounterHospitalizationComponent o = (EncounterHospitalizationComponent) other;
1765        return true;
1766      }
1767
1768      public boolean isEmpty() {
1769        return super.isEmpty() && (preAdmissionIdentifier == null || preAdmissionIdentifier.isEmpty())
1770           && (origin == null || origin.isEmpty()) && (admitSource == null || admitSource.isEmpty())
1771           && (admittingDiagnosis == null || admittingDiagnosis.isEmpty()) && (reAdmission == null || reAdmission.isEmpty())
1772           && (dietPreference == null || dietPreference.isEmpty()) && (specialCourtesy == null || specialCourtesy.isEmpty())
1773           && (specialArrangement == null || specialArrangement.isEmpty()) && (destination == null || destination.isEmpty())
1774           && (dischargeDisposition == null || dischargeDisposition.isEmpty()) && (dischargeDiagnosis == null || dischargeDiagnosis.isEmpty())
1775          ;
1776      }
1777
1778  public String fhirType() {
1779    return "Encounter.hospitalization";
1780
1781  }
1782
1783  }
1784
1785    @Block()
1786    public static class EncounterLocationComponent extends BackboneElement implements IBaseBackboneElement {
1787        /**
1788         * The location where the encounter takes place.
1789         */
1790        @Child(name = "location", type = {Location.class}, order=1, min=1, max=1, modifier=false, summary=false)
1791        @Description(shortDefinition="Location the encounter takes place", formalDefinition="The location where the encounter takes place." )
1792        protected Reference location;
1793
1794        /**
1795         * The actual object that is the target of the reference (The location where the encounter takes place.)
1796         */
1797        protected Location locationTarget;
1798
1799        /**
1800         * The status of the participants' presence at the specified location during the period specified. If the participant is is no longer at the location, then the period will have an end date/time.
1801         */
1802        @Child(name = "status", type = {CodeType.class}, order=2, min=0, max=1, modifier=false, summary=false)
1803        @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 is no longer at the location, then the period will have an end date/time." )
1804        protected Enumeration<EncounterLocationStatus> status;
1805
1806        /**
1807         * Time period during which the patient was present at the location.
1808         */
1809        @Child(name = "period", type = {Period.class}, order=3, min=0, max=1, modifier=false, summary=false)
1810        @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." )
1811        protected Period period;
1812
1813        private static final long serialVersionUID = -322984880L;
1814
1815    /**
1816     * Constructor
1817     */
1818      public EncounterLocationComponent() {
1819        super();
1820      }
1821
1822    /**
1823     * Constructor
1824     */
1825      public EncounterLocationComponent(Reference location) {
1826        super();
1827        this.location = location;
1828      }
1829
1830        /**
1831         * @return {@link #location} (The location where the encounter takes place.)
1832         */
1833        public Reference getLocation() { 
1834          if (this.location == null)
1835            if (Configuration.errorOnAutoCreate())
1836              throw new Error("Attempt to auto-create EncounterLocationComponent.location");
1837            else if (Configuration.doAutoCreate())
1838              this.location = new Reference(); // cc
1839          return this.location;
1840        }
1841
1842        public boolean hasLocation() { 
1843          return this.location != null && !this.location.isEmpty();
1844        }
1845
1846        /**
1847         * @param value {@link #location} (The location where the encounter takes place.)
1848         */
1849        public EncounterLocationComponent setLocation(Reference value) { 
1850          this.location = value;
1851          return this;
1852        }
1853
1854        /**
1855         * @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.)
1856         */
1857        public Location getLocationTarget() { 
1858          if (this.locationTarget == null)
1859            if (Configuration.errorOnAutoCreate())
1860              throw new Error("Attempt to auto-create EncounterLocationComponent.location");
1861            else if (Configuration.doAutoCreate())
1862              this.locationTarget = new Location(); // aa
1863          return this.locationTarget;
1864        }
1865
1866        /**
1867         * @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.)
1868         */
1869        public EncounterLocationComponent setLocationTarget(Location value) { 
1870          this.locationTarget = value;
1871          return this;
1872        }
1873
1874        /**
1875         * @return {@link #status} (The status of the participants' presence at the specified location during the period specified. If the participant is 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
1876         */
1877        public Enumeration<EncounterLocationStatus> getStatusElement() { 
1878          if (this.status == null)
1879            if (Configuration.errorOnAutoCreate())
1880              throw new Error("Attempt to auto-create EncounterLocationComponent.status");
1881            else if (Configuration.doAutoCreate())
1882              this.status = new Enumeration<EncounterLocationStatus>(new EncounterLocationStatusEnumFactory()); // bb
1883          return this.status;
1884        }
1885
1886        public boolean hasStatusElement() { 
1887          return this.status != null && !this.status.isEmpty();
1888        }
1889
1890        public boolean hasStatus() { 
1891          return this.status != null && !this.status.isEmpty();
1892        }
1893
1894        /**
1895         * @param value {@link #status} (The status of the participants' presence at the specified location during the period specified. If the participant is 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
1896         */
1897        public EncounterLocationComponent setStatusElement(Enumeration<EncounterLocationStatus> value) { 
1898          this.status = value;
1899          return this;
1900        }
1901
1902        /**
1903         * @return The status of the participants' presence at the specified location during the period specified. If the participant is is no longer at the location, then the period will have an end date/time.
1904         */
1905        public EncounterLocationStatus getStatus() { 
1906          return this.status == null ? null : this.status.getValue();
1907        }
1908
1909        /**
1910         * @param value The status of the participants' presence at the specified location during the period specified. If the participant is is no longer at the location, then the period will have an end date/time.
1911         */
1912        public EncounterLocationComponent setStatus(EncounterLocationStatus value) { 
1913          if (value == null)
1914            this.status = null;
1915          else {
1916            if (this.status == null)
1917              this.status = new Enumeration<EncounterLocationStatus>(new EncounterLocationStatusEnumFactory());
1918            this.status.setValue(value);
1919          }
1920          return this;
1921        }
1922
1923        /**
1924         * @return {@link #period} (Time period during which the patient was present at the location.)
1925         */
1926        public Period getPeriod() { 
1927          if (this.period == null)
1928            if (Configuration.errorOnAutoCreate())
1929              throw new Error("Attempt to auto-create EncounterLocationComponent.period");
1930            else if (Configuration.doAutoCreate())
1931              this.period = new Period(); // cc
1932          return this.period;
1933        }
1934
1935        public boolean hasPeriod() { 
1936          return this.period != null && !this.period.isEmpty();
1937        }
1938
1939        /**
1940         * @param value {@link #period} (Time period during which the patient was present at the location.)
1941         */
1942        public EncounterLocationComponent setPeriod(Period value) { 
1943          this.period = value;
1944          return this;
1945        }
1946
1947        protected void listChildren(List<Property> childrenList) {
1948          super.listChildren(childrenList);
1949          childrenList.add(new Property("location", "Reference(Location)", "The location where the encounter takes place.", 0, java.lang.Integer.MAX_VALUE, location));
1950          childrenList.add(new Property("status", "code", "The status of the participants' presence at the specified location during the period specified. If the participant is is no longer at the location, then the period will have an end date/time.", 0, java.lang.Integer.MAX_VALUE, status));
1951          childrenList.add(new Property("period", "Period", "Time period during which the patient was present at the location.", 0, java.lang.Integer.MAX_VALUE, period));
1952        }
1953
1954      @Override
1955      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1956        switch (hash) {
1957        case 1901043637: /*location*/ return this.location == null ? new Base[0] : new Base[] {this.location}; // Reference
1958        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<EncounterLocationStatus>
1959        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
1960        default: return super.getProperty(hash, name, checkValid);
1961        }
1962
1963      }
1964
1965      @Override
1966      public void setProperty(int hash, String name, Base value) throws FHIRException {
1967        switch (hash) {
1968        case 1901043637: // location
1969          this.location = castToReference(value); // Reference
1970          break;
1971        case -892481550: // status
1972          this.status = new EncounterLocationStatusEnumFactory().fromType(value); // Enumeration<EncounterLocationStatus>
1973          break;
1974        case -991726143: // period
1975          this.period = castToPeriod(value); // Period
1976          break;
1977        default: super.setProperty(hash, name, value);
1978        }
1979
1980      }
1981
1982      @Override
1983      public void setProperty(String name, Base value) throws FHIRException {
1984        if (name.equals("location"))
1985          this.location = castToReference(value); // Reference
1986        else if (name.equals("status"))
1987          this.status = new EncounterLocationStatusEnumFactory().fromType(value); // Enumeration<EncounterLocationStatus>
1988        else if (name.equals("period"))
1989          this.period = castToPeriod(value); // Period
1990        else
1991          super.setProperty(name, value);
1992      }
1993
1994      @Override
1995      public Base makeProperty(int hash, String name) throws FHIRException {
1996        switch (hash) {
1997        case 1901043637:  return getLocation(); // Reference
1998        case -892481550: throw new FHIRException("Cannot make property status as it is not a complex type"); // Enumeration<EncounterLocationStatus>
1999        case -991726143:  return getPeriod(); // Period
2000        default: return super.makeProperty(hash, name);
2001        }
2002
2003      }
2004
2005      @Override
2006      public Base addChild(String name) throws FHIRException {
2007        if (name.equals("location")) {
2008          this.location = new Reference();
2009          return this.location;
2010        }
2011        else if (name.equals("status")) {
2012          throw new FHIRException("Cannot call addChild on a primitive type Encounter.status");
2013        }
2014        else if (name.equals("period")) {
2015          this.period = new Period();
2016          return this.period;
2017        }
2018        else
2019          return super.addChild(name);
2020      }
2021
2022      public EncounterLocationComponent copy() {
2023        EncounterLocationComponent dst = new EncounterLocationComponent();
2024        copyValues(dst);
2025        dst.location = location == null ? null : location.copy();
2026        dst.status = status == null ? null : status.copy();
2027        dst.period = period == null ? null : period.copy();
2028        return dst;
2029      }
2030
2031      @Override
2032      public boolean equalsDeep(Base other) {
2033        if (!super.equalsDeep(other))
2034          return false;
2035        if (!(other instanceof EncounterLocationComponent))
2036          return false;
2037        EncounterLocationComponent o = (EncounterLocationComponent) other;
2038        return compareDeep(location, o.location, true) && compareDeep(status, o.status, true) && compareDeep(period, o.period, true)
2039          ;
2040      }
2041
2042      @Override
2043      public boolean equalsShallow(Base other) {
2044        if (!super.equalsShallow(other))
2045          return false;
2046        if (!(other instanceof EncounterLocationComponent))
2047          return false;
2048        EncounterLocationComponent o = (EncounterLocationComponent) other;
2049        return compareValues(status, o.status, true);
2050      }
2051
2052      public boolean isEmpty() {
2053        return super.isEmpty() && (location == null || location.isEmpty()) && (status == null || status.isEmpty())
2054           && (period == null || period.isEmpty());
2055      }
2056
2057  public String fhirType() {
2058    return "Encounter.location";
2059
2060  }
2061
2062  }
2063
2064    /**
2065     * Identifier(s) by which this encounter is known.
2066     */
2067    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2068    @Description(shortDefinition="Identifier(s) by which this encounter is known", formalDefinition="Identifier(s) by which this encounter is known." )
2069    protected List<Identifier> identifier;
2070
2071    /**
2072     * planned | arrived | in-progress | onleave | finished | cancelled.
2073     */
2074    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
2075    @Description(shortDefinition="planned | arrived | in-progress | onleave | finished | cancelled", formalDefinition="planned | arrived | in-progress | onleave | finished | cancelled." )
2076    protected Enumeration<EncounterState> status;
2077
2078    /**
2079     * 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.
2080     */
2081    @Child(name = "statusHistory", type = {}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2082    @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." )
2083    protected List<EncounterStatusHistoryComponent> statusHistory;
2084
2085    /**
2086     * inpatient | outpatient | ambulatory | emergency +.
2087     */
2088    @Child(name = "class", type = {CodeType.class}, order=3, min=0, max=1, modifier=false, summary=true)
2089    @Description(shortDefinition="inpatient | outpatient | ambulatory | emergency +", formalDefinition="inpatient | outpatient | ambulatory | emergency +." )
2090    protected Enumeration<EncounterClass> class_;
2091
2092    /**
2093     * Specific type of encounter (e.g. e-mail consultation, surgical day-care, skilled nursing, rehabilitation).
2094     */
2095    @Child(name = "type", type = {CodeableConcept.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2096    @Description(shortDefinition="Specific type of encounter", formalDefinition="Specific type of encounter (e.g. e-mail consultation, surgical day-care, skilled nursing, rehabilitation)." )
2097    protected List<CodeableConcept> type;
2098
2099    /**
2100     * Indicates the urgency of the encounter.
2101     */
2102    @Child(name = "priority", type = {CodeableConcept.class}, order=5, min=0, max=1, modifier=false, summary=false)
2103    @Description(shortDefinition="Indicates the urgency of the encounter", formalDefinition="Indicates the urgency of the encounter." )
2104    protected CodeableConcept priority;
2105
2106    /**
2107     * The patient present at the encounter.
2108     */
2109    @Child(name = "patient", type = {Patient.class}, order=6, min=0, max=1, modifier=false, summary=true)
2110    @Description(shortDefinition="The patient present at the encounter", formalDefinition="The patient present at the encounter." )
2111    protected Reference patient;
2112
2113    /**
2114     * The actual object that is the target of the reference (The patient present at the encounter.)
2115     */
2116    protected Patient patientTarget;
2117
2118    /**
2119     * 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).
2120     */
2121    @Child(name = "episodeOfCare", type = {EpisodeOfCare.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2122    @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)." )
2123    protected List<Reference> episodeOfCare;
2124    /**
2125     * 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).)
2126     */
2127    protected List<EpisodeOfCare> episodeOfCareTarget;
2128
2129
2130    /**
2131     * The referral request this encounter satisfies (incoming referral).
2132     */
2133    @Child(name = "incomingReferral", type = {ReferralRequest.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2134    @Description(shortDefinition="The ReferralRequest that initiated this encounter", formalDefinition="The referral request this encounter satisfies (incoming referral)." )
2135    protected List<Reference> incomingReferral;
2136    /**
2137     * The actual objects that are the target of the reference (The referral request this encounter satisfies (incoming referral).)
2138     */
2139    protected List<ReferralRequest> incomingReferralTarget;
2140
2141
2142    /**
2143     * The list of people responsible for providing the service.
2144     */
2145    @Child(name = "participant", type = {}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2146    @Description(shortDefinition="List of participants involved in the encounter", formalDefinition="The list of people responsible for providing the service." )
2147    protected List<EncounterParticipantComponent> participant;
2148
2149    /**
2150     * The appointment that scheduled this encounter.
2151     */
2152    @Child(name = "appointment", type = {Appointment.class}, order=10, min=0, max=1, modifier=false, summary=true)
2153    @Description(shortDefinition="The appointment that scheduled this encounter", formalDefinition="The appointment that scheduled this encounter." )
2154    protected Reference appointment;
2155
2156    /**
2157     * The actual object that is the target of the reference (The appointment that scheduled this encounter.)
2158     */
2159    protected Appointment appointmentTarget;
2160
2161    /**
2162     * The start and end time of the encounter.
2163     */
2164    @Child(name = "period", type = {Period.class}, order=11, min=0, max=1, modifier=false, summary=false)
2165    @Description(shortDefinition="The start and end time of the encounter", formalDefinition="The start and end time of the encounter." )
2166    protected Period period;
2167
2168    /**
2169     * Quantity of time the encounter lasted. This excludes the time during leaves of absence.
2170     */
2171    @Child(name = "length", type = {Duration.class}, order=12, min=0, max=1, modifier=false, summary=false)
2172    @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." )
2173    protected Duration length;
2174
2175    /**
2176     * Reason the encounter takes place, expressed as a code. For admissions, this can be used for a coded admission diagnosis.
2177     */
2178    @Child(name = "reason", type = {CodeableConcept.class}, order=13, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2179    @Description(shortDefinition="Reason the encounter takes place (code)", formalDefinition="Reason the encounter takes place, expressed as a code. For admissions, this can be used for a coded admission diagnosis." )
2180    protected List<CodeableConcept> reason;
2181
2182    /**
2183     * 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.
2184     */
2185    @Child(name = "indication", type = {Condition.class, Procedure.class}, order=14, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2186    @Description(shortDefinition="Reason the encounter takes place (resource)", 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." )
2187    protected List<Reference> indication;
2188    /**
2189     * The actual objects that are 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.)
2190     */
2191    protected List<Resource> indicationTarget;
2192
2193
2194    /**
2195     * Details about the admission to a healthcare service.
2196     */
2197    @Child(name = "hospitalization", type = {}, order=15, min=0, max=1, modifier=false, summary=false)
2198    @Description(shortDefinition="Details about the admission to a healthcare service", formalDefinition="Details about the admission to a healthcare service." )
2199    protected EncounterHospitalizationComponent hospitalization;
2200
2201    /**
2202     * List of locations where  the patient has been during this encounter.
2203     */
2204    @Child(name = "location", type = {}, order=16, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2205    @Description(shortDefinition="List of locations where the patient has been", formalDefinition="List of locations where  the patient has been during this encounter." )
2206    protected List<EncounterLocationComponent> location;
2207
2208    /**
2209     * An organization that is in charge of maintaining the information of this Encounter (e.g. who maintains the report or the master service catalog item, etc.). This MAY be the same as the organization on the Patient record, however it could be different. This MAY not be not the Service Delivery Location's Organization.
2210     */
2211    @Child(name = "serviceProvider", type = {Organization.class}, order=17, min=0, max=1, modifier=false, summary=false)
2212    @Description(shortDefinition="The custodian organization of this Encounter record", formalDefinition="An organization that is in charge of maintaining the information of this Encounter (e.g. who maintains the report or the master service catalog item, etc.). This MAY be the same as the organization on the Patient record, however it could be different. This MAY not be not the Service Delivery Location's Organization." )
2213    protected Reference serviceProvider;
2214
2215    /**
2216     * The actual object that is the target of the reference (An organization that is in charge of maintaining the information of this Encounter (e.g. who maintains the report or the master service catalog item, etc.). This MAY be the same as the organization on the Patient record, however it could be different. This MAY not be not the Service Delivery Location's Organization.)
2217     */
2218    protected Organization serviceProviderTarget;
2219
2220    /**
2221     * Another Encounter of which this encounter is a part of (administratively or in time).
2222     */
2223    @Child(name = "partOf", type = {Encounter.class}, order=18, min=0, max=1, modifier=false, summary=false)
2224    @Description(shortDefinition="Another Encounter this encounter is part of", formalDefinition="Another Encounter of which this encounter is a part of (administratively or in time)." )
2225    protected Reference partOf;
2226
2227    /**
2228     * The actual object that is the target of the reference (Another Encounter of which this encounter is a part of (administratively or in time).)
2229     */
2230    protected Encounter partOfTarget;
2231
2232    private static final long serialVersionUID = 929562300L;
2233
2234  /**
2235   * Constructor
2236   */
2237    public Encounter() {
2238      super();
2239    }
2240
2241  /**
2242   * Constructor
2243   */
2244    public Encounter(Enumeration<EncounterState> status) {
2245      super();
2246      this.status = status;
2247    }
2248
2249    /**
2250     * @return {@link #identifier} (Identifier(s) by which this encounter is known.)
2251     */
2252    public List<Identifier> getIdentifier() { 
2253      if (this.identifier == null)
2254        this.identifier = new ArrayList<Identifier>();
2255      return this.identifier;
2256    }
2257
2258    public boolean hasIdentifier() { 
2259      if (this.identifier == null)
2260        return false;
2261      for (Identifier item : this.identifier)
2262        if (!item.isEmpty())
2263          return true;
2264      return false;
2265    }
2266
2267    /**
2268     * @return {@link #identifier} (Identifier(s) by which this encounter is known.)
2269     */
2270    // syntactic sugar
2271    public Identifier addIdentifier() { //3
2272      Identifier t = new Identifier();
2273      if (this.identifier == null)
2274        this.identifier = new ArrayList<Identifier>();
2275      this.identifier.add(t);
2276      return t;
2277    }
2278
2279    // syntactic sugar
2280    public Encounter addIdentifier(Identifier t) { //3
2281      if (t == null)
2282        return this;
2283      if (this.identifier == null)
2284        this.identifier = new ArrayList<Identifier>();
2285      this.identifier.add(t);
2286      return this;
2287    }
2288
2289    /**
2290     * @return {@link #status} (planned | arrived | in-progress | onleave | finished | cancelled.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
2291     */
2292    public Enumeration<EncounterState> getStatusElement() { 
2293      if (this.status == null)
2294        if (Configuration.errorOnAutoCreate())
2295          throw new Error("Attempt to auto-create Encounter.status");
2296        else if (Configuration.doAutoCreate())
2297          this.status = new Enumeration<EncounterState>(new EncounterStateEnumFactory()); // bb
2298      return this.status;
2299    }
2300
2301    public boolean hasStatusElement() { 
2302      return this.status != null && !this.status.isEmpty();
2303    }
2304
2305    public boolean hasStatus() { 
2306      return this.status != null && !this.status.isEmpty();
2307    }
2308
2309    /**
2310     * @param value {@link #status} (planned | arrived | in-progress | onleave | finished | cancelled.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
2311     */
2312    public Encounter setStatusElement(Enumeration<EncounterState> value) { 
2313      this.status = value;
2314      return this;
2315    }
2316
2317    /**
2318     * @return planned | arrived | in-progress | onleave | finished | cancelled.
2319     */
2320    public EncounterState getStatus() { 
2321      return this.status == null ? null : this.status.getValue();
2322    }
2323
2324    /**
2325     * @param value planned | arrived | in-progress | onleave | finished | cancelled.
2326     */
2327    public Encounter setStatus(EncounterState value) { 
2328        if (this.status == null)
2329          this.status = new Enumeration<EncounterState>(new EncounterStateEnumFactory());
2330        this.status.setValue(value);
2331      return this;
2332    }
2333
2334    /**
2335     * @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.)
2336     */
2337    public List<EncounterStatusHistoryComponent> getStatusHistory() { 
2338      if (this.statusHistory == null)
2339        this.statusHistory = new ArrayList<EncounterStatusHistoryComponent>();
2340      return this.statusHistory;
2341    }
2342
2343    public boolean hasStatusHistory() { 
2344      if (this.statusHistory == null)
2345        return false;
2346      for (EncounterStatusHistoryComponent item : this.statusHistory)
2347        if (!item.isEmpty())
2348          return true;
2349      return false;
2350    }
2351
2352    /**
2353     * @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.)
2354     */
2355    // syntactic sugar
2356    public EncounterStatusHistoryComponent addStatusHistory() { //3
2357      EncounterStatusHistoryComponent t = new EncounterStatusHistoryComponent();
2358      if (this.statusHistory == null)
2359        this.statusHistory = new ArrayList<EncounterStatusHistoryComponent>();
2360      this.statusHistory.add(t);
2361      return t;
2362    }
2363
2364    // syntactic sugar
2365    public Encounter addStatusHistory(EncounterStatusHistoryComponent t) { //3
2366      if (t == null)
2367        return this;
2368      if (this.statusHistory == null)
2369        this.statusHistory = new ArrayList<EncounterStatusHistoryComponent>();
2370      this.statusHistory.add(t);
2371      return this;
2372    }
2373
2374    /**
2375     * @return {@link #class_} (inpatient | outpatient | ambulatory | emergency +.). This is the underlying object with id, value and extensions. The accessor "getClass_" gives direct access to the value
2376     */
2377    public Enumeration<EncounterClass> getClass_Element() { 
2378      if (this.class_ == null)
2379        if (Configuration.errorOnAutoCreate())
2380          throw new Error("Attempt to auto-create Encounter.class_");
2381        else if (Configuration.doAutoCreate())
2382          this.class_ = new Enumeration<EncounterClass>(new EncounterClassEnumFactory()); // bb
2383      return this.class_;
2384    }
2385
2386    public boolean hasClass_Element() { 
2387      return this.class_ != null && !this.class_.isEmpty();
2388    }
2389
2390    public boolean hasClass_() { 
2391      return this.class_ != null && !this.class_.isEmpty();
2392    }
2393
2394    /**
2395     * @param value {@link #class_} (inpatient | outpatient | ambulatory | emergency +.). This is the underlying object with id, value and extensions. The accessor "getClass_" gives direct access to the value
2396     */
2397    public Encounter setClass_Element(Enumeration<EncounterClass> value) { 
2398      this.class_ = value;
2399      return this;
2400    }
2401
2402    /**
2403     * @return inpatient | outpatient | ambulatory | emergency +.
2404     */
2405    public EncounterClass getClass_() { 
2406      return this.class_ == null ? null : this.class_.getValue();
2407    }
2408
2409    /**
2410     * @param value inpatient | outpatient | ambulatory | emergency +.
2411     */
2412    public Encounter setClass_(EncounterClass value) { 
2413      if (value == null)
2414        this.class_ = null;
2415      else {
2416        if (this.class_ == null)
2417          this.class_ = new Enumeration<EncounterClass>(new EncounterClassEnumFactory());
2418        this.class_.setValue(value);
2419      }
2420      return this;
2421    }
2422
2423    /**
2424     * @return {@link #type} (Specific type of encounter (e.g. e-mail consultation, surgical day-care, skilled nursing, rehabilitation).)
2425     */
2426    public List<CodeableConcept> getType() { 
2427      if (this.type == null)
2428        this.type = new ArrayList<CodeableConcept>();
2429      return this.type;
2430    }
2431
2432    public boolean hasType() { 
2433      if (this.type == null)
2434        return false;
2435      for (CodeableConcept item : this.type)
2436        if (!item.isEmpty())
2437          return true;
2438      return false;
2439    }
2440
2441    /**
2442     * @return {@link #type} (Specific type of encounter (e.g. e-mail consultation, surgical day-care, skilled nursing, rehabilitation).)
2443     */
2444    // syntactic sugar
2445    public CodeableConcept addType() { //3
2446      CodeableConcept t = new CodeableConcept();
2447      if (this.type == null)
2448        this.type = new ArrayList<CodeableConcept>();
2449      this.type.add(t);
2450      return t;
2451    }
2452
2453    // syntactic sugar
2454    public Encounter addType(CodeableConcept t) { //3
2455      if (t == null)
2456        return this;
2457      if (this.type == null)
2458        this.type = new ArrayList<CodeableConcept>();
2459      this.type.add(t);
2460      return this;
2461    }
2462
2463    /**
2464     * @return {@link #priority} (Indicates the urgency of the encounter.)
2465     */
2466    public CodeableConcept getPriority() { 
2467      if (this.priority == null)
2468        if (Configuration.errorOnAutoCreate())
2469          throw new Error("Attempt to auto-create Encounter.priority");
2470        else if (Configuration.doAutoCreate())
2471          this.priority = new CodeableConcept(); // cc
2472      return this.priority;
2473    }
2474
2475    public boolean hasPriority() { 
2476      return this.priority != null && !this.priority.isEmpty();
2477    }
2478
2479    /**
2480     * @param value {@link #priority} (Indicates the urgency of the encounter.)
2481     */
2482    public Encounter setPriority(CodeableConcept value) { 
2483      this.priority = value;
2484      return this;
2485    }
2486
2487    /**
2488     * @return {@link #patient} (The patient present at the encounter.)
2489     */
2490    public Reference getPatient() { 
2491      if (this.patient == null)
2492        if (Configuration.errorOnAutoCreate())
2493          throw new Error("Attempt to auto-create Encounter.patient");
2494        else if (Configuration.doAutoCreate())
2495          this.patient = new Reference(); // cc
2496      return this.patient;
2497    }
2498
2499    public boolean hasPatient() { 
2500      return this.patient != null && !this.patient.isEmpty();
2501    }
2502
2503    /**
2504     * @param value {@link #patient} (The patient present at the encounter.)
2505     */
2506    public Encounter setPatient(Reference value) { 
2507      this.patient = value;
2508      return this;
2509    }
2510
2511    /**
2512     * @return {@link #patient} 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 present at the encounter.)
2513     */
2514    public Patient getPatientTarget() { 
2515      if (this.patientTarget == null)
2516        if (Configuration.errorOnAutoCreate())
2517          throw new Error("Attempt to auto-create Encounter.patient");
2518        else if (Configuration.doAutoCreate())
2519          this.patientTarget = new Patient(); // aa
2520      return this.patientTarget;
2521    }
2522
2523    /**
2524     * @param value {@link #patient} 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 present at the encounter.)
2525     */
2526    public Encounter setPatientTarget(Patient value) { 
2527      this.patientTarget = value;
2528      return this;
2529    }
2530
2531    /**
2532     * @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).)
2533     */
2534    public List<Reference> getEpisodeOfCare() { 
2535      if (this.episodeOfCare == null)
2536        this.episodeOfCare = new ArrayList<Reference>();
2537      return this.episodeOfCare;
2538    }
2539
2540    public boolean hasEpisodeOfCare() { 
2541      if (this.episodeOfCare == null)
2542        return false;
2543      for (Reference item : this.episodeOfCare)
2544        if (!item.isEmpty())
2545          return true;
2546      return false;
2547    }
2548
2549    /**
2550     * @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).)
2551     */
2552    // syntactic sugar
2553    public Reference addEpisodeOfCare() { //3
2554      Reference t = new Reference();
2555      if (this.episodeOfCare == null)
2556        this.episodeOfCare = new ArrayList<Reference>();
2557      this.episodeOfCare.add(t);
2558      return t;
2559    }
2560
2561    // syntactic sugar
2562    public Encounter addEpisodeOfCare(Reference t) { //3
2563      if (t == null)
2564        return this;
2565      if (this.episodeOfCare == null)
2566        this.episodeOfCare = new ArrayList<Reference>();
2567      this.episodeOfCare.add(t);
2568      return this;
2569    }
2570
2571    /**
2572     * @return {@link #episodeOfCare} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. 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).)
2573     */
2574    public List<EpisodeOfCare> getEpisodeOfCareTarget() { 
2575      if (this.episodeOfCareTarget == null)
2576        this.episodeOfCareTarget = new ArrayList<EpisodeOfCare>();
2577      return this.episodeOfCareTarget;
2578    }
2579
2580    // syntactic sugar
2581    /**
2582     * @return {@link #episodeOfCare} (Add an actual object that is the target of the reference. The reference library doesn't use these, but you can use this to hold the resources if you resolvethemt. 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).)
2583     */
2584    public EpisodeOfCare addEpisodeOfCareTarget() { 
2585      EpisodeOfCare r = new EpisodeOfCare();
2586      if (this.episodeOfCareTarget == null)
2587        this.episodeOfCareTarget = new ArrayList<EpisodeOfCare>();
2588      this.episodeOfCareTarget.add(r);
2589      return r;
2590    }
2591
2592    /**
2593     * @return {@link #incomingReferral} (The referral request this encounter satisfies (incoming referral).)
2594     */
2595    public List<Reference> getIncomingReferral() { 
2596      if (this.incomingReferral == null)
2597        this.incomingReferral = new ArrayList<Reference>();
2598      return this.incomingReferral;
2599    }
2600
2601    public boolean hasIncomingReferral() { 
2602      if (this.incomingReferral == null)
2603        return false;
2604      for (Reference item : this.incomingReferral)
2605        if (!item.isEmpty())
2606          return true;
2607      return false;
2608    }
2609
2610    /**
2611     * @return {@link #incomingReferral} (The referral request this encounter satisfies (incoming referral).)
2612     */
2613    // syntactic sugar
2614    public Reference addIncomingReferral() { //3
2615      Reference t = new Reference();
2616      if (this.incomingReferral == null)
2617        this.incomingReferral = new ArrayList<Reference>();
2618      this.incomingReferral.add(t);
2619      return t;
2620    }
2621
2622    // syntactic sugar
2623    public Encounter addIncomingReferral(Reference t) { //3
2624      if (t == null)
2625        return this;
2626      if (this.incomingReferral == null)
2627        this.incomingReferral = new ArrayList<Reference>();
2628      this.incomingReferral.add(t);
2629      return this;
2630    }
2631
2632    /**
2633     * @return {@link #incomingReferral} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. The referral request this encounter satisfies (incoming referral).)
2634     */
2635    public List<ReferralRequest> getIncomingReferralTarget() { 
2636      if (this.incomingReferralTarget == null)
2637        this.incomingReferralTarget = new ArrayList<ReferralRequest>();
2638      return this.incomingReferralTarget;
2639    }
2640
2641    // syntactic sugar
2642    /**
2643     * @return {@link #incomingReferral} (Add an actual object that is the target of the reference. The reference library doesn't use these, but you can use this to hold the resources if you resolvethemt. The referral request this encounter satisfies (incoming referral).)
2644     */
2645    public ReferralRequest addIncomingReferralTarget() { 
2646      ReferralRequest r = new ReferralRequest();
2647      if (this.incomingReferralTarget == null)
2648        this.incomingReferralTarget = new ArrayList<ReferralRequest>();
2649      this.incomingReferralTarget.add(r);
2650      return r;
2651    }
2652
2653    /**
2654     * @return {@link #participant} (The list of people responsible for providing the service.)
2655     */
2656    public List<EncounterParticipantComponent> getParticipant() { 
2657      if (this.participant == null)
2658        this.participant = new ArrayList<EncounterParticipantComponent>();
2659      return this.participant;
2660    }
2661
2662    public boolean hasParticipant() { 
2663      if (this.participant == null)
2664        return false;
2665      for (EncounterParticipantComponent item : this.participant)
2666        if (!item.isEmpty())
2667          return true;
2668      return false;
2669    }
2670
2671    /**
2672     * @return {@link #participant} (The list of people responsible for providing the service.)
2673     */
2674    // syntactic sugar
2675    public EncounterParticipantComponent addParticipant() { //3
2676      EncounterParticipantComponent t = new EncounterParticipantComponent();
2677      if (this.participant == null)
2678        this.participant = new ArrayList<EncounterParticipantComponent>();
2679      this.participant.add(t);
2680      return t;
2681    }
2682
2683    // syntactic sugar
2684    public Encounter addParticipant(EncounterParticipantComponent t) { //3
2685      if (t == null)
2686        return this;
2687      if (this.participant == null)
2688        this.participant = new ArrayList<EncounterParticipantComponent>();
2689      this.participant.add(t);
2690      return this;
2691    }
2692
2693    /**
2694     * @return {@link #appointment} (The appointment that scheduled this encounter.)
2695     */
2696    public Reference getAppointment() { 
2697      if (this.appointment == null)
2698        if (Configuration.errorOnAutoCreate())
2699          throw new Error("Attempt to auto-create Encounter.appointment");
2700        else if (Configuration.doAutoCreate())
2701          this.appointment = new Reference(); // cc
2702      return this.appointment;
2703    }
2704
2705    public boolean hasAppointment() { 
2706      return this.appointment != null && !this.appointment.isEmpty();
2707    }
2708
2709    /**
2710     * @param value {@link #appointment} (The appointment that scheduled this encounter.)
2711     */
2712    public Encounter setAppointment(Reference value) { 
2713      this.appointment = value;
2714      return this;
2715    }
2716
2717    /**
2718     * @return {@link #appointment} 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 appointment that scheduled this encounter.)
2719     */
2720    public Appointment getAppointmentTarget() { 
2721      if (this.appointmentTarget == null)
2722        if (Configuration.errorOnAutoCreate())
2723          throw new Error("Attempt to auto-create Encounter.appointment");
2724        else if (Configuration.doAutoCreate())
2725          this.appointmentTarget = new Appointment(); // aa
2726      return this.appointmentTarget;
2727    }
2728
2729    /**
2730     * @param value {@link #appointment} 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 appointment that scheduled this encounter.)
2731     */
2732    public Encounter setAppointmentTarget(Appointment value) { 
2733      this.appointmentTarget = value;
2734      return this;
2735    }
2736
2737    /**
2738     * @return {@link #period} (The start and end time of the encounter.)
2739     */
2740    public Period getPeriod() { 
2741      if (this.period == null)
2742        if (Configuration.errorOnAutoCreate())
2743          throw new Error("Attempt to auto-create Encounter.period");
2744        else if (Configuration.doAutoCreate())
2745          this.period = new Period(); // cc
2746      return this.period;
2747    }
2748
2749    public boolean hasPeriod() { 
2750      return this.period != null && !this.period.isEmpty();
2751    }
2752
2753    /**
2754     * @param value {@link #period} (The start and end time of the encounter.)
2755     */
2756    public Encounter setPeriod(Period value) { 
2757      this.period = value;
2758      return this;
2759    }
2760
2761    /**
2762     * @return {@link #length} (Quantity of time the encounter lasted. This excludes the time during leaves of absence.)
2763     */
2764    public Duration getLength() { 
2765      if (this.length == null)
2766        if (Configuration.errorOnAutoCreate())
2767          throw new Error("Attempt to auto-create Encounter.length");
2768        else if (Configuration.doAutoCreate())
2769          this.length = new Duration(); // cc
2770      return this.length;
2771    }
2772
2773    public boolean hasLength() { 
2774      return this.length != null && !this.length.isEmpty();
2775    }
2776
2777    /**
2778     * @param value {@link #length} (Quantity of time the encounter lasted. This excludes the time during leaves of absence.)
2779     */
2780    public Encounter setLength(Duration value) { 
2781      this.length = value;
2782      return this;
2783    }
2784
2785    /**
2786     * @return {@link #reason} (Reason the encounter takes place, expressed as a code. For admissions, this can be used for a coded admission diagnosis.)
2787     */
2788    public List<CodeableConcept> getReason() { 
2789      if (this.reason == null)
2790        this.reason = new ArrayList<CodeableConcept>();
2791      return this.reason;
2792    }
2793
2794    public boolean hasReason() { 
2795      if (this.reason == null)
2796        return false;
2797      for (CodeableConcept item : this.reason)
2798        if (!item.isEmpty())
2799          return true;
2800      return false;
2801    }
2802
2803    /**
2804     * @return {@link #reason} (Reason the encounter takes place, expressed as a code. For admissions, this can be used for a coded admission diagnosis.)
2805     */
2806    // syntactic sugar
2807    public CodeableConcept addReason() { //3
2808      CodeableConcept t = new CodeableConcept();
2809      if (this.reason == null)
2810        this.reason = new ArrayList<CodeableConcept>();
2811      this.reason.add(t);
2812      return t;
2813    }
2814
2815    // syntactic sugar
2816    public Encounter addReason(CodeableConcept t) { //3
2817      if (t == null)
2818        return this;
2819      if (this.reason == null)
2820        this.reason = new ArrayList<CodeableConcept>();
2821      this.reason.add(t);
2822      return this;
2823    }
2824
2825    /**
2826     * @return {@link #indication} (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.)
2827     */
2828    public List<Reference> getIndication() { 
2829      if (this.indication == null)
2830        this.indication = new ArrayList<Reference>();
2831      return this.indication;
2832    }
2833
2834    public boolean hasIndication() { 
2835      if (this.indication == null)
2836        return false;
2837      for (Reference item : this.indication)
2838        if (!item.isEmpty())
2839          return true;
2840      return false;
2841    }
2842
2843    /**
2844     * @return {@link #indication} (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.)
2845     */
2846    // syntactic sugar
2847    public Reference addIndication() { //3
2848      Reference t = new Reference();
2849      if (this.indication == null)
2850        this.indication = new ArrayList<Reference>();
2851      this.indication.add(t);
2852      return t;
2853    }
2854
2855    // syntactic sugar
2856    public Encounter addIndication(Reference t) { //3
2857      if (t == null)
2858        return this;
2859      if (this.indication == null)
2860        this.indication = new ArrayList<Reference>();
2861      this.indication.add(t);
2862      return this;
2863    }
2864
2865    /**
2866     * @return {@link #indication} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. 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.)
2867     */
2868    public List<Resource> getIndicationTarget() { 
2869      if (this.indicationTarget == null)
2870        this.indicationTarget = new ArrayList<Resource>();
2871      return this.indicationTarget;
2872    }
2873
2874    /**
2875     * @return {@link #hospitalization} (Details about the admission to a healthcare service.)
2876     */
2877    public EncounterHospitalizationComponent getHospitalization() { 
2878      if (this.hospitalization == null)
2879        if (Configuration.errorOnAutoCreate())
2880          throw new Error("Attempt to auto-create Encounter.hospitalization");
2881        else if (Configuration.doAutoCreate())
2882          this.hospitalization = new EncounterHospitalizationComponent(); // cc
2883      return this.hospitalization;
2884    }
2885
2886    public boolean hasHospitalization() { 
2887      return this.hospitalization != null && !this.hospitalization.isEmpty();
2888    }
2889
2890    /**
2891     * @param value {@link #hospitalization} (Details about the admission to a healthcare service.)
2892     */
2893    public Encounter setHospitalization(EncounterHospitalizationComponent value) { 
2894      this.hospitalization = value;
2895      return this;
2896    }
2897
2898    /**
2899     * @return {@link #location} (List of locations where  the patient has been during this encounter.)
2900     */
2901    public List<EncounterLocationComponent> getLocation() { 
2902      if (this.location == null)
2903        this.location = new ArrayList<EncounterLocationComponent>();
2904      return this.location;
2905    }
2906
2907    public boolean hasLocation() { 
2908      if (this.location == null)
2909        return false;
2910      for (EncounterLocationComponent item : this.location)
2911        if (!item.isEmpty())
2912          return true;
2913      return false;
2914    }
2915
2916    /**
2917     * @return {@link #location} (List of locations where  the patient has been during this encounter.)
2918     */
2919    // syntactic sugar
2920    public EncounterLocationComponent addLocation() { //3
2921      EncounterLocationComponent t = new EncounterLocationComponent();
2922      if (this.location == null)
2923        this.location = new ArrayList<EncounterLocationComponent>();
2924      this.location.add(t);
2925      return t;
2926    }
2927
2928    // syntactic sugar
2929    public Encounter addLocation(EncounterLocationComponent t) { //3
2930      if (t == null)
2931        return this;
2932      if (this.location == null)
2933        this.location = new ArrayList<EncounterLocationComponent>();
2934      this.location.add(t);
2935      return this;
2936    }
2937
2938    /**
2939     * @return {@link #serviceProvider} (An organization that is in charge of maintaining the information of this Encounter (e.g. who maintains the report or the master service catalog item, etc.). This MAY be the same as the organization on the Patient record, however it could be different. This MAY not be not the Service Delivery Location's Organization.)
2940     */
2941    public Reference getServiceProvider() { 
2942      if (this.serviceProvider == null)
2943        if (Configuration.errorOnAutoCreate())
2944          throw new Error("Attempt to auto-create Encounter.serviceProvider");
2945        else if (Configuration.doAutoCreate())
2946          this.serviceProvider = new Reference(); // cc
2947      return this.serviceProvider;
2948    }
2949
2950    public boolean hasServiceProvider() { 
2951      return this.serviceProvider != null && !this.serviceProvider.isEmpty();
2952    }
2953
2954    /**
2955     * @param value {@link #serviceProvider} (An organization that is in charge of maintaining the information of this Encounter (e.g. who maintains the report or the master service catalog item, etc.). This MAY be the same as the organization on the Patient record, however it could be different. This MAY not be not the Service Delivery Location's Organization.)
2956     */
2957    public Encounter setServiceProvider(Reference value) { 
2958      this.serviceProvider = value;
2959      return this;
2960    }
2961
2962    /**
2963     * @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. (An organization that is in charge of maintaining the information of this Encounter (e.g. who maintains the report or the master service catalog item, etc.). This MAY be the same as the organization on the Patient record, however it could be different. This MAY not be not the Service Delivery Location's Organization.)
2964     */
2965    public Organization getServiceProviderTarget() { 
2966      if (this.serviceProviderTarget == null)
2967        if (Configuration.errorOnAutoCreate())
2968          throw new Error("Attempt to auto-create Encounter.serviceProvider");
2969        else if (Configuration.doAutoCreate())
2970          this.serviceProviderTarget = new Organization(); // aa
2971      return this.serviceProviderTarget;
2972    }
2973
2974    /**
2975     * @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. (An organization that is in charge of maintaining the information of this Encounter (e.g. who maintains the report or the master service catalog item, etc.). This MAY be the same as the organization on the Patient record, however it could be different. This MAY not be not the Service Delivery Location's Organization.)
2976     */
2977    public Encounter setServiceProviderTarget(Organization value) { 
2978      this.serviceProviderTarget = value;
2979      return this;
2980    }
2981
2982    /**
2983     * @return {@link #partOf} (Another Encounter of which this encounter is a part of (administratively or in time).)
2984     */
2985    public Reference getPartOf() { 
2986      if (this.partOf == null)
2987        if (Configuration.errorOnAutoCreate())
2988          throw new Error("Attempt to auto-create Encounter.partOf");
2989        else if (Configuration.doAutoCreate())
2990          this.partOf = new Reference(); // cc
2991      return this.partOf;
2992    }
2993
2994    public boolean hasPartOf() { 
2995      return this.partOf != null && !this.partOf.isEmpty();
2996    }
2997
2998    /**
2999     * @param value {@link #partOf} (Another Encounter of which this encounter is a part of (administratively or in time).)
3000     */
3001    public Encounter setPartOf(Reference value) { 
3002      this.partOf = value;
3003      return this;
3004    }
3005
3006    /**
3007     * @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).)
3008     */
3009    public Encounter getPartOfTarget() { 
3010      if (this.partOfTarget == null)
3011        if (Configuration.errorOnAutoCreate())
3012          throw new Error("Attempt to auto-create Encounter.partOf");
3013        else if (Configuration.doAutoCreate())
3014          this.partOfTarget = new Encounter(); // aa
3015      return this.partOfTarget;
3016    }
3017
3018    /**
3019     * @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).)
3020     */
3021    public Encounter setPartOfTarget(Encounter value) { 
3022      this.partOfTarget = value;
3023      return this;
3024    }
3025
3026      protected void listChildren(List<Property> childrenList) {
3027        super.listChildren(childrenList);
3028        childrenList.add(new Property("identifier", "Identifier", "Identifier(s) by which this encounter is known.", 0, java.lang.Integer.MAX_VALUE, identifier));
3029        childrenList.add(new Property("status", "code", "planned | arrived | in-progress | onleave | finished | cancelled.", 0, java.lang.Integer.MAX_VALUE, status));
3030        childrenList.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));
3031        childrenList.add(new Property("class", "code", "inpatient | outpatient | ambulatory | emergency +.", 0, java.lang.Integer.MAX_VALUE, class_));
3032        childrenList.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));
3033        childrenList.add(new Property("priority", "CodeableConcept", "Indicates the urgency of the encounter.", 0, java.lang.Integer.MAX_VALUE, priority));
3034        childrenList.add(new Property("patient", "Reference(Patient)", "The patient present at the encounter.", 0, java.lang.Integer.MAX_VALUE, patient));
3035        childrenList.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));
3036        childrenList.add(new Property("incomingReferral", "Reference(ReferralRequest)", "The referral request this encounter satisfies (incoming referral).", 0, java.lang.Integer.MAX_VALUE, incomingReferral));
3037        childrenList.add(new Property("participant", "", "The list of people responsible for providing the service.", 0, java.lang.Integer.MAX_VALUE, participant));
3038        childrenList.add(new Property("appointment", "Reference(Appointment)", "The appointment that scheduled this encounter.", 0, java.lang.Integer.MAX_VALUE, appointment));
3039        childrenList.add(new Property("period", "Period", "The start and end time of the encounter.", 0, java.lang.Integer.MAX_VALUE, period));
3040        childrenList.add(new Property("length", "Duration", "Quantity of time the encounter lasted. This excludes the time during leaves of absence.", 0, java.lang.Integer.MAX_VALUE, length));
3041        childrenList.add(new Property("reason", "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, reason));
3042        childrenList.add(new Property("indication", "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, java.lang.Integer.MAX_VALUE, indication));
3043        childrenList.add(new Property("hospitalization", "", "Details about the admission to a healthcare service.", 0, java.lang.Integer.MAX_VALUE, hospitalization));
3044        childrenList.add(new Property("location", "", "List of locations where  the patient has been during this encounter.", 0, java.lang.Integer.MAX_VALUE, location));
3045        childrenList.add(new Property("serviceProvider", "Reference(Organization)", "An organization that is in charge of maintaining the information of this Encounter (e.g. who maintains the report or the master service catalog item, etc.). This MAY be the same as the organization on the Patient record, however it could be different. This MAY not be not the Service Delivery Location's Organization.", 0, java.lang.Integer.MAX_VALUE, serviceProvider));
3046        childrenList.add(new Property("partOf", "Reference(Encounter)", "Another Encounter of which this encounter is a part of (administratively or in time).", 0, java.lang.Integer.MAX_VALUE, partOf));
3047      }
3048
3049      @Override
3050      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
3051        switch (hash) {
3052        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
3053        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<EncounterState>
3054        case -986695614: /*statusHistory*/ return this.statusHistory == null ? new Base[0] : this.statusHistory.toArray(new Base[this.statusHistory.size()]); // EncounterStatusHistoryComponent
3055        case 94742904: /*class*/ return this.class_ == null ? new Base[0] : new Base[] {this.class_}; // Enumeration<EncounterClass>
3056        case 3575610: /*type*/ return this.type == null ? new Base[0] : this.type.toArray(new Base[this.type.size()]); // CodeableConcept
3057        case -1165461084: /*priority*/ return this.priority == null ? new Base[0] : new Base[] {this.priority}; // CodeableConcept
3058        case -791418107: /*patient*/ return this.patient == null ? new Base[0] : new Base[] {this.patient}; // Reference
3059        case -1892140189: /*episodeOfCare*/ return this.episodeOfCare == null ? new Base[0] : this.episodeOfCare.toArray(new Base[this.episodeOfCare.size()]); // Reference
3060        case -1258204701: /*incomingReferral*/ return this.incomingReferral == null ? new Base[0] : this.incomingReferral.toArray(new Base[this.incomingReferral.size()]); // Reference
3061        case 767422259: /*participant*/ return this.participant == null ? new Base[0] : this.participant.toArray(new Base[this.participant.size()]); // EncounterParticipantComponent
3062        case -1474995297: /*appointment*/ return this.appointment == null ? new Base[0] : new Base[] {this.appointment}; // Reference
3063        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
3064        case -1106363674: /*length*/ return this.length == null ? new Base[0] : new Base[] {this.length}; // Duration
3065        case -934964668: /*reason*/ return this.reason == null ? new Base[0] : this.reason.toArray(new Base[this.reason.size()]); // CodeableConcept
3066        case -597168804: /*indication*/ return this.indication == null ? new Base[0] : this.indication.toArray(new Base[this.indication.size()]); // Reference
3067        case 1057894634: /*hospitalization*/ return this.hospitalization == null ? new Base[0] : new Base[] {this.hospitalization}; // EncounterHospitalizationComponent
3068        case 1901043637: /*location*/ return this.location == null ? new Base[0] : this.location.toArray(new Base[this.location.size()]); // EncounterLocationComponent
3069        case 243182534: /*serviceProvider*/ return this.serviceProvider == null ? new Base[0] : new Base[] {this.serviceProvider}; // Reference
3070        case -995410646: /*partOf*/ return this.partOf == null ? new Base[0] : new Base[] {this.partOf}; // Reference
3071        default: return super.getProperty(hash, name, checkValid);
3072        }
3073
3074      }
3075
3076      @Override
3077      public void setProperty(int hash, String name, Base value) throws FHIRException {
3078        switch (hash) {
3079        case -1618432855: // identifier
3080          this.getIdentifier().add(castToIdentifier(value)); // Identifier
3081          break;
3082        case -892481550: // status
3083          this.status = new EncounterStateEnumFactory().fromType(value); // Enumeration<EncounterState>
3084          break;
3085        case -986695614: // statusHistory
3086          this.getStatusHistory().add((EncounterStatusHistoryComponent) value); // EncounterStatusHistoryComponent
3087          break;
3088        case 94742904: // class
3089          this.class_ = new EncounterClassEnumFactory().fromType(value); // Enumeration<EncounterClass>
3090          break;
3091        case 3575610: // type
3092          this.getType().add(castToCodeableConcept(value)); // CodeableConcept
3093          break;
3094        case -1165461084: // priority
3095          this.priority = castToCodeableConcept(value); // CodeableConcept
3096          break;
3097        case -791418107: // patient
3098          this.patient = castToReference(value); // Reference
3099          break;
3100        case -1892140189: // episodeOfCare
3101          this.getEpisodeOfCare().add(castToReference(value)); // Reference
3102          break;
3103        case -1258204701: // incomingReferral
3104          this.getIncomingReferral().add(castToReference(value)); // Reference
3105          break;
3106        case 767422259: // participant
3107          this.getParticipant().add((EncounterParticipantComponent) value); // EncounterParticipantComponent
3108          break;
3109        case -1474995297: // appointment
3110          this.appointment = castToReference(value); // Reference
3111          break;
3112        case -991726143: // period
3113          this.period = castToPeriod(value); // Period
3114          break;
3115        case -1106363674: // length
3116          this.length = castToDuration(value); // Duration
3117          break;
3118        case -934964668: // reason
3119          this.getReason().add(castToCodeableConcept(value)); // CodeableConcept
3120          break;
3121        case -597168804: // indication
3122          this.getIndication().add(castToReference(value)); // Reference
3123          break;
3124        case 1057894634: // hospitalization
3125          this.hospitalization = (EncounterHospitalizationComponent) value; // EncounterHospitalizationComponent
3126          break;
3127        case 1901043637: // location
3128          this.getLocation().add((EncounterLocationComponent) value); // EncounterLocationComponent
3129          break;
3130        case 243182534: // serviceProvider
3131          this.serviceProvider = castToReference(value); // Reference
3132          break;
3133        case -995410646: // partOf
3134          this.partOf = castToReference(value); // Reference
3135          break;
3136        default: super.setProperty(hash, name, value);
3137        }
3138
3139      }
3140
3141      @Override
3142      public void setProperty(String name, Base value) throws FHIRException {
3143        if (name.equals("identifier"))
3144          this.getIdentifier().add(castToIdentifier(value));
3145        else if (name.equals("status"))
3146          this.status = new EncounterStateEnumFactory().fromType(value); // Enumeration<EncounterState>
3147        else if (name.equals("statusHistory"))
3148          this.getStatusHistory().add((EncounterStatusHistoryComponent) value);
3149        else if (name.equals("class"))
3150          this.class_ = new EncounterClassEnumFactory().fromType(value); // Enumeration<EncounterClass>
3151        else if (name.equals("type"))
3152          this.getType().add(castToCodeableConcept(value));
3153        else if (name.equals("priority"))
3154          this.priority = castToCodeableConcept(value); // CodeableConcept
3155        else if (name.equals("patient"))
3156          this.patient = castToReference(value); // Reference
3157        else if (name.equals("episodeOfCare"))
3158          this.getEpisodeOfCare().add(castToReference(value));
3159        else if (name.equals("incomingReferral"))
3160          this.getIncomingReferral().add(castToReference(value));
3161        else if (name.equals("participant"))
3162          this.getParticipant().add((EncounterParticipantComponent) value);
3163        else if (name.equals("appointment"))
3164          this.appointment = castToReference(value); // Reference
3165        else if (name.equals("period"))
3166          this.period = castToPeriod(value); // Period
3167        else if (name.equals("length"))
3168          this.length = castToDuration(value); // Duration
3169        else if (name.equals("reason"))
3170          this.getReason().add(castToCodeableConcept(value));
3171        else if (name.equals("indication"))
3172          this.getIndication().add(castToReference(value));
3173        else if (name.equals("hospitalization"))
3174          this.hospitalization = (EncounterHospitalizationComponent) value; // EncounterHospitalizationComponent
3175        else if (name.equals("location"))
3176          this.getLocation().add((EncounterLocationComponent) value);
3177        else if (name.equals("serviceProvider"))
3178          this.serviceProvider = castToReference(value); // Reference
3179        else if (name.equals("partOf"))
3180          this.partOf = castToReference(value); // Reference
3181        else
3182          super.setProperty(name, value);
3183      }
3184
3185      @Override
3186      public Base makeProperty(int hash, String name) throws FHIRException {
3187        switch (hash) {
3188        case -1618432855:  return addIdentifier(); // Identifier
3189        case -892481550: throw new FHIRException("Cannot make property status as it is not a complex type"); // Enumeration<EncounterState>
3190        case -986695614:  return addStatusHistory(); // EncounterStatusHistoryComponent
3191        case 94742904: throw new FHIRException("Cannot make property class as it is not a complex type"); // Enumeration<EncounterClass>
3192        case 3575610:  return addType(); // CodeableConcept
3193        case -1165461084:  return getPriority(); // CodeableConcept
3194        case -791418107:  return getPatient(); // Reference
3195        case -1892140189:  return addEpisodeOfCare(); // Reference
3196        case -1258204701:  return addIncomingReferral(); // Reference
3197        case 767422259:  return addParticipant(); // EncounterParticipantComponent
3198        case -1474995297:  return getAppointment(); // Reference
3199        case -991726143:  return getPeriod(); // Period
3200        case -1106363674:  return getLength(); // Duration
3201        case -934964668:  return addReason(); // CodeableConcept
3202        case -597168804:  return addIndication(); // Reference
3203        case 1057894634:  return getHospitalization(); // EncounterHospitalizationComponent
3204        case 1901043637:  return addLocation(); // EncounterLocationComponent
3205        case 243182534:  return getServiceProvider(); // Reference
3206        case -995410646:  return getPartOf(); // Reference
3207        default: return super.makeProperty(hash, name);
3208        }
3209
3210      }
3211
3212      @Override
3213      public Base addChild(String name) throws FHIRException {
3214        if (name.equals("identifier")) {
3215          return addIdentifier();
3216        }
3217        else if (name.equals("status")) {
3218          throw new FHIRException("Cannot call addChild on a primitive type Encounter.status");
3219        }
3220        else if (name.equals("statusHistory")) {
3221          return addStatusHistory();
3222        }
3223        else if (name.equals("class")) {
3224          throw new FHIRException("Cannot call addChild on a primitive type Encounter.class");
3225        }
3226        else if (name.equals("type")) {
3227          return addType();
3228        }
3229        else if (name.equals("priority")) {
3230          this.priority = new CodeableConcept();
3231          return this.priority;
3232        }
3233        else if (name.equals("patient")) {
3234          this.patient = new Reference();
3235          return this.patient;
3236        }
3237        else if (name.equals("episodeOfCare")) {
3238          return addEpisodeOfCare();
3239        }
3240        else if (name.equals("incomingReferral")) {
3241          return addIncomingReferral();
3242        }
3243        else if (name.equals("participant")) {
3244          return addParticipant();
3245        }
3246        else if (name.equals("appointment")) {
3247          this.appointment = new Reference();
3248          return this.appointment;
3249        }
3250        else if (name.equals("period")) {
3251          this.period = new Period();
3252          return this.period;
3253        }
3254        else if (name.equals("length")) {
3255          this.length = new Duration();
3256          return this.length;
3257        }
3258        else if (name.equals("reason")) {
3259          return addReason();
3260        }
3261        else if (name.equals("indication")) {
3262          return addIndication();
3263        }
3264        else if (name.equals("hospitalization")) {
3265          this.hospitalization = new EncounterHospitalizationComponent();
3266          return this.hospitalization;
3267        }
3268        else if (name.equals("location")) {
3269          return addLocation();
3270        }
3271        else if (name.equals("serviceProvider")) {
3272          this.serviceProvider = new Reference();
3273          return this.serviceProvider;
3274        }
3275        else if (name.equals("partOf")) {
3276          this.partOf = new Reference();
3277          return this.partOf;
3278        }
3279        else
3280          return super.addChild(name);
3281      }
3282
3283  public String fhirType() {
3284    return "Encounter";
3285
3286  }
3287
3288      public Encounter copy() {
3289        Encounter dst = new Encounter();
3290        copyValues(dst);
3291        if (identifier != null) {
3292          dst.identifier = new ArrayList<Identifier>();
3293          for (Identifier i : identifier)
3294            dst.identifier.add(i.copy());
3295        };
3296        dst.status = status == null ? null : status.copy();
3297        if (statusHistory != null) {
3298          dst.statusHistory = new ArrayList<EncounterStatusHistoryComponent>();
3299          for (EncounterStatusHistoryComponent i : statusHistory)
3300            dst.statusHistory.add(i.copy());
3301        };
3302        dst.class_ = class_ == null ? null : class_.copy();
3303        if (type != null) {
3304          dst.type = new ArrayList<CodeableConcept>();
3305          for (CodeableConcept i : type)
3306            dst.type.add(i.copy());
3307        };
3308        dst.priority = priority == null ? null : priority.copy();
3309        dst.patient = patient == null ? null : patient.copy();
3310        if (episodeOfCare != null) {
3311          dst.episodeOfCare = new ArrayList<Reference>();
3312          for (Reference i : episodeOfCare)
3313            dst.episodeOfCare.add(i.copy());
3314        };
3315        if (incomingReferral != null) {
3316          dst.incomingReferral = new ArrayList<Reference>();
3317          for (Reference i : incomingReferral)
3318            dst.incomingReferral.add(i.copy());
3319        };
3320        if (participant != null) {
3321          dst.participant = new ArrayList<EncounterParticipantComponent>();
3322          for (EncounterParticipantComponent i : participant)
3323            dst.participant.add(i.copy());
3324        };
3325        dst.appointment = appointment == null ? null : appointment.copy();
3326        dst.period = period == null ? null : period.copy();
3327        dst.length = length == null ? null : length.copy();
3328        if (reason != null) {
3329          dst.reason = new ArrayList<CodeableConcept>();
3330          for (CodeableConcept i : reason)
3331            dst.reason.add(i.copy());
3332        };
3333        if (indication != null) {
3334          dst.indication = new ArrayList<Reference>();
3335          for (Reference i : indication)
3336            dst.indication.add(i.copy());
3337        };
3338        dst.hospitalization = hospitalization == null ? null : hospitalization.copy();
3339        if (location != null) {
3340          dst.location = new ArrayList<EncounterLocationComponent>();
3341          for (EncounterLocationComponent i : location)
3342            dst.location.add(i.copy());
3343        };
3344        dst.serviceProvider = serviceProvider == null ? null : serviceProvider.copy();
3345        dst.partOf = partOf == null ? null : partOf.copy();
3346        return dst;
3347      }
3348
3349      protected Encounter typedCopy() {
3350        return copy();
3351      }
3352
3353      @Override
3354      public boolean equalsDeep(Base other) {
3355        if (!super.equalsDeep(other))
3356          return false;
3357        if (!(other instanceof Encounter))
3358          return false;
3359        Encounter o = (Encounter) other;
3360        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(statusHistory, o.statusHistory, true)
3361           && compareDeep(class_, o.class_, true) && compareDeep(type, o.type, true) && compareDeep(priority, o.priority, true)
3362           && compareDeep(patient, o.patient, true) && compareDeep(episodeOfCare, o.episodeOfCare, true) && compareDeep(incomingReferral, o.incomingReferral, true)
3363           && compareDeep(participant, o.participant, true) && compareDeep(appointment, o.appointment, true)
3364           && compareDeep(period, o.period, true) && compareDeep(length, o.length, true) && compareDeep(reason, o.reason, true)
3365           && compareDeep(indication, o.indication, true) && compareDeep(hospitalization, o.hospitalization, true)
3366           && compareDeep(location, o.location, true) && compareDeep(serviceProvider, o.serviceProvider, true)
3367           && compareDeep(partOf, o.partOf, true);
3368      }
3369
3370      @Override
3371      public boolean equalsShallow(Base other) {
3372        if (!super.equalsShallow(other))
3373          return false;
3374        if (!(other instanceof Encounter))
3375          return false;
3376        Encounter o = (Encounter) other;
3377        return compareValues(status, o.status, true) && compareValues(class_, o.class_, true);
3378      }
3379
3380      public boolean isEmpty() {
3381        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (status == null || status.isEmpty())
3382           && (statusHistory == null || statusHistory.isEmpty()) && (class_ == null || class_.isEmpty())
3383           && (type == null || type.isEmpty()) && (priority == null || priority.isEmpty()) && (patient == null || patient.isEmpty())
3384           && (episodeOfCare == null || episodeOfCare.isEmpty()) && (incomingReferral == null || incomingReferral.isEmpty())
3385           && (participant == null || participant.isEmpty()) && (appointment == null || appointment.isEmpty())
3386           && (period == null || period.isEmpty()) && (length == null || length.isEmpty()) && (reason == null || reason.isEmpty())
3387           && (indication == null || indication.isEmpty()) && (hospitalization == null || hospitalization.isEmpty())
3388           && (location == null || location.isEmpty()) && (serviceProvider == null || serviceProvider.isEmpty())
3389           && (partOf == null || partOf.isEmpty());
3390      }
3391
3392  @Override
3393  public ResourceType getResourceType() {
3394    return ResourceType.Encounter;
3395   }
3396
3397 /**
3398   * Search parameter: <b>participant-type</b>
3399   * <p>
3400   * Description: <b>Role of participant in encounter</b><br>
3401   * Type: <b>token</b><br>
3402   * Path: <b>Encounter.participant.type</b><br>
3403   * </p>
3404   */
3405  @SearchParamDefinition(name="participant-type", path="Encounter.participant.type", description="Role of participant in encounter", type="token" )
3406  public static final String SP_PARTICIPANT_TYPE = "participant-type";
3407 /**
3408   * <b>Fluent Client</b> search parameter constant for <b>participant-type</b>
3409   * <p>
3410   * Description: <b>Role of participant in encounter</b><br>
3411   * Type: <b>token</b><br>
3412   * Path: <b>Encounter.participant.type</b><br>
3413   * </p>
3414   */
3415  public static final ca.uhn.fhir.rest.gclient.TokenClientParam PARTICIPANT_TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_PARTICIPANT_TYPE);
3416
3417 /**
3418   * Search parameter: <b>episodeofcare</b>
3419   * <p>
3420   * Description: <b>Episode(s) of care that this encounter should be recorded against</b><br>
3421   * Type: <b>reference</b><br>
3422   * Path: <b>Encounter.episodeOfCare</b><br>
3423   * </p>
3424   */
3425  @SearchParamDefinition(name="episodeofcare", path="Encounter.episodeOfCare", description="Episode(s) of care that this encounter should be recorded against", type="reference" )
3426  public static final String SP_EPISODEOFCARE = "episodeofcare";
3427 /**
3428   * <b>Fluent Client</b> search parameter constant for <b>episodeofcare</b>
3429   * <p>
3430   * Description: <b>Episode(s) of care that this encounter should be recorded against</b><br>
3431   * Type: <b>reference</b><br>
3432   * Path: <b>Encounter.episodeOfCare</b><br>
3433   * </p>
3434   */
3435  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam EPISODEOFCARE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_EPISODEOFCARE);
3436
3437/**
3438   * Constant for fluent queries to be used to add include statements. Specifies
3439   * the path value of "<b>Encounter:episodeofcare</b>".
3440   */
3441  public static final ca.uhn.fhir.model.api.Include INCLUDE_EPISODEOFCARE = new ca.uhn.fhir.model.api.Include("Encounter:episodeofcare").toLocked();
3442
3443 /**
3444   * Search parameter: <b>status</b>
3445   * <p>
3446   * Description: <b>planned | arrived | in-progress | onleave | finished | cancelled</b><br>
3447   * Type: <b>token</b><br>
3448   * Path: <b>Encounter.status</b><br>
3449   * </p>
3450   */
3451  @SearchParamDefinition(name="status", path="Encounter.status", description="planned | arrived | in-progress | onleave | finished | cancelled", type="token" )
3452  public static final String SP_STATUS = "status";
3453 /**
3454   * <b>Fluent Client</b> search parameter constant for <b>status</b>
3455   * <p>
3456   * Description: <b>planned | arrived | in-progress | onleave | finished | cancelled</b><br>
3457   * Type: <b>token</b><br>
3458   * Path: <b>Encounter.status</b><br>
3459   * </p>
3460   */
3461  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
3462
3463 /**
3464   * Search parameter: <b>reason</b>
3465   * <p>
3466   * Description: <b>Reason the encounter takes place (code)</b><br>
3467   * Type: <b>token</b><br>
3468   * Path: <b>Encounter.reason</b><br>
3469   * </p>
3470   */
3471  @SearchParamDefinition(name="reason", path="Encounter.reason", description="Reason the encounter takes place (code)", type="token" )
3472  public static final String SP_REASON = "reason";
3473 /**
3474   * <b>Fluent Client</b> search parameter constant for <b>reason</b>
3475   * <p>
3476   * Description: <b>Reason the encounter takes place (code)</b><br>
3477   * Type: <b>token</b><br>
3478   * Path: <b>Encounter.reason</b><br>
3479   * </p>
3480   */
3481  public static final ca.uhn.fhir.rest.gclient.TokenClientParam REASON = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_REASON);
3482
3483 /**
3484   * Search parameter: <b>condition</b>
3485   * <p>
3486   * Description: <b>Reason the encounter takes place (resource)</b><br>
3487   * Type: <b>reference</b><br>
3488   * Path: <b>Encounter.indication</b><br>
3489   * </p>
3490   */
3491  @SearchParamDefinition(name="condition", path="Encounter.indication", description="Reason the encounter takes place (resource)", type="reference" )
3492  public static final String SP_CONDITION = "condition";
3493 /**
3494   * <b>Fluent Client</b> search parameter constant for <b>condition</b>
3495   * <p>
3496   * Description: <b>Reason the encounter takes place (resource)</b><br>
3497   * Type: <b>reference</b><br>
3498   * Path: <b>Encounter.indication</b><br>
3499   * </p>
3500   */
3501  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam CONDITION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_CONDITION);
3502
3503/**
3504   * Constant for fluent queries to be used to add include statements. Specifies
3505   * the path value of "<b>Encounter:condition</b>".
3506   */
3507  public static final ca.uhn.fhir.model.api.Include INCLUDE_CONDITION = new ca.uhn.fhir.model.api.Include("Encounter:condition").toLocked();
3508
3509 /**
3510   * Search parameter: <b>location</b>
3511   * <p>
3512   * Description: <b>Location the encounter takes place</b><br>
3513   * Type: <b>reference</b><br>
3514   * Path: <b>Encounter.location.location</b><br>
3515   * </p>
3516   */
3517  @SearchParamDefinition(name="location", path="Encounter.location.location", description="Location the encounter takes place", type="reference" )
3518  public static final String SP_LOCATION = "location";
3519 /**
3520   * <b>Fluent Client</b> search parameter constant for <b>location</b>
3521   * <p>
3522   * Description: <b>Location the encounter takes place</b><br>
3523   * Type: <b>reference</b><br>
3524   * Path: <b>Encounter.location.location</b><br>
3525   * </p>
3526   */
3527  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam LOCATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_LOCATION);
3528
3529/**
3530   * Constant for fluent queries to be used to add include statements. Specifies
3531   * the path value of "<b>Encounter:location</b>".
3532   */
3533  public static final ca.uhn.fhir.model.api.Include INCLUDE_LOCATION = new ca.uhn.fhir.model.api.Include("Encounter:location").toLocked();
3534
3535 /**
3536   * Search parameter: <b>indication</b>
3537   * <p>
3538   * Description: <b>Reason the encounter takes place (resource)</b><br>
3539   * Type: <b>reference</b><br>
3540   * Path: <b>Encounter.indication</b><br>
3541   * </p>
3542   */
3543  @SearchParamDefinition(name="indication", path="Encounter.indication", description="Reason the encounter takes place (resource)", type="reference" )
3544  public static final String SP_INDICATION = "indication";
3545 /**
3546   * <b>Fluent Client</b> search parameter constant for <b>indication</b>
3547   * <p>
3548   * Description: <b>Reason the encounter takes place (resource)</b><br>
3549   * Type: <b>reference</b><br>
3550   * Path: <b>Encounter.indication</b><br>
3551   * </p>
3552   */
3553  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam INDICATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_INDICATION);
3554
3555/**
3556   * Constant for fluent queries to be used to add include statements. Specifies
3557   * the path value of "<b>Encounter:indication</b>".
3558   */
3559  public static final ca.uhn.fhir.model.api.Include INCLUDE_INDICATION = new ca.uhn.fhir.model.api.Include("Encounter:indication").toLocked();
3560
3561 /**
3562   * Search parameter: <b>type</b>
3563   * <p>
3564   * Description: <b>Specific type of encounter</b><br>
3565   * Type: <b>token</b><br>
3566   * Path: <b>Encounter.type</b><br>
3567   * </p>
3568   */
3569  @SearchParamDefinition(name="type", path="Encounter.type", description="Specific type of encounter", type="token" )
3570  public static final String SP_TYPE = "type";
3571 /**
3572   * <b>Fluent Client</b> search parameter constant for <b>type</b>
3573   * <p>
3574   * Description: <b>Specific type of encounter</b><br>
3575   * Type: <b>token</b><br>
3576   * Path: <b>Encounter.type</b><br>
3577   * </p>
3578   */
3579  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_TYPE);
3580
3581 /**
3582   * Search parameter: <b>date</b>
3583   * <p>
3584   * Description: <b>A date within the period the Encounter lasted</b><br>
3585   * Type: <b>date</b><br>
3586   * Path: <b>Encounter.period</b><br>
3587   * </p>
3588   */
3589  @SearchParamDefinition(name="date", path="Encounter.period", description="A date within the period the Encounter lasted", type="date" )
3590  public static final String SP_DATE = "date";
3591 /**
3592   * <b>Fluent Client</b> search parameter constant for <b>date</b>
3593   * <p>
3594   * Description: <b>A date within the period the Encounter lasted</b><br>
3595   * Type: <b>date</b><br>
3596   * Path: <b>Encounter.period</b><br>
3597   * </p>
3598   */
3599  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
3600
3601 /**
3602   * Search parameter: <b>special-arrangement</b>
3603   * <p>
3604   * Description: <b>Wheelchair, translator, stretcher, etc.</b><br>
3605   * Type: <b>token</b><br>
3606   * Path: <b>Encounter.hospitalization.specialArrangement</b><br>
3607   * </p>
3608   */
3609  @SearchParamDefinition(name="special-arrangement", path="Encounter.hospitalization.specialArrangement", description="Wheelchair, translator, stretcher, etc.", type="token" )
3610  public static final String SP_SPECIAL_ARRANGEMENT = "special-arrangement";
3611 /**
3612   * <b>Fluent Client</b> search parameter constant for <b>special-arrangement</b>
3613   * <p>
3614   * Description: <b>Wheelchair, translator, stretcher, etc.</b><br>
3615   * Type: <b>token</b><br>
3616   * Path: <b>Encounter.hospitalization.specialArrangement</b><br>
3617   * </p>
3618   */
3619  public static final ca.uhn.fhir.rest.gclient.TokenClientParam SPECIAL_ARRANGEMENT = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_SPECIAL_ARRANGEMENT);
3620
3621 /**
3622   * Search parameter: <b>part-of</b>
3623   * <p>
3624   * Description: <b>Another Encounter this encounter is part of</b><br>
3625   * Type: <b>reference</b><br>
3626   * Path: <b>Encounter.partOf</b><br>
3627   * </p>
3628   */
3629  @SearchParamDefinition(name="part-of", path="Encounter.partOf", description="Another Encounter this encounter is part of", type="reference" )
3630  public static final String SP_PART_OF = "part-of";
3631 /**
3632   * <b>Fluent Client</b> search parameter constant for <b>part-of</b>
3633   * <p>
3634   * Description: <b>Another Encounter this encounter is part of</b><br>
3635   * Type: <b>reference</b><br>
3636   * Path: <b>Encounter.partOf</b><br>
3637   * </p>
3638   */
3639  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PART_OF = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PART_OF);
3640
3641/**
3642   * Constant for fluent queries to be used to add include statements. Specifies
3643   * the path value of "<b>Encounter:part-of</b>".
3644   */
3645  public static final ca.uhn.fhir.model.api.Include INCLUDE_PART_OF = new ca.uhn.fhir.model.api.Include("Encounter:part-of").toLocked();
3646
3647 /**
3648   * Search parameter: <b>appointment</b>
3649   * <p>
3650   * Description: <b>The appointment that scheduled this encounter</b><br>
3651   * Type: <b>reference</b><br>
3652   * Path: <b>Encounter.appointment</b><br>
3653   * </p>
3654   */
3655  @SearchParamDefinition(name="appointment", path="Encounter.appointment", description="The appointment that scheduled this encounter", type="reference" )
3656  public static final String SP_APPOINTMENT = "appointment";
3657 /**
3658   * <b>Fluent Client</b> search parameter constant for <b>appointment</b>
3659   * <p>
3660   * Description: <b>The appointment that scheduled this encounter</b><br>
3661   * Type: <b>reference</b><br>
3662   * Path: <b>Encounter.appointment</b><br>
3663   * </p>
3664   */
3665  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam APPOINTMENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_APPOINTMENT);
3666
3667/**
3668   * Constant for fluent queries to be used to add include statements. Specifies
3669   * the path value of "<b>Encounter:appointment</b>".
3670   */
3671  public static final ca.uhn.fhir.model.api.Include INCLUDE_APPOINTMENT = new ca.uhn.fhir.model.api.Include("Encounter:appointment").toLocked();
3672
3673 /**
3674   * Search parameter: <b>patient</b>
3675   * <p>
3676   * Description: <b>The patient present at the encounter</b><br>
3677   * Type: <b>reference</b><br>
3678   * Path: <b>Encounter.patient</b><br>
3679   * </p>
3680   */
3681  @SearchParamDefinition(name="patient", path="Encounter.patient", description="The patient present at the encounter", type="reference" )
3682  public static final String SP_PATIENT = "patient";
3683 /**
3684   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
3685   * <p>
3686   * Description: <b>The patient present at the encounter</b><br>
3687   * Type: <b>reference</b><br>
3688   * Path: <b>Encounter.patient</b><br>
3689   * </p>
3690   */
3691  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
3692
3693/**
3694   * Constant for fluent queries to be used to add include statements. Specifies
3695   * the path value of "<b>Encounter:patient</b>".
3696   */
3697  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("Encounter:patient").toLocked();
3698
3699 /**
3700   * Search parameter: <b>practitioner</b>
3701   * <p>
3702   * Description: <b>Persons involved in the encounter other than the patient</b><br>
3703   * Type: <b>reference</b><br>
3704   * Path: <b>Encounter.participant.individual</b><br>
3705   * </p>
3706   */
3707  @SearchParamDefinition(name="practitioner", path="Encounter.participant.individual", description="Persons involved in the encounter other than the patient", type="reference" )
3708  public static final String SP_PRACTITIONER = "practitioner";
3709 /**
3710   * <b>Fluent Client</b> search parameter constant for <b>practitioner</b>
3711   * <p>
3712   * Description: <b>Persons involved in the encounter other than the patient</b><br>
3713   * Type: <b>reference</b><br>
3714   * Path: <b>Encounter.participant.individual</b><br>
3715   * </p>
3716   */
3717  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PRACTITIONER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PRACTITIONER);
3718
3719/**
3720   * Constant for fluent queries to be used to add include statements. Specifies
3721   * the path value of "<b>Encounter:practitioner</b>".
3722   */
3723  public static final ca.uhn.fhir.model.api.Include INCLUDE_PRACTITIONER = new ca.uhn.fhir.model.api.Include("Encounter:practitioner").toLocked();
3724
3725 /**
3726   * Search parameter: <b>length</b>
3727   * <p>
3728   * Description: <b>Length of encounter in days</b><br>
3729   * Type: <b>number</b><br>
3730   * Path: <b>Encounter.length</b><br>
3731   * </p>
3732   */
3733  @SearchParamDefinition(name="length", path="Encounter.length", description="Length of encounter in days", type="number" )
3734  public static final String SP_LENGTH = "length";
3735 /**
3736   * <b>Fluent Client</b> search parameter constant for <b>length</b>
3737   * <p>
3738   * Description: <b>Length of encounter in days</b><br>
3739   * Type: <b>number</b><br>
3740   * Path: <b>Encounter.length</b><br>
3741   * </p>
3742   */
3743  public static final ca.uhn.fhir.rest.gclient.NumberClientParam LENGTH = new ca.uhn.fhir.rest.gclient.NumberClientParam(SP_LENGTH);
3744
3745 /**
3746   * Search parameter: <b>participant</b>
3747   * <p>
3748   * Description: <b>Persons involved in the encounter other than the patient</b><br>
3749   * Type: <b>reference</b><br>
3750   * Path: <b>Encounter.participant.individual</b><br>
3751   * </p>
3752   */
3753  @SearchParamDefinition(name="participant", path="Encounter.participant.individual", description="Persons involved in the encounter other than the patient", type="reference" )
3754  public static final String SP_PARTICIPANT = "participant";
3755 /**
3756   * <b>Fluent Client</b> search parameter constant for <b>participant</b>
3757   * <p>
3758   * Description: <b>Persons involved in the encounter other than the patient</b><br>
3759   * Type: <b>reference</b><br>
3760   * Path: <b>Encounter.participant.individual</b><br>
3761   * </p>
3762   */
3763  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PARTICIPANT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PARTICIPANT);
3764
3765/**
3766   * Constant for fluent queries to be used to add include statements. Specifies
3767   * the path value of "<b>Encounter:participant</b>".
3768   */
3769  public static final ca.uhn.fhir.model.api.Include INCLUDE_PARTICIPANT = new ca.uhn.fhir.model.api.Include("Encounter:participant").toLocked();
3770
3771 /**
3772   * Search parameter: <b>incomingreferral</b>
3773   * <p>
3774   * Description: <b>The ReferralRequest that initiated this encounter</b><br>
3775   * Type: <b>reference</b><br>
3776   * Path: <b>Encounter.incomingReferral</b><br>
3777   * </p>
3778   */
3779  @SearchParamDefinition(name="incomingreferral", path="Encounter.incomingReferral", description="The ReferralRequest that initiated this encounter", type="reference" )
3780  public static final String SP_INCOMINGREFERRAL = "incomingreferral";
3781 /**
3782   * <b>Fluent Client</b> search parameter constant for <b>incomingreferral</b>
3783   * <p>
3784   * Description: <b>The ReferralRequest that initiated this encounter</b><br>
3785   * Type: <b>reference</b><br>
3786   * Path: <b>Encounter.incomingReferral</b><br>
3787   * </p>
3788   */
3789  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam INCOMINGREFERRAL = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_INCOMINGREFERRAL);
3790
3791/**
3792   * Constant for fluent queries to be used to add include statements. Specifies
3793   * the path value of "<b>Encounter:incomingreferral</b>".
3794   */
3795  public static final ca.uhn.fhir.model.api.Include INCLUDE_INCOMINGREFERRAL = new ca.uhn.fhir.model.api.Include("Encounter:incomingreferral").toLocked();
3796
3797 /**
3798   * Search parameter: <b>identifier</b>
3799   * <p>
3800   * Description: <b>Identifier(s) by which this encounter is known</b><br>
3801   * Type: <b>token</b><br>
3802   * Path: <b>Encounter.identifier</b><br>
3803   * </p>
3804   */
3805  @SearchParamDefinition(name="identifier", path="Encounter.identifier", description="Identifier(s) by which this encounter is known", type="token" )
3806  public static final String SP_IDENTIFIER = "identifier";
3807 /**
3808   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
3809   * <p>
3810   * Description: <b>Identifier(s) by which this encounter is known</b><br>
3811   * Type: <b>token</b><br>
3812   * Path: <b>Encounter.identifier</b><br>
3813   * </p>
3814   */
3815  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
3816
3817 /**
3818   * Search parameter: <b>procedure</b>
3819   * <p>
3820   * Description: <b>Reason the encounter takes place (resource)</b><br>
3821   * Type: <b>reference</b><br>
3822   * Path: <b>Encounter.indication</b><br>
3823   * </p>
3824   */
3825  @SearchParamDefinition(name="procedure", path="Encounter.indication", description="Reason the encounter takes place (resource)", type="reference" )
3826  public static final String SP_PROCEDURE = "procedure";
3827 /**
3828   * <b>Fluent Client</b> search parameter constant for <b>procedure</b>
3829   * <p>
3830   * Description: <b>Reason the encounter takes place (resource)</b><br>
3831   * Type: <b>reference</b><br>
3832   * Path: <b>Encounter.indication</b><br>
3833   * </p>
3834   */
3835  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PROCEDURE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PROCEDURE);
3836
3837/**
3838   * Constant for fluent queries to be used to add include statements. Specifies
3839   * the path value of "<b>Encounter:procedure</b>".
3840   */
3841  public static final ca.uhn.fhir.model.api.Include INCLUDE_PROCEDURE = new ca.uhn.fhir.model.api.Include("Encounter:procedure").toLocked();
3842
3843 /**
3844   * Search parameter: <b>location-period</b>
3845   * <p>
3846   * Description: <b>Time period during which the patient was present at the location</b><br>
3847   * Type: <b>date</b><br>
3848   * Path: <b>Encounter.location.period</b><br>
3849   * </p>
3850   */
3851  @SearchParamDefinition(name="location-period", path="Encounter.location.period", description="Time period during which the patient was present at the location", type="date" )
3852  public static final String SP_LOCATION_PERIOD = "location-period";
3853 /**
3854   * <b>Fluent Client</b> search parameter constant for <b>location-period</b>
3855   * <p>
3856   * Description: <b>Time period during which the patient was present at the location</b><br>
3857   * Type: <b>date</b><br>
3858   * Path: <b>Encounter.location.period</b><br>
3859   * </p>
3860   */
3861  public static final ca.uhn.fhir.rest.gclient.DateClientParam LOCATION_PERIOD = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_LOCATION_PERIOD);
3862
3863
3864}