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 Mon, Apr 17, 2017 17:38-0400 for FHIR v3.0.1 033 034import java.util.*; 035 036import org.hl7.fhir.utilities.Utilities; 037import ca.uhn.fhir.model.api.annotation.ResourceDef; 038import ca.uhn.fhir.model.api.annotation.SearchParamDefinition; 039import ca.uhn.fhir.model.api.annotation.Child; 040import ca.uhn.fhir.model.api.annotation.ChildOrder; 041import ca.uhn.fhir.model.api.annotation.Description; 042import ca.uhn.fhir.model.api.annotation.Block; 043import org.hl7.fhir.instance.model.api.*; 044import org.hl7.fhir.exceptions.FHIRException; 045/** 046 * A record of a device being used by a patient where the record is the result of a report from the patient or another clinician. 047 */ 048@ResourceDef(name="DeviceUseStatement", profile="http://hl7.org/fhir/Profile/DeviceUseStatement") 049public class DeviceUseStatement extends DomainResource { 050 051 public enum DeviceUseStatementStatus { 052 /** 053 * The device is still being used. 054 */ 055 ACTIVE, 056 /** 057 * The device is no longer being used. 058 */ 059 COMPLETED, 060 /** 061 * The statement was recorded incorrectly. 062 */ 063 ENTEREDINERROR, 064 /** 065 * The device may be used at some time in the future. 066 */ 067 INTENDED, 068 /** 069 * Actions implied by the statement have been permanently halted, before all of them occurred. 070 */ 071 STOPPED, 072 /** 073 * Actions implied by the statement have been temporarily halted, but are expected to continue later. May also be called "suspended". 074 */ 075 ONHOLD, 076 /** 077 * added to help the parsers with the generic types 078 */ 079 NULL; 080 public static DeviceUseStatementStatus fromCode(String codeString) throws FHIRException { 081 if (codeString == null || "".equals(codeString)) 082 return null; 083 if ("active".equals(codeString)) 084 return ACTIVE; 085 if ("completed".equals(codeString)) 086 return COMPLETED; 087 if ("entered-in-error".equals(codeString)) 088 return ENTEREDINERROR; 089 if ("intended".equals(codeString)) 090 return INTENDED; 091 if ("stopped".equals(codeString)) 092 return STOPPED; 093 if ("on-hold".equals(codeString)) 094 return ONHOLD; 095 if (Configuration.isAcceptInvalidEnums()) 096 return null; 097 else 098 throw new FHIRException("Unknown DeviceUseStatementStatus code '"+codeString+"'"); 099 } 100 public String toCode() { 101 switch (this) { 102 case ACTIVE: return "active"; 103 case COMPLETED: return "completed"; 104 case ENTEREDINERROR: return "entered-in-error"; 105 case INTENDED: return "intended"; 106 case STOPPED: return "stopped"; 107 case ONHOLD: return "on-hold"; 108 default: return "?"; 109 } 110 } 111 public String getSystem() { 112 switch (this) { 113 case ACTIVE: return "http://hl7.org/fhir/device-statement-status"; 114 case COMPLETED: return "http://hl7.org/fhir/device-statement-status"; 115 case ENTEREDINERROR: return "http://hl7.org/fhir/device-statement-status"; 116 case INTENDED: return "http://hl7.org/fhir/device-statement-status"; 117 case STOPPED: return "http://hl7.org/fhir/device-statement-status"; 118 case ONHOLD: return "http://hl7.org/fhir/device-statement-status"; 119 default: return "?"; 120 } 121 } 122 public String getDefinition() { 123 switch (this) { 124 case ACTIVE: return "The device is still being used."; 125 case COMPLETED: return "The device is no longer being used."; 126 case ENTEREDINERROR: return "The statement was recorded incorrectly."; 127 case INTENDED: return "The device may be used at some time in the future."; 128 case STOPPED: return "Actions implied by the statement have been permanently halted, before all of them occurred."; 129 case ONHOLD: return "Actions implied by the statement have been temporarily halted, but are expected to continue later. May also be called \"suspended\"."; 130 default: return "?"; 131 } 132 } 133 public String getDisplay() { 134 switch (this) { 135 case ACTIVE: return "Active"; 136 case COMPLETED: return "Completed"; 137 case ENTEREDINERROR: return "Entered in Error"; 138 case INTENDED: return "Intended"; 139 case STOPPED: return "Stopped"; 140 case ONHOLD: return "On Hold"; 141 default: return "?"; 142 } 143 } 144 } 145 146 public static class DeviceUseStatementStatusEnumFactory implements EnumFactory<DeviceUseStatementStatus> { 147 public DeviceUseStatementStatus fromCode(String codeString) throws IllegalArgumentException { 148 if (codeString == null || "".equals(codeString)) 149 if (codeString == null || "".equals(codeString)) 150 return null; 151 if ("active".equals(codeString)) 152 return DeviceUseStatementStatus.ACTIVE; 153 if ("completed".equals(codeString)) 154 return DeviceUseStatementStatus.COMPLETED; 155 if ("entered-in-error".equals(codeString)) 156 return DeviceUseStatementStatus.ENTEREDINERROR; 157 if ("intended".equals(codeString)) 158 return DeviceUseStatementStatus.INTENDED; 159 if ("stopped".equals(codeString)) 160 return DeviceUseStatementStatus.STOPPED; 161 if ("on-hold".equals(codeString)) 162 return DeviceUseStatementStatus.ONHOLD; 163 throw new IllegalArgumentException("Unknown DeviceUseStatementStatus code '"+codeString+"'"); 164 } 165 public Enumeration<DeviceUseStatementStatus> fromType(Base code) throws FHIRException { 166 if (code == null) 167 return null; 168 if (code.isEmpty()) 169 return new Enumeration<DeviceUseStatementStatus>(this); 170 String codeString = ((PrimitiveType) code).asStringValue(); 171 if (codeString == null || "".equals(codeString)) 172 return null; 173 if ("active".equals(codeString)) 174 return new Enumeration<DeviceUseStatementStatus>(this, DeviceUseStatementStatus.ACTIVE); 175 if ("completed".equals(codeString)) 176 return new Enumeration<DeviceUseStatementStatus>(this, DeviceUseStatementStatus.COMPLETED); 177 if ("entered-in-error".equals(codeString)) 178 return new Enumeration<DeviceUseStatementStatus>(this, DeviceUseStatementStatus.ENTEREDINERROR); 179 if ("intended".equals(codeString)) 180 return new Enumeration<DeviceUseStatementStatus>(this, DeviceUseStatementStatus.INTENDED); 181 if ("stopped".equals(codeString)) 182 return new Enumeration<DeviceUseStatementStatus>(this, DeviceUseStatementStatus.STOPPED); 183 if ("on-hold".equals(codeString)) 184 return new Enumeration<DeviceUseStatementStatus>(this, DeviceUseStatementStatus.ONHOLD); 185 throw new FHIRException("Unknown DeviceUseStatementStatus code '"+codeString+"'"); 186 } 187 public String toCode(DeviceUseStatementStatus code) { 188 if (code == DeviceUseStatementStatus.ACTIVE) 189 return "active"; 190 if (code == DeviceUseStatementStatus.COMPLETED) 191 return "completed"; 192 if (code == DeviceUseStatementStatus.ENTEREDINERROR) 193 return "entered-in-error"; 194 if (code == DeviceUseStatementStatus.INTENDED) 195 return "intended"; 196 if (code == DeviceUseStatementStatus.STOPPED) 197 return "stopped"; 198 if (code == DeviceUseStatementStatus.ONHOLD) 199 return "on-hold"; 200 return "?"; 201 } 202 public String toSystem(DeviceUseStatementStatus code) { 203 return code.getSystem(); 204 } 205 } 206 207 /** 208 * An external identifier for this statement such as an IRI. 209 */ 210 @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 211 @Description(shortDefinition="External identifier for this record", formalDefinition="An external identifier for this statement such as an IRI." ) 212 protected List<Identifier> identifier; 213 214 /** 215 * A code representing the patient or other source's judgment about the state of the device used that this statement is about. Generally this will be active or completed. 216 */ 217 @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true) 218 @Description(shortDefinition="active | completed | entered-in-error +", formalDefinition="A code representing the patient or other source's judgment about the state of the device used that this statement is about. Generally this will be active or completed." ) 219 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/device-statement-status") 220 protected Enumeration<DeviceUseStatementStatus> status; 221 222 /** 223 * The patient who used the device. 224 */ 225 @Child(name = "subject", type = {Patient.class, Group.class}, order=2, min=1, max=1, modifier=false, summary=false) 226 @Description(shortDefinition="Patient using device", formalDefinition="The patient who used the device." ) 227 protected Reference subject; 228 229 /** 230 * The actual object that is the target of the reference (The patient who used the device.) 231 */ 232 protected Resource subjectTarget; 233 234 /** 235 * The time period over which the device was used. 236 */ 237 @Child(name = "whenUsed", type = {Period.class}, order=3, min=0, max=1, modifier=false, summary=false) 238 @Description(shortDefinition="Period device was used", formalDefinition="The time period over which the device was used." ) 239 protected Period whenUsed; 240 241 /** 242 * How often the device was used. 243 */ 244 @Child(name = "timing", type = {Timing.class, Period.class, DateTimeType.class}, order=4, min=0, max=1, modifier=false, summary=false) 245 @Description(shortDefinition="How often the device was used", formalDefinition="How often the device was used." ) 246 protected Type timing; 247 248 /** 249 * The time at which the statement was made/recorded. 250 */ 251 @Child(name = "recordedOn", type = {DateTimeType.class}, order=5, min=0, max=1, modifier=false, summary=false) 252 @Description(shortDefinition="When statement was recorded", formalDefinition="The time at which the statement was made/recorded." ) 253 protected DateTimeType recordedOn; 254 255 /** 256 * Who reported the device was being used by the patient. 257 */ 258 @Child(name = "source", type = {Patient.class, Practitioner.class, RelatedPerson.class}, order=6, min=0, max=1, modifier=false, summary=false) 259 @Description(shortDefinition="Who made the statement", formalDefinition="Who reported the device was being used by the patient." ) 260 protected Reference source; 261 262 /** 263 * The actual object that is the target of the reference (Who reported the device was being used by the patient.) 264 */ 265 protected Resource sourceTarget; 266 267 /** 268 * The details of the device used. 269 */ 270 @Child(name = "device", type = {Device.class}, order=7, min=1, max=1, modifier=false, summary=false) 271 @Description(shortDefinition="Reference to device used", formalDefinition="The details of the device used." ) 272 protected Reference device; 273 274 /** 275 * The actual object that is the target of the reference (The details of the device used.) 276 */ 277 protected Device deviceTarget; 278 279 /** 280 * Reason or justification for the use of the device. 281 */ 282 @Child(name = "indication", type = {CodeableConcept.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 283 @Description(shortDefinition="Why device was used", formalDefinition="Reason or justification for the use of the device." ) 284 protected List<CodeableConcept> indication; 285 286 /** 287 * Indicates the site on the subject's body where the device was used ( i.e. the target site). 288 */ 289 @Child(name = "bodySite", type = {CodeableConcept.class}, order=9, min=0, max=1, modifier=false, summary=false) 290 @Description(shortDefinition="Target body site", formalDefinition="Indicates the site on the subject's body where the device was used ( i.e. the target site)." ) 291 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/body-site") 292 protected CodeableConcept bodySite; 293 294 /** 295 * Details about the device statement that were not represented at all or sufficiently in one of the attributes provided in a class. These may include for example a comment, an instruction, or a note associated with the statement. 296 */ 297 @Child(name = "note", type = {Annotation.class}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 298 @Description(shortDefinition="Addition details (comments, instructions)", formalDefinition="Details about the device statement that were not represented at all or sufficiently in one of the attributes provided in a class. These may include for example a comment, an instruction, or a note associated with the statement." ) 299 protected List<Annotation> note; 300 301 private static final long serialVersionUID = 2144163845L; 302 303 /** 304 * Constructor 305 */ 306 public DeviceUseStatement() { 307 super(); 308 } 309 310 /** 311 * Constructor 312 */ 313 public DeviceUseStatement(Enumeration<DeviceUseStatementStatus> status, Reference subject, Reference device) { 314 super(); 315 this.status = status; 316 this.subject = subject; 317 this.device = device; 318 } 319 320 /** 321 * @return {@link #identifier} (An external identifier for this statement such as an IRI.) 322 */ 323 public List<Identifier> getIdentifier() { 324 if (this.identifier == null) 325 this.identifier = new ArrayList<Identifier>(); 326 return this.identifier; 327 } 328 329 /** 330 * @return Returns a reference to <code>this</code> for easy method chaining 331 */ 332 public DeviceUseStatement setIdentifier(List<Identifier> theIdentifier) { 333 this.identifier = theIdentifier; 334 return this; 335 } 336 337 public boolean hasIdentifier() { 338 if (this.identifier == null) 339 return false; 340 for (Identifier item : this.identifier) 341 if (!item.isEmpty()) 342 return true; 343 return false; 344 } 345 346 public Identifier addIdentifier() { //3 347 Identifier t = new Identifier(); 348 if (this.identifier == null) 349 this.identifier = new ArrayList<Identifier>(); 350 this.identifier.add(t); 351 return t; 352 } 353 354 public DeviceUseStatement addIdentifier(Identifier t) { //3 355 if (t == null) 356 return this; 357 if (this.identifier == null) 358 this.identifier = new ArrayList<Identifier>(); 359 this.identifier.add(t); 360 return this; 361 } 362 363 /** 364 * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist 365 */ 366 public Identifier getIdentifierFirstRep() { 367 if (getIdentifier().isEmpty()) { 368 addIdentifier(); 369 } 370 return getIdentifier().get(0); 371 } 372 373 /** 374 * @return {@link #status} (A code representing the patient or other source's judgment about the state of the device used that this statement is about. Generally this will be active or completed.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value 375 */ 376 public Enumeration<DeviceUseStatementStatus> getStatusElement() { 377 if (this.status == null) 378 if (Configuration.errorOnAutoCreate()) 379 throw new Error("Attempt to auto-create DeviceUseStatement.status"); 380 else if (Configuration.doAutoCreate()) 381 this.status = new Enumeration<DeviceUseStatementStatus>(new DeviceUseStatementStatusEnumFactory()); // bb 382 return this.status; 383 } 384 385 public boolean hasStatusElement() { 386 return this.status != null && !this.status.isEmpty(); 387 } 388 389 public boolean hasStatus() { 390 return this.status != null && !this.status.isEmpty(); 391 } 392 393 /** 394 * @param value {@link #status} (A code representing the patient or other source's judgment about the state of the device used that this statement is about. Generally this will be active or completed.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value 395 */ 396 public DeviceUseStatement setStatusElement(Enumeration<DeviceUseStatementStatus> value) { 397 this.status = value; 398 return this; 399 } 400 401 /** 402 * @return A code representing the patient or other source's judgment about the state of the device used that this statement is about. Generally this will be active or completed. 403 */ 404 public DeviceUseStatementStatus getStatus() { 405 return this.status == null ? null : this.status.getValue(); 406 } 407 408 /** 409 * @param value A code representing the patient or other source's judgment about the state of the device used that this statement is about. Generally this will be active or completed. 410 */ 411 public DeviceUseStatement setStatus(DeviceUseStatementStatus value) { 412 if (this.status == null) 413 this.status = new Enumeration<DeviceUseStatementStatus>(new DeviceUseStatementStatusEnumFactory()); 414 this.status.setValue(value); 415 return this; 416 } 417 418 /** 419 * @return {@link #subject} (The patient who used the device.) 420 */ 421 public Reference getSubject() { 422 if (this.subject == null) 423 if (Configuration.errorOnAutoCreate()) 424 throw new Error("Attempt to auto-create DeviceUseStatement.subject"); 425 else if (Configuration.doAutoCreate()) 426 this.subject = new Reference(); // cc 427 return this.subject; 428 } 429 430 public boolean hasSubject() { 431 return this.subject != null && !this.subject.isEmpty(); 432 } 433 434 /** 435 * @param value {@link #subject} (The patient who used the device.) 436 */ 437 public DeviceUseStatement setSubject(Reference value) { 438 this.subject = value; 439 return this; 440 } 441 442 /** 443 * @return {@link #subject} 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 patient who used the device.) 444 */ 445 public Resource getSubjectTarget() { 446 return this.subjectTarget; 447 } 448 449 /** 450 * @param value {@link #subject} 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 patient who used the device.) 451 */ 452 public DeviceUseStatement setSubjectTarget(Resource value) { 453 this.subjectTarget = value; 454 return this; 455 } 456 457 /** 458 * @return {@link #whenUsed} (The time period over which the device was used.) 459 */ 460 public Period getWhenUsed() { 461 if (this.whenUsed == null) 462 if (Configuration.errorOnAutoCreate()) 463 throw new Error("Attempt to auto-create DeviceUseStatement.whenUsed"); 464 else if (Configuration.doAutoCreate()) 465 this.whenUsed = new Period(); // cc 466 return this.whenUsed; 467 } 468 469 public boolean hasWhenUsed() { 470 return this.whenUsed != null && !this.whenUsed.isEmpty(); 471 } 472 473 /** 474 * @param value {@link #whenUsed} (The time period over which the device was used.) 475 */ 476 public DeviceUseStatement setWhenUsed(Period value) { 477 this.whenUsed = value; 478 return this; 479 } 480 481 /** 482 * @return {@link #timing} (How often the device was used.) 483 */ 484 public Type getTiming() { 485 return this.timing; 486 } 487 488 /** 489 * @return {@link #timing} (How often the device was used.) 490 */ 491 public Timing getTimingTiming() throws FHIRException { 492 if (!(this.timing instanceof Timing)) 493 throw new FHIRException("Type mismatch: the type Timing was expected, but "+this.timing.getClass().getName()+" was encountered"); 494 return (Timing) this.timing; 495 } 496 497 public boolean hasTimingTiming() { 498 return this.timing instanceof Timing; 499 } 500 501 /** 502 * @return {@link #timing} (How often the device was used.) 503 */ 504 public Period getTimingPeriod() throws FHIRException { 505 if (!(this.timing instanceof Period)) 506 throw new FHIRException("Type mismatch: the type Period was expected, but "+this.timing.getClass().getName()+" was encountered"); 507 return (Period) this.timing; 508 } 509 510 public boolean hasTimingPeriod() { 511 return this.timing instanceof Period; 512 } 513 514 /** 515 * @return {@link #timing} (How often the device was used.) 516 */ 517 public DateTimeType getTimingDateTimeType() throws FHIRException { 518 if (!(this.timing instanceof DateTimeType)) 519 throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.timing.getClass().getName()+" was encountered"); 520 return (DateTimeType) this.timing; 521 } 522 523 public boolean hasTimingDateTimeType() { 524 return this.timing instanceof DateTimeType; 525 } 526 527 public boolean hasTiming() { 528 return this.timing != null && !this.timing.isEmpty(); 529 } 530 531 /** 532 * @param value {@link #timing} (How often the device was used.) 533 */ 534 public DeviceUseStatement setTiming(Type value) { 535 this.timing = value; 536 return this; 537 } 538 539 /** 540 * @return {@link #recordedOn} (The time at which the statement was made/recorded.). This is the underlying object with id, value and extensions. The accessor "getRecordedOn" gives direct access to the value 541 */ 542 public DateTimeType getRecordedOnElement() { 543 if (this.recordedOn == null) 544 if (Configuration.errorOnAutoCreate()) 545 throw new Error("Attempt to auto-create DeviceUseStatement.recordedOn"); 546 else if (Configuration.doAutoCreate()) 547 this.recordedOn = new DateTimeType(); // bb 548 return this.recordedOn; 549 } 550 551 public boolean hasRecordedOnElement() { 552 return this.recordedOn != null && !this.recordedOn.isEmpty(); 553 } 554 555 public boolean hasRecordedOn() { 556 return this.recordedOn != null && !this.recordedOn.isEmpty(); 557 } 558 559 /** 560 * @param value {@link #recordedOn} (The time at which the statement was made/recorded.). This is the underlying object with id, value and extensions. The accessor "getRecordedOn" gives direct access to the value 561 */ 562 public DeviceUseStatement setRecordedOnElement(DateTimeType value) { 563 this.recordedOn = value; 564 return this; 565 } 566 567 /** 568 * @return The time at which the statement was made/recorded. 569 */ 570 public Date getRecordedOn() { 571 return this.recordedOn == null ? null : this.recordedOn.getValue(); 572 } 573 574 /** 575 * @param value The time at which the statement was made/recorded. 576 */ 577 public DeviceUseStatement setRecordedOn(Date value) { 578 if (value == null) 579 this.recordedOn = null; 580 else { 581 if (this.recordedOn == null) 582 this.recordedOn = new DateTimeType(); 583 this.recordedOn.setValue(value); 584 } 585 return this; 586 } 587 588 /** 589 * @return {@link #source} (Who reported the device was being used by the patient.) 590 */ 591 public Reference getSource() { 592 if (this.source == null) 593 if (Configuration.errorOnAutoCreate()) 594 throw new Error("Attempt to auto-create DeviceUseStatement.source"); 595 else if (Configuration.doAutoCreate()) 596 this.source = new Reference(); // cc 597 return this.source; 598 } 599 600 public boolean hasSource() { 601 return this.source != null && !this.source.isEmpty(); 602 } 603 604 /** 605 * @param value {@link #source} (Who reported the device was being used by the patient.) 606 */ 607 public DeviceUseStatement setSource(Reference value) { 608 this.source = value; 609 return this; 610 } 611 612 /** 613 * @return {@link #source} 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. (Who reported the device was being used by the patient.) 614 */ 615 public Resource getSourceTarget() { 616 return this.sourceTarget; 617 } 618 619 /** 620 * @param value {@link #source} 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. (Who reported the device was being used by the patient.) 621 */ 622 public DeviceUseStatement setSourceTarget(Resource value) { 623 this.sourceTarget = value; 624 return this; 625 } 626 627 /** 628 * @return {@link #device} (The details of the device used.) 629 */ 630 public Reference getDevice() { 631 if (this.device == null) 632 if (Configuration.errorOnAutoCreate()) 633 throw new Error("Attempt to auto-create DeviceUseStatement.device"); 634 else if (Configuration.doAutoCreate()) 635 this.device = new Reference(); // cc 636 return this.device; 637 } 638 639 public boolean hasDevice() { 640 return this.device != null && !this.device.isEmpty(); 641 } 642 643 /** 644 * @param value {@link #device} (The details of the device used.) 645 */ 646 public DeviceUseStatement setDevice(Reference value) { 647 this.device = value; 648 return this; 649 } 650 651 /** 652 * @return {@link #device} 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 details of the device used.) 653 */ 654 public Device getDeviceTarget() { 655 if (this.deviceTarget == null) 656 if (Configuration.errorOnAutoCreate()) 657 throw new Error("Attempt to auto-create DeviceUseStatement.device"); 658 else if (Configuration.doAutoCreate()) 659 this.deviceTarget = new Device(); // aa 660 return this.deviceTarget; 661 } 662 663 /** 664 * @param value {@link #device} 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 details of the device used.) 665 */ 666 public DeviceUseStatement setDeviceTarget(Device value) { 667 this.deviceTarget = value; 668 return this; 669 } 670 671 /** 672 * @return {@link #indication} (Reason or justification for the use of the device.) 673 */ 674 public List<CodeableConcept> getIndication() { 675 if (this.indication == null) 676 this.indication = new ArrayList<CodeableConcept>(); 677 return this.indication; 678 } 679 680 /** 681 * @return Returns a reference to <code>this</code> for easy method chaining 682 */ 683 public DeviceUseStatement setIndication(List<CodeableConcept> theIndication) { 684 this.indication = theIndication; 685 return this; 686 } 687 688 public boolean hasIndication() { 689 if (this.indication == null) 690 return false; 691 for (CodeableConcept item : this.indication) 692 if (!item.isEmpty()) 693 return true; 694 return false; 695 } 696 697 public CodeableConcept addIndication() { //3 698 CodeableConcept t = new CodeableConcept(); 699 if (this.indication == null) 700 this.indication = new ArrayList<CodeableConcept>(); 701 this.indication.add(t); 702 return t; 703 } 704 705 public DeviceUseStatement addIndication(CodeableConcept t) { //3 706 if (t == null) 707 return this; 708 if (this.indication == null) 709 this.indication = new ArrayList<CodeableConcept>(); 710 this.indication.add(t); 711 return this; 712 } 713 714 /** 715 * @return The first repetition of repeating field {@link #indication}, creating it if it does not already exist 716 */ 717 public CodeableConcept getIndicationFirstRep() { 718 if (getIndication().isEmpty()) { 719 addIndication(); 720 } 721 return getIndication().get(0); 722 } 723 724 /** 725 * @return {@link #bodySite} (Indicates the site on the subject's body where the device was used ( i.e. the target site).) 726 */ 727 public CodeableConcept getBodySite() { 728 if (this.bodySite == null) 729 if (Configuration.errorOnAutoCreate()) 730 throw new Error("Attempt to auto-create DeviceUseStatement.bodySite"); 731 else if (Configuration.doAutoCreate()) 732 this.bodySite = new CodeableConcept(); // cc 733 return this.bodySite; 734 } 735 736 public boolean hasBodySite() { 737 return this.bodySite != null && !this.bodySite.isEmpty(); 738 } 739 740 /** 741 * @param value {@link #bodySite} (Indicates the site on the subject's body where the device was used ( i.e. the target site).) 742 */ 743 public DeviceUseStatement setBodySite(CodeableConcept value) { 744 this.bodySite = value; 745 return this; 746 } 747 748 /** 749 * @return {@link #note} (Details about the device statement that were not represented at all or sufficiently in one of the attributes provided in a class. These may include for example a comment, an instruction, or a note associated with the statement.) 750 */ 751 public List<Annotation> getNote() { 752 if (this.note == null) 753 this.note = new ArrayList<Annotation>(); 754 return this.note; 755 } 756 757 /** 758 * @return Returns a reference to <code>this</code> for easy method chaining 759 */ 760 public DeviceUseStatement setNote(List<Annotation> theNote) { 761 this.note = theNote; 762 return this; 763 } 764 765 public boolean hasNote() { 766 if (this.note == null) 767 return false; 768 for (Annotation item : this.note) 769 if (!item.isEmpty()) 770 return true; 771 return false; 772 } 773 774 public Annotation addNote() { //3 775 Annotation t = new Annotation(); 776 if (this.note == null) 777 this.note = new ArrayList<Annotation>(); 778 this.note.add(t); 779 return t; 780 } 781 782 public DeviceUseStatement addNote(Annotation t) { //3 783 if (t == null) 784 return this; 785 if (this.note == null) 786 this.note = new ArrayList<Annotation>(); 787 this.note.add(t); 788 return this; 789 } 790 791 /** 792 * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist 793 */ 794 public Annotation getNoteFirstRep() { 795 if (getNote().isEmpty()) { 796 addNote(); 797 } 798 return getNote().get(0); 799 } 800 801 protected void listChildren(List<Property> childrenList) { 802 super.listChildren(childrenList); 803 childrenList.add(new Property("identifier", "Identifier", "An external identifier for this statement such as an IRI.", 0, java.lang.Integer.MAX_VALUE, identifier)); 804 childrenList.add(new Property("status", "code", "A code representing the patient or other source's judgment about the state of the device used that this statement is about. Generally this will be active or completed.", 0, java.lang.Integer.MAX_VALUE, status)); 805 childrenList.add(new Property("subject", "Reference(Patient|Group)", "The patient who used the device.", 0, java.lang.Integer.MAX_VALUE, subject)); 806 childrenList.add(new Property("whenUsed", "Period", "The time period over which the device was used.", 0, java.lang.Integer.MAX_VALUE, whenUsed)); 807 childrenList.add(new Property("timing[x]", "Timing|Period|dateTime", "How often the device was used.", 0, java.lang.Integer.MAX_VALUE, timing)); 808 childrenList.add(new Property("recordedOn", "dateTime", "The time at which the statement was made/recorded.", 0, java.lang.Integer.MAX_VALUE, recordedOn)); 809 childrenList.add(new Property("source", "Reference(Patient|Practitioner|RelatedPerson)", "Who reported the device was being used by the patient.", 0, java.lang.Integer.MAX_VALUE, source)); 810 childrenList.add(new Property("device", "Reference(Device)", "The details of the device used.", 0, java.lang.Integer.MAX_VALUE, device)); 811 childrenList.add(new Property("indication", "CodeableConcept", "Reason or justification for the use of the device.", 0, java.lang.Integer.MAX_VALUE, indication)); 812 childrenList.add(new Property("bodySite", "CodeableConcept", "Indicates the site on the subject's body where the device was used ( i.e. the target site).", 0, java.lang.Integer.MAX_VALUE, bodySite)); 813 childrenList.add(new Property("note", "Annotation", "Details about the device statement that were not represented at all or sufficiently in one of the attributes provided in a class. These may include for example a comment, an instruction, or a note associated with the statement.", 0, java.lang.Integer.MAX_VALUE, note)); 814 } 815 816 @Override 817 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 818 switch (hash) { 819 case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier 820 case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<DeviceUseStatementStatus> 821 case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference 822 case 2042879511: /*whenUsed*/ return this.whenUsed == null ? new Base[0] : new Base[] {this.whenUsed}; // Period 823 case -873664438: /*timing*/ return this.timing == null ? new Base[0] : new Base[] {this.timing}; // Type 824 case 735397551: /*recordedOn*/ return this.recordedOn == null ? new Base[0] : new Base[] {this.recordedOn}; // DateTimeType 825 case -896505829: /*source*/ return this.source == null ? new Base[0] : new Base[] {this.source}; // Reference 826 case -1335157162: /*device*/ return this.device == null ? new Base[0] : new Base[] {this.device}; // Reference 827 case -597168804: /*indication*/ return this.indication == null ? new Base[0] : this.indication.toArray(new Base[this.indication.size()]); // CodeableConcept 828 case 1702620169: /*bodySite*/ return this.bodySite == null ? new Base[0] : new Base[] {this.bodySite}; // CodeableConcept 829 case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation 830 default: return super.getProperty(hash, name, checkValid); 831 } 832 833 } 834 835 @Override 836 public Base setProperty(int hash, String name, Base value) throws FHIRException { 837 switch (hash) { 838 case -1618432855: // identifier 839 this.getIdentifier().add(castToIdentifier(value)); // Identifier 840 return value; 841 case -892481550: // status 842 value = new DeviceUseStatementStatusEnumFactory().fromType(castToCode(value)); 843 this.status = (Enumeration) value; // Enumeration<DeviceUseStatementStatus> 844 return value; 845 case -1867885268: // subject 846 this.subject = castToReference(value); // Reference 847 return value; 848 case 2042879511: // whenUsed 849 this.whenUsed = castToPeriod(value); // Period 850 return value; 851 case -873664438: // timing 852 this.timing = castToType(value); // Type 853 return value; 854 case 735397551: // recordedOn 855 this.recordedOn = castToDateTime(value); // DateTimeType 856 return value; 857 case -896505829: // source 858 this.source = castToReference(value); // Reference 859 return value; 860 case -1335157162: // device 861 this.device = castToReference(value); // Reference 862 return value; 863 case -597168804: // indication 864 this.getIndication().add(castToCodeableConcept(value)); // CodeableConcept 865 return value; 866 case 1702620169: // bodySite 867 this.bodySite = castToCodeableConcept(value); // CodeableConcept 868 return value; 869 case 3387378: // note 870 this.getNote().add(castToAnnotation(value)); // Annotation 871 return value; 872 default: return super.setProperty(hash, name, value); 873 } 874 875 } 876 877 @Override 878 public Base setProperty(String name, Base value) throws FHIRException { 879 if (name.equals("identifier")) { 880 this.getIdentifier().add(castToIdentifier(value)); 881 } else if (name.equals("status")) { 882 value = new DeviceUseStatementStatusEnumFactory().fromType(castToCode(value)); 883 this.status = (Enumeration) value; // Enumeration<DeviceUseStatementStatus> 884 } else if (name.equals("subject")) { 885 this.subject = castToReference(value); // Reference 886 } else if (name.equals("whenUsed")) { 887 this.whenUsed = castToPeriod(value); // Period 888 } else if (name.equals("timing[x]")) { 889 this.timing = castToType(value); // Type 890 } else if (name.equals("recordedOn")) { 891 this.recordedOn = castToDateTime(value); // DateTimeType 892 } else if (name.equals("source")) { 893 this.source = castToReference(value); // Reference 894 } else if (name.equals("device")) { 895 this.device = castToReference(value); // Reference 896 } else if (name.equals("indication")) { 897 this.getIndication().add(castToCodeableConcept(value)); 898 } else if (name.equals("bodySite")) { 899 this.bodySite = castToCodeableConcept(value); // CodeableConcept 900 } else if (name.equals("note")) { 901 this.getNote().add(castToAnnotation(value)); 902 } else 903 return super.setProperty(name, value); 904 return value; 905 } 906 907 @Override 908 public Base makeProperty(int hash, String name) throws FHIRException { 909 switch (hash) { 910 case -1618432855: return addIdentifier(); 911 case -892481550: return getStatusElement(); 912 case -1867885268: return getSubject(); 913 case 2042879511: return getWhenUsed(); 914 case 164632566: return getTiming(); 915 case -873664438: return getTiming(); 916 case 735397551: return getRecordedOnElement(); 917 case -896505829: return getSource(); 918 case -1335157162: return getDevice(); 919 case -597168804: return addIndication(); 920 case 1702620169: return getBodySite(); 921 case 3387378: return addNote(); 922 default: return super.makeProperty(hash, name); 923 } 924 925 } 926 927 @Override 928 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 929 switch (hash) { 930 case -1618432855: /*identifier*/ return new String[] {"Identifier"}; 931 case -892481550: /*status*/ return new String[] {"code"}; 932 case -1867885268: /*subject*/ return new String[] {"Reference"}; 933 case 2042879511: /*whenUsed*/ return new String[] {"Period"}; 934 case -873664438: /*timing*/ return new String[] {"Timing", "Period", "dateTime"}; 935 case 735397551: /*recordedOn*/ return new String[] {"dateTime"}; 936 case -896505829: /*source*/ return new String[] {"Reference"}; 937 case -1335157162: /*device*/ return new String[] {"Reference"}; 938 case -597168804: /*indication*/ return new String[] {"CodeableConcept"}; 939 case 1702620169: /*bodySite*/ return new String[] {"CodeableConcept"}; 940 case 3387378: /*note*/ return new String[] {"Annotation"}; 941 default: return super.getTypesForProperty(hash, name); 942 } 943 944 } 945 946 @Override 947 public Base addChild(String name) throws FHIRException { 948 if (name.equals("identifier")) { 949 return addIdentifier(); 950 } 951 else if (name.equals("status")) { 952 throw new FHIRException("Cannot call addChild on a primitive type DeviceUseStatement.status"); 953 } 954 else if (name.equals("subject")) { 955 this.subject = new Reference(); 956 return this.subject; 957 } 958 else if (name.equals("whenUsed")) { 959 this.whenUsed = new Period(); 960 return this.whenUsed; 961 } 962 else if (name.equals("timingTiming")) { 963 this.timing = new Timing(); 964 return this.timing; 965 } 966 else if (name.equals("timingPeriod")) { 967 this.timing = new Period(); 968 return this.timing; 969 } 970 else if (name.equals("timingDateTime")) { 971 this.timing = new DateTimeType(); 972 return this.timing; 973 } 974 else if (name.equals("recordedOn")) { 975 throw new FHIRException("Cannot call addChild on a primitive type DeviceUseStatement.recordedOn"); 976 } 977 else if (name.equals("source")) { 978 this.source = new Reference(); 979 return this.source; 980 } 981 else if (name.equals("device")) { 982 this.device = new Reference(); 983 return this.device; 984 } 985 else if (name.equals("indication")) { 986 return addIndication(); 987 } 988 else if (name.equals("bodySite")) { 989 this.bodySite = new CodeableConcept(); 990 return this.bodySite; 991 } 992 else if (name.equals("note")) { 993 return addNote(); 994 } 995 else 996 return super.addChild(name); 997 } 998 999 public String fhirType() { 1000 return "DeviceUseStatement"; 1001 1002 } 1003 1004 public DeviceUseStatement copy() { 1005 DeviceUseStatement dst = new DeviceUseStatement(); 1006 copyValues(dst); 1007 if (identifier != null) { 1008 dst.identifier = new ArrayList<Identifier>(); 1009 for (Identifier i : identifier) 1010 dst.identifier.add(i.copy()); 1011 }; 1012 dst.status = status == null ? null : status.copy(); 1013 dst.subject = subject == null ? null : subject.copy(); 1014 dst.whenUsed = whenUsed == null ? null : whenUsed.copy(); 1015 dst.timing = timing == null ? null : timing.copy(); 1016 dst.recordedOn = recordedOn == null ? null : recordedOn.copy(); 1017 dst.source = source == null ? null : source.copy(); 1018 dst.device = device == null ? null : device.copy(); 1019 if (indication != null) { 1020 dst.indication = new ArrayList<CodeableConcept>(); 1021 for (CodeableConcept i : indication) 1022 dst.indication.add(i.copy()); 1023 }; 1024 dst.bodySite = bodySite == null ? null : bodySite.copy(); 1025 if (note != null) { 1026 dst.note = new ArrayList<Annotation>(); 1027 for (Annotation i : note) 1028 dst.note.add(i.copy()); 1029 }; 1030 return dst; 1031 } 1032 1033 protected DeviceUseStatement typedCopy() { 1034 return copy(); 1035 } 1036 1037 @Override 1038 public boolean equalsDeep(Base other) { 1039 if (!super.equalsDeep(other)) 1040 return false; 1041 if (!(other instanceof DeviceUseStatement)) 1042 return false; 1043 DeviceUseStatement o = (DeviceUseStatement) other; 1044 return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(subject, o.subject, true) 1045 && compareDeep(whenUsed, o.whenUsed, true) && compareDeep(timing, o.timing, true) && compareDeep(recordedOn, o.recordedOn, true) 1046 && compareDeep(source, o.source, true) && compareDeep(device, o.device, true) && compareDeep(indication, o.indication, true) 1047 && compareDeep(bodySite, o.bodySite, true) && compareDeep(note, o.note, true); 1048 } 1049 1050 @Override 1051 public boolean equalsShallow(Base other) { 1052 if (!super.equalsShallow(other)) 1053 return false; 1054 if (!(other instanceof DeviceUseStatement)) 1055 return false; 1056 DeviceUseStatement o = (DeviceUseStatement) other; 1057 return compareValues(status, o.status, true) && compareValues(recordedOn, o.recordedOn, true); 1058 } 1059 1060 public boolean isEmpty() { 1061 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, subject 1062 , whenUsed, timing, recordedOn, source, device, indication, bodySite, note); 1063 } 1064 1065 @Override 1066 public ResourceType getResourceType() { 1067 return ResourceType.DeviceUseStatement; 1068 } 1069 1070 /** 1071 * Search parameter: <b>identifier</b> 1072 * <p> 1073 * Description: <b>Search by identifier</b><br> 1074 * Type: <b>token</b><br> 1075 * Path: <b>DeviceUseStatement.identifier</b><br> 1076 * </p> 1077 */ 1078 @SearchParamDefinition(name="identifier", path="DeviceUseStatement.identifier", description="Search by identifier", type="token" ) 1079 public static final String SP_IDENTIFIER = "identifier"; 1080 /** 1081 * <b>Fluent Client</b> search parameter constant for <b>identifier</b> 1082 * <p> 1083 * Description: <b>Search by identifier</b><br> 1084 * Type: <b>token</b><br> 1085 * Path: <b>DeviceUseStatement.identifier</b><br> 1086 * </p> 1087 */ 1088 public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER); 1089 1090 /** 1091 * Search parameter: <b>subject</b> 1092 * <p> 1093 * Description: <b>Search by subject</b><br> 1094 * Type: <b>reference</b><br> 1095 * Path: <b>DeviceUseStatement.subject</b><br> 1096 * </p> 1097 */ 1098 @SearchParamDefinition(name="subject", path="DeviceUseStatement.subject", description="Search by subject", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Group.class, Patient.class } ) 1099 public static final String SP_SUBJECT = "subject"; 1100 /** 1101 * <b>Fluent Client</b> search parameter constant for <b>subject</b> 1102 * <p> 1103 * Description: <b>Search by subject</b><br> 1104 * Type: <b>reference</b><br> 1105 * Path: <b>DeviceUseStatement.subject</b><br> 1106 * </p> 1107 */ 1108 public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT); 1109 1110/** 1111 * Constant for fluent queries to be used to add include statements. Specifies 1112 * the path value of "<b>DeviceUseStatement:subject</b>". 1113 */ 1114 public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("DeviceUseStatement:subject").toLocked(); 1115 1116 /** 1117 * Search parameter: <b>patient</b> 1118 * <p> 1119 * Description: <b>Search by subject - a patient</b><br> 1120 * Type: <b>reference</b><br> 1121 * Path: <b>DeviceUseStatement.subject</b><br> 1122 * </p> 1123 */ 1124 @SearchParamDefinition(name="patient", path="DeviceUseStatement.subject", description="Search by subject - a patient", type="reference", target={Group.class, Patient.class } ) 1125 public static final String SP_PATIENT = "patient"; 1126 /** 1127 * <b>Fluent Client</b> search parameter constant for <b>patient</b> 1128 * <p> 1129 * Description: <b>Search by subject - a patient</b><br> 1130 * Type: <b>reference</b><br> 1131 * Path: <b>DeviceUseStatement.subject</b><br> 1132 * </p> 1133 */ 1134 public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT); 1135 1136/** 1137 * Constant for fluent queries to be used to add include statements. Specifies 1138 * the path value of "<b>DeviceUseStatement:patient</b>". 1139 */ 1140 public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("DeviceUseStatement:patient").toLocked(); 1141 1142 /** 1143 * Search parameter: <b>device</b> 1144 * <p> 1145 * Description: <b>Search by device</b><br> 1146 * Type: <b>reference</b><br> 1147 * Path: <b>DeviceUseStatement.device</b><br> 1148 * </p> 1149 */ 1150 @SearchParamDefinition(name="device", path="DeviceUseStatement.device", description="Search by device", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Device") }, target={Device.class } ) 1151 public static final String SP_DEVICE = "device"; 1152 /** 1153 * <b>Fluent Client</b> search parameter constant for <b>device</b> 1154 * <p> 1155 * Description: <b>Search by device</b><br> 1156 * Type: <b>reference</b><br> 1157 * Path: <b>DeviceUseStatement.device</b><br> 1158 * </p> 1159 */ 1160 public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam DEVICE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_DEVICE); 1161 1162/** 1163 * Constant for fluent queries to be used to add include statements. Specifies 1164 * the path value of "<b>DeviceUseStatement:device</b>". 1165 */ 1166 public static final ca.uhn.fhir.model.api.Include INCLUDE_DEVICE = new ca.uhn.fhir.model.api.Include("DeviceUseStatement:device").toLocked(); 1167 1168 1169} 1170