001package org.hl7.fhir.dstu2.model; 002 003 004 005 006/* 007 Copyright (c) 2011+, HL7, Inc. 008 All rights reserved. 009 010 Redistribution and use in source and binary forms, with or without modification, 011 are permitted provided that the following conditions are met: 012 013 * Redistributions of source code must retain the above copyright notice, this 014 list of conditions and the following disclaimer. 015 * Redistributions in binary form must reproduce the above copyright notice, 016 this list of conditions and the following disclaimer in the documentation 017 and/or other materials provided with the distribution. 018 * Neither the name of HL7 nor the names of its contributors may be used to 019 endorse or promote products derived from this software without specific 020 prior written permission. 021 022 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 023 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 024 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 025 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 026 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 027 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 028 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 029 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 030 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 031 POSSIBILITY OF SUCH DAMAGE. 032 033*/ 034 035// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2 036import java.util.List; 037 038import ca.uhn.fhir.model.api.annotation.Child; 039import ca.uhn.fhir.model.api.annotation.DatatypeDef; 040import ca.uhn.fhir.model.api.annotation.Description; 041import org.hl7.fhir.instance.model.api.IBaseCoding; 042import org.hl7.fhir.instance.model.api.ICompositeType; 043import org.hl7.fhir.exceptions.FHIRException; 044import org.hl7.fhir.utilities.Utilities; 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 * @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 097 */ 098 public UriType getSystemElement() { 099 if (this.system == null) 100 if (Configuration.errorOnAutoCreate()) 101 throw new Error("Attempt to auto-create Coding.system"); 102 else if (Configuration.doAutoCreate()) 103 this.system = new UriType(); // bb 104 return this.system; 105 } 106 107 public boolean hasSystemElement() { 108 return this.system != null && !this.system.isEmpty(); 109 } 110 111 public boolean hasSystem() { 112 return this.system != null && !this.system.isEmpty(); 113 } 114 115 /** 116 * @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 117 */ 118 public Coding setSystemElement(UriType value) { 119 this.system = value; 120 return this; 121 } 122 123 /** 124 * @return The identification of the code system that defines the meaning of the symbol in the code. 125 */ 126 public String getSystem() { 127 return this.system == null ? null : this.system.getValue(); 128 } 129 130 /** 131 * @param value The identification of the code system that defines the meaning of the symbol in the code. 132 */ 133 public Coding setSystem(String value) { 134 if (Utilities.noString(value)) 135 this.system = null; 136 else { 137 if (this.system == null) 138 this.system = new UriType(); 139 this.system.setValue(value); 140 } 141 return this; 142 } 143 144 /** 145 * @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 146 */ 147 public StringType getVersionElement() { 148 if (this.version == null) 149 if (Configuration.errorOnAutoCreate()) 150 throw new Error("Attempt to auto-create Coding.version"); 151 else if (Configuration.doAutoCreate()) 152 this.version = new StringType(); // bb 153 return this.version; 154 } 155 156 public boolean hasVersionElement() { 157 return this.version != null && !this.version.isEmpty(); 158 } 159 160 public boolean hasVersion() { 161 return this.version != null && !this.version.isEmpty(); 162 } 163 164 /** 165 * @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 166 */ 167 public Coding setVersionElement(StringType value) { 168 this.version = value; 169 return this; 170 } 171 172 /** 173 * @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. 174 */ 175 public String getVersion() { 176 return this.version == null ? null : this.version.getValue(); 177 } 178 179 /** 180 * @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. 181 */ 182 public Coding setVersion(String value) { 183 if (Utilities.noString(value)) 184 this.version = null; 185 else { 186 if (this.version == null) 187 this.version = new StringType(); 188 this.version.setValue(value); 189 } 190 return this; 191 } 192 193 /** 194 * @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 195 */ 196 public CodeType getCodeElement() { 197 if (this.code == null) 198 if (Configuration.errorOnAutoCreate()) 199 throw new Error("Attempt to auto-create Coding.code"); 200 else if (Configuration.doAutoCreate()) 201 this.code = new CodeType(); // bb 202 return this.code; 203 } 204 205 public boolean hasCodeElement() { 206 return this.code != null && !this.code.isEmpty(); 207 } 208 209 public boolean hasCode() { 210 return this.code != null && !this.code.isEmpty(); 211 } 212 213 /** 214 * @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 215 */ 216 public Coding setCodeElement(CodeType value) { 217 this.code = value; 218 return this; 219 } 220 221 /** 222 * @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). 223 */ 224 public String getCode() { 225 return this.code == null ? null : this.code.getValue(); 226 } 227 228 /** 229 * @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). 230 */ 231 public Coding setCode(String value) { 232 if (Utilities.noString(value)) 233 this.code = null; 234 else { 235 if (this.code == null) 236 this.code = new CodeType(); 237 this.code.setValue(value); 238 } 239 return this; 240 } 241 242 /** 243 * @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 244 */ 245 public StringType getDisplayElement() { 246 if (this.display == null) 247 if (Configuration.errorOnAutoCreate()) 248 throw new Error("Attempt to auto-create Coding.display"); 249 else if (Configuration.doAutoCreate()) 250 this.display = new StringType(); // bb 251 return this.display; 252 } 253 254 public boolean hasDisplayElement() { 255 return this.display != null && !this.display.isEmpty(); 256 } 257 258 public boolean hasDisplay() { 259 return this.display != null && !this.display.isEmpty(); 260 } 261 262 /** 263 * @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 264 */ 265 public Coding setDisplayElement(StringType value) { 266 this.display = value; 267 return this; 268 } 269 270 /** 271 * @return A representation of the meaning of the code in the system, following the rules of the system. 272 */ 273 public String getDisplay() { 274 return this.display == null ? null : this.display.getValue(); 275 } 276 277 /** 278 * @param value A representation of the meaning of the code in the system, following the rules of the system. 279 */ 280 public Coding setDisplay(String value) { 281 if (Utilities.noString(value)) 282 this.display = null; 283 else { 284 if (this.display == null) 285 this.display = new StringType(); 286 this.display.setValue(value); 287 } 288 return this; 289 } 290 291 /** 292 * @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 293 */ 294 public BooleanType getUserSelectedElement() { 295 if (this.userSelected == null) 296 if (Configuration.errorOnAutoCreate()) 297 throw new Error("Attempt to auto-create Coding.userSelected"); 298 else if (Configuration.doAutoCreate()) 299 this.userSelected = new BooleanType(); // bb 300 return this.userSelected; 301 } 302 303 public boolean hasUserSelectedElement() { 304 return this.userSelected != null && !this.userSelected.isEmpty(); 305 } 306 307 public boolean hasUserSelected() { 308 return this.userSelected != null && !this.userSelected.isEmpty(); 309 } 310 311 /** 312 * @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 313 */ 314 public Coding setUserSelectedElement(BooleanType value) { 315 this.userSelected = value; 316 return this; 317 } 318 319 /** 320 * @return Indicates that this coding was chosen by a user directly - i.e. off a pick list of available items (codes or displays). 321 */ 322 public boolean getUserSelected() { 323 return this.userSelected == null || this.userSelected.isEmpty() ? false : this.userSelected.getValue(); 324 } 325 326 /** 327 * @param value Indicates that this coding was chosen by a user directly - i.e. off a pick list of available items (codes or displays). 328 */ 329 public Coding setUserSelected(boolean value) { 330 if (this.userSelected == null) 331 this.userSelected = new BooleanType(); 332 this.userSelected.setValue(value); 333 return this; 334 } 335 336 protected void listChildren(List<Property> childrenList) { 337 super.listChildren(childrenList); 338 childrenList.add(new Property("system", "uri", "The identification of the code system that defines the meaning of the symbol in the code.", 0, java.lang.Integer.MAX_VALUE, system)); 339 childrenList.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, java.lang.Integer.MAX_VALUE, version)); 340 childrenList.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, java.lang.Integer.MAX_VALUE, code)); 341 childrenList.add(new Property("display", "string", "A representation of the meaning of the code in the system, following the rules of the system.", 0, java.lang.Integer.MAX_VALUE, display)); 342 childrenList.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, java.lang.Integer.MAX_VALUE, userSelected)); 343 } 344 345 @Override 346 public void setProperty(String name, Base value) throws FHIRException { 347 if (name.equals("system")) 348 this.system = castToUri(value); // UriType 349 else if (name.equals("version")) 350 this.version = castToString(value); // StringType 351 else if (name.equals("code")) 352 this.code = castToCode(value); // CodeType 353 else if (name.equals("display")) 354 this.display = castToString(value); // StringType 355 else if (name.equals("userSelected")) 356 this.userSelected = castToBoolean(value); // BooleanType 357 else 358 super.setProperty(name, value); 359 } 360 361 @Override 362 public Base addChild(String name) throws FHIRException { 363 if (name.equals("system")) { 364 throw new FHIRException("Cannot call addChild on a primitive type Coding.system"); 365 } 366 else if (name.equals("version")) { 367 throw new FHIRException("Cannot call addChild on a primitive type Coding.version"); 368 } 369 else if (name.equals("code")) { 370 throw new FHIRException("Cannot call addChild on a primitive type Coding.code"); 371 } 372 else if (name.equals("display")) { 373 throw new FHIRException("Cannot call addChild on a primitive type Coding.display"); 374 } 375 else if (name.equals("userSelected")) { 376 throw new FHIRException("Cannot call addChild on a primitive type Coding.userSelected"); 377 } 378 else 379 return super.addChild(name); 380 } 381 382 public String fhirType() { 383 return "Coding"; 384 385 } 386 387 public Coding copy() { 388 Coding dst = new Coding(); 389 copyValues(dst); 390 dst.system = system == null ? null : system.copy(); 391 dst.version = version == null ? null : version.copy(); 392 dst.code = code == null ? null : code.copy(); 393 dst.display = display == null ? null : display.copy(); 394 dst.userSelected = userSelected == null ? null : userSelected.copy(); 395 return dst; 396 } 397 398 protected Coding typedCopy() { 399 return copy(); 400 } 401 402 @Override 403 public boolean equalsDeep(Base other) { 404 if (!super.equalsDeep(other)) 405 return false; 406 if (!(other instanceof Coding)) 407 return false; 408 Coding o = (Coding) other; 409 return compareDeep(system, o.system, true) && compareDeep(version, o.version, true) && compareDeep(code, o.code, true) 410 && compareDeep(display, o.display, true) && compareDeep(userSelected, o.userSelected, true); 411 } 412 413 @Override 414 public boolean equalsShallow(Base other) { 415 if (!super.equalsShallow(other)) 416 return false; 417 if (!(other instanceof Coding)) 418 return false; 419 Coding o = (Coding) other; 420 return compareValues(system, o.system, true) && compareValues(version, o.version, true) && compareValues(code, o.code, true) 421 && compareValues(display, o.display, true) && compareValues(userSelected, o.userSelected, true); 422 } 423 424 public boolean isEmpty() { 425 return super.isEmpty() && (system == null || system.isEmpty()) && (version == null || version.isEmpty()) 426 && (code == null || code.isEmpty()) && (display == null || display.isEmpty()) && (userSelected == null || userSelected.isEmpty()) 427 ; 428 } 429 430 431}