001package org.hl7.fhir.r5.model; 002 003 004/* 005 Copyright (c) 2011+, HL7, Inc. 006 All rights reserved. 007 008 Redistribution and use in source and binary forms, with or without modification, \ 009 are permitted provided that the following conditions are met: 010 011 * Redistributions of source code must retain the above copyright notice, this \ 012 list of conditions and the following disclaimer. 013 * Redistributions in binary form must reproduce the above copyright notice, \ 014 this list of conditions and the following disclaimer in the documentation \ 015 and/or other materials provided with the distribution. 016 * Neither the name of HL7 nor the names of its contributors may be used to 017 endorse or promote products derived from this software without specific 018 prior written permission. 019 020 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \ 021 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \ 022 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \ 023 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \ 024 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \ 025 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \ 026 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \ 027 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \ 028 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \ 029 POSSIBILITY OF SUCH DAMAGE. 030 */ 031 032// Generated on Thu, Mar 23, 2023 19:59+1100 for FHIR v5.0.0 033 034import java.util.ArrayList; 035import java.util.Date; 036import java.util.List; 037import org.hl7.fhir.utilities.Utilities; 038import org.hl7.fhir.r5.model.Enumerations.*; 039import org.hl7.fhir.instance.model.api.IBaseBackboneElement; 040import org.hl7.fhir.exceptions.FHIRException; 041import org.hl7.fhir.instance.model.api.ICompositeType; 042import ca.uhn.fhir.model.api.annotation.ResourceDef; 043import ca.uhn.fhir.model.api.annotation.SearchParamDefinition; 044import org.hl7.fhir.instance.model.api.IBaseBackboneElement; 045import ca.uhn.fhir.model.api.annotation.Child; 046import ca.uhn.fhir.model.api.annotation.ChildOrder; 047import ca.uhn.fhir.model.api.annotation.Description; 048import ca.uhn.fhir.model.api.annotation.Block; 049 050import org.hl7.fhir.instance.model.api.IAnyResource; 051/** 052 * This is the base resource type for everything. 053 */ 054public abstract class Resource extends BaseResource implements IAnyResource { 055 056 /** 057 * The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes. 058 */ 059 @Child(name = "id", type = {IdType.class}, order=0, min=0, max=1, modifier=false, summary=true) 060 @Description(shortDefinition="Logical id of this artifact", formalDefinition="The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes." ) 061 protected IdType id; 062 063 /** 064 * The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource. 065 */ 066 @Child(name = "meta", type = {Meta.class}, order=1, min=0, max=1, modifier=false, summary=true) 067 @Description(shortDefinition="Metadata about the resource", formalDefinition="The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource." ) 068 protected Meta meta; 069 070 /** 071 * A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc. 072 */ 073 @Child(name = "implicitRules", type = {UriType.class}, order=2, min=0, max=1, modifier=true, summary=true) 074 @Description(shortDefinition="A set of rules under which this content was created", formalDefinition="A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc." ) 075 protected UriType implicitRules; 076 077 /** 078 * The base language in which the resource is written. 079 */ 080 @Child(name = "language", type = {CodeType.class}, order=3, min=0, max=1, modifier=false, summary=false) 081 @Description(shortDefinition="Language of the resource content", formalDefinition="The base language in which the resource is written." ) 082 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/all-languages") 083 protected CodeType language; 084 085 private static final long serialVersionUID = -559462759L; 086 087 /** 088 * Constructor 089 */ 090 public Resource() { 091 super(); 092 } 093 094 /** 095 * @return {@link #id} (The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.). This is the underlying object with id, value and extensions. The accessor "getId" gives direct access to the value 096 */ 097 public IdType getIdElement() { 098 if (this.id == null) 099 if (Configuration.errorOnAutoCreate()) 100 throw new Error("Attempt to auto-create Resource.id"); 101 else if (Configuration.doAutoCreate()) 102 this.id = new IdType(); // bb 103 return this.id; 104 } 105 106 public boolean hasIdElement() { 107 return this.id != null && !this.id.isEmpty(); 108 } 109 110 public boolean hasId() { 111 return this.id != null && !this.id.isEmpty(); 112 } 113 114 /** 115 * @param value {@link #id} (The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.). This is the underlying object with id, value and extensions. The accessor "getId" gives direct access to the value 116 */ 117 public Resource setIdElement(IdType value) { 118 this.id = value; 119 return this; 120 } 121 122 /** 123 * @return The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes. 124 */ 125 public String getId() { 126 return this.id == null ? null : this.id.getValue(); 127 } 128 129 /** 130 * @param value The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes. 131 */ 132 public Resource setId(String value) { 133 if (Utilities.noString(value)) 134 this.id = null; 135 else { 136 if (this.id == null) 137 this.id = new IdType(); 138 this.id.setValue(value); 139 } 140 return this; 141 } 142 143 /** 144 * @return {@link #meta} (The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource.) 145 */ 146 public Meta getMeta() { 147 if (this.meta == null) 148 if (Configuration.errorOnAutoCreate()) 149 throw new Error("Attempt to auto-create Resource.meta"); 150 else if (Configuration.doAutoCreate()) 151 this.meta = new Meta(); // cc 152 return this.meta; 153 } 154 155 public boolean hasMeta() { 156 return this.meta != null && !this.meta.isEmpty(); 157 } 158 159 /** 160 * @param value {@link #meta} (The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource.) 161 */ 162 public Resource setMeta(Meta value) { 163 this.meta = value; 164 return this; 165 } 166 167 /** 168 * @return {@link #implicitRules} (A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.). This is the underlying object with id, value and extensions. The accessor "getImplicitRules" gives direct access to the value 169 */ 170 public UriType getImplicitRulesElement() { 171 if (this.implicitRules == null) 172 if (Configuration.errorOnAutoCreate()) 173 throw new Error("Attempt to auto-create Resource.implicitRules"); 174 else if (Configuration.doAutoCreate()) 175 this.implicitRules = new UriType(); // bb 176 return this.implicitRules; 177 } 178 179 public boolean hasImplicitRulesElement() { 180 return this.implicitRules != null && !this.implicitRules.isEmpty(); 181 } 182 183 public boolean hasImplicitRules() { 184 return this.implicitRules != null && !this.implicitRules.isEmpty(); 185 } 186 187 /** 188 * @param value {@link #implicitRules} (A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.). This is the underlying object with id, value and extensions. The accessor "getImplicitRules" gives direct access to the value 189 */ 190 public Resource setImplicitRulesElement(UriType value) { 191 this.implicitRules = value; 192 return this; 193 } 194 195 /** 196 * @return A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc. 197 */ 198 public String getImplicitRules() { 199 return this.implicitRules == null ? null : this.implicitRules.getValue(); 200 } 201 202 /** 203 * @param value A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc. 204 */ 205 public Resource setImplicitRules(String value) { 206 if (Utilities.noString(value)) 207 this.implicitRules = null; 208 else { 209 if (this.implicitRules == null) 210 this.implicitRules = new UriType(); 211 this.implicitRules.setValue(value); 212 } 213 return this; 214 } 215 216 /** 217 * @return {@link #language} (The base language in which the resource is written.). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value 218 */ 219 public CodeType getLanguageElement() { 220 if (this.language == null) 221 if (Configuration.errorOnAutoCreate()) 222 throw new Error("Attempt to auto-create Resource.language"); 223 else if (Configuration.doAutoCreate()) 224 this.language = new CodeType(); // bb 225 return this.language; 226 } 227 228 public boolean hasLanguageElement() { 229 return this.language != null && !this.language.isEmpty(); 230 } 231 232 public boolean hasLanguage() { 233 return this.language != null && !this.language.isEmpty(); 234 } 235 236 /** 237 * @param value {@link #language} (The base language in which the resource is written.). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value 238 */ 239 public Resource setLanguageElement(CodeType value) { 240 this.language = value; 241 return this; 242 } 243 244 /** 245 * @return The base language in which the resource is written. 246 */ 247 public String getLanguage() { 248 return this.language == null ? null : this.language.getValue(); 249 } 250 251 /** 252 * @param value The base language in which the resource is written. 253 */ 254 public Resource setLanguage(String value) { 255 if (Utilities.noString(value)) 256 this.language = null; 257 else { 258 if (this.language == null) 259 this.language = new CodeType(); 260 this.language.setValue(value); 261 } 262 return this; 263 } 264 265 protected void listChildren(List<Property> children) { 266 super.listChildren(children); 267 children.add(new Property("id", "id", "The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.", 0, 1, id)); 268 children.add(new Property("meta", "Meta", "The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource.", 0, 1, meta)); 269 children.add(new Property("implicitRules", "uri", "A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.", 0, 1, implicitRules)); 270 children.add(new Property("language", "code", "The base language in which the resource is written.", 0, 1, language)); 271 } 272 273 @Override 274 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 275 switch (_hash) { 276 case 3355: /*id*/ return new Property("id", "id", "The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.", 0, 1, id); 277 case 3347973: /*meta*/ return new Property("meta", "Meta", "The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource.", 0, 1, meta); 278 case -961826286: /*implicitRules*/ return new Property("implicitRules", "uri", "A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.", 0, 1, implicitRules); 279 case -1613589672: /*language*/ return new Property("language", "code", "The base language in which the resource is written.", 0, 1, language); 280 default: return super.getNamedProperty(_hash, _name, _checkValid); 281 } 282 283 } 284 285 @Override 286 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 287 switch (hash) { 288 case 3355: /*id*/ return this.id == null ? new Base[0] : new Base[] {this.id}; // IdType 289 case 3347973: /*meta*/ return this.meta == null ? new Base[0] : new Base[] {this.meta}; // Meta 290 case -961826286: /*implicitRules*/ return this.implicitRules == null ? new Base[0] : new Base[] {this.implicitRules}; // UriType 291 case -1613589672: /*language*/ return this.language == null ? new Base[0] : new Base[] {this.language}; // CodeType 292 default: return super.getProperty(hash, name, checkValid); 293 } 294 295 } 296 297 @Override 298 public Base setProperty(int hash, String name, Base value) throws FHIRException { 299 switch (hash) { 300 case 3355: // id 301 this.id = TypeConvertor.castToId(value); // IdType 302 return value; 303 case 3347973: // meta 304 this.meta = TypeConvertor.castToMeta(value); // Meta 305 return value; 306 case -961826286: // implicitRules 307 this.implicitRules = TypeConvertor.castToUri(value); // UriType 308 return value; 309 case -1613589672: // language 310 this.language = TypeConvertor.castToCode(value); // CodeType 311 return value; 312 default: return super.setProperty(hash, name, value); 313 } 314 315 } 316 317 @Override 318 public Base setProperty(String name, Base value) throws FHIRException { 319 if (name.equals("id")) { 320 this.id = TypeConvertor.castToId(value); // IdType 321 } else if (name.equals("meta")) { 322 this.meta = TypeConvertor.castToMeta(value); // Meta 323 } else if (name.equals("implicitRules")) { 324 this.implicitRules = TypeConvertor.castToUri(value); // UriType 325 } else if (name.equals("language")) { 326 this.language = TypeConvertor.castToCode(value); // CodeType 327 } else 328 return super.setProperty(name, value); 329 return value; 330 } 331 332 @Override 333 public Base makeProperty(int hash, String name) throws FHIRException { 334 switch (hash) { 335 case 3355: return getIdElement(); 336 case 3347973: return getMeta(); 337 case -961826286: return getImplicitRulesElement(); 338 case -1613589672: return getLanguageElement(); 339 default: return super.makeProperty(hash, name); 340 } 341 342 } 343 344 @Override 345 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 346 switch (hash) { 347 case 3355: /*id*/ return new String[] {"id"}; 348 case 3347973: /*meta*/ return new String[] {"Meta"}; 349 case -961826286: /*implicitRules*/ return new String[] {"uri"}; 350 case -1613589672: /*language*/ return new String[] {"code"}; 351 default: return super.getTypesForProperty(hash, name); 352 } 353 354 } 355 356 @Override 357 public Base addChild(String name) throws FHIRException { 358 if (name.equals("id")) { 359 throw new FHIRException("Cannot call addChild on a singleton property Resource.id"); 360 } 361 else if (name.equals("meta")) { 362 this.meta = new Meta(); 363 return this.meta; 364 } 365 else if (name.equals("implicitRules")) { 366 throw new FHIRException("Cannot call addChild on a singleton property Resource.implicitRules"); 367 } 368 else if (name.equals("language")) { 369 throw new FHIRException("Cannot call addChild on a singleton property Resource.language"); 370 } 371 else 372 return super.addChild(name); 373 } 374 375 public String fhirType() { 376 return "Resource"; 377 378 } 379 380 public abstract Resource copy(); 381 382 public void copyValues(Resource dst) { 383 super.copyValues(dst); 384 dst.id = id == null ? null : id.copy(); 385 dst.meta = meta == null ? null : meta.copy(); 386 dst.implicitRules = implicitRules == null ? null : implicitRules.copy(); 387 dst.language = language == null ? null : language.copy(); 388 } 389 390 @Override 391 public boolean equalsDeep(Base other_) { 392 if (!super.equalsDeep(other_)) 393 return false; 394 if (!(other_ instanceof Resource)) 395 return false; 396 Resource o = (Resource) other_; 397 return compareDeep(id, o.id, true) && compareDeep(meta, o.meta, true) && compareDeep(implicitRules, o.implicitRules, true) 398 && compareDeep(language, o.language, true); 399 } 400 401 @Override 402 public boolean equalsShallow(Base other_) { 403 if (!super.equalsShallow(other_)) 404 return false; 405 if (!(other_ instanceof Resource)) 406 return false; 407 Resource o = (Resource) other_; 408 return compareValues(id, o.id, true) && compareValues(implicitRules, o.implicitRules, true) && compareValues(language, o.language, true) 409 ; 410 } 411 412 public boolean isEmpty() { 413 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(id, meta, implicitRules 414 , language); 415 } 416 417// Manual code (from Configuration.txt): 418@Override 419 public String getIdBase() { 420 return getId(); 421 } 422 423 @Override 424 public void setIdBase(String value) { 425 setId(value); 426 } 427 public abstract ResourceType getResourceType(); 428 429 public String getLanguage(String defValue) { 430 return hasLanguage() ? getLanguage() : defValue; 431 } 432 433 private String webPath; 434 public boolean hasWebPath() { 435 return webPath != null; 436 } 437 public String getWebPath() { 438 return webPath; 439 } 440 public void setWebPath(String webPath) { 441 this.webPath = webPath; 442 } 443 444 // when possible, the source package is considered when performing reference resolution. 445 446 447 448 private PackageInformation sourcePackage; 449 450 public boolean hasSourcePackage() { 451 return sourcePackage != null; 452 } 453 454 public PackageInformation getSourcePackage() { 455 return sourcePackage; 456 } 457 458 public void setSourcePackage(PackageInformation sourcePackage) { 459 this.sourcePackage = sourcePackage; 460 } 461 462 /** 463 * @return the logical ID part of this resource's id 464 * @see IdType#getIdPart() 465 */ 466 public String getIdPart() { 467 return getIdElement().getIdPart(); 468 } 469 470// end addition 471 472} 473