001package org.hl7.fhir.dstu2.model;
002
003
004
005
006/*
007  Copyright (c) 2011+, HL7, Inc.
008  All rights reserved.
009  
010  Redistribution and use in source and binary forms, with or without modification, 
011  are permitted provided that the following conditions are met:
012  
013   * Redistributions of source code must retain the above copyright notice, this 
014     list of conditions and the following disclaimer.
015   * Redistributions in binary form must reproduce the above copyright notice, 
016     this list of conditions and the following disclaimer in the documentation 
017     and/or other materials provided with the distribution.
018   * Neither the name of HL7 nor the names of its contributors may be used to 
019     endorse or promote products derived from this software without specific 
020     prior written permission.
021  
022  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
023  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
024  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
025  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
026  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
027  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
028  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
029  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
030  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
031  POSSIBILITY OF SUCH DAMAGE.
032  
033*/
034
035// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
036import java.util.ArrayList;
037import java.util.Date;
038import java.util.List;
039
040import ca.uhn.fhir.model.api.annotation.Block;
041import ca.uhn.fhir.model.api.annotation.Child;
042import ca.uhn.fhir.model.api.annotation.Description;
043import ca.uhn.fhir.model.api.annotation.ResourceDef;
044import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
045import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
046import org.hl7.fhir.exceptions.FHIRException;
047import org.hl7.fhir.utilities.Utilities;
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         * added to help the parsers
085         */
086        NULL;
087        public static AppointmentStatus fromCode(String codeString) throws FHIRException {
088            if (codeString == null || "".equals(codeString))
089                return null;
090        if ("proposed".equals(codeString))
091          return PROPOSED;
092        if ("pending".equals(codeString))
093          return PENDING;
094        if ("booked".equals(codeString))
095          return BOOKED;
096        if ("arrived".equals(codeString))
097          return ARRIVED;
098        if ("fulfilled".equals(codeString))
099          return FULFILLED;
100        if ("cancelled".equals(codeString))
101          return CANCELLED;
102        if ("noshow".equals(codeString))
103          return NOSHOW;
104        throw new FHIRException("Unknown AppointmentStatus code '"+codeString+"'");
105        }
106        public String toCode() {
107          switch (this) {
108            case PROPOSED: return "proposed";
109            case PENDING: return "pending";
110            case BOOKED: return "booked";
111            case ARRIVED: return "arrived";
112            case FULFILLED: return "fulfilled";
113            case CANCELLED: return "cancelled";
114            case NOSHOW: return "noshow";
115            default: return "?";
116          }
117        }
118        public String getSystem() {
119          switch (this) {
120            case PROPOSED: return "http://hl7.org/fhir/appointmentstatus";
121            case PENDING: return "http://hl7.org/fhir/appointmentstatus";
122            case BOOKED: return "http://hl7.org/fhir/appointmentstatus";
123            case ARRIVED: return "http://hl7.org/fhir/appointmentstatus";
124            case FULFILLED: return "http://hl7.org/fhir/appointmentstatus";
125            case CANCELLED: return "http://hl7.org/fhir/appointmentstatus";
126            case NOSHOW: return "http://hl7.org/fhir/appointmentstatus";
127            default: return "?";
128          }
129        }
130        public String getDefinition() {
131          switch (this) {
132            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.";
133            case PENDING: return "Some or all of the participant(s) have not finalized their acceptance of the appointment request.";
134            case BOOKED: return "All participant(s) have been considered and the appointment is confirmed to go ahead at the date/times specified.";
135            case ARRIVED: return "Some of the patients have arrived.";
136            case FULFILLED: return "This appointment has completed and may have resulted in an encounter.";
137            case CANCELLED: return "The appointment has been cancelled.";
138            case NOSHOW: return "Some or all of the participant(s) have not/did not appear for the appointment (usually the patient).";
139            default: return "?";
140          }
141        }
142        public String getDisplay() {
143          switch (this) {
144            case PROPOSED: return "Proposed";
145            case PENDING: return "Pending";
146            case BOOKED: return "Booked";
147            case ARRIVED: return "Arrived";
148            case FULFILLED: return "Fulfilled";
149            case CANCELLED: return "Cancelled";
150            case NOSHOW: return "No Show";
151            default: return "?";
152          }
153        }
154    }
155
156  public static class AppointmentStatusEnumFactory implements EnumFactory<AppointmentStatus> {
157    public AppointmentStatus fromCode(String codeString) throws IllegalArgumentException {
158      if (codeString == null || "".equals(codeString))
159            if (codeString == null || "".equals(codeString))
160                return null;
161        if ("proposed".equals(codeString))
162          return AppointmentStatus.PROPOSED;
163        if ("pending".equals(codeString))
164          return AppointmentStatus.PENDING;
165        if ("booked".equals(codeString))
166          return AppointmentStatus.BOOKED;
167        if ("arrived".equals(codeString))
168          return AppointmentStatus.ARRIVED;
169        if ("fulfilled".equals(codeString))
170          return AppointmentStatus.FULFILLED;
171        if ("cancelled".equals(codeString))
172          return AppointmentStatus.CANCELLED;
173        if ("noshow".equals(codeString))
174          return AppointmentStatus.NOSHOW;
175        throw new IllegalArgumentException("Unknown AppointmentStatus code '"+codeString+"'");
176        }
177        public Enumeration<AppointmentStatus> fromType(Base code) throws FHIRException {
178          if (code == null || code.isEmpty())
179            return null;
180          String codeString = ((PrimitiveType) code).asStringValue();
181          if (codeString == null || "".equals(codeString))
182            return null;
183        if ("proposed".equals(codeString))
184          return new Enumeration<AppointmentStatus>(this, AppointmentStatus.PROPOSED);
185        if ("pending".equals(codeString))
186          return new Enumeration<AppointmentStatus>(this, AppointmentStatus.PENDING);
187        if ("booked".equals(codeString))
188          return new Enumeration<AppointmentStatus>(this, AppointmentStatus.BOOKED);
189        if ("arrived".equals(codeString))
190          return new Enumeration<AppointmentStatus>(this, AppointmentStatus.ARRIVED);
191        if ("fulfilled".equals(codeString))
192          return new Enumeration<AppointmentStatus>(this, AppointmentStatus.FULFILLED);
193        if ("cancelled".equals(codeString))
194          return new Enumeration<AppointmentStatus>(this, AppointmentStatus.CANCELLED);
195        if ("noshow".equals(codeString))
196          return new Enumeration<AppointmentStatus>(this, AppointmentStatus.NOSHOW);
197        throw new FHIRException("Unknown AppointmentStatus code '"+codeString+"'");
198        }
199    public String toCode(AppointmentStatus code) {
200      if (code == AppointmentStatus.PROPOSED)
201        return "proposed";
202      if (code == AppointmentStatus.PENDING)
203        return "pending";
204      if (code == AppointmentStatus.BOOKED)
205        return "booked";
206      if (code == AppointmentStatus.ARRIVED)
207        return "arrived";
208      if (code == AppointmentStatus.FULFILLED)
209        return "fulfilled";
210      if (code == AppointmentStatus.CANCELLED)
211        return "cancelled";
212      if (code == AppointmentStatus.NOSHOW)
213        return "noshow";
214      return "?";
215      }
216    }
217
218    public enum ParticipantRequired {
219        /**
220         * The participant is required to attend the appointment.
221         */
222        REQUIRED, 
223        /**
224         * The participant may optionally attend the appointment.
225         */
226        OPTIONAL, 
227        /**
228         * 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).
229         */
230        INFORMATIONONLY, 
231        /**
232         * added to help the parsers
233         */
234        NULL;
235        public static ParticipantRequired fromCode(String codeString) throws FHIRException {
236            if (codeString == null || "".equals(codeString))
237                return null;
238        if ("required".equals(codeString))
239          return REQUIRED;
240        if ("optional".equals(codeString))
241          return OPTIONAL;
242        if ("information-only".equals(codeString))
243          return INFORMATIONONLY;
244        throw new FHIRException("Unknown ParticipantRequired code '"+codeString+"'");
245        }
246        public String toCode() {
247          switch (this) {
248            case REQUIRED: return "required";
249            case OPTIONAL: return "optional";
250            case INFORMATIONONLY: return "information-only";
251            default: return "?";
252          }
253        }
254        public String getSystem() {
255          switch (this) {
256            case REQUIRED: return "http://hl7.org/fhir/participantrequired";
257            case OPTIONAL: return "http://hl7.org/fhir/participantrequired";
258            case INFORMATIONONLY: return "http://hl7.org/fhir/participantrequired";
259            default: return "?";
260          }
261        }
262        public String getDefinition() {
263          switch (this) {
264            case REQUIRED: return "The participant is required to attend the appointment.";
265            case OPTIONAL: return "The participant may optionally attend the appointment.";
266            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).";
267            default: return "?";
268          }
269        }
270        public String getDisplay() {
271          switch (this) {
272            case REQUIRED: return "Required";
273            case OPTIONAL: return "Optional";
274            case INFORMATIONONLY: return "Information Only";
275            default: return "?";
276          }
277        }
278    }
279
280  public static class ParticipantRequiredEnumFactory implements EnumFactory<ParticipantRequired> {
281    public ParticipantRequired fromCode(String codeString) throws IllegalArgumentException {
282      if (codeString == null || "".equals(codeString))
283            if (codeString == null || "".equals(codeString))
284                return null;
285        if ("required".equals(codeString))
286          return ParticipantRequired.REQUIRED;
287        if ("optional".equals(codeString))
288          return ParticipantRequired.OPTIONAL;
289        if ("information-only".equals(codeString))
290          return ParticipantRequired.INFORMATIONONLY;
291        throw new IllegalArgumentException("Unknown ParticipantRequired code '"+codeString+"'");
292        }
293        public Enumeration<ParticipantRequired> fromType(Base code) throws FHIRException {
294          if (code == null || code.isEmpty())
295            return null;
296          String codeString = ((PrimitiveType) code).asStringValue();
297          if (codeString == null || "".equals(codeString))
298            return null;
299        if ("required".equals(codeString))
300          return new Enumeration<ParticipantRequired>(this, ParticipantRequired.REQUIRED);
301        if ("optional".equals(codeString))
302          return new Enumeration<ParticipantRequired>(this, ParticipantRequired.OPTIONAL);
303        if ("information-only".equals(codeString))
304          return new Enumeration<ParticipantRequired>(this, ParticipantRequired.INFORMATIONONLY);
305        throw new FHIRException("Unknown ParticipantRequired code '"+codeString+"'");
306        }
307    public String toCode(ParticipantRequired code) {
308      if (code == ParticipantRequired.REQUIRED)
309        return "required";
310      if (code == ParticipantRequired.OPTIONAL)
311        return "optional";
312      if (code == ParticipantRequired.INFORMATIONONLY)
313        return "information-only";
314      return "?";
315      }
316    }
317
318    public enum ParticipationStatus {
319        /**
320         * The participant has accepted the appointment.
321         */
322        ACCEPTED, 
323        /**
324         * The participant has declined the appointment and will not participate in the appointment.
325         */
326        DECLINED, 
327        /**
328         * 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.
329         */
330        TENTATIVE, 
331        /**
332         * The participant needs to indicate if they accept the appointment by changing this status to one of the other statuses.
333         */
334        NEEDSACTION, 
335        /**
336         * added to help the parsers
337         */
338        NULL;
339        public static ParticipationStatus fromCode(String codeString) throws FHIRException {
340            if (codeString == null || "".equals(codeString))
341                return null;
342        if ("accepted".equals(codeString))
343          return ACCEPTED;
344        if ("declined".equals(codeString))
345          return DECLINED;
346        if ("tentative".equals(codeString))
347          return TENTATIVE;
348        if ("needs-action".equals(codeString))
349          return NEEDSACTION;
350        throw new FHIRException("Unknown ParticipationStatus code '"+codeString+"'");
351        }
352        public String toCode() {
353          switch (this) {
354            case ACCEPTED: return "accepted";
355            case DECLINED: return "declined";
356            case TENTATIVE: return "tentative";
357            case NEEDSACTION: return "needs-action";
358            default: return "?";
359          }
360        }
361        public String getSystem() {
362          switch (this) {
363            case ACCEPTED: return "http://hl7.org/fhir/participationstatus";
364            case DECLINED: return "http://hl7.org/fhir/participationstatus";
365            case TENTATIVE: return "http://hl7.org/fhir/participationstatus";
366            case NEEDSACTION: return "http://hl7.org/fhir/participationstatus";
367            default: return "?";
368          }
369        }
370        public String getDefinition() {
371          switch (this) {
372            case ACCEPTED: return "The participant has accepted the appointment.";
373            case DECLINED: return "The participant has declined the appointment and will not participate in the appointment.";
374            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.";
375            case NEEDSACTION: return "The participant needs to indicate if they accept the appointment by changing this status to one of the other statuses.";
376            default: return "?";
377          }
378        }
379        public String getDisplay() {
380          switch (this) {
381            case ACCEPTED: return "Accepted";
382            case DECLINED: return "Declined";
383            case TENTATIVE: return "Tentative";
384            case NEEDSACTION: return "Needs Action";
385            default: return "?";
386          }
387        }
388    }
389
390  public static class ParticipationStatusEnumFactory implements EnumFactory<ParticipationStatus> {
391    public ParticipationStatus fromCode(String codeString) throws IllegalArgumentException {
392      if (codeString == null || "".equals(codeString))
393            if (codeString == null || "".equals(codeString))
394                return null;
395        if ("accepted".equals(codeString))
396          return ParticipationStatus.ACCEPTED;
397        if ("declined".equals(codeString))
398          return ParticipationStatus.DECLINED;
399        if ("tentative".equals(codeString))
400          return ParticipationStatus.TENTATIVE;
401        if ("needs-action".equals(codeString))
402          return ParticipationStatus.NEEDSACTION;
403        throw new IllegalArgumentException("Unknown ParticipationStatus code '"+codeString+"'");
404        }
405        public Enumeration<ParticipationStatus> fromType(Base code) throws FHIRException {
406          if (code == null || code.isEmpty())
407            return null;
408          String codeString = ((PrimitiveType) code).asStringValue();
409          if (codeString == null || "".equals(codeString))
410            return null;
411        if ("accepted".equals(codeString))
412          return new Enumeration<ParticipationStatus>(this, ParticipationStatus.ACCEPTED);
413        if ("declined".equals(codeString))
414          return new Enumeration<ParticipationStatus>(this, ParticipationStatus.DECLINED);
415        if ("tentative".equals(codeString))
416          return new Enumeration<ParticipationStatus>(this, ParticipationStatus.TENTATIVE);
417        if ("needs-action".equals(codeString))
418          return new Enumeration<ParticipationStatus>(this, ParticipationStatus.NEEDSACTION);
419        throw new FHIRException("Unknown ParticipationStatus code '"+codeString+"'");
420        }
421    public String toCode(ParticipationStatus code) {
422      if (code == ParticipationStatus.ACCEPTED)
423        return "accepted";
424      if (code == ParticipationStatus.DECLINED)
425        return "declined";
426      if (code == ParticipationStatus.TENTATIVE)
427        return "tentative";
428      if (code == ParticipationStatus.NEEDSACTION)
429        return "needs-action";
430      return "?";
431      }
432    }
433
434    @Block()
435    public static class AppointmentParticipantComponent extends BackboneElement implements IBaseBackboneElement {
436        /**
437         * Role of participant in the appointment.
438         */
439        @Child(name = "type", type = {CodeableConcept.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
440        @Description(shortDefinition="Role of participant in the appointment", formalDefinition="Role of participant in the appointment." )
441        protected List<CodeableConcept> type;
442
443        /**
444         * A Person, Location/HealthcareService or Device that is participating in the appointment.
445         */
446        @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)
447        @Description(shortDefinition="Person, Location/HealthcareService or Device", formalDefinition="A Person, Location/HealthcareService or Device that is participating in the appointment." )
448        protected Reference actor;
449
450        /**
451         * The actual object that is the target of the reference (A Person, Location/HealthcareService or Device that is participating in the appointment.)
452         */
453        protected Resource actorTarget;
454
455        /**
456         * 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.
457         */
458        @Child(name = "required", type = {CodeType.class}, order=3, min=0, max=1, modifier=false, summary=true)
459        @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." )
460        protected Enumeration<ParticipantRequired> required;
461
462        /**
463         * Participation status of the Patient.
464         */
465        @Child(name = "status", type = {CodeType.class}, order=4, min=1, max=1, modifier=false, summary=false)
466        @Description(shortDefinition="accepted | declined | tentative | needs-action", formalDefinition="Participation status of the Patient." )
467        protected Enumeration<ParticipationStatus> status;
468
469        private static final long serialVersionUID = -1620552507L;
470
471    /*
472     * Constructor
473     */
474      public AppointmentParticipantComponent() {
475        super();
476      }
477
478    /*
479     * Constructor
480     */
481      public AppointmentParticipantComponent(Enumeration<ParticipationStatus> status) {
482        super();
483        this.status = status;
484      }
485
486        /**
487         * @return {@link #type} (Role of participant in the appointment.)
488         */
489        public List<CodeableConcept> getType() { 
490          if (this.type == null)
491            this.type = new ArrayList<CodeableConcept>();
492          return this.type;
493        }
494
495        public boolean hasType() { 
496          if (this.type == null)
497            return false;
498          for (CodeableConcept item : this.type)
499            if (!item.isEmpty())
500              return true;
501          return false;
502        }
503
504        /**
505         * @return {@link #type} (Role of participant in the appointment.)
506         */
507    // syntactic sugar
508        public CodeableConcept addType() { //3
509          CodeableConcept t = new CodeableConcept();
510          if (this.type == null)
511            this.type = new ArrayList<CodeableConcept>();
512          this.type.add(t);
513          return t;
514        }
515
516    // syntactic sugar
517        public AppointmentParticipantComponent addType(CodeableConcept t) { //3
518          if (t == null)
519            return this;
520          if (this.type == null)
521            this.type = new ArrayList<CodeableConcept>();
522          this.type.add(t);
523          return this;
524        }
525
526        /**
527         * @return {@link #actor} (A Person, Location/HealthcareService or Device that is participating in the appointment.)
528         */
529        public Reference getActor() { 
530          if (this.actor == null)
531            if (Configuration.errorOnAutoCreate())
532              throw new Error("Attempt to auto-create AppointmentParticipantComponent.actor");
533            else if (Configuration.doAutoCreate())
534              this.actor = new Reference(); // cc
535          return this.actor;
536        }
537
538        public boolean hasActor() { 
539          return this.actor != null && !this.actor.isEmpty();
540        }
541
542        /**
543         * @param value {@link #actor} (A Person, Location/HealthcareService or Device that is participating in the appointment.)
544         */
545        public AppointmentParticipantComponent setActor(Reference value) { 
546          this.actor = value;
547          return this;
548        }
549
550        /**
551         * @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.)
552         */
553        public Resource getActorTarget() { 
554          return this.actorTarget;
555        }
556
557        /**
558         * @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.)
559         */
560        public AppointmentParticipantComponent setActorTarget(Resource value) { 
561          this.actorTarget = value;
562          return this;
563        }
564
565        /**
566         * @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
567         */
568        public Enumeration<ParticipantRequired> getRequiredElement() { 
569          if (this.required == null)
570            if (Configuration.errorOnAutoCreate())
571              throw new Error("Attempt to auto-create AppointmentParticipantComponent.required");
572            else if (Configuration.doAutoCreate())
573              this.required = new Enumeration<ParticipantRequired>(new ParticipantRequiredEnumFactory()); // bb
574          return this.required;
575        }
576
577        public boolean hasRequiredElement() { 
578          return this.required != null && !this.required.isEmpty();
579        }
580
581        public boolean hasRequired() { 
582          return this.required != null && !this.required.isEmpty();
583        }
584
585        /**
586         * @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
587         */
588        public AppointmentParticipantComponent setRequiredElement(Enumeration<ParticipantRequired> value) { 
589          this.required = value;
590          return this;
591        }
592
593        /**
594         * @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.
595         */
596        public ParticipantRequired getRequired() { 
597          return this.required == null ? null : this.required.getValue();
598        }
599
600        /**
601         * @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.
602         */
603        public AppointmentParticipantComponent setRequired(ParticipantRequired value) { 
604          if (value == null)
605            this.required = null;
606          else {
607            if (this.required == null)
608              this.required = new Enumeration<ParticipantRequired>(new ParticipantRequiredEnumFactory());
609            this.required.setValue(value);
610          }
611          return this;
612        }
613
614        /**
615         * @return {@link #status} (Participation status of the Patient.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
616         */
617        public Enumeration<ParticipationStatus> getStatusElement() { 
618          if (this.status == null)
619            if (Configuration.errorOnAutoCreate())
620              throw new Error("Attempt to auto-create AppointmentParticipantComponent.status");
621            else if (Configuration.doAutoCreate())
622              this.status = new Enumeration<ParticipationStatus>(new ParticipationStatusEnumFactory()); // bb
623          return this.status;
624        }
625
626        public boolean hasStatusElement() { 
627          return this.status != null && !this.status.isEmpty();
628        }
629
630        public boolean hasStatus() { 
631          return this.status != null && !this.status.isEmpty();
632        }
633
634        /**
635         * @param value {@link #status} (Participation status of the Patient.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
636         */
637        public AppointmentParticipantComponent setStatusElement(Enumeration<ParticipationStatus> value) { 
638          this.status = value;
639          return this;
640        }
641
642        /**
643         * @return Participation status of the Patient.
644         */
645        public ParticipationStatus getStatus() { 
646          return this.status == null ? null : this.status.getValue();
647        }
648
649        /**
650         * @param value Participation status of the Patient.
651         */
652        public AppointmentParticipantComponent setStatus(ParticipationStatus value) { 
653            if (this.status == null)
654              this.status = new Enumeration<ParticipationStatus>(new ParticipationStatusEnumFactory());
655            this.status.setValue(value);
656          return this;
657        }
658
659        protected void listChildren(List<Property> childrenList) {
660          super.listChildren(childrenList);
661          childrenList.add(new Property("type", "CodeableConcept", "Role of participant in the appointment.", 0, java.lang.Integer.MAX_VALUE, type));
662          childrenList.add(new Property("actor", "Reference(Patient|Practitioner|RelatedPerson|Device|HealthcareService|Location)", "A Person, Location/HealthcareService or Device that is participating in the appointment.", 0, java.lang.Integer.MAX_VALUE, actor));
663          childrenList.add(new Property("required", "code", "Is this participant required to be present at the meeting. This covers a use-case where 2 doctors need to meet to discuss the results for a specific patient, and the patient is not required to be present.", 0, java.lang.Integer.MAX_VALUE, required));
664          childrenList.add(new Property("status", "code", "Participation status of the Patient.", 0, java.lang.Integer.MAX_VALUE, status));
665        }
666
667      @Override
668      public void setProperty(String name, Base value) throws FHIRException {
669        if (name.equals("type"))
670          this.getType().add(castToCodeableConcept(value));
671        else if (name.equals("actor"))
672          this.actor = castToReference(value); // Reference
673        else if (name.equals("required"))
674          this.required = new ParticipantRequiredEnumFactory().fromType(value); // Enumeration<ParticipantRequired>
675        else if (name.equals("status"))
676          this.status = new ParticipationStatusEnumFactory().fromType(value); // Enumeration<ParticipationStatus>
677        else
678          super.setProperty(name, value);
679      }
680
681      @Override
682      public Base addChild(String name) throws FHIRException {
683        if (name.equals("type")) {
684          return addType();
685        }
686        else if (name.equals("actor")) {
687          this.actor = new Reference();
688          return this.actor;
689        }
690        else if (name.equals("required")) {
691          throw new FHIRException("Cannot call addChild on a primitive type Appointment.required");
692        }
693        else if (name.equals("status")) {
694          throw new FHIRException("Cannot call addChild on a primitive type Appointment.status");
695        }
696        else
697          return super.addChild(name);
698      }
699
700      public AppointmentParticipantComponent copy() {
701        AppointmentParticipantComponent dst = new AppointmentParticipantComponent();
702        copyValues(dst);
703        if (type != null) {
704          dst.type = new ArrayList<CodeableConcept>();
705          for (CodeableConcept i : type)
706            dst.type.add(i.copy());
707        };
708        dst.actor = actor == null ? null : actor.copy();
709        dst.required = required == null ? null : required.copy();
710        dst.status = status == null ? null : status.copy();
711        return dst;
712      }
713
714      @Override
715      public boolean equalsDeep(Base other) {
716        if (!super.equalsDeep(other))
717          return false;
718        if (!(other instanceof AppointmentParticipantComponent))
719          return false;
720        AppointmentParticipantComponent o = (AppointmentParticipantComponent) other;
721        return compareDeep(type, o.type, true) && compareDeep(actor, o.actor, true) && compareDeep(required, o.required, true)
722           && compareDeep(status, o.status, true);
723      }
724
725      @Override
726      public boolean equalsShallow(Base other) {
727        if (!super.equalsShallow(other))
728          return false;
729        if (!(other instanceof AppointmentParticipantComponent))
730          return false;
731        AppointmentParticipantComponent o = (AppointmentParticipantComponent) other;
732        return compareValues(required, o.required, true) && compareValues(status, o.status, true);
733      }
734
735      public boolean isEmpty() {
736        return super.isEmpty() && (type == null || type.isEmpty()) && (actor == null || actor.isEmpty())
737           && (required == null || required.isEmpty()) && (status == null || status.isEmpty());
738      }
739
740  public String fhirType() {
741    return "Appointment.participant";
742
743  }
744
745  }
746
747    /**
748     * 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).
749     */
750    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
751    @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)." )
752    protected List<Identifier> identifier;
753
754    /**
755     * 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.
756     */
757    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
758    @Description(shortDefinition="proposed | pending | booked | arrived | fulfilled | cancelled | noshow", 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." )
759    protected Enumeration<AppointmentStatus> status;
760
761    /**
762     * The type of appointment that is being booked (This may also be associated with participants for location, and/or a HealthcareService).
763     */
764    @Child(name = "type", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
765    @Description(shortDefinition="The type of appointment that is being booked", formalDefinition="The type of appointment that is being booked (This may also be associated with participants for location, and/or a HealthcareService)." )
766    protected CodeableConcept type;
767
768    /**
769     * The reason that this appointment is being scheduled. This is more clinical than administrative.
770     */
771    @Child(name = "reason", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true)
772    @Description(shortDefinition="Reason this appointment is scheduled", formalDefinition="The reason that this appointment is being scheduled. This is more clinical than administrative." )
773    protected CodeableConcept reason;
774
775    /**
776     * 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).
777     */
778    @Child(name = "priority", type = {UnsignedIntType.class}, order=4, min=0, max=1, modifier=false, summary=false)
779    @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)." )
780    protected UnsignedIntType priority;
781
782    /**
783     * 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.
784     */
785    @Child(name = "description", type = {StringType.class}, order=5, min=0, max=1, modifier=false, summary=false)
786    @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." )
787    protected StringType description;
788
789    /**
790     * Date/Time that the appointment is to take place.
791     */
792    @Child(name = "start", type = {InstantType.class}, order=6, min=0, max=1, modifier=false, summary=true)
793    @Description(shortDefinition="When appointment is to take place", formalDefinition="Date/Time that the appointment is to take place." )
794    protected InstantType start;
795
796    /**
797     * Date/Time that the appointment is to conclude.
798     */
799    @Child(name = "end", type = {InstantType.class}, order=7, min=0, max=1, modifier=false, summary=true)
800    @Description(shortDefinition="When appointment is to conclude", formalDefinition="Date/Time that the appointment is to conclude." )
801    protected InstantType end;
802
803    /**
804     * 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).
805     */
806    @Child(name = "minutesDuration", type = {PositiveIntType.class}, order=8, min=0, max=1, modifier=false, summary=false)
807    @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)." )
808    protected PositiveIntType minutesDuration;
809
810    /**
811     * The slot that this appointment is filling. If provided then the schedule will not be provided as slots are not recursive, and the start/end values MUST be the same as from the slot.
812     */
813    @Child(name = "slot", type = {Slot.class}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
814    @Description(shortDefinition="If provided, then no schedule and start/end values MUST match slot", formalDefinition="The slot that this appointment is filling. If provided then the schedule will not be provided as slots are not recursive, and the start/end values MUST be the same as from the slot." )
815    protected List<Reference> slot;
816    /**
817     * The actual objects that are the target of the reference (The slot that this appointment is filling. If provided then the schedule will not be provided as slots are not recursive, and the start/end values MUST be the same as from the slot.)
818     */
819    protected List<Slot> slotTarget;
820
821
822    /**
823     * Additional comments about the appointment.
824     */
825    @Child(name = "comment", type = {StringType.class}, order=10, min=0, max=1, modifier=false, summary=false)
826    @Description(shortDefinition="Additional comments", formalDefinition="Additional comments about the appointment." )
827    protected StringType comment;
828
829    /**
830     * List of participants involved in the appointment.
831     */
832    @Child(name = "participant", type = {}, order=11, min=1, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
833    @Description(shortDefinition="Participants involved in appointment", formalDefinition="List of participants involved in the appointment." )
834    protected List<AppointmentParticipantComponent> participant;
835
836    private static final long serialVersionUID = -1403944125L;
837
838  /*
839   * Constructor
840   */
841    public Appointment() {
842      super();
843    }
844
845  /*
846   * Constructor
847   */
848    public Appointment(Enumeration<AppointmentStatus> status) {
849      super();
850      this.status = status;
851    }
852
853    /**
854     * @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).)
855     */
856    public List<Identifier> getIdentifier() { 
857      if (this.identifier == null)
858        this.identifier = new ArrayList<Identifier>();
859      return this.identifier;
860    }
861
862    public boolean hasIdentifier() { 
863      if (this.identifier == null)
864        return false;
865      for (Identifier item : this.identifier)
866        if (!item.isEmpty())
867          return true;
868      return false;
869    }
870
871    /**
872     * @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).)
873     */
874    // syntactic sugar
875    public Identifier addIdentifier() { //3
876      Identifier t = new Identifier();
877      if (this.identifier == null)
878        this.identifier = new ArrayList<Identifier>();
879      this.identifier.add(t);
880      return t;
881    }
882
883    // syntactic sugar
884    public Appointment addIdentifier(Identifier t) { //3
885      if (t == null)
886        return this;
887      if (this.identifier == null)
888        this.identifier = new ArrayList<Identifier>();
889      this.identifier.add(t);
890      return this;
891    }
892
893    /**
894     * @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
895     */
896    public Enumeration<AppointmentStatus> getStatusElement() { 
897      if (this.status == null)
898        if (Configuration.errorOnAutoCreate())
899          throw new Error("Attempt to auto-create Appointment.status");
900        else if (Configuration.doAutoCreate())
901          this.status = new Enumeration<AppointmentStatus>(new AppointmentStatusEnumFactory()); // bb
902      return this.status;
903    }
904
905    public boolean hasStatusElement() { 
906      return this.status != null && !this.status.isEmpty();
907    }
908
909    public boolean hasStatus() { 
910      return this.status != null && !this.status.isEmpty();
911    }
912
913    /**
914     * @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
915     */
916    public Appointment setStatusElement(Enumeration<AppointmentStatus> value) { 
917      this.status = value;
918      return this;
919    }
920
921    /**
922     * @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.
923     */
924    public AppointmentStatus getStatus() { 
925      return this.status == null ? null : this.status.getValue();
926    }
927
928    /**
929     * @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.
930     */
931    public Appointment setStatus(AppointmentStatus value) { 
932        if (this.status == null)
933          this.status = new Enumeration<AppointmentStatus>(new AppointmentStatusEnumFactory());
934        this.status.setValue(value);
935      return this;
936    }
937
938    /**
939     * @return {@link #type} (The type of appointment that is being booked (This may also be associated with participants for location, and/or a HealthcareService).)
940     */
941    public CodeableConcept getType() { 
942      if (this.type == null)
943        if (Configuration.errorOnAutoCreate())
944          throw new Error("Attempt to auto-create Appointment.type");
945        else if (Configuration.doAutoCreate())
946          this.type = new CodeableConcept(); // cc
947      return this.type;
948    }
949
950    public boolean hasType() { 
951      return this.type != null && !this.type.isEmpty();
952    }
953
954    /**
955     * @param value {@link #type} (The type of appointment that is being booked (This may also be associated with participants for location, and/or a HealthcareService).)
956     */
957    public Appointment setType(CodeableConcept value) { 
958      this.type = value;
959      return this;
960    }
961
962    /**
963     * @return {@link #reason} (The reason that this appointment is being scheduled. This is more clinical than administrative.)
964     */
965    public CodeableConcept getReason() { 
966      if (this.reason == null)
967        if (Configuration.errorOnAutoCreate())
968          throw new Error("Attempt to auto-create Appointment.reason");
969        else if (Configuration.doAutoCreate())
970          this.reason = new CodeableConcept(); // cc
971      return this.reason;
972    }
973
974    public boolean hasReason() { 
975      return this.reason != null && !this.reason.isEmpty();
976    }
977
978    /**
979     * @param value {@link #reason} (The reason that this appointment is being scheduled. This is more clinical than administrative.)
980     */
981    public Appointment setReason(CodeableConcept value) { 
982      this.reason = value;
983      return this;
984    }
985
986    /**
987     * @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
988     */
989    public UnsignedIntType getPriorityElement() { 
990      if (this.priority == null)
991        if (Configuration.errorOnAutoCreate())
992          throw new Error("Attempt to auto-create Appointment.priority");
993        else if (Configuration.doAutoCreate())
994          this.priority = new UnsignedIntType(); // bb
995      return this.priority;
996    }
997
998    public boolean hasPriorityElement() { 
999      return this.priority != null && !this.priority.isEmpty();
1000    }
1001
1002    public boolean hasPriority() { 
1003      return this.priority != null && !this.priority.isEmpty();
1004    }
1005
1006    /**
1007     * @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
1008     */
1009    public Appointment setPriorityElement(UnsignedIntType value) { 
1010      this.priority = value;
1011      return this;
1012    }
1013
1014    /**
1015     * @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).
1016     */
1017    public int getPriority() { 
1018      return this.priority == null || this.priority.isEmpty() ? 0 : this.priority.getValue();
1019    }
1020
1021    /**
1022     * @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).
1023     */
1024    public Appointment setPriority(int value) { 
1025        if (this.priority == null)
1026          this.priority = new UnsignedIntType();
1027        this.priority.setValue(value);
1028      return this;
1029    }
1030
1031    /**
1032     * @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
1033     */
1034    public StringType getDescriptionElement() { 
1035      if (this.description == null)
1036        if (Configuration.errorOnAutoCreate())
1037          throw new Error("Attempt to auto-create Appointment.description");
1038        else if (Configuration.doAutoCreate())
1039          this.description = new StringType(); // bb
1040      return this.description;
1041    }
1042
1043    public boolean hasDescriptionElement() { 
1044      return this.description != null && !this.description.isEmpty();
1045    }
1046
1047    public boolean hasDescription() { 
1048      return this.description != null && !this.description.isEmpty();
1049    }
1050
1051    /**
1052     * @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
1053     */
1054    public Appointment setDescriptionElement(StringType value) { 
1055      this.description = value;
1056      return this;
1057    }
1058
1059    /**
1060     * @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.
1061     */
1062    public String getDescription() { 
1063      return this.description == null ? null : this.description.getValue();
1064    }
1065
1066    /**
1067     * @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.
1068     */
1069    public Appointment setDescription(String value) { 
1070      if (Utilities.noString(value))
1071        this.description = null;
1072      else {
1073        if (this.description == null)
1074          this.description = new StringType();
1075        this.description.setValue(value);
1076      }
1077      return this;
1078    }
1079
1080    /**
1081     * @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
1082     */
1083    public InstantType getStartElement() { 
1084      if (this.start == null)
1085        if (Configuration.errorOnAutoCreate())
1086          throw new Error("Attempt to auto-create Appointment.start");
1087        else if (Configuration.doAutoCreate())
1088          this.start = new InstantType(); // bb
1089      return this.start;
1090    }
1091
1092    public boolean hasStartElement() { 
1093      return this.start != null && !this.start.isEmpty();
1094    }
1095
1096    public boolean hasStart() { 
1097      return this.start != null && !this.start.isEmpty();
1098    }
1099
1100    /**
1101     * @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
1102     */
1103    public Appointment setStartElement(InstantType value) { 
1104      this.start = value;
1105      return this;
1106    }
1107
1108    /**
1109     * @return Date/Time that the appointment is to take place.
1110     */
1111    public Date getStart() { 
1112      return this.start == null ? null : this.start.getValue();
1113    }
1114
1115    /**
1116     * @param value Date/Time that the appointment is to take place.
1117     */
1118    public Appointment setStart(Date value) { 
1119      if (value == null)
1120        this.start = null;
1121      else {
1122        if (this.start == null)
1123          this.start = new InstantType();
1124        this.start.setValue(value);
1125      }
1126      return this;
1127    }
1128
1129    /**
1130     * @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
1131     */
1132    public InstantType getEndElement() { 
1133      if (this.end == null)
1134        if (Configuration.errorOnAutoCreate())
1135          throw new Error("Attempt to auto-create Appointment.end");
1136        else if (Configuration.doAutoCreate())
1137          this.end = new InstantType(); // bb
1138      return this.end;
1139    }
1140
1141    public boolean hasEndElement() { 
1142      return this.end != null && !this.end.isEmpty();
1143    }
1144
1145    public boolean hasEnd() { 
1146      return this.end != null && !this.end.isEmpty();
1147    }
1148
1149    /**
1150     * @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
1151     */
1152    public Appointment setEndElement(InstantType value) { 
1153      this.end = value;
1154      return this;
1155    }
1156
1157    /**
1158     * @return Date/Time that the appointment is to conclude.
1159     */
1160    public Date getEnd() { 
1161      return this.end == null ? null : this.end.getValue();
1162    }
1163
1164    /**
1165     * @param value Date/Time that the appointment is to conclude.
1166     */
1167    public Appointment setEnd(Date value) { 
1168      if (value == null)
1169        this.end = null;
1170      else {
1171        if (this.end == null)
1172          this.end = new InstantType();
1173        this.end.setValue(value);
1174      }
1175      return this;
1176    }
1177
1178    /**
1179     * @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
1180     */
1181    public PositiveIntType getMinutesDurationElement() { 
1182      if (this.minutesDuration == null)
1183        if (Configuration.errorOnAutoCreate())
1184          throw new Error("Attempt to auto-create Appointment.minutesDuration");
1185        else if (Configuration.doAutoCreate())
1186          this.minutesDuration = new PositiveIntType(); // bb
1187      return this.minutesDuration;
1188    }
1189
1190    public boolean hasMinutesDurationElement() { 
1191      return this.minutesDuration != null && !this.minutesDuration.isEmpty();
1192    }
1193
1194    public boolean hasMinutesDuration() { 
1195      return this.minutesDuration != null && !this.minutesDuration.isEmpty();
1196    }
1197
1198    /**
1199     * @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
1200     */
1201    public Appointment setMinutesDurationElement(PositiveIntType value) { 
1202      this.minutesDuration = value;
1203      return this;
1204    }
1205
1206    /**
1207     * @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).
1208     */
1209    public int getMinutesDuration() { 
1210      return this.minutesDuration == null || this.minutesDuration.isEmpty() ? 0 : this.minutesDuration.getValue();
1211    }
1212
1213    /**
1214     * @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).
1215     */
1216    public Appointment setMinutesDuration(int value) { 
1217        if (this.minutesDuration == null)
1218          this.minutesDuration = new PositiveIntType();
1219        this.minutesDuration.setValue(value);
1220      return this;
1221    }
1222
1223    /**
1224     * @return {@link #slot} (The slot that this appointment is filling. If provided then the schedule will not be provided as slots are not recursive, and the start/end values MUST be the same as from the slot.)
1225     */
1226    public List<Reference> getSlot() { 
1227      if (this.slot == null)
1228        this.slot = new ArrayList<Reference>();
1229      return this.slot;
1230    }
1231
1232    public boolean hasSlot() { 
1233      if (this.slot == null)
1234        return false;
1235      for (Reference item : this.slot)
1236        if (!item.isEmpty())
1237          return true;
1238      return false;
1239    }
1240
1241    /**
1242     * @return {@link #slot} (The slot that this appointment is filling. If provided then the schedule will not be provided as slots are not recursive, and the start/end values MUST be the same as from the slot.)
1243     */
1244    // syntactic sugar
1245    public Reference addSlot() { //3
1246      Reference t = new Reference();
1247      if (this.slot == null)
1248        this.slot = new ArrayList<Reference>();
1249      this.slot.add(t);
1250      return t;
1251    }
1252
1253    // syntactic sugar
1254    public Appointment addSlot(Reference t) { //3
1255      if (t == null)
1256        return this;
1257      if (this.slot == null)
1258        this.slot = new ArrayList<Reference>();
1259      this.slot.add(t);
1260      return this;
1261    }
1262
1263    /**
1264     * @return {@link #slot} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. The slot that this appointment is filling. If provided then the schedule will not be provided as slots are not recursive, and the start/end values MUST be the same as from the slot.)
1265     */
1266    public List<Slot> getSlotTarget() { 
1267      if (this.slotTarget == null)
1268        this.slotTarget = new ArrayList<Slot>();
1269      return this.slotTarget;
1270    }
1271
1272    // syntactic sugar
1273    /**
1274     * @return {@link #slot} (Add an actual object that is the target of the reference. The reference library doesn't use these, but you can use this to hold the resources if you resolvethemt. The slot that this appointment is filling. If provided then the schedule will not be provided as slots are not recursive, and the start/end values MUST be the same as from the slot.)
1275     */
1276    public Slot addSlotTarget() { 
1277      Slot r = new Slot();
1278      if (this.slotTarget == null)
1279        this.slotTarget = new ArrayList<Slot>();
1280      this.slotTarget.add(r);
1281      return r;
1282    }
1283
1284    /**
1285     * @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
1286     */
1287    public StringType getCommentElement() { 
1288      if (this.comment == null)
1289        if (Configuration.errorOnAutoCreate())
1290          throw new Error("Attempt to auto-create Appointment.comment");
1291        else if (Configuration.doAutoCreate())
1292          this.comment = new StringType(); // bb
1293      return this.comment;
1294    }
1295
1296    public boolean hasCommentElement() { 
1297      return this.comment != null && !this.comment.isEmpty();
1298    }
1299
1300    public boolean hasComment() { 
1301      return this.comment != null && !this.comment.isEmpty();
1302    }
1303
1304    /**
1305     * @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
1306     */
1307    public Appointment setCommentElement(StringType value) { 
1308      this.comment = value;
1309      return this;
1310    }
1311
1312    /**
1313     * @return Additional comments about the appointment.
1314     */
1315    public String getComment() { 
1316      return this.comment == null ? null : this.comment.getValue();
1317    }
1318
1319    /**
1320     * @param value Additional comments about the appointment.
1321     */
1322    public Appointment setComment(String value) { 
1323      if (Utilities.noString(value))
1324        this.comment = null;
1325      else {
1326        if (this.comment == null)
1327          this.comment = new StringType();
1328        this.comment.setValue(value);
1329      }
1330      return this;
1331    }
1332
1333    /**
1334     * @return {@link #participant} (List of participants involved in the appointment.)
1335     */
1336    public List<AppointmentParticipantComponent> getParticipant() { 
1337      if (this.participant == null)
1338        this.participant = new ArrayList<AppointmentParticipantComponent>();
1339      return this.participant;
1340    }
1341
1342    public boolean hasParticipant() { 
1343      if (this.participant == null)
1344        return false;
1345      for (AppointmentParticipantComponent item : this.participant)
1346        if (!item.isEmpty())
1347          return true;
1348      return false;
1349    }
1350
1351    /**
1352     * @return {@link #participant} (List of participants involved in the appointment.)
1353     */
1354    // syntactic sugar
1355    public AppointmentParticipantComponent addParticipant() { //3
1356      AppointmentParticipantComponent t = new AppointmentParticipantComponent();
1357      if (this.participant == null)
1358        this.participant = new ArrayList<AppointmentParticipantComponent>();
1359      this.participant.add(t);
1360      return t;
1361    }
1362
1363    // syntactic sugar
1364    public Appointment addParticipant(AppointmentParticipantComponent t) { //3
1365      if (t == null)
1366        return this;
1367      if (this.participant == null)
1368        this.participant = new ArrayList<AppointmentParticipantComponent>();
1369      this.participant.add(t);
1370      return this;
1371    }
1372
1373      protected void listChildren(List<Property> childrenList) {
1374        super.listChildren(childrenList);
1375        childrenList.add(new Property("identifier", "Identifier", "This records identifiers associated with this appointment concern that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).", 0, java.lang.Integer.MAX_VALUE, identifier));
1376        childrenList.add(new Property("status", "code", "The overall status of the Appointment. Each of the participants has their own participation status which indicates their involvement in the process, however this status indicates the shared status.", 0, java.lang.Integer.MAX_VALUE, status));
1377        childrenList.add(new Property("type", "CodeableConcept", "The type of appointment that is being booked (This may also be associated with participants for location, and/or a HealthcareService).", 0, java.lang.Integer.MAX_VALUE, type));
1378        childrenList.add(new Property("reason", "CodeableConcept", "The reason that this appointment is being scheduled. This is more clinical than administrative.", 0, java.lang.Integer.MAX_VALUE, reason));
1379        childrenList.add(new Property("priority", "unsignedInt", "The priority of the appointment. Can be used to make informed decisions if needing to re-prioritize appointments. (The iCal Standard specifies 0 as undefined, 1 as highest, 9 as lowest priority).", 0, java.lang.Integer.MAX_VALUE, priority));
1380        childrenList.add(new Property("description", "string", "The brief description of the appointment as would be shown on a subject line in a meeting request, or appointment list. Detailed or expanded information should be put in the comment field.", 0, java.lang.Integer.MAX_VALUE, description));
1381        childrenList.add(new Property("start", "instant", "Date/Time that the appointment is to take place.", 0, java.lang.Integer.MAX_VALUE, start));
1382        childrenList.add(new Property("end", "instant", "Date/Time that the appointment is to conclude.", 0, java.lang.Integer.MAX_VALUE, end));
1383        childrenList.add(new Property("minutesDuration", "positiveInt", "Number of minutes that the appointment is to take. This can be less than the duration between the start and end times (where actual time of appointment is only an estimate or is a planned appointment request).", 0, java.lang.Integer.MAX_VALUE, minutesDuration));
1384        childrenList.add(new Property("slot", "Reference(Slot)", "The slot that this appointment is filling. If provided then the schedule will not be provided as slots are not recursive, and the start/end values MUST be the same as from the slot.", 0, java.lang.Integer.MAX_VALUE, slot));
1385        childrenList.add(new Property("comment", "string", "Additional comments about the appointment.", 0, java.lang.Integer.MAX_VALUE, comment));
1386        childrenList.add(new Property("participant", "", "List of participants involved in the appointment.", 0, java.lang.Integer.MAX_VALUE, participant));
1387      }
1388
1389      @Override
1390      public void setProperty(String name, Base value) throws FHIRException {
1391        if (name.equals("identifier"))
1392          this.getIdentifier().add(castToIdentifier(value));
1393        else if (name.equals("status"))
1394          this.status = new AppointmentStatusEnumFactory().fromType(value); // Enumeration<AppointmentStatus>
1395        else if (name.equals("type"))
1396          this.type = castToCodeableConcept(value); // CodeableConcept
1397        else if (name.equals("reason"))
1398          this.reason = castToCodeableConcept(value); // CodeableConcept
1399        else if (name.equals("priority"))
1400          this.priority = castToUnsignedInt(value); // UnsignedIntType
1401        else if (name.equals("description"))
1402          this.description = castToString(value); // StringType
1403        else if (name.equals("start"))
1404          this.start = castToInstant(value); // InstantType
1405        else if (name.equals("end"))
1406          this.end = castToInstant(value); // InstantType
1407        else if (name.equals("minutesDuration"))
1408          this.minutesDuration = castToPositiveInt(value); // PositiveIntType
1409        else if (name.equals("slot"))
1410          this.getSlot().add(castToReference(value));
1411        else if (name.equals("comment"))
1412          this.comment = castToString(value); // StringType
1413        else if (name.equals("participant"))
1414          this.getParticipant().add((AppointmentParticipantComponent) value);
1415        else
1416          super.setProperty(name, value);
1417      }
1418
1419      @Override
1420      public Base addChild(String name) throws FHIRException {
1421        if (name.equals("identifier")) {
1422          return addIdentifier();
1423        }
1424        else if (name.equals("status")) {
1425          throw new FHIRException("Cannot call addChild on a primitive type Appointment.status");
1426        }
1427        else if (name.equals("type")) {
1428          this.type = new CodeableConcept();
1429          return this.type;
1430        }
1431        else if (name.equals("reason")) {
1432          this.reason = new CodeableConcept();
1433          return this.reason;
1434        }
1435        else if (name.equals("priority")) {
1436          throw new FHIRException("Cannot call addChild on a primitive type Appointment.priority");
1437        }
1438        else if (name.equals("description")) {
1439          throw new FHIRException("Cannot call addChild on a primitive type Appointment.description");
1440        }
1441        else if (name.equals("start")) {
1442          throw new FHIRException("Cannot call addChild on a primitive type Appointment.start");
1443        }
1444        else if (name.equals("end")) {
1445          throw new FHIRException("Cannot call addChild on a primitive type Appointment.end");
1446        }
1447        else if (name.equals("minutesDuration")) {
1448          throw new FHIRException("Cannot call addChild on a primitive type Appointment.minutesDuration");
1449        }
1450        else if (name.equals("slot")) {
1451          return addSlot();
1452        }
1453        else if (name.equals("comment")) {
1454          throw new FHIRException("Cannot call addChild on a primitive type Appointment.comment");
1455        }
1456        else if (name.equals("participant")) {
1457          return addParticipant();
1458        }
1459        else
1460          return super.addChild(name);
1461      }
1462
1463  public String fhirType() {
1464    return "Appointment";
1465
1466  }
1467
1468      public Appointment copy() {
1469        Appointment dst = new Appointment();
1470        copyValues(dst);
1471        if (identifier != null) {
1472          dst.identifier = new ArrayList<Identifier>();
1473          for (Identifier i : identifier)
1474            dst.identifier.add(i.copy());
1475        };
1476        dst.status = status == null ? null : status.copy();
1477        dst.type = type == null ? null : type.copy();
1478        dst.reason = reason == null ? null : reason.copy();
1479        dst.priority = priority == null ? null : priority.copy();
1480        dst.description = description == null ? null : description.copy();
1481        dst.start = start == null ? null : start.copy();
1482        dst.end = end == null ? null : end.copy();
1483        dst.minutesDuration = minutesDuration == null ? null : minutesDuration.copy();
1484        if (slot != null) {
1485          dst.slot = new ArrayList<Reference>();
1486          for (Reference i : slot)
1487            dst.slot.add(i.copy());
1488        };
1489        dst.comment = comment == null ? null : comment.copy();
1490        if (participant != null) {
1491          dst.participant = new ArrayList<AppointmentParticipantComponent>();
1492          for (AppointmentParticipantComponent i : participant)
1493            dst.participant.add(i.copy());
1494        };
1495        return dst;
1496      }
1497
1498      protected Appointment typedCopy() {
1499        return copy();
1500      }
1501
1502      @Override
1503      public boolean equalsDeep(Base other) {
1504        if (!super.equalsDeep(other))
1505          return false;
1506        if (!(other instanceof Appointment))
1507          return false;
1508        Appointment o = (Appointment) other;
1509        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(type, o.type, true)
1510           && compareDeep(reason, o.reason, true) && compareDeep(priority, o.priority, true) && compareDeep(description, o.description, true)
1511           && compareDeep(start, o.start, true) && compareDeep(end, o.end, true) && compareDeep(minutesDuration, o.minutesDuration, true)
1512           && compareDeep(slot, o.slot, true) && compareDeep(comment, o.comment, true) && compareDeep(participant, o.participant, true)
1513          ;
1514      }
1515
1516      @Override
1517      public boolean equalsShallow(Base other) {
1518        if (!super.equalsShallow(other))
1519          return false;
1520        if (!(other instanceof Appointment))
1521          return false;
1522        Appointment o = (Appointment) other;
1523        return compareValues(status, o.status, true) && compareValues(priority, o.priority, true) && compareValues(description, o.description, true)
1524           && compareValues(start, o.start, true) && compareValues(end, o.end, true) && compareValues(minutesDuration, o.minutesDuration, true)
1525           && compareValues(comment, o.comment, true);
1526      }
1527
1528      public boolean isEmpty() {
1529        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (status == null || status.isEmpty())
1530           && (type == null || type.isEmpty()) && (reason == null || reason.isEmpty()) && (priority == null || priority.isEmpty())
1531           && (description == null || description.isEmpty()) && (start == null || start.isEmpty()) && (end == null || end.isEmpty())
1532           && (minutesDuration == null || minutesDuration.isEmpty()) && (slot == null || slot.isEmpty())
1533           && (comment == null || comment.isEmpty()) && (participant == null || participant.isEmpty())
1534          ;
1535      }
1536
1537  @Override
1538  public ResourceType getResourceType() {
1539    return ResourceType.Appointment;
1540   }
1541
1542  @SearchParamDefinition(name="date", path="Appointment.start", description="Appointment date/time.", type="date" )
1543  public static final String SP_DATE = "date";
1544  @SearchParamDefinition(name="actor", path="Appointment.participant.actor", description="Any one of the individuals participating in the appointment", type="reference" )
1545  public static final String SP_ACTOR = "actor";
1546  @SearchParamDefinition(name="identifier", path="Appointment.identifier", description="An Identifier of the Appointment", type="token" )
1547  public static final String SP_IDENTIFIER = "identifier";
1548  @SearchParamDefinition(name="practitioner", path="Appointment.participant.actor", description="One of the individuals of the appointment is this practitioner", type="reference" )
1549  public static final String SP_PRACTITIONER = "practitioner";
1550  @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" )
1551  public static final String SP_PARTSTATUS = "part-status";
1552  @SearchParamDefinition(name="patient", path="Appointment.participant.actor", description="One of the individuals of the appointment is this patient", type="reference" )
1553  public static final String SP_PATIENT = "patient";
1554  @SearchParamDefinition(name="location", path="Appointment.participant.actor", description="This location is listed in the participants of the appointment", type="reference" )
1555  public static final String SP_LOCATION = "location";
1556  @SearchParamDefinition(name="status", path="Appointment.status", description="The overall status of the appointment", type="token" )
1557  public static final String SP_STATUS = "status";
1558
1559}