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