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