001package org.hl7.fhir.dstu3.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 Fri, Mar 16, 2018 15:21+1100 for FHIR v3.0.1 033 034import java.util.*; 035 036import org.hl7.fhir.utilities.Utilities; 037import org.hl7.fhir.dstu3.model.Enumerations.*; 038import ca.uhn.fhir.model.api.annotation.Child; 039import ca.uhn.fhir.model.api.annotation.ChildOrder; 040import ca.uhn.fhir.model.api.annotation.Description; 041import ca.uhn.fhir.model.api.annotation.DatatypeDef; 042import ca.uhn.fhir.model.api.annotation.Block; 043import org.hl7.fhir.instance.model.api.*; 044import org.hl7.fhir.exceptions.FHIRException; 045import org.hl7.fhir.exceptions.FHIRFormatError; 046/** 047 * The metadata about a resource. This is content in the resource that is maintained by the infrastructure. Changes to the content may not always be associated with version changes to the resource. 048 */ 049@DatatypeDef(name="Meta") 050public class Meta extends Type implements IBaseMetaType { 051 052 /** 053 * The version specific identifier, as it appears in the version portion of the URL. This values changes when the resource is created, updated, or deleted. 054 */ 055 @Child(name = "versionId", type = {IdType.class}, order=0, min=0, max=1, modifier=false, summary=true) 056 @Description(shortDefinition="Version specific identifier", formalDefinition="The version specific identifier, as it appears in the version portion of the URL. This values changes when the resource is created, updated, or deleted." ) 057 protected IdType versionId; 058 059 /** 060 * When the resource last changed - e.g. when the version changed. 061 */ 062 @Child(name = "lastUpdated", type = {InstantType.class}, order=1, min=0, max=1, modifier=false, summary=true) 063 @Description(shortDefinition="When the resource version last changed", formalDefinition="When the resource last changed - e.g. when the version changed." ) 064 protected InstantType lastUpdated; 065 066 /** 067 * A list of profiles (references to [[[StructureDefinition]]] resources) that this resource claims to conform to. The URL is a reference to [[[StructureDefinition.url]]]. 068 */ 069 @Child(name = "profile", type = {UriType.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 070 @Description(shortDefinition="Profiles this resource claims to conform to", formalDefinition="A list of profiles (references to [[[StructureDefinition]]] resources) that this resource claims to conform to. The URL is a reference to [[[StructureDefinition.url]]]." ) 071 protected List<UriType> profile; 072 073 /** 074 * Security labels applied to this resource. These tags connect specific resources to the overall security policy and infrastructure. 075 */ 076 @Child(name = "security", type = {Coding.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 077 @Description(shortDefinition="Security Labels applied to this resource", formalDefinition="Security labels applied to this resource. These tags connect specific resources to the overall security policy and infrastructure." ) 078 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/security-labels") 079 protected List<Coding> security; 080 081 /** 082 * Tags applied to this resource. Tags are intended to be used to identify and relate resources to process and workflow, and applications are not required to consider the tags when interpreting the meaning of a resource. 083 */ 084 @Child(name = "tag", type = {Coding.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 085 @Description(shortDefinition="Tags applied to this resource", formalDefinition="Tags applied to this resource. Tags are intended to be used to identify and relate resources to process and workflow, and applications are not required to consider the tags when interpreting the meaning of a resource." ) 086 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/common-tags") 087 protected List<Coding> tag; 088 089 private static final long serialVersionUID = 867134915L; 090 091 /** 092 * Constructor 093 */ 094 public Meta() { 095 super(); 096 } 097 098 /** 099 * @return {@link #versionId} (The version specific identifier, as it appears in the version portion of the URL. This values changes when the resource is created, updated, or deleted.). This is the underlying object with id, value and extensions. The accessor "getVersionId" gives direct access to the value 100 */ 101 public IdType getVersionIdElement() { 102 if (this.versionId == null) 103 if (Configuration.errorOnAutoCreate()) 104 throw new Error("Attempt to auto-create Meta.versionId"); 105 else if (Configuration.doAutoCreate()) 106 this.versionId = new IdType(); // bb 107 return this.versionId; 108 } 109 110 public boolean hasVersionIdElement() { 111 return this.versionId != null && !this.versionId.isEmpty(); 112 } 113 114 public boolean hasVersionId() { 115 return this.versionId != null && !this.versionId.isEmpty(); 116 } 117 118 /** 119 * @param value {@link #versionId} (The version specific identifier, as it appears in the version portion of the URL. This values changes when the resource is created, updated, or deleted.). This is the underlying object with id, value and extensions. The accessor "getVersionId" gives direct access to the value 120 */ 121 public Meta setVersionIdElement(IdType value) { 122 this.versionId = value; 123 return this; 124 } 125 126 /** 127 * @return The version specific identifier, as it appears in the version portion of the URL. This values changes when the resource is created, updated, or deleted. 128 */ 129 public String getVersionId() { 130 return this.versionId == null ? null : this.versionId.getValue(); 131 } 132 133 /** 134 * @param value The version specific identifier, as it appears in the version portion of the URL. This values changes when the resource is created, updated, or deleted. 135 */ 136 public Meta setVersionId(String value) { 137 if (Utilities.noString(value)) 138 this.versionId = null; 139 else { 140 if (this.versionId == null) 141 this.versionId = new IdType(); 142 this.versionId.setValue(value); 143 } 144 return this; 145 } 146 147 /** 148 * @return {@link #lastUpdated} (When the resource last changed - e.g. when the version changed.). This is the underlying object with id, value and extensions. The accessor "getLastUpdated" gives direct access to the value 149 */ 150 public InstantType getLastUpdatedElement() { 151 if (this.lastUpdated == null) 152 if (Configuration.errorOnAutoCreate()) 153 throw new Error("Attempt to auto-create Meta.lastUpdated"); 154 else if (Configuration.doAutoCreate()) 155 this.lastUpdated = new InstantType(); // bb 156 return this.lastUpdated; 157 } 158 159 public boolean hasLastUpdatedElement() { 160 return this.lastUpdated != null && !this.lastUpdated.isEmpty(); 161 } 162 163 public boolean hasLastUpdated() { 164 return this.lastUpdated != null && !this.lastUpdated.isEmpty(); 165 } 166 167 /** 168 * @param value {@link #lastUpdated} (When the resource last changed - e.g. when the version changed.). This is the underlying object with id, value and extensions. The accessor "getLastUpdated" gives direct access to the value 169 */ 170 public Meta setLastUpdatedElement(InstantType value) { 171 this.lastUpdated = value; 172 return this; 173 } 174 175 /** 176 * @return When the resource last changed - e.g. when the version changed. 177 */ 178 public Date getLastUpdated() { 179 return this.lastUpdated == null ? null : this.lastUpdated.getValue(); 180 } 181 182 /** 183 * @param value When the resource last changed - e.g. when the version changed. 184 */ 185 public Meta setLastUpdated(Date value) { 186 if (value == null) 187 this.lastUpdated = null; 188 else { 189 if (this.lastUpdated == null) 190 this.lastUpdated = new InstantType(); 191 this.lastUpdated.setValue(value); 192 } 193 return this; 194 } 195 196 /** 197 * @return {@link #profile} (A list of profiles (references to [[[StructureDefinition]]] resources) that this resource claims to conform to. The URL is a reference to [[[StructureDefinition.url]]].) 198 */ 199 public List<UriType> getProfile() { 200 if (this.profile == null) 201 this.profile = new ArrayList<UriType>(); 202 return this.profile; 203 } 204 205 /** 206 * @return Returns a reference to <code>this</code> for easy method chaining 207 */ 208 public Meta setProfile(List<UriType> theProfile) { 209 this.profile = theProfile; 210 return this; 211 } 212 213 public boolean hasProfile() { 214 if (this.profile == null) 215 return false; 216 for (UriType item : this.profile) 217 if (!item.isEmpty()) 218 return true; 219 return false; 220 } 221 222 /** 223 * @return {@link #profile} (A list of profiles (references to [[[StructureDefinition]]] resources) that this resource claims to conform to. The URL is a reference to [[[StructureDefinition.url]]].) 224 */ 225 public UriType addProfileElement() {//2 226 UriType t = new UriType(); 227 if (this.profile == null) 228 this.profile = new ArrayList<UriType>(); 229 this.profile.add(t); 230 return t; 231 } 232 233 /** 234 * @param value {@link #profile} (A list of profiles (references to [[[StructureDefinition]]] resources) that this resource claims to conform to. The URL is a reference to [[[StructureDefinition.url]]].) 235 */ 236 public Meta addProfile(String value) { //1 237 UriType t = new UriType(); 238 t.setValue(value); 239 if (this.profile == null) 240 this.profile = new ArrayList<UriType>(); 241 this.profile.add(t); 242 return this; 243 } 244 245 /** 246 * @param value {@link #profile} (A list of profiles (references to [[[StructureDefinition]]] resources) that this resource claims to conform to. The URL is a reference to [[[StructureDefinition.url]]].) 247 */ 248 public boolean hasProfile(String value) { 249 if (this.profile == null) 250 return false; 251 for (UriType v : this.profile) 252 if (v.getValue().equals(value)) // uri 253 return true; 254 return false; 255 } 256 257 /** 258 * @return {@link #security} (Security labels applied to this resource. These tags connect specific resources to the overall security policy and infrastructure.) 259 */ 260 public List<Coding> getSecurity() { 261 if (this.security == null) 262 this.security = new ArrayList<Coding>(); 263 return this.security; 264 } 265 266 /** 267 * @return Returns a reference to <code>this</code> for easy method chaining 268 */ 269 public Meta setSecurity(List<Coding> theSecurity) { 270 this.security = theSecurity; 271 return this; 272 } 273 274 public boolean hasSecurity() { 275 if (this.security == null) 276 return false; 277 for (Coding item : this.security) 278 if (!item.isEmpty()) 279 return true; 280 return false; 281 } 282 283 public Coding addSecurity() { //3 284 Coding t = new Coding(); 285 if (this.security == null) 286 this.security = new ArrayList<Coding>(); 287 this.security.add(t); 288 return t; 289 } 290 291 public Meta addSecurity(Coding t) { //3 292 if (t == null) 293 return this; 294 if (this.security == null) 295 this.security = new ArrayList<Coding>(); 296 this.security.add(t); 297 return this; 298 } 299 300 /** 301 * @return The first repetition of repeating field {@link #security}, creating it if it does not already exist 302 */ 303 public Coding getSecurityFirstRep() { 304 if (getSecurity().isEmpty()) { 305 addSecurity(); 306 } 307 return getSecurity().get(0); 308 } 309 310 /** 311 * @return {@link #tag} (Tags applied to this resource. Tags are intended to be used to identify and relate resources to process and workflow, and applications are not required to consider the tags when interpreting the meaning of a resource.) 312 */ 313 public List<Coding> getTag() { 314 if (this.tag == null) 315 this.tag = new ArrayList<Coding>(); 316 return this.tag; 317 } 318 319 /** 320 * @return Returns a reference to <code>this</code> for easy method chaining 321 */ 322 public Meta setTag(List<Coding> theTag) { 323 this.tag = theTag; 324 return this; 325 } 326 327 public boolean hasTag() { 328 if (this.tag == null) 329 return false; 330 for (Coding item : this.tag) 331 if (!item.isEmpty()) 332 return true; 333 return false; 334 } 335 336 public Coding addTag() { //3 337 Coding t = new Coding(); 338 if (this.tag == null) 339 this.tag = new ArrayList<Coding>(); 340 this.tag.add(t); 341 return t; 342 } 343 344 public Meta addTag(Coding t) { //3 345 if (t == null) 346 return this; 347 if (this.tag == null) 348 this.tag = new ArrayList<Coding>(); 349 this.tag.add(t); 350 return this; 351 } 352 353 /** 354 * @return The first repetition of repeating field {@link #tag}, creating it if it does not already exist 355 */ 356 public Coding getTagFirstRep() { 357 if (getTag().isEmpty()) { 358 addTag(); 359 } 360 return getTag().get(0); 361 } 362 363 /** 364 * Convenience method which adds a tag 365 * 366 * @param theSystem The code system 367 * @param theCode The code 368 * @param theDisplay The display name 369 * @return Returns a reference to <code>this</code> for easy chaining 370 */ 371 public Meta addTag(String theSystem, String theCode, String theDisplay) { 372 addTag().setSystem(theSystem).setCode(theCode).setDisplay(theDisplay); 373 return this; 374 } 375 /** 376 * Convenience method which adds a security tag 377 * 378 * @param theSystem The code system 379 * @param theCode The code 380 * @param theDisplay The display name 381 * @return Returns a reference to <code>this</code> for easy chaining 382 */ 383 public Meta addSecurity(String theSystem, String theCode, String theDisplay) { 384 addSecurity().setSystem(theSystem).setCode(theCode).setDisplay(theDisplay); 385 return this; 386 } 387 /** 388 * Returns the first tag (if any) that has the given system and code, or returns 389 * <code>null</code> if none 390 */ 391 public Coding getTag(String theSystem, String theCode) { 392 for (Coding next : getTag()) { 393 if (ca.uhn.fhir.util.ObjectUtil.equals(next.getSystem(), theSystem) && ca.uhn.fhir.util.ObjectUtil.equals(next.getCode(), theCode)) { 394 return next; 395 } 396 } 397 return null; 398 } 399 400 /** 401 * Returns the first security label (if any) that has the given system and code, or returns 402 * <code>null</code> if none 403 */ 404 public Coding getSecurity(String theSystem, String theCode) { 405 for (Coding next : getTag()) { 406 if (ca.uhn.fhir.util.ObjectUtil.equals(next.getSystem(), theSystem) && ca.uhn.fhir.util.ObjectUtil.equals(next.getCode(), theCode)) { 407 return next; 408 } 409 } 410 return null; 411 } 412 protected void listChildren(List<Property> children) { 413 super.listChildren(children); 414 children.add(new Property("versionId", "id", "The version specific identifier, as it appears in the version portion of the URL. This values changes when the resource is created, updated, or deleted.", 0, 1, versionId)); 415 children.add(new Property("lastUpdated", "instant", "When the resource last changed - e.g. when the version changed.", 0, 1, lastUpdated)); 416 children.add(new Property("profile", "uri", "A list of profiles (references to [[[StructureDefinition]]] resources) that this resource claims to conform to. The URL is a reference to [[[StructureDefinition.url]]].", 0, java.lang.Integer.MAX_VALUE, profile)); 417 children.add(new Property("security", "Coding", "Security labels applied to this resource. These tags connect specific resources to the overall security policy and infrastructure.", 0, java.lang.Integer.MAX_VALUE, security)); 418 children.add(new Property("tag", "Coding", "Tags applied to this resource. Tags are intended to be used to identify and relate resources to process and workflow, and applications are not required to consider the tags when interpreting the meaning of a resource.", 0, java.lang.Integer.MAX_VALUE, tag)); 419 } 420 421 @Override 422 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 423 switch (_hash) { 424 case -1407102957: /*versionId*/ return new Property("versionId", "id", "The version specific identifier, as it appears in the version portion of the URL. This values changes when the resource is created, updated, or deleted.", 0, 1, versionId); 425 case 1649733957: /*lastUpdated*/ return new Property("lastUpdated", "instant", "When the resource last changed - e.g. when the version changed.", 0, 1, lastUpdated); 426 case -309425751: /*profile*/ return new Property("profile", "uri", "A list of profiles (references to [[[StructureDefinition]]] resources) that this resource claims to conform to. The URL is a reference to [[[StructureDefinition.url]]].", 0, java.lang.Integer.MAX_VALUE, profile); 427 case 949122880: /*security*/ return new Property("security", "Coding", "Security labels applied to this resource. These tags connect specific resources to the overall security policy and infrastructure.", 0, java.lang.Integer.MAX_VALUE, security); 428 case 114586: /*tag*/ return new Property("tag", "Coding", "Tags applied to this resource. Tags are intended to be used to identify and relate resources to process and workflow, and applications are not required to consider the tags when interpreting the meaning of a resource.", 0, java.lang.Integer.MAX_VALUE, tag); 429 default: return super.getNamedProperty(_hash, _name, _checkValid); 430 } 431 432 } 433 434 @Override 435 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 436 switch (hash) { 437 case -1407102957: /*versionId*/ return this.versionId == null ? new Base[0] : new Base[] {this.versionId}; // IdType 438 case 1649733957: /*lastUpdated*/ return this.lastUpdated == null ? new Base[0] : new Base[] {this.lastUpdated}; // InstantType 439 case -309425751: /*profile*/ return this.profile == null ? new Base[0] : this.profile.toArray(new Base[this.profile.size()]); // UriType 440 case 949122880: /*security*/ return this.security == null ? new Base[0] : this.security.toArray(new Base[this.security.size()]); // Coding 441 case 114586: /*tag*/ return this.tag == null ? new Base[0] : this.tag.toArray(new Base[this.tag.size()]); // Coding 442 default: return super.getProperty(hash, name, checkValid); 443 } 444 445 } 446 447 @Override 448 public Base setProperty(int hash, String name, Base value) throws FHIRException { 449 switch (hash) { 450 case -1407102957: // versionId 451 this.versionId = castToId(value); // IdType 452 return value; 453 case 1649733957: // lastUpdated 454 this.lastUpdated = castToInstant(value); // InstantType 455 return value; 456 case -309425751: // profile 457 this.getProfile().add(castToUri(value)); // UriType 458 return value; 459 case 949122880: // security 460 this.getSecurity().add(castToCoding(value)); // Coding 461 return value; 462 case 114586: // tag 463 this.getTag().add(castToCoding(value)); // Coding 464 return value; 465 default: return super.setProperty(hash, name, value); 466 } 467 468 } 469 470 @Override 471 public Base setProperty(String name, Base value) throws FHIRException { 472 if (name.equals("versionId")) { 473 this.versionId = castToId(value); // IdType 474 } else if (name.equals("lastUpdated")) { 475 this.lastUpdated = castToInstant(value); // InstantType 476 } else if (name.equals("profile")) { 477 this.getProfile().add(castToUri(value)); 478 } else if (name.equals("security")) { 479 this.getSecurity().add(castToCoding(value)); 480 } else if (name.equals("tag")) { 481 this.getTag().add(castToCoding(value)); 482 } else 483 return super.setProperty(name, value); 484 return value; 485 } 486 487 @Override 488 public Base makeProperty(int hash, String name) throws FHIRException { 489 switch (hash) { 490 case -1407102957: return getVersionIdElement(); 491 case 1649733957: return getLastUpdatedElement(); 492 case -309425751: return addProfileElement(); 493 case 949122880: return addSecurity(); 494 case 114586: return addTag(); 495 default: return super.makeProperty(hash, name); 496 } 497 498 } 499 500 @Override 501 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 502 switch (hash) { 503 case -1407102957: /*versionId*/ return new String[] {"id"}; 504 case 1649733957: /*lastUpdated*/ return new String[] {"instant"}; 505 case -309425751: /*profile*/ return new String[] {"uri"}; 506 case 949122880: /*security*/ return new String[] {"Coding"}; 507 case 114586: /*tag*/ return new String[] {"Coding"}; 508 default: return super.getTypesForProperty(hash, name); 509 } 510 511 } 512 513 @Override 514 public Base addChild(String name) throws FHIRException { 515 if (name.equals("versionId")) { 516 throw new FHIRException("Cannot call addChild on a primitive type Meta.versionId"); 517 } 518 else if (name.equals("lastUpdated")) { 519 throw new FHIRException("Cannot call addChild on a primitive type Meta.lastUpdated"); 520 } 521 else if (name.equals("profile")) { 522 throw new FHIRException("Cannot call addChild on a primitive type Meta.profile"); 523 } 524 else if (name.equals("security")) { 525 return addSecurity(); 526 } 527 else if (name.equals("tag")) { 528 return addTag(); 529 } 530 else 531 return super.addChild(name); 532 } 533 534 public String fhirType() { 535 return "Meta"; 536 537 } 538 539 public Meta copy() { 540 Meta dst = new Meta(); 541 copyValues(dst); 542 dst.versionId = versionId == null ? null : versionId.copy(); 543 dst.lastUpdated = lastUpdated == null ? null : lastUpdated.copy(); 544 if (profile != null) { 545 dst.profile = new ArrayList<UriType>(); 546 for (UriType i : profile) 547 dst.profile.add(i.copy()); 548 }; 549 if (security != null) { 550 dst.security = new ArrayList<Coding>(); 551 for (Coding i : security) 552 dst.security.add(i.copy()); 553 }; 554 if (tag != null) { 555 dst.tag = new ArrayList<Coding>(); 556 for (Coding i : tag) 557 dst.tag.add(i.copy()); 558 }; 559 return dst; 560 } 561 562 protected Meta typedCopy() { 563 return copy(); 564 } 565 566 @Override 567 public boolean equalsDeep(Base other_) { 568 if (!super.equalsDeep(other_)) 569 return false; 570 if (!(other_ instanceof Meta)) 571 return false; 572 Meta o = (Meta) other_; 573 return compareDeep(versionId, o.versionId, true) && compareDeep(lastUpdated, o.lastUpdated, true) 574 && compareDeep(profile, o.profile, true) && compareDeep(security, o.security, true) && compareDeep(tag, o.tag, true) 575 ; 576 } 577 578 @Override 579 public boolean equalsShallow(Base other_) { 580 if (!super.equalsShallow(other_)) 581 return false; 582 if (!(other_ instanceof Meta)) 583 return false; 584 Meta o = (Meta) other_; 585 return compareValues(versionId, o.versionId, true) && compareValues(lastUpdated, o.lastUpdated, true) 586 && compareValues(profile, o.profile, true); 587 } 588 589 public boolean isEmpty() { 590 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(versionId, lastUpdated, profile 591 , security, tag); 592 } 593 594 595} 596