001package org.hl7.fhir.r4.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Thu, Sep 13, 2018 09:04-0400 for FHIR v3.5.0
033
034import java.util.*;
035
036import java.math.*;
037import org.hl7.fhir.utilities.Utilities;
038import ca.uhn.fhir.model.api.annotation.ResourceDef;
039import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
040import ca.uhn.fhir.model.api.annotation.Child;
041import ca.uhn.fhir.model.api.annotation.ChildOrder;
042import ca.uhn.fhir.model.api.annotation.Description;
043import ca.uhn.fhir.model.api.annotation.Block;
044import org.hl7.fhir.instance.model.api.*;
045import org.hl7.fhir.exceptions.FHIRException;
046/**
047 * A photo, video, or audio recording acquired or used in healthcare. The actual content may be inline or provided by direct reference.
048 */
049@ResourceDef(name="Media", profile="http://hl7.org/fhir/StructureDefinition/Media")
050public class Media extends DomainResource {
051
052    public enum MediaStatus {
053        /**
054         * The core event has not started yet, but some staging activities have begun (e.g. surgical suite preparation).  Preparation stages may be tracked for billing purposes.
055         */
056        PREPARATION, 
057        /**
058         * The event is currently occurring.
059         */
060        INPROGRESS, 
061        /**
062         * The event was terminated prior to any activity beyond preparation.  I.e. The 'main' activity has not yet begun.  The boundary between preparatory and the 'main' activity is context-specific.
063         */
064        NOTDONE, 
065        /**
066         * The event has been temporarily stopped but is expected to resume in the future.
067         */
068        ONHOLD, 
069        /**
070         * The event was terminated prior to the full completion of the intended activity but after at least some of the 'main' activity (beyond preparation) has occurred.
071         */
072        STOPPED, 
073        /**
074         * The event has now concluded.
075         */
076        COMPLETED, 
077        /**
078         * This electronic record should never have existed, though it is possible that real-world decisions were based on it.  (If real-world activity has occurred, the status should be "cancelled" rather than "entered-in-error".).
079         */
080        ENTEREDINERROR, 
081        /**
082         * The authoring system does not know which of the status values currently applies for this request.  Note: This concept is not to be used for "other" - one of the listed statuses is presumed to apply, it's just not known which one.
083         */
084        UNKNOWN, 
085        /**
086         * added to help the parsers with the generic types
087         */
088        NULL;
089        public static MediaStatus fromCode(String codeString) throws FHIRException {
090            if (codeString == null || "".equals(codeString))
091                return null;
092        if ("preparation".equals(codeString))
093          return PREPARATION;
094        if ("in-progress".equals(codeString))
095          return INPROGRESS;
096        if ("not-done".equals(codeString))
097          return NOTDONE;
098        if ("on-hold".equals(codeString))
099          return ONHOLD;
100        if ("stopped".equals(codeString))
101          return STOPPED;
102        if ("completed".equals(codeString))
103          return COMPLETED;
104        if ("entered-in-error".equals(codeString))
105          return ENTEREDINERROR;
106        if ("unknown".equals(codeString))
107          return UNKNOWN;
108        if (Configuration.isAcceptInvalidEnums())
109          return null;
110        else
111          throw new FHIRException("Unknown MediaStatus code '"+codeString+"'");
112        }
113        public String toCode() {
114          switch (this) {
115            case PREPARATION: return "preparation";
116            case INPROGRESS: return "in-progress";
117            case NOTDONE: return "not-done";
118            case ONHOLD: return "on-hold";
119            case STOPPED: return "stopped";
120            case COMPLETED: return "completed";
121            case ENTEREDINERROR: return "entered-in-error";
122            case UNKNOWN: return "unknown";
123            default: return "?";
124          }
125        }
126        public String getSystem() {
127          switch (this) {
128            case PREPARATION: return "http://hl7.org/fhir/event-status";
129            case INPROGRESS: return "http://hl7.org/fhir/event-status";
130            case NOTDONE: return "http://hl7.org/fhir/event-status";
131            case ONHOLD: return "http://hl7.org/fhir/event-status";
132            case STOPPED: return "http://hl7.org/fhir/event-status";
133            case COMPLETED: return "http://hl7.org/fhir/event-status";
134            case ENTEREDINERROR: return "http://hl7.org/fhir/event-status";
135            case UNKNOWN: return "http://hl7.org/fhir/event-status";
136            default: return "?";
137          }
138        }
139        public String getDefinition() {
140          switch (this) {
141            case PREPARATION: return "The core event has not started yet, but some staging activities have begun (e.g. surgical suite preparation).  Preparation stages may be tracked for billing purposes.";
142            case INPROGRESS: return "The event is currently occurring.";
143            case NOTDONE: return "The event was terminated prior to any activity beyond preparation.  I.e. The 'main' activity has not yet begun.  The boundary between preparatory and the 'main' activity is context-specific.";
144            case ONHOLD: return "The event has been temporarily stopped but is expected to resume in the future.";
145            case STOPPED: return "The event was terminated prior to the full completion of the intended activity but after at least some of the 'main' activity (beyond preparation) has occurred.";
146            case COMPLETED: return "The event has now concluded.";
147            case ENTEREDINERROR: return "This electronic record should never have existed, though it is possible that real-world decisions were based on it.  (If real-world activity has occurred, the status should be \"cancelled\" rather than \"entered-in-error\".).";
148            case UNKNOWN: return "The authoring system does not know which of the status values currently applies for this request.  Note: This concept is not to be used for \"other\" - one of the listed statuses is presumed to apply, it's just not known which one.";
149            default: return "?";
150          }
151        }
152        public String getDisplay() {
153          switch (this) {
154            case PREPARATION: return "Preparation";
155            case INPROGRESS: return "In Progress";
156            case NOTDONE: return "Not Done";
157            case ONHOLD: return "On Hold";
158            case STOPPED: return "Stopped";
159            case COMPLETED: return "Completed";
160            case ENTEREDINERROR: return "Entered in Error";
161            case UNKNOWN: return "Unknown";
162            default: return "?";
163          }
164        }
165    }
166
167  public static class MediaStatusEnumFactory implements EnumFactory<MediaStatus> {
168    public MediaStatus fromCode(String codeString) throws IllegalArgumentException {
169      if (codeString == null || "".equals(codeString))
170            if (codeString == null || "".equals(codeString))
171                return null;
172        if ("preparation".equals(codeString))
173          return MediaStatus.PREPARATION;
174        if ("in-progress".equals(codeString))
175          return MediaStatus.INPROGRESS;
176        if ("not-done".equals(codeString))
177          return MediaStatus.NOTDONE;
178        if ("on-hold".equals(codeString))
179          return MediaStatus.ONHOLD;
180        if ("stopped".equals(codeString))
181          return MediaStatus.STOPPED;
182        if ("completed".equals(codeString))
183          return MediaStatus.COMPLETED;
184        if ("entered-in-error".equals(codeString))
185          return MediaStatus.ENTEREDINERROR;
186        if ("unknown".equals(codeString))
187          return MediaStatus.UNKNOWN;
188        throw new IllegalArgumentException("Unknown MediaStatus code '"+codeString+"'");
189        }
190        public Enumeration<MediaStatus> fromType(Base code) throws FHIRException {
191          if (code == null)
192            return null;
193          if (code.isEmpty())
194            return new Enumeration<MediaStatus>(this);
195          String codeString = ((PrimitiveType) code).asStringValue();
196          if (codeString == null || "".equals(codeString))
197            return null;
198        if ("preparation".equals(codeString))
199          return new Enumeration<MediaStatus>(this, MediaStatus.PREPARATION);
200        if ("in-progress".equals(codeString))
201          return new Enumeration<MediaStatus>(this, MediaStatus.INPROGRESS);
202        if ("not-done".equals(codeString))
203          return new Enumeration<MediaStatus>(this, MediaStatus.NOTDONE);
204        if ("on-hold".equals(codeString))
205          return new Enumeration<MediaStatus>(this, MediaStatus.ONHOLD);
206        if ("stopped".equals(codeString))
207          return new Enumeration<MediaStatus>(this, MediaStatus.STOPPED);
208        if ("completed".equals(codeString))
209          return new Enumeration<MediaStatus>(this, MediaStatus.COMPLETED);
210        if ("entered-in-error".equals(codeString))
211          return new Enumeration<MediaStatus>(this, MediaStatus.ENTEREDINERROR);
212        if ("unknown".equals(codeString))
213          return new Enumeration<MediaStatus>(this, MediaStatus.UNKNOWN);
214        throw new FHIRException("Unknown MediaStatus code '"+codeString+"'");
215        }
216    public String toCode(MediaStatus code) {
217      if (code == MediaStatus.PREPARATION)
218        return "preparation";
219      if (code == MediaStatus.INPROGRESS)
220        return "in-progress";
221      if (code == MediaStatus.NOTDONE)
222        return "not-done";
223      if (code == MediaStatus.ONHOLD)
224        return "on-hold";
225      if (code == MediaStatus.STOPPED)
226        return "stopped";
227      if (code == MediaStatus.COMPLETED)
228        return "completed";
229      if (code == MediaStatus.ENTEREDINERROR)
230        return "entered-in-error";
231      if (code == MediaStatus.UNKNOWN)
232        return "unknown";
233      return "?";
234      }
235    public String toSystem(MediaStatus code) {
236      return code.getSystem();
237      }
238    }
239
240    /**
241     * 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.
242     */
243    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
244    @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." )
245    protected List<Identifier> identifier;
246
247    /**
248     * A procedure that is fulfilled in whole or in part by the creation of this media.
249     */
250    @Child(name = "basedOn", type = {ServiceRequest.class, CarePlan.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
251    @Description(shortDefinition="Procedure that caused this media to be created", formalDefinition="A procedure that is fulfilled in whole or in part by the creation of this media." )
252    protected List<Reference> basedOn;
253    /**
254     * The actual objects that are the target of the reference (A procedure that is fulfilled in whole or in part by the creation of this media.)
255     */
256    protected List<Resource> basedOnTarget;
257
258
259    /**
260     * A larger event of which this particular event is a component or step.
261     */
262    @Child(name = "partOf", type = {Reference.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
263    @Description(shortDefinition="Part of referenced event", formalDefinition="A larger event of which this particular event is a component or step." )
264    protected List<Reference> partOf;
265    /**
266     * The actual objects that are the target of the reference (A larger event of which this particular event is a component or step.)
267     */
268    protected List<Resource> partOfTarget;
269
270
271    /**
272     * The current state of the {{title}}.
273     */
274    @Child(name = "status", type = {CodeType.class}, order=3, min=1, max=1, modifier=true, summary=true)
275    @Description(shortDefinition="preparation | in-progress | not-done | suspended | aborted | completed | entered-in-error | unknown", formalDefinition="The current state of the {{title}}." )
276    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/event-status")
277    protected Enumeration<MediaStatus> status;
278
279    /**
280     * A code that classifies whether the media is an image, video or audio recording or some other media category.
281     */
282    @Child(name = "type", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=true)
283    @Description(shortDefinition="Classification of media as image, video, or audio", formalDefinition="A code that classifies whether the media is an image, video or audio recording or some other media category." )
284    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/media-type")
285    protected CodeableConcept type;
286
287    /**
288     * 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.
289     */
290    @Child(name = "modality", type = {CodeableConcept.class}, order=5, min=0, max=1, modifier=false, summary=true)
291    @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." )
292    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/media-modality")
293    protected CodeableConcept modality;
294
295    /**
296     * The name of the imaging view e.g. Lateral or Antero-posterior (AP).
297     */
298    @Child(name = "view", type = {CodeableConcept.class}, order=6, min=0, max=1, modifier=false, summary=true)
299    @Description(shortDefinition="Imaging view, e.g. Lateral or Antero-posterior", formalDefinition="The name of the imaging view e.g. Lateral or Antero-posterior (AP)." )
300    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/media-view")
301    protected CodeableConcept view;
302
303    /**
304     * Who/What this Media is a record of.
305     */
306    @Child(name = "subject", type = {Patient.class, Practitioner.class, Group.class, Device.class, Specimen.class, Location.class}, order=7, min=0, max=1, modifier=false, summary=true)
307    @Description(shortDefinition="Who/What this Media is a record of", formalDefinition="Who/What this Media is a record of." )
308    protected Reference subject;
309
310    /**
311     * The actual object that is the target of the reference (Who/What this Media is a record of.)
312     */
313    protected Resource subjectTarget;
314
315    /**
316     * The encounter or episode of care that establishes the context for this media.
317     */
318    @Child(name = "context", type = {Encounter.class, EpisodeOfCare.class}, order=8, min=0, max=1, modifier=false, summary=true)
319    @Description(shortDefinition="Encounter / Episode associated with media", formalDefinition="The encounter or episode of care that establishes the context for this media." )
320    protected Reference context;
321
322    /**
323     * The actual object that is the target of the reference (The encounter or episode of care that establishes the context for this media.)
324     */
325    protected Resource contextTarget;
326
327    /**
328     * The date and time(s) at which the media was collected.
329     */
330    @Child(name = "created", type = {DateTimeType.class, Period.class}, order=9, min=0, max=1, modifier=false, summary=true)
331    @Description(shortDefinition="When Media was collected", formalDefinition="The date and time(s) at which the media was collected." )
332    protected Type created;
333
334    /**
335     * The date and time this version of the media was made available to providers, typically after having been reviewed.
336     */
337    @Child(name = "issued", type = {InstantType.class}, order=10, min=0, max=1, modifier=false, summary=true)
338    @Description(shortDefinition="Date/Time this version was made available", formalDefinition="The date and time this version of the media was made available to providers, typically after having been reviewed." )
339    protected InstantType issued;
340
341    /**
342     * The person who administered the collection of the image.
343     */
344    @Child(name = "operator", type = {Practitioner.class, PractitionerRole.class, Organization.class, CareTeam.class, Patient.class, Device.class, RelatedPerson.class}, order=11, min=0, max=1, modifier=false, summary=true)
345    @Description(shortDefinition="The person who generated the image", formalDefinition="The person who administered the collection of the image." )
346    protected Reference operator;
347
348    /**
349     * The actual object that is the target of the reference (The person who administered the collection of the image.)
350     */
351    protected Resource operatorTarget;
352
353    /**
354     * Describes why the event occurred in coded or textual form.
355     */
356    @Child(name = "reasonCode", type = {CodeableConcept.class}, order=12, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
357    @Description(shortDefinition="Why was event performed?", formalDefinition="Describes why the event occurred in coded or textual form." )
358    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/procedure-reason")
359    protected List<CodeableConcept> reasonCode;
360
361    /**
362     * Indicates the site on the subject's body where the observation was made (i.e. the target site).
363     */
364    @Child(name = "bodySite", type = {CodeableConcept.class}, order=13, min=0, max=1, modifier=false, summary=true)
365    @Description(shortDefinition="Observed body part", formalDefinition="Indicates the site on the subject's body where the observation was made (i.e. the target site)." )
366    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/body-site")
367    protected CodeableConcept bodySite;
368
369    /**
370     * The name of the device / manufacturer of the device  that was used to make the recording.
371     */
372    @Child(name = "deviceName", type = {StringType.class}, order=14, min=0, max=1, modifier=false, summary=true)
373    @Description(shortDefinition="Name of the device/manufacturer", formalDefinition="The name of the device / manufacturer of the device  that was used to make the recording." )
374    protected StringType deviceName;
375
376    /**
377     * The device used to collect the media.
378     */
379    @Child(name = "device", type = {Device.class, DeviceMetric.class, Device.class}, order=15, min=0, max=1, modifier=false, summary=true)
380    @Description(shortDefinition="Observing Device", formalDefinition="The device used to collect the media." )
381    protected Reference device;
382
383    /**
384     * The actual object that is the target of the reference (The device used to collect the media.)
385     */
386    protected Resource deviceTarget;
387
388    /**
389     * Height of the image in pixels (photo/video).
390     */
391    @Child(name = "height", type = {PositiveIntType.class}, order=16, min=0, max=1, modifier=false, summary=true)
392    @Description(shortDefinition="Height of the image in pixels (photo/video)", formalDefinition="Height of the image in pixels (photo/video)." )
393    protected PositiveIntType height;
394
395    /**
396     * Width of the image in pixels (photo/video).
397     */
398    @Child(name = "width", type = {PositiveIntType.class}, order=17, min=0, max=1, modifier=false, summary=true)
399    @Description(shortDefinition="Width of the image in pixels (photo/video)", formalDefinition="Width of the image in pixels (photo/video)." )
400    protected PositiveIntType width;
401
402    /**
403     * 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.
404     */
405    @Child(name = "frames", type = {PositiveIntType.class}, order=18, min=0, max=1, modifier=false, summary=true)
406    @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." )
407    protected PositiveIntType frames;
408
409    /**
410     * The duration of the recording in seconds - for audio and video.
411     */
412    @Child(name = "duration", type = {DecimalType.class}, order=19, min=0, max=1, modifier=false, summary=true)
413    @Description(shortDefinition="Length in seconds (audio / video)", formalDefinition="The duration of the recording in seconds - for audio and video." )
414    protected DecimalType duration;
415
416    /**
417     * The actual content of the media - inline or by direct reference to the media source file.
418     */
419    @Child(name = "content", type = {Attachment.class}, order=20, min=1, max=1, modifier=false, summary=true)
420    @Description(shortDefinition="Actual Media - reference or data", formalDefinition="The actual content of the media - inline or by direct reference to the media source file." )
421    protected Attachment content;
422
423    /**
424     * Comments made about the media by the performer, subject or other participants.
425     */
426    @Child(name = "note", type = {Annotation.class}, order=21, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
427    @Description(shortDefinition="Comments made about the media", formalDefinition="Comments made about the media by the performer, subject or other participants." )
428    protected List<Annotation> note;
429
430    private static final long serialVersionUID = 413873607L;
431
432  /**
433   * Constructor
434   */
435    public Media() {
436      super();
437    }
438
439  /**
440   * Constructor
441   */
442    public Media(Enumeration<MediaStatus> status, Attachment content) {
443      super();
444      this.status = status;
445      this.content = content;
446    }
447
448    /**
449     * @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.)
450     */
451    public List<Identifier> getIdentifier() { 
452      if (this.identifier == null)
453        this.identifier = new ArrayList<Identifier>();
454      return this.identifier;
455    }
456
457    /**
458     * @return Returns a reference to <code>this</code> for easy method chaining
459     */
460    public Media setIdentifier(List<Identifier> theIdentifier) { 
461      this.identifier = theIdentifier;
462      return this;
463    }
464
465    public boolean hasIdentifier() { 
466      if (this.identifier == null)
467        return false;
468      for (Identifier item : this.identifier)
469        if (!item.isEmpty())
470          return true;
471      return false;
472    }
473
474    public Identifier addIdentifier() { //3
475      Identifier t = new Identifier();
476      if (this.identifier == null)
477        this.identifier = new ArrayList<Identifier>();
478      this.identifier.add(t);
479      return t;
480    }
481
482    public Media addIdentifier(Identifier t) { //3
483      if (t == null)
484        return this;
485      if (this.identifier == null)
486        this.identifier = new ArrayList<Identifier>();
487      this.identifier.add(t);
488      return this;
489    }
490
491    /**
492     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
493     */
494    public Identifier getIdentifierFirstRep() { 
495      if (getIdentifier().isEmpty()) {
496        addIdentifier();
497      }
498      return getIdentifier().get(0);
499    }
500
501    /**
502     * @return {@link #basedOn} (A procedure that is fulfilled in whole or in part by the creation of this media.)
503     */
504    public List<Reference> getBasedOn() { 
505      if (this.basedOn == null)
506        this.basedOn = new ArrayList<Reference>();
507      return this.basedOn;
508    }
509
510    /**
511     * @return Returns a reference to <code>this</code> for easy method chaining
512     */
513    public Media setBasedOn(List<Reference> theBasedOn) { 
514      this.basedOn = theBasedOn;
515      return this;
516    }
517
518    public boolean hasBasedOn() { 
519      if (this.basedOn == null)
520        return false;
521      for (Reference item : this.basedOn)
522        if (!item.isEmpty())
523          return true;
524      return false;
525    }
526
527    public Reference addBasedOn() { //3
528      Reference t = new Reference();
529      if (this.basedOn == null)
530        this.basedOn = new ArrayList<Reference>();
531      this.basedOn.add(t);
532      return t;
533    }
534
535    public Media addBasedOn(Reference t) { //3
536      if (t == null)
537        return this;
538      if (this.basedOn == null)
539        this.basedOn = new ArrayList<Reference>();
540      this.basedOn.add(t);
541      return this;
542    }
543
544    /**
545     * @return The first repetition of repeating field {@link #basedOn}, creating it if it does not already exist
546     */
547    public Reference getBasedOnFirstRep() { 
548      if (getBasedOn().isEmpty()) {
549        addBasedOn();
550      }
551      return getBasedOn().get(0);
552    }
553
554    /**
555     * @deprecated Use Reference#setResource(IBaseResource) instead
556     */
557    @Deprecated
558    public List<Resource> getBasedOnTarget() { 
559      if (this.basedOnTarget == null)
560        this.basedOnTarget = new ArrayList<Resource>();
561      return this.basedOnTarget;
562    }
563
564    /**
565     * @return {@link #partOf} (A larger event of which this particular event is a component or step.)
566     */
567    public List<Reference> getPartOf() { 
568      if (this.partOf == null)
569        this.partOf = new ArrayList<Reference>();
570      return this.partOf;
571    }
572
573    /**
574     * @return Returns a reference to <code>this</code> for easy method chaining
575     */
576    public Media setPartOf(List<Reference> thePartOf) { 
577      this.partOf = thePartOf;
578      return this;
579    }
580
581    public boolean hasPartOf() { 
582      if (this.partOf == null)
583        return false;
584      for (Reference item : this.partOf)
585        if (!item.isEmpty())
586          return true;
587      return false;
588    }
589
590    public Reference addPartOf() { //3
591      Reference t = new Reference();
592      if (this.partOf == null)
593        this.partOf = new ArrayList<Reference>();
594      this.partOf.add(t);
595      return t;
596    }
597
598    public Media addPartOf(Reference t) { //3
599      if (t == null)
600        return this;
601      if (this.partOf == null)
602        this.partOf = new ArrayList<Reference>();
603      this.partOf.add(t);
604      return this;
605    }
606
607    /**
608     * @return The first repetition of repeating field {@link #partOf}, creating it if it does not already exist
609     */
610    public Reference getPartOfFirstRep() { 
611      if (getPartOf().isEmpty()) {
612        addPartOf();
613      }
614      return getPartOf().get(0);
615    }
616
617    /**
618     * @deprecated Use Reference#setResource(IBaseResource) instead
619     */
620    @Deprecated
621    public List<Resource> getPartOfTarget() { 
622      if (this.partOfTarget == null)
623        this.partOfTarget = new ArrayList<Resource>();
624      return this.partOfTarget;
625    }
626
627    /**
628     * @return {@link #status} (The current state of the {{title}}.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
629     */
630    public Enumeration<MediaStatus> getStatusElement() { 
631      if (this.status == null)
632        if (Configuration.errorOnAutoCreate())
633          throw new Error("Attempt to auto-create Media.status");
634        else if (Configuration.doAutoCreate())
635          this.status = new Enumeration<MediaStatus>(new MediaStatusEnumFactory()); // bb
636      return this.status;
637    }
638
639    public boolean hasStatusElement() { 
640      return this.status != null && !this.status.isEmpty();
641    }
642
643    public boolean hasStatus() { 
644      return this.status != null && !this.status.isEmpty();
645    }
646
647    /**
648     * @param value {@link #status} (The current state of the {{title}}.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
649     */
650    public Media setStatusElement(Enumeration<MediaStatus> value) { 
651      this.status = value;
652      return this;
653    }
654
655    /**
656     * @return The current state of the {{title}}.
657     */
658    public MediaStatus getStatus() { 
659      return this.status == null ? null : this.status.getValue();
660    }
661
662    /**
663     * @param value The current state of the {{title}}.
664     */
665    public Media setStatus(MediaStatus value) { 
666        if (this.status == null)
667          this.status = new Enumeration<MediaStatus>(new MediaStatusEnumFactory());
668        this.status.setValue(value);
669      return this;
670    }
671
672    /**
673     * @return {@link #type} (A code that classifies whether the media is an image, video or audio recording or some other media category.)
674     */
675    public CodeableConcept getType() { 
676      if (this.type == null)
677        if (Configuration.errorOnAutoCreate())
678          throw new Error("Attempt to auto-create Media.type");
679        else if (Configuration.doAutoCreate())
680          this.type = new CodeableConcept(); // cc
681      return this.type;
682    }
683
684    public boolean hasType() { 
685      return this.type != null && !this.type.isEmpty();
686    }
687
688    /**
689     * @param value {@link #type} (A code that classifies whether the media is an image, video or audio recording or some other media category.)
690     */
691    public Media setType(CodeableConcept value) { 
692      this.type = value;
693      return this;
694    }
695
696    /**
697     * @return {@link #modality} (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.)
698     */
699    public CodeableConcept getModality() { 
700      if (this.modality == null)
701        if (Configuration.errorOnAutoCreate())
702          throw new Error("Attempt to auto-create Media.modality");
703        else if (Configuration.doAutoCreate())
704          this.modality = new CodeableConcept(); // cc
705      return this.modality;
706    }
707
708    public boolean hasModality() { 
709      return this.modality != null && !this.modality.isEmpty();
710    }
711
712    /**
713     * @param value {@link #modality} (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.)
714     */
715    public Media setModality(CodeableConcept value) { 
716      this.modality = value;
717      return this;
718    }
719
720    /**
721     * @return {@link #view} (The name of the imaging view e.g. Lateral or Antero-posterior (AP).)
722     */
723    public CodeableConcept getView() { 
724      if (this.view == null)
725        if (Configuration.errorOnAutoCreate())
726          throw new Error("Attempt to auto-create Media.view");
727        else if (Configuration.doAutoCreate())
728          this.view = new CodeableConcept(); // cc
729      return this.view;
730    }
731
732    public boolean hasView() { 
733      return this.view != null && !this.view.isEmpty();
734    }
735
736    /**
737     * @param value {@link #view} (The name of the imaging view e.g. Lateral or Antero-posterior (AP).)
738     */
739    public Media setView(CodeableConcept value) { 
740      this.view = value;
741      return this;
742    }
743
744    /**
745     * @return {@link #subject} (Who/What this Media is a record of.)
746     */
747    public Reference getSubject() { 
748      if (this.subject == null)
749        if (Configuration.errorOnAutoCreate())
750          throw new Error("Attempt to auto-create Media.subject");
751        else if (Configuration.doAutoCreate())
752          this.subject = new Reference(); // cc
753      return this.subject;
754    }
755
756    public boolean hasSubject() { 
757      return this.subject != null && !this.subject.isEmpty();
758    }
759
760    /**
761     * @param value {@link #subject} (Who/What this Media is a record of.)
762     */
763    public Media setSubject(Reference value) { 
764      this.subject = value;
765      return this;
766    }
767
768    /**
769     * @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.)
770     */
771    public Resource getSubjectTarget() { 
772      return this.subjectTarget;
773    }
774
775    /**
776     * @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.)
777     */
778    public Media setSubjectTarget(Resource value) { 
779      this.subjectTarget = value;
780      return this;
781    }
782
783    /**
784     * @return {@link #context} (The encounter or episode of care that establishes the context for this media.)
785     */
786    public Reference getContext() { 
787      if (this.context == null)
788        if (Configuration.errorOnAutoCreate())
789          throw new Error("Attempt to auto-create Media.context");
790        else if (Configuration.doAutoCreate())
791          this.context = new Reference(); // cc
792      return this.context;
793    }
794
795    public boolean hasContext() { 
796      return this.context != null && !this.context.isEmpty();
797    }
798
799    /**
800     * @param value {@link #context} (The encounter or episode of care that establishes the context for this media.)
801     */
802    public Media setContext(Reference value) { 
803      this.context = value;
804      return this;
805    }
806
807    /**
808     * @return {@link #context} 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 encounter or episode of care that establishes the context for this media.)
809     */
810    public Resource getContextTarget() { 
811      return this.contextTarget;
812    }
813
814    /**
815     * @param value {@link #context} 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 encounter or episode of care that establishes the context for this media.)
816     */
817    public Media setContextTarget(Resource value) { 
818      this.contextTarget = value;
819      return this;
820    }
821
822    /**
823     * @return {@link #created} (The date and time(s) at which the media was collected.)
824     */
825    public Type getCreated() { 
826      return this.created;
827    }
828
829    /**
830     * @return {@link #created} (The date and time(s) at which the media was collected.)
831     */
832    public DateTimeType getCreatedDateTimeType() throws FHIRException { 
833      if (this.created == null)
834        return null;
835      if (!(this.created instanceof DateTimeType))
836        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.created.getClass().getName()+" was encountered");
837      return (DateTimeType) this.created;
838    }
839
840    public boolean hasCreatedDateTimeType() { 
841      return this != null && this.created instanceof DateTimeType;
842    }
843
844    /**
845     * @return {@link #created} (The date and time(s) at which the media was collected.)
846     */
847    public Period getCreatedPeriod() throws FHIRException { 
848      if (this.created == null)
849        return null;
850      if (!(this.created instanceof Period))
851        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.created.getClass().getName()+" was encountered");
852      return (Period) this.created;
853    }
854
855    public boolean hasCreatedPeriod() { 
856      return this != null && this.created instanceof Period;
857    }
858
859    public boolean hasCreated() { 
860      return this.created != null && !this.created.isEmpty();
861    }
862
863    /**
864     * @param value {@link #created} (The date and time(s) at which the media was collected.)
865     */
866    public Media setCreated(Type value) { 
867      if (value != null && !(value instanceof DateTimeType || value instanceof Period))
868        throw new Error("Not the right type for Media.created[x]: "+value.fhirType());
869      this.created = value;
870      return this;
871    }
872
873    /**
874     * @return {@link #issued} (The date and time this version of the media was made available to providers, typically after having been reviewed.). This is the underlying object with id, value and extensions. The accessor "getIssued" gives direct access to the value
875     */
876    public InstantType getIssuedElement() { 
877      if (this.issued == null)
878        if (Configuration.errorOnAutoCreate())
879          throw new Error("Attempt to auto-create Media.issued");
880        else if (Configuration.doAutoCreate())
881          this.issued = new InstantType(); // bb
882      return this.issued;
883    }
884
885    public boolean hasIssuedElement() { 
886      return this.issued != null && !this.issued.isEmpty();
887    }
888
889    public boolean hasIssued() { 
890      return this.issued != null && !this.issued.isEmpty();
891    }
892
893    /**
894     * @param value {@link #issued} (The date and time this version of the media was made available to providers, typically after having been reviewed.). This is the underlying object with id, value and extensions. The accessor "getIssued" gives direct access to the value
895     */
896    public Media setIssuedElement(InstantType value) { 
897      this.issued = value;
898      return this;
899    }
900
901    /**
902     * @return The date and time this version of the media was made available to providers, typically after having been reviewed.
903     */
904    public Date getIssued() { 
905      return this.issued == null ? null : this.issued.getValue();
906    }
907
908    /**
909     * @param value The date and time this version of the media was made available to providers, typically after having been reviewed.
910     */
911    public Media setIssued(Date value) { 
912      if (value == null)
913        this.issued = null;
914      else {
915        if (this.issued == null)
916          this.issued = new InstantType();
917        this.issued.setValue(value);
918      }
919      return this;
920    }
921
922    /**
923     * @return {@link #operator} (The person who administered the collection of the image.)
924     */
925    public Reference getOperator() { 
926      if (this.operator == null)
927        if (Configuration.errorOnAutoCreate())
928          throw new Error("Attempt to auto-create Media.operator");
929        else if (Configuration.doAutoCreate())
930          this.operator = new Reference(); // cc
931      return this.operator;
932    }
933
934    public boolean hasOperator() { 
935      return this.operator != null && !this.operator.isEmpty();
936    }
937
938    /**
939     * @param value {@link #operator} (The person who administered the collection of the image.)
940     */
941    public Media setOperator(Reference value) { 
942      this.operator = value;
943      return this;
944    }
945
946    /**
947     * @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.)
948     */
949    public Resource getOperatorTarget() { 
950      return this.operatorTarget;
951    }
952
953    /**
954     * @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.)
955     */
956    public Media setOperatorTarget(Resource value) { 
957      this.operatorTarget = value;
958      return this;
959    }
960
961    /**
962     * @return {@link #reasonCode} (Describes why the event occurred in coded or textual form.)
963     */
964    public List<CodeableConcept> getReasonCode() { 
965      if (this.reasonCode == null)
966        this.reasonCode = new ArrayList<CodeableConcept>();
967      return this.reasonCode;
968    }
969
970    /**
971     * @return Returns a reference to <code>this</code> for easy method chaining
972     */
973    public Media setReasonCode(List<CodeableConcept> theReasonCode) { 
974      this.reasonCode = theReasonCode;
975      return this;
976    }
977
978    public boolean hasReasonCode() { 
979      if (this.reasonCode == null)
980        return false;
981      for (CodeableConcept item : this.reasonCode)
982        if (!item.isEmpty())
983          return true;
984      return false;
985    }
986
987    public CodeableConcept addReasonCode() { //3
988      CodeableConcept t = new CodeableConcept();
989      if (this.reasonCode == null)
990        this.reasonCode = new ArrayList<CodeableConcept>();
991      this.reasonCode.add(t);
992      return t;
993    }
994
995    public Media addReasonCode(CodeableConcept t) { //3
996      if (t == null)
997        return this;
998      if (this.reasonCode == null)
999        this.reasonCode = new ArrayList<CodeableConcept>();
1000      this.reasonCode.add(t);
1001      return this;
1002    }
1003
1004    /**
1005     * @return The first repetition of repeating field {@link #reasonCode}, creating it if it does not already exist
1006     */
1007    public CodeableConcept getReasonCodeFirstRep() { 
1008      if (getReasonCode().isEmpty()) {
1009        addReasonCode();
1010      }
1011      return getReasonCode().get(0);
1012    }
1013
1014    /**
1015     * @return {@link #bodySite} (Indicates the site on the subject's body where the observation was made (i.e. the target site).)
1016     */
1017    public CodeableConcept getBodySite() { 
1018      if (this.bodySite == null)
1019        if (Configuration.errorOnAutoCreate())
1020          throw new Error("Attempt to auto-create Media.bodySite");
1021        else if (Configuration.doAutoCreate())
1022          this.bodySite = new CodeableConcept(); // cc
1023      return this.bodySite;
1024    }
1025
1026    public boolean hasBodySite() { 
1027      return this.bodySite != null && !this.bodySite.isEmpty();
1028    }
1029
1030    /**
1031     * @param value {@link #bodySite} (Indicates the site on the subject's body where the observation was made (i.e. the target site).)
1032     */
1033    public Media setBodySite(CodeableConcept value) { 
1034      this.bodySite = value;
1035      return this;
1036    }
1037
1038    /**
1039     * @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
1040     */
1041    public StringType getDeviceNameElement() { 
1042      if (this.deviceName == null)
1043        if (Configuration.errorOnAutoCreate())
1044          throw new Error("Attempt to auto-create Media.deviceName");
1045        else if (Configuration.doAutoCreate())
1046          this.deviceName = new StringType(); // bb
1047      return this.deviceName;
1048    }
1049
1050    public boolean hasDeviceNameElement() { 
1051      return this.deviceName != null && !this.deviceName.isEmpty();
1052    }
1053
1054    public boolean hasDeviceName() { 
1055      return this.deviceName != null && !this.deviceName.isEmpty();
1056    }
1057
1058    /**
1059     * @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
1060     */
1061    public Media setDeviceNameElement(StringType value) { 
1062      this.deviceName = value;
1063      return this;
1064    }
1065
1066    /**
1067     * @return The name of the device / manufacturer of the device  that was used to make the recording.
1068     */
1069    public String getDeviceName() { 
1070      return this.deviceName == null ? null : this.deviceName.getValue();
1071    }
1072
1073    /**
1074     * @param value The name of the device / manufacturer of the device  that was used to make the recording.
1075     */
1076    public Media setDeviceName(String value) { 
1077      if (Utilities.noString(value))
1078        this.deviceName = null;
1079      else {
1080        if (this.deviceName == null)
1081          this.deviceName = new StringType();
1082        this.deviceName.setValue(value);
1083      }
1084      return this;
1085    }
1086
1087    /**
1088     * @return {@link #device} (The device used to collect the media.)
1089     */
1090    public Reference getDevice() { 
1091      if (this.device == null)
1092        if (Configuration.errorOnAutoCreate())
1093          throw new Error("Attempt to auto-create Media.device");
1094        else if (Configuration.doAutoCreate())
1095          this.device = new Reference(); // cc
1096      return this.device;
1097    }
1098
1099    public boolean hasDevice() { 
1100      return this.device != null && !this.device.isEmpty();
1101    }
1102
1103    /**
1104     * @param value {@link #device} (The device used to collect the media.)
1105     */
1106    public Media setDevice(Reference value) { 
1107      this.device = value;
1108      return this;
1109    }
1110
1111    /**
1112     * @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 device used to collect the media.)
1113     */
1114    public Resource getDeviceTarget() { 
1115      return this.deviceTarget;
1116    }
1117
1118    /**
1119     * @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 device used to collect the media.)
1120     */
1121    public Media setDeviceTarget(Resource value) { 
1122      this.deviceTarget = value;
1123      return this;
1124    }
1125
1126    /**
1127     * @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
1128     */
1129    public PositiveIntType getHeightElement() { 
1130      if (this.height == null)
1131        if (Configuration.errorOnAutoCreate())
1132          throw new Error("Attempt to auto-create Media.height");
1133        else if (Configuration.doAutoCreate())
1134          this.height = new PositiveIntType(); // bb
1135      return this.height;
1136    }
1137
1138    public boolean hasHeightElement() { 
1139      return this.height != null && !this.height.isEmpty();
1140    }
1141
1142    public boolean hasHeight() { 
1143      return this.height != null && !this.height.isEmpty();
1144    }
1145
1146    /**
1147     * @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
1148     */
1149    public Media setHeightElement(PositiveIntType value) { 
1150      this.height = value;
1151      return this;
1152    }
1153
1154    /**
1155     * @return Height of the image in pixels (photo/video).
1156     */
1157    public int getHeight() { 
1158      return this.height == null || this.height.isEmpty() ? 0 : this.height.getValue();
1159    }
1160
1161    /**
1162     * @param value Height of the image in pixels (photo/video).
1163     */
1164    public Media setHeight(int value) { 
1165        if (this.height == null)
1166          this.height = new PositiveIntType();
1167        this.height.setValue(value);
1168      return this;
1169    }
1170
1171    /**
1172     * @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
1173     */
1174    public PositiveIntType getWidthElement() { 
1175      if (this.width == null)
1176        if (Configuration.errorOnAutoCreate())
1177          throw new Error("Attempt to auto-create Media.width");
1178        else if (Configuration.doAutoCreate())
1179          this.width = new PositiveIntType(); // bb
1180      return this.width;
1181    }
1182
1183    public boolean hasWidthElement() { 
1184      return this.width != null && !this.width.isEmpty();
1185    }
1186
1187    public boolean hasWidth() { 
1188      return this.width != null && !this.width.isEmpty();
1189    }
1190
1191    /**
1192     * @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
1193     */
1194    public Media setWidthElement(PositiveIntType value) { 
1195      this.width = value;
1196      return this;
1197    }
1198
1199    /**
1200     * @return Width of the image in pixels (photo/video).
1201     */
1202    public int getWidth() { 
1203      return this.width == null || this.width.isEmpty() ? 0 : this.width.getValue();
1204    }
1205
1206    /**
1207     * @param value Width of the image in pixels (photo/video).
1208     */
1209    public Media setWidth(int value) { 
1210        if (this.width == null)
1211          this.width = new PositiveIntType();
1212        this.width.setValue(value);
1213      return this;
1214    }
1215
1216    /**
1217     * @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
1218     */
1219    public PositiveIntType getFramesElement() { 
1220      if (this.frames == null)
1221        if (Configuration.errorOnAutoCreate())
1222          throw new Error("Attempt to auto-create Media.frames");
1223        else if (Configuration.doAutoCreate())
1224          this.frames = new PositiveIntType(); // bb
1225      return this.frames;
1226    }
1227
1228    public boolean hasFramesElement() { 
1229      return this.frames != null && !this.frames.isEmpty();
1230    }
1231
1232    public boolean hasFrames() { 
1233      return this.frames != null && !this.frames.isEmpty();
1234    }
1235
1236    /**
1237     * @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
1238     */
1239    public Media setFramesElement(PositiveIntType value) { 
1240      this.frames = value;
1241      return this;
1242    }
1243
1244    /**
1245     * @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.
1246     */
1247    public int getFrames() { 
1248      return this.frames == null || this.frames.isEmpty() ? 0 : this.frames.getValue();
1249    }
1250
1251    /**
1252     * @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.
1253     */
1254    public Media setFrames(int value) { 
1255        if (this.frames == null)
1256          this.frames = new PositiveIntType();
1257        this.frames.setValue(value);
1258      return this;
1259    }
1260
1261    /**
1262     * @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
1263     */
1264    public DecimalType getDurationElement() { 
1265      if (this.duration == null)
1266        if (Configuration.errorOnAutoCreate())
1267          throw new Error("Attempt to auto-create Media.duration");
1268        else if (Configuration.doAutoCreate())
1269          this.duration = new DecimalType(); // bb
1270      return this.duration;
1271    }
1272
1273    public boolean hasDurationElement() { 
1274      return this.duration != null && !this.duration.isEmpty();
1275    }
1276
1277    public boolean hasDuration() { 
1278      return this.duration != null && !this.duration.isEmpty();
1279    }
1280
1281    /**
1282     * @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
1283     */
1284    public Media setDurationElement(DecimalType value) { 
1285      this.duration = value;
1286      return this;
1287    }
1288
1289    /**
1290     * @return The duration of the recording in seconds - for audio and video.
1291     */
1292    public BigDecimal getDuration() { 
1293      return this.duration == null ? null : this.duration.getValue();
1294    }
1295
1296    /**
1297     * @param value The duration of the recording in seconds - for audio and video.
1298     */
1299    public Media setDuration(BigDecimal value) { 
1300      if (value == null)
1301        this.duration = null;
1302      else {
1303        if (this.duration == null)
1304          this.duration = new DecimalType();
1305        this.duration.setValue(value);
1306      }
1307      return this;
1308    }
1309
1310    /**
1311     * @param value The duration of the recording in seconds - for audio and video.
1312     */
1313    public Media setDuration(long value) { 
1314          this.duration = new DecimalType();
1315        this.duration.setValue(value);
1316      return this;
1317    }
1318
1319    /**
1320     * @param value The duration of the recording in seconds - for audio and video.
1321     */
1322    public Media setDuration(double value) { 
1323          this.duration = new DecimalType();
1324        this.duration.setValue(value);
1325      return this;
1326    }
1327
1328    /**
1329     * @return {@link #content} (The actual content of the media - inline or by direct reference to the media source file.)
1330     */
1331    public Attachment getContent() { 
1332      if (this.content == null)
1333        if (Configuration.errorOnAutoCreate())
1334          throw new Error("Attempt to auto-create Media.content");
1335        else if (Configuration.doAutoCreate())
1336          this.content = new Attachment(); // cc
1337      return this.content;
1338    }
1339
1340    public boolean hasContent() { 
1341      return this.content != null && !this.content.isEmpty();
1342    }
1343
1344    /**
1345     * @param value {@link #content} (The actual content of the media - inline or by direct reference to the media source file.)
1346     */
1347    public Media setContent(Attachment value) { 
1348      this.content = value;
1349      return this;
1350    }
1351
1352    /**
1353     * @return {@link #note} (Comments made about the media by the performer, subject or other participants.)
1354     */
1355    public List<Annotation> getNote() { 
1356      if (this.note == null)
1357        this.note = new ArrayList<Annotation>();
1358      return this.note;
1359    }
1360
1361    /**
1362     * @return Returns a reference to <code>this</code> for easy method chaining
1363     */
1364    public Media setNote(List<Annotation> theNote) { 
1365      this.note = theNote;
1366      return this;
1367    }
1368
1369    public boolean hasNote() { 
1370      if (this.note == null)
1371        return false;
1372      for (Annotation item : this.note)
1373        if (!item.isEmpty())
1374          return true;
1375      return false;
1376    }
1377
1378    public Annotation addNote() { //3
1379      Annotation t = new Annotation();
1380      if (this.note == null)
1381        this.note = new ArrayList<Annotation>();
1382      this.note.add(t);
1383      return t;
1384    }
1385
1386    public Media addNote(Annotation t) { //3
1387      if (t == null)
1388        return this;
1389      if (this.note == null)
1390        this.note = new ArrayList<Annotation>();
1391      this.note.add(t);
1392      return this;
1393    }
1394
1395    /**
1396     * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist
1397     */
1398    public Annotation getNoteFirstRep() { 
1399      if (getNote().isEmpty()) {
1400        addNote();
1401      }
1402      return getNote().get(0);
1403    }
1404
1405      protected void listChildren(List<Property> children) {
1406        super.listChildren(children);
1407        children.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));
1408        children.add(new Property("basedOn", "Reference(ServiceRequest|CarePlan)", "A procedure that is fulfilled in whole or in part by the creation of this media.", 0, java.lang.Integer.MAX_VALUE, basedOn));
1409        children.add(new Property("partOf", "Reference(Any)", "A larger event of which this particular event is a component or step.", 0, java.lang.Integer.MAX_VALUE, partOf));
1410        children.add(new Property("status", "code", "The current state of the {{title}}.", 0, 1, status));
1411        children.add(new Property("type", "CodeableConcept", "A code that classifies whether the media is an image, video or audio recording or some other media category.", 0, 1, type));
1412        children.add(new Property("modality", "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, 1, modality));
1413        children.add(new Property("view", "CodeableConcept", "The name of the imaging view e.g. Lateral or Antero-posterior (AP).", 0, 1, view));
1414        children.add(new Property("subject", "Reference(Patient|Practitioner|Group|Device|Specimen|Location)", "Who/What this Media is a record of.", 0, 1, subject));
1415        children.add(new Property("context", "Reference(Encounter|EpisodeOfCare)", "The encounter or episode of care that establishes the context for this media.", 0, 1, context));
1416        children.add(new Property("created[x]", "dateTime|Period", "The date and time(s) at which the media was collected.", 0, 1, created));
1417        children.add(new Property("issued", "instant", "The date and time this version of the media was made available to providers, typically after having been reviewed.", 0, 1, issued));
1418        children.add(new Property("operator", "Reference(Practitioner|PractitionerRole|Organization|CareTeam|Patient|Device|RelatedPerson)", "The person who administered the collection of the image.", 0, 1, operator));
1419        children.add(new Property("reasonCode", "CodeableConcept", "Describes why the event occurred in coded or textual form.", 0, java.lang.Integer.MAX_VALUE, reasonCode));
1420        children.add(new Property("bodySite", "CodeableConcept", "Indicates the site on the subject's body where the observation was made (i.e. the target site).", 0, 1, bodySite));
1421        children.add(new Property("deviceName", "string", "The name of the device / manufacturer of the device  that was used to make the recording.", 0, 1, deviceName));
1422        children.add(new Property("device", "Reference(Device|DeviceMetric|Device)", "The device used to collect the media.", 0, 1, device));
1423        children.add(new Property("height", "positiveInt", "Height of the image in pixels (photo/video).", 0, 1, height));
1424        children.add(new Property("width", "positiveInt", "Width of the image in pixels (photo/video).", 0, 1, width));
1425        children.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, 1, frames));
1426        children.add(new Property("duration", "decimal", "The duration of the recording in seconds - for audio and video.", 0, 1, duration));
1427        children.add(new Property("content", "Attachment", "The actual content of the media - inline or by direct reference to the media source file.", 0, 1, content));
1428        children.add(new Property("note", "Annotation", "Comments made about the media by the performer, subject or other participants.", 0, java.lang.Integer.MAX_VALUE, note));
1429      }
1430
1431      @Override
1432      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1433        switch (_hash) {
1434        case -1618432855: /*identifier*/  return 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);
1435        case -332612366: /*basedOn*/  return new Property("basedOn", "Reference(ServiceRequest|CarePlan)", "A procedure that is fulfilled in whole or in part by the creation of this media.", 0, java.lang.Integer.MAX_VALUE, basedOn);
1436        case -995410646: /*partOf*/  return new Property("partOf", "Reference(Any)", "A larger event of which this particular event is a component or step.", 0, java.lang.Integer.MAX_VALUE, partOf);
1437        case -892481550: /*status*/  return new Property("status", "code", "The current state of the {{title}}.", 0, 1, status);
1438        case 3575610: /*type*/  return new Property("type", "CodeableConcept", "A code that classifies whether the media is an image, video or audio recording or some other media category.", 0, 1, type);
1439        case -622722335: /*modality*/  return new Property("modality", "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, 1, modality);
1440        case 3619493: /*view*/  return new Property("view", "CodeableConcept", "The name of the imaging view e.g. Lateral or Antero-posterior (AP).", 0, 1, view);
1441        case -1867885268: /*subject*/  return new Property("subject", "Reference(Patient|Practitioner|Group|Device|Specimen|Location)", "Who/What this Media is a record of.", 0, 1, subject);
1442        case 951530927: /*context*/  return new Property("context", "Reference(Encounter|EpisodeOfCare)", "The encounter or episode of care that establishes the context for this media.", 0, 1, context);
1443        case 1369676952: /*created[x]*/  return new Property("created[x]", "dateTime|Period", "The date and time(s) at which the media was collected.", 0, 1, created);
1444        case 1028554472: /*created*/  return new Property("created[x]", "dateTime|Period", "The date and time(s) at which the media was collected.", 0, 1, created);
1445        case -1968526685: /*createdDateTime*/  return new Property("created[x]", "dateTime|Period", "The date and time(s) at which the media was collected.", 0, 1, created);
1446        case 1525027529: /*createdPeriod*/  return new Property("created[x]", "dateTime|Period", "The date and time(s) at which the media was collected.", 0, 1, created);
1447        case -1179159893: /*issued*/  return new Property("issued", "instant", "The date and time this version of the media was made available to providers, typically after having been reviewed.", 0, 1, issued);
1448        case -500553564: /*operator*/  return new Property("operator", "Reference(Practitioner|PractitionerRole|Organization|CareTeam|Patient|Device|RelatedPerson)", "The person who administered the collection of the image.", 0, 1, operator);
1449        case 722137681: /*reasonCode*/  return new Property("reasonCode", "CodeableConcept", "Describes why the event occurred in coded or textual form.", 0, java.lang.Integer.MAX_VALUE, reasonCode);
1450        case 1702620169: /*bodySite*/  return new Property("bodySite", "CodeableConcept", "Indicates the site on the subject's body where the observation was made (i.e. the target site).", 0, 1, bodySite);
1451        case 780988929: /*deviceName*/  return new Property("deviceName", "string", "The name of the device / manufacturer of the device  that was used to make the recording.", 0, 1, deviceName);
1452        case -1335157162: /*device*/  return new Property("device", "Reference(Device|DeviceMetric|Device)", "The device used to collect the media.", 0, 1, device);
1453        case -1221029593: /*height*/  return new Property("height", "positiveInt", "Height of the image in pixels (photo/video).", 0, 1, height);
1454        case 113126854: /*width*/  return new Property("width", "positiveInt", "Width of the image in pixels (photo/video).", 0, 1, width);
1455        case -1266514778: /*frames*/  return 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, 1, frames);
1456        case -1992012396: /*duration*/  return new Property("duration", "decimal", "The duration of the recording in seconds - for audio and video.", 0, 1, duration);
1457        case 951530617: /*content*/  return new Property("content", "Attachment", "The actual content of the media - inline or by direct reference to the media source file.", 0, 1, content);
1458        case 3387378: /*note*/  return new Property("note", "Annotation", "Comments made about the media by the performer, subject or other participants.", 0, java.lang.Integer.MAX_VALUE, note);
1459        default: return super.getNamedProperty(_hash, _name, _checkValid);
1460        }
1461
1462      }
1463
1464      @Override
1465      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1466        switch (hash) {
1467        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1468        case -332612366: /*basedOn*/ return this.basedOn == null ? new Base[0] : this.basedOn.toArray(new Base[this.basedOn.size()]); // Reference
1469        case -995410646: /*partOf*/ return this.partOf == null ? new Base[0] : this.partOf.toArray(new Base[this.partOf.size()]); // Reference
1470        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<MediaStatus>
1471        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
1472        case -622722335: /*modality*/ return this.modality == null ? new Base[0] : new Base[] {this.modality}; // CodeableConcept
1473        case 3619493: /*view*/ return this.view == null ? new Base[0] : new Base[] {this.view}; // CodeableConcept
1474        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
1475        case 951530927: /*context*/ return this.context == null ? new Base[0] : new Base[] {this.context}; // Reference
1476        case 1028554472: /*created*/ return this.created == null ? new Base[0] : new Base[] {this.created}; // Type
1477        case -1179159893: /*issued*/ return this.issued == null ? new Base[0] : new Base[] {this.issued}; // InstantType
1478        case -500553564: /*operator*/ return this.operator == null ? new Base[0] : new Base[] {this.operator}; // Reference
1479        case 722137681: /*reasonCode*/ return this.reasonCode == null ? new Base[0] : this.reasonCode.toArray(new Base[this.reasonCode.size()]); // CodeableConcept
1480        case 1702620169: /*bodySite*/ return this.bodySite == null ? new Base[0] : new Base[] {this.bodySite}; // CodeableConcept
1481        case 780988929: /*deviceName*/ return this.deviceName == null ? new Base[0] : new Base[] {this.deviceName}; // StringType
1482        case -1335157162: /*device*/ return this.device == null ? new Base[0] : new Base[] {this.device}; // Reference
1483        case -1221029593: /*height*/ return this.height == null ? new Base[0] : new Base[] {this.height}; // PositiveIntType
1484        case 113126854: /*width*/ return this.width == null ? new Base[0] : new Base[] {this.width}; // PositiveIntType
1485        case -1266514778: /*frames*/ return this.frames == null ? new Base[0] : new Base[] {this.frames}; // PositiveIntType
1486        case -1992012396: /*duration*/ return this.duration == null ? new Base[0] : new Base[] {this.duration}; // DecimalType
1487        case 951530617: /*content*/ return this.content == null ? new Base[0] : new Base[] {this.content}; // Attachment
1488        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
1489        default: return super.getProperty(hash, name, checkValid);
1490        }
1491
1492      }
1493
1494      @Override
1495      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1496        switch (hash) {
1497        case -1618432855: // identifier
1498          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1499          return value;
1500        case -332612366: // basedOn
1501          this.getBasedOn().add(castToReference(value)); // Reference
1502          return value;
1503        case -995410646: // partOf
1504          this.getPartOf().add(castToReference(value)); // Reference
1505          return value;
1506        case -892481550: // status
1507          value = new MediaStatusEnumFactory().fromType(castToCode(value));
1508          this.status = (Enumeration) value; // Enumeration<MediaStatus>
1509          return value;
1510        case 3575610: // type
1511          this.type = castToCodeableConcept(value); // CodeableConcept
1512          return value;
1513        case -622722335: // modality
1514          this.modality = castToCodeableConcept(value); // CodeableConcept
1515          return value;
1516        case 3619493: // view
1517          this.view = castToCodeableConcept(value); // CodeableConcept
1518          return value;
1519        case -1867885268: // subject
1520          this.subject = castToReference(value); // Reference
1521          return value;
1522        case 951530927: // context
1523          this.context = castToReference(value); // Reference
1524          return value;
1525        case 1028554472: // created
1526          this.created = castToType(value); // Type
1527          return value;
1528        case -1179159893: // issued
1529          this.issued = castToInstant(value); // InstantType
1530          return value;
1531        case -500553564: // operator
1532          this.operator = castToReference(value); // Reference
1533          return value;
1534        case 722137681: // reasonCode
1535          this.getReasonCode().add(castToCodeableConcept(value)); // CodeableConcept
1536          return value;
1537        case 1702620169: // bodySite
1538          this.bodySite = castToCodeableConcept(value); // CodeableConcept
1539          return value;
1540        case 780988929: // deviceName
1541          this.deviceName = castToString(value); // StringType
1542          return value;
1543        case -1335157162: // device
1544          this.device = castToReference(value); // Reference
1545          return value;
1546        case -1221029593: // height
1547          this.height = castToPositiveInt(value); // PositiveIntType
1548          return value;
1549        case 113126854: // width
1550          this.width = castToPositiveInt(value); // PositiveIntType
1551          return value;
1552        case -1266514778: // frames
1553          this.frames = castToPositiveInt(value); // PositiveIntType
1554          return value;
1555        case -1992012396: // duration
1556          this.duration = castToDecimal(value); // DecimalType
1557          return value;
1558        case 951530617: // content
1559          this.content = castToAttachment(value); // Attachment
1560          return value;
1561        case 3387378: // note
1562          this.getNote().add(castToAnnotation(value)); // Annotation
1563          return value;
1564        default: return super.setProperty(hash, name, value);
1565        }
1566
1567      }
1568
1569      @Override
1570      public Base setProperty(String name, Base value) throws FHIRException {
1571        if (name.equals("identifier")) {
1572          this.getIdentifier().add(castToIdentifier(value));
1573        } else if (name.equals("basedOn")) {
1574          this.getBasedOn().add(castToReference(value));
1575        } else if (name.equals("partOf")) {
1576          this.getPartOf().add(castToReference(value));
1577        } else if (name.equals("status")) {
1578          value = new MediaStatusEnumFactory().fromType(castToCode(value));
1579          this.status = (Enumeration) value; // Enumeration<MediaStatus>
1580        } else if (name.equals("type")) {
1581          this.type = castToCodeableConcept(value); // CodeableConcept
1582        } else if (name.equals("modality")) {
1583          this.modality = castToCodeableConcept(value); // CodeableConcept
1584        } else if (name.equals("view")) {
1585          this.view = castToCodeableConcept(value); // CodeableConcept
1586        } else if (name.equals("subject")) {
1587          this.subject = castToReference(value); // Reference
1588        } else if (name.equals("context")) {
1589          this.context = castToReference(value); // Reference
1590        } else if (name.equals("created[x]")) {
1591          this.created = castToType(value); // Type
1592        } else if (name.equals("issued")) {
1593          this.issued = castToInstant(value); // InstantType
1594        } else if (name.equals("operator")) {
1595          this.operator = castToReference(value); // Reference
1596        } else if (name.equals("reasonCode")) {
1597          this.getReasonCode().add(castToCodeableConcept(value));
1598        } else if (name.equals("bodySite")) {
1599          this.bodySite = castToCodeableConcept(value); // CodeableConcept
1600        } else if (name.equals("deviceName")) {
1601          this.deviceName = castToString(value); // StringType
1602        } else if (name.equals("device")) {
1603          this.device = castToReference(value); // Reference
1604        } else if (name.equals("height")) {
1605          this.height = castToPositiveInt(value); // PositiveIntType
1606        } else if (name.equals("width")) {
1607          this.width = castToPositiveInt(value); // PositiveIntType
1608        } else if (name.equals("frames")) {
1609          this.frames = castToPositiveInt(value); // PositiveIntType
1610        } else if (name.equals("duration")) {
1611          this.duration = castToDecimal(value); // DecimalType
1612        } else if (name.equals("content")) {
1613          this.content = castToAttachment(value); // Attachment
1614        } else if (name.equals("note")) {
1615          this.getNote().add(castToAnnotation(value));
1616        } else
1617          return super.setProperty(name, value);
1618        return value;
1619      }
1620
1621      @Override
1622      public Base makeProperty(int hash, String name) throws FHIRException {
1623        switch (hash) {
1624        case -1618432855:  return addIdentifier(); 
1625        case -332612366:  return addBasedOn(); 
1626        case -995410646:  return addPartOf(); 
1627        case -892481550:  return getStatusElement();
1628        case 3575610:  return getType(); 
1629        case -622722335:  return getModality(); 
1630        case 3619493:  return getView(); 
1631        case -1867885268:  return getSubject(); 
1632        case 951530927:  return getContext(); 
1633        case 1369676952:  return getCreated(); 
1634        case 1028554472:  return getCreated(); 
1635        case -1179159893:  return getIssuedElement();
1636        case -500553564:  return getOperator(); 
1637        case 722137681:  return addReasonCode(); 
1638        case 1702620169:  return getBodySite(); 
1639        case 780988929:  return getDeviceNameElement();
1640        case -1335157162:  return getDevice(); 
1641        case -1221029593:  return getHeightElement();
1642        case 113126854:  return getWidthElement();
1643        case -1266514778:  return getFramesElement();
1644        case -1992012396:  return getDurationElement();
1645        case 951530617:  return getContent(); 
1646        case 3387378:  return addNote(); 
1647        default: return super.makeProperty(hash, name);
1648        }
1649
1650      }
1651
1652      @Override
1653      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1654        switch (hash) {
1655        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
1656        case -332612366: /*basedOn*/ return new String[] {"Reference"};
1657        case -995410646: /*partOf*/ return new String[] {"Reference"};
1658        case -892481550: /*status*/ return new String[] {"code"};
1659        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
1660        case -622722335: /*modality*/ return new String[] {"CodeableConcept"};
1661        case 3619493: /*view*/ return new String[] {"CodeableConcept"};
1662        case -1867885268: /*subject*/ return new String[] {"Reference"};
1663        case 951530927: /*context*/ return new String[] {"Reference"};
1664        case 1028554472: /*created*/ return new String[] {"dateTime", "Period"};
1665        case -1179159893: /*issued*/ return new String[] {"instant"};
1666        case -500553564: /*operator*/ return new String[] {"Reference"};
1667        case 722137681: /*reasonCode*/ return new String[] {"CodeableConcept"};
1668        case 1702620169: /*bodySite*/ return new String[] {"CodeableConcept"};
1669        case 780988929: /*deviceName*/ return new String[] {"string"};
1670        case -1335157162: /*device*/ return new String[] {"Reference"};
1671        case -1221029593: /*height*/ return new String[] {"positiveInt"};
1672        case 113126854: /*width*/ return new String[] {"positiveInt"};
1673        case -1266514778: /*frames*/ return new String[] {"positiveInt"};
1674        case -1992012396: /*duration*/ return new String[] {"decimal"};
1675        case 951530617: /*content*/ return new String[] {"Attachment"};
1676        case 3387378: /*note*/ return new String[] {"Annotation"};
1677        default: return super.getTypesForProperty(hash, name);
1678        }
1679
1680      }
1681
1682      @Override
1683      public Base addChild(String name) throws FHIRException {
1684        if (name.equals("identifier")) {
1685          return addIdentifier();
1686        }
1687        else if (name.equals("basedOn")) {
1688          return addBasedOn();
1689        }
1690        else if (name.equals("partOf")) {
1691          return addPartOf();
1692        }
1693        else if (name.equals("status")) {
1694          throw new FHIRException("Cannot call addChild on a primitive type Media.status");
1695        }
1696        else if (name.equals("type")) {
1697          this.type = new CodeableConcept();
1698          return this.type;
1699        }
1700        else if (name.equals("modality")) {
1701          this.modality = new CodeableConcept();
1702          return this.modality;
1703        }
1704        else if (name.equals("view")) {
1705          this.view = new CodeableConcept();
1706          return this.view;
1707        }
1708        else if (name.equals("subject")) {
1709          this.subject = new Reference();
1710          return this.subject;
1711        }
1712        else if (name.equals("context")) {
1713          this.context = new Reference();
1714          return this.context;
1715        }
1716        else if (name.equals("createdDateTime")) {
1717          this.created = new DateTimeType();
1718          return this.created;
1719        }
1720        else if (name.equals("createdPeriod")) {
1721          this.created = new Period();
1722          return this.created;
1723        }
1724        else if (name.equals("issued")) {
1725          throw new FHIRException("Cannot call addChild on a primitive type Media.issued");
1726        }
1727        else if (name.equals("operator")) {
1728          this.operator = new Reference();
1729          return this.operator;
1730        }
1731        else if (name.equals("reasonCode")) {
1732          return addReasonCode();
1733        }
1734        else if (name.equals("bodySite")) {
1735          this.bodySite = new CodeableConcept();
1736          return this.bodySite;
1737        }
1738        else if (name.equals("deviceName")) {
1739          throw new FHIRException("Cannot call addChild on a primitive type Media.deviceName");
1740        }
1741        else if (name.equals("device")) {
1742          this.device = new Reference();
1743          return this.device;
1744        }
1745        else if (name.equals("height")) {
1746          throw new FHIRException("Cannot call addChild on a primitive type Media.height");
1747        }
1748        else if (name.equals("width")) {
1749          throw new FHIRException("Cannot call addChild on a primitive type Media.width");
1750        }
1751        else if (name.equals("frames")) {
1752          throw new FHIRException("Cannot call addChild on a primitive type Media.frames");
1753        }
1754        else if (name.equals("duration")) {
1755          throw new FHIRException("Cannot call addChild on a primitive type Media.duration");
1756        }
1757        else if (name.equals("content")) {
1758          this.content = new Attachment();
1759          return this.content;
1760        }
1761        else if (name.equals("note")) {
1762          return addNote();
1763        }
1764        else
1765          return super.addChild(name);
1766      }
1767
1768  public String fhirType() {
1769    return "Media";
1770
1771  }
1772
1773      public Media copy() {
1774        Media dst = new Media();
1775        copyValues(dst);
1776        if (identifier != null) {
1777          dst.identifier = new ArrayList<Identifier>();
1778          for (Identifier i : identifier)
1779            dst.identifier.add(i.copy());
1780        };
1781        if (basedOn != null) {
1782          dst.basedOn = new ArrayList<Reference>();
1783          for (Reference i : basedOn)
1784            dst.basedOn.add(i.copy());
1785        };
1786        if (partOf != null) {
1787          dst.partOf = new ArrayList<Reference>();
1788          for (Reference i : partOf)
1789            dst.partOf.add(i.copy());
1790        };
1791        dst.status = status == null ? null : status.copy();
1792        dst.type = type == null ? null : type.copy();
1793        dst.modality = modality == null ? null : modality.copy();
1794        dst.view = view == null ? null : view.copy();
1795        dst.subject = subject == null ? null : subject.copy();
1796        dst.context = context == null ? null : context.copy();
1797        dst.created = created == null ? null : created.copy();
1798        dst.issued = issued == null ? null : issued.copy();
1799        dst.operator = operator == null ? null : operator.copy();
1800        if (reasonCode != null) {
1801          dst.reasonCode = new ArrayList<CodeableConcept>();
1802          for (CodeableConcept i : reasonCode)
1803            dst.reasonCode.add(i.copy());
1804        };
1805        dst.bodySite = bodySite == null ? null : bodySite.copy();
1806        dst.deviceName = deviceName == null ? null : deviceName.copy();
1807        dst.device = device == null ? null : device.copy();
1808        dst.height = height == null ? null : height.copy();
1809        dst.width = width == null ? null : width.copy();
1810        dst.frames = frames == null ? null : frames.copy();
1811        dst.duration = duration == null ? null : duration.copy();
1812        dst.content = content == null ? null : content.copy();
1813        if (note != null) {
1814          dst.note = new ArrayList<Annotation>();
1815          for (Annotation i : note)
1816            dst.note.add(i.copy());
1817        };
1818        return dst;
1819      }
1820
1821      protected Media typedCopy() {
1822        return copy();
1823      }
1824
1825      @Override
1826      public boolean equalsDeep(Base other_) {
1827        if (!super.equalsDeep(other_))
1828          return false;
1829        if (!(other_ instanceof Media))
1830          return false;
1831        Media o = (Media) other_;
1832        return compareDeep(identifier, o.identifier, true) && compareDeep(basedOn, o.basedOn, true) && compareDeep(partOf, o.partOf, true)
1833           && compareDeep(status, o.status, true) && compareDeep(type, o.type, true) && compareDeep(modality, o.modality, true)
1834           && compareDeep(view, o.view, true) && compareDeep(subject, o.subject, true) && compareDeep(context, o.context, true)
1835           && compareDeep(created, o.created, true) && compareDeep(issued, o.issued, true) && compareDeep(operator, o.operator, true)
1836           && compareDeep(reasonCode, o.reasonCode, true) && compareDeep(bodySite, o.bodySite, true) && compareDeep(deviceName, o.deviceName, true)
1837           && compareDeep(device, o.device, true) && compareDeep(height, o.height, true) && compareDeep(width, o.width, true)
1838           && compareDeep(frames, o.frames, true) && compareDeep(duration, o.duration, true) && compareDeep(content, o.content, true)
1839           && compareDeep(note, o.note, true);
1840      }
1841
1842      @Override
1843      public boolean equalsShallow(Base other_) {
1844        if (!super.equalsShallow(other_))
1845          return false;
1846        if (!(other_ instanceof Media))
1847          return false;
1848        Media o = (Media) other_;
1849        return compareValues(status, o.status, true) && compareValues(issued, o.issued, true) && compareValues(deviceName, o.deviceName, true)
1850           && compareValues(height, o.height, true) && compareValues(width, o.width, true) && compareValues(frames, o.frames, true)
1851           && compareValues(duration, o.duration, true);
1852      }
1853
1854      public boolean isEmpty() {
1855        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, basedOn, partOf
1856          , status, type, modality, view, subject, context, created, issued, operator
1857          , reasonCode, bodySite, deviceName, device, height, width, frames, duration
1858          , content, note);
1859      }
1860
1861  @Override
1862  public ResourceType getResourceType() {
1863    return ResourceType.Media;
1864   }
1865
1866 /**
1867   * Search parameter: <b>identifier</b>
1868   * <p>
1869   * Description: <b>Identifier(s) for the image</b><br>
1870   * Type: <b>token</b><br>
1871   * Path: <b>Media.identifier</b><br>
1872   * </p>
1873   */
1874  @SearchParamDefinition(name="identifier", path="Media.identifier", description="Identifier(s) for the image", type="token" )
1875  public static final String SP_IDENTIFIER = "identifier";
1876 /**
1877   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
1878   * <p>
1879   * Description: <b>Identifier(s) for the image</b><br>
1880   * Type: <b>token</b><br>
1881   * Path: <b>Media.identifier</b><br>
1882   * </p>
1883   */
1884  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
1885
1886 /**
1887   * Search parameter: <b>modality</b>
1888   * <p>
1889   * Description: <b>The type of acquisition equipment/process</b><br>
1890   * Type: <b>token</b><br>
1891   * Path: <b>Media.modality</b><br>
1892   * </p>
1893   */
1894  @SearchParamDefinition(name="modality", path="Media.modality", description="The type of acquisition equipment/process", type="token" )
1895  public static final String SP_MODALITY = "modality";
1896 /**
1897   * <b>Fluent Client</b> search parameter constant for <b>modality</b>
1898   * <p>
1899   * Description: <b>The type of acquisition equipment/process</b><br>
1900   * Type: <b>token</b><br>
1901   * Path: <b>Media.modality</b><br>
1902   * </p>
1903   */
1904  public static final ca.uhn.fhir.rest.gclient.TokenClientParam MODALITY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_MODALITY);
1905
1906 /**
1907   * Search parameter: <b>subject</b>
1908   * <p>
1909   * Description: <b>Who/What this Media is a record of</b><br>
1910   * Type: <b>reference</b><br>
1911   * Path: <b>Media.subject</b><br>
1912   * </p>
1913   */
1914  @SearchParamDefinition(name="subject", path="Media.subject", description="Who/What this Media is a record of", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Device"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner") }, target={Device.class, Group.class, Location.class, Patient.class, Practitioner.class, Specimen.class } )
1915  public static final String SP_SUBJECT = "subject";
1916 /**
1917   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
1918   * <p>
1919   * Description: <b>Who/What this Media is a record of</b><br>
1920   * Type: <b>reference</b><br>
1921   * Path: <b>Media.subject</b><br>
1922   * </p>
1923   */
1924  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
1925
1926/**
1927   * Constant for fluent queries to be used to add include statements. Specifies
1928   * the path value of "<b>Media:subject</b>".
1929   */
1930  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("Media:subject").toLocked();
1931
1932 /**
1933   * Search parameter: <b>created</b>
1934   * <p>
1935   * Description: <b>When Media was collected</b><br>
1936   * Type: <b>date</b><br>
1937   * Path: <b>Media.created[x]</b><br>
1938   * </p>
1939   */
1940  @SearchParamDefinition(name="created", path="Media.created", description="When Media was collected", type="date" )
1941  public static final String SP_CREATED = "created";
1942 /**
1943   * <b>Fluent Client</b> search parameter constant for <b>created</b>
1944   * <p>
1945   * Description: <b>When Media was collected</b><br>
1946   * Type: <b>date</b><br>
1947   * Path: <b>Media.created[x]</b><br>
1948   * </p>
1949   */
1950  public static final ca.uhn.fhir.rest.gclient.DateClientParam CREATED = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_CREATED);
1951
1952 /**
1953   * Search parameter: <b>type</b>
1954   * <p>
1955   * Description: <b>Classification of media as image, video, or audio</b><br>
1956   * Type: <b>token</b><br>
1957   * Path: <b>Media.type</b><br>
1958   * </p>
1959   */
1960  @SearchParamDefinition(name="type", path="Media.type", description="Classification of media as image, video, or audio", type="token" )
1961  public static final String SP_TYPE = "type";
1962 /**
1963   * <b>Fluent Client</b> search parameter constant for <b>type</b>
1964   * <p>
1965   * Description: <b>Classification of media as image, video, or audio</b><br>
1966   * Type: <b>token</b><br>
1967   * Path: <b>Media.type</b><br>
1968   * </p>
1969   */
1970  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_TYPE);
1971
1972 /**
1973   * Search parameter: <b>operator</b>
1974   * <p>
1975   * Description: <b>The person who generated the image</b><br>
1976   * Type: <b>reference</b><br>
1977   * Path: <b>Media.operator</b><br>
1978   * </p>
1979   */
1980  @SearchParamDefinition(name="operator", path="Media.operator", description="The person who generated the image", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner") }, target={CareTeam.class, Device.class, Organization.class, Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class } )
1981  public static final String SP_OPERATOR = "operator";
1982 /**
1983   * <b>Fluent Client</b> search parameter constant for <b>operator</b>
1984   * <p>
1985   * Description: <b>The person who generated the image</b><br>
1986   * Type: <b>reference</b><br>
1987   * Path: <b>Media.operator</b><br>
1988   * </p>
1989   */
1990  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam OPERATOR = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_OPERATOR);
1991
1992/**
1993   * Constant for fluent queries to be used to add include statements. Specifies
1994   * the path value of "<b>Media:operator</b>".
1995   */
1996  public static final ca.uhn.fhir.model.api.Include INCLUDE_OPERATOR = new ca.uhn.fhir.model.api.Include("Media:operator").toLocked();
1997
1998 /**
1999   * Search parameter: <b>view</b>
2000   * <p>
2001   * Description: <b>Imaging view, e.g. Lateral or Antero-posterior</b><br>
2002   * Type: <b>token</b><br>
2003   * Path: <b>Media.view</b><br>
2004   * </p>
2005   */
2006  @SearchParamDefinition(name="view", path="Media.view", description="Imaging view, e.g. Lateral or Antero-posterior", type="token" )
2007  public static final String SP_VIEW = "view";
2008 /**
2009   * <b>Fluent Client</b> search parameter constant for <b>view</b>
2010   * <p>
2011   * Description: <b>Imaging view, e.g. Lateral or Antero-posterior</b><br>
2012   * Type: <b>token</b><br>
2013   * Path: <b>Media.view</b><br>
2014   * </p>
2015   */
2016  public static final ca.uhn.fhir.rest.gclient.TokenClientParam VIEW = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_VIEW);
2017
2018 /**
2019   * Search parameter: <b>site</b>
2020   * <p>
2021   * Description: <b>Observed body part</b><br>
2022   * Type: <b>token</b><br>
2023   * Path: <b>Media.bodySite</b><br>
2024   * </p>
2025   */
2026  @SearchParamDefinition(name="site", path="Media.bodySite", description="Observed body part", type="token" )
2027  public static final String SP_SITE = "site";
2028 /**
2029   * <b>Fluent Client</b> search parameter constant for <b>site</b>
2030   * <p>
2031   * Description: <b>Observed body part</b><br>
2032   * Type: <b>token</b><br>
2033   * Path: <b>Media.bodySite</b><br>
2034   * </p>
2035   */
2036  public static final ca.uhn.fhir.rest.gclient.TokenClientParam SITE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_SITE);
2037
2038 /**
2039   * Search parameter: <b>based-on</b>
2040   * <p>
2041   * Description: <b>Procedure that caused this media to be created</b><br>
2042   * Type: <b>reference</b><br>
2043   * Path: <b>Media.basedOn</b><br>
2044   * </p>
2045   */
2046  @SearchParamDefinition(name="based-on", path="Media.basedOn", description="Procedure that caused this media to be created", type="reference", target={CarePlan.class, ServiceRequest.class } )
2047  public static final String SP_BASED_ON = "based-on";
2048 /**
2049   * <b>Fluent Client</b> search parameter constant for <b>based-on</b>
2050   * <p>
2051   * Description: <b>Procedure that caused this media to be created</b><br>
2052   * Type: <b>reference</b><br>
2053   * Path: <b>Media.basedOn</b><br>
2054   * </p>
2055   */
2056  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam BASED_ON = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_BASED_ON);
2057
2058/**
2059   * Constant for fluent queries to be used to add include statements. Specifies
2060   * the path value of "<b>Media:based-on</b>".
2061   */
2062  public static final ca.uhn.fhir.model.api.Include INCLUDE_BASED_ON = new ca.uhn.fhir.model.api.Include("Media:based-on").toLocked();
2063
2064 /**
2065   * Search parameter: <b>patient</b>
2066   * <p>
2067   * Description: <b>Who/What this Media is a record of</b><br>
2068   * Type: <b>reference</b><br>
2069   * Path: <b>Media.subject</b><br>
2070   * </p>
2071   */
2072  @SearchParamDefinition(name="patient", path="Media.subject.where(resolve() is Patient)", description="Who/What this Media is a record of", type="reference", target={Patient.class } )
2073  public static final String SP_PATIENT = "patient";
2074 /**
2075   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
2076   * <p>
2077   * Description: <b>Who/What this Media is a record of</b><br>
2078   * Type: <b>reference</b><br>
2079   * Path: <b>Media.subject</b><br>
2080   * </p>
2081   */
2082  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
2083
2084/**
2085   * Constant for fluent queries to be used to add include statements. Specifies
2086   * the path value of "<b>Media:patient</b>".
2087   */
2088  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("Media:patient").toLocked();
2089
2090 /**
2091   * Search parameter: <b>context</b>
2092   * <p>
2093   * Description: <b>Encounter / Episode associated with media</b><br>
2094   * Type: <b>reference</b><br>
2095   * Path: <b>Media.context</b><br>
2096   * </p>
2097   */
2098  @SearchParamDefinition(name="context", path="Media.context", description="Encounter / Episode associated with media", type="reference", target={Encounter.class, EpisodeOfCare.class } )
2099  public static final String SP_CONTEXT = "context";
2100 /**
2101   * <b>Fluent Client</b> search parameter constant for <b>context</b>
2102   * <p>
2103   * Description: <b>Encounter / Episode associated with media</b><br>
2104   * Type: <b>reference</b><br>
2105   * Path: <b>Media.context</b><br>
2106   * </p>
2107   */
2108  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam CONTEXT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_CONTEXT);
2109
2110/**
2111   * Constant for fluent queries to be used to add include statements. Specifies
2112   * the path value of "<b>Media:context</b>".
2113   */
2114  public static final ca.uhn.fhir.model.api.Include INCLUDE_CONTEXT = new ca.uhn.fhir.model.api.Include("Media:context").toLocked();
2115
2116 /**
2117   * Search parameter: <b>device</b>
2118   * <p>
2119   * Description: <b>Observing Device</b><br>
2120   * Type: <b>reference</b><br>
2121   * Path: <b>Media.device</b><br>
2122   * </p>
2123   */
2124  @SearchParamDefinition(name="device", path="Media.device", description="Observing Device", type="reference", target={Device.class, DeviceMetric.class } )
2125  public static final String SP_DEVICE = "device";
2126 /**
2127   * <b>Fluent Client</b> search parameter constant for <b>device</b>
2128   * <p>
2129   * Description: <b>Observing Device</b><br>
2130   * Type: <b>reference</b><br>
2131   * Path: <b>Media.device</b><br>
2132   * </p>
2133   */
2134  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam DEVICE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_DEVICE);
2135
2136/**
2137   * Constant for fluent queries to be used to add include statements. Specifies
2138   * the path value of "<b>Media:device</b>".
2139   */
2140  public static final ca.uhn.fhir.model.api.Include INCLUDE_DEVICE = new ca.uhn.fhir.model.api.Include("Media:device").toLocked();
2141
2142 /**
2143   * Search parameter: <b>status</b>
2144   * <p>
2145   * Description: <b>preparation | in-progress | not-done | suspended | aborted | completed | entered-in-error | unknown</b><br>
2146   * Type: <b>token</b><br>
2147   * Path: <b>Media.status</b><br>
2148   * </p>
2149   */
2150  @SearchParamDefinition(name="status", path="Media.status", description="preparation | in-progress | not-done | suspended | aborted | completed | entered-in-error | unknown", type="token" )
2151  public static final String SP_STATUS = "status";
2152 /**
2153   * <b>Fluent Client</b> search parameter constant for <b>status</b>
2154   * <p>
2155   * Description: <b>preparation | in-progress | not-done | suspended | aborted | completed | entered-in-error | unknown</b><br>
2156   * Type: <b>token</b><br>
2157   * Path: <b>Media.status</b><br>
2158   * </p>
2159   */
2160  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
2161
2162
2163}
2164