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