001package org.hl7.fhir.r4.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 6, 2018 17:51-0400 for FHIR v3.4.0 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; 044/** 045 * Chemical substances are a single substance type whose primary defining element is the molecular structure. Chemical substances shall be defined on the basis of their complete covalent molecular structure; the presence of a salt (counter-ion) and/or solvates (water, alcohols) is also captured. Purity, grade, physical form or particle size are not taken into account in the definition of a chemical substance or in the assignment of a Substance ID. 046 */ 047@DatatypeDef(name="SubstanceMoiety") 048public class SubstanceMoiety extends BackboneElement implements ICompositeType { 049 050 /** 051 * The role of the moiety should be specified if there is a specific role the moiety is playing. 052 */ 053 @Child(name = "role", type = {CodeableConcept.class}, order=0, min=0, max=1, modifier=false, summary=true) 054 @Description(shortDefinition="The role of the moiety should be specified if there is a specific role the moiety is playing", formalDefinition="The role of the moiety should be specified if there is a specific role the moiety is playing." ) 055 protected CodeableConcept role; 056 057 /** 058 * The unique identifier assigned to the substance representing the moiety based on the ISO 11238 substance controlled vocabulary. 059 */ 060 @Child(name = "identifier", type = {Identifier.class}, order=1, min=0, max=1, modifier=false, summary=true) 061 @Description(shortDefinition="The unique identifier assigned to the substance representing the moiety based on the ISO 11238 substance controlled vocabulary", formalDefinition="The unique identifier assigned to the substance representing the moiety based on the ISO 11238 substance controlled vocabulary." ) 062 protected Identifier identifier; 063 064 /** 065 * The name of the moiety shall be provided. 066 */ 067 @Child(name = "name", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=true) 068 @Description(shortDefinition="The name of the moiety shall be provided", formalDefinition="The name of the moiety shall be provided." ) 069 protected StringType name; 070 071 /** 072 * Stereochemistry shall be captured as described in 4.7.1. 073 */ 074 @Child(name = "stereochemistry", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true) 075 @Description(shortDefinition="Stereochemistry shall be captured as described in 4.7.1", formalDefinition="Stereochemistry shall be captured as described in 4.7.1." ) 076 protected CodeableConcept stereochemistry; 077 078 /** 079 * Optical activity shall be captured as described in 4.7.2. 080 */ 081 @Child(name = "opticalActivity", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=true) 082 @Description(shortDefinition="Optical activity shall be captured as described in 4.7.2", formalDefinition="Optical activity shall be captured as described in 4.7.2." ) 083 protected CodeableConcept opticalActivity; 084 085 /** 086 * Molecular formula shall be captured as described in 4.7.3. 087 */ 088 @Child(name = "molecularFormula", type = {StringType.class}, order=5, min=0, max=1, modifier=false, summary=true) 089 @Description(shortDefinition="Molecular formula shall be captured as described in 4.7.3", formalDefinition="Molecular formula shall be captured as described in 4.7.3." ) 090 protected StringType molecularFormula; 091 092 /** 093 * Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field. 094 */ 095 @Child(name = "amount", type = {SubstanceAmount.class}, order=6, min=0, max=1, modifier=false, summary=true) 096 @Description(shortDefinition="Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field", formalDefinition="Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field." ) 097 protected SubstanceAmount amount; 098 099 private static final long serialVersionUID = 204575891L; 100 101 /** 102 * Constructor 103 */ 104 public SubstanceMoiety() { 105 super(); 106 } 107 108 /** 109 * @return {@link #role} (The role of the moiety should be specified if there is a specific role the moiety is playing.) 110 */ 111 public CodeableConcept getRole() { 112 if (this.role == null) 113 if (Configuration.errorOnAutoCreate()) 114 throw new Error("Attempt to auto-create SubstanceMoiety.role"); 115 else if (Configuration.doAutoCreate()) 116 this.role = new CodeableConcept(); // cc 117 return this.role; 118 } 119 120 public boolean hasRole() { 121 return this.role != null && !this.role.isEmpty(); 122 } 123 124 /** 125 * @param value {@link #role} (The role of the moiety should be specified if there is a specific role the moiety is playing.) 126 */ 127 public SubstanceMoiety setRole(CodeableConcept value) { 128 this.role = value; 129 return this; 130 } 131 132 /** 133 * @return {@link #identifier} (The unique identifier assigned to the substance representing the moiety based on the ISO 11238 substance controlled vocabulary.) 134 */ 135 public Identifier getIdentifier() { 136 if (this.identifier == null) 137 if (Configuration.errorOnAutoCreate()) 138 throw new Error("Attempt to auto-create SubstanceMoiety.identifier"); 139 else if (Configuration.doAutoCreate()) 140 this.identifier = new Identifier(); // cc 141 return this.identifier; 142 } 143 144 public boolean hasIdentifier() { 145 return this.identifier != null && !this.identifier.isEmpty(); 146 } 147 148 /** 149 * @param value {@link #identifier} (The unique identifier assigned to the substance representing the moiety based on the ISO 11238 substance controlled vocabulary.) 150 */ 151 public SubstanceMoiety setIdentifier(Identifier value) { 152 this.identifier = value; 153 return this; 154 } 155 156 /** 157 * @return {@link #name} (The name of the moiety shall be provided.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value 158 */ 159 public StringType getNameElement() { 160 if (this.name == null) 161 if (Configuration.errorOnAutoCreate()) 162 throw new Error("Attempt to auto-create SubstanceMoiety.name"); 163 else if (Configuration.doAutoCreate()) 164 this.name = new StringType(); // bb 165 return this.name; 166 } 167 168 public boolean hasNameElement() { 169 return this.name != null && !this.name.isEmpty(); 170 } 171 172 public boolean hasName() { 173 return this.name != null && !this.name.isEmpty(); 174 } 175 176 /** 177 * @param value {@link #name} (The name of the moiety shall be provided.). This is the underlying object with id, value and extensions. The accessor "getName" gives direct access to the value 178 */ 179 public SubstanceMoiety setNameElement(StringType value) { 180 this.name = value; 181 return this; 182 } 183 184 /** 185 * @return The name of the moiety shall be provided. 186 */ 187 public String getName() { 188 return this.name == null ? null : this.name.getValue(); 189 } 190 191 /** 192 * @param value The name of the moiety shall be provided. 193 */ 194 public SubstanceMoiety setName(String value) { 195 if (Utilities.noString(value)) 196 this.name = null; 197 else { 198 if (this.name == null) 199 this.name = new StringType(); 200 this.name.setValue(value); 201 } 202 return this; 203 } 204 205 /** 206 * @return {@link #stereochemistry} (Stereochemistry shall be captured as described in 4.7.1.) 207 */ 208 public CodeableConcept getStereochemistry() { 209 if (this.stereochemistry == null) 210 if (Configuration.errorOnAutoCreate()) 211 throw new Error("Attempt to auto-create SubstanceMoiety.stereochemistry"); 212 else if (Configuration.doAutoCreate()) 213 this.stereochemistry = new CodeableConcept(); // cc 214 return this.stereochemistry; 215 } 216 217 public boolean hasStereochemistry() { 218 return this.stereochemistry != null && !this.stereochemistry.isEmpty(); 219 } 220 221 /** 222 * @param value {@link #stereochemistry} (Stereochemistry shall be captured as described in 4.7.1.) 223 */ 224 public SubstanceMoiety setStereochemistry(CodeableConcept value) { 225 this.stereochemistry = value; 226 return this; 227 } 228 229 /** 230 * @return {@link #opticalActivity} (Optical activity shall be captured as described in 4.7.2.) 231 */ 232 public CodeableConcept getOpticalActivity() { 233 if (this.opticalActivity == null) 234 if (Configuration.errorOnAutoCreate()) 235 throw new Error("Attempt to auto-create SubstanceMoiety.opticalActivity"); 236 else if (Configuration.doAutoCreate()) 237 this.opticalActivity = new CodeableConcept(); // cc 238 return this.opticalActivity; 239 } 240 241 public boolean hasOpticalActivity() { 242 return this.opticalActivity != null && !this.opticalActivity.isEmpty(); 243 } 244 245 /** 246 * @param value {@link #opticalActivity} (Optical activity shall be captured as described in 4.7.2.) 247 */ 248 public SubstanceMoiety setOpticalActivity(CodeableConcept value) { 249 this.opticalActivity = value; 250 return this; 251 } 252 253 /** 254 * @return {@link #molecularFormula} (Molecular formula shall be captured as described in 4.7.3.). This is the underlying object with id, value and extensions. The accessor "getMolecularFormula" gives direct access to the value 255 */ 256 public StringType getMolecularFormulaElement() { 257 if (this.molecularFormula == null) 258 if (Configuration.errorOnAutoCreate()) 259 throw new Error("Attempt to auto-create SubstanceMoiety.molecularFormula"); 260 else if (Configuration.doAutoCreate()) 261 this.molecularFormula = new StringType(); // bb 262 return this.molecularFormula; 263 } 264 265 public boolean hasMolecularFormulaElement() { 266 return this.molecularFormula != null && !this.molecularFormula.isEmpty(); 267 } 268 269 public boolean hasMolecularFormula() { 270 return this.molecularFormula != null && !this.molecularFormula.isEmpty(); 271 } 272 273 /** 274 * @param value {@link #molecularFormula} (Molecular formula shall be captured as described in 4.7.3.). This is the underlying object with id, value and extensions. The accessor "getMolecularFormula" gives direct access to the value 275 */ 276 public SubstanceMoiety setMolecularFormulaElement(StringType value) { 277 this.molecularFormula = value; 278 return this; 279 } 280 281 /** 282 * @return Molecular formula shall be captured as described in 4.7.3. 283 */ 284 public String getMolecularFormula() { 285 return this.molecularFormula == null ? null : this.molecularFormula.getValue(); 286 } 287 288 /** 289 * @param value Molecular formula shall be captured as described in 4.7.3. 290 */ 291 public SubstanceMoiety setMolecularFormula(String value) { 292 if (Utilities.noString(value)) 293 this.molecularFormula = null; 294 else { 295 if (this.molecularFormula == null) 296 this.molecularFormula = new StringType(); 297 this.molecularFormula.setValue(value); 298 } 299 return this; 300 } 301 302 /** 303 * @return {@link #amount} (Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.) 304 */ 305 public SubstanceAmount getAmount() { 306 if (this.amount == null) 307 if (Configuration.errorOnAutoCreate()) 308 throw new Error("Attempt to auto-create SubstanceMoiety.amount"); 309 else if (Configuration.doAutoCreate()) 310 this.amount = new SubstanceAmount(); // cc 311 return this.amount; 312 } 313 314 public boolean hasAmount() { 315 return this.amount != null && !this.amount.isEmpty(); 316 } 317 318 /** 319 * @param value {@link #amount} (Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.) 320 */ 321 public SubstanceMoiety setAmount(SubstanceAmount value) { 322 this.amount = value; 323 return this; 324 } 325 326 protected void listChildren(List<Property> children) { 327 super.listChildren(children); 328 children.add(new Property("role", "CodeableConcept", "The role of the moiety should be specified if there is a specific role the moiety is playing.", 0, 1, role)); 329 children.add(new Property("identifier", "Identifier", "The unique identifier assigned to the substance representing the moiety based on the ISO 11238 substance controlled vocabulary.", 0, 1, identifier)); 330 children.add(new Property("name", "string", "The name of the moiety shall be provided.", 0, 1, name)); 331 children.add(new Property("stereochemistry", "CodeableConcept", "Stereochemistry shall be captured as described in 4.7.1.", 0, 1, stereochemistry)); 332 children.add(new Property("opticalActivity", "CodeableConcept", "Optical activity shall be captured as described in 4.7.2.", 0, 1, opticalActivity)); 333 children.add(new Property("molecularFormula", "string", "Molecular formula shall be captured as described in 4.7.3.", 0, 1, molecularFormula)); 334 children.add(new Property("amount", "SubstanceAmount", "Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.", 0, 1, amount)); 335 } 336 337 @Override 338 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 339 switch (_hash) { 340 case 3506294: /*role*/ return new Property("role", "CodeableConcept", "The role of the moiety should be specified if there is a specific role the moiety is playing.", 0, 1, role); 341 case -1618432855: /*identifier*/ return new Property("identifier", "Identifier", "The unique identifier assigned to the substance representing the moiety based on the ISO 11238 substance controlled vocabulary.", 0, 1, identifier); 342 case 3373707: /*name*/ return new Property("name", "string", "The name of the moiety shall be provided.", 0, 1, name); 343 case 263475116: /*stereochemistry*/ return new Property("stereochemistry", "CodeableConcept", "Stereochemistry shall be captured as described in 4.7.1.", 0, 1, stereochemistry); 344 case 1420900135: /*opticalActivity*/ return new Property("opticalActivity", "CodeableConcept", "Optical activity shall be captured as described in 4.7.2.", 0, 1, opticalActivity); 345 case 616660246: /*molecularFormula*/ return new Property("molecularFormula", "string", "Molecular formula shall be captured as described in 4.7.3.", 0, 1, molecularFormula); 346 case -1413853096: /*amount*/ return new Property("amount", "SubstanceAmount", "Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.", 0, 1, amount); 347 default: return super.getNamedProperty(_hash, _name, _checkValid); 348 } 349 350 } 351 352 @Override 353 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 354 switch (hash) { 355 case 3506294: /*role*/ return this.role == null ? new Base[0] : new Base[] {this.role}; // CodeableConcept 356 case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : new Base[] {this.identifier}; // Identifier 357 case 3373707: /*name*/ return this.name == null ? new Base[0] : new Base[] {this.name}; // StringType 358 case 263475116: /*stereochemistry*/ return this.stereochemistry == null ? new Base[0] : new Base[] {this.stereochemistry}; // CodeableConcept 359 case 1420900135: /*opticalActivity*/ return this.opticalActivity == null ? new Base[0] : new Base[] {this.opticalActivity}; // CodeableConcept 360 case 616660246: /*molecularFormula*/ return this.molecularFormula == null ? new Base[0] : new Base[] {this.molecularFormula}; // StringType 361 case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : new Base[] {this.amount}; // SubstanceAmount 362 default: return super.getProperty(hash, name, checkValid); 363 } 364 365 } 366 367 @Override 368 public Base setProperty(int hash, String name, Base value) throws FHIRException { 369 switch (hash) { 370 case 3506294: // role 371 this.role = castToCodeableConcept(value); // CodeableConcept 372 return value; 373 case -1618432855: // identifier 374 this.identifier = castToIdentifier(value); // Identifier 375 return value; 376 case 3373707: // name 377 this.name = castToString(value); // StringType 378 return value; 379 case 263475116: // stereochemistry 380 this.stereochemistry = castToCodeableConcept(value); // CodeableConcept 381 return value; 382 case 1420900135: // opticalActivity 383 this.opticalActivity = castToCodeableConcept(value); // CodeableConcept 384 return value; 385 case 616660246: // molecularFormula 386 this.molecularFormula = castToString(value); // StringType 387 return value; 388 case -1413853096: // amount 389 this.amount = castToSubstanceAmount(value); // SubstanceAmount 390 return value; 391 default: return super.setProperty(hash, name, value); 392 } 393 394 } 395 396 @Override 397 public Base setProperty(String name, Base value) throws FHIRException { 398 if (name.equals("role")) { 399 this.role = castToCodeableConcept(value); // CodeableConcept 400 } else if (name.equals("identifier")) { 401 this.identifier = castToIdentifier(value); // Identifier 402 } else if (name.equals("name")) { 403 this.name = castToString(value); // StringType 404 } else if (name.equals("stereochemistry")) { 405 this.stereochemistry = castToCodeableConcept(value); // CodeableConcept 406 } else if (name.equals("opticalActivity")) { 407 this.opticalActivity = castToCodeableConcept(value); // CodeableConcept 408 } else if (name.equals("molecularFormula")) { 409 this.molecularFormula = castToString(value); // StringType 410 } else if (name.equals("amount")) { 411 this.amount = castToSubstanceAmount(value); // SubstanceAmount 412 } else 413 return super.setProperty(name, value); 414 return value; 415 } 416 417 @Override 418 public Base makeProperty(int hash, String name) throws FHIRException { 419 switch (hash) { 420 case 3506294: return getRole(); 421 case -1618432855: return getIdentifier(); 422 case 3373707: return getNameElement(); 423 case 263475116: return getStereochemistry(); 424 case 1420900135: return getOpticalActivity(); 425 case 616660246: return getMolecularFormulaElement(); 426 case -1413853096: return getAmount(); 427 default: return super.makeProperty(hash, name); 428 } 429 430 } 431 432 @Override 433 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 434 switch (hash) { 435 case 3506294: /*role*/ return new String[] {"CodeableConcept"}; 436 case -1618432855: /*identifier*/ return new String[] {"Identifier"}; 437 case 3373707: /*name*/ return new String[] {"string"}; 438 case 263475116: /*stereochemistry*/ return new String[] {"CodeableConcept"}; 439 case 1420900135: /*opticalActivity*/ return new String[] {"CodeableConcept"}; 440 case 616660246: /*molecularFormula*/ return new String[] {"string"}; 441 case -1413853096: /*amount*/ return new String[] {"SubstanceAmount"}; 442 default: return super.getTypesForProperty(hash, name); 443 } 444 445 } 446 447 @Override 448 public Base addChild(String name) throws FHIRException { 449 if (name.equals("role")) { 450 this.role = new CodeableConcept(); 451 return this.role; 452 } 453 else if (name.equals("identifier")) { 454 this.identifier = new Identifier(); 455 return this.identifier; 456 } 457 else if (name.equals("name")) { 458 throw new FHIRException("Cannot call addChild on a primitive type SubstanceMoiety.name"); 459 } 460 else if (name.equals("stereochemistry")) { 461 this.stereochemistry = new CodeableConcept(); 462 return this.stereochemistry; 463 } 464 else if (name.equals("opticalActivity")) { 465 this.opticalActivity = new CodeableConcept(); 466 return this.opticalActivity; 467 } 468 else if (name.equals("molecularFormula")) { 469 throw new FHIRException("Cannot call addChild on a primitive type SubstanceMoiety.molecularFormula"); 470 } 471 else if (name.equals("amount")) { 472 this.amount = new SubstanceAmount(); 473 return this.amount; 474 } 475 else 476 return super.addChild(name); 477 } 478 479 public String fhirType() { 480 return "SubstanceMoiety"; 481 482 } 483 484 public SubstanceMoiety copy() { 485 SubstanceMoiety dst = new SubstanceMoiety(); 486 copyValues(dst); 487 dst.role = role == null ? null : role.copy(); 488 dst.identifier = identifier == null ? null : identifier.copy(); 489 dst.name = name == null ? null : name.copy(); 490 dst.stereochemistry = stereochemistry == null ? null : stereochemistry.copy(); 491 dst.opticalActivity = opticalActivity == null ? null : opticalActivity.copy(); 492 dst.molecularFormula = molecularFormula == null ? null : molecularFormula.copy(); 493 dst.amount = amount == null ? null : amount.copy(); 494 return dst; 495 } 496 497 protected SubstanceMoiety typedCopy() { 498 return copy(); 499 } 500 501 @Override 502 public boolean equalsDeep(Base other_) { 503 if (!super.equalsDeep(other_)) 504 return false; 505 if (!(other_ instanceof SubstanceMoiety)) 506 return false; 507 SubstanceMoiety o = (SubstanceMoiety) other_; 508 return compareDeep(role, o.role, true) && compareDeep(identifier, o.identifier, true) && compareDeep(name, o.name, true) 509 && compareDeep(stereochemistry, o.stereochemistry, true) && compareDeep(opticalActivity, o.opticalActivity, true) 510 && compareDeep(molecularFormula, o.molecularFormula, true) && compareDeep(amount, o.amount, true) 511 ; 512 } 513 514 @Override 515 public boolean equalsShallow(Base other_) { 516 if (!super.equalsShallow(other_)) 517 return false; 518 if (!(other_ instanceof SubstanceMoiety)) 519 return false; 520 SubstanceMoiety o = (SubstanceMoiety) other_; 521 return compareValues(name, o.name, true) && compareValues(molecularFormula, o.molecularFormula, true) 522 ; 523 } 524 525 public boolean isEmpty() { 526 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(role, identifier, name, stereochemistry 527 , opticalActivity, molecularFormula, amount); 528 } 529 530 531} 532