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 * A photo, video, or audio recording acquired or used in healthcare. The actual content may be inline or provided by direct reference. 065 */ 066@ResourceDef(name="Media", profile="http://hl7.org/fhir/Profile/Media") 067public class Media extends DomainResource { 068 069 public enum DigitalMediaType { 070 /** 071 * The media consists of one or more unmoving images, including photographs, computer-generated graphs and charts, and scanned documents 072 */ 073 PHOTO, 074 /** 075 * The media consists of a series of frames that capture a moving image 076 */ 077 VIDEO, 078 /** 079 * The media consists of a sound recording 080 */ 081 AUDIO, 082 /** 083 * added to help the parsers 084 */ 085 NULL; 086 public static DigitalMediaType fromCode(String codeString) throws FHIRException { 087 if (codeString == null || "".equals(codeString)) 088 return null; 089 if ("photo".equals(codeString)) 090 return PHOTO; 091 if ("video".equals(codeString)) 092 return VIDEO; 093 if ("audio".equals(codeString)) 094 return AUDIO; 095 throw new FHIRException("Unknown DigitalMediaType code '"+codeString+"'"); 096 } 097 public String toCode() { 098 switch (this) { 099 case PHOTO: return "photo"; 100 case VIDEO: return "video"; 101 case AUDIO: return "audio"; 102 default: return "?"; 103 } 104 } 105 public String getSystem() { 106 switch (this) { 107 case PHOTO: return "http://hl7.org/fhir/digital-media-type"; 108 case VIDEO: return "http://hl7.org/fhir/digital-media-type"; 109 case AUDIO: return "http://hl7.org/fhir/digital-media-type"; 110 default: return "?"; 111 } 112 } 113 public String getDefinition() { 114 switch (this) { 115 case PHOTO: return "The media consists of one or more unmoving images, including photographs, computer-generated graphs and charts, and scanned documents"; 116 case VIDEO: return "The media consists of a series of frames that capture a moving image"; 117 case AUDIO: return "The media consists of a sound recording"; 118 default: return "?"; 119 } 120 } 121 public String getDisplay() { 122 switch (this) { 123 case PHOTO: return "Photo"; 124 case VIDEO: return "Video"; 125 case AUDIO: return "Audio"; 126 default: return "?"; 127 } 128 } 129 } 130 131 public static class DigitalMediaTypeEnumFactory implements EnumFactory<DigitalMediaType> { 132 public DigitalMediaType fromCode(String codeString) throws IllegalArgumentException { 133 if (codeString == null || "".equals(codeString)) 134 if (codeString == null || "".equals(codeString)) 135 return null; 136 if ("photo".equals(codeString)) 137 return DigitalMediaType.PHOTO; 138 if ("video".equals(codeString)) 139 return DigitalMediaType.VIDEO; 140 if ("audio".equals(codeString)) 141 return DigitalMediaType.AUDIO; 142 throw new IllegalArgumentException("Unknown DigitalMediaType code '"+codeString+"'"); 143 } 144 public Enumeration<DigitalMediaType> fromType(Base code) throws FHIRException { 145 if (code == null || code.isEmpty()) 146 return null; 147 String codeString = ((PrimitiveType) code).asStringValue(); 148 if (codeString == null || "".equals(codeString)) 149 return null; 150 if ("photo".equals(codeString)) 151 return new Enumeration<DigitalMediaType>(this, DigitalMediaType.PHOTO); 152 if ("video".equals(codeString)) 153 return new Enumeration<DigitalMediaType>(this, DigitalMediaType.VIDEO); 154 if ("audio".equals(codeString)) 155 return new Enumeration<DigitalMediaType>(this, DigitalMediaType.AUDIO); 156 throw new FHIRException("Unknown DigitalMediaType code '"+codeString+"'"); 157 } 158 public String toCode(DigitalMediaType code) { 159 if (code == DigitalMediaType.PHOTO) 160 return "photo"; 161 if (code == DigitalMediaType.VIDEO) 162 return "video"; 163 if (code == DigitalMediaType.AUDIO) 164 return "audio"; 165 return "?"; 166 } 167 } 168 169 /** 170 * Whether the media is a photo (still image), an audio recording, or a video recording. 171 */ 172 @Child(name = "type", type = {CodeType.class}, order=0, min=1, max=1, modifier=false, summary=true) 173 @Description(shortDefinition="photo | video | audio", formalDefinition="Whether the media is a photo (still image), an audio recording, or a video recording." ) 174 protected Enumeration<DigitalMediaType> type; 175 176 /** 177 * Details of the type of the media - usually, how it was acquired (what type of device). If images sourced from a DICOM system, are wrapped in a Media resource, then this is the modality. 178 */ 179 @Child(name = "subtype", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true) 180 @Description(shortDefinition="The type of acquisition equipment/process", formalDefinition="Details of the type of the media - usually, how it was acquired (what type of device). If images sourced from a DICOM system, are wrapped in a Media resource, then this is the modality." ) 181 protected CodeableConcept subtype; 182 183 /** 184 * Identifiers associated with the image - these may include identifiers for the image itself, identifiers for the context of its collection (e.g. series ids) and context ids such as accession numbers or other workflow identifiers. 185 */ 186 @Child(name = "identifier", type = {Identifier.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 187 @Description(shortDefinition="Identifier(s) for the image", formalDefinition="Identifiers associated with the image - these may include identifiers for the image itself, identifiers for the context of its collection (e.g. series ids) and context ids such as accession numbers or other workflow identifiers." ) 188 protected List<Identifier> identifier; 189 190 /** 191 * Who/What this Media is a record of. 192 */ 193 @Child(name = "subject", type = {Patient.class, Practitioner.class, Group.class, Device.class, Specimen.class}, order=3, min=0, max=1, modifier=false, summary=true) 194 @Description(shortDefinition="Who/What this Media is a record of", formalDefinition="Who/What this Media is a record of." ) 195 protected Reference subject; 196 197 /** 198 * The actual object that is the target of the reference (Who/What this Media is a record of.) 199 */ 200 protected Resource subjectTarget; 201 202 /** 203 * The person who administered the collection of the image. 204 */ 205 @Child(name = "operator", type = {Practitioner.class}, order=4, min=0, max=1, modifier=false, summary=true) 206 @Description(shortDefinition="The person who generated the image", formalDefinition="The person who administered the collection of the image." ) 207 protected Reference operator; 208 209 /** 210 * The actual object that is the target of the reference (The person who administered the collection of the image.) 211 */ 212 protected Practitioner operatorTarget; 213 214 /** 215 * The name of the imaging view e.g. Lateral or Antero-posterior (AP). 216 */ 217 @Child(name = "view", type = {CodeableConcept.class}, order=5, min=0, max=1, modifier=false, summary=true) 218 @Description(shortDefinition="Imaging view, e.g. Lateral or Antero-posterior", formalDefinition="The name of the imaging view e.g. Lateral or Antero-posterior (AP)." ) 219 protected CodeableConcept view; 220 221 /** 222 * The name of the device / manufacturer of the device that was used to make the recording. 223 */ 224 @Child(name = "deviceName", type = {StringType.class}, order=6, min=0, max=1, modifier=false, summary=true) 225 @Description(shortDefinition="Name of the device/manufacturer", formalDefinition="The name of the device / manufacturer of the device that was used to make the recording." ) 226 protected StringType deviceName; 227 228 /** 229 * Height of the image in pixels (photo/video). 230 */ 231 @Child(name = "height", type = {PositiveIntType.class}, order=7, min=0, max=1, modifier=false, summary=true) 232 @Description(shortDefinition="Height of the image in pixels (photo/video)", formalDefinition="Height of the image in pixels (photo/video)." ) 233 protected PositiveIntType height; 234 235 /** 236 * Width of the image in pixels (photo/video). 237 */ 238 @Child(name = "width", type = {PositiveIntType.class}, order=8, min=0, max=1, modifier=false, summary=true) 239 @Description(shortDefinition="Width of the image in pixels (photo/video)", formalDefinition="Width of the image in pixels (photo/video)." ) 240 protected PositiveIntType width; 241 242 /** 243 * The number of frames in a photo. This is used with a multi-page fax, or an imaging acquisition context that takes multiple slices in a single image, or an animated gif. If there is more than one frame, this SHALL have a value in order to alert interface software that a multi-frame capable rendering widget is required. 244 */ 245 @Child(name = "frames", type = {PositiveIntType.class}, order=9, min=0, max=1, modifier=false, summary=true) 246 @Description(shortDefinition="Number of frames if > 1 (photo)", formalDefinition="The number of frames in a photo. This is used with a multi-page fax, or an imaging acquisition context that takes multiple slices in a single image, or an animated gif. If there is more than one frame, this SHALL have a value in order to alert interface software that a multi-frame capable rendering widget is required." ) 247 protected PositiveIntType frames; 248 249 /** 250 * The duration of the recording in seconds - for audio and video. 251 */ 252 @Child(name = "duration", type = {UnsignedIntType.class}, order=10, min=0, max=1, modifier=false, summary=true) 253 @Description(shortDefinition="Length in seconds (audio / video)", formalDefinition="The duration of the recording in seconds - for audio and video." ) 254 protected UnsignedIntType duration; 255 256 /** 257 * The actual content of the media - inline or by direct reference to the media source file. 258 */ 259 @Child(name = "content", type = {Attachment.class}, order=11, min=1, max=1, modifier=false, summary=false) 260 @Description(shortDefinition="Actual Media - reference or data", formalDefinition="The actual content of the media - inline or by direct reference to the media source file." ) 261 protected Attachment content; 262 263 private static final long serialVersionUID = -280764739L; 264 265 /* 266 * Constructor 267 */ 268 public Media() { 269 super(); 270 } 271 272 /* 273 * Constructor 274 */ 275 public Media(Enumeration<DigitalMediaType> type, Attachment content) { 276 super(); 277 this.type = type; 278 this.content = content; 279 } 280 281 /** 282 * @return {@link #type} (Whether the media is a photo (still image), an audio recording, or a video recording.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value 283 */ 284 public Enumeration<DigitalMediaType> getTypeElement() { 285 if (this.type == null) 286 if (Configuration.errorOnAutoCreate()) 287 throw new Error("Attempt to auto-create Media.type"); 288 else if (Configuration.doAutoCreate()) 289 this.type = new Enumeration<DigitalMediaType>(new DigitalMediaTypeEnumFactory()); // bb 290 return this.type; 291 } 292 293 public boolean hasTypeElement() { 294 return this.type != null && !this.type.isEmpty(); 295 } 296 297 public boolean hasType() { 298 return this.type != null && !this.type.isEmpty(); 299 } 300 301 /** 302 * @param value {@link #type} (Whether the media is a photo (still image), an audio recording, or a video recording.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value 303 */ 304 public Media setTypeElement(Enumeration<DigitalMediaType> value) { 305 this.type = value; 306 return this; 307 } 308 309 /** 310 * @return Whether the media is a photo (still image), an audio recording, or a video recording. 311 */ 312 public DigitalMediaType getType() { 313 return this.type == null ? null : this.type.getValue(); 314 } 315 316 /** 317 * @param value Whether the media is a photo (still image), an audio recording, or a video recording. 318 */ 319 public Media setType(DigitalMediaType value) { 320 if (this.type == null) 321 this.type = new Enumeration<DigitalMediaType>(new DigitalMediaTypeEnumFactory()); 322 this.type.setValue(value); 323 return this; 324 } 325 326 /** 327 * @return {@link #subtype} (Details of the type of the media - usually, how it was acquired (what type of device). If images sourced from a DICOM system, are wrapped in a Media resource, then this is the modality.) 328 */ 329 public CodeableConcept getSubtype() { 330 if (this.subtype == null) 331 if (Configuration.errorOnAutoCreate()) 332 throw new Error("Attempt to auto-create Media.subtype"); 333 else if (Configuration.doAutoCreate()) 334 this.subtype = new CodeableConcept(); // cc 335 return this.subtype; 336 } 337 338 public boolean hasSubtype() { 339 return this.subtype != null && !this.subtype.isEmpty(); 340 } 341 342 /** 343 * @param value {@link #subtype} (Details of the type of the media - usually, how it was acquired (what type of device). If images sourced from a DICOM system, are wrapped in a Media resource, then this is the modality.) 344 */ 345 public Media setSubtype(CodeableConcept value) { 346 this.subtype = value; 347 return this; 348 } 349 350 /** 351 * @return {@link #identifier} (Identifiers associated with the image - these may include identifiers for the image itself, identifiers for the context of its collection (e.g. series ids) and context ids such as accession numbers or other workflow identifiers.) 352 */ 353 public List<Identifier> getIdentifier() { 354 if (this.identifier == null) 355 this.identifier = new ArrayList<Identifier>(); 356 return this.identifier; 357 } 358 359 public boolean hasIdentifier() { 360 if (this.identifier == null) 361 return false; 362 for (Identifier item : this.identifier) 363 if (!item.isEmpty()) 364 return true; 365 return false; 366 } 367 368 /** 369 * @return {@link #identifier} (Identifiers associated with the image - these may include identifiers for the image itself, identifiers for the context of its collection (e.g. series ids) and context ids such as accession numbers or other workflow identifiers.) 370 */ 371 // syntactic sugar 372 public Identifier addIdentifier() { //3 373 Identifier t = new Identifier(); 374 if (this.identifier == null) 375 this.identifier = new ArrayList<Identifier>(); 376 this.identifier.add(t); 377 return t; 378 } 379 380 // syntactic sugar 381 public Media addIdentifier(Identifier t) { //3 382 if (t == null) 383 return this; 384 if (this.identifier == null) 385 this.identifier = new ArrayList<Identifier>(); 386 this.identifier.add(t); 387 return this; 388 } 389 390 /** 391 * @return {@link #subject} (Who/What this Media is a record of.) 392 */ 393 public Reference getSubject() { 394 if (this.subject == null) 395 if (Configuration.errorOnAutoCreate()) 396 throw new Error("Attempt to auto-create Media.subject"); 397 else if (Configuration.doAutoCreate()) 398 this.subject = new Reference(); // cc 399 return this.subject; 400 } 401 402 public boolean hasSubject() { 403 return this.subject != null && !this.subject.isEmpty(); 404 } 405 406 /** 407 * @param value {@link #subject} (Who/What this Media is a record of.) 408 */ 409 public Media setSubject(Reference value) { 410 this.subject = value; 411 return this; 412 } 413 414 /** 415 * @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. (Who/What this Media is a record of.) 416 */ 417 public Resource getSubjectTarget() { 418 return this.subjectTarget; 419 } 420 421 /** 422 * @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. (Who/What this Media is a record of.) 423 */ 424 public Media setSubjectTarget(Resource value) { 425 this.subjectTarget = value; 426 return this; 427 } 428 429 /** 430 * @return {@link #operator} (The person who administered the collection of the image.) 431 */ 432 public Reference getOperator() { 433 if (this.operator == null) 434 if (Configuration.errorOnAutoCreate()) 435 throw new Error("Attempt to auto-create Media.operator"); 436 else if (Configuration.doAutoCreate()) 437 this.operator = new Reference(); // cc 438 return this.operator; 439 } 440 441 public boolean hasOperator() { 442 return this.operator != null && !this.operator.isEmpty(); 443 } 444 445 /** 446 * @param value {@link #operator} (The person who administered the collection of the image.) 447 */ 448 public Media setOperator(Reference value) { 449 this.operator = value; 450 return this; 451 } 452 453 /** 454 * @return {@link #operator} 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 who administered the collection of the image.) 455 */ 456 public Practitioner getOperatorTarget() { 457 if (this.operatorTarget == null) 458 if (Configuration.errorOnAutoCreate()) 459 throw new Error("Attempt to auto-create Media.operator"); 460 else if (Configuration.doAutoCreate()) 461 this.operatorTarget = new Practitioner(); // aa 462 return this.operatorTarget; 463 } 464 465 /** 466 * @param value {@link #operator} 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 who administered the collection of the image.) 467 */ 468 public Media setOperatorTarget(Practitioner value) { 469 this.operatorTarget = value; 470 return this; 471 } 472 473 /** 474 * @return {@link #view} (The name of the imaging view e.g. Lateral or Antero-posterior (AP).) 475 */ 476 public CodeableConcept getView() { 477 if (this.view == null) 478 if (Configuration.errorOnAutoCreate()) 479 throw new Error("Attempt to auto-create Media.view"); 480 else if (Configuration.doAutoCreate()) 481 this.view = new CodeableConcept(); // cc 482 return this.view; 483 } 484 485 public boolean hasView() { 486 return this.view != null && !this.view.isEmpty(); 487 } 488 489 /** 490 * @param value {@link #view} (The name of the imaging view e.g. Lateral or Antero-posterior (AP).) 491 */ 492 public Media setView(CodeableConcept value) { 493 this.view = value; 494 return this; 495 } 496 497 /** 498 * @return {@link #deviceName} (The name of the device / manufacturer of the device that was used to make the recording.). This is the underlying object with id, value and extensions. The accessor "getDeviceName" gives direct access to the value 499 */ 500 public StringType getDeviceNameElement() { 501 if (this.deviceName == null) 502 if (Configuration.errorOnAutoCreate()) 503 throw new Error("Attempt to auto-create Media.deviceName"); 504 else if (Configuration.doAutoCreate()) 505 this.deviceName = new StringType(); // bb 506 return this.deviceName; 507 } 508 509 public boolean hasDeviceNameElement() { 510 return this.deviceName != null && !this.deviceName.isEmpty(); 511 } 512 513 public boolean hasDeviceName() { 514 return this.deviceName != null && !this.deviceName.isEmpty(); 515 } 516 517 /** 518 * @param value {@link #deviceName} (The name of the device / manufacturer of the device that was used to make the recording.). This is the underlying object with id, value and extensions. The accessor "getDeviceName" gives direct access to the value 519 */ 520 public Media setDeviceNameElement(StringType value) { 521 this.deviceName = value; 522 return this; 523 } 524 525 /** 526 * @return The name of the device / manufacturer of the device that was used to make the recording. 527 */ 528 public String getDeviceName() { 529 return this.deviceName == null ? null : this.deviceName.getValue(); 530 } 531 532 /** 533 * @param value The name of the device / manufacturer of the device that was used to make the recording. 534 */ 535 public Media setDeviceName(String value) { 536 if (Utilities.noString(value)) 537 this.deviceName = null; 538 else { 539 if (this.deviceName == null) 540 this.deviceName = new StringType(); 541 this.deviceName.setValue(value); 542 } 543 return this; 544 } 545 546 /** 547 * @return {@link #height} (Height of the image in pixels (photo/video).). This is the underlying object with id, value and extensions. The accessor "getHeight" gives direct access to the value 548 */ 549 public PositiveIntType getHeightElement() { 550 if (this.height == null) 551 if (Configuration.errorOnAutoCreate()) 552 throw new Error("Attempt to auto-create Media.height"); 553 else if (Configuration.doAutoCreate()) 554 this.height = new PositiveIntType(); // bb 555 return this.height; 556 } 557 558 public boolean hasHeightElement() { 559 return this.height != null && !this.height.isEmpty(); 560 } 561 562 public boolean hasHeight() { 563 return this.height != null && !this.height.isEmpty(); 564 } 565 566 /** 567 * @param value {@link #height} (Height of the image in pixels (photo/video).). This is the underlying object with id, value and extensions. The accessor "getHeight" gives direct access to the value 568 */ 569 public Media setHeightElement(PositiveIntType value) { 570 this.height = value; 571 return this; 572 } 573 574 /** 575 * @return Height of the image in pixels (photo/video). 576 */ 577 public int getHeight() { 578 return this.height == null || this.height.isEmpty() ? 0 : this.height.getValue(); 579 } 580 581 /** 582 * @param value Height of the image in pixels (photo/video). 583 */ 584 public Media setHeight(int value) { 585 if (this.height == null) 586 this.height = new PositiveIntType(); 587 this.height.setValue(value); 588 return this; 589 } 590 591 /** 592 * @return {@link #width} (Width of the image in pixels (photo/video).). This is the underlying object with id, value and extensions. The accessor "getWidth" gives direct access to the value 593 */ 594 public PositiveIntType getWidthElement() { 595 if (this.width == null) 596 if (Configuration.errorOnAutoCreate()) 597 throw new Error("Attempt to auto-create Media.width"); 598 else if (Configuration.doAutoCreate()) 599 this.width = new PositiveIntType(); // bb 600 return this.width; 601 } 602 603 public boolean hasWidthElement() { 604 return this.width != null && !this.width.isEmpty(); 605 } 606 607 public boolean hasWidth() { 608 return this.width != null && !this.width.isEmpty(); 609 } 610 611 /** 612 * @param value {@link #width} (Width of the image in pixels (photo/video).). This is the underlying object with id, value and extensions. The accessor "getWidth" gives direct access to the value 613 */ 614 public Media setWidthElement(PositiveIntType value) { 615 this.width = value; 616 return this; 617 } 618 619 /** 620 * @return Width of the image in pixels (photo/video). 621 */ 622 public int getWidth() { 623 return this.width == null || this.width.isEmpty() ? 0 : this.width.getValue(); 624 } 625 626 /** 627 * @param value Width of the image in pixels (photo/video). 628 */ 629 public Media setWidth(int value) { 630 if (this.width == null) 631 this.width = new PositiveIntType(); 632 this.width.setValue(value); 633 return this; 634 } 635 636 /** 637 * @return {@link #frames} (The number of frames in a photo. This is used with a multi-page fax, or an imaging acquisition context that takes multiple slices in a single image, or an animated gif. If there is more than one frame, this SHALL have a value in order to alert interface software that a multi-frame capable rendering widget is required.). This is the underlying object with id, value and extensions. The accessor "getFrames" gives direct access to the value 638 */ 639 public PositiveIntType getFramesElement() { 640 if (this.frames == null) 641 if (Configuration.errorOnAutoCreate()) 642 throw new Error("Attempt to auto-create Media.frames"); 643 else if (Configuration.doAutoCreate()) 644 this.frames = new PositiveIntType(); // bb 645 return this.frames; 646 } 647 648 public boolean hasFramesElement() { 649 return this.frames != null && !this.frames.isEmpty(); 650 } 651 652 public boolean hasFrames() { 653 return this.frames != null && !this.frames.isEmpty(); 654 } 655 656 /** 657 * @param value {@link #frames} (The number of frames in a photo. This is used with a multi-page fax, or an imaging acquisition context that takes multiple slices in a single image, or an animated gif. If there is more than one frame, this SHALL have a value in order to alert interface software that a multi-frame capable rendering widget is required.). This is the underlying object with id, value and extensions. The accessor "getFrames" gives direct access to the value 658 */ 659 public Media setFramesElement(PositiveIntType value) { 660 this.frames = value; 661 return this; 662 } 663 664 /** 665 * @return The number of frames in a photo. This is used with a multi-page fax, or an imaging acquisition context that takes multiple slices in a single image, or an animated gif. If there is more than one frame, this SHALL have a value in order to alert interface software that a multi-frame capable rendering widget is required. 666 */ 667 public int getFrames() { 668 return this.frames == null || this.frames.isEmpty() ? 0 : this.frames.getValue(); 669 } 670 671 /** 672 * @param value The number of frames in a photo. This is used with a multi-page fax, or an imaging acquisition context that takes multiple slices in a single image, or an animated gif. If there is more than one frame, this SHALL have a value in order to alert interface software that a multi-frame capable rendering widget is required. 673 */ 674 public Media setFrames(int value) { 675 if (this.frames == null) 676 this.frames = new PositiveIntType(); 677 this.frames.setValue(value); 678 return this; 679 } 680 681 /** 682 * @return {@link #duration} (The duration of the recording in seconds - for audio and video.). This is the underlying object with id, value and extensions. The accessor "getDuration" gives direct access to the value 683 */ 684 public UnsignedIntType getDurationElement() { 685 if (this.duration == null) 686 if (Configuration.errorOnAutoCreate()) 687 throw new Error("Attempt to auto-create Media.duration"); 688 else if (Configuration.doAutoCreate()) 689 this.duration = new UnsignedIntType(); // bb 690 return this.duration; 691 } 692 693 public boolean hasDurationElement() { 694 return this.duration != null && !this.duration.isEmpty(); 695 } 696 697 public boolean hasDuration() { 698 return this.duration != null && !this.duration.isEmpty(); 699 } 700 701 /** 702 * @param value {@link #duration} (The duration of the recording in seconds - for audio and video.). This is the underlying object with id, value and extensions. The accessor "getDuration" gives direct access to the value 703 */ 704 public Media setDurationElement(UnsignedIntType value) { 705 this.duration = value; 706 return this; 707 } 708 709 /** 710 * @return The duration of the recording in seconds - for audio and video. 711 */ 712 public int getDuration() { 713 return this.duration == null || this.duration.isEmpty() ? 0 : this.duration.getValue(); 714 } 715 716 /** 717 * @param value The duration of the recording in seconds - for audio and video. 718 */ 719 public Media setDuration(int value) { 720 if (this.duration == null) 721 this.duration = new UnsignedIntType(); 722 this.duration.setValue(value); 723 return this; 724 } 725 726 /** 727 * @return {@link #content} (The actual content of the media - inline or by direct reference to the media source file.) 728 */ 729 public Attachment getContent() { 730 if (this.content == null) 731 if (Configuration.errorOnAutoCreate()) 732 throw new Error("Attempt to auto-create Media.content"); 733 else if (Configuration.doAutoCreate()) 734 this.content = new Attachment(); // cc 735 return this.content; 736 } 737 738 public boolean hasContent() { 739 return this.content != null && !this.content.isEmpty(); 740 } 741 742 /** 743 * @param value {@link #content} (The actual content of the media - inline or by direct reference to the media source file.) 744 */ 745 public Media setContent(Attachment value) { 746 this.content = value; 747 return this; 748 } 749 750 protected void listChildren(List<Property> childrenList) { 751 super.listChildren(childrenList); 752 childrenList.add(new Property("type", "code", "Whether the media is a photo (still image), an audio recording, or a video recording.", 0, java.lang.Integer.MAX_VALUE, type)); 753 childrenList.add(new Property("subtype", "CodeableConcept", "Details of the type of the media - usually, how it was acquired (what type of device). If images sourced from a DICOM system, are wrapped in a Media resource, then this is the modality.", 0, java.lang.Integer.MAX_VALUE, subtype)); 754 childrenList.add(new Property("identifier", "Identifier", "Identifiers associated with the image - these may include identifiers for the image itself, identifiers for the context of its collection (e.g. series ids) and context ids such as accession numbers or other workflow identifiers.", 0, java.lang.Integer.MAX_VALUE, identifier)); 755 childrenList.add(new Property("subject", "Reference(Patient|Practitioner|Group|Device|Specimen)", "Who/What this Media is a record of.", 0, java.lang.Integer.MAX_VALUE, subject)); 756 childrenList.add(new Property("operator", "Reference(Practitioner)", "The person who administered the collection of the image.", 0, java.lang.Integer.MAX_VALUE, operator)); 757 childrenList.add(new Property("view", "CodeableConcept", "The name of the imaging view e.g. Lateral or Antero-posterior (AP).", 0, java.lang.Integer.MAX_VALUE, view)); 758 childrenList.add(new Property("deviceName", "string", "The name of the device / manufacturer of the device that was used to make the recording.", 0, java.lang.Integer.MAX_VALUE, deviceName)); 759 childrenList.add(new Property("height", "positiveInt", "Height of the image in pixels (photo/video).", 0, java.lang.Integer.MAX_VALUE, height)); 760 childrenList.add(new Property("width", "positiveInt", "Width of the image in pixels (photo/video).", 0, java.lang.Integer.MAX_VALUE, width)); 761 childrenList.add(new Property("frames", "positiveInt", "The number of frames in a photo. This is used with a multi-page fax, or an imaging acquisition context that takes multiple slices in a single image, or an animated gif. If there is more than one frame, this SHALL have a value in order to alert interface software that a multi-frame capable rendering widget is required.", 0, java.lang.Integer.MAX_VALUE, frames)); 762 childrenList.add(new Property("duration", "unsignedInt", "The duration of the recording in seconds - for audio and video.", 0, java.lang.Integer.MAX_VALUE, duration)); 763 childrenList.add(new Property("content", "Attachment", "The actual content of the media - inline or by direct reference to the media source file.", 0, java.lang.Integer.MAX_VALUE, content)); 764 } 765 766 @Override 767 public void setProperty(String name, Base value) throws FHIRException { 768 if (name.equals("type")) 769 this.type = new DigitalMediaTypeEnumFactory().fromType(value); // Enumeration<DigitalMediaType> 770 else if (name.equals("subtype")) 771 this.subtype = castToCodeableConcept(value); // CodeableConcept 772 else if (name.equals("identifier")) 773 this.getIdentifier().add(castToIdentifier(value)); 774 else if (name.equals("subject")) 775 this.subject = castToReference(value); // Reference 776 else if (name.equals("operator")) 777 this.operator = castToReference(value); // Reference 778 else if (name.equals("view")) 779 this.view = castToCodeableConcept(value); // CodeableConcept 780 else if (name.equals("deviceName")) 781 this.deviceName = castToString(value); // StringType 782 else if (name.equals("height")) 783 this.height = castToPositiveInt(value); // PositiveIntType 784 else if (name.equals("width")) 785 this.width = castToPositiveInt(value); // PositiveIntType 786 else if (name.equals("frames")) 787 this.frames = castToPositiveInt(value); // PositiveIntType 788 else if (name.equals("duration")) 789 this.duration = castToUnsignedInt(value); // UnsignedIntType 790 else if (name.equals("content")) 791 this.content = castToAttachment(value); // Attachment 792 else 793 super.setProperty(name, value); 794 } 795 796 @Override 797 public Base addChild(String name) throws FHIRException { 798 if (name.equals("type")) { 799 throw new FHIRException("Cannot call addChild on a primitive type Media.type"); 800 } 801 else if (name.equals("subtype")) { 802 this.subtype = new CodeableConcept(); 803 return this.subtype; 804 } 805 else if (name.equals("identifier")) { 806 return addIdentifier(); 807 } 808 else if (name.equals("subject")) { 809 this.subject = new Reference(); 810 return this.subject; 811 } 812 else if (name.equals("operator")) { 813 this.operator = new Reference(); 814 return this.operator; 815 } 816 else if (name.equals("view")) { 817 this.view = new CodeableConcept(); 818 return this.view; 819 } 820 else if (name.equals("deviceName")) { 821 throw new FHIRException("Cannot call addChild on a primitive type Media.deviceName"); 822 } 823 else if (name.equals("height")) { 824 throw new FHIRException("Cannot call addChild on a primitive type Media.height"); 825 } 826 else if (name.equals("width")) { 827 throw new FHIRException("Cannot call addChild on a primitive type Media.width"); 828 } 829 else if (name.equals("frames")) { 830 throw new FHIRException("Cannot call addChild on a primitive type Media.frames"); 831 } 832 else if (name.equals("duration")) { 833 throw new FHIRException("Cannot call addChild on a primitive type Media.duration"); 834 } 835 else if (name.equals("content")) { 836 this.content = new Attachment(); 837 return this.content; 838 } 839 else 840 return super.addChild(name); 841 } 842 843 public String fhirType() { 844 return "Media"; 845 846 } 847 848 public Media copy() { 849 Media dst = new Media(); 850 copyValues(dst); 851 dst.type = type == null ? null : type.copy(); 852 dst.subtype = subtype == null ? null : subtype.copy(); 853 if (identifier != null) { 854 dst.identifier = new ArrayList<Identifier>(); 855 for (Identifier i : identifier) 856 dst.identifier.add(i.copy()); 857 }; 858 dst.subject = subject == null ? null : subject.copy(); 859 dst.operator = operator == null ? null : operator.copy(); 860 dst.view = view == null ? null : view.copy(); 861 dst.deviceName = deviceName == null ? null : deviceName.copy(); 862 dst.height = height == null ? null : height.copy(); 863 dst.width = width == null ? null : width.copy(); 864 dst.frames = frames == null ? null : frames.copy(); 865 dst.duration = duration == null ? null : duration.copy(); 866 dst.content = content == null ? null : content.copy(); 867 return dst; 868 } 869 870 protected Media typedCopy() { 871 return copy(); 872 } 873 874 @Override 875 public boolean equalsDeep(Base other) { 876 if (!super.equalsDeep(other)) 877 return false; 878 if (!(other instanceof Media)) 879 return false; 880 Media o = (Media) other; 881 return compareDeep(type, o.type, true) && compareDeep(subtype, o.subtype, true) && compareDeep(identifier, o.identifier, true) 882 && compareDeep(subject, o.subject, true) && compareDeep(operator, o.operator, true) && compareDeep(view, o.view, true) 883 && compareDeep(deviceName, o.deviceName, true) && compareDeep(height, o.height, true) && compareDeep(width, o.width, true) 884 && compareDeep(frames, o.frames, true) && compareDeep(duration, o.duration, true) && compareDeep(content, o.content, true) 885 ; 886 } 887 888 @Override 889 public boolean equalsShallow(Base other) { 890 if (!super.equalsShallow(other)) 891 return false; 892 if (!(other instanceof Media)) 893 return false; 894 Media o = (Media) other; 895 return compareValues(type, o.type, true) && compareValues(deviceName, o.deviceName, true) && compareValues(height, o.height, true) 896 && compareValues(width, o.width, true) && compareValues(frames, o.frames, true) && compareValues(duration, o.duration, true) 897 ; 898 } 899 900 public boolean isEmpty() { 901 return super.isEmpty() && (type == null || type.isEmpty()) && (subtype == null || subtype.isEmpty()) 902 && (identifier == null || identifier.isEmpty()) && (subject == null || subject.isEmpty()) 903 && (operator == null || operator.isEmpty()) && (view == null || view.isEmpty()) && (deviceName == null || deviceName.isEmpty()) 904 && (height == null || height.isEmpty()) && (width == null || width.isEmpty()) && (frames == null || frames.isEmpty()) 905 && (duration == null || duration.isEmpty()) && (content == null || content.isEmpty()); 906 } 907 908 @Override 909 public ResourceType getResourceType() { 910 return ResourceType.Media; 911 } 912 913 @SearchParamDefinition(name="identifier", path="Media.identifier", description="Identifier(s) for the image", type="token" ) 914 public static final String SP_IDENTIFIER = "identifier"; 915 @SearchParamDefinition(name="view", path="Media.view", description="Imaging view, e.g. Lateral or Antero-posterior", type="token" ) 916 public static final String SP_VIEW = "view"; 917 @SearchParamDefinition(name="subtype", path="Media.subtype", description="The type of acquisition equipment/process", type="token" ) 918 public static final String SP_SUBTYPE = "subtype"; 919 @SearchParamDefinition(name="created", path="Media.content.creation", description="Date attachment was first created", type="date" ) 920 public static final String SP_CREATED = "created"; 921 @SearchParamDefinition(name="subject", path="Media.subject", description="Who/What this Media is a record of", type="reference" ) 922 public static final String SP_SUBJECT = "subject"; 923 @SearchParamDefinition(name="patient", path="Media.subject", description="Who/What this Media is a record of", type="reference" ) 924 public static final String SP_PATIENT = "patient"; 925 @SearchParamDefinition(name="type", path="Media.type", description="photo | video | audio", type="token" ) 926 public static final String SP_TYPE = "type"; 927 @SearchParamDefinition(name="operator", path="Media.operator", description="The person who generated the image", type="reference" ) 928 public static final String SP_OPERATOR = "operator"; 929 930} 931