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