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, Dec 27, 2018 10:06-0500 for FHIR v4.0.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/source system does not know which of the status values currently applies for this event.  Note: This concept is not to be used for "other" - one of the listed statuses is presumed to apply,  but the authoring/source system does not know which.
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/source system does not know which of the status values currently applies for this event.  Note: This concept is not to be used for \"other\" - one of the listed statuses is presumed to apply,  but the authoring/source system does not know which.";
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, PractitionerRole.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 that establishes the context for this media.
317     */
318    @Child(name = "encounter", type = {Encounter.class}, order=8, min=0, max=1, modifier=false, summary=true)
319    @Description(shortDefinition="Encounter associated with media", formalDefinition="The encounter that establishes the context for this media." )
320    protected Reference encounter;
321
322    /**
323     * The actual object that is the target of the reference (The encounter that establishes the context for this media.)
324     */
325    protected Encounter encounterTarget;
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 = 2069980126L;
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 #encounter} (The encounter that establishes the context for this media.)
785     */
786    public Reference getEncounter() { 
787      if (this.encounter == null)
788        if (Configuration.errorOnAutoCreate())
789          throw new Error("Attempt to auto-create Media.encounter");
790        else if (Configuration.doAutoCreate())
791          this.encounter = new Reference(); // cc
792      return this.encounter;
793    }
794
795    public boolean hasEncounter() { 
796      return this.encounter != null && !this.encounter.isEmpty();
797    }
798
799    /**
800     * @param value {@link #encounter} (The encounter that establishes the context for this media.)
801     */
802    public Media setEncounter(Reference value) { 
803      this.encounter = value;
804      return this;
805    }
806
807    /**
808     * @return {@link #encounter} 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 that establishes the context for this media.)
809     */
810    public Encounter getEncounterTarget() { 
811      if (this.encounterTarget == null)
812        if (Configuration.errorOnAutoCreate())
813          throw new Error("Attempt to auto-create Media.encounter");
814        else if (Configuration.doAutoCreate())
815          this.encounterTarget = new Encounter(); // aa
816      return this.encounterTarget;
817    }
818
819    /**
820     * @param value {@link #encounter} 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 that establishes the context for this media.)
821     */
822    public Media setEncounterTarget(Encounter value) { 
823      this.encounterTarget = value;
824      return this;
825    }
826
827    /**
828     * @return {@link #created} (The date and time(s) at which the media was collected.)
829     */
830    public Type getCreated() { 
831      return this.created;
832    }
833
834    /**
835     * @return {@link #created} (The date and time(s) at which the media was collected.)
836     */
837    public DateTimeType getCreatedDateTimeType() throws FHIRException { 
838      if (this.created == null)
839        this.created = new DateTimeType();
840      if (!(this.created instanceof DateTimeType))
841        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.created.getClass().getName()+" was encountered");
842      return (DateTimeType) this.created;
843    }
844
845    public boolean hasCreatedDateTimeType() { 
846      return this != null && this.created instanceof DateTimeType;
847    }
848
849    /**
850     * @return {@link #created} (The date and time(s) at which the media was collected.)
851     */
852    public Period getCreatedPeriod() throws FHIRException { 
853      if (this.created == null)
854        this.created = new Period();
855      if (!(this.created instanceof Period))
856        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.created.getClass().getName()+" was encountered");
857      return (Period) this.created;
858    }
859
860    public boolean hasCreatedPeriod() { 
861      return this != null && this.created instanceof Period;
862    }
863
864    public boolean hasCreated() { 
865      return this.created != null && !this.created.isEmpty();
866    }
867
868    /**
869     * @param value {@link #created} (The date and time(s) at which the media was collected.)
870     */
871    public Media setCreated(Type value) { 
872      if (value != null && !(value instanceof DateTimeType || value instanceof Period))
873        throw new Error("Not the right type for Media.created[x]: "+value.fhirType());
874      this.created = value;
875      return this;
876    }
877
878    /**
879     * @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
880     */
881    public InstantType getIssuedElement() { 
882      if (this.issued == null)
883        if (Configuration.errorOnAutoCreate())
884          throw new Error("Attempt to auto-create Media.issued");
885        else if (Configuration.doAutoCreate())
886          this.issued = new InstantType(); // bb
887      return this.issued;
888    }
889
890    public boolean hasIssuedElement() { 
891      return this.issued != null && !this.issued.isEmpty();
892    }
893
894    public boolean hasIssued() { 
895      return this.issued != null && !this.issued.isEmpty();
896    }
897
898    /**
899     * @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
900     */
901    public Media setIssuedElement(InstantType value) { 
902      this.issued = value;
903      return this;
904    }
905
906    /**
907     * @return The date and time this version of the media was made available to providers, typically after having been reviewed.
908     */
909    public Date getIssued() { 
910      return this.issued == null ? null : this.issued.getValue();
911    }
912
913    /**
914     * @param value The date and time this version of the media was made available to providers, typically after having been reviewed.
915     */
916    public Media setIssued(Date value) { 
917      if (value == null)
918        this.issued = null;
919      else {
920        if (this.issued == null)
921          this.issued = new InstantType();
922        this.issued.setValue(value);
923      }
924      return this;
925    }
926
927    /**
928     * @return {@link #operator} (The person who administered the collection of the image.)
929     */
930    public Reference getOperator() { 
931      if (this.operator == null)
932        if (Configuration.errorOnAutoCreate())
933          throw new Error("Attempt to auto-create Media.operator");
934        else if (Configuration.doAutoCreate())
935          this.operator = new Reference(); // cc
936      return this.operator;
937    }
938
939    public boolean hasOperator() { 
940      return this.operator != null && !this.operator.isEmpty();
941    }
942
943    /**
944     * @param value {@link #operator} (The person who administered the collection of the image.)
945     */
946    public Media setOperator(Reference value) { 
947      this.operator = value;
948      return this;
949    }
950
951    /**
952     * @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.)
953     */
954    public Resource getOperatorTarget() { 
955      return this.operatorTarget;
956    }
957
958    /**
959     * @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.)
960     */
961    public Media setOperatorTarget(Resource value) { 
962      this.operatorTarget = value;
963      return this;
964    }
965
966    /**
967     * @return {@link #reasonCode} (Describes why the event occurred in coded or textual form.)
968     */
969    public List<CodeableConcept> getReasonCode() { 
970      if (this.reasonCode == null)
971        this.reasonCode = new ArrayList<CodeableConcept>();
972      return this.reasonCode;
973    }
974
975    /**
976     * @return Returns a reference to <code>this</code> for easy method chaining
977     */
978    public Media setReasonCode(List<CodeableConcept> theReasonCode) { 
979      this.reasonCode = theReasonCode;
980      return this;
981    }
982
983    public boolean hasReasonCode() { 
984      if (this.reasonCode == null)
985        return false;
986      for (CodeableConcept item : this.reasonCode)
987        if (!item.isEmpty())
988          return true;
989      return false;
990    }
991
992    public CodeableConcept addReasonCode() { //3
993      CodeableConcept t = new CodeableConcept();
994      if (this.reasonCode == null)
995        this.reasonCode = new ArrayList<CodeableConcept>();
996      this.reasonCode.add(t);
997      return t;
998    }
999
1000    public Media addReasonCode(CodeableConcept t) { //3
1001      if (t == null)
1002        return this;
1003      if (this.reasonCode == null)
1004        this.reasonCode = new ArrayList<CodeableConcept>();
1005      this.reasonCode.add(t);
1006      return this;
1007    }
1008
1009    /**
1010     * @return The first repetition of repeating field {@link #reasonCode}, creating it if it does not already exist
1011     */
1012    public CodeableConcept getReasonCodeFirstRep() { 
1013      if (getReasonCode().isEmpty()) {
1014        addReasonCode();
1015      }
1016      return getReasonCode().get(0);
1017    }
1018
1019    /**
1020     * @return {@link #bodySite} (Indicates the site on the subject's body where the observation was made (i.e. the target site).)
1021     */
1022    public CodeableConcept getBodySite() { 
1023      if (this.bodySite == null)
1024        if (Configuration.errorOnAutoCreate())
1025          throw new Error("Attempt to auto-create Media.bodySite");
1026        else if (Configuration.doAutoCreate())
1027          this.bodySite = new CodeableConcept(); // cc
1028      return this.bodySite;
1029    }
1030
1031    public boolean hasBodySite() { 
1032      return this.bodySite != null && !this.bodySite.isEmpty();
1033    }
1034
1035    /**
1036     * @param value {@link #bodySite} (Indicates the site on the subject's body where the observation was made (i.e. the target site).)
1037     */
1038    public Media setBodySite(CodeableConcept value) { 
1039      this.bodySite = value;
1040      return this;
1041    }
1042
1043    /**
1044     * @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
1045     */
1046    public StringType getDeviceNameElement() { 
1047      if (this.deviceName == null)
1048        if (Configuration.errorOnAutoCreate())
1049          throw new Error("Attempt to auto-create Media.deviceName");
1050        else if (Configuration.doAutoCreate())
1051          this.deviceName = new StringType(); // bb
1052      return this.deviceName;
1053    }
1054
1055    public boolean hasDeviceNameElement() { 
1056      return this.deviceName != null && !this.deviceName.isEmpty();
1057    }
1058
1059    public boolean hasDeviceName() { 
1060      return this.deviceName != null && !this.deviceName.isEmpty();
1061    }
1062
1063    /**
1064     * @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
1065     */
1066    public Media setDeviceNameElement(StringType value) { 
1067      this.deviceName = value;
1068      return this;
1069    }
1070
1071    /**
1072     * @return The name of the device / manufacturer of the device  that was used to make the recording.
1073     */
1074    public String getDeviceName() { 
1075      return this.deviceName == null ? null : this.deviceName.getValue();
1076    }
1077
1078    /**
1079     * @param value The name of the device / manufacturer of the device  that was used to make the recording.
1080     */
1081    public Media setDeviceName(String value) { 
1082      if (Utilities.noString(value))
1083        this.deviceName = null;
1084      else {
1085        if (this.deviceName == null)
1086          this.deviceName = new StringType();
1087        this.deviceName.setValue(value);
1088      }
1089      return this;
1090    }
1091
1092    /**
1093     * @return {@link #device} (The device used to collect the media.)
1094     */
1095    public Reference getDevice() { 
1096      if (this.device == null)
1097        if (Configuration.errorOnAutoCreate())
1098          throw new Error("Attempt to auto-create Media.device");
1099        else if (Configuration.doAutoCreate())
1100          this.device = new Reference(); // cc
1101      return this.device;
1102    }
1103
1104    public boolean hasDevice() { 
1105      return this.device != null && !this.device.isEmpty();
1106    }
1107
1108    /**
1109     * @param value {@link #device} (The device used to collect the media.)
1110     */
1111    public Media setDevice(Reference value) { 
1112      this.device = value;
1113      return this;
1114    }
1115
1116    /**
1117     * @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.)
1118     */
1119    public Resource getDeviceTarget() { 
1120      return this.deviceTarget;
1121    }
1122
1123    /**
1124     * @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.)
1125     */
1126    public Media setDeviceTarget(Resource value) { 
1127      this.deviceTarget = value;
1128      return this;
1129    }
1130
1131    /**
1132     * @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
1133     */
1134    public PositiveIntType getHeightElement() { 
1135      if (this.height == null)
1136        if (Configuration.errorOnAutoCreate())
1137          throw new Error("Attempt to auto-create Media.height");
1138        else if (Configuration.doAutoCreate())
1139          this.height = new PositiveIntType(); // bb
1140      return this.height;
1141    }
1142
1143    public boolean hasHeightElement() { 
1144      return this.height != null && !this.height.isEmpty();
1145    }
1146
1147    public boolean hasHeight() { 
1148      return this.height != null && !this.height.isEmpty();
1149    }
1150
1151    /**
1152     * @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
1153     */
1154    public Media setHeightElement(PositiveIntType value) { 
1155      this.height = value;
1156      return this;
1157    }
1158
1159    /**
1160     * @return Height of the image in pixels (photo/video).
1161     */
1162    public int getHeight() { 
1163      return this.height == null || this.height.isEmpty() ? 0 : this.height.getValue();
1164    }
1165
1166    /**
1167     * @param value Height of the image in pixels (photo/video).
1168     */
1169    public Media setHeight(int value) { 
1170        if (this.height == null)
1171          this.height = new PositiveIntType();
1172        this.height.setValue(value);
1173      return this;
1174    }
1175
1176    /**
1177     * @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
1178     */
1179    public PositiveIntType getWidthElement() { 
1180      if (this.width == null)
1181        if (Configuration.errorOnAutoCreate())
1182          throw new Error("Attempt to auto-create Media.width");
1183        else if (Configuration.doAutoCreate())
1184          this.width = new PositiveIntType(); // bb
1185      return this.width;
1186    }
1187
1188    public boolean hasWidthElement() { 
1189      return this.width != null && !this.width.isEmpty();
1190    }
1191
1192    public boolean hasWidth() { 
1193      return this.width != null && !this.width.isEmpty();
1194    }
1195
1196    /**
1197     * @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
1198     */
1199    public Media setWidthElement(PositiveIntType value) { 
1200      this.width = value;
1201      return this;
1202    }
1203
1204    /**
1205     * @return Width of the image in pixels (photo/video).
1206     */
1207    public int getWidth() { 
1208      return this.width == null || this.width.isEmpty() ? 0 : this.width.getValue();
1209    }
1210
1211    /**
1212     * @param value Width of the image in pixels (photo/video).
1213     */
1214    public Media setWidth(int value) { 
1215        if (this.width == null)
1216          this.width = new PositiveIntType();
1217        this.width.setValue(value);
1218      return this;
1219    }
1220
1221    /**
1222     * @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
1223     */
1224    public PositiveIntType getFramesElement() { 
1225      if (this.frames == null)
1226        if (Configuration.errorOnAutoCreate())
1227          throw new Error("Attempt to auto-create Media.frames");
1228        else if (Configuration.doAutoCreate())
1229          this.frames = new PositiveIntType(); // bb
1230      return this.frames;
1231    }
1232
1233    public boolean hasFramesElement() { 
1234      return this.frames != null && !this.frames.isEmpty();
1235    }
1236
1237    public boolean hasFrames() { 
1238      return this.frames != null && !this.frames.isEmpty();
1239    }
1240
1241    /**
1242     * @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
1243     */
1244    public Media setFramesElement(PositiveIntType value) { 
1245      this.frames = value;
1246      return this;
1247    }
1248
1249    /**
1250     * @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.
1251     */
1252    public int getFrames() { 
1253      return this.frames == null || this.frames.isEmpty() ? 0 : this.frames.getValue();
1254    }
1255
1256    /**
1257     * @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.
1258     */
1259    public Media setFrames(int value) { 
1260        if (this.frames == null)
1261          this.frames = new PositiveIntType();
1262        this.frames.setValue(value);
1263      return this;
1264    }
1265
1266    /**
1267     * @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
1268     */
1269    public DecimalType getDurationElement() { 
1270      if (this.duration == null)
1271        if (Configuration.errorOnAutoCreate())
1272          throw new Error("Attempt to auto-create Media.duration");
1273        else if (Configuration.doAutoCreate())
1274          this.duration = new DecimalType(); // bb
1275      return this.duration;
1276    }
1277
1278    public boolean hasDurationElement() { 
1279      return this.duration != null && !this.duration.isEmpty();
1280    }
1281
1282    public boolean hasDuration() { 
1283      return this.duration != null && !this.duration.isEmpty();
1284    }
1285
1286    /**
1287     * @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
1288     */
1289    public Media setDurationElement(DecimalType value) { 
1290      this.duration = value;
1291      return this;
1292    }
1293
1294    /**
1295     * @return The duration of the recording in seconds - for audio and video.
1296     */
1297    public BigDecimal getDuration() { 
1298      return this.duration == null ? null : this.duration.getValue();
1299    }
1300
1301    /**
1302     * @param value The duration of the recording in seconds - for audio and video.
1303     */
1304    public Media setDuration(BigDecimal value) { 
1305      if (value == null)
1306        this.duration = null;
1307      else {
1308        if (this.duration == null)
1309          this.duration = new DecimalType();
1310        this.duration.setValue(value);
1311      }
1312      return this;
1313    }
1314
1315    /**
1316     * @param value The duration of the recording in seconds - for audio and video.
1317     */
1318    public Media setDuration(long value) { 
1319          this.duration = new DecimalType();
1320        this.duration.setValue(value);
1321      return this;
1322    }
1323
1324    /**
1325     * @param value The duration of the recording in seconds - for audio and video.
1326     */
1327    public Media setDuration(double value) { 
1328          this.duration = new DecimalType();
1329        this.duration.setValue(value);
1330      return this;
1331    }
1332
1333    /**
1334     * @return {@link #content} (The actual content of the media - inline or by direct reference to the media source file.)
1335     */
1336    public Attachment getContent() { 
1337      if (this.content == null)
1338        if (Configuration.errorOnAutoCreate())
1339          throw new Error("Attempt to auto-create Media.content");
1340        else if (Configuration.doAutoCreate())
1341          this.content = new Attachment(); // cc
1342      return this.content;
1343    }
1344
1345    public boolean hasContent() { 
1346      return this.content != null && !this.content.isEmpty();
1347    }
1348
1349    /**
1350     * @param value {@link #content} (The actual content of the media - inline or by direct reference to the media source file.)
1351     */
1352    public Media setContent(Attachment value) { 
1353      this.content = value;
1354      return this;
1355    }
1356
1357    /**
1358     * @return {@link #note} (Comments made about the media by the performer, subject or other participants.)
1359     */
1360    public List<Annotation> getNote() { 
1361      if (this.note == null)
1362        this.note = new ArrayList<Annotation>();
1363      return this.note;
1364    }
1365
1366    /**
1367     * @return Returns a reference to <code>this</code> for easy method chaining
1368     */
1369    public Media setNote(List<Annotation> theNote) { 
1370      this.note = theNote;
1371      return this;
1372    }
1373
1374    public boolean hasNote() { 
1375      if (this.note == null)
1376        return false;
1377      for (Annotation item : this.note)
1378        if (!item.isEmpty())
1379          return true;
1380      return false;
1381    }
1382
1383    public Annotation addNote() { //3
1384      Annotation t = new Annotation();
1385      if (this.note == null)
1386        this.note = new ArrayList<Annotation>();
1387      this.note.add(t);
1388      return t;
1389    }
1390
1391    public Media addNote(Annotation t) { //3
1392      if (t == null)
1393        return this;
1394      if (this.note == null)
1395        this.note = new ArrayList<Annotation>();
1396      this.note.add(t);
1397      return this;
1398    }
1399
1400    /**
1401     * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist
1402     */
1403    public Annotation getNoteFirstRep() { 
1404      if (getNote().isEmpty()) {
1405        addNote();
1406      }
1407      return getNote().get(0);
1408    }
1409
1410      protected void listChildren(List<Property> children) {
1411        super.listChildren(children);
1412        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));
1413        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));
1414        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));
1415        children.add(new Property("status", "code", "The current state of the {{title}}.", 0, 1, status));
1416        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));
1417        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));
1418        children.add(new Property("view", "CodeableConcept", "The name of the imaging view e.g. Lateral or Antero-posterior (AP).", 0, 1, view));
1419        children.add(new Property("subject", "Reference(Patient|Practitioner|PractitionerRole|Group|Device|Specimen|Location)", "Who/What this Media is a record of.", 0, 1, subject));
1420        children.add(new Property("encounter", "Reference(Encounter)", "The encounter that establishes the context for this media.", 0, 1, encounter));
1421        children.add(new Property("created[x]", "dateTime|Period", "The date and time(s) at which the media was collected.", 0, 1, created));
1422        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));
1423        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));
1424        children.add(new Property("reasonCode", "CodeableConcept", "Describes why the event occurred in coded or textual form.", 0, java.lang.Integer.MAX_VALUE, reasonCode));
1425        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));
1426        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));
1427        children.add(new Property("device", "Reference(Device|DeviceMetric|Device)", "The device used to collect the media.", 0, 1, device));
1428        children.add(new Property("height", "positiveInt", "Height of the image in pixels (photo/video).", 0, 1, height));
1429        children.add(new Property("width", "positiveInt", "Width of the image in pixels (photo/video).", 0, 1, width));
1430        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));
1431        children.add(new Property("duration", "decimal", "The duration of the recording in seconds - for audio and video.", 0, 1, duration));
1432        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));
1433        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));
1434      }
1435
1436      @Override
1437      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1438        switch (_hash) {
1439        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);
1440        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);
1441        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);
1442        case -892481550: /*status*/  return new Property("status", "code", "The current state of the {{title}}.", 0, 1, status);
1443        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);
1444        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);
1445        case 3619493: /*view*/  return new Property("view", "CodeableConcept", "The name of the imaging view e.g. Lateral or Antero-posterior (AP).", 0, 1, view);
1446        case -1867885268: /*subject*/  return new Property("subject", "Reference(Patient|Practitioner|PractitionerRole|Group|Device|Specimen|Location)", "Who/What this Media is a record of.", 0, 1, subject);
1447        case 1524132147: /*encounter*/  return new Property("encounter", "Reference(Encounter)", "The encounter that establishes the context for this media.", 0, 1, encounter);
1448        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);
1449        case 1028554472: /*created*/  return new Property("created[x]", "dateTime|Period", "The date and time(s) at which the media was collected.", 0, 1, created);
1450        case -1968526685: /*createdDateTime*/  return new Property("created[x]", "dateTime|Period", "The date and time(s) at which the media was collected.", 0, 1, created);
1451        case 1525027529: /*createdPeriod*/  return new Property("created[x]", "dateTime|Period", "The date and time(s) at which the media was collected.", 0, 1, created);
1452        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);
1453        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);
1454        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);
1455        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);
1456        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);
1457        case -1335157162: /*device*/  return new Property("device", "Reference(Device|DeviceMetric|Device)", "The device used to collect the media.", 0, 1, device);
1458        case -1221029593: /*height*/  return new Property("height", "positiveInt", "Height of the image in pixels (photo/video).", 0, 1, height);
1459        case 113126854: /*width*/  return new Property("width", "positiveInt", "Width of the image in pixels (photo/video).", 0, 1, width);
1460        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);
1461        case -1992012396: /*duration*/  return new Property("duration", "decimal", "The duration of the recording in seconds - for audio and video.", 0, 1, duration);
1462        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);
1463        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);
1464        default: return super.getNamedProperty(_hash, _name, _checkValid);
1465        }
1466
1467      }
1468
1469      @Override
1470      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1471        switch (hash) {
1472        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1473        case -332612366: /*basedOn*/ return this.basedOn == null ? new Base[0] : this.basedOn.toArray(new Base[this.basedOn.size()]); // Reference
1474        case -995410646: /*partOf*/ return this.partOf == null ? new Base[0] : this.partOf.toArray(new Base[this.partOf.size()]); // Reference
1475        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<MediaStatus>
1476        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
1477        case -622722335: /*modality*/ return this.modality == null ? new Base[0] : new Base[] {this.modality}; // CodeableConcept
1478        case 3619493: /*view*/ return this.view == null ? new Base[0] : new Base[] {this.view}; // CodeableConcept
1479        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
1480        case 1524132147: /*encounter*/ return this.encounter == null ? new Base[0] : new Base[] {this.encounter}; // Reference
1481        case 1028554472: /*created*/ return this.created == null ? new Base[0] : new Base[] {this.created}; // Type
1482        case -1179159893: /*issued*/ return this.issued == null ? new Base[0] : new Base[] {this.issued}; // InstantType
1483        case -500553564: /*operator*/ return this.operator == null ? new Base[0] : new Base[] {this.operator}; // Reference
1484        case 722137681: /*reasonCode*/ return this.reasonCode == null ? new Base[0] : this.reasonCode.toArray(new Base[this.reasonCode.size()]); // CodeableConcept
1485        case 1702620169: /*bodySite*/ return this.bodySite == null ? new Base[0] : new Base[] {this.bodySite}; // CodeableConcept
1486        case 780988929: /*deviceName*/ return this.deviceName == null ? new Base[0] : new Base[] {this.deviceName}; // StringType
1487        case -1335157162: /*device*/ return this.device == null ? new Base[0] : new Base[] {this.device}; // Reference
1488        case -1221029593: /*height*/ return this.height == null ? new Base[0] : new Base[] {this.height}; // PositiveIntType
1489        case 113126854: /*width*/ return this.width == null ? new Base[0] : new Base[] {this.width}; // PositiveIntType
1490        case -1266514778: /*frames*/ return this.frames == null ? new Base[0] : new Base[] {this.frames}; // PositiveIntType
1491        case -1992012396: /*duration*/ return this.duration == null ? new Base[0] : new Base[] {this.duration}; // DecimalType
1492        case 951530617: /*content*/ return this.content == null ? new Base[0] : new Base[] {this.content}; // Attachment
1493        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
1494        default: return super.getProperty(hash, name, checkValid);
1495        }
1496
1497      }
1498
1499      @Override
1500      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1501        switch (hash) {
1502        case -1618432855: // identifier
1503          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1504          return value;
1505        case -332612366: // basedOn
1506          this.getBasedOn().add(castToReference(value)); // Reference
1507          return value;
1508        case -995410646: // partOf
1509          this.getPartOf().add(castToReference(value)); // Reference
1510          return value;
1511        case -892481550: // status
1512          value = new MediaStatusEnumFactory().fromType(castToCode(value));
1513          this.status = (Enumeration) value; // Enumeration<MediaStatus>
1514          return value;
1515        case 3575610: // type
1516          this.type = castToCodeableConcept(value); // CodeableConcept
1517          return value;
1518        case -622722335: // modality
1519          this.modality = castToCodeableConcept(value); // CodeableConcept
1520          return value;
1521        case 3619493: // view
1522          this.view = castToCodeableConcept(value); // CodeableConcept
1523          return value;
1524        case -1867885268: // subject
1525          this.subject = castToReference(value); // Reference
1526          return value;
1527        case 1524132147: // encounter
1528          this.encounter = castToReference(value); // Reference
1529          return value;
1530        case 1028554472: // created
1531          this.created = castToType(value); // Type
1532          return value;
1533        case -1179159893: // issued
1534          this.issued = castToInstant(value); // InstantType
1535          return value;
1536        case -500553564: // operator
1537          this.operator = castToReference(value); // Reference
1538          return value;
1539        case 722137681: // reasonCode
1540          this.getReasonCode().add(castToCodeableConcept(value)); // CodeableConcept
1541          return value;
1542        case 1702620169: // bodySite
1543          this.bodySite = castToCodeableConcept(value); // CodeableConcept
1544          return value;
1545        case 780988929: // deviceName
1546          this.deviceName = castToString(value); // StringType
1547          return value;
1548        case -1335157162: // device
1549          this.device = castToReference(value); // Reference
1550          return value;
1551        case -1221029593: // height
1552          this.height = castToPositiveInt(value); // PositiveIntType
1553          return value;
1554        case 113126854: // width
1555          this.width = castToPositiveInt(value); // PositiveIntType
1556          return value;
1557        case -1266514778: // frames
1558          this.frames = castToPositiveInt(value); // PositiveIntType
1559          return value;
1560        case -1992012396: // duration
1561          this.duration = castToDecimal(value); // DecimalType
1562          return value;
1563        case 951530617: // content
1564          this.content = castToAttachment(value); // Attachment
1565          return value;
1566        case 3387378: // note
1567          this.getNote().add(castToAnnotation(value)); // Annotation
1568          return value;
1569        default: return super.setProperty(hash, name, value);
1570        }
1571
1572      }
1573
1574      @Override
1575      public Base setProperty(String name, Base value) throws FHIRException {
1576        if (name.equals("identifier")) {
1577          this.getIdentifier().add(castToIdentifier(value));
1578        } else if (name.equals("basedOn")) {
1579          this.getBasedOn().add(castToReference(value));
1580        } else if (name.equals("partOf")) {
1581          this.getPartOf().add(castToReference(value));
1582        } else if (name.equals("status")) {
1583          value = new MediaStatusEnumFactory().fromType(castToCode(value));
1584          this.status = (Enumeration) value; // Enumeration<MediaStatus>
1585        } else if (name.equals("type")) {
1586          this.type = castToCodeableConcept(value); // CodeableConcept
1587        } else if (name.equals("modality")) {
1588          this.modality = castToCodeableConcept(value); // CodeableConcept
1589        } else if (name.equals("view")) {
1590          this.view = castToCodeableConcept(value); // CodeableConcept
1591        } else if (name.equals("subject")) {
1592          this.subject = castToReference(value); // Reference
1593        } else if (name.equals("encounter")) {
1594          this.encounter = castToReference(value); // Reference
1595        } else if (name.equals("created[x]")) {
1596          this.created = castToType(value); // Type
1597        } else if (name.equals("issued")) {
1598          this.issued = castToInstant(value); // InstantType
1599        } else if (name.equals("operator")) {
1600          this.operator = castToReference(value); // Reference
1601        } else if (name.equals("reasonCode")) {
1602          this.getReasonCode().add(castToCodeableConcept(value));
1603        } else if (name.equals("bodySite")) {
1604          this.bodySite = castToCodeableConcept(value); // CodeableConcept
1605        } else if (name.equals("deviceName")) {
1606          this.deviceName = castToString(value); // StringType
1607        } else if (name.equals("device")) {
1608          this.device = castToReference(value); // Reference
1609        } else if (name.equals("height")) {
1610          this.height = castToPositiveInt(value); // PositiveIntType
1611        } else if (name.equals("width")) {
1612          this.width = castToPositiveInt(value); // PositiveIntType
1613        } else if (name.equals("frames")) {
1614          this.frames = castToPositiveInt(value); // PositiveIntType
1615        } else if (name.equals("duration")) {
1616          this.duration = castToDecimal(value); // DecimalType
1617        } else if (name.equals("content")) {
1618          this.content = castToAttachment(value); // Attachment
1619        } else if (name.equals("note")) {
1620          this.getNote().add(castToAnnotation(value));
1621        } else
1622          return super.setProperty(name, value);
1623        return value;
1624      }
1625
1626      @Override
1627      public Base makeProperty(int hash, String name) throws FHIRException {
1628        switch (hash) {
1629        case -1618432855:  return addIdentifier(); 
1630        case -332612366:  return addBasedOn(); 
1631        case -995410646:  return addPartOf(); 
1632        case -892481550:  return getStatusElement();
1633        case 3575610:  return getType(); 
1634        case -622722335:  return getModality(); 
1635        case 3619493:  return getView(); 
1636        case -1867885268:  return getSubject(); 
1637        case 1524132147:  return getEncounter(); 
1638        case 1369676952:  return getCreated(); 
1639        case 1028554472:  return getCreated(); 
1640        case -1179159893:  return getIssuedElement();
1641        case -500553564:  return getOperator(); 
1642        case 722137681:  return addReasonCode(); 
1643        case 1702620169:  return getBodySite(); 
1644        case 780988929:  return getDeviceNameElement();
1645        case -1335157162:  return getDevice(); 
1646        case -1221029593:  return getHeightElement();
1647        case 113126854:  return getWidthElement();
1648        case -1266514778:  return getFramesElement();
1649        case -1992012396:  return getDurationElement();
1650        case 951530617:  return getContent(); 
1651        case 3387378:  return addNote(); 
1652        default: return super.makeProperty(hash, name);
1653        }
1654
1655      }
1656
1657      @Override
1658      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1659        switch (hash) {
1660        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
1661        case -332612366: /*basedOn*/ return new String[] {"Reference"};
1662        case -995410646: /*partOf*/ return new String[] {"Reference"};
1663        case -892481550: /*status*/ return new String[] {"code"};
1664        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
1665        case -622722335: /*modality*/ return new String[] {"CodeableConcept"};
1666        case 3619493: /*view*/ return new String[] {"CodeableConcept"};
1667        case -1867885268: /*subject*/ return new String[] {"Reference"};
1668        case 1524132147: /*encounter*/ return new String[] {"Reference"};
1669        case 1028554472: /*created*/ return new String[] {"dateTime", "Period"};
1670        case -1179159893: /*issued*/ return new String[] {"instant"};
1671        case -500553564: /*operator*/ return new String[] {"Reference"};
1672        case 722137681: /*reasonCode*/ return new String[] {"CodeableConcept"};
1673        case 1702620169: /*bodySite*/ return new String[] {"CodeableConcept"};
1674        case 780988929: /*deviceName*/ return new String[] {"string"};
1675        case -1335157162: /*device*/ return new String[] {"Reference"};
1676        case -1221029593: /*height*/ return new String[] {"positiveInt"};
1677        case 113126854: /*width*/ return new String[] {"positiveInt"};
1678        case -1266514778: /*frames*/ return new String[] {"positiveInt"};
1679        case -1992012396: /*duration*/ return new String[] {"decimal"};
1680        case 951530617: /*content*/ return new String[] {"Attachment"};
1681        case 3387378: /*note*/ return new String[] {"Annotation"};
1682        default: return super.getTypesForProperty(hash, name);
1683        }
1684
1685      }
1686
1687      @Override
1688      public Base addChild(String name) throws FHIRException {
1689        if (name.equals("identifier")) {
1690          return addIdentifier();
1691        }
1692        else if (name.equals("basedOn")) {
1693          return addBasedOn();
1694        }
1695        else if (name.equals("partOf")) {
1696          return addPartOf();
1697        }
1698        else if (name.equals("status")) {
1699          throw new FHIRException("Cannot call addChild on a primitive type Media.status");
1700        }
1701        else if (name.equals("type")) {
1702          this.type = new CodeableConcept();
1703          return this.type;
1704        }
1705        else if (name.equals("modality")) {
1706          this.modality = new CodeableConcept();
1707          return this.modality;
1708        }
1709        else if (name.equals("view")) {
1710          this.view = new CodeableConcept();
1711          return this.view;
1712        }
1713        else if (name.equals("subject")) {
1714          this.subject = new Reference();
1715          return this.subject;
1716        }
1717        else if (name.equals("encounter")) {
1718          this.encounter = new Reference();
1719          return this.encounter;
1720        }
1721        else if (name.equals("createdDateTime")) {
1722          this.created = new DateTimeType();
1723          return this.created;
1724        }
1725        else if (name.equals("createdPeriod")) {
1726          this.created = new Period();
1727          return this.created;
1728        }
1729        else if (name.equals("issued")) {
1730          throw new FHIRException("Cannot call addChild on a primitive type Media.issued");
1731        }
1732        else if (name.equals("operator")) {
1733          this.operator = new Reference();
1734          return this.operator;
1735        }
1736        else if (name.equals("reasonCode")) {
1737          return addReasonCode();
1738        }
1739        else if (name.equals("bodySite")) {
1740          this.bodySite = new CodeableConcept();
1741          return this.bodySite;
1742        }
1743        else if (name.equals("deviceName")) {
1744          throw new FHIRException("Cannot call addChild on a primitive type Media.deviceName");
1745        }
1746        else if (name.equals("device")) {
1747          this.device = new Reference();
1748          return this.device;
1749        }
1750        else if (name.equals("height")) {
1751          throw new FHIRException("Cannot call addChild on a primitive type Media.height");
1752        }
1753        else if (name.equals("width")) {
1754          throw new FHIRException("Cannot call addChild on a primitive type Media.width");
1755        }
1756        else if (name.equals("frames")) {
1757          throw new FHIRException("Cannot call addChild on a primitive type Media.frames");
1758        }
1759        else if (name.equals("duration")) {
1760          throw new FHIRException("Cannot call addChild on a primitive type Media.duration");
1761        }
1762        else if (name.equals("content")) {
1763          this.content = new Attachment();
1764          return this.content;
1765        }
1766        else if (name.equals("note")) {
1767          return addNote();
1768        }
1769        else
1770          return super.addChild(name);
1771      }
1772
1773  public String fhirType() {
1774    return "Media";
1775
1776  }
1777
1778      public Media copy() {
1779        Media dst = new Media();
1780        copyValues(dst);
1781        if (identifier != null) {
1782          dst.identifier = new ArrayList<Identifier>();
1783          for (Identifier i : identifier)
1784            dst.identifier.add(i.copy());
1785        };
1786        if (basedOn != null) {
1787          dst.basedOn = new ArrayList<Reference>();
1788          for (Reference i : basedOn)
1789            dst.basedOn.add(i.copy());
1790        };
1791        if (partOf != null) {
1792          dst.partOf = new ArrayList<Reference>();
1793          for (Reference i : partOf)
1794            dst.partOf.add(i.copy());
1795        };
1796        dst.status = status == null ? null : status.copy();
1797        dst.type = type == null ? null : type.copy();
1798        dst.modality = modality == null ? null : modality.copy();
1799        dst.view = view == null ? null : view.copy();
1800        dst.subject = subject == null ? null : subject.copy();
1801        dst.encounter = encounter == null ? null : encounter.copy();
1802        dst.created = created == null ? null : created.copy();
1803        dst.issued = issued == null ? null : issued.copy();
1804        dst.operator = operator == null ? null : operator.copy();
1805        if (reasonCode != null) {
1806          dst.reasonCode = new ArrayList<CodeableConcept>();
1807          for (CodeableConcept i : reasonCode)
1808            dst.reasonCode.add(i.copy());
1809        };
1810        dst.bodySite = bodySite == null ? null : bodySite.copy();
1811        dst.deviceName = deviceName == null ? null : deviceName.copy();
1812        dst.device = device == null ? null : device.copy();
1813        dst.height = height == null ? null : height.copy();
1814        dst.width = width == null ? null : width.copy();
1815        dst.frames = frames == null ? null : frames.copy();
1816        dst.duration = duration == null ? null : duration.copy();
1817        dst.content = content == null ? null : content.copy();
1818        if (note != null) {
1819          dst.note = new ArrayList<Annotation>();
1820          for (Annotation i : note)
1821            dst.note.add(i.copy());
1822        };
1823        return dst;
1824      }
1825
1826      protected Media typedCopy() {
1827        return copy();
1828      }
1829
1830      @Override
1831      public boolean equalsDeep(Base other_) {
1832        if (!super.equalsDeep(other_))
1833          return false;
1834        if (!(other_ instanceof Media))
1835          return false;
1836        Media o = (Media) other_;
1837        return compareDeep(identifier, o.identifier, true) && compareDeep(basedOn, o.basedOn, true) && compareDeep(partOf, o.partOf, true)
1838           && compareDeep(status, o.status, true) && compareDeep(type, o.type, true) && compareDeep(modality, o.modality, true)
1839           && compareDeep(view, o.view, true) && compareDeep(subject, o.subject, true) && compareDeep(encounter, o.encounter, true)
1840           && compareDeep(created, o.created, true) && compareDeep(issued, o.issued, true) && compareDeep(operator, o.operator, true)
1841           && compareDeep(reasonCode, o.reasonCode, true) && compareDeep(bodySite, o.bodySite, true) && compareDeep(deviceName, o.deviceName, true)
1842           && compareDeep(device, o.device, true) && compareDeep(height, o.height, true) && compareDeep(width, o.width, true)
1843           && compareDeep(frames, o.frames, true) && compareDeep(duration, o.duration, true) && compareDeep(content, o.content, true)
1844           && compareDeep(note, o.note, true);
1845      }
1846
1847      @Override
1848      public boolean equalsShallow(Base other_) {
1849        if (!super.equalsShallow(other_))
1850          return false;
1851        if (!(other_ instanceof Media))
1852          return false;
1853        Media o = (Media) other_;
1854        return compareValues(status, o.status, true) && compareValues(issued, o.issued, true) && compareValues(deviceName, o.deviceName, true)
1855           && compareValues(height, o.height, true) && compareValues(width, o.width, true) && compareValues(frames, o.frames, true)
1856           && compareValues(duration, o.duration, true);
1857      }
1858
1859      public boolean isEmpty() {
1860        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, basedOn, partOf
1861          , status, type, modality, view, subject, encounter, created, issued, operator
1862          , reasonCode, bodySite, deviceName, device, height, width, frames, duration
1863          , content, note);
1864      }
1865
1866  @Override
1867  public ResourceType getResourceType() {
1868    return ResourceType.Media;
1869   }
1870
1871 /**
1872   * Search parameter: <b>identifier</b>
1873   * <p>
1874   * Description: <b>Identifier(s) for the image</b><br>
1875   * Type: <b>token</b><br>
1876   * Path: <b>Media.identifier</b><br>
1877   * </p>
1878   */
1879  @SearchParamDefinition(name="identifier", path="Media.identifier", description="Identifier(s) for the image", type="token" )
1880  public static final String SP_IDENTIFIER = "identifier";
1881 /**
1882   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
1883   * <p>
1884   * Description: <b>Identifier(s) for the image</b><br>
1885   * Type: <b>token</b><br>
1886   * Path: <b>Media.identifier</b><br>
1887   * </p>
1888   */
1889  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
1890
1891 /**
1892   * Search parameter: <b>modality</b>
1893   * <p>
1894   * Description: <b>The type of acquisition equipment/process</b><br>
1895   * Type: <b>token</b><br>
1896   * Path: <b>Media.modality</b><br>
1897   * </p>
1898   */
1899  @SearchParamDefinition(name="modality", path="Media.modality", description="The type of acquisition equipment/process", type="token" )
1900  public static final String SP_MODALITY = "modality";
1901 /**
1902   * <b>Fluent Client</b> search parameter constant for <b>modality</b>
1903   * <p>
1904   * Description: <b>The type of acquisition equipment/process</b><br>
1905   * Type: <b>token</b><br>
1906   * Path: <b>Media.modality</b><br>
1907   * </p>
1908   */
1909  public static final ca.uhn.fhir.rest.gclient.TokenClientParam MODALITY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_MODALITY);
1910
1911 /**
1912   * Search parameter: <b>subject</b>
1913   * <p>
1914   * Description: <b>Who/What this Media is a record of</b><br>
1915   * Type: <b>reference</b><br>
1916   * Path: <b>Media.subject</b><br>
1917   * </p>
1918   */
1919  @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, PractitionerRole.class, Specimen.class } )
1920  public static final String SP_SUBJECT = "subject";
1921 /**
1922   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
1923   * <p>
1924   * Description: <b>Who/What this Media is a record of</b><br>
1925   * Type: <b>reference</b><br>
1926   * Path: <b>Media.subject</b><br>
1927   * </p>
1928   */
1929  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
1930
1931/**
1932   * Constant for fluent queries to be used to add include statements. Specifies
1933   * the path value of "<b>Media:subject</b>".
1934   */
1935  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("Media:subject").toLocked();
1936
1937 /**
1938   * Search parameter: <b>created</b>
1939   * <p>
1940   * Description: <b>When Media was collected</b><br>
1941   * Type: <b>date</b><br>
1942   * Path: <b>Media.created[x]</b><br>
1943   * </p>
1944   */
1945  @SearchParamDefinition(name="created", path="Media.created", description="When Media was collected", type="date" )
1946  public static final String SP_CREATED = "created";
1947 /**
1948   * <b>Fluent Client</b> search parameter constant for <b>created</b>
1949   * <p>
1950   * Description: <b>When Media was collected</b><br>
1951   * Type: <b>date</b><br>
1952   * Path: <b>Media.created[x]</b><br>
1953   * </p>
1954   */
1955  public static final ca.uhn.fhir.rest.gclient.DateClientParam CREATED = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_CREATED);
1956
1957 /**
1958   * Search parameter: <b>encounter</b>
1959   * <p>
1960   * Description: <b>Encounter associated with media</b><br>
1961   * Type: <b>reference</b><br>
1962   * Path: <b>Media.encounter</b><br>
1963   * </p>
1964   */
1965  @SearchParamDefinition(name="encounter", path="Media.encounter", description="Encounter associated with media", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Encounter") }, target={Encounter.class } )
1966  public static final String SP_ENCOUNTER = "encounter";
1967 /**
1968   * <b>Fluent Client</b> search parameter constant for <b>encounter</b>
1969   * <p>
1970   * Description: <b>Encounter associated with media</b><br>
1971   * Type: <b>reference</b><br>
1972   * Path: <b>Media.encounter</b><br>
1973   * </p>
1974   */
1975  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENCOUNTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENCOUNTER);
1976
1977/**
1978   * Constant for fluent queries to be used to add include statements. Specifies
1979   * the path value of "<b>Media:encounter</b>".
1980   */
1981  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENCOUNTER = new ca.uhn.fhir.model.api.Include("Media:encounter").toLocked();
1982
1983 /**
1984   * Search parameter: <b>type</b>
1985   * <p>
1986   * Description: <b>Classification of media as image, video, or audio</b><br>
1987   * Type: <b>token</b><br>
1988   * Path: <b>Media.type</b><br>
1989   * </p>
1990   */
1991  @SearchParamDefinition(name="type", path="Media.type", description="Classification of media as image, video, or audio", type="token" )
1992  public static final String SP_TYPE = "type";
1993 /**
1994   * <b>Fluent Client</b> search parameter constant for <b>type</b>
1995   * <p>
1996   * Description: <b>Classification of media as image, video, or audio</b><br>
1997   * Type: <b>token</b><br>
1998   * Path: <b>Media.type</b><br>
1999   * </p>
2000   */
2001  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_TYPE);
2002
2003 /**
2004   * Search parameter: <b>operator</b>
2005   * <p>
2006   * Description: <b>The person who generated the image</b><br>
2007   * Type: <b>reference</b><br>
2008   * Path: <b>Media.operator</b><br>
2009   * </p>
2010   */
2011  @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 } )
2012  public static final String SP_OPERATOR = "operator";
2013 /**
2014   * <b>Fluent Client</b> search parameter constant for <b>operator</b>
2015   * <p>
2016   * Description: <b>The person who generated the image</b><br>
2017   * Type: <b>reference</b><br>
2018   * Path: <b>Media.operator</b><br>
2019   * </p>
2020   */
2021  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam OPERATOR = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_OPERATOR);
2022
2023/**
2024   * Constant for fluent queries to be used to add include statements. Specifies
2025   * the path value of "<b>Media:operator</b>".
2026   */
2027  public static final ca.uhn.fhir.model.api.Include INCLUDE_OPERATOR = new ca.uhn.fhir.model.api.Include("Media:operator").toLocked();
2028
2029 /**
2030   * Search parameter: <b>view</b>
2031   * <p>
2032   * Description: <b>Imaging view, e.g. Lateral or Antero-posterior</b><br>
2033   * Type: <b>token</b><br>
2034   * Path: <b>Media.view</b><br>
2035   * </p>
2036   */
2037  @SearchParamDefinition(name="view", path="Media.view", description="Imaging view, e.g. Lateral or Antero-posterior", type="token" )
2038  public static final String SP_VIEW = "view";
2039 /**
2040   * <b>Fluent Client</b> search parameter constant for <b>view</b>
2041   * <p>
2042   * Description: <b>Imaging view, e.g. Lateral or Antero-posterior</b><br>
2043   * Type: <b>token</b><br>
2044   * Path: <b>Media.view</b><br>
2045   * </p>
2046   */
2047  public static final ca.uhn.fhir.rest.gclient.TokenClientParam VIEW = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_VIEW);
2048
2049 /**
2050   * Search parameter: <b>site</b>
2051   * <p>
2052   * Description: <b>Observed body part</b><br>
2053   * Type: <b>token</b><br>
2054   * Path: <b>Media.bodySite</b><br>
2055   * </p>
2056   */
2057  @SearchParamDefinition(name="site", path="Media.bodySite", description="Observed body part", type="token" )
2058  public static final String SP_SITE = "site";
2059 /**
2060   * <b>Fluent Client</b> search parameter constant for <b>site</b>
2061   * <p>
2062   * Description: <b>Observed body part</b><br>
2063   * Type: <b>token</b><br>
2064   * Path: <b>Media.bodySite</b><br>
2065   * </p>
2066   */
2067  public static final ca.uhn.fhir.rest.gclient.TokenClientParam SITE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_SITE);
2068
2069 /**
2070   * Search parameter: <b>based-on</b>
2071   * <p>
2072   * Description: <b>Procedure that caused this media to be created</b><br>
2073   * Type: <b>reference</b><br>
2074   * Path: <b>Media.basedOn</b><br>
2075   * </p>
2076   */
2077  @SearchParamDefinition(name="based-on", path="Media.basedOn", description="Procedure that caused this media to be created", type="reference", target={CarePlan.class, ServiceRequest.class } )
2078  public static final String SP_BASED_ON = "based-on";
2079 /**
2080   * <b>Fluent Client</b> search parameter constant for <b>based-on</b>
2081   * <p>
2082   * Description: <b>Procedure that caused this media to be created</b><br>
2083   * Type: <b>reference</b><br>
2084   * Path: <b>Media.basedOn</b><br>
2085   * </p>
2086   */
2087  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam BASED_ON = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_BASED_ON);
2088
2089/**
2090   * Constant for fluent queries to be used to add include statements. Specifies
2091   * the path value of "<b>Media:based-on</b>".
2092   */
2093  public static final ca.uhn.fhir.model.api.Include INCLUDE_BASED_ON = new ca.uhn.fhir.model.api.Include("Media:based-on").toLocked();
2094
2095 /**
2096   * Search parameter: <b>patient</b>
2097   * <p>
2098   * Description: <b>Who/What this Media is a record of</b><br>
2099   * Type: <b>reference</b><br>
2100   * Path: <b>Media.subject</b><br>
2101   * </p>
2102   */
2103  @SearchParamDefinition(name="patient", path="Media.subject.where(resolve() is Patient)", description="Who/What this Media is a record of", type="reference", target={Patient.class } )
2104  public static final String SP_PATIENT = "patient";
2105 /**
2106   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
2107   * <p>
2108   * Description: <b>Who/What this Media is a record of</b><br>
2109   * Type: <b>reference</b><br>
2110   * Path: <b>Media.subject</b><br>
2111   * </p>
2112   */
2113  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
2114
2115/**
2116   * Constant for fluent queries to be used to add include statements. Specifies
2117   * the path value of "<b>Media:patient</b>".
2118   */
2119  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("Media:patient").toLocked();
2120
2121 /**
2122   * Search parameter: <b>device</b>
2123   * <p>
2124   * Description: <b>Observing Device</b><br>
2125   * Type: <b>reference</b><br>
2126   * Path: <b>Media.device</b><br>
2127   * </p>
2128   */
2129  @SearchParamDefinition(name="device", path="Media.device", description="Observing Device", type="reference", target={Device.class, DeviceMetric.class } )
2130  public static final String SP_DEVICE = "device";
2131 /**
2132   * <b>Fluent Client</b> search parameter constant for <b>device</b>
2133   * <p>
2134   * Description: <b>Observing Device</b><br>
2135   * Type: <b>reference</b><br>
2136   * Path: <b>Media.device</b><br>
2137   * </p>
2138   */
2139  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam DEVICE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_DEVICE);
2140
2141/**
2142   * Constant for fluent queries to be used to add include statements. Specifies
2143   * the path value of "<b>Media:device</b>".
2144   */
2145  public static final ca.uhn.fhir.model.api.Include INCLUDE_DEVICE = new ca.uhn.fhir.model.api.Include("Media:device").toLocked();
2146
2147 /**
2148   * Search parameter: <b>status</b>
2149   * <p>
2150   * Description: <b>preparation | in-progress | not-done | suspended | aborted | completed | entered-in-error | unknown</b><br>
2151   * Type: <b>token</b><br>
2152   * Path: <b>Media.status</b><br>
2153   * </p>
2154   */
2155  @SearchParamDefinition(name="status", path="Media.status", description="preparation | in-progress | not-done | suspended | aborted | completed | entered-in-error | unknown", type="token" )
2156  public static final String SP_STATUS = "status";
2157 /**
2158   * <b>Fluent Client</b> search parameter constant for <b>status</b>
2159   * <p>
2160   * Description: <b>preparation | in-progress | not-done | suspended | aborted | completed | entered-in-error | unknown</b><br>
2161   * Type: <b>token</b><br>
2162   * Path: <b>Media.status</b><br>
2163   * </p>
2164   */
2165  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
2166
2167
2168}
2169