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