001package org.hl7.fhir.dstu2.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
033import java.util.ArrayList;
034import java.util.Date;
035import java.util.List;
036
037import ca.uhn.fhir.model.api.annotation.Child;
038import ca.uhn.fhir.model.api.annotation.Description;
039import ca.uhn.fhir.model.api.annotation.ResourceDef;
040import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
041import org.hl7.fhir.exceptions.FHIRException;
042import org.hl7.fhir.utilities.Utilities;
043
044/**
045 * A reply to an appointment request for a patient and/or practitioner(s), such
046 * 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 appointment participant has accepted that they can attend the appointment
054     * at the time specified in the AppointmentResponse.
055     */
056    ACCEPTED,
057    /**
058     * The appointment participant has declined the appointment.
059     */
060    DECLINED,
061    /**
062     * The appointment participant has tentatively accepted the appointment.
063     */
064    TENTATIVE,
065    /**
066     * The participant has in-process the appointment.
067     */
068    INPROCESS,
069    /**
070     * The participant has completed the appointment.
071     */
072    COMPLETED,
073    /**
074     * This is the intitial status of an appointment participant until a participant
075     * has replied. It implies that there is no commitment for the appointment.
076     */
077    NEEDSACTION,
078    /**
079     * added to help the parsers
080     */
081    NULL;
082
083    public static ParticipantStatus fromCode(String codeString) throws FHIRException {
084      if (codeString == null || "".equals(codeString))
085        return null;
086      if ("accepted".equals(codeString))
087        return ACCEPTED;
088      if ("declined".equals(codeString))
089        return DECLINED;
090      if ("tentative".equals(codeString))
091        return TENTATIVE;
092      if ("in-process".equals(codeString))
093        return INPROCESS;
094      if ("completed".equals(codeString))
095        return COMPLETED;
096      if ("needs-action".equals(codeString))
097        return NEEDSACTION;
098      throw new FHIRException("Unknown ParticipantStatus code '" + codeString + "'");
099    }
100
101    public String toCode() {
102      switch (this) {
103      case ACCEPTED:
104        return "accepted";
105      case DECLINED:
106        return "declined";
107      case TENTATIVE:
108        return "tentative";
109      case INPROCESS:
110        return "in-process";
111      case COMPLETED:
112        return "completed";
113      case NEEDSACTION:
114        return "needs-action";
115      case NULL:
116        return null;
117      default:
118        return "?";
119      }
120    }
121
122    public String getSystem() {
123      switch (this) {
124      case ACCEPTED:
125        return "http://hl7.org/fhir/participantstatus";
126      case DECLINED:
127        return "http://hl7.org/fhir/participantstatus";
128      case TENTATIVE:
129        return "http://hl7.org/fhir/participantstatus";
130      case INPROCESS:
131        return "http://hl7.org/fhir/participantstatus";
132      case COMPLETED:
133        return "http://hl7.org/fhir/participantstatus";
134      case NEEDSACTION:
135        return "http://hl7.org/fhir/participantstatus";
136      case NULL:
137        return null;
138      default:
139        return "?";
140      }
141    }
142
143    public String getDefinition() {
144      switch (this) {
145      case ACCEPTED:
146        return "The appointment participant has accepted that they can attend the appointment at the time specified in the AppointmentResponse.";
147      case DECLINED:
148        return "The appointment participant has declined the appointment.";
149      case TENTATIVE:
150        return "The appointment participant has tentatively accepted the appointment.";
151      case INPROCESS:
152        return "The participant has in-process the appointment.";
153      case COMPLETED:
154        return "The participant has completed the appointment.";
155      case NEEDSACTION:
156        return "This is the intitial status of an appointment participant until a participant has replied. It implies that there is no commitment for the appointment.";
157      case NULL:
158        return null;
159      default:
160        return "?";
161      }
162    }
163
164    public String getDisplay() {
165      switch (this) {
166      case ACCEPTED:
167        return "Accepted";
168      case DECLINED:
169        return "Declined";
170      case TENTATIVE:
171        return "Tentative";
172      case INPROCESS:
173        return "In Process";
174      case COMPLETED:
175        return "Completed";
176      case NEEDSACTION:
177        return "Needs Action";
178      case NULL:
179        return null;
180      default:
181        return "?";
182      }
183    }
184  }
185
186  public static class ParticipantStatusEnumFactory implements EnumFactory<ParticipantStatus> {
187    public ParticipantStatus fromCode(String codeString) throws IllegalArgumentException {
188      if (codeString == null || "".equals(codeString))
189        if (codeString == null || "".equals(codeString))
190          return null;
191      if ("accepted".equals(codeString))
192        return ParticipantStatus.ACCEPTED;
193      if ("declined".equals(codeString))
194        return ParticipantStatus.DECLINED;
195      if ("tentative".equals(codeString))
196        return ParticipantStatus.TENTATIVE;
197      if ("in-process".equals(codeString))
198        return ParticipantStatus.INPROCESS;
199      if ("completed".equals(codeString))
200        return ParticipantStatus.COMPLETED;
201      if ("needs-action".equals(codeString))
202        return ParticipantStatus.NEEDSACTION;
203      throw new IllegalArgumentException("Unknown ParticipantStatus code '" + codeString + "'");
204    }
205
206    public Enumeration<ParticipantStatus> fromType(Base code) throws FHIRException {
207      if (code == null || code.isEmpty())
208        return null;
209      String codeString = ((PrimitiveType) code).asStringValue();
210      if (codeString == null || "".equals(codeString))
211        return null;
212      if ("accepted".equals(codeString))
213        return new Enumeration<ParticipantStatus>(this, ParticipantStatus.ACCEPTED);
214      if ("declined".equals(codeString))
215        return new Enumeration<ParticipantStatus>(this, ParticipantStatus.DECLINED);
216      if ("tentative".equals(codeString))
217        return new Enumeration<ParticipantStatus>(this, ParticipantStatus.TENTATIVE);
218      if ("in-process".equals(codeString))
219        return new Enumeration<ParticipantStatus>(this, ParticipantStatus.INPROCESS);
220      if ("completed".equals(codeString))
221        return new Enumeration<ParticipantStatus>(this, ParticipantStatus.COMPLETED);
222      if ("needs-action".equals(codeString))
223        return new Enumeration<ParticipantStatus>(this, ParticipantStatus.NEEDSACTION);
224      throw new FHIRException("Unknown ParticipantStatus code '" + codeString + "'");
225    }
226
227    public String toCode(ParticipantStatus code) {
228      if (code == ParticipantStatus.ACCEPTED)
229        return "accepted";
230      if (code == ParticipantStatus.DECLINED)
231        return "declined";
232      if (code == ParticipantStatus.TENTATIVE)
233        return "tentative";
234      if (code == ParticipantStatus.INPROCESS)
235        return "in-process";
236      if (code == ParticipantStatus.COMPLETED)
237        return "completed";
238      if (code == ParticipantStatus.NEEDSACTION)
239        return "needs-action";
240      return "?";
241    }
242  }
243
244  /**
245   * This records identifiers associated with this appointment response concern
246   * that are defined by business processes and/ or used to refer to it when a
247   * direct URL reference to the resource itself is not appropriate.
248   */
249  @Child(name = "identifier", type = {
250      Identifier.class }, order = 0, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
251  @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.")
252  protected List<Identifier> identifier;
253
254  /**
255   * Appointment that this response is replying to.
256   */
257  @Child(name = "appointment", type = {
258      Appointment.class }, order = 1, min = 1, max = 1, modifier = false, summary = true)
259  @Description(shortDefinition = "Appointment this response relates to", formalDefinition = "Appointment that this response is replying to.")
260  protected Reference appointment;
261
262  /**
263   * The actual object that is the target of the reference (Appointment that this
264   * response is replying to.)
265   */
266  protected Appointment appointmentTarget;
267
268  /**
269   * Date/Time that the appointment is to take place, or requested new start time.
270   */
271  @Child(name = "start", type = { InstantType.class }, order = 2, min = 0, max = 1, modifier = false, summary = false)
272  @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.")
273  protected InstantType start;
274
275  /**
276   * This may be either the same as the appointment request to confirm the details
277   * of the appointment, or alternately a new time to request a re-negotiation of
278   * the end time.
279   */
280  @Child(name = "end", type = { InstantType.class }, order = 3, min = 0, max = 1, modifier = false, summary = false)
281  @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.")
282  protected InstantType end;
283
284  /**
285   * Role of participant in the appointment.
286   */
287  @Child(name = "participantType", type = {
288      CodeableConcept.class }, order = 4, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
289  @Description(shortDefinition = "Role of participant in the appointment", formalDefinition = "Role of participant in the appointment.")
290  protected List<CodeableConcept> participantType;
291
292  /**
293   * A Person, Location/HealthcareService or Device that is participating in the
294   * appointment.
295   */
296  @Child(name = "actor", type = { Patient.class, Practitioner.class, RelatedPerson.class, Device.class,
297      HealthcareService.class, Location.class }, order = 5, min = 0, max = 1, modifier = false, summary = true)
298  @Description(shortDefinition = "Person, Location/HealthcareService or Device", formalDefinition = "A Person, Location/HealthcareService or Device that is participating in the appointment.")
299  protected Reference actor;
300
301  /**
302   * The actual object that is the target of the reference (A Person,
303   * Location/HealthcareService or Device that is participating in the
304   * appointment.)
305   */
306  protected Resource actorTarget;
307
308  /**
309   * Participation status of the participant. When the status is declined or
310   * tentative if the start/end times are different to the appointment, then these
311   * times should be interpreted as a requested time change. When the status is
312   * accepted, the times can either be the time of the appointment (as a
313   * confirmation of the time) or can be empty.
314   */
315  @Child(name = "participantStatus", type = {
316      CodeType.class }, order = 6, min = 1, max = 1, modifier = true, summary = true)
317  @Description(shortDefinition = "accepted | declined | tentative | in-process | completed | 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.")
318  protected Enumeration<ParticipantStatus> participantStatus;
319
320  /**
321   * Additional comments about the appointment.
322   */
323  @Child(name = "comment", type = { StringType.class }, order = 7, min = 0, max = 1, modifier = false, summary = false)
324  @Description(shortDefinition = "Additional comments", formalDefinition = "Additional comments about the appointment.")
325  protected StringType comment;
326
327  private static final long serialVersionUID = 248548635L;
328
329  /*
330   * Constructor
331   */
332  public AppointmentResponse() {
333    super();
334  }
335
336  /*
337   * Constructor
338   */
339  public AppointmentResponse(Reference appointment, Enumeration<ParticipantStatus> participantStatus) {
340    super();
341    this.appointment = appointment;
342    this.participantStatus = participantStatus;
343  }
344
345  /**
346   * @return {@link #identifier} (This records identifiers associated with this
347   *         appointment response concern that are defined by business processes
348   *         and/ or used to refer to it when a direct URL reference to the
349   *         resource itself is not appropriate.)
350   */
351  public List<Identifier> getIdentifier() {
352    if (this.identifier == null)
353      this.identifier = new ArrayList<Identifier>();
354    return this.identifier;
355  }
356
357  public boolean hasIdentifier() {
358    if (this.identifier == null)
359      return false;
360    for (Identifier item : this.identifier)
361      if (!item.isEmpty())
362        return true;
363    return false;
364  }
365
366  /**
367   * @return {@link #identifier} (This records identifiers associated with this
368   *         appointment response concern that are defined by business processes
369   *         and/ or used to refer to it when a direct URL reference to the
370   *         resource itself is not appropriate.)
371   */
372  // syntactic sugar
373  public Identifier addIdentifier() { // 3
374    Identifier t = new Identifier();
375    if (this.identifier == null)
376      this.identifier = new ArrayList<Identifier>();
377    this.identifier.add(t);
378    return t;
379  }
380
381  // syntactic sugar
382  public AppointmentResponse addIdentifier(Identifier t) { // 3
383    if (t == null)
384      return this;
385    if (this.identifier == null)
386      this.identifier = new ArrayList<Identifier>();
387    this.identifier.add(t);
388    return this;
389  }
390
391  /**
392   * @return {@link #appointment} (Appointment that this response is replying to.)
393   */
394  public Reference getAppointment() {
395    if (this.appointment == null)
396      if (Configuration.errorOnAutoCreate())
397        throw new Error("Attempt to auto-create AppointmentResponse.appointment");
398      else if (Configuration.doAutoCreate())
399        this.appointment = new Reference(); // cc
400    return this.appointment;
401  }
402
403  public boolean hasAppointment() {
404    return this.appointment != null && !this.appointment.isEmpty();
405  }
406
407  /**
408   * @param value {@link #appointment} (Appointment that this response is replying
409   *              to.)
410   */
411  public AppointmentResponse setAppointment(Reference value) {
412    this.appointment = value;
413    return this;
414  }
415
416  /**
417   * @return {@link #appointment} The actual object that is the target of the
418   *         reference. The reference library doesn't populate this, but you can
419   *         use it to hold the resource if you resolve it. (Appointment that this
420   *         response is replying to.)
421   */
422  public Appointment getAppointmentTarget() {
423    if (this.appointmentTarget == null)
424      if (Configuration.errorOnAutoCreate())
425        throw new Error("Attempt to auto-create AppointmentResponse.appointment");
426      else if (Configuration.doAutoCreate())
427        this.appointmentTarget = new Appointment(); // aa
428    return this.appointmentTarget;
429  }
430
431  /**
432   * @param value {@link #appointment} The actual object that is the target of the
433   *              reference. The reference library doesn't use these, but you can
434   *              use it to hold the resource if you resolve it. (Appointment that
435   *              this response is replying to.)
436   */
437  public AppointmentResponse setAppointmentTarget(Appointment value) {
438    this.appointmentTarget = value;
439    return this;
440  }
441
442  /**
443   * @return {@link #start} (Date/Time that the appointment is to take place, or
444   *         requested new start time.). This is the underlying object with id,
445   *         value and extensions. The accessor "getStart" gives direct access to
446   *         the value
447   */
448  public InstantType getStartElement() {
449    if (this.start == null)
450      if (Configuration.errorOnAutoCreate())
451        throw new Error("Attempt to auto-create AppointmentResponse.start");
452      else if (Configuration.doAutoCreate())
453        this.start = new InstantType(); // bb
454    return this.start;
455  }
456
457  public boolean hasStartElement() {
458    return this.start != null && !this.start.isEmpty();
459  }
460
461  public boolean hasStart() {
462    return this.start != null && !this.start.isEmpty();
463  }
464
465  /**
466   * @param value {@link #start} (Date/Time that the appointment is to take place,
467   *              or requested new start time.). This is the underlying object
468   *              with id, value and extensions. The accessor "getStart" gives
469   *              direct access to the value
470   */
471  public AppointmentResponse setStartElement(InstantType value) {
472    this.start = value;
473    return this;
474  }
475
476  /**
477   * @return Date/Time that the appointment is to take place, or requested new
478   *         start time.
479   */
480  public Date getStart() {
481    return this.start == null ? null : this.start.getValue();
482  }
483
484  /**
485   * @param value Date/Time that the appointment is to take place, or requested
486   *              new start time.
487   */
488  public AppointmentResponse setStart(Date value) {
489    if (value == null)
490      this.start = null;
491    else {
492      if (this.start == null)
493        this.start = new InstantType();
494      this.start.setValue(value);
495    }
496    return this;
497  }
498
499  /**
500   * @return {@link #end} (This may be either the same as the appointment request
501   *         to confirm the details of the appointment, or alternately a new time
502   *         to request a re-negotiation of the end time.). This is the underlying
503   *         object with id, value and extensions. The accessor "getEnd" gives
504   *         direct access to the value
505   */
506  public InstantType getEndElement() {
507    if (this.end == null)
508      if (Configuration.errorOnAutoCreate())
509        throw new Error("Attempt to auto-create AppointmentResponse.end");
510      else if (Configuration.doAutoCreate())
511        this.end = new InstantType(); // bb
512    return this.end;
513  }
514
515  public boolean hasEndElement() {
516    return this.end != null && !this.end.isEmpty();
517  }
518
519  public boolean hasEnd() {
520    return this.end != null && !this.end.isEmpty();
521  }
522
523  /**
524   * @param value {@link #end} (This may be either the same as the appointment
525   *              request to confirm the details of the appointment, or
526   *              alternately a new time to request a re-negotiation of the end
527   *              time.). This is the underlying object with id, value and
528   *              extensions. The accessor "getEnd" gives direct access to the
529   *              value
530   */
531  public AppointmentResponse setEndElement(InstantType value) {
532    this.end = value;
533    return this;
534  }
535
536  /**
537   * @return This may be either the same as the appointment request to confirm the
538   *         details of the appointment, or alternately a new time to request a
539   *         re-negotiation of the end time.
540   */
541  public Date getEnd() {
542    return this.end == null ? null : this.end.getValue();
543  }
544
545  /**
546   * @param value This may be either the same as the appointment request to
547   *              confirm the details of the appointment, or alternately a new
548   *              time to request a re-negotiation of the end time.
549   */
550  public AppointmentResponse setEnd(Date value) {
551    if (value == null)
552      this.end = null;
553    else {
554      if (this.end == null)
555        this.end = new InstantType();
556      this.end.setValue(value);
557    }
558    return this;
559  }
560
561  /**
562   * @return {@link #participantType} (Role of participant in the appointment.)
563   */
564  public List<CodeableConcept> getParticipantType() {
565    if (this.participantType == null)
566      this.participantType = new ArrayList<CodeableConcept>();
567    return this.participantType;
568  }
569
570  public boolean hasParticipantType() {
571    if (this.participantType == null)
572      return false;
573    for (CodeableConcept item : this.participantType)
574      if (!item.isEmpty())
575        return true;
576    return false;
577  }
578
579  /**
580   * @return {@link #participantType} (Role of participant in the appointment.)
581   */
582  // syntactic sugar
583  public CodeableConcept addParticipantType() { // 3
584    CodeableConcept t = new CodeableConcept();
585    if (this.participantType == null)
586      this.participantType = new ArrayList<CodeableConcept>();
587    this.participantType.add(t);
588    return t;
589  }
590
591  // syntactic sugar
592  public AppointmentResponse addParticipantType(CodeableConcept t) { // 3
593    if (t == null)
594      return this;
595    if (this.participantType == null)
596      this.participantType = new ArrayList<CodeableConcept>();
597    this.participantType.add(t);
598    return this;
599  }
600
601  /**
602   * @return {@link #actor} (A Person, Location/HealthcareService or Device that
603   *         is participating in the appointment.)
604   */
605  public Reference getActor() {
606    if (this.actor == null)
607      if (Configuration.errorOnAutoCreate())
608        throw new Error("Attempt to auto-create AppointmentResponse.actor");
609      else if (Configuration.doAutoCreate())
610        this.actor = new Reference(); // cc
611    return this.actor;
612  }
613
614  public boolean hasActor() {
615    return this.actor != null && !this.actor.isEmpty();
616  }
617
618  /**
619   * @param value {@link #actor} (A Person, Location/HealthcareService or Device
620   *              that is participating in the appointment.)
621   */
622  public AppointmentResponse setActor(Reference value) {
623    this.actor = value;
624    return this;
625  }
626
627  /**
628   * @return {@link #actor} The actual object that is the target of the reference.
629   *         The reference library doesn't populate this, but you can use it to
630   *         hold the resource if you resolve it. (A Person,
631   *         Location/HealthcareService or Device that is participating in the
632   *         appointment.)
633   */
634  public Resource getActorTarget() {
635    return this.actorTarget;
636  }
637
638  /**
639   * @param value {@link #actor} The actual object that is the target of the
640   *              reference. The reference library doesn't use these, but you can
641   *              use it to hold the resource if you resolve it. (A Person,
642   *              Location/HealthcareService or Device that is participating in
643   *              the appointment.)
644   */
645  public AppointmentResponse setActorTarget(Resource value) {
646    this.actorTarget = value;
647    return this;
648  }
649
650  /**
651   * @return {@link #participantStatus} (Participation status of the participant.
652   *         When the status is declined or tentative if the start/end times are
653   *         different to the appointment, then these times should be interpreted
654   *         as a requested time change. When the status is accepted, the times
655   *         can either be the time of the appointment (as a confirmation of the
656   *         time) or can be empty.). This is the underlying object with id, value
657   *         and extensions. The accessor "getParticipantStatus" gives direct
658   *         access to the value
659   */
660  public Enumeration<ParticipantStatus> getParticipantStatusElement() {
661    if (this.participantStatus == null)
662      if (Configuration.errorOnAutoCreate())
663        throw new Error("Attempt to auto-create AppointmentResponse.participantStatus");
664      else if (Configuration.doAutoCreate())
665        this.participantStatus = new Enumeration<ParticipantStatus>(new ParticipantStatusEnumFactory()); // bb
666    return this.participantStatus;
667  }
668
669  public boolean hasParticipantStatusElement() {
670    return this.participantStatus != null && !this.participantStatus.isEmpty();
671  }
672
673  public boolean hasParticipantStatus() {
674    return this.participantStatus != null && !this.participantStatus.isEmpty();
675  }
676
677  /**
678   * @param value {@link #participantStatus} (Participation status of the
679   *              participant. When the status is declined or tentative if the
680   *              start/end times are different to the appointment, then these
681   *              times should be interpreted as a requested time change. When the
682   *              status is accepted, the times can either be the time of the
683   *              appointment (as a confirmation of the time) or can be empty.).
684   *              This is the underlying object with id, value and extensions. The
685   *              accessor "getParticipantStatus" gives direct access to the value
686   */
687  public AppointmentResponse setParticipantStatusElement(Enumeration<ParticipantStatus> value) {
688    this.participantStatus = value;
689    return this;
690  }
691
692  /**
693   * @return Participation status of the participant. When the status is declined
694   *         or tentative if the start/end times are different to the appointment,
695   *         then these times should be interpreted as a requested time change.
696   *         When the status is accepted, the times can either be the time of the
697   *         appointment (as a confirmation of the time) or can be empty.
698   */
699  public ParticipantStatus getParticipantStatus() {
700    return this.participantStatus == null ? null : this.participantStatus.getValue();
701  }
702
703  /**
704   * @param value Participation status of the participant. When the status is
705   *              declined or tentative if the start/end times are different to
706   *              the appointment, then these times should be interpreted as a
707   *              requested time change. When the status is accepted, the times
708   *              can either be the time of the appointment (as a confirmation of
709   *              the time) or can be empty.
710   */
711  public AppointmentResponse setParticipantStatus(ParticipantStatus value) {
712    if (this.participantStatus == null)
713      this.participantStatus = new Enumeration<ParticipantStatus>(new ParticipantStatusEnumFactory());
714    this.participantStatus.setValue(value);
715    return this;
716  }
717
718  /**
719   * @return {@link #comment} (Additional comments about the appointment.). This
720   *         is the underlying object with id, value and extensions. The accessor
721   *         "getComment" gives direct access to the value
722   */
723  public StringType getCommentElement() {
724    if (this.comment == null)
725      if (Configuration.errorOnAutoCreate())
726        throw new Error("Attempt to auto-create AppointmentResponse.comment");
727      else if (Configuration.doAutoCreate())
728        this.comment = new StringType(); // bb
729    return this.comment;
730  }
731
732  public boolean hasCommentElement() {
733    return this.comment != null && !this.comment.isEmpty();
734  }
735
736  public boolean hasComment() {
737    return this.comment != null && !this.comment.isEmpty();
738  }
739
740  /**
741   * @param value {@link #comment} (Additional comments about the appointment.).
742   *              This is the underlying object with id, value and extensions. The
743   *              accessor "getComment" gives direct access to the value
744   */
745  public AppointmentResponse setCommentElement(StringType value) {
746    this.comment = value;
747    return this;
748  }
749
750  /**
751   * @return Additional comments about the appointment.
752   */
753  public String getComment() {
754    return this.comment == null ? null : this.comment.getValue();
755  }
756
757  /**
758   * @param value Additional comments about the appointment.
759   */
760  public AppointmentResponse setComment(String value) {
761    if (Utilities.noString(value))
762      this.comment = null;
763    else {
764      if (this.comment == null)
765        this.comment = new StringType();
766      this.comment.setValue(value);
767    }
768    return this;
769  }
770
771  protected void listChildren(List<Property> childrenList) {
772    super.listChildren(childrenList);
773    childrenList.add(new Property("identifier", "Identifier",
774        "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.",
775        0, java.lang.Integer.MAX_VALUE, identifier));
776    childrenList.add(new Property("appointment", "Reference(Appointment)",
777        "Appointment that this response is replying to.", 0, java.lang.Integer.MAX_VALUE, appointment));
778    childrenList.add(new Property("start", "instant",
779        "Date/Time that the appointment is to take place, or requested new start time.", 0, java.lang.Integer.MAX_VALUE,
780        start));
781    childrenList.add(new Property("end", "instant",
782        "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.",
783        0, java.lang.Integer.MAX_VALUE, end));
784    childrenList.add(new Property("participantType", "CodeableConcept", "Role of participant in the appointment.", 0,
785        java.lang.Integer.MAX_VALUE, participantType));
786    childrenList
787        .add(new Property("actor", "Reference(Patient|Practitioner|RelatedPerson|Device|HealthcareService|Location)",
788            "A Person, Location/HealthcareService or Device that is participating in the appointment.", 0,
789            java.lang.Integer.MAX_VALUE, actor));
790    childrenList.add(new Property("participantStatus", "code",
791        "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.",
792        0, java.lang.Integer.MAX_VALUE, participantStatus));
793    childrenList.add(new Property("comment", "string", "Additional comments about the appointment.", 0,
794        java.lang.Integer.MAX_VALUE, comment));
795  }
796
797  @Override
798  public void setProperty(String name, Base value) throws FHIRException {
799    if (name.equals("identifier"))
800      this.getIdentifier().add(castToIdentifier(value));
801    else if (name.equals("appointment"))
802      this.appointment = castToReference(value); // Reference
803    else if (name.equals("start"))
804      this.start = castToInstant(value); // InstantType
805    else if (name.equals("end"))
806      this.end = castToInstant(value); // InstantType
807    else if (name.equals("participantType"))
808      this.getParticipantType().add(castToCodeableConcept(value));
809    else if (name.equals("actor"))
810      this.actor = castToReference(value); // Reference
811    else if (name.equals("participantStatus"))
812      this.participantStatus = new ParticipantStatusEnumFactory().fromType(value); // Enumeration<ParticipantStatus>
813    else if (name.equals("comment"))
814      this.comment = castToString(value); // StringType
815    else
816      super.setProperty(name, value);
817  }
818
819  @Override
820  public Base addChild(String name) throws FHIRException {
821    if (name.equals("identifier")) {
822      return addIdentifier();
823    } else if (name.equals("appointment")) {
824      this.appointment = new Reference();
825      return this.appointment;
826    } else if (name.equals("start")) {
827      throw new FHIRException("Cannot call addChild on a singleton property AppointmentResponse.start");
828    } else if (name.equals("end")) {
829      throw new FHIRException("Cannot call addChild on a singleton property AppointmentResponse.end");
830    } else if (name.equals("participantType")) {
831      return addParticipantType();
832    } else if (name.equals("actor")) {
833      this.actor = new Reference();
834      return this.actor;
835    } else if (name.equals("participantStatus")) {
836      throw new FHIRException("Cannot call addChild on a singleton property AppointmentResponse.participantStatus");
837    } else if (name.equals("comment")) {
838      throw new FHIRException("Cannot call addChild on a singleton property AppointmentResponse.comment");
839    } else
840      return super.addChild(name);
841  }
842
843  public String fhirType() {
844    return "AppointmentResponse";
845
846  }
847
848  public AppointmentResponse copy() {
849    AppointmentResponse dst = new AppointmentResponse();
850    copyValues(dst);
851    if (identifier != null) {
852      dst.identifier = new ArrayList<Identifier>();
853      for (Identifier i : identifier)
854        dst.identifier.add(i.copy());
855    }
856    ;
857    dst.appointment = appointment == null ? null : appointment.copy();
858    dst.start = start == null ? null : start.copy();
859    dst.end = end == null ? null : end.copy();
860    if (participantType != null) {
861      dst.participantType = new ArrayList<CodeableConcept>();
862      for (CodeableConcept i : participantType)
863        dst.participantType.add(i.copy());
864    }
865    ;
866    dst.actor = actor == null ? null : actor.copy();
867    dst.participantStatus = participantStatus == null ? null : participantStatus.copy();
868    dst.comment = comment == null ? null : comment.copy();
869    return dst;
870  }
871
872  protected AppointmentResponse typedCopy() {
873    return copy();
874  }
875
876  @Override
877  public boolean equalsDeep(Base other) {
878    if (!super.equalsDeep(other))
879      return false;
880    if (!(other instanceof AppointmentResponse))
881      return false;
882    AppointmentResponse o = (AppointmentResponse) other;
883    return compareDeep(identifier, o.identifier, true) && compareDeep(appointment, o.appointment, true)
884        && compareDeep(start, o.start, true) && compareDeep(end, o.end, true)
885        && compareDeep(participantType, o.participantType, true) && compareDeep(actor, o.actor, true)
886        && compareDeep(participantStatus, o.participantStatus, true) && compareDeep(comment, o.comment, true);
887  }
888
889  @Override
890  public boolean equalsShallow(Base other) {
891    if (!super.equalsShallow(other))
892      return false;
893    if (!(other instanceof AppointmentResponse))
894      return false;
895    AppointmentResponse o = (AppointmentResponse) other;
896    return compareValues(start, o.start, true) && compareValues(end, o.end, true)
897        && compareValues(participantStatus, o.participantStatus, true) && compareValues(comment, o.comment, true);
898  }
899
900  public boolean isEmpty() {
901    return super.isEmpty() && (identifier == null || identifier.isEmpty())
902        && (appointment == null || appointment.isEmpty()) && (start == null || start.isEmpty())
903        && (end == null || end.isEmpty()) && (participantType == null || participantType.isEmpty())
904        && (actor == null || actor.isEmpty()) && (participantStatus == null || participantStatus.isEmpty())
905        && (comment == null || comment.isEmpty());
906  }
907
908  @Override
909  public ResourceType getResourceType() {
910    return ResourceType.AppointmentResponse;
911  }
912
913  @SearchParamDefinition(name = "actor", path = "AppointmentResponse.actor", description = "The Person, Location/HealthcareService or Device that this appointment response replies for", type = "reference")
914  public static final String SP_ACTOR = "actor";
915  @SearchParamDefinition(name = "identifier", path = "AppointmentResponse.identifier", description = "An Identifier in this appointment response", type = "token")
916  public static final String SP_IDENTIFIER = "identifier";
917  @SearchParamDefinition(name = "practitioner", path = "AppointmentResponse.actor", description = "This Response is for this Practitioner", type = "reference")
918  public static final String SP_PRACTITIONER = "practitioner";
919  @SearchParamDefinition(name = "part-status", path = "AppointmentResponse.participantStatus", description = "The participants acceptance status for this appointment", type = "token")
920  public static final String SP_PARTSTATUS = "part-status";
921  @SearchParamDefinition(name = "patient", path = "AppointmentResponse.actor", description = "This Response is for this Patient", type = "reference")
922  public static final String SP_PATIENT = "patient";
923  @SearchParamDefinition(name = "appointment", path = "AppointmentResponse.appointment", description = "The appointment that the response is attached to", type = "reference")
924  public static final String SP_APPOINTMENT = "appointment";
925  @SearchParamDefinition(name = "location", path = "AppointmentResponse.actor", description = "This Response is for this Location", type = "reference")
926  public static final String SP_LOCATION = "location";
927
928}