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