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