001package org.hl7.fhir.r4.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 Sun, May 6, 2018 17:51-0400 for FHIR v3.4.0
033
034import java.util.*;
035
036import org.hl7.fhir.utilities.Utilities;
037import ca.uhn.fhir.model.api.annotation.ResourceDef;
038import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.ChildOrder;
041import ca.uhn.fhir.model.api.annotation.Description;
042import ca.uhn.fhir.model.api.annotation.Block;
043import org.hl7.fhir.instance.model.api.*;
044import org.hl7.fhir.exceptions.FHIRException;
045/**
046 * A reply to an appointment request for a patient and/or practitioner(s), such as a confirmation or rejection.
047 */
048@ResourceDef(name="AppointmentResponse", profile="http://hl7.org/fhir/Profile/AppointmentResponse")
049public class AppointmentResponse extends DomainResource {
050
051    public enum ParticipantStatus {
052        /**
053         * The participant has accepted the appointment.
054         */
055        ACCEPTED, 
056        /**
057         * The participant has declined the appointment and will not participate in the appointment.
058         */
059        DECLINED, 
060        /**
061         * 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.
062         */
063        TENTATIVE, 
064        /**
065         * The participant needs to indicate if they accept the appointment by changing this status to one of the other statuses.
066         */
067        NEEDSACTION, 
068        /**
069         * added to help the parsers with the generic types
070         */
071        NULL;
072        public static ParticipantStatus fromCode(String codeString) throws FHIRException {
073            if (codeString == null || "".equals(codeString))
074                return null;
075        if ("accepted".equals(codeString))
076          return ACCEPTED;
077        if ("declined".equals(codeString))
078          return DECLINED;
079        if ("tentative".equals(codeString))
080          return TENTATIVE;
081        if ("needs-action".equals(codeString))
082          return NEEDSACTION;
083        if (Configuration.isAcceptInvalidEnums())
084          return null;
085        else
086          throw new FHIRException("Unknown ParticipantStatus code '"+codeString+"'");
087        }
088        public String toCode() {
089          switch (this) {
090            case ACCEPTED: return "accepted";
091            case DECLINED: return "declined";
092            case TENTATIVE: return "tentative";
093            case NEEDSACTION: return "needs-action";
094            default: return "?";
095          }
096        }
097        public String getSystem() {
098          switch (this) {
099            case ACCEPTED: return "http://hl7.org/fhir/participationstatus";
100            case DECLINED: return "http://hl7.org/fhir/participationstatus";
101            case TENTATIVE: return "http://hl7.org/fhir/participationstatus";
102            case NEEDSACTION: return "http://hl7.org/fhir/participationstatus";
103            default: return "?";
104          }
105        }
106        public String getDefinition() {
107          switch (this) {
108            case ACCEPTED: return "The participant has accepted the appointment.";
109            case DECLINED: return "The participant has declined the appointment and will not participate in the appointment.";
110            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.";
111            case NEEDSACTION: return "The participant needs to indicate if they accept the appointment by changing this status to one of the other statuses.";
112            default: return "?";
113          }
114        }
115        public String getDisplay() {
116          switch (this) {
117            case ACCEPTED: return "Accepted";
118            case DECLINED: return "Declined";
119            case TENTATIVE: return "Tentative";
120            case NEEDSACTION: return "Needs Action";
121            default: return "?";
122          }
123        }
124    }
125
126  public static class ParticipantStatusEnumFactory implements EnumFactory<ParticipantStatus> {
127    public ParticipantStatus fromCode(String codeString) throws IllegalArgumentException {
128      if (codeString == null || "".equals(codeString))
129            if (codeString == null || "".equals(codeString))
130                return null;
131        if ("accepted".equals(codeString))
132          return ParticipantStatus.ACCEPTED;
133        if ("declined".equals(codeString))
134          return ParticipantStatus.DECLINED;
135        if ("tentative".equals(codeString))
136          return ParticipantStatus.TENTATIVE;
137        if ("needs-action".equals(codeString))
138          return ParticipantStatus.NEEDSACTION;
139        throw new IllegalArgumentException("Unknown ParticipantStatus code '"+codeString+"'");
140        }
141        public Enumeration<ParticipantStatus> fromType(Base code) throws FHIRException {
142          if (code == null)
143            return null;
144          if (code.isEmpty())
145            return new Enumeration<ParticipantStatus>(this);
146          String codeString = ((PrimitiveType) code).asStringValue();
147          if (codeString == null || "".equals(codeString))
148            return null;
149        if ("accepted".equals(codeString))
150          return new Enumeration<ParticipantStatus>(this, ParticipantStatus.ACCEPTED);
151        if ("declined".equals(codeString))
152          return new Enumeration<ParticipantStatus>(this, ParticipantStatus.DECLINED);
153        if ("tentative".equals(codeString))
154          return new Enumeration<ParticipantStatus>(this, ParticipantStatus.TENTATIVE);
155        if ("needs-action".equals(codeString))
156          return new Enumeration<ParticipantStatus>(this, ParticipantStatus.NEEDSACTION);
157        throw new FHIRException("Unknown ParticipantStatus code '"+codeString+"'");
158        }
159    public String toCode(ParticipantStatus code) {
160      if (code == ParticipantStatus.ACCEPTED)
161        return "accepted";
162      if (code == ParticipantStatus.DECLINED)
163        return "declined";
164      if (code == ParticipantStatus.TENTATIVE)
165        return "tentative";
166      if (code == ParticipantStatus.NEEDSACTION)
167        return "needs-action";
168      return "?";
169      }
170    public String toSystem(ParticipantStatus code) {
171      return code.getSystem();
172      }
173    }
174
175    /**
176     * This records identifiers associated with this appointment response 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.
177     */
178    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
179    @Description(shortDefinition="External Ids for this item", formalDefinition="This records identifiers associated with this appointment response 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." )
180    protected List<Identifier> identifier;
181
182    /**
183     * Appointment that this response is replying to.
184     */
185    @Child(name = "appointment", type = {Appointment.class}, order=1, min=1, max=1, modifier=false, summary=true)
186    @Description(shortDefinition="Appointment this response relates to", formalDefinition="Appointment that this response is replying to." )
187    protected Reference appointment;
188
189    /**
190     * The actual object that is the target of the reference (Appointment that this response is replying to.)
191     */
192    protected Appointment appointmentTarget;
193
194    /**
195     * Date/Time that the appointment is to take place, or requested new start time.
196     */
197    @Child(name = "start", type = {InstantType.class}, order=2, min=0, max=1, modifier=false, summary=false)
198    @Description(shortDefinition="Time from appointment, or requested new start time", formalDefinition="Date/Time that the appointment is to take place, or requested new start time." )
199    protected InstantType start;
200
201    /**
202     * This may be either the same as the appointment request to confirm the details of the appointment, or alternately a new time to request a re-negotiation of the end time.
203     */
204    @Child(name = "end", type = {InstantType.class}, order=3, min=0, max=1, modifier=false, summary=false)
205    @Description(shortDefinition="Time from appointment, or requested new end time", formalDefinition="This may be either the same as the appointment request to confirm the details of the appointment, or alternately a new time to request a re-negotiation of the end time." )
206    protected InstantType end;
207
208    /**
209     * Role of participant in the appointment.
210     */
211    @Child(name = "participantType", type = {CodeableConcept.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
212    @Description(shortDefinition="Role of participant in the appointment", formalDefinition="Role of participant in the appointment." )
213    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/encounter-participant-type")
214    protected List<CodeableConcept> participantType;
215
216    /**
217     * A Person, Location, HealthcareService, or Device that is participating in the appointment.
218     */
219    @Child(name = "actor", type = {Patient.class, Practitioner.class, RelatedPerson.class, Device.class, HealthcareService.class, Location.class}, order=5, min=0, max=1, modifier=false, summary=true)
220    @Description(shortDefinition="Person, Location, HealthcareService, or Device", formalDefinition="A Person, Location, HealthcareService, or Device that is participating in the appointment." )
221    protected Reference actor;
222
223    /**
224     * The actual object that is the target of the reference (A Person, Location, HealthcareService, or Device that is participating in the appointment.)
225     */
226    protected Resource actorTarget;
227
228    /**
229     * Participation status of the participant. When the status is declined or tentative if the start/end times are different to the appointment, then these times should be interpreted as a requested time change. When the status is accepted, the times can either be the time of the appointment (as a confirmation of the time) or can be empty.
230     */
231    @Child(name = "participantStatus", type = {CodeType.class}, order=6, min=1, max=1, modifier=true, summary=true)
232    @Description(shortDefinition="accepted | declined | tentative | in-process | completed | needs-action | entered-in-error", formalDefinition="Participation status of the participant. When the status is declined or tentative if the start/end times are different to the appointment, then these times should be interpreted as a requested time change. When the status is accepted, the times can either be the time of the appointment (as a confirmation of the time) or can be empty." )
233    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/participationstatus")
234    protected Enumeration<ParticipantStatus> participantStatus;
235
236    /**
237     * Additional comments about the appointment.
238     */
239    @Child(name = "comment", type = {StringType.class}, order=7, min=0, max=1, modifier=false, summary=false)
240    @Description(shortDefinition="Additional comments", formalDefinition="Additional comments about the appointment." )
241    protected StringType comment;
242
243    private static final long serialVersionUID = 248548635L;
244
245  /**
246   * Constructor
247   */
248    public AppointmentResponse() {
249      super();
250    }
251
252  /**
253   * Constructor
254   */
255    public AppointmentResponse(Reference appointment, Enumeration<ParticipantStatus> participantStatus) {
256      super();
257      this.appointment = appointment;
258      this.participantStatus = participantStatus;
259    }
260
261    /**
262     * @return {@link #identifier} (This records identifiers associated with this appointment response 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.)
263     */
264    public List<Identifier> getIdentifier() { 
265      if (this.identifier == null)
266        this.identifier = new ArrayList<Identifier>();
267      return this.identifier;
268    }
269
270    /**
271     * @return Returns a reference to <code>this</code> for easy method chaining
272     */
273    public AppointmentResponse setIdentifier(List<Identifier> theIdentifier) { 
274      this.identifier = theIdentifier;
275      return this;
276    }
277
278    public boolean hasIdentifier() { 
279      if (this.identifier == null)
280        return false;
281      for (Identifier item : this.identifier)
282        if (!item.isEmpty())
283          return true;
284      return false;
285    }
286
287    public Identifier addIdentifier() { //3
288      Identifier t = new Identifier();
289      if (this.identifier == null)
290        this.identifier = new ArrayList<Identifier>();
291      this.identifier.add(t);
292      return t;
293    }
294
295    public AppointmentResponse addIdentifier(Identifier t) { //3
296      if (t == null)
297        return this;
298      if (this.identifier == null)
299        this.identifier = new ArrayList<Identifier>();
300      this.identifier.add(t);
301      return this;
302    }
303
304    /**
305     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
306     */
307    public Identifier getIdentifierFirstRep() { 
308      if (getIdentifier().isEmpty()) {
309        addIdentifier();
310      }
311      return getIdentifier().get(0);
312    }
313
314    /**
315     * @return {@link #appointment} (Appointment that this response is replying to.)
316     */
317    public Reference getAppointment() { 
318      if (this.appointment == null)
319        if (Configuration.errorOnAutoCreate())
320          throw new Error("Attempt to auto-create AppointmentResponse.appointment");
321        else if (Configuration.doAutoCreate())
322          this.appointment = new Reference(); // cc
323      return this.appointment;
324    }
325
326    public boolean hasAppointment() { 
327      return this.appointment != null && !this.appointment.isEmpty();
328    }
329
330    /**
331     * @param value {@link #appointment} (Appointment that this response is replying to.)
332     */
333    public AppointmentResponse setAppointment(Reference value) { 
334      this.appointment = value;
335      return this;
336    }
337
338    /**
339     * @return {@link #appointment} 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. (Appointment that this response is replying to.)
340     */
341    public Appointment getAppointmentTarget() { 
342      if (this.appointmentTarget == null)
343        if (Configuration.errorOnAutoCreate())
344          throw new Error("Attempt to auto-create AppointmentResponse.appointment");
345        else if (Configuration.doAutoCreate())
346          this.appointmentTarget = new Appointment(); // aa
347      return this.appointmentTarget;
348    }
349
350    /**
351     * @param value {@link #appointment} 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. (Appointment that this response is replying to.)
352     */
353    public AppointmentResponse setAppointmentTarget(Appointment value) { 
354      this.appointmentTarget = value;
355      return this;
356    }
357
358    /**
359     * @return {@link #start} (Date/Time that the appointment is to take place, or requested new start time.). This is the underlying object with id, value and extensions. The accessor "getStart" gives direct access to the value
360     */
361    public InstantType getStartElement() { 
362      if (this.start == null)
363        if (Configuration.errorOnAutoCreate())
364          throw new Error("Attempt to auto-create AppointmentResponse.start");
365        else if (Configuration.doAutoCreate())
366          this.start = new InstantType(); // bb
367      return this.start;
368    }
369
370    public boolean hasStartElement() { 
371      return this.start != null && !this.start.isEmpty();
372    }
373
374    public boolean hasStart() { 
375      return this.start != null && !this.start.isEmpty();
376    }
377
378    /**
379     * @param value {@link #start} (Date/Time that the appointment is to take place, or requested new start time.). This is the underlying object with id, value and extensions. The accessor "getStart" gives direct access to the value
380     */
381    public AppointmentResponse setStartElement(InstantType value) { 
382      this.start = value;
383      return this;
384    }
385
386    /**
387     * @return Date/Time that the appointment is to take place, or requested new start time.
388     */
389    public Date getStart() { 
390      return this.start == null ? null : this.start.getValue();
391    }
392
393    /**
394     * @param value Date/Time that the appointment is to take place, or requested new start time.
395     */
396    public AppointmentResponse setStart(Date value) { 
397      if (value == null)
398        this.start = null;
399      else {
400        if (this.start == null)
401          this.start = new InstantType();
402        this.start.setValue(value);
403      }
404      return this;
405    }
406
407    /**
408     * @return {@link #end} (This may be either the same as the appointment request to confirm the details of the appointment, or alternately a new time to request a re-negotiation of the end time.). This is the underlying object with id, value and extensions. The accessor "getEnd" gives direct access to the value
409     */
410    public InstantType getEndElement() { 
411      if (this.end == null)
412        if (Configuration.errorOnAutoCreate())
413          throw new Error("Attempt to auto-create AppointmentResponse.end");
414        else if (Configuration.doAutoCreate())
415          this.end = new InstantType(); // bb
416      return this.end;
417    }
418
419    public boolean hasEndElement() { 
420      return this.end != null && !this.end.isEmpty();
421    }
422
423    public boolean hasEnd() { 
424      return this.end != null && !this.end.isEmpty();
425    }
426
427    /**
428     * @param value {@link #end} (This may be either the same as the appointment request to confirm the details of the appointment, or alternately a new time to request a re-negotiation of the end time.). This is the underlying object with id, value and extensions. The accessor "getEnd" gives direct access to the value
429     */
430    public AppointmentResponse setEndElement(InstantType value) { 
431      this.end = value;
432      return this;
433    }
434
435    /**
436     * @return This may be either the same as the appointment request to confirm the details of the appointment, or alternately a new time to request a re-negotiation of the end time.
437     */
438    public Date getEnd() { 
439      return this.end == null ? null : this.end.getValue();
440    }
441
442    /**
443     * @param value This may be either the same as the appointment request to confirm the details of the appointment, or alternately a new time to request a re-negotiation of the end time.
444     */
445    public AppointmentResponse setEnd(Date value) { 
446      if (value == null)
447        this.end = null;
448      else {
449        if (this.end == null)
450          this.end = new InstantType();
451        this.end.setValue(value);
452      }
453      return this;
454    }
455
456    /**
457     * @return {@link #participantType} (Role of participant in the appointment.)
458     */
459    public List<CodeableConcept> getParticipantType() { 
460      if (this.participantType == null)
461        this.participantType = new ArrayList<CodeableConcept>();
462      return this.participantType;
463    }
464
465    /**
466     * @return Returns a reference to <code>this</code> for easy method chaining
467     */
468    public AppointmentResponse setParticipantType(List<CodeableConcept> theParticipantType) { 
469      this.participantType = theParticipantType;
470      return this;
471    }
472
473    public boolean hasParticipantType() { 
474      if (this.participantType == null)
475        return false;
476      for (CodeableConcept item : this.participantType)
477        if (!item.isEmpty())
478          return true;
479      return false;
480    }
481
482    public CodeableConcept addParticipantType() { //3
483      CodeableConcept t = new CodeableConcept();
484      if (this.participantType == null)
485        this.participantType = new ArrayList<CodeableConcept>();
486      this.participantType.add(t);
487      return t;
488    }
489
490    public AppointmentResponse addParticipantType(CodeableConcept t) { //3
491      if (t == null)
492        return this;
493      if (this.participantType == null)
494        this.participantType = new ArrayList<CodeableConcept>();
495      this.participantType.add(t);
496      return this;
497    }
498
499    /**
500     * @return The first repetition of repeating field {@link #participantType}, creating it if it does not already exist
501     */
502    public CodeableConcept getParticipantTypeFirstRep() { 
503      if (getParticipantType().isEmpty()) {
504        addParticipantType();
505      }
506      return getParticipantType().get(0);
507    }
508
509    /**
510     * @return {@link #actor} (A Person, Location, HealthcareService, or Device that is participating in the appointment.)
511     */
512    public Reference getActor() { 
513      if (this.actor == null)
514        if (Configuration.errorOnAutoCreate())
515          throw new Error("Attempt to auto-create AppointmentResponse.actor");
516        else if (Configuration.doAutoCreate())
517          this.actor = new Reference(); // cc
518      return this.actor;
519    }
520
521    public boolean hasActor() { 
522      return this.actor != null && !this.actor.isEmpty();
523    }
524
525    /**
526     * @param value {@link #actor} (A Person, Location, HealthcareService, or Device that is participating in the appointment.)
527     */
528    public AppointmentResponse setActor(Reference value) { 
529      this.actor = value;
530      return this;
531    }
532
533    /**
534     * @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.)
535     */
536    public Resource getActorTarget() { 
537      return this.actorTarget;
538    }
539
540    /**
541     * @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.)
542     */
543    public AppointmentResponse setActorTarget(Resource value) { 
544      this.actorTarget = value;
545      return this;
546    }
547
548    /**
549     * @return {@link #participantStatus} (Participation status of the participant. When the status is declined or tentative if the start/end times are different to the appointment, then these times should be interpreted as a requested time change. When the status is accepted, the times can either be the time of the appointment (as a confirmation of the time) or can be empty.). This is the underlying object with id, value and extensions. The accessor "getParticipantStatus" gives direct access to the value
550     */
551    public Enumeration<ParticipantStatus> getParticipantStatusElement() { 
552      if (this.participantStatus == null)
553        if (Configuration.errorOnAutoCreate())
554          throw new Error("Attempt to auto-create AppointmentResponse.participantStatus");
555        else if (Configuration.doAutoCreate())
556          this.participantStatus = new Enumeration<ParticipantStatus>(new ParticipantStatusEnumFactory()); // bb
557      return this.participantStatus;
558    }
559
560    public boolean hasParticipantStatusElement() { 
561      return this.participantStatus != null && !this.participantStatus.isEmpty();
562    }
563
564    public boolean hasParticipantStatus() { 
565      return this.participantStatus != null && !this.participantStatus.isEmpty();
566    }
567
568    /**
569     * @param value {@link #participantStatus} (Participation status of the participant. When the status is declined or tentative if the start/end times are different to the appointment, then these times should be interpreted as a requested time change. When the status is accepted, the times can either be the time of the appointment (as a confirmation of the time) or can be empty.). This is the underlying object with id, value and extensions. The accessor "getParticipantStatus" gives direct access to the value
570     */
571    public AppointmentResponse setParticipantStatusElement(Enumeration<ParticipantStatus> value) { 
572      this.participantStatus = value;
573      return this;
574    }
575
576    /**
577     * @return Participation status of the participant. When the status is declined or tentative if the start/end times are different to the appointment, then these times should be interpreted as a requested time change. When the status is accepted, the times can either be the time of the appointment (as a confirmation of the time) or can be empty.
578     */
579    public ParticipantStatus getParticipantStatus() { 
580      return this.participantStatus == null ? null : this.participantStatus.getValue();
581    }
582
583    /**
584     * @param value Participation status of the participant. When the status is declined or tentative if the start/end times are different to the appointment, then these times should be interpreted as a requested time change. When the status is accepted, the times can either be the time of the appointment (as a confirmation of the time) or can be empty.
585     */
586    public AppointmentResponse setParticipantStatus(ParticipantStatus value) { 
587        if (this.participantStatus == null)
588          this.participantStatus = new Enumeration<ParticipantStatus>(new ParticipantStatusEnumFactory());
589        this.participantStatus.setValue(value);
590      return this;
591    }
592
593    /**
594     * @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
595     */
596    public StringType getCommentElement() { 
597      if (this.comment == null)
598        if (Configuration.errorOnAutoCreate())
599          throw new Error("Attempt to auto-create AppointmentResponse.comment");
600        else if (Configuration.doAutoCreate())
601          this.comment = new StringType(); // bb
602      return this.comment;
603    }
604
605    public boolean hasCommentElement() { 
606      return this.comment != null && !this.comment.isEmpty();
607    }
608
609    public boolean hasComment() { 
610      return this.comment != null && !this.comment.isEmpty();
611    }
612
613    /**
614     * @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
615     */
616    public AppointmentResponse setCommentElement(StringType value) { 
617      this.comment = value;
618      return this;
619    }
620
621    /**
622     * @return Additional comments about the appointment.
623     */
624    public String getComment() { 
625      return this.comment == null ? null : this.comment.getValue();
626    }
627
628    /**
629     * @param value Additional comments about the appointment.
630     */
631    public AppointmentResponse setComment(String value) { 
632      if (Utilities.noString(value))
633        this.comment = null;
634      else {
635        if (this.comment == null)
636          this.comment = new StringType();
637        this.comment.setValue(value);
638      }
639      return this;
640    }
641
642      protected void listChildren(List<Property> children) {
643        super.listChildren(children);
644        children.add(new Property("identifier", "Identifier", "This records identifiers associated with this appointment response 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.", 0, java.lang.Integer.MAX_VALUE, identifier));
645        children.add(new Property("appointment", "Reference(Appointment)", "Appointment that this response is replying to.", 0, 1, appointment));
646        children.add(new Property("start", "instant", "Date/Time that the appointment is to take place, or requested new start time.", 0, 1, start));
647        children.add(new Property("end", "instant", "This may be either the same as the appointment request to confirm the details of the appointment, or alternately a new time to request a re-negotiation of the end time.", 0, 1, end));
648        children.add(new Property("participantType", "CodeableConcept", "Role of participant in the appointment.", 0, java.lang.Integer.MAX_VALUE, participantType));
649        children.add(new Property("actor", "Reference(Patient|Practitioner|RelatedPerson|Device|HealthcareService|Location)", "A Person, Location, HealthcareService, or Device that is participating in the appointment.", 0, 1, actor));
650        children.add(new Property("participantStatus", "code", "Participation status of the participant. When the status is declined or tentative if the start/end times are different to the appointment, then these times should be interpreted as a requested time change. When the status is accepted, the times can either be the time of the appointment (as a confirmation of the time) or can be empty.", 0, 1, participantStatus));
651        children.add(new Property("comment", "string", "Additional comments about the appointment.", 0, 1, comment));
652      }
653
654      @Override
655      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
656        switch (_hash) {
657        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "This records identifiers associated with this appointment response 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.", 0, java.lang.Integer.MAX_VALUE, identifier);
658        case -1474995297: /*appointment*/  return new Property("appointment", "Reference(Appointment)", "Appointment that this response is replying to.", 0, 1, appointment);
659        case 109757538: /*start*/  return new Property("start", "instant", "Date/Time that the appointment is to take place, or requested new start time.", 0, 1, start);
660        case 100571: /*end*/  return new Property("end", "instant", "This may be either the same as the appointment request to confirm the details of the appointment, or alternately a new time to request a re-negotiation of the end time.", 0, 1, end);
661        case 841294093: /*participantType*/  return new Property("participantType", "CodeableConcept", "Role of participant in the appointment.", 0, java.lang.Integer.MAX_VALUE, participantType);
662        case 92645877: /*actor*/  return new Property("actor", "Reference(Patient|Practitioner|RelatedPerson|Device|HealthcareService|Location)", "A Person, Location, HealthcareService, or Device that is participating in the appointment.", 0, 1, actor);
663        case 996096261: /*participantStatus*/  return new Property("participantStatus", "code", "Participation status of the participant. When the status is declined or tentative if the start/end times are different to the appointment, then these times should be interpreted as a requested time change. When the status is accepted, the times can either be the time of the appointment (as a confirmation of the time) or can be empty.", 0, 1, participantStatus);
664        case 950398559: /*comment*/  return new Property("comment", "string", "Additional comments about the appointment.", 0, 1, comment);
665        default: return super.getNamedProperty(_hash, _name, _checkValid);
666        }
667
668      }
669
670      @Override
671      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
672        switch (hash) {
673        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
674        case -1474995297: /*appointment*/ return this.appointment == null ? new Base[0] : new Base[] {this.appointment}; // Reference
675        case 109757538: /*start*/ return this.start == null ? new Base[0] : new Base[] {this.start}; // InstantType
676        case 100571: /*end*/ return this.end == null ? new Base[0] : new Base[] {this.end}; // InstantType
677        case 841294093: /*participantType*/ return this.participantType == null ? new Base[0] : this.participantType.toArray(new Base[this.participantType.size()]); // CodeableConcept
678        case 92645877: /*actor*/ return this.actor == null ? new Base[0] : new Base[] {this.actor}; // Reference
679        case 996096261: /*participantStatus*/ return this.participantStatus == null ? new Base[0] : new Base[] {this.participantStatus}; // Enumeration<ParticipantStatus>
680        case 950398559: /*comment*/ return this.comment == null ? new Base[0] : new Base[] {this.comment}; // StringType
681        default: return super.getProperty(hash, name, checkValid);
682        }
683
684      }
685
686      @Override
687      public Base setProperty(int hash, String name, Base value) throws FHIRException {
688        switch (hash) {
689        case -1618432855: // identifier
690          this.getIdentifier().add(castToIdentifier(value)); // Identifier
691          return value;
692        case -1474995297: // appointment
693          this.appointment = castToReference(value); // Reference
694          return value;
695        case 109757538: // start
696          this.start = castToInstant(value); // InstantType
697          return value;
698        case 100571: // end
699          this.end = castToInstant(value); // InstantType
700          return value;
701        case 841294093: // participantType
702          this.getParticipantType().add(castToCodeableConcept(value)); // CodeableConcept
703          return value;
704        case 92645877: // actor
705          this.actor = castToReference(value); // Reference
706          return value;
707        case 996096261: // participantStatus
708          value = new ParticipantStatusEnumFactory().fromType(castToCode(value));
709          this.participantStatus = (Enumeration) value; // Enumeration<ParticipantStatus>
710          return value;
711        case 950398559: // comment
712          this.comment = castToString(value); // StringType
713          return value;
714        default: return super.setProperty(hash, name, value);
715        }
716
717      }
718
719      @Override
720      public Base setProperty(String name, Base value) throws FHIRException {
721        if (name.equals("identifier")) {
722          this.getIdentifier().add(castToIdentifier(value));
723        } else if (name.equals("appointment")) {
724          this.appointment = castToReference(value); // Reference
725        } else if (name.equals("start")) {
726          this.start = castToInstant(value); // InstantType
727        } else if (name.equals("end")) {
728          this.end = castToInstant(value); // InstantType
729        } else if (name.equals("participantType")) {
730          this.getParticipantType().add(castToCodeableConcept(value));
731        } else if (name.equals("actor")) {
732          this.actor = castToReference(value); // Reference
733        } else if (name.equals("participantStatus")) {
734          value = new ParticipantStatusEnumFactory().fromType(castToCode(value));
735          this.participantStatus = (Enumeration) value; // Enumeration<ParticipantStatus>
736        } else if (name.equals("comment")) {
737          this.comment = castToString(value); // StringType
738        } else
739          return super.setProperty(name, value);
740        return value;
741      }
742
743      @Override
744      public Base makeProperty(int hash, String name) throws FHIRException {
745        switch (hash) {
746        case -1618432855:  return addIdentifier(); 
747        case -1474995297:  return getAppointment(); 
748        case 109757538:  return getStartElement();
749        case 100571:  return getEndElement();
750        case 841294093:  return addParticipantType(); 
751        case 92645877:  return getActor(); 
752        case 996096261:  return getParticipantStatusElement();
753        case 950398559:  return getCommentElement();
754        default: return super.makeProperty(hash, name);
755        }
756
757      }
758
759      @Override
760      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
761        switch (hash) {
762        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
763        case -1474995297: /*appointment*/ return new String[] {"Reference"};
764        case 109757538: /*start*/ return new String[] {"instant"};
765        case 100571: /*end*/ return new String[] {"instant"};
766        case 841294093: /*participantType*/ return new String[] {"CodeableConcept"};
767        case 92645877: /*actor*/ return new String[] {"Reference"};
768        case 996096261: /*participantStatus*/ return new String[] {"code"};
769        case 950398559: /*comment*/ return new String[] {"string"};
770        default: return super.getTypesForProperty(hash, name);
771        }
772
773      }
774
775      @Override
776      public Base addChild(String name) throws FHIRException {
777        if (name.equals("identifier")) {
778          return addIdentifier();
779        }
780        else if (name.equals("appointment")) {
781          this.appointment = new Reference();
782          return this.appointment;
783        }
784        else if (name.equals("start")) {
785          throw new FHIRException("Cannot call addChild on a primitive type AppointmentResponse.start");
786        }
787        else if (name.equals("end")) {
788          throw new FHIRException("Cannot call addChild on a primitive type AppointmentResponse.end");
789        }
790        else if (name.equals("participantType")) {
791          return addParticipantType();
792        }
793        else if (name.equals("actor")) {
794          this.actor = new Reference();
795          return this.actor;
796        }
797        else if (name.equals("participantStatus")) {
798          throw new FHIRException("Cannot call addChild on a primitive type AppointmentResponse.participantStatus");
799        }
800        else if (name.equals("comment")) {
801          throw new FHIRException("Cannot call addChild on a primitive type AppointmentResponse.comment");
802        }
803        else
804          return super.addChild(name);
805      }
806
807  public String fhirType() {
808    return "AppointmentResponse";
809
810  }
811
812      public AppointmentResponse copy() {
813        AppointmentResponse dst = new AppointmentResponse();
814        copyValues(dst);
815        if (identifier != null) {
816          dst.identifier = new ArrayList<Identifier>();
817          for (Identifier i : identifier)
818            dst.identifier.add(i.copy());
819        };
820        dst.appointment = appointment == null ? null : appointment.copy();
821        dst.start = start == null ? null : start.copy();
822        dst.end = end == null ? null : end.copy();
823        if (participantType != null) {
824          dst.participantType = new ArrayList<CodeableConcept>();
825          for (CodeableConcept i : participantType)
826            dst.participantType.add(i.copy());
827        };
828        dst.actor = actor == null ? null : actor.copy();
829        dst.participantStatus = participantStatus == null ? null : participantStatus.copy();
830        dst.comment = comment == null ? null : comment.copy();
831        return dst;
832      }
833
834      protected AppointmentResponse typedCopy() {
835        return copy();
836      }
837
838      @Override
839      public boolean equalsDeep(Base other_) {
840        if (!super.equalsDeep(other_))
841          return false;
842        if (!(other_ instanceof AppointmentResponse))
843          return false;
844        AppointmentResponse o = (AppointmentResponse) other_;
845        return compareDeep(identifier, o.identifier, true) && compareDeep(appointment, o.appointment, true)
846           && compareDeep(start, o.start, true) && compareDeep(end, o.end, true) && compareDeep(participantType, o.participantType, true)
847           && compareDeep(actor, o.actor, true) && compareDeep(participantStatus, o.participantStatus, true)
848           && compareDeep(comment, o.comment, true);
849      }
850
851      @Override
852      public boolean equalsShallow(Base other_) {
853        if (!super.equalsShallow(other_))
854          return false;
855        if (!(other_ instanceof AppointmentResponse))
856          return false;
857        AppointmentResponse o = (AppointmentResponse) other_;
858        return compareValues(start, o.start, true) && compareValues(end, o.end, true) && compareValues(participantStatus, o.participantStatus, true)
859           && compareValues(comment, o.comment, true);
860      }
861
862      public boolean isEmpty() {
863        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, appointment, start
864          , end, participantType, actor, participantStatus, comment);
865      }
866
867  @Override
868  public ResourceType getResourceType() {
869    return ResourceType.AppointmentResponse;
870   }
871
872 /**
873   * Search parameter: <b>actor</b>
874   * <p>
875   * Description: <b>The Person, Location/HealthcareService or Device that this appointment response replies for</b><br>
876   * Type: <b>reference</b><br>
877   * Path: <b>AppointmentResponse.actor</b><br>
878   * </p>
879   */
880  @SearchParamDefinition(name="actor", path="AppointmentResponse.actor", description="The Person, Location/HealthcareService or Device that this appointment response replies for", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Device"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner"), @ca.uhn.fhir.model.api.annotation.Compartment(name="RelatedPerson") }, target={Device.class, HealthcareService.class, Location.class, Patient.class, Practitioner.class, RelatedPerson.class } )
881  public static final String SP_ACTOR = "actor";
882 /**
883   * <b>Fluent Client</b> search parameter constant for <b>actor</b>
884   * <p>
885   * Description: <b>The Person, Location/HealthcareService or Device that this appointment response replies for</b><br>
886   * Type: <b>reference</b><br>
887   * Path: <b>AppointmentResponse.actor</b><br>
888   * </p>
889   */
890  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ACTOR = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ACTOR);
891
892/**
893   * Constant for fluent queries to be used to add include statements. Specifies
894   * the path value of "<b>AppointmentResponse:actor</b>".
895   */
896  public static final ca.uhn.fhir.model.api.Include INCLUDE_ACTOR = new ca.uhn.fhir.model.api.Include("AppointmentResponse:actor").toLocked();
897
898 /**
899   * Search parameter: <b>identifier</b>
900   * <p>
901   * Description: <b>An Identifier in this appointment response</b><br>
902   * Type: <b>token</b><br>
903   * Path: <b>AppointmentResponse.identifier</b><br>
904   * </p>
905   */
906  @SearchParamDefinition(name="identifier", path="AppointmentResponse.identifier", description="An Identifier in this appointment response", type="token" )
907  public static final String SP_IDENTIFIER = "identifier";
908 /**
909   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
910   * <p>
911   * Description: <b>An Identifier in this appointment response</b><br>
912   * Type: <b>token</b><br>
913   * Path: <b>AppointmentResponse.identifier</b><br>
914   * </p>
915   */
916  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
917
918 /**
919   * Search parameter: <b>practitioner</b>
920   * <p>
921   * Description: <b>This Response is for this Practitioner</b><br>
922   * Type: <b>reference</b><br>
923   * Path: <b>AppointmentResponse.actor</b><br>
924   * </p>
925   */
926  @SearchParamDefinition(name="practitioner", path="AppointmentResponse.actor", description="This Response is for this Practitioner", type="reference", target={Practitioner.class } )
927  public static final String SP_PRACTITIONER = "practitioner";
928 /**
929   * <b>Fluent Client</b> search parameter constant for <b>practitioner</b>
930   * <p>
931   * Description: <b>This Response is for this Practitioner</b><br>
932   * Type: <b>reference</b><br>
933   * Path: <b>AppointmentResponse.actor</b><br>
934   * </p>
935   */
936  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PRACTITIONER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PRACTITIONER);
937
938/**
939   * Constant for fluent queries to be used to add include statements. Specifies
940   * the path value of "<b>AppointmentResponse:practitioner</b>".
941   */
942  public static final ca.uhn.fhir.model.api.Include INCLUDE_PRACTITIONER = new ca.uhn.fhir.model.api.Include("AppointmentResponse:practitioner").toLocked();
943
944 /**
945   * Search parameter: <b>part-status</b>
946   * <p>
947   * Description: <b>The participants acceptance status for this appointment</b><br>
948   * Type: <b>token</b><br>
949   * Path: <b>AppointmentResponse.participantStatus</b><br>
950   * </p>
951   */
952  @SearchParamDefinition(name="part-status", path="AppointmentResponse.participantStatus", description="The participants acceptance status for this appointment", type="token" )
953  public static final String SP_PART_STATUS = "part-status";
954 /**
955   * <b>Fluent Client</b> search parameter constant for <b>part-status</b>
956   * <p>
957   * Description: <b>The participants acceptance status for this appointment</b><br>
958   * Type: <b>token</b><br>
959   * Path: <b>AppointmentResponse.participantStatus</b><br>
960   * </p>
961   */
962  public static final ca.uhn.fhir.rest.gclient.TokenClientParam PART_STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_PART_STATUS);
963
964 /**
965   * Search parameter: <b>patient</b>
966   * <p>
967   * Description: <b>This Response is for this Patient</b><br>
968   * Type: <b>reference</b><br>
969   * Path: <b>AppointmentResponse.actor</b><br>
970   * </p>
971   */
972  @SearchParamDefinition(name="patient", path="AppointmentResponse.actor", description="This Response is for this Patient", type="reference", target={Patient.class } )
973  public static final String SP_PATIENT = "patient";
974 /**
975   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
976   * <p>
977   * Description: <b>This Response is for this Patient</b><br>
978   * Type: <b>reference</b><br>
979   * Path: <b>AppointmentResponse.actor</b><br>
980   * </p>
981   */
982  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
983
984/**
985   * Constant for fluent queries to be used to add include statements. Specifies
986   * the path value of "<b>AppointmentResponse:patient</b>".
987   */
988  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("AppointmentResponse:patient").toLocked();
989
990 /**
991   * Search parameter: <b>appointment</b>
992   * <p>
993   * Description: <b>The appointment that the response is attached to</b><br>
994   * Type: <b>reference</b><br>
995   * Path: <b>AppointmentResponse.appointment</b><br>
996   * </p>
997   */
998  @SearchParamDefinition(name="appointment", path="AppointmentResponse.appointment", description="The appointment that the response is attached to", type="reference", target={Appointment.class } )
999  public static final String SP_APPOINTMENT = "appointment";
1000 /**
1001   * <b>Fluent Client</b> search parameter constant for <b>appointment</b>
1002   * <p>
1003   * Description: <b>The appointment that the response is attached to</b><br>
1004   * Type: <b>reference</b><br>
1005   * Path: <b>AppointmentResponse.appointment</b><br>
1006   * </p>
1007   */
1008  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam APPOINTMENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_APPOINTMENT);
1009
1010/**
1011   * Constant for fluent queries to be used to add include statements. Specifies
1012   * the path value of "<b>AppointmentResponse:appointment</b>".
1013   */
1014  public static final ca.uhn.fhir.model.api.Include INCLUDE_APPOINTMENT = new ca.uhn.fhir.model.api.Include("AppointmentResponse:appointment").toLocked();
1015
1016 /**
1017   * Search parameter: <b>location</b>
1018   * <p>
1019   * Description: <b>This Response is for this Location</b><br>
1020   * Type: <b>reference</b><br>
1021   * Path: <b>AppointmentResponse.actor</b><br>
1022   * </p>
1023   */
1024  @SearchParamDefinition(name="location", path="AppointmentResponse.actor", description="This Response is for this Location", type="reference", target={Location.class } )
1025  public static final String SP_LOCATION = "location";
1026 /**
1027   * <b>Fluent Client</b> search parameter constant for <b>location</b>
1028   * <p>
1029   * Description: <b>This Response is for this Location</b><br>
1030   * Type: <b>reference</b><br>
1031   * Path: <b>AppointmentResponse.actor</b><br>
1032   * </p>
1033   */
1034  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam LOCATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_LOCATION);
1035
1036/**
1037   * Constant for fluent queries to be used to add include statements. Specifies
1038   * the path value of "<b>AppointmentResponse:location</b>".
1039   */
1040  public static final ca.uhn.fhir.model.api.Include INCLUDE_LOCATION = new ca.uhn.fhir.model.api.Include("AppointmentResponse:location").toLocked();
1041
1042
1043}
1044