001package org.hl7.fhir.dstu3.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 Mon, Apr 17, 2017 17:38-0400 for FHIR v3.0.1
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> childrenList) {
643        super.listChildren(childrenList);
644        childrenList.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        childrenList.add(new Property("appointment", "Reference(Appointment)", "Appointment that this response is replying to.", 0, java.lang.Integer.MAX_VALUE, appointment));
646        childrenList.add(new Property("start", "instant", "Date/Time that the appointment is to take place, or requested new start time.", 0, java.lang.Integer.MAX_VALUE, start));
647        childrenList.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, java.lang.Integer.MAX_VALUE, end));
648        childrenList.add(new Property("participantType", "CodeableConcept", "Role of participant in the appointment.", 0, java.lang.Integer.MAX_VALUE, participantType));
649        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));
650        childrenList.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, java.lang.Integer.MAX_VALUE, participantStatus));
651        childrenList.add(new Property("comment", "string", "Additional comments about the appointment.", 0, java.lang.Integer.MAX_VALUE, comment));
652      }
653
654      @Override
655      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
656        switch (hash) {
657        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
658        case -1474995297: /*appointment*/ return this.appointment == null ? new Base[0] : new Base[] {this.appointment}; // Reference
659        case 109757538: /*start*/ return this.start == null ? new Base[0] : new Base[] {this.start}; // InstantType
660        case 100571: /*end*/ return this.end == null ? new Base[0] : new Base[] {this.end}; // InstantType
661        case 841294093: /*participantType*/ return this.participantType == null ? new Base[0] : this.participantType.toArray(new Base[this.participantType.size()]); // CodeableConcept
662        case 92645877: /*actor*/ return this.actor == null ? new Base[0] : new Base[] {this.actor}; // Reference
663        case 996096261: /*participantStatus*/ return this.participantStatus == null ? new Base[0] : new Base[] {this.participantStatus}; // Enumeration<ParticipantStatus>
664        case 950398559: /*comment*/ return this.comment == null ? new Base[0] : new Base[] {this.comment}; // StringType
665        default: return super.getProperty(hash, name, checkValid);
666        }
667
668      }
669
670      @Override
671      public Base setProperty(int hash, String name, Base value) throws FHIRException {
672        switch (hash) {
673        case -1618432855: // identifier
674          this.getIdentifier().add(castToIdentifier(value)); // Identifier
675          return value;
676        case -1474995297: // appointment
677          this.appointment = castToReference(value); // Reference
678          return value;
679        case 109757538: // start
680          this.start = castToInstant(value); // InstantType
681          return value;
682        case 100571: // end
683          this.end = castToInstant(value); // InstantType
684          return value;
685        case 841294093: // participantType
686          this.getParticipantType().add(castToCodeableConcept(value)); // CodeableConcept
687          return value;
688        case 92645877: // actor
689          this.actor = castToReference(value); // Reference
690          return value;
691        case 996096261: // participantStatus
692          value = new ParticipantStatusEnumFactory().fromType(castToCode(value));
693          this.participantStatus = (Enumeration) value; // Enumeration<ParticipantStatus>
694          return value;
695        case 950398559: // comment
696          this.comment = castToString(value); // StringType
697          return value;
698        default: return super.setProperty(hash, name, value);
699        }
700
701      }
702
703      @Override
704      public Base setProperty(String name, Base value) throws FHIRException {
705        if (name.equals("identifier")) {
706          this.getIdentifier().add(castToIdentifier(value));
707        } else if (name.equals("appointment")) {
708          this.appointment = castToReference(value); // Reference
709        } else if (name.equals("start")) {
710          this.start = castToInstant(value); // InstantType
711        } else if (name.equals("end")) {
712          this.end = castToInstant(value); // InstantType
713        } else if (name.equals("participantType")) {
714          this.getParticipantType().add(castToCodeableConcept(value));
715        } else if (name.equals("actor")) {
716          this.actor = castToReference(value); // Reference
717        } else if (name.equals("participantStatus")) {
718          value = new ParticipantStatusEnumFactory().fromType(castToCode(value));
719          this.participantStatus = (Enumeration) value; // Enumeration<ParticipantStatus>
720        } else if (name.equals("comment")) {
721          this.comment = castToString(value); // StringType
722        } else
723          return super.setProperty(name, value);
724        return value;
725      }
726
727      @Override
728      public Base makeProperty(int hash, String name) throws FHIRException {
729        switch (hash) {
730        case -1618432855:  return addIdentifier(); 
731        case -1474995297:  return getAppointment(); 
732        case 109757538:  return getStartElement();
733        case 100571:  return getEndElement();
734        case 841294093:  return addParticipantType(); 
735        case 92645877:  return getActor(); 
736        case 996096261:  return getParticipantStatusElement();
737        case 950398559:  return getCommentElement();
738        default: return super.makeProperty(hash, name);
739        }
740
741      }
742
743      @Override
744      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
745        switch (hash) {
746        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
747        case -1474995297: /*appointment*/ return new String[] {"Reference"};
748        case 109757538: /*start*/ return new String[] {"instant"};
749        case 100571: /*end*/ return new String[] {"instant"};
750        case 841294093: /*participantType*/ return new String[] {"CodeableConcept"};
751        case 92645877: /*actor*/ return new String[] {"Reference"};
752        case 996096261: /*participantStatus*/ return new String[] {"code"};
753        case 950398559: /*comment*/ return new String[] {"string"};
754        default: return super.getTypesForProperty(hash, name);
755        }
756
757      }
758
759      @Override
760      public Base addChild(String name) throws FHIRException {
761        if (name.equals("identifier")) {
762          return addIdentifier();
763        }
764        else if (name.equals("appointment")) {
765          this.appointment = new Reference();
766          return this.appointment;
767        }
768        else if (name.equals("start")) {
769          throw new FHIRException("Cannot call addChild on a primitive type AppointmentResponse.start");
770        }
771        else if (name.equals("end")) {
772          throw new FHIRException("Cannot call addChild on a primitive type AppointmentResponse.end");
773        }
774        else if (name.equals("participantType")) {
775          return addParticipantType();
776        }
777        else if (name.equals("actor")) {
778          this.actor = new Reference();
779          return this.actor;
780        }
781        else if (name.equals("participantStatus")) {
782          throw new FHIRException("Cannot call addChild on a primitive type AppointmentResponse.participantStatus");
783        }
784        else if (name.equals("comment")) {
785          throw new FHIRException("Cannot call addChild on a primitive type AppointmentResponse.comment");
786        }
787        else
788          return super.addChild(name);
789      }
790
791  public String fhirType() {
792    return "AppointmentResponse";
793
794  }
795
796      public AppointmentResponse copy() {
797        AppointmentResponse dst = new AppointmentResponse();
798        copyValues(dst);
799        if (identifier != null) {
800          dst.identifier = new ArrayList<Identifier>();
801          for (Identifier i : identifier)
802            dst.identifier.add(i.copy());
803        };
804        dst.appointment = appointment == null ? null : appointment.copy();
805        dst.start = start == null ? null : start.copy();
806        dst.end = end == null ? null : end.copy();
807        if (participantType != null) {
808          dst.participantType = new ArrayList<CodeableConcept>();
809          for (CodeableConcept i : participantType)
810            dst.participantType.add(i.copy());
811        };
812        dst.actor = actor == null ? null : actor.copy();
813        dst.participantStatus = participantStatus == null ? null : participantStatus.copy();
814        dst.comment = comment == null ? null : comment.copy();
815        return dst;
816      }
817
818      protected AppointmentResponse typedCopy() {
819        return copy();
820      }
821
822      @Override
823      public boolean equalsDeep(Base other) {
824        if (!super.equalsDeep(other))
825          return false;
826        if (!(other instanceof AppointmentResponse))
827          return false;
828        AppointmentResponse o = (AppointmentResponse) other;
829        return compareDeep(identifier, o.identifier, true) && compareDeep(appointment, o.appointment, true)
830           && compareDeep(start, o.start, true) && compareDeep(end, o.end, true) && compareDeep(participantType, o.participantType, true)
831           && compareDeep(actor, o.actor, true) && compareDeep(participantStatus, o.participantStatus, true)
832           && compareDeep(comment, o.comment, true);
833      }
834
835      @Override
836      public boolean equalsShallow(Base other) {
837        if (!super.equalsShallow(other))
838          return false;
839        if (!(other instanceof AppointmentResponse))
840          return false;
841        AppointmentResponse o = (AppointmentResponse) other;
842        return compareValues(start, o.start, true) && compareValues(end, o.end, true) && compareValues(participantStatus, o.participantStatus, true)
843           && compareValues(comment, o.comment, true);
844      }
845
846      public boolean isEmpty() {
847        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, appointment, start
848          , end, participantType, actor, participantStatus, comment);
849      }
850
851  @Override
852  public ResourceType getResourceType() {
853    return ResourceType.AppointmentResponse;
854   }
855
856 /**
857   * Search parameter: <b>actor</b>
858   * <p>
859   * Description: <b>The Person, Location/HealthcareService or Device that this appointment response replies for</b><br>
860   * Type: <b>reference</b><br>
861   * Path: <b>AppointmentResponse.actor</b><br>
862   * </p>
863   */
864  @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 } )
865  public static final String SP_ACTOR = "actor";
866 /**
867   * <b>Fluent Client</b> search parameter constant for <b>actor</b>
868   * <p>
869   * Description: <b>The Person, Location/HealthcareService or Device that this appointment response replies for</b><br>
870   * Type: <b>reference</b><br>
871   * Path: <b>AppointmentResponse.actor</b><br>
872   * </p>
873   */
874  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ACTOR = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ACTOR);
875
876/**
877   * Constant for fluent queries to be used to add include statements. Specifies
878   * the path value of "<b>AppointmentResponse:actor</b>".
879   */
880  public static final ca.uhn.fhir.model.api.Include INCLUDE_ACTOR = new ca.uhn.fhir.model.api.Include("AppointmentResponse:actor").toLocked();
881
882 /**
883   * Search parameter: <b>identifier</b>
884   * <p>
885   * Description: <b>An Identifier in this appointment response</b><br>
886   * Type: <b>token</b><br>
887   * Path: <b>AppointmentResponse.identifier</b><br>
888   * </p>
889   */
890  @SearchParamDefinition(name="identifier", path="AppointmentResponse.identifier", description="An Identifier in this appointment response", type="token" )
891  public static final String SP_IDENTIFIER = "identifier";
892 /**
893   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
894   * <p>
895   * Description: <b>An Identifier in this appointment response</b><br>
896   * Type: <b>token</b><br>
897   * Path: <b>AppointmentResponse.identifier</b><br>
898   * </p>
899   */
900  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
901
902 /**
903   * Search parameter: <b>practitioner</b>
904   * <p>
905   * Description: <b>This Response is for this Practitioner</b><br>
906   * Type: <b>reference</b><br>
907   * Path: <b>AppointmentResponse.actor</b><br>
908   * </p>
909   */
910  @SearchParamDefinition(name="practitioner", path="AppointmentResponse.actor", description="This Response is for this Practitioner", type="reference", target={Practitioner.class } )
911  public static final String SP_PRACTITIONER = "practitioner";
912 /**
913   * <b>Fluent Client</b> search parameter constant for <b>practitioner</b>
914   * <p>
915   * Description: <b>This Response is for this Practitioner</b><br>
916   * Type: <b>reference</b><br>
917   * Path: <b>AppointmentResponse.actor</b><br>
918   * </p>
919   */
920  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PRACTITIONER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PRACTITIONER);
921
922/**
923   * Constant for fluent queries to be used to add include statements. Specifies
924   * the path value of "<b>AppointmentResponse:practitioner</b>".
925   */
926  public static final ca.uhn.fhir.model.api.Include INCLUDE_PRACTITIONER = new ca.uhn.fhir.model.api.Include("AppointmentResponse:practitioner").toLocked();
927
928 /**
929   * Search parameter: <b>part-status</b>
930   * <p>
931   * Description: <b>The participants acceptance status for this appointment</b><br>
932   * Type: <b>token</b><br>
933   * Path: <b>AppointmentResponse.participantStatus</b><br>
934   * </p>
935   */
936  @SearchParamDefinition(name="part-status", path="AppointmentResponse.participantStatus", description="The participants acceptance status for this appointment", type="token" )
937  public static final String SP_PART_STATUS = "part-status";
938 /**
939   * <b>Fluent Client</b> search parameter constant for <b>part-status</b>
940   * <p>
941   * Description: <b>The participants acceptance status for this appointment</b><br>
942   * Type: <b>token</b><br>
943   * Path: <b>AppointmentResponse.participantStatus</b><br>
944   * </p>
945   */
946  public static final ca.uhn.fhir.rest.gclient.TokenClientParam PART_STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_PART_STATUS);
947
948 /**
949   * Search parameter: <b>patient</b>
950   * <p>
951   * Description: <b>This Response is for this Patient</b><br>
952   * Type: <b>reference</b><br>
953   * Path: <b>AppointmentResponse.actor</b><br>
954   * </p>
955   */
956  @SearchParamDefinition(name="patient", path="AppointmentResponse.actor", description="This Response is for this Patient", type="reference", target={Patient.class } )
957  public static final String SP_PATIENT = "patient";
958 /**
959   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
960   * <p>
961   * Description: <b>This Response is for this Patient</b><br>
962   * Type: <b>reference</b><br>
963   * Path: <b>AppointmentResponse.actor</b><br>
964   * </p>
965   */
966  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
967
968/**
969   * Constant for fluent queries to be used to add include statements. Specifies
970   * the path value of "<b>AppointmentResponse:patient</b>".
971   */
972  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("AppointmentResponse:patient").toLocked();
973
974 /**
975   * Search parameter: <b>appointment</b>
976   * <p>
977   * Description: <b>The appointment that the response is attached to</b><br>
978   * Type: <b>reference</b><br>
979   * Path: <b>AppointmentResponse.appointment</b><br>
980   * </p>
981   */
982  @SearchParamDefinition(name="appointment", path="AppointmentResponse.appointment", description="The appointment that the response is attached to", type="reference", target={Appointment.class } )
983  public static final String SP_APPOINTMENT = "appointment";
984 /**
985   * <b>Fluent Client</b> search parameter constant for <b>appointment</b>
986   * <p>
987   * Description: <b>The appointment that the response is attached to</b><br>
988   * Type: <b>reference</b><br>
989   * Path: <b>AppointmentResponse.appointment</b><br>
990   * </p>
991   */
992  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam APPOINTMENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_APPOINTMENT);
993
994/**
995   * Constant for fluent queries to be used to add include statements. Specifies
996   * the path value of "<b>AppointmentResponse:appointment</b>".
997   */
998  public static final ca.uhn.fhir.model.api.Include INCLUDE_APPOINTMENT = new ca.uhn.fhir.model.api.Include("AppointmentResponse:appointment").toLocked();
999
1000 /**
1001   * Search parameter: <b>location</b>
1002   * <p>
1003   * Description: <b>This Response is for this Location</b><br>
1004   * Type: <b>reference</b><br>
1005   * Path: <b>AppointmentResponse.actor</b><br>
1006   * </p>
1007   */
1008  @SearchParamDefinition(name="location", path="AppointmentResponse.actor", description="This Response is for this Location", type="reference", target={Location.class } )
1009  public static final String SP_LOCATION = "location";
1010 /**
1011   * <b>Fluent Client</b> search parameter constant for <b>location</b>
1012   * <p>
1013   * Description: <b>This Response is for this Location</b><br>
1014   * Type: <b>reference</b><br>
1015   * Path: <b>AppointmentResponse.actor</b><br>
1016   * </p>
1017   */
1018  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam LOCATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_LOCATION);
1019
1020/**
1021   * Constant for fluent queries to be used to add include statements. Specifies
1022   * the path value of "<b>AppointmentResponse:location</b>".
1023   */
1024  public static final ca.uhn.fhir.model.api.Include INCLUDE_LOCATION = new ca.uhn.fhir.model.api.Include("AppointmentResponse:location").toLocked();
1025
1026
1027}
1028