001package org.hl7.fhir.dstu2016may.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 Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0 036import java.util.List; 037 038import org.hl7.fhir.exceptions.FHIRException; 039import org.hl7.fhir.instance.model.api.ICompositeType; 040import org.hl7.fhir.utilities.Utilities; 041 042import ca.uhn.fhir.model.api.annotation.Child; 043import ca.uhn.fhir.model.api.annotation.DatatypeDef; 044import ca.uhn.fhir.model.api.annotation.Description; 045/** 046 * A description of a triggering event. 047 */ 048@DatatypeDef(name="TriggerDefinition") 049public class TriggerDefinition extends Type implements ICompositeType { 050 051 public enum TriggerType { 052 /** 053 * The trigger occurs in response to a specific named event 054 */ 055 NAMEDEVENT, 056 /** 057 * The trigger occurs at a specific time or periodically as described by a timing or schedule 058 */ 059 PERIODIC, 060 /** 061 * The trigger occurs whenever data of a particular type is added 062 */ 063 DATAADDED, 064 /** 065 * The trigger occurs whenever data of a particular type is modified 066 */ 067 DATAMODIFIED, 068 /** 069 * The trigger occurs whenever data of a particular type is removed 070 */ 071 DATAREMOVED, 072 /** 073 * The trigger occurs whenever data of a particular type is accessed 074 */ 075 DATAACCESSED, 076 /** 077 * The trigger occurs whenever access to data of a particular type is completed 078 */ 079 DATAACCESSENDED, 080 /** 081 * added to help the parsers 082 */ 083 NULL; 084 public static TriggerType fromCode(String codeString) throws FHIRException { 085 if (codeString == null || "".equals(codeString)) 086 return null; 087 if ("named-event".equals(codeString)) 088 return NAMEDEVENT; 089 if ("periodic".equals(codeString)) 090 return PERIODIC; 091 if ("data-added".equals(codeString)) 092 return DATAADDED; 093 if ("data-modified".equals(codeString)) 094 return DATAMODIFIED; 095 if ("data-removed".equals(codeString)) 096 return DATAREMOVED; 097 if ("data-accessed".equals(codeString)) 098 return DATAACCESSED; 099 if ("data-access-ended".equals(codeString)) 100 return DATAACCESSENDED; 101 throw new FHIRException("Unknown TriggerType code '"+codeString+"'"); 102 } 103 public String toCode() { 104 switch (this) { 105 case NAMEDEVENT: return "named-event"; 106 case PERIODIC: return "periodic"; 107 case DATAADDED: return "data-added"; 108 case DATAMODIFIED: return "data-modified"; 109 case DATAREMOVED: return "data-removed"; 110 case DATAACCESSED: return "data-accessed"; 111 case DATAACCESSENDED: return "data-access-ended"; 112 case NULL: return null; 113 default: return "?"; 114 } 115 } 116 public String getSystem() { 117 switch (this) { 118 case NAMEDEVENT: return "http://hl7.org/fhir/trigger-type"; 119 case PERIODIC: return "http://hl7.org/fhir/trigger-type"; 120 case DATAADDED: return "http://hl7.org/fhir/trigger-type"; 121 case DATAMODIFIED: return "http://hl7.org/fhir/trigger-type"; 122 case DATAREMOVED: return "http://hl7.org/fhir/trigger-type"; 123 case DATAACCESSED: return "http://hl7.org/fhir/trigger-type"; 124 case DATAACCESSENDED: return "http://hl7.org/fhir/trigger-type"; 125 case NULL: return null; 126 default: return "?"; 127 } 128 } 129 public String getDefinition() { 130 switch (this) { 131 case NAMEDEVENT: return "The trigger occurs in response to a specific named event"; 132 case PERIODIC: return "The trigger occurs at a specific time or periodically as described by a timing or schedule"; 133 case DATAADDED: return "The trigger occurs whenever data of a particular type is added"; 134 case DATAMODIFIED: return "The trigger occurs whenever data of a particular type is modified"; 135 case DATAREMOVED: return "The trigger occurs whenever data of a particular type is removed"; 136 case DATAACCESSED: return "The trigger occurs whenever data of a particular type is accessed"; 137 case DATAACCESSENDED: return "The trigger occurs whenever access to data of a particular type is completed"; 138 case NULL: return null; 139 default: return "?"; 140 } 141 } 142 public String getDisplay() { 143 switch (this) { 144 case NAMEDEVENT: return "Named Event"; 145 case PERIODIC: return "Periodic"; 146 case DATAADDED: return "Data Added"; 147 case DATAMODIFIED: return "Data Modified"; 148 case DATAREMOVED: return "Data Removed"; 149 case DATAACCESSED: return "Data Accessed"; 150 case DATAACCESSENDED: return "Data Access Ended"; 151 case NULL: return null; 152 default: return "?"; 153 } 154 } 155 } 156 157 public static class TriggerTypeEnumFactory implements EnumFactory<TriggerType> { 158 public TriggerType fromCode(String codeString) throws IllegalArgumentException { 159 if (codeString == null || "".equals(codeString)) 160 if (codeString == null || "".equals(codeString)) 161 return null; 162 if ("named-event".equals(codeString)) 163 return TriggerType.NAMEDEVENT; 164 if ("periodic".equals(codeString)) 165 return TriggerType.PERIODIC; 166 if ("data-added".equals(codeString)) 167 return TriggerType.DATAADDED; 168 if ("data-modified".equals(codeString)) 169 return TriggerType.DATAMODIFIED; 170 if ("data-removed".equals(codeString)) 171 return TriggerType.DATAREMOVED; 172 if ("data-accessed".equals(codeString)) 173 return TriggerType.DATAACCESSED; 174 if ("data-access-ended".equals(codeString)) 175 return TriggerType.DATAACCESSENDED; 176 throw new IllegalArgumentException("Unknown TriggerType code '"+codeString+"'"); 177 } 178 public Enumeration<TriggerType> fromType(Base code) throws FHIRException { 179 if (code == null || code.isEmpty()) 180 return null; 181 String codeString = ((PrimitiveType) code).asStringValue(); 182 if (codeString == null || "".equals(codeString)) 183 return null; 184 if ("named-event".equals(codeString)) 185 return new Enumeration<TriggerType>(this, TriggerType.NAMEDEVENT); 186 if ("periodic".equals(codeString)) 187 return new Enumeration<TriggerType>(this, TriggerType.PERIODIC); 188 if ("data-added".equals(codeString)) 189 return new Enumeration<TriggerType>(this, TriggerType.DATAADDED); 190 if ("data-modified".equals(codeString)) 191 return new Enumeration<TriggerType>(this, TriggerType.DATAMODIFIED); 192 if ("data-removed".equals(codeString)) 193 return new Enumeration<TriggerType>(this, TriggerType.DATAREMOVED); 194 if ("data-accessed".equals(codeString)) 195 return new Enumeration<TriggerType>(this, TriggerType.DATAACCESSED); 196 if ("data-access-ended".equals(codeString)) 197 return new Enumeration<TriggerType>(this, TriggerType.DATAACCESSENDED); 198 throw new FHIRException("Unknown TriggerType code '"+codeString+"'"); 199 } 200 public String toCode(TriggerType code) { 201 if (code == TriggerType.NAMEDEVENT) 202 return "named-event"; 203 if (code == TriggerType.PERIODIC) 204 return "periodic"; 205 if (code == TriggerType.DATAADDED) 206 return "data-added"; 207 if (code == TriggerType.DATAMODIFIED) 208 return "data-modified"; 209 if (code == TriggerType.DATAREMOVED) 210 return "data-removed"; 211 if (code == TriggerType.DATAACCESSED) 212 return "data-accessed"; 213 if (code == TriggerType.DATAACCESSENDED) 214 return "data-access-ended"; 215 return "?"; 216 } 217 public String toSystem(TriggerType code) { 218 return code.getSystem(); 219 } 220 } 221 222 /** 223 * The type of triggering event. 224 */ 225 @Child(name = "type", type = {CodeType.class}, order=0, min=1, max=1, modifier=false, summary=true) 226 @Description(shortDefinition="named-event | periodic | data-added | data-modified | data-removed | data-accessed | data-access-ended", formalDefinition="The type of triggering event." ) 227 protected Enumeration<TriggerType> type; 228 229 /** 230 * The name of the event (if this is a named-event trigger). 231 */ 232 @Child(name = "eventName", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true) 233 @Description(shortDefinition="Name of the event", formalDefinition="The name of the event (if this is a named-event trigger)." ) 234 protected StringType eventName; 235 236 /** 237 * The timing of the event (if this is a period trigger). 238 */ 239 @Child(name = "eventTiming", type = {Timing.class, Schedule.class, DateType.class, DateTimeType.class}, order=2, min=0, max=1, modifier=false, summary=true) 240 @Description(shortDefinition="Timing of the event", formalDefinition="The timing of the event (if this is a period trigger)." ) 241 protected Type eventTiming; 242 243 /** 244 * The triggering data of the event (if this is a data trigger). 245 */ 246 @Child(name = "eventData", type = {DataRequirement.class}, order=3, min=0, max=1, modifier=false, summary=true) 247 @Description(shortDefinition="Triggering data of the event", formalDefinition="The triggering data of the event (if this is a data trigger)." ) 248 protected DataRequirement eventData; 249 250 private static final long serialVersionUID = -1695534864L; 251 252 /** 253 * Constructor 254 */ 255 public TriggerDefinition() { 256 super(); 257 } 258 259 /** 260 * Constructor 261 */ 262 public TriggerDefinition(Enumeration<TriggerType> type) { 263 super(); 264 this.type = type; 265 } 266 267 /** 268 * @return {@link #type} (The type of triggering event.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value 269 */ 270 public Enumeration<TriggerType> getTypeElement() { 271 if (this.type == null) 272 if (Configuration.errorOnAutoCreate()) 273 throw new Error("Attempt to auto-create TriggerDefinition.type"); 274 else if (Configuration.doAutoCreate()) 275 this.type = new Enumeration<TriggerType>(new TriggerTypeEnumFactory()); // bb 276 return this.type; 277 } 278 279 public boolean hasTypeElement() { 280 return this.type != null && !this.type.isEmpty(); 281 } 282 283 public boolean hasType() { 284 return this.type != null && !this.type.isEmpty(); 285 } 286 287 /** 288 * @param value {@link #type} (The type of triggering event.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value 289 */ 290 public TriggerDefinition setTypeElement(Enumeration<TriggerType> value) { 291 this.type = value; 292 return this; 293 } 294 295 /** 296 * @return The type of triggering event. 297 */ 298 public TriggerType getType() { 299 return this.type == null ? null : this.type.getValue(); 300 } 301 302 /** 303 * @param value The type of triggering event. 304 */ 305 public TriggerDefinition setType(TriggerType value) { 306 if (this.type == null) 307 this.type = new Enumeration<TriggerType>(new TriggerTypeEnumFactory()); 308 this.type.setValue(value); 309 return this; 310 } 311 312 /** 313 * @return {@link #eventName} (The name of the event (if this is a named-event trigger).). This is the underlying object with id, value and extensions. The accessor "getEventName" gives direct access to the value 314 */ 315 public StringType getEventNameElement() { 316 if (this.eventName == null) 317 if (Configuration.errorOnAutoCreate()) 318 throw new Error("Attempt to auto-create TriggerDefinition.eventName"); 319 else if (Configuration.doAutoCreate()) 320 this.eventName = new StringType(); // bb 321 return this.eventName; 322 } 323 324 public boolean hasEventNameElement() { 325 return this.eventName != null && !this.eventName.isEmpty(); 326 } 327 328 public boolean hasEventName() { 329 return this.eventName != null && !this.eventName.isEmpty(); 330 } 331 332 /** 333 * @param value {@link #eventName} (The name of the event (if this is a named-event trigger).). This is the underlying object with id, value and extensions. The accessor "getEventName" gives direct access to the value 334 */ 335 public TriggerDefinition setEventNameElement(StringType value) { 336 this.eventName = value; 337 return this; 338 } 339 340 /** 341 * @return The name of the event (if this is a named-event trigger). 342 */ 343 public String getEventName() { 344 return this.eventName == null ? null : this.eventName.getValue(); 345 } 346 347 /** 348 * @param value The name of the event (if this is a named-event trigger). 349 */ 350 public TriggerDefinition setEventName(String value) { 351 if (Utilities.noString(value)) 352 this.eventName = null; 353 else { 354 if (this.eventName == null) 355 this.eventName = new StringType(); 356 this.eventName.setValue(value); 357 } 358 return this; 359 } 360 361 /** 362 * @return {@link #eventTiming} (The timing of the event (if this is a period trigger).) 363 */ 364 public Type getEventTiming() { 365 return this.eventTiming; 366 } 367 368 /** 369 * @return {@link #eventTiming} (The timing of the event (if this is a period trigger).) 370 */ 371 public Timing getEventTimingTiming() throws FHIRException { 372 if (!(this.eventTiming instanceof Timing)) 373 throw new FHIRException("Type mismatch: the type Timing was expected, but "+this.eventTiming.getClass().getName()+" was encountered"); 374 return (Timing) this.eventTiming; 375 } 376 377 public boolean hasEventTimingTiming() { 378 return this.eventTiming instanceof Timing; 379 } 380 381 /** 382 * @return {@link #eventTiming} (The timing of the event (if this is a period trigger).) 383 */ 384 public Reference getEventTimingReference() throws FHIRException { 385 if (!(this.eventTiming instanceof Reference)) 386 throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.eventTiming.getClass().getName()+" was encountered"); 387 return (Reference) this.eventTiming; 388 } 389 390 public boolean hasEventTimingReference() { 391 return this.eventTiming instanceof Reference; 392 } 393 394 /** 395 * @return {@link #eventTiming} (The timing of the event (if this is a period trigger).) 396 */ 397 public DateType getEventTimingDateType() throws FHIRException { 398 if (!(this.eventTiming instanceof DateType)) 399 throw new FHIRException("Type mismatch: the type DateType was expected, but "+this.eventTiming.getClass().getName()+" was encountered"); 400 return (DateType) this.eventTiming; 401 } 402 403 public boolean hasEventTimingDateType() { 404 return this.eventTiming instanceof DateType; 405 } 406 407 /** 408 * @return {@link #eventTiming} (The timing of the event (if this is a period trigger).) 409 */ 410 public DateTimeType getEventTimingDateTimeType() throws FHIRException { 411 if (!(this.eventTiming instanceof DateTimeType)) 412 throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.eventTiming.getClass().getName()+" was encountered"); 413 return (DateTimeType) this.eventTiming; 414 } 415 416 public boolean hasEventTimingDateTimeType() { 417 return this.eventTiming instanceof DateTimeType; 418 } 419 420 public boolean hasEventTiming() { 421 return this.eventTiming != null && !this.eventTiming.isEmpty(); 422 } 423 424 /** 425 * @param value {@link #eventTiming} (The timing of the event (if this is a period trigger).) 426 */ 427 public TriggerDefinition setEventTiming(Type value) { 428 this.eventTiming = value; 429 return this; 430 } 431 432 /** 433 * @return {@link #eventData} (The triggering data of the event (if this is a data trigger).) 434 */ 435 public DataRequirement getEventData() { 436 if (this.eventData == null) 437 if (Configuration.errorOnAutoCreate()) 438 throw new Error("Attempt to auto-create TriggerDefinition.eventData"); 439 else if (Configuration.doAutoCreate()) 440 this.eventData = new DataRequirement(); // cc 441 return this.eventData; 442 } 443 444 public boolean hasEventData() { 445 return this.eventData != null && !this.eventData.isEmpty(); 446 } 447 448 /** 449 * @param value {@link #eventData} (The triggering data of the event (if this is a data trigger).) 450 */ 451 public TriggerDefinition setEventData(DataRequirement value) { 452 this.eventData = value; 453 return this; 454 } 455 456 protected void listChildren(List<Property> childrenList) { 457 super.listChildren(childrenList); 458 childrenList.add(new Property("type", "code", "The type of triggering event.", 0, java.lang.Integer.MAX_VALUE, type)); 459 childrenList.add(new Property("eventName", "string", "The name of the event (if this is a named-event trigger).", 0, java.lang.Integer.MAX_VALUE, eventName)); 460 childrenList.add(new Property("eventTiming[x]", "Timing|Reference(Schedule)|date|dateTime", "The timing of the event (if this is a period trigger).", 0, java.lang.Integer.MAX_VALUE, eventTiming)); 461 childrenList.add(new Property("eventData", "DataRequirement", "The triggering data of the event (if this is a data trigger).", 0, java.lang.Integer.MAX_VALUE, eventData)); 462 } 463 464 @Override 465 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 466 switch (hash) { 467 case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // Enumeration<TriggerType> 468 case 31228997: /*eventName*/ return this.eventName == null ? new Base[0] : new Base[] {this.eventName}; // StringType 469 case 125465476: /*eventTiming*/ return this.eventTiming == null ? new Base[0] : new Base[] {this.eventTiming}; // Type 470 case 30931300: /*eventData*/ return this.eventData == null ? new Base[0] : new Base[] {this.eventData}; // DataRequirement 471 default: return super.getProperty(hash, name, checkValid); 472 } 473 474 } 475 476 @Override 477 public void setProperty(int hash, String name, Base value) throws FHIRException { 478 switch (hash) { 479 case 3575610: // type 480 this.type = new TriggerTypeEnumFactory().fromType(value); // Enumeration<TriggerType> 481 break; 482 case 31228997: // eventName 483 this.eventName = castToString(value); // StringType 484 break; 485 case 125465476: // eventTiming 486 this.eventTiming = (Type) value; // Type 487 break; 488 case 30931300: // eventData 489 this.eventData = castToDataRequirement(value); // DataRequirement 490 break; 491 default: super.setProperty(hash, name, value); 492 } 493 494 } 495 496 @Override 497 public void setProperty(String name, Base value) throws FHIRException { 498 if (name.equals("type")) 499 this.type = new TriggerTypeEnumFactory().fromType(value); // Enumeration<TriggerType> 500 else if (name.equals("eventName")) 501 this.eventName = castToString(value); // StringType 502 else if (name.equals("eventTiming[x]")) 503 this.eventTiming = (Type) value; // Type 504 else if (name.equals("eventData")) 505 this.eventData = castToDataRequirement(value); // DataRequirement 506 else 507 super.setProperty(name, value); 508 } 509 510 @Override 511 public Base makeProperty(int hash, String name) throws FHIRException { 512 switch (hash) { 513 case 3575610: throw new FHIRException("Cannot make property type as it is not a complex type"); // Enumeration<TriggerType> 514 case 31228997: throw new FHIRException("Cannot make property eventName as it is not a complex type"); // StringType 515 case 1120539260: return getEventTiming(); // Type 516 case 30931300: return getEventData(); // DataRequirement 517 default: return super.makeProperty(hash, name); 518 } 519 520 } 521 522 @Override 523 public Base addChild(String name) throws FHIRException { 524 if (name.equals("type")) { 525 throw new FHIRException("Cannot call addChild on a primitive type TriggerDefinition.type"); 526 } 527 else if (name.equals("eventName")) { 528 throw new FHIRException("Cannot call addChild on a primitive type TriggerDefinition.eventName"); 529 } 530 else if (name.equals("eventTimingTiming")) { 531 this.eventTiming = new Timing(); 532 return this.eventTiming; 533 } 534 else if (name.equals("eventTimingReference")) { 535 this.eventTiming = new Reference(); 536 return this.eventTiming; 537 } 538 else if (name.equals("eventTimingDate")) { 539 this.eventTiming = new DateType(); 540 return this.eventTiming; 541 } 542 else if (name.equals("eventTimingDateTime")) { 543 this.eventTiming = new DateTimeType(); 544 return this.eventTiming; 545 } 546 else if (name.equals("eventData")) { 547 this.eventData = new DataRequirement(); 548 return this.eventData; 549 } 550 else 551 return super.addChild(name); 552 } 553 554 public String fhirType() { 555 return "TriggerDefinition"; 556 557 } 558 559 public TriggerDefinition copy() { 560 TriggerDefinition dst = new TriggerDefinition(); 561 copyValues(dst); 562 dst.type = type == null ? null : type.copy(); 563 dst.eventName = eventName == null ? null : eventName.copy(); 564 dst.eventTiming = eventTiming == null ? null : eventTiming.copy(); 565 dst.eventData = eventData == null ? null : eventData.copy(); 566 return dst; 567 } 568 569 protected TriggerDefinition typedCopy() { 570 return copy(); 571 } 572 573 @Override 574 public boolean equalsDeep(Base other) { 575 if (!super.equalsDeep(other)) 576 return false; 577 if (!(other instanceof TriggerDefinition)) 578 return false; 579 TriggerDefinition o = (TriggerDefinition) other; 580 return compareDeep(type, o.type, true) && compareDeep(eventName, o.eventName, true) && compareDeep(eventTiming, o.eventTiming, true) 581 && compareDeep(eventData, o.eventData, true); 582 } 583 584 @Override 585 public boolean equalsShallow(Base other) { 586 if (!super.equalsShallow(other)) 587 return false; 588 if (!(other instanceof TriggerDefinition)) 589 return false; 590 TriggerDefinition o = (TriggerDefinition) other; 591 return compareValues(type, o.type, true) && compareValues(eventName, o.eventName, true); 592 } 593 594 public boolean isEmpty() { 595 return super.isEmpty() && (type == null || type.isEmpty()) && (eventName == null || eventName.isEmpty()) 596 && (eventTiming == null || eventTiming.isEmpty()) && (eventData == null || eventData.isEmpty()) 597 ; 598 } 599 600 601}