001package org.hl7.fhir.dstu2016may.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 Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0 033import java.util.List; 034 035import org.hl7.fhir.exceptions.FHIRException; 036import org.hl7.fhir.instance.model.api.ICompositeType; 037import org.hl7.fhir.utilities.Utilities; 038 039import ca.uhn.fhir.model.api.annotation.Child; 040import ca.uhn.fhir.model.api.annotation.DatatypeDef; 041import ca.uhn.fhir.model.api.annotation.Description; 042/** 043 * A technical identifier - identifies some entity uniquely and unambiguously. 044 */ 045@DatatypeDef(name="Identifier") 046public class Identifier extends Type implements ICompositeType { 047 048 public enum IdentifierUse { 049 /** 050 * The identifier recommended for display and use in real-world interactions. 051 */ 052 USUAL, 053 /** 054 * The identifier considered to be most trusted for the identification of this item. 055 */ 056 OFFICIAL, 057 /** 058 * A temporary identifier. 059 */ 060 TEMP, 061 /** 062 * An identifier that was assigned in secondary use - it serves to identify the object in a relative context, but cannot be consistently assigned to the same object again in a different context. 063 */ 064 SECONDARY, 065 /** 066 * added to help the parsers 067 */ 068 NULL; 069 public static IdentifierUse fromCode(String codeString) throws FHIRException { 070 if (codeString == null || "".equals(codeString)) 071 return null; 072 if ("usual".equals(codeString)) 073 return USUAL; 074 if ("official".equals(codeString)) 075 return OFFICIAL; 076 if ("temp".equals(codeString)) 077 return TEMP; 078 if ("secondary".equals(codeString)) 079 return SECONDARY; 080 throw new FHIRException("Unknown IdentifierUse code '"+codeString+"'"); 081 } 082 public String toCode() { 083 switch (this) { 084 case USUAL: return "usual"; 085 case OFFICIAL: return "official"; 086 case TEMP: return "temp"; 087 case SECONDARY: return "secondary"; 088 default: return "?"; 089 } 090 } 091 public String getSystem() { 092 switch (this) { 093 case USUAL: return "http://hl7.org/fhir/identifier-use"; 094 case OFFICIAL: return "http://hl7.org/fhir/identifier-use"; 095 case TEMP: return "http://hl7.org/fhir/identifier-use"; 096 case SECONDARY: return "http://hl7.org/fhir/identifier-use"; 097 default: return "?"; 098 } 099 } 100 public String getDefinition() { 101 switch (this) { 102 case USUAL: return "The identifier recommended for display and use in real-world interactions."; 103 case OFFICIAL: return "The identifier considered to be most trusted for the identification of this item."; 104 case TEMP: return "A temporary identifier."; 105 case SECONDARY: return "An identifier that was assigned in secondary use - it serves to identify the object in a relative context, but cannot be consistently assigned to the same object again in a different context."; 106 default: return "?"; 107 } 108 } 109 public String getDisplay() { 110 switch (this) { 111 case USUAL: return "Usual"; 112 case OFFICIAL: return "Official"; 113 case TEMP: return "Temp"; 114 case SECONDARY: return "Secondary"; 115 default: return "?"; 116 } 117 } 118 } 119 120 public static class IdentifierUseEnumFactory implements EnumFactory<IdentifierUse> { 121 public IdentifierUse fromCode(String codeString) throws IllegalArgumentException { 122 if (codeString == null || "".equals(codeString)) 123 if (codeString == null || "".equals(codeString)) 124 return null; 125 if ("usual".equals(codeString)) 126 return IdentifierUse.USUAL; 127 if ("official".equals(codeString)) 128 return IdentifierUse.OFFICIAL; 129 if ("temp".equals(codeString)) 130 return IdentifierUse.TEMP; 131 if ("secondary".equals(codeString)) 132 return IdentifierUse.SECONDARY; 133 throw new IllegalArgumentException("Unknown IdentifierUse code '"+codeString+"'"); 134 } 135 public Enumeration<IdentifierUse> fromType(Base code) throws FHIRException { 136 if (code == null || code.isEmpty()) 137 return null; 138 String codeString = ((PrimitiveType) code).asStringValue(); 139 if (codeString == null || "".equals(codeString)) 140 return null; 141 if ("usual".equals(codeString)) 142 return new Enumeration<IdentifierUse>(this, IdentifierUse.USUAL); 143 if ("official".equals(codeString)) 144 return new Enumeration<IdentifierUse>(this, IdentifierUse.OFFICIAL); 145 if ("temp".equals(codeString)) 146 return new Enumeration<IdentifierUse>(this, IdentifierUse.TEMP); 147 if ("secondary".equals(codeString)) 148 return new Enumeration<IdentifierUse>(this, IdentifierUse.SECONDARY); 149 throw new FHIRException("Unknown IdentifierUse code '"+codeString+"'"); 150 } 151 public String toCode(IdentifierUse code) { 152 if (code == IdentifierUse.USUAL) 153 return "usual"; 154 if (code == IdentifierUse.OFFICIAL) 155 return "official"; 156 if (code == IdentifierUse.TEMP) 157 return "temp"; 158 if (code == IdentifierUse.SECONDARY) 159 return "secondary"; 160 return "?"; 161 } 162 public String toSystem(IdentifierUse code) { 163 return code.getSystem(); 164 } 165 } 166 167 /** 168 * The purpose of this identifier. 169 */ 170 @Child(name = "use", type = {CodeType.class}, order=0, min=0, max=1, modifier=true, summary=true) 171 @Description(shortDefinition="usual | official | temp | secondary (If known)", formalDefinition="The purpose of this identifier." ) 172 protected Enumeration<IdentifierUse> use; 173 174 /** 175 * A coded type for the identifier that can be used to determine which identifier to use for a specific purpose. 176 */ 177 @Child(name = "type", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true) 178 @Description(shortDefinition="Description of identifier", formalDefinition="A coded type for the identifier that can be used to determine which identifier to use for a specific purpose." ) 179 protected CodeableConcept type; 180 181 /** 182 * Establishes the namespace in which set of possible id values is unique. 183 */ 184 @Child(name = "system", type = {UriType.class}, order=2, min=0, max=1, modifier=false, summary=true) 185 @Description(shortDefinition="The namespace for the identifier", formalDefinition="Establishes the namespace in which set of possible id values is unique." ) 186 protected UriType system; 187 188 /** 189 * The portion of the identifier typically relevant to the user and which is unique within the context of the system. 190 */ 191 @Child(name = "value", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true) 192 @Description(shortDefinition="The value that is unique", formalDefinition="The portion of the identifier typically relevant to the user and which is unique within the context of the system." ) 193 protected StringType value; 194 195 /** 196 * Time period during which identifier is/was valid for use. 197 */ 198 @Child(name = "period", type = {Period.class}, order=4, min=0, max=1, modifier=false, summary=true) 199 @Description(shortDefinition="Time period when id is/was valid for use", formalDefinition="Time period during which identifier is/was valid for use." ) 200 protected Period period; 201 202 /** 203 * Organization that issued/manages the identifier. 204 */ 205 @Child(name = "assigner", type = {Organization.class}, order=5, min=0, max=1, modifier=false, summary=true) 206 @Description(shortDefinition="Organization that issued id (may be just text)", formalDefinition="Organization that issued/manages the identifier." ) 207 protected Reference assigner; 208 209 /** 210 * The actual object that is the target of the reference (Organization that issued/manages the identifier.) 211 */ 212 protected Organization assignerTarget; 213 214 private static final long serialVersionUID = -478840981L; 215 216 /** 217 * Constructor 218 */ 219 public Identifier() { 220 super(); 221 } 222 223 /** 224 * @return {@link #use} (The purpose of this identifier.). This is the underlying object with id, value and extensions. The accessor "getUse" gives direct access to the value 225 */ 226 public Enumeration<IdentifierUse> getUseElement() { 227 if (this.use == null) 228 if (Configuration.errorOnAutoCreate()) 229 throw new Error("Attempt to auto-create Identifier.use"); 230 else if (Configuration.doAutoCreate()) 231 this.use = new Enumeration<IdentifierUse>(new IdentifierUseEnumFactory()); // bb 232 return this.use; 233 } 234 235 public boolean hasUseElement() { 236 return this.use != null && !this.use.isEmpty(); 237 } 238 239 public boolean hasUse() { 240 return this.use != null && !this.use.isEmpty(); 241 } 242 243 /** 244 * @param value {@link #use} (The purpose of this identifier.). This is the underlying object with id, value and extensions. The accessor "getUse" gives direct access to the value 245 */ 246 public Identifier setUseElement(Enumeration<IdentifierUse> value) { 247 this.use = value; 248 return this; 249 } 250 251 /** 252 * @return The purpose of this identifier. 253 */ 254 public IdentifierUse getUse() { 255 return this.use == null ? null : this.use.getValue(); 256 } 257 258 /** 259 * @param value The purpose of this identifier. 260 */ 261 public Identifier setUse(IdentifierUse value) { 262 if (value == null) 263 this.use = null; 264 else { 265 if (this.use == null) 266 this.use = new Enumeration<IdentifierUse>(new IdentifierUseEnumFactory()); 267 this.use.setValue(value); 268 } 269 return this; 270 } 271 272 /** 273 * @return {@link #type} (A coded type for the identifier that can be used to determine which identifier to use for a specific purpose.) 274 */ 275 public CodeableConcept getType() { 276 if (this.type == null) 277 if (Configuration.errorOnAutoCreate()) 278 throw new Error("Attempt to auto-create Identifier.type"); 279 else if (Configuration.doAutoCreate()) 280 this.type = new CodeableConcept(); // cc 281 return this.type; 282 } 283 284 public boolean hasType() { 285 return this.type != null && !this.type.isEmpty(); 286 } 287 288 /** 289 * @param value {@link #type} (A coded type for the identifier that can be used to determine which identifier to use for a specific purpose.) 290 */ 291 public Identifier setType(CodeableConcept value) { 292 this.type = value; 293 return this; 294 } 295 296 /** 297 * @return {@link #system} (Establishes the namespace in which set of possible id values is unique.). This is the underlying object with id, value and extensions. The accessor "getSystem" gives direct access to the value 298 */ 299 public UriType getSystemElement() { 300 if (this.system == null) 301 if (Configuration.errorOnAutoCreate()) 302 throw new Error("Attempt to auto-create Identifier.system"); 303 else if (Configuration.doAutoCreate()) 304 this.system = new UriType(); // bb 305 return this.system; 306 } 307 308 public boolean hasSystemElement() { 309 return this.system != null && !this.system.isEmpty(); 310 } 311 312 public boolean hasSystem() { 313 return this.system != null && !this.system.isEmpty(); 314 } 315 316 /** 317 * @param value {@link #system} (Establishes the namespace in which set of possible id values is unique.). This is the underlying object with id, value and extensions. The accessor "getSystem" gives direct access to the value 318 */ 319 public Identifier setSystemElement(UriType value) { 320 this.system = value; 321 return this; 322 } 323 324 /** 325 * @return Establishes the namespace in which set of possible id values is unique. 326 */ 327 public String getSystem() { 328 return this.system == null ? null : this.system.getValue(); 329 } 330 331 /** 332 * @param value Establishes the namespace in which set of possible id values is unique. 333 */ 334 public Identifier setSystem(String value) { 335 if (Utilities.noString(value)) 336 this.system = null; 337 else { 338 if (this.system == null) 339 this.system = new UriType(); 340 this.system.setValue(value); 341 } 342 return this; 343 } 344 345 /** 346 * @return {@link #value} (The portion of the identifier typically relevant to the user and which is unique within the context of the system.). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value 347 */ 348 public StringType getValueElement() { 349 if (this.value == null) 350 if (Configuration.errorOnAutoCreate()) 351 throw new Error("Attempt to auto-create Identifier.value"); 352 else if (Configuration.doAutoCreate()) 353 this.value = new StringType(); // bb 354 return this.value; 355 } 356 357 public boolean hasValueElement() { 358 return this.value != null && !this.value.isEmpty(); 359 } 360 361 public boolean hasValue() { 362 return this.value != null && !this.value.isEmpty(); 363 } 364 365 /** 366 * @param value {@link #value} (The portion of the identifier typically relevant to the user and which is unique within the context of the system.). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value 367 */ 368 public Identifier setValueElement(StringType value) { 369 this.value = value; 370 return this; 371 } 372 373 /** 374 * @return The portion of the identifier typically relevant to the user and which is unique within the context of the system. 375 */ 376 public String getValue() { 377 return this.value == null ? null : this.value.getValue(); 378 } 379 380 /** 381 * @param value The portion of the identifier typically relevant to the user and which is unique within the context of the system. 382 */ 383 public Identifier setValue(String value) { 384 if (Utilities.noString(value)) 385 this.value = null; 386 else { 387 if (this.value == null) 388 this.value = new StringType(); 389 this.value.setValue(value); 390 } 391 return this; 392 } 393 394 /** 395 * @return {@link #period} (Time period during which identifier is/was valid for use.) 396 */ 397 public Period getPeriod() { 398 if (this.period == null) 399 if (Configuration.errorOnAutoCreate()) 400 throw new Error("Attempt to auto-create Identifier.period"); 401 else if (Configuration.doAutoCreate()) 402 this.period = new Period(); // cc 403 return this.period; 404 } 405 406 public boolean hasPeriod() { 407 return this.period != null && !this.period.isEmpty(); 408 } 409 410 /** 411 * @param value {@link #period} (Time period during which identifier is/was valid for use.) 412 */ 413 public Identifier setPeriod(Period value) { 414 this.period = value; 415 return this; 416 } 417 418 /** 419 * @return {@link #assigner} (Organization that issued/manages the identifier.) 420 */ 421 public Reference getAssigner() { 422 if (this.assigner == null) 423 if (Configuration.errorOnAutoCreate()) 424 throw new Error("Attempt to auto-create Identifier.assigner"); 425 else if (Configuration.doAutoCreate()) 426 this.assigner = new Reference(); // cc 427 return this.assigner; 428 } 429 430 public boolean hasAssigner() { 431 return this.assigner != null && !this.assigner.isEmpty(); 432 } 433 434 /** 435 * @param value {@link #assigner} (Organization that issued/manages the identifier.) 436 */ 437 public Identifier setAssigner(Reference value) { 438 this.assigner = value; 439 return this; 440 } 441 442 /** 443 * @return {@link #assigner} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Organization that issued/manages the identifier.) 444 */ 445 public Organization getAssignerTarget() { 446 if (this.assignerTarget == null) 447 if (Configuration.errorOnAutoCreate()) 448 throw new Error("Attempt to auto-create Identifier.assigner"); 449 else if (Configuration.doAutoCreate()) 450 this.assignerTarget = new Organization(); // aa 451 return this.assignerTarget; 452 } 453 454 /** 455 * @param value {@link #assigner} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Organization that issued/manages the identifier.) 456 */ 457 public Identifier setAssignerTarget(Organization value) { 458 this.assignerTarget = value; 459 return this; 460 } 461 462 protected void listChildren(List<Property> childrenList) { 463 super.listChildren(childrenList); 464 childrenList.add(new Property("use", "code", "The purpose of this identifier.", 0, java.lang.Integer.MAX_VALUE, use)); 465 childrenList.add(new Property("type", "CodeableConcept", "A coded type for the identifier that can be used to determine which identifier to use for a specific purpose.", 0, java.lang.Integer.MAX_VALUE, type)); 466 childrenList.add(new Property("system", "uri", "Establishes the namespace in which set of possible id values is unique.", 0, java.lang.Integer.MAX_VALUE, system)); 467 childrenList.add(new Property("value", "string", "The portion of the identifier typically relevant to the user and which is unique within the context of the system.", 0, java.lang.Integer.MAX_VALUE, value)); 468 childrenList.add(new Property("period", "Period", "Time period during which identifier is/was valid for use.", 0, java.lang.Integer.MAX_VALUE, period)); 469 childrenList.add(new Property("assigner", "Reference(Organization)", "Organization that issued/manages the identifier.", 0, java.lang.Integer.MAX_VALUE, assigner)); 470 } 471 472 @Override 473 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 474 switch (hash) { 475 case 116103: /*use*/ return this.use == null ? new Base[0] : new Base[] {this.use}; // Enumeration<IdentifierUse> 476 case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept 477 case -887328209: /*system*/ return this.system == null ? new Base[0] : new Base[] {this.system}; // UriType 478 case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // StringType 479 case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period 480 case -369881636: /*assigner*/ return this.assigner == null ? new Base[0] : new Base[] {this.assigner}; // Reference 481 default: return super.getProperty(hash, name, checkValid); 482 } 483 484 } 485 486 @Override 487 public void setProperty(int hash, String name, Base value) throws FHIRException { 488 switch (hash) { 489 case 116103: // use 490 this.use = new IdentifierUseEnumFactory().fromType(value); // Enumeration<IdentifierUse> 491 break; 492 case 3575610: // type 493 this.type = castToCodeableConcept(value); // CodeableConcept 494 break; 495 case -887328209: // system 496 this.system = castToUri(value); // UriType 497 break; 498 case 111972721: // value 499 this.value = castToString(value); // StringType 500 break; 501 case -991726143: // period 502 this.period = castToPeriod(value); // Period 503 break; 504 case -369881636: // assigner 505 this.assigner = castToReference(value); // Reference 506 break; 507 default: super.setProperty(hash, name, value); 508 } 509 510 } 511 512 @Override 513 public void setProperty(String name, Base value) throws FHIRException { 514 if (name.equals("use")) 515 this.use = new IdentifierUseEnumFactory().fromType(value); // Enumeration<IdentifierUse> 516 else if (name.equals("type")) 517 this.type = castToCodeableConcept(value); // CodeableConcept 518 else if (name.equals("system")) 519 this.system = castToUri(value); // UriType 520 else if (name.equals("value")) 521 this.value = castToString(value); // StringType 522 else if (name.equals("period")) 523 this.period = castToPeriod(value); // Period 524 else if (name.equals("assigner")) 525 this.assigner = castToReference(value); // Reference 526 else 527 super.setProperty(name, value); 528 } 529 530 @Override 531 public Base makeProperty(int hash, String name) throws FHIRException { 532 switch (hash) { 533 case 116103: throw new FHIRException("Cannot make property use as it is not a complex type"); // Enumeration<IdentifierUse> 534 case 3575610: return getType(); // CodeableConcept 535 case -887328209: throw new FHIRException("Cannot make property system as it is not a complex type"); // UriType 536 case 111972721: throw new FHIRException("Cannot make property value as it is not a complex type"); // StringType 537 case -991726143: return getPeriod(); // Period 538 case -369881636: return getAssigner(); // Reference 539 default: return super.makeProperty(hash, name); 540 } 541 542 } 543 544 @Override 545 public Base addChild(String name) throws FHIRException { 546 if (name.equals("use")) { 547 throw new FHIRException("Cannot call addChild on a primitive type Identifier.use"); 548 } 549 else if (name.equals("type")) { 550 this.type = new CodeableConcept(); 551 return this.type; 552 } 553 else if (name.equals("system")) { 554 throw new FHIRException("Cannot call addChild on a primitive type Identifier.system"); 555 } 556 else if (name.equals("value")) { 557 throw new FHIRException("Cannot call addChild on a primitive type Identifier.value"); 558 } 559 else if (name.equals("period")) { 560 this.period = new Period(); 561 return this.period; 562 } 563 else if (name.equals("assigner")) { 564 this.assigner = new Reference(); 565 return this.assigner; 566 } 567 else 568 return super.addChild(name); 569 } 570 571 public String fhirType() { 572 return "Identifier"; 573 574 } 575 576 public Identifier copy() { 577 Identifier dst = new Identifier(); 578 copyValues(dst); 579 dst.use = use == null ? null : use.copy(); 580 dst.type = type == null ? null : type.copy(); 581 dst.system = system == null ? null : system.copy(); 582 dst.value = value == null ? null : value.copy(); 583 dst.period = period == null ? null : period.copy(); 584 dst.assigner = assigner == null ? null : assigner.copy(); 585 return dst; 586 } 587 588 protected Identifier typedCopy() { 589 return copy(); 590 } 591 592 @Override 593 public boolean equalsDeep(Base other) { 594 if (!super.equalsDeep(other)) 595 return false; 596 if (!(other instanceof Identifier)) 597 return false; 598 Identifier o = (Identifier) other; 599 return compareDeep(use, o.use, true) && compareDeep(type, o.type, true) && compareDeep(system, o.system, true) 600 && compareDeep(value, o.value, true) && compareDeep(period, o.period, true) && compareDeep(assigner, o.assigner, true) 601 ; 602 } 603 604 @Override 605 public boolean equalsShallow(Base other) { 606 if (!super.equalsShallow(other)) 607 return false; 608 if (!(other instanceof Identifier)) 609 return false; 610 Identifier o = (Identifier) other; 611 return compareValues(use, o.use, true) && compareValues(system, o.system, true) && compareValues(value, o.value, true) 612 ; 613 } 614 615 public boolean isEmpty() { 616 return super.isEmpty() && (use == null || use.isEmpty()) && (type == null || type.isEmpty()) 617 && (system == null || system.isEmpty()) && (value == null || value.isEmpty()) && (period == null || period.isEmpty()) 618 && (assigner == null || assigner.isEmpty()); 619 } 620 621 622} 623