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 ca.uhn.fhir.model.api.annotation.Child; 038import ca.uhn.fhir.model.api.annotation.ChildOrder; 039import ca.uhn.fhir.model.api.annotation.Description; 040import ca.uhn.fhir.model.api.annotation.DatatypeDef; 041import ca.uhn.fhir.model.api.annotation.Block; 042import org.hl7.fhir.instance.model.api.*; 043import org.hl7.fhir.exceptions.FHIRException; 044import org.hl7.fhir.exceptions.FHIRFormatError; 045/** 046 * A reference to a code defined by a terminology system. 047 */ 048@DatatypeDef(name="Coding") 049public class Coding extends Type implements IBaseCoding, ICompositeType { 050 051 /** 052 * The identification of the code system that defines the meaning of the symbol in the code. 053 */ 054 @Child(name = "system", type = {UriType.class}, order=0, min=0, max=1, modifier=false, summary=true) 055 @Description(shortDefinition="Identity of the terminology system", formalDefinition="The identification of the code system that defines the meaning of the symbol in the code." ) 056 protected UriType system; 057 058 /** 059 * The version of the code system which was used when choosing this code. Note that a well-maintained code system does not need the version reported, because the meaning of codes is consistent across versions. However this cannot consistently be assured. and when the meaning is not guaranteed to be consistent, the version SHOULD be exchanged. 060 */ 061 @Child(name = "version", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true) 062 @Description(shortDefinition="Version of the system - if relevant", formalDefinition="The version of the code system which was used when choosing this code. Note that a well-maintained code system does not need the version reported, because the meaning of codes is consistent across versions. However this cannot consistently be assured. and when the meaning is not guaranteed to be consistent, the version SHOULD be exchanged." ) 063 protected StringType version; 064 065 /** 066 * A symbol in syntax defined by the system. The symbol may be a predefined code or an expression in a syntax defined by the coding system (e.g. post-coordination). 067 */ 068 @Child(name = "code", type = {CodeType.class}, order=2, min=0, max=1, modifier=false, summary=true) 069 @Description(shortDefinition="Symbol in syntax defined by the system", formalDefinition="A symbol in syntax defined by the system. The symbol may be a predefined code or an expression in a syntax defined by the coding system (e.g. post-coordination)." ) 070 protected CodeType code; 071 072 /** 073 * A representation of the meaning of the code in the system, following the rules of the system. 074 */ 075 @Child(name = "display", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true) 076 @Description(shortDefinition="Representation defined by the system", formalDefinition="A representation of the meaning of the code in the system, following the rules of the system." ) 077 protected StringType display; 078 079 /** 080 * Indicates that this coding was chosen by a user directly - i.e. off a pick list of available items (codes or displays). 081 */ 082 @Child(name = "userSelected", type = {BooleanType.class}, order=4, min=0, max=1, modifier=false, summary=true) 083 @Description(shortDefinition="If this coding was chosen directly by the user", formalDefinition="Indicates that this coding was chosen by a user directly - i.e. off a pick list of available items (codes or displays)." ) 084 protected BooleanType userSelected; 085 086 private static final long serialVersionUID = -1417514061L; 087 088 /** 089 * Constructor 090 */ 091 public Coding() { 092 super(); 093 } 094 095 /** 096 * Convenience constructor 097 * 098 * @param theSystem The {@link #setSystem(String) code system} 099 * @param theCode The {@link #setCode(String) code} 100 * @param theDisplay The {@link #setDisplay(String) human readable display} 101 */ 102 public Coding(String theSystem, String theCode, String theDisplay) { 103 setSystem(theSystem); 104 setCode(theCode); 105 setDisplay(theDisplay); 106 } 107 /** 108 * @return {@link #system} (The identification of the code system that defines the meaning of the symbol in the code.). This is the underlying object with id, value and extensions. The accessor "getSystem" gives direct access to the value 109 */ 110 public UriType getSystemElement() { 111 if (this.system == null) 112 if (Configuration.errorOnAutoCreate()) 113 throw new Error("Attempt to auto-create Coding.system"); 114 else if (Configuration.doAutoCreate()) 115 this.system = new UriType(); // bb 116 return this.system; 117 } 118 119 public boolean hasSystemElement() { 120 return this.system != null && !this.system.isEmpty(); 121 } 122 123 public boolean hasSystem() { 124 return this.system != null && !this.system.isEmpty(); 125 } 126 127 /** 128 * @param value {@link #system} (The identification of the code system that defines the meaning of the symbol in the code.). This is the underlying object with id, value and extensions. The accessor "getSystem" gives direct access to the value 129 */ 130 public Coding setSystemElement(UriType value) { 131 this.system = value; 132 return this; 133 } 134 135 /** 136 * @return The identification of the code system that defines the meaning of the symbol in the code. 137 */ 138 public String getSystem() { 139 return this.system == null ? null : this.system.getValue(); 140 } 141 142 /** 143 * @param value The identification of the code system that defines the meaning of the symbol in the code. 144 */ 145 public Coding setSystem(String value) { 146 if (Utilities.noString(value)) 147 this.system = null; 148 else { 149 if (this.system == null) 150 this.system = new UriType(); 151 this.system.setValue(value); 152 } 153 return this; 154 } 155 156 /** 157 * @return {@link #version} (The version of the code system which was used when choosing this code. Note that a well-maintained code system does not need the version reported, because the meaning of codes is consistent across versions. However this cannot consistently be assured. and when the meaning is not guaranteed to be consistent, the version SHOULD be exchanged.). This is the underlying object with id, value and extensions. The accessor "getVersion" gives direct access to the value 158 */ 159 public StringType getVersionElement() { 160 if (this.version == null) 161 if (Configuration.errorOnAutoCreate()) 162 throw new Error("Attempt to auto-create Coding.version"); 163 else if (Configuration.doAutoCreate()) 164 this.version = new StringType(); // bb 165 return this.version; 166 } 167 168 public boolean hasVersionElement() { 169 return this.version != null && !this.version.isEmpty(); 170 } 171 172 public boolean hasVersion() { 173 return this.version != null && !this.version.isEmpty(); 174 } 175 176 /** 177 * @param value {@link #version} (The version of the code system which was used when choosing this code. Note that a well-maintained code system does not need the version reported, because the meaning of codes is consistent across versions. However this cannot consistently be assured. and when the meaning is not guaranteed to be consistent, the version SHOULD be exchanged.). This is the underlying object with id, value and extensions. The accessor "getVersion" gives direct access to the value 178 */ 179 public Coding setVersionElement(StringType value) { 180 this.version = value; 181 return this; 182 } 183 184 /** 185 * @return The version of the code system which was used when choosing this code. Note that a well-maintained code system does not need the version reported, because the meaning of codes is consistent across versions. However this cannot consistently be assured. and when the meaning is not guaranteed to be consistent, the version SHOULD be exchanged. 186 */ 187 public String getVersion() { 188 return this.version == null ? null : this.version.getValue(); 189 } 190 191 /** 192 * @param value The version of the code system which was used when choosing this code. Note that a well-maintained code system does not need the version reported, because the meaning of codes is consistent across versions. However this cannot consistently be assured. and when the meaning is not guaranteed to be consistent, the version SHOULD be exchanged. 193 */ 194 public Coding setVersion(String value) { 195 if (Utilities.noString(value)) 196 this.version = null; 197 else { 198 if (this.version == null) 199 this.version = new StringType(); 200 this.version.setValue(value); 201 } 202 return this; 203 } 204 205 /** 206 * @return {@link #code} (A symbol in syntax defined by the system. The symbol may be a predefined code or an expression in a syntax defined by the coding system (e.g. post-coordination).). This is the underlying object with id, value and extensions. The accessor "getCode" gives direct access to the value 207 */ 208 public CodeType getCodeElement() { 209 if (this.code == null) 210 if (Configuration.errorOnAutoCreate()) 211 throw new Error("Attempt to auto-create Coding.code"); 212 else if (Configuration.doAutoCreate()) 213 this.code = new CodeType(); // bb 214 return this.code; 215 } 216 217 public boolean hasCodeElement() { 218 return this.code != null && !this.code.isEmpty(); 219 } 220 221 public boolean hasCode() { 222 return this.code != null && !this.code.isEmpty(); 223 } 224 225 /** 226 * @param value {@link #code} (A symbol in syntax defined by the system. The symbol may be a predefined code or an expression in a syntax defined by the coding system (e.g. post-coordination).). This is the underlying object with id, value and extensions. The accessor "getCode" gives direct access to the value 227 */ 228 public Coding setCodeElement(CodeType value) { 229 this.code = value; 230 return this; 231 } 232 233 /** 234 * @return A symbol in syntax defined by the system. The symbol may be a predefined code or an expression in a syntax defined by the coding system (e.g. post-coordination). 235 */ 236 public String getCode() { 237 return this.code == null ? null : this.code.getValue(); 238 } 239 240 /** 241 * @param value A symbol in syntax defined by the system. The symbol may be a predefined code or an expression in a syntax defined by the coding system (e.g. post-coordination). 242 */ 243 public Coding setCode(String value) { 244 if (Utilities.noString(value)) 245 this.code = null; 246 else { 247 if (this.code == null) 248 this.code = new CodeType(); 249 this.code.setValue(value); 250 } 251 return this; 252 } 253 254 /** 255 * @return {@link #display} (A representation of the meaning of the code in the system, following the rules of the system.). This is the underlying object with id, value and extensions. The accessor "getDisplay" gives direct access to the value 256 */ 257 public StringType getDisplayElement() { 258 if (this.display == null) 259 if (Configuration.errorOnAutoCreate()) 260 throw new Error("Attempt to auto-create Coding.display"); 261 else if (Configuration.doAutoCreate()) 262 this.display = new StringType(); // bb 263 return this.display; 264 } 265 266 public boolean hasDisplayElement() { 267 return this.display != null && !this.display.isEmpty(); 268 } 269 270 public boolean hasDisplay() { 271 return this.display != null && !this.display.isEmpty(); 272 } 273 274 /** 275 * @param value {@link #display} (A representation of the meaning of the code in the system, following the rules of the system.). This is the underlying object with id, value and extensions. The accessor "getDisplay" gives direct access to the value 276 */ 277 public Coding setDisplayElement(StringType value) { 278 this.display = value; 279 return this; 280 } 281 282 /** 283 * @return A representation of the meaning of the code in the system, following the rules of the system. 284 */ 285 public String getDisplay() { 286 return this.display == null ? null : this.display.getValue(); 287 } 288 289 /** 290 * @param value A representation of the meaning of the code in the system, following the rules of the system. 291 */ 292 public Coding setDisplay(String value) { 293 if (Utilities.noString(value)) 294 this.display = null; 295 else { 296 if (this.display == null) 297 this.display = new StringType(); 298 this.display.setValue(value); 299 } 300 return this; 301 } 302 303 /** 304 * @return {@link #userSelected} (Indicates that this coding was chosen by a user directly - i.e. off a pick list of available items (codes or displays).). This is the underlying object with id, value and extensions. The accessor "getUserSelected" gives direct access to the value 305 */ 306 public BooleanType getUserSelectedElement() { 307 if (this.userSelected == null) 308 if (Configuration.errorOnAutoCreate()) 309 throw new Error("Attempt to auto-create Coding.userSelected"); 310 else if (Configuration.doAutoCreate()) 311 this.userSelected = new BooleanType(); // bb 312 return this.userSelected; 313 } 314 315 public boolean hasUserSelectedElement() { 316 return this.userSelected != null && !this.userSelected.isEmpty(); 317 } 318 319 public boolean hasUserSelected() { 320 return this.userSelected != null && !this.userSelected.isEmpty(); 321 } 322 323 /** 324 * @param value {@link #userSelected} (Indicates that this coding was chosen by a user directly - i.e. off a pick list of available items (codes or displays).). This is the underlying object with id, value and extensions. The accessor "getUserSelected" gives direct access to the value 325 */ 326 public Coding setUserSelectedElement(BooleanType value) { 327 this.userSelected = value; 328 return this; 329 } 330 331 /** 332 * @return Indicates that this coding was chosen by a user directly - i.e. off a pick list of available items (codes or displays). 333 */ 334 public boolean getUserSelected() { 335 return this.userSelected == null || this.userSelected.isEmpty() ? false : this.userSelected.getValue(); 336 } 337 338 /** 339 * @param value Indicates that this coding was chosen by a user directly - i.e. off a pick list of available items (codes or displays). 340 */ 341 public Coding setUserSelected(boolean value) { 342 if (this.userSelected == null) 343 this.userSelected = new BooleanType(); 344 this.userSelected.setValue(value); 345 return this; 346 } 347 348 protected void listChildren(List<Property> children) { 349 super.listChildren(children); 350 children.add(new Property("system", "uri", "The identification of the code system that defines the meaning of the symbol in the code.", 0, 1, system)); 351 children.add(new Property("version", "string", "The version of the code system which was used when choosing this code. Note that a well-maintained code system does not need the version reported, because the meaning of codes is consistent across versions. However this cannot consistently be assured. and when the meaning is not guaranteed to be consistent, the version SHOULD be exchanged.", 0, 1, version)); 352 children.add(new Property("code", "code", "A symbol in syntax defined by the system. The symbol may be a predefined code or an expression in a syntax defined by the coding system (e.g. post-coordination).", 0, 1, code)); 353 children.add(new Property("display", "string", "A representation of the meaning of the code in the system, following the rules of the system.", 0, 1, display)); 354 children.add(new Property("userSelected", "boolean", "Indicates that this coding was chosen by a user directly - i.e. off a pick list of available items (codes or displays).", 0, 1, userSelected)); 355 } 356 357 @Override 358 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 359 switch (_hash) { 360 case -887328209: /*system*/ return new Property("system", "uri", "The identification of the code system that defines the meaning of the symbol in the code.", 0, 1, system); 361 case 351608024: /*version*/ return new Property("version", "string", "The version of the code system which was used when choosing this code. Note that a well-maintained code system does not need the version reported, because the meaning of codes is consistent across versions. However this cannot consistently be assured. and when the meaning is not guaranteed to be consistent, the version SHOULD be exchanged.", 0, 1, version); 362 case 3059181: /*code*/ return new Property("code", "code", "A symbol in syntax defined by the system. The symbol may be a predefined code or an expression in a syntax defined by the coding system (e.g. post-coordination).", 0, 1, code); 363 case 1671764162: /*display*/ return new Property("display", "string", "A representation of the meaning of the code in the system, following the rules of the system.", 0, 1, display); 364 case 423643014: /*userSelected*/ return new Property("userSelected", "boolean", "Indicates that this coding was chosen by a user directly - i.e. off a pick list of available items (codes or displays).", 0, 1, userSelected); 365 default: return super.getNamedProperty(_hash, _name, _checkValid); 366 } 367 368 } 369 370 @Override 371 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 372 switch (hash) { 373 case -887328209: /*system*/ return this.system == null ? new Base[0] : new Base[] {this.system}; // UriType 374 case 351608024: /*version*/ return this.version == null ? new Base[0] : new Base[] {this.version}; // StringType 375 case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeType 376 case 1671764162: /*display*/ return this.display == null ? new Base[0] : new Base[] {this.display}; // StringType 377 case 423643014: /*userSelected*/ return this.userSelected == null ? new Base[0] : new Base[] {this.userSelected}; // BooleanType 378 default: return super.getProperty(hash, name, checkValid); 379 } 380 381 } 382 383 @Override 384 public Base setProperty(int hash, String name, Base value) throws FHIRException { 385 switch (hash) { 386 case -887328209: // system 387 this.system = castToUri(value); // UriType 388 return value; 389 case 351608024: // version 390 this.version = castToString(value); // StringType 391 return value; 392 case 3059181: // code 393 this.code = castToCode(value); // CodeType 394 return value; 395 case 1671764162: // display 396 this.display = castToString(value); // StringType 397 return value; 398 case 423643014: // userSelected 399 this.userSelected = castToBoolean(value); // BooleanType 400 return value; 401 default: return super.setProperty(hash, name, value); 402 } 403 404 } 405 406 @Override 407 public Base setProperty(String name, Base value) throws FHIRException { 408 if (name.equals("system")) { 409 this.system = castToUri(value); // UriType 410 } else if (name.equals("version")) { 411 this.version = castToString(value); // StringType 412 } else if (name.equals("code")) { 413 this.code = castToCode(value); // CodeType 414 } else if (name.equals("display")) { 415 this.display = castToString(value); // StringType 416 } else if (name.equals("userSelected")) { 417 this.userSelected = castToBoolean(value); // BooleanType 418 } else 419 return super.setProperty(name, value); 420 return value; 421 } 422 423 @Override 424 public Base makeProperty(int hash, String name) throws FHIRException { 425 switch (hash) { 426 case -887328209: return getSystemElement(); 427 case 351608024: return getVersionElement(); 428 case 3059181: return getCodeElement(); 429 case 1671764162: return getDisplayElement(); 430 case 423643014: return getUserSelectedElement(); 431 default: return super.makeProperty(hash, name); 432 } 433 434 } 435 436 @Override 437 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 438 switch (hash) { 439 case -887328209: /*system*/ return new String[] {"uri"}; 440 case 351608024: /*version*/ return new String[] {"string"}; 441 case 3059181: /*code*/ return new String[] {"code"}; 442 case 1671764162: /*display*/ return new String[] {"string"}; 443 case 423643014: /*userSelected*/ return new String[] {"boolean"}; 444 default: return super.getTypesForProperty(hash, name); 445 } 446 447 } 448 449 @Override 450 public Base addChild(String name) throws FHIRException { 451 if (name.equals("system")) { 452 throw new FHIRException("Cannot call addChild on a primitive type Coding.system"); 453 } 454 else if (name.equals("version")) { 455 throw new FHIRException("Cannot call addChild on a primitive type Coding.version"); 456 } 457 else if (name.equals("code")) { 458 throw new FHIRException("Cannot call addChild on a primitive type Coding.code"); 459 } 460 else if (name.equals("display")) { 461 throw new FHIRException("Cannot call addChild on a primitive type Coding.display"); 462 } 463 else if (name.equals("userSelected")) { 464 throw new FHIRException("Cannot call addChild on a primitive type Coding.userSelected"); 465 } 466 else 467 return super.addChild(name); 468 } 469 470 public String fhirType() { 471 return "Coding"; 472 473 } 474 475 public Coding copy() { 476 Coding dst = new Coding(); 477 copyValues(dst); 478 dst.system = system == null ? null : system.copy(); 479 dst.version = version == null ? null : version.copy(); 480 dst.code = code == null ? null : code.copy(); 481 dst.display = display == null ? null : display.copy(); 482 dst.userSelected = userSelected == null ? null : userSelected.copy(); 483 return dst; 484 } 485 486 protected Coding typedCopy() { 487 return copy(); 488 } 489 490 @Override 491 public boolean equalsDeep(Base other_) { 492 if (!super.equalsDeep(other_)) 493 return false; 494 if (!(other_ instanceof Coding)) 495 return false; 496 Coding o = (Coding) other_; 497 return compareDeep(system, o.system, true) && compareDeep(version, o.version, true) && compareDeep(code, o.code, true) 498 && compareDeep(display, o.display, true) && compareDeep(userSelected, o.userSelected, true); 499 } 500 501 @Override 502 public boolean equalsShallow(Base other_) { 503 if (!super.equalsShallow(other_)) 504 return false; 505 if (!(other_ instanceof Coding)) 506 return false; 507 Coding o = (Coding) other_; 508 return compareValues(system, o.system, true) && compareValues(version, o.version, true) && compareValues(code, o.code, true) 509 && compareValues(display, o.display, true) && compareValues(userSelected, o.userSelected, true); 510 } 511 512 public boolean isEmpty() { 513 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(system, version, code, display 514 , userSelected); 515 } 516 517 518} 519