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