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