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