001package org.hl7.fhir.dstu3.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 Mon, Apr 17, 2017 17:38-0400 for FHIR v3.0.1
033
034import java.util.*;
035
036import org.hl7.fhir.utilities.Utilities;
037import ca.uhn.fhir.model.api.annotation.ResourceDef;
038import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.ChildOrder;
041import ca.uhn.fhir.model.api.annotation.Description;
042import ca.uhn.fhir.model.api.annotation.Block;
043import org.hl7.fhir.instance.model.api.*;
044import org.hl7.fhir.exceptions.FHIRException;
045/**
046 * A booking of a healthcare event among patient(s), practitioner(s), related person(s) and/or device(s) for a specific date/time. This may result in one or more Encounter(s).
047 */
048@ResourceDef(name="Appointment", profile="http://hl7.org/fhir/Profile/Appointment")
049public class Appointment extends DomainResource {
050
051    public enum AppointmentStatus {
052        /**
053         * None of the participant(s) have finalized their acceptance of the appointment request, and the start/end time may not be set yet.
054         */
055        PROPOSED, 
056        /**
057         * Some or all of the participant(s) have not finalized their acceptance of the appointment request.
058         */
059        PENDING, 
060        /**
061         * All participant(s) have been considered and the appointment is confirmed to go ahead at the date/times specified.
062         */
063        BOOKED, 
064        /**
065         * Some of the patients have arrived.
066         */
067        ARRIVED, 
068        /**
069         * This appointment has completed and may have resulted in an encounter.
070         */
071        FULFILLED, 
072        /**
073         * The appointment has been cancelled.
074         */
075        CANCELLED, 
076        /**
077         * Some or all of the participant(s) have not/did not appear for the appointment (usually the patient).
078         */
079        NOSHOW, 
080        /**
081         * This instance should not have been part of this patient's medical record.
082         */
083        ENTEREDINERROR, 
084        /**
085         * added to help the parsers with the generic types
086         */
087        NULL;
088        public static AppointmentStatus fromCode(String codeString) throws FHIRException {
089            if (codeString == null || "".equals(codeString))
090                return null;
091        if ("proposed".equals(codeString))
092          return PROPOSED;
093        if ("pending".equals(codeString))
094          return PENDING;
095        if ("booked".equals(codeString))
096          return BOOKED;
097        if ("arrived".equals(codeString))
098          return ARRIVED;
099        if ("fulfilled".equals(codeString))
100          return FULFILLED;
101        if ("cancelled".equals(codeString))
102          return CANCELLED;
103        if ("noshow".equals(codeString))
104          return NOSHOW;
105        if ("entered-in-error".equals(codeString))
106          return ENTEREDINERROR;
107        if (Configuration.isAcceptInvalidEnums())
108          return null;
109        else
110          throw new FHIRException("Unknown AppointmentStatus code '"+codeString+"'");
111        }
112        public String toCode() {
113          switch (this) {
114            case PROPOSED: return "proposed";
115            case PENDING: return "pending";
116            case BOOKED: return "booked";
117            case ARRIVED: return "arrived";
118            case FULFILLED: return "fulfilled";
119            case CANCELLED: return "cancelled";
120            case NOSHOW: return "noshow";
121            case ENTEREDINERROR: return "entered-in-error";
122            default: return "?";
123          }
124        }
125        public String getSystem() {
126          switch (this) {
127            case PROPOSED: return "http://hl7.org/fhir/appointmentstatus";
128            case PENDING: return "http://hl7.org/fhir/appointmentstatus";
129            case BOOKED: return "http://hl7.org/fhir/appointmentstatus";
130            case ARRIVED: return "http://hl7.org/fhir/appointmentstatus";
131            case FULFILLED: return "http://hl7.org/fhir/appointmentstatus";
132            case CANCELLED: return "http://hl7.org/fhir/appointmentstatus";
133            case NOSHOW: return "http://hl7.org/fhir/appointmentstatus";
134            case ENTEREDINERROR: return "http://hl7.org/fhir/appointmentstatus";
135            default: return "?";
136          }
137        }
138        public String getDefinition() {
139          switch (this) {
140            case PROPOSED: return "None of the participant(s) have finalized their acceptance of the appointment request, and the start/end time may not be set yet.";
141            case PENDING: return "Some or all of the participant(s) have not finalized their acceptance of the appointment request.";
142            case BOOKED: return "All participant(s) have been considered and the appointment is confirmed to go ahead at the date/times specified.";
143            case ARRIVED: return "Some of the patients have arrived.";
144            case FULFILLED: return "This appointment has completed and may have resulted in an encounter.";
145            case CANCELLED: return "The appointment has been cancelled.";
146            case NOSHOW: return "Some or all of the participant(s) have not/did not appear for the appointment (usually the patient).";
147            case ENTEREDINERROR: return "This instance should not have been part of this patient's medical record.";
148            default: return "?";
149          }
150        }
151        public String getDisplay() {
152          switch (this) {
153            case PROPOSED: return "Proposed";
154            case PENDING: return "Pending";
155            case BOOKED: return "Booked";
156            case ARRIVED: return "Arrived";
157            case FULFILLED: return "Fulfilled";
158            case CANCELLED: return "Cancelled";
159            case NOSHOW: return "No Show";
160            case ENTEREDINERROR: return "Entered in error";
161            default: return "?";
162          }
163        }
164    }
165
166  public static class AppointmentStatusEnumFactory implements EnumFactory<AppointmentStatus> {
167    public AppointmentStatus fromCode(String codeString) throws IllegalArgumentException {
168      if (codeString == null || "".equals(codeString))
169            if (codeString == null || "".equals(codeString))
170                return null;
171        if ("proposed".equals(codeString))
172          return AppointmentStatus.PROPOSED;
173        if ("pending".equals(codeString))
174          return AppointmentStatus.PENDING;
175        if ("booked".equals(codeString))
176          return AppointmentStatus.BOOKED;
177        if ("arrived".equals(codeString))
178          return AppointmentStatus.ARRIVED;
179        if ("fulfilled".equals(codeString))
180          return AppointmentStatus.FULFILLED;
181        if ("cancelled".equals(codeString))
182          return AppointmentStatus.CANCELLED;
183        if ("noshow".equals(codeString))
184          return AppointmentStatus.NOSHOW;
185        if ("entered-in-error".equals(codeString))
186          return AppointmentStatus.ENTEREDINERROR;
187        throw new IllegalArgumentException("Unknown AppointmentStatus code '"+codeString+"'");
188        }
189        public Enumeration<AppointmentStatus> fromType(Base code) throws FHIRException {
190          if (code == null)
191            return null;
192          if (code.isEmpty())
193            return new Enumeration<AppointmentStatus>(this);
194          String codeString = ((PrimitiveType) code).asStringValue();
195          if (codeString == null || "".equals(codeString))
196            return null;
197        if ("proposed".equals(codeString))
198          return new Enumeration<AppointmentStatus>(this, AppointmentStatus.PROPOSED);
199        if ("pending".equals(codeString))
200          return new Enumeration<AppointmentStatus>(this, AppointmentStatus.PENDING);
201        if ("booked".equals(codeString))
202          return new Enumeration<AppointmentStatus>(this, AppointmentStatus.BOOKED);
203        if ("arrived".equals(codeString))
204          return new Enumeration<AppointmentStatus>(this, AppointmentStatus.ARRIVED);
205        if ("fulfilled".equals(codeString))
206          return new Enumeration<AppointmentStatus>(this, AppointmentStatus.FULFILLED);
207        if ("cancelled".equals(codeString))
208          return new Enumeration<AppointmentStatus>(this, AppointmentStatus.CANCELLED);
209        if ("noshow".equals(codeString))
210          return new Enumeration<AppointmentStatus>(this, AppointmentStatus.NOSHOW);
211        if ("entered-in-error".equals(codeString))
212          return new Enumeration<AppointmentStatus>(this, AppointmentStatus.ENTEREDINERROR);
213        throw new FHIRException("Unknown AppointmentStatus code '"+codeString+"'");
214        }
215    public String toCode(AppointmentStatus code) {
216      if (code == AppointmentStatus.PROPOSED)
217        return "proposed";
218      if (code == AppointmentStatus.PENDING)
219        return "pending";
220      if (code == AppointmentStatus.BOOKED)
221        return "booked";
222      if (code == AppointmentStatus.ARRIVED)
223        return "arrived";
224      if (code == AppointmentStatus.FULFILLED)
225        return "fulfilled";
226      if (code == AppointmentStatus.CANCELLED)
227        return "cancelled";
228      if (code == AppointmentStatus.NOSHOW)
229        return "noshow";
230      if (code == AppointmentStatus.ENTEREDINERROR)
231        return "entered-in-error";
232      return "?";
233      }
234    public String toSystem(AppointmentStatus code) {
235      return code.getSystem();
236      }
237    }
238
239    public enum ParticipantRequired {
240        /**
241         * The participant is required to attend the appointment.
242         */
243        REQUIRED, 
244        /**
245         * The participant may optionally attend the appointment.
246         */
247        OPTIONAL, 
248        /**
249         * The participant is excluded from the appointment, and may not be informed of the appointment taking place. (Appointment is about them, not for them - such as 2 doctors discussing results about a patient's test).
250         */
251        INFORMATIONONLY, 
252        /**
253         * added to help the parsers with the generic types
254         */
255        NULL;
256        public static ParticipantRequired fromCode(String codeString) throws FHIRException {
257            if (codeString == null || "".equals(codeString))
258                return null;
259        if ("required".equals(codeString))
260          return REQUIRED;
261        if ("optional".equals(codeString))
262          return OPTIONAL;
263        if ("information-only".equals(codeString))
264          return INFORMATIONONLY;
265        if (Configuration.isAcceptInvalidEnums())
266          return null;
267        else
268          throw new FHIRException("Unknown ParticipantRequired code '"+codeString+"'");
269        }
270        public String toCode() {
271          switch (this) {
272            case REQUIRED: return "required";
273            case OPTIONAL: return "optional";
274            case INFORMATIONONLY: return "information-only";
275            default: return "?";
276          }
277        }
278        public String getSystem() {
279          switch (this) {
280            case REQUIRED: return "http://hl7.org/fhir/participantrequired";
281            case OPTIONAL: return "http://hl7.org/fhir/participantrequired";
282            case INFORMATIONONLY: return "http://hl7.org/fhir/participantrequired";
283            default: return "?";
284          }
285        }
286        public String getDefinition() {
287          switch (this) {
288            case REQUIRED: return "The participant is required to attend the appointment.";
289            case OPTIONAL: return "The participant may optionally attend the appointment.";
290            case INFORMATIONONLY: return "The participant is excluded from the appointment, and may not be informed of the appointment taking place. (Appointment is about them, not for them - such as 2 doctors discussing results about a patient's test).";
291            default: return "?";
292          }
293        }
294        public String getDisplay() {
295          switch (this) {
296            case REQUIRED: return "Required";
297            case OPTIONAL: return "Optional";
298            case INFORMATIONONLY: return "Information Only";
299            default: return "?";
300          }
301        }
302    }
303
304  public static class ParticipantRequiredEnumFactory implements EnumFactory<ParticipantRequired> {
305    public ParticipantRequired fromCode(String codeString) throws IllegalArgumentException {
306      if (codeString == null || "".equals(codeString))
307            if (codeString == null || "".equals(codeString))
308                return null;
309        if ("required".equals(codeString))
310          return ParticipantRequired.REQUIRED;
311        if ("optional".equals(codeString))
312          return ParticipantRequired.OPTIONAL;
313        if ("information-only".equals(codeString))
314          return ParticipantRequired.INFORMATIONONLY;
315        throw new IllegalArgumentException("Unknown ParticipantRequired code '"+codeString+"'");
316        }
317        public Enumeration<ParticipantRequired> fromType(Base code) throws FHIRException {
318          if (code == null)
319            return null;
320          if (code.isEmpty())
321            return new Enumeration<ParticipantRequired>(this);
322          String codeString = ((PrimitiveType) code).asStringValue();
323          if (codeString == null || "".equals(codeString))
324            return null;
325        if ("required".equals(codeString))
326          return new Enumeration<ParticipantRequired>(this, ParticipantRequired.REQUIRED);
327        if ("optional".equals(codeString))
328          return new Enumeration<ParticipantRequired>(this, ParticipantRequired.OPTIONAL);
329        if ("information-only".equals(codeString))
330          return new Enumeration<ParticipantRequired>(this, ParticipantRequired.INFORMATIONONLY);
331        throw new FHIRException("Unknown ParticipantRequired code '"+codeString+"'");
332        }
333    public String toCode(ParticipantRequired code) {
334      if (code == ParticipantRequired.REQUIRED)
335        return "required";
336      if (code == ParticipantRequired.OPTIONAL)
337        return "optional";
338      if (code == ParticipantRequired.INFORMATIONONLY)
339        return "information-only";
340      return "?";
341      }
342    public String toSystem(ParticipantRequired code) {
343      return code.getSystem();
344      }
345    }
346
347    public enum ParticipationStatus {
348        /**
349         * The participant has accepted the appointment.
350         */
351        ACCEPTED, 
352        /**
353         * The participant has declined the appointment and will not participate in the appointment.
354         */
355        DECLINED, 
356        /**
357         * The participant has  tentatively accepted the appointment. This could be automatically created by a system and requires further processing before it can be accepted. There is no commitment that attendance will occur.
358         */
359        TENTATIVE, 
360        /**
361         * The participant needs to indicate if they accept the appointment by changing this status to one of the other statuses.
362         */
363        NEEDSACTION, 
364        /**
365         * added to help the parsers with the generic types
366         */
367        NULL;
368        public static ParticipationStatus fromCode(String codeString) throws FHIRException {
369            if (codeString == null || "".equals(codeString))
370                return null;
371        if ("accepted".equals(codeString))
372          return ACCEPTED;
373        if ("declined".equals(codeString))
374          return DECLINED;
375        if ("tentative".equals(codeString))
376          return TENTATIVE;
377        if ("needs-action".equals(codeString))
378          return NEEDSACTION;
379        if (Configuration.isAcceptInvalidEnums())
380          return null;
381        else
382          throw new FHIRException("Unknown ParticipationStatus code '"+codeString+"'");
383        }
384        public String toCode() {
385          switch (this) {
386            case ACCEPTED: return "accepted";
387            case DECLINED: return "declined";
388            case TENTATIVE: return "tentative";
389            case NEEDSACTION: return "needs-action";
390            default: return "?";
391          }
392        }
393        public String getSystem() {
394          switch (this) {
395            case ACCEPTED: return "http://hl7.org/fhir/participationstatus";
396            case DECLINED: return "http://hl7.org/fhir/participationstatus";
397            case TENTATIVE: return "http://hl7.org/fhir/participationstatus";
398            case NEEDSACTION: return "http://hl7.org/fhir/participationstatus";
399            default: return "?";
400          }
401        }
402        public String getDefinition() {
403          switch (this) {
404            case ACCEPTED: return "The participant has accepted the appointment.";
405            case DECLINED: return "The participant has declined the appointment and will not participate in the appointment.";
406            case TENTATIVE: return "The participant has  tentatively accepted the appointment. This could be automatically created by a system and requires further processing before it can be accepted. There is no commitment that attendance will occur.";
407            case NEEDSACTION: return "The participant needs to indicate if they accept the appointment by changing this status to one of the other statuses.";
408            default: return "?";
409          }
410        }
411        public String getDisplay() {
412          switch (this) {
413            case ACCEPTED: return "Accepted";
414            case DECLINED: return "Declined";
415            case TENTATIVE: return "Tentative";
416            case NEEDSACTION: return "Needs Action";
417            default: return "?";
418          }
419        }
420    }
421
422  public static class ParticipationStatusEnumFactory implements EnumFactory<ParticipationStatus> {
423    public ParticipationStatus fromCode(String codeString) throws IllegalArgumentException {
424      if (codeString == null || "".equals(codeString))
425            if (codeString == null || "".equals(codeString))
426                return null;
427        if ("accepted".equals(codeString))
428          return ParticipationStatus.ACCEPTED;
429        if ("declined".equals(codeString))
430          return ParticipationStatus.DECLINED;
431        if ("tentative".equals(codeString))
432          return ParticipationStatus.TENTATIVE;
433        if ("needs-action".equals(codeString))
434          return ParticipationStatus.NEEDSACTION;
435        throw new IllegalArgumentException("Unknown ParticipationStatus code '"+codeString+"'");
436        }
437        public Enumeration<ParticipationStatus> fromType(Base code) throws FHIRException {
438          if (code == null)
439            return null;
440          if (code.isEmpty())
441            return new Enumeration<ParticipationStatus>(this);
442          String codeString = ((PrimitiveType) code).asStringValue();
443          if (codeString == null || "".equals(codeString))
444            return null;
445        if ("accepted".equals(codeString))
446          return new Enumeration<ParticipationStatus>(this, ParticipationStatus.ACCEPTED);
447        if ("declined".equals(codeString))
448          return new Enumeration<ParticipationStatus>(this, ParticipationStatus.DECLINED);
449        if ("tentative".equals(codeString))
450          return new Enumeration<ParticipationStatus>(this, ParticipationStatus.TENTATIVE);
451        if ("needs-action".equals(codeString))
452          return new Enumeration<ParticipationStatus>(this, ParticipationStatus.NEEDSACTION);
453        throw new FHIRException("Unknown ParticipationStatus code '"+codeString+"'");
454        }
455    public String toCode(ParticipationStatus code) {
456      if (code == ParticipationStatus.ACCEPTED)
457        return "accepted";
458      if (code == ParticipationStatus.DECLINED)
459        return "declined";
460      if (code == ParticipationStatus.TENTATIVE)
461        return "tentative";
462      if (code == ParticipationStatus.NEEDSACTION)
463        return "needs-action";
464      return "?";
465      }
466    public String toSystem(ParticipationStatus code) {
467      return code.getSystem();
468      }
469    }
470
471    @Block()
472    public static class AppointmentParticipantComponent extends BackboneElement implements IBaseBackboneElement {
473        /**
474         * Role of participant in the appointment.
475         */
476        @Child(name = "type", type = {CodeableConcept.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
477        @Description(shortDefinition="Role of participant in the appointment", formalDefinition="Role of participant in the appointment." )
478        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/encounter-participant-type")
479        protected List<CodeableConcept> type;
480
481        /**
482         * A Person, Location/HealthcareService or Device that is participating in the appointment.
483         */
484        @Child(name = "actor", type = {Patient.class, Practitioner.class, RelatedPerson.class, Device.class, HealthcareService.class, Location.class}, order=2, min=0, max=1, modifier=false, summary=true)
485        @Description(shortDefinition="Person, Location/HealthcareService or Device", formalDefinition="A Person, Location/HealthcareService or Device that is participating in the appointment." )
486        protected Reference actor;
487
488        /**
489         * The actual object that is the target of the reference (A Person, Location/HealthcareService or Device that is participating in the appointment.)
490         */
491        protected Resource actorTarget;
492
493        /**
494         * Is this participant required to be present at the meeting. This covers a use-case where 2 doctors need to meet to discuss the results for a specific patient, and the patient is not required to be present.
495         */
496        @Child(name = "required", type = {CodeType.class}, order=3, min=0, max=1, modifier=false, summary=true)
497        @Description(shortDefinition="required | optional | information-only", formalDefinition="Is this participant required to be present at the meeting. This covers a use-case where 2 doctors need to meet to discuss the results for a specific patient, and the patient is not required to be present." )
498        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/participantrequired")
499        protected Enumeration<ParticipantRequired> required;
500
501        /**
502         * Participation status of the actor.
503         */
504        @Child(name = "status", type = {CodeType.class}, order=4, min=1, max=1, modifier=false, summary=false)
505        @Description(shortDefinition="accepted | declined | tentative | needs-action", formalDefinition="Participation status of the actor." )
506        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/participationstatus")
507        protected Enumeration<ParticipationStatus> status;
508
509        private static final long serialVersionUID = -1620552507L;
510
511    /**
512     * Constructor
513     */
514      public AppointmentParticipantComponent() {
515        super();
516      }
517
518    /**
519     * Constructor
520     */
521      public AppointmentParticipantComponent(Enumeration<ParticipationStatus> status) {
522        super();
523        this.status = status;
524      }
525
526        /**
527         * @return {@link #type} (Role of participant in the appointment.)
528         */
529        public List<CodeableConcept> getType() { 
530          if (this.type == null)
531            this.type = new ArrayList<CodeableConcept>();
532          return this.type;
533        }
534
535        /**
536         * @return Returns a reference to <code>this</code> for easy method chaining
537         */
538        public AppointmentParticipantComponent setType(List<CodeableConcept> theType) { 
539          this.type = theType;
540          return this;
541        }
542
543        public boolean hasType() { 
544          if (this.type == null)
545            return false;
546          for (CodeableConcept item : this.type)
547            if (!item.isEmpty())
548              return true;
549          return false;
550        }
551
552        public CodeableConcept addType() { //3
553          CodeableConcept t = new CodeableConcept();
554          if (this.type == null)
555            this.type = new ArrayList<CodeableConcept>();
556          this.type.add(t);
557          return t;
558        }
559
560        public AppointmentParticipantComponent addType(CodeableConcept t) { //3
561          if (t == null)
562            return this;
563          if (this.type == null)
564            this.type = new ArrayList<CodeableConcept>();
565          this.type.add(t);
566          return this;
567        }
568
569        /**
570         * @return The first repetition of repeating field {@link #type}, creating it if it does not already exist
571         */
572        public CodeableConcept getTypeFirstRep() { 
573          if (getType().isEmpty()) {
574            addType();
575          }
576          return getType().get(0);
577        }
578
579        /**
580         * @return {@link #actor} (A Person, Location/HealthcareService or Device that is participating in the appointment.)
581         */
582        public Reference getActor() { 
583          if (this.actor == null)
584            if (Configuration.errorOnAutoCreate())
585              throw new Error("Attempt to auto-create AppointmentParticipantComponent.actor");
586            else if (Configuration.doAutoCreate())
587              this.actor = new Reference(); // cc
588          return this.actor;
589        }
590
591        public boolean hasActor() { 
592          return this.actor != null && !this.actor.isEmpty();
593        }
594
595        /**
596         * @param value {@link #actor} (A Person, Location/HealthcareService or Device that is participating in the appointment.)
597         */
598        public AppointmentParticipantComponent setActor(Reference value) { 
599          this.actor = value;
600          return this;
601        }
602
603        /**
604         * @return {@link #actor} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (A Person, Location/HealthcareService or Device that is participating in the appointment.)
605         */
606        public Resource getActorTarget() { 
607          return this.actorTarget;
608        }
609
610        /**
611         * @param value {@link #actor} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (A Person, Location/HealthcareService or Device that is participating in the appointment.)
612         */
613        public AppointmentParticipantComponent setActorTarget(Resource value) { 
614          this.actorTarget = value;
615          return this;
616        }
617
618        /**
619         * @return {@link #required} (Is this participant required to be present at the meeting. This covers a use-case where 2 doctors need to meet to discuss the results for a specific patient, and the patient is not required to be present.). This is the underlying object with id, value and extensions. The accessor "getRequired" gives direct access to the value
620         */
621        public Enumeration<ParticipantRequired> getRequiredElement() { 
622          if (this.required == null)
623            if (Configuration.errorOnAutoCreate())
624              throw new Error("Attempt to auto-create AppointmentParticipantComponent.required");
625            else if (Configuration.doAutoCreate())
626              this.required = new Enumeration<ParticipantRequired>(new ParticipantRequiredEnumFactory()); // bb
627          return this.required;
628        }
629
630        public boolean hasRequiredElement() { 
631          return this.required != null && !this.required.isEmpty();
632        }
633
634        public boolean hasRequired() { 
635          return this.required != null && !this.required.isEmpty();
636        }
637
638        /**
639         * @param value {@link #required} (Is this participant required to be present at the meeting. This covers a use-case where 2 doctors need to meet to discuss the results for a specific patient, and the patient is not required to be present.). This is the underlying object with id, value and extensions. The accessor "getRequired" gives direct access to the value
640         */
641        public AppointmentParticipantComponent setRequiredElement(Enumeration<ParticipantRequired> value) { 
642          this.required = value;
643          return this;
644        }
645
646        /**
647         * @return Is this participant required to be present at the meeting. This covers a use-case where 2 doctors need to meet to discuss the results for a specific patient, and the patient is not required to be present.
648         */
649        public ParticipantRequired getRequired() { 
650          return this.required == null ? null : this.required.getValue();
651        }
652
653        /**
654         * @param value Is this participant required to be present at the meeting. This covers a use-case where 2 doctors need to meet to discuss the results for a specific patient, and the patient is not required to be present.
655         */
656        public AppointmentParticipantComponent setRequired(ParticipantRequired value) { 
657          if (value == null)
658            this.required = null;
659          else {
660            if (this.required == null)
661              this.required = new Enumeration<ParticipantRequired>(new ParticipantRequiredEnumFactory());
662            this.required.setValue(value);
663          }
664          return this;
665        }
666
667        /**
668         * @return {@link #status} (Participation status of the actor.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
669         */
670        public Enumeration<ParticipationStatus> getStatusElement() { 
671          if (this.status == null)
672            if (Configuration.errorOnAutoCreate())
673              throw new Error("Attempt to auto-create AppointmentParticipantComponent.status");
674            else if (Configuration.doAutoCreate())
675              this.status = new Enumeration<ParticipationStatus>(new ParticipationStatusEnumFactory()); // bb
676          return this.status;
677        }
678
679        public boolean hasStatusElement() { 
680          return this.status != null && !this.status.isEmpty();
681        }
682
683        public boolean hasStatus() { 
684          return this.status != null && !this.status.isEmpty();
685        }
686
687        /**
688         * @param value {@link #status} (Participation status of the actor.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
689         */
690        public AppointmentParticipantComponent setStatusElement(Enumeration<ParticipationStatus> value) { 
691          this.status = value;
692          return this;
693        }
694
695        /**
696         * @return Participation status of the actor.
697         */
698        public ParticipationStatus getStatus() { 
699          return this.status == null ? null : this.status.getValue();
700        }
701
702        /**
703         * @param value Participation status of the actor.
704         */
705        public AppointmentParticipantComponent setStatus(ParticipationStatus value) { 
706            if (this.status == null)
707              this.status = new Enumeration<ParticipationStatus>(new ParticipationStatusEnumFactory());
708            this.status.setValue(value);
709          return this;
710        }
711
712        protected void listChildren(List<Property> childrenList) {
713          super.listChildren(childrenList);
714          childrenList.add(new Property("type", "CodeableConcept", "Role of participant in the appointment.", 0, java.lang.Integer.MAX_VALUE, type));
715          childrenList.add(new Property("actor", "Reference(Patient|Practitioner|RelatedPerson|Device|HealthcareService|Location)", "A Person, Location/HealthcareService or Device that is participating in the appointment.", 0, java.lang.Integer.MAX_VALUE, actor));
716          childrenList.add(new Property("required", "code", "Is this participant required to be present at the meeting. This covers a use-case where 2 doctors need to meet to discuss the results for a specific patient, and the patient is not required to be present.", 0, java.lang.Integer.MAX_VALUE, required));
717          childrenList.add(new Property("status", "code", "Participation status of the actor.", 0, java.lang.Integer.MAX_VALUE, status));
718        }
719
720      @Override
721      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
722        switch (hash) {
723        case 3575610: /*type*/ return this.type == null ? new Base[0] : this.type.toArray(new Base[this.type.size()]); // CodeableConcept
724        case 92645877: /*actor*/ return this.actor == null ? new Base[0] : new Base[] {this.actor}; // Reference
725        case -393139297: /*required*/ return this.required == null ? new Base[0] : new Base[] {this.required}; // Enumeration<ParticipantRequired>
726        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<ParticipationStatus>
727        default: return super.getProperty(hash, name, checkValid);
728        }
729
730      }
731
732      @Override
733      public Base setProperty(int hash, String name, Base value) throws FHIRException {
734        switch (hash) {
735        case 3575610: // type
736          this.getType().add(castToCodeableConcept(value)); // CodeableConcept
737          return value;
738        case 92645877: // actor
739          this.actor = castToReference(value); // Reference
740          return value;
741        case -393139297: // required
742          value = new ParticipantRequiredEnumFactory().fromType(castToCode(value));
743          this.required = (Enumeration) value; // Enumeration<ParticipantRequired>
744          return value;
745        case -892481550: // status
746          value = new ParticipationStatusEnumFactory().fromType(castToCode(value));
747          this.status = (Enumeration) value; // Enumeration<ParticipationStatus>
748          return value;
749        default: return super.setProperty(hash, name, value);
750        }
751
752      }
753
754      @Override
755      public Base setProperty(String name, Base value) throws FHIRException {
756        if (name.equals("type")) {
757          this.getType().add(castToCodeableConcept(value));
758        } else if (name.equals("actor")) {
759          this.actor = castToReference(value); // Reference
760        } else if (name.equals("required")) {
761          value = new ParticipantRequiredEnumFactory().fromType(castToCode(value));
762          this.required = (Enumeration) value; // Enumeration<ParticipantRequired>
763        } else if (name.equals("status")) {
764          value = new ParticipationStatusEnumFactory().fromType(castToCode(value));
765          this.status = (Enumeration) value; // Enumeration<ParticipationStatus>
766        } else
767          return super.setProperty(name, value);
768        return value;
769      }
770
771      @Override
772      public Base makeProperty(int hash, String name) throws FHIRException {
773        switch (hash) {
774        case 3575610:  return addType(); 
775        case 92645877:  return getActor(); 
776        case -393139297:  return getRequiredElement();
777        case -892481550:  return getStatusElement();
778        default: return super.makeProperty(hash, name);
779        }
780
781      }
782
783      @Override
784      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
785        switch (hash) {
786        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
787        case 92645877: /*actor*/ return new String[] {"Reference"};
788        case -393139297: /*required*/ return new String[] {"code"};
789        case -892481550: /*status*/ return new String[] {"code"};
790        default: return super.getTypesForProperty(hash, name);
791        }
792
793      }
794
795      @Override
796      public Base addChild(String name) throws FHIRException {
797        if (name.equals("type")) {
798          return addType();
799        }
800        else if (name.equals("actor")) {
801          this.actor = new Reference();
802          return this.actor;
803        }
804        else if (name.equals("required")) {
805          throw new FHIRException("Cannot call addChild on a primitive type Appointment.required");
806        }
807        else if (name.equals("status")) {
808          throw new FHIRException("Cannot call addChild on a primitive type Appointment.status");
809        }
810        else
811          return super.addChild(name);
812      }
813
814      public AppointmentParticipantComponent copy() {
815        AppointmentParticipantComponent dst = new AppointmentParticipantComponent();
816        copyValues(dst);
817        if (type != null) {
818          dst.type = new ArrayList<CodeableConcept>();
819          for (CodeableConcept i : type)
820            dst.type.add(i.copy());
821        };
822        dst.actor = actor == null ? null : actor.copy();
823        dst.required = required == null ? null : required.copy();
824        dst.status = status == null ? null : status.copy();
825        return dst;
826      }
827
828      @Override
829      public boolean equalsDeep(Base other) {
830        if (!super.equalsDeep(other))
831          return false;
832        if (!(other instanceof AppointmentParticipantComponent))
833          return false;
834        AppointmentParticipantComponent o = (AppointmentParticipantComponent) other;
835        return compareDeep(type, o.type, true) && compareDeep(actor, o.actor, true) && compareDeep(required, o.required, true)
836           && compareDeep(status, o.status, true);
837      }
838
839      @Override
840      public boolean equalsShallow(Base other) {
841        if (!super.equalsShallow(other))
842          return false;
843        if (!(other instanceof AppointmentParticipantComponent))
844          return false;
845        AppointmentParticipantComponent o = (AppointmentParticipantComponent) other;
846        return compareValues(required, o.required, true) && compareValues(status, o.status, true);
847      }
848
849      public boolean isEmpty() {
850        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, actor, required, status
851          );
852      }
853
854  public String fhirType() {
855    return "Appointment.participant";
856
857  }
858
859  }
860
861    /**
862     * This records identifiers associated with this appointment concern that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).
863     */
864    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
865    @Description(shortDefinition="External Ids for this item", formalDefinition="This records identifiers associated with this appointment concern that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation)." )
866    protected List<Identifier> identifier;
867
868    /**
869     * The overall status of the Appointment. Each of the participants has their own participation status which indicates their involvement in the process, however this status indicates the shared status.
870     */
871    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
872    @Description(shortDefinition="proposed | pending | booked | arrived | fulfilled | cancelled | noshow | entered-in-error", formalDefinition="The overall status of the Appointment. Each of the participants has their own participation status which indicates their involvement in the process, however this status indicates the shared status." )
873    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/appointmentstatus")
874    protected Enumeration<AppointmentStatus> status;
875
876    /**
877     * A broad categorisation of the service that is to be performed during this appointment.
878     */
879    @Child(name = "serviceCategory", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
880    @Description(shortDefinition="A broad categorisation of the service that is to be performed during this appointment", formalDefinition="A broad categorisation of the service that is to be performed during this appointment." )
881    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/service-category")
882    protected CodeableConcept serviceCategory;
883
884    /**
885     * The specific service that is to be performed during this appointment.
886     */
887    @Child(name = "serviceType", type = {CodeableConcept.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
888    @Description(shortDefinition="The specific service that is to be performed during this appointment", formalDefinition="The specific service that is to be performed during this appointment." )
889    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/service-type")
890    protected List<CodeableConcept> serviceType;
891
892    /**
893     * The specialty of a practitioner that would be required to perform the service requested in this appointment.
894     */
895    @Child(name = "specialty", type = {CodeableConcept.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
896    @Description(shortDefinition="The specialty of a practitioner that would be required to perform the service requested in this appointment", formalDefinition="The specialty of a practitioner that would be required to perform the service requested in this appointment." )
897    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/c80-practice-codes")
898    protected List<CodeableConcept> specialty;
899
900    /**
901     * The style of appointment or patient that has been booked in the slot (not service type).
902     */
903    @Child(name = "appointmentType", type = {CodeableConcept.class}, order=5, min=0, max=1, modifier=false, summary=true)
904    @Description(shortDefinition="The style of appointment or patient that has been booked in the slot (not service type)", formalDefinition="The style of appointment or patient that has been booked in the slot (not service type)." )
905    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/v2-0276")
906    protected CodeableConcept appointmentType;
907
908    /**
909     * The reason that this appointment is being scheduled. This is more clinical than administrative.
910     */
911    @Child(name = "reason", type = {CodeableConcept.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
912    @Description(shortDefinition="Reason this appointment is scheduled", formalDefinition="The reason that this appointment is being scheduled. This is more clinical than administrative." )
913    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/encounter-reason")
914    protected List<CodeableConcept> reason;
915
916    /**
917     * Reason the appointment has been scheduled to take place, as specified using information from another resource. When the patient arrives and the encounter begins it may be used as the admission diagnosis. The indication will typically be a Condition (with other resources referenced in the evidence.detail), or a Procedure.
918     */
919    @Child(name = "indication", type = {Condition.class, Procedure.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
920    @Description(shortDefinition="Reason the appointment is to takes place (resource)", formalDefinition="Reason the appointment has been scheduled to take place, as specified using information from another resource. When the patient arrives and the encounter begins it may be used as the admission diagnosis. The indication will typically be a Condition (with other resources referenced in the evidence.detail), or a Procedure." )
921    protected List<Reference> indication;
922    /**
923     * The actual objects that are the target of the reference (Reason the appointment has been scheduled to take place, as specified using information from another resource. When the patient arrives and the encounter begins it may be used as the admission diagnosis. The indication will typically be a Condition (with other resources referenced in the evidence.detail), or a Procedure.)
924     */
925    protected List<Resource> indicationTarget;
926
927
928    /**
929     * The priority of the appointment. Can be used to make informed decisions if needing to re-prioritize appointments. (The iCal Standard specifies 0 as undefined, 1 as highest, 9 as lowest priority).
930     */
931    @Child(name = "priority", type = {UnsignedIntType.class}, order=8, min=0, max=1, modifier=false, summary=false)
932    @Description(shortDefinition="Used to make informed decisions if needing to re-prioritize", formalDefinition="The priority of the appointment. Can be used to make informed decisions if needing to re-prioritize appointments. (The iCal Standard specifies 0 as undefined, 1 as highest, 9 as lowest priority)." )
933    protected UnsignedIntType priority;
934
935    /**
936     * The brief description of the appointment as would be shown on a subject line in a meeting request, or appointment list. Detailed or expanded information should be put in the comment field.
937     */
938    @Child(name = "description", type = {StringType.class}, order=9, min=0, max=1, modifier=false, summary=false)
939    @Description(shortDefinition="Shown on a subject line in a meeting request, or appointment list", formalDefinition="The brief description of the appointment as would be shown on a subject line in a meeting request, or appointment list. Detailed or expanded information should be put in the comment field." )
940    protected StringType description;
941
942    /**
943     * Additional information to support the appointment provided when making the appointment.
944     */
945    @Child(name = "supportingInformation", type = {Reference.class}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
946    @Description(shortDefinition="Additional information to support the appointment", formalDefinition="Additional information to support the appointment provided when making the appointment." )
947    protected List<Reference> supportingInformation;
948    /**
949     * The actual objects that are the target of the reference (Additional information to support the appointment provided when making the appointment.)
950     */
951    protected List<Resource> supportingInformationTarget;
952
953
954    /**
955     * Date/Time that the appointment is to take place.
956     */
957    @Child(name = "start", type = {InstantType.class}, order=11, min=0, max=1, modifier=false, summary=true)
958    @Description(shortDefinition="When appointment is to take place", formalDefinition="Date/Time that the appointment is to take place." )
959    protected InstantType start;
960
961    /**
962     * Date/Time that the appointment is to conclude.
963     */
964    @Child(name = "end", type = {InstantType.class}, order=12, min=0, max=1, modifier=false, summary=true)
965    @Description(shortDefinition="When appointment is to conclude", formalDefinition="Date/Time that the appointment is to conclude." )
966    protected InstantType end;
967
968    /**
969     * Number of minutes that the appointment is to take. This can be less than the duration between the start and end times (where actual time of appointment is only an estimate or is a planned appointment request).
970     */
971    @Child(name = "minutesDuration", type = {PositiveIntType.class}, order=13, min=0, max=1, modifier=false, summary=false)
972    @Description(shortDefinition="Can be less than start/end (e.g. estimate)", formalDefinition="Number of minutes that the appointment is to take. This can be less than the duration between the start and end times (where actual time of appointment is only an estimate or is a planned appointment request)." )
973    protected PositiveIntType minutesDuration;
974
975    /**
976     * The slots from the participants' schedules that will be filled by the appointment.
977     */
978    @Child(name = "slot", type = {Slot.class}, order=14, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
979    @Description(shortDefinition="The slots that this appointment is filling", formalDefinition="The slots from the participants' schedules that will be filled by the appointment." )
980    protected List<Reference> slot;
981    /**
982     * The actual objects that are the target of the reference (The slots from the participants' schedules that will be filled by the appointment.)
983     */
984    protected List<Slot> slotTarget;
985
986
987    /**
988     * The date that this appointment was initially created. This could be different to the meta.lastModified value on the initial entry, as this could have been before the resource was created on the FHIR server, and should remain unchanged over the lifespan of the appointment.
989     */
990    @Child(name = "created", type = {DateTimeType.class}, order=15, min=0, max=1, modifier=false, summary=false)
991    @Description(shortDefinition="The date that this appointment was initially created", formalDefinition="The date that this appointment was initially created. This could be different to the meta.lastModified value on the initial entry, as this could have been before the resource was created on the FHIR server, and should remain unchanged over the lifespan of the appointment." )
992    protected DateTimeType created;
993
994    /**
995     * Additional comments about the appointment.
996     */
997    @Child(name = "comment", type = {StringType.class}, order=16, min=0, max=1, modifier=false, summary=false)
998    @Description(shortDefinition="Additional comments", formalDefinition="Additional comments about the appointment." )
999    protected StringType comment;
1000
1001    /**
1002     * The referral request this appointment is allocated to assess (incoming referral).
1003     */
1004    @Child(name = "incomingReferral", type = {ReferralRequest.class}, order=17, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1005    @Description(shortDefinition="The ReferralRequest provided as information to allocate to the Encounter", formalDefinition="The referral request this appointment is allocated to assess (incoming referral)." )
1006    protected List<Reference> incomingReferral;
1007    /**
1008     * The actual objects that are the target of the reference (The referral request this appointment is allocated to assess (incoming referral).)
1009     */
1010    protected List<ReferralRequest> incomingReferralTarget;
1011
1012
1013    /**
1014     * List of participants involved in the appointment.
1015     */
1016    @Child(name = "participant", type = {}, order=18, min=1, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1017    @Description(shortDefinition="Participants involved in appointment", formalDefinition="List of participants involved in the appointment." )
1018    protected List<AppointmentParticipantComponent> participant;
1019
1020    /**
1021     * A set of date ranges (potentially including times) that the appointment is preferred to be scheduled within. When using these values, the minutes duration should be provided to indicate the length of the appointment to fill and populate the start/end times for the actual allocated time.
1022     */
1023    @Child(name = "requestedPeriod", type = {Period.class}, order=19, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1024    @Description(shortDefinition="Potential date/time interval(s) requested to allocate the appointment within", formalDefinition="A set of date ranges (potentially including times) that the appointment is preferred to be scheduled within. When using these values, the minutes duration should be provided to indicate the length of the appointment to fill and populate the start/end times for the actual allocated time." )
1025    protected List<Period> requestedPeriod;
1026
1027    private static final long serialVersionUID = -1589372810L;
1028
1029  /**
1030   * Constructor
1031   */
1032    public Appointment() {
1033      super();
1034    }
1035
1036  /**
1037   * Constructor
1038   */
1039    public Appointment(Enumeration<AppointmentStatus> status) {
1040      super();
1041      this.status = status;
1042    }
1043
1044    /**
1045     * @return {@link #identifier} (This records identifiers associated with this appointment concern that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).)
1046     */
1047    public List<Identifier> getIdentifier() { 
1048      if (this.identifier == null)
1049        this.identifier = new ArrayList<Identifier>();
1050      return this.identifier;
1051    }
1052
1053    /**
1054     * @return Returns a reference to <code>this</code> for easy method chaining
1055     */
1056    public Appointment setIdentifier(List<Identifier> theIdentifier) { 
1057      this.identifier = theIdentifier;
1058      return this;
1059    }
1060
1061    public boolean hasIdentifier() { 
1062      if (this.identifier == null)
1063        return false;
1064      for (Identifier item : this.identifier)
1065        if (!item.isEmpty())
1066          return true;
1067      return false;
1068    }
1069
1070    public Identifier addIdentifier() { //3
1071      Identifier t = new Identifier();
1072      if (this.identifier == null)
1073        this.identifier = new ArrayList<Identifier>();
1074      this.identifier.add(t);
1075      return t;
1076    }
1077
1078    public Appointment addIdentifier(Identifier t) { //3
1079      if (t == null)
1080        return this;
1081      if (this.identifier == null)
1082        this.identifier = new ArrayList<Identifier>();
1083      this.identifier.add(t);
1084      return this;
1085    }
1086
1087    /**
1088     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
1089     */
1090    public Identifier getIdentifierFirstRep() { 
1091      if (getIdentifier().isEmpty()) {
1092        addIdentifier();
1093      }
1094      return getIdentifier().get(0);
1095    }
1096
1097    /**
1098     * @return {@link #status} (The overall status of the Appointment. Each of the participants has their own participation status which indicates their involvement in the process, however this status indicates the shared status.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1099     */
1100    public Enumeration<AppointmentStatus> getStatusElement() { 
1101      if (this.status == null)
1102        if (Configuration.errorOnAutoCreate())
1103          throw new Error("Attempt to auto-create Appointment.status");
1104        else if (Configuration.doAutoCreate())
1105          this.status = new Enumeration<AppointmentStatus>(new AppointmentStatusEnumFactory()); // bb
1106      return this.status;
1107    }
1108
1109    public boolean hasStatusElement() { 
1110      return this.status != null && !this.status.isEmpty();
1111    }
1112
1113    public boolean hasStatus() { 
1114      return this.status != null && !this.status.isEmpty();
1115    }
1116
1117    /**
1118     * @param value {@link #status} (The overall status of the Appointment. Each of the participants has their own participation status which indicates their involvement in the process, however this status indicates the shared status.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1119     */
1120    public Appointment setStatusElement(Enumeration<AppointmentStatus> value) { 
1121      this.status = value;
1122      return this;
1123    }
1124
1125    /**
1126     * @return The overall status of the Appointment. Each of the participants has their own participation status which indicates their involvement in the process, however this status indicates the shared status.
1127     */
1128    public AppointmentStatus getStatus() { 
1129      return this.status == null ? null : this.status.getValue();
1130    }
1131
1132    /**
1133     * @param value The overall status of the Appointment. Each of the participants has their own participation status which indicates their involvement in the process, however this status indicates the shared status.
1134     */
1135    public Appointment setStatus(AppointmentStatus value) { 
1136        if (this.status == null)
1137          this.status = new Enumeration<AppointmentStatus>(new AppointmentStatusEnumFactory());
1138        this.status.setValue(value);
1139      return this;
1140    }
1141
1142    /**
1143     * @return {@link #serviceCategory} (A broad categorisation of the service that is to be performed during this appointment.)
1144     */
1145    public CodeableConcept getServiceCategory() { 
1146      if (this.serviceCategory == null)
1147        if (Configuration.errorOnAutoCreate())
1148          throw new Error("Attempt to auto-create Appointment.serviceCategory");
1149        else if (Configuration.doAutoCreate())
1150          this.serviceCategory = new CodeableConcept(); // cc
1151      return this.serviceCategory;
1152    }
1153
1154    public boolean hasServiceCategory() { 
1155      return this.serviceCategory != null && !this.serviceCategory.isEmpty();
1156    }
1157
1158    /**
1159     * @param value {@link #serviceCategory} (A broad categorisation of the service that is to be performed during this appointment.)
1160     */
1161    public Appointment setServiceCategory(CodeableConcept value) { 
1162      this.serviceCategory = value;
1163      return this;
1164    }
1165
1166    /**
1167     * @return {@link #serviceType} (The specific service that is to be performed during this appointment.)
1168     */
1169    public List<CodeableConcept> getServiceType() { 
1170      if (this.serviceType == null)
1171        this.serviceType = new ArrayList<CodeableConcept>();
1172      return this.serviceType;
1173    }
1174
1175    /**
1176     * @return Returns a reference to <code>this</code> for easy method chaining
1177     */
1178    public Appointment setServiceType(List<CodeableConcept> theServiceType) { 
1179      this.serviceType = theServiceType;
1180      return this;
1181    }
1182
1183    public boolean hasServiceType() { 
1184      if (this.serviceType == null)
1185        return false;
1186      for (CodeableConcept item : this.serviceType)
1187        if (!item.isEmpty())
1188          return true;
1189      return false;
1190    }
1191
1192    public CodeableConcept addServiceType() { //3
1193      CodeableConcept t = new CodeableConcept();
1194      if (this.serviceType == null)
1195        this.serviceType = new ArrayList<CodeableConcept>();
1196      this.serviceType.add(t);
1197      return t;
1198    }
1199
1200    public Appointment addServiceType(CodeableConcept t) { //3
1201      if (t == null)
1202        return this;
1203      if (this.serviceType == null)
1204        this.serviceType = new ArrayList<CodeableConcept>();
1205      this.serviceType.add(t);
1206      return this;
1207    }
1208
1209    /**
1210     * @return The first repetition of repeating field {@link #serviceType}, creating it if it does not already exist
1211     */
1212    public CodeableConcept getServiceTypeFirstRep() { 
1213      if (getServiceType().isEmpty()) {
1214        addServiceType();
1215      }
1216      return getServiceType().get(0);
1217    }
1218
1219    /**
1220     * @return {@link #specialty} (The specialty of a practitioner that would be required to perform the service requested in this appointment.)
1221     */
1222    public List<CodeableConcept> getSpecialty() { 
1223      if (this.specialty == null)
1224        this.specialty = new ArrayList<CodeableConcept>();
1225      return this.specialty;
1226    }
1227
1228    /**
1229     * @return Returns a reference to <code>this</code> for easy method chaining
1230     */
1231    public Appointment setSpecialty(List<CodeableConcept> theSpecialty) { 
1232      this.specialty = theSpecialty;
1233      return this;
1234    }
1235
1236    public boolean hasSpecialty() { 
1237      if (this.specialty == null)
1238        return false;
1239      for (CodeableConcept item : this.specialty)
1240        if (!item.isEmpty())
1241          return true;
1242      return false;
1243    }
1244
1245    public CodeableConcept addSpecialty() { //3
1246      CodeableConcept t = new CodeableConcept();
1247      if (this.specialty == null)
1248        this.specialty = new ArrayList<CodeableConcept>();
1249      this.specialty.add(t);
1250      return t;
1251    }
1252
1253    public Appointment addSpecialty(CodeableConcept t) { //3
1254      if (t == null)
1255        return this;
1256      if (this.specialty == null)
1257        this.specialty = new ArrayList<CodeableConcept>();
1258      this.specialty.add(t);
1259      return this;
1260    }
1261
1262    /**
1263     * @return The first repetition of repeating field {@link #specialty}, creating it if it does not already exist
1264     */
1265    public CodeableConcept getSpecialtyFirstRep() { 
1266      if (getSpecialty().isEmpty()) {
1267        addSpecialty();
1268      }
1269      return getSpecialty().get(0);
1270    }
1271
1272    /**
1273     * @return {@link #appointmentType} (The style of appointment or patient that has been booked in the slot (not service type).)
1274     */
1275    public CodeableConcept getAppointmentType() { 
1276      if (this.appointmentType == null)
1277        if (Configuration.errorOnAutoCreate())
1278          throw new Error("Attempt to auto-create Appointment.appointmentType");
1279        else if (Configuration.doAutoCreate())
1280          this.appointmentType = new CodeableConcept(); // cc
1281      return this.appointmentType;
1282    }
1283
1284    public boolean hasAppointmentType() { 
1285      return this.appointmentType != null && !this.appointmentType.isEmpty();
1286    }
1287
1288    /**
1289     * @param value {@link #appointmentType} (The style of appointment or patient that has been booked in the slot (not service type).)
1290     */
1291    public Appointment setAppointmentType(CodeableConcept value) { 
1292      this.appointmentType = value;
1293      return this;
1294    }
1295
1296    /**
1297     * @return {@link #reason} (The reason that this appointment is being scheduled. This is more clinical than administrative.)
1298     */
1299    public List<CodeableConcept> getReason() { 
1300      if (this.reason == null)
1301        this.reason = new ArrayList<CodeableConcept>();
1302      return this.reason;
1303    }
1304
1305    /**
1306     * @return Returns a reference to <code>this</code> for easy method chaining
1307     */
1308    public Appointment setReason(List<CodeableConcept> theReason) { 
1309      this.reason = theReason;
1310      return this;
1311    }
1312
1313    public boolean hasReason() { 
1314      if (this.reason == null)
1315        return false;
1316      for (CodeableConcept item : this.reason)
1317        if (!item.isEmpty())
1318          return true;
1319      return false;
1320    }
1321
1322    public CodeableConcept addReason() { //3
1323      CodeableConcept t = new CodeableConcept();
1324      if (this.reason == null)
1325        this.reason = new ArrayList<CodeableConcept>();
1326      this.reason.add(t);
1327      return t;
1328    }
1329
1330    public Appointment addReason(CodeableConcept t) { //3
1331      if (t == null)
1332        return this;
1333      if (this.reason == null)
1334        this.reason = new ArrayList<CodeableConcept>();
1335      this.reason.add(t);
1336      return this;
1337    }
1338
1339    /**
1340     * @return The first repetition of repeating field {@link #reason}, creating it if it does not already exist
1341     */
1342    public CodeableConcept getReasonFirstRep() { 
1343      if (getReason().isEmpty()) {
1344        addReason();
1345      }
1346      return getReason().get(0);
1347    }
1348
1349    /**
1350     * @return {@link #indication} (Reason the appointment has been scheduled to take place, as specified using information from another resource. When the patient arrives and the encounter begins it may be used as the admission diagnosis. The indication will typically be a Condition (with other resources referenced in the evidence.detail), or a Procedure.)
1351     */
1352    public List<Reference> getIndication() { 
1353      if (this.indication == null)
1354        this.indication = new ArrayList<Reference>();
1355      return this.indication;
1356    }
1357
1358    /**
1359     * @return Returns a reference to <code>this</code> for easy method chaining
1360     */
1361    public Appointment setIndication(List<Reference> theIndication) { 
1362      this.indication = theIndication;
1363      return this;
1364    }
1365
1366    public boolean hasIndication() { 
1367      if (this.indication == null)
1368        return false;
1369      for (Reference item : this.indication)
1370        if (!item.isEmpty())
1371          return true;
1372      return false;
1373    }
1374
1375    public Reference addIndication() { //3
1376      Reference t = new Reference();
1377      if (this.indication == null)
1378        this.indication = new ArrayList<Reference>();
1379      this.indication.add(t);
1380      return t;
1381    }
1382
1383    public Appointment addIndication(Reference t) { //3
1384      if (t == null)
1385        return this;
1386      if (this.indication == null)
1387        this.indication = new ArrayList<Reference>();
1388      this.indication.add(t);
1389      return this;
1390    }
1391
1392    /**
1393     * @return The first repetition of repeating field {@link #indication}, creating it if it does not already exist
1394     */
1395    public Reference getIndicationFirstRep() { 
1396      if (getIndication().isEmpty()) {
1397        addIndication();
1398      }
1399      return getIndication().get(0);
1400    }
1401
1402    /**
1403     * @deprecated Use Reference#setResource(IBaseResource) instead
1404     */
1405    @Deprecated
1406    public List<Resource> getIndicationTarget() { 
1407      if (this.indicationTarget == null)
1408        this.indicationTarget = new ArrayList<Resource>();
1409      return this.indicationTarget;
1410    }
1411
1412    /**
1413     * @return {@link #priority} (The priority of the appointment. Can be used to make informed decisions if needing to re-prioritize appointments. (The iCal Standard specifies 0 as undefined, 1 as highest, 9 as lowest priority).). This is the underlying object with id, value and extensions. The accessor "getPriority" gives direct access to the value
1414     */
1415    public UnsignedIntType getPriorityElement() { 
1416      if (this.priority == null)
1417        if (Configuration.errorOnAutoCreate())
1418          throw new Error("Attempt to auto-create Appointment.priority");
1419        else if (Configuration.doAutoCreate())
1420          this.priority = new UnsignedIntType(); // bb
1421      return this.priority;
1422    }
1423
1424    public boolean hasPriorityElement() { 
1425      return this.priority != null && !this.priority.isEmpty();
1426    }
1427
1428    public boolean hasPriority() { 
1429      return this.priority != null && !this.priority.isEmpty();
1430    }
1431
1432    /**
1433     * @param value {@link #priority} (The priority of the appointment. Can be used to make informed decisions if needing to re-prioritize appointments. (The iCal Standard specifies 0 as undefined, 1 as highest, 9 as lowest priority).). This is the underlying object with id, value and extensions. The accessor "getPriority" gives direct access to the value
1434     */
1435    public Appointment setPriorityElement(UnsignedIntType value) { 
1436      this.priority = value;
1437      return this;
1438    }
1439
1440    /**
1441     * @return The priority of the appointment. Can be used to make informed decisions if needing to re-prioritize appointments. (The iCal Standard specifies 0 as undefined, 1 as highest, 9 as lowest priority).
1442     */
1443    public int getPriority() { 
1444      return this.priority == null || this.priority.isEmpty() ? 0 : this.priority.getValue();
1445    }
1446
1447    /**
1448     * @param value The priority of the appointment. Can be used to make informed decisions if needing to re-prioritize appointments. (The iCal Standard specifies 0 as undefined, 1 as highest, 9 as lowest priority).
1449     */
1450    public Appointment setPriority(int value) { 
1451        if (this.priority == null)
1452          this.priority = new UnsignedIntType();
1453        this.priority.setValue(value);
1454      return this;
1455    }
1456
1457    /**
1458     * @return {@link #description} (The brief description of the appointment as would be shown on a subject line in a meeting request, or appointment list. Detailed or expanded information should be put in the comment field.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
1459     */
1460    public StringType getDescriptionElement() { 
1461      if (this.description == null)
1462        if (Configuration.errorOnAutoCreate())
1463          throw new Error("Attempt to auto-create Appointment.description");
1464        else if (Configuration.doAutoCreate())
1465          this.description = new StringType(); // bb
1466      return this.description;
1467    }
1468
1469    public boolean hasDescriptionElement() { 
1470      return this.description != null && !this.description.isEmpty();
1471    }
1472
1473    public boolean hasDescription() { 
1474      return this.description != null && !this.description.isEmpty();
1475    }
1476
1477    /**
1478     * @param value {@link #description} (The brief description of the appointment as would be shown on a subject line in a meeting request, or appointment list. Detailed or expanded information should be put in the comment field.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
1479     */
1480    public Appointment setDescriptionElement(StringType value) { 
1481      this.description = value;
1482      return this;
1483    }
1484
1485    /**
1486     * @return The brief description of the appointment as would be shown on a subject line in a meeting request, or appointment list. Detailed or expanded information should be put in the comment field.
1487     */
1488    public String getDescription() { 
1489      return this.description == null ? null : this.description.getValue();
1490    }
1491
1492    /**
1493     * @param value The brief description of the appointment as would be shown on a subject line in a meeting request, or appointment list. Detailed or expanded information should be put in the comment field.
1494     */
1495    public Appointment setDescription(String value) { 
1496      if (Utilities.noString(value))
1497        this.description = null;
1498      else {
1499        if (this.description == null)
1500          this.description = new StringType();
1501        this.description.setValue(value);
1502      }
1503      return this;
1504    }
1505
1506    /**
1507     * @return {@link #supportingInformation} (Additional information to support the appointment provided when making the appointment.)
1508     */
1509    public List<Reference> getSupportingInformation() { 
1510      if (this.supportingInformation == null)
1511        this.supportingInformation = new ArrayList<Reference>();
1512      return this.supportingInformation;
1513    }
1514
1515    /**
1516     * @return Returns a reference to <code>this</code> for easy method chaining
1517     */
1518    public Appointment setSupportingInformation(List<Reference> theSupportingInformation) { 
1519      this.supportingInformation = theSupportingInformation;
1520      return this;
1521    }
1522
1523    public boolean hasSupportingInformation() { 
1524      if (this.supportingInformation == null)
1525        return false;
1526      for (Reference item : this.supportingInformation)
1527        if (!item.isEmpty())
1528          return true;
1529      return false;
1530    }
1531
1532    public Reference addSupportingInformation() { //3
1533      Reference t = new Reference();
1534      if (this.supportingInformation == null)
1535        this.supportingInformation = new ArrayList<Reference>();
1536      this.supportingInformation.add(t);
1537      return t;
1538    }
1539
1540    public Appointment addSupportingInformation(Reference t) { //3
1541      if (t == null)
1542        return this;
1543      if (this.supportingInformation == null)
1544        this.supportingInformation = new ArrayList<Reference>();
1545      this.supportingInformation.add(t);
1546      return this;
1547    }
1548
1549    /**
1550     * @return The first repetition of repeating field {@link #supportingInformation}, creating it if it does not already exist
1551     */
1552    public Reference getSupportingInformationFirstRep() { 
1553      if (getSupportingInformation().isEmpty()) {
1554        addSupportingInformation();
1555      }
1556      return getSupportingInformation().get(0);
1557    }
1558
1559    /**
1560     * @deprecated Use Reference#setResource(IBaseResource) instead
1561     */
1562    @Deprecated
1563    public List<Resource> getSupportingInformationTarget() { 
1564      if (this.supportingInformationTarget == null)
1565        this.supportingInformationTarget = new ArrayList<Resource>();
1566      return this.supportingInformationTarget;
1567    }
1568
1569    /**
1570     * @return {@link #start} (Date/Time that the appointment is to take place.). This is the underlying object with id, value and extensions. The accessor "getStart" gives direct access to the value
1571     */
1572    public InstantType getStartElement() { 
1573      if (this.start == null)
1574        if (Configuration.errorOnAutoCreate())
1575          throw new Error("Attempt to auto-create Appointment.start");
1576        else if (Configuration.doAutoCreate())
1577          this.start = new InstantType(); // bb
1578      return this.start;
1579    }
1580
1581    public boolean hasStartElement() { 
1582      return this.start != null && !this.start.isEmpty();
1583    }
1584
1585    public boolean hasStart() { 
1586      return this.start != null && !this.start.isEmpty();
1587    }
1588
1589    /**
1590     * @param value {@link #start} (Date/Time that the appointment is to take place.). This is the underlying object with id, value and extensions. The accessor "getStart" gives direct access to the value
1591     */
1592    public Appointment setStartElement(InstantType value) { 
1593      this.start = value;
1594      return this;
1595    }
1596
1597    /**
1598     * @return Date/Time that the appointment is to take place.
1599     */
1600    public Date getStart() { 
1601      return this.start == null ? null : this.start.getValue();
1602    }
1603
1604    /**
1605     * @param value Date/Time that the appointment is to take place.
1606     */
1607    public Appointment setStart(Date value) { 
1608      if (value == null)
1609        this.start = null;
1610      else {
1611        if (this.start == null)
1612          this.start = new InstantType();
1613        this.start.setValue(value);
1614      }
1615      return this;
1616    }
1617
1618    /**
1619     * @return {@link #end} (Date/Time that the appointment is to conclude.). This is the underlying object with id, value and extensions. The accessor "getEnd" gives direct access to the value
1620     */
1621    public InstantType getEndElement() { 
1622      if (this.end == null)
1623        if (Configuration.errorOnAutoCreate())
1624          throw new Error("Attempt to auto-create Appointment.end");
1625        else if (Configuration.doAutoCreate())
1626          this.end = new InstantType(); // bb
1627      return this.end;
1628    }
1629
1630    public boolean hasEndElement() { 
1631      return this.end != null && !this.end.isEmpty();
1632    }
1633
1634    public boolean hasEnd() { 
1635      return this.end != null && !this.end.isEmpty();
1636    }
1637
1638    /**
1639     * @param value {@link #end} (Date/Time that the appointment is to conclude.). This is the underlying object with id, value and extensions. The accessor "getEnd" gives direct access to the value
1640     */
1641    public Appointment setEndElement(InstantType value) { 
1642      this.end = value;
1643      return this;
1644    }
1645
1646    /**
1647     * @return Date/Time that the appointment is to conclude.
1648     */
1649    public Date getEnd() { 
1650      return this.end == null ? null : this.end.getValue();
1651    }
1652
1653    /**
1654     * @param value Date/Time that the appointment is to conclude.
1655     */
1656    public Appointment setEnd(Date value) { 
1657      if (value == null)
1658        this.end = null;
1659      else {
1660        if (this.end == null)
1661          this.end = new InstantType();
1662        this.end.setValue(value);
1663      }
1664      return this;
1665    }
1666
1667    /**
1668     * @return {@link #minutesDuration} (Number of minutes that the appointment is to take. This can be less than the duration between the start and end times (where actual time of appointment is only an estimate or is a planned appointment request).). This is the underlying object with id, value and extensions. The accessor "getMinutesDuration" gives direct access to the value
1669     */
1670    public PositiveIntType getMinutesDurationElement() { 
1671      if (this.minutesDuration == null)
1672        if (Configuration.errorOnAutoCreate())
1673          throw new Error("Attempt to auto-create Appointment.minutesDuration");
1674        else if (Configuration.doAutoCreate())
1675          this.minutesDuration = new PositiveIntType(); // bb
1676      return this.minutesDuration;
1677    }
1678
1679    public boolean hasMinutesDurationElement() { 
1680      return this.minutesDuration != null && !this.minutesDuration.isEmpty();
1681    }
1682
1683    public boolean hasMinutesDuration() { 
1684      return this.minutesDuration != null && !this.minutesDuration.isEmpty();
1685    }
1686
1687    /**
1688     * @param value {@link #minutesDuration} (Number of minutes that the appointment is to take. This can be less than the duration between the start and end times (where actual time of appointment is only an estimate or is a planned appointment request).). This is the underlying object with id, value and extensions. The accessor "getMinutesDuration" gives direct access to the value
1689     */
1690    public Appointment setMinutesDurationElement(PositiveIntType value) { 
1691      this.minutesDuration = value;
1692      return this;
1693    }
1694
1695    /**
1696     * @return Number of minutes that the appointment is to take. This can be less than the duration between the start and end times (where actual time of appointment is only an estimate or is a planned appointment request).
1697     */
1698    public int getMinutesDuration() { 
1699      return this.minutesDuration == null || this.minutesDuration.isEmpty() ? 0 : this.minutesDuration.getValue();
1700    }
1701
1702    /**
1703     * @param value Number of minutes that the appointment is to take. This can be less than the duration between the start and end times (where actual time of appointment is only an estimate or is a planned appointment request).
1704     */
1705    public Appointment setMinutesDuration(int value) { 
1706        if (this.minutesDuration == null)
1707          this.minutesDuration = new PositiveIntType();
1708        this.minutesDuration.setValue(value);
1709      return this;
1710    }
1711
1712    /**
1713     * @return {@link #slot} (The slots from the participants' schedules that will be filled by the appointment.)
1714     */
1715    public List<Reference> getSlot() { 
1716      if (this.slot == null)
1717        this.slot = new ArrayList<Reference>();
1718      return this.slot;
1719    }
1720
1721    /**
1722     * @return Returns a reference to <code>this</code> for easy method chaining
1723     */
1724    public Appointment setSlot(List<Reference> theSlot) { 
1725      this.slot = theSlot;
1726      return this;
1727    }
1728
1729    public boolean hasSlot() { 
1730      if (this.slot == null)
1731        return false;
1732      for (Reference item : this.slot)
1733        if (!item.isEmpty())
1734          return true;
1735      return false;
1736    }
1737
1738    public Reference addSlot() { //3
1739      Reference t = new Reference();
1740      if (this.slot == null)
1741        this.slot = new ArrayList<Reference>();
1742      this.slot.add(t);
1743      return t;
1744    }
1745
1746    public Appointment addSlot(Reference t) { //3
1747      if (t == null)
1748        return this;
1749      if (this.slot == null)
1750        this.slot = new ArrayList<Reference>();
1751      this.slot.add(t);
1752      return this;
1753    }
1754
1755    /**
1756     * @return The first repetition of repeating field {@link #slot}, creating it if it does not already exist
1757     */
1758    public Reference getSlotFirstRep() { 
1759      if (getSlot().isEmpty()) {
1760        addSlot();
1761      }
1762      return getSlot().get(0);
1763    }
1764
1765    /**
1766     * @deprecated Use Reference#setResource(IBaseResource) instead
1767     */
1768    @Deprecated
1769    public List<Slot> getSlotTarget() { 
1770      if (this.slotTarget == null)
1771        this.slotTarget = new ArrayList<Slot>();
1772      return this.slotTarget;
1773    }
1774
1775    /**
1776     * @deprecated Use Reference#setResource(IBaseResource) instead
1777     */
1778    @Deprecated
1779    public Slot addSlotTarget() { 
1780      Slot r = new Slot();
1781      if (this.slotTarget == null)
1782        this.slotTarget = new ArrayList<Slot>();
1783      this.slotTarget.add(r);
1784      return r;
1785    }
1786
1787    /**
1788     * @return {@link #created} (The date that this appointment was initially created. This could be different to the meta.lastModified value on the initial entry, as this could have been before the resource was created on the FHIR server, and should remain unchanged over the lifespan of the appointment.). This is the underlying object with id, value and extensions. The accessor "getCreated" gives direct access to the value
1789     */
1790    public DateTimeType getCreatedElement() { 
1791      if (this.created == null)
1792        if (Configuration.errorOnAutoCreate())
1793          throw new Error("Attempt to auto-create Appointment.created");
1794        else if (Configuration.doAutoCreate())
1795          this.created = new DateTimeType(); // bb
1796      return this.created;
1797    }
1798
1799    public boolean hasCreatedElement() { 
1800      return this.created != null && !this.created.isEmpty();
1801    }
1802
1803    public boolean hasCreated() { 
1804      return this.created != null && !this.created.isEmpty();
1805    }
1806
1807    /**
1808     * @param value {@link #created} (The date that this appointment was initially created. This could be different to the meta.lastModified value on the initial entry, as this could have been before the resource was created on the FHIR server, and should remain unchanged over the lifespan of the appointment.). This is the underlying object with id, value and extensions. The accessor "getCreated" gives direct access to the value
1809     */
1810    public Appointment setCreatedElement(DateTimeType value) { 
1811      this.created = value;
1812      return this;
1813    }
1814
1815    /**
1816     * @return The date that this appointment was initially created. This could be different to the meta.lastModified value on the initial entry, as this could have been before the resource was created on the FHIR server, and should remain unchanged over the lifespan of the appointment.
1817     */
1818    public Date getCreated() { 
1819      return this.created == null ? null : this.created.getValue();
1820    }
1821
1822    /**
1823     * @param value The date that this appointment was initially created. This could be different to the meta.lastModified value on the initial entry, as this could have been before the resource was created on the FHIR server, and should remain unchanged over the lifespan of the appointment.
1824     */
1825    public Appointment setCreated(Date value) { 
1826      if (value == null)
1827        this.created = null;
1828      else {
1829        if (this.created == null)
1830          this.created = new DateTimeType();
1831        this.created.setValue(value);
1832      }
1833      return this;
1834    }
1835
1836    /**
1837     * @return {@link #comment} (Additional comments about the appointment.). This is the underlying object with id, value and extensions. The accessor "getComment" gives direct access to the value
1838     */
1839    public StringType getCommentElement() { 
1840      if (this.comment == null)
1841        if (Configuration.errorOnAutoCreate())
1842          throw new Error("Attempt to auto-create Appointment.comment");
1843        else if (Configuration.doAutoCreate())
1844          this.comment = new StringType(); // bb
1845      return this.comment;
1846    }
1847
1848    public boolean hasCommentElement() { 
1849      return this.comment != null && !this.comment.isEmpty();
1850    }
1851
1852    public boolean hasComment() { 
1853      return this.comment != null && !this.comment.isEmpty();
1854    }
1855
1856    /**
1857     * @param value {@link #comment} (Additional comments about the appointment.). This is the underlying object with id, value and extensions. The accessor "getComment" gives direct access to the value
1858     */
1859    public Appointment setCommentElement(StringType value) { 
1860      this.comment = value;
1861      return this;
1862    }
1863
1864    /**
1865     * @return Additional comments about the appointment.
1866     */
1867    public String getComment() { 
1868      return this.comment == null ? null : this.comment.getValue();
1869    }
1870
1871    /**
1872     * @param value Additional comments about the appointment.
1873     */
1874    public Appointment setComment(String value) { 
1875      if (Utilities.noString(value))
1876        this.comment = null;
1877      else {
1878        if (this.comment == null)
1879          this.comment = new StringType();
1880        this.comment.setValue(value);
1881      }
1882      return this;
1883    }
1884
1885    /**
1886     * @return {@link #incomingReferral} (The referral request this appointment is allocated to assess (incoming referral).)
1887     */
1888    public List<Reference> getIncomingReferral() { 
1889      if (this.incomingReferral == null)
1890        this.incomingReferral = new ArrayList<Reference>();
1891      return this.incomingReferral;
1892    }
1893
1894    /**
1895     * @return Returns a reference to <code>this</code> for easy method chaining
1896     */
1897    public Appointment setIncomingReferral(List<Reference> theIncomingReferral) { 
1898      this.incomingReferral = theIncomingReferral;
1899      return this;
1900    }
1901
1902    public boolean hasIncomingReferral() { 
1903      if (this.incomingReferral == null)
1904        return false;
1905      for (Reference item : this.incomingReferral)
1906        if (!item.isEmpty())
1907          return true;
1908      return false;
1909    }
1910
1911    public Reference addIncomingReferral() { //3
1912      Reference t = new Reference();
1913      if (this.incomingReferral == null)
1914        this.incomingReferral = new ArrayList<Reference>();
1915      this.incomingReferral.add(t);
1916      return t;
1917    }
1918
1919    public Appointment addIncomingReferral(Reference t) { //3
1920      if (t == null)
1921        return this;
1922      if (this.incomingReferral == null)
1923        this.incomingReferral = new ArrayList<Reference>();
1924      this.incomingReferral.add(t);
1925      return this;
1926    }
1927
1928    /**
1929     * @return The first repetition of repeating field {@link #incomingReferral}, creating it if it does not already exist
1930     */
1931    public Reference getIncomingReferralFirstRep() { 
1932      if (getIncomingReferral().isEmpty()) {
1933        addIncomingReferral();
1934      }
1935      return getIncomingReferral().get(0);
1936    }
1937
1938    /**
1939     * @deprecated Use Reference#setResource(IBaseResource) instead
1940     */
1941    @Deprecated
1942    public List<ReferralRequest> getIncomingReferralTarget() { 
1943      if (this.incomingReferralTarget == null)
1944        this.incomingReferralTarget = new ArrayList<ReferralRequest>();
1945      return this.incomingReferralTarget;
1946    }
1947
1948    /**
1949     * @deprecated Use Reference#setResource(IBaseResource) instead
1950     */
1951    @Deprecated
1952    public ReferralRequest addIncomingReferralTarget() { 
1953      ReferralRequest r = new ReferralRequest();
1954      if (this.incomingReferralTarget == null)
1955        this.incomingReferralTarget = new ArrayList<ReferralRequest>();
1956      this.incomingReferralTarget.add(r);
1957      return r;
1958    }
1959
1960    /**
1961     * @return {@link #participant} (List of participants involved in the appointment.)
1962     */
1963    public List<AppointmentParticipantComponent> getParticipant() { 
1964      if (this.participant == null)
1965        this.participant = new ArrayList<AppointmentParticipantComponent>();
1966      return this.participant;
1967    }
1968
1969    /**
1970     * @return Returns a reference to <code>this</code> for easy method chaining
1971     */
1972    public Appointment setParticipant(List<AppointmentParticipantComponent> theParticipant) { 
1973      this.participant = theParticipant;
1974      return this;
1975    }
1976
1977    public boolean hasParticipant() { 
1978      if (this.participant == null)
1979        return false;
1980      for (AppointmentParticipantComponent item : this.participant)
1981        if (!item.isEmpty())
1982          return true;
1983      return false;
1984    }
1985
1986    public AppointmentParticipantComponent addParticipant() { //3
1987      AppointmentParticipantComponent t = new AppointmentParticipantComponent();
1988      if (this.participant == null)
1989        this.participant = new ArrayList<AppointmentParticipantComponent>();
1990      this.participant.add(t);
1991      return t;
1992    }
1993
1994    public Appointment addParticipant(AppointmentParticipantComponent t) { //3
1995      if (t == null)
1996        return this;
1997      if (this.participant == null)
1998        this.participant = new ArrayList<AppointmentParticipantComponent>();
1999      this.participant.add(t);
2000      return this;
2001    }
2002
2003    /**
2004     * @return The first repetition of repeating field {@link #participant}, creating it if it does not already exist
2005     */
2006    public AppointmentParticipantComponent getParticipantFirstRep() { 
2007      if (getParticipant().isEmpty()) {
2008        addParticipant();
2009      }
2010      return getParticipant().get(0);
2011    }
2012
2013    /**
2014     * @return {@link #requestedPeriod} (A set of date ranges (potentially including times) that the appointment is preferred to be scheduled within. When using these values, the minutes duration should be provided to indicate the length of the appointment to fill and populate the start/end times for the actual allocated time.)
2015     */
2016    public List<Period> getRequestedPeriod() { 
2017      if (this.requestedPeriod == null)
2018        this.requestedPeriod = new ArrayList<Period>();
2019      return this.requestedPeriod;
2020    }
2021
2022    /**
2023     * @return Returns a reference to <code>this</code> for easy method chaining
2024     */
2025    public Appointment setRequestedPeriod(List<Period> theRequestedPeriod) { 
2026      this.requestedPeriod = theRequestedPeriod;
2027      return this;
2028    }
2029
2030    public boolean hasRequestedPeriod() { 
2031      if (this.requestedPeriod == null)
2032        return false;
2033      for (Period item : this.requestedPeriod)
2034        if (!item.isEmpty())
2035          return true;
2036      return false;
2037    }
2038
2039    public Period addRequestedPeriod() { //3
2040      Period t = new Period();
2041      if (this.requestedPeriod == null)
2042        this.requestedPeriod = new ArrayList<Period>();
2043      this.requestedPeriod.add(t);
2044      return t;
2045    }
2046
2047    public Appointment addRequestedPeriod(Period t) { //3
2048      if (t == null)
2049        return this;
2050      if (this.requestedPeriod == null)
2051        this.requestedPeriod = new ArrayList<Period>();
2052      this.requestedPeriod.add(t);
2053      return this;
2054    }
2055
2056    /**
2057     * @return The first repetition of repeating field {@link #requestedPeriod}, creating it if it does not already exist
2058     */
2059    public Period getRequestedPeriodFirstRep() { 
2060      if (getRequestedPeriod().isEmpty()) {
2061        addRequestedPeriod();
2062      }
2063      return getRequestedPeriod().get(0);
2064    }
2065
2066      protected void listChildren(List<Property> childrenList) {
2067        super.listChildren(childrenList);
2068        childrenList.add(new Property("identifier", "Identifier", "This records identifiers associated with this appointment concern that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).", 0, java.lang.Integer.MAX_VALUE, identifier));
2069        childrenList.add(new Property("status", "code", "The overall status of the Appointment. Each of the participants has their own participation status which indicates their involvement in the process, however this status indicates the shared status.", 0, java.lang.Integer.MAX_VALUE, status));
2070        childrenList.add(new Property("serviceCategory", "CodeableConcept", "A broad categorisation of the service that is to be performed during this appointment.", 0, java.lang.Integer.MAX_VALUE, serviceCategory));
2071        childrenList.add(new Property("serviceType", "CodeableConcept", "The specific service that is to be performed during this appointment.", 0, java.lang.Integer.MAX_VALUE, serviceType));
2072        childrenList.add(new Property("specialty", "CodeableConcept", "The specialty of a practitioner that would be required to perform the service requested in this appointment.", 0, java.lang.Integer.MAX_VALUE, specialty));
2073        childrenList.add(new Property("appointmentType", "CodeableConcept", "The style of appointment or patient that has been booked in the slot (not service type).", 0, java.lang.Integer.MAX_VALUE, appointmentType));
2074        childrenList.add(new Property("reason", "CodeableConcept", "The reason that this appointment is being scheduled. This is more clinical than administrative.", 0, java.lang.Integer.MAX_VALUE, reason));
2075        childrenList.add(new Property("indication", "Reference(Condition|Procedure)", "Reason the appointment has been scheduled to take place, as specified using information from another resource. When the patient arrives and the encounter begins it may be used as the admission diagnosis. The indication will typically be a Condition (with other resources referenced in the evidence.detail), or a Procedure.", 0, java.lang.Integer.MAX_VALUE, indication));
2076        childrenList.add(new Property("priority", "unsignedInt", "The priority of the appointment. Can be used to make informed decisions if needing to re-prioritize appointments. (The iCal Standard specifies 0 as undefined, 1 as highest, 9 as lowest priority).", 0, java.lang.Integer.MAX_VALUE, priority));
2077        childrenList.add(new Property("description", "string", "The brief description of the appointment as would be shown on a subject line in a meeting request, or appointment list. Detailed or expanded information should be put in the comment field.", 0, java.lang.Integer.MAX_VALUE, description));
2078        childrenList.add(new Property("supportingInformation", "Reference(Any)", "Additional information to support the appointment provided when making the appointment.", 0, java.lang.Integer.MAX_VALUE, supportingInformation));
2079        childrenList.add(new Property("start", "instant", "Date/Time that the appointment is to take place.", 0, java.lang.Integer.MAX_VALUE, start));
2080        childrenList.add(new Property("end", "instant", "Date/Time that the appointment is to conclude.", 0, java.lang.Integer.MAX_VALUE, end));
2081        childrenList.add(new Property("minutesDuration", "positiveInt", "Number of minutes that the appointment is to take. This can be less than the duration between the start and end times (where actual time of appointment is only an estimate or is a planned appointment request).", 0, java.lang.Integer.MAX_VALUE, minutesDuration));
2082        childrenList.add(new Property("slot", "Reference(Slot)", "The slots from the participants' schedules that will be filled by the appointment.", 0, java.lang.Integer.MAX_VALUE, slot));
2083        childrenList.add(new Property("created", "dateTime", "The date that this appointment was initially created. This could be different to the meta.lastModified value on the initial entry, as this could have been before the resource was created on the FHIR server, and should remain unchanged over the lifespan of the appointment.", 0, java.lang.Integer.MAX_VALUE, created));
2084        childrenList.add(new Property("comment", "string", "Additional comments about the appointment.", 0, java.lang.Integer.MAX_VALUE, comment));
2085        childrenList.add(new Property("incomingReferral", "Reference(ReferralRequest)", "The referral request this appointment is allocated to assess (incoming referral).", 0, java.lang.Integer.MAX_VALUE, incomingReferral));
2086        childrenList.add(new Property("participant", "", "List of participants involved in the appointment.", 0, java.lang.Integer.MAX_VALUE, participant));
2087        childrenList.add(new Property("requestedPeriod", "Period", "A set of date ranges (potentially including times) that the appointment is preferred to be scheduled within. When using these values, the minutes duration should be provided to indicate the length of the appointment to fill and populate the start/end times for the actual allocated time.", 0, java.lang.Integer.MAX_VALUE, requestedPeriod));
2088      }
2089
2090      @Override
2091      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2092        switch (hash) {
2093        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
2094        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<AppointmentStatus>
2095        case 1281188563: /*serviceCategory*/ return this.serviceCategory == null ? new Base[0] : new Base[] {this.serviceCategory}; // CodeableConcept
2096        case -1928370289: /*serviceType*/ return this.serviceType == null ? new Base[0] : this.serviceType.toArray(new Base[this.serviceType.size()]); // CodeableConcept
2097        case -1694759682: /*specialty*/ return this.specialty == null ? new Base[0] : this.specialty.toArray(new Base[this.specialty.size()]); // CodeableConcept
2098        case -1596426375: /*appointmentType*/ return this.appointmentType == null ? new Base[0] : new Base[] {this.appointmentType}; // CodeableConcept
2099        case -934964668: /*reason*/ return this.reason == null ? new Base[0] : this.reason.toArray(new Base[this.reason.size()]); // CodeableConcept
2100        case -597168804: /*indication*/ return this.indication == null ? new Base[0] : this.indication.toArray(new Base[this.indication.size()]); // Reference
2101        case -1165461084: /*priority*/ return this.priority == null ? new Base[0] : new Base[] {this.priority}; // UnsignedIntType
2102        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // StringType
2103        case -1248768647: /*supportingInformation*/ return this.supportingInformation == null ? new Base[0] : this.supportingInformation.toArray(new Base[this.supportingInformation.size()]); // Reference
2104        case 109757538: /*start*/ return this.start == null ? new Base[0] : new Base[] {this.start}; // InstantType
2105        case 100571: /*end*/ return this.end == null ? new Base[0] : new Base[] {this.end}; // InstantType
2106        case -413630573: /*minutesDuration*/ return this.minutesDuration == null ? new Base[0] : new Base[] {this.minutesDuration}; // PositiveIntType
2107        case 3533310: /*slot*/ return this.slot == null ? new Base[0] : this.slot.toArray(new Base[this.slot.size()]); // Reference
2108        case 1028554472: /*created*/ return this.created == null ? new Base[0] : new Base[] {this.created}; // DateTimeType
2109        case 950398559: /*comment*/ return this.comment == null ? new Base[0] : new Base[] {this.comment}; // StringType
2110        case -1258204701: /*incomingReferral*/ return this.incomingReferral == null ? new Base[0] : this.incomingReferral.toArray(new Base[this.incomingReferral.size()]); // Reference
2111        case 767422259: /*participant*/ return this.participant == null ? new Base[0] : this.participant.toArray(new Base[this.participant.size()]); // AppointmentParticipantComponent
2112        case -897241393: /*requestedPeriod*/ return this.requestedPeriod == null ? new Base[0] : this.requestedPeriod.toArray(new Base[this.requestedPeriod.size()]); // Period
2113        default: return super.getProperty(hash, name, checkValid);
2114        }
2115
2116      }
2117
2118      @Override
2119      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2120        switch (hash) {
2121        case -1618432855: // identifier
2122          this.getIdentifier().add(castToIdentifier(value)); // Identifier
2123          return value;
2124        case -892481550: // status
2125          value = new AppointmentStatusEnumFactory().fromType(castToCode(value));
2126          this.status = (Enumeration) value; // Enumeration<AppointmentStatus>
2127          return value;
2128        case 1281188563: // serviceCategory
2129          this.serviceCategory = castToCodeableConcept(value); // CodeableConcept
2130          return value;
2131        case -1928370289: // serviceType
2132          this.getServiceType().add(castToCodeableConcept(value)); // CodeableConcept
2133          return value;
2134        case -1694759682: // specialty
2135          this.getSpecialty().add(castToCodeableConcept(value)); // CodeableConcept
2136          return value;
2137        case -1596426375: // appointmentType
2138          this.appointmentType = castToCodeableConcept(value); // CodeableConcept
2139          return value;
2140        case -934964668: // reason
2141          this.getReason().add(castToCodeableConcept(value)); // CodeableConcept
2142          return value;
2143        case -597168804: // indication
2144          this.getIndication().add(castToReference(value)); // Reference
2145          return value;
2146        case -1165461084: // priority
2147          this.priority = castToUnsignedInt(value); // UnsignedIntType
2148          return value;
2149        case -1724546052: // description
2150          this.description = castToString(value); // StringType
2151          return value;
2152        case -1248768647: // supportingInformation
2153          this.getSupportingInformation().add(castToReference(value)); // Reference
2154          return value;
2155        case 109757538: // start
2156          this.start = castToInstant(value); // InstantType
2157          return value;
2158        case 100571: // end
2159          this.end = castToInstant(value); // InstantType
2160          return value;
2161        case -413630573: // minutesDuration
2162          this.minutesDuration = castToPositiveInt(value); // PositiveIntType
2163          return value;
2164        case 3533310: // slot
2165          this.getSlot().add(castToReference(value)); // Reference
2166          return value;
2167        case 1028554472: // created
2168          this.created = castToDateTime(value); // DateTimeType
2169          return value;
2170        case 950398559: // comment
2171          this.comment = castToString(value); // StringType
2172          return value;
2173        case -1258204701: // incomingReferral
2174          this.getIncomingReferral().add(castToReference(value)); // Reference
2175          return value;
2176        case 767422259: // participant
2177          this.getParticipant().add((AppointmentParticipantComponent) value); // AppointmentParticipantComponent
2178          return value;
2179        case -897241393: // requestedPeriod
2180          this.getRequestedPeriod().add(castToPeriod(value)); // Period
2181          return value;
2182        default: return super.setProperty(hash, name, value);
2183        }
2184
2185      }
2186
2187      @Override
2188      public Base setProperty(String name, Base value) throws FHIRException {
2189        if (name.equals("identifier")) {
2190          this.getIdentifier().add(castToIdentifier(value));
2191        } else if (name.equals("status")) {
2192          value = new AppointmentStatusEnumFactory().fromType(castToCode(value));
2193          this.status = (Enumeration) value; // Enumeration<AppointmentStatus>
2194        } else if (name.equals("serviceCategory")) {
2195          this.serviceCategory = castToCodeableConcept(value); // CodeableConcept
2196        } else if (name.equals("serviceType")) {
2197          this.getServiceType().add(castToCodeableConcept(value));
2198        } else if (name.equals("specialty")) {
2199          this.getSpecialty().add(castToCodeableConcept(value));
2200        } else if (name.equals("appointmentType")) {
2201          this.appointmentType = castToCodeableConcept(value); // CodeableConcept
2202        } else if (name.equals("reason")) {
2203          this.getReason().add(castToCodeableConcept(value));
2204        } else if (name.equals("indication")) {
2205          this.getIndication().add(castToReference(value));
2206        } else if (name.equals("priority")) {
2207          this.priority = castToUnsignedInt(value); // UnsignedIntType
2208        } else if (name.equals("description")) {
2209          this.description = castToString(value); // StringType
2210        } else if (name.equals("supportingInformation")) {
2211          this.getSupportingInformation().add(castToReference(value));
2212        } else if (name.equals("start")) {
2213          this.start = castToInstant(value); // InstantType
2214        } else if (name.equals("end")) {
2215          this.end = castToInstant(value); // InstantType
2216        } else if (name.equals("minutesDuration")) {
2217          this.minutesDuration = castToPositiveInt(value); // PositiveIntType
2218        } else if (name.equals("slot")) {
2219          this.getSlot().add(castToReference(value));
2220        } else if (name.equals("created")) {
2221          this.created = castToDateTime(value); // DateTimeType
2222        } else if (name.equals("comment")) {
2223          this.comment = castToString(value); // StringType
2224        } else if (name.equals("incomingReferral")) {
2225          this.getIncomingReferral().add(castToReference(value));
2226        } else if (name.equals("participant")) {
2227          this.getParticipant().add((AppointmentParticipantComponent) value);
2228        } else if (name.equals("requestedPeriod")) {
2229          this.getRequestedPeriod().add(castToPeriod(value));
2230        } else
2231          return super.setProperty(name, value);
2232        return value;
2233      }
2234
2235      @Override
2236      public Base makeProperty(int hash, String name) throws FHIRException {
2237        switch (hash) {
2238        case -1618432855:  return addIdentifier(); 
2239        case -892481550:  return getStatusElement();
2240        case 1281188563:  return getServiceCategory(); 
2241        case -1928370289:  return addServiceType(); 
2242        case -1694759682:  return addSpecialty(); 
2243        case -1596426375:  return getAppointmentType(); 
2244        case -934964668:  return addReason(); 
2245        case -597168804:  return addIndication(); 
2246        case -1165461084:  return getPriorityElement();
2247        case -1724546052:  return getDescriptionElement();
2248        case -1248768647:  return addSupportingInformation(); 
2249        case 109757538:  return getStartElement();
2250        case 100571:  return getEndElement();
2251        case -413630573:  return getMinutesDurationElement();
2252        case 3533310:  return addSlot(); 
2253        case 1028554472:  return getCreatedElement();
2254        case 950398559:  return getCommentElement();
2255        case -1258204701:  return addIncomingReferral(); 
2256        case 767422259:  return addParticipant(); 
2257        case -897241393:  return addRequestedPeriod(); 
2258        default: return super.makeProperty(hash, name);
2259        }
2260
2261      }
2262
2263      @Override
2264      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2265        switch (hash) {
2266        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
2267        case -892481550: /*status*/ return new String[] {"code"};
2268        case 1281188563: /*serviceCategory*/ return new String[] {"CodeableConcept"};
2269        case -1928370289: /*serviceType*/ return new String[] {"CodeableConcept"};
2270        case -1694759682: /*specialty*/ return new String[] {"CodeableConcept"};
2271        case -1596426375: /*appointmentType*/ return new String[] {"CodeableConcept"};
2272        case -934964668: /*reason*/ return new String[] {"CodeableConcept"};
2273        case -597168804: /*indication*/ return new String[] {"Reference"};
2274        case -1165461084: /*priority*/ return new String[] {"unsignedInt"};
2275        case -1724546052: /*description*/ return new String[] {"string"};
2276        case -1248768647: /*supportingInformation*/ return new String[] {"Reference"};
2277        case 109757538: /*start*/ return new String[] {"instant"};
2278        case 100571: /*end*/ return new String[] {"instant"};
2279        case -413630573: /*minutesDuration*/ return new String[] {"positiveInt"};
2280        case 3533310: /*slot*/ return new String[] {"Reference"};
2281        case 1028554472: /*created*/ return new String[] {"dateTime"};
2282        case 950398559: /*comment*/ return new String[] {"string"};
2283        case -1258204701: /*incomingReferral*/ return new String[] {"Reference"};
2284        case 767422259: /*participant*/ return new String[] {};
2285        case -897241393: /*requestedPeriod*/ return new String[] {"Period"};
2286        default: return super.getTypesForProperty(hash, name);
2287        }
2288
2289      }
2290
2291      @Override
2292      public Base addChild(String name) throws FHIRException {
2293        if (name.equals("identifier")) {
2294          return addIdentifier();
2295        }
2296        else if (name.equals("status")) {
2297          throw new FHIRException("Cannot call addChild on a primitive type Appointment.status");
2298        }
2299        else if (name.equals("serviceCategory")) {
2300          this.serviceCategory = new CodeableConcept();
2301          return this.serviceCategory;
2302        }
2303        else if (name.equals("serviceType")) {
2304          return addServiceType();
2305        }
2306        else if (name.equals("specialty")) {
2307          return addSpecialty();
2308        }
2309        else if (name.equals("appointmentType")) {
2310          this.appointmentType = new CodeableConcept();
2311          return this.appointmentType;
2312        }
2313        else if (name.equals("reason")) {
2314          return addReason();
2315        }
2316        else if (name.equals("indication")) {
2317          return addIndication();
2318        }
2319        else if (name.equals("priority")) {
2320          throw new FHIRException("Cannot call addChild on a primitive type Appointment.priority");
2321        }
2322        else if (name.equals("description")) {
2323          throw new FHIRException("Cannot call addChild on a primitive type Appointment.description");
2324        }
2325        else if (name.equals("supportingInformation")) {
2326          return addSupportingInformation();
2327        }
2328        else if (name.equals("start")) {
2329          throw new FHIRException("Cannot call addChild on a primitive type Appointment.start");
2330        }
2331        else if (name.equals("end")) {
2332          throw new FHIRException("Cannot call addChild on a primitive type Appointment.end");
2333        }
2334        else if (name.equals("minutesDuration")) {
2335          throw new FHIRException("Cannot call addChild on a primitive type Appointment.minutesDuration");
2336        }
2337        else if (name.equals("slot")) {
2338          return addSlot();
2339        }
2340        else if (name.equals("created")) {
2341          throw new FHIRException("Cannot call addChild on a primitive type Appointment.created");
2342        }
2343        else if (name.equals("comment")) {
2344          throw new FHIRException("Cannot call addChild on a primitive type Appointment.comment");
2345        }
2346        else if (name.equals("incomingReferral")) {
2347          return addIncomingReferral();
2348        }
2349        else if (name.equals("participant")) {
2350          return addParticipant();
2351        }
2352        else if (name.equals("requestedPeriod")) {
2353          return addRequestedPeriod();
2354        }
2355        else
2356          return super.addChild(name);
2357      }
2358
2359  public String fhirType() {
2360    return "Appointment";
2361
2362  }
2363
2364      public Appointment copy() {
2365        Appointment dst = new Appointment();
2366        copyValues(dst);
2367        if (identifier != null) {
2368          dst.identifier = new ArrayList<Identifier>();
2369          for (Identifier i : identifier)
2370            dst.identifier.add(i.copy());
2371        };
2372        dst.status = status == null ? null : status.copy();
2373        dst.serviceCategory = serviceCategory == null ? null : serviceCategory.copy();
2374        if (serviceType != null) {
2375          dst.serviceType = new ArrayList<CodeableConcept>();
2376          for (CodeableConcept i : serviceType)
2377            dst.serviceType.add(i.copy());
2378        };
2379        if (specialty != null) {
2380          dst.specialty = new ArrayList<CodeableConcept>();
2381          for (CodeableConcept i : specialty)
2382            dst.specialty.add(i.copy());
2383        };
2384        dst.appointmentType = appointmentType == null ? null : appointmentType.copy();
2385        if (reason != null) {
2386          dst.reason = new ArrayList<CodeableConcept>();
2387          for (CodeableConcept i : reason)
2388            dst.reason.add(i.copy());
2389        };
2390        if (indication != null) {
2391          dst.indication = new ArrayList<Reference>();
2392          for (Reference i : indication)
2393            dst.indication.add(i.copy());
2394        };
2395        dst.priority = priority == null ? null : priority.copy();
2396        dst.description = description == null ? null : description.copy();
2397        if (supportingInformation != null) {
2398          dst.supportingInformation = new ArrayList<Reference>();
2399          for (Reference i : supportingInformation)
2400            dst.supportingInformation.add(i.copy());
2401        };
2402        dst.start = start == null ? null : start.copy();
2403        dst.end = end == null ? null : end.copy();
2404        dst.minutesDuration = minutesDuration == null ? null : minutesDuration.copy();
2405        if (slot != null) {
2406          dst.slot = new ArrayList<Reference>();
2407          for (Reference i : slot)
2408            dst.slot.add(i.copy());
2409        };
2410        dst.created = created == null ? null : created.copy();
2411        dst.comment = comment == null ? null : comment.copy();
2412        if (incomingReferral != null) {
2413          dst.incomingReferral = new ArrayList<Reference>();
2414          for (Reference i : incomingReferral)
2415            dst.incomingReferral.add(i.copy());
2416        };
2417        if (participant != null) {
2418          dst.participant = new ArrayList<AppointmentParticipantComponent>();
2419          for (AppointmentParticipantComponent i : participant)
2420            dst.participant.add(i.copy());
2421        };
2422        if (requestedPeriod != null) {
2423          dst.requestedPeriod = new ArrayList<Period>();
2424          for (Period i : requestedPeriod)
2425            dst.requestedPeriod.add(i.copy());
2426        };
2427        return dst;
2428      }
2429
2430      protected Appointment typedCopy() {
2431        return copy();
2432      }
2433
2434      @Override
2435      public boolean equalsDeep(Base other) {
2436        if (!super.equalsDeep(other))
2437          return false;
2438        if (!(other instanceof Appointment))
2439          return false;
2440        Appointment o = (Appointment) other;
2441        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(serviceCategory, o.serviceCategory, true)
2442           && compareDeep(serviceType, o.serviceType, true) && compareDeep(specialty, o.specialty, true) && compareDeep(appointmentType, o.appointmentType, true)
2443           && compareDeep(reason, o.reason, true) && compareDeep(indication, o.indication, true) && compareDeep(priority, o.priority, true)
2444           && compareDeep(description, o.description, true) && compareDeep(supportingInformation, o.supportingInformation, true)
2445           && compareDeep(start, o.start, true) && compareDeep(end, o.end, true) && compareDeep(minutesDuration, o.minutesDuration, true)
2446           && compareDeep(slot, o.slot, true) && compareDeep(created, o.created, true) && compareDeep(comment, o.comment, true)
2447           && compareDeep(incomingReferral, o.incomingReferral, true) && compareDeep(participant, o.participant, true)
2448           && compareDeep(requestedPeriod, o.requestedPeriod, true);
2449      }
2450
2451      @Override
2452      public boolean equalsShallow(Base other) {
2453        if (!super.equalsShallow(other))
2454          return false;
2455        if (!(other instanceof Appointment))
2456          return false;
2457        Appointment o = (Appointment) other;
2458        return compareValues(status, o.status, true) && compareValues(priority, o.priority, true) && compareValues(description, o.description, true)
2459           && compareValues(start, o.start, true) && compareValues(end, o.end, true) && compareValues(minutesDuration, o.minutesDuration, true)
2460           && compareValues(created, o.created, true) && compareValues(comment, o.comment, true);
2461      }
2462
2463      public boolean isEmpty() {
2464        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, serviceCategory
2465          , serviceType, specialty, appointmentType, reason, indication, priority, description
2466          , supportingInformation, start, end, minutesDuration, slot, created, comment, incomingReferral
2467          , participant, requestedPeriod);
2468      }
2469
2470  @Override
2471  public ResourceType getResourceType() {
2472    return ResourceType.Appointment;
2473   }
2474
2475 /**
2476   * Search parameter: <b>date</b>
2477   * <p>
2478   * Description: <b>Appointment date/time.</b><br>
2479   * Type: <b>date</b><br>
2480   * Path: <b>Appointment.start</b><br>
2481   * </p>
2482   */
2483  @SearchParamDefinition(name="date", path="Appointment.start", description="Appointment date/time.", type="date" )
2484  public static final String SP_DATE = "date";
2485 /**
2486   * <b>Fluent Client</b> search parameter constant for <b>date</b>
2487   * <p>
2488   * Description: <b>Appointment date/time.</b><br>
2489   * Type: <b>date</b><br>
2490   * Path: <b>Appointment.start</b><br>
2491   * </p>
2492   */
2493  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
2494
2495 /**
2496   * Search parameter: <b>actor</b>
2497   * <p>
2498   * Description: <b>Any one of the individuals participating in the appointment</b><br>
2499   * Type: <b>reference</b><br>
2500   * Path: <b>Appointment.participant.actor</b><br>
2501   * </p>
2502   */
2503  @SearchParamDefinition(name="actor", path="Appointment.participant.actor", description="Any one of the individuals participating in the appointment", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Device"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner"), @ca.uhn.fhir.model.api.annotation.Compartment(name="RelatedPerson") }, target={Device.class, HealthcareService.class, Location.class, Patient.class, Practitioner.class, RelatedPerson.class } )
2504  public static final String SP_ACTOR = "actor";
2505 /**
2506   * <b>Fluent Client</b> search parameter constant for <b>actor</b>
2507   * <p>
2508   * Description: <b>Any one of the individuals participating in the appointment</b><br>
2509   * Type: <b>reference</b><br>
2510   * Path: <b>Appointment.participant.actor</b><br>
2511   * </p>
2512   */
2513  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ACTOR = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ACTOR);
2514
2515/**
2516   * Constant for fluent queries to be used to add include statements. Specifies
2517   * the path value of "<b>Appointment:actor</b>".
2518   */
2519  public static final ca.uhn.fhir.model.api.Include INCLUDE_ACTOR = new ca.uhn.fhir.model.api.Include("Appointment:actor").toLocked();
2520
2521 /**
2522   * Search parameter: <b>identifier</b>
2523   * <p>
2524   * Description: <b>An Identifier of the Appointment</b><br>
2525   * Type: <b>token</b><br>
2526   * Path: <b>Appointment.identifier</b><br>
2527   * </p>
2528   */
2529  @SearchParamDefinition(name="identifier", path="Appointment.identifier", description="An Identifier of the Appointment", type="token" )
2530  public static final String SP_IDENTIFIER = "identifier";
2531 /**
2532   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2533   * <p>
2534   * Description: <b>An Identifier of the Appointment</b><br>
2535   * Type: <b>token</b><br>
2536   * Path: <b>Appointment.identifier</b><br>
2537   * </p>
2538   */
2539  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
2540
2541 /**
2542   * Search parameter: <b>practitioner</b>
2543   * <p>
2544   * Description: <b>One of the individuals of the appointment is this practitioner</b><br>
2545   * Type: <b>reference</b><br>
2546   * Path: <b>Appointment.participant.actor</b><br>
2547   * </p>
2548   */
2549  @SearchParamDefinition(name="practitioner", path="Appointment.participant.actor", description="One of the individuals of the appointment is this practitioner", type="reference", target={Practitioner.class } )
2550  public static final String SP_PRACTITIONER = "practitioner";
2551 /**
2552   * <b>Fluent Client</b> search parameter constant for <b>practitioner</b>
2553   * <p>
2554   * Description: <b>One of the individuals of the appointment is this practitioner</b><br>
2555   * Type: <b>reference</b><br>
2556   * Path: <b>Appointment.participant.actor</b><br>
2557   * </p>
2558   */
2559  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PRACTITIONER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PRACTITIONER);
2560
2561/**
2562   * Constant for fluent queries to be used to add include statements. Specifies
2563   * the path value of "<b>Appointment:practitioner</b>".
2564   */
2565  public static final ca.uhn.fhir.model.api.Include INCLUDE_PRACTITIONER = new ca.uhn.fhir.model.api.Include("Appointment:practitioner").toLocked();
2566
2567 /**
2568   * Search parameter: <b>incomingreferral</b>
2569   * <p>
2570   * Description: <b>The ReferralRequest provided as information to allocate to the Encounter</b><br>
2571   * Type: <b>reference</b><br>
2572   * Path: <b>Appointment.incomingReferral</b><br>
2573   * </p>
2574   */
2575  @SearchParamDefinition(name="incomingreferral", path="Appointment.incomingReferral", description="The ReferralRequest provided as information to allocate to the Encounter", type="reference", target={ReferralRequest.class } )
2576  public static final String SP_INCOMINGREFERRAL = "incomingreferral";
2577 /**
2578   * <b>Fluent Client</b> search parameter constant for <b>incomingreferral</b>
2579   * <p>
2580   * Description: <b>The ReferralRequest provided as information to allocate to the Encounter</b><br>
2581   * Type: <b>reference</b><br>
2582   * Path: <b>Appointment.incomingReferral</b><br>
2583   * </p>
2584   */
2585  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam INCOMINGREFERRAL = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_INCOMINGREFERRAL);
2586
2587/**
2588   * Constant for fluent queries to be used to add include statements. Specifies
2589   * the path value of "<b>Appointment:incomingreferral</b>".
2590   */
2591  public static final ca.uhn.fhir.model.api.Include INCLUDE_INCOMINGREFERRAL = new ca.uhn.fhir.model.api.Include("Appointment:incomingreferral").toLocked();
2592
2593 /**
2594   * Search parameter: <b>part-status</b>
2595   * <p>
2596   * Description: <b>The Participation status of the subject, or other participant on the appointment. Can be used to locate participants that have not responded to meeting requests.</b><br>
2597   * Type: <b>token</b><br>
2598   * Path: <b>Appointment.participant.status</b><br>
2599   * </p>
2600   */
2601  @SearchParamDefinition(name="part-status", path="Appointment.participant.status", description="The Participation status of the subject, or other participant on the appointment. Can be used to locate participants that have not responded to meeting requests.", type="token" )
2602  public static final String SP_PART_STATUS = "part-status";
2603 /**
2604   * <b>Fluent Client</b> search parameter constant for <b>part-status</b>
2605   * <p>
2606   * Description: <b>The Participation status of the subject, or other participant on the appointment. Can be used to locate participants that have not responded to meeting requests.</b><br>
2607   * Type: <b>token</b><br>
2608   * Path: <b>Appointment.participant.status</b><br>
2609   * </p>
2610   */
2611  public static final ca.uhn.fhir.rest.gclient.TokenClientParam PART_STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_PART_STATUS);
2612
2613 /**
2614   * Search parameter: <b>patient</b>
2615   * <p>
2616   * Description: <b>One of the individuals of the appointment is this patient</b><br>
2617   * Type: <b>reference</b><br>
2618   * Path: <b>Appointment.participant.actor</b><br>
2619   * </p>
2620   */
2621  @SearchParamDefinition(name="patient", path="Appointment.participant.actor", description="One of the individuals of the appointment is this patient", type="reference", target={Patient.class } )
2622  public static final String SP_PATIENT = "patient";
2623 /**
2624   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
2625   * <p>
2626   * Description: <b>One of the individuals of the appointment is this patient</b><br>
2627   * Type: <b>reference</b><br>
2628   * Path: <b>Appointment.participant.actor</b><br>
2629   * </p>
2630   */
2631  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
2632
2633/**
2634   * Constant for fluent queries to be used to add include statements. Specifies
2635   * the path value of "<b>Appointment:patient</b>".
2636   */
2637  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("Appointment:patient").toLocked();
2638
2639 /**
2640   * Search parameter: <b>appointment-type</b>
2641   * <p>
2642   * Description: <b>The style of appointment or patient that has been booked in the slot (not service type)</b><br>
2643   * Type: <b>token</b><br>
2644   * Path: <b>Appointment.appointmentType</b><br>
2645   * </p>
2646   */
2647  @SearchParamDefinition(name="appointment-type", path="Appointment.appointmentType", description="The style of appointment or patient that has been booked in the slot (not service type)", type="token" )
2648  public static final String SP_APPOINTMENT_TYPE = "appointment-type";
2649 /**
2650   * <b>Fluent Client</b> search parameter constant for <b>appointment-type</b>
2651   * <p>
2652   * Description: <b>The style of appointment or patient that has been booked in the slot (not service type)</b><br>
2653   * Type: <b>token</b><br>
2654   * Path: <b>Appointment.appointmentType</b><br>
2655   * </p>
2656   */
2657  public static final ca.uhn.fhir.rest.gclient.TokenClientParam APPOINTMENT_TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_APPOINTMENT_TYPE);
2658
2659 /**
2660   * Search parameter: <b>service-type</b>
2661   * <p>
2662   * Description: <b>The specific service that is to be performed during this appointment</b><br>
2663   * Type: <b>token</b><br>
2664   * Path: <b>Appointment.serviceType</b><br>
2665   * </p>
2666   */
2667  @SearchParamDefinition(name="service-type", path="Appointment.serviceType", description="The specific service that is to be performed during this appointment", type="token" )
2668  public static final String SP_SERVICE_TYPE = "service-type";
2669 /**
2670   * <b>Fluent Client</b> search parameter constant for <b>service-type</b>
2671   * <p>
2672   * Description: <b>The specific service that is to be performed during this appointment</b><br>
2673   * Type: <b>token</b><br>
2674   * Path: <b>Appointment.serviceType</b><br>
2675   * </p>
2676   */
2677  public static final ca.uhn.fhir.rest.gclient.TokenClientParam SERVICE_TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_SERVICE_TYPE);
2678
2679 /**
2680   * Search parameter: <b>location</b>
2681   * <p>
2682   * Description: <b>This location is listed in the participants of the appointment</b><br>
2683   * Type: <b>reference</b><br>
2684   * Path: <b>Appointment.participant.actor</b><br>
2685   * </p>
2686   */
2687  @SearchParamDefinition(name="location", path="Appointment.participant.actor", description="This location is listed in the participants of the appointment", type="reference", target={Location.class } )
2688  public static final String SP_LOCATION = "location";
2689 /**
2690   * <b>Fluent Client</b> search parameter constant for <b>location</b>
2691   * <p>
2692   * Description: <b>This location is listed in the participants of the appointment</b><br>
2693   * Type: <b>reference</b><br>
2694   * Path: <b>Appointment.participant.actor</b><br>
2695   * </p>
2696   */
2697  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam LOCATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_LOCATION);
2698
2699/**
2700   * Constant for fluent queries to be used to add include statements. Specifies
2701   * the path value of "<b>Appointment:location</b>".
2702   */
2703  public static final ca.uhn.fhir.model.api.Include INCLUDE_LOCATION = new ca.uhn.fhir.model.api.Include("Appointment:location").toLocked();
2704
2705 /**
2706   * Search parameter: <b>status</b>
2707   * <p>
2708   * Description: <b>The overall status of the appointment</b><br>
2709   * Type: <b>token</b><br>
2710   * Path: <b>Appointment.status</b><br>
2711   * </p>
2712   */
2713  @SearchParamDefinition(name="status", path="Appointment.status", description="The overall status of the appointment", type="token" )
2714  public static final String SP_STATUS = "status";
2715 /**
2716   * <b>Fluent Client</b> search parameter constant for <b>status</b>
2717   * <p>
2718   * Description: <b>The overall status of the appointment</b><br>
2719   * Type: <b>token</b><br>
2720   * Path: <b>Appointment.status</b><br>
2721   * </p>
2722   */
2723  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
2724
2725
2726}
2727