001package org.hl7.fhir.r5.model;
002
003
004/*
005  Copyright (c) 2011+, HL7, Inc.
006  All rights reserved.
007  
008  Redistribution and use in source and binary forms, with or without modification, \
009  are permitted provided that the following conditions are met:
010  
011   * Redistributions of source code must retain the above copyright notice, this \
012     list of conditions and the following disclaimer.
013   * Redistributions in binary form must reproduce the above copyright notice, \
014     this list of conditions and the following disclaimer in the documentation \
015     and/or other materials provided with the distribution.
016   * Neither the name of HL7 nor the names of its contributors may be used to 
017     endorse or promote products derived from this software without specific 
018     prior written permission.
019  
020  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
021  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
022  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
023  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
024  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
025  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
026  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
027  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
028  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
029  POSSIBILITY OF SUCH DAMAGE.
030  */
031
032// Generated on Thu, Mar 23, 2023 19:59+1100 for FHIR v5.0.0
033
034import java.util.ArrayList;
035import java.util.Date;
036import java.util.List;
037import org.hl7.fhir.utilities.Utilities;
038import org.hl7.fhir.r5.model.Enumerations.*;
039import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
040import org.hl7.fhir.exceptions.FHIRException;
041import org.hl7.fhir.instance.model.api.ICompositeType;
042import ca.uhn.fhir.model.api.annotation.ResourceDef;
043import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
044import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
045import ca.uhn.fhir.model.api.annotation.Child;
046import ca.uhn.fhir.model.api.annotation.ChildOrder;
047import ca.uhn.fhir.model.api.annotation.Description;
048import ca.uhn.fhir.model.api.annotation.Block;
049
050/**
051 * A record of significant events/milestones key data throughout the history of an Encounter
052 */
053@ResourceDef(name="EncounterHistory", profile="http://hl7.org/fhir/StructureDefinition/EncounterHistory")
054public class EncounterHistory extends DomainResource {
055
056    @Block()
057    public static class EncounterHistoryLocationComponent extends BackboneElement implements IBaseBackboneElement {
058        /**
059         * The location where the encounter takes place.
060         */
061        @Child(name = "location", type = {Location.class}, order=1, min=1, max=1, modifier=false, summary=false)
062        @Description(shortDefinition="Location the encounter takes place", formalDefinition="The location where the encounter takes place." )
063        protected Reference location;
064
065        /**
066         * This will be used to specify the required levels (bed/ward/room/etc.) desired to be recorded to simplify either messaging or query.
067         */
068        @Child(name = "form", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
069        @Description(shortDefinition="The physical type of the location (usually the level in the location hierarchy - bed, room, ward, virtual etc.)", formalDefinition="This will be used to specify the required levels (bed/ward/room/etc.) desired to be recorded to simplify either messaging or query." )
070        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/location-form")
071        protected CodeableConcept form;
072
073        private static final long serialVersionUID = -1306742681L;
074
075    /**
076     * Constructor
077     */
078      public EncounterHistoryLocationComponent() {
079        super();
080      }
081
082    /**
083     * Constructor
084     */
085      public EncounterHistoryLocationComponent(Reference location) {
086        super();
087        this.setLocation(location);
088      }
089
090        /**
091         * @return {@link #location} (The location where the encounter takes place.)
092         */
093        public Reference getLocation() { 
094          if (this.location == null)
095            if (Configuration.errorOnAutoCreate())
096              throw new Error("Attempt to auto-create EncounterHistoryLocationComponent.location");
097            else if (Configuration.doAutoCreate())
098              this.location = new Reference(); // cc
099          return this.location;
100        }
101
102        public boolean hasLocation() { 
103          return this.location != null && !this.location.isEmpty();
104        }
105
106        /**
107         * @param value {@link #location} (The location where the encounter takes place.)
108         */
109        public EncounterHistoryLocationComponent setLocation(Reference value) { 
110          this.location = value;
111          return this;
112        }
113
114        /**
115         * @return {@link #form} (This will be used to specify the required levels (bed/ward/room/etc.) desired to be recorded to simplify either messaging or query.)
116         */
117        public CodeableConcept getForm() { 
118          if (this.form == null)
119            if (Configuration.errorOnAutoCreate())
120              throw new Error("Attempt to auto-create EncounterHistoryLocationComponent.form");
121            else if (Configuration.doAutoCreate())
122              this.form = new CodeableConcept(); // cc
123          return this.form;
124        }
125
126        public boolean hasForm() { 
127          return this.form != null && !this.form.isEmpty();
128        }
129
130        /**
131         * @param value {@link #form} (This will be used to specify the required levels (bed/ward/room/etc.) desired to be recorded to simplify either messaging or query.)
132         */
133        public EncounterHistoryLocationComponent setForm(CodeableConcept value) { 
134          this.form = value;
135          return this;
136        }
137
138        protected void listChildren(List<Property> children) {
139          super.listChildren(children);
140          children.add(new Property("location", "Reference(Location)", "The location where the encounter takes place.", 0, 1, location));
141          children.add(new Property("form", "CodeableConcept", "This will be used to specify the required levels (bed/ward/room/etc.) desired to be recorded to simplify either messaging or query.", 0, 1, form));
142        }
143
144        @Override
145        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
146          switch (_hash) {
147          case 1901043637: /*location*/  return new Property("location", "Reference(Location)", "The location where the encounter takes place.", 0, 1, location);
148          case 3148996: /*form*/  return new Property("form", "CodeableConcept", "This will be used to specify the required levels (bed/ward/room/etc.) desired to be recorded to simplify either messaging or query.", 0, 1, form);
149          default: return super.getNamedProperty(_hash, _name, _checkValid);
150          }
151
152        }
153
154      @Override
155      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
156        switch (hash) {
157        case 1901043637: /*location*/ return this.location == null ? new Base[0] : new Base[] {this.location}; // Reference
158        case 3148996: /*form*/ return this.form == null ? new Base[0] : new Base[] {this.form}; // CodeableConcept
159        default: return super.getProperty(hash, name, checkValid);
160        }
161
162      }
163
164      @Override
165      public Base setProperty(int hash, String name, Base value) throws FHIRException {
166        switch (hash) {
167        case 1901043637: // location
168          this.location = TypeConvertor.castToReference(value); // Reference
169          return value;
170        case 3148996: // form
171          this.form = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
172          return value;
173        default: return super.setProperty(hash, name, value);
174        }
175
176      }
177
178      @Override
179      public Base setProperty(String name, Base value) throws FHIRException {
180        if (name.equals("location")) {
181          this.location = TypeConvertor.castToReference(value); // Reference
182        } else if (name.equals("form")) {
183          this.form = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
184        } else
185          return super.setProperty(name, value);
186        return value;
187      }
188
189      @Override
190      public Base makeProperty(int hash, String name) throws FHIRException {
191        switch (hash) {
192        case 1901043637:  return getLocation();
193        case 3148996:  return getForm();
194        default: return super.makeProperty(hash, name);
195        }
196
197      }
198
199      @Override
200      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
201        switch (hash) {
202        case 1901043637: /*location*/ return new String[] {"Reference"};
203        case 3148996: /*form*/ return new String[] {"CodeableConcept"};
204        default: return super.getTypesForProperty(hash, name);
205        }
206
207      }
208
209      @Override
210      public Base addChild(String name) throws FHIRException {
211        if (name.equals("location")) {
212          this.location = new Reference();
213          return this.location;
214        }
215        else if (name.equals("form")) {
216          this.form = new CodeableConcept();
217          return this.form;
218        }
219        else
220          return super.addChild(name);
221      }
222
223      public EncounterHistoryLocationComponent copy() {
224        EncounterHistoryLocationComponent dst = new EncounterHistoryLocationComponent();
225        copyValues(dst);
226        return dst;
227      }
228
229      public void copyValues(EncounterHistoryLocationComponent dst) {
230        super.copyValues(dst);
231        dst.location = location == null ? null : location.copy();
232        dst.form = form == null ? null : form.copy();
233      }
234
235      @Override
236      public boolean equalsDeep(Base other_) {
237        if (!super.equalsDeep(other_))
238          return false;
239        if (!(other_ instanceof EncounterHistoryLocationComponent))
240          return false;
241        EncounterHistoryLocationComponent o = (EncounterHistoryLocationComponent) other_;
242        return compareDeep(location, o.location, true) && compareDeep(form, o.form, true);
243      }
244
245      @Override
246      public boolean equalsShallow(Base other_) {
247        if (!super.equalsShallow(other_))
248          return false;
249        if (!(other_ instanceof EncounterHistoryLocationComponent))
250          return false;
251        EncounterHistoryLocationComponent o = (EncounterHistoryLocationComponent) other_;
252        return true;
253      }
254
255      public boolean isEmpty() {
256        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(location, form);
257      }
258
259  public String fhirType() {
260    return "EncounterHistory.location";
261
262  }
263
264  }
265
266    /**
267     * The Encounter associated with this set of historic values.
268     */
269    @Child(name = "encounter", type = {Encounter.class}, order=0, min=0, max=1, modifier=false, summary=false)
270    @Description(shortDefinition="The Encounter associated with this set of historic values", formalDefinition="The Encounter associated with this set of historic values." )
271    protected Reference encounter;
272
273    /**
274     * Identifier(s) by which this encounter is known.
275     */
276    @Child(name = "identifier", type = {Identifier.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
277    @Description(shortDefinition="Identifier(s) by which this encounter is known", formalDefinition="Identifier(s) by which this encounter is known." )
278    protected List<Identifier> identifier;
279
280    /**
281     * planned | in-progress | on-hold | discharged | completed | cancelled | discontinued | entered-in-error | unknown.
282     */
283    @Child(name = "status", type = {CodeType.class}, order=2, min=1, max=1, modifier=true, summary=true)
284    @Description(shortDefinition="planned | in-progress | on-hold | discharged | completed | cancelled | discontinued | entered-in-error | unknown", formalDefinition="planned | in-progress | on-hold | discharged | completed | cancelled | discontinued | entered-in-error | unknown." )
285    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/encounter-status")
286    protected Enumeration<EncounterStatus> status;
287
288    /**
289     * Concepts representing classification of patient encounter such as ambulatory (outpatient), inpatient, emergency, home health or others due to local variations.
290     */
291    @Child(name = "class", type = {CodeableConcept.class}, order=3, min=1, max=1, modifier=false, summary=true)
292    @Description(shortDefinition="Classification of patient encounter", formalDefinition="Concepts representing classification of patient encounter such as ambulatory (outpatient), inpatient, emergency, home health or others due to local variations." )
293    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://terminology.hl7.org/ValueSet/v3-ActEncounterCode")
294    protected CodeableConcept class_;
295
296    /**
297     * Specific type of encounter (e.g. e-mail consultation, surgical day-care, skilled nursing, rehabilitation).
298     */
299    @Child(name = "type", type = {CodeableConcept.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
300    @Description(shortDefinition="Specific type of encounter", formalDefinition="Specific type of encounter (e.g. e-mail consultation, surgical day-care, skilled nursing, rehabilitation)." )
301    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/encounter-type")
302    protected List<CodeableConcept> type;
303
304    /**
305     * Broad categorization of the service that is to be provided (e.g. cardiology).
306     */
307    @Child(name = "serviceType", type = {CodeableReference.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
308    @Description(shortDefinition="Specific type of service", formalDefinition="Broad categorization of the service that is to be provided (e.g. cardiology)." )
309    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/service-type")
310    protected List<CodeableReference> serviceType;
311
312    /**
313     * The patient or group related to this encounter. In some use-cases the patient MAY not be present, such as a case meeting about a patient between several practitioners or a careteam.
314     */
315    @Child(name = "subject", type = {Patient.class, Group.class}, order=6, min=0, max=1, modifier=false, summary=true)
316    @Description(shortDefinition="The patient or group related to this encounter", formalDefinition="The patient or group related to this encounter. In some use-cases the patient MAY not be present, such as a case meeting about a patient between several practitioners or a careteam." )
317    protected Reference subject;
318
319    /**
320     * The subjectStatus value can be used to track the patient's status within the encounter. It details whether the patient has arrived or departed, has been triaged or is currently in a waiting status.
321     */
322    @Child(name = "subjectStatus", type = {CodeableConcept.class}, order=7, min=0, max=1, modifier=false, summary=false)
323    @Description(shortDefinition="The current status of the subject in relation to the Encounter", formalDefinition="The subjectStatus value can be used to track the patient's status within the encounter. It details whether the patient has arrived or departed, has been triaged or is currently in a waiting status." )
324    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/encounter-subject-status")
325    protected CodeableConcept subjectStatus;
326
327    /**
328     * The start and end time associated with this set of values associated with the encounter, may be different to the planned times for various reasons.
329     */
330    @Child(name = "actualPeriod", type = {Period.class}, order=8, min=0, max=1, modifier=false, summary=false)
331    @Description(shortDefinition="The actual start and end time associated with this set of values associated with the encounter", formalDefinition="The start and end time associated with this set of values associated with the encounter, may be different to the planned times for various reasons." )
332    protected Period actualPeriod;
333
334    /**
335     * The planned start date/time (or admission date) of the encounter.
336     */
337    @Child(name = "plannedStartDate", type = {DateTimeType.class}, order=9, min=0, max=1, modifier=false, summary=false)
338    @Description(shortDefinition="The planned start date/time (or admission date) of the encounter", formalDefinition="The planned start date/time (or admission date) of the encounter." )
339    protected DateTimeType plannedStartDate;
340
341    /**
342     * The planned end date/time (or discharge date) of the encounter.
343     */
344    @Child(name = "plannedEndDate", type = {DateTimeType.class}, order=10, min=0, max=1, modifier=false, summary=false)
345    @Description(shortDefinition="The planned end date/time (or discharge date) of the encounter", formalDefinition="The planned end date/time (or discharge date) of the encounter." )
346    protected DateTimeType plannedEndDate;
347
348    /**
349     * Actual quantity of time the encounter lasted. This excludes the time during leaves of absence.
350
351When missing it is the time in between the start and end values.
352     */
353    @Child(name = "length", type = {Duration.class}, order=11, min=0, max=1, modifier=false, summary=false)
354    @Description(shortDefinition="Actual quantity of time the encounter lasted (less time absent)", formalDefinition="Actual quantity of time the encounter lasted. This excludes the time during leaves of absence.\r\rWhen missing it is the time in between the start and end values." )
355    protected Duration length;
356
357    /**
358     * The location of the patient at this point in the encounter, the multiple cardinality permits de-normalizing the levels of the location hierarchy, such as site/ward/room/bed.
359     */
360    @Child(name = "location", type = {}, order=12, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
361    @Description(shortDefinition="Location of the patient at this point in the encounter", formalDefinition="The location of the patient at this point in the encounter, the multiple cardinality permits de-normalizing the levels of the location hierarchy, such as site/ward/room/bed." )
362    protected List<EncounterHistoryLocationComponent> location;
363
364    private static final long serialVersionUID = 775989939L;
365
366  /**
367   * Constructor
368   */
369    public EncounterHistory() {
370      super();
371    }
372
373  /**
374   * Constructor
375   */
376    public EncounterHistory(EncounterStatus status, CodeableConcept class_) {
377      super();
378      this.setStatus(status);
379      this.setClass_(class_);
380    }
381
382    /**
383     * @return {@link #encounter} (The Encounter associated with this set of historic values.)
384     */
385    public Reference getEncounter() { 
386      if (this.encounter == null)
387        if (Configuration.errorOnAutoCreate())
388          throw new Error("Attempt to auto-create EncounterHistory.encounter");
389        else if (Configuration.doAutoCreate())
390          this.encounter = new Reference(); // cc
391      return this.encounter;
392    }
393
394    public boolean hasEncounter() { 
395      return this.encounter != null && !this.encounter.isEmpty();
396    }
397
398    /**
399     * @param value {@link #encounter} (The Encounter associated with this set of historic values.)
400     */
401    public EncounterHistory setEncounter(Reference value) { 
402      this.encounter = value;
403      return this;
404    }
405
406    /**
407     * @return {@link #identifier} (Identifier(s) by which this encounter is known.)
408     */
409    public List<Identifier> getIdentifier() { 
410      if (this.identifier == null)
411        this.identifier = new ArrayList<Identifier>();
412      return this.identifier;
413    }
414
415    /**
416     * @return Returns a reference to <code>this</code> for easy method chaining
417     */
418    public EncounterHistory setIdentifier(List<Identifier> theIdentifier) { 
419      this.identifier = theIdentifier;
420      return this;
421    }
422
423    public boolean hasIdentifier() { 
424      if (this.identifier == null)
425        return false;
426      for (Identifier item : this.identifier)
427        if (!item.isEmpty())
428          return true;
429      return false;
430    }
431
432    public Identifier addIdentifier() { //3
433      Identifier t = new Identifier();
434      if (this.identifier == null)
435        this.identifier = new ArrayList<Identifier>();
436      this.identifier.add(t);
437      return t;
438    }
439
440    public EncounterHistory addIdentifier(Identifier t) { //3
441      if (t == null)
442        return this;
443      if (this.identifier == null)
444        this.identifier = new ArrayList<Identifier>();
445      this.identifier.add(t);
446      return this;
447    }
448
449    /**
450     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist {3}
451     */
452    public Identifier getIdentifierFirstRep() { 
453      if (getIdentifier().isEmpty()) {
454        addIdentifier();
455      }
456      return getIdentifier().get(0);
457    }
458
459    /**
460     * @return {@link #status} (planned | in-progress | on-hold | discharged | completed | cancelled | discontinued | entered-in-error | unknown.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
461     */
462    public Enumeration<EncounterStatus> getStatusElement() { 
463      if (this.status == null)
464        if (Configuration.errorOnAutoCreate())
465          throw new Error("Attempt to auto-create EncounterHistory.status");
466        else if (Configuration.doAutoCreate())
467          this.status = new Enumeration<EncounterStatus>(new EncounterStatusEnumFactory()); // bb
468      return this.status;
469    }
470
471    public boolean hasStatusElement() { 
472      return this.status != null && !this.status.isEmpty();
473    }
474
475    public boolean hasStatus() { 
476      return this.status != null && !this.status.isEmpty();
477    }
478
479    /**
480     * @param value {@link #status} (planned | in-progress | on-hold | discharged | completed | cancelled | discontinued | entered-in-error | unknown.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
481     */
482    public EncounterHistory setStatusElement(Enumeration<EncounterStatus> value) { 
483      this.status = value;
484      return this;
485    }
486
487    /**
488     * @return planned | in-progress | on-hold | discharged | completed | cancelled | discontinued | entered-in-error | unknown.
489     */
490    public EncounterStatus getStatus() { 
491      return this.status == null ? null : this.status.getValue();
492    }
493
494    /**
495     * @param value planned | in-progress | on-hold | discharged | completed | cancelled | discontinued | entered-in-error | unknown.
496     */
497    public EncounterHistory setStatus(EncounterStatus value) { 
498        if (this.status == null)
499          this.status = new Enumeration<EncounterStatus>(new EncounterStatusEnumFactory());
500        this.status.setValue(value);
501      return this;
502    }
503
504    /**
505     * @return {@link #class_} (Concepts representing classification of patient encounter such as ambulatory (outpatient), inpatient, emergency, home health or others due to local variations.)
506     */
507    public CodeableConcept getClass_() { 
508      if (this.class_ == null)
509        if (Configuration.errorOnAutoCreate())
510          throw new Error("Attempt to auto-create EncounterHistory.class_");
511        else if (Configuration.doAutoCreate())
512          this.class_ = new CodeableConcept(); // cc
513      return this.class_;
514    }
515
516    public boolean hasClass_() { 
517      return this.class_ != null && !this.class_.isEmpty();
518    }
519
520    /**
521     * @param value {@link #class_} (Concepts representing classification of patient encounter such as ambulatory (outpatient), inpatient, emergency, home health or others due to local variations.)
522     */
523    public EncounterHistory setClass_(CodeableConcept value) { 
524      this.class_ = value;
525      return this;
526    }
527
528    /**
529     * @return {@link #type} (Specific type of encounter (e.g. e-mail consultation, surgical day-care, skilled nursing, rehabilitation).)
530     */
531    public List<CodeableConcept> getType() { 
532      if (this.type == null)
533        this.type = new ArrayList<CodeableConcept>();
534      return this.type;
535    }
536
537    /**
538     * @return Returns a reference to <code>this</code> for easy method chaining
539     */
540    public EncounterHistory setType(List<CodeableConcept> theType) { 
541      this.type = theType;
542      return this;
543    }
544
545    public boolean hasType() { 
546      if (this.type == null)
547        return false;
548      for (CodeableConcept item : this.type)
549        if (!item.isEmpty())
550          return true;
551      return false;
552    }
553
554    public CodeableConcept addType() { //3
555      CodeableConcept t = new CodeableConcept();
556      if (this.type == null)
557        this.type = new ArrayList<CodeableConcept>();
558      this.type.add(t);
559      return t;
560    }
561
562    public EncounterHistory addType(CodeableConcept t) { //3
563      if (t == null)
564        return this;
565      if (this.type == null)
566        this.type = new ArrayList<CodeableConcept>();
567      this.type.add(t);
568      return this;
569    }
570
571    /**
572     * @return The first repetition of repeating field {@link #type}, creating it if it does not already exist {3}
573     */
574    public CodeableConcept getTypeFirstRep() { 
575      if (getType().isEmpty()) {
576        addType();
577      }
578      return getType().get(0);
579    }
580
581    /**
582     * @return {@link #serviceType} (Broad categorization of the service that is to be provided (e.g. cardiology).)
583     */
584    public List<CodeableReference> getServiceType() { 
585      if (this.serviceType == null)
586        this.serviceType = new ArrayList<CodeableReference>();
587      return this.serviceType;
588    }
589
590    /**
591     * @return Returns a reference to <code>this</code> for easy method chaining
592     */
593    public EncounterHistory setServiceType(List<CodeableReference> theServiceType) { 
594      this.serviceType = theServiceType;
595      return this;
596    }
597
598    public boolean hasServiceType() { 
599      if (this.serviceType == null)
600        return false;
601      for (CodeableReference item : this.serviceType)
602        if (!item.isEmpty())
603          return true;
604      return false;
605    }
606
607    public CodeableReference addServiceType() { //3
608      CodeableReference t = new CodeableReference();
609      if (this.serviceType == null)
610        this.serviceType = new ArrayList<CodeableReference>();
611      this.serviceType.add(t);
612      return t;
613    }
614
615    public EncounterHistory addServiceType(CodeableReference t) { //3
616      if (t == null)
617        return this;
618      if (this.serviceType == null)
619        this.serviceType = new ArrayList<CodeableReference>();
620      this.serviceType.add(t);
621      return this;
622    }
623
624    /**
625     * @return The first repetition of repeating field {@link #serviceType}, creating it if it does not already exist {3}
626     */
627    public CodeableReference getServiceTypeFirstRep() { 
628      if (getServiceType().isEmpty()) {
629        addServiceType();
630      }
631      return getServiceType().get(0);
632    }
633
634    /**
635     * @return {@link #subject} (The patient or group related to this encounter. In some use-cases the patient MAY not be present, such as a case meeting about a patient between several practitioners or a careteam.)
636     */
637    public Reference getSubject() { 
638      if (this.subject == null)
639        if (Configuration.errorOnAutoCreate())
640          throw new Error("Attempt to auto-create EncounterHistory.subject");
641        else if (Configuration.doAutoCreate())
642          this.subject = new Reference(); // cc
643      return this.subject;
644    }
645
646    public boolean hasSubject() { 
647      return this.subject != null && !this.subject.isEmpty();
648    }
649
650    /**
651     * @param value {@link #subject} (The patient or group related to this encounter. In some use-cases the patient MAY not be present, such as a case meeting about a patient between several practitioners or a careteam.)
652     */
653    public EncounterHistory setSubject(Reference value) { 
654      this.subject = value;
655      return this;
656    }
657
658    /**
659     * @return {@link #subjectStatus} (The subjectStatus value can be used to track the patient's status within the encounter. It details whether the patient has arrived or departed, has been triaged or is currently in a waiting status.)
660     */
661    public CodeableConcept getSubjectStatus() { 
662      if (this.subjectStatus == null)
663        if (Configuration.errorOnAutoCreate())
664          throw new Error("Attempt to auto-create EncounterHistory.subjectStatus");
665        else if (Configuration.doAutoCreate())
666          this.subjectStatus = new CodeableConcept(); // cc
667      return this.subjectStatus;
668    }
669
670    public boolean hasSubjectStatus() { 
671      return this.subjectStatus != null && !this.subjectStatus.isEmpty();
672    }
673
674    /**
675     * @param value {@link #subjectStatus} (The subjectStatus value can be used to track the patient's status within the encounter. It details whether the patient has arrived or departed, has been triaged or is currently in a waiting status.)
676     */
677    public EncounterHistory setSubjectStatus(CodeableConcept value) { 
678      this.subjectStatus = value;
679      return this;
680    }
681
682    /**
683     * @return {@link #actualPeriod} (The start and end time associated with this set of values associated with the encounter, may be different to the planned times for various reasons.)
684     */
685    public Period getActualPeriod() { 
686      if (this.actualPeriod == null)
687        if (Configuration.errorOnAutoCreate())
688          throw new Error("Attempt to auto-create EncounterHistory.actualPeriod");
689        else if (Configuration.doAutoCreate())
690          this.actualPeriod = new Period(); // cc
691      return this.actualPeriod;
692    }
693
694    public boolean hasActualPeriod() { 
695      return this.actualPeriod != null && !this.actualPeriod.isEmpty();
696    }
697
698    /**
699     * @param value {@link #actualPeriod} (The start and end time associated with this set of values associated with the encounter, may be different to the planned times for various reasons.)
700     */
701    public EncounterHistory setActualPeriod(Period value) { 
702      this.actualPeriod = value;
703      return this;
704    }
705
706    /**
707     * @return {@link #plannedStartDate} (The planned start date/time (or admission date) of the encounter.). This is the underlying object with id, value and extensions. The accessor "getPlannedStartDate" gives direct access to the value
708     */
709    public DateTimeType getPlannedStartDateElement() { 
710      if (this.plannedStartDate == null)
711        if (Configuration.errorOnAutoCreate())
712          throw new Error("Attempt to auto-create EncounterHistory.plannedStartDate");
713        else if (Configuration.doAutoCreate())
714          this.plannedStartDate = new DateTimeType(); // bb
715      return this.plannedStartDate;
716    }
717
718    public boolean hasPlannedStartDateElement() { 
719      return this.plannedStartDate != null && !this.plannedStartDate.isEmpty();
720    }
721
722    public boolean hasPlannedStartDate() { 
723      return this.plannedStartDate != null && !this.plannedStartDate.isEmpty();
724    }
725
726    /**
727     * @param value {@link #plannedStartDate} (The planned start date/time (or admission date) of the encounter.). This is the underlying object with id, value and extensions. The accessor "getPlannedStartDate" gives direct access to the value
728     */
729    public EncounterHistory setPlannedStartDateElement(DateTimeType value) { 
730      this.plannedStartDate = value;
731      return this;
732    }
733
734    /**
735     * @return The planned start date/time (or admission date) of the encounter.
736     */
737    public Date getPlannedStartDate() { 
738      return this.plannedStartDate == null ? null : this.plannedStartDate.getValue();
739    }
740
741    /**
742     * @param value The planned start date/time (or admission date) of the encounter.
743     */
744    public EncounterHistory setPlannedStartDate(Date value) { 
745      if (value == null)
746        this.plannedStartDate = null;
747      else {
748        if (this.plannedStartDate == null)
749          this.plannedStartDate = new DateTimeType();
750        this.plannedStartDate.setValue(value);
751      }
752      return this;
753    }
754
755    /**
756     * @return {@link #plannedEndDate} (The planned end date/time (or discharge date) of the encounter.). This is the underlying object with id, value and extensions. The accessor "getPlannedEndDate" gives direct access to the value
757     */
758    public DateTimeType getPlannedEndDateElement() { 
759      if (this.plannedEndDate == null)
760        if (Configuration.errorOnAutoCreate())
761          throw new Error("Attempt to auto-create EncounterHistory.plannedEndDate");
762        else if (Configuration.doAutoCreate())
763          this.plannedEndDate = new DateTimeType(); // bb
764      return this.plannedEndDate;
765    }
766
767    public boolean hasPlannedEndDateElement() { 
768      return this.plannedEndDate != null && !this.plannedEndDate.isEmpty();
769    }
770
771    public boolean hasPlannedEndDate() { 
772      return this.plannedEndDate != null && !this.plannedEndDate.isEmpty();
773    }
774
775    /**
776     * @param value {@link #plannedEndDate} (The planned end date/time (or discharge date) of the encounter.). This is the underlying object with id, value and extensions. The accessor "getPlannedEndDate" gives direct access to the value
777     */
778    public EncounterHistory setPlannedEndDateElement(DateTimeType value) { 
779      this.plannedEndDate = value;
780      return this;
781    }
782
783    /**
784     * @return The planned end date/time (or discharge date) of the encounter.
785     */
786    public Date getPlannedEndDate() { 
787      return this.plannedEndDate == null ? null : this.plannedEndDate.getValue();
788    }
789
790    /**
791     * @param value The planned end date/time (or discharge date) of the encounter.
792     */
793    public EncounterHistory setPlannedEndDate(Date value) { 
794      if (value == null)
795        this.plannedEndDate = null;
796      else {
797        if (this.plannedEndDate == null)
798          this.plannedEndDate = new DateTimeType();
799        this.plannedEndDate.setValue(value);
800      }
801      return this;
802    }
803
804    /**
805     * @return {@link #length} (Actual quantity of time the encounter lasted. This excludes the time during leaves of absence.
806
807When missing it is the time in between the start and end values.)
808     */
809    public Duration getLength() { 
810      if (this.length == null)
811        if (Configuration.errorOnAutoCreate())
812          throw new Error("Attempt to auto-create EncounterHistory.length");
813        else if (Configuration.doAutoCreate())
814          this.length = new Duration(); // cc
815      return this.length;
816    }
817
818    public boolean hasLength() { 
819      return this.length != null && !this.length.isEmpty();
820    }
821
822    /**
823     * @param value {@link #length} (Actual quantity of time the encounter lasted. This excludes the time during leaves of absence.
824
825When missing it is the time in between the start and end values.)
826     */
827    public EncounterHistory setLength(Duration value) { 
828      this.length = value;
829      return this;
830    }
831
832    /**
833     * @return {@link #location} (The location of the patient at this point in the encounter, the multiple cardinality permits de-normalizing the levels of the location hierarchy, such as site/ward/room/bed.)
834     */
835    public List<EncounterHistoryLocationComponent> getLocation() { 
836      if (this.location == null)
837        this.location = new ArrayList<EncounterHistoryLocationComponent>();
838      return this.location;
839    }
840
841    /**
842     * @return Returns a reference to <code>this</code> for easy method chaining
843     */
844    public EncounterHistory setLocation(List<EncounterHistoryLocationComponent> theLocation) { 
845      this.location = theLocation;
846      return this;
847    }
848
849    public boolean hasLocation() { 
850      if (this.location == null)
851        return false;
852      for (EncounterHistoryLocationComponent item : this.location)
853        if (!item.isEmpty())
854          return true;
855      return false;
856    }
857
858    public EncounterHistoryLocationComponent addLocation() { //3
859      EncounterHistoryLocationComponent t = new EncounterHistoryLocationComponent();
860      if (this.location == null)
861        this.location = new ArrayList<EncounterHistoryLocationComponent>();
862      this.location.add(t);
863      return t;
864    }
865
866    public EncounterHistory addLocation(EncounterHistoryLocationComponent t) { //3
867      if (t == null)
868        return this;
869      if (this.location == null)
870        this.location = new ArrayList<EncounterHistoryLocationComponent>();
871      this.location.add(t);
872      return this;
873    }
874
875    /**
876     * @return The first repetition of repeating field {@link #location}, creating it if it does not already exist {3}
877     */
878    public EncounterHistoryLocationComponent getLocationFirstRep() { 
879      if (getLocation().isEmpty()) {
880        addLocation();
881      }
882      return getLocation().get(0);
883    }
884
885      protected void listChildren(List<Property> children) {
886        super.listChildren(children);
887        children.add(new Property("encounter", "Reference(Encounter)", "The Encounter associated with this set of historic values.", 0, 1, encounter));
888        children.add(new Property("identifier", "Identifier", "Identifier(s) by which this encounter is known.", 0, java.lang.Integer.MAX_VALUE, identifier));
889        children.add(new Property("status", "code", "planned | in-progress | on-hold | discharged | completed | cancelled | discontinued | entered-in-error | unknown.", 0, 1, status));
890        children.add(new Property("class", "CodeableConcept", "Concepts representing classification of patient encounter such as ambulatory (outpatient), inpatient, emergency, home health or others due to local variations.", 0, 1, class_));
891        children.add(new Property("type", "CodeableConcept", "Specific type of encounter (e.g. e-mail consultation, surgical day-care, skilled nursing, rehabilitation).", 0, java.lang.Integer.MAX_VALUE, type));
892        children.add(new Property("serviceType", "CodeableReference(HealthcareService)", "Broad categorization of the service that is to be provided (e.g. cardiology).", 0, java.lang.Integer.MAX_VALUE, serviceType));
893        children.add(new Property("subject", "Reference(Patient|Group)", "The patient or group related to this encounter. In some use-cases the patient MAY not be present, such as a case meeting about a patient between several practitioners or a careteam.", 0, 1, subject));
894        children.add(new Property("subjectStatus", "CodeableConcept", "The subjectStatus value can be used to track the patient's status within the encounter. It details whether the patient has arrived or departed, has been triaged or is currently in a waiting status.", 0, 1, subjectStatus));
895        children.add(new Property("actualPeriod", "Period", "The start and end time associated with this set of values associated with the encounter, may be different to the planned times for various reasons.", 0, 1, actualPeriod));
896        children.add(new Property("plannedStartDate", "dateTime", "The planned start date/time (or admission date) of the encounter.", 0, 1, plannedStartDate));
897        children.add(new Property("plannedEndDate", "dateTime", "The planned end date/time (or discharge date) of the encounter.", 0, 1, plannedEndDate));
898        children.add(new Property("length", "Duration", "Actual quantity of time the encounter lasted. This excludes the time during leaves of absence.\r\rWhen missing it is the time in between the start and end values.", 0, 1, length));
899        children.add(new Property("location", "", "The location of the patient at this point in the encounter, the multiple cardinality permits de-normalizing the levels of the location hierarchy, such as site/ward/room/bed.", 0, java.lang.Integer.MAX_VALUE, location));
900      }
901
902      @Override
903      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
904        switch (_hash) {
905        case 1524132147: /*encounter*/  return new Property("encounter", "Reference(Encounter)", "The Encounter associated with this set of historic values.", 0, 1, encounter);
906        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Identifier(s) by which this encounter is known.", 0, java.lang.Integer.MAX_VALUE, identifier);
907        case -892481550: /*status*/  return new Property("status", "code", "planned | in-progress | on-hold | discharged | completed | cancelled | discontinued | entered-in-error | unknown.", 0, 1, status);
908        case 94742904: /*class*/  return new Property("class", "CodeableConcept", "Concepts representing classification of patient encounter such as ambulatory (outpatient), inpatient, emergency, home health or others due to local variations.", 0, 1, class_);
909        case 3575610: /*type*/  return new Property("type", "CodeableConcept", "Specific type of encounter (e.g. e-mail consultation, surgical day-care, skilled nursing, rehabilitation).", 0, java.lang.Integer.MAX_VALUE, type);
910        case -1928370289: /*serviceType*/  return new Property("serviceType", "CodeableReference(HealthcareService)", "Broad categorization of the service that is to be provided (e.g. cardiology).", 0, java.lang.Integer.MAX_VALUE, serviceType);
911        case -1867885268: /*subject*/  return new Property("subject", "Reference(Patient|Group)", "The patient or group related to this encounter. In some use-cases the patient MAY not be present, such as a case meeting about a patient between several practitioners or a careteam.", 0, 1, subject);
912        case 110854206: /*subjectStatus*/  return new Property("subjectStatus", "CodeableConcept", "The subjectStatus value can be used to track the patient's status within the encounter. It details whether the patient has arrived or departed, has been triaged or is currently in a waiting status.", 0, 1, subjectStatus);
913        case 789194991: /*actualPeriod*/  return new Property("actualPeriod", "Period", "The start and end time associated with this set of values associated with the encounter, may be different to the planned times for various reasons.", 0, 1, actualPeriod);
914        case 460857804: /*plannedStartDate*/  return new Property("plannedStartDate", "dateTime", "The planned start date/time (or admission date) of the encounter.", 0, 1, plannedStartDate);
915        case 1657534661: /*plannedEndDate*/  return new Property("plannedEndDate", "dateTime", "The planned end date/time (or discharge date) of the encounter.", 0, 1, plannedEndDate);
916        case -1106363674: /*length*/  return new Property("length", "Duration", "Actual quantity of time the encounter lasted. This excludes the time during leaves of absence.\r\rWhen missing it is the time in between the start and end values.", 0, 1, length);
917        case 1901043637: /*location*/  return new Property("location", "", "The location of the patient at this point in the encounter, the multiple cardinality permits de-normalizing the levels of the location hierarchy, such as site/ward/room/bed.", 0, java.lang.Integer.MAX_VALUE, location);
918        default: return super.getNamedProperty(_hash, _name, _checkValid);
919        }
920
921      }
922
923      @Override
924      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
925        switch (hash) {
926        case 1524132147: /*encounter*/ return this.encounter == null ? new Base[0] : new Base[] {this.encounter}; // Reference
927        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
928        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<EncounterStatus>
929        case 94742904: /*class*/ return this.class_ == null ? new Base[0] : new Base[] {this.class_}; // CodeableConcept
930        case 3575610: /*type*/ return this.type == null ? new Base[0] : this.type.toArray(new Base[this.type.size()]); // CodeableConcept
931        case -1928370289: /*serviceType*/ return this.serviceType == null ? new Base[0] : this.serviceType.toArray(new Base[this.serviceType.size()]); // CodeableReference
932        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
933        case 110854206: /*subjectStatus*/ return this.subjectStatus == null ? new Base[0] : new Base[] {this.subjectStatus}; // CodeableConcept
934        case 789194991: /*actualPeriod*/ return this.actualPeriod == null ? new Base[0] : new Base[] {this.actualPeriod}; // Period
935        case 460857804: /*plannedStartDate*/ return this.plannedStartDate == null ? new Base[0] : new Base[] {this.plannedStartDate}; // DateTimeType
936        case 1657534661: /*plannedEndDate*/ return this.plannedEndDate == null ? new Base[0] : new Base[] {this.plannedEndDate}; // DateTimeType
937        case -1106363674: /*length*/ return this.length == null ? new Base[0] : new Base[] {this.length}; // Duration
938        case 1901043637: /*location*/ return this.location == null ? new Base[0] : this.location.toArray(new Base[this.location.size()]); // EncounterHistoryLocationComponent
939        default: return super.getProperty(hash, name, checkValid);
940        }
941
942      }
943
944      @Override
945      public Base setProperty(int hash, String name, Base value) throws FHIRException {
946        switch (hash) {
947        case 1524132147: // encounter
948          this.encounter = TypeConvertor.castToReference(value); // Reference
949          return value;
950        case -1618432855: // identifier
951          this.getIdentifier().add(TypeConvertor.castToIdentifier(value)); // Identifier
952          return value;
953        case -892481550: // status
954          value = new EncounterStatusEnumFactory().fromType(TypeConvertor.castToCode(value));
955          this.status = (Enumeration) value; // Enumeration<EncounterStatus>
956          return value;
957        case 94742904: // class
958          this.class_ = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
959          return value;
960        case 3575610: // type
961          this.getType().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
962          return value;
963        case -1928370289: // serviceType
964          this.getServiceType().add(TypeConvertor.castToCodeableReference(value)); // CodeableReference
965          return value;
966        case -1867885268: // subject
967          this.subject = TypeConvertor.castToReference(value); // Reference
968          return value;
969        case 110854206: // subjectStatus
970          this.subjectStatus = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
971          return value;
972        case 789194991: // actualPeriod
973          this.actualPeriod = TypeConvertor.castToPeriod(value); // Period
974          return value;
975        case 460857804: // plannedStartDate
976          this.plannedStartDate = TypeConvertor.castToDateTime(value); // DateTimeType
977          return value;
978        case 1657534661: // plannedEndDate
979          this.plannedEndDate = TypeConvertor.castToDateTime(value); // DateTimeType
980          return value;
981        case -1106363674: // length
982          this.length = TypeConvertor.castToDuration(value); // Duration
983          return value;
984        case 1901043637: // location
985          this.getLocation().add((EncounterHistoryLocationComponent) value); // EncounterHistoryLocationComponent
986          return value;
987        default: return super.setProperty(hash, name, value);
988        }
989
990      }
991
992      @Override
993      public Base setProperty(String name, Base value) throws FHIRException {
994        if (name.equals("encounter")) {
995          this.encounter = TypeConvertor.castToReference(value); // Reference
996        } else if (name.equals("identifier")) {
997          this.getIdentifier().add(TypeConvertor.castToIdentifier(value));
998        } else if (name.equals("status")) {
999          value = new EncounterStatusEnumFactory().fromType(TypeConvertor.castToCode(value));
1000          this.status = (Enumeration) value; // Enumeration<EncounterStatus>
1001        } else if (name.equals("class")) {
1002          this.class_ = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1003        } else if (name.equals("type")) {
1004          this.getType().add(TypeConvertor.castToCodeableConcept(value));
1005        } else if (name.equals("serviceType")) {
1006          this.getServiceType().add(TypeConvertor.castToCodeableReference(value));
1007        } else if (name.equals("subject")) {
1008          this.subject = TypeConvertor.castToReference(value); // Reference
1009        } else if (name.equals("subjectStatus")) {
1010          this.subjectStatus = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1011        } else if (name.equals("actualPeriod")) {
1012          this.actualPeriod = TypeConvertor.castToPeriod(value); // Period
1013        } else if (name.equals("plannedStartDate")) {
1014          this.plannedStartDate = TypeConvertor.castToDateTime(value); // DateTimeType
1015        } else if (name.equals("plannedEndDate")) {
1016          this.plannedEndDate = TypeConvertor.castToDateTime(value); // DateTimeType
1017        } else if (name.equals("length")) {
1018          this.length = TypeConvertor.castToDuration(value); // Duration
1019        } else if (name.equals("location")) {
1020          this.getLocation().add((EncounterHistoryLocationComponent) value);
1021        } else
1022          return super.setProperty(name, value);
1023        return value;
1024      }
1025
1026      @Override
1027      public Base makeProperty(int hash, String name) throws FHIRException {
1028        switch (hash) {
1029        case 1524132147:  return getEncounter();
1030        case -1618432855:  return addIdentifier(); 
1031        case -892481550:  return getStatusElement();
1032        case 94742904:  return getClass_();
1033        case 3575610:  return addType(); 
1034        case -1928370289:  return addServiceType(); 
1035        case -1867885268:  return getSubject();
1036        case 110854206:  return getSubjectStatus();
1037        case 789194991:  return getActualPeriod();
1038        case 460857804:  return getPlannedStartDateElement();
1039        case 1657534661:  return getPlannedEndDateElement();
1040        case -1106363674:  return getLength();
1041        case 1901043637:  return addLocation(); 
1042        default: return super.makeProperty(hash, name);
1043        }
1044
1045      }
1046
1047      @Override
1048      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1049        switch (hash) {
1050        case 1524132147: /*encounter*/ return new String[] {"Reference"};
1051        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
1052        case -892481550: /*status*/ return new String[] {"code"};
1053        case 94742904: /*class*/ return new String[] {"CodeableConcept"};
1054        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
1055        case -1928370289: /*serviceType*/ return new String[] {"CodeableReference"};
1056        case -1867885268: /*subject*/ return new String[] {"Reference"};
1057        case 110854206: /*subjectStatus*/ return new String[] {"CodeableConcept"};
1058        case 789194991: /*actualPeriod*/ return new String[] {"Period"};
1059        case 460857804: /*plannedStartDate*/ return new String[] {"dateTime"};
1060        case 1657534661: /*plannedEndDate*/ return new String[] {"dateTime"};
1061        case -1106363674: /*length*/ return new String[] {"Duration"};
1062        case 1901043637: /*location*/ return new String[] {};
1063        default: return super.getTypesForProperty(hash, name);
1064        }
1065
1066      }
1067
1068      @Override
1069      public Base addChild(String name) throws FHIRException {
1070        if (name.equals("encounter")) {
1071          this.encounter = new Reference();
1072          return this.encounter;
1073        }
1074        else if (name.equals("identifier")) {
1075          return addIdentifier();
1076        }
1077        else if (name.equals("status")) {
1078          throw new FHIRException("Cannot call addChild on a singleton property EncounterHistory.status");
1079        }
1080        else if (name.equals("class")) {
1081          this.class_ = new CodeableConcept();
1082          return this.class_;
1083        }
1084        else if (name.equals("type")) {
1085          return addType();
1086        }
1087        else if (name.equals("serviceType")) {
1088          return addServiceType();
1089        }
1090        else if (name.equals("subject")) {
1091          this.subject = new Reference();
1092          return this.subject;
1093        }
1094        else if (name.equals("subjectStatus")) {
1095          this.subjectStatus = new CodeableConcept();
1096          return this.subjectStatus;
1097        }
1098        else if (name.equals("actualPeriod")) {
1099          this.actualPeriod = new Period();
1100          return this.actualPeriod;
1101        }
1102        else if (name.equals("plannedStartDate")) {
1103          throw new FHIRException("Cannot call addChild on a singleton property EncounterHistory.plannedStartDate");
1104        }
1105        else if (name.equals("plannedEndDate")) {
1106          throw new FHIRException("Cannot call addChild on a singleton property EncounterHistory.plannedEndDate");
1107        }
1108        else if (name.equals("length")) {
1109          this.length = new Duration();
1110          return this.length;
1111        }
1112        else if (name.equals("location")) {
1113          return addLocation();
1114        }
1115        else
1116          return super.addChild(name);
1117      }
1118
1119  public String fhirType() {
1120    return "EncounterHistory";
1121
1122  }
1123
1124      public EncounterHistory copy() {
1125        EncounterHistory dst = new EncounterHistory();
1126        copyValues(dst);
1127        return dst;
1128      }
1129
1130      public void copyValues(EncounterHistory dst) {
1131        super.copyValues(dst);
1132        dst.encounter = encounter == null ? null : encounter.copy();
1133        if (identifier != null) {
1134          dst.identifier = new ArrayList<Identifier>();
1135          for (Identifier i : identifier)
1136            dst.identifier.add(i.copy());
1137        };
1138        dst.status = status == null ? null : status.copy();
1139        dst.class_ = class_ == null ? null : class_.copy();
1140        if (type != null) {
1141          dst.type = new ArrayList<CodeableConcept>();
1142          for (CodeableConcept i : type)
1143            dst.type.add(i.copy());
1144        };
1145        if (serviceType != null) {
1146          dst.serviceType = new ArrayList<CodeableReference>();
1147          for (CodeableReference i : serviceType)
1148            dst.serviceType.add(i.copy());
1149        };
1150        dst.subject = subject == null ? null : subject.copy();
1151        dst.subjectStatus = subjectStatus == null ? null : subjectStatus.copy();
1152        dst.actualPeriod = actualPeriod == null ? null : actualPeriod.copy();
1153        dst.plannedStartDate = plannedStartDate == null ? null : plannedStartDate.copy();
1154        dst.plannedEndDate = plannedEndDate == null ? null : plannedEndDate.copy();
1155        dst.length = length == null ? null : length.copy();
1156        if (location != null) {
1157          dst.location = new ArrayList<EncounterHistoryLocationComponent>();
1158          for (EncounterHistoryLocationComponent i : location)
1159            dst.location.add(i.copy());
1160        };
1161      }
1162
1163      protected EncounterHistory typedCopy() {
1164        return copy();
1165      }
1166
1167      @Override
1168      public boolean equalsDeep(Base other_) {
1169        if (!super.equalsDeep(other_))
1170          return false;
1171        if (!(other_ instanceof EncounterHistory))
1172          return false;
1173        EncounterHistory o = (EncounterHistory) other_;
1174        return compareDeep(encounter, o.encounter, true) && compareDeep(identifier, o.identifier, true)
1175           && compareDeep(status, o.status, true) && compareDeep(class_, o.class_, true) && compareDeep(type, o.type, true)
1176           && compareDeep(serviceType, o.serviceType, true) && compareDeep(subject, o.subject, true) && compareDeep(subjectStatus, o.subjectStatus, true)
1177           && compareDeep(actualPeriod, o.actualPeriod, true) && compareDeep(plannedStartDate, o.plannedStartDate, true)
1178           && compareDeep(plannedEndDate, o.plannedEndDate, true) && compareDeep(length, o.length, true) && compareDeep(location, o.location, true)
1179          ;
1180      }
1181
1182      @Override
1183      public boolean equalsShallow(Base other_) {
1184        if (!super.equalsShallow(other_))
1185          return false;
1186        if (!(other_ instanceof EncounterHistory))
1187          return false;
1188        EncounterHistory o = (EncounterHistory) other_;
1189        return compareValues(status, o.status, true) && compareValues(plannedStartDate, o.plannedStartDate, true)
1190           && compareValues(plannedEndDate, o.plannedEndDate, true);
1191      }
1192
1193      public boolean isEmpty() {
1194        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(encounter, identifier, status
1195          , class_, type, serviceType, subject, subjectStatus, actualPeriod, plannedStartDate
1196          , plannedEndDate, length, location);
1197      }
1198
1199  @Override
1200  public ResourceType getResourceType() {
1201    return ResourceType.EncounterHistory;
1202   }
1203
1204 /**
1205   * Search parameter: <b>identifier</b>
1206   * <p>
1207   * Description: <b>Identifier(s) by which this encounter is known</b><br>
1208   * Type: <b>token</b><br>
1209   * Path: <b>EncounterHistory.identifier</b><br>
1210   * </p>
1211   */
1212  @SearchParamDefinition(name="identifier", path="EncounterHistory.identifier", description="Identifier(s) by which this encounter is known", type="token" )
1213  public static final String SP_IDENTIFIER = "identifier";
1214 /**
1215   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
1216   * <p>
1217   * Description: <b>Identifier(s) by which this encounter is known</b><br>
1218   * Type: <b>token</b><br>
1219   * Path: <b>EncounterHistory.identifier</b><br>
1220   * </p>
1221   */
1222  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
1223
1224 /**
1225   * Search parameter: <b>patient</b>
1226   * <p>
1227   * Description: <b>The patient present at the encounter</b><br>
1228   * Type: <b>reference</b><br>
1229   * Path: <b>EncounterHistory.subject.where(resolve() is Patient)</b><br>
1230   * </p>
1231   */
1232  @SearchParamDefinition(name="patient", path="EncounterHistory.subject.where(resolve() is Patient)", description="The patient present at the encounter", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Base FHIR compartment definition for Patient") }, target={Patient.class } )
1233  public static final String SP_PATIENT = "patient";
1234 /**
1235   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
1236   * <p>
1237   * Description: <b>The patient present at the encounter</b><br>
1238   * Type: <b>reference</b><br>
1239   * Path: <b>EncounterHistory.subject.where(resolve() is Patient)</b><br>
1240   * </p>
1241   */
1242  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
1243
1244/**
1245   * Constant for fluent queries to be used to add include statements. Specifies
1246   * the path value of "<b>EncounterHistory:patient</b>".
1247   */
1248  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("EncounterHistory:patient").toLocked();
1249
1250 /**
1251   * Search parameter: <b>status</b>
1252   * <p>
1253   * Description: <b>Status of the Encounter history entry</b><br>
1254   * Type: <b>token</b><br>
1255   * Path: <b>EncounterHistory.status</b><br>
1256   * </p>
1257   */
1258  @SearchParamDefinition(name="status", path="EncounterHistory.status", description="Status of the Encounter history entry", type="token" )
1259  public static final String SP_STATUS = "status";
1260 /**
1261   * <b>Fluent Client</b> search parameter constant for <b>status</b>
1262   * <p>
1263   * Description: <b>Status of the Encounter history entry</b><br>
1264   * Type: <b>token</b><br>
1265   * Path: <b>EncounterHistory.status</b><br>
1266   * </p>
1267   */
1268  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
1269
1270 /**
1271   * Search parameter: <b>subject</b>
1272   * <p>
1273   * Description: <b>The patient or group present at the encounter</b><br>
1274   * Type: <b>reference</b><br>
1275   * Path: <b>EncounterHistory.subject</b><br>
1276   * </p>
1277   */
1278  @SearchParamDefinition(name="subject", path="EncounterHistory.subject", description="The patient or group present at the encounter", type="reference", target={Group.class, Patient.class } )
1279  public static final String SP_SUBJECT = "subject";
1280 /**
1281   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
1282   * <p>
1283   * Description: <b>The patient or group present at the encounter</b><br>
1284   * Type: <b>reference</b><br>
1285   * Path: <b>EncounterHistory.subject</b><br>
1286   * </p>
1287   */
1288  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
1289
1290/**
1291   * Constant for fluent queries to be used to add include statements. Specifies
1292   * the path value of "<b>EncounterHistory:subject</b>".
1293   */
1294  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("EncounterHistory:subject").toLocked();
1295
1296 /**
1297   * Search parameter: <b>encounter</b>
1298   * <p>
1299   * Description: <b>Multiple Resources: 
1300
1301* [AuditEvent](auditevent.html): Encounter related to the activity recorded in the AuditEvent
1302* [CarePlan](careplan.html): The Encounter during which this CarePlan was created
1303* [ChargeItem](chargeitem.html): Encounter associated with event
1304* [Claim](claim.html): Encounters associated with a billed line item
1305* [ClinicalImpression](clinicalimpression.html): The Encounter during which this ClinicalImpression was created
1306* [Communication](communication.html): The Encounter during which this Communication was created
1307* [CommunicationRequest](communicationrequest.html): The Encounter during which this CommunicationRequest was created
1308* [Composition](composition.html): Context of the Composition
1309* [Condition](condition.html): The Encounter during which this Condition was created
1310* [DeviceRequest](devicerequest.html): Encounter during which request was created
1311* [DiagnosticReport](diagnosticreport.html): The Encounter when the order was made
1312* [EncounterHistory](encounterhistory.html): The Encounter associated with this set of history values
1313* [ExplanationOfBenefit](explanationofbenefit.html): Encounters associated with a billed line item
1314* [Flag](flag.html): Alert relevant during encounter
1315* [ImagingStudy](imagingstudy.html): The context of the study
1316* [List](list.html): Context in which list created
1317* [MedicationDispense](medicationdispense.html): Returns dispenses with a specific encounter
1318* [MedicationStatement](medicationstatement.html): Returns statements for a specific encounter
1319* [NutritionIntake](nutritionintake.html): Returns statements for a specific encounter
1320* [NutritionOrder](nutritionorder.html): Return nutrition orders with this encounter identifier
1321* [Observation](observation.html): Encounter related to the observation
1322* [Procedure](procedure.html): The Encounter during which this Procedure was created
1323* [Provenance](provenance.html): Encounter related to the Provenance
1324* [QuestionnaireResponse](questionnaireresponse.html): Encounter associated with the questionnaire response
1325* [RequestOrchestration](requestorchestration.html): The encounter the request orchestration applies to
1326* [RiskAssessment](riskassessment.html): Where was assessment performed?
1327* [ServiceRequest](servicerequest.html): An encounter in which this request is made
1328* [Task](task.html): Search by encounter
1329* [VisionPrescription](visionprescription.html): Return prescriptions with this encounter identifier
1330</b><br>
1331   * Type: <b>reference</b><br>
1332   * Path: <b>AuditEvent.encounter | CarePlan.encounter | ChargeItem.encounter | Claim.item.encounter | ClinicalImpression.encounter | Communication.encounter | CommunicationRequest.encounter | Composition.encounter | Condition.encounter | DeviceRequest.encounter | DiagnosticReport.encounter | EncounterHistory.encounter | ExplanationOfBenefit.item.encounter | Flag.encounter | ImagingStudy.encounter | List.encounter | MedicationDispense.encounter | MedicationStatement.encounter | NutritionIntake.encounter | NutritionOrder.encounter | Observation.encounter | Procedure.encounter | Provenance.encounter | QuestionnaireResponse.encounter | RequestOrchestration.encounter | RiskAssessment.encounter | ServiceRequest.encounter | Task.encounter | VisionPrescription.encounter</b><br>
1333   * </p>
1334   */
1335  @SearchParamDefinition(name="encounter", path="AuditEvent.encounter | CarePlan.encounter | ChargeItem.encounter | Claim.item.encounter | ClinicalImpression.encounter | Communication.encounter | CommunicationRequest.encounter | Composition.encounter | Condition.encounter | DeviceRequest.encounter | DiagnosticReport.encounter | EncounterHistory.encounter | ExplanationOfBenefit.item.encounter | Flag.encounter | ImagingStudy.encounter | List.encounter | MedicationDispense.encounter | MedicationStatement.encounter | NutritionIntake.encounter | NutritionOrder.encounter | Observation.encounter | Procedure.encounter | Provenance.encounter | QuestionnaireResponse.encounter | RequestOrchestration.encounter | RiskAssessment.encounter | ServiceRequest.encounter | Task.encounter | VisionPrescription.encounter", description="Multiple Resources: \r\n\r\n* [AuditEvent](auditevent.html): Encounter related to the activity recorded in the AuditEvent\r\n* [CarePlan](careplan.html): The Encounter during which this CarePlan was created\r\n* [ChargeItem](chargeitem.html): Encounter associated with event\r\n* [Claim](claim.html): Encounters associated with a billed line item\r\n* [ClinicalImpression](clinicalimpression.html): The Encounter during which this ClinicalImpression was created\r\n* [Communication](communication.html): The Encounter during which this Communication was created\r\n* [CommunicationRequest](communicationrequest.html): The Encounter during which this CommunicationRequest was created\r\n* [Composition](composition.html): Context of the Composition\r\n* [Condition](condition.html): The Encounter during which this Condition was created\r\n* [DeviceRequest](devicerequest.html): Encounter during which request was created\r\n* [DiagnosticReport](diagnosticreport.html): The Encounter when the order was made\r\n* [EncounterHistory](encounterhistory.html): The Encounter associated with this set of history values\r\n* [ExplanationOfBenefit](explanationofbenefit.html): Encounters associated with a billed line item\r\n* [Flag](flag.html): Alert relevant during encounter\r\n* [ImagingStudy](imagingstudy.html): The context of the study\r\n* [List](list.html): Context in which list created\r\n* [MedicationDispense](medicationdispense.html): Returns dispenses with a specific encounter\r\n* [MedicationStatement](medicationstatement.html): Returns statements for a specific encounter\r\n* [NutritionIntake](nutritionintake.html): Returns statements for a specific encounter\r\n* [NutritionOrder](nutritionorder.html): Return nutrition orders with this encounter identifier\r\n* [Observation](observation.html): Encounter related to the observation\r\n* [Procedure](procedure.html): The Encounter during which this Procedure was created\r\n* [Provenance](provenance.html): Encounter related to the Provenance\r\n* [QuestionnaireResponse](questionnaireresponse.html): Encounter associated with the questionnaire response\r\n* [RequestOrchestration](requestorchestration.html): The encounter the request orchestration applies to\r\n* [RiskAssessment](riskassessment.html): Where was assessment performed?\r\n* [ServiceRequest](servicerequest.html): An encounter in which this request is made\r\n* [Task](task.html): Search by encounter\r\n* [VisionPrescription](visionprescription.html): Return prescriptions with this encounter identifier\r\n", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Base FHIR compartment definition for Encounter") }, target={Encounter.class } )
1336  public static final String SP_ENCOUNTER = "encounter";
1337 /**
1338   * <b>Fluent Client</b> search parameter constant for <b>encounter</b>
1339   * <p>
1340   * Description: <b>Multiple Resources: 
1341
1342* [AuditEvent](auditevent.html): Encounter related to the activity recorded in the AuditEvent
1343* [CarePlan](careplan.html): The Encounter during which this CarePlan was created
1344* [ChargeItem](chargeitem.html): Encounter associated with event
1345* [Claim](claim.html): Encounters associated with a billed line item
1346* [ClinicalImpression](clinicalimpression.html): The Encounter during which this ClinicalImpression was created
1347* [Communication](communication.html): The Encounter during which this Communication was created
1348* [CommunicationRequest](communicationrequest.html): The Encounter during which this CommunicationRequest was created
1349* [Composition](composition.html): Context of the Composition
1350* [Condition](condition.html): The Encounter during which this Condition was created
1351* [DeviceRequest](devicerequest.html): Encounter during which request was created
1352* [DiagnosticReport](diagnosticreport.html): The Encounter when the order was made
1353* [EncounterHistory](encounterhistory.html): The Encounter associated with this set of history values
1354* [ExplanationOfBenefit](explanationofbenefit.html): Encounters associated with a billed line item
1355* [Flag](flag.html): Alert relevant during encounter
1356* [ImagingStudy](imagingstudy.html): The context of the study
1357* [List](list.html): Context in which list created
1358* [MedicationDispense](medicationdispense.html): Returns dispenses with a specific encounter
1359* [MedicationStatement](medicationstatement.html): Returns statements for a specific encounter
1360* [NutritionIntake](nutritionintake.html): Returns statements for a specific encounter
1361* [NutritionOrder](nutritionorder.html): Return nutrition orders with this encounter identifier
1362* [Observation](observation.html): Encounter related to the observation
1363* [Procedure](procedure.html): The Encounter during which this Procedure was created
1364* [Provenance](provenance.html): Encounter related to the Provenance
1365* [QuestionnaireResponse](questionnaireresponse.html): Encounter associated with the questionnaire response
1366* [RequestOrchestration](requestorchestration.html): The encounter the request orchestration applies to
1367* [RiskAssessment](riskassessment.html): Where was assessment performed?
1368* [ServiceRequest](servicerequest.html): An encounter in which this request is made
1369* [Task](task.html): Search by encounter
1370* [VisionPrescription](visionprescription.html): Return prescriptions with this encounter identifier
1371</b><br>
1372   * Type: <b>reference</b><br>
1373   * Path: <b>AuditEvent.encounter | CarePlan.encounter | ChargeItem.encounter | Claim.item.encounter | ClinicalImpression.encounter | Communication.encounter | CommunicationRequest.encounter | Composition.encounter | Condition.encounter | DeviceRequest.encounter | DiagnosticReport.encounter | EncounterHistory.encounter | ExplanationOfBenefit.item.encounter | Flag.encounter | ImagingStudy.encounter | List.encounter | MedicationDispense.encounter | MedicationStatement.encounter | NutritionIntake.encounter | NutritionOrder.encounter | Observation.encounter | Procedure.encounter | Provenance.encounter | QuestionnaireResponse.encounter | RequestOrchestration.encounter | RiskAssessment.encounter | ServiceRequest.encounter | Task.encounter | VisionPrescription.encounter</b><br>
1374   * </p>
1375   */
1376  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENCOUNTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENCOUNTER);
1377
1378/**
1379   * Constant for fluent queries to be used to add include statements. Specifies
1380   * the path value of "<b>EncounterHistory:encounter</b>".
1381   */
1382  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENCOUNTER = new ca.uhn.fhir.model.api.Include("EncounterHistory:encounter").toLocked();
1383
1384
1385}
1386