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