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.ArrayList; 034import java.util.List; 035 036import org.hl7.fhir.exceptions.FHIRException; 037import org.hl7.fhir.utilities.Utilities; 038 039import ca.uhn.fhir.model.api.annotation.*; 040/** 041 * A container for slot(s) of time that may be available for booking appointments. 042 */ 043@ResourceDef(name="Schedule", profile="http://hl7.org/fhir/Profile/Schedule") 044public class Schedule extends DomainResource { 045 046 /** 047 * External Ids for this item. 048 */ 049 @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 050 @Description(shortDefinition="External Ids for this item", formalDefinition="External Ids for this item." ) 051 protected List<Identifier> identifier; 052 053 /** 054 * The schedule type can be used for the categorization of healthcare services or other appointment types. 055 */ 056 @Child(name = "type", type = {CodeableConcept.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 057 @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." ) 058 protected List<CodeableConcept> type; 059 060 /** 061 * 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. 062 */ 063 @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) 064 @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." ) 065 protected Reference actor; 066 067 /** 068 * 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.) 069 */ 070 protected Resource actorTarget; 071 072 /** 073 * 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. 074 */ 075 @Child(name = "planningHorizon", type = {Period.class}, order=3, min=0, max=1, modifier=false, summary=true) 076 @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." ) 077 protected Period planningHorizon; 078 079 /** 080 * Comments on the availability to describe any extended information. Such as custom constraints on the slot(s) that may be associated. 081 */ 082 @Child(name = "comment", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=false) 083 @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." ) 084 protected StringType comment; 085 086 private static final long serialVersionUID = 158030926L; 087 088 /* 089 * Constructor 090 */ 091 public Schedule() { 092 super(); 093 } 094 095 /* 096 * Constructor 097 */ 098 public Schedule(Reference actor) { 099 super(); 100 this.actor = actor; 101 } 102 103 /** 104 * @return {@link #identifier} (External Ids for this item.) 105 */ 106 public List<Identifier> getIdentifier() { 107 if (this.identifier == null) 108 this.identifier = new ArrayList<Identifier>(); 109 return this.identifier; 110 } 111 112 public boolean hasIdentifier() { 113 if (this.identifier == null) 114 return false; 115 for (Identifier item : this.identifier) 116 if (!item.isEmpty()) 117 return true; 118 return false; 119 } 120 121 /** 122 * @return {@link #identifier} (External Ids for this item.) 123 */ 124 // syntactic sugar 125 public Identifier addIdentifier() { //3 126 Identifier t = new Identifier(); 127 if (this.identifier == null) 128 this.identifier = new ArrayList<Identifier>(); 129 this.identifier.add(t); 130 return t; 131 } 132 133 // syntactic sugar 134 public Schedule addIdentifier(Identifier t) { //3 135 if (t == null) 136 return this; 137 if (this.identifier == null) 138 this.identifier = new ArrayList<Identifier>(); 139 this.identifier.add(t); 140 return this; 141 } 142 143 /** 144 * @return {@link #type} (The schedule type can be used for the categorization of healthcare services or other appointment types.) 145 */ 146 public List<CodeableConcept> getType() { 147 if (this.type == null) 148 this.type = new ArrayList<CodeableConcept>(); 149 return this.type; 150 } 151 152 public boolean hasType() { 153 if (this.type == null) 154 return false; 155 for (CodeableConcept item : this.type) 156 if (!item.isEmpty()) 157 return true; 158 return false; 159 } 160 161 /** 162 * @return {@link #type} (The schedule type can be used for the categorization of healthcare services or other appointment types.) 163 */ 164 // syntactic sugar 165 public CodeableConcept addType() { //3 166 CodeableConcept t = new CodeableConcept(); 167 if (this.type == null) 168 this.type = new ArrayList<CodeableConcept>(); 169 this.type.add(t); 170 return t; 171 } 172 173 // syntactic sugar 174 public Schedule addType(CodeableConcept t) { //3 175 if (t == null) 176 return this; 177 if (this.type == null) 178 this.type = new ArrayList<CodeableConcept>(); 179 this.type.add(t); 180 return this; 181 } 182 183 /** 184 * @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.) 185 */ 186 public Reference getActor() { 187 if (this.actor == null) 188 if (Configuration.errorOnAutoCreate()) 189 throw new Error("Attempt to auto-create Schedule.actor"); 190 else if (Configuration.doAutoCreate()) 191 this.actor = new Reference(); // cc 192 return this.actor; 193 } 194 195 public boolean hasActor() { 196 return this.actor != null && !this.actor.isEmpty(); 197 } 198 199 /** 200 * @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.) 201 */ 202 public Schedule setActor(Reference value) { 203 this.actor = value; 204 return this; 205 } 206 207 /** 208 * @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.) 209 */ 210 public Resource getActorTarget() { 211 return this.actorTarget; 212 } 213 214 /** 215 * @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.) 216 */ 217 public Schedule setActorTarget(Resource value) { 218 this.actorTarget = value; 219 return this; 220 } 221 222 /** 223 * @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.) 224 */ 225 public Period getPlanningHorizon() { 226 if (this.planningHorizon == null) 227 if (Configuration.errorOnAutoCreate()) 228 throw new Error("Attempt to auto-create Schedule.planningHorizon"); 229 else if (Configuration.doAutoCreate()) 230 this.planningHorizon = new Period(); // cc 231 return this.planningHorizon; 232 } 233 234 public boolean hasPlanningHorizon() { 235 return this.planningHorizon != null && !this.planningHorizon.isEmpty(); 236 } 237 238 /** 239 * @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.) 240 */ 241 public Schedule setPlanningHorizon(Period value) { 242 this.planningHorizon = value; 243 return this; 244 } 245 246 /** 247 * @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 248 */ 249 public StringType getCommentElement() { 250 if (this.comment == null) 251 if (Configuration.errorOnAutoCreate()) 252 throw new Error("Attempt to auto-create Schedule.comment"); 253 else if (Configuration.doAutoCreate()) 254 this.comment = new StringType(); // bb 255 return this.comment; 256 } 257 258 public boolean hasCommentElement() { 259 return this.comment != null && !this.comment.isEmpty(); 260 } 261 262 public boolean hasComment() { 263 return this.comment != null && !this.comment.isEmpty(); 264 } 265 266 /** 267 * @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 268 */ 269 public Schedule setCommentElement(StringType value) { 270 this.comment = value; 271 return this; 272 } 273 274 /** 275 * @return Comments on the availability to describe any extended information. Such as custom constraints on the slot(s) that may be associated. 276 */ 277 public String getComment() { 278 return this.comment == null ? null : this.comment.getValue(); 279 } 280 281 /** 282 * @param value Comments on the availability to describe any extended information. Such as custom constraints on the slot(s) that may be associated. 283 */ 284 public Schedule setComment(String value) { 285 if (Utilities.noString(value)) 286 this.comment = null; 287 else { 288 if (this.comment == null) 289 this.comment = new StringType(); 290 this.comment.setValue(value); 291 } 292 return this; 293 } 294 295 protected void listChildren(List<Property> childrenList) { 296 super.listChildren(childrenList); 297 childrenList.add(new Property("identifier", "Identifier", "External Ids for this item.", 0, java.lang.Integer.MAX_VALUE, identifier)); 298 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)); 299 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)); 300 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)); 301 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)); 302 } 303 304 @Override 305 public void setProperty(String name, Base value) throws FHIRException { 306 if (name.equals("identifier")) 307 this.getIdentifier().add(castToIdentifier(value)); 308 else if (name.equals("type")) 309 this.getType().add(castToCodeableConcept(value)); 310 else if (name.equals("actor")) 311 this.actor = castToReference(value); // Reference 312 else if (name.equals("planningHorizon")) 313 this.planningHorizon = castToPeriod(value); // Period 314 else if (name.equals("comment")) 315 this.comment = castToString(value); // StringType 316 else 317 super.setProperty(name, value); 318 } 319 320 @Override 321 public Base addChild(String name) throws FHIRException { 322 if (name.equals("identifier")) { 323 return addIdentifier(); 324 } 325 else if (name.equals("type")) { 326 return addType(); 327 } 328 else if (name.equals("actor")) { 329 this.actor = new Reference(); 330 return this.actor; 331 } 332 else if (name.equals("planningHorizon")) { 333 this.planningHorizon = new Period(); 334 return this.planningHorizon; 335 } 336 else if (name.equals("comment")) { 337 throw new FHIRException("Cannot call addChild on a primitive type Schedule.comment"); 338 } 339 else 340 return super.addChild(name); 341 } 342 343 public String fhirType() { 344 return "Schedule"; 345 346 } 347 348 public Schedule copy() { 349 Schedule dst = new Schedule(); 350 copyValues(dst); 351 if (identifier != null) { 352 dst.identifier = new ArrayList<Identifier>(); 353 for (Identifier i : identifier) 354 dst.identifier.add(i.copy()); 355 }; 356 if (type != null) { 357 dst.type = new ArrayList<CodeableConcept>(); 358 for (CodeableConcept i : type) 359 dst.type.add(i.copy()); 360 }; 361 dst.actor = actor == null ? null : actor.copy(); 362 dst.planningHorizon = planningHorizon == null ? null : planningHorizon.copy(); 363 dst.comment = comment == null ? null : comment.copy(); 364 return dst; 365 } 366 367 protected Schedule typedCopy() { 368 return copy(); 369 } 370 371 @Override 372 public boolean equalsDeep(Base other) { 373 if (!super.equalsDeep(other)) 374 return false; 375 if (!(other instanceof Schedule)) 376 return false; 377 Schedule o = (Schedule) other; 378 return compareDeep(identifier, o.identifier, true) && compareDeep(type, o.type, true) && compareDeep(actor, o.actor, true) 379 && compareDeep(planningHorizon, o.planningHorizon, true) && compareDeep(comment, o.comment, true) 380 ; 381 } 382 383 @Override 384 public boolean equalsShallow(Base other) { 385 if (!super.equalsShallow(other)) 386 return false; 387 if (!(other instanceof Schedule)) 388 return false; 389 Schedule o = (Schedule) other; 390 return compareValues(comment, o.comment, true); 391 } 392 393 public boolean isEmpty() { 394 return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (type == null || type.isEmpty()) 395 && (actor == null || actor.isEmpty()) && (planningHorizon == null || planningHorizon.isEmpty()) 396 && (comment == null || comment.isEmpty()); 397 } 398 399 @Override 400 public ResourceType getResourceType() { 401 return ResourceType.Schedule; 402 } 403 404 @SearchParamDefinition(name="actor", path="Schedule.actor", description="The individual(HealthcareService, Practitioner, Location, ...) to find a Schedule for", type="reference" ) 405 public static final String SP_ACTOR = "actor"; 406 @SearchParamDefinition(name="date", path="Schedule.planningHorizon", description="Search for Schedule resources that have a period that contains this date specified", type="date" ) 407 public static final String SP_DATE = "date"; 408 @SearchParamDefinition(name="identifier", path="Schedule.identifier", description="A Schedule Identifier", type="token" ) 409 public static final String SP_IDENTIFIER = "identifier"; 410 @SearchParamDefinition(name="type", path="Schedule.type", description="The type of appointments that can be booked into associated slot(s)", type="token" ) 411 public static final String SP_TYPE = "type"; 412 413} 414