001package org.hl7.fhir.dstu2.model; 002 003/*- 004 * #%L 005 * org.hl7.fhir.dstu2 006 * %% 007 * Copyright (C) 2014 - 2019 Health Level 7 008 * %% 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 * #L% 021 */ 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 053// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2 054import java.util.ArrayList; 055import java.util.List; 056 057import ca.uhn.fhir.model.api.annotation.Child; 058import ca.uhn.fhir.model.api.annotation.Description; 059import ca.uhn.fhir.model.api.annotation.ResourceDef; 060import ca.uhn.fhir.model.api.annotation.SearchParamDefinition; 061import org.hl7.fhir.exceptions.FHIRException; 062import org.hl7.fhir.utilities.Utilities; 063/** 064 * Record details about the anatomical location of a specimen or body part. This resource may be used when a coded concept does not provide the necessary detail needed for the use case. 065 */ 066@ResourceDef(name="BodySite", profile="http://hl7.org/fhir/Profile/BodySite") 067public class BodySite extends DomainResource { 068 069 /** 070 * The person to which the body site belongs. 071 */ 072 @Child(name = "patient", type = {Patient.class}, order=0, min=1, max=1, modifier=false, summary=true) 073 @Description(shortDefinition="Patient", formalDefinition="The person to which the body site belongs." ) 074 protected Reference patient; 075 076 /** 077 * The actual object that is the target of the reference (The person to which the body site belongs.) 078 */ 079 protected Patient patientTarget; 080 081 /** 082 * Identifier for this instance of the anatomical location. 083 */ 084 @Child(name = "identifier", type = {Identifier.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 085 @Description(shortDefinition="Bodysite identifier", formalDefinition="Identifier for this instance of the anatomical location." ) 086 protected List<Identifier> identifier; 087 088 /** 089 * Named anatomical location - ideally coded where possible. 090 */ 091 @Child(name = "code", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true) 092 @Description(shortDefinition="Named anatomical location", formalDefinition="Named anatomical location - ideally coded where possible." ) 093 protected CodeableConcept code; 094 095 /** 096 * Modifier to refine the anatomical location. These include modifiers for laterality, relative location, directionality, number, and plane. 097 */ 098 @Child(name = "modifier", type = {CodeableConcept.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 099 @Description(shortDefinition="Modification to location code", formalDefinition="Modifier to refine the anatomical location. These include modifiers for laterality, relative location, directionality, number, and plane." ) 100 protected List<CodeableConcept> modifier; 101 102 /** 103 * Description of anatomical location. 104 */ 105 @Child(name = "description", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=true) 106 @Description(shortDefinition="The Description of anatomical location", formalDefinition="Description of anatomical location." ) 107 protected StringType description; 108 109 /** 110 * Image or images used to identify a location. 111 */ 112 @Child(name = "image", type = {Attachment.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 113 @Description(shortDefinition="Attached images", formalDefinition="Image or images used to identify a location." ) 114 protected List<Attachment> image; 115 116 private static final long serialVersionUID = 1568109920L; 117 118 /* 119 * Constructor 120 */ 121 public BodySite() { 122 super(); 123 } 124 125 /* 126 * Constructor 127 */ 128 public BodySite(Reference patient) { 129 super(); 130 this.patient = patient; 131 } 132 133 /** 134 * @return {@link #patient} (The person to which the body site belongs.) 135 */ 136 public Reference getPatient() { 137 if (this.patient == null) 138 if (Configuration.errorOnAutoCreate()) 139 throw new Error("Attempt to auto-create BodySite.patient"); 140 else if (Configuration.doAutoCreate()) 141 this.patient = new Reference(); // cc 142 return this.patient; 143 } 144 145 public boolean hasPatient() { 146 return this.patient != null && !this.patient.isEmpty(); 147 } 148 149 /** 150 * @param value {@link #patient} (The person to which the body site belongs.) 151 */ 152 public BodySite setPatient(Reference value) { 153 this.patient = value; 154 return this; 155 } 156 157 /** 158 * @return {@link #patient} 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. (The person to which the body site belongs.) 159 */ 160 public Patient getPatientTarget() { 161 if (this.patientTarget == null) 162 if (Configuration.errorOnAutoCreate()) 163 throw new Error("Attempt to auto-create BodySite.patient"); 164 else if (Configuration.doAutoCreate()) 165 this.patientTarget = new Patient(); // aa 166 return this.patientTarget; 167 } 168 169 /** 170 * @param value {@link #patient} 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. (The person to which the body site belongs.) 171 */ 172 public BodySite setPatientTarget(Patient value) { 173 this.patientTarget = value; 174 return this; 175 } 176 177 /** 178 * @return {@link #identifier} (Identifier for this instance of the anatomical location.) 179 */ 180 public List<Identifier> getIdentifier() { 181 if (this.identifier == null) 182 this.identifier = new ArrayList<Identifier>(); 183 return this.identifier; 184 } 185 186 public boolean hasIdentifier() { 187 if (this.identifier == null) 188 return false; 189 for (Identifier item : this.identifier) 190 if (!item.isEmpty()) 191 return true; 192 return false; 193 } 194 195 /** 196 * @return {@link #identifier} (Identifier for this instance of the anatomical location.) 197 */ 198 // syntactic sugar 199 public Identifier addIdentifier() { //3 200 Identifier t = new Identifier(); 201 if (this.identifier == null) 202 this.identifier = new ArrayList<Identifier>(); 203 this.identifier.add(t); 204 return t; 205 } 206 207 // syntactic sugar 208 public BodySite addIdentifier(Identifier t) { //3 209 if (t == null) 210 return this; 211 if (this.identifier == null) 212 this.identifier = new ArrayList<Identifier>(); 213 this.identifier.add(t); 214 return this; 215 } 216 217 /** 218 * @return {@link #code} (Named anatomical location - ideally coded where possible.) 219 */ 220 public CodeableConcept getCode() { 221 if (this.code == null) 222 if (Configuration.errorOnAutoCreate()) 223 throw new Error("Attempt to auto-create BodySite.code"); 224 else if (Configuration.doAutoCreate()) 225 this.code = new CodeableConcept(); // cc 226 return this.code; 227 } 228 229 public boolean hasCode() { 230 return this.code != null && !this.code.isEmpty(); 231 } 232 233 /** 234 * @param value {@link #code} (Named anatomical location - ideally coded where possible.) 235 */ 236 public BodySite setCode(CodeableConcept value) { 237 this.code = value; 238 return this; 239 } 240 241 /** 242 * @return {@link #modifier} (Modifier to refine the anatomical location. These include modifiers for laterality, relative location, directionality, number, and plane.) 243 */ 244 public List<CodeableConcept> getModifier() { 245 if (this.modifier == null) 246 this.modifier = new ArrayList<CodeableConcept>(); 247 return this.modifier; 248 } 249 250 public boolean hasModifier() { 251 if (this.modifier == null) 252 return false; 253 for (CodeableConcept item : this.modifier) 254 if (!item.isEmpty()) 255 return true; 256 return false; 257 } 258 259 /** 260 * @return {@link #modifier} (Modifier to refine the anatomical location. These include modifiers for laterality, relative location, directionality, number, and plane.) 261 */ 262 // syntactic sugar 263 public CodeableConcept addModifier() { //3 264 CodeableConcept t = new CodeableConcept(); 265 if (this.modifier == null) 266 this.modifier = new ArrayList<CodeableConcept>(); 267 this.modifier.add(t); 268 return t; 269 } 270 271 // syntactic sugar 272 public BodySite addModifier(CodeableConcept t) { //3 273 if (t == null) 274 return this; 275 if (this.modifier == null) 276 this.modifier = new ArrayList<CodeableConcept>(); 277 this.modifier.add(t); 278 return this; 279 } 280 281 /** 282 * @return {@link #description} (Description of anatomical location.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value 283 */ 284 public StringType getDescriptionElement() { 285 if (this.description == null) 286 if (Configuration.errorOnAutoCreate()) 287 throw new Error("Attempt to auto-create BodySite.description"); 288 else if (Configuration.doAutoCreate()) 289 this.description = new StringType(); // bb 290 return this.description; 291 } 292 293 public boolean hasDescriptionElement() { 294 return this.description != null && !this.description.isEmpty(); 295 } 296 297 public boolean hasDescription() { 298 return this.description != null && !this.description.isEmpty(); 299 } 300 301 /** 302 * @param value {@link #description} (Description of anatomical location.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value 303 */ 304 public BodySite setDescriptionElement(StringType value) { 305 this.description = value; 306 return this; 307 } 308 309 /** 310 * @return Description of anatomical location. 311 */ 312 public String getDescription() { 313 return this.description == null ? null : this.description.getValue(); 314 } 315 316 /** 317 * @param value Description of anatomical location. 318 */ 319 public BodySite setDescription(String value) { 320 if (Utilities.noString(value)) 321 this.description = null; 322 else { 323 if (this.description == null) 324 this.description = new StringType(); 325 this.description.setValue(value); 326 } 327 return this; 328 } 329 330 /** 331 * @return {@link #image} (Image or images used to identify a location.) 332 */ 333 public List<Attachment> getImage() { 334 if (this.image == null) 335 this.image = new ArrayList<Attachment>(); 336 return this.image; 337 } 338 339 public boolean hasImage() { 340 if (this.image == null) 341 return false; 342 for (Attachment item : this.image) 343 if (!item.isEmpty()) 344 return true; 345 return false; 346 } 347 348 /** 349 * @return {@link #image} (Image or images used to identify a location.) 350 */ 351 // syntactic sugar 352 public Attachment addImage() { //3 353 Attachment t = new Attachment(); 354 if (this.image == null) 355 this.image = new ArrayList<Attachment>(); 356 this.image.add(t); 357 return t; 358 } 359 360 // syntactic sugar 361 public BodySite addImage(Attachment t) { //3 362 if (t == null) 363 return this; 364 if (this.image == null) 365 this.image = new ArrayList<Attachment>(); 366 this.image.add(t); 367 return this; 368 } 369 370 protected void listChildren(List<Property> childrenList) { 371 super.listChildren(childrenList); 372 childrenList.add(new Property("patient", "Reference(Patient)", "The person to which the body site belongs.", 0, java.lang.Integer.MAX_VALUE, patient)); 373 childrenList.add(new Property("identifier", "Identifier", "Identifier for this instance of the anatomical location.", 0, java.lang.Integer.MAX_VALUE, identifier)); 374 childrenList.add(new Property("code", "CodeableConcept", "Named anatomical location - ideally coded where possible.", 0, java.lang.Integer.MAX_VALUE, code)); 375 childrenList.add(new Property("modifier", "CodeableConcept", "Modifier to refine the anatomical location. These include modifiers for laterality, relative location, directionality, number, and plane.", 0, java.lang.Integer.MAX_VALUE, modifier)); 376 childrenList.add(new Property("description", "string", "Description of anatomical location.", 0, java.lang.Integer.MAX_VALUE, description)); 377 childrenList.add(new Property("image", "Attachment", "Image or images used to identify a location.", 0, java.lang.Integer.MAX_VALUE, image)); 378 } 379 380 @Override 381 public void setProperty(String name, Base value) throws FHIRException { 382 if (name.equals("patient")) 383 this.patient = castToReference(value); // Reference 384 else if (name.equals("identifier")) 385 this.getIdentifier().add(castToIdentifier(value)); 386 else if (name.equals("code")) 387 this.code = castToCodeableConcept(value); // CodeableConcept 388 else if (name.equals("modifier")) 389 this.getModifier().add(castToCodeableConcept(value)); 390 else if (name.equals("description")) 391 this.description = castToString(value); // StringType 392 else if (name.equals("image")) 393 this.getImage().add(castToAttachment(value)); 394 else 395 super.setProperty(name, value); 396 } 397 398 @Override 399 public Base addChild(String name) throws FHIRException { 400 if (name.equals("patient")) { 401 this.patient = new Reference(); 402 return this.patient; 403 } 404 else if (name.equals("identifier")) { 405 return addIdentifier(); 406 } 407 else if (name.equals("code")) { 408 this.code = new CodeableConcept(); 409 return this.code; 410 } 411 else if (name.equals("modifier")) { 412 return addModifier(); 413 } 414 else if (name.equals("description")) { 415 throw new FHIRException("Cannot call addChild on a primitive type BodySite.description"); 416 } 417 else if (name.equals("image")) { 418 return addImage(); 419 } 420 else 421 return super.addChild(name); 422 } 423 424 public String fhirType() { 425 return "BodySite"; 426 427 } 428 429 public BodySite copy() { 430 BodySite dst = new BodySite(); 431 copyValues(dst); 432 dst.patient = patient == null ? null : patient.copy(); 433 if (identifier != null) { 434 dst.identifier = new ArrayList<Identifier>(); 435 for (Identifier i : identifier) 436 dst.identifier.add(i.copy()); 437 }; 438 dst.code = code == null ? null : code.copy(); 439 if (modifier != null) { 440 dst.modifier = new ArrayList<CodeableConcept>(); 441 for (CodeableConcept i : modifier) 442 dst.modifier.add(i.copy()); 443 }; 444 dst.description = description == null ? null : description.copy(); 445 if (image != null) { 446 dst.image = new ArrayList<Attachment>(); 447 for (Attachment i : image) 448 dst.image.add(i.copy()); 449 }; 450 return dst; 451 } 452 453 protected BodySite typedCopy() { 454 return copy(); 455 } 456 457 @Override 458 public boolean equalsDeep(Base other) { 459 if (!super.equalsDeep(other)) 460 return false; 461 if (!(other instanceof BodySite)) 462 return false; 463 BodySite o = (BodySite) other; 464 return compareDeep(patient, o.patient, true) && compareDeep(identifier, o.identifier, true) && compareDeep(code, o.code, true) 465 && compareDeep(modifier, o.modifier, true) && compareDeep(description, o.description, true) && compareDeep(image, o.image, true) 466 ; 467 } 468 469 @Override 470 public boolean equalsShallow(Base other) { 471 if (!super.equalsShallow(other)) 472 return false; 473 if (!(other instanceof BodySite)) 474 return false; 475 BodySite o = (BodySite) other; 476 return compareValues(description, o.description, true); 477 } 478 479 public boolean isEmpty() { 480 return super.isEmpty() && (patient == null || patient.isEmpty()) && (identifier == null || identifier.isEmpty()) 481 && (code == null || code.isEmpty()) && (modifier == null || modifier.isEmpty()) && (description == null || description.isEmpty()) 482 && (image == null || image.isEmpty()); 483 } 484 485 @Override 486 public ResourceType getResourceType() { 487 return ResourceType.BodySite; 488 } 489 490 @SearchParamDefinition(name="identifier", path="BodySite.identifier", description="Identifier for this instance of the anatomical location", type="token" ) 491 public static final String SP_IDENTIFIER = "identifier"; 492 @SearchParamDefinition(name="code", path="BodySite.code", description="Named anatomical location", type="token" ) 493 public static final String SP_CODE = "code"; 494 @SearchParamDefinition(name="patient", path="BodySite.patient", description="Patient to whom bodysite belongs", type="reference" ) 495 public static final String SP_PATIENT = "patient"; 496 497} 498