001package org.hl7.fhir.r5.model; 002 003 004/* 005 * #%L 006 * org.hl7.fhir.r5 007 * %% 008 * Copyright (C) 2014 - 2019 Health Level 7 009 * %% 010 * Licensed under the Apache License, Version 2.0 (the \"License\"); 011 * you may not use this file except in compliance with the License. 012 * You may obtain a copy of the License at 013 * 014 * http://www.apache.org/licenses/LICENSE-2.0 015 * 016 * Unless required by applicable law or agreed to in writing, software 017 * distributed under the License is distributed on an \"AS IS\" BASIS, 018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 019 * See the License for the specific language governing permissions and 020 * limitations under the License. 021 * #L% 022 */ 023 024/* 025 Copyright (c) 2011+, HL7, Inc. 026 All rights reserved. 027 028 Redistribution and use in source and binary forms, with or without modification, \ 029 are permitted provided that the following conditions are met: 030 031 * Redistributions of source code must retain the above copyright notice, this \ 032 list of conditions and the following disclaimer. 033 * Redistributions in binary form must reproduce the above copyright notice, \ 034 this list of conditions and the following disclaimer in the documentation \ 035 and/or other materials provided with the distribution. 036 * Neither the name of HL7 nor the names of its contributors may be used to 037 endorse or promote products derived from this software without specific 038 prior written permission. 039 040 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \ 041 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \ 042 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \ 043 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \ 044 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \ 045 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \ 046 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \ 047 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \ 048 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \ 049 POSSIBILITY OF SUCH DAMAGE. 050 */ 051 052// Generated on Tue, Dec 31, 2019 12:12+1100 for FHIR vcurrent 053 054import java.util.ArrayList; 055import java.util.Date; 056import java.util.List; 057import org.hl7.fhir.utilities.Utilities; 058import org.hl7.fhir.r5.model.Enumerations.*; 059import org.hl7.fhir.instance.model.api.IBaseDatatypeElement; 060import org.hl7.fhir.exceptions.FHIRException; 061import org.hl7.fhir.instance.model.api.ICompositeType; 062import ca.uhn.fhir.model.api.annotation.Child; 063import ca.uhn.fhir.model.api.annotation.ChildOrder; 064import ca.uhn.fhir.model.api.annotation.DatatypeDef; 065import ca.uhn.fhir.model.api.annotation.Description; 066import ca.uhn.fhir.model.api.annotation.Block; 067 068/** 069 * Base StructureDefinition for Expression Type: A expression that is evaluated in a specified context and returns a value. The context of use of the expression must specify the context in which the expression is evaluated, and how the result of the expression is used. 070 */ 071@DatatypeDef(name="Expression") 072public class Expression extends DataType implements ICompositeType { 073 074 /** 075 * A brief, natural language description of the condition that effectively communicates the intended semantics. 076 */ 077 @Child(name = "description", type = {StringType.class}, order=0, min=0, max=1, modifier=false, summary=true) 078 @Description(shortDefinition="Natural language description of the condition", formalDefinition="A brief, natural language description of the condition that effectively communicates the intended semantics." ) 079 protected StringType description; 080 081 /** 082 * A short name assigned to the expression to allow for multiple reuse of the expression in the context where it is defined. 083 */ 084 @Child(name = "name", type = {IdType.class}, order=1, min=0, max=1, modifier=false, summary=true) 085 @Description(shortDefinition="Short name assigned to expression for reuse", formalDefinition="A short name assigned to the expression to allow for multiple reuse of the expression in the context where it is defined." ) 086 protected IdType name; 087 088 /** 089 * The media type of the language for the expression. 090 */ 091 @Child(name = "language", type = {CodeType.class}, order=2, min=1, max=1, modifier=false, summary=true) 092 @Description(shortDefinition="text/cql | text/fhirpath | application/x-fhir-query | etc.", formalDefinition="The media type of the language for the expression." ) 093 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/expression-language") 094 protected CodeType language; 095 096 /** 097 * An expression in the specified language that returns a value. 098 */ 099 @Child(name = "expression", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true) 100 @Description(shortDefinition="Expression in specified language", formalDefinition="An expression in the specified language that returns a value." ) 101 protected StringType expression; 102 103 /** 104 * A URI that defines where the expression is found. 105 */ 106 @Child(name = "reference", type = {UriType.class}, order=4, min=0, max=1, modifier=false, summary=true) 107 @Description(shortDefinition="Where the expression is found", formalDefinition="A URI that defines where the expression is found." ) 108 protected UriType reference; 109 110 private static final long serialVersionUID = -465056222L; 111 112 /** 113 * Constructor 114 */ 115 public Expression() { 116 super(); 117 } 118 119 /** 120 * Constructor 121 */ 122 public Expression(String language) { 123 super(); 124 this.setLanguage(language); 125 } 126 127 /** 128 * @return {@link #description} (A brief, natural language description of the condition that effectively communicates the intended semantics.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value 129 */ 130 public StringType getDescriptionElement() { 131 if (this.description == null) 132 if (Configuration.errorOnAutoCreate()) 133 throw new Error("Attempt to auto-create Expression.description"); 134 else if (Configuration.doAutoCreate()) 135 this.description = new StringType(); // bb 136 return this.description; 137 } 138 139 public boolean hasDescriptionElement() { 140 return this.description != null && !this.description.isEmpty(); 141 } 142 143 public boolean hasDescription() { 144 return this.description != null && !this.description.isEmpty(); 145 } 146 147 /** 148 * @param value {@link #description} (A brief, natural language description of the condition that effectively communicates the intended semantics.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value 149 */ 150 public Expression setDescriptionElement(StringType value) { 151 this.description = value; 152 return this; 153 } 154 155 /** 156 * @return A brief, natural language description of the condition that effectively communicates the intended semantics. 157 */ 158 public String getDescription() { 159 return this.description == null ? null : this.description.getValue(); 160 } 161 162 /** 163 * @param value A brief, natural language description of the condition that effectively communicates the intended semantics. 164 */ 165 public Expression setDescription(String value) { 166 if (Utilities.noString(value)) 167 this.description = null; 168 else { 169 if (this.description == null) 170 this.description = new StringType(); 171 this.description.setValue(value); 172 } 173 return this; 174 } 175 176 /** 177 * @return {@link #name} (A short name assigned to the expression to allow for multiple reuse of the expression in the context where it is defined.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value 178 */ 179 public IdType getNameElement() { 180 if (this.name == null) 181 if (Configuration.errorOnAutoCreate()) 182 throw new Error("Attempt to auto-create Expression.name"); 183 else if (Configuration.doAutoCreate()) 184 this.name = new IdType(); // bb 185 return this.name; 186 } 187 188 public boolean hasNameElement() { 189 return this.name != null && !this.name.isEmpty(); 190 } 191 192 public boolean hasName() { 193 return this.name != null && !this.name.isEmpty(); 194 } 195 196 /** 197 * @param value {@link #name} (A short name assigned to the expression to allow for multiple reuse of the expression in the context where it is defined.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value 198 */ 199 public Expression setNameElement(IdType value) { 200 this.name = value; 201 return this; 202 } 203 204 /** 205 * @return A short name assigned to the expression to allow for multiple reuse of the expression in the context where it is defined. 206 */ 207 public String getName() { 208 return this.name == null ? null : this.name.getValue(); 209 } 210 211 /** 212 * @param value A short name assigned to the expression to allow for multiple reuse of the expression in the context where it is defined. 213 */ 214 public Expression setName(String value) { 215 if (Utilities.noString(value)) 216 this.name = null; 217 else { 218 if (this.name == null) 219 this.name = new IdType(); 220 this.name.setValue(value); 221 } 222 return this; 223 } 224 225 /** 226 * @return {@link #language} (The media type of the language for the expression.). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value 227 */ 228 public CodeType getLanguageElement() { 229 if (this.language == null) 230 if (Configuration.errorOnAutoCreate()) 231 throw new Error("Attempt to auto-create Expression.language"); 232 else if (Configuration.doAutoCreate()) 233 this.language = new CodeType(); // bb 234 return this.language; 235 } 236 237 public boolean hasLanguageElement() { 238 return this.language != null && !this.language.isEmpty(); 239 } 240 241 public boolean hasLanguage() { 242 return this.language != null && !this.language.isEmpty(); 243 } 244 245 /** 246 * @param value {@link #language} (The media type of the language for the expression.). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value 247 */ 248 public Expression setLanguageElement(CodeType value) { 249 this.language = value; 250 return this; 251 } 252 253 /** 254 * @return The media type of the language for the expression. 255 */ 256 public String getLanguage() { 257 return this.language == null ? null : this.language.getValue(); 258 } 259 260 /** 261 * @param value The media type of the language for the expression. 262 */ 263 public Expression setLanguage(String value) { 264 if (this.language == null) 265 this.language = new CodeType(); 266 this.language.setValue(value); 267 return this; 268 } 269 270 /** 271 * @return {@link #expression} (An expression in the specified language that returns a value.). This is the underlying object with id, value and extensions. The accessor "getExpression" gives direct access to the value 272 */ 273 public StringType getExpressionElement() { 274 if (this.expression == null) 275 if (Configuration.errorOnAutoCreate()) 276 throw new Error("Attempt to auto-create Expression.expression"); 277 else if (Configuration.doAutoCreate()) 278 this.expression = new StringType(); // bb 279 return this.expression; 280 } 281 282 public boolean hasExpressionElement() { 283 return this.expression != null && !this.expression.isEmpty(); 284 } 285 286 public boolean hasExpression() { 287 return this.expression != null && !this.expression.isEmpty(); 288 } 289 290 /** 291 * @param value {@link #expression} (An expression in the specified language that returns a value.). This is the underlying object with id, value and extensions. The accessor "getExpression" gives direct access to the value 292 */ 293 public Expression setExpressionElement(StringType value) { 294 this.expression = value; 295 return this; 296 } 297 298 /** 299 * @return An expression in the specified language that returns a value. 300 */ 301 public String getExpression() { 302 return this.expression == null ? null : this.expression.getValue(); 303 } 304 305 /** 306 * @param value An expression in the specified language that returns a value. 307 */ 308 public Expression setExpression(String value) { 309 if (Utilities.noString(value)) 310 this.expression = null; 311 else { 312 if (this.expression == null) 313 this.expression = new StringType(); 314 this.expression.setValue(value); 315 } 316 return this; 317 } 318 319 /** 320 * @return {@link #reference} (A URI that defines where the expression is found.). This is the underlying object with id, value and extensions. The accessor "getReference" gives direct access to the value 321 */ 322 public UriType getReferenceElement() { 323 if (this.reference == null) 324 if (Configuration.errorOnAutoCreate()) 325 throw new Error("Attempt to auto-create Expression.reference"); 326 else if (Configuration.doAutoCreate()) 327 this.reference = new UriType(); // bb 328 return this.reference; 329 } 330 331 public boolean hasReferenceElement() { 332 return this.reference != null && !this.reference.isEmpty(); 333 } 334 335 public boolean hasReference() { 336 return this.reference != null && !this.reference.isEmpty(); 337 } 338 339 /** 340 * @param value {@link #reference} (A URI that defines where the expression is found.). This is the underlying object with id, value and extensions. The accessor "getReference" gives direct access to the value 341 */ 342 public Expression setReferenceElement(UriType value) { 343 this.reference = value; 344 return this; 345 } 346 347 /** 348 * @return A URI that defines where the expression is found. 349 */ 350 public String getReference() { 351 return this.reference == null ? null : this.reference.getValue(); 352 } 353 354 /** 355 * @param value A URI that defines where the expression is found. 356 */ 357 public Expression setReference(String value) { 358 if (Utilities.noString(value)) 359 this.reference = null; 360 else { 361 if (this.reference == null) 362 this.reference = new UriType(); 363 this.reference.setValue(value); 364 } 365 return this; 366 } 367 368 protected void listChildren(List<Property> children) { 369 super.listChildren(children); 370 children.add(new Property("description", "string", "A brief, natural language description of the condition that effectively communicates the intended semantics.", 0, 1, description)); 371 children.add(new Property("name", "id", "A short name assigned to the expression to allow for multiple reuse of the expression in the context where it is defined.", 0, 1, name)); 372 children.add(new Property("language", "code", "The media type of the language for the expression.", 0, 1, language)); 373 children.add(new Property("expression", "string", "An expression in the specified language that returns a value.", 0, 1, expression)); 374 children.add(new Property("reference", "uri", "A URI that defines where the expression is found.", 0, 1, reference)); 375 } 376 377 @Override 378 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 379 switch (_hash) { 380 case -1724546052: /*description*/ return new Property("description", "string", "A brief, natural language description of the condition that effectively communicates the intended semantics.", 0, 1, description); 381 case 3373707: /*name*/ return new Property("name", "id", "A short name assigned to the expression to allow for multiple reuse of the expression in the context where it is defined.", 0, 1, name); 382 case -1613589672: /*language*/ return new Property("language", "code", "The media type of the language for the expression.", 0, 1, language); 383 case -1795452264: /*expression*/ return new Property("expression", "string", "An expression in the specified language that returns a value.", 0, 1, expression); 384 case -925155509: /*reference*/ return new Property("reference", "uri", "A URI that defines where the expression is found.", 0, 1, reference); 385 default: return super.getNamedProperty(_hash, _name, _checkValid); 386 } 387 388 } 389 390 @Override 391 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 392 switch (hash) { 393 case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // StringType 394 case 3373707: /*name*/ return this.name == null ? new Base[0] : new Base[] {this.name}; // IdType 395 case -1613589672: /*language*/ return this.language == null ? new Base[0] : new Base[] {this.language}; // CodeType 396 case -1795452264: /*expression*/ return this.expression == null ? new Base[0] : new Base[] {this.expression}; // StringType 397 case -925155509: /*reference*/ return this.reference == null ? new Base[0] : new Base[] {this.reference}; // UriType 398 default: return super.getProperty(hash, name, checkValid); 399 } 400 401 } 402 403 @Override 404 public Base setProperty(int hash, String name, Base value) throws FHIRException { 405 switch (hash) { 406 case -1724546052: // description 407 this.description = TypeConvertor.castToString(value); // StringType 408 return value; 409 case 3373707: // name 410 this.name = TypeConvertor.castToId(value); // IdType 411 return value; 412 case -1613589672: // language 413 this.language = TypeConvertor.castToCode(value); // CodeType 414 return value; 415 case -1795452264: // expression 416 this.expression = TypeConvertor.castToString(value); // StringType 417 return value; 418 case -925155509: // reference 419 this.reference = TypeConvertor.castToUri(value); // UriType 420 return value; 421 default: return super.setProperty(hash, name, value); 422 } 423 424 } 425 426 @Override 427 public Base setProperty(String name, Base value) throws FHIRException { 428 if (name.equals("description")) { 429 this.description = TypeConvertor.castToString(value); // StringType 430 } else if (name.equals("name")) { 431 this.name = TypeConvertor.castToId(value); // IdType 432 } else if (name.equals("language")) { 433 this.language = TypeConvertor.castToCode(value); // CodeType 434 } else if (name.equals("expression")) { 435 this.expression = TypeConvertor.castToString(value); // StringType 436 } else if (name.equals("reference")) { 437 this.reference = TypeConvertor.castToUri(value); // UriType 438 } else 439 return super.setProperty(name, value); 440 return value; 441 } 442 443 @Override 444 public Base makeProperty(int hash, String name) throws FHIRException { 445 switch (hash) { 446 case -1724546052: return getDescriptionElement(); 447 case 3373707: return getNameElement(); 448 case -1613589672: return getLanguageElement(); 449 case -1795452264: return getExpressionElement(); 450 case -925155509: return getReferenceElement(); 451 default: return super.makeProperty(hash, name); 452 } 453 454 } 455 456 @Override 457 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 458 switch (hash) { 459 case -1724546052: /*description*/ return new String[] {"string"}; 460 case 3373707: /*name*/ return new String[] {"id"}; 461 case -1613589672: /*language*/ return new String[] {"code"}; 462 case -1795452264: /*expression*/ return new String[] {"string"}; 463 case -925155509: /*reference*/ return new String[] {"uri"}; 464 default: return super.getTypesForProperty(hash, name); 465 } 466 467 } 468 469 @Override 470 public Base addChild(String name) throws FHIRException { 471 if (name.equals("description")) { 472 throw new FHIRException("Cannot call addChild on a primitive type Expression.description"); 473 } 474 else if (name.equals("name")) { 475 throw new FHIRException("Cannot call addChild on a primitive type Expression.name"); 476 } 477 else if (name.equals("language")) { 478 throw new FHIRException("Cannot call addChild on a primitive type Expression.language"); 479 } 480 else if (name.equals("expression")) { 481 throw new FHIRException("Cannot call addChild on a primitive type Expression.expression"); 482 } 483 else if (name.equals("reference")) { 484 throw new FHIRException("Cannot call addChild on a primitive type Expression.reference"); 485 } 486 else 487 return super.addChild(name); 488 } 489 490 public String fhirType() { 491 return "Expression"; 492 493 } 494 495 public Expression copy() { 496 Expression dst = new Expression(); 497 copyValues(dst); 498 return dst; 499 } 500 501 public void copyValues(Expression dst) { 502 super.copyValues(dst); 503 dst.description = description == null ? null : description.copy(); 504 dst.name = name == null ? null : name.copy(); 505 dst.language = language == null ? null : language.copy(); 506 dst.expression = expression == null ? null : expression.copy(); 507 dst.reference = reference == null ? null : reference.copy(); 508 } 509 510 protected Expression typedCopy() { 511 return copy(); 512 } 513 514 @Override 515 public boolean equalsDeep(Base other_) { 516 if (!super.equalsDeep(other_)) 517 return false; 518 if (!(other_ instanceof Expression)) 519 return false; 520 Expression o = (Expression) other_; 521 return compareDeep(description, o.description, true) && compareDeep(name, o.name, true) && compareDeep(language, o.language, true) 522 && compareDeep(expression, o.expression, true) && compareDeep(reference, o.reference, true); 523 } 524 525 @Override 526 public boolean equalsShallow(Base other_) { 527 if (!super.equalsShallow(other_)) 528 return false; 529 if (!(other_ instanceof Expression)) 530 return false; 531 Expression o = (Expression) other_; 532 return compareValues(description, o.description, true) && compareValues(name, o.name, true) && compareValues(language, o.language, true) 533 && compareValues(expression, o.expression, true) && compareValues(reference, o.reference, true); 534 } 535 536 public boolean isEmpty() { 537 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(description, name, language 538 , expression, reference); 539 } 540 541 542} 543