001package org.hl7.fhir.instance.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.*; 036 037import org.hl7.fhir.exceptions.FHIRException; 038import org.hl7.fhir.instance.model.api.IBaseDatatypeElement; 039import org.hl7.fhir.instance.model.api.ICompositeType; 040 041import ca.uhn.fhir.model.api.annotation.*; 042/** 043 * Specifies an event that may occur multiple times. Timing schedules are used to record when things are expected or requested to occur. The most common usage is in dosage instructions for medications. They are also used when planning care of various kinds. 044 */ 045@DatatypeDef(name="Timing") 046public class Timing extends Type implements ICompositeType { 047 048 public enum UnitsOfTime { 049 /** 050 * null 051 */ 052 S, 053 /** 054 * null 055 */ 056 MIN, 057 /** 058 * null 059 */ 060 H, 061 /** 062 * null 063 */ 064 D, 065 /** 066 * null 067 */ 068 WK, 069 /** 070 * null 071 */ 072 MO, 073 /** 074 * null 075 */ 076 A, 077 /** 078 * added to help the parsers 079 */ 080 NULL; 081 public static UnitsOfTime fromCode(String codeString) throws FHIRException { 082 if (codeString == null || "".equals(codeString)) 083 return null; 084 if ("s".equals(codeString)) 085 return S; 086 if ("min".equals(codeString)) 087 return MIN; 088 if ("h".equals(codeString)) 089 return H; 090 if ("d".equals(codeString)) 091 return D; 092 if ("wk".equals(codeString)) 093 return WK; 094 if ("mo".equals(codeString)) 095 return MO; 096 if ("a".equals(codeString)) 097 return A; 098 throw new FHIRException("Unknown UnitsOfTime code '"+codeString+"'"); 099 } 100 public String toCode() { 101 switch (this) { 102 case S: return "s"; 103 case MIN: return "min"; 104 case H: return "h"; 105 case D: return "d"; 106 case WK: return "wk"; 107 case MO: return "mo"; 108 case A: return "a"; 109 default: return "?"; 110 } 111 } 112 public String getSystem() { 113 switch (this) { 114 case S: return "http://unitsofmeasure.org"; 115 case MIN: return "http://unitsofmeasure.org"; 116 case H: return "http://unitsofmeasure.org"; 117 case D: return "http://unitsofmeasure.org"; 118 case WK: return "http://unitsofmeasure.org"; 119 case MO: return "http://unitsofmeasure.org"; 120 case A: return "http://unitsofmeasure.org"; 121 default: return "?"; 122 } 123 } 124 public String getDefinition() { 125 switch (this) { 126 case S: return ""; 127 case MIN: return ""; 128 case H: return ""; 129 case D: return ""; 130 case WK: return ""; 131 case MO: return ""; 132 case A: return ""; 133 default: return "?"; 134 } 135 } 136 public String getDisplay() { 137 switch (this) { 138 case S: return "s"; 139 case MIN: return "min"; 140 case H: return "h"; 141 case D: return "d"; 142 case WK: return "wk"; 143 case MO: return "mo"; 144 case A: return "a"; 145 default: return "?"; 146 } 147 } 148 } 149 150 public static class UnitsOfTimeEnumFactory implements EnumFactory<UnitsOfTime> { 151 public UnitsOfTime fromCode(String codeString) throws IllegalArgumentException { 152 if (codeString == null || "".equals(codeString)) 153 if (codeString == null || "".equals(codeString)) 154 return null; 155 if ("s".equals(codeString)) 156 return UnitsOfTime.S; 157 if ("min".equals(codeString)) 158 return UnitsOfTime.MIN; 159 if ("h".equals(codeString)) 160 return UnitsOfTime.H; 161 if ("d".equals(codeString)) 162 return UnitsOfTime.D; 163 if ("wk".equals(codeString)) 164 return UnitsOfTime.WK; 165 if ("mo".equals(codeString)) 166 return UnitsOfTime.MO; 167 if ("a".equals(codeString)) 168 return UnitsOfTime.A; 169 throw new IllegalArgumentException("Unknown UnitsOfTime code '"+codeString+"'"); 170 } 171 public Enumeration<UnitsOfTime> fromType(Base code) throws FHIRException { 172 if (code == null || code.isEmpty()) 173 return null; 174 String codeString = ((PrimitiveType) code).asStringValue(); 175 if (codeString == null || "".equals(codeString)) 176 return null; 177 if ("s".equals(codeString)) 178 return new Enumeration<UnitsOfTime>(this, UnitsOfTime.S); 179 if ("min".equals(codeString)) 180 return new Enumeration<UnitsOfTime>(this, UnitsOfTime.MIN); 181 if ("h".equals(codeString)) 182 return new Enumeration<UnitsOfTime>(this, UnitsOfTime.H); 183 if ("d".equals(codeString)) 184 return new Enumeration<UnitsOfTime>(this, UnitsOfTime.D); 185 if ("wk".equals(codeString)) 186 return new Enumeration<UnitsOfTime>(this, UnitsOfTime.WK); 187 if ("mo".equals(codeString)) 188 return new Enumeration<UnitsOfTime>(this, UnitsOfTime.MO); 189 if ("a".equals(codeString)) 190 return new Enumeration<UnitsOfTime>(this, UnitsOfTime.A); 191 throw new FHIRException("Unknown UnitsOfTime code '"+codeString+"'"); 192 } 193 public String toCode(UnitsOfTime code) { 194 if (code == UnitsOfTime.S) 195 return "s"; 196 if (code == UnitsOfTime.MIN) 197 return "min"; 198 if (code == UnitsOfTime.H) 199 return "h"; 200 if (code == UnitsOfTime.D) 201 return "d"; 202 if (code == UnitsOfTime.WK) 203 return "wk"; 204 if (code == UnitsOfTime.MO) 205 return "mo"; 206 if (code == UnitsOfTime.A) 207 return "a"; 208 return "?"; 209 } 210 } 211 212 public enum EventTiming { 213 /** 214 * null 215 */ 216 HS, 217 /** 218 * null 219 */ 220 WAKE, 221 /** 222 * null 223 */ 224 C, 225 /** 226 * null 227 */ 228 CM, 229 /** 230 * null 231 */ 232 CD, 233 /** 234 * null 235 */ 236 CV, 237 /** 238 * null 239 */ 240 AC, 241 /** 242 * null 243 */ 244 ACM, 245 /** 246 * null 247 */ 248 ACD, 249 /** 250 * null 251 */ 252 ACV, 253 /** 254 * null 255 */ 256 PC, 257 /** 258 * null 259 */ 260 PCM, 261 /** 262 * null 263 */ 264 PCD, 265 /** 266 * null 267 */ 268 PCV, 269 /** 270 * added to help the parsers 271 */ 272 NULL; 273 public static EventTiming fromCode(String codeString) throws FHIRException { 274 if (codeString == null || "".equals(codeString)) 275 return null; 276 if ("HS".equals(codeString)) 277 return HS; 278 if ("WAKE".equals(codeString)) 279 return WAKE; 280 if ("C".equals(codeString)) 281 return C; 282 if ("CM".equals(codeString)) 283 return CM; 284 if ("CD".equals(codeString)) 285 return CD; 286 if ("CV".equals(codeString)) 287 return CV; 288 if ("AC".equals(codeString)) 289 return AC; 290 if ("ACM".equals(codeString)) 291 return ACM; 292 if ("ACD".equals(codeString)) 293 return ACD; 294 if ("ACV".equals(codeString)) 295 return ACV; 296 if ("PC".equals(codeString)) 297 return PC; 298 if ("PCM".equals(codeString)) 299 return PCM; 300 if ("PCD".equals(codeString)) 301 return PCD; 302 if ("PCV".equals(codeString)) 303 return PCV; 304 throw new FHIRException("Unknown EventTiming code '"+codeString+"'"); 305 } 306 public String toCode() { 307 switch (this) { 308 case HS: return "HS"; 309 case WAKE: return "WAKE"; 310 case C: return "C"; 311 case CM: return "CM"; 312 case CD: return "CD"; 313 case CV: return "CV"; 314 case AC: return "AC"; 315 case ACM: return "ACM"; 316 case ACD: return "ACD"; 317 case ACV: return "ACV"; 318 case PC: return "PC"; 319 case PCM: return "PCM"; 320 case PCD: return "PCD"; 321 case PCV: return "PCV"; 322 default: return "?"; 323 } 324 } 325 public String getSystem() { 326 switch (this) { 327 case HS: return "http://hl7.org/fhir/v3/TimingEvent"; 328 case WAKE: return "http://hl7.org/fhir/v3/TimingEvent"; 329 case C: return "http://hl7.org/fhir/v3/TimingEvent"; 330 case CM: return "http://hl7.org/fhir/v3/TimingEvent"; 331 case CD: return "http://hl7.org/fhir/v3/TimingEvent"; 332 case CV: return "http://hl7.org/fhir/v3/TimingEvent"; 333 case AC: return "http://hl7.org/fhir/v3/TimingEvent"; 334 case ACM: return "http://hl7.org/fhir/v3/TimingEvent"; 335 case ACD: return "http://hl7.org/fhir/v3/TimingEvent"; 336 case ACV: return "http://hl7.org/fhir/v3/TimingEvent"; 337 case PC: return "http://hl7.org/fhir/v3/TimingEvent"; 338 case PCM: return "http://hl7.org/fhir/v3/TimingEvent"; 339 case PCD: return "http://hl7.org/fhir/v3/TimingEvent"; 340 case PCV: return "http://hl7.org/fhir/v3/TimingEvent"; 341 default: return "?"; 342 } 343 } 344 public String getDefinition() { 345 switch (this) { 346 case HS: return ""; 347 case WAKE: return ""; 348 case C: return ""; 349 case CM: return ""; 350 case CD: return ""; 351 case CV: return ""; 352 case AC: return ""; 353 case ACM: return ""; 354 case ACD: return ""; 355 case ACV: return ""; 356 case PC: return ""; 357 case PCM: return ""; 358 case PCD: return ""; 359 case PCV: return ""; 360 default: return "?"; 361 } 362 } 363 public String getDisplay() { 364 switch (this) { 365 case HS: return "HS"; 366 case WAKE: return "WAKE"; 367 case C: return "C"; 368 case CM: return "CM"; 369 case CD: return "CD"; 370 case CV: return "CV"; 371 case AC: return "AC"; 372 case ACM: return "ACM"; 373 case ACD: return "ACD"; 374 case ACV: return "ACV"; 375 case PC: return "PC"; 376 case PCM: return "PCM"; 377 case PCD: return "PCD"; 378 case PCV: return "PCV"; 379 default: return "?"; 380 } 381 } 382 } 383 384 public static class EventTimingEnumFactory implements EnumFactory<EventTiming> { 385 public EventTiming fromCode(String codeString) throws IllegalArgumentException { 386 if (codeString == null || "".equals(codeString)) 387 if (codeString == null || "".equals(codeString)) 388 return null; 389 if ("HS".equals(codeString)) 390 return EventTiming.HS; 391 if ("WAKE".equals(codeString)) 392 return EventTiming.WAKE; 393 if ("C".equals(codeString)) 394 return EventTiming.C; 395 if ("CM".equals(codeString)) 396 return EventTiming.CM; 397 if ("CD".equals(codeString)) 398 return EventTiming.CD; 399 if ("CV".equals(codeString)) 400 return EventTiming.CV; 401 if ("AC".equals(codeString)) 402 return EventTiming.AC; 403 if ("ACM".equals(codeString)) 404 return EventTiming.ACM; 405 if ("ACD".equals(codeString)) 406 return EventTiming.ACD; 407 if ("ACV".equals(codeString)) 408 return EventTiming.ACV; 409 if ("PC".equals(codeString)) 410 return EventTiming.PC; 411 if ("PCM".equals(codeString)) 412 return EventTiming.PCM; 413 if ("PCD".equals(codeString)) 414 return EventTiming.PCD; 415 if ("PCV".equals(codeString)) 416 return EventTiming.PCV; 417 throw new IllegalArgumentException("Unknown EventTiming code '"+codeString+"'"); 418 } 419 public Enumeration<EventTiming> fromType(Base code) throws FHIRException { 420 if (code == null || code.isEmpty()) 421 return null; 422 String codeString = ((PrimitiveType) code).asStringValue(); 423 if (codeString == null || "".equals(codeString)) 424 return null; 425 if ("HS".equals(codeString)) 426 return new Enumeration<EventTiming>(this, EventTiming.HS); 427 if ("WAKE".equals(codeString)) 428 return new Enumeration<EventTiming>(this, EventTiming.WAKE); 429 if ("C".equals(codeString)) 430 return new Enumeration<EventTiming>(this, EventTiming.C); 431 if ("CM".equals(codeString)) 432 return new Enumeration<EventTiming>(this, EventTiming.CM); 433 if ("CD".equals(codeString)) 434 return new Enumeration<EventTiming>(this, EventTiming.CD); 435 if ("CV".equals(codeString)) 436 return new Enumeration<EventTiming>(this, EventTiming.CV); 437 if ("AC".equals(codeString)) 438 return new Enumeration<EventTiming>(this, EventTiming.AC); 439 if ("ACM".equals(codeString)) 440 return new Enumeration<EventTiming>(this, EventTiming.ACM); 441 if ("ACD".equals(codeString)) 442 return new Enumeration<EventTiming>(this, EventTiming.ACD); 443 if ("ACV".equals(codeString)) 444 return new Enumeration<EventTiming>(this, EventTiming.ACV); 445 if ("PC".equals(codeString)) 446 return new Enumeration<EventTiming>(this, EventTiming.PC); 447 if ("PCM".equals(codeString)) 448 return new Enumeration<EventTiming>(this, EventTiming.PCM); 449 if ("PCD".equals(codeString)) 450 return new Enumeration<EventTiming>(this, EventTiming.PCD); 451 if ("PCV".equals(codeString)) 452 return new Enumeration<EventTiming>(this, EventTiming.PCV); 453 throw new FHIRException("Unknown EventTiming code '"+codeString+"'"); 454 } 455 public String toCode(EventTiming code) { 456 if (code == EventTiming.HS) 457 return "HS"; 458 if (code == EventTiming.WAKE) 459 return "WAKE"; 460 if (code == EventTiming.C) 461 return "C"; 462 if (code == EventTiming.CM) 463 return "CM"; 464 if (code == EventTiming.CD) 465 return "CD"; 466 if (code == EventTiming.CV) 467 return "CV"; 468 if (code == EventTiming.AC) 469 return "AC"; 470 if (code == EventTiming.ACM) 471 return "ACM"; 472 if (code == EventTiming.ACD) 473 return "ACD"; 474 if (code == EventTiming.ACV) 475 return "ACV"; 476 if (code == EventTiming.PC) 477 return "PC"; 478 if (code == EventTiming.PCM) 479 return "PCM"; 480 if (code == EventTiming.PCD) 481 return "PCD"; 482 if (code == EventTiming.PCV) 483 return "PCV"; 484 return "?"; 485 } 486 } 487 488 @Block() 489 public static class TimingRepeatComponent extends Element implements IBaseDatatypeElement { 490 /** 491 * 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. 492 */ 493 @Child(name = "bounds", type = {Duration.class, Range.class, Period.class}, order=1, min=0, max=1, modifier=false, summary=true) 494 @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." ) 495 protected Type bounds; 496 497 /** 498 * A total count of the desired number of repetitions. 499 */ 500 @Child(name = "count", type = {IntegerType.class}, order=2, min=0, max=1, modifier=false, summary=true) 501 @Description(shortDefinition="Number of times to repeat", formalDefinition="A total count of the desired number of repetitions." ) 502 protected IntegerType count; 503 504 /** 505 * How long this thing happens for when it happens. 506 */ 507 @Child(name = "duration", type = {DecimalType.class}, order=3, min=0, max=1, modifier=false, summary=true) 508 @Description(shortDefinition="How long when it happens", formalDefinition="How long this thing happens for when it happens." ) 509 protected DecimalType duration; 510 511 /** 512 * The upper limit of how long this thing happens for when it happens. 513 */ 514 @Child(name = "durationMax", type = {DecimalType.class}, order=4, min=0, max=1, modifier=false, summary=true) 515 @Description(shortDefinition="How long when it happens (Max)", formalDefinition="The upper limit of how long this thing happens for when it happens." ) 516 protected DecimalType durationMax; 517 518 /** 519 * The units of time for the duration, in UCUM units. 520 */ 521 @Child(name = "durationUnits", type = {CodeType.class}, order=5, min=0, max=1, modifier=false, summary=true) 522 @Description(shortDefinition="s | min | h | d | wk | mo | a - unit of time (UCUM)", formalDefinition="The units of time for the duration, in UCUM units." ) 523 protected Enumeration<UnitsOfTime> durationUnits; 524 525 /** 526 * The number of times to repeat the action within the specified period / period range (i.e. both period and periodMax provided). 527 */ 528 @Child(name = "frequency", type = {IntegerType.class}, order=6, min=0, max=1, modifier=false, summary=true) 529 @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)." ) 530 protected IntegerType frequency; 531 532 /** 533 * If present, indicates that the frequency is a range - so repeat between [frequency] and [frequencyMax] times within the period or period range. 534 */ 535 @Child(name = "frequencyMax", type = {IntegerType.class}, order=7, min=0, max=1, modifier=false, summary=true) 536 @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." ) 537 protected IntegerType frequencyMax; 538 539 /** 540 * 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. 541 */ 542 @Child(name = "period", type = {DecimalType.class}, order=8, min=0, max=1, modifier=false, summary=true) 543 @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." ) 544 protected DecimalType period; 545 546 /** 547 * 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. 548 */ 549 @Child(name = "periodMax", type = {DecimalType.class}, order=9, min=0, max=1, modifier=false, summary=true) 550 @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." ) 551 protected DecimalType periodMax; 552 553 /** 554 * The units of time for the period in UCUM units. 555 */ 556 @Child(name = "periodUnits", type = {CodeType.class}, order=10, min=0, max=1, modifier=false, summary=true) 557 @Description(shortDefinition="s | min | h | d | wk | mo | a - unit of time (UCUM)", formalDefinition="The units of time for the period in UCUM units." ) 558 protected Enumeration<UnitsOfTime> periodUnits; 559 560 /** 561 * A real world event that the occurrence of the event should be tied to. 562 */ 563 @Child(name = "when", type = {CodeType.class}, order=11, min=0, max=1, modifier=false, summary=true) 564 @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." ) 565 protected Enumeration<EventTiming> when; 566 567 private static final long serialVersionUID = -585686982L; 568 569 /* 570 * Constructor 571 */ 572 public TimingRepeatComponent() { 573 super(); 574 } 575 576 /** 577 * @return {@link #bounds} (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.) 578 */ 579 public Type getBounds() { 580 return this.bounds; 581 } 582 583 /** 584 * @return {@link #bounds} (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.) 585 */ 586 public Duration getBoundsDuration() throws FHIRException { 587 if (!(this.bounds instanceof Duration)) 588 throw new FHIRException("Type mismatch: the type Duration was expected, but "+this.bounds.getClass().getName()+" was encountered"); 589 return (Duration) this.bounds; 590 } 591 592 public boolean hasBoundsDuration() { 593 return this.bounds instanceof Duration; 594 } 595 596 /** 597 * @return {@link #bounds} (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.) 598 */ 599 public Range getBoundsRange() throws FHIRException { 600 if (!(this.bounds instanceof Range)) 601 throw new FHIRException("Type mismatch: the type Range was expected, but "+this.bounds.getClass().getName()+" was encountered"); 602 return (Range) this.bounds; 603 } 604 605 public boolean hasBoundsRange() { 606 return this.bounds instanceof Range; 607 } 608 609 /** 610 * @return {@link #bounds} (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.) 611 */ 612 public Period getBoundsPeriod() throws FHIRException { 613 if (!(this.bounds instanceof Period)) 614 throw new FHIRException("Type mismatch: the type Period was expected, but "+this.bounds.getClass().getName()+" was encountered"); 615 return (Period) this.bounds; 616 } 617 618 public boolean hasBoundsPeriod() { 619 return this.bounds instanceof Period; 620 } 621 622 public boolean hasBounds() { 623 return this.bounds != null && !this.bounds.isEmpty(); 624 } 625 626 /** 627 * @param value {@link #bounds} (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.) 628 */ 629 public TimingRepeatComponent setBounds(Type value) { 630 this.bounds = value; 631 return this; 632 } 633 634 /** 635 * @return {@link #count} (A total count of the desired number of repetitions.). This is the underlying object with id, value and extensions. The accessor "getCount" gives direct access to the value 636 */ 637 public IntegerType getCountElement() { 638 if (this.count == null) 639 if (Configuration.errorOnAutoCreate()) 640 throw new Error("Attempt to auto-create TimingRepeatComponent.count"); 641 else if (Configuration.doAutoCreate()) 642 this.count = new IntegerType(); // bb 643 return this.count; 644 } 645 646 public boolean hasCountElement() { 647 return this.count != null && !this.count.isEmpty(); 648 } 649 650 public boolean hasCount() { 651 return this.count != null && !this.count.isEmpty(); 652 } 653 654 /** 655 * @param value {@link #count} (A total count of the desired number of repetitions.). This is the underlying object with id, value and extensions. The accessor "getCount" gives direct access to the value 656 */ 657 public TimingRepeatComponent setCountElement(IntegerType value) { 658 this.count = value; 659 return this; 660 } 661 662 /** 663 * @return A total count of the desired number of repetitions. 664 */ 665 public int getCount() { 666 return this.count == null || this.count.isEmpty() ? 0 : this.count.getValue(); 667 } 668 669 /** 670 * @param value A total count of the desired number of repetitions. 671 */ 672 public TimingRepeatComponent setCount(int value) { 673 if (this.count == null) 674 this.count = new IntegerType(); 675 this.count.setValue(value); 676 return this; 677 } 678 679 /** 680 * @return {@link #duration} (How long this thing happens for when it happens.). This is the underlying object with id, value and extensions. The accessor "getDuration" gives direct access to the value 681 */ 682 public DecimalType getDurationElement() { 683 if (this.duration == null) 684 if (Configuration.errorOnAutoCreate()) 685 throw new Error("Attempt to auto-create TimingRepeatComponent.duration"); 686 else if (Configuration.doAutoCreate()) 687 this.duration = new DecimalType(); // bb 688 return this.duration; 689 } 690 691 public boolean hasDurationElement() { 692 return this.duration != null && !this.duration.isEmpty(); 693 } 694 695 public boolean hasDuration() { 696 return this.duration != null && !this.duration.isEmpty(); 697 } 698 699 /** 700 * @param value {@link #duration} (How long this thing happens for when it happens.). This is the underlying object with id, value and extensions. The accessor "getDuration" gives direct access to the value 701 */ 702 public TimingRepeatComponent setDurationElement(DecimalType value) { 703 this.duration = value; 704 return this; 705 } 706 707 /** 708 * @return How long this thing happens for when it happens. 709 */ 710 public BigDecimal getDuration() { 711 return this.duration == null ? null : this.duration.getValue(); 712 } 713 714 /** 715 * @param value How long this thing happens for when it happens. 716 */ 717 public TimingRepeatComponent setDuration(BigDecimal value) { 718 if (value == null) 719 this.duration = null; 720 else { 721 if (this.duration == null) 722 this.duration = new DecimalType(); 723 this.duration.setValue(value); 724 } 725 return this; 726 } 727 728 /** 729 * @return {@link #durationMax} (The upper limit of how long this thing happens for when it happens.). This is the underlying object with id, value and extensions. The accessor "getDurationMax" gives direct access to the value 730 */ 731 public DecimalType getDurationMaxElement() { 732 if (this.durationMax == null) 733 if (Configuration.errorOnAutoCreate()) 734 throw new Error("Attempt to auto-create TimingRepeatComponent.durationMax"); 735 else if (Configuration.doAutoCreate()) 736 this.durationMax = new DecimalType(); // bb 737 return this.durationMax; 738 } 739 740 public boolean hasDurationMaxElement() { 741 return this.durationMax != null && !this.durationMax.isEmpty(); 742 } 743 744 public boolean hasDurationMax() { 745 return this.durationMax != null && !this.durationMax.isEmpty(); 746 } 747 748 /** 749 * @param value {@link #durationMax} (The upper limit of how long this thing happens for when it happens.). This is the underlying object with id, value and extensions. The accessor "getDurationMax" gives direct access to the value 750 */ 751 public TimingRepeatComponent setDurationMaxElement(DecimalType value) { 752 this.durationMax = value; 753 return this; 754 } 755 756 /** 757 * @return The upper limit of how long this thing happens for when it happens. 758 */ 759 public BigDecimal getDurationMax() { 760 return this.durationMax == null ? null : this.durationMax.getValue(); 761 } 762 763 /** 764 * @param value The upper limit of how long this thing happens for when it happens. 765 */ 766 public TimingRepeatComponent setDurationMax(BigDecimal value) { 767 if (value == null) 768 this.durationMax = null; 769 else { 770 if (this.durationMax == null) 771 this.durationMax = new DecimalType(); 772 this.durationMax.setValue(value); 773 } 774 return this; 775 } 776 777 /** 778 * @return {@link #durationUnits} (The units of time for the duration, in UCUM units.). This is the underlying object with id, value and extensions. The accessor "getDurationUnits" gives direct access to the value 779 */ 780 public Enumeration<UnitsOfTime> getDurationUnitsElement() { 781 if (this.durationUnits == null) 782 if (Configuration.errorOnAutoCreate()) 783 throw new Error("Attempt to auto-create TimingRepeatComponent.durationUnits"); 784 else if (Configuration.doAutoCreate()) 785 this.durationUnits = new Enumeration<UnitsOfTime>(new UnitsOfTimeEnumFactory()); // bb 786 return this.durationUnits; 787 } 788 789 public boolean hasDurationUnitsElement() { 790 return this.durationUnits != null && !this.durationUnits.isEmpty(); 791 } 792 793 public boolean hasDurationUnits() { 794 return this.durationUnits != null && !this.durationUnits.isEmpty(); 795 } 796 797 /** 798 * @param value {@link #durationUnits} (The units of time for the duration, in UCUM units.). This is the underlying object with id, value and extensions. The accessor "getDurationUnits" gives direct access to the value 799 */ 800 public TimingRepeatComponent setDurationUnitsElement(Enumeration<UnitsOfTime> value) { 801 this.durationUnits = value; 802 return this; 803 } 804 805 /** 806 * @return The units of time for the duration, in UCUM units. 807 */ 808 public UnitsOfTime getDurationUnits() { 809 return this.durationUnits == null ? null : this.durationUnits.getValue(); 810 } 811 812 /** 813 * @param value The units of time for the duration, in UCUM units. 814 */ 815 public TimingRepeatComponent setDurationUnits(UnitsOfTime value) { 816 if (value == null) 817 this.durationUnits = null; 818 else { 819 if (this.durationUnits == null) 820 this.durationUnits = new Enumeration<UnitsOfTime>(new UnitsOfTimeEnumFactory()); 821 this.durationUnits.setValue(value); 822 } 823 return this; 824 } 825 826 /** 827 * @return {@link #frequency} (The number of times to repeat the action within the specified period / period range (i.e. both period and periodMax provided).). This is the underlying object with id, value and extensions. The accessor "getFrequency" gives direct access to the value 828 */ 829 public IntegerType getFrequencyElement() { 830 if (this.frequency == null) 831 if (Configuration.errorOnAutoCreate()) 832 throw new Error("Attempt to auto-create TimingRepeatComponent.frequency"); 833 else if (Configuration.doAutoCreate()) 834 this.frequency = new IntegerType(); // bb 835 return this.frequency; 836 } 837 838 public boolean hasFrequencyElement() { 839 return this.frequency != null && !this.frequency.isEmpty(); 840 } 841 842 public boolean hasFrequency() { 843 return this.frequency != null && !this.frequency.isEmpty(); 844 } 845 846 /** 847 * @param value {@link #frequency} (The number of times to repeat the action within the specified period / period range (i.e. both period and periodMax provided).). This is the underlying object with id, value and extensions. The accessor "getFrequency" gives direct access to the value 848 */ 849 public TimingRepeatComponent setFrequencyElement(IntegerType value) { 850 this.frequency = value; 851 return this; 852 } 853 854 /** 855 * @return The number of times to repeat the action within the specified period / period range (i.e. both period and periodMax provided). 856 */ 857 public int getFrequency() { 858 return this.frequency == null || this.frequency.isEmpty() ? 0 : this.frequency.getValue(); 859 } 860 861 /** 862 * @param value The number of times to repeat the action within the specified period / period range (i.e. both period and periodMax provided). 863 */ 864 public TimingRepeatComponent setFrequency(int value) { 865 if (this.frequency == null) 866 this.frequency = new IntegerType(); 867 this.frequency.setValue(value); 868 return this; 869 } 870 871 /** 872 * @return {@link #frequencyMax} (If present, indicates that the frequency is a range - so repeat between [frequency] and [frequencyMax] times within the period or period range.). This is the underlying object with id, value and extensions. The accessor "getFrequencyMax" gives direct access to the value 873 */ 874 public IntegerType getFrequencyMaxElement() { 875 if (this.frequencyMax == null) 876 if (Configuration.errorOnAutoCreate()) 877 throw new Error("Attempt to auto-create TimingRepeatComponent.frequencyMax"); 878 else if (Configuration.doAutoCreate()) 879 this.frequencyMax = new IntegerType(); // bb 880 return this.frequencyMax; 881 } 882 883 public boolean hasFrequencyMaxElement() { 884 return this.frequencyMax != null && !this.frequencyMax.isEmpty(); 885 } 886 887 public boolean hasFrequencyMax() { 888 return this.frequencyMax != null && !this.frequencyMax.isEmpty(); 889 } 890 891 /** 892 * @param value {@link #frequencyMax} (If present, indicates that the frequency is a range - so repeat between [frequency] and [frequencyMax] times within the period or period range.). This is the underlying object with id, value and extensions. The accessor "getFrequencyMax" gives direct access to the value 893 */ 894 public TimingRepeatComponent setFrequencyMaxElement(IntegerType value) { 895 this.frequencyMax = value; 896 return this; 897 } 898 899 /** 900 * @return If present, indicates that the frequency is a range - so repeat between [frequency] and [frequencyMax] times within the period or period range. 901 */ 902 public int getFrequencyMax() { 903 return this.frequencyMax == null || this.frequencyMax.isEmpty() ? 0 : this.frequencyMax.getValue(); 904 } 905 906 /** 907 * @param value If present, indicates that the frequency is a range - so repeat between [frequency] and [frequencyMax] times within the period or period range. 908 */ 909 public TimingRepeatComponent setFrequencyMax(int value) { 910 if (this.frequencyMax == null) 911 this.frequencyMax = new IntegerType(); 912 this.frequencyMax.setValue(value); 913 return this; 914 } 915 916 /** 917 * @return {@link #period} (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.). This is the underlying object with id, value and extensions. The accessor "getPeriod" gives direct access to the value 918 */ 919 public DecimalType getPeriodElement() { 920 if (this.period == null) 921 if (Configuration.errorOnAutoCreate()) 922 throw new Error("Attempt to auto-create TimingRepeatComponent.period"); 923 else if (Configuration.doAutoCreate()) 924 this.period = new DecimalType(); // bb 925 return this.period; 926 } 927 928 public boolean hasPeriodElement() { 929 return this.period != null && !this.period.isEmpty(); 930 } 931 932 public boolean hasPeriod() { 933 return this.period != null && !this.period.isEmpty(); 934 } 935 936 /** 937 * @param value {@link #period} (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.). This is the underlying object with id, value and extensions. The accessor "getPeriod" gives direct access to the value 938 */ 939 public TimingRepeatComponent setPeriodElement(DecimalType value) { 940 this.period = value; 941 return this; 942 } 943 944 /** 945 * @return 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. 946 */ 947 public BigDecimal getPeriod() { 948 return this.period == null ? null : this.period.getValue(); 949 } 950 951 /** 952 * @param value 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. 953 */ 954 public TimingRepeatComponent setPeriod(BigDecimal value) { 955 if (value == null) 956 this.period = null; 957 else { 958 if (this.period == null) 959 this.period = new DecimalType(); 960 this.period.setValue(value); 961 } 962 return this; 963 } 964 965 /** 966 * @return {@link #periodMax} (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.). This is the underlying object with id, value and extensions. The accessor "getPeriodMax" gives direct access to the value 967 */ 968 public DecimalType getPeriodMaxElement() { 969 if (this.periodMax == null) 970 if (Configuration.errorOnAutoCreate()) 971 throw new Error("Attempt to auto-create TimingRepeatComponent.periodMax"); 972 else if (Configuration.doAutoCreate()) 973 this.periodMax = new DecimalType(); // bb 974 return this.periodMax; 975 } 976 977 public boolean hasPeriodMaxElement() { 978 return this.periodMax != null && !this.periodMax.isEmpty(); 979 } 980 981 public boolean hasPeriodMax() { 982 return this.periodMax != null && !this.periodMax.isEmpty(); 983 } 984 985 /** 986 * @param value {@link #periodMax} (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.). This is the underlying object with id, value and extensions. The accessor "getPeriodMax" gives direct access to the value 987 */ 988 public TimingRepeatComponent setPeriodMaxElement(DecimalType value) { 989 this.periodMax = value; 990 return this; 991 } 992 993 /** 994 * @return 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. 995 */ 996 public BigDecimal getPeriodMax() { 997 return this.periodMax == null ? null : this.periodMax.getValue(); 998 } 999 1000 /** 1001 * @param value 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. 1002 */ 1003 public TimingRepeatComponent setPeriodMax(BigDecimal value) { 1004 if (value == null) 1005 this.periodMax = null; 1006 else { 1007 if (this.periodMax == null) 1008 this.periodMax = new DecimalType(); 1009 this.periodMax.setValue(value); 1010 } 1011 return this; 1012 } 1013 1014 /** 1015 * @return {@link #periodUnits} (The units of time for the period in UCUM units.). This is the underlying object with id, value and extensions. The accessor "getPeriodUnits" gives direct access to the value 1016 */ 1017 public Enumeration<UnitsOfTime> getPeriodUnitsElement() { 1018 if (this.periodUnits == null) 1019 if (Configuration.errorOnAutoCreate()) 1020 throw new Error("Attempt to auto-create TimingRepeatComponent.periodUnits"); 1021 else if (Configuration.doAutoCreate()) 1022 this.periodUnits = new Enumeration<UnitsOfTime>(new UnitsOfTimeEnumFactory()); // bb 1023 return this.periodUnits; 1024 } 1025 1026 public boolean hasPeriodUnitsElement() { 1027 return this.periodUnits != null && !this.periodUnits.isEmpty(); 1028 } 1029 1030 public boolean hasPeriodUnits() { 1031 return this.periodUnits != null && !this.periodUnits.isEmpty(); 1032 } 1033 1034 /** 1035 * @param value {@link #periodUnits} (The units of time for the period in UCUM units.). This is the underlying object with id, value and extensions. The accessor "getPeriodUnits" gives direct access to the value 1036 */ 1037 public TimingRepeatComponent setPeriodUnitsElement(Enumeration<UnitsOfTime> value) { 1038 this.periodUnits = value; 1039 return this; 1040 } 1041 1042 /** 1043 * @return The units of time for the period in UCUM units. 1044 */ 1045 public UnitsOfTime getPeriodUnits() { 1046 return this.periodUnits == null ? null : this.periodUnits.getValue(); 1047 } 1048 1049 /** 1050 * @param value The units of time for the period in UCUM units. 1051 */ 1052 public TimingRepeatComponent setPeriodUnits(UnitsOfTime value) { 1053 if (value == null) 1054 this.periodUnits = null; 1055 else { 1056 if (this.periodUnits == null) 1057 this.periodUnits = new Enumeration<UnitsOfTime>(new UnitsOfTimeEnumFactory()); 1058 this.periodUnits.setValue(value); 1059 } 1060 return this; 1061 } 1062 1063 /** 1064 * @return {@link #when} (A real world event that the occurrence of the event should be tied to.). This is the underlying object with id, value and extensions. The accessor "getWhen" gives direct access to the value 1065 */ 1066 public Enumeration<EventTiming> getWhenElement() { 1067 if (this.when == null) 1068 if (Configuration.errorOnAutoCreate()) 1069 throw new Error("Attempt to auto-create TimingRepeatComponent.when"); 1070 else if (Configuration.doAutoCreate()) 1071 this.when = new Enumeration<EventTiming>(new EventTimingEnumFactory()); // bb 1072 return this.when; 1073 } 1074 1075 public boolean hasWhenElement() { 1076 return this.when != null && !this.when.isEmpty(); 1077 } 1078 1079 public boolean hasWhen() { 1080 return this.when != null && !this.when.isEmpty(); 1081 } 1082 1083 /** 1084 * @param value {@link #when} (A real world event that the occurrence of the event should be tied to.). This is the underlying object with id, value and extensions. The accessor "getWhen" gives direct access to the value 1085 */ 1086 public TimingRepeatComponent setWhenElement(Enumeration<EventTiming> value) { 1087 this.when = value; 1088 return this; 1089 } 1090 1091 /** 1092 * @return A real world event that the occurrence of the event should be tied to. 1093 */ 1094 public EventTiming getWhen() { 1095 return this.when == null ? null : this.when.getValue(); 1096 } 1097 1098 /** 1099 * @param value A real world event that the occurrence of the event should be tied to. 1100 */ 1101 public TimingRepeatComponent setWhen(EventTiming value) { 1102 if (value == null) 1103 this.when = null; 1104 else { 1105 if (this.when == null) 1106 this.when = new Enumeration<EventTiming>(new EventTimingEnumFactory()); 1107 this.when.setValue(value); 1108 } 1109 return this; 1110 } 1111 1112 protected void listChildren(List<Property> childrenList) { 1113 super.listChildren(childrenList); 1114 childrenList.add(new Property("bounds[x]", "Duration|Range|Period", "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.", 0, java.lang.Integer.MAX_VALUE, bounds)); 1115 childrenList.add(new Property("count", "integer", "A total count of the desired number of repetitions.", 0, java.lang.Integer.MAX_VALUE, count)); 1116 childrenList.add(new Property("duration", "decimal", "How long this thing happens for when it happens.", 0, java.lang.Integer.MAX_VALUE, duration)); 1117 childrenList.add(new Property("durationMax", "decimal", "The upper limit of how long this thing happens for when it happens.", 0, java.lang.Integer.MAX_VALUE, durationMax)); 1118 childrenList.add(new Property("durationUnits", "code", "The units of time for the duration, in UCUM units.", 0, java.lang.Integer.MAX_VALUE, durationUnits)); 1119 childrenList.add(new Property("frequency", "integer", "The number of times to repeat the action within the specified period / period range (i.e. both period and periodMax provided).", 0, java.lang.Integer.MAX_VALUE, frequency)); 1120 childrenList.add(new Property("frequencyMax", "integer", "If present, indicates that the frequency is a range - so repeat between [frequency] and [frequencyMax] times within the period or period range.", 0, java.lang.Integer.MAX_VALUE, frequencyMax)); 1121 childrenList.add(new Property("period", "decimal", "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.", 0, java.lang.Integer.MAX_VALUE, period)); 1122 childrenList.add(new Property("periodMax", "decimal", "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.", 0, java.lang.Integer.MAX_VALUE, periodMax)); 1123 childrenList.add(new Property("periodUnits", "code", "The units of time for the period in UCUM units.", 0, java.lang.Integer.MAX_VALUE, periodUnits)); 1124 childrenList.add(new Property("when", "code", "A real world event that the occurrence of the event should be tied to.", 0, java.lang.Integer.MAX_VALUE, when)); 1125 } 1126 1127 @Override 1128 public void setProperty(String name, Base value) throws FHIRException { 1129 if (name.equals("bounds[x]")) 1130 this.bounds = (Type) value; // Type 1131 else if (name.equals("count")) 1132 this.count = castToInteger(value); // IntegerType 1133 else if (name.equals("duration")) 1134 this.duration = castToDecimal(value); // DecimalType 1135 else if (name.equals("durationMax")) 1136 this.durationMax = castToDecimal(value); // DecimalType 1137 else if (name.equals("durationUnits")) 1138 this.durationUnits = new UnitsOfTimeEnumFactory().fromType(value); // Enumeration<UnitsOfTime> 1139 else if (name.equals("frequency")) 1140 this.frequency = castToInteger(value); // IntegerType 1141 else if (name.equals("frequencyMax")) 1142 this.frequencyMax = castToInteger(value); // IntegerType 1143 else if (name.equals("period")) 1144 this.period = castToDecimal(value); // DecimalType 1145 else if (name.equals("periodMax")) 1146 this.periodMax = castToDecimal(value); // DecimalType 1147 else if (name.equals("periodUnits")) 1148 this.periodUnits = new UnitsOfTimeEnumFactory().fromType(value); // Enumeration<UnitsOfTime> 1149 else if (name.equals("when")) 1150 this.when = new EventTimingEnumFactory().fromType(value); // Enumeration<EventTiming> 1151 else 1152 super.setProperty(name, value); 1153 } 1154 1155 @Override 1156 public Base addChild(String name) throws FHIRException { 1157 if (name.equals("boundsDuration")) { 1158 this.bounds = new Duration(); 1159 return this.bounds; 1160 } 1161 else if (name.equals("boundsRange")) { 1162 this.bounds = new Range(); 1163 return this.bounds; 1164 } 1165 else if (name.equals("boundsPeriod")) { 1166 this.bounds = new Period(); 1167 return this.bounds; 1168 } 1169 else if (name.equals("count")) { 1170 throw new FHIRException("Cannot call addChild on a primitive type Timing.count"); 1171 } 1172 else if (name.equals("duration")) { 1173 throw new FHIRException("Cannot call addChild on a primitive type Timing.duration"); 1174 } 1175 else if (name.equals("durationMax")) { 1176 throw new FHIRException("Cannot call addChild on a primitive type Timing.durationMax"); 1177 } 1178 else if (name.equals("durationUnits")) { 1179 throw new FHIRException("Cannot call addChild on a primitive type Timing.durationUnits"); 1180 } 1181 else if (name.equals("frequency")) { 1182 throw new FHIRException("Cannot call addChild on a primitive type Timing.frequency"); 1183 } 1184 else if (name.equals("frequencyMax")) { 1185 throw new FHIRException("Cannot call addChild on a primitive type Timing.frequencyMax"); 1186 } 1187 else if (name.equals("period")) { 1188 throw new FHIRException("Cannot call addChild on a primitive type Timing.period"); 1189 } 1190 else if (name.equals("periodMax")) { 1191 throw new FHIRException("Cannot call addChild on a primitive type Timing.periodMax"); 1192 } 1193 else if (name.equals("periodUnits")) { 1194 throw new FHIRException("Cannot call addChild on a primitive type Timing.periodUnits"); 1195 } 1196 else if (name.equals("when")) { 1197 throw new FHIRException("Cannot call addChild on a primitive type Timing.when"); 1198 } 1199 else 1200 return super.addChild(name); 1201 } 1202 1203 public TimingRepeatComponent copy() { 1204 TimingRepeatComponent dst = new TimingRepeatComponent(); 1205 copyValues(dst); 1206 dst.bounds = bounds == null ? null : bounds.copy(); 1207 dst.count = count == null ? null : count.copy(); 1208 dst.duration = duration == null ? null : duration.copy(); 1209 dst.durationMax = durationMax == null ? null : durationMax.copy(); 1210 dst.durationUnits = durationUnits == null ? null : durationUnits.copy(); 1211 dst.frequency = frequency == null ? null : frequency.copy(); 1212 dst.frequencyMax = frequencyMax == null ? null : frequencyMax.copy(); 1213 dst.period = period == null ? null : period.copy(); 1214 dst.periodMax = periodMax == null ? null : periodMax.copy(); 1215 dst.periodUnits = periodUnits == null ? null : periodUnits.copy(); 1216 dst.when = when == null ? null : when.copy(); 1217 return dst; 1218 } 1219 1220 @Override 1221 public boolean equalsDeep(Base other) { 1222 if (!super.equalsDeep(other)) 1223 return false; 1224 if (!(other instanceof TimingRepeatComponent)) 1225 return false; 1226 TimingRepeatComponent o = (TimingRepeatComponent) other; 1227 return compareDeep(bounds, o.bounds, true) && compareDeep(count, o.count, true) && compareDeep(duration, o.duration, true) 1228 && compareDeep(durationMax, o.durationMax, true) && compareDeep(durationUnits, o.durationUnits, true) 1229 && compareDeep(frequency, o.frequency, true) && compareDeep(frequencyMax, o.frequencyMax, true) 1230 && compareDeep(period, o.period, true) && compareDeep(periodMax, o.periodMax, true) && compareDeep(periodUnits, o.periodUnits, true) 1231 && compareDeep(when, o.when, true); 1232 } 1233 1234 @Override 1235 public boolean equalsShallow(Base other) { 1236 if (!super.equalsShallow(other)) 1237 return false; 1238 if (!(other instanceof TimingRepeatComponent)) 1239 return false; 1240 TimingRepeatComponent o = (TimingRepeatComponent) other; 1241 return compareValues(count, o.count, true) && compareValues(duration, o.duration, true) && compareValues(durationMax, o.durationMax, true) 1242 && compareValues(durationUnits, o.durationUnits, true) && compareValues(frequency, o.frequency, true) 1243 && compareValues(frequencyMax, o.frequencyMax, true) && compareValues(period, o.period, true) && compareValues(periodMax, o.periodMax, true) 1244 && compareValues(periodUnits, o.periodUnits, true) && compareValues(when, o.when, true); 1245 } 1246 1247 public boolean isEmpty() { 1248 return super.isEmpty() && (bounds == null || bounds.isEmpty()) && (count == null || count.isEmpty()) 1249 && (duration == null || duration.isEmpty()) && (durationMax == null || durationMax.isEmpty()) 1250 && (durationUnits == null || durationUnits.isEmpty()) && (frequency == null || frequency.isEmpty()) 1251 && (frequencyMax == null || frequencyMax.isEmpty()) && (period == null || period.isEmpty()) 1252 && (periodMax == null || periodMax.isEmpty()) && (periodUnits == null || periodUnits.isEmpty()) 1253 && (when == null || when.isEmpty()); 1254 } 1255 1256 public String fhirType() { 1257 return "Timing.repeat"; 1258 1259 } 1260 1261 } 1262 1263 /** 1264 * Identifies specific times when the event occurs. 1265 */ 1266 @Child(name = "event", type = {DateTimeType.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 1267 @Description(shortDefinition="When the event occurs", formalDefinition="Identifies specific times when the event occurs." ) 1268 protected List<DateTimeType> event; 1269 1270 /** 1271 * A set of rules that describe when the event should occur. 1272 */ 1273 @Child(name = "repeat", type = {}, order=1, min=0, max=1, modifier=false, summary=true) 1274 @Description(shortDefinition="When the event is to occur", formalDefinition="A set of rules that describe when the event should occur." ) 1275 protected TimingRepeatComponent repeat; 1276 1277 /** 1278 * A code for the timing pattern. Some codes such as BID are ubiquitous, but many institutions define their own additional codes. 1279 */ 1280 @Child(name = "code", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true) 1281 @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." ) 1282 protected CodeableConcept code; 1283 1284 private static final long serialVersionUID = 791565112L; 1285 1286 /* 1287 * Constructor 1288 */ 1289 public Timing() { 1290 super(); 1291 } 1292 1293 /** 1294 * @return {@link #event} (Identifies specific times when the event occurs.) 1295 */ 1296 public List<DateTimeType> getEvent() { 1297 if (this.event == null) 1298 this.event = new ArrayList<DateTimeType>(); 1299 return this.event; 1300 } 1301 1302 public boolean hasEvent() { 1303 if (this.event == null) 1304 return false; 1305 for (DateTimeType item : this.event) 1306 if (!item.isEmpty()) 1307 return true; 1308 return false; 1309 } 1310 1311 /** 1312 * @return {@link #event} (Identifies specific times when the event occurs.) 1313 */ 1314 // syntactic sugar 1315 public DateTimeType addEventElement() {//2 1316 DateTimeType t = new DateTimeType(); 1317 if (this.event == null) 1318 this.event = new ArrayList<DateTimeType>(); 1319 this.event.add(t); 1320 return t; 1321 } 1322 1323 /** 1324 * @param value {@link #event} (Identifies specific times when the event occurs.) 1325 */ 1326 public Timing addEvent(Date value) { //1 1327 DateTimeType t = new DateTimeType(); 1328 t.setValue(value); 1329 if (this.event == null) 1330 this.event = new ArrayList<DateTimeType>(); 1331 this.event.add(t); 1332 return this; 1333 } 1334 1335 /** 1336 * @param value {@link #event} (Identifies specific times when the event occurs.) 1337 */ 1338 public boolean hasEvent(Date value) { 1339 if (this.event == null) 1340 return false; 1341 for (DateTimeType v : this.event) 1342 if (v.equals(value)) // dateTime 1343 return true; 1344 return false; 1345 } 1346 1347 /** 1348 * @return {@link #repeat} (A set of rules that describe when the event should occur.) 1349 */ 1350 public TimingRepeatComponent getRepeat() { 1351 if (this.repeat == null) 1352 if (Configuration.errorOnAutoCreate()) 1353 throw new Error("Attempt to auto-create Timing.repeat"); 1354 else if (Configuration.doAutoCreate()) 1355 this.repeat = new TimingRepeatComponent(); // cc 1356 return this.repeat; 1357 } 1358 1359 public boolean hasRepeat() { 1360 return this.repeat != null && !this.repeat.isEmpty(); 1361 } 1362 1363 /** 1364 * @param value {@link #repeat} (A set of rules that describe when the event should occur.) 1365 */ 1366 public Timing setRepeat(TimingRepeatComponent value) { 1367 this.repeat = value; 1368 return this; 1369 } 1370 1371 /** 1372 * @return {@link #code} (A code for the timing pattern. Some codes such as BID are ubiquitous, but many institutions define their own additional codes.) 1373 */ 1374 public CodeableConcept getCode() { 1375 if (this.code == null) 1376 if (Configuration.errorOnAutoCreate()) 1377 throw new Error("Attempt to auto-create Timing.code"); 1378 else if (Configuration.doAutoCreate()) 1379 this.code = new CodeableConcept(); // cc 1380 return this.code; 1381 } 1382 1383 public boolean hasCode() { 1384 return this.code != null && !this.code.isEmpty(); 1385 } 1386 1387 /** 1388 * @param value {@link #code} (A code for the timing pattern. Some codes such as BID are ubiquitous, but many institutions define their own additional codes.) 1389 */ 1390 public Timing setCode(CodeableConcept value) { 1391 this.code = value; 1392 return this; 1393 } 1394 1395 protected void listChildren(List<Property> childrenList) { 1396 super.listChildren(childrenList); 1397 childrenList.add(new Property("event", "dateTime", "Identifies specific times when the event occurs.", 0, java.lang.Integer.MAX_VALUE, event)); 1398 childrenList.add(new Property("repeat", "", "A set of rules that describe when the event should occur.", 0, java.lang.Integer.MAX_VALUE, repeat)); 1399 childrenList.add(new Property("code", "CodeableConcept", "A code for the timing pattern. Some codes such as BID are ubiquitous, but many institutions define their own additional codes.", 0, java.lang.Integer.MAX_VALUE, code)); 1400 } 1401 1402 @Override 1403 public void setProperty(String name, Base value) throws FHIRException { 1404 if (name.equals("event")) 1405 this.getEvent().add(castToDateTime(value)); 1406 else if (name.equals("repeat")) 1407 this.repeat = (TimingRepeatComponent) value; // TimingRepeatComponent 1408 else if (name.equals("code")) 1409 this.code = castToCodeableConcept(value); // CodeableConcept 1410 else 1411 super.setProperty(name, value); 1412 } 1413 1414 @Override 1415 public Base addChild(String name) throws FHIRException { 1416 if (name.equals("event")) { 1417 throw new FHIRException("Cannot call addChild on a primitive type Timing.event"); 1418 } 1419 else if (name.equals("repeat")) { 1420 this.repeat = new TimingRepeatComponent(); 1421 return this.repeat; 1422 } 1423 else if (name.equals("code")) { 1424 this.code = new CodeableConcept(); 1425 return this.code; 1426 } 1427 else 1428 return super.addChild(name); 1429 } 1430 1431 public String fhirType() { 1432 return "Timing"; 1433 1434 } 1435 1436 public Timing copy() { 1437 Timing dst = new Timing(); 1438 copyValues(dst); 1439 if (event != null) { 1440 dst.event = new ArrayList<DateTimeType>(); 1441 for (DateTimeType i : event) 1442 dst.event.add(i.copy()); 1443 }; 1444 dst.repeat = repeat == null ? null : repeat.copy(); 1445 dst.code = code == null ? null : code.copy(); 1446 return dst; 1447 } 1448 1449 protected Timing typedCopy() { 1450 return copy(); 1451 } 1452 1453 @Override 1454 public boolean equalsDeep(Base other) { 1455 if (!super.equalsDeep(other)) 1456 return false; 1457 if (!(other instanceof Timing)) 1458 return false; 1459 Timing o = (Timing) other; 1460 return compareDeep(event, o.event, true) && compareDeep(repeat, o.repeat, true) && compareDeep(code, o.code, true) 1461 ; 1462 } 1463 1464 @Override 1465 public boolean equalsShallow(Base other) { 1466 if (!super.equalsShallow(other)) 1467 return false; 1468 if (!(other instanceof Timing)) 1469 return false; 1470 Timing o = (Timing) other; 1471 return compareValues(event, o.event, true); 1472 } 1473 1474 public boolean isEmpty() { 1475 return super.isEmpty() && (event == null || event.isEmpty()) && (repeat == null || repeat.isEmpty()) 1476 && (code == null || code.isEmpty()); 1477 } 1478 1479 1480} 1481