001package org.hl7.fhir.instance.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.*;
034
035import org.hl7.fhir.exceptions.FHIRException;
036import org.hl7.fhir.utilities.Utilities;
037
038import ca.uhn.fhir.model.api.annotation.*;
039/**
040 * A slot of time on a schedule that may be available for booking appointments.
041 */
042@ResourceDef(name="Slot", profile="http://hl7.org/fhir/Profile/Slot")
043public class Slot extends DomainResource {
044
045    public enum SlotStatus {
046        /**
047         * Indicates that the time interval is busy because one  or more events have been scheduled for that interval.
048         */
049        BUSY, 
050        /**
051         * Indicates that the time interval is free for scheduling.
052         */
053        FREE, 
054        /**
055         * Indicates that the time interval is busy and that the interval can not be scheduled.
056         */
057        BUSYUNAVAILABLE, 
058        /**
059         * Indicates that the time interval is busy because one or more events have been tentatively scheduled for that interval.
060         */
061        BUSYTENTATIVE, 
062        /**
063         * added to help the parsers
064         */
065        NULL;
066        public static SlotStatus fromCode(String codeString) throws FHIRException {
067            if (codeString == null || "".equals(codeString))
068                return null;
069        if ("busy".equals(codeString))
070          return BUSY;
071        if ("free".equals(codeString))
072          return FREE;
073        if ("busy-unavailable".equals(codeString))
074          return BUSYUNAVAILABLE;
075        if ("busy-tentative".equals(codeString))
076          return BUSYTENTATIVE;
077        throw new FHIRException("Unknown SlotStatus code '"+codeString+"'");
078        }
079        public String toCode() {
080          switch (this) {
081            case BUSY: return "busy";
082            case FREE: return "free";
083            case BUSYUNAVAILABLE: return "busy-unavailable";
084            case BUSYTENTATIVE: return "busy-tentative";
085            default: return "?";
086          }
087        }
088        public String getSystem() {
089          switch (this) {
090            case BUSY: return "http://hl7.org/fhir/slotstatus";
091            case FREE: return "http://hl7.org/fhir/slotstatus";
092            case BUSYUNAVAILABLE: return "http://hl7.org/fhir/slotstatus";
093            case BUSYTENTATIVE: return "http://hl7.org/fhir/slotstatus";
094            default: return "?";
095          }
096        }
097        public String getDefinition() {
098          switch (this) {
099            case BUSY: return "Indicates that the time interval is busy because one  or more events have been scheduled for that interval.";
100            case FREE: return "Indicates that the time interval is free for scheduling.";
101            case BUSYUNAVAILABLE: return "Indicates that the time interval is busy and that the interval can not be scheduled.";
102            case BUSYTENTATIVE: return "Indicates that the time interval is busy because one or more events have been tentatively scheduled for that interval.";
103            default: return "?";
104          }
105        }
106        public String getDisplay() {
107          switch (this) {
108            case BUSY: return "Busy";
109            case FREE: return "Free";
110            case BUSYUNAVAILABLE: return "Busy (Unavailable)";
111            case BUSYTENTATIVE: return "Busy (Tentative)";
112            default: return "?";
113          }
114        }
115    }
116
117  public static class SlotStatusEnumFactory implements EnumFactory<SlotStatus> {
118    public SlotStatus fromCode(String codeString) throws IllegalArgumentException {
119      if (codeString == null || "".equals(codeString))
120            if (codeString == null || "".equals(codeString))
121                return null;
122        if ("busy".equals(codeString))
123          return SlotStatus.BUSY;
124        if ("free".equals(codeString))
125          return SlotStatus.FREE;
126        if ("busy-unavailable".equals(codeString))
127          return SlotStatus.BUSYUNAVAILABLE;
128        if ("busy-tentative".equals(codeString))
129          return SlotStatus.BUSYTENTATIVE;
130        throw new IllegalArgumentException("Unknown SlotStatus code '"+codeString+"'");
131        }
132        public Enumeration<SlotStatus> fromType(Base code) throws FHIRException {
133          if (code == null || code.isEmpty())
134            return null;
135          String codeString = ((PrimitiveType) code).asStringValue();
136          if (codeString == null || "".equals(codeString))
137            return null;
138        if ("busy".equals(codeString))
139          return new Enumeration<SlotStatus>(this, SlotStatus.BUSY);
140        if ("free".equals(codeString))
141          return new Enumeration<SlotStatus>(this, SlotStatus.FREE);
142        if ("busy-unavailable".equals(codeString))
143          return new Enumeration<SlotStatus>(this, SlotStatus.BUSYUNAVAILABLE);
144        if ("busy-tentative".equals(codeString))
145          return new Enumeration<SlotStatus>(this, SlotStatus.BUSYTENTATIVE);
146        throw new FHIRException("Unknown SlotStatus code '"+codeString+"'");
147        }
148    public String toCode(SlotStatus code) {
149      if (code == SlotStatus.BUSY)
150        return "busy";
151      if (code == SlotStatus.FREE)
152        return "free";
153      if (code == SlotStatus.BUSYUNAVAILABLE)
154        return "busy-unavailable";
155      if (code == SlotStatus.BUSYTENTATIVE)
156        return "busy-tentative";
157      return "?";
158      }
159    }
160
161    /**
162     * External Ids for this item.
163     */
164    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
165    @Description(shortDefinition="External Ids for this item", formalDefinition="External Ids for this item." )
166    protected List<Identifier> identifier;
167
168    /**
169     * The type of appointments that can be booked into this slot (ideally this would be an identifiable service - which is at a location, rather than the location itself). If provided then this overrides the value provided on the availability resource.
170     */
171    @Child(name = "type", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=false)
172    @Description(shortDefinition="The type of appointments that can be booked into this slot (ideally this would be an identifiable service - which is at a location, rather than the location itself). If provided then this overrides the value provided on the availability resource", formalDefinition="The type of appointments that can be booked into this slot (ideally this would be an identifiable service - which is at a location, rather than the location itself). If provided then this overrides the value provided on the availability resource." )
173    protected CodeableConcept type;
174
175    /**
176     * The schedule resource that this slot defines an interval of status information.
177     */
178    @Child(name = "schedule", type = {Schedule.class}, order=2, min=1, max=1, modifier=false, summary=true)
179    @Description(shortDefinition="The schedule resource that this slot defines an interval of status information", formalDefinition="The schedule resource that this slot defines an interval of status information." )
180    protected Reference schedule;
181
182    /**
183     * The actual object that is the target of the reference (The schedule resource that this slot defines an interval of status information.)
184     */
185    protected Schedule scheduleTarget;
186
187    /**
188     * busy | free | busy-unavailable | busy-tentative.
189     */
190    @Child(name = "freeBusyType", type = {CodeType.class}, order=3, min=1, max=1, modifier=false, summary=true)
191    @Description(shortDefinition="busy | free | busy-unavailable | busy-tentative", formalDefinition="busy | free | busy-unavailable | busy-tentative." )
192    protected Enumeration<SlotStatus> freeBusyType;
193
194    /**
195     * Date/Time that the slot is to begin.
196     */
197    @Child(name = "start", type = {InstantType.class}, order=4, min=1, max=1, modifier=false, summary=true)
198    @Description(shortDefinition="Date/Time that the slot is to begin", formalDefinition="Date/Time that the slot is to begin." )
199    protected InstantType start;
200
201    /**
202     * Date/Time that the slot is to conclude.
203     */
204    @Child(name = "end", type = {InstantType.class}, order=5, min=1, max=1, modifier=false, summary=true)
205    @Description(shortDefinition="Date/Time that the slot is to conclude", formalDefinition="Date/Time that the slot is to conclude." )
206    protected InstantType end;
207
208    /**
209     * This slot has already been overbooked, appointments are unlikely to be accepted for this time.
210     */
211    @Child(name = "overbooked", type = {BooleanType.class}, order=6, min=0, max=1, modifier=false, summary=false)
212    @Description(shortDefinition="This slot has already been overbooked, appointments are unlikely to be accepted for this time", formalDefinition="This slot has already been overbooked, appointments are unlikely to be accepted for this time." )
213    protected BooleanType overbooked;
214
215    /**
216     * Comments on the slot to describe any extended information. Such as custom constraints on the slot.
217     */
218    @Child(name = "comment", type = {StringType.class}, order=7, min=0, max=1, modifier=false, summary=false)
219    @Description(shortDefinition="Comments on the slot to describe any extended information. Such as custom constraints on the slot", formalDefinition="Comments on the slot to describe any extended information. Such as custom constraints on the slot." )
220    protected StringType comment;
221
222    private static final long serialVersionUID = 1984269299L;
223
224  /*
225   * Constructor
226   */
227    public Slot() {
228      super();
229    }
230
231  /*
232   * Constructor
233   */
234    public Slot(Reference schedule, Enumeration<SlotStatus> freeBusyType, InstantType start, InstantType end) {
235      super();
236      this.schedule = schedule;
237      this.freeBusyType = freeBusyType;
238      this.start = start;
239      this.end = end;
240    }
241
242    /**
243     * @return {@link #identifier} (External Ids for this item.)
244     */
245    public List<Identifier> getIdentifier() { 
246      if (this.identifier == null)
247        this.identifier = new ArrayList<Identifier>();
248      return this.identifier;
249    }
250
251    public boolean hasIdentifier() { 
252      if (this.identifier == null)
253        return false;
254      for (Identifier item : this.identifier)
255        if (!item.isEmpty())
256          return true;
257      return false;
258    }
259
260    /**
261     * @return {@link #identifier} (External Ids for this item.)
262     */
263    // syntactic sugar
264    public Identifier addIdentifier() { //3
265      Identifier t = new Identifier();
266      if (this.identifier == null)
267        this.identifier = new ArrayList<Identifier>();
268      this.identifier.add(t);
269      return t;
270    }
271
272    // syntactic sugar
273    public Slot addIdentifier(Identifier t) { //3
274      if (t == null)
275        return this;
276      if (this.identifier == null)
277        this.identifier = new ArrayList<Identifier>();
278      this.identifier.add(t);
279      return this;
280    }
281
282    /**
283     * @return {@link #type} (The type of appointments that can be booked into this slot (ideally this would be an identifiable service - which is at a location, rather than the location itself). If provided then this overrides the value provided on the availability resource.)
284     */
285    public CodeableConcept getType() { 
286      if (this.type == null)
287        if (Configuration.errorOnAutoCreate())
288          throw new Error("Attempt to auto-create Slot.type");
289        else if (Configuration.doAutoCreate())
290          this.type = new CodeableConcept(); // cc
291      return this.type;
292    }
293
294    public boolean hasType() { 
295      return this.type != null && !this.type.isEmpty();
296    }
297
298    /**
299     * @param value {@link #type} (The type of appointments that can be booked into this slot (ideally this would be an identifiable service - which is at a location, rather than the location itself). If provided then this overrides the value provided on the availability resource.)
300     */
301    public Slot setType(CodeableConcept value) { 
302      this.type = value;
303      return this;
304    }
305
306    /**
307     * @return {@link #schedule} (The schedule resource that this slot defines an interval of status information.)
308     */
309    public Reference getSchedule() { 
310      if (this.schedule == null)
311        if (Configuration.errorOnAutoCreate())
312          throw new Error("Attempt to auto-create Slot.schedule");
313        else if (Configuration.doAutoCreate())
314          this.schedule = new Reference(); // cc
315      return this.schedule;
316    }
317
318    public boolean hasSchedule() { 
319      return this.schedule != null && !this.schedule.isEmpty();
320    }
321
322    /**
323     * @param value {@link #schedule} (The schedule resource that this slot defines an interval of status information.)
324     */
325    public Slot setSchedule(Reference value) { 
326      this.schedule = value;
327      return this;
328    }
329
330    /**
331     * @return {@link #schedule} 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. (The schedule resource that this slot defines an interval of status information.)
332     */
333    public Schedule getScheduleTarget() { 
334      if (this.scheduleTarget == null)
335        if (Configuration.errorOnAutoCreate())
336          throw new Error("Attempt to auto-create Slot.schedule");
337        else if (Configuration.doAutoCreate())
338          this.scheduleTarget = new Schedule(); // aa
339      return this.scheduleTarget;
340    }
341
342    /**
343     * @param value {@link #schedule} 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. (The schedule resource that this slot defines an interval of status information.)
344     */
345    public Slot setScheduleTarget(Schedule value) { 
346      this.scheduleTarget = value;
347      return this;
348    }
349
350    /**
351     * @return {@link #freeBusyType} (busy | free | busy-unavailable | busy-tentative.). This is the underlying object with id, value and extensions. The accessor "getFreeBusyType" gives direct access to the value
352     */
353    public Enumeration<SlotStatus> getFreeBusyTypeElement() { 
354      if (this.freeBusyType == null)
355        if (Configuration.errorOnAutoCreate())
356          throw new Error("Attempt to auto-create Slot.freeBusyType");
357        else if (Configuration.doAutoCreate())
358          this.freeBusyType = new Enumeration<SlotStatus>(new SlotStatusEnumFactory()); // bb
359      return this.freeBusyType;
360    }
361
362    public boolean hasFreeBusyTypeElement() { 
363      return this.freeBusyType != null && !this.freeBusyType.isEmpty();
364    }
365
366    public boolean hasFreeBusyType() { 
367      return this.freeBusyType != null && !this.freeBusyType.isEmpty();
368    }
369
370    /**
371     * @param value {@link #freeBusyType} (busy | free | busy-unavailable | busy-tentative.). This is the underlying object with id, value and extensions. The accessor "getFreeBusyType" gives direct access to the value
372     */
373    public Slot setFreeBusyTypeElement(Enumeration<SlotStatus> value) { 
374      this.freeBusyType = value;
375      return this;
376    }
377
378    /**
379     * @return busy | free | busy-unavailable | busy-tentative.
380     */
381    public SlotStatus getFreeBusyType() { 
382      return this.freeBusyType == null ? null : this.freeBusyType.getValue();
383    }
384
385    /**
386     * @param value busy | free | busy-unavailable | busy-tentative.
387     */
388    public Slot setFreeBusyType(SlotStatus value) { 
389        if (this.freeBusyType == null)
390          this.freeBusyType = new Enumeration<SlotStatus>(new SlotStatusEnumFactory());
391        this.freeBusyType.setValue(value);
392      return this;
393    }
394
395    /**
396     * @return {@link #start} (Date/Time that the slot is to begin.). This is the underlying object with id, value and extensions. The accessor "getStart" gives direct access to the value
397     */
398    public InstantType getStartElement() { 
399      if (this.start == null)
400        if (Configuration.errorOnAutoCreate())
401          throw new Error("Attempt to auto-create Slot.start");
402        else if (Configuration.doAutoCreate())
403          this.start = new InstantType(); // bb
404      return this.start;
405    }
406
407    public boolean hasStartElement() { 
408      return this.start != null && !this.start.isEmpty();
409    }
410
411    public boolean hasStart() { 
412      return this.start != null && !this.start.isEmpty();
413    }
414
415    /**
416     * @param value {@link #start} (Date/Time that the slot is to begin.). This is the underlying object with id, value and extensions. The accessor "getStart" gives direct access to the value
417     */
418    public Slot setStartElement(InstantType value) { 
419      this.start = value;
420      return this;
421    }
422
423    /**
424     * @return Date/Time that the slot is to begin.
425     */
426    public Date getStart() { 
427      return this.start == null ? null : this.start.getValue();
428    }
429
430    /**
431     * @param value Date/Time that the slot is to begin.
432     */
433    public Slot setStart(Date value) { 
434        if (this.start == null)
435          this.start = new InstantType();
436        this.start.setValue(value);
437      return this;
438    }
439
440    /**
441     * @return {@link #end} (Date/Time that the slot is to conclude.). This is the underlying object with id, value and extensions. The accessor "getEnd" gives direct access to the value
442     */
443    public InstantType getEndElement() { 
444      if (this.end == null)
445        if (Configuration.errorOnAutoCreate())
446          throw new Error("Attempt to auto-create Slot.end");
447        else if (Configuration.doAutoCreate())
448          this.end = new InstantType(); // bb
449      return this.end;
450    }
451
452    public boolean hasEndElement() { 
453      return this.end != null && !this.end.isEmpty();
454    }
455
456    public boolean hasEnd() { 
457      return this.end != null && !this.end.isEmpty();
458    }
459
460    /**
461     * @param value {@link #end} (Date/Time that the slot is to conclude.). This is the underlying object with id, value and extensions. The accessor "getEnd" gives direct access to the value
462     */
463    public Slot setEndElement(InstantType value) { 
464      this.end = value;
465      return this;
466    }
467
468    /**
469     * @return Date/Time that the slot is to conclude.
470     */
471    public Date getEnd() { 
472      return this.end == null ? null : this.end.getValue();
473    }
474
475    /**
476     * @param value Date/Time that the slot is to conclude.
477     */
478    public Slot setEnd(Date value) { 
479        if (this.end == null)
480          this.end = new InstantType();
481        this.end.setValue(value);
482      return this;
483    }
484
485    /**
486     * @return {@link #overbooked} (This slot has already been overbooked, appointments are unlikely to be accepted for this time.). This is the underlying object with id, value and extensions. The accessor "getOverbooked" gives direct access to the value
487     */
488    public BooleanType getOverbookedElement() { 
489      if (this.overbooked == null)
490        if (Configuration.errorOnAutoCreate())
491          throw new Error("Attempt to auto-create Slot.overbooked");
492        else if (Configuration.doAutoCreate())
493          this.overbooked = new BooleanType(); // bb
494      return this.overbooked;
495    }
496
497    public boolean hasOverbookedElement() { 
498      return this.overbooked != null && !this.overbooked.isEmpty();
499    }
500
501    public boolean hasOverbooked() { 
502      return this.overbooked != null && !this.overbooked.isEmpty();
503    }
504
505    /**
506     * @param value {@link #overbooked} (This slot has already been overbooked, appointments are unlikely to be accepted for this time.). This is the underlying object with id, value and extensions. The accessor "getOverbooked" gives direct access to the value
507     */
508    public Slot setOverbookedElement(BooleanType value) { 
509      this.overbooked = value;
510      return this;
511    }
512
513    /**
514     * @return This slot has already been overbooked, appointments are unlikely to be accepted for this time.
515     */
516    public boolean getOverbooked() { 
517      return this.overbooked == null || this.overbooked.isEmpty() ? false : this.overbooked.getValue();
518    }
519
520    /**
521     * @param value This slot has already been overbooked, appointments are unlikely to be accepted for this time.
522     */
523    public Slot setOverbooked(boolean value) { 
524        if (this.overbooked == null)
525          this.overbooked = new BooleanType();
526        this.overbooked.setValue(value);
527      return this;
528    }
529
530    /**
531     * @return {@link #comment} (Comments on the slot to describe any extended information. Such as custom constraints on the slot.). This is the underlying object with id, value and extensions. The accessor "getComment" gives direct access to the value
532     */
533    public StringType getCommentElement() { 
534      if (this.comment == null)
535        if (Configuration.errorOnAutoCreate())
536          throw new Error("Attempt to auto-create Slot.comment");
537        else if (Configuration.doAutoCreate())
538          this.comment = new StringType(); // bb
539      return this.comment;
540    }
541
542    public boolean hasCommentElement() { 
543      return this.comment != null && !this.comment.isEmpty();
544    }
545
546    public boolean hasComment() { 
547      return this.comment != null && !this.comment.isEmpty();
548    }
549
550    /**
551     * @param value {@link #comment} (Comments on the slot to describe any extended information. Such as custom constraints on the slot.). This is the underlying object with id, value and extensions. The accessor "getComment" gives direct access to the value
552     */
553    public Slot setCommentElement(StringType value) { 
554      this.comment = value;
555      return this;
556    }
557
558    /**
559     * @return Comments on the slot to describe any extended information. Such as custom constraints on the slot.
560     */
561    public String getComment() { 
562      return this.comment == null ? null : this.comment.getValue();
563    }
564
565    /**
566     * @param value Comments on the slot to describe any extended information. Such as custom constraints on the slot.
567     */
568    public Slot setComment(String value) { 
569      if (Utilities.noString(value))
570        this.comment = null;
571      else {
572        if (this.comment == null)
573          this.comment = new StringType();
574        this.comment.setValue(value);
575      }
576      return this;
577    }
578
579      protected void listChildren(List<Property> childrenList) {
580        super.listChildren(childrenList);
581        childrenList.add(new Property("identifier", "Identifier", "External Ids for this item.", 0, java.lang.Integer.MAX_VALUE, identifier));
582        childrenList.add(new Property("type", "CodeableConcept", "The type of appointments that can be booked into this slot (ideally this would be an identifiable service - which is at a location, rather than the location itself). If provided then this overrides the value provided on the availability resource.", 0, java.lang.Integer.MAX_VALUE, type));
583        childrenList.add(new Property("schedule", "Reference(Schedule)", "The schedule resource that this slot defines an interval of status information.", 0, java.lang.Integer.MAX_VALUE, schedule));
584        childrenList.add(new Property("freeBusyType", "code", "busy | free | busy-unavailable | busy-tentative.", 0, java.lang.Integer.MAX_VALUE, freeBusyType));
585        childrenList.add(new Property("start", "instant", "Date/Time that the slot is to begin.", 0, java.lang.Integer.MAX_VALUE, start));
586        childrenList.add(new Property("end", "instant", "Date/Time that the slot is to conclude.", 0, java.lang.Integer.MAX_VALUE, end));
587        childrenList.add(new Property("overbooked", "boolean", "This slot has already been overbooked, appointments are unlikely to be accepted for this time.", 0, java.lang.Integer.MAX_VALUE, overbooked));
588        childrenList.add(new Property("comment", "string", "Comments on the slot to describe any extended information. Such as custom constraints on the slot.", 0, java.lang.Integer.MAX_VALUE, comment));
589      }
590
591      @Override
592      public void setProperty(String name, Base value) throws FHIRException {
593        if (name.equals("identifier"))
594          this.getIdentifier().add(castToIdentifier(value));
595        else if (name.equals("type"))
596          this.type = castToCodeableConcept(value); // CodeableConcept
597        else if (name.equals("schedule"))
598          this.schedule = castToReference(value); // Reference
599        else if (name.equals("freeBusyType"))
600          this.freeBusyType = new SlotStatusEnumFactory().fromType(value); // Enumeration<SlotStatus>
601        else if (name.equals("start"))
602          this.start = castToInstant(value); // InstantType
603        else if (name.equals("end"))
604          this.end = castToInstant(value); // InstantType
605        else if (name.equals("overbooked"))
606          this.overbooked = castToBoolean(value); // BooleanType
607        else if (name.equals("comment"))
608          this.comment = castToString(value); // StringType
609        else
610          super.setProperty(name, value);
611      }
612
613      @Override
614      public Base addChild(String name) throws FHIRException {
615        if (name.equals("identifier")) {
616          return addIdentifier();
617        }
618        else if (name.equals("type")) {
619          this.type = new CodeableConcept();
620          return this.type;
621        }
622        else if (name.equals("schedule")) {
623          this.schedule = new Reference();
624          return this.schedule;
625        }
626        else if (name.equals("freeBusyType")) {
627          throw new FHIRException("Cannot call addChild on a primitive type Slot.freeBusyType");
628        }
629        else if (name.equals("start")) {
630          throw new FHIRException("Cannot call addChild on a primitive type Slot.start");
631        }
632        else if (name.equals("end")) {
633          throw new FHIRException("Cannot call addChild on a primitive type Slot.end");
634        }
635        else if (name.equals("overbooked")) {
636          throw new FHIRException("Cannot call addChild on a primitive type Slot.overbooked");
637        }
638        else if (name.equals("comment")) {
639          throw new FHIRException("Cannot call addChild on a primitive type Slot.comment");
640        }
641        else
642          return super.addChild(name);
643      }
644
645  public String fhirType() {
646    return "Slot";
647
648  }
649
650      public Slot copy() {
651        Slot dst = new Slot();
652        copyValues(dst);
653        if (identifier != null) {
654          dst.identifier = new ArrayList<Identifier>();
655          for (Identifier i : identifier)
656            dst.identifier.add(i.copy());
657        };
658        dst.type = type == null ? null : type.copy();
659        dst.schedule = schedule == null ? null : schedule.copy();
660        dst.freeBusyType = freeBusyType == null ? null : freeBusyType.copy();
661        dst.start = start == null ? null : start.copy();
662        dst.end = end == null ? null : end.copy();
663        dst.overbooked = overbooked == null ? null : overbooked.copy();
664        dst.comment = comment == null ? null : comment.copy();
665        return dst;
666      }
667
668      protected Slot typedCopy() {
669        return copy();
670      }
671
672      @Override
673      public boolean equalsDeep(Base other) {
674        if (!super.equalsDeep(other))
675          return false;
676        if (!(other instanceof Slot))
677          return false;
678        Slot o = (Slot) other;
679        return compareDeep(identifier, o.identifier, true) && compareDeep(type, o.type, true) && compareDeep(schedule, o.schedule, true)
680           && compareDeep(freeBusyType, o.freeBusyType, true) && compareDeep(start, o.start, true) && compareDeep(end, o.end, true)
681           && compareDeep(overbooked, o.overbooked, true) && compareDeep(comment, o.comment, true);
682      }
683
684      @Override
685      public boolean equalsShallow(Base other) {
686        if (!super.equalsShallow(other))
687          return false;
688        if (!(other instanceof Slot))
689          return false;
690        Slot o = (Slot) other;
691        return compareValues(freeBusyType, o.freeBusyType, true) && compareValues(start, o.start, true) && compareValues(end, o.end, true)
692           && compareValues(overbooked, o.overbooked, true) && compareValues(comment, o.comment, true);
693      }
694
695      public boolean isEmpty() {
696        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (type == null || type.isEmpty())
697           && (schedule == null || schedule.isEmpty()) && (freeBusyType == null || freeBusyType.isEmpty())
698           && (start == null || start.isEmpty()) && (end == null || end.isEmpty()) && (overbooked == null || overbooked.isEmpty())
699           && (comment == null || comment.isEmpty());
700      }
701
702  @Override
703  public ResourceType getResourceType() {
704    return ResourceType.Slot;
705   }
706
707  @SearchParamDefinition(name="schedule", path="Slot.schedule", description="The Schedule Resource that we are seeking a slot within", type="reference" )
708  public static final String SP_SCHEDULE = "schedule";
709  @SearchParamDefinition(name="identifier", path="Slot.identifier", description="A Slot Identifier", type="token" )
710  public static final String SP_IDENTIFIER = "identifier";
711  @SearchParamDefinition(name="start", path="Slot.start", description="Appointment date/time.", type="date" )
712  public static final String SP_START = "start";
713  @SearchParamDefinition(name="slot-type", path="Slot.type", description="The type of appointments that can be booked into the slot", type="token" )
714  public static final String SP_SLOTTYPE = "slot-type";
715  @SearchParamDefinition(name="fb-type", path="Slot.freeBusyType", description="The free/busy status of the appointment", type="token" )
716  public static final String SP_FBTYPE = "fb-type";
717
718}
719