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