001package org.hl7.fhir.r4.model; 002 003 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 035// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1 036 037import java.util.*; 038 039import org.hl7.fhir.utilities.Utilities; 040import ca.uhn.fhir.model.api.annotation.Child; 041import ca.uhn.fhir.model.api.annotation.ChildOrder; 042import ca.uhn.fhir.model.api.annotation.Description; 043import ca.uhn.fhir.model.api.annotation.DatatypeDef; 044import ca.uhn.fhir.model.api.annotation.Block; 045import org.hl7.fhir.instance.model.api.*; 046import org.hl7.fhir.exceptions.FHIRException; 047/** 048 * Optional Extension Element - found in all resources. 049 */ 050@DatatypeDef(name="Extension") 051public class Extension extends BaseExtension implements IBaseExtension<Extension, Type>, IBaseHasExtensions { 052 053 /** 054 * Source of the definition for the extension code - a logical name or a URL. 055 */ 056 @Child(name = "url", type = {UriType.class}, order=0, min=1, max=1, modifier=false, summary=false) 057 @Description(shortDefinition="identifies the meaning of the extension", formalDefinition="Source of the definition for the extension code - a logical name or a URL." ) 058 protected UriType url; 059 060 /** 061 * Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list). 062 */ 063 @Child(name = "value", type = {}, order=1, min=0, max=1, modifier=false, summary=false) 064 @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)." ) 065 protected org.hl7.fhir.r4.model.Type value; 066 067 private static final long serialVersionUID = 194602931L; 068 069 /** 070 * Constructor 071 */ 072 public Extension() { 073 super(); 074 } 075 076 /** 077 * Constructor 078 */ 079 public Extension(UriType url) { 080 super(); 081 this.url = url; 082 } 083 084 /** 085 * Constructor 086 */ 087 public Extension(String theUrl) { 088 setUrl(theUrl); 089 } 090 091 /** 092 * Constructor 093 */ 094 public Extension(String theUrl, IBaseDatatype theValue) { 095 setUrl(theUrl); 096 setValue(theValue); 097 } 098 099 /** 100 * @return {@link #url} (Source of the definition for the extension code - a logical name or a URL.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value 101 */ 102 public UriType getUrlElement() { 103 if (this.url == null) 104 if (Configuration.errorOnAutoCreate()) 105 throw new Error("Attempt to auto-create Extension.url"); 106 else if (Configuration.doAutoCreate()) 107 this.url = new UriType(); // bb 108 return this.url; 109 } 110 111 public boolean hasUrlElement() { 112 return this.url != null && !this.url.isEmpty(); 113 } 114 115 public boolean hasUrl() { 116 return this.url != null && !this.url.isEmpty(); 117 } 118 119 /** 120 * @param value {@link #url} (Source of the definition for the extension code - a logical name or a URL.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value 121 */ 122 public Extension setUrlElement(UriType value) { 123 this.url = value; 124 return this; 125 } 126 127 /** 128 * @return Source of the definition for the extension code - a logical name or a URL. 129 */ 130 public String getUrl() { 131 return this.url == null ? null : this.url.getValue(); 132 } 133 134 /** 135 * @param value Source of the definition for the extension code - a logical name or a URL. 136 */ 137 public Extension setUrl(String value) { 138 if (this.url == null) 139 this.url = new UriType(); 140 this.url.setValue(value); 141 return this; 142 } 143 144 /** 145 * @return {@link #value} (Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).) 146 */ 147 public org.hl7.fhir.r4.model.Type getValue() { 148 return this.value; 149 } 150 151 public boolean hasValue() { 152 return this.value != null && !this.value.isEmpty(); 153 } 154 155 /** 156 * @param value {@link #value} (Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).) 157 */ 158 public Extension setValue(org.hl7.fhir.r4.model.Type value) { 159 this.value = value; 160 return this; 161 } 162 163 protected void listChildren(List<Property> children) { 164 super.listChildren(children); 165 children.add(new Property("url", "uri", "Source of the definition for the extension code - a logical name or a URL.", 0, 1, url)); 166 children.add(new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value)); 167 } 168 169 @Override 170 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 171 switch (_hash) { 172 case 116079: /*url*/ return new Property("url", "uri", "Source of the definition for the extension code - a logical name or a URL.", 0, 1, url); 173 case -1410166417: /*value[x]*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 174 case 111972721: /*value*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 175 case -1535024575: /*valueBase64Binary*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 176 case 733421943: /*valueBoolean*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 177 case -786218365: /*valueCanonical*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 178 case -766209282: /*valueCode*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 179 case -766192449: /*valueDate*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 180 case 1047929900: /*valueDateTime*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 181 case -2083993440: /*valueDecimal*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 182 case 231604844: /*valueId*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 183 case -1668687056: /*valueInstant*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 184 case -1668204915: /*valueInteger*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 185 case -497880704: /*valueMarkdown*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 186 case -1410178407: /*valueOid*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 187 case -1249932027: /*valuePositiveInt*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 188 case -1424603934: /*valueString*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 189 case -765708322: /*valueTime*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 190 case 26529417: /*valueUnsignedInt*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 191 case -1410172357: /*valueUri*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 192 case -1410172354: /*valueUrl*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 193 case -765667124: /*valueUuid*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 194 case -478981821: /*valueAddress*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 195 case -67108992: /*valueAnnotation*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 196 case -475566732: /*valueAttachment*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 197 case 924902896: /*valueCodeableConcept*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 198 case -1887705029: /*valueCoding*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 199 case 944904545: /*valueContactPoint*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 200 case -2026205465: /*valueHumanName*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 201 case -130498310: /*valueIdentifier*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 202 case -1524344174: /*valuePeriod*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 203 case -2029823716: /*valueQuantity*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 204 case 2030761548: /*valueRange*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 205 case 2030767386: /*valueRatio*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 206 case 1755241690: /*valueReference*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 207 case -962229101: /*valueSampledData*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 208 case -540985785: /*valueSignature*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 209 case -1406282469: /*valueTiming*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 210 case -1858636920: /*valueDosage*/ return new Property("value[x]", "*", "Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).", 0, 1, value); 211 default: return super.getNamedProperty(_hash, _name, _checkValid); 212 } 213 214 } 215 216 @Override 217 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 218 switch (hash) { 219 case 116079: /*url*/ return this.url == null ? new Base[0] : new Base[] {this.url}; // UriType 220 case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // org.hl7.fhir.r4.model.Type 221 default: return super.getProperty(hash, name, checkValid); 222 } 223 224 } 225 226 @Override 227 public Base setProperty(int hash, String name, Base value) throws FHIRException { 228 switch (hash) { 229 case 116079: // url 230 this.url = castToUri(value); // UriType 231 return value; 232 case 111972721: // value 233 this.value = castToType(value); // org.hl7.fhir.r4.model.Type 234 return value; 235 default: return super.setProperty(hash, name, value); 236 } 237 238 } 239 240 @Override 241 public Base setProperty(String name, Base value) throws FHIRException { 242 if (name.equals("url")) { 243 this.url = castToUri(value); // UriType 244 } else if (name.equals("value[x]")) { 245 this.value = castToType(value); // org.hl7.fhir.r4.model.Type 246 } else 247 return super.setProperty(name, value); 248 return value; 249 } 250 251 @Override 252 public Base makeProperty(int hash, String name) throws FHIRException { 253 switch (hash) { 254 case 116079: return getUrlElement(); 255 case -1410166417: return getValue(); 256 case 111972721: return getValue(); 257 default: return super.makeProperty(hash, name); 258 } 259 260 } 261 262 @Override 263 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 264 switch (hash) { 265 case 116079: /*url*/ return new String[] {"uri"}; 266 case 111972721: /*value*/ return new String[] {"*"}; 267 default: return super.getTypesForProperty(hash, name); 268 } 269 270 } 271 272 @Override 273 public Base addChild(String name) throws FHIRException { 274 if (name.equals("url")) { 275 throw new FHIRException("Cannot call addChild on a primitive type Extension.url"); 276 } 277 else if (name.equals("valueBase64Binary")) { 278 this.value = new Base64BinaryType(); 279 return this.value; 280 } 281 else if (name.equals("valueBoolean")) { 282 this.value = new BooleanType(); 283 return this.value; 284 } 285 else if (name.equals("valueCanonical")) { 286 this.value = new CanonicalType(); 287 return this.value; 288 } 289 else if (name.equals("valueCode")) { 290 this.value = new CodeType(); 291 return this.value; 292 } 293 else if (name.equals("valueDate")) { 294 this.value = new DateType(); 295 return this.value; 296 } 297 else if (name.equals("valueDateTime")) { 298 this.value = new DateTimeType(); 299 return this.value; 300 } 301 else if (name.equals("valueDecimal")) { 302 this.value = new DecimalType(); 303 return this.value; 304 } 305 else if (name.equals("valueId")) { 306 this.value = new IdType(); 307 return this.value; 308 } 309 else if (name.equals("valueInstant")) { 310 this.value = new InstantType(); 311 return this.value; 312 } 313 else if (name.equals("valueInteger")) { 314 this.value = new IntegerType(); 315 return this.value; 316 } 317 else if (name.equals("valueMarkdown")) { 318 this.value = new MarkdownType(); 319 return this.value; 320 } 321 else if (name.equals("valueOid")) { 322 this.value = new OidType(); 323 return this.value; 324 } 325 else if (name.equals("valuePositiveInt")) { 326 this.value = new PositiveIntType(); 327 return this.value; 328 } 329 else if (name.equals("valueString")) { 330 this.value = new StringType(); 331 return this.value; 332 } 333 else if (name.equals("valueTime")) { 334 this.value = new TimeType(); 335 return this.value; 336 } 337 else if (name.equals("valueUnsignedInt")) { 338 this.value = new UnsignedIntType(); 339 return this.value; 340 } 341 else if (name.equals("valueUri")) { 342 this.value = new UriType(); 343 return this.value; 344 } 345 else if (name.equals("valueUrl")) { 346 this.value = new UrlType(); 347 return this.value; 348 } 349 else if (name.equals("valueUuid")) { 350 this.value = new UuidType(); 351 return this.value; 352 } 353 else if (name.equals("valueAddress")) { 354 this.value = new Address(); 355 return this.value; 356 } 357 else if (name.equals("valueAge")) { 358 this.value = new Age(); 359 return this.value; 360 } 361 else if (name.equals("valueAnnotation")) { 362 this.value = new Annotation(); 363 return this.value; 364 } 365 else if (name.equals("valueAttachment")) { 366 this.value = new Attachment(); 367 return this.value; 368 } 369 else if (name.equals("valueCodeableConcept")) { 370 this.value = new CodeableConcept(); 371 return this.value; 372 } 373 else if (name.equals("valueCoding")) { 374 this.value = new Coding(); 375 return this.value; 376 } 377 else if (name.equals("valueContactPoint")) { 378 this.value = new ContactPoint(); 379 return this.value; 380 } 381 else if (name.equals("valueCount")) { 382 this.value = new Count(); 383 return this.value; 384 } 385 else if (name.equals("valueDistance")) { 386 this.value = new Distance(); 387 return this.value; 388 } 389 else if (name.equals("valueDuration")) { 390 this.value = new Duration(); 391 return this.value; 392 } 393 else if (name.equals("valueHumanName")) { 394 this.value = new HumanName(); 395 return this.value; 396 } 397 else if (name.equals("valueIdentifier")) { 398 this.value = new Identifier(); 399 return this.value; 400 } 401 else if (name.equals("valueMoney")) { 402 this.value = new Money(); 403 return this.value; 404 } 405 else if (name.equals("valuePeriod")) { 406 this.value = new Period(); 407 return this.value; 408 } 409 else if (name.equals("valueQuantity")) { 410 this.value = new Quantity(); 411 return this.value; 412 } 413 else if (name.equals("valueRange")) { 414 this.value = new Range(); 415 return this.value; 416 } 417 else if (name.equals("valueRatio")) { 418 this.value = new Ratio(); 419 return this.value; 420 } 421 else if (name.equals("valueReference")) { 422 this.value = new Reference(); 423 return this.value; 424 } 425 else if (name.equals("valueSampledData")) { 426 this.value = new SampledData(); 427 return this.value; 428 } 429 else if (name.equals("valueSignature")) { 430 this.value = new Signature(); 431 return this.value; 432 } 433 else if (name.equals("valueTiming")) { 434 this.value = new Timing(); 435 return this.value; 436 } 437 else if (name.equals("valueContactDetail")) { 438 this.value = new ContactDetail(); 439 return this.value; 440 } 441 else if (name.equals("valueContributor")) { 442 this.value = new Contributor(); 443 return this.value; 444 } 445 else if (name.equals("valueDataRequirement")) { 446 this.value = new DataRequirement(); 447 return this.value; 448 } 449 else if (name.equals("valueExpression")) { 450 this.value = new Expression(); 451 return this.value; 452 } 453 else if (name.equals("valueParameterDefinition")) { 454 this.value = new ParameterDefinition(); 455 return this.value; 456 } 457 else if (name.equals("valueRelatedArtifact")) { 458 this.value = new RelatedArtifact(); 459 return this.value; 460 } 461 else if (name.equals("valueTriggerDefinition")) { 462 this.value = new TriggerDefinition(); 463 return this.value; 464 } 465 else if (name.equals("valueUsageContext")) { 466 this.value = new UsageContext(); 467 return this.value; 468 } 469 else if (name.equals("valueDosage")) { 470 this.value = new Dosage(); 471 return this.value; 472 } 473 else if (name.equals("valueMeta")) { 474 this.value = new Meta(); 475 return this.value; 476 } 477 else 478 return super.addChild(name); 479 } 480 481 public String fhirType() { 482 return "Extension"; 483 484 } 485 486 public Extension copy() { 487 Extension dst = new Extension(); 488 copyValues(dst); 489 return dst; 490 } 491 492 public void copyValues(Extension dst) { 493 super.copyValues(dst); 494 dst.url = url == null ? null : url.copy(); 495 dst.value = value == null ? null : value.copy(); 496 } 497 498 protected Extension typedCopy() { 499 return copy(); 500 } 501 502 @Override 503 public boolean equalsDeep(Base other_) { 504 if (!super.equalsDeep(other_)) 505 return false; 506 if (!(other_ instanceof Extension)) 507 return false; 508 Extension o = (Extension) other_; 509 return compareDeep(url, o.url, true) && compareDeep(value, o.value, true); 510 } 511 512 @Override 513 public boolean equalsShallow(Base other_) { 514 if (!super.equalsShallow(other_)) 515 return false; 516 if (!(other_ instanceof Extension)) 517 return false; 518 Extension o = (Extension) other_; 519 return compareValues(url, o.url, true); 520 } 521 522 public boolean isEmpty() { 523 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(url, value); 524 } 525 526 527}