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