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.instance.model.api.IBaseBackboneElement; 037import org.hl7.fhir.utilities.Utilities; 038 039import ca.uhn.fhir.model.api.annotation.*; 040/** 041 * The subscription resource is used to define a push based subscription from a server to another system. Once a subscription is registered with the server, the server checks every resource that is created or updated, and if the resource matches the given criteria, it sends a message on the defined "channel" so that another system is able to take an appropriate action. 042 */ 043@ResourceDef(name="Subscription", profile="http://hl7.org/fhir/Profile/Subscription") 044public class Subscription extends DomainResource { 045 046 public enum SubscriptionStatus { 047 /** 048 * The client has requested the subscription, and the server has not yet set it up. 049 */ 050 REQUESTED, 051 /** 052 * The subscription is active. 053 */ 054 ACTIVE, 055 /** 056 * The server has an error executing the notification. 057 */ 058 ERROR, 059 /** 060 * Too many errors have occurred or the subscription has expired. 061 */ 062 OFF, 063 /** 064 * added to help the parsers 065 */ 066 NULL; 067 public static SubscriptionStatus fromCode(String codeString) throws FHIRException { 068 if (codeString == null || "".equals(codeString)) 069 return null; 070 if ("requested".equals(codeString)) 071 return REQUESTED; 072 if ("active".equals(codeString)) 073 return ACTIVE; 074 if ("error".equals(codeString)) 075 return ERROR; 076 if ("off".equals(codeString)) 077 return OFF; 078 throw new FHIRException("Unknown SubscriptionStatus code '"+codeString+"'"); 079 } 080 public String toCode() { 081 switch (this) { 082 case REQUESTED: return "requested"; 083 case ACTIVE: return "active"; 084 case ERROR: return "error"; 085 case OFF: return "off"; 086 default: return "?"; 087 } 088 } 089 public String getSystem() { 090 switch (this) { 091 case REQUESTED: return "http://hl7.org/fhir/subscription-status"; 092 case ACTIVE: return "http://hl7.org/fhir/subscription-status"; 093 case ERROR: return "http://hl7.org/fhir/subscription-status"; 094 case OFF: return "http://hl7.org/fhir/subscription-status"; 095 default: return "?"; 096 } 097 } 098 public String getDefinition() { 099 switch (this) { 100 case REQUESTED: return "The client has requested the subscription, and the server has not yet set it up."; 101 case ACTIVE: return "The subscription is active."; 102 case ERROR: return "The server has an error executing the notification."; 103 case OFF: return "Too many errors have occurred or the subscription has expired."; 104 default: return "?"; 105 } 106 } 107 public String getDisplay() { 108 switch (this) { 109 case REQUESTED: return "Requested"; 110 case ACTIVE: return "Active"; 111 case ERROR: return "Error"; 112 case OFF: return "Off"; 113 default: return "?"; 114 } 115 } 116 } 117 118 public static class SubscriptionStatusEnumFactory implements EnumFactory<SubscriptionStatus> { 119 public SubscriptionStatus fromCode(String codeString) throws IllegalArgumentException { 120 if (codeString == null || "".equals(codeString)) 121 if (codeString == null || "".equals(codeString)) 122 return null; 123 if ("requested".equals(codeString)) 124 return SubscriptionStatus.REQUESTED; 125 if ("active".equals(codeString)) 126 return SubscriptionStatus.ACTIVE; 127 if ("error".equals(codeString)) 128 return SubscriptionStatus.ERROR; 129 if ("off".equals(codeString)) 130 return SubscriptionStatus.OFF; 131 throw new IllegalArgumentException("Unknown SubscriptionStatus code '"+codeString+"'"); 132 } 133 public Enumeration<SubscriptionStatus> fromType(Base code) throws FHIRException { 134 if (code == null || code.isEmpty()) 135 return null; 136 String codeString = ((PrimitiveType) code).asStringValue(); 137 if (codeString == null || "".equals(codeString)) 138 return null; 139 if ("requested".equals(codeString)) 140 return new Enumeration<SubscriptionStatus>(this, SubscriptionStatus.REQUESTED); 141 if ("active".equals(codeString)) 142 return new Enumeration<SubscriptionStatus>(this, SubscriptionStatus.ACTIVE); 143 if ("error".equals(codeString)) 144 return new Enumeration<SubscriptionStatus>(this, SubscriptionStatus.ERROR); 145 if ("off".equals(codeString)) 146 return new Enumeration<SubscriptionStatus>(this, SubscriptionStatus.OFF); 147 throw new FHIRException("Unknown SubscriptionStatus code '"+codeString+"'"); 148 } 149 public String toCode(SubscriptionStatus code) { 150 if (code == SubscriptionStatus.REQUESTED) 151 return "requested"; 152 if (code == SubscriptionStatus.ACTIVE) 153 return "active"; 154 if (code == SubscriptionStatus.ERROR) 155 return "error"; 156 if (code == SubscriptionStatus.OFF) 157 return "off"; 158 return "?"; 159 } 160 } 161 162 public enum SubscriptionChannelType { 163 /** 164 * The channel is executed by making a post to the URI. If a payload is included, the URL is interpreted as the service base, and an update (PUT) is made. 165 */ 166 RESTHOOK, 167 /** 168 * The channel is executed by sending a packet across a web socket connection maintained by the client. The URL identifies the websocket, and the client binds to this URL. 169 */ 170 WEBSOCKET, 171 /** 172 * The channel is executed by sending an email to the email addressed in the URI (which must be a mailto:). 173 */ 174 EMAIL, 175 /** 176 * The channel is executed by sending an SMS message to the phone number identified in the URL (tel:). 177 */ 178 SMS, 179 /** 180 * The channel is executed by sending a message (e.g. a Bundle with a MessageHeader resource etc.) to the application identified in the URI. 181 */ 182 MESSAGE, 183 /** 184 * added to help the parsers 185 */ 186 NULL; 187 public static SubscriptionChannelType fromCode(String codeString) throws FHIRException { 188 if (codeString == null || "".equals(codeString)) 189 return null; 190 if ("rest-hook".equals(codeString)) 191 return RESTHOOK; 192 if ("websocket".equals(codeString)) 193 return WEBSOCKET; 194 if ("email".equals(codeString)) 195 return EMAIL; 196 if ("sms".equals(codeString)) 197 return SMS; 198 if ("message".equals(codeString)) 199 return MESSAGE; 200 throw new FHIRException("Unknown SubscriptionChannelType code '"+codeString+"'"); 201 } 202 public String toCode() { 203 switch (this) { 204 case RESTHOOK: return "rest-hook"; 205 case WEBSOCKET: return "websocket"; 206 case EMAIL: return "email"; 207 case SMS: return "sms"; 208 case MESSAGE: return "message"; 209 default: return "?"; 210 } 211 } 212 public String getSystem() { 213 switch (this) { 214 case RESTHOOK: return "http://hl7.org/fhir/subscription-channel-type"; 215 case WEBSOCKET: return "http://hl7.org/fhir/subscription-channel-type"; 216 case EMAIL: return "http://hl7.org/fhir/subscription-channel-type"; 217 case SMS: return "http://hl7.org/fhir/subscription-channel-type"; 218 case MESSAGE: return "http://hl7.org/fhir/subscription-channel-type"; 219 default: return "?"; 220 } 221 } 222 public String getDefinition() { 223 switch (this) { 224 case RESTHOOK: return "The channel is executed by making a post to the URI. If a payload is included, the URL is interpreted as the service base, and an update (PUT) is made."; 225 case WEBSOCKET: return "The channel is executed by sending a packet across a web socket connection maintained by the client. The URL identifies the websocket, and the client binds to this URL."; 226 case EMAIL: return "The channel is executed by sending an email to the email addressed in the URI (which must be a mailto:)."; 227 case SMS: return "The channel is executed by sending an SMS message to the phone number identified in the URL (tel:)."; 228 case MESSAGE: return "The channel is executed by sending a message (e.g. a Bundle with a MessageHeader resource etc.) to the application identified in the URI."; 229 default: return "?"; 230 } 231 } 232 public String getDisplay() { 233 switch (this) { 234 case RESTHOOK: return "Rest Hook"; 235 case WEBSOCKET: return "Websocket"; 236 case EMAIL: return "Email"; 237 case SMS: return "SMS"; 238 case MESSAGE: return "Message"; 239 default: return "?"; 240 } 241 } 242 } 243 244 public static class SubscriptionChannelTypeEnumFactory implements EnumFactory<SubscriptionChannelType> { 245 public SubscriptionChannelType fromCode(String codeString) throws IllegalArgumentException { 246 if (codeString == null || "".equals(codeString)) 247 if (codeString == null || "".equals(codeString)) 248 return null; 249 if ("rest-hook".equals(codeString)) 250 return SubscriptionChannelType.RESTHOOK; 251 if ("websocket".equals(codeString)) 252 return SubscriptionChannelType.WEBSOCKET; 253 if ("email".equals(codeString)) 254 return SubscriptionChannelType.EMAIL; 255 if ("sms".equals(codeString)) 256 return SubscriptionChannelType.SMS; 257 if ("message".equals(codeString)) 258 return SubscriptionChannelType.MESSAGE; 259 throw new IllegalArgumentException("Unknown SubscriptionChannelType code '"+codeString+"'"); 260 } 261 public Enumeration<SubscriptionChannelType> fromType(Base code) throws FHIRException { 262 if (code == null || code.isEmpty()) 263 return null; 264 String codeString = ((PrimitiveType) code).asStringValue(); 265 if (codeString == null || "".equals(codeString)) 266 return null; 267 if ("rest-hook".equals(codeString)) 268 return new Enumeration<SubscriptionChannelType>(this, SubscriptionChannelType.RESTHOOK); 269 if ("websocket".equals(codeString)) 270 return new Enumeration<SubscriptionChannelType>(this, SubscriptionChannelType.WEBSOCKET); 271 if ("email".equals(codeString)) 272 return new Enumeration<SubscriptionChannelType>(this, SubscriptionChannelType.EMAIL); 273 if ("sms".equals(codeString)) 274 return new Enumeration<SubscriptionChannelType>(this, SubscriptionChannelType.SMS); 275 if ("message".equals(codeString)) 276 return new Enumeration<SubscriptionChannelType>(this, SubscriptionChannelType.MESSAGE); 277 throw new FHIRException("Unknown SubscriptionChannelType code '"+codeString+"'"); 278 } 279 public String toCode(SubscriptionChannelType code) { 280 if (code == SubscriptionChannelType.RESTHOOK) 281 return "rest-hook"; 282 if (code == SubscriptionChannelType.WEBSOCKET) 283 return "websocket"; 284 if (code == SubscriptionChannelType.EMAIL) 285 return "email"; 286 if (code == SubscriptionChannelType.SMS) 287 return "sms"; 288 if (code == SubscriptionChannelType.MESSAGE) 289 return "message"; 290 return "?"; 291 } 292 } 293 294 @Block() 295 public static class SubscriptionChannelComponent extends BackboneElement implements IBaseBackboneElement { 296 /** 297 * The type of channel to send notifications on. 298 */ 299 @Child(name = "type", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=true) 300 @Description(shortDefinition="rest-hook | websocket | email | sms | message", formalDefinition="The type of channel to send notifications on." ) 301 protected Enumeration<SubscriptionChannelType> type; 302 303 /** 304 * The uri that describes the actual end-point to send messages to. 305 */ 306 @Child(name = "endpoint", type = {UriType.class}, order=2, min=0, max=1, modifier=false, summary=true) 307 @Description(shortDefinition="Where the channel points to", formalDefinition="The uri that describes the actual end-point to send messages to." ) 308 protected UriType endpoint; 309 310 /** 311 * The mime type to send the payload in - either application/xml+fhir, or application/json+fhir. If the mime type is blank, then there is no payload in the notification, just a notification. 312 */ 313 @Child(name = "payload", type = {StringType.class}, order=3, min=1, max=1, modifier=false, summary=true) 314 @Description(shortDefinition="Mimetype to send, or blank for no payload", formalDefinition="The mime type to send the payload in - either application/xml+fhir, or application/json+fhir. If the mime type is blank, then there is no payload in the notification, just a notification." ) 315 protected StringType payload; 316 317 /** 318 * Additional headers / information to send as part of the notification. 319 */ 320 @Child(name = "header", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=true) 321 @Description(shortDefinition="Usage depends on the channel type", formalDefinition="Additional headers / information to send as part of the notification." ) 322 protected StringType header; 323 324 private static final long serialVersionUID = -279715391L; 325 326 /* 327 * Constructor 328 */ 329 public SubscriptionChannelComponent() { 330 super(); 331 } 332 333 /* 334 * Constructor 335 */ 336 public SubscriptionChannelComponent(Enumeration<SubscriptionChannelType> type, StringType payload) { 337 super(); 338 this.type = type; 339 this.payload = payload; 340 } 341 342 /** 343 * @return {@link #type} (The type of channel to send notifications on.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value 344 */ 345 public Enumeration<SubscriptionChannelType> getTypeElement() { 346 if (this.type == null) 347 if (Configuration.errorOnAutoCreate()) 348 throw new Error("Attempt to auto-create SubscriptionChannelComponent.type"); 349 else if (Configuration.doAutoCreate()) 350 this.type = new Enumeration<SubscriptionChannelType>(new SubscriptionChannelTypeEnumFactory()); // bb 351 return this.type; 352 } 353 354 public boolean hasTypeElement() { 355 return this.type != null && !this.type.isEmpty(); 356 } 357 358 public boolean hasType() { 359 return this.type != null && !this.type.isEmpty(); 360 } 361 362 /** 363 * @param value {@link #type} (The type of channel to send notifications on.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value 364 */ 365 public SubscriptionChannelComponent setTypeElement(Enumeration<SubscriptionChannelType> value) { 366 this.type = value; 367 return this; 368 } 369 370 /** 371 * @return The type of channel to send notifications on. 372 */ 373 public SubscriptionChannelType getType() { 374 return this.type == null ? null : this.type.getValue(); 375 } 376 377 /** 378 * @param value The type of channel to send notifications on. 379 */ 380 public SubscriptionChannelComponent setType(SubscriptionChannelType value) { 381 if (this.type == null) 382 this.type = new Enumeration<SubscriptionChannelType>(new SubscriptionChannelTypeEnumFactory()); 383 this.type.setValue(value); 384 return this; 385 } 386 387 /** 388 * @return {@link #endpoint} (The uri that describes the actual end-point to send messages to.). This is the underlying object with id, value and extensions. The accessor "getEndpoint" gives direct access to the value 389 */ 390 public UriType getEndpointElement() { 391 if (this.endpoint == null) 392 if (Configuration.errorOnAutoCreate()) 393 throw new Error("Attempt to auto-create SubscriptionChannelComponent.endpoint"); 394 else if (Configuration.doAutoCreate()) 395 this.endpoint = new UriType(); // bb 396 return this.endpoint; 397 } 398 399 public boolean hasEndpointElement() { 400 return this.endpoint != null && !this.endpoint.isEmpty(); 401 } 402 403 public boolean hasEndpoint() { 404 return this.endpoint != null && !this.endpoint.isEmpty(); 405 } 406 407 /** 408 * @param value {@link #endpoint} (The uri that describes the actual end-point to send messages to.). This is the underlying object with id, value and extensions. The accessor "getEndpoint" gives direct access to the value 409 */ 410 public SubscriptionChannelComponent setEndpointElement(UriType value) { 411 this.endpoint = value; 412 return this; 413 } 414 415 /** 416 * @return The uri that describes the actual end-point to send messages to. 417 */ 418 public String getEndpoint() { 419 return this.endpoint == null ? null : this.endpoint.getValue(); 420 } 421 422 /** 423 * @param value The uri that describes the actual end-point to send messages to. 424 */ 425 public SubscriptionChannelComponent setEndpoint(String value) { 426 if (Utilities.noString(value)) 427 this.endpoint = null; 428 else { 429 if (this.endpoint == null) 430 this.endpoint = new UriType(); 431 this.endpoint.setValue(value); 432 } 433 return this; 434 } 435 436 /** 437 * @return {@link #payload} (The mime type to send the payload in - either application/xml+fhir, or application/json+fhir. If the mime type is blank, then there is no payload in the notification, just a notification.). This is the underlying object with id, value and extensions. The accessor "getPayload" gives direct access to the value 438 */ 439 public StringType getPayloadElement() { 440 if (this.payload == null) 441 if (Configuration.errorOnAutoCreate()) 442 throw new Error("Attempt to auto-create SubscriptionChannelComponent.payload"); 443 else if (Configuration.doAutoCreate()) 444 this.payload = new StringType(); // bb 445 return this.payload; 446 } 447 448 public boolean hasPayloadElement() { 449 return this.payload != null && !this.payload.isEmpty(); 450 } 451 452 public boolean hasPayload() { 453 return this.payload != null && !this.payload.isEmpty(); 454 } 455 456 /** 457 * @param value {@link #payload} (The mime type to send the payload in - either application/xml+fhir, or application/json+fhir. If the mime type is blank, then there is no payload in the notification, just a notification.). This is the underlying object with id, value and extensions. The accessor "getPayload" gives direct access to the value 458 */ 459 public SubscriptionChannelComponent setPayloadElement(StringType value) { 460 this.payload = value; 461 return this; 462 } 463 464 /** 465 * @return The mime type to send the payload in - either application/xml+fhir, or application/json+fhir. If the mime type is blank, then there is no payload in the notification, just a notification. 466 */ 467 public String getPayload() { 468 return this.payload == null ? null : this.payload.getValue(); 469 } 470 471 /** 472 * @param value The mime type to send the payload in - either application/xml+fhir, or application/json+fhir. If the mime type is blank, then there is no payload in the notification, just a notification. 473 */ 474 public SubscriptionChannelComponent setPayload(String value) { 475 if (this.payload == null) 476 this.payload = new StringType(); 477 this.payload.setValue(value); 478 return this; 479 } 480 481 /** 482 * @return {@link #header} (Additional headers / information to send as part of the notification.). This is the underlying object with id, value and extensions. The accessor "getHeader" gives direct access to the value 483 */ 484 public StringType getHeaderElement() { 485 if (this.header == null) 486 if (Configuration.errorOnAutoCreate()) 487 throw new Error("Attempt to auto-create SubscriptionChannelComponent.header"); 488 else if (Configuration.doAutoCreate()) 489 this.header = new StringType(); // bb 490 return this.header; 491 } 492 493 public boolean hasHeaderElement() { 494 return this.header != null && !this.header.isEmpty(); 495 } 496 497 public boolean hasHeader() { 498 return this.header != null && !this.header.isEmpty(); 499 } 500 501 /** 502 * @param value {@link #header} (Additional headers / information to send as part of the notification.). This is the underlying object with id, value and extensions. The accessor "getHeader" gives direct access to the value 503 */ 504 public SubscriptionChannelComponent setHeaderElement(StringType value) { 505 this.header = value; 506 return this; 507 } 508 509 /** 510 * @return Additional headers / information to send as part of the notification. 511 */ 512 public String getHeader() { 513 return this.header == null ? null : this.header.getValue(); 514 } 515 516 /** 517 * @param value Additional headers / information to send as part of the notification. 518 */ 519 public SubscriptionChannelComponent setHeader(String value) { 520 if (Utilities.noString(value)) 521 this.header = null; 522 else { 523 if (this.header == null) 524 this.header = new StringType(); 525 this.header.setValue(value); 526 } 527 return this; 528 } 529 530 protected void listChildren(List<Property> childrenList) { 531 super.listChildren(childrenList); 532 childrenList.add(new Property("type", "code", "The type of channel to send notifications on.", 0, java.lang.Integer.MAX_VALUE, type)); 533 childrenList.add(new Property("endpoint", "uri", "The uri that describes the actual end-point to send messages to.", 0, java.lang.Integer.MAX_VALUE, endpoint)); 534 childrenList.add(new Property("payload", "string", "The mime type to send the payload in - either application/xml+fhir, or application/json+fhir. If the mime type is blank, then there is no payload in the notification, just a notification.", 0, java.lang.Integer.MAX_VALUE, payload)); 535 childrenList.add(new Property("header", "string", "Additional headers / information to send as part of the notification.", 0, java.lang.Integer.MAX_VALUE, header)); 536 } 537 538 @Override 539 public void setProperty(String name, Base value) throws FHIRException { 540 if (name.equals("type")) 541 this.type = new SubscriptionChannelTypeEnumFactory().fromType(value); // Enumeration<SubscriptionChannelType> 542 else if (name.equals("endpoint")) 543 this.endpoint = castToUri(value); // UriType 544 else if (name.equals("payload")) 545 this.payload = castToString(value); // StringType 546 else if (name.equals("header")) 547 this.header = castToString(value); // StringType 548 else 549 super.setProperty(name, value); 550 } 551 552 @Override 553 public Base addChild(String name) throws FHIRException { 554 if (name.equals("type")) { 555 throw new FHIRException("Cannot call addChild on a primitive type Subscription.type"); 556 } 557 else if (name.equals("endpoint")) { 558 throw new FHIRException("Cannot call addChild on a primitive type Subscription.endpoint"); 559 } 560 else if (name.equals("payload")) { 561 throw new FHIRException("Cannot call addChild on a primitive type Subscription.payload"); 562 } 563 else if (name.equals("header")) { 564 throw new FHIRException("Cannot call addChild on a primitive type Subscription.header"); 565 } 566 else 567 return super.addChild(name); 568 } 569 570 public SubscriptionChannelComponent copy() { 571 SubscriptionChannelComponent dst = new SubscriptionChannelComponent(); 572 copyValues(dst); 573 dst.type = type == null ? null : type.copy(); 574 dst.endpoint = endpoint == null ? null : endpoint.copy(); 575 dst.payload = payload == null ? null : payload.copy(); 576 dst.header = header == null ? null : header.copy(); 577 return dst; 578 } 579 580 @Override 581 public boolean equalsDeep(Base other) { 582 if (!super.equalsDeep(other)) 583 return false; 584 if (!(other instanceof SubscriptionChannelComponent)) 585 return false; 586 SubscriptionChannelComponent o = (SubscriptionChannelComponent) other; 587 return compareDeep(type, o.type, true) && compareDeep(endpoint, o.endpoint, true) && compareDeep(payload, o.payload, true) 588 && compareDeep(header, o.header, true); 589 } 590 591 @Override 592 public boolean equalsShallow(Base other) { 593 if (!super.equalsShallow(other)) 594 return false; 595 if (!(other instanceof SubscriptionChannelComponent)) 596 return false; 597 SubscriptionChannelComponent o = (SubscriptionChannelComponent) other; 598 return compareValues(type, o.type, true) && compareValues(endpoint, o.endpoint, true) && compareValues(payload, o.payload, true) 599 && compareValues(header, o.header, true); 600 } 601 602 public boolean isEmpty() { 603 return super.isEmpty() && (type == null || type.isEmpty()) && (endpoint == null || endpoint.isEmpty()) 604 && (payload == null || payload.isEmpty()) && (header == null || header.isEmpty()); 605 } 606 607 public String fhirType() { 608 return "Subscription.channel"; 609 610 } 611 612 } 613 614 /** 615 * The rules that the server should use to determine when to generate notifications for this subscription. 616 */ 617 @Child(name = "criteria", type = {StringType.class}, order=0, min=1, max=1, modifier=false, summary=true) 618 @Description(shortDefinition="Rule for server push criteria", formalDefinition="The rules that the server should use to determine when to generate notifications for this subscription." ) 619 protected StringType criteria; 620 621 /** 622 * Contact details for a human to contact about the subscription. The primary use of this for system administrator troubleshooting. 623 */ 624 @Child(name = "contact", type = {ContactPoint.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 625 @Description(shortDefinition="Contact details for source (e.g. troubleshooting)", formalDefinition="Contact details for a human to contact about the subscription. The primary use of this for system administrator troubleshooting." ) 626 protected List<ContactPoint> contact; 627 628 /** 629 * A description of why this subscription is defined. 630 */ 631 @Child(name = "reason", type = {StringType.class}, order=2, min=1, max=1, modifier=false, summary=true) 632 @Description(shortDefinition="Description of why this subscription was created", formalDefinition="A description of why this subscription is defined." ) 633 protected StringType reason; 634 635 /** 636 * The status of the subscription, which marks the server state for managing the subscription. 637 */ 638 @Child(name = "status", type = {CodeType.class}, order=3, min=1, max=1, modifier=true, summary=true) 639 @Description(shortDefinition="requested | active | error | off", formalDefinition="The status of the subscription, which marks the server state for managing the subscription." ) 640 protected Enumeration<SubscriptionStatus> status; 641 642 /** 643 * A record of the last error that occurred when the server processed a notification. 644 */ 645 @Child(name = "error", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=true) 646 @Description(shortDefinition="Latest error note", formalDefinition="A record of the last error that occurred when the server processed a notification." ) 647 protected StringType error; 648 649 /** 650 * Details where to send notifications when resources are received that meet the criteria. 651 */ 652 @Child(name = "channel", type = {}, order=5, min=1, max=1, modifier=false, summary=true) 653 @Description(shortDefinition="The channel on which to report matches to the criteria", formalDefinition="Details where to send notifications when resources are received that meet the criteria." ) 654 protected SubscriptionChannelComponent channel; 655 656 /** 657 * The time for the server to turn the subscription off. 658 */ 659 @Child(name = "end", type = {InstantType.class}, order=6, min=0, max=1, modifier=false, summary=true) 660 @Description(shortDefinition="When to automatically delete the subscription", formalDefinition="The time for the server to turn the subscription off." ) 661 protected InstantType end; 662 663 /** 664 * A tag to add to any resource that matches the criteria, after the subscription is processed. 665 */ 666 @Child(name = "tag", type = {Coding.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 667 @Description(shortDefinition="A tag to add to matching resources", formalDefinition="A tag to add to any resource that matches the criteria, after the subscription is processed." ) 668 protected List<Coding> tag; 669 670 private static final long serialVersionUID = -1390870804L; 671 672 /* 673 * Constructor 674 */ 675 public Subscription() { 676 super(); 677 } 678 679 /* 680 * Constructor 681 */ 682 public Subscription(StringType criteria, StringType reason, Enumeration<SubscriptionStatus> status, SubscriptionChannelComponent channel) { 683 super(); 684 this.criteria = criteria; 685 this.reason = reason; 686 this.status = status; 687 this.channel = channel; 688 } 689 690 /** 691 * @return {@link #criteria} (The rules that the server should use to determine when to generate notifications for this subscription.). This is the underlying object with id, value and extensions. The accessor "getCriteria" gives direct access to the value 692 */ 693 public StringType getCriteriaElement() { 694 if (this.criteria == null) 695 if (Configuration.errorOnAutoCreate()) 696 throw new Error("Attempt to auto-create Subscription.criteria"); 697 else if (Configuration.doAutoCreate()) 698 this.criteria = new StringType(); // bb 699 return this.criteria; 700 } 701 702 public boolean hasCriteriaElement() { 703 return this.criteria != null && !this.criteria.isEmpty(); 704 } 705 706 public boolean hasCriteria() { 707 return this.criteria != null && !this.criteria.isEmpty(); 708 } 709 710 /** 711 * @param value {@link #criteria} (The rules that the server should use to determine when to generate notifications for this subscription.). This is the underlying object with id, value and extensions. The accessor "getCriteria" gives direct access to the value 712 */ 713 public Subscription setCriteriaElement(StringType value) { 714 this.criteria = value; 715 return this; 716 } 717 718 /** 719 * @return The rules that the server should use to determine when to generate notifications for this subscription. 720 */ 721 public String getCriteria() { 722 return this.criteria == null ? null : this.criteria.getValue(); 723 } 724 725 /** 726 * @param value The rules that the server should use to determine when to generate notifications for this subscription. 727 */ 728 public Subscription setCriteria(String value) { 729 if (this.criteria == null) 730 this.criteria = new StringType(); 731 this.criteria.setValue(value); 732 return this; 733 } 734 735 /** 736 * @return {@link #contact} (Contact details for a human to contact about the subscription. The primary use of this for system administrator troubleshooting.) 737 */ 738 public List<ContactPoint> getContact() { 739 if (this.contact == null) 740 this.contact = new ArrayList<ContactPoint>(); 741 return this.contact; 742 } 743 744 public boolean hasContact() { 745 if (this.contact == null) 746 return false; 747 for (ContactPoint item : this.contact) 748 if (!item.isEmpty()) 749 return true; 750 return false; 751 } 752 753 /** 754 * @return {@link #contact} (Contact details for a human to contact about the subscription. The primary use of this for system administrator troubleshooting.) 755 */ 756 // syntactic sugar 757 public ContactPoint addContact() { //3 758 ContactPoint t = new ContactPoint(); 759 if (this.contact == null) 760 this.contact = new ArrayList<ContactPoint>(); 761 this.contact.add(t); 762 return t; 763 } 764 765 // syntactic sugar 766 public Subscription addContact(ContactPoint t) { //3 767 if (t == null) 768 return this; 769 if (this.contact == null) 770 this.contact = new ArrayList<ContactPoint>(); 771 this.contact.add(t); 772 return this; 773 } 774 775 /** 776 * @return {@link #reason} (A description of why this subscription is defined.). This is the underlying object with id, value and extensions. The accessor "getReason" gives direct access to the value 777 */ 778 public StringType getReasonElement() { 779 if (this.reason == null) 780 if (Configuration.errorOnAutoCreate()) 781 throw new Error("Attempt to auto-create Subscription.reason"); 782 else if (Configuration.doAutoCreate()) 783 this.reason = new StringType(); // bb 784 return this.reason; 785 } 786 787 public boolean hasReasonElement() { 788 return this.reason != null && !this.reason.isEmpty(); 789 } 790 791 public boolean hasReason() { 792 return this.reason != null && !this.reason.isEmpty(); 793 } 794 795 /** 796 * @param value {@link #reason} (A description of why this subscription is defined.). This is the underlying object with id, value and extensions. The accessor "getReason" gives direct access to the value 797 */ 798 public Subscription setReasonElement(StringType value) { 799 this.reason = value; 800 return this; 801 } 802 803 /** 804 * @return A description of why this subscription is defined. 805 */ 806 public String getReason() { 807 return this.reason == null ? null : this.reason.getValue(); 808 } 809 810 /** 811 * @param value A description of why this subscription is defined. 812 */ 813 public Subscription setReason(String value) { 814 if (this.reason == null) 815 this.reason = new StringType(); 816 this.reason.setValue(value); 817 return this; 818 } 819 820 /** 821 * @return {@link #status} (The status of the subscription, which marks the server state for managing the subscription.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value 822 */ 823 public Enumeration<SubscriptionStatus> getStatusElement() { 824 if (this.status == null) 825 if (Configuration.errorOnAutoCreate()) 826 throw new Error("Attempt to auto-create Subscription.status"); 827 else if (Configuration.doAutoCreate()) 828 this.status = new Enumeration<SubscriptionStatus>(new SubscriptionStatusEnumFactory()); // bb 829 return this.status; 830 } 831 832 public boolean hasStatusElement() { 833 return this.status != null && !this.status.isEmpty(); 834 } 835 836 public boolean hasStatus() { 837 return this.status != null && !this.status.isEmpty(); 838 } 839 840 /** 841 * @param value {@link #status} (The status of the subscription, which marks the server state for managing the subscription.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value 842 */ 843 public Subscription setStatusElement(Enumeration<SubscriptionStatus> value) { 844 this.status = value; 845 return this; 846 } 847 848 /** 849 * @return The status of the subscription, which marks the server state for managing the subscription. 850 */ 851 public SubscriptionStatus getStatus() { 852 return this.status == null ? null : this.status.getValue(); 853 } 854 855 /** 856 * @param value The status of the subscription, which marks the server state for managing the subscription. 857 */ 858 public Subscription setStatus(SubscriptionStatus value) { 859 if (this.status == null) 860 this.status = new Enumeration<SubscriptionStatus>(new SubscriptionStatusEnumFactory()); 861 this.status.setValue(value); 862 return this; 863 } 864 865 /** 866 * @return {@link #error} (A record of the last error that occurred when the server processed a notification.). This is the underlying object with id, value and extensions. The accessor "getError" gives direct access to the value 867 */ 868 public StringType getErrorElement() { 869 if (this.error == null) 870 if (Configuration.errorOnAutoCreate()) 871 throw new Error("Attempt to auto-create Subscription.error"); 872 else if (Configuration.doAutoCreate()) 873 this.error = new StringType(); // bb 874 return this.error; 875 } 876 877 public boolean hasErrorElement() { 878 return this.error != null && !this.error.isEmpty(); 879 } 880 881 public boolean hasError() { 882 return this.error != null && !this.error.isEmpty(); 883 } 884 885 /** 886 * @param value {@link #error} (A record of the last error that occurred when the server processed a notification.). This is the underlying object with id, value and extensions. The accessor "getError" gives direct access to the value 887 */ 888 public Subscription setErrorElement(StringType value) { 889 this.error = value; 890 return this; 891 } 892 893 /** 894 * @return A record of the last error that occurred when the server processed a notification. 895 */ 896 public String getError() { 897 return this.error == null ? null : this.error.getValue(); 898 } 899 900 /** 901 * @param value A record of the last error that occurred when the server processed a notification. 902 */ 903 public Subscription setError(String value) { 904 if (Utilities.noString(value)) 905 this.error = null; 906 else { 907 if (this.error == null) 908 this.error = new StringType(); 909 this.error.setValue(value); 910 } 911 return this; 912 } 913 914 /** 915 * @return {@link #channel} (Details where to send notifications when resources are received that meet the criteria.) 916 */ 917 public SubscriptionChannelComponent getChannel() { 918 if (this.channel == null) 919 if (Configuration.errorOnAutoCreate()) 920 throw new Error("Attempt to auto-create Subscription.channel"); 921 else if (Configuration.doAutoCreate()) 922 this.channel = new SubscriptionChannelComponent(); // cc 923 return this.channel; 924 } 925 926 public boolean hasChannel() { 927 return this.channel != null && !this.channel.isEmpty(); 928 } 929 930 /** 931 * @param value {@link #channel} (Details where to send notifications when resources are received that meet the criteria.) 932 */ 933 public Subscription setChannel(SubscriptionChannelComponent value) { 934 this.channel = value; 935 return this; 936 } 937 938 /** 939 * @return {@link #end} (The time for the server to turn the subscription off.). This is the underlying object with id, value and extensions. The accessor "getEnd" gives direct access to the value 940 */ 941 public InstantType getEndElement() { 942 if (this.end == null) 943 if (Configuration.errorOnAutoCreate()) 944 throw new Error("Attempt to auto-create Subscription.end"); 945 else if (Configuration.doAutoCreate()) 946 this.end = new InstantType(); // bb 947 return this.end; 948 } 949 950 public boolean hasEndElement() { 951 return this.end != null && !this.end.isEmpty(); 952 } 953 954 public boolean hasEnd() { 955 return this.end != null && !this.end.isEmpty(); 956 } 957 958 /** 959 * @param value {@link #end} (The time for the server to turn the subscription off.). This is the underlying object with id, value and extensions. The accessor "getEnd" gives direct access to the value 960 */ 961 public Subscription setEndElement(InstantType value) { 962 this.end = value; 963 return this; 964 } 965 966 /** 967 * @return The time for the server to turn the subscription off. 968 */ 969 public Date getEnd() { 970 return this.end == null ? null : this.end.getValue(); 971 } 972 973 /** 974 * @param value The time for the server to turn the subscription off. 975 */ 976 public Subscription setEnd(Date value) { 977 if (value == null) 978 this.end = null; 979 else { 980 if (this.end == null) 981 this.end = new InstantType(); 982 this.end.setValue(value); 983 } 984 return this; 985 } 986 987 /** 988 * @return {@link #tag} (A tag to add to any resource that matches the criteria, after the subscription is processed.) 989 */ 990 public List<Coding> getTag() { 991 if (this.tag == null) 992 this.tag = new ArrayList<Coding>(); 993 return this.tag; 994 } 995 996 public boolean hasTag() { 997 if (this.tag == null) 998 return false; 999 for (Coding item : this.tag) 1000 if (!item.isEmpty()) 1001 return true; 1002 return false; 1003 } 1004 1005 /** 1006 * @return {@link #tag} (A tag to add to any resource that matches the criteria, after the subscription is processed.) 1007 */ 1008 // syntactic sugar 1009 public Coding addTag() { //3 1010 Coding t = new Coding(); 1011 if (this.tag == null) 1012 this.tag = new ArrayList<Coding>(); 1013 this.tag.add(t); 1014 return t; 1015 } 1016 1017 // syntactic sugar 1018 public Subscription addTag(Coding t) { //3 1019 if (t == null) 1020 return this; 1021 if (this.tag == null) 1022 this.tag = new ArrayList<Coding>(); 1023 this.tag.add(t); 1024 return this; 1025 } 1026 1027 protected void listChildren(List<Property> childrenList) { 1028 super.listChildren(childrenList); 1029 childrenList.add(new Property("criteria", "string", "The rules that the server should use to determine when to generate notifications for this subscription.", 0, java.lang.Integer.MAX_VALUE, criteria)); 1030 childrenList.add(new Property("contact", "ContactPoint", "Contact details for a human to contact about the subscription. The primary use of this for system administrator troubleshooting.", 0, java.lang.Integer.MAX_VALUE, contact)); 1031 childrenList.add(new Property("reason", "string", "A description of why this subscription is defined.", 0, java.lang.Integer.MAX_VALUE, reason)); 1032 childrenList.add(new Property("status", "code", "The status of the subscription, which marks the server state for managing the subscription.", 0, java.lang.Integer.MAX_VALUE, status)); 1033 childrenList.add(new Property("error", "string", "A record of the last error that occurred when the server processed a notification.", 0, java.lang.Integer.MAX_VALUE, error)); 1034 childrenList.add(new Property("channel", "", "Details where to send notifications when resources are received that meet the criteria.", 0, java.lang.Integer.MAX_VALUE, channel)); 1035 childrenList.add(new Property("end", "instant", "The time for the server to turn the subscription off.", 0, java.lang.Integer.MAX_VALUE, end)); 1036 childrenList.add(new Property("tag", "Coding", "A tag to add to any resource that matches the criteria, after the subscription is processed.", 0, java.lang.Integer.MAX_VALUE, tag)); 1037 } 1038 1039 @Override 1040 public void setProperty(String name, Base value) throws FHIRException { 1041 if (name.equals("criteria")) 1042 this.criteria = castToString(value); // StringType 1043 else if (name.equals("contact")) 1044 this.getContact().add(castToContactPoint(value)); 1045 else if (name.equals("reason")) 1046 this.reason = castToString(value); // StringType 1047 else if (name.equals("status")) 1048 this.status = new SubscriptionStatusEnumFactory().fromType(value); // Enumeration<SubscriptionStatus> 1049 else if (name.equals("error")) 1050 this.error = castToString(value); // StringType 1051 else if (name.equals("channel")) 1052 this.channel = (SubscriptionChannelComponent) value; // SubscriptionChannelComponent 1053 else if (name.equals("end")) 1054 this.end = castToInstant(value); // InstantType 1055 else if (name.equals("tag")) 1056 this.getTag().add(castToCoding(value)); 1057 else 1058 super.setProperty(name, value); 1059 } 1060 1061 @Override 1062 public Base addChild(String name) throws FHIRException { 1063 if (name.equals("criteria")) { 1064 throw new FHIRException("Cannot call addChild on a primitive type Subscription.criteria"); 1065 } 1066 else if (name.equals("contact")) { 1067 return addContact(); 1068 } 1069 else if (name.equals("reason")) { 1070 throw new FHIRException("Cannot call addChild on a primitive type Subscription.reason"); 1071 } 1072 else if (name.equals("status")) { 1073 throw new FHIRException("Cannot call addChild on a primitive type Subscription.status"); 1074 } 1075 else if (name.equals("error")) { 1076 throw new FHIRException("Cannot call addChild on a primitive type Subscription.error"); 1077 } 1078 else if (name.equals("channel")) { 1079 this.channel = new SubscriptionChannelComponent(); 1080 return this.channel; 1081 } 1082 else if (name.equals("end")) { 1083 throw new FHIRException("Cannot call addChild on a primitive type Subscription.end"); 1084 } 1085 else if (name.equals("tag")) { 1086 return addTag(); 1087 } 1088 else 1089 return super.addChild(name); 1090 } 1091 1092 public String fhirType() { 1093 return "Subscription"; 1094 1095 } 1096 1097 public Subscription copy() { 1098 Subscription dst = new Subscription(); 1099 copyValues(dst); 1100 dst.criteria = criteria == null ? null : criteria.copy(); 1101 if (contact != null) { 1102 dst.contact = new ArrayList<ContactPoint>(); 1103 for (ContactPoint i : contact) 1104 dst.contact.add(i.copy()); 1105 }; 1106 dst.reason = reason == null ? null : reason.copy(); 1107 dst.status = status == null ? null : status.copy(); 1108 dst.error = error == null ? null : error.copy(); 1109 dst.channel = channel == null ? null : channel.copy(); 1110 dst.end = end == null ? null : end.copy(); 1111 if (tag != null) { 1112 dst.tag = new ArrayList<Coding>(); 1113 for (Coding i : tag) 1114 dst.tag.add(i.copy()); 1115 }; 1116 return dst; 1117 } 1118 1119 protected Subscription typedCopy() { 1120 return copy(); 1121 } 1122 1123 @Override 1124 public boolean equalsDeep(Base other) { 1125 if (!super.equalsDeep(other)) 1126 return false; 1127 if (!(other instanceof Subscription)) 1128 return false; 1129 Subscription o = (Subscription) other; 1130 return compareDeep(criteria, o.criteria, true) && compareDeep(contact, o.contact, true) && compareDeep(reason, o.reason, true) 1131 && compareDeep(status, o.status, true) && compareDeep(error, o.error, true) && compareDeep(channel, o.channel, true) 1132 && compareDeep(end, o.end, true) && compareDeep(tag, o.tag, true); 1133 } 1134 1135 @Override 1136 public boolean equalsShallow(Base other) { 1137 if (!super.equalsShallow(other)) 1138 return false; 1139 if (!(other instanceof Subscription)) 1140 return false; 1141 Subscription o = (Subscription) other; 1142 return compareValues(criteria, o.criteria, true) && compareValues(reason, o.reason, true) && compareValues(status, o.status, true) 1143 && compareValues(error, o.error, true) && compareValues(end, o.end, true); 1144 } 1145 1146 public boolean isEmpty() { 1147 return super.isEmpty() && (criteria == null || criteria.isEmpty()) && (contact == null || contact.isEmpty()) 1148 && (reason == null || reason.isEmpty()) && (status == null || status.isEmpty()) && (error == null || error.isEmpty()) 1149 && (channel == null || channel.isEmpty()) && (end == null || end.isEmpty()) && (tag == null || tag.isEmpty()) 1150 ; 1151 } 1152 1153 @Override 1154 public ResourceType getResourceType() { 1155 return ResourceType.Subscription; 1156 } 1157 1158 @SearchParamDefinition(name="payload", path="Subscription.channel.payload", description="Mimetype to send, or blank for no payload", type="string" ) 1159 public static final String SP_PAYLOAD = "payload"; 1160 @SearchParamDefinition(name="criteria", path="Subscription.criteria", description="Rule for server push criteria", type="string" ) 1161 public static final String SP_CRITERIA = "criteria"; 1162 @SearchParamDefinition(name="contact", path="Subscription.contact", description="Contact details for source (e.g. troubleshooting)", type="token" ) 1163 public static final String SP_CONTACT = "contact"; 1164 @SearchParamDefinition(name="tag", path="Subscription.tag", description="A tag to add to matching resources", type="token" ) 1165 public static final String SP_TAG = "tag"; 1166 @SearchParamDefinition(name="type", path="Subscription.channel.type", description="rest-hook | websocket | email | sms | message", type="token" ) 1167 public static final String SP_TYPE = "type"; 1168 @SearchParamDefinition(name="url", path="Subscription.channel.endpoint", description="Where the channel points to", type="uri" ) 1169 public static final String SP_URL = "url"; 1170 @SearchParamDefinition(name="status", path="Subscription.status", description="requested | active | error | off", type="token" ) 1171 public static final String SP_STATUS = "status"; 1172 1173} 1174