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