001package org.hl7.fhir.dstu2.model;
002
003
004
005
006/*
007  Copyright (c) 2011+, HL7, Inc.
008  All rights reserved.
009  
010  Redistribution and use in source and binary forms, with or without modification, 
011  are permitted provided that the following conditions are met:
012  
013   * Redistributions of source code must retain the above copyright notice, this 
014     list of conditions and the following disclaimer.
015   * Redistributions in binary form must reproduce the above copyright notice, 
016     this list of conditions and the following disclaimer in the documentation 
017     and/or other materials provided with the distribution.
018   * Neither the name of HL7 nor the names of its contributors may be used to 
019     endorse or promote products derived from this software without specific 
020     prior written permission.
021  
022  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
023  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
024  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
025  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
026  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
027  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
028  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
029  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
030  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
031  POSSIBILITY OF SUCH DAMAGE.
032  
033*/
034
035// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
036import java.util.ArrayList;
037import java.util.List;
038
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.Description;
041import ca.uhn.fhir.model.api.annotation.ResourceDef;
042import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
043import org.hl7.fhir.exceptions.FHIRException;
044import org.hl7.fhir.utilities.Utilities;
045/**
046 * A container for slot(s) of time that may be available for booking appointments.
047 */
048@ResourceDef(name="Schedule", profile="http://hl7.org/fhir/Profile/Schedule")
049public class Schedule extends DomainResource {
050
051    /**
052     * External Ids for this item.
053     */
054    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
055    @Description(shortDefinition="External Ids for this item", formalDefinition="External Ids for this item." )
056    protected List<Identifier> identifier;
057
058    /**
059     * The schedule type can be used for the categorization of healthcare services or other appointment types.
060     */
061    @Child(name = "type", type = {CodeableConcept.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
062    @Description(shortDefinition="The schedule type can be used for the categorization of healthcare services or other appointment types", formalDefinition="The schedule type can be used for the categorization of healthcare services or other appointment types." )
063    protected List<CodeableConcept> type;
064
065    /**
066     * The resource this Schedule resource is providing availability information for. These are expected to usually be one of HealthcareService, Location, Practitioner, Device, Patient or RelatedPerson.
067     */
068    @Child(name = "actor", type = {Patient.class, Practitioner.class, RelatedPerson.class, Device.class, HealthcareService.class, Location.class}, order=2, min=1, max=1, modifier=false, summary=true)
069    @Description(shortDefinition="The resource this Schedule resource is providing availability information for. These are expected to usually be one of HealthcareService, Location, Practitioner, Device, Patient or RelatedPerson", formalDefinition="The resource this Schedule resource is providing availability information for. These are expected to usually be one of HealthcareService, Location, Practitioner, Device, Patient or RelatedPerson." )
070    protected Reference actor;
071
072    /**
073     * The actual object that is the target of the reference (The resource this Schedule resource is providing availability information for. These are expected to usually be one of HealthcareService, Location, Practitioner, Device, Patient or RelatedPerson.)
074     */
075    protected Resource actorTarget;
076
077    /**
078     * The period of time that the slots that are attached to this Schedule resource cover (even if none exist). These  cover the amount of time that an organization's planning horizon; the interval for which they are currently accepting appointments. This does not define a "template" for planning outside these dates.
079     */
080    @Child(name = "planningHorizon", type = {Period.class}, order=3, min=0, max=1, modifier=false, summary=true)
081    @Description(shortDefinition="The period of time that the slots that are attached to this Schedule resource cover (even if none exist). These  cover the amount of time that an organization's planning horizon; the interval for which they are currently accepting appointments. This does not define a \"template\" for planning outside these dates", formalDefinition="The period of time that the slots that are attached to this Schedule resource cover (even if none exist). These  cover the amount of time that an organization's planning horizon; the interval for which they are currently accepting appointments. This does not define a \"template\" for planning outside these dates." )
082    protected Period planningHorizon;
083
084    /**
085     * Comments on the availability to describe any extended information. Such as custom constraints on the slot(s) that may be associated.
086     */
087    @Child(name = "comment", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=false)
088    @Description(shortDefinition="Comments on the availability to describe any extended information. Such as custom constraints on the slot(s) that may be associated", formalDefinition="Comments on the availability to describe any extended information. Such as custom constraints on the slot(s) that may be associated." )
089    protected StringType comment;
090
091    private static final long serialVersionUID = 158030926L;
092
093  /*
094   * Constructor
095   */
096    public Schedule() {
097      super();
098    }
099
100  /*
101   * Constructor
102   */
103    public Schedule(Reference actor) {
104      super();
105      this.actor = actor;
106    }
107
108    /**
109     * @return {@link #identifier} (External Ids for this item.)
110     */
111    public List<Identifier> getIdentifier() { 
112      if (this.identifier == null)
113        this.identifier = new ArrayList<Identifier>();
114      return this.identifier;
115    }
116
117    public boolean hasIdentifier() { 
118      if (this.identifier == null)
119        return false;
120      for (Identifier item : this.identifier)
121        if (!item.isEmpty())
122          return true;
123      return false;
124    }
125
126    /**
127     * @return {@link #identifier} (External Ids for this item.)
128     */
129    // syntactic sugar
130    public Identifier addIdentifier() { //3
131      Identifier t = new Identifier();
132      if (this.identifier == null)
133        this.identifier = new ArrayList<Identifier>();
134      this.identifier.add(t);
135      return t;
136    }
137
138    // syntactic sugar
139    public Schedule addIdentifier(Identifier t) { //3
140      if (t == null)
141        return this;
142      if (this.identifier == null)
143        this.identifier = new ArrayList<Identifier>();
144      this.identifier.add(t);
145      return this;
146    }
147
148    /**
149     * @return {@link #type} (The schedule type can be used for the categorization of healthcare services or other appointment types.)
150     */
151    public List<CodeableConcept> getType() { 
152      if (this.type == null)
153        this.type = new ArrayList<CodeableConcept>();
154      return this.type;
155    }
156
157    public boolean hasType() { 
158      if (this.type == null)
159        return false;
160      for (CodeableConcept item : this.type)
161        if (!item.isEmpty())
162          return true;
163      return false;
164    }
165
166    /**
167     * @return {@link #type} (The schedule type can be used for the categorization of healthcare services or other appointment types.)
168     */
169    // syntactic sugar
170    public CodeableConcept addType() { //3
171      CodeableConcept t = new CodeableConcept();
172      if (this.type == null)
173        this.type = new ArrayList<CodeableConcept>();
174      this.type.add(t);
175      return t;
176    }
177
178    // syntactic sugar
179    public Schedule addType(CodeableConcept t) { //3
180      if (t == null)
181        return this;
182      if (this.type == null)
183        this.type = new ArrayList<CodeableConcept>();
184      this.type.add(t);
185      return this;
186    }
187
188    /**
189     * @return {@link #actor} (The resource this Schedule resource is providing availability information for. These are expected to usually be one of HealthcareService, Location, Practitioner, Device, Patient or RelatedPerson.)
190     */
191    public Reference getActor() { 
192      if (this.actor == null)
193        if (Configuration.errorOnAutoCreate())
194          throw new Error("Attempt to auto-create Schedule.actor");
195        else if (Configuration.doAutoCreate())
196          this.actor = new Reference(); // cc
197      return this.actor;
198    }
199
200    public boolean hasActor() { 
201      return this.actor != null && !this.actor.isEmpty();
202    }
203
204    /**
205     * @param value {@link #actor} (The resource this Schedule resource is providing availability information for. These are expected to usually be one of HealthcareService, Location, Practitioner, Device, Patient or RelatedPerson.)
206     */
207    public Schedule setActor(Reference value) { 
208      this.actor = value;
209      return this;
210    }
211
212    /**
213     * @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. (The resource this Schedule resource is providing availability information for. These are expected to usually be one of HealthcareService, Location, Practitioner, Device, Patient or RelatedPerson.)
214     */
215    public Resource getActorTarget() { 
216      return this.actorTarget;
217    }
218
219    /**
220     * @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. (The resource this Schedule resource is providing availability information for. These are expected to usually be one of HealthcareService, Location, Practitioner, Device, Patient or RelatedPerson.)
221     */
222    public Schedule setActorTarget(Resource value) { 
223      this.actorTarget = value;
224      return this;
225    }
226
227    /**
228     * @return {@link #planningHorizon} (The period of time that the slots that are attached to this Schedule resource cover (even if none exist). These  cover the amount of time that an organization's planning horizon; the interval for which they are currently accepting appointments. This does not define a "template" for planning outside these dates.)
229     */
230    public Period getPlanningHorizon() { 
231      if (this.planningHorizon == null)
232        if (Configuration.errorOnAutoCreate())
233          throw new Error("Attempt to auto-create Schedule.planningHorizon");
234        else if (Configuration.doAutoCreate())
235          this.planningHorizon = new Period(); // cc
236      return this.planningHorizon;
237    }
238
239    public boolean hasPlanningHorizon() { 
240      return this.planningHorizon != null && !this.planningHorizon.isEmpty();
241    }
242
243    /**
244     * @param value {@link #planningHorizon} (The period of time that the slots that are attached to this Schedule resource cover (even if none exist). These  cover the amount of time that an organization's planning horizon; the interval for which they are currently accepting appointments. This does not define a "template" for planning outside these dates.)
245     */
246    public Schedule setPlanningHorizon(Period value) { 
247      this.planningHorizon = value;
248      return this;
249    }
250
251    /**
252     * @return {@link #comment} (Comments on the availability to describe any extended information. Such as custom constraints on the slot(s) that may be associated.). This is the underlying object with id, value and extensions. The accessor "getComment" gives direct access to the value
253     */
254    public StringType getCommentElement() { 
255      if (this.comment == null)
256        if (Configuration.errorOnAutoCreate())
257          throw new Error("Attempt to auto-create Schedule.comment");
258        else if (Configuration.doAutoCreate())
259          this.comment = new StringType(); // bb
260      return this.comment;
261    }
262
263    public boolean hasCommentElement() { 
264      return this.comment != null && !this.comment.isEmpty();
265    }
266
267    public boolean hasComment() { 
268      return this.comment != null && !this.comment.isEmpty();
269    }
270
271    /**
272     * @param value {@link #comment} (Comments on the availability to describe any extended information. Such as custom constraints on the slot(s) that may be associated.). This is the underlying object with id, value and extensions. The accessor "getComment" gives direct access to the value
273     */
274    public Schedule setCommentElement(StringType value) { 
275      this.comment = value;
276      return this;
277    }
278
279    /**
280     * @return Comments on the availability to describe any extended information. Such as custom constraints on the slot(s) that may be associated.
281     */
282    public String getComment() { 
283      return this.comment == null ? null : this.comment.getValue();
284    }
285
286    /**
287     * @param value Comments on the availability to describe any extended information. Such as custom constraints on the slot(s) that may be associated.
288     */
289    public Schedule setComment(String value) { 
290      if (Utilities.noString(value))
291        this.comment = null;
292      else {
293        if (this.comment == null)
294          this.comment = new StringType();
295        this.comment.setValue(value);
296      }
297      return this;
298    }
299
300      protected void listChildren(List<Property> childrenList) {
301        super.listChildren(childrenList);
302        childrenList.add(new Property("identifier", "Identifier", "External Ids for this item.", 0, java.lang.Integer.MAX_VALUE, identifier));
303        childrenList.add(new Property("type", "CodeableConcept", "The schedule type can be used for the categorization of healthcare services or other appointment types.", 0, java.lang.Integer.MAX_VALUE, type));
304        childrenList.add(new Property("actor", "Reference(Patient|Practitioner|RelatedPerson|Device|HealthcareService|Location)", "The resource this Schedule resource is providing availability information for. These are expected to usually be one of HealthcareService, Location, Practitioner, Device, Patient or RelatedPerson.", 0, java.lang.Integer.MAX_VALUE, actor));
305        childrenList.add(new Property("planningHorizon", "Period", "The period of time that the slots that are attached to this Schedule resource cover (even if none exist). These  cover the amount of time that an organization's planning horizon; the interval for which they are currently accepting appointments. This does not define a \"template\" for planning outside these dates.", 0, java.lang.Integer.MAX_VALUE, planningHorizon));
306        childrenList.add(new Property("comment", "string", "Comments on the availability to describe any extended information. Such as custom constraints on the slot(s) that may be associated.", 0, java.lang.Integer.MAX_VALUE, comment));
307      }
308
309      @Override
310      public void setProperty(String name, Base value) throws FHIRException {
311        if (name.equals("identifier"))
312          this.getIdentifier().add(castToIdentifier(value));
313        else if (name.equals("type"))
314          this.getType().add(castToCodeableConcept(value));
315        else if (name.equals("actor"))
316          this.actor = castToReference(value); // Reference
317        else if (name.equals("planningHorizon"))
318          this.planningHorizon = castToPeriod(value); // Period
319        else if (name.equals("comment"))
320          this.comment = castToString(value); // StringType
321        else
322          super.setProperty(name, value);
323      }
324
325      @Override
326      public Base addChild(String name) throws FHIRException {
327        if (name.equals("identifier")) {
328          return addIdentifier();
329        }
330        else if (name.equals("type")) {
331          return addType();
332        }
333        else if (name.equals("actor")) {
334          this.actor = new Reference();
335          return this.actor;
336        }
337        else if (name.equals("planningHorizon")) {
338          this.planningHorizon = new Period();
339          return this.planningHorizon;
340        }
341        else if (name.equals("comment")) {
342          throw new FHIRException("Cannot call addChild on a primitive type Schedule.comment");
343        }
344        else
345          return super.addChild(name);
346      }
347
348  public String fhirType() {
349    return "Schedule";
350
351  }
352
353      public Schedule copy() {
354        Schedule dst = new Schedule();
355        copyValues(dst);
356        if (identifier != null) {
357          dst.identifier = new ArrayList<Identifier>();
358          for (Identifier i : identifier)
359            dst.identifier.add(i.copy());
360        };
361        if (type != null) {
362          dst.type = new ArrayList<CodeableConcept>();
363          for (CodeableConcept i : type)
364            dst.type.add(i.copy());
365        };
366        dst.actor = actor == null ? null : actor.copy();
367        dst.planningHorizon = planningHorizon == null ? null : planningHorizon.copy();
368        dst.comment = comment == null ? null : comment.copy();
369        return dst;
370      }
371
372      protected Schedule typedCopy() {
373        return copy();
374      }
375
376      @Override
377      public boolean equalsDeep(Base other) {
378        if (!super.equalsDeep(other))
379          return false;
380        if (!(other instanceof Schedule))
381          return false;
382        Schedule o = (Schedule) other;
383        return compareDeep(identifier, o.identifier, true) && compareDeep(type, o.type, true) && compareDeep(actor, o.actor, true)
384           && compareDeep(planningHorizon, o.planningHorizon, true) && compareDeep(comment, o.comment, true)
385          ;
386      }
387
388      @Override
389      public boolean equalsShallow(Base other) {
390        if (!super.equalsShallow(other))
391          return false;
392        if (!(other instanceof Schedule))
393          return false;
394        Schedule o = (Schedule) other;
395        return compareValues(comment, o.comment, true);
396      }
397
398      public boolean isEmpty() {
399        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (type == null || type.isEmpty())
400           && (actor == null || actor.isEmpty()) && (planningHorizon == null || planningHorizon.isEmpty())
401           && (comment == null || comment.isEmpty());
402      }
403
404  @Override
405  public ResourceType getResourceType() {
406    return ResourceType.Schedule;
407   }
408
409  @SearchParamDefinition(name="actor", path="Schedule.actor", description="The individual(HealthcareService, Practitioner, Location, ...) to find a Schedule for", type="reference" )
410  public static final String SP_ACTOR = "actor";
411  @SearchParamDefinition(name="date", path="Schedule.planningHorizon", description="Search for Schedule resources that have a period that contains this date specified", type="date" )
412  public static final String SP_DATE = "date";
413  @SearchParamDefinition(name="identifier", path="Schedule.identifier", description="A Schedule Identifier", type="token" )
414  public static final String SP_IDENTIFIER = "identifier";
415  @SearchParamDefinition(name="type", path="Schedule.type", description="The type of appointments that can be booked into associated slot(s)", type="token" )
416  public static final String SP_TYPE = "type";
417
418}