001package org.hl7.fhir.r4.model; 002 003/* 004 Copyright (c) 2011+, HL7, Inc. 005 All rights reserved. 006 007 Redistribution and use in source and binary forms, with or without modification, 008 are permitted provided that the following conditions are met: 009 010 * Redistributions of source code must retain the above copyright notice, this 011 list of conditions and the following disclaimer. 012 * Redistributions in binary form must reproduce the above copyright notice, 013 this list of conditions and the following disclaimer in the documentation 014 and/or other materials provided with the distribution. 015 * Neither the name of HL7 nor the names of its contributors may be used to 016 endorse or promote products derived from this software without specific 017 prior written permission. 018 019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 020 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 021 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 022 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 023 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 024 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 025 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 026 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 027 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 028 POSSIBILITY OF SUCH DAMAGE. 029 030*/ 031 032// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1 033import java.util.List; 034 035import org.hl7.fhir.exceptions.FHIRException; 036import org.hl7.fhir.instance.model.api.IBaseDatatype; 037import org.hl7.fhir.instance.model.api.IBaseExtension; 038import org.hl7.fhir.instance.model.api.IBaseHasExtensions; 039 040import ca.uhn.fhir.model.api.annotation.Child; 041import ca.uhn.fhir.model.api.annotation.DatatypeDef; 042import ca.uhn.fhir.model.api.annotation.Description; 043 044/** 045 * Optional Extension Element - found in all resources. 046 */ 047@DatatypeDef(name = "Extension") 048public class Extension extends BaseExtension implements IBaseExtension<Extension, Type>, IBaseHasExtensions { 049 050 /** 051 * Source of the definition for the extension code - a logical name or a URL. 052 */ 053 @Child(name = "url", type = { UriType.class }, order = 0, min = 1, max = 1, modifier = false, summary = false) 054 @Description(shortDefinition = "identifies the meaning of the extension", formalDefinition = "Source of the definition for the extension code - a logical name or a URL.") 055 protected UriType url; 056 057 /** 058 * Value of extension - must be one of a constrained set of the data types (see 059 * [Extensibility](extensibility.html) for a list). 060 */ 061 @Child(name = "value", type = {}, order = 1, min = 0, max = 1, modifier = false, summary = false) 062 @Description(shortDefinition = "Value of extension", formalDefinition = "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).") 063 protected org.hl7.fhir.r4.model.Type value; 064 065 private static final long serialVersionUID = 194602931L; 066 067 /** 068 * Constructor 069 */ 070 public Extension() { 071 super(); 072 } 073 074 /** 075 * Constructor 076 */ 077 public Extension(UriType url) { 078 super(); 079 this.url = url; 080 } 081 082 /** 083 * Constructor 084 */ 085 public Extension(String theUrl) { 086 setUrl(theUrl); 087 } 088 089 /** 090 * Constructor 091 */ 092 public Extension(String theUrl, IBaseDatatype theValue) { 093 setUrl(theUrl); 094 setValue(theValue); 095 } 096 097 /** 098 * @return {@link #url} (Source of the definition for the extension code - a 099 * logical name or a URL.). This is the underlying object with id, value 100 * and extensions. The accessor "getUrl" gives direct access to the 101 * value 102 */ 103 public UriType getUrlElement() { 104 if (this.url == null) 105 if (Configuration.errorOnAutoCreate()) 106 throw new Error("Attempt to auto-create Extension.url"); 107 else if (Configuration.doAutoCreate()) 108 this.url = new UriType(); // bb 109 return this.url; 110 } 111 112 public boolean hasUrlElement() { 113 return this.url != null && !this.url.isEmpty(); 114 } 115 116 public boolean hasUrl() { 117 return this.url != null && !this.url.isEmpty(); 118 } 119 120 /** 121 * @param value {@link #url} (Source of the definition for the extension code - 122 * a logical name or a URL.). This is the underlying object with 123 * id, value and extensions. The accessor "getUrl" gives direct 124 * access to the value 125 */ 126 public Extension setUrlElement(UriType value) { 127 this.url = value; 128 return this; 129 } 130 131 /** 132 * @return Source of the definition for the extension code - a logical name or a 133 * URL. 134 */ 135 public String getUrl() { 136 return this.url == null ? null : this.url.getValue(); 137 } 138 139 /** 140 * @param value Source of the definition for the extension code - a logical name 141 * or a URL. 142 */ 143 public Extension setUrl(String value) { 144 if (this.url == null) 145 this.url = new UriType(); 146 this.url.setValue(value); 147 return this; 148 } 149 150 /** 151 * @return {@link #value} (Value of extension - must be one of a constrained set 152 * of the data types (see [Extensibility](extensibility.html) for a 153 * list).) 154 */ 155 public org.hl7.fhir.r4.model.Type getValue() { 156 return this.value; 157 } 158 159 public boolean hasValue() { 160 return this.value != null && !this.value.isEmpty(); 161 } 162 163 /** 164 * @param value {@link #value} (Value of extension - must be one of a 165 * constrained set of the data types (see 166 * [Extensibility](extensibility.html) for a list).) 167 */ 168 public Extension setValue(org.hl7.fhir.r4.model.Type value) { 169 this.value = value; 170 return this; 171 } 172 173 protected void listChildren(List<Property> children) { 174 super.listChildren(children); 175 children.add(new Property("url", "uri", 176 "Source of the definition for the extension code - a logical name or a URL.", 0, 1, url)); 177 children.add(new Property("value[x]", "*", 178 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 179 0, 1, value)); 180 } 181 182 @Override 183 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 184 switch (_hash) { 185 case 116079: 186 /* url */ return new Property("url", "uri", 187 "Source of the definition for the extension code - a logical name or a URL.", 0, 1, url); 188 case -1410166417: 189 /* value[x] */ return new Property("value[x]", "*", 190 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 191 0, 1, value); 192 case 111972721: 193 /* value */ return new Property("value[x]", "*", 194 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 195 0, 1, value); 196 case -1535024575: 197 /* valueBase64Binary */ return new Property("value[x]", "*", 198 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 199 0, 1, value); 200 case 733421943: 201 /* valueBoolean */ return new Property("value[x]", "*", 202 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 203 0, 1, value); 204 case -786218365: 205 /* valueCanonical */ return new Property("value[x]", "*", 206 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 207 0, 1, value); 208 case -766209282: 209 /* valueCode */ return new Property("value[x]", "*", 210 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 211 0, 1, value); 212 case -766192449: 213 /* valueDate */ return new Property("value[x]", "*", 214 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 215 0, 1, value); 216 case 1047929900: 217 /* valueDateTime */ return new Property("value[x]", "*", 218 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 219 0, 1, value); 220 case -2083993440: 221 /* valueDecimal */ return new Property("value[x]", "*", 222 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 223 0, 1, value); 224 case 231604844: 225 /* valueId */ return new Property("value[x]", "*", 226 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 227 0, 1, value); 228 case -1668687056: 229 /* valueInstant */ return new Property("value[x]", "*", 230 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 231 0, 1, value); 232 case -1668204915: 233 /* valueInteger */ return new Property("value[x]", "*", 234 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 235 0, 1, value); 236 case -497880704: 237 /* valueMarkdown */ return new Property("value[x]", "*", 238 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 239 0, 1, value); 240 case -1410178407: 241 /* valueOid */ return new Property("value[x]", "*", 242 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 243 0, 1, value); 244 case -1249932027: 245 /* valuePositiveInt */ return new Property("value[x]", "*", 246 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 247 0, 1, value); 248 case -1424603934: 249 /* valueString */ return new Property("value[x]", "*", 250 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 251 0, 1, value); 252 case -765708322: 253 /* valueTime */ return new Property("value[x]", "*", 254 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 255 0, 1, value); 256 case 26529417: 257 /* valueUnsignedInt */ return new Property("value[x]", "*", 258 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 259 0, 1, value); 260 case -1410172357: 261 /* valueUri */ return new Property("value[x]", "*", 262 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 263 0, 1, value); 264 case -1410172354: 265 /* valueUrl */ return new Property("value[x]", "*", 266 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 267 0, 1, value); 268 case -765667124: 269 /* valueUuid */ return new Property("value[x]", "*", 270 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 271 0, 1, value); 272 case -478981821: 273 /* valueAddress */ return new Property("value[x]", "*", 274 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 275 0, 1, value); 276 case -67108992: 277 /* valueAnnotation */ return new Property("value[x]", "*", 278 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 279 0, 1, value); 280 case -475566732: 281 /* valueAttachment */ return new Property("value[x]", "*", 282 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 283 0, 1, value); 284 case 924902896: 285 /* valueCodeableConcept */ return new Property("value[x]", "*", 286 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 287 0, 1, value); 288 case -1887705029: 289 /* valueCoding */ return new Property("value[x]", "*", 290 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 291 0, 1, value); 292 case 944904545: 293 /* valueContactPoint */ return new Property("value[x]", "*", 294 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 295 0, 1, value); 296 case -2026205465: 297 /* valueHumanName */ return new Property("value[x]", "*", 298 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 299 0, 1, value); 300 case -130498310: 301 /* valueIdentifier */ return new Property("value[x]", "*", 302 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 303 0, 1, value); 304 case -1524344174: 305 /* valuePeriod */ return new Property("value[x]", "*", 306 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 307 0, 1, value); 308 case -2029823716: 309 /* valueQuantity */ return new Property("value[x]", "*", 310 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 311 0, 1, value); 312 case 2030761548: 313 /* valueRange */ return new Property("value[x]", "*", 314 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 315 0, 1, value); 316 case 2030767386: 317 /* valueRatio */ return new Property("value[x]", "*", 318 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 319 0, 1, value); 320 case 1755241690: 321 /* valueReference */ return new Property("value[x]", "*", 322 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 323 0, 1, value); 324 case -962229101: 325 /* valueSampledData */ return new Property("value[x]", "*", 326 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 327 0, 1, value); 328 case -540985785: 329 /* valueSignature */ return new Property("value[x]", "*", 330 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 331 0, 1, value); 332 case -1406282469: 333 /* valueTiming */ return new Property("value[x]", "*", 334 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 335 0, 1, value); 336 case -1858636920: 337 /* valueDosage */ return new Property("value[x]", "*", 338 "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 339 0, 1, value); 340 default: 341 return super.getNamedProperty(_hash, _name, _checkValid); 342 } 343 344 } 345 346 @Override 347 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 348 switch (hash) { 349 case 116079: 350 /* url */ return this.url == null ? new Base[0] : new Base[] { this.url }; // UriType 351 case 111972721: 352 /* value */ return this.value == null ? new Base[0] : new Base[] { this.value }; // org.hl7.fhir.r4.model.Type 353 default: 354 return super.getProperty(hash, name, checkValid); 355 } 356 357 } 358 359 @Override 360 public Base setProperty(int hash, String name, Base value) throws FHIRException { 361 switch (hash) { 362 case 116079: // url 363 this.url = castToUri(value); // UriType 364 return value; 365 case 111972721: // value 366 this.value = castToType(value); // org.hl7.fhir.r4.model.Type 367 return value; 368 default: 369 return super.setProperty(hash, name, value); 370 } 371 372 } 373 374 @Override 375 public Base setProperty(String name, Base value) throws FHIRException { 376 if (name.equals("url")) { 377 this.url = castToUri(value); // UriType 378 } else if (name.equals("value[x]")) { 379 this.value = castToType(value); // org.hl7.fhir.r4.model.Type 380 } else 381 return super.setProperty(name, value); 382 return value; 383 } 384 385 @Override 386 public void removeChild(String name, Base value) throws FHIRException { 387 if (name.equals("url")) { 388 this.url = null; 389 } else if (name.equals("value[x]")) { 390 this.value = null; 391 } else 392 super.removeChild(name, value); 393 394 } 395 396 @Override 397 public Base makeProperty(int hash, String name) throws FHIRException { 398 switch (hash) { 399 case 116079: 400 return getUrlElement(); 401 case -1410166417: 402 return getValue(); 403 case 111972721: 404 return getValue(); 405 default: 406 return super.makeProperty(hash, name); 407 } 408 409 } 410 411 @Override 412 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 413 switch (hash) { 414 case 116079: 415 /* url */ return new String[] { "uri" }; 416 case 111972721: 417 /* value */ return new String[] { "*" }; 418 default: 419 return super.getTypesForProperty(hash, name); 420 } 421 422 } 423 424 @Override 425 public Base addChild(String name) throws FHIRException { 426 if (name.equals("url")) { 427 throw new FHIRException("Cannot call addChild on a singleton property Extension.url"); 428 } else if (name.equals("valueBase64Binary")) { 429 this.value = new Base64BinaryType(); 430 return this.value; 431 } else if (name.equals("valueBoolean")) { 432 this.value = new BooleanType(); 433 return this.value; 434 } else if (name.equals("valueCanonical")) { 435 this.value = new CanonicalType(); 436 return this.value; 437 } else if (name.equals("valueCode")) { 438 this.value = new CodeType(); 439 return this.value; 440 } else if (name.equals("valueDate")) { 441 this.value = new DateType(); 442 return this.value; 443 } else if (name.equals("valueDateTime")) { 444 this.value = new DateTimeType(); 445 return this.value; 446 } else if (name.equals("valueDecimal")) { 447 this.value = new DecimalType(); 448 return this.value; 449 } else if (name.equals("valueId")) { 450 this.value = new IdType(); 451 return this.value; 452 } else if (name.equals("valueInstant")) { 453 this.value = new InstantType(); 454 return this.value; 455 } else if (name.equals("valueInteger")) { 456 this.value = new IntegerType(); 457 return this.value; 458 } else if (name.equals("valueMarkdown")) { 459 this.value = new MarkdownType(); 460 return this.value; 461 } else if (name.equals("valueOid")) { 462 this.value = new OidType(); 463 return this.value; 464 } else if (name.equals("valuePositiveInt")) { 465 this.value = new PositiveIntType(); 466 return this.value; 467 } else if (name.equals("valueString")) { 468 this.value = new StringType(); 469 return this.value; 470 } else if (name.equals("valueTime")) { 471 this.value = new TimeType(); 472 return this.value; 473 } else if (name.equals("valueUnsignedInt")) { 474 this.value = new UnsignedIntType(); 475 return this.value; 476 } else if (name.equals("valueUri")) { 477 this.value = new UriType(); 478 return this.value; 479 } else if (name.equals("valueUrl")) { 480 this.value = new UrlType(); 481 return this.value; 482 } else if (name.equals("valueUuid")) { 483 this.value = new UuidType(); 484 return this.value; 485 } else if (name.equals("valueAddress")) { 486 this.value = new Address(); 487 return this.value; 488 } else if (name.equals("valueAge")) { 489 this.value = new Age(); 490 return this.value; 491 } else if (name.equals("valueAnnotation")) { 492 this.value = new Annotation(); 493 return this.value; 494 } else if (name.equals("valueAttachment")) { 495 this.value = new Attachment(); 496 return this.value; 497 } else if (name.equals("valueCodeableConcept")) { 498 this.value = new CodeableConcept(); 499 return this.value; 500 } else if (name.equals("valueCoding")) { 501 this.value = new Coding(); 502 return this.value; 503 } else if (name.equals("valueContactPoint")) { 504 this.value = new ContactPoint(); 505 return this.value; 506 } else if (name.equals("valueCount")) { 507 this.value = new Count(); 508 return this.value; 509 } else if (name.equals("valueDistance")) { 510 this.value = new Distance(); 511 return this.value; 512 } else if (name.equals("valueDuration")) { 513 this.value = new Duration(); 514 return this.value; 515 } else if (name.equals("valueHumanName")) { 516 this.value = new HumanName(); 517 return this.value; 518 } else if (name.equals("valueIdentifier")) { 519 this.value = new Identifier(); 520 return this.value; 521 } else if (name.equals("valueMoney")) { 522 this.value = new Money(); 523 return this.value; 524 } else if (name.equals("valuePeriod")) { 525 this.value = new Period(); 526 return this.value; 527 } else if (name.equals("valueQuantity")) { 528 this.value = new Quantity(); 529 return this.value; 530 } else if (name.equals("valueRange")) { 531 this.value = new Range(); 532 return this.value; 533 } else if (name.equals("valueRatio")) { 534 this.value = new Ratio(); 535 return this.value; 536 } else if (name.equals("valueReference")) { 537 this.value = new Reference(); 538 return this.value; 539 } else if (name.equals("valueSampledData")) { 540 this.value = new SampledData(); 541 return this.value; 542 } else if (name.equals("valueSignature")) { 543 this.value = new Signature(); 544 return this.value; 545 } else if (name.equals("valueTiming")) { 546 this.value = new Timing(); 547 return this.value; 548 } else if (name.equals("valueContactDetail")) { 549 this.value = new ContactDetail(); 550 return this.value; 551 } else if (name.equals("valueContributor")) { 552 this.value = new Contributor(); 553 return this.value; 554 } else if (name.equals("valueDataRequirement")) { 555 this.value = new DataRequirement(); 556 return this.value; 557 } else if (name.equals("valueExpression")) { 558 this.value = new Expression(); 559 return this.value; 560 } else if (name.equals("valueParameterDefinition")) { 561 this.value = new ParameterDefinition(); 562 return this.value; 563 } else if (name.equals("valueRelatedArtifact")) { 564 this.value = new RelatedArtifact(); 565 return this.value; 566 } else if (name.equals("valueTriggerDefinition")) { 567 this.value = new TriggerDefinition(); 568 return this.value; 569 } else if (name.equals("valueUsageContext")) { 570 this.value = new UsageContext(); 571 return this.value; 572 } else if (name.equals("valueDosage")) { 573 this.value = new Dosage(); 574 return this.value; 575 } else if (name.equals("valueMeta")) { 576 this.value = new Meta(); 577 return this.value; 578 } else 579 return super.addChild(name); 580 } 581 582 public String fhirType() { 583 return "Extension"; 584 585 } 586 587 public Extension copy() { 588 Extension dst = new Extension(); 589 copyValues(dst); 590 return dst; 591 } 592 593 public void copyValues(Extension dst) { 594 super.copyValues(dst); 595 dst.url = url == null ? null : url.copy(); 596 dst.value = value == null ? null : value.copy(); 597 } 598 599 protected Extension typedCopy() { 600 return copy(); 601 } 602 603 @Override 604 public boolean equalsDeep(Base other_) { 605 if (!super.equalsDeep(other_)) 606 return false; 607 if (!(other_ instanceof Extension)) 608 return false; 609 Extension o = (Extension) other_; 610 return compareDeep(url, o.url, true) && compareDeep(value, o.value, true); 611 } 612 613 @Override 614 public boolean equalsShallow(Base other_) { 615 if (!super.equalsShallow(other_)) 616 return false; 617 if (!(other_ instanceof Extension)) 618 return false; 619 Extension o = (Extension) other_; 620 return compareValues(url, o.url, true); 621 } 622 623 public boolean isEmpty() { 624 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(url, value); 625 } 626 627}