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