001package org.hl7.fhir.dstu2.model; 002 003import java.math.BigDecimal; 004 005/* 006 Copyright (c) 2011+, HL7, Inc. 007 All rights reserved. 008 009 Redistribution and use in source and binary forms, with or without modification, 010 are permitted provided that the following conditions are met: 011 012 * Redistributions of source code must retain the above copyright notice, this 013 list of conditions and the following disclaimer. 014 * Redistributions in binary form must reproduce the above copyright notice, 015 this list of conditions and the following disclaimer in the documentation 016 and/or other materials provided with the distribution. 017 * Neither the name of HL7 nor the names of its contributors may be used to 018 endorse or promote products derived from this software without specific 019 prior written permission. 020 021 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 022 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 023 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 024 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 025 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 026 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 027 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 028 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 029 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 030 POSSIBILITY OF SUCH DAMAGE. 031 032*/ 033 034// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2 035import java.util.ArrayList; 036import java.util.Date; 037import java.util.List; 038 039import ca.uhn.fhir.model.api.annotation.Block; 040import ca.uhn.fhir.model.api.annotation.Child; 041import ca.uhn.fhir.model.api.annotation.DatatypeDef; 042import ca.uhn.fhir.model.api.annotation.Description; 043import org.hl7.fhir.instance.model.api.IBaseDatatypeElement; 044import org.hl7.fhir.instance.model.api.ICompositeType; 045import org.hl7.fhir.exceptions.FHIRException; 046 047/** 048 * Specifies an event that may occur multiple times. Timing schedules are used 049 * to record when things are expected or requested to occur. The most common 050 * usage is in dosage instructions for medications. They are also used when 051 * planning care of various kinds. 052 */ 053@DatatypeDef(name = "Timing") 054public class Timing extends Type implements ICompositeType { 055 056 public enum UnitsOfTime { 057 /** 058 * null 059 */ 060 S, 061 /** 062 * null 063 */ 064 MIN, 065 /** 066 * null 067 */ 068 H, 069 /** 070 * null 071 */ 072 D, 073 /** 074 * null 075 */ 076 WK, 077 /** 078 * null 079 */ 080 MO, 081 /** 082 * null 083 */ 084 A, 085 /** 086 * added to help the parsers 087 */ 088 NULL; 089 090 public static UnitsOfTime fromCode(String codeString) throws FHIRException { 091 if (codeString == null || "".equals(codeString)) 092 return null; 093 if ("s".equals(codeString)) 094 return S; 095 if ("min".equals(codeString)) 096 return MIN; 097 if ("h".equals(codeString)) 098 return H; 099 if ("d".equals(codeString)) 100 return D; 101 if ("wk".equals(codeString)) 102 return WK; 103 if ("mo".equals(codeString)) 104 return MO; 105 if ("a".equals(codeString)) 106 return A; 107 throw new FHIRException("Unknown UnitsOfTime code '" + codeString + "'"); 108 } 109 110 public String toCode() { 111 switch (this) { 112 case S: 113 return "s"; 114 case MIN: 115 return "min"; 116 case H: 117 return "h"; 118 case D: 119 return "d"; 120 case WK: 121 return "wk"; 122 case MO: 123 return "mo"; 124 case A: 125 return "a"; 126 case NULL: 127 return null; 128 default: 129 return "?"; 130 } 131 } 132 133 public String getSystem() { 134 switch (this) { 135 case S: 136 return "http://unitsofmeasure.org"; 137 case MIN: 138 return "http://unitsofmeasure.org"; 139 case H: 140 return "http://unitsofmeasure.org"; 141 case D: 142 return "http://unitsofmeasure.org"; 143 case WK: 144 return "http://unitsofmeasure.org"; 145 case MO: 146 return "http://unitsofmeasure.org"; 147 case A: 148 return "http://unitsofmeasure.org"; 149 case NULL: 150 return null; 151 default: 152 return "?"; 153 } 154 } 155 156 public String getDefinition() { 157 switch (this) { 158 case S: 159 return ""; 160 case MIN: 161 return ""; 162 case H: 163 return ""; 164 case D: 165 return ""; 166 case WK: 167 return ""; 168 case MO: 169 return ""; 170 case A: 171 return ""; 172 case NULL: 173 return null; 174 default: 175 return "?"; 176 } 177 } 178 179 public String getDisplay() { 180 switch (this) { 181 case S: 182 return "s"; 183 case MIN: 184 return "min"; 185 case H: 186 return "h"; 187 case D: 188 return "d"; 189 case WK: 190 return "wk"; 191 case MO: 192 return "mo"; 193 case A: 194 return "a"; 195 case NULL: 196 return null; 197 default: 198 return "?"; 199 } 200 } 201 } 202 203 public static class UnitsOfTimeEnumFactory implements EnumFactory<UnitsOfTime> { 204 public UnitsOfTime fromCode(String codeString) throws IllegalArgumentException { 205 if (codeString == null || "".equals(codeString)) 206 if (codeString == null || "".equals(codeString)) 207 return null; 208 if ("s".equals(codeString)) 209 return UnitsOfTime.S; 210 if ("min".equals(codeString)) 211 return UnitsOfTime.MIN; 212 if ("h".equals(codeString)) 213 return UnitsOfTime.H; 214 if ("d".equals(codeString)) 215 return UnitsOfTime.D; 216 if ("wk".equals(codeString)) 217 return UnitsOfTime.WK; 218 if ("mo".equals(codeString)) 219 return UnitsOfTime.MO; 220 if ("a".equals(codeString)) 221 return UnitsOfTime.A; 222 throw new IllegalArgumentException("Unknown UnitsOfTime code '" + codeString + "'"); 223 } 224 225 public Enumeration<UnitsOfTime> fromType(Base code) throws FHIRException { 226 if (code == null || code.isEmpty()) 227 return null; 228 String codeString = ((PrimitiveType) code).asStringValue(); 229 if (codeString == null || "".equals(codeString)) 230 return null; 231 if ("s".equals(codeString)) 232 return new Enumeration<UnitsOfTime>(this, UnitsOfTime.S); 233 if ("min".equals(codeString)) 234 return new Enumeration<UnitsOfTime>(this, UnitsOfTime.MIN); 235 if ("h".equals(codeString)) 236 return new Enumeration<UnitsOfTime>(this, UnitsOfTime.H); 237 if ("d".equals(codeString)) 238 return new Enumeration<UnitsOfTime>(this, UnitsOfTime.D); 239 if ("wk".equals(codeString)) 240 return new Enumeration<UnitsOfTime>(this, UnitsOfTime.WK); 241 if ("mo".equals(codeString)) 242 return new Enumeration<UnitsOfTime>(this, UnitsOfTime.MO); 243 if ("a".equals(codeString)) 244 return new Enumeration<UnitsOfTime>(this, UnitsOfTime.A); 245 throw new FHIRException("Unknown UnitsOfTime code '" + codeString + "'"); 246 } 247 248 public String toCode(UnitsOfTime code) 249 { 250 if (code == UnitsOfTime.NULL) 251 return null; 252 if (code == UnitsOfTime.S) 253 return "s"; 254 if (code == UnitsOfTime.MIN) 255 return "min"; 256 if (code == UnitsOfTime.H) 257 return "h"; 258 if (code == UnitsOfTime.D) 259 return "d"; 260 if (code == UnitsOfTime.WK) 261 return "wk"; 262 if (code == UnitsOfTime.MO) 263 return "mo"; 264 if (code == UnitsOfTime.A) 265 return "a"; 266 return "?"; 267 } 268 } 269 270 public enum EventTiming { 271 /** 272 * null 273 */ 274 HS, 275 /** 276 * null 277 */ 278 WAKE, 279 /** 280 * null 281 */ 282 C, 283 /** 284 * null 285 */ 286 CM, 287 /** 288 * null 289 */ 290 CD, 291 /** 292 * null 293 */ 294 CV, 295 /** 296 * null 297 */ 298 AC, 299 /** 300 * null 301 */ 302 ACM, 303 /** 304 * null 305 */ 306 ACD, 307 /** 308 * null 309 */ 310 ACV, 311 /** 312 * null 313 */ 314 PC, 315 /** 316 * null 317 */ 318 PCM, 319 /** 320 * null 321 */ 322 PCD, 323 /** 324 * null 325 */ 326 PCV, 327 /** 328 * added to help the parsers 329 */ 330 NULL; 331 332 public static EventTiming fromCode(String codeString) throws FHIRException { 333 if (codeString == null || "".equals(codeString)) 334 return null; 335 if ("HS".equals(codeString)) 336 return HS; 337 if ("WAKE".equals(codeString)) 338 return WAKE; 339 if ("C".equals(codeString)) 340 return C; 341 if ("CM".equals(codeString)) 342 return CM; 343 if ("CD".equals(codeString)) 344 return CD; 345 if ("CV".equals(codeString)) 346 return CV; 347 if ("AC".equals(codeString)) 348 return AC; 349 if ("ACM".equals(codeString)) 350 return ACM; 351 if ("ACD".equals(codeString)) 352 return ACD; 353 if ("ACV".equals(codeString)) 354 return ACV; 355 if ("PC".equals(codeString)) 356 return PC; 357 if ("PCM".equals(codeString)) 358 return PCM; 359 if ("PCD".equals(codeString)) 360 return PCD; 361 if ("PCV".equals(codeString)) 362 return PCV; 363 throw new FHIRException("Unknown EventTiming code '" + codeString + "'"); 364 } 365 366 public String toCode() { 367 switch (this) { 368 case HS: 369 return "HS"; 370 case WAKE: 371 return "WAKE"; 372 case C: 373 return "C"; 374 case CM: 375 return "CM"; 376 case CD: 377 return "CD"; 378 case CV: 379 return "CV"; 380 case AC: 381 return "AC"; 382 case ACM: 383 return "ACM"; 384 case ACD: 385 return "ACD"; 386 case ACV: 387 return "ACV"; 388 case PC: 389 return "PC"; 390 case PCM: 391 return "PCM"; 392 case PCD: 393 return "PCD"; 394 case PCV: 395 return "PCV"; 396 case NULL: 397 return null; 398 default: 399 return "?"; 400 } 401 } 402 403 public String getSystem() { 404 switch (this) { 405 case HS: 406 return "http://hl7.org/fhir/v3/TimingEvent"; 407 case WAKE: 408 return "http://hl7.org/fhir/v3/TimingEvent"; 409 case C: 410 return "http://hl7.org/fhir/v3/TimingEvent"; 411 case CM: 412 return "http://hl7.org/fhir/v3/TimingEvent"; 413 case CD: 414 return "http://hl7.org/fhir/v3/TimingEvent"; 415 case CV: 416 return "http://hl7.org/fhir/v3/TimingEvent"; 417 case AC: 418 return "http://hl7.org/fhir/v3/TimingEvent"; 419 case ACM: 420 return "http://hl7.org/fhir/v3/TimingEvent"; 421 case ACD: 422 return "http://hl7.org/fhir/v3/TimingEvent"; 423 case ACV: 424 return "http://hl7.org/fhir/v3/TimingEvent"; 425 case PC: 426 return "http://hl7.org/fhir/v3/TimingEvent"; 427 case PCM: 428 return "http://hl7.org/fhir/v3/TimingEvent"; 429 case PCD: 430 return "http://hl7.org/fhir/v3/TimingEvent"; 431 case PCV: 432 return "http://hl7.org/fhir/v3/TimingEvent"; 433 case NULL: 434 return null; 435 default: 436 return "?"; 437 } 438 } 439 440 public String getDefinition() { 441 switch (this) { 442 case HS: 443 return ""; 444 case WAKE: 445 return ""; 446 case C: 447 return ""; 448 case CM: 449 return ""; 450 case CD: 451 return ""; 452 case CV: 453 return ""; 454 case AC: 455 return ""; 456 case ACM: 457 return ""; 458 case ACD: 459 return ""; 460 case ACV: 461 return ""; 462 case PC: 463 return ""; 464 case PCM: 465 return ""; 466 case PCD: 467 return ""; 468 case PCV: 469 return ""; 470 case NULL: 471 return null; 472 default: 473 return "?"; 474 } 475 } 476 477 public String getDisplay() { 478 switch (this) { 479 case HS: 480 return "HS"; 481 case WAKE: 482 return "WAKE"; 483 case C: 484 return "C"; 485 case CM: 486 return "CM"; 487 case CD: 488 return "CD"; 489 case CV: 490 return "CV"; 491 case AC: 492 return "AC"; 493 case ACM: 494 return "ACM"; 495 case ACD: 496 return "ACD"; 497 case ACV: 498 return "ACV"; 499 case PC: 500 return "PC"; 501 case PCM: 502 return "PCM"; 503 case PCD: 504 return "PCD"; 505 case PCV: 506 return "PCV"; 507 case NULL: 508 return null; 509 default: 510 return "?"; 511 } 512 } 513 } 514 515 public static class EventTimingEnumFactory implements EnumFactory<EventTiming> { 516 public EventTiming fromCode(String codeString) throws IllegalArgumentException { 517 if (codeString == null || "".equals(codeString)) 518 if (codeString == null || "".equals(codeString)) 519 return null; 520 if ("HS".equals(codeString)) 521 return EventTiming.HS; 522 if ("WAKE".equals(codeString)) 523 return EventTiming.WAKE; 524 if ("C".equals(codeString)) 525 return EventTiming.C; 526 if ("CM".equals(codeString)) 527 return EventTiming.CM; 528 if ("CD".equals(codeString)) 529 return EventTiming.CD; 530 if ("CV".equals(codeString)) 531 return EventTiming.CV; 532 if ("AC".equals(codeString)) 533 return EventTiming.AC; 534 if ("ACM".equals(codeString)) 535 return EventTiming.ACM; 536 if ("ACD".equals(codeString)) 537 return EventTiming.ACD; 538 if ("ACV".equals(codeString)) 539 return EventTiming.ACV; 540 if ("PC".equals(codeString)) 541 return EventTiming.PC; 542 if ("PCM".equals(codeString)) 543 return EventTiming.PCM; 544 if ("PCD".equals(codeString)) 545 return EventTiming.PCD; 546 if ("PCV".equals(codeString)) 547 return EventTiming.PCV; 548 throw new IllegalArgumentException("Unknown EventTiming code '" + codeString + "'"); 549 } 550 551 public Enumeration<EventTiming> fromType(Base code) throws FHIRException { 552 if (code == null || code.isEmpty()) 553 return null; 554 String codeString = ((PrimitiveType) code).asStringValue(); 555 if (codeString == null || "".equals(codeString)) 556 return null; 557 if ("HS".equals(codeString)) 558 return new Enumeration<EventTiming>(this, EventTiming.HS); 559 if ("WAKE".equals(codeString)) 560 return new Enumeration<EventTiming>(this, EventTiming.WAKE); 561 if ("C".equals(codeString)) 562 return new Enumeration<EventTiming>(this, EventTiming.C); 563 if ("CM".equals(codeString)) 564 return new Enumeration<EventTiming>(this, EventTiming.CM); 565 if ("CD".equals(codeString)) 566 return new Enumeration<EventTiming>(this, EventTiming.CD); 567 if ("CV".equals(codeString)) 568 return new Enumeration<EventTiming>(this, EventTiming.CV); 569 if ("AC".equals(codeString)) 570 return new Enumeration<EventTiming>(this, EventTiming.AC); 571 if ("ACM".equals(codeString)) 572 return new Enumeration<EventTiming>(this, EventTiming.ACM); 573 if ("ACD".equals(codeString)) 574 return new Enumeration<EventTiming>(this, EventTiming.ACD); 575 if ("ACV".equals(codeString)) 576 return new Enumeration<EventTiming>(this, EventTiming.ACV); 577 if ("PC".equals(codeString)) 578 return new Enumeration<EventTiming>(this, EventTiming.PC); 579 if ("PCM".equals(codeString)) 580 return new Enumeration<EventTiming>(this, EventTiming.PCM); 581 if ("PCD".equals(codeString)) 582 return new Enumeration<EventTiming>(this, EventTiming.PCD); 583 if ("PCV".equals(codeString)) 584 return new Enumeration<EventTiming>(this, EventTiming.PCV); 585 throw new FHIRException("Unknown EventTiming code '" + codeString + "'"); 586 } 587 588 public String toCode(EventTiming code) 589 { 590 if (code == EventTiming.NULL) 591 return null; 592 if (code == EventTiming.HS) 593 return "HS"; 594 if (code == EventTiming.WAKE) 595 return "WAKE"; 596 if (code == EventTiming.C) 597 return "C"; 598 if (code == EventTiming.CM) 599 return "CM"; 600 if (code == EventTiming.CD) 601 return "CD"; 602 if (code == EventTiming.CV) 603 return "CV"; 604 if (code == EventTiming.AC) 605 return "AC"; 606 if (code == EventTiming.ACM) 607 return "ACM"; 608 if (code == EventTiming.ACD) 609 return "ACD"; 610 if (code == EventTiming.ACV) 611 return "ACV"; 612 if (code == EventTiming.PC) 613 return "PC"; 614 if (code == EventTiming.PCM) 615 return "PCM"; 616 if (code == EventTiming.PCD) 617 return "PCD"; 618 if (code == EventTiming.PCV) 619 return "PCV"; 620 return "?"; 621 } 622 } 623 624 @Block() 625 public static class TimingRepeatComponent extends Element implements IBaseDatatypeElement { 626 /** 627 * Either a duration for the length of the timing schedule, a range of possible 628 * length, or outer bounds for start and/or end limits of the timing schedule. 629 */ 630 @Child(name = "bounds", type = { Duration.class, Range.class, 631 Period.class }, order = 1, min = 0, max = 1, modifier = false, summary = true) 632 @Description(shortDefinition = "Length/Range of lengths, or (Start and/or end) limits", formalDefinition = "Either a duration for the length of the timing schedule, a range of possible length, or outer bounds for start and/or end limits of the timing schedule.") 633 protected Type bounds; 634 635 /** 636 * A total count of the desired number of repetitions. 637 */ 638 @Child(name = "count", type = { IntegerType.class }, order = 2, min = 0, max = 1, modifier = false, summary = true) 639 @Description(shortDefinition = "Number of times to repeat", formalDefinition = "A total count of the desired number of repetitions.") 640 protected IntegerType count; 641 642 /** 643 * How long this thing happens for when it happens. 644 */ 645 @Child(name = "duration", type = { 646 DecimalType.class }, order = 3, min = 0, max = 1, modifier = false, summary = true) 647 @Description(shortDefinition = "How long when it happens", formalDefinition = "How long this thing happens for when it happens.") 648 protected DecimalType duration; 649 650 /** 651 * The upper limit of how long this thing happens for when it happens. 652 */ 653 @Child(name = "durationMax", type = { 654 DecimalType.class }, order = 4, min = 0, max = 1, modifier = false, summary = true) 655 @Description(shortDefinition = "How long when it happens (Max)", formalDefinition = "The upper limit of how long this thing happens for when it happens.") 656 protected DecimalType durationMax; 657 658 /** 659 * The units of time for the duration, in UCUM units. 660 */ 661 @Child(name = "durationUnits", type = { 662 CodeType.class }, order = 5, min = 0, max = 1, modifier = false, summary = true) 663 @Description(shortDefinition = "s | min | h | d | wk | mo | a - unit of time (UCUM)", formalDefinition = "The units of time for the duration, in UCUM units.") 664 protected Enumeration<UnitsOfTime> durationUnits; 665 666 /** 667 * The number of times to repeat the action within the specified period / period 668 * range (i.e. both period and periodMax provided). 669 */ 670 @Child(name = "frequency", type = { 671 IntegerType.class }, order = 6, min = 0, max = 1, modifier = false, summary = true) 672 @Description(shortDefinition = "Event occurs frequency times per period", formalDefinition = "The number of times to repeat the action within the specified period / period range (i.e. both period and periodMax provided).") 673 protected IntegerType frequency; 674 675 /** 676 * If present, indicates that the frequency is a range - so repeat between 677 * [frequency] and [frequencyMax] times within the period or period range. 678 */ 679 @Child(name = "frequencyMax", type = { 680 IntegerType.class }, order = 7, min = 0, max = 1, modifier = false, summary = true) 681 @Description(shortDefinition = "Event occurs up to frequencyMax times per period", formalDefinition = "If present, indicates that the frequency is a range - so repeat between [frequency] and [frequencyMax] times within the period or period range.") 682 protected IntegerType frequencyMax; 683 684 /** 685 * Indicates the duration of time over which repetitions are to occur; e.g. to 686 * express "3 times per day", 3 would be the frequency and "1 day" would be the 687 * period. 688 */ 689 @Child(name = "period", type = { DecimalType.class }, order = 8, min = 0, max = 1, modifier = false, summary = true) 690 @Description(shortDefinition = "Event occurs frequency times per period", formalDefinition = "Indicates the duration of time over which repetitions are to occur; e.g. to express \"3 times per day\", 3 would be the frequency and \"1 day\" would be the period.") 691 protected DecimalType period; 692 693 /** 694 * If present, indicates that the period is a range from [period] to 695 * [periodMax], allowing expressing concepts such as "do this once every 3-5 696 * days. 697 */ 698 @Child(name = "periodMax", type = { 699 DecimalType.class }, order = 9, min = 0, max = 1, modifier = false, summary = true) 700 @Description(shortDefinition = "Upper limit of period (3-4 hours)", formalDefinition = "If present, indicates that the period is a range from [period] to [periodMax], allowing expressing concepts such as \"do this once every 3-5 days.") 701 protected DecimalType periodMax; 702 703 /** 704 * The units of time for the period in UCUM units. 705 */ 706 @Child(name = "periodUnits", type = { 707 CodeType.class }, order = 10, min = 0, max = 1, modifier = false, summary = true) 708 @Description(shortDefinition = "s | min | h | d | wk | mo | a - unit of time (UCUM)", formalDefinition = "The units of time for the period in UCUM units.") 709 protected Enumeration<UnitsOfTime> periodUnits; 710 711 /** 712 * A real world event that the occurrence of the event should be tied to. 713 */ 714 @Child(name = "when", type = { CodeType.class }, order = 11, min = 0, max = 1, modifier = false, summary = true) 715 @Description(shortDefinition = "Regular life events the event is tied to", formalDefinition = "A real world event that the occurrence of the event should be tied to.") 716 protected Enumeration<EventTiming> when; 717 718 private static final long serialVersionUID = -585686982L; 719 720 /* 721 * Constructor 722 */ 723 public TimingRepeatComponent() { 724 super(); 725 } 726 727 /** 728 * @return {@link #bounds} (Either a duration for the length of the timing 729 * schedule, a range of possible length, or outer bounds for start 730 * and/or end limits of the timing schedule.) 731 */ 732 public Type getBounds() { 733 return this.bounds; 734 } 735 736 /** 737 * @return {@link #bounds} (Either a duration for the length of the timing 738 * schedule, a range of possible length, or outer bounds for start 739 * and/or end limits of the timing schedule.) 740 */ 741 public Duration getBoundsDuration() throws FHIRException { 742 if (!(this.bounds instanceof Duration)) 743 throw new FHIRException("Type mismatch: the type Duration was expected, but " + this.bounds.getClass().getName() 744 + " was encountered"); 745 return (Duration) this.bounds; 746 } 747 748 public boolean hasBoundsDuration() { 749 return this.bounds instanceof Duration; 750 } 751 752 /** 753 * @return {@link #bounds} (Either a duration for the length of the timing 754 * schedule, a range of possible length, or outer bounds for start 755 * and/or end limits of the timing schedule.) 756 */ 757 public Range getBoundsRange() throws FHIRException { 758 if (!(this.bounds instanceof Range)) 759 throw new FHIRException( 760 "Type mismatch: the type Range was expected, but " + this.bounds.getClass().getName() + " was encountered"); 761 return (Range) this.bounds; 762 } 763 764 public boolean hasBoundsRange() { 765 return this.bounds instanceof Range; 766 } 767 768 /** 769 * @return {@link #bounds} (Either a duration for the length of the timing 770 * schedule, a range of possible length, or outer bounds for start 771 * and/or end limits of the timing schedule.) 772 */ 773 public Period getBoundsPeriod() throws FHIRException { 774 if (!(this.bounds instanceof Period)) 775 throw new FHIRException("Type mismatch: the type Period was expected, but " + this.bounds.getClass().getName() 776 + " was encountered"); 777 return (Period) this.bounds; 778 } 779 780 public boolean hasBoundsPeriod() { 781 return this.bounds instanceof Period; 782 } 783 784 public boolean hasBounds() { 785 return this.bounds != null && !this.bounds.isEmpty(); 786 } 787 788 /** 789 * @param value {@link #bounds} (Either a duration for the length of the timing 790 * schedule, a range of possible length, or outer bounds for start 791 * and/or end limits of the timing schedule.) 792 */ 793 public TimingRepeatComponent setBounds(Type value) { 794 this.bounds = value; 795 return this; 796 } 797 798 /** 799 * @return {@link #count} (A total count of the desired number of repetitions.). 800 * This is the underlying object with id, value and extensions. The 801 * accessor "getCount" gives direct access to the value 802 */ 803 public IntegerType getCountElement() { 804 if (this.count == null) 805 if (Configuration.errorOnAutoCreate()) 806 throw new Error("Attempt to auto-create TimingRepeatComponent.count"); 807 else if (Configuration.doAutoCreate()) 808 this.count = new IntegerType(); // bb 809 return this.count; 810 } 811 812 public boolean hasCountElement() { 813 return this.count != null && !this.count.isEmpty(); 814 } 815 816 public boolean hasCount() { 817 return this.count != null && !this.count.isEmpty(); 818 } 819 820 /** 821 * @param value {@link #count} (A total count of the desired number of 822 * repetitions.). This is the underlying object with id, value and 823 * extensions. The accessor "getCount" gives direct access to the 824 * value 825 */ 826 public TimingRepeatComponent setCountElement(IntegerType value) { 827 this.count = value; 828 return this; 829 } 830 831 /** 832 * @return A total count of the desired number of repetitions. 833 */ 834 public int getCount() { 835 return this.count == null || this.count.isEmpty() ? 0 : this.count.getValue(); 836 } 837 838 /** 839 * @param value A total count of the desired number of repetitions. 840 */ 841 public TimingRepeatComponent setCount(int value) { 842 if (this.count == null) 843 this.count = new IntegerType(); 844 this.count.setValue(value); 845 return this; 846 } 847 848 /** 849 * @return {@link #duration} (How long this thing happens for when it happens.). 850 * This is the underlying object with id, value and extensions. The 851 * accessor "getDuration" gives direct access to the value 852 */ 853 public DecimalType getDurationElement() { 854 if (this.duration == null) 855 if (Configuration.errorOnAutoCreate()) 856 throw new Error("Attempt to auto-create TimingRepeatComponent.duration"); 857 else if (Configuration.doAutoCreate()) 858 this.duration = new DecimalType(); // bb 859 return this.duration; 860 } 861 862 public boolean hasDurationElement() { 863 return this.duration != null && !this.duration.isEmpty(); 864 } 865 866 public boolean hasDuration() { 867 return this.duration != null && !this.duration.isEmpty(); 868 } 869 870 /** 871 * @param value {@link #duration} (How long this thing happens for when it 872 * happens.). This is the underlying object with id, value and 873 * extensions. The accessor "getDuration" gives direct access to 874 * the value 875 */ 876 public TimingRepeatComponent setDurationElement(DecimalType value) { 877 this.duration = value; 878 return this; 879 } 880 881 /** 882 * @return How long this thing happens for when it happens. 883 */ 884 public BigDecimal getDuration() { 885 return this.duration == null ? null : this.duration.getValue(); 886 } 887 888 /** 889 * @param value How long this thing happens for when it happens. 890 */ 891 public TimingRepeatComponent setDuration(BigDecimal value) { 892 if (value == null) 893 this.duration = null; 894 else { 895 if (this.duration == null) 896 this.duration = new DecimalType(); 897 this.duration.setValue(value); 898 } 899 return this; 900 } 901 902 /** 903 * @return {@link #durationMax} (The upper limit of how long this thing happens 904 * for when it happens.). This is the underlying object with id, value 905 * and extensions. The accessor "getDurationMax" gives direct access to 906 * the value 907 */ 908 public DecimalType getDurationMaxElement() { 909 if (this.durationMax == null) 910 if (Configuration.errorOnAutoCreate()) 911 throw new Error("Attempt to auto-create TimingRepeatComponent.durationMax"); 912 else if (Configuration.doAutoCreate()) 913 this.durationMax = new DecimalType(); // bb 914 return this.durationMax; 915 } 916 917 public boolean hasDurationMaxElement() { 918 return this.durationMax != null && !this.durationMax.isEmpty(); 919 } 920 921 public boolean hasDurationMax() { 922 return this.durationMax != null && !this.durationMax.isEmpty(); 923 } 924 925 /** 926 * @param value {@link #durationMax} (The upper limit of how long this thing 927 * happens for when it happens.). This is the underlying object 928 * with id, value and extensions. The accessor "getDurationMax" 929 * gives direct access to the value 930 */ 931 public TimingRepeatComponent setDurationMaxElement(DecimalType value) { 932 this.durationMax = value; 933 return this; 934 } 935 936 /** 937 * @return The upper limit of how long this thing happens for when it happens. 938 */ 939 public BigDecimal getDurationMax() { 940 return this.durationMax == null ? null : this.durationMax.getValue(); 941 } 942 943 /** 944 * @param value The upper limit of how long this thing happens for when it 945 * happens. 946 */ 947 public TimingRepeatComponent setDurationMax(BigDecimal value) { 948 if (value == null) 949 this.durationMax = null; 950 else { 951 if (this.durationMax == null) 952 this.durationMax = new DecimalType(); 953 this.durationMax.setValue(value); 954 } 955 return this; 956 } 957 958 /** 959 * @return {@link #durationUnits} (The units of time for the duration, in UCUM 960 * units.). This is the underlying object with id, value and extensions. 961 * The accessor "getDurationUnits" gives direct access to the value 962 */ 963 public Enumeration<UnitsOfTime> getDurationUnitsElement() { 964 if (this.durationUnits == null) 965 if (Configuration.errorOnAutoCreate()) 966 throw new Error("Attempt to auto-create TimingRepeatComponent.durationUnits"); 967 else if (Configuration.doAutoCreate()) 968 this.durationUnits = new Enumeration<UnitsOfTime>(new UnitsOfTimeEnumFactory()); // bb 969 return this.durationUnits; 970 } 971 972 public boolean hasDurationUnitsElement() { 973 return this.durationUnits != null && !this.durationUnits.isEmpty(); 974 } 975 976 public boolean hasDurationUnits() { 977 return this.durationUnits != null && !this.durationUnits.isEmpty(); 978 } 979 980 /** 981 * @param value {@link #durationUnits} (The units of time for the duration, in 982 * UCUM units.). This is the underlying object with id, value and 983 * extensions. The accessor "getDurationUnits" gives direct access 984 * to the value 985 */ 986 public TimingRepeatComponent setDurationUnitsElement(Enumeration<UnitsOfTime> value) { 987 this.durationUnits = value; 988 return this; 989 } 990 991 /** 992 * @return The units of time for the duration, in UCUM units. 993 */ 994 public UnitsOfTime getDurationUnits() { 995 return this.durationUnits == null ? null : this.durationUnits.getValue(); 996 } 997 998 /** 999 * @param value The units of time for the duration, in UCUM units. 1000 */ 1001 public TimingRepeatComponent setDurationUnits(UnitsOfTime value) { 1002 if (value == null) 1003 this.durationUnits = null; 1004 else { 1005 if (this.durationUnits == null) 1006 this.durationUnits = new Enumeration<UnitsOfTime>(new UnitsOfTimeEnumFactory()); 1007 this.durationUnits.setValue(value); 1008 } 1009 return this; 1010 } 1011 1012 /** 1013 * @return {@link #frequency} (The number of times to repeat the action within 1014 * the specified period / period range (i.e. both period and periodMax 1015 * provided).). This is the underlying object with id, value and 1016 * extensions. The accessor "getFrequency" gives direct access to the 1017 * value 1018 */ 1019 public IntegerType getFrequencyElement() { 1020 if (this.frequency == null) 1021 if (Configuration.errorOnAutoCreate()) 1022 throw new Error("Attempt to auto-create TimingRepeatComponent.frequency"); 1023 else if (Configuration.doAutoCreate()) 1024 this.frequency = new IntegerType(); // bb 1025 return this.frequency; 1026 } 1027 1028 public boolean hasFrequencyElement() { 1029 return this.frequency != null && !this.frequency.isEmpty(); 1030 } 1031 1032 public boolean hasFrequency() { 1033 return this.frequency != null && !this.frequency.isEmpty(); 1034 } 1035 1036 /** 1037 * @param value {@link #frequency} (The number of times to repeat the action 1038 * within the specified period / period range (i.e. both period and 1039 * periodMax provided).). This is the underlying object with id, 1040 * value and extensions. The accessor "getFrequency" gives direct 1041 * access to the value 1042 */ 1043 public TimingRepeatComponent setFrequencyElement(IntegerType value) { 1044 this.frequency = value; 1045 return this; 1046 } 1047 1048 /** 1049 * @return The number of times to repeat the action within the specified period 1050 * / period range (i.e. both period and periodMax provided). 1051 */ 1052 public int getFrequency() { 1053 return this.frequency == null || this.frequency.isEmpty() ? 0 : this.frequency.getValue(); 1054 } 1055 1056 /** 1057 * @param value The number of times to repeat the action within the specified 1058 * period / period range (i.e. both period and periodMax provided). 1059 */ 1060 public TimingRepeatComponent setFrequency(int value) { 1061 if (this.frequency == null) 1062 this.frequency = new IntegerType(); 1063 this.frequency.setValue(value); 1064 return this; 1065 } 1066 1067 /** 1068 * @return {@link #frequencyMax} (If present, indicates that the frequency is a 1069 * range - so repeat between [frequency] and [frequencyMax] times within 1070 * the period or period range.). This is the underlying object with id, 1071 * value and extensions. The accessor "getFrequencyMax" gives direct 1072 * access to the value 1073 */ 1074 public IntegerType getFrequencyMaxElement() { 1075 if (this.frequencyMax == null) 1076 if (Configuration.errorOnAutoCreate()) 1077 throw new Error("Attempt to auto-create TimingRepeatComponent.frequencyMax"); 1078 else if (Configuration.doAutoCreate()) 1079 this.frequencyMax = new IntegerType(); // bb 1080 return this.frequencyMax; 1081 } 1082 1083 public boolean hasFrequencyMaxElement() { 1084 return this.frequencyMax != null && !this.frequencyMax.isEmpty(); 1085 } 1086 1087 public boolean hasFrequencyMax() { 1088 return this.frequencyMax != null && !this.frequencyMax.isEmpty(); 1089 } 1090 1091 /** 1092 * @param value {@link #frequencyMax} (If present, indicates that the frequency 1093 * is a range - so repeat between [frequency] and [frequencyMax] 1094 * times within the period or period range.). This is the 1095 * underlying object with id, value and extensions. The accessor 1096 * "getFrequencyMax" gives direct access to the value 1097 */ 1098 public TimingRepeatComponent setFrequencyMaxElement(IntegerType value) { 1099 this.frequencyMax = value; 1100 return this; 1101 } 1102 1103 /** 1104 * @return If present, indicates that the frequency is a range - so repeat 1105 * between [frequency] and [frequencyMax] times within the period or 1106 * period range. 1107 */ 1108 public int getFrequencyMax() { 1109 return this.frequencyMax == null || this.frequencyMax.isEmpty() ? 0 : this.frequencyMax.getValue(); 1110 } 1111 1112 /** 1113 * @param value If present, indicates that the frequency is a range - so repeat 1114 * between [frequency] and [frequencyMax] times within the period 1115 * or period range. 1116 */ 1117 public TimingRepeatComponent setFrequencyMax(int value) { 1118 if (this.frequencyMax == null) 1119 this.frequencyMax = new IntegerType(); 1120 this.frequencyMax.setValue(value); 1121 return this; 1122 } 1123 1124 /** 1125 * @return {@link #period} (Indicates the duration of time over which 1126 * repetitions are to occur; e.g. to express "3 times per day", 3 would 1127 * be the frequency and "1 day" would be the period.). This is the 1128 * underlying object with id, value and extensions. The accessor 1129 * "getPeriod" gives direct access to the value 1130 */ 1131 public DecimalType getPeriodElement() { 1132 if (this.period == null) 1133 if (Configuration.errorOnAutoCreate()) 1134 throw new Error("Attempt to auto-create TimingRepeatComponent.period"); 1135 else if (Configuration.doAutoCreate()) 1136 this.period = new DecimalType(); // bb 1137 return this.period; 1138 } 1139 1140 public boolean hasPeriodElement() { 1141 return this.period != null && !this.period.isEmpty(); 1142 } 1143 1144 public boolean hasPeriod() { 1145 return this.period != null && !this.period.isEmpty(); 1146 } 1147 1148 /** 1149 * @param value {@link #period} (Indicates the duration of time over which 1150 * repetitions are to occur; e.g. to express "3 times per day", 3 1151 * would be the frequency and "1 day" would be the period.). This 1152 * is the underlying object with id, value and extensions. The 1153 * accessor "getPeriod" gives direct access to the value 1154 */ 1155 public TimingRepeatComponent setPeriodElement(DecimalType value) { 1156 this.period = value; 1157 return this; 1158 } 1159 1160 /** 1161 * @return Indicates the duration of time over which repetitions are to occur; 1162 * e.g. to express "3 times per day", 3 would be the frequency and "1 1163 * day" would be the period. 1164 */ 1165 public BigDecimal getPeriod() { 1166 return this.period == null ? null : this.period.getValue(); 1167 } 1168 1169 /** 1170 * @param value Indicates the duration of time over which repetitions are to 1171 * occur; e.g. to express "3 times per day", 3 would be the 1172 * frequency and "1 day" would be the period. 1173 */ 1174 public TimingRepeatComponent setPeriod(BigDecimal value) { 1175 if (value == null) 1176 this.period = null; 1177 else { 1178 if (this.period == null) 1179 this.period = new DecimalType(); 1180 this.period.setValue(value); 1181 } 1182 return this; 1183 } 1184 1185 /** 1186 * @return {@link #periodMax} (If present, indicates that the period is a range 1187 * from [period] to [periodMax], allowing expressing concepts such as 1188 * "do this once every 3-5 days.). This is the underlying object with 1189 * id, value and extensions. The accessor "getPeriodMax" gives direct 1190 * access to the value 1191 */ 1192 public DecimalType getPeriodMaxElement() { 1193 if (this.periodMax == null) 1194 if (Configuration.errorOnAutoCreate()) 1195 throw new Error("Attempt to auto-create TimingRepeatComponent.periodMax"); 1196 else if (Configuration.doAutoCreate()) 1197 this.periodMax = new DecimalType(); // bb 1198 return this.periodMax; 1199 } 1200 1201 public boolean hasPeriodMaxElement() { 1202 return this.periodMax != null && !this.periodMax.isEmpty(); 1203 } 1204 1205 public boolean hasPeriodMax() { 1206 return this.periodMax != null && !this.periodMax.isEmpty(); 1207 } 1208 1209 /** 1210 * @param value {@link #periodMax} (If present, indicates that the period is a 1211 * range from [period] to [periodMax], allowing expressing concepts 1212 * such as "do this once every 3-5 days.). This is the underlying 1213 * object with id, value and extensions. The accessor 1214 * "getPeriodMax" gives direct access to the value 1215 */ 1216 public TimingRepeatComponent setPeriodMaxElement(DecimalType value) { 1217 this.periodMax = value; 1218 return this; 1219 } 1220 1221 /** 1222 * @return If present, indicates that the period is a range from [period] to 1223 * [periodMax], allowing expressing concepts such as "do this once every 1224 * 3-5 days. 1225 */ 1226 public BigDecimal getPeriodMax() { 1227 return this.periodMax == null ? null : this.periodMax.getValue(); 1228 } 1229 1230 /** 1231 * @param value If present, indicates that the period is a range from [period] 1232 * to [periodMax], allowing expressing concepts such as "do this 1233 * once every 3-5 days. 1234 */ 1235 public TimingRepeatComponent setPeriodMax(BigDecimal value) { 1236 if (value == null) 1237 this.periodMax = null; 1238 else { 1239 if (this.periodMax == null) 1240 this.periodMax = new DecimalType(); 1241 this.periodMax.setValue(value); 1242 } 1243 return this; 1244 } 1245 1246 /** 1247 * @return {@link #periodUnits} (The units of time for the period in UCUM 1248 * units.). This is the underlying object with id, value and extensions. 1249 * The accessor "getPeriodUnits" gives direct access to the value 1250 */ 1251 public Enumeration<UnitsOfTime> getPeriodUnitsElement() { 1252 if (this.periodUnits == null) 1253 if (Configuration.errorOnAutoCreate()) 1254 throw new Error("Attempt to auto-create TimingRepeatComponent.periodUnits"); 1255 else if (Configuration.doAutoCreate()) 1256 this.periodUnits = new Enumeration<UnitsOfTime>(new UnitsOfTimeEnumFactory()); // bb 1257 return this.periodUnits; 1258 } 1259 1260 public boolean hasPeriodUnitsElement() { 1261 return this.periodUnits != null && !this.periodUnits.isEmpty(); 1262 } 1263 1264 public boolean hasPeriodUnits() { 1265 return this.periodUnits != null && !this.periodUnits.isEmpty(); 1266 } 1267 1268 /** 1269 * @param value {@link #periodUnits} (The units of time for the period in UCUM 1270 * units.). This is the underlying object with id, value and 1271 * extensions. The accessor "getPeriodUnits" gives direct access to 1272 * the value 1273 */ 1274 public TimingRepeatComponent setPeriodUnitsElement(Enumeration<UnitsOfTime> value) { 1275 this.periodUnits = value; 1276 return this; 1277 } 1278 1279 /** 1280 * @return The units of time for the period in UCUM units. 1281 */ 1282 public UnitsOfTime getPeriodUnits() { 1283 return this.periodUnits == null ? null : this.periodUnits.getValue(); 1284 } 1285 1286 /** 1287 * @param value The units of time for the period in UCUM units. 1288 */ 1289 public TimingRepeatComponent setPeriodUnits(UnitsOfTime value) { 1290 if (value == null) 1291 this.periodUnits = null; 1292 else { 1293 if (this.periodUnits == null) 1294 this.periodUnits = new Enumeration<UnitsOfTime>(new UnitsOfTimeEnumFactory()); 1295 this.periodUnits.setValue(value); 1296 } 1297 return this; 1298 } 1299 1300 /** 1301 * @return {@link #when} (A real world event that the occurrence of the event 1302 * should be tied to.). This is the underlying object with id, value and 1303 * extensions. The accessor "getWhen" gives direct access to the value 1304 */ 1305 public Enumeration<EventTiming> getWhenElement() { 1306 if (this.when == null) 1307 if (Configuration.errorOnAutoCreate()) 1308 throw new Error("Attempt to auto-create TimingRepeatComponent.when"); 1309 else if (Configuration.doAutoCreate()) 1310 this.when = new Enumeration<EventTiming>(new EventTimingEnumFactory()); // bb 1311 return this.when; 1312 } 1313 1314 public boolean hasWhenElement() { 1315 return this.when != null && !this.when.isEmpty(); 1316 } 1317 1318 public boolean hasWhen() { 1319 return this.when != null && !this.when.isEmpty(); 1320 } 1321 1322 /** 1323 * @param value {@link #when} (A real world event that the occurrence of the 1324 * event should be tied to.). This is the underlying object with 1325 * id, value and extensions. The accessor "getWhen" gives direct 1326 * access to the value 1327 */ 1328 public TimingRepeatComponent setWhenElement(Enumeration<EventTiming> value) { 1329 this.when = value; 1330 return this; 1331 } 1332 1333 /** 1334 * @return A real world event that the occurrence of the event should be tied 1335 * to. 1336 */ 1337 public EventTiming getWhen() { 1338 return this.when == null ? null : this.when.getValue(); 1339 } 1340 1341 /** 1342 * @param value A real world event that the occurrence of the event should be 1343 * tied to. 1344 */ 1345 public TimingRepeatComponent setWhen(EventTiming value) { 1346 if (value == null) 1347 this.when = null; 1348 else { 1349 if (this.when == null) 1350 this.when = new Enumeration<EventTiming>(new EventTimingEnumFactory()); 1351 this.when.setValue(value); 1352 } 1353 return this; 1354 } 1355 1356 protected void listChildren(List<Property> childrenList) { 1357 super.listChildren(childrenList); 1358 childrenList.add(new Property("bounds[x]", "Duration|Range|Period", 1359 "Either a duration for the length of the timing schedule, a range of possible length, or outer bounds for start and/or end limits of the timing schedule.", 1360 0, java.lang.Integer.MAX_VALUE, bounds)); 1361 childrenList.add(new Property("count", "integer", "A total count of the desired number of repetitions.", 0, 1362 java.lang.Integer.MAX_VALUE, count)); 1363 childrenList.add(new Property("duration", "decimal", "How long this thing happens for when it happens.", 0, 1364 java.lang.Integer.MAX_VALUE, duration)); 1365 childrenList.add( 1366 new Property("durationMax", "decimal", "The upper limit of how long this thing happens for when it happens.", 1367 0, java.lang.Integer.MAX_VALUE, durationMax)); 1368 childrenList.add(new Property("durationUnits", "code", "The units of time for the duration, in UCUM units.", 0, 1369 java.lang.Integer.MAX_VALUE, durationUnits)); 1370 childrenList.add(new Property("frequency", "integer", 1371 "The number of times to repeat the action within the specified period / period range (i.e. both period and periodMax provided).", 1372 0, java.lang.Integer.MAX_VALUE, frequency)); 1373 childrenList.add(new Property("frequencyMax", "integer", 1374 "If present, indicates that the frequency is a range - so repeat between [frequency] and [frequencyMax] times within the period or period range.", 1375 0, java.lang.Integer.MAX_VALUE, frequencyMax)); 1376 childrenList.add(new Property("period", "decimal", 1377 "Indicates the duration of time over which repetitions are to occur; e.g. to express \"3 times per day\", 3 would be the frequency and \"1 day\" would be the period.", 1378 0, java.lang.Integer.MAX_VALUE, period)); 1379 childrenList.add(new Property("periodMax", "decimal", 1380 "If present, indicates that the period is a range from [period] to [periodMax], allowing expressing concepts such as \"do this once every 3-5 days.", 1381 0, java.lang.Integer.MAX_VALUE, periodMax)); 1382 childrenList.add(new Property("periodUnits", "code", "The units of time for the period in UCUM units.", 0, 1383 java.lang.Integer.MAX_VALUE, periodUnits)); 1384 childrenList 1385 .add(new Property("when", "code", "A real world event that the occurrence of the event should be tied to.", 0, 1386 java.lang.Integer.MAX_VALUE, when)); 1387 } 1388 1389 @Override 1390 public void setProperty(String name, Base value) throws FHIRException { 1391 if (name.equals("bounds[x]")) 1392 this.bounds = (Type) value; // Type 1393 else if (name.equals("count")) 1394 this.count = castToInteger(value); // IntegerType 1395 else if (name.equals("duration")) 1396 this.duration = castToDecimal(value); // DecimalType 1397 else if (name.equals("durationMax")) 1398 this.durationMax = castToDecimal(value); // DecimalType 1399 else if (name.equals("durationUnits")) 1400 this.durationUnits = new UnitsOfTimeEnumFactory().fromType(value); // Enumeration<UnitsOfTime> 1401 else if (name.equals("frequency")) 1402 this.frequency = castToInteger(value); // IntegerType 1403 else if (name.equals("frequencyMax")) 1404 this.frequencyMax = castToInteger(value); // IntegerType 1405 else if (name.equals("period")) 1406 this.period = castToDecimal(value); // DecimalType 1407 else if (name.equals("periodMax")) 1408 this.periodMax = castToDecimal(value); // DecimalType 1409 else if (name.equals("periodUnits")) 1410 this.periodUnits = new UnitsOfTimeEnumFactory().fromType(value); // Enumeration<UnitsOfTime> 1411 else if (name.equals("when")) 1412 this.when = new EventTimingEnumFactory().fromType(value); // Enumeration<EventTiming> 1413 else 1414 super.setProperty(name, value); 1415 } 1416 1417 @Override 1418 public Base addChild(String name) throws FHIRException { 1419 if (name.equals("boundsDuration")) { 1420 this.bounds = new Duration(); 1421 return this.bounds; 1422 } else if (name.equals("boundsRange")) { 1423 this.bounds = new Range(); 1424 return this.bounds; 1425 } else if (name.equals("boundsPeriod")) { 1426 this.bounds = new Period(); 1427 return this.bounds; 1428 } else if (name.equals("count")) { 1429 throw new FHIRException("Cannot call addChild on a singleton property Timing.count"); 1430 } else if (name.equals("duration")) { 1431 throw new FHIRException("Cannot call addChild on a singleton property Timing.duration"); 1432 } else if (name.equals("durationMax")) { 1433 throw new FHIRException("Cannot call addChild on a singleton property Timing.durationMax"); 1434 } else if (name.equals("durationUnits")) { 1435 throw new FHIRException("Cannot call addChild on a singleton property Timing.durationUnits"); 1436 } else if (name.equals("frequency")) { 1437 throw new FHIRException("Cannot call addChild on a singleton property Timing.frequency"); 1438 } else if (name.equals("frequencyMax")) { 1439 throw new FHIRException("Cannot call addChild on a singleton property Timing.frequencyMax"); 1440 } else if (name.equals("period")) { 1441 throw new FHIRException("Cannot call addChild on a singleton property Timing.period"); 1442 } else if (name.equals("periodMax")) { 1443 throw new FHIRException("Cannot call addChild on a singleton property Timing.periodMax"); 1444 } else if (name.equals("periodUnits")) { 1445 throw new FHIRException("Cannot call addChild on a singleton property Timing.periodUnits"); 1446 } else if (name.equals("when")) { 1447 throw new FHIRException("Cannot call addChild on a singleton property Timing.when"); 1448 } else 1449 return super.addChild(name); 1450 } 1451 1452 public TimingRepeatComponent copy() { 1453 TimingRepeatComponent dst = new TimingRepeatComponent(); 1454 copyValues(dst); 1455 dst.bounds = bounds == null ? null : bounds.copy(); 1456 dst.count = count == null ? null : count.copy(); 1457 dst.duration = duration == null ? null : duration.copy(); 1458 dst.durationMax = durationMax == null ? null : durationMax.copy(); 1459 dst.durationUnits = durationUnits == null ? null : durationUnits.copy(); 1460 dst.frequency = frequency == null ? null : frequency.copy(); 1461 dst.frequencyMax = frequencyMax == null ? null : frequencyMax.copy(); 1462 dst.period = period == null ? null : period.copy(); 1463 dst.periodMax = periodMax == null ? null : periodMax.copy(); 1464 dst.periodUnits = periodUnits == null ? null : periodUnits.copy(); 1465 dst.when = when == null ? null : when.copy(); 1466 return dst; 1467 } 1468 1469 @Override 1470 public boolean equalsDeep(Base other) { 1471 if (!super.equalsDeep(other)) 1472 return false; 1473 if (!(other instanceof TimingRepeatComponent)) 1474 return false; 1475 TimingRepeatComponent o = (TimingRepeatComponent) other; 1476 return compareDeep(bounds, o.bounds, true) && compareDeep(count, o.count, true) 1477 && compareDeep(duration, o.duration, true) && compareDeep(durationMax, o.durationMax, true) 1478 && compareDeep(durationUnits, o.durationUnits, true) && compareDeep(frequency, o.frequency, true) 1479 && compareDeep(frequencyMax, o.frequencyMax, true) && compareDeep(period, o.period, true) 1480 && compareDeep(periodMax, o.periodMax, true) && compareDeep(periodUnits, o.periodUnits, true) 1481 && compareDeep(when, o.when, true); 1482 } 1483 1484 @Override 1485 public boolean equalsShallow(Base other) { 1486 if (!super.equalsShallow(other)) 1487 return false; 1488 if (!(other instanceof TimingRepeatComponent)) 1489 return false; 1490 TimingRepeatComponent o = (TimingRepeatComponent) other; 1491 return compareValues(count, o.count, true) && compareValues(duration, o.duration, true) 1492 && compareValues(durationMax, o.durationMax, true) && compareValues(durationUnits, o.durationUnits, true) 1493 && compareValues(frequency, o.frequency, true) && compareValues(frequencyMax, o.frequencyMax, true) 1494 && compareValues(period, o.period, true) && compareValues(periodMax, o.periodMax, true) 1495 && compareValues(periodUnits, o.periodUnits, true) && compareValues(when, o.when, true); 1496 } 1497 1498 public boolean isEmpty() { 1499 return super.isEmpty() && (bounds == null || bounds.isEmpty()) && (count == null || count.isEmpty()) 1500 && (duration == null || duration.isEmpty()) && (durationMax == null || durationMax.isEmpty()) 1501 && (durationUnits == null || durationUnits.isEmpty()) && (frequency == null || frequency.isEmpty()) 1502 && (frequencyMax == null || frequencyMax.isEmpty()) && (period == null || period.isEmpty()) 1503 && (periodMax == null || periodMax.isEmpty()) && (periodUnits == null || periodUnits.isEmpty()) 1504 && (when == null || when.isEmpty()); 1505 } 1506 1507 public String fhirType() { 1508 return "Timing.repeat"; 1509 1510 } 1511 1512 } 1513 1514 /** 1515 * Identifies specific times when the event occurs. 1516 */ 1517 @Child(name = "event", type = { 1518 DateTimeType.class }, order = 0, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true) 1519 @Description(shortDefinition = "When the event occurs", formalDefinition = "Identifies specific times when the event occurs.") 1520 protected List<DateTimeType> event; 1521 1522 /** 1523 * A set of rules that describe when the event should occur. 1524 */ 1525 @Child(name = "repeat", type = {}, order = 1, min = 0, max = 1, modifier = false, summary = true) 1526 @Description(shortDefinition = "When the event is to occur", formalDefinition = "A set of rules that describe when the event should occur.") 1527 protected TimingRepeatComponent repeat; 1528 1529 /** 1530 * A code for the timing pattern. Some codes such as BID are ubiquitous, but 1531 * many institutions define their own additional codes. 1532 */ 1533 @Child(name = "code", type = { CodeableConcept.class }, order = 2, min = 0, max = 1, modifier = false, summary = true) 1534 @Description(shortDefinition = "QD | QOD | Q4H | Q6H | BID | TID | QID | AM | PM +", formalDefinition = "A code for the timing pattern. Some codes such as BID are ubiquitous, but many institutions define their own additional codes.") 1535 protected CodeableConcept code; 1536 1537 private static final long serialVersionUID = 791565112L; 1538 1539 /* 1540 * Constructor 1541 */ 1542 public Timing() { 1543 super(); 1544 } 1545 1546 /** 1547 * @return {@link #event} (Identifies specific times when the event occurs.) 1548 */ 1549 public List<DateTimeType> getEvent() { 1550 if (this.event == null) 1551 this.event = new ArrayList<DateTimeType>(); 1552 return this.event; 1553 } 1554 1555 public boolean hasEvent() { 1556 if (this.event == null) 1557 return false; 1558 for (DateTimeType item : this.event) 1559 if (!item.isEmpty()) 1560 return true; 1561 return false; 1562 } 1563 1564 /** 1565 * @return {@link #event} (Identifies specific times when the event occurs.) 1566 */ 1567 // syntactic sugar 1568 public DateTimeType addEventElement() {// 2 1569 DateTimeType t = new DateTimeType(); 1570 if (this.event == null) 1571 this.event = new ArrayList<DateTimeType>(); 1572 this.event.add(t); 1573 return t; 1574 } 1575 1576 /** 1577 * @param value {@link #event} (Identifies specific times when the event 1578 * occurs.) 1579 */ 1580 public Timing addEvent(Date value) { // 1 1581 DateTimeType t = new DateTimeType(); 1582 t.setValue(value); 1583 if (this.event == null) 1584 this.event = new ArrayList<DateTimeType>(); 1585 this.event.add(t); 1586 return this; 1587 } 1588 1589 /** 1590 * @param value {@link #event} (Identifies specific times when the event 1591 * occurs.) 1592 */ 1593 public boolean hasEvent(Date value) { 1594 if (this.event == null) 1595 return false; 1596 for (DateTimeType v : this.event) 1597 if (v.equals(value)) // dateTime 1598 return true; 1599 return false; 1600 } 1601 1602 /** 1603 * @return {@link #repeat} (A set of rules that describe when the event should 1604 * occur.) 1605 */ 1606 public TimingRepeatComponent getRepeat() { 1607 if (this.repeat == null) 1608 if (Configuration.errorOnAutoCreate()) 1609 throw new Error("Attempt to auto-create Timing.repeat"); 1610 else if (Configuration.doAutoCreate()) 1611 this.repeat = new TimingRepeatComponent(); // cc 1612 return this.repeat; 1613 } 1614 1615 public boolean hasRepeat() { 1616 return this.repeat != null && !this.repeat.isEmpty(); 1617 } 1618 1619 /** 1620 * @param value {@link #repeat} (A set of rules that describe when the event 1621 * should occur.) 1622 */ 1623 public Timing setRepeat(TimingRepeatComponent value) { 1624 this.repeat = value; 1625 return this; 1626 } 1627 1628 /** 1629 * @return {@link #code} (A code for the timing pattern. Some codes such as BID 1630 * are ubiquitous, but many institutions define their own additional 1631 * codes.) 1632 */ 1633 public CodeableConcept getCode() { 1634 if (this.code == null) 1635 if (Configuration.errorOnAutoCreate()) 1636 throw new Error("Attempt to auto-create Timing.code"); 1637 else if (Configuration.doAutoCreate()) 1638 this.code = new CodeableConcept(); // cc 1639 return this.code; 1640 } 1641 1642 public boolean hasCode() { 1643 return this.code != null && !this.code.isEmpty(); 1644 } 1645 1646 /** 1647 * @param value {@link #code} (A code for the timing pattern. Some codes such as 1648 * BID are ubiquitous, but many institutions define their own 1649 * additional codes.) 1650 */ 1651 public Timing setCode(CodeableConcept value) { 1652 this.code = value; 1653 return this; 1654 } 1655 1656 protected void listChildren(List<Property> childrenList) { 1657 super.listChildren(childrenList); 1658 childrenList.add(new Property("event", "dateTime", "Identifies specific times when the event occurs.", 0, 1659 java.lang.Integer.MAX_VALUE, event)); 1660 childrenList.add(new Property("repeat", "", "A set of rules that describe when the event should occur.", 0, 1661 java.lang.Integer.MAX_VALUE, repeat)); 1662 childrenList.add(new Property("code", "CodeableConcept", 1663 "A code for the timing pattern. Some codes such as BID are ubiquitous, but many institutions define their own additional codes.", 1664 0, java.lang.Integer.MAX_VALUE, code)); 1665 } 1666 1667 @Override 1668 public void setProperty(String name, Base value) throws FHIRException { 1669 if (name.equals("event")) 1670 this.getEvent().add(castToDateTime(value)); 1671 else if (name.equals("repeat")) 1672 this.repeat = (TimingRepeatComponent) value; // TimingRepeatComponent 1673 else if (name.equals("code")) 1674 this.code = castToCodeableConcept(value); // CodeableConcept 1675 else 1676 super.setProperty(name, value); 1677 } 1678 1679 @Override 1680 public Base addChild(String name) throws FHIRException { 1681 if (name.equals("event")) { 1682 throw new FHIRException("Cannot call addChild on a singleton property Timing.event"); 1683 } else if (name.equals("repeat")) { 1684 this.repeat = new TimingRepeatComponent(); 1685 return this.repeat; 1686 } else if (name.equals("code")) { 1687 this.code = new CodeableConcept(); 1688 return this.code; 1689 } else 1690 return super.addChild(name); 1691 } 1692 1693 public String fhirType() { 1694 return "Timing"; 1695 1696 } 1697 1698 public Timing copy() { 1699 Timing dst = new Timing(); 1700 copyValues(dst); 1701 if (event != null) { 1702 dst.event = new ArrayList<DateTimeType>(); 1703 for (DateTimeType i : event) 1704 dst.event.add(i.copy()); 1705 } 1706 ; 1707 dst.repeat = repeat == null ? null : repeat.copy(); 1708 dst.code = code == null ? null : code.copy(); 1709 return dst; 1710 } 1711 1712 protected Timing typedCopy() { 1713 return copy(); 1714 } 1715 1716 @Override 1717 public boolean equalsDeep(Base other) { 1718 if (!super.equalsDeep(other)) 1719 return false; 1720 if (!(other instanceof Timing)) 1721 return false; 1722 Timing o = (Timing) other; 1723 return compareDeep(event, o.event, true) && compareDeep(repeat, o.repeat, true) && compareDeep(code, o.code, true); 1724 } 1725 1726 @Override 1727 public boolean equalsShallow(Base other) { 1728 if (!super.equalsShallow(other)) 1729 return false; 1730 if (!(other instanceof Timing)) 1731 return false; 1732 Timing o = (Timing) other; 1733 return compareValues(event, o.event, true); 1734 } 1735 1736 public boolean isEmpty() { 1737 return super.isEmpty() && (event == null || event.isEmpty()) && (repeat == null || repeat.isEmpty()) 1738 && (code == null || code.isEmpty()); 1739 } 1740 1741}