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