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