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